{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reroute-email-demo",
  "type": "registry:block",
  "title": "Reroute: Email Relays",
  "description": "Animated Failover Diagram example, Email Relays: An email API's relays with a switch each. Pause relays and the mail moves on to whichever is still up. A take on the flow diagram (flowchart). Fits hero and features sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "hero",
    "features",
    "flow-diagram",
    "interaction",
    "ai",
    "diagram"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/reroute#reroute-email-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/reroute.json"
  ],
  "files": [
    {
      "path": "components/reroute-email-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Reroute, type RerouteItem } from \"@/components/ui/reroute\";\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// Postwick, a transactional email API, sends through four relays. Flip one off and mail reroutes.\nconst RELAYS: (RerouteItem & { short: string })[] = [\n  {\n    id: \"pelican\",\n    short: \"Pelican\",\n    name: \"Pelican Mail\",\n    detail: \"99.2% inboxed · 1.1s\",\n    icon: (\n      <Mark>\n        <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"3.5\" fill=\"#0ea5e9\" />\n        <path d=\"M6.5 9l5.5 4 5.5-4\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"courier\",\n    short: \"Courier\",\n    name: \"Courier One\",\n    detail: \"98.7% inboxed · 0.9s\",\n    icon: (\n      <Mark>\n        <path d=\"M3.5 11.5 20.5 4l-5 16-3.6-6.2z\" fill=\"#f97316\" />\n        <path d=\"M11.9 13.8 20.5 4\" stroke=\"#fff\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"harbor\",\n    short: \"Harbor\",\n    name: \"Harbor SMTP\",\n    detail: \"99.0% inboxed · 1.4s\",\n    icon: (\n      <Mark>\n        <circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"#4f46e5\" />\n        <path d=\"M12 6.5v10M8 12.5a4 4 0 0 0 8 0M9.5 8.5h5\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n      </Mark>\n    ),\n  },\n  {\n    id: \"beacon\",\n    short: \"Beacon\",\n    name: \"Beacon Relay\",\n    detail: \"98.9% inboxed · 1.2s\",\n    icon: (\n      <Mark>\n        <rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"5\" fill=\"#16a34a\" />\n        <circle cx=\"12\" cy=\"12\" r=\"2.4\" fill=\"#fff\" />\n        <path d=\"M7.8 7.8a6 6 0 0 0 0 8.4M16.2 7.8a6 6 0 0 1 0 8.4\" fill=\"none\" stroke=\"#bbf7d0\" strokeWidth=\"1.6\" strokeLinecap=\"round\" />\n      </Mark>\n    ),\n  },\n];\n\nexport function RerouteEmailDemo() {\n  const [down, setDown] = React.useState<string[]>([\"courier\"]);\n  const [live, setLive] = React.useState<string | null>(\"pelican\");\n  const [sent, setSent] = React.useState(18204);\n\n  // Mail keeps going out while any relay is up.\n  React.useEffect(() => {\n    if (!live) return;\n    const id = window.setInterval(() => setSent((n) => n + 1 + Math.floor(Math.random() * 3)), 420);\n    return () => window.clearInterval(id);\n  }, [live]);\n\n  const toggle = (id: string) => setDown((d) => (d.includes(id) ? d.filter((x) => x !== id) : [...d, id]));\n\n  return (\n    <div className=\"w-full max-w-xl overflow-hidden rounded-3xl border border-zinc-950/[0.08] bg-white shadow-[0_1px_2px_rgba(0,0,0,0.04)] dark:border-white/10 dark:bg-zinc-950\">\n      <div className=\"flex items-end justify-between gap-4 px-6 pt-6\">\n        <div className=\"min-w-0\">\n          <h3 className=\"text-[15px] font-semibold tracking-tight text-zinc-950 dark:text-white\">Delivery relays</h3>\n          <p className=\"mt-0.5 text-xs text-zinc-500 dark:text-zinc-400\">Pause a relay and mail moves to the next one.</p>\n        </div>\n        <div className=\"shrink-0 text-right\">\n          <p className=\"font-mono text-lg font-medium leading-6 tabular-nums tracking-tight text-zinc-950 dark:text-white\">\n            {sent.toLocaleString(\"en-US\")}\n          </p>\n          <p className=\"text-[11px] text-zinc-500 dark:text-zinc-400\">sent today</p>\n        </div>\n      </div>\n\n      <Reroute\n        className=\"[--reroute-accent:#00a86b] [--reroute-down:#ef4444] dark:[--reroute-accent:#1fd18f] dark:[--reroute-down:#f87171]\"\n        label=\"Email relay\"\n        items={RELAYS}\n        defaultValue=\"pelican\"\n        down={down}\n        onRoute={(id) => setLive(id)}\n        hub={\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n            <rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"13\" rx=\"2.5\" />\n            <path d=\"M4 7l8 6 8-6\" />\n          </svg>\n        }\n      />\n\n      <ul className=\"grid grid-cols-1 gap-px border-t border-zinc-950/[0.06] bg-zinc-950/[0.06] sm:grid-cols-2 dark:border-white/[0.08] dark:bg-white/[0.08]\">\n        {RELAYS.map((r) => {\n          const off = down.includes(r.id);\n          return (\n            <li key={r.id} className=\"flex items-center gap-3 bg-white px-5 py-3 dark:bg-zinc-950\">\n              <span className=\"size-5 shrink-0\">{r.icon}</span>\n              <span className=\"min-w-0 flex-1\">\n                <span className=\"block truncate text-[13px] font-medium tracking-tight text-zinc-950 dark:text-white\">{r.short}</span>\n                <span className=\"block text-[11px] text-zinc-500 dark:text-zinc-400\">\n                  {off ? \"Paused\" : r.id === live ? \"Sending\" : \"Standing by\"}\n                </span>\n              </span>\n              <button\n                type=\"button\"\n                role=\"switch\"\n                aria-checked={!off}\n                aria-label={`${r.short} relay`}\n                onClick={() => toggle(r.id)}\n                className=\"relative h-6 w-10 shrink-0 rounded-full outline-offset-2 outline-[#00a86b] transition-colors duration-200 focus-visible:outline-2 aria-checked:bg-[#00a86b] aria-[checked=false]:bg-zinc-200 dark:aria-checked:bg-[#1fd18f] dark:aria-[checked=false]:bg-zinc-700\"\n              >\n                <span\n                  className=\"absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow-sm transition-transform duration-200 ease-[cubic-bezier(0.23,1,0.32,1)]\"\n                  style={{ transform: off ? \"translateX(0)\" : \"translateX(16px)\" }}\n                />\n              </button>\n            </li>\n          );\n        })}\n      </ul>\n    </div>\n  );\n}\n"
    }
  ]
}