{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reroute-hero",
  "type": "registry:block",
  "title": "Reroute Hero",
  "description": "Hero Section built with Reroute (animated failover diagram): payments reroute when a processor fails. A take on the flow diagram (flowchart). A payments-routing hero with the processors on a wheel under your mark. It drills its own outage within two seconds: the live processor drops, the charge reroutes to the next one, then traffic moves back. Visitors can take one offline themselves.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "blocks",
    "hero-sections",
    "hero",
    "flow-diagram"
  ],
  "docs": "Live preview and the components it's built with: https://keyframeui.com/blocks/hero-sections/reroute-hero",
  "registryDependencies": [
    "https://keyframeui.com/r/reroute.json"
  ],
  "files": [
    {
      "path": "components/reroute-hero.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Reroute, type RerouteItem, type RerouteReason } from \"@/components/ui/reroute\";\n\n/* ── Content ─────────────────────────────────────────────────\n * Everything you'd change to make the section yours: the copy,\n * the processors on the wheel and the outage drill. The drill\n * takes the live processor down, brings it back, then moves\n * traffic on, so a visitor sees a failover within two seconds.\n * It stops the first time they press anything.\n * ─────────────────────────────────────────────────────────── */\n\n/** The one accent: the hub, the cable, the primary buttons. */\nconst ACCENT = \"#ff3b1f\";\nconst ACCENT_DARK = \"#ff5a3c\";\n\nconst BRAND = { name: \"Switchyard\", href: \"#\" };\nconst NAV_LINKS = [\n  { label: \"Product\", href: \"#product\" },\n  { label: \"Processors\", href: \"#processors\" },\n  { label: \"Pricing\", href: \"#pricing\" },\n  { label: \"Docs\", href: \"#docs\" },\n];\nconst SIGN_IN = { label: \"Sign in\", href: \"#sign-in\" };\nconst NAV_CTA = { label: \"Get a demo\", href: \"#demo\" };\n\nconst BADGE = { tag: \"New\", text: \"Failover routing is out of beta\" };\nconst HEADLINE = \"Checkout that routes around outages.\";\nconst SUBLINE =\n  \"Switchyard sits between your checkout and every processor you use. When one stalls, the charge retries on the next healthy one before your customer notices.\";\nconst PRIMARY_CTA = { label: \"Start routing\", href: \"#start\" };\nconst SECONDARY_CTA = { label: \"Read the docs\", href: \"#docs\" };\nconst STATS = [\n  { value: \"99.995%\", label: \"checkout uptime\" },\n  { value: \"38 ms\", label: \"median failover\" },\n  { value: \"6\", label: \"processors, one API\" },\n];\n\nconst PANEL = { title: \"Live route\", scope: \"EU checkout · production\", healthy: \"All processors up\", degraded: \"1 processor down\" };\nconst LOG_EMPTY = \"Watching every processor…\";\n/** ms: wait, take the live one down, bring it back, move on. */\nconst DRILL = { first: 1600, down: 3400, next: 2600, rest: 10000 };\n\nfunction Mark({ children }: { children: React.ReactNode }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" className=\"size-full\" aria-hidden>\n      {children}\n    </svg>\n  );\n}\n\n// Every processor name and mark is made up.\nconst PROCESSORS: RerouteItem[] = [\n  {\n    id: \"northpay\",\n    name: \"Northpay\",\n    detail: \"auth 98.4% · 212 ms\",\n    icon: (\n      <Mark>\n        <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"5\" fill=\"#1d4ed8\" />\n        <path d=\"M8 16V8l8 8V8\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"kestrel\",\n    name: \"Kestrel Payments\",\n    detail: \"auth 97.9% · 188 ms\",\n    icon: (\n      <Mark>\n        <path d=\"M3 16.5 12 5l9 11.5-4.2-2.4L12 19l-4.8-4.9z\" fill=\"#f97316\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"paywell\",\n    name: \"Paywell\",\n    detail: \"auth 98.1% · 240 ms\",\n    icon: (\n      <Mark>\n        <circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"#0d9488\" />\n        <path d=\"M6.5 12.5c1.8-2.4 3.6-2.4 5.5 0s3.7 2.4 5.5 0\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"1.9\" strokeLinecap=\"round\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"ledgerline\",\n    name: \"Ledgerline\",\n    detail: \"auth 98.7% · 176 ms\",\n    icon: (\n      <Mark>\n        <rect x=\"4\" y=\"4\" width=\"16\" height=\"4\" rx=\"2\" fill=\"currentColor\" />\n        <rect x=\"4\" y=\"10\" width=\"11\" height=\"4\" rx=\"2\" fill=\"currentColor\" opacity=\"0.6\" />\n        <rect x=\"4\" y=\"16\" width=\"7\" height=\"4\" rx=\"2\" fill=\"currentColor\" opacity=\"0.35\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"orbit\",\n    name: \"Orbit Pay\",\n    detail: \"auth 97.6% · 205 ms\",\n    icon: (\n      <Mark>\n        <circle cx=\"12\" cy=\"12\" r=\"7.5\" fill=\"none\" stroke=\"#7c3aed\" strokeWidth=\"3\" />\n        <circle cx=\"18.2\" cy=\"6.6\" r=\"2.6\" fill=\"#a78bfa\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"tandem\",\n    name: \"Tandem\",\n    detail: \"auth 98.2% · 198 ms\",\n    icon: (\n      <Mark>\n        <circle cx=\"8.5\" cy=\"12\" r=\"5\" fill=\"#16a34a\" />\n        <circle cx=\"15.5\" cy=\"12\" r=\"5\" fill=\"#86efac\" opacity=\"0.85\" />\n      </Mark>\n    ),\n  },\n];\n\nconst nameOf = (id: string | null) => PROCESSORS.find((p) => p.id === id)?.name ?? \"nothing\";\nconst shortName = (id: string | null) => nameOf(id).split(\" \")[0];\nconst clock = () => new Date().toLocaleTimeString(\"en-GB\", { hour: \"2-digit\", minute: \"2-digit\", second: \"2-digit\" });\n\n/* ── Marks ── */\n\nfunction SwitchyardMark({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" className={className} aria-hidden>\n      <rect x=\"2\" y=\"2\" width=\"20\" height=\"20\" rx=\"6\" fill=\"currentColor\" />\n      <path d=\"M9 18V6M9 14.5c0-3.5 6-3 6-8.5\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"2\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\nfunction Arrow({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" className={className} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n      <path d=\"M3.5 8h9M8.5 4l4 4-4 4\" />\n    </svg>\n  );\n}\n\n/* ── Section ── */\n\ntype Entry = { id: number; time: string; text: string; fail: boolean };\n\nexport function RerouteHero() {\n  const [value, setValue] = React.useState(PROCESSORS[0].id);\n  const [down, setDown] = React.useState<string[]>([]);\n  const [live, setLive] = React.useState<string | null>(PROCESSORS[0].id);\n  const [log, setLog] = React.useState<Entry[]>([]);\n  const [touched, setTouched] = React.useState(false);\n  const liveRef = React.useRef(live);\n  const prevLive = React.useRef(live);\n  const seq = React.useRef(0);\n\n  const onRoute = React.useCallback((id: string | null, reason: RerouteReason) => {\n    const from = prevLive.current;\n    prevLive.current = id;\n    liveRef.current = id;\n    setLive(id);\n    const text =\n      reason === \"failover\"\n        ? `${shortName(from)} timed out · retried on ${shortName(id)}`\n        : reason === \"recover\"\n          ? `${shortName(id)} recovered · traffic moved back`\n          : `Routing to ${shortName(id)}`;\n    seq.current += 1;\n    const entry = { id: seq.current, time: clock(), text, fail: reason === \"failover\" };\n    setLog((l) => [entry, ...l].slice(0, 2));\n  }, []);\n\n  // The outage drill, until the visitor takes over.\n  React.useEffect(() => {\n    if (touched) return;\n    let alive = true;\n    const timers: number[] = [];\n    const wait = (ms: number) => new Promise<void>((r) => timers.push(window.setTimeout(r, ms)));\n    (async () => {\n      await wait(DRILL.first);\n      while (alive) {\n        const victim = liveRef.current;\n        if (victim) setDown([victim]);\n        await wait(DRILL.down);\n        if (!alive) return;\n        setDown([]);\n        await wait(DRILL.next);\n        if (!alive) return;\n        const at = PROCESSORS.findIndex((p) => p.id === liveRef.current);\n        setValue(PROCESSORS[(at + 1) % PROCESSORS.length].id);\n        await wait(DRILL.next);\n      }\n    })();\n    return () => {\n      alive = false;\n      timers.forEach((t) => window.clearTimeout(t));\n    };\n  }, [touched]);\n\n  const anyDown = down.length > 0;\n\n  return (\n    <section\n      style={{ \"--accent\": ACCENT, \"--accent-dark\": ACCENT_DARK } as React.CSSProperties}\n      className=\"relative overflow-hidden bg-white text-zinc-950 dark:bg-zinc-950 dark:text-white\"\n    >\n      <header className=\"border-b border-zinc-950/[0.07] dark:border-white/[0.08]\">\n        <div className=\"mx-auto flex h-16 max-w-6xl items-center justify-between gap-6 px-6\">\n          <a\n            href={BRAND.href}\n            className=\"flex items-center gap-2 rounded-md text-[15px] font-semibold tracking-tight focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-(--accent)\"\n          >\n            <SwitchyardMark className=\"size-6 text-(--accent) dark:text-(--accent-dark)\" />\n            {BRAND.name}\n          </a>\n          <nav aria-label=\"Main\" className=\"hidden items-center gap-8 text-sm text-zinc-600 md:flex dark:text-zinc-400\">\n            {NAV_LINKS.map((link) => (\n              <a\n                key={link.label}\n                href={link.href}\n                className=\"rounded-sm transition-colors duration-150 hover:text-zinc-950 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-(--accent) dark:hover:text-white\"\n              >\n                {link.label}\n              </a>\n            ))}\n          </nav>\n          <div className=\"flex items-center gap-2\">\n            <a\n              href={SIGN_IN.href}\n              className=\"hidden h-9 items-center rounded-full bg-zinc-950/[0.04] px-4 text-[13px] font-medium text-zinc-800 transition-colors duration-150 hover:bg-zinc-950/[0.08] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) sm:flex dark:bg-white/[0.06] dark:text-zinc-200 dark:hover:bg-white/[0.1]\"\n            >\n              {SIGN_IN.label}\n            </a>\n            <a\n              href={NAV_CTA.href}\n              className=\"flex h-9 items-center rounded-full bg-[color-mix(in_oklab,var(--accent)_10%,white)] px-4 text-[13px] font-semibold text-(--accent) transition-colors duration-150 hover:bg-[color-mix(in_oklab,var(--accent)_16%,white)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) dark:bg-[color-mix(in_oklab,var(--accent-dark)_16%,transparent)] dark:text-(--accent-dark) dark:hover:bg-[color-mix(in_oklab,var(--accent-dark)_24%,transparent)]\"\n            >\n              {NAV_CTA.label}\n            </a>\n          </div>\n        </div>\n      </header>\n\n      <div className=\"mx-auto grid max-w-6xl grid-cols-1 items-center gap-12 px-6 pb-20 pt-12 sm:pt-16 lg:grid-cols-[1fr_minmax(0,34rem)] lg:gap-14 lg:pb-24 lg:pt-14\">\n        <div className=\"max-w-xl\">\n          <a\n            href=\"#changelog\"\n            className=\"inline-flex items-center gap-2 rounded-full border border-zinc-950/[0.08] bg-white py-1 pl-1 pr-3 text-[13px] text-zinc-600 transition-colors duration-150 hover:border-zinc-950/20 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) dark:border-white/10 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-white/25\"\n          >\n            <span className=\"rounded-full bg-(--accent) px-2 py-0.5 text-[11px] font-semibold text-white dark:bg-(--accent-dark)\">{BADGE.tag}</span>\n            {BADGE.text}\n            <Arrow className=\"size-3.5 text-zinc-400\" />\n          </a>\n          <h1 className=\"mt-6 text-balance text-[2.5rem] font-semibold leading-[1.05] tracking-[-0.04em] sm:text-[3.5rem] lg:text-[3.75rem]\">\n            {HEADLINE}\n          </h1>\n          <p className=\"mt-5 max-w-lg text-pretty text-base leading-relaxed text-zinc-600 sm:text-[17px] dark:text-zinc-400\">{SUBLINE}</p>\n          <div className=\"mt-8 flex flex-wrap items-center gap-3\">\n            <a\n              href={PRIMARY_CTA.href}\n              className=\"inline-flex h-11 items-center gap-2 rounded-full bg-(--accent) px-5 text-sm font-semibold text-white shadow-[0_8px_24px_-10px_var(--accent)] transition-[transform,filter] duration-150 hover:brightness-110 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) active:scale-[0.97] dark:bg-(--accent-dark)\"\n            >\n              {PRIMARY_CTA.label}\n              <Arrow className=\"size-4\" />\n            </a>\n            <a\n              href={SECONDARY_CTA.href}\n              className=\"inline-flex h-11 items-center rounded-full border border-zinc-950/10 px-5 text-sm font-semibold text-zinc-900 transition-colors duration-150 hover:border-zinc-950/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) dark:border-white/15 dark:text-white dark:hover:border-white/30\"\n            >\n              {SECONDARY_CTA.label}\n            </a>\n          </div>\n          <dl className=\"mt-12 grid max-w-md grid-cols-3 gap-6 border-t border-zinc-950/[0.07] pt-6 dark:border-white/[0.08]\">\n            {STATS.map((s) => (\n              <div key={s.label}>\n                <dt className=\"sr-only\">{s.label}</dt>\n                <dd className=\"text-xl font-semibold tabular-nums tracking-tight sm:text-2xl\">{s.value}</dd>\n                <dd className=\"mt-1 text-xs leading-snug text-zinc-500 dark:text-zinc-400\">{s.label}</dd>\n              </div>\n            ))}\n          </dl>\n        </div>\n\n        <div className=\"relative\">\n          <div\n            aria-hidden\n            className=\"pointer-events-none absolute -inset-x-10 -inset-y-12 -z-0 bg-[radial-gradient(closest-side,color-mix(in_oklab,var(--accent)_13%,transparent),transparent)]\"\n          />\n          <div className=\"relative overflow-hidden rounded-[28px] border border-zinc-950/[0.08] bg-white shadow-[0_1px_2px_rgba(0,0,0,0.04),0_24px_60px_-28px_rgba(0,0,0,0.18)] dark:border-white/10 dark:bg-zinc-900 dark:shadow-none\">\n            <div className=\"flex items-center justify-between gap-3 px-5 pt-5\">\n              <div className=\"min-w-0\">\n                <p className=\"text-[13px] font-medium tracking-tight\">{PANEL.title}</p>\n                <p className=\"truncate text-xs text-zinc-500 dark:text-zinc-400\">{PANEL.scope}</p>\n              </div>\n              <span className=\"inline-flex shrink-0 items-center gap-1.5 rounded-full border border-zinc-950/[0.08] px-2.5 py-1 text-[11px] font-medium text-zinc-600 dark:border-white/10 dark:text-zinc-300\">\n                <span className={anyDown ? \"size-1.5 rounded-full bg-zinc-950 dark:bg-zinc-200\" : \"size-1.5 rounded-full bg-(--accent) dark:bg-(--accent-dark)\"} />\n                <span aria-live=\"polite\">{anyDown ? PANEL.degraded : PANEL.healthy}</span>\n              </span>\n            </div>\n            <Reroute\n              className=\"mt-1 [--reroute-accent:var(--accent)] dark:[--reroute-accent:var(--accent-dark)]\"\n              label=\"Payment processor\"\n              items={PROCESSORS}\n              value={value}\n              onValueChange={(id) => {\n                setTouched(true);\n                setValue(id);\n              }}\n              down={down}\n              onRoute={onRoute}\n              hub={<SwitchyardGlyph />}\n            />\n            <div className=\"flex flex-col items-start gap-3 border-t border-zinc-950/[0.06] px-5 py-4 sm:flex-row sm:items-center sm:justify-between dark:border-white/[0.08]\">\n              <ol className=\"w-full min-w-0 flex-1 space-y-1\" aria-label=\"Routing log\">\n                {log.length === 0 ? (\n                  <li className=\"text-xs text-zinc-400 dark:text-zinc-500\">{LOG_EMPTY}</li>\n                ) : (\n                  log.map((e, i) => (\n                    <li key={e.id} className={i ? \"flex gap-2 text-xs opacity-50\" : \"flex gap-2 text-xs\"}>\n                      <span className=\"shrink-0 font-mono tabular-nums text-zinc-400 dark:text-zinc-500\">{e.time}</span>\n                      <span className={e.fail ? \"truncate font-medium\" : \"truncate text-zinc-600 dark:text-zinc-300\"}>{e.text}</span>\n                    </li>\n                  ))\n                )}\n              </ol>\n              <button\n                type=\"button\"\n                onClick={() => {\n                  setTouched(true);\n                  setDown(anyDown ? [] : live ? [live] : []);\n                }}\n                className=\"h-9 shrink-0 rounded-full bg-zinc-950 px-4 text-[13px] font-medium text-white transition-transform duration-150 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent) active:scale-[0.97] dark:bg-white dark:text-zinc-950\"\n              >\n                {anyDown ? `Bring ${shortName(down[0])} back` : `Take ${shortName(live)} offline`}\n              </button>\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nfunction SwitchyardGlyph() {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" aria-hidden>\n      <path d=\"M8.5 20V4M8.5 15c0-4.5 7-4 7-11\" />\n    </svg>\n  );\n}\n"
    }
  ]
}