{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "download-qr-handoff",
  "type": "registry:component",
  "title": "Download QR Handoff",
  "description": "A continue on your phone card with a QR pattern built from the link, a scan line sweeping over it and a countdown that refreshes the code. A text me a link form and a phone preview of the session sit alongside.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "download",
    "qr code",
    "handoff",
    "mobile",
    "scan",
    "sms link",
    "download"
  ],
  "docs": "https://hyperblur.dev/effects/download-qr-handoff",
  "files": [
    {
      "path": "registry/hyperblur/download-qr-handoff.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/download-qr-handoff.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface DownloadQrHandoffProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  url?: string;\n  steps?: string[];\n  refreshSeconds?: number;\n  session?: { title: string; detail: string };\n  onSend?: (phone: string) => void;\n  storeLinks?: { label: string; href: string }[];\n  accent?: string;\n}\n\nconst css = `\n.hb-yhc {\n  --hb-yhc-accent: #8b5cf6;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  overflow: hidden;\n  padding: clamp(64px, 8cqi, 104px) 20px;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-yhc *, .hb-yhc *::before, .hb-yhc *::after { box-sizing: border-box; }\n.hb-yhc-in {\n  position: relative;\n  display: grid;\n  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n  gap: 40px;\n  align-items: center;\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: clamp(28px, 4.5cqi, 56px);\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 28px;\n  background:\n    radial-gradient(60% 80% at 100% 50%, color-mix(in srgb, var(--hb-yhc-accent) 24%, transparent), transparent 70%),\n    radial-gradient(40% 50% at 0% 0%, rgba(56,189,248,.08), transparent 70%),\n    linear-gradient(180deg, #121212, #0c0c0c);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);\n  overflow: hidden;\n}\n.hb-yhc-in::before { content: \"\"; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px); background-size: 32px 32px; -webkit-mask-image: radial-gradient(50% 70% at 80% 50%, #000, transparent); mask-image: radial-gradient(50% 70% at 80% 50%, #000, transparent); pointer-events: none; }\n.hb-yhc-copy { position: relative; min-width: 0; }\n.hb-yhc-eyebrow { display: inline-flex; align-items: center; gap: 8px; color: #a1a1a1; font-size: 13px; font-weight: 500; }\n.hb-yhc-eyebrow svg { width: 15px; height: 15px; fill: none; stroke: var(--hb-yhc-accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }\n.hb-yhc-title { margin: 14px 0 0; font-size: clamp(28px, 4cqi, 44px); font-weight: 650; letter-spacing: -.035em; line-height: 1.06; }\n.hb-yhc-sub { margin: 12px 0 0; max-width: 440px; color: #8f8f8f; font-size: 15px; line-height: 1.6; }\n.hb-yhc-steps { display: grid; gap: 12px; margin: 26px 0 0; padding: 0; list-style: none; counter-reset: hb-yhc-n; }\n.hb-yhc-step { display: flex; align-items: center; gap: 12px; color: #c9c9c9; font-size: 14px; counter-increment: hb-yhc-n; }\n.hb-yhc-step::before { content: counter(hb-yhc-n); display: grid; place-items: center; flex: none; width: 26px; height: 26px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; background: rgba(255,255,255,.04); color: #ededed; font-size: 12px; font-weight: 650; }\n.hb-yhc-form { display: flex; gap: 8px; max-width: 420px; margin-top: 28px; padding: 5px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; background: rgba(0,0,0,.35); transition: border-color .2s ease, box-shadow .2s ease; }\n.hb-yhc-form:focus-within { border-color: color-mix(in srgb, var(--hb-yhc-accent) 60%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hb-yhc-accent) 18%, transparent); }\n.hb-yhc-input { flex: 1; min-width: 0; height: 40px; padding: 0 14px; border: 0; background: transparent; color: #ededed; font: inherit; font-size: 14px; outline: none; }\n.hb-yhc-input::placeholder { color: #6f6f6f; }\n.hb-yhc-send { flex: none; height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: #ededed; color: #0a0a0a; font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer; transition: background-color .2s ease, transform .15s ease; }\n.hb-yhc-send:hover { background: #fff; }\n.hb-yhc-send:active { transform: scale(.97); }\n.hb-yhc-send:focus-visible, .hb-yhc-store:focus-visible { outline: 2px solid var(--hb-yhc-accent); outline-offset: 2px; }\n.hb-yhc-msg { min-height: 20px; margin: 10px 0 0 6px; color: #8f8f8f; font-size: 12.5px; }\n.hb-yhc-msg[data-ok=\"true\"] { color: color-mix(in srgb, var(--hb-yhc-accent) 55%, #fff); }\n.hb-yhc-stores { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }\n.hb-yhc-store { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; color: #c4c4c4; font-size: 12.5px; font-weight: 600; text-decoration: none; transition: border-color .2s ease, color .2s ease; }\n.hb-yhc-store:hover { border-color: rgba(255,255,255,.22); color: #fff; }\n.hb-yhc-store svg { width: 14px; height: 14px; fill: currentColor; }\n.hb-yhc-vis { position: relative; display: flex; justify-content: center; align-items: center; min-height: 400px; }\n.hb-yhc-card {\n  position: relative;\n  z-index: 2;\n  width: 270px;\n  padding: 20px;\n  border: 1px solid rgba(255,255,255,.12);\n  border-radius: 26px;\n  background: linear-gradient(180deg, rgba(30,30,34,.92), rgba(18,18,20,.94));\n  backdrop-filter: blur(12px);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 40px 80px -30px rgba(0,0,0,.9), 0 0 60px -20px color-mix(in srgb, var(--hb-yhc-accent) 50%, transparent);\n  animation: hb-yhc-float 7s ease-in-out infinite;\n}\n.hb-yhc-qr { position: relative; padding: 14px; border-radius: 18px; background: #fff; overflow: hidden; }\n.hb-yhc-qr svg { display: block; width: 100%; height: auto; }\n.hb-yhc-mod { fill: #0a0a0a; transition: opacity .4s ease; }\n.hb-yhc-qr[data-fresh=\"true\"] .hb-yhc-mod { animation: hb-yhc-fresh .6s ease; }\n.hb-yhc-logo { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 46px; height: 46px; border: 4px solid #fff; border-radius: 13px; background: linear-gradient(135deg, var(--hb-yhc-accent), #312e81); color: #fff; transform: translate(-50%, -50%); }\n.hb-yhc-logo svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }\n.hb-yhc-scan { position: absolute; left: 6px; right: 6px; top: 0; height: 2px; border-radius: 2px; background: var(--hb-yhc-accent); box-shadow: 0 0 12px 2px color-mix(in srgb, var(--hb-yhc-accent) 70%, transparent); animation: hb-yhc-scan 2.6s cubic-bezier(.45,0,.55,1) infinite; pointer-events: none; }\n.hb-yhc-scan::after { content: \"\"; position: absolute; left: 0; right: 0; bottom: 2px; height: 46px; background: linear-gradient(0deg, color-mix(in srgb, var(--hb-yhc-accent) 22%, transparent), transparent); }\n.hb-yhc-br { position: absolute; width: 22px; height: 22px; border: 3px solid var(--hb-yhc-accent); pointer-events: none; }\n.hb-yhc-br[data-c=\"tl\"] { top: 6px; left: 6px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }\n.hb-yhc-br[data-c=\"tr\"] { top: 6px; right: 6px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }\n.hb-yhc-br[data-c=\"bl\"] { bottom: 6px; left: 6px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }\n.hb-yhc-br[data-c=\"br\"] { bottom: 6px; right: 6px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }\n.hb-yhc-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; color: #8f8f8f; font-size: 12px; }\n.hb-yhc-meta b { color: #ededed; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-yhc-tbar { height: 3px; margin-top: 8px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }\n.hb-yhc-tbar i { display: block; height: 100%; width: calc(var(--hb-yhc-t) * 100%); border-radius: inherit; background: var(--hb-yhc-accent); transition: width 1s linear; }\n.hb-yhc-phone { position: absolute; z-index: 1; right: 2%; bottom: 0; width: 150px; height: 300px; padding: 7px; border-radius: 30px; background: linear-gradient(145deg, #2b2b2e, #141416); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1), 0 30px 60px -20px rgba(0,0,0,.9); transform: rotate(8deg); opacity: .9; }\n.hb-yhc-ps { height: 100%; padding: 30px 12px 12px; border-radius: 24px; background: linear-gradient(180deg, #17151f, #0d0c12); overflow: hidden; }\n.hb-yhc-pk { color: color-mix(in srgb, var(--hb-yhc-accent) 60%, #fff); font-size: 9px; font-weight: 700; letter-spacing: .08em; }\n.hb-yhc-pt { margin-top: 6px; font-size: 12px; font-weight: 650; line-height: 1.3; }\n.hb-yhc-pd { margin-top: 4px; color: #8f8f8f; font-size: 9.5px; }\n.hb-yhc-slide { height: 70px; margin-top: 12px; border-radius: 10px; background: linear-gradient(135deg, color-mix(in srgb, var(--hb-yhc-accent) 60%, #0a0a0a), #1e1b4b); }\n.hb-yhc-pl { height: 6px; margin-top: 8px; border-radius: 3px; background: rgba(255,255,255,.08); }\n.hb-yhc-pb { display: block; height: 26px; margin-top: 14px; border-radius: 99px; background: var(--hb-yhc-accent); color: #fff; font-size: 9.5px; font-weight: 650; line-height: 26px; text-align: center; }\n.hb-yhc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-yhc-scan { 0% { top: 8px; } 50% { top: calc(100% - 10px); } 100% { top: 8px; } }\n@keyframes hb-yhc-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(-1deg); } }\n@keyframes hb-yhc-fresh { from { opacity: 0; } to { opacity: 1; } }\n@container (max-width: 860px) {\n  .hb-yhc-in { grid-template-columns: minmax(0, 1fr); }\n  .hb-yhc-vis { min-height: 380px; }\n}\n@container (max-width: 480px) {\n  .hb-yhc-phone { display: none; }\n  .hb-yhc-form { flex-direction: column; border-radius: 18px; }\n  .hb-yhc-send { width: 100%; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-yhc *, .hb-yhc *::before, .hb-yhc *::after { animation: none !important; transition: none !important; }\n  .hb-yhc-scan { top: 50%; }\n}\n`;\n\nconst SIZE = 25;\n\nfunction seedOf(s: string) {\n  let h = 2166136261;\n  for (let i = 0; i < s.length; i++) {\n    h ^= s.charCodeAt(i);\n    h = Math.imul(h, 16777619);\n  }\n  return h >>> 0;\n}\n\nfunction bit(seed: number, x: number, y: number) {\n  let h = (seed ^ Math.imul(x + 1, 374761393) ^ Math.imul(y + 1, 668265263)) >>> 0;\n  h = Math.imul(h ^ (h >>> 13), 1274126177) >>> 0;\n  h = (h ^ (h >>> 16)) >>> 0;\n  return (h & 7) < 4;\n}\n\nfunction inFinder(x: number, y: number) {\n  const zones = [\n    [0, 0],\n    [SIZE - 7, 0],\n    [0, SIZE - 7],\n  ];\n  for (const [fx, fy] of zones) {\n    if (x >= fx! - 1 && x <= fx! + 7 && y >= fy! - 1 && y <= fy! + 7) {\n      const dx = x - fx!;\n      const dy = y - fy!;\n      if (dx < 0 || dy < 0 || dx > 6 || dy > 6) return 0;\n      const ring = Math.min(dx, dy, 6 - dx, 6 - dy);\n      return ring === 1 ? 0 : 1;\n    }\n  }\n  return -1;\n}\n\nfunction buildPath(text: string) {\n  const seed = seedOf(text);\n  let d = \"\";\n  const c0 = Math.floor(SIZE / 2) - 3;\n  const c1 = Math.floor(SIZE / 2) + 3;\n  for (let y = 0; y < SIZE; y++) {\n    for (let x = 0; x < SIZE; x++) {\n      let on: boolean;\n      const f = inFinder(x, y);\n      if (f !== -1) on = f === 1;\n      else if (x >= c0 && x <= c1 && y >= c0 && y <= c1) on = false;\n      else if (x >= 16 && x <= 20 && y >= 16 && y <= 20) {\n        const ring = Math.max(Math.abs(x - 18), Math.abs(y - 18));\n        on = ring !== 1;\n      } else if (y === 6) on = x % 2 === 0;\n      else if (x === 6) on = y % 2 === 0;\n      else on = bit(seed, x, y);\n      if (on) d += `M${x} ${y}h1v1h-1z`;\n    }\n  }\n  return d;\n}\n\nconst defaultSteps = [\"Open the camera on your phone\", \"Point it at the code\", \"Tap the banner to pick up right where you are\"];\n\nconst defaultStores = [\n  { label: \"iPhone\", href: \"#\" },\n  { label: \"Android\", href: \"#\" },\n];\n\nexport function DownloadQrHandoff({\n  eyebrow = \"Slate for mobile\",\n  title = \"Continue on your phone in one scan\",\n  subtitle = \"Your open document, scroll position and unsaved comments travel with you. No sign in, no typing.\",\n  url = \"https://slate.so/h/7KQ2-M9XW\",\n  steps = defaultSteps,\n  refreshSeconds = 60,\n  session = { title: \"Q3 board deck\", detail: \"Slide 14 of 32, 3 comments\" },\n  onSend,\n  storeLinks = defaultStores,\n  accent = \"#8b5cf6\",\n  className = \"\",\n  style,\n  ...rest\n}: DownloadQrHandoffProps) {\n  const uid = React.useId();\n  const [tick, setTick] = React.useState(0);\n  const [phone, setPhone] = React.useState(\"\");\n  const [sent, setSent] = React.useState<string | null>(null);\n  const [error, setError] = React.useState<string | null>(null);\n  const period = Math.max(0, Math.round(refreshSeconds));\n  const gen = period > 0 ? Math.floor(tick / period) : 0;\n  const left = period > 0 ? period - (tick % period) : 0;\n\n  React.useEffect(() => {\n    if (period <= 0) return;\n    const id = window.setInterval(() => setTick((t) => t + 1), 1000);\n    return () => window.clearInterval(id);\n  }, [period]);\n\n  const path = React.useMemo(() => buildPath(`${url}#${gen}`), [url, gen]);\n\n  function submit(e: React.FormEvent) {\n    e.preventDefault();\n    const digits = phone.replace(/\\D/g, \"\");\n    if (digits.length < 7) {\n      setError(\"Enter a full phone number, including the area code.\");\n      setSent(null);\n      return;\n    }\n    setError(null);\n    setSent(digits.slice(-4));\n    onSend?.(phone.trim());\n  }\n\n  const mm = Math.floor(left / 60);\n  const ss = String(left % 60).padStart(2, \"0\");\n\n  return (\n    <section className={`hb-yhc ${className}`} style={{ \"--hb-yhc-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-download-qr-handoff\" precedence=\"default\">\n        {css}\n      </style>\n      <div className=\"hb-yhc-in\">\n        <div className=\"hb-yhc-copy\">\n          <span className=\"hb-yhc-eyebrow\">\n            <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n              <rect x=\"4\" y=\"1.5\" width=\"8\" height=\"13\" rx=\"2\" />\n              <path d=\"M7 12h2\" />\n            </svg>\n            {eyebrow}\n          </span>\n          <h2 className=\"hb-yhc-title\">{title}</h2>\n          {subtitle && <p className=\"hb-yhc-sub\">{subtitle}</p>}\n          <ol className=\"hb-yhc-steps\">\n            {steps.map((s) => (\n              <li key={s} className=\"hb-yhc-step\">\n                {s}\n              </li>\n            ))}\n          </ol>\n          <form className=\"hb-yhc-form\" onSubmit={submit} noValidate>\n            <label htmlFor={`${uid}-phone`} className=\"hb-yhc-sr\">\n              Phone number\n            </label>\n            <input\n              id={`${uid}-phone`}\n              className=\"hb-yhc-input\"\n              type=\"tel\"\n              inputMode=\"tel\"\n              autoComplete=\"tel\"\n              placeholder=\"Or text me a link: +1 555 014 2297\"\n              value={phone}\n              onChange={(e) => setPhone(e.target.value)}\n              aria-invalid={error ? true : undefined}\n              aria-describedby={`${uid}-msg`}\n            />\n            <button type=\"submit\" className=\"hb-yhc-send\">\n              Send link\n            </button>\n          </form>\n          <p id={`${uid}-msg`} className=\"hb-yhc-msg\" data-ok={sent ? \"true\" : \"false\"} aria-live=\"polite\">\n            {error ?? (sent ? `Link sent to the number ending in ${sent}.` : \"We only use your number to send this link.\")}\n          </p>\n          {storeLinks.length > 0 && (\n            <div className=\"hb-yhc-stores\">\n              {storeLinks.map((s) => (\n                <a key={s.label} href={s.href} className=\"hb-yhc-store\">\n                  <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n                    <path d=\"M8 1.5v8.2M4.8 6.6 8 9.8l3.2-3.2M2.5 12.5h11v2h-11z\" />\n                  </svg>\n                  Get it for {s.label}\n                </a>\n              ))}\n            </div>\n          )}\n        </div>\n        <div className=\"hb-yhc-vis\">\n          <div className=\"hb-yhc-phone\" aria-hidden=\"true\">\n            <div className=\"hb-yhc-ps\">\n              <div className=\"hb-yhc-pk\">READY ON PHONE</div>\n              <div className=\"hb-yhc-pt\">{session.title}</div>\n              <div className=\"hb-yhc-pd\">{session.detail}</div>\n              <div className=\"hb-yhc-slide\" />\n              <div className=\"hb-yhc-pl\" style={{ width: \"86%\" }} />\n              <div className=\"hb-yhc-pl\" style={{ width: \"64%\" }} />\n              <span className=\"hb-yhc-pb\">Continue here</span>\n            </div>\n          </div>\n          <div className=\"hb-yhc-card\">\n            <div className=\"hb-yhc-qr\" key={gen} data-fresh={gen > 0 ? \"true\" : \"false\"} role=\"img\" aria-label={`QR code that opens ${url}`}>\n              <svg viewBox={`-1 -1 ${SIZE + 2} ${SIZE + 2}`} shapeRendering=\"crispEdges\" aria-hidden=\"true\">\n                <path className=\"hb-yhc-mod\" d={path} />\n              </svg>\n              <span className=\"hb-yhc-logo\" aria-hidden=\"true\">\n                <svg viewBox=\"0 0 16 16\">\n                  <path d=\"M11.5 4.5c-.8-1-2-1.5-3.5-1.5-2 0-3.5 1-3.5 2.5 0 3.5 7 2 7 5.5 0 1.5-1.5 2.5-3.5 2.5-1.6 0-2.9-.6-3.7-1.6\" />\n                </svg>\n              </span>\n              <span className=\"hb-yhc-scan\" aria-hidden=\"true\" />\n              <span className=\"hb-yhc-br\" data-c=\"tl\" aria-hidden=\"true\" />\n              <span className=\"hb-yhc-br\" data-c=\"tr\" aria-hidden=\"true\" />\n              <span className=\"hb-yhc-br\" data-c=\"bl\" aria-hidden=\"true\" />\n              <span className=\"hb-yhc-br\" data-c=\"br\" aria-hidden=\"true\" />\n            </div>\n            {period > 0 && (\n              <>\n                <div className=\"hb-yhc-meta\">\n                  <span>Code refreshes in</span>\n                  <b>\n                    {mm}:{ss}\n                  </b>\n                </div>\n                <div className=\"hb-yhc-tbar\" aria-hidden=\"true\">\n                  <i style={{ \"--hb-yhc-t\": (left / period).toFixed(3) } as React.CSSProperties} />\n                </div>\n              </>\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}