{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pulse-status-demo",
  "type": "registry:block",
  "title": "Pulse: Status Page",
  "description": "Live Data Dot Grid Background example, Status Page: An API status page where every region's health checks pass as small rings, until one region turns red and an incident runs from investigating to resolved. A take on the animated background (backdrop). Fits hero, CTA and stats sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "hero",
    "cta",
    "stats",
    "animated-background",
    "chart",
    "map",
    "background",
    "data",
    "canvas"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/pulse#pulse-status-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/pulse.json"
  ],
  "files": [
    {
      "path": "components/pulse-status-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Pulse, type PulseEvent } from \"@/components/ui/pulse\";\nimport { cn } from \"@/lib/utils\";\n\n// A flattened world map squeezed into the band between the headline and the cards.\nconst place = (lon: number, lat: number) => ({\n  x: 0.05 + ((lon + 180) / 360) * 0.9,\n  y: 0.36 + (((90 - lat) / 180 - 0.2) / 0.5) * 0.24,\n});\n\nconst REGIONS = [\n  { code: \"sfo1\", city: \"San Francisco\", ...place(-122.4, 37.8) },\n  { code: \"iad1\", city: \"Washington\", ...place(-77.5, 39) },\n  { code: \"gru1\", city: \"São Paulo\", ...place(-46.6, -23.5) },\n  { code: \"lhr1\", city: \"London\", ...place(-0.45, 51.5) },\n  { code: \"fra1\", city: \"Frankfurt\", ...place(8.7, 50.1) },\n  { code: \"bom1\", city: \"Mumbai\", ...place(72.9, 19.1) },\n  { code: \"sin1\", city: \"Singapore\", ...place(103.8, 1.35) },\n  { code: \"syd1\", city: \"Sydney\", ...place(151.2, -33.9) },\n  { code: \"nrt1\", city: \"Tokyo\", ...place(140.4, 35.8) },\n];\n\ntype Step = { at: string; state: \"Investigating\" | \"Identified\" | \"Monitoring\" | \"Resolved\"; text: string };\n\nconst INCIDENTS: { region: string; title: string; summary: string; steps: Step[] }[] = [\n  {\n    region: \"fra1\",\n    title: \"Elevated errors in Frankfurt\",\n    summary: \"Inference calls in fra1 are failing at 4%. Every other region is healthy.\",\n    steps: [\n      { at: \"14:02\", state: \"Investigating\", text: \"Inference calls in fra1 are returning 503s.\" },\n      { at: \"14:06\", state: \"Identified\", text: \"A GPU pool failed its driver update. Traffic is moving to lhr1.\" },\n      { at: \"14:11\", state: \"Monitoring\", text: \"Error rate is back under 0.1%.\" },\n      { at: \"14:19\", state: \"Resolved\", text: \"fra1 is serving normally.\" },\n    ],\n  },\n  {\n    region: \"sin1\",\n    title: \"Slow responses in Singapore\",\n    summary: \"p95 latency in sin1 is 2.4 s. Requests are completing.\",\n    steps: [\n      { at: \"09:41\", state: \"Investigating\", text: \"p95 latency in sin1 rose to 2.4 s.\" },\n      { at: \"09:44\", state: \"Identified\", text: \"A congested route to the storage tier.\" },\n      { at: \"09:52\", state: \"Monitoring\", text: \"Traffic rerouted. p95 is back to 180 ms.\" },\n      { at: \"10:03\", state: \"Resolved\", text: \"sin1 latency is normal.\" },\n    ],\n  },\n];\n\nconst STEP_MS = 4500; // each incident update\nconst CALM_MS = 6000; // all clear before the next incident\n\nlet nextId = 0;\n\nexport function PulseStatusDemo() {\n  const [events, setEvents] = React.useState<PulseEvent[]>([]);\n  // `step` -1 is the quiet start; 0–2 an open incident; 3 resolved, which is also the calm before the next one.\n  const [phase, setPhase] = React.useState({ incident: 0, step: -1 });\n  const incident = INCIDENTS[phase.incident];\n  const open = phase.step >= 0 && phase.step < 3;\n  const failing = open ? incident.region : null;\n\n  // The incident's clock: updates every 4.5s, then a calm spell, then the next incident.\n  React.useEffect(() => {\n    const wait = phase.step === -1 || phase.step === 3 ? CALM_MS : STEP_MS;\n    const timer = window.setTimeout(() => {\n      setPhase((p) =>\n        p.step === 3 ? { incident: (p.incident + 1) % INCIDENTS.length, step: 0 } : { ...p, step: p.step + 1 },\n      );\n    }, wait);\n    return () => window.clearTimeout(timer);\n  }, [phase]);\n\n  // Health checks: one every 280–650ms from a random region. The failing one checks more often, in red.\n  const failingRef = React.useRef<{ region: string | null; step: number }>({ region: null, step: -1 });\n  React.useEffect(() => {\n    failingRef.current = { region: failing, step: phase.step };\n  }, [failing, phase.step]);\n  React.useEffect(() => {\n    let timer = 0;\n    const tick = () => {\n      const { region: bad, step } = failingRef.current;\n      const region =\n        bad && Math.random() < 0.35\n          ? REGIONS.find((r) => r.code === bad)!\n          : REGIONS[Math.floor(Math.random() * REGIONS.length)];\n      // While monitoring, only some of the failing region's checks still fail.\n      const fails = region.code === bad && (step < 2 || Math.random() < 0.4);\n      const jitter = () => (Math.random() - 0.5) * 0.02;\n      setEvents((list) => [\n        ...list.slice(-11),\n        {\n          id: `check-${nextId++}`,\n          x: region.x + jitter(),\n          y: region.y + jitter(),\n          strength: fails ? 0.8 : 0.3 + Math.random() * 0.15,\n          tone: fails ? \"accent\" : \"ink\",\n          label: region.code,\n        },\n      ]);\n      timer = window.setTimeout(tick, 280 + Math.random() * 370);\n    };\n    timer = window.setTimeout(tick, 400);\n    return () => window.clearTimeout(timer);\n  }, []);\n\n  const shown = phase.step >= 0 ? incident.steps.slice(0, phase.step + 1).reverse() : [];\n\n  return (\n    <Pulse\n      events={events}\n      accentClassName=\"text-red-500 dark:text-red-400\"\n      className=\"flex h-[var(--demo-height,36rem)] w-full flex-col rounded-2xl border border-border bg-background text-foreground\"\n    >\n      {/* The status line sits on a clean ground; the map shows below it. */}\n      <div\n        aria-hidden\n        className=\"pointer-events-none absolute inset-x-0 top-0 h-56 bg-[linear-gradient(to_bottom,var(--background)_55%,transparent)] sm:h-60\"\n      />\n      <header className=\"relative flex items-center justify-between px-5 pt-5 sm:px-8 sm:pt-6\">\n        <a href=\"https://status.ferrule.example\" className=\"flex items-center gap-2 text-sm font-semibold\">\n          <span aria-hidden className=\"grid size-6 place-items-center rounded-md bg-foreground text-background\">\n            <svg viewBox=\"0 0 16 16\" className=\"size-3.5\" fill=\"currentColor\">\n              <path d=\"M3 3h10v3H6v2h6v3H6v2H3z\" />\n            </svg>\n          </span>\n          Ferrule\n          <span className=\"font-normal text-muted-foreground\">Status</span>\n        </a>\n        <a\n          href=\"https://status.ferrule.example/subscribe\"\n          className=\"inline-flex h-9 items-center rounded-full border border-border bg-background px-4 text-sm font-medium transition-colors hover:bg-muted\"\n        >\n          Subscribe\n        </a>\n      </header>\n\n      <div className=\"relative px-5 pt-6 sm:px-8 sm:pt-8\">\n        <h2 className=\"flex items-center gap-2.5 text-2xl font-semibold tracking-tight sm:text-3xl\">\n          <span aria-hidden className={cn(\"size-2.5 shrink-0 rounded-full\", open ? \"bg-red-500 dark:bg-red-400\" : \"bg-foreground\")} />\n          {open ? incident.title : \"All systems operational\"}\n        </h2>\n        <p aria-live=\"polite\" className=\"mt-2 text-sm text-muted-foreground\">\n          {/* The summary describes the outage; once it's identified, the latest update says where things stand. */}\n          {open ? (phase.step === 0 ? incident.summary : incident.steps[phase.step].text) : \"Health checks are passing in all 9 regions.\"}\n        </p>\n      </div>\n\n      <div className=\"flex-1\" />\n\n      <div className=\"relative grid gap-3 p-4 sm:grid-cols-[minmax(0,1.25fr)_minmax(0,1fr)] sm:p-6\">\n        <section className=\"rounded-xl border border-border bg-background p-4 shadow-sm\">\n          <div className=\"flex items-baseline justify-between gap-3\">\n            <h3 className=\"text-sm font-medium\">Regions</h3>\n            <p className=\"text-xs text-muted-foreground tabular-nums\">99.98% over 90 days</p>\n          </div>\n          <ul className=\"mt-3 grid grid-cols-3 gap-x-4 gap-y-2 text-xs\">\n            {REGIONS.map((r) => {\n              const down = r.code === failing;\n              return (\n                <li key={r.code} className=\"flex min-w-0 items-center gap-2\">\n                  <span\n                    aria-hidden\n                    className={cn(\"size-1.5 shrink-0 rounded-full\", down ? \"bg-red-500 dark:bg-red-400\" : \"bg-foreground/35\")}\n                  />\n                  <span className={cn(\"font-mono\", down && \"text-red-600 dark:text-red-400\")}>{r.code}</span>\n                  <span className=\"hidden truncate text-muted-foreground sm:inline\">{r.city}</span>\n                  <span className=\"sr-only\">{down ? \"degraded\" : \"operational\"}</span>\n                </li>\n              );\n            })}\n          </ul>\n        </section>\n\n        <section className=\"rounded-xl border border-border bg-background p-4 shadow-sm\">\n          <h3 className=\"text-sm font-medium\">{shown.length ? incident.title : \"Incidents\"}</h3>\n          {shown.length ? (\n            <ol className=\"mt-3 space-y-2 text-xs\">\n              {shown.map((s, i) => (\n                <li key={s.state} className={cn(\"flex gap-3\", i > 0 && \"text-muted-foreground\")}>\n                  <span className=\"shrink-0 font-mono tabular-nums text-muted-foreground\">{s.at}</span>\n                  <span>\n                    <span\n                      className={cn(\n                        \"font-medium\",\n                        i === 0 && s.state !== \"Resolved\" && \"text-red-600 dark:text-red-400\",\n                        i > 0 && \"text-foreground/70\",\n                      )}\n                    >\n                      {s.state}\n                    </span>{\" \"}\n                    {s.text}\n                  </span>\n                </li>\n              ))}\n            </ol>\n          ) : (\n            <p className=\"mt-3 text-xs text-muted-foreground\">\n              No open incidents. Each region is checked every 30 seconds.\n            </p>\n          )}\n        </section>\n      </div>\n    </Pulse>\n  );\n}\n"
    }
  ]
}