{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "premium-upgrade-upsell-card",
  "title": "Premium Upgrade Upsell Card",
  "description": "An in-app upgrade card shown near a plan limit: a rotating gradient border, a segmented usage meter, what Pro unlocks, a monthly / yearly switch with an animated per-seat price and savings, a seat stepper with the total, a free-trial button with loading and welcome states, and Maybe later that collapses it into a slim banner.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/premium-upgrade-upsell-card/premium-upgrade-upsell-card.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 PremiumUpgradeUpsellCardProps {\n  used?: number;\n  limit?: number;\n  monthly?: number;\n  yearlyDiscount?: number;\n  trialDays?: number;\n  /** Return a Promise to show the loading state until checkout starts. */\n  onUpgrade?: (plan: { billing: \"monthly\" | \"yearly\"; seats: number; total: number }) => void | Promise<void>;\n  onDismiss?: () => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.38)\", card: \"#111111\", panel: \"#161616\", well: \"rgba(255,255,255,0.04)\", border: \"rgba(255,255,255,0.09)\", track: \"rgba(255,255,255,0.1)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", accent: \"#C4B5FD\", accent2: \"#F9A8D4\", amber: \"#FBBF24\", green: \"#4ADE80\", ring: \"rgba(245,244,241,0.6)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.42)\", card: \"#FFFFFF\", panel: \"#FAF9FF\", well: \"rgba(10,10,10,0.035)\", border: \"rgba(10,10,10,0.1)\", track: \"rgba(10,10,10,0.1)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", accent: \"#7C3AED\", accent2: \"#DB2777\", amber: \"#B45309\", green: \"#15803D\", ring: \"rgba(10,10,10,0.5)\" },\n};\nconst FEATURES = [\n  { label: \"Unlimited projects\", hint: \"No more archiving to make room\", hot: true },\n  { label: \"Version history for 1 year\", hint: \"Restore any change, any time\" },\n  { label: \"Custom domains & branding\", hint: \"Share from your own URL\" },\n  { label: \"Priority support\", hint: \"Replies within 4 hours\" },\n  { label: \"Advanced permissions\", hint: \"Guests, reviewers and admins\" },\n];\n\nfunction Price({ value, reduce }: { value: number; reduce: boolean }) {\n  const mv = useMotionValue(value);\n  const text = useTransform(mv, (v) => `$${Math.round(v)}`);\n  React.useEffect(() => {\n    if (reduce) {\n      mv.set(value);\n      return;\n    }\n    const c = animate(mv, value, { duration: 0.5, 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 PremiumUpgradeUpsellCard({ used = 9, limit = 10, monthly = 16, yearlyDiscount = 0.25, trialDays = 14, onUpgrade, onDismiss, theme = \"dark\", className }: PremiumUpgradeUpsellCardProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [billing, setBilling] = React.useState<\"monthly\" | \"yearly\">(\"yearly\");\n  const [seats, setSeats] = React.useState(3);\n  const [state, setState] = React.useState<\"idle\" | \"loading\" | \"done\" | \"dismissed\">(\"idle\");\n\n  const perSeat = billing === \"yearly\" ? Math.round(monthly * (1 - yearlyDiscount)) : monthly;\n  const total = perSeat * seats;\n  const yearlySave = (monthly - Math.round(monthly * (1 - yearlyDiscount))) * seats * 12;\n  const pct = Math.min(1, used / limit);\n\n  const upgrade = async () => {\n    if (state === \"loading\") return;\n    setState(\"loading\");\n    try {\n      await (onUpgrade ? onUpgrade({ billing, seats, total }) : new Promise((r) => setTimeout(r, reduce ? 0 : 1100)));\n      setState(\"done\");\n    } catch {\n      setState(\"idle\");\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  const grad = `linear-gradient(120deg, ${p.accent}, ${p.accent2})`;\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-3xl px-4 py-10 @[640px]:px-6\">\n        <AnimatePresence mode=\"popLayout\" initial={false}>\n          {state === \"dismissed\" ? (\n            <motion.div key=\"slim\" initial={reduce ? false : { opacity: 0, y: -6 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0 }} className=\"flex flex-wrap items-center gap-3 rounded-xl border px-4 py-3\" style={{ borderColor: p.border, background: p.card }}>\n              <span className=\"grid h-7 w-7 place-items-center rounded-lg text-[13px]\" style={{ background: grad, color: \"#0A0A0A\" }} aria-hidden=\"true\">\n                ✦\n              </span>\n              <span className=\"min-w-0 flex-1 text-[13px]\" style={{ color: p.muted }}>\n                {used} of {limit} projects used. Pro removes the limit.\n              </span>\n              <button type=\"button\" onClick={() => setState(\"idle\")} className={cn(\"h-8 cursor-pointer rounded-lg border bg-transparent px-3 text-[12.5px] font-medium\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                See Pro\n              </button>\n            </motion.div>\n          ) : (\n            <motion.div key=\"card\" initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, scale: 0.98 }} className=\"relative overflow-hidden rounded-2xl p-px\">\n              {/* Moving sheen border */}\n              <span className=\"absolute inset-0 rounded-2xl\" style={{ background: p.border }} aria-hidden=\"true\" />\n              {!reduce && (\n                <motion.span\n                  className=\"absolute top-1/2 left-1/2 aspect-square w-[320%]\"\n                  style={{ background: `conic-gradient(from 0deg, transparent 0deg, ${p.accent} 40deg, ${p.accent2} 80deg, transparent 120deg)`, x: \"-50%\", y: \"-50%\" }}\n                  animate={{ rotate: 360 }}\n                  transition={{ repeat: Infinity, duration: 6, ease: \"linear\" }}\n                  aria-hidden=\"true\"\n                />\n              )}\n              <div className=\"relative grid grid-cols-1 overflow-hidden rounded-[15px] @[640px]:grid-cols-[minmax(0,1fr)_280px]\" style={{ background: p.card }}>\n                <span className=\"pointer-events-none absolute -top-24 -left-16 h-56 w-56 rounded-full opacity-[0.18] blur-3xl\" style={{ background: grad }} aria-hidden=\"true\" />\n                <div className=\"relative p-6\">\n                  <div className=\"flex items-center justify-between gap-3\">\n                    <span className=\"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11.5px] font-semibold\" style={{ background: grad, color: \"#0A0A0A\" }}>\n                      ✦ Nexora Pro\n                    </span>\n                    {state !== \"done\" && (\n                      <button\n                        type=\"button\"\n                        onClick={() => {\n                          setState(\"dismissed\");\n                          onDismiss?.();\n                        }}\n                        className={cn(\"cursor-pointer border-0 bg-transparent p-0 text-[12.5px] underline-offset-2 hover:underline\", focus)}\n                        style={{ color: p.faint, ...ring }}\n                      >\n                        Maybe later\n                      </button>\n                    )}\n                  </div>\n                  <h2 className=\"m-0 mt-4 text-[22px] leading-tight font-semibold tracking-[-0.01em] @[640px]:text-[24px]\">\n                    You&apos;re almost out of projects\n                  </h2>\n                  <p className=\"m-0 mt-1.5 text-[13.5px]\" style={{ color: p.muted }}>\n                    Upgrade to keep building without archiving old work.\n                  </p>\n\n                  <div className=\"mt-5\" role=\"meter\" aria-valuemin={0} aria-valuemax={limit} aria-valuenow={used} aria-label=\"Projects used\">\n                    <div className=\"flex items-baseline justify-between text-[12.5px]\">\n                      <span style={{ color: p.muted }}>Projects on Free</span>\n                      <span className=\"font-medium tabular-nums\" style={{ color: pct >= 0.9 ? p.amber : p.text }}>\n                        {used} / {limit}\n                      </span>\n                    </div>\n                    <div className=\"mt-2 grid gap-1\" style={{ gridTemplateColumns: `repeat(${limit}, minmax(0, 1fr))` }}>\n                      {Array.from({ length: limit }, (_, i) => (\n                        <motion.span key={i} className=\"h-2 rounded-sm\" initial={reduce ? false : { scaleY: 0.3, opacity: 0 }} animate={{ scaleY: 1, opacity: 1 }} transition={{ delay: reduce ? 0 : 0.15 + i * 0.04 }} style={{ background: i < used ? (pct >= 0.9 ? p.amber : p.text) : p.track }} />\n                      ))}\n                    </div>\n                  </div>\n\n                  <ul className=\"m-0 mt-6 grid list-none grid-cols-1 gap-2.5 p-0 @[480px]:grid-cols-2 @[640px]:grid-cols-1\">\n                    {FEATURES.map((f, i) => (\n                      <motion.li key={f.label} initial={reduce ? false : { opacity: 0, x: -6 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: reduce ? 0 : 0.25 + i * 0.06 }} className=\"flex items-start gap-2.5\">\n                        <span className=\"mt-px grid h-[18px] w-[18px] shrink-0 place-items-center rounded-full\" style={{ background: f.hot ? grad : p.well, color: f.hot ? \"#0A0A0A\" : p.accent }}>\n                          <svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                            <path d=\"m5 12.5 4.5 4.5L19 7.5\" />\n                          </svg>\n                        </span>\n                        <span className=\"min-w-0\">\n                          <span className=\"block text-[13.5px] font-medium\">{f.label}</span>\n                          <span className=\"block text-[12px]\" style={{ color: p.faint }}>\n                            {f.hint}\n                          </span>\n                        </span>\n                      </motion.li>\n                    ))}\n                  </ul>\n                </div>\n\n                <div className=\"relative flex flex-col border-t p-6 @[640px]:border-t-0 @[640px]:border-l\" style={{ borderColor: p.border, background: p.panel }}>\n                  <AnimatePresence mode=\"popLayout\" initial={false}>\n                    {state === \"done\" ? (\n                      <motion.div key=\"done\" role=\"status\" initial={reduce ? false : { opacity: 0, scale: 0.96 }} animate={{ opacity: 1, scale: 1 }} className=\"flex flex-1 flex-col items-center justify-center py-6 text-center\">\n                        <motion.span initial={reduce ? false : { scale: 0, rotate: -90 }} animate={{ scale: 1, rotate: 0 }} transition={{ type: \"spring\", stiffness: 380, damping: 18, delay: reduce ? 0 : 0.1 }} className=\"grid h-14 w-14 place-items-center rounded-full text-[22px]\" style={{ background: grad, color: \"#0A0A0A\" }} aria-hidden=\"true\">\n                          ✦\n                        </motion.span>\n                        <p className=\"m-0 mt-4 text-[17px] font-semibold\">Welcome to Pro</p>\n                        <p className=\"m-0 mt-1 text-[13px]\" style={{ color: p.muted }}>\n                          Your {trialDays}-day trial is active for {seats} {seats === 1 ? \"seat\" : \"seats\"}. We&apos;ll remind you 3 days before it ends.\n                        </p>\n                        <a href=\"#\" className={cn(\"mt-5 flex h-9 items-center rounded-lg px-4 text-[13px] font-medium no-underline\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                          Create a project →\n                        </a>\n                      </motion.div>\n                    ) : (\n                      <motion.div key=\"buy\" exit={reduce ? undefined : { opacity: 0, scale: 0.97 }} className=\"flex flex-1 flex-col\">\n                        <div role=\"radiogroup\" aria-label=\"Billing period\" className=\"grid grid-cols-2 rounded-lg border p-0.5\" style={{ borderColor: p.border }}>\n                          {([\"monthly\", \"yearly\"] as const).map((b) => (\n                            <button key={b} type=\"button\" role=\"radio\" aria-checked={billing === b} onClick={() => setBilling(b)} className={cn(\"relative h-8 cursor-pointer rounded-md border-0 bg-transparent text-[12.5px] font-medium capitalize\", focus)} style={{ color: billing === b ? p.onText : p.muted, ...ring }}>\n                              {billing === b && <motion.span layoutId={reduce ? undefined : `${uid}-bill`} className=\"absolute inset-0 rounded-md\" style={{ background: p.on }} transition={{ type: \"spring\", stiffness: 500, damping: 38 }} />}\n                              <span className=\"relative\">\n                                {b}\n                                {b === \"yearly\" && (\n                                  <span className=\"ml-1 text-[10.5px] font-semibold\" style={{ color: billing === b ? p.onText : p.green }}>\n                                    −{Math.round(yearlyDiscount * 100)}%\n                                  </span>\n                                )}\n                              </span>\n                            </button>\n                          ))}\n                        </div>\n\n                        <div className=\"mt-5 flex items-baseline gap-1.5\" aria-live=\"polite\">\n                          <span className=\"text-[40px] leading-none font-semibold tracking-[-0.03em] tabular-nums\">\n                            <Price value={perSeat} reduce={reduce} />\n                          </span>\n                          <span className=\"text-[12.5px]\" style={{ color: p.muted }}>\n                            per seat / month\n                          </span>\n                        </div>\n                        <p className=\"m-0 mt-1 h-4 text-[12px]\" style={{ color: billing === \"yearly\" ? p.green : p.faint }}>\n                          {billing === \"yearly\" ? `Billed yearly · you save $${yearlySave} a year` : \"Billed monthly · cancel any time\"}\n                        </p>\n\n                        <div className=\"mt-5 flex items-center justify-between gap-3\">\n                          <span id={`${uid}-seats`} className=\"text-[13px]\" style={{ color: p.muted }}>\n                            Seats\n                          </span>\n                          <div className=\"flex items-center rounded-lg border\" style={{ borderColor: p.border }} role=\"group\" aria-labelledby={`${uid}-seats`}>\n                            <button type=\"button\" onClick={() => setSeats((s) => Math.max(1, s - 1))} disabled={seats <= 1} aria-label=\"Remove a seat\" className={cn(\"grid h-8 w-8 cursor-pointer place-items-center rounded-l-lg border-0 bg-transparent text-[15px] disabled:cursor-not-allowed disabled:opacity-30\", focus)} style={{ color: p.text, ...ring }}>\n                              −\n                            </button>\n                            <span className=\"w-8 text-center text-[13.5px] font-medium tabular-nums\" aria-live=\"polite\">\n                              {seats}\n                            </span>\n                            <button type=\"button\" onClick={() => setSeats((s) => Math.min(50, s + 1))} aria-label=\"Add a seat\" className={cn(\"grid h-8 w-8 cursor-pointer place-items-center rounded-r-lg border-0 bg-transparent text-[15px]\", focus)} style={{ color: p.text, ...ring }}>\n                              +\n                            </button>\n                          </div>\n                        </div>\n                        <div className=\"mt-3 flex items-baseline justify-between border-t pt-3 text-[13px]\" style={{ borderColor: p.border }}>\n                          <span style={{ color: p.muted }}>After trial</span>\n                          <span className=\"font-semibold tabular-nums\">\n                            <Price value={total} reduce={reduce} />\n                            <span className=\"font-normal\" style={{ color: p.faint }}>\n                              {\" \"}\n                              / month\n                            </span>\n                          </span>\n                        </div>\n\n                        <button type=\"button\" onClick={upgrade} aria-busy={state === \"loading\"} className={cn(\"relative mt-5 flex h-10 w-full cursor-pointer items-center justify-center gap-2 overflow-hidden rounded-lg border-0 text-[13.5px] font-semibold\", focus)} style={{ background: grad, color: \"#0A0A0A\", ...ring }}>\n                          {state === \"loading\" ? (\n                            <>\n                              <motion.span className=\"h-3.5 w-3.5 rounded-full border-2 border-current border-t-transparent\" animate={reduce ? undefined : { rotate: 360 }} transition={{ repeat: Infinity, duration: 0.7, ease: \"linear\" }} aria-hidden=\"true\" />\n                              Starting trial…\n                            </>\n                          ) : (\n                            `Start ${trialDays}-day free trial`\n                          )}\n                        </button>\n                        <p className=\"m-0 mt-2.5 text-center text-[11.5px]\" style={{ color: p.faint }}>\n                          No card needed for the trial\n                        </p>\n                      </motion.div>\n                    )}\n                  </AnimatePresence>\n                </div>\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    </section>\n  );\n}\n\nexport default PremiumUpgradeUpsellCard;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}