{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "password-reset",
  "title": "Password reset",
  "description": "Three-step reset flow on one card: request by email, 6-digit code with resend cooldown, then a new password with live rules, ending on an animated success.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/button.json",
    "https://goodui.dev/r/input.json",
    "https://goodui.dev/r/otp-input.json",
    "https://goodui.dev/r/success-check.json"
  ],
  "files": [
    {
      "path": "registry/blocks/auth/password-reset.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ArrowLeft, ArrowRight, Check, Eye, EyeOff, KeyRound, Mail, ShieldCheck } from \"lucide-react\"\nimport { Button } from \"@/components/goodui/button\"\nimport { Input } from \"@/components/goodui/input\"\nimport { SuccessCheck } from \"@/components/goodui/success-check\"\nimport { OtpInput } from \"@/components/goodui/otp-input\"\nimport { cn } from \"@/lib/utils\"\n\nconst DEMO_CODE = \"482913\"\nconst RESEND_SECONDS = 30\ntype Step = \"request\" | \"code\" | \"password\" | \"done\"\nconst STEPS: Step[] = [\"request\", \"code\", \"password\"]\n\nconst RULES = [\n  { id: \"len\", label: \"At least 12 characters\", test: (p: string) => p.length >= 12 },\n  { id: \"case\", label: \"Upper and lower case\", test: (p: string) => /[a-z]/.test(p) && /[A-Z]/.test(p) },\n  { id: \"num\", label: \"A number\", test: (p: string) => /\\d/.test(p) },\n  { id: \"sym\", label: \"A symbol\", test: (p: string) => /[^\\w\\s]/.test(p) },\n]\n\nfunction KeyArt({ step }: { step: Step }) {\n  return (\n    <svg viewBox=\"0 0 120 120\" className=\"size-24\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id=\"pr-g\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopColor=\"var(--chart-1)\" />\n          <stop offset=\"1\" stopColor=\"var(--chart-4)\" />\n        </linearGradient>\n      </defs>\n      <circle cx=\"60\" cy=\"60\" r=\"54\" fill=\"url(#pr-g)\" opacity=\"0.12\" />\n      <circle cx=\"60\" cy=\"60\" r=\"40\" fill=\"url(#pr-g)\" opacity=\"0.18\" />\n      <g transform=\"translate(60 60) rotate(-35)\" className=\"transition-transform duration-700 motion-reduce:transition-none\" style={{ transform: step === \"done\" ? \"translate(60px,60px) rotate(0deg)\" : undefined }}>\n        <circle cx=\"-16\" cy=\"0\" r=\"14\" fill=\"none\" stroke=\"url(#pr-g)\" strokeWidth=\"7\" />\n        <path d=\"M-2 0h36M24 0v10M32 0v8\" stroke=\"url(#pr-g)\" strokeWidth=\"7\" strokeLinecap=\"round\" fill=\"none\" />\n      </g>\n      {step === \"done\" && <circle cx=\"60\" cy=\"60\" r=\"54\" fill=\"none\" stroke=\"var(--chart-2)\" strokeWidth=\"3\" strokeDasharray=\"340\" strokeDashoffset=\"0\" className=\"motion-safe:animate-[pr-ring_1s_ease-out]\" />}\n      <style>{`@keyframes pr-ring{from{stroke-dashoffset:340}to{stroke-dashoffset:0}}`}</style>\n    </svg>\n  )\n}\n\nexport default function PasswordReset() {\n  const [step, setStep] = React.useState<Step>(\"request\")\n  const [email, setEmail] = React.useState(\"\")\n  const [error, setError] = React.useState<string | null>(null)\n  const [loading, setLoading] = React.useState(false)\n  const [cooldown, setCooldown] = React.useState(0)\n  const [code, setCode] = React.useState(\"\")\n  const [otpStatus, setOtpStatus] = React.useState<\"idle\" | \"verifying\" | \"success\" | \"error\">(\"idle\")\n  const [password, setPassword] = React.useState(\"\")\n  const [confirm, setConfirm] = React.useState(\"\")\n  const [show, setShow] = React.useState(false)\n\n  React.useEffect(() => {\n    if (cooldown <= 0) return\n    const id = setTimeout(() => setCooldown((c) => c - 1), 1000)\n    return () => clearTimeout(id)\n  }, [cooldown])\n\n  const request = (e?: React.FormEvent) => {\n    e?.preventDefault()\n    if (!/^\\S+@\\S+\\.\\S+$/.test(email)) return setError(\"Enter the email you signed up with\")\n    setError(null)\n    setLoading(true)\n    setTimeout(() => {\n      setLoading(false)\n      setCooldown(RESEND_SECONDS)\n      setStep(\"code\")\n    }, 900)\n  }\n\n  const verify = (value: string) =>\n    new Promise<boolean>((resolve) => {\n      setOtpStatus(\"verifying\")\n      setTimeout(() => {\n        const ok = value === DEMO_CODE\n        setOtpStatus(ok ? \"success\" : \"error\")\n        if (ok) setTimeout(() => setStep(\"password\"), 500)\n        resolve(ok)\n      }, 800)\n    })\n\n  const passed = RULES.filter((r) => r.test(password)).length\n  const savePassword = (e: React.FormEvent) => {\n    e.preventDefault()\n    if (passed < RULES.length) return setError(\"Your password does not meet every rule yet\")\n    if (password !== confirm) return setError(\"The two passwords do not match\")\n    setError(null)\n    setLoading(true)\n    setTimeout(() => {\n      setLoading(false)\n      setStep(\"done\")\n    }, 900)\n  }\n\n  const restart = () => {\n    setStep(\"request\")\n    setEmail(\"\")\n    setCode(\"\")\n    setPassword(\"\")\n    setConfirm(\"\")\n    setOtpStatus(\"idle\")\n    setError(null)\n  }\n\n  const index = STEPS.indexOf(step)\n\n  return (\n    <div className=\"p-4 md:p-6\">\n      <div className=\"mx-auto max-w-md\">\n        <div className=\"relative overflow-hidden rounded-3xl border bg-card p-6 shadow-sm md:p-8\">\n          <div className=\"pointer-events-none absolute -top-24 left-1/2 size-72 -translate-x-1/2 rounded-full bg-[var(--chart-1)]/10 blur-3xl\" aria-hidden=\"true\" />\n\n          {/* Stepper */}\n          <ol className=\"relative mb-6 flex items-center justify-center gap-2\" aria-label=\"Progress\">\n            {STEPS.map((s, i) => (\n              <React.Fragment key={s}>\n                {i > 0 && <span className={cn(\"h-0.5 w-8 rounded-full transition-colors\", i <= index || step === \"done\" ? \"bg-primary\" : \"bg-border\")} aria-hidden=\"true\" />}\n                <li aria-current={s === step ? \"step\" : undefined} className={cn(\"flex size-7 items-center justify-center rounded-full text-xs font-semibold transition-colors\", i < index || step === \"done\" ? \"bg-primary text-primary-foreground\" : s === step ? \"bg-foreground text-background\" : \"bg-muted text-muted-foreground\")}>\n                  {i < index || step === \"done\" ? <Check className=\"size-3.5\" /> : i + 1}\n                  <span className=\"sr-only\">{s}</span>\n                </li>\n              </React.Fragment>\n            ))}\n          </ol>\n\n          <div className=\"relative flex justify-center\">\n            <KeyArt step={step} />\n          </div>\n\n          {step === \"request\" && (\n            <form onSubmit={request} className=\"relative mt-4 grid gap-4\" noValidate>\n              <div className=\"text-center\">\n                <h2 className=\"font-heading text-2xl font-semibold tracking-tight\">Forgot your password?</h2>\n                <p className=\"mt-1 text-sm text-muted-foreground\">No problem. We will email you a 6-digit code to reset it.</p>\n              </div>\n              <Input id=\"pr-email\" type=\"email\" label=\"Email\" placeholder=\"you@salon.com\" value={email} onValueChange={(v) => { setEmail(v); setError(null) }} leading={<Mail className=\"size-4\" />} state={error ? \"error\" : \"default\"} message={error} shake autoComplete=\"email\" autoFocus />\n              <Button type=\"submit\" size=\"lg\" fullWidth loading={loading} iconRight={<ArrowRight />} animation=\"arrow\">\n                Send reset code\n              </Button>\n              <p className=\"text-center text-sm text-muted-foreground\">\n                Remembered it?{\" \"}\n                <button type=\"button\" className=\"font-medium text-foreground underline-offset-4 hover:underline\" onClick={restart}>\n                  Back to sign in\n                </button>\n              </p>\n            </form>\n          )}\n\n          {step === \"code\" && (\n            <div className=\"relative mt-4 grid gap-5\">\n              <div className=\"text-center\">\n                <h2 className=\"font-heading text-2xl font-semibold tracking-tight\">Check your inbox</h2>\n                <p className=\"mt-1 text-sm text-muted-foreground\">\n                  We sent a code to <span className=\"font-medium text-foreground\">{email}</span>.{\" \"}\n                  <button type=\"button\" className=\"underline underline-offset-2\" onClick={() => setStep(\"request\")}>\n                    Wrong email?\n                  </button>\n                </p>\n              </div>\n              <div className=\"flex justify-center\">\n                <OtpInput length={6} value={code} onValueChange={setCode} onComplete={verify} status={otpStatus} clearOnError autoFocus groupSize={3} aria-label=\"Reset code\" />\n              </div>\n              <p role=\"status\" aria-live=\"polite\" className={cn(\"min-h-5 text-center text-sm\", otpStatus === \"error\" ? \"text-rose-600 dark:text-rose-400\" : otpStatus === \"success\" ? \"text-emerald-700 dark:text-emerald-300\" : \"text-muted-foreground\")}>\n                {otpStatus === \"error\" ? \"That code is not right. Try again.\" : otpStatus === \"success\" ? \"Code accepted\" : otpStatus === \"verifying\" ? \"Checking…\" : `Demo code: ${DEMO_CODE}`}\n              </p>\n              <div className=\"flex items-center justify-between text-sm\">\n                <button type=\"button\" className=\"inline-flex items-center gap-1 text-muted-foreground hover:text-foreground\" onClick={() => setStep(\"request\")}>\n                  <ArrowLeft className=\"size-4\" /> Back\n                </button>\n                <Button size=\"sm\" variant=\"ghost\" tone=\"neutral\" disabled={cooldown > 0} onClick={() => { setCooldown(RESEND_SECONDS); setOtpStatus(\"idle\"); setCode(\"\") }}>\n                  {cooldown > 0 ? `Resend in ${cooldown}s` : \"Resend code\"}\n                </Button>\n              </div>\n            </div>\n          )}\n\n          {step === \"password\" && (\n            <form onSubmit={savePassword} className=\"relative mt-4 grid gap-4\" noValidate>\n              <div className=\"text-center\">\n                <h2 className=\"font-heading text-2xl font-semibold tracking-tight\">Choose a new password</h2>\n                <p className=\"mt-1 text-sm text-muted-foreground\">Make it long. A sentence you will remember works well.</p>\n              </div>\n              <Input\n                id=\"pr-password\"\n                type={show ? \"text\" : \"password\"}\n                label=\"New password\"\n                value={password}\n                onValueChange={(v) => { setPassword(v); setError(null) }}\n                leading={<KeyRound className=\"size-4\" />}\n                autoComplete=\"new-password\"\n                autoFocus\n                trailing={\n                  <button type=\"button\" onClick={() => setShow((s) => !s)} aria-label={show ? \"Hide password\" : \"Show password\"} aria-pressed={show} className=\"rounded p-0.5 text-muted-foreground hover:text-foreground\">\n                    {show ? <EyeOff className=\"size-4\" /> : <Eye className=\"size-4\" />}\n                  </button>\n                }\n              />\n              <div className=\"flex gap-1\" aria-hidden=\"true\">\n                {RULES.map((_, i) => (\n                  <span key={i} className={cn(\"h-1.5 flex-1 rounded-full transition-colors duration-300\", i < passed ? (passed === RULES.length ? \"bg-emerald-500\" : passed >= 2 ? \"bg-amber-500\" : \"bg-rose-500\") : \"bg-muted\")} />\n                ))}\n              </div>\n              <ul className=\"grid grid-cols-2 gap-x-3 gap-y-1 text-xs\" aria-label=\"Password rules\">\n                {RULES.map((r) => {\n                  const ok = r.test(password)\n                  return (\n                    <li key={r.id} className={cn(\"flex items-center gap-1.5 transition-colors\", ok ? \"text-emerald-700 dark:text-emerald-300\" : \"text-muted-foreground\")}>\n                      <span className={cn(\"flex size-4 items-center justify-center rounded-full\", ok ? \"bg-emerald-500 text-white\" : \"border\")}>{ok && <Check className=\"size-2.5\" />}</span>\n                      {r.label}\n                    </li>\n                  )\n                })}\n              </ul>\n              <Input id=\"pr-confirm\" type={show ? \"text\" : \"password\"} label=\"Confirm password\" value={confirm} onValueChange={(v) => { setConfirm(v); setError(null) }} autoComplete=\"new-password\" state={confirm && confirm !== password ? \"error\" : confirm && confirm === password ? \"success\" : \"default\"} message={confirm && confirm !== password ? \"Does not match\" : undefined} />\n              {error && (\n                <p role=\"alert\" className=\"text-sm text-rose-600 dark:text-rose-400\">\n                  {error}\n                </p>\n              )}\n              <Button type=\"submit\" size=\"lg\" fullWidth loading={loading} iconLeft={<ShieldCheck />}>\n                Reset password\n              </Button>\n            </form>\n          )}\n\n          {step === \"done\" && (\n            <div className=\"relative mt-4 grid gap-4 text-center\">\n              <div className=\"flex justify-center\">\n                <SuccessCheck size={64} />\n              </div>\n              <div>\n                <h2 className=\"font-heading text-2xl font-semibold tracking-tight\">Password updated</h2>\n                <p className=\"mt-1 text-sm text-muted-foreground\">You are signed out everywhere else. Use your new password to sign in.</p>\n              </div>\n              <Button size=\"lg\" fullWidth onClick={restart} iconRight={<ArrowRight />} animation=\"arrow\">\n                Continue to sign in\n              </Button>\n            </div>\n          )}\n        </div>\n        <p className=\"mt-4 text-center text-xs text-muted-foreground\">Codes expire after 10 minutes. Having trouble? Email support@bookly.com.</p>\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/password-reset.tsx"
    }
  ],
  "categories": [
    "auth"
  ],
  "type": "registry:block"
}
