{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reset-password-card",
  "title": "Reset Password Card",
  "description": "The screen behind a reset link: it checks the link, then asks for a new password with live rule chips, a confirm field that shows when they match, an expiry countdown and sign out of other devices, and finishes with a countdown into the app. Expired links get their own state with a send-a-new-link flow and resend cooldown.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/reset-password-card/reset-password-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\ntype Step = \"checking\" | \"form\" | \"saving\" | \"done\" | \"expired\" | \"sent\";\n\nexport interface ResetPasswordCardProps {\n  email?: string;\n  linkState?: \"valid\" | \"expired\";\n  /** Seconds left before the link expires. */\n  expiresIn?: number;\n  minLength?: number;\n  onReset?: (password: string, signOutOthers: boolean) => Promise<void> | void;\n  onRequestLink?: (email: string) => Promise<void> | void;\n  onContinue?: () => void;\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\", chip: \"rgba(255,255,255,0.05)\", 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\", chip: \"rgba(10,10,10,0.05)\", error: \"#E5484D\", ok: \"#1F9D5C\", warn: \"#B7791F\", ring: \"rgba(10,10,10,0.5)\" },\n};\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\nconst clock = (s: number) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, \"0\")}`;\n\nexport function ResetPasswordCard({ email: email0 = \"lena@nexora.io\", linkState = \"valid\", expiresIn = 1752, minLength = 10, onReset, onRequestLink, onContinue, theme = \"dark\", className }: ResetPasswordCardProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [step, setStep] = React.useState<Step>(\"checking\");\n  const [pw, setPw] = React.useState(\"\");\n  const [confirm, setConfirm] = React.useState(\"\");\n  const [show, setShow] = React.useState(false);\n  const [signOut, setSignOut] = React.useState(true);\n  const [touched, setTouched] = React.useState(false);\n  const [left, setLeft] = React.useState(expiresIn);\n  const [redirect, setRedirect] = React.useState(3);\n  const [email, setEmail] = React.useState(email0);\n  const [cooldown, setCooldown] = React.useState(0);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  // Pretend to check the token, then show the right screen.\n  React.useEffect(() => {\n    const t = setTimeout(() => setStep(linkState === \"valid\" ? \"form\" : \"expired\"), reduce ? 0 : 700);\n    return () => clearTimeout(t);\n  }, [linkState, reduce]);\n  React.useEffect(() => {\n    const id = setInterval(() => {\n      setLeft((s) => Math.max(0, s - 1));\n      setCooldown((s) => Math.max(0, s - 1));\n    }, 1000);\n    return () => clearInterval(id);\n  }, []);\n  React.useEffect(() => {\n    if (step !== \"form\" || left > 0) return;\n    const t = setTimeout(() => setStep(\"expired\"), 0);\n    return () => clearTimeout(t);\n  }, [step, left]);\n  React.useEffect(() => {\n    if (step !== \"done\") return;\n    if (redirect === 0) {\n      onContinue?.();\n      return;\n    }\n    const t = setTimeout(() => setRedirect((r) => r - 1), 1000);\n    return () => clearTimeout(t);\n  }, [step, redirect, onContinue]);\n  React.useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    [],\n  );\n\n  const rules = [\n    { id: \"len\", label: `${minLength}+ characters`, ok: pw.length >= minLength },\n    { id: \"case\", label: \"Upper & lower case\", ok: /[a-z]/.test(pw) && /[A-Z]/.test(pw) },\n    { id: \"num\", label: \"A number\", ok: /\\d/.test(pw) },\n    { id: \"sym\", label: \"A symbol\", ok: /[^A-Za-z0-9]/.test(pw) },\n  ];\n  const passed = rules.filter((r) => r.ok).length;\n  const strong = passed >= 3 && rules[0].ok;\n  const matches = confirm.length > 0 && confirm === pw;\n  const canSave = strong && matches;\n\n  const run = (fn: (() => Promise<void> | void) | undefined, done: () => void, ms = 800) => {\n    const r = fn?.();\n    if (r instanceof Promise) r.then(done, () => setStep((s) => (s === \"saving\" ? \"form\" : s)));\n    else timer.current = setTimeout(done, reduce ? 0 : ms);\n  };\n  const save = () => {\n    setTouched(true);\n    if (!canSave || step !== \"form\") return;\n    setStep(\"saving\");\n    run(onReset && (() => onReset(pw, signOut)), () => {\n      setRedirect(3);\n      setStep(\"done\");\n    });\n  };\n  const requestLink = () => {\n    if (!EMAIL.test(email) || cooldown > 0) return;\n    setCooldown(30);\n    run(onRequestLink && (() => onRequestLink(email)), () => setStep(\"sent\"), 600);\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(\"mt-5 flex h-11 w-full cursor-pointer items-center justify-center gap-2 rounded-xl border-0 text-[14px] font-semibold disabled:cursor-not-allowed disabled:opacity-40\", focus);\n  const fieldWrap = \"flex h-11 items-center rounded-xl border pr-1 pl-3.5 focus-within:border-[var(--f)]\";\n  // Enter-only: screens swap instantly and the new one fades up.\n  const fade = { initial: reduce ? false : { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.2 } } as const;\n  const tile = (path: string, color: string) => (\n    <span className=\"grid h-11 w-11 place-items-center rounded-xl border\" style={{ borderColor: p.border, color }} aria-hidden=\"true\">\n      <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        <path d={path} />\n      </svg>\n    </span>\n  );\n  const eye = (\n    <button type=\"button\" onClick={() => setShow((s) => !s)} aria-label={show ? \"Hide passwords\" : \"Show passwords\"} aria-pressed={show} className={cn(\"grid h-8 w-8 shrink-0 cursor-pointer place-items-center rounded-lg border-0 bg-transparent\", focus)} style={{ color: p.muted, ...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        {show ? <path d=\"M3 3l18 18M10.6 6.1A9.6 9.6 0 0 1 12 6c5 0 8.5 4.5 9.5 6a17 17 0 0 1-2.6 3.2M6.6 6.6C4.3 8 2.9 10.2 2.5 12c1 1.5 4.5 6 9.5 6 1.6 0 3-.4 4.3-1.1M9.9 9.9a3 3 0 0 0 4.2 4.2\" /> : <path d=\"M2.5 12C3.5 10.5 7 6 12 6s8.5 4.5 9.5 6c-1 1.5-4.5 6-9.5 6s-8.5-4.5-9.5-6ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z\" />}\n      </svg>\n    </button>\n  );\n\n  return (\n    <section className={cn(\"@container grid min-h-[640px] 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 @[480px]:p-8\" style={{ background: p.panel, borderColor: p.border }}>\n        <AnimatePresence mode=\"wait\" initial={false}>\n          {step === \"checking\" && (\n            <motion.div key=\"checking\" {...fade} className=\"flex flex-col items-center gap-3 py-10 text-center\" role=\"status\">\n              <motion.span className=\"h-6 w-6 rounded-full border-2 border-t-transparent\" style={{ borderColor: p.muted, borderTopColor: \"transparent\" }} animate={reduce ? undefined : { rotate: 360 }} transition={{ repeat: Infinity, duration: 0.8, ease: \"linear\" }} />\n              <p className=\"m-0 text-[13.5px]\" style={{ color: p.muted }}>\n                Checking your reset link…\n              </p>\n            </motion.div>\n          )}\n\n          {(step === \"form\" || step === \"saving\") && (\n            <motion.form\n              key=\"form\"\n              {...fade}\n              noValidate\n              onSubmit={(e) => {\n                e.preventDefault();\n                save();\n              }}\n            >\n              {tile(\"M7 11V8a5 5 0 0 1 10 0v3M5 11h14v10H5zM12 15v2\", p.text)}\n              <h2 className=\"m-0 mt-5 text-[22px] font-semibold tracking-[-0.02em]\">Set a new password</h2>\n              <p className=\"m-0 mt-1.5 text-[14px] leading-relaxed\" style={{ color: p.muted }}>\n                for <span style={{ color: p.text }}>{email0}</span>\n              </p>\n              <input type=\"email\" value={email0} readOnly autoComplete=\"username\" className=\"sr-only\" tabIndex={-1} aria-hidden=\"true\" />\n\n              <label htmlFor={`${uid}-pw`} className=\"mt-6 block text-[13px] font-medium\">\n                New password\n              </label>\n              <div className={cn(fieldWrap, \"mt-1.5\")} style={{ borderColor: touched && !strong ? p.error : p.fieldBorder, background: p.field, [\"--f\" as string]: p.focus }}>\n                <input id={`${uid}-pw`} type={show ? \"text\" : \"password\"} value={pw} onChange={(e) => setPw(e.target.value)} autoComplete=\"new-password\" aria-describedby={`${uid}-rules`} aria-invalid={touched && !strong} disabled={step === \"saving\"} className=\"h-full min-w-0 flex-1 border-0 bg-transparent text-[14px] outline-none\" style={{ color: p.text }} />\n                {eye}\n              </div>\n              <ul id={`${uid}-rules`} className=\"m-0 mt-2.5 flex list-none flex-wrap gap-1.5 p-0\" aria-label=\"Password rules\">\n                {rules.map((r) => (\n                  <motion.li key={r.id} layout={!reduce} className=\"flex items-center gap-1 rounded-full px-2 py-0.5 text-[11.5px]\" style={{ background: r.ok ? `${p.ok}1f` : p.chip, color: r.ok ? p.ok : p.muted }} animate={{ scale: r.ok && !reduce ? [1, 1.06, 1] : 1 }} transition={{ duration: 0.25 }}>\n                    {r.ok ? \"✓\" : \"·\"} {r.label}\n                    <span className=\"sr-only\">{r.ok ? \" met\" : \" not met\"}</span>\n                  </motion.li>\n                ))}\n              </ul>\n\n              <label htmlFor={`${uid}-cf`} className=\"mt-5 block text-[13px] font-medium\">\n                Confirm password\n              </label>\n              <div className={cn(fieldWrap, \"mt-1.5 pr-3\")} style={{ borderColor: confirm && !matches ? (touched ? p.error : p.fieldBorder) : matches ? p.ok : p.fieldBorder, background: p.field, [\"--f\" as string]: matches ? p.ok : p.focus }}>\n                <input id={`${uid}-cf`} type={show ? \"text\" : \"password\"} value={confirm} onChange={(e) => setConfirm(e.target.value)} autoComplete=\"new-password\" aria-describedby={`${uid}-match`} aria-invalid={touched && !matches} disabled={step === \"saving\"} className=\"h-full min-w-0 flex-1 border-0 bg-transparent text-[14px] outline-none\" style={{ color: p.text }} />\n                <AnimatePresence>\n                  {matches && (\n                    <motion.svg key=\"m\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.ok} strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={reduce ? false : { scale: 0.4, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={reduce ? undefined : { scale: 0.4, opacity: 0 }} aria-hidden=\"true\">\n                      <path d=\"m5 12.5 4.5 4.5L19 7.5\" />\n                    </motion.svg>\n                  )}\n                </AnimatePresence>\n              </div>\n              <p id={`${uid}-match`} className=\"m-0 mt-1.5 min-h-[18px] text-[12.5px]\" style={{ color: matches ? p.ok : confirm ? (touched ? p.error : p.muted) : p.faint }} aria-live=\"polite\">\n                {matches ? \"Passwords match\" : confirm ? (pw.startsWith(confirm) ? \"Keep typing…\" : \"Doesn't match the new password\") : \"Type it again to make sure\"}\n              </p>\n\n              <label className=\"mt-4 flex cursor-pointer items-start gap-2.5 text-[13px] has-[:focus-visible]:underline\" style={{ color: p.muted }}>\n                <input type=\"checkbox\" checked={signOut} onChange={(e) => setSignOut(e.target.checked)} className=\"mt-0.5 h-4 w-4 cursor-pointer\" style={{ accentColor: p.primary }} />\n                <span>\n                  Sign out of all other devices\n                  <span className=\"block text-[12px]\" style={{ color: p.faint }}>\n                    Recommended if you think someone else knows your password.\n                  </span>\n                </span>\n              </label>\n\n              <button type=\"submit\" disabled={step === \"saving\" || (touched && !canSave)} className={primary} style={{ background: p.primary, color: p.onPrimary, ...ring }}>\n                {step === \"saving\" && <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                {step === \"saving\" ? \"Updating…\" : \"Update password\"}\n              </button>\n              <p className=\"m-0 mt-4 text-center text-[12px] tabular-nums\" style={{ color: left < 300 ? p.warn : p.faint }} aria-live=\"off\">\n                This link expires in {clock(left)}\n              </p>\n            </motion.form>\n          )}\n\n          {step === \"done\" && (\n            <motion.div key=\"done\" {...fade} className=\"flex flex-col items-center py-4 text-center\" role=\"status\">\n              <span className=\"relative grid h-16 w-16 place-items-center\">\n                <svg className=\"absolute inset-0\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" aria-hidden=\"true\">\n                  <circle cx=\"32\" cy=\"32\" r=\"29\" fill=\"none\" stroke={p.chip} strokeWidth=\"3\" />\n                  <motion.circle cx=\"32\" cy=\"32\" r=\"29\" fill=\"none\" stroke={p.ok} strokeWidth=\"3\" strokeLinecap=\"round\" transform=\"rotate(-90 32 32)\" initial={{ pathLength: 1 }} animate={{ pathLength: redirect / 3 }} transition={{ duration: reduce ? 0 : 1, ease: \"linear\" }} />\n                </svg>\n                <svg width=\"26\" height=\"26\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.ok} 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 }} />\n                </svg>\n              </span>\n              <h2 className=\"m-0 mt-5 text-[22px] font-semibold tracking-[-0.02em]\">Password updated</h2>\n              <p className=\"m-0 mt-2 text-[14px] leading-relaxed\" style={{ color: p.muted }}>\n                {signOut ? \"Other devices have been signed out. \" : \"\"}\n                {redirect > 0 ? `Signing you in in ${redirect}…` : \"You're signed in.\"}\n              </p>\n              <button type=\"button\" onClick={() => (onContinue ? onContinue() : setRedirect(0))} className={primary} style={{ background: p.primary, color: p.onPrimary, ...ring }}>\n                Continue now\n              </button>\n            </motion.div>\n          )}\n\n          {(step === \"expired\" || step === \"sent\") && (\n            <motion.div key={step} {...fade}>\n              {step === \"expired\" ? tile(\"M12 7v5l3 2M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Z\", p.warn) : tile(\"M3 7l9 6 9-6M3 6h18v12H3z\", p.ok)}\n              <h2 className=\"m-0 mt-5 text-[22px] font-semibold tracking-[-0.02em]\">{step === \"expired\" ? \"This link has expired\" : \"Check your email\"}</h2>\n              <p className=\"m-0 mt-1.5 text-[14px] leading-relaxed\" style={{ color: p.muted }} aria-live=\"polite\">\n                {step === \"expired\" ? (\n                  \"Reset links work for 30 minutes and only once. Send yourself a new one.\"\n                ) : (\n                  <>\n                    We sent a new link to <span style={{ color: p.text }}>{email}</span>. It works for 30 minutes.\n                  </>\n                )}\n              </p>\n              {step === \"expired\" ? (\n                <form\n                  noValidate\n                  onSubmit={(e) => {\n                    e.preventDefault();\n                    requestLink();\n                  }}\n                >\n                  <label htmlFor={`${uid}-em`} className=\"mt-6 block text-[13px] font-medium\">\n                    Email\n                  </label>\n                  <div className={cn(fieldWrap, \"mt-1.5 pr-3.5\")} style={{ borderColor: email && !EMAIL.test(email) ? p.error : p.fieldBorder, background: p.field, [\"--f\" as string]: p.focus }}>\n                    <input id={`${uid}-em`} type=\"email\" value={email} onChange={(e) => setEmail(e.target.value)} autoComplete=\"email\" aria-invalid={!!email && !EMAIL.test(email)} className=\"h-full min-w-0 flex-1 border-0 bg-transparent text-[14px] outline-none\" style={{ color: p.text }} />\n                  </div>\n                  <button type=\"submit\" disabled={!EMAIL.test(email) || cooldown > 0} className={primary} style={{ background: p.primary, color: p.onPrimary, ...ring }}>\n                    Send a new link\n                  </button>\n                </form>\n              ) : (\n                <>\n                  <ol className=\"m-0 mt-5 flex list-none flex-col gap-2 rounded-xl p-3.5 text-[12.5px]\" style={{ background: p.chip, color: p.muted }}>\n                    {[\"Open the newest email from Nexora\", \"Click Reset password within 30 minutes\", \"Choose a new password\"].map((s, i) => (\n                      <li key={s} className=\"flex gap-2.5\">\n                        <span className=\"grid h-5 w-5 shrink-0 place-items-center rounded-full text-[11px] font-semibold\" style={{ background: p.panel, color: p.text }}>\n                          {i + 1}\n                        </span>\n                        {s}\n                      </li>\n                    ))}\n                  </ol>\n                  <div className=\"mt-5 flex items-center justify-between text-[13px]\">\n                    <button type=\"button\" onClick={() => setStep(\"expired\")} className={cn(\"cursor-pointer rounded border-0 bg-transparent p-0 text-[13px] underline underline-offset-2\", focus)} style={{ color: p.muted, ...ring }}>\n                      Use another email\n                    </button>\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={requestLink} className={cn(\"cursor-pointer rounded border-0 bg-transparent p-0 text-[13px] font-medium underline underline-offset-2\", focus)} style={{ color: p.text, ...ring }}>\n                        Resend link\n                      </button>\n                    )}\n                  </div>\n                </>\n              )}\n            </motion.div>\n          )}\n        </AnimatePresence>\n        <div className=\"mt-6 border-t pt-4 text-center text-[13px]\" style={{ borderColor: p.border }}>\n          <a href=\"#\" className={cn(\"rounded no-underline\", focus)} style={{ color: p.muted, ...ring }}>\n            ← Back to sign in\n          </a>\n        </div>\n      </motion.div>\n    </section>\n  );\n}\n\nexport default ResetPasswordCard;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}