{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auth-magic-flight",
  "type": "registry:component",
  "title": "Auth Magic Flight",
  "description": "A dark magic link sign-in where the letter folds into an envelope and flies along a dotted route into an inbox tray that catches it and shows a badge. The sent state has a live expiry bar, an Open mail button and a resend cooldown.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "auth",
    "auth",
    "magic link",
    "passwordless",
    "email",
    "envelope",
    "countdown"
  ],
  "docs": "https://hyperblur.dev/effects/auth-magic-flight",
  "files": [
    {
      "path": "registry/hyperblur/auth-magic-flight.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/auth-magic-flight.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface AuthMagicFlightProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  brand?: string;\n  title?: string;\n  subtitle?: string;\n  sender?: string;\n  expiresMinutes?: number;\n  resendSeconds?: number;\n  mailHref?: string;\n  defaultEmail?: string;\n  defaultSent?: boolean;\n  onSend?: (email: string) => boolean | void | Promise<boolean | void>;\n  onResend?: (email: string) => void;\n  accent?: string;\n}\n\nconst css = `\n.hb-vf5 {\n  --hb-vf5-accent: #ff8a4c;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  min-height: 600px;\n  display: grid;\n  place-items: center;\n  padding: 52px 20px;\n  overflow: hidden;\n  background: linear-gradient(180deg, #0c0a09, #0a0a0a 60%);\n  color: #ededed;\n  font-family: inherit;\n}\n.hb-vf5 *, .hb-vf5 *::before, .hb-vf5 *::after { box-sizing: border-box; }\n.hb-vf5::before { content: \"\"; position: absolute; left: 50%; top: 18%; width: 620px; height: 320px; transform: translateX(-50%); background: radial-gradient(ellipse, color-mix(in srgb, var(--hb-vf5-accent) 13%, transparent), transparent 65%); pointer-events: none; }\n.hb-vf5-card { position: relative; width: 100%; max-width: 420px; container-type: inline-size; padding: 28px 30px 26px; border-radius: 22px; background: linear-gradient(180deg, #141210, #0f0f0f); border: 1px solid #242120; box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 40px 80px -30px rgba(0,0,0,.9); }\n.hb-vf5-brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; margin-bottom: 18px; }\n.hb-vf5-brand i { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 200deg, var(--hb-vf5-accent), #ffd28a, var(--hb-vf5-accent)); box-shadow: 0 6px 16px -6px var(--hb-vf5-accent); }\n.hb-vf5-stage { position: relative; width: 340px; height: 132px; margin: 0 auto 18px; }\n@container (max-width: 380px) { .hb-vf5-stage { transform: scale(.8); transform-origin: top center; margin-bottom: -8px; } }\n.hb-vf5-path { position: absolute; inset: 0; overflow: visible; }\n.hb-vf5-route { fill: none; stroke: #2e2a27; stroke-width: 1.5; stroke-dasharray: 2 6; stroke-linecap: round; }\n.hb-vf5-trail { fill: none; stroke: var(--hb-vf5-accent); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 360; stroke-dashoffset: 360; opacity: 0; }\n.hb-vf5[data-stage=\"sending\"] .hb-vf5-trail { opacity: 1; animation: hb-vf5-trail 1.3s .35s cubic-bezier(.55,0,.3,1) forwards; }\n.hb-vf5[data-stage=\"sent\"] .hb-vf5-trail { opacity: .35; stroke-dashoffset: 0; }\n.hb-vf5-sheet { position: absolute; left: 14px; top: 62px; width: 56px; height: 44px; border-radius: 6px; background: linear-gradient(180deg, #f6efe8, #e6ddd3); box-shadow: 0 10px 24px -10px rgba(0,0,0,.8); padding: 9px 9px; display: grid; gap: 5px; align-content: start; transform-origin: 50% 100%; animation: hb-vf5-hover 3.6s cubic-bezier(.45,0,.55,1) infinite; }\n.hb-vf5-sheet span { height: 3px; border-radius: 2px; background: #c9bdb0; }\n.hb-vf5-sheet span:first-child { width: 60%; background: var(--hb-vf5-accent); }\n.hb-vf5-sheet span:nth-child(3) { width: 75%; }\n.hb-vf5[data-stage=\"sending\"] .hb-vf5-sheet { animation: hb-vf5-fold .4s cubic-bezier(.6,0,.4,1) forwards; }\n.hb-vf5[data-stage=\"sent\"] .hb-vf5-sheet { opacity: 0; animation: none; }\n.hb-vf5-env { position: absolute; left: 0; top: 0; width: 52px; height: 36px; offset-path: path(\"M42 84 C 110 -8, 226 -12, 294 74\"); offset-rotate: auto; offset-distance: 0%; opacity: 0; }\n.hb-vf5[data-stage=\"sending\"] .hb-vf5-env { animation: hb-vf5-fly 1.3s .35s cubic-bezier(.55,0,.3,1) forwards; }\n.hb-vf5-env svg { display: block; width: 100%; height: 100%; transform: rotate(0deg); filter: drop-shadow(0 8px 14px rgba(0,0,0,.6)); }\n.hb-vf5-tray { position: absolute; right: 8px; top: 48px; width: 76px; height: 62px; display: grid; place-items: center; border-radius: 16px; border: 1px solid #2a2622; background: linear-gradient(180deg, #1a1715, #121110); transition: border-color .5s, box-shadow .5s; }\n.hb-vf5[data-stage=\"sent\"] .hb-vf5-tray { border-color: color-mix(in srgb, var(--hb-vf5-accent) 55%, #2a2622); box-shadow: 0 0 40px -10px var(--hb-vf5-accent), inset 0 1px 0 rgba(255,255,255,.06); animation: hb-vf5-catch .5s cubic-bezier(.3,1.6,.5,1); }\n.hb-vf5-tray svg { color: #8f8a85; transition: color .5s; }\n.hb-vf5[data-stage=\"sent\"] .hb-vf5-tray svg { color: #ededed; }\n.hb-vf5-badge { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--hb-vf5-accent); color: #1a0d05; font-size: 12px; font-weight: 700; box-shadow: 0 0 0 3px #121110; transform: scale(0); transition: transform .45s .1s cubic-bezier(.3,1.7,.5,1); }\n.hb-vf5[data-stage=\"sent\"] .hb-vf5-badge { transform: scale(1); }\n.hb-vf5-from { position: absolute; left: 12px; top: 112px; font-size: 10.5px; color: #6f6964; font-family: var(--font-mono), ui-monospace, monospace; }\n.hb-vf5-to { position: absolute; right: 0; top: 116px; width: 92px; text-align: center; font-size: 10.5px; color: #6f6964; font-family: var(--font-mono), ui-monospace, monospace; }\n.hb-vf5-title { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -.025em; }\n.hb-vf5-sub { margin: 8px 0 20px; color: #9a948f; font-size: 14px; line-height: 1.55; }\n.hb-vf5-sub b { color: #ededed; font-weight: 500; }\n.hb-vf5-field { position: relative; }\n.hb-vf5-input { width: 100%; height: 50px; padding: 0 128px 0 16px; border-radius: 14px; border: 1px solid #2a2622; background: #0c0b0a; color: #ededed; font: inherit; font-size: 14.5px; outline: none; transition: border-color .2s, box-shadow .2s; }\n.hb-vf5-input::placeholder { color: #5f5954; }\n.hb-vf5-input:focus { border-color: var(--hb-vf5-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hb-vf5-accent) 16%, transparent); }\n.hb-vf5-input[aria-invalid=\"true\"] { border-color: #ef5f5f; }\n.hb-vf5-send { position: absolute; right: 5px; top: 5px; height: 40px; padding: 0 16px; border: 0; border-radius: 10px; display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 13.5px; font-weight: 600; color: #1a0d05; background: var(--hb-vf5-accent); cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.4); transition: filter .2s, transform .2s cubic-bezier(.2,.8,.2,1); }\n.hb-vf5-send:hover { filter: brightness(1.08); }\n.hb-vf5-send:active { transform: scale(.97); }\n.hb-vf5-send:disabled { cursor: progress; }\n.hb-vf5-send svg { transition: transform .3s cubic-bezier(.2,.8,.2,1); }\n.hb-vf5-send:hover svg { transform: translate(2px, -2px); }\n.hb-vf5-err { margin: 8px 0 0; font-size: 12.5px; color: #f39494; }\n.hb-vf5-note { margin: 14px 0 0; font-size: 12.5px; color: #6f6964; line-height: 1.5; }\n.hb-vf5-exp { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; border: 1px solid #242120; background: #0d0c0b; }\n.hb-vf5-exp-row { display: flex; justify-content: space-between; font-size: 12.5px; color: #9a948f; margin-bottom: 9px; }\n.hb-vf5-exp-row b { font-family: var(--font-mono), ui-monospace, monospace; font-weight: 500; color: #ededed; }\n.hb-vf5-bar { height: 4px; border-radius: 4px; background: #221f1d; overflow: hidden; }\n.hb-vf5-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--hb-vf5-accent), #ffd28a); transform-origin: 0 50%; transition: transform 1s linear; }\n.hb-vf5-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }\n.hb-vf5-open, .hb-vf5-ghost { height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; transition: filter .2s, background .2s, border-color .2s, transform .2s cubic-bezier(.2,.8,.2,1); }\n.hb-vf5-open { color: #1a0d05; background: var(--hb-vf5-accent); border: 0; box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 12px 28px -14px var(--hb-vf5-accent); }\n.hb-vf5-open:hover { filter: brightness(1.07); }\n.hb-vf5-ghost { color: #ededed; background: #141210; border: 1px solid #2a2622; }\n.hb-vf5-ghost:hover:not(:disabled) { background: #1b1816; border-color: #3a3430; }\n.hb-vf5-ghost:disabled { color: #6f6964; cursor: not-allowed; }\n.hb-vf5-open:active, .hb-vf5-ghost:active:not(:disabled) { transform: scale(.985); }\n.hb-vf5-change { display: block; margin: 16px auto 0; border: 0; background: none; color: #9a948f; font: inherit; font-size: 13px; cursor: pointer; border-radius: 6px; }\n.hb-vf5-change:hover { color: #ededed; }\n.hb-vf5 :is(.hb-vf5-send, .hb-vf5-open, .hb-vf5-ghost, .hb-vf5-change):focus-visible { outline: 2px solid var(--hb-vf5-accent); outline-offset: 3px; }\n.hb-vf5-swap { animation: hb-vf5-in .5s cubic-bezier(.2,.8,.2,1) both; }\n@keyframes hb-vf5-hover { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(-2deg); } }\n@keyframes hb-vf5-fold { 0% { transform: rotate(-4deg); } 60% { transform: scaleY(.55) rotate(0deg); opacity: 1; } 100% { transform: scaleY(.3) translateY(-20px); opacity: 0; } }\n@keyframes hb-vf5-fly { 0% { offset-distance: 0%; opacity: 0; transform: scale(.7); } 12% { opacity: 1; transform: scale(1); } 85% { opacity: 1; transform: scale(.85); } 100% { offset-distance: 100%; opacity: 0; transform: scale(.4); } }\n@keyframes hb-vf5-trail { to { stroke-dashoffset: 0; } }\n@keyframes hb-vf5-catch { 0% { transform: scale(1); } 40% { transform: scale(1.08) translateY(2px); } 100% { transform: scale(1); } }\n@keyframes hb-vf5-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-vf5 *, .hb-vf5 *::before, .hb-vf5 *::after { animation: none !important; transition: none !important; }\n  .hb-vf5-env { display: none; }\n}\n`;\n\nconst isEmail = (v: string) => /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/.test(v.trim());\nconst wait = (ms: number) => new Promise((r) => setTimeout(r, ms));\nconst mmss = (s: number) => `${String(Math.floor(s / 60)).padStart(2, \"0\")}:${String(s % 60).padStart(2, \"0\")}`;\n\nexport function AuthMagicFlight({\n  brand = \"Parcel\",\n  title = \"Sign in with a link\",\n  subtitle = \"Enter your email and we will send a one-tap sign-in link. No password to remember.\",\n  sender = \"login@parcel.app\",\n  expiresMinutes = 15,\n  resendSeconds = 30,\n  mailHref = \"mailto:\",\n  defaultEmail = \"\",\n  defaultSent = false,\n  onSend,\n  onResend,\n  accent = \"#ff8a4c\",\n  className,\n  style,\n  ...rest\n}: AuthMagicFlightProps) {\n  const id = React.useId();\n  const [email, setEmail] = React.useState(defaultEmail || (defaultSent ? \"maya@parcel.app\" : \"\"));\n  const [stage, setStage] = React.useState<\"idle\" | \"sending\" | \"sent\">(defaultSent ? \"sent\" : \"idle\");\n  const [touched, setTouched] = React.useState(false);\n  const [error, setError] = React.useState<string | null>(null);\n  const [elapsed, setElapsed] = React.useState(0);\n  const [resendAt, setResendAt] = React.useState(resendSeconds);\n  const sentAt = React.useRef(0);\n\n  React.useEffect(() => {\n    if (stage !== \"sent\") return;\n    if (!sentAt.current) sentAt.current = performance.now();\n    const t = window.setInterval(() => setElapsed(Math.floor((performance.now() - sentAt.current) / 1000)), 500);\n    return () => window.clearInterval(t);\n  }, [stage]);\n\n  const total = expiresMinutes * 60;\n  const remaining = Math.max(0, total - elapsed);\n  const cooldown = Math.max(0, resendAt - elapsed);\n\n  const send = async (e: React.FormEvent) => {\n    e.preventDefault();\n    setTouched(true);\n    setError(null);\n    if (!isEmail(email)) return;\n    setStage(\"sending\");\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    try {\n      const [r] = await Promise.all([onSend ? onSend(email.trim()) : wait(400).then(() => true), wait(reduce ? 0 : 1700)]);\n      if (r === false) {\n        setStage(\"idle\");\n        setError(\"We could not send a link to that address.\");\n        return;\n      }\n      sentAt.current = performance.now();\n      setElapsed(0);\n      setResendAt(resendSeconds);\n      setStage(\"sent\");\n    } catch (err) {\n      setStage(\"idle\");\n      setError(err instanceof Error ? err.message : \"Something went wrong. Try again.\");\n    }\n  };\n\n  const resend = () => {\n    if (cooldown > 0) return;\n    onResend?.(email.trim());\n    sentAt.current = performance.now();\n    setElapsed(0);\n    setResendAt(resendSeconds);\n  };\n\n  const reset = () => {\n    sentAt.current = 0;\n    setElapsed(0);\n    setStage(\"idle\");\n    setTouched(false);\n  };\n\n  const bad = touched && !isEmail(email);\n\n  return (\n    <section className={[\"hb-vf5\", className].filter(Boolean).join(\" \")} data-stage={stage} style={{ \"--hb-vf5-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-auth-magic-flight\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vf5-card\">\n        <div className=\"hb-vf5-brand\"><i aria-hidden=\"true\" />{brand}</div>\n        <div className=\"hb-vf5-stage\" aria-hidden=\"true\">\n          <svg className=\"hb-vf5-path\" viewBox=\"0 0 340 132\">\n            <path className=\"hb-vf5-route\" d=\"M42 84 C 110 -8, 226 -12, 294 74\" />\n            <path className=\"hb-vf5-trail\" d=\"M42 84 C 110 -8, 226 -12, 294 74\" />\n          </svg>\n          <div className=\"hb-vf5-sheet\"><span /><span /><span /><span /></div>\n          <div className=\"hb-vf5-env\">\n            <svg viewBox=\"0 0 52 36\" fill=\"none\">\n              <rect x=\"1\" y=\"1\" width=\"50\" height=\"34\" rx=\"5\" fill=\"#f6efe8\" />\n              <path d=\"M2 4l24 17L50 4\" stroke={accent} strokeWidth=\"2.4\" strokeLinejoin=\"round\" />\n              <path d=\"M2 33l17-14M50 33 33 19\" stroke=\"#d6cabd\" strokeWidth=\"1.6\" />\n            </svg>\n          </div>\n          <div className=\"hb-vf5-tray\">\n            <svg width=\"34\" height=\"28\" viewBox=\"0 0 34 28\" fill=\"none\">\n              <path d=\"M3 15 8 3h18l5 12v8a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3Z\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinejoin=\"round\" />\n              <path d=\"M3 15h8l2 4h8l2-4h8\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinejoin=\"round\" />\n            </svg>\n            <span className=\"hb-vf5-badge\">1</span>\n          </div>\n          <span className=\"hb-vf5-from\">{sender}</span>\n          <span className=\"hb-vf5-to\">Inbox</span>\n        </div>\n        {stage === \"sent\" ? (\n          <div className=\"hb-vf5-swap\" role=\"status\">\n            <h2 className=\"hb-vf5-title\">Check your inbox</h2>\n            <p className=\"hb-vf5-sub\">We sent a sign-in link to <b>{email.trim()}</b>. Open it on this device to continue.</p>\n            <div className=\"hb-vf5-exp\">\n              <div className=\"hb-vf5-exp-row\"><span>{remaining > 0 ? \"Link expires in\" : \"Link expired\"}</span><b>{mmss(remaining)}</b></div>\n              <div className=\"hb-vf5-bar\"><i style={{ transform: `scaleX(${(remaining / total).toFixed(4)})` }} /></div>\n            </div>\n            <div className=\"hb-vf5-actions\">\n              <a className=\"hb-vf5-open\" href={mailHref}>\n                <svg width=\"15\" height=\"15\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\"><path d=\"M6 3H3.5A1.5 1.5 0 0 0 2 4.5v8A1.5 1.5 0 0 0 3.5 14h8a1.5 1.5 0 0 0 1.5-1.5V10M9 2h5v5M14 2 7.5 8.5\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n                Open mail\n              </a>\n              <button type=\"button\" className=\"hb-vf5-ghost\" onClick={resend} disabled={cooldown > 0}>{cooldown > 0 ? `Resend in ${cooldown}s` : \"Resend link\"}</button>\n            </div>\n            <button type=\"button\" className=\"hb-vf5-change\" onClick={reset}>Use a different email</button>\n          </div>\n        ) : (\n          <form className=\"hb-vf5-swap\" onSubmit={send} noValidate>\n            <h2 className=\"hb-vf5-title\">{title}</h2>\n            <p className=\"hb-vf5-sub\">{subtitle}</p>\n            <div className=\"hb-vf5-field\">\n              <label htmlFor={`${id}-e`} style={{ position: \"absolute\", width: 1, height: 1, overflow: \"hidden\", clip: \"rect(0 0 0 0)\" }}>Email address</label>\n              <input id={`${id}-e`} className=\"hb-vf5-input\" type=\"email\" autoComplete=\"email\" placeholder=\"you@company.com\" value={email} onChange={(e) => setEmail(e.target.value)} disabled={stage === \"sending\"} aria-invalid={bad ? true : undefined} aria-describedby={bad ? `${id}-err` : undefined} />\n              <button type=\"submit\" className=\"hb-vf5-send\" disabled={stage === \"sending\"} aria-busy={stage === \"sending\"}>\n                {stage === \"sending\" ? \"Sending\" : \"Send link\"}\n                <svg width=\"13\" height=\"13\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\"><path d=\"M2 8.5 14 2l-4 12-2.5-5Z\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinejoin=\"round\" /></svg>\n              </button>\n            </div>\n            {bad ? <p id={`${id}-err`} className=\"hb-vf5-err\" role=\"alert\">Enter the email you use for {brand}.</p> : null}\n            {error ? <p className=\"hb-vf5-err\" role=\"alert\">{error}</p> : null}\n            <p className=\"hb-vf5-note\">Links expire after {expiresMinutes} minutes and work once. We will never ask for your password by email.</p>\n          </form>\n        )}\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}