{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tacho-disc",
  "title": "Tacho Disc",
  "description": "Today's security activity as one rotating polar disc under a fixed stylus: sign-ins, permission grants and revocations scribed at their true time-of-day angle, radius by category, older days stacked behind as dimmer discs. Dragging or arrowing it scrubs a real, bound event list.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/core/tacho-disc/component.tsx",
      "content": "\"use client\";\n\nimport {\n  useCallback,\n  useEffect,\n  useMemo,\n  useRef,\n  useState,\n  type KeyboardEvent as ReactKeyboardEvent,\n  type PointerEvent as ReactPointerEvent,\n} from \"react\";\n\n// ---------------------------------------------------------------------------\n// TachoDisc — a day of security activity (sign-ins, permission grants,\n// revocations) drawn as one polar disc: 24 hours mapped to 360 degrees under\n// a fixed stylus at 12 o'clock, every event scribed at its true time-of-day\n// angle. Radius encodes category (sign-ins outer, grants middle, revocations\n// inner, the last drawn as a punched hole rather than a line). Older days sit\n// behind as smaller, dimmer discs sharing the same rotation, so the same\n// time-of-day lines up radially across nights. A faint hour graduation —\n// ticks every hour, numerals at 00/06/12/18 — shares that same rotation\n// rather than sitting fixed under the stylus, so a tick always sits at its\n// own true hour angle and reads as chart paper under the event ink.\n//\n// ONE governing scalar drives the whole disc: `discAngle`, the real\n// time-of-day angle of \"now\". Every mark's screen position is its true\n// timestamp angle plus that single rotation — nothing is laid out by index,\n// so a credential-stuffing run (many failures seconds apart) piles into a\n// visibly dense arc instead of being spread evenly like ordinary traffic.\n// That's the whole point: even-spacing-by-index would hide exactly the\n// pattern this exists to show.\n//\n// The disc is an index onto a real list, not a decoration standing alone:\n// - The event list (time / actor / action / result, all text) is the primary\n//   semantic surface. All disc marks are aria-hidden.\n// - Hovering or arrow-stepping a list row rotates a faint sector highlight to\n//   that event's angle on the disc.\n// - The disc itself is role=\"slider\": dragging it (or arrowing it while\n//   focused, event-to-event, not minute-by-minute) finds the nearest event\n//   and scrolls the list to it, updating aria-valuetext with a live readout.\n// - Live-arriving failures draw in with a 90ms scribe and announce through a\n//   single coalesced aria-live region (\"N failed sign-ins in the last\n//   minute\"), never one announcement per mark. A revocation is a true hole\n//   (background fill + border ring) that appears whole in one frame — no\n//   scribe, it isn't an arrival, it's an absence.\n// ---------------------------------------------------------------------------\n\nexport interface SecurityEvent {\n  id: string;\n  /** ms since epoch */\n  time: number;\n  category: \"sign-in\" | \"grant\" | \"revocation\";\n  actor: string;\n  action: string;\n  result: \"success\" | \"failed\" | \"revoked\";\n}\n\nexport interface TachoDiscProps {\n  /** every event in the visible window — today plus however many prior days feed the dimmer stacked discs. */\n  events: SecurityEvent[];\n  /** how many prior days render as dimmer discs behind today's. Default 2. */\n  historyDays?: number;\n  /** current instant; defaults to an internally ticking clock. Pass to control/test. */\n  now?: number;\n  /** accessible label stem, e.g. \"Security activity\". */\n  label?: string;\n  className?: string;\n}\n\nconst DAY_MS = 86_400_000;\nconst MIN_PER_DAY = 1440;\n\nconst BANDS: Record<SecurityEvent[\"category\"], { r: number; seg: number }> = {\n  \"sign-in\": { r: 118, seg: 15 },\n  grant: { r: 87, seg: 13 },\n  revocation: { r: 55, seg: 0 },\n};\nconst CX = 140;\nconst CY = 140;\nconst DISC_R = 132;\nconst HOLE_R = 5;\n\n// hour graduation — chart paper under the event ink, drawn once at true,\n// unrotated hour angles and sharing the same group rotation as every event\n// mark (see discAngle below): a tick sits exactly where a same-hour event\n// would land, at every rotation, not just when \"now\" happens to be that\n// hour. Faint minor ticks every hour, a slightly longer major tick plus a\n// numeral at the four cardinal hours.\nconst GRAD_R_OUTER = DISC_R;\nconst GRAD_R_MINOR = DISC_R - 4;\nconst GRAD_R_MAJOR = DISC_R - 8;\nconst GRAD_LABEL_R = DISC_R + 11;\nconst HOUR_TICKS = Array.from({ length: 24 }, (_, h) => ({\n  hour: h,\n  angle: (h / 24) * 360,\n  major: h % 6 === 0,\n}));\n\nfunction clamp(v: number, min: number, max: number): number {\n  return Math.min(max, Math.max(min, v));\n}\n\nfunction startOfDay(ms: number): number {\n  const d = new Date(ms);\n  d.setHours(0, 0, 0, 0);\n  return d.getTime();\n}\n\nfunction minutesOfDay(ms: number): number {\n  const d = new Date(ms);\n  return d.getHours() * 60 + d.getMinutes() + d.getSeconds() / 60;\n}\n\nfunction angleForMs(ms: number): number {\n  return (minutesOfDay(ms) / MIN_PER_DAY) * 360;\n}\n\n// rounded to 3 decimals: Math.sin/cos can differ by a ULP between Node (SSR)\n// and the browser's engine (CSR), which surfaced as x1=\"29.148748315591874\"\n// on the server vs 29.148748315591888 on the client — a hydration mismatch\n// despite both being \"correct\". Every mark's coords come through here.\nfunction r3(n: number): number {\n  return Math.round(n * 1000) / 1000;\n}\n\nfunction polar(r: number, angleDeg: number): { x: number; y: number } {\n  const rad = (angleDeg * Math.PI) / 180;\n  return { x: r3(CX + r * Math.sin(rad)), y: r3(CY - r * Math.cos(rad)) };\n}\n\nfunction angDist(a: number, b: number): number {\n  const d = Math.abs(a - b) % 360;\n  return d > 180 ? 360 - d : d;\n}\n\nfunction formatClock(ms: number): string {\n  const d = new Date(ms);\n  return `${String(d.getHours()).padStart(2, \"0\")}:${String(d.getMinutes()).padStart(2, \"0\")}`;\n}\n\nfunction nearbyFailedCount(events: SecurityEvent[], atMinutes: number, windowMin: number): number {\n  let n = 0;\n  for (const e of events) {\n    if (e.result !== \"failed\") continue;\n    if (angDist((minutesOfDay(e.time) / MIN_PER_DAY) * 360, (atMinutes / MIN_PER_DAY) * 360) <= (windowMin / MIN_PER_DAY) * 360) {\n      n++;\n    }\n  }\n  return n;\n}\n\n// -- draw-in mark for a live-arriving failure: undrawn -> drawn over 90ms,\n// via an imperative stroke-dashoffset transition (never React state on the\n// per-mark hot path, matching the ref-write idiom used across the registry).\nfunction ScribeLine({\n  x1,\n  y1,\n  x2,\n  y2,\n  live,\n  reduced,\n  width,\n}: {\n  x1: number;\n  y1: number;\n  x2: number;\n  y2: number;\n  live: boolean;\n  reduced: boolean;\n  width: number;\n}) {\n  const ref = useRef<SVGLineElement | null>(null);\n  const scribedRef = useRef(false);\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || !live || reduced || scribedRef.current) return;\n    scribedRef.current = true;\n    const len = Math.hypot(x2 - x1, y2 - y1) || 1;\n    el.style.strokeDasharray = `${len}`;\n    el.style.strokeDashoffset = `${len}`;\n    const id = requestAnimationFrame(() => {\n      el.style.transition = \"stroke-dashoffset 90ms ease-out\";\n      el.style.strokeDashoffset = \"0\";\n    });\n    return () => cancelAnimationFrame(id);\n  }, [live, reduced, x1, y1, x2, y2]);\n  return <line ref={ref} x1={x1} y1={y1} x2={x2} y2={y2} stroke=\"var(--foreground)\" strokeWidth={width} strokeLinecap=\"round\" />;\n}\n\nexport function TachoDisc({ events, historyDays = 2, now: controlledNow, label = \"Security activity\", className = \"\" }: TachoDiscProps) {\n  // Quantised to the minute: Date.now() on the server and again on the client\n  // milliseconds later gave two different rotation angles (-334.03333 vs\n  // -334.0375) and React discarded the subtree as a hydration mismatch. The\n  // dial only re-reads the clock every 60s and never renders sub-minute\n  // precision, so flooring to the minute costs nothing and makes both renders\n  // agree. The interval below still moves it in real time after mount.\n  const [internalNow, setInternalNow] = useState(() => Math.floor(Date.now() / 60_000) * 60_000);\n  const nowMs = controlledNow ?? internalNow;\n\n  const reducedRef = useRef(false);\n  const [reduced, setReduced] = useState(false);\n  useEffect(() => {\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    reducedRef.current = mq.matches;\n    setReduced(mq.matches);\n    const onChange = () => {\n      reducedRef.current = mq.matches;\n      setReduced(mq.matches);\n    };\n    mq.addEventListener(\"change\", onChange);\n    return () => mq.removeEventListener(\"change\", onChange);\n  }, []);\n\n  useEffect(() => {\n    if (controlledNow !== undefined) return;\n    const id = window.setInterval(() => setInternalNow(Date.now()), 60_000);\n    return () => window.clearInterval(id);\n  }, [controlledNow]);\n\n  const todayStart = useMemo(() => startOfDay(nowMs), [nowMs]);\n\n  // group by day offset (0 = today) once; drawn oldest-first so today paints on top.\n  const layers = useMemo(() => {\n    const byOffset = new Map<number, SecurityEvent[]>();\n    for (const e of events) {\n      const offset = Math.floor((todayStart - startOfDay(e.time)) / DAY_MS);\n      if (offset < 0 || offset > historyDays) continue;\n      const arr = byOffset.get(offset) ?? [];\n      arr.push(e);\n      byOffset.set(offset, arr);\n    }\n    const out: { offset: number; events: SecurityEvent[] }[] = [];\n    for (let o = historyDays; o >= 0; o--) {\n      out.push({ offset: o, events: (byOffset.get(o) ?? []).slice().sort((a, b) => a.time - b.time) });\n    }\n    return out;\n  }, [events, todayStart, historyDays]);\n\n  const todayEvents = layers[layers.length - 1]?.events ?? [];\n\n  // -- shared index: the disc IS the list's index, not a separate widget --\n  const [activeIndex, setActiveIndex] = useState<number | null>(null);\n  const [scrubbing, setScrubbing] = useState(false);\n  const [tabStop, setTabStop] = useState(0);\n  const itemRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n  const scrollToIndex = useCallback((i: number, immediate = false) => {\n    itemRefs.current[i]?.scrollIntoView({\n      block: \"nearest\",\n      behavior: reducedRef.current || immediate ? \"auto\" : \"smooth\",\n    });\n  }, []);\n\n  // -- live arrivals: track which ids have been seen so only genuinely new\n  // failure marks scribe in; the initial mount never animates. --\n  const seenIdsRef = useRef<Set<string> | null>(null);\n  const [liveIds, setLiveIds] = useState<Set<string>>(new Set());\n  const [liveMessage, setLiveMessage] = useState(\"\");\n  const pendingFailuresRef = useRef(0);\n  const announceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n  const announceParityRef = useRef(false);\n\n  useEffect(() => {\n    const seen = seenIdsRef.current;\n    if (seen === null) {\n      seenIdsRef.current = new Set(events.map((e) => e.id));\n      return;\n    }\n    const fresh: string[] = [];\n    for (const e of events) {\n      if (!seen.has(e.id)) {\n        seen.add(e.id);\n        fresh.push(e.id);\n        if (e.result === \"failed\") pendingFailuresRef.current += 1;\n      }\n    }\n    if (fresh.length > 0) {\n      setLiveIds((prev) => {\n        const next = new Set(prev);\n        for (const id of fresh) next.add(id);\n        return next;\n      });\n    }\n    // clear-and-reschedule: every arrival pushes the window out, so one burst\n    // (however long it runs) resolves to exactly one announcement, not one\n    // per arrival and not a truncated first window plus a trailing one.\n    if (pendingFailuresRef.current > 0) {\n      if (announceTimerRef.current) clearTimeout(announceTimerRef.current);\n      announceTimerRef.current = setTimeout(() => {\n        const n = pendingFailuresRef.current;\n        pendingFailuresRef.current = 0;\n        announceTimerRef.current = null;\n        // a zero-width toggle forces a real text-node change even when the\n        // message repeats verbatim across bursts — that's what actually\n        // re-triggers the announcement (see autosave-ratchet).\n        announceParityRef.current = !announceParityRef.current;\n        setLiveMessage(`${n} failed sign-in${n === 1 ? \"\" : \"s\"} in the last minute${announceParityRef.current ? \"​\" : \"\"}`);\n      }, 700);\n    }\n  }, [events]);\n\n  useEffect(() => {\n    return () => {\n      if (announceTimerRef.current) clearTimeout(announceTimerRef.current);\n    };\n  }, []);\n\n  const discAngle = useMemo(() => -angleForMs(nowMs), [nowMs]);\n\n  const activeEvent = activeIndex !== null ? todayEvents[activeIndex] : undefined;\n\n  const failuresLastHour = useMemo(() => nearbyFailedCount(todayEvents, minutesOfDay(nowMs), 60), [todayEvents, nowMs]);\n\n  const valueNow = activeEvent ? Math.round(minutesOfDay(activeEvent.time)) : Math.round(minutesOfDay(nowMs));\n  const valueText = activeEvent\n    ? scrubbing\n      ? `scrubbing ${formatClock(activeEvent.time)}, ${nearbyFailedCount(todayEvents, minutesOfDay(activeEvent.time), 30)} failed sign-ins nearby`\n      : `${formatClock(activeEvent.time)}, ${activeEvent.actor}, ${activeEvent.action}, ${activeEvent.result}`\n    : `now ${formatClock(nowMs)}, ${failuresLastHour} failed sign-in${failuresLastHour === 1 ? \"\" : \"s\"} in the last hour`;\n\n  const setActive = useCallback(\n    (i: number | null, scroll = true, immediate = false) => {\n      setActiveIndex(i);\n      if (i !== null && scroll) scrollToIndex(i, immediate);\n    },\n    [scrollToIndex]\n  );\n\n  const nearestIndexAtAngle = useCallback(\n    (screenAngle: number, radius: number) => {\n      if (todayEvents.length === 0) return null;\n      const trueAngle = (((screenAngle - discAngle) % 360) + 360) % 360;\n      let bestCategory: SecurityEvent[\"category\"] = \"sign-in\";\n      let bestDr = Infinity;\n      (Object.keys(BANDS) as SecurityEvent[\"category\"][]).forEach((cat) => {\n        const dr = Math.abs(radius - BANDS[cat].r);\n        if (dr < bestDr) {\n          bestDr = dr;\n          bestCategory = cat;\n        }\n      });\n      let candidates = todayEvents.map((e, i) => ({ e, i })).filter(({ e }) => e.category === bestCategory);\n      if (candidates.length === 0) candidates = todayEvents.map((e, i) => ({ e, i }));\n      let best = candidates[0]!;\n      let bestDist = Infinity;\n      for (const c of candidates) {\n        const d = angDist(angleForMs(c.e.time), trueAngle);\n        if (d < bestDist) {\n          bestDist = d;\n          best = c;\n        }\n      }\n      return best.i;\n    },\n    [todayEvents, discAngle]\n  );\n\n  // The interactive box: role=\"slider\" and every pointer/keyboard handler\n  // live on this plain <div>, not the <svg> — a focus-visible outline on an\n  // SVG root is unverifiable across browsers, so the SVG below is purely\n  // aria-hidden decoration sized to fill this box.\n  const discBoxRef = useRef<HTMLDivElement | null>(null);\n  const draggingRef = useRef(false);\n\n  const angleFromPointer = (clientX: number, clientY: number) => {\n    const rect = discBoxRef.current?.getBoundingClientRect();\n    if (!rect) return null;\n    const scale = 280 / rect.width;\n    const x = (clientX - rect.left) * scale - CX;\n    const y = (clientY - rect.top) * scale - CY;\n    let deg = (Math.atan2(x, -y) * 180) / Math.PI;\n    if (deg < 0) deg += 360;\n    return { deg, radius: Math.hypot(x, y) };\n  };\n\n  const onPointerDown = (e: ReactPointerEvent<HTMLDivElement>) => {\n    discBoxRef.current?.setPointerCapture(e.pointerId);\n    draggingRef.current = true;\n    setScrubbing(true);\n    const p = angleFromPointer(e.clientX, e.clientY);\n    if (p) {\n      const idx = nearestIndexAtAngle(p.deg, p.radius);\n      if (idx !== null) setActive(idx, true, true);\n    }\n  };\n  const onPointerMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n    // live hover preview (not just active drags) — the disc is an index, so\n    // sweeping it with the pointer should rotate the highlight the same way\n    // hovering the list does, even before a drag starts. But a hover sweep\n    // (not dragging) must only move the highlight, never re-target the list's\n    // scroll position on every ~30Hz sample — only an actual drag scrolls,\n    // and it scrolls immediately (no smooth re-target chase mid-gesture).\n    const p = angleFromPointer(e.clientX, e.clientY);\n    if (p) {\n      const idx = nearestIndexAtAngle(p.deg, p.radius);\n      if (idx !== null) setActive(idx, draggingRef.current, true);\n    }\n  };\n  const onPointerUp = (e: ReactPointerEvent<HTMLDivElement>) => {\n    if (!draggingRef.current) return;\n    draggingRef.current = false;\n    setScrubbing(false);\n    discBoxRef.current?.releasePointerCapture(e.pointerId);\n  };\n\n  const onDiscKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {\n    if (todayEvents.length === 0) return;\n    const step = (delta: number) => {\n      e.preventDefault();\n      const base = activeIndex ?? 0;\n      const next = clamp(base + delta, 0, todayEvents.length - 1);\n      setActive(next);\n    };\n    switch (e.key) {\n      case \"ArrowLeft\":\n      case \"ArrowDown\":\n        step(-1);\n        break;\n      case \"ArrowRight\":\n      case \"ArrowUp\":\n        step(1);\n        break;\n      case \"Home\":\n        e.preventDefault();\n        setActive(0);\n        break;\n      case \"End\":\n        e.preventDefault();\n        setActive(todayEvents.length - 1);\n        break;\n      default:\n        break;\n    }\n  };\n\n  const onListKeyDown = (e: ReactKeyboardEvent<HTMLButtonElement>, i: number) => {\n    const move = (next: number) => {\n      e.preventDefault();\n      const clamped = clamp(next, 0, todayEvents.length - 1);\n      setTabStop(clamped);\n      setActiveIndex(clamped);\n      itemRefs.current[clamped]?.focus();\n    };\n    switch (e.key) {\n      case \"ArrowDown\":\n        move(i + 1);\n        break;\n      case \"ArrowUp\":\n        move(i - 1);\n        break;\n      case \"Home\":\n        move(0);\n        break;\n      case \"End\":\n        move(todayEvents.length - 1);\n        break;\n      default:\n        break;\n    }\n  };\n\n  return (\n    <div className={`flex flex-col gap-6 sm:flex-row sm:items-start ${className}`}>\n      <style>{CSS}</style>\n\n      <div\n        ref={discBoxRef}\n        data-tacho-disc=\"\"\n        role=\"slider\"\n        tabIndex={0}\n        aria-label={`${label} disc`}\n        aria-valuemin={0}\n        aria-valuemax={MIN_PER_DAY - 1}\n        aria-valuenow={valueNow}\n        aria-valuetext={valueText}\n        className=\"ns-tacho-disc h-64 w-64 shrink-0 touch-none select-none rounded-full focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ns-accent\"\n        onPointerDown={onPointerDown}\n        onPointerMove={onPointerMove}\n        onPointerUp={onPointerUp}\n        onPointerCancel={onPointerUp}\n        onKeyDown={onDiscKeyDown}\n      >\n      <svg viewBox=\"-16 -16 312 312\" aria-hidden=\"true\" className=\"block h-full w-full\">\n        <circle cx={CX} cy={CY} r={DISC_R} fill=\"none\" stroke=\"var(--border)\" strokeWidth={1} aria-hidden=\"true\" />\n\n        {/* fixed stylus at 12 o'clock — outside the rotating group, never moves */}\n        <g aria-hidden=\"true\">\n          <polygon points={`${CX - 5},4 ${CX + 5},4 ${CX},15`} fill=\"var(--foreground)\" />\n          <line x1={CX} y1={15} x2={CX} y2={28} stroke=\"var(--foreground)\" strokeWidth={2} />\n        </g>\n\n        {/* the one governing scalar: discAngle. every layer below shares this rotation. */}\n        <g transform={`rotate(${discAngle} ${CX} ${CY})`} className={reduced ? \"\" : \"ns-tacho-rotate\"} aria-hidden=\"true\">\n          {/* hour graduation — chart paper, drawn under the event ink and rotating\n              with it so a tick always sits at its own true hour angle. */}\n          <g>\n            {HOUR_TICKS.map(({ hour, angle, major }) => {\n              const inner = polar(major ? GRAD_R_MAJOR : GRAD_R_MINOR, angle);\n              const outer = polar(GRAD_R_OUTER, angle);\n              return (\n                <g key={hour}>\n                  <line\n                    x1={inner.x}\n                    y1={inner.y}\n                    x2={outer.x}\n                    y2={outer.y}\n                    stroke=\"var(--ns-muted)\"\n                    strokeWidth={major ? 1 : 0.5}\n                    strokeOpacity={major ? 0.6 : 0.35}\n                  />\n                  {major && (\n                    <g transform={`rotate(${-discAngle} ${polar(GRAD_LABEL_R, angle).x} ${polar(GRAD_LABEL_R, angle).y})`}>\n                      <text\n                        x={polar(GRAD_LABEL_R, angle).x}\n                        y={polar(GRAD_LABEL_R, angle).y}\n                        textAnchor=\"middle\"\n                        dominantBaseline=\"middle\"\n                        fill=\"var(--ns-muted)\"\n                        fontSize={9}\n                        style={{ fontFamily: \"var(--font-mono)\" }}\n                      >\n                        {String(hour).padStart(2, \"0\")}\n                      </text>\n                    </g>\n                  )}\n                </g>\n              );\n            })}\n          </g>\n\n          {layers.map(({ offset, events: dayEvents }) => {\n            const isToday = offset === 0;\n            const layerScale = 1 - offset * 0.13;\n            const opacity = isToday ? 1 : Math.max(0.16, 0.5 - offset * 0.15);\n            return (\n              <g key={offset} opacity={opacity}>\n                {dayEvents.map((ev) => {\n                  const angle = angleForMs(ev.time);\n                  if (ev.category === \"revocation\") {\n                    const r = BANDS.revocation.r * layerScale;\n                    const p = polar(r, angle);\n                    return (\n                      <circle\n                        key={ev.id}\n                        cx={p.x}\n                        cy={p.y}\n                        r={HOLE_R * layerScale}\n                        fill=\"var(--background)\"\n                        stroke=\"var(--border)\"\n                        strokeWidth={1.5}\n                      />\n                    );\n                  }\n                  const band = BANDS[ev.category];\n                  const r = band.r * layerScale;\n                  const seg = band.seg * layerScale;\n                  const p1 = polar(r - seg / 2, angle);\n                  const p2 = polar(r + seg / 2, angle);\n                  const failed = ev.result === \"failed\";\n                  if (isToday && failed) {\n                    return (\n                      <ScribeLine\n                        key={ev.id}\n                        x1={p1.x}\n                        y1={p1.y}\n                        x2={p2.x}\n                        y2={p2.y}\n                        width={8}\n                        live={liveIds.has(ev.id)}\n                        reduced={reduced}\n                      />\n                    );\n                  }\n                  return (\n                    <line\n                      key={ev.id}\n                      x1={p1.x}\n                      y1={p1.y}\n                      x2={p2.x}\n                      y2={p2.y}\n                      stroke=\"var(--foreground)\"\n                      strokeWidth={failed ? 8 : 3}\n                      strokeLinecap=\"round\"\n                    />\n                  );\n                })}\n                {isToday && activeEvent && (\n                  <line\n                    x1={CX}\n                    y1={CY}\n                    x2={polar(DISC_R - 4, angleForMs(activeEvent.time)).x}\n                    y2={polar(DISC_R - 4, angleForMs(activeEvent.time)).y}\n                    stroke=\"var(--ns-accent)\"\n                    strokeWidth={16}\n                    strokeOpacity={0.1}\n                    strokeLinecap=\"round\"\n                  />\n                )}\n              </g>\n            );\n          })}\n        </g>\n      </svg>\n      </div>\n\n      <div className=\"flex min-w-0 flex-1 flex-col gap-2\">\n        <div className=\"flex items-baseline justify-between gap-3\">\n          <h3 className=\"text-sm font-medium text-foreground\">{label}</h3>\n          <span className=\"font-mono text-xs tabular-nums text-ns-muted\">last 24h · now {formatClock(nowMs)}</span>\n        </div>\n\n        <ul\n          role=\"list\"\n          aria-label={`${label} events, last 24 hours`}\n          className=\"ns-tacho-list flex max-h-72 flex-col gap-1 overflow-y-auto rounded-[12px] border border-border bg-background p-1\"\n        >\n          {todayEvents.length === 0 && <li className=\"px-3 py-4 text-sm text-ns-muted\">No activity in the last 24 hours.</li>}\n          {todayEvents.map((ev, i) => {\n            const isActive = activeIndex === i;\n            return (\n              <li key={ev.id}>\n                <button\n                  type=\"button\"\n                  ref={(el) => {\n                    itemRefs.current[i] = el;\n                  }}\n                  tabIndex={tabStop === i ? 0 : -1}\n                  aria-current={isActive ? \"true\" : undefined}\n                  aria-label={`${formatClock(ev.time)}, ${ev.actor}, ${ev.action}, ${ev.result}`}\n                  className={`ns-tacho-row flex w-full items-center gap-3 rounded-[6px] px-2 py-1.5 text-left text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ns-accent ${\n                    isActive ? \"ns-tacho-row-active\" : \"\"\n                  }`}\n                  onMouseEnter={() => setActive(i)}\n                  onFocus={() => {\n                    setTabStop(i);\n                    setActiveIndex(i);\n                  }}\n                  onKeyDown={(e) => onListKeyDown(e, i)}\n                >\n                  <span aria-hidden=\"true\" className=\"w-3 shrink-0 text-center text-foreground\">\n                    {isActive ? \"›\" : \"\"}\n                  </span>\n                  <time className={`w-12 shrink-0 font-mono text-xs tabular-nums text-ns-muted ${isActive ? \"font-semibold\" : \"\"}`}>\n                    {formatClock(ev.time)}\n                  </time>\n                  <span className={`w-44 shrink-0 truncate text-foreground ${isActive ? \"font-semibold\" : \"\"}`}>{ev.actor}</span>\n                  <span className=\"min-w-0 flex-1 truncate text-ns-muted\">{ev.action}</span>\n                  <span\n                    className={`shrink-0 font-mono text-xs uppercase tracking-wide ${\n                      ev.result === \"failed\" ? \"text-foreground\" : \"text-ns-muted\"\n                    }`}\n                  >\n                    {ev.result}\n                  </span>\n                </button>\n              </li>\n            );\n          })}\n        </ul>\n\n        <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n          {liveMessage}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nconst CSS = `\n.ns-tacho-rotate{ transition: transform 60s linear; }\n.ns-tacho-row-active{ background-color: var(--border); }\n@media (prefers-reduced-motion: reduce){\n  .ns-tacho-rotate{ transition: none !important; }\n}\n`;\n",
      "type": "registry:ui",
      "target": "components/ui/tacho-disc.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-ns-muted": "var(--ns-muted)",
      "color-ns-accent": "var(--ns-accent)"
    },
    "light": {
      "ns-muted": "#4d4d4d",
      "ns-accent": "#006bff"
    },
    "dark": {
      "ns-muted": "#8f8f8f"
    }
  },
  "meta": {
    "collection": "core",
    "tags": [
      "security",
      "activity-log",
      "svg",
      "slider",
      "feed",
      "aria-live",
      "keyboard",
      "accessibility",
      "dashboard"
    ],
    "instruction": "Build <TachoDisc events historyDays? now? label? className?> where `events: SecurityEvent[]` is `{ id, time /* ms epoch */, category: \"sign-in\"|\"grant\"|\"revocation\", actor, action, result: \"success\"|\"failed\"|\"revoked\" }[]`. STRUCTURE: a flex row (column on narrow viewports) of an SVG disc on one side and a real event list on the other — the list is the primary semantic surface, the disc is aria-hidden geometry plus one role=\"slider\" control. GEOMETRY / THE ONE GOVERNING SCALAR: 24 hours maps to 360 degrees (angleForMs = minutesOfDay/1440*360, clockwise from 12 o'clock). Compute exactly one rotation value, `discAngle = -angleForMs(now)`, and apply it as a single SVG <g transform=\"rotate(discAngle cx cy)\"> wrapping every day's marks — every mark inside is positioned at its OWN true, unrotated timestamp angle; the shared group rotation is what makes \"now\" line up under a fixed stylus glyph drawn OUTSIDE that group at 12 o'clock, which itself never moves. This is the falsifiable constraint: marks sit at true angular time on the shared clock. Do NOT lay marks out evenly by array index — a burst of failures seconds apart must pile into a visibly dense arc because it geometrically is one; index-based spacing would hide exactly the pattern the component exists to reveal. HOUR GRADUATION: inside that same rotated group, under every event layer, draw a faint hour ring — a tick at each of the 24 true hour angles, a slightly longer major tick plus a `00`/`06`/`12`/`18` numeral (Geist Mono, var(--ns-muted), counter-rotated in place so the glyph itself stays upright as the disc turns) at the cardinal hours — so the dial reads as a day at a glance instead of a bare fan of event ticks; it shares discAngle rather than sitting fixed under the stylus, because a fixed graduation would drift out of true-hour alignment with the events the moment \"now\" moved off the hour. It is chart paper: thinner and dimmer than every event mark, never var(--foreground), never mistakable for one. RADIUS BY CATEGORY: sign-ins draw as a radial line segment at the outer radius band, grants at a middle radius band, revocations at the innermost radius but as a punched HOLE — a small circle filled var(--background) with a var(--border) ring stroke, appearing whole in a single frame with no draw-in animation (it is an absence being marked, not an arrival). Ordinary sign-in/grant events (result \"success\") draw as a 3px hairline (var(--foreground), round cap). Any event with result \"failed\" draws at 8px stroke width regardless of category. OLDER DAYS: group events by calendar day (0 = today); render days oldest-first inside the SAME rotated group so they share discAngle, each day's own sub-group scaled slightly smaller (~13% per day back, applied to that day's radius numbers, not a DOM-level CSS scale/transform-origin trick) and faded down toward ~0.16 opacity, so older nights sit behind today as visibly smaller, dimmer, concentric discs, with the same time-of-day landing at the same angle across all of them for at-a-glance night-over-night comparison. LIVE ARRIVALS: track which event ids were present at first mount; any id that appears afterward on a TODAY, failed, sign-in/grant mark gets a 90ms stroke-dashoffset draw-in (dasharray = own line length, offset animated length\\u21920 via an imperative ref effect on mount of that mark, one real transition, never a CSS keyframe percentage hack) — skip the animation entirely under prefers-reduced-motion, drawing it fully formed instead. Revocations never scribe. THE DISC AS INDEX, NOT DECORATION: keep one shared piece of state, `activeIndex` into today's chronologically-sorted events, plus a transient `scrubbing` boolean. Hovering a list row, or arrow/Home/End-ing within the list (roving tabindex, one row's button has tabIndex 0 at a time, ArrowUp/Down moves both the DOM focus and activeIndex, Home/End jump to first/last), sets activeIndex and — inside the disc's rotated \"today\" sub-group only — draws a low-opacity var(--ns-accent) wedge (fillOpacity ~0.1, a wide radial line from center outward) at that event's angle: this is the one and only place --ns-accent appears, purely interaction-driven, never a resting/decorative color. The disc SVG itself is role=\"slider\" tabIndex 0, aria-valuemin 0, aria-valuemax 1439 (minutes in a day), aria-valuenow the active (or, if none, \"now\") event's minute-of-day, aria-valuetext formatted `scrubbing HH:MM, N failed sign-ins nearby` while a pointer drag is live, `HH:MM, actor, action, result` when a row/step is focused but not dragging, or `now HH:MM, N failed sign-ins in the last hour` at rest. ArrowLeft/Down and ArrowRight/Up on the focused disc step activeIndex to the previous/next event chronologically (event-to-event, never a fixed-minute increment) and Home/End jump to the day's first/last event; every activeIndex change (from either the list or the disc) calls scrollIntoView({block:'nearest'}) on the corresponding list row, so scrubbing the disc scrolls the list to the nearest event and vice versa. Dragging directly on the disc (pointerdown/move/up, pointer capture held for the gesture) converts the pointer's angle-from-center back through the current discAngle into a true time-of-day, picks the category band whose radius the pointer is nearest, and sets activeIndex to the angularly-nearest event within that band (falling back to nearest across all categories if that band is empty for the day) — this is a live scrub, not a discrete click. LIVE-FAILURE ANNOUNCEMENT: a visually-hidden role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" node is the ONLY place new failures are spoken. Batch every failed arrival behind a ~700ms debounce and announce once per batch — \"4 failed sign-ins in the last minute\", pluralized — never one live-region update per mark; this is a hard constraint, not a nicety, since a real credential-stuffing run would otherwise spam a screen reader with dozens of individual announcements. TOKENS: every disc mark, ring, and hole uses var(--foreground)/var(--border)/var(--background) only; var(--ns-accent) is reserved solely for the interaction-driven highlight wedge and the slider/list focus-visible rings — never a resting color, never the failure or revocation encoding itself (severity is stroke weight and hole shape, not color). REDUCED MOTION: the rotating group's 60s linear CSS transition (the mechanism that makes discAngle glide smoothly as the internal clock ticks once a minute) is disabled outright, so the disc jumps to each new minute's angle rather than sweeping — the update cadence itself doesn't need to change, only whether it's animated; the scribe draw-in is likewise skipped, marks simply appear complete. DEMO: three days of baseline sign-ins/grants, today seeded with a tight nine-failure credential-stuffing run (~95s apart) followed by a session-key revocation around 03:10\\u201303:27, then a real setInterval appends a fresh 4-failure burst to the SAME today array a beat after mount and again every ~9s, driving the live scribe-in and coalesced announcement through actual state updates rather than a scripted replay."
  },
  "type": "registry:ui"
}