{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "inventory-reorder-forecast",
  "title": "Inventory Reorder Forecast",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-react/blocks/inventory-reorder-forecast/InventoryReorderForecast.tsx",
      "content": "'use client'\n\nimport * as React from 'react'\nimport {\n  AlertTriangle,\n  ArrowUpRight,\n  Boxes,\n  Building2,\n  CheckCircle2,\n  Clock,\n  DollarSign,\n  Download,\n  FileCheck,\n  PackageCheck,\n  PackagePlus,\n  Search,\n  TrendingUp,\n  X,\n  Zap,\n} from 'lucide-react'\nimport { cn } from '@/lib/utils'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'\nimport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n} from '@/components/ui/dialog'\nimport { Input } from '@/components/ui/input'\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'\nimport { Separator } from '@/components/ui/separator'\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'\n\nexport type StockHealthStatus = 'critical' | 'warning' | 'healthy'\n\nexport interface ReorderItem {\n  id: string\n  sku: string\n  name: string\n  category: string\n  supplier: string\n  onHandStock: number\n  safetyStockThreshold: number\n  dailySalesVelocity: number\n  velocityTrend: number\n  daysOfInventoryRemaining: number\n  supplierLeadTimeDays: number\n  recommendedReorderQty: number\n  unitCost: number\n  estimatedPoCost: number\n  status: StockHealthStatus\n}\n\nconst reorderItems: ReorderItem[] = [\n  {\n    id: 'sku-1',\n    sku: 'SKU-RN-105-BLK',\n    name: 'Aero Minimalist Runner 10.5',\n    category: 'Footwear',\n    supplier: 'Apex Footwear Ltd',\n    onHandStock: 42,\n    safetyStockThreshold: 80,\n    dailySalesVelocity: 12.4,\n    velocityTrend: 14.2,\n    daysOfInventoryRemaining: 3.4,\n    supplierLeadTimeDays: 14,\n    recommendedReorderQty: 250,\n    unitCost: 50.0,\n    estimatedPoCost: 12500.0,\n    status: 'critical',\n  },\n  {\n    id: 'sku-2',\n    sku: 'SKU-PK-082-SLT',\n    name: 'Technical Shell Parka L',\n    category: 'Outerwear',\n    supplier: 'Nordic Outerwear Co',\n    onHandStock: 18,\n    safetyStockThreshold: 50,\n    dailySalesVelocity: 4.5,\n    velocityTrend: 8.5,\n    daysOfInventoryRemaining: 4.0,\n    supplierLeadTimeDays: 21,\n    recommendedReorderQty: 120,\n    unitCost: 145.0,\n    estimatedPoCost: 17400.0,\n    status: 'critical',\n  },\n  {\n    id: 'sku-3',\n    sku: 'SKU-HD-419-PRO',\n    name: 'Pro Studio Headphones',\n    category: 'Electronics',\n    supplier: 'Sonic Acoustics Inc',\n    onHandStock: 65,\n    safetyStockThreshold: 85,\n    dailySalesVelocity: 8.2,\n    velocityTrend: 5.0,\n    daysOfInventoryRemaining: 7.9,\n    supplierLeadTimeDays: 10,\n    recommendedReorderQty: 100,\n    unitCost: 110.0,\n    estimatedPoCost: 11000.0,\n    status: 'warning',\n  },\n  {\n    id: 'sku-4',\n    sku: 'SKU-CD-904-BRN',\n    name: 'Leather Cardholder',\n    category: 'Accessories',\n    supplier: 'Tuscan Goods Ltd',\n    onHandStock: 88,\n    safetyStockThreshold: 100,\n    dailySalesVelocity: 6.0,\n    velocityTrend: 2.1,\n    daysOfInventoryRemaining: 14.7,\n    supplierLeadTimeDays: 12,\n    recommendedReorderQty: 150,\n    unitCost: 32.0,\n    estimatedPoCost: 4800.0,\n    status: 'warning',\n  },\n  {\n    id: 'sku-5',\n    sku: 'SKU-WC-331-WHT',\n    name: 'Wireless Charger Mat',\n    category: 'Electronics',\n    supplier: 'Volt Innovations',\n    onHandStock: 340,\n    safetyStockThreshold: 120,\n    dailySalesVelocity: 8.1,\n    velocityTrend: -1.4,\n    daysOfInventoryRemaining: 42.0,\n    supplierLeadTimeDays: 7,\n    recommendedReorderQty: 100,\n    unitCost: 25.5,\n    estimatedPoCost: 2550.0,\n    status: 'healthy',\n  },\n]\n\nexport function InventoryReorderForecast({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {\n  const [facility, setFacility] = React.useState('global-fulfillment')\n  const [searchQuery, setSearchQuery] = React.useState('')\n  const [categoryFilter, setCategoryFilter] = React.useState('all')\n  const [statusFilter, setStatusFilter] = React.useState('all')\n\n  const [createPoDialogOpen, setCreatePoDialogOpen] = React.useState(false)\n  const [bulkPoDialogOpen, setBulkPoDialogOpen] = React.useState(false)\n  const [selectedSkuItem, setSelectedSkuItem] = React.useState<ReorderItem | null>(null)\n  const [customReorderQty, setCustomReorderQty] = React.useState<number>(250)\n  const [selectedShippingMethod, setSelectedShippingMethod] = React.useState('standard-freight')\n\n  const [actionFeedback, setActionFeedback] = React.useState<string | null>(null)\n\n  const filteredItems = React.useMemo(() => {\n    return reorderItems.filter((item) => {\n      const q = searchQuery.trim().toLowerCase()\n      const matchesSearch =\n        !q ||\n        item.name.toLowerCase().includes(q) ||\n        item.sku.toLowerCase().includes(q) ||\n        item.category.toLowerCase().includes(q) ||\n        item.supplier.toLowerCase().includes(q)\n\n      const matchesCategory = categoryFilter === 'all' || item.category === categoryFilter\n      const matchesStatus = statusFilter === 'all' || item.status === statusFilter\n\n      return matchesSearch && matchesCategory && matchesStatus\n    })\n  }, [searchQuery, categoryFilter, statusFilter])\n\n  const criticalAndWarningItems = React.useMemo(() => {\n    return reorderItems.filter((item) => item.status === 'critical' || item.status === 'warning')\n  }, [])\n\n  const dialogCalculatedCost = React.useMemo(() => {\n    if (!selectedSkuItem) return 0\n    return customReorderQty * selectedSkuItem.unitCost\n  }, [selectedSkuItem, customReorderQty])\n\n  const openCreatePoDialog = (item: ReorderItem) => {\n    setSelectedSkuItem(item)\n    setCustomReorderQty(item.recommendedReorderQty)\n    setSelectedShippingMethod('standard-freight')\n    setCreatePoDialogOpen(true)\n  }\n\n  const handleConfirmCreatePo = () => {\n    if (!selectedSkuItem) return\n    const poNumber = `PO-2026-${Math.floor(1000 + Math.random() * 9000)}`\n    setActionFeedback(\n      `Draft ${poNumber} created for ${selectedSkuItem.sku} (${customReorderQty} units · $${dialogCalculatedCost.toLocaleString('en-US', { minimumFractionDigits: 2 })}) routed to ${selectedSkuItem.supplier}.`,\n    )\n    setCreatePoDialogOpen(false)\n    setTimeout(() => {\n      setActionFeedback(null)\n    }, 4500)\n  }\n\n  const openBulkPoDialog = () => {\n    setBulkPoDialogOpen(true)\n  }\n\n  const handleConfirmBulkPos = () => {\n    setActionFeedback(\n      `Successfully generated 4 Purchase Orders (Total $48,250.00) for Global Fulfillment Center replenishment.`,\n    )\n    setBulkPoDialogOpen(false)\n    setTimeout(() => {\n      setActionFeedback(null)\n    }, 5000)\n  }\n\n  const handleExportPlan = () => {\n    setActionFeedback(`Replenishment forecast plan for ${reorderItems.length} SKUs exported successfully as CSV.`)\n    setTimeout(() => {\n      setActionFeedback(null)\n    }, 4000)\n  }\n\n  return (\n    <div data-slot=\"inventory-reorder-forecast\" className={cn('w-full space-y-6', className)} {...props}>\n      {/* Header Section */}\n      <div className=\"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between\">\n        <div className=\"space-y-1\">\n          <div className=\"flex flex-wrap items-center gap-2.5\">\n            <div className=\"bg-primary/10 text-primary flex size-8 items-center justify-center rounded-lg\">\n              <Boxes className=\"size-4.5\" />\n            </div>\n            <h1 className=\"text-foreground text-xl font-bold tracking-tight sm:text-2xl\">\n              Inventory Demand & Reorder Forecast\n            </h1>\n            <Badge variant=\"warning\" className=\"border-warning/30 bg-warning/10 text-warning gap-1.5\">\n              <span className=\"bg-warning size-1.5 animate-pulse rounded-full\" />4 SKUs Need Reorder\n            </Badge>\n          </div>\n          <p className=\"text-muted-foreground text-xs sm:text-sm\">\n            Multi-channel supply chain replenishment planner with lead-time demand forecasting and automated purchase\n            order generation.\n          </p>\n        </div>\n\n        <div className=\"flex flex-wrap items-center gap-2.5\">\n          {/* Facility Selector */}\n          <Select value={facility} onValueChange={setFacility}>\n            <SelectTrigger className=\"w-full sm:w-[280px]\">\n              <Building2 className=\"text-muted-foreground size-4 shrink-0\" />\n              <SelectValue placeholder=\"Select fulfillment facility\" />\n            </SelectTrigger>\n            <SelectContent>\n              <SelectItem value=\"global-fulfillment\">Global Fulfillment Center</SelectItem>\n              <SelectItem value=\"na-west-hub\">North America West Distribution Hub</SelectItem>\n              <SelectItem value=\"eu-central-dc\">European Central Logistics Depot</SelectItem>\n              <SelectItem value=\"apac-regional\">APAC Regional Hub · Singapore</SelectItem>\n            </SelectContent>\n          </Select>\n\n          {/* Export Plan Button */}\n          <Button\n            aria-label=\"Download attachment\"\n            variant=\"outline\"\n            className=\"gap-1.5 shadow-xs\"\n            onClick={handleExportPlan}\n          >\n            <Download className=\"size-4\" />\n            Export Replenishment Plan\n          </Button>\n\n          {/* Primary Action: Generate Bulk POs */}\n          <Button className=\"gap-1.5 shadow-xs\" onClick={openBulkPoDialog}>\n            <PackagePlus className=\"size-4\" />\n            Generate Bulk POs\n          </Button>\n        </div>\n      </div>\n\n      {/* Notification / Action Feedback Banner */}\n      {actionFeedback && (\n        <div className=\"border-primary/20 bg-primary/5 text-foreground flex items-center justify-between rounded-lg border px-4 py-3 text-sm shadow-xs transition-colors\">\n          <div className=\"flex items-center gap-2.5\">\n            <CheckCircle2 className=\"text-success size-4 shrink-0\" />\n            <span className=\"text-xs font-medium sm:text-sm\">{actionFeedback}</span>\n          </div>\n          <Button\n            variant=\"ghost\"\n            size=\"xs\"\n            className=\"h-6 w-6 p-0\"\n            aria-label=\"Dismiss notification\"\n            onClick={() => setActionFeedback(null)}\n          >\n            <X className=\"size-3.5\" />\n          </Button>\n        </div>\n      )}\n\n      {/* 4 Forecasting KPI Cards */}\n      <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n        {/* Metric 1: Critical Reorder SKUs */}\n        <Card className=\"shadow-xs\">\n          <CardHeader className=\"flex flex-row items-center justify-between space-y-0 pb-2\">\n            <CardTitle className=\"text-muted-foreground text-xs font-medium tracking-wider uppercase\">\n              Critical Reorder SKUs\n            </CardTitle>\n            <div className=\"bg-warning/10 text-warning flex size-8 items-center justify-center rounded-md\">\n              <AlertTriangle className=\"size-4\" />\n            </div>\n          </CardHeader>\n          <CardContent className=\"space-y-1\">\n            <div className=\"flex items-baseline gap-2\">\n              <div className=\"text-warning text-warning text-2xl font-bold tracking-tight tabular-nums\">\n                4 <span className=\"text-muted-foreground text-sm font-normal\">SKUs</span>\n              </div>\n              <Badge variant=\"warning\" className=\"text-xs font-normal\">\n                Action Required\n              </Badge>\n            </div>\n            <p className=\"text-muted-foreground pt-1 text-xs\">Below safety threshold · 2 in urgent stockout zone</p>\n          </CardContent>\n        </Card>\n\n        {/* Metric 2: Estimated Stockout Days */}\n        <Card className=\"shadow-xs\">\n          <CardHeader className=\"flex flex-row items-center justify-between space-y-0 pb-2\">\n            <CardTitle className=\"text-muted-foreground text-xs font-medium tracking-wider uppercase\">\n              Estimated Stockout Days\n            </CardTitle>\n            <div className=\"bg-destructive/10 text-destructive flex size-8 items-center justify-center rounded-md\">\n              <Clock className=\"size-4\" />\n            </div>\n          </CardHeader>\n          <CardContent className=\"space-y-1\">\n            <div className=\"flex items-baseline gap-2\">\n              <div className=\"text-foreground text-2xl font-bold tracking-tight tabular-nums\">\n                6.4 <span className=\"text-muted-foreground text-sm font-normal\">Days</span>\n              </div>\n              <Badge variant=\"destructive\" className=\"text-xs font-normal\">\n                Critical Risk\n              </Badge>\n            </div>\n            <p className=\"text-muted-foreground pt-1 text-xs\">6.4 Days until stockout on top SKU · Urgent PO needed</p>\n          </CardContent>\n        </Card>\n\n        {/* Metric 3: Suggested Purchase Order Value */}\n        <Card className=\"shadow-xs\">\n          <CardHeader className=\"flex flex-row items-center justify-between space-y-0 pb-2\">\n            <CardTitle className=\"text-muted-foreground text-xs font-medium tracking-wider uppercase\">\n              Suggested PO Value\n            </CardTitle>\n            <div className=\"bg-primary/10 text-primary flex size-8 items-center justify-center rounded-md\">\n              <DollarSign className=\"size-4\" />\n            </div>\n          </CardHeader>\n          <CardContent className=\"space-y-1\">\n            <div className=\"text-foreground text-2xl font-bold tracking-tight tabular-nums\">$48,250.00</div>\n            <p className=\"text-muted-foreground flex items-center gap-1.5 pt-1 text-xs\">\n              <span className=\"text-success flex items-center font-medium\">\n                <Zap className=\"mr-1 inline size-3\" />4 replenishment POs\n              </span>\n              <span>· 620 units total</span>\n            </p>\n          </CardContent>\n        </Card>\n\n        {/* Metric 4: Inventory Turnover Rate */}\n        <Card className=\"shadow-xs\">\n          <CardHeader className=\"flex flex-row items-center justify-between space-y-0 pb-2\">\n            <CardTitle className=\"text-muted-foreground text-xs font-medium tracking-wider uppercase\">\n              Inventory Turnover Rate\n            </CardTitle>\n            <div className=\"bg-success/10 text-success flex size-8 items-center justify-center rounded-md\">\n              <TrendingUp className=\"size-4\" />\n            </div>\n          </CardHeader>\n          <CardContent className=\"space-y-1\">\n            <div className=\"text-foreground text-2xl font-bold tracking-tight tabular-nums\">\n              8.4x <span className=\"text-muted-foreground text-sm font-normal\">/ year</span>\n            </div>\n            <p className=\"text-muted-foreground flex items-center gap-1.5 pt-1 text-xs\">\n              <span className=\"text-success flex items-center font-medium\">\n                <ArrowUpRight className=\"mr-0.5 inline size-3\" />\n                +1.2x\n              </span>\n              <span>vs industry benchmark (7.2x)</span>\n            </p>\n          </CardContent>\n        </Card>\n      </div>\n\n      {/* Reorder Demand Forecast Table Toolbar & Card */}\n      <Card className=\"shadow-xs\">\n        <CardHeader className=\"border-border border-b pb-3\">\n          <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n            <div className=\"flex flex-1 flex-wrap items-center gap-2\">\n              <div className=\"relative w-full max-w-sm\">\n                <Search className=\"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n                <Input\n                  value={searchQuery}\n                  onChange={(e) => setSearchQuery(e.target.value)}\n                  placeholder=\"Search SKU, product name, supplier...\"\n                  className=\"h-9 pl-9 text-xs sm:text-sm\"\n                />\n              </div>\n\n              {/* Category Filter */}\n              <Select value={categoryFilter} onValueChange={setCategoryFilter}>\n                <SelectTrigger className=\"h-9 w-[160px] text-xs\">\n                  <SelectValue placeholder=\"All Categories\" />\n                </SelectTrigger>\n                <SelectContent>\n                  <SelectItem value=\"all\">All Categories</SelectItem>\n                  <SelectItem value=\"Footwear\">Footwear</SelectItem>\n                  <SelectItem value=\"Outerwear\">Outerwear</SelectItem>\n                  <SelectItem value=\"Electronics\">Electronics</SelectItem>\n                  <SelectItem value=\"Accessories\">Accessories</SelectItem>\n                </SelectContent>\n              </Select>\n\n              {/* Status Filter */}\n              <Select value={statusFilter} onValueChange={setStatusFilter}>\n                <SelectTrigger className=\"h-9 w-[170px] text-xs\">\n                  <SelectValue placeholder=\"All Health Status\" />\n                </SelectTrigger>\n                <SelectContent>\n                  <SelectItem value=\"all\">All Stock Status</SelectItem>\n                  <SelectItem value=\"critical\">Critical Stockout (&lt;7d)</SelectItem>\n                  <SelectItem value=\"warning\">Reorder Warning (7-15d)</SelectItem>\n                  <SelectItem value=\"healthy\">Healthy Stock (&gt;30d)</SelectItem>\n                </SelectContent>\n              </Select>\n            </div>\n\n            <div className=\"text-muted-foreground flex items-center gap-2 text-xs\">\n              <span>\n                Showing <strong className=\"text-foreground tabular-nums\">{filteredItems.length}</strong> of{' '}\n                {reorderItems.length} forecast SKUs\n              </span>\n            </div>\n          </div>\n        </CardHeader>\n\n        <CardContent className=\"p-0\">\n          {/* Demand Table */}\n          <div className=\"overflow-x-auto\">\n            <Table>\n              <TableHeader>\n                <TableRow className=\"hover:bg-transparent\">\n                  <TableHead className=\"w-[240px] text-xs font-semibold\">SKU Identifier & Product</TableHead>\n                  <TableHead className=\"text-right text-xs font-semibold\">Current On-Hand</TableHead>\n                  <TableHead className=\"text-right text-xs font-semibold\">Sales Velocity</TableHead>\n                  <TableHead className=\"min-w-[150px] text-xs font-semibold\">Days Remaining</TableHead>\n                  <TableHead className=\"text-right text-xs font-semibold\">Supplier Lead Time</TableHead>\n                  <TableHead className=\"text-right text-xs font-semibold\">Recommended Qty</TableHead>\n                  <TableHead className=\"text-right text-xs font-semibold\">Est. PO Cost</TableHead>\n                  <TableHead className=\"w-[120px] text-right text-xs font-semibold\">Quick Action</TableHead>\n                </TableRow>\n              </TableHeader>\n              <TableBody>\n                {filteredItems.map((item) => (\n                  <TableRow key={item.id} className=\"hover:bg-muted/40 transition-colors\">\n                    {/* SKU Identifier & Product Name */}\n                    <TableCell className=\"py-3\">\n                      <div className=\"space-y-1\">\n                        <div className=\"text-foreground font-mono text-xs font-semibold\">{item.sku}</div>\n                        <div className=\"text-foreground text-sm font-medium\">{item.name}</div>\n                        <div className=\"text-muted-foreground flex items-center gap-1.5 text-xs\">\n                          <span>{item.category}</span>\n                          <span>·</span>\n                          <span>{item.supplier}</span>\n                        </div>\n                      </div>\n                    </TableCell>\n\n                    {/* Current On-Hand Stock */}\n                    <TableCell className=\"py-3 text-right\">\n                      <div className=\"text-foreground text-sm font-semibold tabular-nums\">\n                        {item.onHandStock.toLocaleString()}{' '}\n                        <span className=\"text-muted-foreground text-xs font-normal\">units</span>\n                      </div>\n                      <div className=\"text-muted-foreground text-xs tabular-nums\">\n                        Safety: {item.safetyStockThreshold} units\n                      </div>\n                    </TableCell>\n\n                    {/* Average Daily Sales Velocity */}\n                    <TableCell className=\"py-3 text-right\">\n                      <div className=\"text-foreground text-sm font-semibold tabular-nums\">\n                        {item.dailySalesVelocity.toFixed(1)}{' '}\n                        <span className=\"text-muted-foreground text-xs font-normal\">units/day</span>\n                      </div>\n                      <div\n                        className={cn(\n                          'text-xs font-medium tabular-nums',\n                          item.velocityTrend >= 0 ? 'text-success' : 'text-destructive',\n                        )}\n                      >\n                        {item.velocityTrend >= 0 ? '+' : ''}\n                        {item.velocityTrend.toFixed(1)}% 7d\n                      </div>\n                    </TableCell>\n\n                    {/* Days of Inventory Remaining Badge */}\n                    <TableCell className=\"py-3\">\n                      <div className=\"space-y-1.5\">\n                        {item.status === 'critical' ? (\n                          <Badge variant=\"destructive\" className=\"gap-1 font-mono text-xs font-semibold\">\n                            <AlertTriangle className=\"size-3\" />\n                            {item.daysOfInventoryRemaining.toFixed(1)} Days\n                          </Badge>\n                        ) : item.status === 'warning' ? (\n                          <Badge variant=\"warning\" className=\"text-warning gap-1 font-mono text-xs font-semibold\">\n                            <Clock className=\"size-3\" />\n                            {item.daysOfInventoryRemaining.toFixed(1)} Days\n                          </Badge>\n                        ) : (\n                          <Badge variant=\"success\" className=\"gap-1 font-mono text-xs font-semibold\">\n                            <CheckCircle2 className=\"size-3\" />\n                            {item.daysOfInventoryRemaining.toFixed(1)} Days\n                          </Badge>\n                        )}\n                        <div className=\"text-muted-foreground text-xs\">\n                          {item.status === 'critical'\n                            ? 'Stockout before delivery'\n                            : item.status === 'warning'\n                              ? 'Reorder buffer thin'\n                              : 'Healthy inventory level'}\n                        </div>\n                      </div>\n                    </TableCell>\n\n                    {/* Supplier Lead Time */}\n                    <TableCell className=\"py-3 text-right\">\n                      <div className=\"text-foreground font-mono text-sm font-semibold tabular-nums\">\n                        {item.supplierLeadTimeDays}{' '}\n                        <span className=\"text-muted-foreground text-xs font-normal\">Days</span>\n                      </div>\n                      <div className=\"text-muted-foreground text-xs\">Mfg & Freight</div>\n                    </TableCell>\n\n                    {/* Recommended Reorder Qty */}\n                    <TableCell className=\"py-3 text-right\">\n                      <div className=\"text-foreground text-sm font-bold tabular-nums\">\n                        {item.recommendedReorderQty}{' '}\n                        <span className=\"text-muted-foreground text-xs font-normal\">units</span>\n                      </div>\n                      <div className=\"text-muted-foreground text-xs\">Optimal batch</div>\n                    </TableCell>\n\n                    {/* Estimated PO Cost */}\n                    <TableCell className=\"py-3 text-right\">\n                      <div className=\"text-foreground font-mono text-sm font-bold tabular-nums\">\n                        ${item.estimatedPoCost.toLocaleString('en-US', { minimumFractionDigits: 2 })}\n                      </div>\n                      <div className=\"text-muted-foreground text-xs tabular-nums\">\n                        ${item.unitCost.toFixed(2)} / unit\n                      </div>\n                    </TableCell>\n\n                    {/* Quick Action Button */}\n                    <TableCell className=\"py-3 text-right\">\n                      <div className=\"flex items-center justify-end gap-1.5\">\n                        <Button\n                          size=\"sm\"\n                          className=\"gap-1 shadow-xs\"\n                          variant={item.status === 'critical' ? 'default' : 'outline'}\n                          onClick={() => openCreatePoDialog(item)}\n                        >\n                          <PackageCheck className=\"size-3.5\" />\n                          Create PO\n                        </Button>\n                      </div>\n                    </TableCell>\n                  </TableRow>\n                ))}\n\n                {filteredItems.length === 0 && (\n                  <TableRow>\n                    <TableCell colSpan={8} className=\"text-muted-foreground h-32 text-center text-sm\">\n                      No inventory forecast items match your current filter criteria.\n                    </TableCell>\n                  </TableRow>\n                )}\n              </TableBody>\n            </Table>\n          </div>\n        </CardContent>\n      </Card>\n\n      {/* Create Purchase Order Draft Dialog */}\n      <Dialog open={createPoDialogOpen} onOpenChange={setCreatePoDialogOpen}>\n        <DialogContent className=\"sm:max-w-lg\">\n          <DialogHeader>\n            <div className=\"flex items-center gap-2\">\n              <div className=\"bg-primary/10 text-primary flex size-8 items-center justify-center rounded-md\">\n                <PackageCheck className=\"size-4\" />\n              </div>\n              <DialogTitle className=\"text-lg font-bold\">Draft Purchase Order</DialogTitle>\n            </div>\n            <DialogDescription className=\"text-muted-foreground text-xs\">\n              Review demand velocity, set purchase order quantity, and dispatch replenishment order to supplier.\n            </DialogDescription>\n          </DialogHeader>\n\n          {selectedSkuItem && (\n            <div className=\"space-y-4 py-2\">\n              {/* SKU Summary Banner */}\n              <div className=\"border-border bg-muted/20 space-y-3 rounded-lg border p-3.5\">\n                <div className=\"flex items-start justify-between gap-2\">\n                  <div>\n                    <div className=\"text-primary font-mono text-xs font-semibold\">{selectedSkuItem.sku}</div>\n                    <div className=\"text-foreground text-sm font-semibold\">{selectedSkuItem.name}</div>\n                    <div className=\"text-muted-foreground text-xs\">\n                      {selectedSkuItem.supplier} · {selectedSkuItem.category}\n                    </div>\n                  </div>\n                  <Badge\n                    variant={\n                      selectedSkuItem.status === 'critical'\n                        ? 'destructive'\n                        : selectedSkuItem.status === 'warning'\n                          ? 'warning'\n                          : 'success'\n                    }\n                    className=\"text-xs\"\n                  >\n                    {selectedSkuItem.daysOfInventoryRemaining} Days Stock Left\n                  </Badge>\n                </div>\n\n                <Separator />\n\n                <div className=\"grid grid-cols-3 gap-2 text-xs\">\n                  <div>\n                    <span className=\"text-muted-foreground\">On Hand:</span>\n                    <p className=\"text-foreground font-semibold tabular-nums\">{selectedSkuItem.onHandStock} units</p>\n                  </div>\n                  <div>\n                    <span className=\"text-muted-foreground\">Daily Velocity:</span>\n                    <p className=\"text-foreground font-semibold tabular-nums\">\n                      {selectedSkuItem.dailySalesVelocity} / day\n                    </p>\n                  </div>\n                  <div>\n                    <span className=\"text-muted-foreground\">Lead Time:</span>\n                    <p className=\"text-foreground font-semibold tabular-nums\">\n                      {selectedSkuItem.supplierLeadTimeDays} Days\n                    </p>\n                  </div>\n                </div>\n              </div>\n\n              {/* Quantity Input & Quick Chips */}\n              <div className=\"space-y-1.5\">\n                <div className=\"flex items-center justify-between\">\n                  <label className=\"text-foreground text-xs font-medium\">Reorder Quantity (Units)</label>\n                  <span className=\"text-muted-foreground text-xs\">\n                    Recommended: {selectedSkuItem.recommendedReorderQty} units\n                  </span>\n                </div>\n                <Input\n                  type=\"number\"\n                  min={1}\n                  value={customReorderQty}\n                  onChange={(e) => setCustomReorderQty(Number(e.target.value))}\n                  className=\"text-xs tabular-nums sm:text-sm\"\n                />\n                <div className=\"flex gap-1.5 pt-1\">\n                  <Button\n                    type=\"button\"\n                    variant=\"outline\"\n                    size=\"xs\"\n                    className=\"flex-1 text-xs\"\n                    onClick={() => setCustomReorderQty(Math.round(selectedSkuItem.recommendedReorderQty * 0.5))}\n                  >\n                    50% ({Math.round(selectedSkuItem.recommendedReorderQty * 0.5)})\n                  </Button>\n                  <Button\n                    type=\"button\"\n                    variant=\"outline\"\n                    size=\"xs\"\n                    className=\"flex-1 text-xs\"\n                    onClick={() => setCustomReorderQty(selectedSkuItem.recommendedReorderQty)}\n                  >\n                    Recommended ({selectedSkuItem.recommendedReorderQty})\n                  </Button>\n                  <Button\n                    type=\"button\"\n                    variant=\"outline\"\n                    size=\"xs\"\n                    className=\"flex-1 text-xs\"\n                    onClick={() => setCustomReorderQty(Math.round(selectedSkuItem.recommendedReorderQty * 1.5))}\n                  >\n                    150% ({Math.round(selectedSkuItem.recommendedReorderQty * 1.5)})\n                  </Button>\n                </div>\n              </div>\n\n              {/* Shipping Freight Method */}\n              <div className=\"space-y-1.5\">\n                <label className=\"text-foreground text-xs font-medium\">Inbound Freight Method</label>\n                <Select value={selectedShippingMethod} onValueChange={setSelectedShippingMethod}>\n                  <SelectTrigger className=\"w-full text-xs\">\n                    <SelectValue placeholder=\"Select shipping method\" />\n                  </SelectTrigger>\n                  <SelectContent>\n                    <SelectItem value=\"standard-freight\">Standard Consolidated Freight (Est. 14 Days)</SelectItem>\n                    <SelectItem value=\"expedited-air\">Expedited Air Express (Est. 4 Days · +$420)</SelectItem>\n                    <SelectItem value=\"ocean-container\">Full Ocean Container FCL (Est. 28 Days · Economy)</SelectItem>\n                  </SelectContent>\n                </Select>\n              </div>\n\n              {/* Cost Calculation Summary Box */}\n              <div className=\"border-border bg-muted/40 space-y-2 rounded-lg border p-3.5 text-xs\">\n                <div className=\"flex items-center justify-between\">\n                  <span className=\"text-muted-foreground\">Unit Cost:</span>\n                  <span className=\"text-foreground font-mono tabular-nums\">${selectedSkuItem.unitCost.toFixed(2)}</span>\n                </div>\n                <div className=\"flex items-center justify-between\">\n                  <span className=\"text-muted-foreground\">Units to Order:</span>\n                  <span className=\"text-foreground font-mono tabular-nums\">{customReorderQty} units</span>\n                </div>\n                <Separator />\n                <div className=\"flex items-center justify-between text-sm font-semibold\">\n                  <span className=\"text-foreground\">Total Estimated PO Value:</span>\n                  <span className=\"text-primary font-mono text-base font-bold tabular-nums\">\n                    $\n                    {dialogCalculatedCost.toLocaleString('en-US', {\n                      minimumFractionDigits: 2,\n                      maximumFractionDigits: 2,\n                    })}\n                  </span>\n                </div>\n              </div>\n            </div>\n          )}\n\n          <DialogFooter className=\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\">\n            <DialogClose asChild>\n              <Button variant=\"outline\">Cancel</Button>\n            </DialogClose>\n            <Button className=\"gap-1.5\" onClick={handleConfirmCreatePo}>\n              <FileCheck className=\"size-4\" />\n              Generate Purchase Order\n            </Button>\n          </DialogFooter>\n        </DialogContent>\n      </Dialog>\n\n      {/* Bulk POs Generation Dialog */}\n      <Dialog open={bulkPoDialogOpen} onOpenChange={setBulkPoDialogOpen}>\n        <DialogContent className=\"sm:max-w-lg\">\n          <DialogHeader>\n            <div className=\"flex items-center gap-2\">\n              <div className=\"bg-primary/10 text-primary flex size-8 items-center justify-center rounded-md\">\n                <PackagePlus className=\"size-4\" />\n              </div>\n              <DialogTitle className=\"text-lg font-bold\">Generate Bulk Purchase Orders</DialogTitle>\n            </div>\n            <DialogDescription className=\"text-muted-foreground text-xs\">\n              Automatically create and batch replenishment purchase orders for all SKUs below safe safety threshold.\n            </DialogDescription>\n          </DialogHeader>\n\n          <div className=\"space-y-4 py-2\">\n            {/* Summary Metrics */}\n            <div className=\"border-border bg-muted/20 space-y-3 rounded-lg border p-4\">\n              <div className=\"flex items-center justify-between\">\n                <span className=\"text-muted-foreground text-xs\">Destination Facility:</span>\n                <Badge variant=\"outline\" className=\"text-xs font-medium\">\n                  Global Fulfillment Center\n                </Badge>\n              </div>\n              <div className=\"flex items-center justify-between\">\n                <span className=\"text-muted-foreground text-xs\">Total Purchase Orders:</span>\n                <span className=\"text-foreground text-xs font-semibold tabular-nums\">4 Vendor POs</span>\n              </div>\n              <div className=\"flex items-center justify-between\">\n                <span className=\"text-muted-foreground text-xs\">Total Replenishment Units:</span>\n                <span className=\"text-foreground text-xs font-semibold tabular-nums\">620 Units</span>\n              </div>\n              <Separator />\n              <div className=\"flex items-center justify-between\">\n                <span className=\"text-foreground text-xs font-semibold\">Combined Total PO Value:</span>\n                <span className=\"text-primary font-mono text-base font-bold tabular-nums\">$48,250.00</span>\n              </div>\n            </div>\n\n            {/* PO List Breakdown */}\n            <div className=\"space-y-2\">\n              <div className=\"text-foreground text-xs font-semibold\">Purchase Order Breakdown by Supplier</div>\n              <div className=\"border-border space-y-2 rounded-md border p-2.5 text-xs\">\n                {criticalAndWarningItems.map((item) => (\n                  <div key={item.id} className=\"flex items-center justify-between py-1\">\n                    <div>\n                      <span className=\"text-foreground font-medium\">{item.supplier}</span>\n                      <div className=\"text-muted-foreground font-mono text-xs\">\n                        {item.sku} ({item.recommendedReorderQty} units)\n                      </div>\n                    </div>\n                    <span className=\"text-foreground font-mono font-semibold tabular-nums\">\n                      ${item.estimatedPoCost.toLocaleString('en-US', { minimumFractionDigits: 2 })}\n                    </span>\n                  </div>\n                ))}\n              </div>\n            </div>\n          </div>\n\n          <DialogFooter className=\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\">\n            <DialogClose asChild>\n              <Button variant=\"outline\">Cancel</Button>\n            </DialogClose>\n            <Button className=\"gap-1.5\" onClick={handleConfirmBulkPos}>\n              <PackagePlus className=\"size-4\" />\n              Generate 4 Purchase Orders\n            </Button>\n          </DialogFooter>\n        </DialogContent>\n      </Dialog>\n    </div>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/InventoryReorderForecast.tsx"
    }
  ],
  "dependencies": [
    "lucide-react"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://uipkge.dev/r/react/badge.json",
    "https://uipkge.dev/r/react/button.json",
    "https://uipkge.dev/r/react/card.json",
    "https://uipkge.dev/r/react/dialog.json",
    "https://uipkge.dev/r/react/input.json",
    "https://uipkge.dev/r/react/select.json",
    "https://uipkge.dev/r/react/separator.json",
    "https://uipkge.dev/r/react/table.json"
  ],
  "description": "Supply chain inventory replenishment planner with lead-time demand forecasting, 4 forecasting KPI metric cards, safety stock triggers, multi-SKU demand table, and automated purchase order generation.",
  "categories": [
    "logistics",
    "app",
    "ecommerce",
    "dashboard"
  ]
}