{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "promo-banner-block",
  "title": "Promo Banner Block",
  "description": "A sale banner for store pages: a big headline that rises in word by word, a copyable discount code, a shop button, a live countdown to a real end date (hidden after it ends), terms, and a collage of product photos that drifts with the pointer next to a springy '40% off' sticker.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/promo-banner-block/promo-banner-block.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useMotionValue, useReducedMotion, useSpring, 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 PromoBannerBlockProps {\n  eyebrow?: string;\n  title?: string;\n  highlight?: string;\n  description?: string;\n  code?: string;\n  /** ISO date-time the offer ends. The countdown hides after it. */\n  endsAt?: string;\n  ctaLabel?: string;\n  ctaHref?: string;\n  images?: { src: string; alt: string }[];\n  terms?: string;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", panel: \"#F1F1F1\", text: \"#111111\", muted: \"rgba(17,17,17,0.6)\", line: \"rgba(17,17,17,0.12)\", accent: \"#7CDE6A\", btnBg: \"#111111\", btnText: \"#FFFFFF\", ring: \"rgba(17,17,17,0.5)\", outer: \"#FFFFFF\" },\n  light: { bg: \"#FFFFFF\", panel: \"#111111\", text: \"#FFFFFF\", muted: \"rgba(255,255,255,0.62)\", line: \"rgba(255,255,255,0.14)\", accent: \"#7CDE6A\", btnBg: \"#FFFFFF\", btnText: \"#111111\", ring: \"rgba(255,255,255,0.6)\", outer: \"#111111\" },\n};\nconst IMAGES = [\n  { src: \"/demo/laptop-stand.webp\", alt: \"Laptop stand\" },\n  { src: \"/demo/notebook.webp\", alt: \"Notebook\" },\n  { src: \"/demo/insulated-water-bottle.webp\", alt: \"Water bottle\" },\n];\n\nfunction useCountdown(endsAt: string) {\n  const [now, setNow] = React.useState<number | null>(null);\n  React.useEffect(() => {\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  }, []);\n  if (now === null) return null;\n  const ms = new Date(endsAt).getTime() - now;\n  if (!(ms > 0)) return { done: true, d: 0, h: 0, m: 0, s: 0 };\n  return { done: false, d: Math.floor(ms / 864e5), h: Math.floor(ms / 36e5) % 24, m: Math.floor(ms / 6e4) % 60, s: Math.floor(ms / 1e3) % 60 };\n}\n\nexport function PromoBannerBlock({\n  eyebrow = \"Desk week\",\n  title = \"Up to 40% off\",\n  highlight = \"desk essentials\",\n  description = \"Stands, lamps and notebooks for a better workspace. Use the code at checkout, on top of free shipping.\",\n  code = \"DESK40\",\n  endsAt = \"2026-12-01T00:00:00Z\",\n  ctaLabel = \"Shop the sale\",\n  ctaHref = \"#\",\n  images = IMAGES,\n  terms = \"Ends 30 Nov, 23:59 UTC. Selected items only, while stock lasts.\",\n  theme = \"dark\",\n  className,\n}: PromoBannerBlockProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const left = useCountdown(endsAt);\n  const [copied, setCopied] = React.useState(false);\n  const mx = useMotionValue(0);\n  const my = useMotionValue(0);\n  const sx = useSpring(mx, { stiffness: 120, damping: 18 });\n  const sy = useSpring(my, { stiffness: 120, damping: 18 });\n  const x1 = useTransform(sx, (v) => v * 18);\n  const y1 = useTransform(sy, (v) => v * 14);\n  const x2 = useTransform(sx, (v) => v * -12);\n  const y2 = useTransform(sy, (v) => v * -10);\n  const x3 = useTransform(sx, (v) => v * 8);\n  const y3 = useTransform(sy, (v) => v * -16);\n\n  React.useEffect(() => {\n    if (!copied) return;\n    const t = setTimeout(() => setCopied(false), 1600);\n    return () => clearTimeout(t);\n  }, [copied]);\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.panel } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const pad = (n: number) => String(n).padStart(2, \"0\");\n  const units = left ? [{ v: left.d, l: \"days\" }, { v: left.h, l: \"hrs\" }, { v: left.m, l: \"min\" }, { v: left.s, l: \"sec\" }] : [];\n  const pos = [\n    { cls: \"right-[7%] bottom-[8%] w-[56%]\", x: x1, y: y1, r: -4 },\n    { cls: \"top-[8%] right-[46%] w-[34%]\", x: x2, y: y2, r: 6 },\n    { cls: \"top-[10%] right-[6%] w-[24%]\", x: x3, y: y3, r: -8 },\n  ];\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg }}>\n      <div className=\"mx-auto max-w-6xl px-4 py-10 @[640px]:px-8\">\n        <div\n          className=\"relative grid grid-cols-1 overflow-hidden rounded-[28px] @[860px]:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]\"\n          style={{ background: p.panel, color: p.text }}\n          onPointerMove={(e) => {\n            if (reduce || e.pointerType === \"touch\") return;\n            const r = e.currentTarget.getBoundingClientRect();\n            mx.set(((e.clientX - r.left) / r.width - 0.5) * 2);\n            my.set(((e.clientY - r.top) / r.height - 0.5) * 2);\n          }}\n          onPointerLeave={() => {\n            mx.set(0);\n            my.set(0);\n          }}\n        >\n          <div className=\"relative z-[1] flex flex-col justify-center p-7 @[640px]:p-12\">\n            <span className=\"inline-flex w-fit items-center gap-2 rounded-full px-3 py-1 text-[12px] font-semibold tracking-[0.06em] uppercase\" style={{ background: p.btnBg, color: p.btnText }}>\n              <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: p.accent }} />\n              {eyebrow}\n            </span>\n            <h2 className=\"m-0 mt-5 text-[40px] leading-[0.98] font-semibold tracking-[-0.04em] @[640px]:text-[64px]\">\n              {title.split(\" \").map((w, i) => (\n                <motion.span key={i} className=\"inline-block pr-[0.22em]\" initial={reduce ? false : { opacity: 0, y: \"0.4em\" }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.5, delay: reduce ? 0 : 0.08 * i, ease: [0.22, 1, 0.36, 1] }}>\n                  {w}\n                </motion.span>\n              ))}\n              <span className=\"block\" style={{ color: p.muted }}>\n                {highlight}\n              </span>\n            </h2>\n            <p className=\"m-0 mt-4 max-w-[42ch] text-[15px] leading-relaxed\" style={{ color: p.muted }}>\n              {description}\n            </p>\n\n            <div className=\"mt-6 flex flex-wrap items-center gap-3\">\n              <a href={ctaHref} className={cn(\"group inline-flex h-12 items-center gap-2 rounded-full px-6 text-[15px] font-semibold no-underline\", focus)} style={{ background: p.btnBg, color: p.btnText, ...ring }}>\n                {ctaLabel}\n                <span className=\"transition-transform group-hover:translate-x-1\" aria-hidden=\"true\">\n                  →\n                </span>\n              </a>\n              <button\n                type=\"button\"\n                onClick={() => {\n                  navigator.clipboard?.writeText(code).catch(() => {});\n                  setCopied(true);\n                }}\n                className={cn(\"relative inline-flex h-12 cursor-pointer items-center gap-2.5 rounded-full border border-dashed bg-transparent px-5 text-[14px]\", focus)}\n                style={{ borderColor: p.muted, color: p.text, ...ring }}\n                aria-label={`Copy code ${code}`}\n              >\n                <span style={{ color: p.muted }}>Code</span>\n                <span className=\"font-mono font-semibold tracking-[0.08em]\">{code}</span>\n                <AnimatePresence mode=\"popLayout\" initial={false}>\n                  <motion.span key={copied ? \"y\" : \"n\"} initial={reduce ? false : { opacity: 0, scale: 0.6 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0, scale: 0.6 }} className=\"text-[12px] font-medium\" style={{ color: copied ? \"#2F9E44\" : p.muted }} aria-live=\"polite\">\n                    {copied ? \"✓ Copied\" : \"Copy\"}\n                  </motion.span>\n                </AnimatePresence>\n              </button>\n            </div>\n\n            <div className=\"mt-7 flex min-h-[54px] items-center gap-2\" aria-live=\"off\">\n              {left && !left.done ? (\n                <>\n                  <span className=\"mr-1 text-[12.5px]\" style={{ color: p.muted }}>\n                    Ends in\n                  </span>\n                  {units.map((u) => (\n                    <span key={u.l} className=\"flex w-[52px] flex-col items-center rounded-xl border py-1.5\" style={{ borderColor: p.line }}>\n                      <span className=\"relative h-[22px] overflow-hidden text-[18px] leading-[22px] font-semibold tabular-nums\">\n                        <AnimatePresence mode=\"popLayout\" initial={false}>\n                          <motion.span key={u.v} className=\"block\" initial={reduce ? false : { y: -22 }} animate={{ y: 0 }} exit={reduce ? undefined : { y: 22 }} transition={{ duration: 0.3 }}>\n                            {pad(u.v)}\n                          </motion.span>\n                        </AnimatePresence>\n                      </span>\n                      <span className=\"text-[10.5px]\" style={{ color: p.muted }}>\n                        {u.l}\n                      </span>\n                    </span>\n                  ))}\n                </>\n              ) : left?.done ? (\n                <span className=\"text-[13px]\" style={{ color: p.muted }}>\n                  This offer has ended. New deals every week.\n                </span>\n              ) : null}\n            </div>\n            <p className=\"m-0 mt-3 text-[11.5px]\" style={{ color: p.muted }}>\n              {terms}\n            </p>\n          </div>\n\n          <div className=\"relative min-h-[300px] @[860px]:min-h-[480px]\" aria-hidden=\"true\">\n            {images.slice(0, 3).map((img, i) => (\n              <motion.div key={img.src} className={cn(\"absolute\", pos[i].cls)} style={{ x: pos[i].x, y: pos[i].y }} initial={reduce ? false : { opacity: 0, scale: 0.9, rotate: 0 }} animate={{ opacity: 1, scale: 1, rotate: pos[i].r }} transition={{ duration: 0.7, delay: reduce ? 0 : 0.2 + i * 0.12, ease: [0.22, 1, 0.36, 1] }}>\n                {/* eslint-disable-next-line @next/next/no-img-element */}\n                <img src={img.src} alt=\"\" className=\"block aspect-[4/3] w-full rounded-2xl object-cover shadow-[0_24px_50px_-20px_rgba(0,0,0,0.45)]\" style={{ background: \"#F1F1F1\", outline: `6px solid ${p.outer}` }} />\n              </motion.div>\n            ))}\n            <motion.div className=\"absolute bottom-[10%] left-[4%] grid h-24 w-24 place-items-center rounded-full text-center text-[13px] leading-tight font-semibold @[640px]:h-28 @[640px]:w-28\" style={{ background: p.accent, color: \"#0A0A0A\" }} initial={reduce ? false : { scale: 0, rotate: -40 }} animate={{ scale: 1, rotate: -12 }} transition={{ type: \"spring\", stiffness: 260, damping: 16, delay: reduce ? 0 : 0.6 }}>\n              <span>\n                <span className=\"block text-[26px] leading-none @[640px]:text-[30px]\">40%</span>\n                off\n              </span>\n            </motion.div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default PromoBannerBlock;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}