{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "order-bump-block",
  "title": "Order Bump Block",
  "description": "A checkout order bump: the main item plus one-time add-on offers in dashed boxes with a pulsing arrow and a passing shine, a checkbox that draws its check, discounted prices, option pills that unfold once added, summary lines that fold in, a counting total and a savings note.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/order-bump-block/order-bump-block.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface BumpOffer {\n  id: string;\n  title: string;\n  pitch: string;\n  price: number;\n  compareAtPrice: number;\n  image?: string;\n  options?: string[];\n}\n\nexport interface OrderBumpBlockProps {\n  item?: { title: string; variant: string; price: number; image?: string };\n  bumps?: BumpOffer[];\n  shipping?: number;\n  currency?: string;\n  onChange?: (selected: { id: string; option?: string }[]) => void;\n  onCheckout?: (total: number) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", title: \"#FFFFFF\", muted: \"rgba(255,255,255,0.45)\", body: \"rgba(255,255,255,0.62)\", line: \"rgba(255,255,255,0.12)\", card: \"#141414\", photo: \"#F1F1F1\", buttonBg: \"#FFFFFF\", buttonText: \"#111111\", accent: \"#7CDE6A\", amber: \"#F5B544\", sale: \"#FF6B57\", ring: \"rgba(255,255,255,0.5)\" },\n  light: { bg: \"#FFFFFF\", title: \"#111111\", muted: \"rgba(0,0,0,0.45)\", body: \"rgba(0,0,0,0.62)\", line: \"rgba(0,0,0,0.1)\", card: \"#F7F7F6\", photo: \"#F1F1F1\", buttonBg: \"#111111\", buttonText: \"#FFFFFF\", accent: \"#2F9E44\", amber: \"#B7791F\", sale: \"#D9480F\", ring: \"rgba(0,0,0,0.45)\" },\n};\nconst ITEM = { title: \"Running Shoes\", variant: \"White · EU 42\", price: 99, image: \"/demo/running-shoes.webp\" };\nconst BUMPS: BumpOffer[] = [\n  { id: \"bottle\", title: \"Insulated Water Bottle\", pitch: \"Cold for 24 hours on your longest runs. Only with this order.\", price: 24, compareAtPrice: 39, image: \"/demo/insulated-water-bottle.webp\", options: [\"500 ml\", \"750 ml\"] },\n  { id: \"care\", title: \"2-year shoe care plan\", pitch: \"Free sole repair and one replacement pair if they wear through early.\", price: 9, compareAtPrice: 19 },\n];\n\nfunction Money({ value, currency, reduce }: { value: number; currency: string; reduce: boolean }) {\n  const mv = useMotionValue(value);\n  const text = useTransform(mv, (v) => `${currency}${v.toFixed(2)}`);\n  React.useEffect(() => {\n    if (reduce) {\n      mv.set(value);\n      return;\n    }\n    const c = animate(mv, value, { duration: 0.45, ease: [0.22, 1, 0.36, 1] });\n    return () => c.stop();\n  }, [value, reduce, mv]);\n  return <motion.span>{text}</motion.span>;\n}\n\nexport function OrderBumpBlock({ item = ITEM, bumps = BUMPS, shipping = 0, currency = \"$\", onChange, onCheckout, theme = \"dark\", className }: OrderBumpBlockProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [picked, setPicked] = React.useState<Record<string, boolean>>({});\n  const [option, setOption] = React.useState<Record<string, string>>(() => Object.fromEntries(bumps.filter((b) => b.options).map((b) => [b.id, b.options![b.options!.length - 1]])));\n  const money = (n: number) => `${currency}${n.toFixed(2)}`;\n  const chosen = bumps.filter((b) => picked[b.id]);\n  const total = item.price + chosen.reduce((a, b) => a + b.price, 0) + shipping;\n  const saved = chosen.reduce((a, b) => a + (b.compareAtPrice - b.price), 0);\n\n  const toggle = (id: string) =>\n    setPicked((s) => {\n      const n = { ...s, [id]: !s[id] };\n      onChange?.(bumps.filter((b) => n[b.id]).map((b) => ({ id: b.id, option: option[b.id] })));\n      return n;\n    });\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.title }}>\n      <div className=\"mx-auto max-w-[560px] px-4 py-10\">\n        <div className=\"rounded-3xl border p-5\" style={{ background: p.card, borderColor: p.line }}>\n          <h2 className=\"m-0 text-[17px] font-semibold\">Your order</h2>\n          <div className=\"mt-3 flex items-center gap-3 border-b pb-4\" style={{ borderColor: p.line }}>\n            <span className=\"h-16 w-16 shrink-0 overflow-hidden rounded-xl\" style={{ background: p.photo }}>\n              {/* eslint-disable-next-line @next/next/no-img-element */}\n              {item.image && <img src={item.image} alt=\"\" className=\"h-full w-full object-cover\" />}\n            </span>\n            <span className=\"min-w-0 flex-1\">\n              <span className=\"block text-[14px] font-medium\">{item.title}</span>\n              <span className=\"block text-[12px]\" style={{ color: p.muted }}>\n                {item.variant}\n              </span>\n            </span>\n            <span className=\"text-[14px] font-medium tabular-nums\">{money(item.price)}</span>\n          </div>\n\n          <ul className=\"m-0 mt-4 flex list-none flex-col gap-3 p-0\">\n            {bumps.map((b, i) => {\n              const on = !!picked[b.id];\n              const off = Math.round((1 - b.price / b.compareAtPrice) * 100);\n              return (\n                <li key={b.id}>\n                  <motion.div className=\"relative overflow-hidden rounded-2xl border-2 border-dashed\" animate={{ borderColor: on ? p.accent : p.amber, backgroundColor: on ? `${p.accent}10` : `${p.amber}0C` }} transition={{ duration: reduce ? 0 : 0.25 }}>\n                    {i === 0 && !on && !reduce && (\n                      <motion.span className=\"pointer-events-none absolute inset-0\" style={{ background: `linear-gradient(100deg, transparent 30%, ${p.amber}22 50%, transparent 70%)` }} animate={{ x: [\"-100%\", \"100%\"] }} transition={{ repeat: Infinity, duration: 2.4, ease: \"easeInOut\", repeatDelay: 1.2 }} aria-hidden=\"true\" />\n                    )}\n                    <div className=\"flex items-center gap-2 px-4 pt-3 text-[11.5px] font-semibold tracking-[0.06em] uppercase\" style={{ color: on ? p.accent : p.amber }}>\n                      <motion.span animate={on || reduce ? { x: 0 } : { x: [0, 5, 0] }} transition={{ repeat: on ? 0 : Infinity, duration: 1 }} aria-hidden=\"true\">\n                        →\n                      </motion.span>\n                      {on ? \"Added to your order\" : `One-time offer · ${off}% off`}\n                    </div>\n                    <label className=\"relative flex cursor-pointer items-start gap-3 px-4 pt-2 pb-4\">\n                      <span className=\"relative mt-0.5 grid h-5 w-5 shrink-0 place-items-center\">\n                        <input id={`${uid}-${b.id}`} type=\"checkbox\" checked={on} onChange={() => toggle(b.id)} className=\"peer absolute inset-0 m-0 cursor-pointer opacity-0\" />\n                        <motion.span className=\"grid h-5 w-5 place-items-center rounded-md border-2 peer-focus-visible:ring-2\" animate={{ backgroundColor: on ? p.accent : \"rgba(0,0,0,0)\", borderColor: on ? p.accent : p.title, scale: on && !reduce ? [1, 1.25, 1] : 1 }} transition={{ duration: 0.3 }} style={ring} aria-hidden=\"true\">\n                          <AnimatePresence>\n                            {on && (\n                              <motion.svg key=\"c\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#0A0A0A\" strokeWidth=\"3.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                                <motion.path d=\"m5 12.5 4.5 4.5L19 7.5\" initial={reduce ? false : { pathLength: 0 }} animate={{ pathLength: 1 }} exit={reduce ? undefined : { pathLength: 0 }} transition={{ duration: 0.25 }} />\n                              </motion.svg>\n                            )}\n                          </AnimatePresence>\n                        </motion.span>\n                      </span>\n                      {b.image && (\n                        <span className=\"h-14 w-14 shrink-0 overflow-hidden rounded-xl\" style={{ background: p.photo }}>\n                          {/* eslint-disable-next-line @next/next/no-img-element */}\n                          <img src={b.image} alt=\"\" className=\"h-full w-full object-cover\" />\n                        </span>\n                      )}\n                      <span className=\"min-w-0 flex-1\">\n                        <span className=\"flex flex-wrap items-baseline justify-between gap-x-3\">\n                          <span className=\"text-[14px] font-semibold\">Yes, add {b.title}</span>\n                          <span className=\"text-[13.5px] tabular-nums\">\n                            <span className=\"mr-1.5 line-through\" style={{ color: p.muted }}>\n                              {money(b.compareAtPrice)}\n                            </span>\n                            <span className=\"font-semibold\" style={{ color: p.sale }}>\n                              {money(b.price)}\n                            </span>\n                          </span>\n                        </span>\n                        <span className=\"mt-1 block text-[12.5px] leading-snug\" style={{ color: p.body }}>\n                          {b.pitch}\n                        </span>\n                      </span>\n                    </label>\n                    <AnimatePresence initial={false}>\n                      {on && b.options && (\n                        <motion.div key=\"opt\" initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} className=\"overflow-hidden\">\n                          <div role=\"radiogroup\" aria-label={`${b.title} size`} className=\"flex gap-1.5 px-4 pb-4 pl-12\">\n                            {b.options.map((o) => (\n                              <button key={o} type=\"button\" role=\"radio\" aria-checked={option[b.id] === o} onClick={() => setOption((s) => ({ ...s, [b.id]: o }))} className={cn(\"h-8 cursor-pointer rounded-full border px-3 text-[12px]\", focus)} style={{ borderColor: option[b.id] === o ? p.title : p.line, background: option[b.id] === o ? p.buttonBg : \"transparent\", color: option[b.id] === o ? p.buttonText : p.title, ...ring }}>\n                                {o}\n                              </button>\n                            ))}\n                          </div>\n                        </motion.div>\n                      )}\n                    </AnimatePresence>\n                  </motion.div>\n                </li>\n              );\n            })}\n          </ul>\n\n          <dl className=\"m-0 mt-5 flex flex-col gap-2 border-t pt-4 text-[13.5px]\" style={{ borderColor: p.line }}>\n            <div className=\"flex justify-between\">\n              <dt style={{ color: p.body }}>{item.title}</dt>\n              <dd className=\"m-0 tabular-nums\">{money(item.price)}</dd>\n            </div>\n            <AnimatePresence initial={false}>\n              {chosen.map((b) => (\n                <motion.div key={b.id} initial={reduce ? false : { opacity: 0, height: 0 }} animate={{ opacity: 1, height: \"auto\" }} exit={reduce ? undefined : { opacity: 0, height: 0 }} className=\"flex justify-between overflow-hidden\">\n                  <dt style={{ color: p.body }}>\n                    {b.title}\n                    {option[b.id] && b.options ? ` · ${option[b.id]}` : \"\"}\n                  </dt>\n                  <dd className=\"m-0 tabular-nums\">{money(b.price)}</dd>\n                </motion.div>\n              ))}\n            </AnimatePresence>\n            <div className=\"flex justify-between\">\n              <dt style={{ color: p.body }}>Shipping</dt>\n              <dd className=\"m-0\" style={{ color: shipping ? p.title : p.accent }}>\n                {shipping ? money(shipping) : \"Free\"}\n              </dd>\n            </div>\n            <div className=\"mt-1 flex items-baseline justify-between border-t pt-3\" style={{ borderColor: p.line }}>\n              <dt className=\"text-[15px] font-semibold\">Total</dt>\n              <dd className=\"m-0 text-[22px] font-semibold tracking-[-0.02em] tabular-nums\">\n                <Money value={total} currency={currency} reduce={reduce} />\n              </dd>\n            </div>\n          </dl>\n          <AnimatePresence initial={false}>\n            {saved > 0 && (\n              <motion.p key=\"s\" initial={reduce ? false : { opacity: 0, y: -4 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0 }} className=\"m-0 mt-2 text-center text-[12.5px] font-medium\" style={{ color: p.accent }} aria-live=\"polite\">\n                You saved {money(saved)} with these add-ons\n              </motion.p>\n            )}\n          </AnimatePresence>\n          <button type=\"button\" onClick={() => onCheckout?.(total)} className={cn(\"mt-4 flex h-12 w-full cursor-pointer items-center justify-center gap-2 rounded-full border-0 text-[15px] font-semibold\", focus)} style={{ background: p.buttonBg, color: p.buttonText, ...ring }}>\n            Complete order · {money(total)}\n          </button>\n          <p className=\"m-0 mt-2.5 text-center text-[11.5px]\" style={{ color: p.muted }}>\n            Add-ons ship together with your order. No subscription.\n          </p>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default OrderBumpBlock;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}