{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "authentication-06",
  "type": "registry:block",
  "description": "Two-factor setup wizard with an authenticator QR code, 6-digit verification and downloadable backup codes.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "input"
  ],
  "files": [
    {
      "path": "registry/designali/blocks/authentication/authentication-06.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport {\n  Check,\n  Copy,\n  Download,\n  Smartphone,\n} from \"@designali/icons\"\n\nimport { Button } from \"@workspace/ui/components/button\"\nimport { Input } from \"@workspace/ui/components/input\"\nimport { cn } from \"@workspace/ui/lib/utils\"\n\nconst SIZE = 25\n\nfunction isFinder(x: number, y: number) {\n  const inBox = (ox: number, oy: number) => x >= ox && x < ox + 7 && y >= oy && y < oy + 7\n  return inBox(0, 0) || inBox(SIZE - 7, 0) || inBox(0, SIZE - 7)\n}\n\nfunction QrCode() {\n  const cells: { x: number; y: number }[] = []\n  for (let y = 0; y < SIZE; y++) {\n    for (let x = 0; x < SIZE; x++) {\n      if (isFinder(x, y)) continue\n      if (((x * 7 + y * 13 + x * y * 3) % 5) < 2) cells.push({ x, y })\n    }\n  }\n  const finders = [\n    [0, 0],\n    [SIZE - 7, 0],\n    [0, SIZE - 7],\n  ] as const\n  return (\n    <svg viewBox={`-1 -1 ${SIZE + 2} ${SIZE + 2}`} className=\"size-full\" aria-label=\"Authenticator QR code\">\n      <rect x={-1} y={-1} width={SIZE + 2} height={SIZE + 2} fill=\"white\" />\n      {cells.map((cell) => (\n        <rect key={`${cell.x}-${cell.y}`} x={cell.x} y={cell.y} width={1} height={1} fill=\"black\" />\n      ))}\n      {finders.map(([fx, fy]) => (\n        <g key={`${fx}-${fy}`}>\n          <rect x={fx + 0.5} y={fy + 0.5} width={6} height={6} fill=\"none\" stroke=\"black\" strokeWidth={1} />\n          <rect x={fx + 2} y={fy + 2} width={3} height={3} fill=\"black\" />\n        </g>\n      ))}\n    </svg>\n  )\n}\n\nconst secret = \"JBSW Y3DP EHPK 3PXP\"\nconst backupCodes = [\"8f3k-2m9q\", \"p7xd-41ac\", \"zq62-mn8r\", \"c4vw-0t5e\", \"h9ly-3bks\", \"u2fj-7rpn\"]\n\nexport default function Authentication06() {\n  const [step, setStep] = useState(0)\n  const [copied, setCopied] = useState(false)\n  const [code, setCode] = useState(\"\")\n\n  const steps = [\"Scan\", \"Verify\", \"Save codes\"]\n\n  return (\n    <section className=\"flex min-h-[720px] w-full items-center justify-center bg-muted/40 px-6 py-16\">\n      <div className=\"w-full max-w-lg border bg-background\">\n        <ol className=\"grid grid-cols-3 border-b text-xs\">\n          {steps.map((label, index) => (\n            <li\n              key={label}\n              className={cn(\n                \"flex items-center justify-center gap-2 border-e py-3 last:border-e-0\",\n                index === step ? \"text-foreground\" : \"text-muted-foreground\"\n              )}\n            >\n              <span\n                className={cn(\n                  \"flex size-5 items-center justify-center border text-[10px]\",\n                  index < step && \"border-foreground bg-foreground text-background\",\n                  index === step && \"border-foreground\"\n                )}\n              >\n                {index < step ? <Check className=\"size-3\" /> : index + 1}\n              </span>\n              {label}\n            </li>\n          ))}\n        </ol>\n\n        <div className=\"p-6 sm:p-8\">\n          {step === 0 && (\n            <div className=\"space-y-6\">\n              <div>\n                <h2 className=\"text-2xl font-semibold tracking-tight\">Set up two-factor authentication</h2>\n                <p className=\"mt-2 text-sm text-muted-foreground\">\n                  Scan this code with an authenticator app like 1Password, Authy or your phone&apos;s built-in passwords app.\n                </p>\n              </div>\n              <div className=\"flex flex-col items-center gap-6 sm:flex-row sm:items-start\">\n                <div className=\"size-44 shrink-0 border p-2\">\n                  <QrCode />\n                </div>\n                <div className=\"w-full space-y-3 text-sm\">\n                  <p className=\"flex items-center gap-2 text-muted-foreground\">\n                    <Smartphone className=\"size-4\" />\n                    Can&apos;t scan? Enter this key manually.\n                  </p>\n                  <div className=\"flex items-center justify-between gap-2 border bg-muted/50 px-3 py-2\">\n                    <code className=\"font-mono text-sm tracking-wider\">{secret}</code>\n                    <button\n                      type=\"button\"\n                      aria-label=\"Copy setup key\"\n                      onClick={() => setCopied(true)}\n                      className=\"text-muted-foreground hover:text-foreground\"\n                    >\n                      {copied ? <Check className=\"size-4\" /> : <Copy className=\"size-4\" />}\n                    </button>\n                  </div>\n                  <p className=\"text-xs text-muted-foreground\">Account: ali@designali.com &middot; Designali</p>\n                </div>\n              </div>\n              <Button className=\"w-full\" onClick={() => setStep(1)}>\n                I&apos;ve scanned the code\n              </Button>\n            </div>\n          )}\n\n          {step === 1 && (\n            <form\n              className=\"space-y-6\"\n              onSubmit={(event) => {\n                event.preventDefault()\n                if (code.length === 6) setStep(2)\n              }}\n            >\n              <div>\n                <h2 className=\"text-2xl font-semibold tracking-tight\">Enter the 6-digit code</h2>\n                <p className=\"mt-2 text-sm text-muted-foreground\">\n                  Type the code your authenticator app shows for Designali.\n                </p>\n              </div>\n              <Input\n                inputMode=\"numeric\"\n                autoComplete=\"one-time-code\"\n                value={code}\n                onChange={(event) => setCode(event.target.value.replace(/\\D/g, \"\").slice(0, 6))}\n                placeholder=\"000000\"\n                className=\"h-14 text-center font-sans text-2xl tracking-[0.5em]\"\n              />\n              <div className=\"flex gap-3\">\n                <Button type=\"button\" variant=\"outline\" onClick={() => setStep(0)}>\n                  Back\n                </Button>\n                <Button type=\"submit\" className=\"flex-1\" disabled={code.length !== 6}>\n                  Verify and enable\n                </Button>\n              </div>\n            </form>\n          )}\n\n          {step === 2 && (\n            <div className=\"space-y-6\">\n              <div>\n                <h2 className=\"text-2xl font-semibold tracking-tight\">Save your backup codes</h2>\n                <p className=\"mt-2 text-sm text-muted-foreground\">\n                  Each code works once. Store them somewhere safe in case you lose your device.\n                </p>\n              </div>\n              <ul className=\"grid grid-cols-2 gap-px border bg-border font-sans text-sm\">\n                {backupCodes.map((item) => (\n                  <li key={item} className=\"bg-muted/40 px-4 py-3 text-center tracking-wider\">\n                    {item}\n                  </li>\n                ))}\n              </ul>\n              <div className=\"flex flex-col gap-3 sm:flex-row\">\n                <Button variant=\"outline\" className=\"flex-1\">\n                  <Download />\n                  Download .txt\n                </Button>\n                <Button className=\"flex-1\">Done</Button>\n              </div>\n            </div>\n          )}\n        </div>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "iframeHeight": "800px"
  },
  "categories": [
    "authentication"
  ]
}