{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-onboarding-steps",
  "type": "registry:component",
  "title": "Onboarding Stepper Modal",
  "description": "A three step onboarding modal: pick a role, name and color the workspace, then invite teammates as email chips. Steps slide in the direction you move and the dialog height follows the content.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "stepper",
    "onboarding",
    "wizard",
    "modal",
    "invite",
    "setup"
  ],
  "docs": "https://hyperblur.dev/effects/modal-onboarding-steps",
  "files": [
    {
      "path": "registry/hyperblur/modal-onboarding-steps.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/modal-onboarding-steps.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface OnboardingRole {\n  id: string;\n  label: string;\n  hint: string;\n  icon: string;\n}\n\nexport interface OnboardingResult {\n  role: string;\n  workspace: string;\n  color: string;\n  invites: string[];\n}\n\nexport interface ModalOnboardingStepsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  embedded?: boolean;\n  trigger?: React.ReactNode;\n  product?: string;\n  domain?: string;\n  roles?: OnboardingRole[];\n  colors?: string[];\n  defaultStep?: number;\n  onStepChange?: (step: number) => void;\n  onComplete?: (result: OnboardingResult) => void;\n  accent?: string;\n}\n\nconst defaultRoles: OnboardingRole[] = [\n  { id: \"design\", label: \"Design\", hint: \"Files, reviews, handoff\", icon: \"M3 13 13 3M9.5 3H13v3.5M3 9.5V13h3.5\" },\n  { id: \"engineering\", label: \"Engineering\", hint: \"Issues, cycles, PRs\", icon: \"m5.5 4.5-3 3.5 3 3.5m5-7 3 3.5-3 3.5M9 3 7 13\" },\n  { id: \"product\", label: \"Product\", hint: \"Roadmaps and specs\", icon: \"M3 12.5h10M4.5 12.5V8m3.5 4.5V4m3.5 8.5V6.5\" },\n  { id: \"ops\", label: \"Operations\", hint: \"Requests and triage\", icon: \"M8 2.5v3M8 10.5v3M2.5 8h3M10.5 8h3M8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z\" },\n];\n\nconst defaultColors = [\"#22d3ee\", \"#a78bfa\", \"#f472b6\", \"#fb923c\", \"#a3e635\", \"#f5f5f5\"];\n\nconst stepGlyphs = [\n  \"M8 2.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Zm0 3v3l2 1.2\",\n  \"M3 4.5a1.5 1.5 0 0 1 1.5-1.5h7A1.5 1.5 0 0 1 13 4.5v7a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 3 11.5ZM6 8h4M8 6v4\",\n  \"M6 7.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4ZM2.5 13a3.5 3.5 0 0 1 7 0M11.5 5.5v4M9.5 7.5h4\",\n  \"m3.5 8.4 3 3 6-6.4\",\n];\n\nconst css = `\n.hb-xe11 { --hb-xe11-accent: #22d3ee; display: inline-block; box-sizing: border-box; color: #ededed; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); }\n.hb-xe11 *, .hb-xe11 *::before, .hb-xe11 *::after { box-sizing: border-box; }\n.hb-xe11[data-embedded] { position: relative; display: grid; place-items: center; width: 100%; height: 100%; min-height: 190px; border-radius: 16px; overflow: hidden; isolation: isolate; background: #09090a; }\n.hb-xe11-trigger { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 8px 0 16px; border: 1px solid #2a2a2c; border-radius: 999px; background: linear-gradient(180deg, #19191b, #131315); color: #ededed; font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer; transition: border-color 0.2s ease, transform 0.15s ease; }\n.hb-xe11-trigger:hover { border-color: #3a3a3e; }\n.hb-xe11-trigger:active { transform: scale(0.97); }\n.hb-xe11-trigger i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--hb-xe11-accent); color: #04191d; font-style: normal; }\n.hb-xe11-trigger svg { width: 12px; height: 12px; }\n.hb-xe11 button:focus-visible, .hb-xe11 input:focus-visible { outline: 2px solid var(--hb-xe11-accent); outline-offset: 2px; }\n.hb-xe11-layer { position: fixed; inset: 0; z-index: 1000; height: 100dvh; display: grid; place-items: center; padding: 16px; }\n.hb-xe11[data-embedded] .hb-xe11-layer { position: absolute; height: auto; z-index: 2; padding: 10px; }\n.hb-xe11-scrim { position: absolute; inset: 0; background: rgba(2, 4, 6, 0.66); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: hb-xe11-fade 0.3s ease both; }\n.hb-xe11-layer[data-state=\"closed\"] .hb-xe11-scrim { animation: hb-xe11-fade-out 0.22s ease both; }\n.hb-xe11-panel { position: relative; width: 100%; max-width: 460px; max-height: 100%; overflow: auto; border: 1px solid #252528; border-radius: 22px; background: #111113; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 40px 90px -30px rgba(0, 0, 0, 0.95); outline: none; animation: hb-xe11-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; transition: height 0.42s cubic-bezier(0.2, 0.9, 0.25, 1); }\n.hb-xe11-layer[data-state=\"closed\"] .hb-xe11-panel { animation: hb-xe11-out 0.22s ease both; }\n.hb-xe11-hero { position: relative; height: 92px; overflow: hidden; border-bottom: 1px solid #1f1f22; background: radial-gradient(60% 120% at 20% 0%, color-mix(in srgb, var(--hb-xe11-accent) 32%, transparent), transparent 70%), radial-gradient(50% 120% at 90% 100%, color-mix(in srgb, var(--hb-xe11-accent) 14%, transparent), transparent 70%), linear-gradient(180deg, #151517, #111113); }\n.hb-xe11-hero::before { content: \"\"; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px); background-size: 14px 14px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent); mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent); }\n.hb-xe11-tiles { position: absolute; inset: 0; display: grid; place-items: center; }\n.hb-xe11-tile { position: absolute; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 24px -10px rgba(0, 0, 0, 0.8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: transform 0.6s cubic-bezier(0.2, 0.9, 0.25, 1.1); }\n.hb-xe11-tile[data-k=\"main\"] { width: 50px; height: 50px; color: #fff; }\n.hb-xe11-tile[data-k=\"main\"] svg { width: 22px; height: 22px; animation: hb-xe11-glyph 0.5s cubic-bezier(0.3, 0.7, 0.4, 1.3) both; }\n.hb-xe11-tile[data-k=\"a\"], .hb-xe11-tile[data-k=\"b\"] { width: 26px; height: 26px; border-radius: 8px; opacity: 0.8; }\n.hb-xe11-tile[data-k=\"a\"] { transform: translate(calc(-62px + var(--hb-xe11-s) * 10px), calc(-12px + var(--hb-xe11-s) * 6px)) rotate(calc(-12deg + var(--hb-xe11-s) * 8deg)); }\n.hb-xe11-tile[data-k=\"b\"] { transform: translate(calc(64px - var(--hb-xe11-s) * 8px), calc(14px - var(--hb-xe11-s) * 8px)) rotate(calc(10deg - var(--hb-xe11-s) * 6deg)); }\n.hb-xe11-tile[data-k=\"a\"]::after, .hb-xe11-tile[data-k=\"b\"]::after { content: \"\"; width: 8px; height: 8px; border-radius: 3px; background: var(--hb-xe11-accent); }\n.hb-xe11-x { position: absolute; top: 10px; right: 10px; z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.35); color: #c4c4c8; cursor: pointer; transition: background-color 0.15s ease; }\n.hb-xe11-x:hover { background: rgba(0, 0, 0, 0.6); color: #fff; }\n.hb-xe11-x svg { width: 12px; height: 12px; }\n.hb-xe11-prog { position: absolute; left: 16px; top: 14px; display: flex; gap: 4px; }\n.hb-xe11-bar { position: relative; width: 26px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }\n.hb-xe11-bar i { position: absolute; inset: 0; background: var(--hb-xe11-accent); transform-origin: left; transform: scaleX(0); transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1); font-style: normal; }\n.hb-xe11-bar[data-on=\"true\"] i { transform: scaleX(1); }\n.hb-xe11-step { padding: 16px 18px 0; animation: hb-xe11-next 0.42s cubic-bezier(0.2, 0.9, 0.25, 1) both; }\n.hb-xe11-step[data-dir=\"back\"] { animation-name: hb-xe11-back; }\n.hb-xe11-kicker { margin: 0; color: var(--hb-xe11-accent); font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; }\n.hb-xe11-title { margin: 3px 0 0; font-family: var(--font-grotesk, inherit); font-size: 18px; font-weight: 600; letter-spacing: -0.025em; }\n.hb-xe11-sub { margin: 3px 0 0; color: #8f8f95; font-size: 12.5px; line-height: 1.45; }\n.hb-xe11-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 14px; }\n.hb-xe11-role { display: grid; grid-template-columns: 28px 1fr; gap: 9px; align-items: center; padding: 10px; border: 1px solid #252528; border-radius: 12px; background: #0d0d0f; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease; }\n.hb-xe11-role:hover { border-color: #34343a; }\n.hb-xe11-role:active { transform: scale(0.98); }\n.hb-xe11-role[aria-checked=\"true\"] { border-color: var(--hb-xe11-accent); background: color-mix(in srgb, var(--hb-xe11-accent) 8%, #0d0d0f); }\n.hb-xe11-ri { display: grid; place-items: center; height: 28px; border-radius: 8px; background: #19191c; color: #a8a8ae; transition: background-color 0.2s ease, color 0.2s ease; }\n.hb-xe11-role[aria-checked=\"true\"] .hb-xe11-ri { background: var(--hb-xe11-accent); color: #04191d; }\n.hb-xe11-ri svg { width: 14px; height: 14px; }\n.hb-xe11-role b { display: block; font-size: 13px; font-weight: 600; }\n.hb-xe11-role span span { display: block; color: #7d7d84; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xe11-ws { display: flex; gap: 12px; align-items: center; margin-top: 14px; }\n.hb-xe11-av { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--hb-xe11-c); color: #0a0a0a; font-family: var(--font-grotesk, inherit); font-size: 22px; font-weight: 700; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 24px -10px var(--hb-xe11-c); transition: background-color 0.3s ease, box-shadow 0.3s ease; }\n.hb-xe11-field { flex: 1; min-width: 0; }\n.hb-xe11-input { display: block; width: 100%; height: 38px; padding: 0 12px; border: 1px solid #2a2a2e; border-radius: 10px; background: #0b0b0d; color: #ededed; font: inherit; font-size: 14px; outline: none; transition: border-color 0.18s ease; }\n.hb-xe11 .hb-xe11-input:focus-visible { outline: none; border-color: var(--hb-xe11-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-xe11-accent) 20%, transparent); }\n.hb-xe11-url { margin-top: 6px; color: #6f6f76; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xe11-url b { color: #cfcfd4; font-weight: 500; }\n.hb-xe11-sw { display: flex; gap: 8px; margin-top: 12px; }\n.hb-xe11-dot { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: var(--hb-xe11-c); cursor: pointer; box-shadow: 0 0 0 0 transparent; transition: box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1.4); }\n.hb-xe11-dot:hover { transform: scale(1.1); }\n.hb-xe11-dot[aria-checked=\"true\"] { box-shadow: 0 0 0 2px #111113, 0 0 0 4px var(--hb-xe11-c); }\n.hb-xe11-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; margin-top: 14px; padding: 6px; border: 1px solid #2a2a2e; border-radius: 12px; background: #0b0b0d; cursor: text; transition: border-color 0.18s ease; }\n.hb-xe11-chips:focus-within { border-color: var(--hb-xe11-accent); }\n.hb-xe11-chips[data-bad=\"a\"] { animation: hb-xe11-shake-a 0.4s ease; border-color: #f43f5e; }\n.hb-xe11-chips[data-bad=\"b\"] { animation: hb-xe11-shake-b 0.4s ease; border-color: #f43f5e; }\n.hb-xe11-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 4px; border-radius: 8px; background: #1b1b1e; box-shadow: inset 0 0 0 1px #2a2a2e; font-size: 12px; animation: hb-xe11-glyph 0.3s cubic-bezier(0.3, 0.7, 0.4, 1.3) both; }\n.hb-xe11-chip i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: color-mix(in srgb, var(--hb-xe11-accent) 25%, #222); color: #fff; font-size: 10px; font-weight: 700; font-style: normal; text-transform: uppercase; }\n.hb-xe11-chip button { display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #7d7d84; cursor: pointer; }\n.hb-xe11-chip button:hover { background: #2a2a2e; color: #fff; }\n.hb-xe11-chip svg { width: 9px; height: 9px; }\n.hb-xe11-chipin { flex: 1; min-width: 140px; height: 28px; border: 0; background: transparent; color: #ededed; font: inherit; font-size: 13px; outline: none; padding: 0 6px; }\n.hb-xe11 .hb-xe11-chipin:focus-visible { outline: none; }\n.hb-xe11-help { margin: 7px 0 0; color: #6f6f76; font-size: 11.5px; }\n.hb-xe11-help[data-bad=\"true\"] { color: #ff7a8a; }\n.hb-xe11-done { display: grid; justify-items: center; gap: 4px; padding-top: 4px; text-align: center; }\n.hb-xe11-sum { width: 100%; margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }\n.hb-xe11-sum li { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 9px; background: #0d0d0f; box-shadow: inset 0 0 0 1px #1f1f22; color: #8f8f95; font-size: 12.5px; }\n.hb-xe11-sum b { color: #ededed; font-weight: 550; }\n.hb-xe11-foot { display: flex; align-items: center; gap: 8px; padding: 16px 18px 18px; }\n.hb-xe11-count { margin-right: auto; color: #6f6f76; font-size: 12px; font-variant-numeric: tabular-nums; }\n.hb-xe11-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid #2a2a2e; border-radius: 999px; background: transparent; color: #cfcfd4; font: inherit; font-size: 13px; font-weight: 550; white-space: nowrap; cursor: pointer; transition: background-color 0.15s ease, opacity 0.2s ease, transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe11-btn:hover:not(:disabled) { background: #1b1b1e; }\n.hb-xe11-btn:active:not(:disabled) { transform: scale(0.97); }\n.hb-xe11-btn[data-primary] { min-width: 112px; border-color: transparent; background: #f4f4f5; color: #0a0a0a; }\n.hb-xe11-btn[data-primary]:hover:not(:disabled) { background: #fff; }\n.hb-xe11-btn:disabled { opacity: 0.35; cursor: not-allowed; }\n.hb-xe11-btn svg { width: 13px; height: 13px; transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe11-btn[data-primary]:hover:not(:disabled) svg { transform: translateX(2px); }\n.hb-xe11[data-embedded] .hb-xe11-hero { height: 60px; }\n.hb-xe11[data-embedded] .hb-xe11-tile[data-k=\"main\"] { width: 40px; height: 40px; border-radius: 12px; }\n.hb-xe11[data-embedded] .hb-xe11-step { padding-top: 12px; }\n.hb-xe11[data-embedded] .hb-xe11-roles { margin-top: 10px; }\n.hb-xe11[data-embedded] .hb-xe11-role { padding: 8px 10px; }\n.hb-xe11[data-embedded] .hb-xe11-foot { padding: 12px 18px 14px; }\n@keyframes hb-xe11-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-xe11-fade-out { from { opacity: 1; } to { opacity: 0; } }\n@keyframes hb-xe11-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe11-out { from { opacity: 1; } to { opacity: 0; transform: scale(0.97); } }\n@keyframes hb-xe11-next { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe11-back { from { opacity: 0; transform: translateX(-22px); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe11-glyph { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe11-shake-a { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }\n@keyframes hb-xe11-shake-b { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xe11-scrim, .hb-xe11-panel, .hb-xe11-step, .hb-xe11-chip, .hb-xe11-chips[data-bad], .hb-xe11-tile[data-k=\"main\"] svg, .hb-xe11-layer[data-state=\"closed\"] .hb-xe11-panel, .hb-xe11-layer[data-state=\"closed\"] .hb-xe11-scrim { animation: none; }\n  .hb-xe11-layer[data-state=\"closed\"] { opacity: 0; }\n  .hb-xe11-panel, .hb-xe11-tile, .hb-xe11-bar i, .hb-xe11-role, .hb-xe11-ri, .hb-xe11-av, .hb-xe11-dot, .hb-xe11-btn, .hb-xe11-btn svg, .hb-xe11-trigger, .hb-xe11-input, .hb-xe11-chips { transition: none; }\n}\n`;\n\nconst focusable =\n  'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])';\n\nfunction useLayer(\n  open: boolean,\n  embedded: boolean,\n  panel: React.RefObject<HTMLElement | null>,\n  onClose: () => void,\n  userOpened: React.RefObject<boolean>,\n) {\n  const closeRef = React.useRef(onClose);\n  React.useEffect(() => {\n    closeRef.current = onClose;\n  });\n  React.useEffect(() => {\n    if (!open) return;\n    const node = panel.current;\n    const steal = !embedded || userOpened.current;\n    const previous = document.activeElement as HTMLElement | null;\n    const html = document.documentElement;\n    const overflow = html.style.overflow;\n    if (!embedded) html.style.overflow = \"hidden\";\n    if (steal && node) {\n      const target = node.querySelector<HTMLElement>(\"[data-autofocus]\") ?? node.querySelector<HTMLElement>(focusable) ?? node;\n      target.focus({ preventScroll: true });\n    }\n    const onKey = (e: KeyboardEvent) => {\n      if (!node) return;\n      if (embedded && !node.contains(document.activeElement)) return;\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        closeRef.current();\n        return;\n      }\n      if (e.key !== \"Tab\") return;\n      const items = Array.from(node.querySelectorAll<HTMLElement>(focusable)).filter((el) => el.getClientRects().length > 0);\n      if (!items.length) {\n        e.preventDefault();\n        node.focus();\n        return;\n      }\n      const first = items[0];\n      const last = items[items.length - 1];\n      const active = document.activeElement;\n      if (!node.contains(active)) {\n        e.preventDefault();\n        first.focus();\n      } else if (e.shiftKey && (active === first || active === node)) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && active === last) {\n        e.preventDefault();\n        first.focus();\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      if (!embedded) html.style.overflow = overflow;\n      if (steal && previous && previous.isConnected && previous !== document.body) previous.focus({ preventScroll: true });\n    };\n  }, [open, embedded, panel, userOpened]);\n}\n\nconst emailRe = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\n\nfunction slugify(v: string) {\n  return v.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\").slice(0, 32);\n}\n\nexport function ModalOnboardingSteps({\n  open,\n  defaultOpen,\n  onOpenChange,\n  embedded = false,\n  trigger = \"Get started\",\n  product = \"Relay\",\n  domain = \"relay.so\",\n  roles = defaultRoles,\n  colors = defaultColors,\n  defaultStep = 0,\n  onStepChange,\n  onComplete,\n  accent = \"#22d3ee\",\n  className = \"\",\n  style,\n  ...rest\n}: ModalOnboardingStepsProps) {\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const [present, setPresent] = React.useState(isOpen);\n  const [step, setStep] = React.useState(defaultStep);\n  const [dir, setDir] = React.useState<\"next\" | \"back\">(\"next\");\n  const [role, setRole] = React.useState(roles[1]?.id ?? \"\");\n  const [workspace, setWorkspace] = React.useState(\"Northwind\");\n  const [color, setColor] = React.useState(colors[0] ?? accent);\n  const [invites, setInvites] = React.useState<string[]>([\"maya@northwind.io\"]);\n  const [draft, setDraft] = React.useState(\"\");\n  const [bad, setBad] = React.useState<\"a\" | \"b\" | undefined>(undefined);\n  const [height, setHeight] = React.useState<number | undefined>(undefined);\n  const userOpened = React.useRef(false);\n  const panel = React.useRef<HTMLDivElement>(null);\n  const content = React.useRef<HTMLDivElement>(null);\n  const moved = React.useRef(false);\n  const id = React.useId();\n  const total = 3;\n\n  if (isOpen && !present) setPresent(true);\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (next) {\n        userOpened.current = true;\n        setStep(defaultStep);\n      }\n      if (open === undefined) setInner(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange, defaultStep],\n  );\n  const close = React.useCallback(() => setOpen(false), [setOpen]);\n\n  React.useEffect(() => {\n    if (isOpen || !present) return;\n    const t = setTimeout(() => setPresent(false), 240);\n    return () => clearTimeout(t);\n  }, [isOpen, present]);\n\n  React.useEffect(() => {\n    const node = content.current;\n    if (!node || typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(() => setHeight(node.offsetHeight + 2));\n    ro.observe(node);\n    return () => ro.disconnect();\n  }, [present]);\n\n  React.useEffect(() => {\n    if (!moved.current) return;\n    moved.current = false;\n    const node = content.current;\n    const target = node?.querySelector<HTMLElement>(\"[data-first]\") ?? node?.querySelector<HTMLElement>(focusable);\n    target?.focus({ preventScroll: true });\n  }, [step]);\n\n  useLayer(isOpen, embedded, panel, close, userOpened);\n\n  function goto(next: number) {\n    setDir(next > step ? \"next\" : \"back\");\n    moved.current = true;\n    setStep(next);\n    onStepChange?.(next);\n    if (next === total) onComplete?.({ role, workspace: workspace.trim(), color, invites });\n  }\n\n  function addInvite(raw: string) {\n    const v = raw.trim().replace(/,$/, \"\");\n    if (!v) return true;\n    if (!emailRe.test(v) || invites.includes(v)) {\n      setBad((b) => (b === \"a\" ? \"b\" : \"a\"));\n      return false;\n    }\n    setInvites((l) => [...l, v]);\n    setDraft(\"\");\n    setBad(undefined);\n    return true;\n  }\n\n  const canNext = step === 0 ? !!role : step === 1 ? workspace.trim().length >= 2 : true;\n  const titles = [\n    { k: \"Your role\", t: `What brings you to ${product}?`, s: \"We will tailor templates and views to how you work.\" },\n    { k: \"Workspace\", t: \"Name your workspace\", s: \"This is where your team plans, builds and ships.\" },\n    { k: \"Team\", t: \"Invite your team\", s: \"Add a few teammates now. You can always invite more later.\" },\n    { k: \"All set\", t: `${workspace.trim() || \"Your workspace\"} is ready`, s: \"We set up a starter project so you can dive in.\" },\n  ][step];\n  const roleLabel = roles.find((r) => r.id === role)?.label ?? \"\";\n  const vars = { \"--hb-xe11-accent\": accent, \"--hb-xe11-c\": color, \"--hb-xe11-s\": step, ...style } as React.CSSProperties;\n  const arrow = <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M3.5 8h9m-3.5-3.5L12.5 8 9 11.5\" /></svg>;\n\n  return (\n    <div className={`hb-xe11 ${className}`} data-embedded={embedded || undefined} style={vars} {...rest}>\n      <style href=\"hb-xe11-css\" precedence=\"default\">{css}</style>\n      {trigger !== null && (\n        <button type=\"button\" className=\"hb-xe11-trigger\" aria-haspopup=\"dialog\" aria-expanded={isOpen} onClick={() => setOpen(true)}>\n          {trigger}\n          <i aria-hidden=\"true\">{arrow}</i>\n        </button>\n      )}\n      {present && (\n        <div className=\"hb-xe11-layer\" data-state={isOpen ? \"open\" : \"closed\"}>\n          <div className=\"hb-xe11-scrim\" onClick={close} aria-hidden=\"true\" />\n          <div\n            ref={panel}\n            role=\"dialog\"\n            aria-modal=\"true\"\n            aria-labelledby={`${id}-t`}\n            aria-describedby={`${id}-d`}\n            tabIndex={-1}\n            className=\"hb-xe11-panel\"\n            style={height ? { height } : undefined}\n          >\n            <div ref={content}>\n              <div className=\"hb-xe11-hero\" aria-hidden=\"true\">\n                <div className=\"hb-xe11-prog\">\n                  {Array.from({ length: total }, (_, i) => (\n                    <span key={i} className=\"hb-xe11-bar\" data-on={i < step || step === total ? \"true\" : undefined}>\n                      <i style={i === step && step < total ? { transform: \"scaleX(0.35)\" } : undefined} />\n                    </span>\n                  ))}\n                </div>\n                <div className=\"hb-xe11-tiles\">\n                  <span className=\"hb-xe11-tile\" data-k=\"a\" />\n                  <span className=\"hb-xe11-tile\" data-k=\"b\" />\n                  <span className=\"hb-xe11-tile\" data-k=\"main\">\n                    <svg key={step} viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                      <path d={stepGlyphs[Math.min(step, 3)]} />\n                    </svg>\n                  </span>\n                </div>\n              </div>\n              <button type=\"button\" className=\"hb-xe11-x\" aria-label=\"Close\" onClick={close}>\n                <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"m4 4 8 8m0-8-8 8\" /></svg>\n              </button>\n              <div key={step} className=\"hb-xe11-step\" data-dir={dir}>\n                <p className=\"hb-xe11-kicker\">{step < total ? `Step ${step + 1} of ${total} · ${titles.k}` : titles.k}</p>\n                <h2 id={`${id}-t`} className=\"hb-xe11-title\">{titles.t}</h2>\n                <p id={`${id}-d`} className=\"hb-xe11-sub\">{titles.s}</p>\n                {step === 0 && (\n                  <div className=\"hb-xe11-roles\" role=\"radiogroup\" aria-label=\"Role\">\n                    {roles.map((r, i) => (\n                      <button\n                        key={r.id}\n                        type=\"button\"\n                        role=\"radio\"\n                        aria-checked={r.id === role}\n                        className=\"hb-xe11-role\"\n                        data-first={(role ? r.id === role : i === 0) ? \"\" : undefined}\n                        data-autofocus={r.id === role ? \"\" : undefined}\n                        onClick={() => setRole(r.id)}\n                      >\n                        <span className=\"hb-xe11-ri\" aria-hidden=\"true\">\n                          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d={r.icon} /></svg>\n                        </span>\n                        <span style={{ minWidth: 0 }}>\n                          <b>{r.label}</b>\n                          <span>{r.hint}</span>\n                        </span>\n                      </button>\n                    ))}\n                  </div>\n                )}\n                {step === 1 && (\n                  <>\n                    <div className=\"hb-xe11-ws\">\n                      <span className=\"hb-xe11-av\" aria-hidden=\"true\">{(workspace.trim()[0] ?? \"?\").toUpperCase()}</span>\n                      <div className=\"hb-xe11-field\">\n                        <input\n                          className=\"hb-xe11-input\"\n                          aria-label=\"Workspace name\"\n                          value={workspace}\n                          maxLength={32}\n                          data-first=\"\"\n                          onChange={(e) => setWorkspace(e.target.value)}\n                          onKeyDown={(e) => {\n                            if (e.key === \"Enter\" && canNext) goto(2);\n                          }}\n                        />\n                        <div className=\"hb-xe11-url\">{domain}/<b>{slugify(workspace) || \"workspace\"}</b></div>\n                      </div>\n                    </div>\n                    <div className=\"hb-xe11-sw\" role=\"radiogroup\" aria-label=\"Workspace color\">\n                      {colors.map((c) => (\n                        <button\n                          key={c}\n                          type=\"button\"\n                          role=\"radio\"\n                          aria-checked={c === color}\n                          aria-label={`Color ${c}`}\n                          className=\"hb-xe11-dot\"\n                          style={{ \"--hb-xe11-c\": c } as React.CSSProperties}\n                          onClick={() => setColor(c)}\n                        />\n                      ))}\n                    </div>\n                  </>\n                )}\n                {step === 2 && (\n                  <>\n                    <div className=\"hb-xe11-chips\" data-bad={bad} onClick={(e) => e.currentTarget.querySelector(\"input\")?.focus()}>\n                      {invites.map((m) => (\n                        <span key={m} className=\"hb-xe11-chip\">\n                          <i aria-hidden=\"true\">{m[0]}</i>\n                          {m}\n                          <button type=\"button\" aria-label={`Remove ${m}`} onClick={() => setInvites((l) => l.filter((x) => x !== m))}>\n                            <svg viewBox=\"0 0 10 10\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\"><path d=\"m2 2 6 6m0-6-6 6\" /></svg>\n                          </button>\n                        </span>\n                      ))}\n                      <input\n                        className=\"hb-xe11-chipin\"\n                        aria-label=\"Invite by email\"\n                        aria-describedby={`${id}-h`}\n                        aria-invalid={bad ? true : undefined}\n                        placeholder={invites.length ? \"Add another\" : \"name@company.com\"}\n                        value={draft}\n                        data-first=\"\"\n                        onChange={(e) => {\n                          const v = e.target.value;\n                          if (v.endsWith(\",\") || v.endsWith(\" \")) addInvite(v);\n                          else {\n                            setDraft(v);\n                            if (bad) setBad(undefined);\n                          }\n                        }}\n                        onKeyDown={(e) => {\n                          if (e.key === \"Enter\") {\n                            e.preventDefault();\n                            addInvite(draft);\n                          } else if (e.key === \"Backspace\" && !draft && invites.length) {\n                            setInvites((l) => l.slice(0, -1));\n                          }\n                        }}\n                        onBlur={() => draft && addInvite(draft)}\n                      />\n                    </div>\n                    <p id={`${id}-h`} className=\"hb-xe11-help\" data-bad={bad ? \"true\" : undefined}>\n                      {bad ? \"That does not look like a new, valid email.\" : \"Press Enter or comma to add. They join as members.\"}\n                    </p>\n                  </>\n                )}\n                {step === total && (\n                  <div className=\"hb-xe11-done\">\n                    <ul className=\"hb-xe11-sum\">\n                      <li><span>Workspace</span><b>{domain}/{slugify(workspace)}</b></li>\n                      <li><span>Set up for</span><b>{roleLabel}</b></li>\n                      <li><span>Invites sent</span><b>{invites.length}</b></li>\n                    </ul>\n                  </div>\n                )}\n              </div>\n              <div className=\"hb-xe11-foot\">\n                {step < total ? (\n                  <>\n                    <span className=\"hb-xe11-count\">{step + 1} / {total}</span>\n                    {step > 0 && <button type=\"button\" className=\"hb-xe11-btn\" onClick={() => goto(step - 1)}>Back</button>}\n                    {step === 2 && invites.length === 0 ? (\n                      <button type=\"button\" className=\"hb-xe11-btn\" data-primary=\"\" onClick={() => goto(3)}>Skip for now</button>\n                    ) : (\n                      <button type=\"button\" className=\"hb-xe11-btn\" data-primary=\"\" disabled={!canNext} onClick={() => goto(step + 1)}>\n                        {step === 2 ? `Send ${invites.length} invite${invites.length === 1 ? \"\" : \"s\"}` : \"Continue\"}\n                        {arrow}\n                      </button>\n                    )}\n                  </>\n                ) : (\n                  <>\n                    <span className=\"hb-xe11-count\" />\n                    <button type=\"button\" className=\"hb-xe11-btn\" data-primary=\"\" data-first=\"\" onClick={close}>\n                      Open {workspace.trim() || \"workspace\"}\n                      {arrow}\n                    </button>\n                  </>\n                )}\n              </div>\n            </div>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}