{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "login-account-chooser",
  "type": "registry:component",
  "title": "Login Account Chooser",
  "description": "A choose-an-account screen with gradient avatars, workspace badges and signed-in dots, full arrow key navigation, a remembered device chip, a Use another account row and a remove mode.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "auth",
    "account chooser",
    "accounts",
    "listbox",
    "keyboard",
    "login",
    "switcher"
  ],
  "docs": "https://hyperblur.dev/effects/login-account-chooser",
  "files": [
    {
      "path": "registry/hyperblur/login-account-chooser.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/login-account-chooser.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LoginAccount {\n  id: string;\n  name: string;\n  email: string;\n  workspace?: string;\n  signedIn?: boolean;\n  hue?: number;\n}\n\nexport interface LoginAccountChooserProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  app?: string;\n  title?: string;\n  accounts?: LoginAccount[];\n  device?: string | null;\n  onItemSelect?: (account: LoginAccount) => boolean | void | Promise<boolean | void>;\n  onUseAnother?: () => void;\n  onRemove?: (account: LoginAccount) => void;\n  accent?: string;\n}\n\nconst css = `\n.hb-qh8 {\n  --hb-qh8-accent: #ff7a59;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  padding: clamp(56px, 8cqw, 104px) 20px;\n}\n.hb-qh8 *, .hb-qh8 *::before, .hb-qh8 *::after { box-sizing: border-box; }\n.hb-qh8-glow { position: absolute; left: 50%; top: -260px; width: 900px; height: 520px; transform: translateX(-50%); pointer-events: none; background: radial-gradient(closest-side, color-mix(in srgb, var(--hb-qh8-accent) 26%, transparent), transparent), radial-gradient(closest-side at 30% 60%, rgba(139,92,246,.18), transparent); filter: blur(30px); animation: hb-qh8-breathe 9s ease-in-out infinite alternate; }\n.hb-qh8-arc { position: absolute; left: 50%; top: 40px; width: 760px; height: 760px; transform: translateX(-50%); border-radius: 50%; border: 1px solid rgba(255,255,255,.05); pointer-events: none; mask: linear-gradient(#000, transparent 45%); }\n.hb-qh8-arc + .hb-qh8-arc { width: 1040px; height: 1040px; top: -60px; }\n.hb-qh8-inner { position: relative; max-width: 460px; margin: 0 auto; }\n.hb-qh8-head { text-align: center; margin-bottom: 24px; }\n.hb-qh8-logo { width: 48px; height: 48px; margin: 0 auto 18px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(145deg, #1c1c1c, #111); border: 1px solid rgba(255,255,255,.1); box-shadow: inset 0 1px 0 rgba(255,255,255,.08); color: var(--hb-qh8-accent); }\n.hb-qh8-title { margin: 0; font-size: clamp(26px, 4cqw, 32px); letter-spacing: -.025em; font-weight: 600; }\n.hb-qh8-sub { margin: 8px 0 0; color: #8f8f8f; font-size: 14.5px; }\n.hb-qh8-sub b { color: #ededed; font-weight: 500; }\n.hb-qh8-chip { display: flex; width: fit-content; margin: 18px auto 0; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 10px; border-radius: 999px; background: #111; border: 1px solid rgba(255,255,255,.08); font-size: 12.5px; color: #a1a1a1; }\n.hb-qh8-chip i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.15); }\n.hb-qh8-card { border-radius: 20px; border: 1px solid rgba(255,255,255,.08); background: #111; box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 30px 70px -40px rgba(0,0,0,.9); overflow: hidden; }\n.hb-qh8-list { list-style: none; margin: 0; padding: 6px; outline: none; }\n.hb-qh8-opt { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; cursor: pointer; outline: none; transition: background .2s; opacity: 0; animation: hb-qh8-in .5s cubic-bezier(.2,.7,.2,1) forwards; }\n.hb-qh8-opt:hover { background: #161616; }\n.hb-qh8-opt[data-active=\"true\"] { background: #181818; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }\n.hb-qh8-list:focus-visible .hb-qh8-opt[data-active=\"true\"] { box-shadow: inset 0 0 0 2px var(--hb-qh8-accent); }\n.hb-qh8-av { position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 600; color: #fff; background: linear-gradient(140deg, hsl(var(--hb-qh8-h) 85% 62%), hsl(calc(var(--hb-qh8-h) + 50) 75% 45%)); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }\n.hb-qh8-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #4ade80; border: 2px solid #111; }\n.hb-qh8-txt { min-width: 0; flex: 1; display: grid; gap: 2px; }\n.hb-qh8-name { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 500; }\n.hb-qh8-ws { height: 19px; padding: 0 7px; border-radius: 6px; display: inline-flex; align-items: center; font-size: 11px; color: #a1a1a1; background: #1c1c1c; border: 1px solid #2a2a2a; white-space: nowrap; }\n.hb-qh8-mail { font-size: 13px; color: #8f8f8f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qh8-state { flex: none; font-size: 12px; color: #6f6f6f; }\n.hb-qh8-arrow { flex: none; color: #555; transition: transform .25s, color .25s; }\n.hb-qh8-opt[data-active=\"true\"] .hb-qh8-arrow { color: var(--hb-qh8-accent); transform: translateX(3px); }\n.hb-qh8-rm { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid #2a2a2a; background: #161616; color: #a1a1a1; display: grid; place-items: center; cursor: pointer; }\n.hb-qh8-rm:hover { color: #fca5a5; border-color: rgba(248,113,113,.4); }\n.hb-qh8-rm:focus-visible, .hb-qh8-manage:focus-visible { outline: 2px solid var(--hb-qh8-accent); outline-offset: 2px; }\n.hb-qh8-new .hb-qh8-av { background: #171717; border: 1px dashed #3a3a3a; color: #a1a1a1; box-shadow: none; }\n.hb-qh8-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); border-top-color: var(--hb-qh8-accent); animation: hb-qh8-turn .7s linear infinite; }\n.hb-qh8-sep { height: 1px; margin: 4px 12px; background: rgba(255,255,255,.06); }\n.hb-qh8-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.06); background: #0e0e0e; font-size: 12px; color: #6f6f6f; }\n.hb-qh8-keys { display: inline-flex; align-items: center; gap: 6px; }\n.hb-qh8-kbd { min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; display: inline-grid; place-items: center; background: #1a1a1a; border: 1px solid #2a2a2a; border-bottom-width: 2px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; color: #a1a1a1; }\n.hb-qh8-manage { border: 0; background: none; padding: 4px 6px; border-radius: 6px; color: #a1a1a1; font: inherit; font-size: 12.5px; cursor: pointer; }\n.hb-qh8-manage:hover { color: #ededed; }\n.hb-qh8-done { display: grid; justify-items: center; gap: 12px; padding: 34px 20px; text-align: center; animation: hb-qh8-in .45s ease both; }\n.hb-qh8-done .hb-qh8-av { width: 64px; height: 64px; font-size: 20px; }\n.hb-qh8-done p { margin: 0; color: #8f8f8f; font-size: 14px; }\n.hb-qh8-done strong { font-size: 18px; font-weight: 600; }\n.hb-qh8-ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--hb-qh8-accent); animation: hb-qh8-turn 1s linear infinite; }\n.hb-qh8-legal { margin: 18px 0 0; text-align: center; font-size: 12.5px; color: #6f6f6f; }\n@container (max-width: 420px) { .hb-qh8-state, .hb-qh8-keys { display: none; } }\n@keyframes hb-qh8-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }\n@keyframes hb-qh8-turn { to { transform: rotate(360deg); } }\n@keyframes hb-qh8-breathe { from { opacity: .75; transform: translateX(-50%) scale(1); } to { opacity: 1; transform: translateX(-50%) scale(1.08); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qh8 *, .hb-qh8 *::before, .hb-qh8 *::after { animation: none !important; transition: none !important; }\n  .hb-qh8-opt { opacity: 1; }\n}\n`;\n\nconst defaults: LoginAccount[] = [\n  { id: \"ines\", name: \"Inês Duarte\", email: \"ines@lumacraft.studio\", workspace: \"Lumacraft\", signedIn: true, hue: 18 },\n  { id: \"ines-personal\", name: \"Inês Duarte\", email: \"ines.duarte@fastmail.com\", workspace: \"Personal\", signedIn: false, hue: 262 },\n  { id: \"ops\", name: \"Ops Team\", email: \"ops@northwind.co\", workspace: \"Northwind\", signedIn: false, hue: 168 },\n];\n\nfunction initials(name: string) {\n  return name.split(/\\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]?.toUpperCase() ?? \"\").join(\"\");\n}\n\nfunction wait(result: unknown) {\n  return result instanceof Promise ? result : new Promise<unknown>((resolve) => setTimeout(() => resolve(result), 1100));\n}\n\nexport function LoginAccountChooser({\n  app = \"Relay\",\n  title = \"Choose an account\",\n  accounts = defaults,\n  device = \"This Mac is remembered · Lisbon, PT\",\n  onItemSelect,\n  onUseAnother,\n  onRemove,\n  accent = \"#ff7a59\",\n  className = \"\",\n  style,\n  ...rest\n}: LoginAccountChooserProps) {\n  const uid = React.useId();\n  const [list, setList] = React.useState(accounts);\n  const [active, setActive] = React.useState(0);\n  const [manage, setManage] = React.useState(false);\n  const [pending, setPending] = React.useState<string | null>(null);\n  const [done, setDone] = React.useState<LoginAccount | null>(null);\n  const [error, setError] = React.useState(\"\");\n  const listRef = React.useRef<HTMLUListElement>(null);\n  const count = list.length + 1;\n  const current = Math.min(active, count - 1);\n\n  async function pick(index: number) {\n    if (pending || manage) return;\n    if (index >= list.length) {\n      onUseAnother?.();\n      return;\n    }\n    const account = list[index];\n    setPending(account.id);\n    setError(\"\");\n    try {\n      const result = await wait(onItemSelect ? onItemSelect(account) : true);\n      if (result === false) setError(`${account.email} needs you to sign in again.`);\n      else setDone(account);\n    } catch {\n      setError(\"Something went wrong. Try again.\");\n    }\n    setPending(null);\n  }\n\n  function remove(account: LoginAccount) {\n    setList((l) => l.filter((a) => a.id !== account.id));\n    onRemove?.(account);\n  }\n\n  function onKeyDown(event: React.KeyboardEvent<HTMLUListElement>) {\n    if (event.key === \"ArrowDown\") {\n      event.preventDefault();\n      setActive((current + 1) % count);\n    } else if (event.key === \"ArrowUp\") {\n      event.preventDefault();\n      setActive((current - 1 + count) % count);\n    } else if (event.key === \"Home\") {\n      event.preventDefault();\n      setActive(0);\n    } else if (event.key === \"End\") {\n      event.preventDefault();\n      setActive(count - 1);\n    } else if (event.key === \"Enter\" || event.key === \" \") {\n      event.preventDefault();\n      void pick(current);\n    } else if ((event.key === \"Delete\" || event.key === \"Backspace\") && manage && current < list.length) {\n      event.preventDefault();\n      remove(list[current]);\n    }\n  }\n\n  const optId = (i: number) => `${uid}-o${i}`;\n\n  return (\n    <section className={`hb-qh8 ${className}`} style={{ \"--hb-qh8-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-login-account-chooser\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qh8-glow\" aria-hidden=\"true\" />\n      <div className=\"hb-qh8-arc\" aria-hidden=\"true\" />\n      <div className=\"hb-qh8-arc\" aria-hidden=\"true\" />\n      <div className=\"hb-qh8-inner\">\n        <div className=\"hb-qh8-head\">\n          <div className=\"hb-qh8-logo\" aria-hidden=\"true\">\n            <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\"><path d=\"M4 11h6l2-5 3 10 2-5h1\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n          </div>\n          <h2 className=\"hb-qh8-title\">{done ? `Welcome back, ${done.name.split(\" \")[0]}` : title}</h2>\n          <p className=\"hb-qh8-sub\">{done ? \"Opening your inbox\" : <>to continue to <b>{app}</b></>}</p>\n          {device && !done && <span className=\"hb-qh8-chip\"><i aria-hidden=\"true\" />{device}</span>}\n        </div>\n        <div className=\"hb-qh8-card\">\n          {done ? (\n            <div className=\"hb-qh8-done\" role=\"status\">\n              <span className=\"hb-qh8-av\" style={{ \"--hb-qh8-h\": done.hue ?? 210 } as React.CSSProperties}>\n                {initials(done.name)}\n                <span className=\"hb-qh8-ring\" aria-hidden=\"true\" />\n              </span>\n              <strong>{done.email}</strong>\n              <p>Signed in on this device.</p>\n            </div>\n          ) : (\n            <>\n              <ul\n                ref={listRef}\n                className=\"hb-qh8-list\"\n                role=\"listbox\"\n                tabIndex={0}\n                aria-label={`Accounts for ${app}`}\n                aria-activedescendant={optId(current)}\n                aria-busy={pending ? true : undefined}\n                onKeyDown={onKeyDown}\n              >\n                {list.map((a, i) => (\n                  <li\n                    key={a.id}\n                    id={optId(i)}\n                    role=\"option\"\n                    aria-selected={current === i}\n                    className=\"hb-qh8-opt\"\n                    data-active={current === i}\n                    style={{ animationDelay: `${(0.05 + i * 0.07).toFixed(2)}s` }}\n                    onMouseEnter={() => setActive(i)}\n                    onClick={() => { listRef.current?.focus(); void pick(i); }}\n                  >\n                    <span className=\"hb-qh8-av\" style={{ \"--hb-qh8-h\": a.hue ?? 210 } as React.CSSProperties} aria-hidden=\"true\">\n                      {initials(a.name)}\n                      {a.signedIn && <span className=\"hb-qh8-dot\" />}\n                    </span>\n                    <span className=\"hb-qh8-txt\">\n                      <span className=\"hb-qh8-name\">{a.name}{a.workspace && <span className=\"hb-qh8-ws\">{a.workspace}</span>}</span>\n                      <span className=\"hb-qh8-mail\">{a.email}</span>\n                    </span>\n                    {manage ? (\n                      <button type=\"button\" className=\"hb-qh8-rm\" aria-label={`Remove ${a.email}`} tabIndex={-1} onClick={(e) => { e.stopPropagation(); remove(a); }}>\n                        <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\"><path d=\"M3 3l6 6M9 3 3 9\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" /></svg>\n                      </button>\n                    ) : pending === a.id ? (\n                      <span className=\"hb-qh8-spin\" aria-label=\"Signing in\" />\n                    ) : (\n                      <>\n                        <span className=\"hb-qh8-state\">{a.signedIn ? \"Signed in\" : \"Signed out\"}</span>\n                        <svg className=\"hb-qh8-arrow\" width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"m6 3 5 5-5 5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n                      </>\n                    )}\n                  </li>\n                ))}\n                {list.length > 0 && <li className=\"hb-qh8-sep\" role=\"presentation\" />}\n                <li\n                  id={optId(list.length)}\n                  role=\"option\"\n                  aria-selected={current === list.length}\n                  className=\"hb-qh8-opt hb-qh8-new\"\n                  data-active={current === list.length}\n                  style={{ animationDelay: `${(0.05 + list.length * 0.07).toFixed(2)}s` }}\n                  onMouseEnter={() => setActive(list.length)}\n                  onClick={() => void pick(list.length)}\n                >\n                  <span className=\"hb-qh8-av\" aria-hidden=\"true\">\n                    <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M8 3v10M3 8h10\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" /></svg>\n                  </span>\n                  <span className=\"hb-qh8-txt\">\n                    <span className=\"hb-qh8-name\">Use another account</span>\n                    <span className=\"hb-qh8-mail\">Sign in with a different email</span>\n                  </span>\n                  <svg className=\"hb-qh8-arrow\" width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"m6 3 5 5-5 5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n                </li>\n              </ul>\n              {error && <p role=\"alert\" style={{ margin: \"0 18px 12px\", fontSize: 13, color: \"#fca5a5\" }}>{error}</p>}\n              <div className=\"hb-qh8-foot\">\n                <span className=\"hb-qh8-keys\" aria-hidden=\"true\">\n                  <span className=\"hb-qh8-kbd\">↑</span><span className=\"hb-qh8-kbd\">↓</span> to move\n                  <span className=\"hb-qh8-kbd\">↵</span> to continue\n                </span>\n                <button type=\"button\" className=\"hb-qh8-manage\" aria-pressed={manage} onClick={() => setManage((m) => !m)}>\n                  {manage ? \"Done\" : \"Remove an account\"}\n                </button>\n              </div>\n            </>\n          )}\n        </div>\n        <p className=\"hb-qh8-legal\">Signing in shares your name, email and photo with {app}.</p>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}