{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "newsletter-discount-modal",
  "title": "Newsletter Discount Modal",
  "description": "A newsletter sign-up popup with a first-order discount: a sample issue on paper, weekly or drops-only frequency, interest chips and an email field, then a stamped letter and a perforated coupon ticket with copy, apply to cart and an expiry countdown, plus a corner teaser if it's dismissed.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/newsletter-discount-modal/newsletter-discount-modal.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 NewsletterIssue {\n  number: number;\n  title: string;\n  images: string[];\n}\n\nexport interface NewsletterDiscountModalProps {\n  store?: string;\n  /** Percent off the first order. */\n  discount?: number;\n  code?: string;\n  /** How long the code is valid after signing up, in hours. */\n  validHours?: number;\n  issue?: NewsletterIssue;\n  interests?: string[];\n  /** Open automatically after this many milliseconds. Set to null to wait for the teaser. */\n  openAfter?: number | null;\n  /** Return a Promise to keep the button busy while you subscribe the email. */\n  onSubscribe?: (value: { email: string; frequency: \"weekly\" | \"drops\"; interests: string[] }) => void | Promise<void>;\n  onApply?: (code: string) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: {\n    bg: \"#0A0A0A\",\n    title: \"#FFFFFF\",\n    muted: \"rgba(255,255,255,0.45)\",\n    body: \"rgba(255,255,255,0.65)\",\n    line: \"rgba(255,255,255,0.12)\",\n    panel: \"#121212\",\n    photo: \"#F1F1F1\",\n    input: \"#0D0D0D\",\n    scrim: \"rgba(0,0,0,0.6)\",\n    buttonBg: \"#FFFFFF\",\n    buttonText: \"#111111\",\n    accent: \"#7CDE6A\",\n    error: \"#FF6B57\",\n    ring: \"rgba(255,255,255,0.5)\",\n    ticket: \"#7CDE6A\",\n    ticketText: \"#0B1A08\",\n  },\n  light: {\n    bg: \"#FFFFFF\",\n    title: \"#111111\",\n    muted: \"rgba(0,0,0,0.45)\",\n    body: \"rgba(0,0,0,0.65)\",\n    line: \"rgba(0,0,0,0.1)\",\n    panel: \"#FFFFFF\",\n    photo: \"#F1F1F1\",\n    input: \"#FAFAF9\",\n    scrim: \"rgba(10,10,10,0.4)\",\n    buttonBg: \"#111111\",\n    buttonText: \"#FFFFFF\",\n    accent: \"#2F9E44\",\n    error: \"#D9480F\",\n    ring: \"rgba(0,0,0,0.45)\",\n    ticket: \"#111111\",\n    ticketText: \"#FFFFFF\",\n  },\n};\n// The letter is paper in both themes.\nconst PAPER = {\n  bg: \"#FAF8F3\",\n  ink: \"#141414\",\n  soft: \"rgba(20,20,20,0.55)\",\n  rule: \"rgba(20,20,20,0.12)\",\n  stamp: \"#D9480F\",\n};\n\nconst ISSUE: NewsletterIssue = {\n  number: 42,\n  title: \"The desk edit: five things we reach for every day\",\n  images: [\"/demo/laptop-stand.webp\", \"/demo/notebook.webp\", \"/demo/minimal-watch.webp\", \"/demo/wireless-earbuds.webp\"],\n};\nconst INTERESTS = [\"Audio\", \"Desk setup\", \"Outdoor\", \"Watches\"];\nconst GRID = [\n  \"/demo/wireless-earbuds.webp\",\n  \"/demo/minimal-watch.webp\",\n  \"/demo/running-shoes.webp\",\n  \"/demo/laptop-stand.webp\",\n  \"/demo/notebook.webp\",\n  \"/demo/insulated-water-bottle.webp\",\n  \"/demo/blocks/product-list/headphones.webp\",\n  \"/demo/blocks/product-list/backpack.webp\",\n];\nconst FREQUENCIES = [\n  {\n    id: \"weekly\" as const,\n    label: \"Weekly letter\",\n    detail: \"Thursdays, one email\",\n  },\n  {\n    id: \"drops\" as const,\n    label: \"Drops only\",\n    detail: \"New products, ~2 a month\",\n  },\n];\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\nexport function NewsletterDiscountModal({ store = \"Northline\", discount = 15, code = \"LETTER15\", validHours = 48, issue = ISSUE, interests = INTERESTS, openAfter = 900, onSubscribe, onApply, theme = \"dark\", className }: NewsletterDiscountModalProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [open, setOpen] = React.useState(false);\n  const [teaser, setTeaser] = React.useState(false);\n  const [step, setStep] = React.useState<\"form\" | \"done\">(\"form\");\n  const [email, setEmail] = React.useState(\"\");\n  const [frequency, setFrequency] = React.useState<\"weekly\" | \"drops\">(\"weekly\");\n  const [picked, setPicked] = React.useState<string[]>([interests[1] ?? interests[0]].filter(Boolean));\n  const [error, setError] = React.useState<string | null>(null);\n  const [busy, setBusy] = React.useState(false);\n  const [copied, setCopied] = React.useState(false);\n  const [applied, setApplied] = React.useState(false);\n  const [expiresAt, setExpiresAt] = React.useState<number | null>(null);\n  const [now, setNow] = React.useState(0);\n  const teaserRef = React.useRef<HTMLButtonElement>(null);\n  const emailRef = React.useRef<HTMLInputElement>(null);\n\n  React.useEffect(() => {\n    if (openAfter === null) {\n      const t = setTimeout(() => setTeaser(true), 0);\n      return () => clearTimeout(t);\n    }\n    const t = setTimeout(() => setOpen(true), reduce ? 0 : openAfter);\n    return () => clearTimeout(t);\n  }, [openAfter, reduce]);\n\n  const close = React.useCallback(() => {\n    setOpen(false);\n    setTeaser(true);\n    setTimeout(() => teaserRef.current?.focus({ preventScroll: true }), 0);\n  }, []);\n  React.useEffect(() => {\n    if (!open) return;\n    const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && close();\n    window.addEventListener(\"keydown\", onKey);\n    return () => window.removeEventListener(\"keydown\", onKey);\n  }, [open, close]);\n  React.useEffect(() => {\n    if (!copied) return;\n    const t = setTimeout(() => setCopied(false), 1600);\n    return () => clearTimeout(t);\n  }, [copied]);\n  // The countdown only ticks once there's a code, and only in the browser.\n  React.useEffect(() => {\n    if (expiresAt === null) return;\n    const tick = () => setNow(Date.now());\n    const first = setTimeout(tick, 0);\n    const id = setInterval(tick, 1000);\n    return () => {\n      clearTimeout(first);\n      clearInterval(id);\n    };\n  }, [expiresAt]);\n\n  const focusOnce = React.useCallback((el: HTMLElement | null) => {\n    if (el && !el.dataset.f) {\n      el.dataset.f = \"1\";\n      el.focus({ preventScroll: true });\n    }\n  }, []);\n\n  const submit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    if (!EMAIL.test(email.trim())) {\n      setError(\"Enter an email like name@example.com.\");\n      emailRef.current?.focus();\n      return;\n    }\n    setError(null);\n    setBusy(true);\n    try {\n      await onSubscribe?.({\n        email: email.trim(),\n        frequency,\n        interests: picked,\n      });\n      if (!onSubscribe && !reduce) await new Promise((r) => setTimeout(r, 900));\n      setExpiresAt(Date.now() + validHours * 3600_000);\n      setStep(\"done\");\n      setTeaser(false);\n    } catch {\n      setError(\"Something went wrong. Please try again.\");\n    } finally {\n      setBusy(false);\n    }\n  };\n  const copy = async () => {\n    try {\n      await navigator.clipboard?.writeText(code);\n    } catch {\n      /* clipboard can be blocked; the code is still on screen */\n    }\n    setCopied(true);\n  };\n  const reopen = () => {\n    setTeaser(false);\n    setOpen(true);\n  };\n\n  const left = expiresAt === null || now === 0 ? validHours * 3600 : Math.max(0, Math.round((expiresAt - now) / 1000));\n  const countdown = `${pad(Math.floor(left / 3600))}:${pad(Math.floor((left % 3600) / 60))}:${pad(left % 60)}`;\n  const ring = {\n    [\"--tw-ring-color\" as string]: p.ring,\n    [\"--tw-ring-offset-color\" as string]: p.panel,\n  } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const done = step === \"done\";\n  const toggle = (x: string) => setPicked((list) => (list.includes(x) ? list.filter((y) => y !== x) : [...list, x]));\n\n  return (\n    <section className={cn(\"@container relative flex min-h-[640px] w-full flex-col overflow-clip\", className)} style={{ background: p.bg, color: p.title }}>\n      {/* Store page behind */}\n      <div className=\"mx-auto w-full max-w-6xl flex-1 px-4 py-8 @[640px]:px-8\" aria-hidden={open || undefined}>\n        <div className=\"flex items-center justify-between\">\n          <span className=\"text-[17px] font-semibold\">{store}</span>\n          <span className=\"flex gap-4 text-[13px]\" style={{ color: p.body }}>\n            <span>Shop</span>\n            <span className=\"hidden @[480px]:inline\">Journal</span>\n            <span>Cart (0)</span>\n          </span>\n        </div>\n        <ul className=\"m-0 mt-6 grid list-none grid-cols-2 gap-3 p-0 @[760px]:grid-cols-4\">\n          {GRID.map((src) => (\n            <li key={src} className=\"aspect-square overflow-hidden rounded-2xl\" style={{ background: p.photo }}>\n              {/* eslint-disable-next-line @next/next/no-img-element */}\n              <img src={src} alt=\"\" className=\"h-full w-full object-cover\" />\n            </li>\n          ))}\n        </ul>\n      </div>\n\n      {/* Teaser tab, left after closing without signing up. A zero-height sticky rail keeps it\n          in the bottom corner of the screen while the section is in view, however tall it is. */}\n      <div className=\"pointer-events-none sticky bottom-5 z-10 h-0\">\n        <AnimatePresence>\n          {teaser && !open && step === \"form\" && (\n            <motion.div\n              key=\"teaser\"\n              className=\"pointer-events-auto absolute bottom-0 left-5 flex items-center rounded-full shadow-[0_16px_40px_-12px_rgba(0,0,0,0.6)]\"\n              style={{ background: p.buttonBg, color: p.buttonText }}\n              initial={reduce ? false : { opacity: 0, y: 20, scale: 0.9 }}\n              animate={{ opacity: 1, y: 0, scale: 1 }}\n              exit={reduce ? undefined : { opacity: 0, y: 12 }}\n              transition={{ type: \"spring\", stiffness: 380, damping: 26 }}\n            >\n              <button ref={teaserRef} type=\"button\" onClick={reopen} className={cn(\"flex h-11 cursor-pointer items-center gap-2 rounded-full border-0 bg-transparent pr-2 pl-4 text-[13px] font-semibold outline-none focus-visible:ring-2 focus-visible:ring-inset\")} style={{ color: p.buttonText, ...ring }}>\n                <span className=\"grid h-6 w-6 place-items-center rounded-full text-[11px] font-bold\" style={{ background: p.accent, color: \"#0B1A08\" }} aria-hidden=\"true\">\n                  %\n                </span>\n                {discount}% off your first order\n              </button>\n              <button type=\"button\" onClick={() => setTeaser(false)} aria-label=\"Dismiss offer\" className={cn(\"mr-1.5 grid h-8 w-8 cursor-pointer place-items-center rounded-full border-0 bg-transparent outline-none focus-visible:ring-2 focus-visible:ring-inset\")} style={{ color: p.buttonText, ...ring }}>\n                <svg width=\"12\" height=\"12\" 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            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n\n      <AnimatePresence>\n        {open && (\n          <motion.div\n            key=\"scrim\"\n            className=\"absolute inset-0 z-20 flex items-start justify-center overflow-y-auto px-3 py-6 backdrop-blur-[3px]\"\n            style={{ background: p.scrim }}\n            initial={reduce ? false : { opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={reduce ? undefined : { opacity: 0 }}\n            onMouseDown={(e) => e.target === e.currentTarget && close()}\n          >\n            <motion.div\n              role=\"dialog\"\n              aria-modal=\"true\"\n              aria-labelledby={`${uid}-t`}\n              className=\"relative my-auto grid w-full max-w-[800px] grid-cols-1 overflow-hidden rounded-3xl border shadow-[0_40px_90px_-30px_rgba(0,0,0,0.8)] @[680px]:grid-cols-[0.95fr_1.05fr]\"\n              style={{ background: p.panel, borderColor: p.line }}\n              initial={reduce ? false : { opacity: 0, y: 30, scale: 0.94 }}\n              animate={{ opacity: 1, y: 0, scale: 1 }}\n              exit={reduce ? undefined : { opacity: 0, y: 16, scale: 0.97 }}\n              transition={{ type: \"spring\", stiffness: 300, damping: 28 }}\n            >\n              {/* The letter */}\n              <div className=\"relative hidden items-center justify-center overflow-hidden px-8 py-10 @[680px]:flex\" style={{ background: theme === \"dark\" ? \"#1A1A1A\" : \"#EFEDE7\" }}>\n                <span\n                  aria-hidden=\"true\"\n                  className=\"absolute h-[78%] w-[72%] rounded-md\"\n                  style={{\n                    background: \"#EDEAE2\",\n                    transform: \"rotate(-5deg) translate(-14px, 8px)\",\n                    boxShadow: \"0 10px 30px -12px rgba(0,0,0,0.35)\",\n                  }}\n                />\n                <motion.article\n                  aria-label={`Sample: issue ${issue.number}`}\n                  className=\"relative w-[86%] max-w-[300px] rounded-md p-4\"\n                  style={{\n                    background: PAPER.bg,\n                    color: PAPER.ink,\n                    boxShadow: \"0 24px 50px -18px rgba(0,0,0,0.5)\",\n                  }}\n                  initial={reduce ? false : { rotate: 6, y: 30, opacity: 0 }}\n                  animate={{ rotate: 2, y: 0, opacity: 1 }}\n                  transition={{\n                    type: \"spring\",\n                    stiffness: 160,\n                    damping: 18,\n                    delay: reduce ? 0 : 0.15,\n                  }}\n                >\n                  <p className=\"m-0 flex justify-between border-b pb-2 font-mono text-[9.5px] tracking-[0.14em] uppercase\" style={{ borderColor: PAPER.rule, color: PAPER.soft }}>\n                    <span>The {store} Letter</span>\n                    <span>No. {issue.number}</span>\n                  </p>\n                  <p className=\"m-0 mt-3 font-serif text-[19px] leading-[1.15] tracking-[-0.01em]\">{issue.title}</p>\n                  <ul className=\"m-0 mt-3 grid list-none grid-cols-2 gap-1.5 p-0\">\n                    {issue.images.slice(0, 4).map((src) => (\n                      <li key={src} className=\"aspect-[4/3] overflow-hidden rounded-[3px]\" style={{ background: \"#F1F1F1\" }}>\n                        {/* eslint-disable-next-line @next/next/no-img-element */}\n                        <img src={src} alt=\"\" className=\"h-full w-full object-cover\" />\n                      </li>\n                    ))}\n                  </ul>\n                  <div className=\"mt-3 space-y-1.5\" aria-hidden=\"true\">\n                    <span className=\"block h-1.5 w-full rounded-full\" style={{ background: PAPER.rule }} />\n                    <span className=\"block h-1.5 w-4/5 rounded-full\" style={{ background: PAPER.rule }} />\n                  </div>\n                  <p className=\"m-0 mt-3 font-mono text-[9.5px] tracking-[0.1em] uppercase\" style={{ color: PAPER.soft }}>\n                    {frequency === \"weekly\" ? \"Every Thursday\" : \"Only when something new lands\"} · unsubscribe anytime\n                  </p>\n                  <AnimatePresence>\n                    {done && (\n                      <motion.span\n                        key=\"stamp\"\n                        aria-hidden=\"true\"\n                        className=\"absolute -right-5 bottom-10 grid h-[92px] w-[92px] place-items-center rounded-full border-[3px] text-center font-mono text-[11px] leading-tight font-bold tracking-[0.1em] uppercase\"\n                        style={{\n                          borderColor: PAPER.stamp,\n                          color: PAPER.stamp,\n                          background: \"rgba(250,248,243,0.75)\",\n                          boxShadow: `inset 0 0 0 4px rgba(250,248,243,0.75), inset 0 0 0 5px ${PAPER.stamp}`,\n                        }}\n                        initial={reduce ? false : { scale: 2.2, opacity: 0, rotate: -40 }}\n                        animate={{ scale: 1, opacity: 0.92, rotate: -14 }}\n                        transition={{\n                          type: \"spring\",\n                          stiffness: 420,\n                          damping: 18,\n                        }}\n                      >\n                        You&apos;re\n                        <br />\n                        in\n                      </motion.span>\n                    )}\n                  </AnimatePresence>\n                </motion.article>\n              </div>\n\n              {/* Form / result */}\n              <div className=\"relative p-6 @[640px]:p-8\">\n                <button\n                  type=\"button\"\n                  ref={focusOnce}\n                  onClick={close}\n                  aria-label=\"Close\"\n                  className={cn(\"absolute top-4 right-4 grid h-9 w-9 cursor-pointer place-items-center rounded-full border-0\", focus)}\n                  style={{ background: p.line, color: p.title, ...ring }}\n                >\n                  <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                    <path d=\"M6 6l12 12M18 6 6 18\" />\n                  </svg>\n                </button>\n\n                <AnimatePresence mode=\"popLayout\" initial={false}>\n                  {!done ? (\n                    <motion.form\n                      key=\"form\"\n                      noValidate\n                      onSubmit={submit}\n                      initial={reduce ? false : { opacity: 0, x: 24 }}\n                      animate={{ opacity: 1, x: 0 }}\n                      exit={reduce ? undefined : { opacity: 0, x: -24 }}\n                      transition={{ duration: 0.25, ease: [0.22, 1, 0.36, 1] }}\n                    >\n                      <p className=\"m-0 font-mono text-[11px] tracking-[0.14em] uppercase\" style={{ color: p.accent }}>\n                        The {store} Letter\n                      </p>\n                      <h2 id={`${uid}-t`} className=\"m-0 mt-2 pr-10 text-[27px] leading-[1.1] font-semibold tracking-[-0.02em]\">\n                        {discount}% off when you join the list.\n                      </h2>\n                      <p className=\"m-0 mt-2 text-[14px] leading-relaxed\" style={{ color: p.body }}>\n                        New drops first, honest gear notes, no spam. Your code arrives the moment you sign up.\n                      </p>\n\n                      <fieldset className=\"m-0 mt-5 border-0 p-0\">\n                        <legend className=\"mb-2 text-[12px] font-medium\" style={{ color: p.muted }}>\n                          How often?\n                        </legend>\n                        <div role=\"radiogroup\" aria-label=\"How often\" className=\"grid grid-cols-2 gap-2\">\n                          {FREQUENCIES.map((f) => {\n                            const on = frequency === f.id;\n                            return (\n                              <button\n                                key={f.id}\n                                type=\"button\"\n                                role=\"radio\"\n                                aria-checked={on}\n                                onClick={() => setFrequency(f.id)}\n                                className={cn(\"relative cursor-pointer rounded-xl border px-3 py-2.5 text-left\", focus)}\n                                style={{\n                                  borderColor: on ? p.accent : p.line,\n                                  background: on ? (theme === \"dark\" ? \"rgba(124,222,106,0.08)\" : \"rgba(47,158,68,0.06)\") : \"transparent\",\n                                  color: p.title,\n                                  ...ring,\n                                }}\n                              >\n                                <span className=\"flex items-center gap-2 text-[13.5px] font-semibold\">\n                                  <span\n                                    className=\"grid h-4 w-4 shrink-0 place-items-center rounded-full border-[1.5px]\"\n                                    style={{\n                                      borderColor: on ? p.accent : p.muted,\n                                    }}\n                                    aria-hidden=\"true\"\n                                  >\n                                    {on && <motion.span layoutId={`${uid}-dot`} className=\"h-2 w-2 rounded-full\" style={{ background: p.accent }} />}\n                                  </span>\n                                  {f.label}\n                                </span>\n                                <span className=\"mt-0.5 block pl-6 text-[12px]\" style={{ color: p.muted }}>\n                                  {f.detail}\n                                </span>\n                              </button>\n                            );\n                          })}\n                        </div>\n                      </fieldset>\n\n                      <fieldset className=\"m-0 mt-4 border-0 p-0\">\n                        <legend className=\"mb-2 text-[12px] font-medium\" style={{ color: p.muted }}>\n                          Into anything in particular? <span style={{ color: p.muted }}>(optional)</span>\n                        </legend>\n                        <div className=\"flex flex-wrap gap-1.5\">\n                          {interests.map((x) => {\n                            const on = picked.includes(x);\n                            return (\n                              <motion.button\n                                key={x}\n                                type=\"button\"\n                                aria-pressed={on}\n                                onClick={() => toggle(x)}\n                                whileTap={reduce ? undefined : { scale: 0.94 }}\n                                className={cn(\"flex h-8 cursor-pointer items-center gap-1.5 rounded-full border px-3 text-[12.5px] font-medium\", focus)}\n                                style={{\n                                  borderColor: on ? p.title : p.line,\n                                  background: on ? p.title : \"transparent\",\n                                  color: on ? p.bg : p.body,\n                                  ...ring,\n                                }}\n                              >\n                                {on && (\n                                  <svg width=\"11\" height=\"11\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                    <path d=\"m5 12 5 5 9-10\" />\n                                  </svg>\n                                )}\n                                {x}\n                              </motion.button>\n                            );\n                          })}\n                        </div>\n                      </fieldset>\n\n                      <label htmlFor={`${uid}-email`} className=\"mt-5 block text-[12px] font-medium\" style={{ color: p.muted }}>\n                        Email\n                      </label>\n                      <div className=\"mt-1.5 flex flex-col gap-2 @[440px]:flex-row\">\n                        <motion.input\n                          ref={emailRef}\n                          id={`${uid}-email`}\n                          type=\"email\"\n                          autoComplete=\"email\"\n                          inputMode=\"email\"\n                          value={email}\n                          onChange={(e) => {\n                            setEmail(e.target.value);\n                            if (error) setError(null);\n                          }}\n                          placeholder=\"you@example.com\"\n                          aria-invalid={!!error}\n                          aria-describedby={error ? `${uid}-err` : undefined}\n                          animate={error && !reduce ? { x: [0, -6, 6, -4, 4, 0] } : { x: 0 }}\n                          transition={{ duration: 0.35 }}\n                          className=\"h-12 w-full min-w-0 rounded-xl border px-3.5 text-[14.5px] outline-none focus:border-[var(--fc)] @[440px]:flex-1\"\n                          style={{\n                            background: p.input,\n                            borderColor: error ? p.error : p.line,\n                            color: p.title,\n                            [\"--fc\" as string]: error ? p.error : p.title,\n                          }}\n                        />\n                        <button\n                          type=\"submit\"\n                          disabled={busy}\n                          className={cn(\"relative h-12 shrink-0 cursor-pointer overflow-hidden rounded-xl border-0 px-5 text-[14px] font-semibold disabled:cursor-wait\", focus)}\n                          style={{\n                            background: p.buttonBg,\n                            color: p.buttonText,\n                            ...ring,\n                          }}\n                        >\n                          <AnimatePresence mode=\"wait\" initial={false}>\n                            <motion.span\n                              key={busy ? \"busy\" : \"idle\"}\n                              className=\"flex items-center justify-center gap-2\"\n                              initial={reduce ? false : { y: 12, opacity: 0 }}\n                              animate={{ y: 0, opacity: 1 }}\n                              exit={reduce ? undefined : { y: -12, opacity: 0 }}\n                              transition={{ duration: 0.18 }}\n                            >\n                              {busy ? (\n                                <>\n                                  <motion.span\n                                    className=\"h-4 w-4 rounded-full border-2\"\n                                    style={{\n                                      borderColor: \"currentColor\",\n                                      borderTopColor: \"transparent\",\n                                    }}\n                                    animate={reduce ? undefined : { rotate: 360 }}\n                                    transition={{\n                                      duration: 0.8,\n                                      repeat: Infinity,\n                                      ease: \"linear\",\n                                    }}\n                                    aria-hidden=\"true\"\n                                  />\n                                  Joining…\n                                </>\n                              ) : (\n                                <>Get my {discount}% off</>\n                              )}\n                            </motion.span>\n                          </AnimatePresence>\n                        </button>\n                      </div>\n                      <p id={`${uid}-err`} role=\"alert\" className=\"m-0 mt-2 min-h-[18px] text-[12.5px]\" style={{ color: p.error }}>\n                        {error}\n                      </p>\n                      <div className=\"mt-1 flex items-center justify-between gap-3\">\n                        <p className=\"m-0 text-[11.5px]\" style={{ color: p.muted }}>\n                          One-click unsubscribe. We never share your email.\n                        </p>\n                        <button type=\"button\" onClick={close} className={cn(\"shrink-0 cursor-pointer rounded border-0 bg-transparent p-0 text-[12.5px] underline underline-offset-4\", focus)} style={{ color: p.body, ...ring }}>\n                          Not now\n                        </button>\n                      </div>\n                    </motion.form>\n                  ) : (\n                    <motion.div key=\"done\" initial={reduce ? false : { opacity: 0, x: 24 }} animate={{ opacity: 1, x: 0 }} transition={{ duration: 0.3, ease: [0.22, 1, 0.36, 1] }}>\n                      <p className=\"m-0 font-mono text-[11px] tracking-[0.14em] uppercase\" style={{ color: p.accent }}>\n                        Welcome to the list\n                      </p>\n                      <h2 id={`${uid}-t`} className=\"m-0 mt-2 pr-10 text-[27px] leading-[1.1] font-semibold tracking-[-0.02em]\">\n                        Here&apos;s your {discount}% off.\n                      </h2>\n                      <p className=\"m-0 mt-2 text-[14px] leading-relaxed\" style={{ color: p.body }}>\n                        We also sent it to <span style={{ color: p.title }}>{email.trim()}</span>. Confirm your email so {frequency === \"weekly\" ? \"the Thursday letter reaches you\" : \"drop alerts reach you\"}.\n                      </p>\n\n                      {/* Ticket */}\n                      <motion.div\n                        className=\"relative mt-5 flex overflow-hidden rounded-2xl\"\n                        style={{\n                          background: p.ticket,\n                          color: p.ticketText,\n                          WebkitMask: \"radial-gradient(circle 11px at 34% 0, transparent 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 11px at 34% 100%, transparent 98%, #000) bottom / 100% 51% no-repeat\",\n                          mask: \"radial-gradient(circle 11px at 34% 0, transparent 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 11px at 34% 100%, transparent 98%, #000) bottom / 100% 51% no-repeat\",\n                        }}\n                        initial={reduce ? false : { y: 40, rotate: -4, opacity: 0 }}\n                        animate={{ y: 0, rotate: 0, opacity: 1 }}\n                        transition={{\n                          type: \"spring\",\n                          stiffness: 260,\n                          damping: 20,\n                          delay: reduce ? 0 : 0.2,\n                        }}\n                      >\n                        {!reduce && (\n                          <motion.span\n                            aria-hidden=\"true\"\n                            className=\"pointer-events-none absolute inset-y-0 w-1/3\"\n                            style={{\n                              background: \"linear-gradient(100deg, transparent, rgba(255,255,255,0.45), transparent)\",\n                            }}\n                            initial={{ x: \"-120%\" }}\n                            animate={{ x: \"380%\" }}\n                            transition={{\n                              duration: 1.1,\n                              delay: 0.7,\n                              ease: \"easeInOut\",\n                            }}\n                          />\n                        )}\n                        <div className=\"flex w-[34%] flex-col items-center justify-center border-r-2 border-dashed px-2 py-5\" style={{ borderColor: \"currentColor\" }}>\n                          <span className=\"text-[34px] leading-none font-bold tracking-[-0.04em] tabular-nums\">{discount}%</span>\n                          <span className=\"mt-1 text-[11px] font-semibold tracking-[0.12em] uppercase opacity-75\">off</span>\n                        </div>\n                        <div className=\"flex min-w-0 flex-1 flex-col justify-center gap-2 px-4 py-4\">\n                          <span className=\"text-[11px] font-semibold tracking-[0.12em] uppercase opacity-70\">Your code</span>\n                          <span className=\"flex items-center gap-2\">\n                            <span className=\"truncate font-mono text-[20px] font-bold tracking-[0.08em]\">{code}</span>\n                            <button\n                              type=\"button\"\n                              ref={focusOnce}\n                              onClick={copy}\n                              className={cn(\"h-8 shrink-0 cursor-pointer rounded-full border-0 px-3 text-[12px] font-semibold\", focus)}\n                              style={{\n                                background: p.ticketText,\n                                color: p.ticket,\n                                ...ring,\n                              }}\n                            >\n                              {copied ? \"Copied ✓\" : \"Copy\"}\n                            </button>\n                          </span>\n                          <span className=\"font-mono text-[11.5px] tabular-nums opacity-75\" aria-label={`Expires in ${countdown}`}>\n                            Expires in {countdown}\n                          </span>\n                        </div>\n                      </motion.div>\n                      <p className=\"sr-only\" aria-live=\"polite\">\n                        {copied ? \"Code copied\" : applied ? \"Code applied to your cart\" : \"\"}\n                      </p>\n\n                      <div className=\"mt-5 flex flex-wrap gap-2\">\n                        <button\n                          type=\"button\"\n                          onClick={() => {\n                            setApplied(true);\n                            onApply?.(code);\n                          }}\n                          disabled={applied}\n                          className={cn(\"flex h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-xl border-0 px-5 text-[14px] font-semibold disabled:cursor-default\", focus)}\n                          style={{\n                            background: p.buttonBg,\n                            color: p.buttonText,\n                            ...ring,\n                          }}\n                        >\n                          {applied ? (\n                            <>\n                              <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                <path d=\"m5 12 5 5 9-10\" />\n                              </svg>\n                              Applied to your cart\n                            </>\n                          ) : (\n                            \"Apply to cart\"\n                          )}\n                        </button>\n                        <button\n                          type=\"button\"\n                          onClick={() => setOpen(false)}\n                          className={cn(\"h-11 cursor-pointer rounded-xl border bg-transparent px-5 text-[14px] font-medium\", focus)}\n                          style={{\n                            borderColor: p.line,\n                            color: p.title,\n                            ...ring,\n                          }}\n                        >\n                          Keep shopping\n                        </button>\n                      </div>\n                      {picked.length > 0 && (\n                        <p className=\"m-0 mt-4 text-[12px]\" style={{ color: p.muted }}>\n                          We&apos;ll lean on {picked.join(\", \").replace(/, ([^,]*)$/, \" and $1\")} in your letters.\n                        </p>\n                      )}\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </div>\n            </motion.div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}