{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ecommerce-ecommerce-bundle-upsells-stack","type":"registry:block","title":"Stack","files":[{"path":"components/blocks/ecommerce/ecommerce-bundle-upsells/stack.tsx","content":"import { useState } from 'react';\nimport { Minus, Plus } from 'lucide-react';\nimport { Button } from '@/components/ui/button';\nimport { Card, CardContent } from '@/components/ui/card';\n\ninterface Product {\n  id: string;\n  name: string;\n  price: number;\n  originalPrice?: number;\n  image: string;\n  description?: string;\n}\n\ninterface UpsellBundleStackProps {\n  mainProduct: Product;\n  upsellItems: Product[];\n  bundleDiscount?: number;\n}\n\nexport default function UpsellBundleStack({\n  mainProduct = {\n    id: 'main-1',\n    name: 'Premium Wireless Headphones',\n    price: 199.99,\n    originalPrice: 249.99,\n    image: '/placeholder.svg?height=300&width=300',\n    description:\n      'High-quality noise-canceling headphones with 30-hour battery life',\n  },\n  upsellItems = [\n    {\n      id: 'upsell-1',\n      name: 'Wireless Charging Case',\n      price: 49.99,\n      originalPrice: 69.99,\n      image: '/placeholder.svg?height=120&width=120',\n    },\n    {\n      id: 'upsell-2',\n      name: 'Premium Audio Cable',\n      price: 29.99,\n      image: '/placeholder.svg?height=120&width=120',\n    },\n    {\n      id: 'upsell-3',\n      name: 'Protective Carrying Case',\n      price: 39.99,\n      originalPrice: 54.99,\n      image: '/placeholder.svg?height=120&width=120',\n    },\n  ],\n  bundleDiscount = 0.1,\n}: UpsellBundleStackProps) {\n  const [selectedItems, setSelectedItems] = useState<Set<string>>(\n    new Set([mainProduct.id])\n  );\n\n  const handleItemToggle = (itemId: string, checked: boolean) => {\n    const newSelected = new Set(selectedItems);\n    if (checked) {\n      newSelected.add(itemId);\n    } else {\n      newSelected.delete(itemId);\n    }\n    setSelectedItems(newSelected);\n  };\n\n  const calculateTotal = () => {\n    let total = 0;\n    if (selectedItems.has(mainProduct.id)) {\n      total += mainProduct.price;\n    }\n    upsellItems.forEach((item) => {\n      if (selectedItems.has(item.id)) {\n        total += item.price;\n      }\n    });\n\n    // Apply bundle discount if more than one item is selected\n    if (selectedItems.size > 1) {\n      total = total * (1 - bundleDiscount);\n    }\n\n    return total;\n  };\n\n  const calculateSavings = () => {\n    let originalTotal = 0;\n    if (selectedItems.has(mainProduct.id)) {\n      originalTotal += mainProduct.originalPrice || mainProduct.price;\n    }\n    upsellItems.forEach((item) => {\n      if (selectedItems.has(item.id)) {\n        originalTotal += item.originalPrice || item.price;\n      }\n    });\n\n    const currentTotal = calculateTotal();\n    return originalTotal - currentTotal;\n  };\n\n  const selectedCount = selectedItems.size;\n  const savings = calculateSavings();\n\n  return (\n    <div className=\"mx-auto max-w-2xl px-4 py-8 md:py-12\">\n      <div className=\"mb-6 text-center sm:mb-8\">\n        <h2 className=\"text-foreground mb-2 text-xl font-bold sm:text-2xl\">\n          Complete Your Bundle\n        </h2>\n        <p className=\"text-muted-foreground text-sm sm:text-base\">\n          Save {Math.round(bundleDiscount * 100)}% when you buy together\n        </p>\n      </div>\n\n      <div className=\"space-y-3 sm:space-y-4\">\n        {/* Main Product */}\n        <Card className=\"border-primary/20 from-muted/50 to-muted border-2 bg-gradient-to-r shadow-lg\">\n          <CardContent className=\"p-4 sm:p-6\">\n            <div className=\"flex flex-col space-y-3 sm:flex-row sm:items-center sm:space-y-0 sm:space-x-4\">\n              <div className=\"flex items-start space-x-3 sm:space-x-4\">\n                <div className=\"relative flex-shrink-0\">\n                  <div className=\"border-primary h-16 w-16 overflow-hidden rounded-lg border-2 bg-white shadow-sm sm:h-20 sm:w-20\">\n                    <img\n                      src={mainProduct.image || '/placeholder.svg'}\n                      alt={mainProduct.name}\n                      width={80}\n                      height={80}\n                      className=\"h-full w-full object-cover\"\n                    />\n                  </div>\n                </div>\n                <div className=\"min-w-0 flex-1\">\n                  <h3 className=\"text-foreground text-base leading-tight font-semibold sm:text-lg\">\n                    {mainProduct.name}\n                  </h3>\n                  {mainProduct.description && (\n                    <p className=\"text-muted-foreground mt-1 line-clamp-2 text-xs sm:text-sm\">\n                      {mainProduct.description}\n                    </p>\n                  )}\n                </div>\n              </div>\n              <div className=\"flex items-center justify-between sm:flex-col sm:items-end sm:justify-center\">\n                <div className=\"flex items-center space-x-2\">\n                  <span className=\"text-foreground text-lg font-bold sm:text-xl\">\n                    ${mainProduct.price.toFixed(2)}\n                  </span>\n                  {mainProduct.originalPrice && (\n                    <span className=\"text-muted-foreground text-xs line-through sm:text-sm\">\n                      ${mainProduct.originalPrice.toFixed(2)}\n                    </span>\n                  )}\n                </div>\n                <div className=\"bg-primary text-primary-foreground rounded-full px-2 py-1 text-xs font-medium sm:mt-1 sm:text-sm\">\n                  Selected\n                </div>\n              </div>\n            </div>\n          </CardContent>\n        </Card>\n\n        {/* Upsell Items */}\n        {upsellItems.map((item) => (\n          <Card\n            key={item.id}\n            className=\"shadow-md transition-shadow duration-200 hover:shadow-lg\"\n          >\n            <CardContent className=\"p-3 sm:p-4\">\n              <div className=\"flex items-center space-x-3 sm:space-x-4\">\n                <div className=\"relative flex-shrink-0\">\n                  <div\n                    className={`bg-muted h-12 w-12 overflow-hidden rounded-lg shadow-sm sm:h-16 sm:w-16 ${\n                      selectedItems.has(item.id)\n                        ? 'border-primary border-2'\n                        : ''\n                    }`}\n                  >\n                    <img\n                      src={item.image || '/placeholder.svg'}\n                      alt={item.name}\n                      width={64}\n                      height={64}\n                      className=\"h-full w-full object-cover\"\n                    />\n                  </div>\n                </div>\n                <div className=\"min-w-0 flex-1\">\n                  <h4 className=\"text-foreground text-sm leading-tight font-medium sm:text-base\">\n                    {item.name}\n                  </h4>\n                  <div className=\"mt-1 flex items-center space-x-2\">\n                    <span className=\"text-foreground text-base font-semibold sm:text-lg\">\n                      ${item.price.toFixed(2)}\n                    </span>\n                    {item.originalPrice && (\n                      <span className=\"text-muted-foreground text-xs line-through sm:text-sm\">\n                        ${item.originalPrice.toFixed(2)}\n                      </span>\n                    )}\n                  </div>\n                </div>\n                <div className=\"flex-shrink-0\">\n                  {selectedItems.has(item.id) ? (\n                    <Button\n                      variant={'outline'}\n                      size=\"sm\"\n                      onClick={() => handleItemToggle(item.id, false)}\n                    >\n                      <Minus className=\"mr-1 h-3 w-3 sm:h-4 sm:w-4\" />\n                      Remove\n                    </Button>\n                  ) : (\n                    <Button\n                      variant=\"outline\"\n                      size=\"sm\"\n                      onClick={() => handleItemToggle(item.id, true)}\n                    >\n                      <Plus className=\"mr-1 h-3 w-3 sm:h-4 sm:w-4\" />\n                      Add\n                    </Button>\n                  )}\n                </div>\n              </div>\n            </CardContent>\n          </Card>\n        ))}\n      </div>\n\n      {/* Bundle Summary */}\n      <Card className=\"border-border mt-4 border-2 shadow-lg sm:mt-6\">\n        <CardContent className=\"p-4 sm:p-6\">\n          <div className=\"space-y-3 sm:space-y-4\">\n            <div className=\"flex flex-col space-y-2 sm:flex-row sm:items-center sm:justify-between sm:space-y-0\">\n              <span className=\"text-foreground text-base font-medium sm:text-lg\">\n                Bundle Total ({selectedCount}{' '}\n                {selectedCount === 1 ? 'item' : 'items'})\n              </span>\n              <div className=\"text-left sm:text-right\">\n                <div className=\"text-foreground text-xl font-bold sm:text-2xl\">\n                  ${calculateTotal().toFixed(2)}\n                </div>\n                {savings > 0 && (\n                  <div className=\"text-sm font-medium text-emerald-600\">\n                    You save ${savings.toFixed(2)}\n                  </div>\n                )}\n              </div>\n            </div>\n\n            {selectedCount > 1 && (\n              <div className=\"flex items-center justify-center space-x-2 rounded-lg bg-emerald-50 p-2 text-xs text-emerald-600 sm:p-3 sm:text-sm dark:bg-emerald-900 dark:text-emerald-400\">\n                <Plus className=\"h-3 w-3 flex-shrink-0 sm:h-4 sm:w-4\" />\n                <span className=\"text-center font-medium\">\n                  Bundle discount applied: {Math.round(bundleDiscount * 100)}%\n                  off\n                </span>\n              </div>\n            )}\n\n            <Button\n              className=\"h-10 w-full text-base font-semibold sm:h-12 sm:text-lg\"\n              disabled={selectedCount === 0}\n            >\n              Add Selected to Cart\n            </Button>\n\n            <p className=\"text-muted-foreground text-center text-xs leading-relaxed\">\n              Free shipping on orders over $100 • 30-day return policy\n            </p>\n          </div>\n        </CardContent>\n      </Card>\n    </div>\n  );\n}\n","type":"registry:component","target":"components/blocks/ecommerce/ecommerce-bundle-upsells/stack.tsx"},{"path":"components/ui/button.tsx","content":"import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Slot } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst buttonVariants = cva(\n  \"group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-primary text-primary-foreground hover:bg-primary/80\",\n        outline:\n          \"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50\",\n        secondary:\n          \"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground\",\n        ghost:\n          \"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50\",\n        destructive:\n          \"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40\",\n        link: \"text-primary underline-offset-4 hover:underline\",\n      },\n      size: {\n        default:\n          \"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2\",\n        xs: \"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3\",\n        sm: \"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5\",\n        lg: \"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2\",\n        icon: \"size-9\",\n        \"icon-xs\":\n          \"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3\",\n        \"icon-sm\":\n          \"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md\",\n        \"icon-lg\": \"size-10\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n      size: \"default\",\n    },\n  }\n)\n\nfunction Button({\n  className,\n  variant = \"default\",\n  size = \"default\",\n  asChild = false,\n  ...props\n}: React.ComponentProps<\"button\"> &\n  VariantProps<typeof buttonVariants> & {\n    asChild?: boolean\n  }) {\n  const Comp = asChild ? Slot.Root : \"button\"\n\n  return (\n    <Comp\n      data-slot=\"button\"\n      data-variant={variant}\n      data-size={size}\n      className={cn(buttonVariants({ variant, size, className }))}\n      {...props}\n    />\n  )\n}\n\nexport { Button, buttonVariants }\n","type":"registry:ui","target":"components/ui/button.tsx"},{"path":"components/ui/card.tsx","content":"import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Card({\n  className,\n  size = \"default\",\n  ...props\n}: React.ComponentProps<\"div\"> & { size?: \"default\" | \"sm\" }) {\n  return (\n    <div\n      data-slot=\"card\"\n      data-size={size}\n      className={cn(\n        \"group/card flex flex-col gap-6 overflow-hidden rounded-xl bg-card py-6 text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-header\"\n      className={cn(\n        \"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-6 group-data-[size=sm]/card:px-4 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-6 group-data-[size=sm]/card:[.border-b]:pb-4\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-title\"\n      className={cn(\n        \"font-heading text-base leading-normal font-medium group-data-[size=sm]/card:text-sm\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardDescription({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-description\"\n      className={cn(\"text-sm text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction CardAction({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-action\"\n      className={cn(\n        \"col-start-2 row-span-2 row-start-1 self-start justify-self-end\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardContent({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-content\"\n      className={cn(\"px-6 group-data-[size=sm]/card:px-4\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction CardFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-footer\"\n      className={cn(\n        \"flex items-center rounded-b-xl px-6 group-data-[size=sm]/card:px-4 [.border-t]:pt-6 group-data-[size=sm]/card:[.border-t]:pt-4\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Card,\n  CardHeader,\n  CardFooter,\n  CardTitle,\n  CardAction,\n  CardDescription,\n  CardContent,\n}\n","type":"registry:ui","target":"components/ui/card.tsx"}],"description":"A vertical stack of bundle items with running totals and one add to cart action. Use it on mobile product pages to offer matching extras as shoppers scroll.","dependencies":["class-variance-authority","lucide-react","radix-ui"]}