{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "waitlist-referral-ladder",
  "type": "registry:component",
  "title": "Waitlist Referral Ladder",
  "description": "A referral waitlist where rewards are rungs on a vertical ladder and a marker climbs the rail as friends join. After signing up you get your place, a copyable link and an email chip field to send invites.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "waitlist",
    "waitlist",
    "referral",
    "rewards",
    "progress",
    "invite",
    "section"
  ],
  "docs": "https://hyperblur.dev/effects/waitlist-referral-ladder",
  "files": [
    {
      "path": "registry/hyperblur/waitlist-referral-ladder.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/waitlist-referral-ladder.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface WaitlistLadderRung {\n  at: number;\n  title: string;\n  detail: string;\n}\n\nexport interface WaitlistReferralLadderProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  rungs?: WaitlistLadderRung[];\n  basePosition?: number;\n  spotsPerReferral?: number;\n  referrals?: number;\n  defaultReferrals?: number;\n  defaultJoined?: boolean;\n  referralBase?: string;\n  simulateJoins?: boolean;\n  onJoin?: (email: string) => void | Promise<void>;\n  onInvite?: (emails: string[]) => void;\n  onLinkCopy?: (link: string) => void;\n  accent?: string;\n}\n\nconst defaultRungs: WaitlistLadderRung[] = [\n  { at: 0, title: \"On the list\", detail: \"Your spot is saved\" },\n  { at: 1, title: \"Skip 250 spots\", detail: \"Per friend who joins\" },\n  { at: 3, title: \"Wave one access\", detail: \"In before the public beta\" },\n  { at: 5, title: \"Founding badge\", detail: \"On your profile, forever\" },\n  { at: 10, title: \"A year of Pro\", detail: \"Worth 144 dollars\" },\n];\n\nconst css = `\n@keyframes hb-wd8-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }\n@keyframes hb-wd8-shine { from { transform: translateY(100%); } to { transform: translateY(-100%); } }\n@keyframes hb-wd8-burst { 0% { transform: scale(0.4); opacity: 0.9; } 100% { transform: scale(2.4); opacity: 0; } }\n@keyframes hb-wd8-spin { to { transform: rotate(360deg); } }\n.hb-wd8 {\n  --hb-wd8-accent: #a3e635;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  overflow: hidden;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-wd8 *, .hb-wd8 *::before, .hb-wd8 *::after { box-sizing: border-box; }\n.hb-wd8::before { content: \"\"; position: absolute; right: -10%; bottom: -30%; width: 60%; height: 90%; background: radial-gradient(closest-side, color-mix(in srgb, var(--hb-wd8-accent) 12%, transparent), transparent); pointer-events: none; }\n.hb-wd8-in { position: relative; max-width: 1120px; margin: 0 auto; padding: 76px 20px 92px; display: grid; gap: 44px; align-items: center; }\n@container (min-width: 880px) { .hb-wd8-in { grid-template-columns: 1.05fr 1fr; gap: 72px; } }\n.hb-wd8-eyebrow { font: 500 12px/1 var(--font-mono, monospace); letter-spacing: 0.08em; text-transform: uppercase; color: var(--hb-wd8-accent); }\n.hb-wd8-title { margin: 14px 0 14px; font: 600 clamp(32px, 5cqw, 54px)/1 var(--font-grotesk, inherit); letter-spacing: -0.035em; }\n.hb-wd8-sub { margin: 0 0 26px; color: #8f8f8f; font-size: 15.5px; line-height: 1.6; max-width: 42ch; }\n.hb-wd8-form { display: flex; gap: 8px; max-width: 440px; flex-wrap: wrap; }\n.hb-wd8-input { flex: 1 1 220px; min-width: 0; height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: #121212; color: #ededed; font: 400 15px/1 inherit; font-family: inherit; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }\n.hb-wd8-input::placeholder { color: #5e5e5e; }\n.hb-wd8-input:focus { border-color: color-mix(in srgb, var(--hb-wd8-accent) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-wd8-accent) 18%, transparent); }\n.hb-wd8-btn { appearance: none; border: 0; height: 48px; padding: 0 20px; border-radius: 12px; background: var(--hb-wd8-accent); color: #0b1203; font: 600 14px/1 inherit; font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 10px 26px -12px var(--hb-wd8-accent); transition: transform 0.2s cubic-bezier(0.34, 1.4, 0.5, 1), filter 0.2s ease; }\n.hb-wd8-btn:hover { filter: brightness(1.06); }\n.hb-wd8-btn:active { transform: scale(0.97); }\n.hb-wd8-btn:focus-visible { outline: 2px solid #ededed; outline-offset: 3px; }\n.hb-wd8-ghost { background: #171717; color: #ededed; box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); }\n.hb-wd8-spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(11,18,3,0.25); border-top-color: #0b1203; animation: hb-wd8-spin 0.7s linear infinite; }\n.hb-wd8-err { margin: 8px 0 0; font-size: 12.5px; color: #f87171; }\n.hb-wd8-me { display: grid; gap: 14px; max-width: 460px; padding: 18px; border-radius: 18px; background: #111; border: 1px solid rgba(255,255,255,0.08); animation: hb-wd8-rise 0.5s ease both; }\n.hb-wd8-pos { display: flex; align-items: baseline; gap: 10px; }\n.hb-wd8-pos b { font: 600 34px/1 var(--font-grotesk, inherit); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }\n.hb-wd8-pos span { font-size: 13px; color: #8f8f8f; }\n.hb-wd8-pos em { margin-left: auto; font: 600 12px/1 var(--font-mono, monospace); font-style: normal; color: var(--hb-wd8-accent); }\n.hb-wd8-link { display: flex; gap: 6px; align-items: center; padding: 5px 5px 5px 12px; border-radius: 12px; background: #0b0b0b; border: 1px dashed rgba(255,255,255,0.14); }\n.hb-wd8-link code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 13px/1 var(--font-mono, monospace); color: #cfcfcf; }\n.hb-wd8-copy { height: 36px; padding: 0 14px; font-size: 13px; }\n.hb-wd8-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border-radius: 12px; background: #0b0b0b; border: 1px solid rgba(255,255,255,0.08); }\n.hb-wd8-chips:focus-within { border-color: color-mix(in srgb, var(--hb-wd8-accent) 60%, transparent); }\n.hb-wd8-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 8px; background: #1b1b1b; font-size: 12.5px; color: #dcdcdc; }\n.hb-wd8-chip[data-state=\"joined\"] { background: color-mix(in srgb, var(--hb-wd8-accent) 18%, #141414); color: #fff; }\n.hb-wd8-chip small { font: 500 10px/1 var(--font-mono, monospace); color: #8f8f8f; }\n.hb-wd8-chip[data-state=\"joined\"] small { color: var(--hb-wd8-accent); }\n.hb-wd8-x { appearance: none; border: 0; background: transparent; color: #8f8f8f; width: 18px; height: 18px; border-radius: 5px; cursor: pointer; display: grid; place-items: center; }\n.hb-wd8-x:hover { background: #2a2a2a; color: #fff; }\n.hb-wd8-x:focus-visible { outline: 2px solid var(--hb-wd8-accent); }\n.hb-wd8-chips input { flex: 1 1 140px; min-width: 120px; border: 0; background: transparent; color: #ededed; font: 400 13.5px/1 inherit; font-family: inherit; padding: 6px; outline: none; }\n.hb-wd8-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }\n.hb-wd8-row small { font-size: 12px; color: #8f8f8f; }\n.hb-wd8-ladder { position: relative; padding: 22px 22px 22px 18px; border-radius: 22px; border: 1px solid rgba(255,255,255,0.08); background: linear-gradient(180deg, #121212, #0d0d0d); box-shadow: inset 0 1px 0 rgba(255,255,255,0.05); }\n.hb-wd8-lhead { display: flex; justify-content: space-between; align-items: center; margin: 0 0 18px 4px; font: 500 11px/1 var(--font-mono, monospace); letter-spacing: 0.08em; text-transform: uppercase; color: #8f8f8f; }\n.hb-wd8-lhead b { color: #ededed; font-size: 13px; letter-spacing: 0; }\n.hb-wd8-climb { position: relative; display: grid; grid-template-columns: 44px 1fr; }\n.hb-wd8-rail { position: relative; grid-row: 1 / -1; grid-column: 1; justify-self: center; width: 6px; border-radius: 3px; background: #1f1f1f; overflow: hidden; margin: 29px 0; }\n.hb-wd8-fill { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px; background: linear-gradient(0deg, color-mix(in srgb, var(--hb-wd8-accent) 40%, transparent), var(--hb-wd8-accent)); transition: height 1s cubic-bezier(0.65, 0, 0.35, 1); }\n.hb-wd8-fill::after { content: \"\"; position: absolute; inset: 0; background: linear-gradient(0deg, transparent, rgba(255,255,255,0.7), transparent); animation: hb-wd8-shine 2.4s ease-in-out infinite; }\n.hb-wd8-climber { position: absolute; left: 22px; z-index: 3; transform: translate(-50%, 50%); transition: bottom 1s cubic-bezier(0.65, 0, 0.35, 1); padding: 4px 8px; border-radius: 999px; background: #ededed; color: #0a0a0a; font: 700 10.5px/1 var(--font-mono, monospace); box-shadow: 0 0 0 4px #0d0d0d, 0 0 20px color-mix(in srgb, var(--hb-wd8-accent) 60%, transparent); white-space: nowrap; }\n.hb-wd8-rungs { grid-column: 2; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 10px; }\n.hb-wd8-rung { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.06); background: #121212; animation: hb-wd8-rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; transition: border-color 0.4s ease, background-color 0.4s ease; }\n.hb-wd8-rung::before { content: \"\"; position: absolute; left: -27px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: #0d0d0d; border: 2px solid #333; transition: border-color 0.3s ease, background-color 0.3s ease; }\n.hb-wd8-rung[data-done=\"true\"] { border-color: color-mix(in srgb, var(--hb-wd8-accent) 35%, transparent); background: linear-gradient(90deg, color-mix(in srgb, var(--hb-wd8-accent) 9%, #121212), #121212); }\n.hb-wd8-rung[data-done=\"true\"]::before { border-color: var(--hb-wd8-accent); background: var(--hb-wd8-accent); }\n.hb-wd8-rung[data-next=\"true\"] { border-color: rgba(255,255,255,0.18); }\n.hb-wd8-rung strong { display: block; font-size: 14.5px; font-weight: 600; }\n.hb-wd8-rung span { display: block; font-size: 12px; color: #8a8a8a; margin-top: 3px; }\n.hb-wd8-badge { font: 600 11px/1 var(--font-mono, monospace); padding: 6px 8px; border-radius: 8px; background: #1b1b1b; color: #a1a1a1; white-space: nowrap; }\n.hb-wd8-rung[data-done=\"true\"] .hb-wd8-badge { background: var(--hb-wd8-accent); color: #0b1203; }\n.hb-wd8-pop { position: absolute; left: -27px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; border: 2px solid var(--hb-wd8-accent); animation: hb-wd8-burst 0.8s ease-out both; pointer-events: none; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wd8 *, .hb-wd8 *::before, .hb-wd8 *::after { animation: none !important; transition: none !important; }\n  .hb-wd8-pop { display: none; }\n}\n`;\n\nexport function WaitlistReferralLadder({\n  eyebrow = \"Early access\",\n  title = \"Bring friends, climb the ladder\",\n  subtitle = \"Join the Tallyhall waitlist, share your link, and every friend who signs up moves you up a rung. Rewards unlock the moment they join.\",\n  rungs = defaultRungs,\n  basePosition = 4318,\n  spotsPerReferral = 250,\n  referrals,\n  defaultReferrals = 0,\n  defaultJoined = false,\n  referralBase = \"tallyhall.app/r/\",\n  simulateJoins = false,\n  onJoin,\n  onInvite,\n  onLinkCopy,\n  accent = \"#a3e635\",\n  className = \"\",\n  style,\n  ...rest\n}: WaitlistReferralLadderProps) {\n  const uid = React.useId().replace(/:/g, \"\");\n  const [joined, setJoined] = React.useState(defaultJoined);\n  const [email, setEmail] = React.useState(\"\");\n  const [saving, setSaving] = React.useState(false);\n  const [error, setError] = React.useState<string | null>(null);\n  const [inner, setInner] = React.useState(defaultReferrals);\n  const [copied, setCopied] = React.useState(false);\n  const [draft, setDraft] = React.useState(\"\");\n  const [invites, setInvites] = React.useState<{ email: string; state: \"draft\" | \"sent\" | \"joined\" }[]>([]);\n  const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);\n  const count = referrals ?? inner;\n  const max = rungs[rungs.length - 1]?.at || 1;\n\n  React.useEffect(() => () => timers.current.forEach(clearTimeout), []);\n\n  const seg = (n: number) => {\n    const idx = rungs.findIndex((r) => r.at > n);\n    if (idx === -1) return 1;\n    if (idx === 0) return 0;\n    const a = rungs[idx - 1];\n    const b = rungs[idx];\n    const t = (n - a.at) / (b.at - a.at);\n    return (idx - 1 + t) / (rungs.length - 1);\n  };\n  const progress = seg(Math.min(count, max));\n  const position = Math.max(1, basePosition - count * spotsPerReferral);\n  const nextRung = rungs.find((r) => r.at > count);\n  const code = (email.split(\"@\")[0] || \"you\").toLowerCase().replace(/[^a-z0-9]/g, \"\").slice(0, 10) || \"you\";\n  const link = `${referralBase}${code}`;\n\n  const join = async (e: React.FormEvent) => {\n    e.preventDefault();\n    if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)) {\n      setError(\"Enter a valid email to save your spot.\");\n      return;\n    }\n    setError(null);\n    setSaving(true);\n    try {\n      if (onJoin) await onJoin(email);\n      else await new Promise((r) => setTimeout(r, 750));\n      setJoined(true);\n    } catch {\n      setError(\"Could not save your spot. Try again.\");\n    } finally {\n      setSaving(false);\n    }\n  };\n\n  const copy = async () => {\n    try {\n      await navigator.clipboard?.writeText(`https://${link}`);\n    } catch {}\n    setCopied(true);\n    onLinkCopy?.(`https://${link}`);\n    timers.current.push(setTimeout(() => setCopied(false), 1600));\n  };\n\n  const addDraft = () => {\n    const v = draft.trim().replace(/,$/, \"\");\n    if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v) || invites.some((i) => i.email === v)) return;\n    setInvites((s) => [...s, { email: v, state: \"draft\" }]);\n    setDraft(\"\");\n  };\n\n  const send = () => {\n    const pending = invites.filter((i) => i.state === \"draft\").map((i) => i.email);\n    if (!pending.length) return;\n    setInvites((s) => s.map((i) => (i.state === \"draft\" ? { ...i, state: \"sent\" } : i)));\n    onInvite?.(pending);\n    if (simulateJoins) {\n      pending.forEach((m, k) => {\n        timers.current.push(\n          setTimeout(() => {\n            setInvites((s) => s.map((i) => (i.email === m ? { ...i, state: \"joined\" } : i)));\n            setInner((c) => c + 1);\n          }, 1400 + k * 1100),\n        );\n      });\n    }\n  };\n\n  return (\n    <section className={`hb-wd8 ${className}`} style={{ \"--hb-wd8-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-waitlist-referral-ladder\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wd8-in\">\n        <div>\n          <div className=\"hb-wd8-eyebrow\">{eyebrow}</div>\n          <h2 className=\"hb-wd8-title\">{title}</h2>\n          <p className=\"hb-wd8-sub\">{subtitle}</p>\n          {!joined ? (\n            <>\n              <form className=\"hb-wd8-form\" onSubmit={join} noValidate>\n                <input className=\"hb-wd8-input\" type=\"email\" value={email} onChange={(e) => setEmail(e.target.value)} placeholder=\"name@studio.com\" aria-label=\"Email address\" aria-invalid={!!error} aria-describedby={error ? `${uid}-err` : undefined} autoComplete=\"email\" />\n                <button type=\"submit\" className=\"hb-wd8-btn\" disabled={saving}>\n                  {saving && <span className=\"hb-wd8-spin\" aria-hidden=\"true\" />}\n                  {saving ? \"Saving\" : \"Save my spot\"}\n                </button>\n              </form>\n              {error && <p id={`${uid}-err`} className=\"hb-wd8-err\" role=\"alert\">{error}</p>}\n            </>\n          ) : (\n            <div className=\"hb-wd8-me\">\n              <div className=\"hb-wd8-pos\" aria-live=\"polite\">\n                <b>#{position.toLocaleString(\"en-US\")}</b>\n                <span>your place in line</span>\n                {count > 0 && <em>+{(count * spotsPerReferral).toLocaleString(\"en-US\")} spots</em>}\n              </div>\n              <div className=\"hb-wd8-link\">\n                <code>{link}</code>\n                <button type=\"button\" className=\"hb-wd8-btn hb-wd8-copy\" onClick={copy} aria-live=\"polite\">\n                  {copied ? \"Copied\" : \"Copy link\"}\n                </button>\n              </div>\n              <div className=\"hb-wd8-chips\">\n                {invites.map((i) => (\n                  <span key={i.email} className=\"hb-wd8-chip\" data-state={i.state}>\n                    {i.email}\n                    {i.state !== \"draft\" && <small>{i.state === \"joined\" ? \"joined\" : \"sent\"}</small>}\n                    {i.state === \"draft\" && (\n                      <button type=\"button\" className=\"hb-wd8-x\" aria-label={`Remove ${i.email}`} onClick={() => setInvites((s) => s.filter((x) => x.email !== i.email))}>\n                        <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"M2 2l6 6M8 2L2 8\" /></svg>\n                      </button>\n                    )}\n                  </span>\n                ))}\n                <input\n                  value={draft}\n                  onChange={(e) => setDraft(e.target.value)}\n                  onKeyDown={(e) => {\n                    if (e.key === \"Enter\" || e.key === \",\" || e.key === \" \") {\n                      e.preventDefault();\n                      addDraft();\n                    } else if (e.key === \"Backspace\" && !draft && invites.length && invites[invites.length - 1].state === \"draft\") {\n                      setInvites((s) => s.slice(0, -1));\n                    }\n                  }}\n                  onBlur={addDraft}\n                  placeholder={invites.length ? \"Add another\" : \"Friend emails, press Enter\"}\n                  aria-label=\"Invite friends by email\"\n                />\n              </div>\n              <div className=\"hb-wd8-row\">\n                <small>{nextRung ? `${nextRung.at - count} more to unlock ${nextRung.title.toLowerCase()}` : \"Every reward unlocked\"}</small>\n                <button type=\"button\" className=\"hb-wd8-btn hb-wd8-ghost\" style={{ height: 40 }} onClick={send} disabled={!invites.some((i) => i.state === \"draft\")}>\n                  Send invites\n                </button>\n              </div>\n            </div>\n          )}\n        </div>\n        <div className=\"hb-wd8-ladder\">\n          <div className=\"hb-wd8-lhead\">\n            <span>Reward ladder</span>\n            <b>\n              {count} / {max} friends\n            </b>\n          </div>\n          <div className=\"hb-wd8-climb\">\n            <div className=\"hb-wd8-rail\" aria-hidden=\"true\">\n              <span className=\"hb-wd8-fill\" style={{ height: `${(progress * 100).toFixed(1)}%` }} />\n            </div>\n            <span className=\"hb-wd8-climber\" style={{ bottom: `calc(29px + (100% - 58px) * ${progress.toFixed(3)})` }} aria-hidden=\"true\">\n              {joined ? \"YOU\" : \"START\"}\n            </span>\n            <ol className=\"hb-wd8-rungs\" role=\"list\" aria-label=\"Rewards\">\n              {rungs.map((r, i) => {\n                const done = joined && count >= r.at;\n                return (\n                  <li key={r.title} className=\"hb-wd8-rung\" data-done={done} data-next={nextRung === r} style={{ animationDelay: `${((rungs.length - i) * 0.07).toFixed(2)}s` }}>\n                    <div>\n                      <strong>{r.title}</strong>\n                      <span>{r.detail}</span>\n                    </div>\n                    <span className=\"hb-wd8-badge\">{r.at === 0 ? \"Join\" : `${r.at} ${r.at === 1 ? \"friend\" : \"friends\"}`}</span>\n                    {done && r.at > 0 && <span key={`p${count}`} className=\"hb-wd8-pop\" aria-hidden=\"true\" />}\n                  </li>\n                );\n              })}\n            </ol>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}