{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "verify-email-card",
  "title": "Verify Email Card",
  "description": "A check-your-inbox screen after sign-up: an animated envelope with a sent counter, the masked address with an inline fix for typos, open email app, an I've-clicked-the-link check that tells people when it isn't done yet, a resend with cooldown and limit, tips for finding the email, and a verified state with a small burst.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/verify-email-card/verify-email-card.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 VerifyEmailCardProps {\n  email?: string;\n  sender?: string;\n  /** Return true once the address is verified. The demo says no the first time. */\n  onCheck?: () => Promise<boolean> | boolean;\n  onResend?: (email: string) => Promise<void> | void;\n  onChangeEmail?: (email: string) => Promise<void> | void;\n  onContinue?: () => void;\n  resendSeconds?: number;\n  maxResends?: number;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.55)\", faint: \"rgba(245,244,241,0.3)\", panel: \"#0E0E0E\", border: \"rgba(255,255,255,0.1)\", field: \"rgba(255,255,255,0.03)\", fieldBorder: \"rgba(255,255,255,0.12)\", focus: \"rgba(245,244,241,0.85)\", primary: \"#F5F4F1\", onPrimary: \"#0A0A0A\", well: \"rgba(255,255,255,0.04)\", env: \"#1A1A1A\", envLine: \"rgba(255,255,255,0.18)\", paper: \"#F5F4F1\", error: \"#FF7A6B\", ok: \"#3FBF7F\", warn: \"#F5C451\", ring: \"rgba(245,244,241,0.6)\" },\n  light: { bg: \"#F4F4F1\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.55)\", faint: \"rgba(10,10,10,0.3)\", panel: \"#FFFFFF\", border: \"rgba(10,10,10,0.1)\", field: \"#FFFFFF\", fieldBorder: \"rgba(10,10,10,0.16)\", focus: \"rgba(10,10,10,0.85)\", primary: \"#0A0A0A\", onPrimary: \"#FFFFFF\", well: \"rgba(10,10,10,0.03)\", env: \"#EDEDEA\", envLine: \"rgba(10,10,10,0.18)\", paper: \"#FFFFFF\", error: \"#E5484D\", ok: \"#1F9D5C\", warn: \"#B7791F\", ring: \"rgba(10,10,10,0.5)\" },\n};\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\nconst mask = (e: string) => e.replace(/^(.)(.*)(@.*)$/, (_, a: string, b: string, c: string) => `${a}${\"•\".repeat(Math.min(5, Math.max(1, b.length)))}${c}`);\nconst clock = (s: number) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, \"0\")}`;\nconst CONFETTI = Array.from({ length: 14 }, (_, i) => ({ a: (i / 14) * Math.PI * 2, d: 46 + (i % 3) * 14, c: [\"#60A5FA\", \"#3FBF7F\", \"#F5C451\", \"#F472B6\"][i % 4] }));\n\nexport function VerifyEmailCard({ email: email0 = \"lena@nexora.io\", sender = \"noreply@nexora.io\", onCheck, onResend, onChangeEmail, onContinue, resendSeconds = 30, maxResends = 3, theme = \"dark\", className }: VerifyEmailCardProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [email, setEmail] = React.useState(email0);\n  const [status, setStatus] = React.useState<\"waiting\" | \"checking\" | \"notyet\" | \"verified\">(\"waiting\");\n  const [checks, setChecks] = React.useState(0);\n  const [cooldown, setCooldown] = React.useState(resendSeconds);\n  const [sent, setSent] = React.useState(1);\n  const [editing, setEditing] = React.useState(false);\n  const [draft, setDraft] = React.useState(email0);\n  const [tips, setTips] = React.useState(false);\n  const [toast, setToast] = React.useState<string | null>(null);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const focusSelect = React.useCallback((el: HTMLInputElement | null) => {\n    el?.focus({ preventScroll: true });\n    el?.select();\n  }, []);\n\n  React.useEffect(() => {\n    if (status === \"verified\") return;\n    const id = setInterval(() => setCooldown((s) => Math.max(0, s - 1)), 1000);\n    return () => clearInterval(id);\n  }, [status]);\n  React.useEffect(() => {\n    if (!toast) return;\n    const t = setTimeout(() => setToast(null), 2400);\n    return () => clearTimeout(t);\n  }, [toast]);\n  React.useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    [],\n  );\n\n  const check = async () => {\n    setStatus(\"checking\");\n    const n = checks + 1;\n    setChecks(n);\n    const ok = onCheck\n      ? await onCheck()\n      : await new Promise<boolean>((resolve) => {\n          timer.current = setTimeout(() => resolve(n >= 2), reduce ? 0 : 900);\n        });\n    setStatus(ok ? \"verified\" : \"notyet\");\n  };\n  const resend = async () => {\n    if (cooldown > 0 || sent >= maxResends) return;\n    await onResend?.(email);\n    setSent((s) => s + 1);\n    setCooldown(resendSeconds);\n    setToast(`Sent again to ${mask(email)}`);\n  };\n  const saveEmail = async () => {\n    if (!EMAIL.test(draft) || draft === email) return;\n    await onChangeEmail?.(draft);\n    setEmail(draft);\n    setEditing(false);\n    setSent(1);\n    setCooldown(resendSeconds);\n    setStatus(\"waiting\");\n    setToast(`Link sent to ${mask(draft)}`);\n  };\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 primary = cn(\"flex h-11 w-full cursor-pointer items-center justify-center gap-2 rounded-xl border-0 text-[14px] font-semibold disabled:cursor-wait\", focus);\n  const secondary = cn(\"flex h-11 w-full cursor-pointer items-center justify-center gap-2 rounded-xl border bg-transparent text-[14px] font-medium no-underline\", focus);\n  const link = cn(\"cursor-pointer rounded border-0 bg-transparent p-0 text-[13px] underline underline-offset-2 disabled:cursor-default disabled:no-underline\", focus);\n\n  return (\n    <section className={cn(\"@container grid min-h-[680px] w-full place-items-center px-4 py-12\", className)} style={{ background: p.bg, color: p.text }}>\n      <motion.div layout={!reduce} transition={{ duration: 0.25 }} className=\"w-full max-w-[400px] overflow-hidden rounded-2xl border p-6 text-center @[480px]:p-8\" style={{ background: p.panel, borderColor: p.border }}>\n        <AnimatePresence mode=\"wait\" initial={false}>\n          {status === \"verified\" ? (\n            <motion.div key=\"ok\" initial={reduce ? false : { opacity: 0, scale: 0.97 }} animate={{ opacity: 1, scale: 1 }} className=\"flex flex-col items-center py-2\" role=\"status\">\n              <span className=\"relative grid h-16 w-16 place-items-center\">\n                {!reduce &&\n                  CONFETTI.map((c, i) => (\n                    <motion.span key={i} className=\"absolute h-1.5 w-1.5 rounded-full\" style={{ background: c.c }} initial={{ x: 0, y: 0, opacity: 1, scale: 1 }} animate={{ x: Math.cos(c.a) * c.d, y: Math.sin(c.a) * c.d, opacity: 0, scale: 0.6 }} transition={{ duration: 0.9, ease: \"easeOut\", delay: 0.05 }} aria-hidden=\"true\" />\n                  ))}\n                <motion.span className=\"grid h-16 w-16 place-items-center rounded-full\" style={{ background: `${p.ok}22`, color: p.ok }} initial={reduce ? false : { scale: 0.5 }} animate={{ scale: 1 }} transition={{ type: \"spring\", stiffness: 420, damping: 15 }}>\n                  <svg width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <motion.path d=\"m5 12.5 4.5 4.5L19 7.5\" initial={reduce ? false : { pathLength: 0 }} animate={{ pathLength: 1 }} transition={{ duration: 0.35, delay: 0.1 }} />\n                  </svg>\n                </motion.span>\n              </span>\n              <h2 className=\"m-0 mt-5 text-[22px] font-semibold tracking-[-0.02em]\">Email verified</h2>\n              <p className=\"m-0 mt-2 text-[14px] leading-relaxed\" style={{ color: p.muted }}>\n                <span style={{ color: p.text }}>{email}</span> is confirmed. Your account is ready.\n              </p>\n              <button\n                type=\"button\"\n                onClick={() => {\n                  if (onContinue) onContinue();\n                  else {\n                    setStatus(\"waiting\");\n                    setChecks(0);\n                  }\n                }}\n                className={cn(primary, \"mt-6\")}\n                style={{ background: p.primary, color: p.onPrimary, ...ring }}\n              >\n                Continue to Nexora\n              </button>\n            </motion.div>\n          ) : (\n            <motion.div key=\"wait\" initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }}>\n              {/* Envelope */}\n              <div className=\"relative mx-auto h-24 w-32\" aria-hidden=\"true\">\n                <svg width=\"128\" height=\"96\" viewBox=\"0 0 128 96\" className=\"absolute inset-0 overflow-visible\">\n                  <rect x=\"14\" y=\"34\" width=\"100\" height=\"58\" rx=\"8\" fill={p.env} stroke={p.envLine} />\n                  <motion.g animate={reduce ? undefined : { y: [14, -6, -6, 14] }} transition={{ duration: 3.2, repeat: Infinity, times: [0, 0.35, 0.75, 1], ease: \"easeInOut\" }}>\n                    <rect x=\"26\" y=\"22\" width=\"76\" height=\"52\" rx=\"5\" fill={p.paper} />\n                    <rect x=\"36\" y=\"34\" width=\"38\" height=\"4\" rx=\"2\" fill=\"#0A0A0A\" opacity=\"0.18\" />\n                    <rect x=\"36\" y=\"43\" width=\"54\" height=\"4\" rx=\"2\" fill=\"#0A0A0A\" opacity=\"0.12\" />\n                    <rect x=\"36\" y=\"54\" width=\"28\" height=\"9\" rx=\"4.5\" fill=\"#60A5FA\" />\n                  </motion.g>\n                  <path d=\"M14 46 64 72l50-26v38a8 8 0 0 1-8 8H22a8 8 0 0 1-8-8Z\" fill={p.env} stroke={p.envLine} />\n                  <path d=\"M14 88 52 62M114 88 76 62\" stroke={p.envLine} />\n                </svg>\n                <motion.span className=\"absolute top-6 right-2 grid h-6 min-w-6 place-items-center rounded-full px-1.5 text-[11px] font-semibold text-white\" style={{ background: \"#F87171\" }} initial={false} animate={{ scale: [1, 1.15, 1] }} transition={{ duration: 0.4 }} key={sent}>\n                  {sent}\n                </motion.span>\n              </div>\n\n              <h2 className=\"m-0 mt-5 text-[22px] font-semibold tracking-[-0.02em]\">Verify your email</h2>\n              <AnimatePresence mode=\"wait\" initial={false}>\n                {editing ? (\n                  <motion.form\n                    key=\"edit\"\n                    initial={reduce ? false : { opacity: 0, height: 0 }}\n                    animate={{ opacity: 1, height: \"auto\" }}\n                    exit={reduce ? undefined : { opacity: 0, height: 0 }}\n                    className=\"overflow-hidden text-left\"\n                    onSubmit={(e) => {\n                      e.preventDefault();\n                      void saveEmail();\n                    }}\n                  >\n                    <label htmlFor={`${uid}-em`} className=\"mt-4 block text-[13px] font-medium\">\n                      New email address\n                    </label>\n                    <input id={`${uid}-em`} ref={focusSelect} type=\"email\" value={draft} onChange={(e) => setDraft(e.target.value)} onKeyDown={(e) => e.key === \"Escape\" && setEditing(false)} autoComplete=\"email\" aria-invalid={!!draft && !EMAIL.test(draft)} className={cn(\"mt-1.5 h-11 w-full rounded-xl border px-3.5 text-[14px]\", focus)} style={{ borderColor: draft && !EMAIL.test(draft) ? p.error : p.fieldBorder, background: p.field, color: p.text, ...ring }} />\n                    <div className=\"mt-3 flex gap-2\">\n                      <button type=\"button\" onClick={() => setEditing(false)} className={secondary} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                        Cancel\n                      </button>\n                      <button type=\"submit\" disabled={!EMAIL.test(draft) || draft === email} className={cn(primary, \"disabled:cursor-not-allowed disabled:opacity-40\")} style={{ background: p.primary, color: p.onPrimary, ...ring }}>\n                        Update & send\n                      </button>\n                    </div>\n                  </motion.form>\n                ) : (\n                  <motion.p key=\"copy\" initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} exit={reduce ? undefined : { opacity: 0 }} className=\"m-0 mt-2 text-[14px] leading-relaxed\" style={{ color: p.muted }}>\n                    We sent a link to <span style={{ color: p.text }}>{mask(email)}</span>.{\" \"}\n                    <button\n                      type=\"button\"\n                      onClick={() => {\n                        setDraft(email);\n                        setEditing(true);\n                      }}\n                      className={link}\n                      style={{ color: p.text, ...ring }}\n                    >\n                      Wrong address?\n                    </button>\n                    <br />\n                    Click it to activate your account.\n                  </motion.p>\n                )}\n              </AnimatePresence>\n\n              {!editing && (\n                <div className=\"mt-6 flex flex-col gap-2.5\">\n                  <a href={`mailto:${email}`} className={secondary} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                    <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                      <path d=\"M3 7l9 6 9-6M3 6h18v12H3z\" />\n                    </svg>\n                    Open email app\n                  </a>\n                  <button type=\"button\" onClick={() => void check()} disabled={status === \"checking\"} className={primary} style={{ background: p.primary, color: p.onPrimary, ...ring }}>\n                    {status === \"checking\" && <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                    {status === \"checking\" ? \"Checking…\" : \"I've clicked the link\"}\n                  </button>\n                </div>\n              )}\n\n              <div aria-live=\"polite\">\n                <AnimatePresence initial={false}>\n                  {status === \"notyet\" && !editing && (\n                    <motion.p key=\"ny\" initial={reduce ? false : { opacity: 0, height: 0 }} animate={{ opacity: 1, height: \"auto\" }} exit={reduce ? undefined : { opacity: 0, height: 0 }} className=\"m-0 overflow-hidden text-[12.5px]\" style={{ color: p.warn }}>\n                      <span className=\"mt-3 block\">Not verified yet. Open the newest email and click Verify email, then try again.</span>\n                    </motion.p>\n                  )}\n                </AnimatePresence>\n              </div>\n\n              <div className=\"mt-5 flex items-center justify-center gap-1.5 text-[13px]\" style={{ color: p.muted }}>\n                <span>Didn&apos;t get it?</span>\n                {sent >= maxResends ? (\n                  <span style={{ color: p.faint }}>Resend limit reached, try again in an hour</span>\n                ) : cooldown > 0 ? (\n                  <span className=\"tabular-nums\" style={{ color: p.faint }}>\n                    Resend in {clock(cooldown)}\n                  </span>\n                ) : (\n                  <button type=\"button\" onClick={() => void resend()} className={cn(link, \"font-medium\")} style={{ color: p.text, ...ring }}>\n                    Resend email\n                  </button>\n                )}\n              </div>\n\n              <div className=\"mt-5 border-t pt-4 text-left\" style={{ borderColor: p.border }}>\n                <button type=\"button\" onClick={() => setTips((t) => !t)} aria-expanded={tips} aria-controls={`${uid}-tips`} className={cn(\"flex w-full cursor-pointer items-center justify-between rounded border-0 bg-transparent p-0 text-[13px]\", focus)} style={{ color: p.muted, ...ring }}>\n                  Trouble finding it?\n                  <motion.svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" animate={{ rotate: tips ? 180 : 0 }} aria-hidden=\"true\">\n                    <path d=\"m6 9 6 6 6-6\" />\n                  </motion.svg>\n                </button>\n                <AnimatePresence initial={false}>\n                  {tips && (\n                    <motion.ul id={`${uid}-tips`} initial={reduce ? false : { opacity: 0, height: 0 }} animate={{ opacity: 1, height: \"auto\" }} exit={reduce ? undefined : { opacity: 0, height: 0 }} className=\"m-0 list-none overflow-hidden p-0\">\n                      {[`Check spam, promotions and other folders for ${sender}.`, \"Emails can take a minute or two to arrive.\", `Add ${sender} to your contacts, then resend.`, \"Company inboxes sometimes filter new senders. Ask IT or use a personal address.\"].map((t) => (\n                        <li key={t} className=\"mt-2.5 flex gap-2 text-[12.5px] leading-[1.5]\" style={{ color: p.muted }}>\n                          <span className=\"mt-[7px] h-1 w-1 shrink-0 rounded-full\" style={{ background: p.faint }} />\n                          {t}\n                        </li>\n                      ))}\n                    </motion.ul>\n                  )}\n                </AnimatePresence>\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </motion.div>\n      <AnimatePresence>\n        {toast && (\n          <motion.div key={toast} role=\"status\" initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0 }} className=\"mt-4 rounded-full border px-3.5 py-1.5 text-[12.5px]\" style={{ background: p.panel, borderColor: p.border, color: p.text }}>\n            {toast}\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </section>\n  );\n}\n\nexport default VerifyEmailCard;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}