{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "wishlist-drawer",
  "title": "Wishlist Drawer",
  "description": "A product grid with heart buttons that burst when saved, a Wishlist pill with a springy count, and a slide-in drawer listing saved items with variant, sale savings and stock, Move to cart, Notify me for sold-out items, a Share link button, a price drop alert switch and Move all to cart.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/wishlist-drawer/wishlist-drawer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } 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 WishProduct {\n  id: string;\n  name: string;\n  variant: string;\n  price: number;\n  was?: number;\n  image: string;\n  stock?: \"in\" | \"low\" | \"out\";\n  zoom?: number;\n}\nexport interface WishlistDrawerProps {\n  products?: WishProduct[];\n  /** Ids saved when the block mounts. */\n  defaultSaved?: string[];\n  currency?: string;\n  shareUrl?: string;\n  onChange?: (ids: string[]) => void;\n  onMoveToCart?: (items: WishProduct[]) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: {\n    bg: \"#0A0A0A\",\n    panel: \"#111111\",\n    card: \"#161616\",\n    title: \"#FFFFFF\",\n    muted: \"rgba(255,255,255,0.45)\",\n    body: \"rgba(255,255,255,0.62)\",\n    line: \"rgba(255,255,255,0.12)\",\n    tile: \"#F1F1F1\",\n    accent: \"#7CDE6A\",\n    accentText: \"#0B1A08\",\n    heart: \"#FF5A6E\",\n    amber: \"#F5B44A\",\n    buttonBg: \"#FFFFFF\",\n    buttonText: \"#111111\",\n    ghost: \"rgba(255,255,255,0.07)\",\n    scrim: \"rgba(0,0,0,0.6)\",\n  },\n  light: {\n    bg: \"#FFFFFF\",\n    panel: \"#FFFFFF\",\n    card: \"#F7F7F7\",\n    title: \"#111111\",\n    muted: \"rgba(0,0,0,0.45)\",\n    body: \"rgba(0,0,0,0.62)\",\n    line: \"rgba(0,0,0,0.1)\",\n    tile: \"#F1F1F1\",\n    accent: \"#2F9E44\",\n    accentText: \"#FFFFFF\",\n    heart: \"#E8384F\",\n    amber: \"#C77A00\",\n    buttonBg: \"#111111\",\n    buttonText: \"#FFFFFF\",\n    ghost: \"rgba(0,0,0,0.05)\",\n    scrim: \"rgba(10,10,10,0.35)\",\n  },\n};\ntype Palette = (typeof PALETTES)[\"dark\"];\n\nconst L = \"/demo/blocks/product-list\";\nconst PRODUCTS: WishProduct[] = [\n  { id: \"watch\", name: \"Minimal Watch\", variant: \"Black · 40 mm\", price: 79, was: 129, image: \"/demo/minimal-watch.webp\", stock: \"in\", zoom: 1.5 },\n  { id: \"shoes\", name: \"Running Shoes\", variant: \"US 9 · Grey\", price: 99, was: 149, image: \"/demo/running-shoes.webp\", stock: \"low\", zoom: 1.15 },\n  { id: \"headphones\", name: \"Headphones\", variant: \"Matte black\", price: 199, image: `${L}/headphones.webp`, stock: \"in\" },\n  { id: \"backpack\", name: \"Backpack\", variant: \"20 L · Black\", price: 89, image: `${L}/backpack.webp`, stock: \"out\" },\n  { id: \"earbuds\", name: \"Wireless Earbuds\", variant: \"Black\", price: 129, image: \"/demo/wireless-earbuds.webp\", stock: \"in\", zoom: 1.35 },\n  { id: \"bottle\", name: \"Insulated Bottle\", variant: \"750 ml\", price: 39, image: \"/demo/insulated-water-bottle.webp\", stock: \"in\", zoom: 1.4 },\n];\n\nconst money = (n: number, c: string) => `${c}${n.toFixed(2)}`;\nconst HEART = \"M12 20.5s-7.5-4.6-9.3-9.2C1.4 8 3.3 4.5 6.8 4.5c2.1 0 3.6 1.2 5.2 3 1.6-1.8 3.1-3 5.2-3 3.5 0 5.4 3.5 4.1 6.8-1.8 4.6-9.3 9.2-9.3 9.2z\";\n// Fixed burst directions keep server and client renders identical.\nconst BURST = [0, 60, 120, 180, 240, 300].map((deg) => ({ x: Math.round(Math.cos((deg * Math.PI) / 180) * 18), y: Math.round(Math.sin((deg * Math.PI) / 180) * 18) }));\n\nfunction HeartButton({ on, onClick, label, p, size = 36 }: { on: boolean; onClick: () => void; label: string; p: Palette; size?: number }) {\n  const reduce = useReducedMotion();\n  const [burst, setBurst] = React.useState(0);\n  return (\n    <motion.button\n      type=\"button\"\n      aria-pressed={on}\n      aria-label={label}\n      onClick={() => {\n        if (!on) setBurst((b) => b + 1);\n        onClick();\n      }}\n      whileTap={reduce ? undefined : { scale: 0.85 }}\n      className=\"relative grid place-items-center rounded-full bg-white/90 shadow-[0_4px_14px_rgba(0,0,0,0.12)] backdrop-blur\"\n      style={{ width: size, height: size }}\n    >\n      <motion.svg width={size * 0.5} height={size * 0.5} viewBox=\"0 0 24 24\" animate={reduce ? undefined : { scale: on ? [1, 1.3, 1] : 1 }} transition={{ duration: 0.35 }} aria-hidden=\"true\">\n        <path d={HEART} fill={on ? p.heart : \"none\"} stroke={on ? p.heart : \"#111111\"} strokeWidth=\"2\" strokeLinejoin=\"round\" style={{ transition: \"fill 150ms, stroke 150ms\" }} />\n      </motion.svg>\n      {!reduce && burst > 0 ? (\n        <span key={burst} className=\"pointer-events-none absolute inset-0\" aria-hidden=\"true\">\n          {BURST.map((b, i) => (\n            <motion.span\n              key={i}\n              className=\"absolute top-1/2 left-1/2 size-1.5 rounded-full\"\n              style={{ background: p.heart, marginLeft: -3, marginTop: -3 }}\n              initial={{ x: 0, y: 0, opacity: 1, scale: 1 }}\n              animate={{ x: b.x, y: b.y, opacity: 0, scale: 0.4 }}\n              transition={{ duration: 0.5, ease: \"easeOut\" }}\n            />\n          ))}\n        </span>\n      ) : null}\n    </motion.button>\n  );\n}\n\nexport function WishlistDrawer({ products = PRODUCTS, defaultSaved = [\"watch\", \"shoes\", \"backpack\"], currency = \"$\", shareUrl = \"https://northline.shop/wishlist/k7x2\", onChange, onMoveToCart, theme = \"dark\", className }: WishlistDrawerProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [saved, setSaved] = React.useState<string[]>(defaultSaved);\n  const [open, setOpen] = React.useState(false);\n  const [cart, setCart] = React.useState(0);\n  const [copied, setCopied] = React.useState(false);\n  const [alerts, setAlerts] = React.useState(true);\n  const openerRef = React.useRef<HTMLButtonElement>(null);\n  const closeRef = React.useRef<HTMLButtonElement>(null);\n  const copyTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  const list = saved.map((id) => products.find((x) => x.id === id)).filter((x): x is WishProduct => !!x);\n  const buyable = list.filter((x) => x.stock !== \"out\");\n  const value = list.reduce((s, x) => s + x.price, 0);\n\n  const update = (next: string[]) => {\n    setSaved(next);\n    onChange?.(next);\n  };\n  const toggle = (id: string) => update(saved.includes(id) ? saved.filter((x) => x !== id) : [id, ...saved]);\n  const move = (items: WishProduct[]) => {\n    if (!items.length) return;\n    setCart((c) => c + items.length);\n    onMoveToCart?.(items);\n    update(saved.filter((id) => !items.some((x) => x.id === id)));\n  };\n  const close = React.useCallback(() => {\n    setOpen(false);\n    setTimeout(() => openerRef.current?.focus(), 0);\n  }, []);\n  const copy = async () => {\n    try {\n      await navigator.clipboard?.writeText(shareUrl);\n    } catch {\n      // Clipboard can be blocked (iframes, permissions); the confirmation still shows the link.\n    }\n    setCopied(true);\n    if (copyTimer.current) clearTimeout(copyTimer.current);\n    copyTimer.current = setTimeout(() => setCopied(false), 2000);\n  };\n\n  React.useEffect(() => {\n    if (!open) return;\n    closeRef.current?.focus();\n    const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && close();\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, [open, close]);\n  React.useEffect(() => () => void (copyTimer.current && clearTimeout(copyTimer.current)), []);\n\n  return (\n    <section className={cn(\"relative min-h-[680px] w-full overflow-hidden\", className)} style={{ background: p.bg, color: p.body }}>\n      {/* Store page */}\n      <div inert={open} className=\"mx-auto w-full max-w-[1040px] px-4 py-10 sm:px-8 sm:py-12\">\n        <div className=\"flex items-center justify-between gap-4\">\n          <div>\n            <p className=\"text-[12px] font-medium tracking-[0.14em] uppercase\" style={{ color: p.muted }}>\n              Northline\n            </p>\n            <h2 className=\"mt-1 text-[26px] font-semibold tracking-tight sm:text-[30px]\" style={{ color: p.title }}>\n              New this week\n            </h2>\n          </div>\n          <div className=\"flex items-center gap-2\">\n            <span className=\"hidden items-center gap-1.5 rounded-full border px-3 py-2 text-[13px] sm:inline-flex\" style={{ borderColor: p.line, color: p.title }} aria-label={`Cart, ${cart} items`}>\n              Cart\n              <motion.span\n                key={cart}\n                initial={reduce || !cart ? false : { scale: 1.6 }}\n                animate={{ scale: 1 }}\n                className=\"grid h-5 min-w-5 place-items-center rounded-full px-1 text-[11px] font-semibold tabular-nums\"\n                style={{ background: cart ? p.accent : p.ghost, color: cart ? p.accentText : p.muted }}\n              >\n                {cart}\n              </motion.span>\n            </span>\n            <button\n              ref={openerRef}\n              type=\"button\"\n              onClick={() => setOpen(true)}\n              aria-haspopup=\"dialog\"\n              aria-label={`Wishlist, ${list.length} saved`}\n              className=\"inline-flex items-center gap-2 rounded-full px-4 py-2 text-[13px] font-semibold\"\n              style={{ background: p.buttonBg, color: p.buttonText }}\n            >\n              <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n                <path d={HEART} fill={list.length ? p.heart : \"none\"} stroke={list.length ? p.heart : \"currentColor\"} strokeWidth=\"2\" strokeLinejoin=\"round\" />\n              </svg>\n              Wishlist\n              <motion.span key={list.length} initial={reduce ? false : { scale: 1.5 }} animate={{ scale: 1 }} transition={{ type: \"spring\", stiffness: 500, damping: 16 }} className=\"tabular-nums\">\n                {list.length}\n              </motion.span>\n            </button>\n          </div>\n        </div>\n\n        <ul className=\"mt-7 grid grid-cols-2 gap-3 sm:gap-4 md:grid-cols-3\">\n          {products.map((it) => {\n            const on = saved.includes(it.id);\n            return (\n              <li key={it.id} className=\"min-w-0\">\n                <div className=\"relative aspect-[4/3] overflow-hidden rounded-2xl\" style={{ background: p.tile }}>\n                  {/* eslint-disable-next-line @next/next/no-img-element -- plain img keeps the block framework-agnostic */}\n                  <img src={it.image} alt={it.name} width={600} height={450} className=\"h-full w-full object-cover\" style={{ transform: `scale(${it.zoom ?? 1})` }} />\n                  <span className=\"absolute top-2.5 right-2.5\">\n                    <HeartButton on={on} onClick={() => toggle(it.id)} label={`Save ${it.name} to wishlist`} p={p} />\n                  </span>\n                  {it.was ? (\n                    <span className=\"absolute top-2.5 left-2.5 rounded-full px-2 py-0.5 text-[11px] font-semibold\" style={{ background: p.accent, color: p.accentText }}>\n                      −{Math.round((1 - it.price / it.was) * 100)}%\n                    </span>\n                  ) : null}\n                </div>\n                <p className=\"mt-2.5 truncate text-[14px] font-medium\" style={{ color: p.title }}>\n                  {it.name}\n                </p>\n                <p className=\"mt-0.5 text-[13px] tabular-nums\">\n                  <span style={{ color: p.title }}>{money(it.price, currency)}</span>\n                  {it.was ? (\n                    <span className=\"ml-2 text-[12px] line-through\" style={{ color: p.muted }}>\n                      {money(it.was, currency)}\n                    </span>\n                  ) : null}\n                </p>\n              </li>\n            );\n          })}\n        </ul>\n      </div>\n\n      {/* Drawer */}\n      <AnimatePresence>\n        {open ? (\n          <>\n            <motion.div key=\"scrim\" className=\"absolute inset-0 z-20\" style={{ background: p.scrim }} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} onClick={close} aria-hidden=\"true\" />\n            <motion.aside\n              key=\"drawer\"\n              role=\"dialog\"\n              aria-modal=\"true\"\n              aria-labelledby={`${uid}-title`}\n              initial={reduce ? { opacity: 0 } : { x: \"100%\" }}\n              animate={reduce ? { opacity: 1 } : { x: 0 }}\n              exit={reduce ? { opacity: 0 } : { x: \"100%\" }}\n              transition={{ type: \"spring\", stiffness: 380, damping: 40 }}\n              className=\"absolute inset-y-0 right-0 z-30 flex w-full max-w-[420px] flex-col border-l\"\n              style={{ background: p.panel, borderColor: p.line }}\n            >\n              <div className=\"flex items-center justify-between gap-3 border-b px-5 py-4\" style={{ borderColor: p.line }}>\n                <h3 id={`${uid}-title`} className=\"flex items-center gap-2 text-[18px] font-semibold\" style={{ color: p.title }}>\n                  Wishlist\n                  <span className=\"rounded-full px-2 py-0.5 text-[12px] tabular-nums\" style={{ background: p.ghost, color: p.body }}>\n                    {list.length}\n                  </span>\n                </h3>\n                <div className=\"flex items-center gap-1.5\">\n                  <button type=\"button\" onClick={copy} className=\"relative inline-flex h-9 items-center gap-1.5 overflow-hidden rounded-full border px-3 text-[13px] font-medium\" style={{ borderColor: p.line, color: copied ? p.accent : p.title }}>\n                    <AnimatePresence mode=\"popLayout\" initial={false}>\n                      <motion.span key={copied ? \"c\" : \"s\"} initial={reduce ? false : { y: 12, opacity: 0 }} animate={{ y: 0, opacity: 1 }} exit={{ y: -12, opacity: 0 }} className=\"inline-flex items-center gap-1.5\">\n                        <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                          {copied ? <path d=\"M5 12.5 10 17l9-10\" /> : <path d=\"M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1\" />}\n                        </svg>\n                        {copied ? \"Link copied\" : \"Share\"}\n                      </motion.span>\n                    </AnimatePresence>\n                  </button>\n                  <button ref={closeRef} type=\"button\" onClick={close} aria-label=\"Close wishlist\" className=\"grid size-9 place-items-center rounded-full\" style={{ background: p.ghost, color: p.title }}>\n                    <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                      <path d=\"M6 6l12 12M18 6 6 18\" />\n                    </svg>\n                  </button>\n                </div>\n              </div>\n\n              <div className=\"min-h-0 flex-1 overflow-y-auto px-5 py-3\">\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  {list.length ? (\n                    list.map((it) => (\n                      <motion.div\n                        key={it.id}\n                        layout={!reduce}\n                        initial={reduce ? false : { opacity: 0, x: 24 }}\n                        animate={{ opacity: 1, x: 0 }}\n                        exit={reduce ? { opacity: 0 } : { opacity: 0, x: 60, transition: { duration: 0.22 } }}\n                        transition={{ type: \"spring\", stiffness: 420, damping: 38 }}\n                        className=\"flex gap-3.5 border-b py-3.5 last:border-b-0\"\n                        style={{ borderColor: p.line }}\n                      >\n                        <span className=\"relative size-[84px] shrink-0 overflow-hidden rounded-xl\" style={{ background: p.tile }}>\n                          {/* eslint-disable-next-line @next/next/no-img-element -- plain img keeps the block framework-agnostic */}\n                          <img src={it.image} alt=\"\" width={168} height={168} className=\"h-full w-full object-cover\" style={{ transform: `scale(${it.zoom ?? 1})`, filter: it.stock === \"out\" ? \"grayscale(1) opacity(0.6)\" : undefined }} />\n                        </span>\n                        <div className=\"flex min-w-0 flex-1 flex-col\">\n                          <div className=\"flex items-start justify-between gap-2\">\n                            <div className=\"min-w-0\">\n                              <p className=\"truncate text-[14px] font-medium\" style={{ color: p.title }}>\n                                {it.name}\n                              </p>\n                              <p className=\"truncate text-[12px]\" style={{ color: p.muted }}>\n                                {it.variant}\n                              </p>\n                            </div>\n                            <button type=\"button\" onClick={() => toggle(it.id)} aria-label={`Remove ${it.name} from wishlist`} className=\"grid size-8 shrink-0 place-items-center rounded-full\" style={{ background: p.ghost }}>\n                              <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n                                <path d={HEART} fill={p.heart} stroke={p.heart} strokeWidth=\"2\" strokeLinejoin=\"round\" />\n                              </svg>\n                            </button>\n                          </div>\n                          <p className=\"mt-1 text-[13px] tabular-nums\">\n                            <span className=\"font-semibold\" style={{ color: p.title }}>\n                              {money(it.price, currency)}\n                            </span>\n                            {it.was ? (\n                              <span className=\"ml-2 text-[12px] line-through\" style={{ color: p.muted }}>\n                                {money(it.was, currency)}\n                              </span>\n                            ) : null}\n                          </p>\n                          <div className=\"mt-auto flex items-center justify-between gap-2 pt-2\">\n                            <span className=\"text-[12px]\" style={{ color: it.stock === \"out\" ? p.muted : it.stock === \"low\" ? p.amber : p.accent }}>\n                              {it.stock === \"out\" ? \"Out of stock\" : it.stock === \"low\" ? \"Only 2 left\" : it.was ? `Saved ${money(it.was - it.price, currency)}` : \"In stock\"}\n                            </span>\n                            {it.stock === \"out\" ? (\n                              <button type=\"button\" className=\"rounded-full border px-3 py-1.5 text-[12px] font-medium\" style={{ borderColor: p.line, color: p.title }}>\n                                Notify me\n                              </button>\n                            ) : (\n                              <button type=\"button\" onClick={() => move([it])} className=\"rounded-full px-3 py-1.5 text-[12px] font-semibold\" style={{ background: p.buttonBg, color: p.buttonText }}>\n                                Move to cart\n                              </button>\n                            )}\n                          </div>\n                        </div>\n                      </motion.div>\n                    ))\n                  ) : (\n                    <motion.div key=\"empty\" initial={reduce ? false : { opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} className=\"flex flex-col items-center px-4 py-16 text-center\">\n                      <span className=\"grid size-14 place-items-center rounded-full\" style={{ background: p.ghost }}>\n                        <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n                          <path d={HEART} fill=\"none\" stroke={p.title} strokeWidth=\"1.8\" strokeLinejoin=\"round\" />\n                        </svg>\n                      </span>\n                      <p className=\"mt-4 text-[16px] font-medium\" style={{ color: p.title }}>\n                        Your wishlist is empty\n                      </p>\n                      <p className=\"mt-1 max-w-[260px] text-[13px] leading-relaxed\">Tap the heart on any product to save it here for later.</p>\n                      <button type=\"button\" onClick={close} className=\"mt-5 rounded-full px-5 py-2.5 text-[13px] font-semibold\" style={{ background: p.buttonBg, color: p.buttonText }}>\n                        Keep shopping\n                      </button>\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </div>\n\n              {list.length ? (\n                <div className=\"border-t px-5 pt-4 pb-5\" style={{ borderColor: p.line }}>\n                  <label className=\"flex cursor-pointer items-center justify-between gap-3 text-[13px]\">\n                    <span>\n                      <span className=\"block font-medium\" style={{ color: p.title }}>\n                        Price drop alerts\n                      </span>\n                      <span className=\"block text-[12px]\" style={{ color: p.muted }}>\n                        Email me when a saved item goes on sale\n                      </span>\n                    </span>\n                    <input type=\"checkbox\" role=\"switch\" checked={alerts} onChange={(e) => setAlerts(e.target.checked)} className=\"peer sr-only\" />\n                    <span className=\"relative h-6 w-10 shrink-0 rounded-full transition-colors peer-focus-visible:ring-2\" style={{ background: alerts ? p.accent : p.ghost, [\"--tw-ring-color\" as string]: p.muted }} aria-hidden=\"true\">\n                      <motion.span className=\"absolute top-0.5 left-0.5 size-5 rounded-full bg-white shadow\" animate={{ x: alerts ? 16 : 0 }} transition={{ type: \"spring\", stiffness: 600, damping: 34 }} />\n                    </span>\n                  </label>\n                  <div className=\"mt-4 flex items-center justify-between gap-3\">\n                    <p className=\"text-[13px]\">\n                      {list.length} item{list.length === 1 ? \"\" : \"s\"} ·{\" \"}\n                      <span className=\"font-semibold tabular-nums\" style={{ color: p.title }}>\n                        {money(value, currency)}\n                      </span>\n                    </p>\n                    <button type=\"button\" disabled={!buyable.length} onClick={() => move(buyable)} className=\"rounded-full px-5 py-2.5 text-[14px] font-semibold disabled:opacity-40\" style={{ background: p.buttonBg, color: p.buttonText }}>\n                      Move {buyable.length === list.length || !buyable.length ? \"all\" : buyable.length} to cart\n                    </button>\n                  </div>\n                </div>\n              ) : null}\n            </motion.aside>\n          </>\n        ) : null}\n      </AnimatePresence>\n    </section>\n  );\n}\n\nexport default WishlistDrawer;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}