{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-ops-03",
  "title": "AI service status",
  "description": "A status page for an AI product: one uptime bar per service read day by day, p50 and p95 lines that glide to the service you pick, and an incident that writes its updates until the orb turns green again.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/chip.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/status-orb.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-03/index.tsx",
      "content": "'use client';\n\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\nimport { StatusOrb } from '@/registry/ndeko/ui/status-orb';\n\nimport { MODELS_DURING_FAULT, PRODUCT_NAME, serviceOf, SERVICES } from './data';\nimport { Incidents } from './incidents';\nimport { LatencyChart } from './latency-chart';\nimport { ServiceList } from './services';\nimport {\n  CONFIRM_MS,\n  hasIncidentToday,\n  INITIAL,\n  isFaultOpen,\n  isSlowNow,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  type Reading,\n  type StatusState,\n} from './session';\nimport { Subscribe } from './subscribe';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nfunction headlineOf(isDegraded: boolean) {\n  if (isDegraded) {\n    return 'Model endpoints are slower than usual';\n  }\n  return 'All systems operational';\n}\n\nfunction orbToneOf(isDegraded: boolean) {\n  if (isDegraded) {\n    return 'warning';\n  }\n  return 'success';\n}\n\n/** While the fault slows the model endpoints, their chart shows the end of both lines lifted. */\nfunction chartServiceOf(state: StatusState) {\n  const isModels = state.selected === 'models';\n  if (isModels && isSlowNow(state)) {\n    return MODELS_DURING_FAULT;\n  }\n  return serviceOf(state.selected);\n}\n\n/** The day the demonstration reads leaves with the demonstration. */\nfunction demoReadingOf(isDemonstrating: boolean, reading: Reading | null) {\n  if (isDemonstrating) {\n    return reading;\n  }\n  return null;\n}\n\nexport default function AgentOps03() {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const { schedule } = useTimeouts();\n  const isDegraded = isFaultOpen(state);\n  const headline = headlineOf(isDegraded);\n  const chartService = chartServiceOf(state);\n  const demoReading = demoReadingOf(isAutoplaying, state.reading);\n  const message = spokenUnless(isAutoplaying, headline);\n  const canReplay = isFinished && !isAutoplaying;\n\n  function subscribe() {\n    act({ type: 'subscribe' });\n    schedule(() => act({ type: 'subscribed' }), CONFIRM_MS);\n  }\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-background text-foreground @container min-h-dvh w-full'\n      >\n        <div className='mx-auto flex max-w-5xl flex-col gap-5 p-4 @3xl:gap-6 @3xl:p-8'>\n          <header className='flex flex-wrap items-center gap-x-4 gap-y-3'>\n            <StatusOrb tone={orbToneOf(isDegraded)} />\n            <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n              <h1 className='text-xl font-semibold text-balance'>\n                <Swap swapKey={headline}>{headline}</Swap>\n              </h1>\n              <p className='text-muted-foreground text-xs'>\n                {PRODUCT_NAME} status · {SERVICES.length} services ·\n                Illustrative figures\n              </p>\n            </div>\n            <ReplayButton\n              isShown={canReplay}\n              onReplay={restart}\n              label='Replay the incident'\n            />\n          </header>\n\n          <div className='flex flex-col gap-4 @4xl:grid @4xl:grid-cols-2 @4xl:items-start @4xl:gap-5'>\n            <div className='min-w-0 @4xl:order-2'>\n              <LatencyChart service={chartService} />\n            </div>\n            <div className='min-w-0 @4xl:order-1'>\n              <ServiceList\n                selected={state.selected}\n                hasFaultToday={hasIncidentToday(state)}\n                isFaultOpen={isDegraded}\n                demoReading={demoReading}\n                pressed={pressed}\n                onSelect={(id) => act({ type: 'selected', id })}\n              />\n            </div>\n          </div>\n\n          <div className='flex flex-col gap-5 @4xl:grid @4xl:grid-cols-[minmax(0,1fr)_22rem] @4xl:items-start @4xl:gap-8'>\n            <Incidents liveUpdatesOut={state.updatesOut} />\n            <Subscribe\n              email={state.email}\n              subscription={state.subscription}\n              isPressed={pressed === 'subscribe'}\n              onEmailChange={(text) => act({ type: 'typed', text })}\n              onSubscribe={subscribe}\n              onUnsubscribe={() => act({ type: 'unsubscribed' })}\n            />\n          </div>\n        </div>\n        <LiveRegion message={message} />\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-03/services.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { WordRoll } from '@/components/core/word-roll';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport {\n  dateLabelOf,\n  DAY_COUNT,\n  dayEventOf,\n  FAULT_MINUTES,\n  SERVICES,\n  TODAY,\n  uptimeOf,\n  type DayEvent,\n  type DayStatus,\n  type Service,\n  type ServiceId,\n} from './data';\n\n/** Phones show the last 45 days: 90 cells in 343 pixels are too thin to read or to touch. */\nconst PHONE_DAYS = 45;\n\nconst FIRST_PHONE_DAY = DAY_COUNT - PHONE_DAYS;\n\nconst DAYS = Array.from({ length: DAY_COUNT }, (_, day) => day);\n\nconst DAY_WORD: Record<DayStatus, string> = {\n  ok: 'No incident',\n  degraded: 'Slower than usual',\n  outage: 'Down',\n};\n\nconst DAY_TONE: Record<DayStatus, string> = {\n  ok: 'bg-success/50',\n  degraded: 'bg-warning',\n  outage: 'bg-destructive',\n};\n\nconst STATE_WORDS = ['Operational', 'Degraded'];\n\nconst UPTIME_FORMAT = new Intl.NumberFormat('en-US', {\n  minimumFractionDigits: 2,\n  maximumFractionDigits: 2,\n});\n\n/** The bubble follows the day it reads and stops at both ends of the bar, so it never leaves the block. */\nconst BUBBLE_LEFT =\n  'clamp(4.75rem, calc((var(--day) - var(--first-day) + 0.5) / var(--day-count) * 100%), calc(100% - 4.75rem))';\n\ntype BubbleStyle = React.CSSProperties & { '--day': number };\n\nfunction minutesOf(event: DayEvent) {\n  if (event.status === 'ok') {\n    return 'Every request answered in time';\n  }\n  if (event.minutes === 1) {\n    return '1 minute affected';\n  }\n  return `${event.minutes} minutes affected`;\n}\n\nfunction stateWordOf(isDegraded: boolean) {\n  if (isDegraded) {\n    return 'Degraded';\n  }\n  return 'Operational';\n}\n\nfunction stateToneOf(isDegraded: boolean) {\n  if (isDegraded) {\n    return 'text-warning-foreground';\n  }\n  return 'text-muted-foreground';\n}\n\nfunction dotToneOf(isDegraded: boolean) {\n  if (isDegraded) {\n    return 'bg-warning';\n  }\n  return 'bg-success';\n}\n\n/** The picked service is tinted as a whole, so its button only answers the pointer when it is not picked. */\nfunction rowToneOf(isSelected: boolean) {\n  if (isSelected) {\n    return undefined;\n  }\n  return 'hover:bg-foreground/[0.04]';\n}\n\nfunction pressedQuietOf(isPressed: boolean) {\n  if (isPressed) {\n    return 'scale-[0.985] bg-foreground/[0.07]';\n  }\n  return undefined;\n}\n\nfunction cellLiftOf(isRead: boolean) {\n  if (isRead) {\n    return '-translate-y-0.5 opacity-100';\n  }\n  return 'opacity-75';\n}\n\nfunction dayOfTarget(target: EventTarget) {\n  if (!(target instanceof HTMLElement)) {\n    return null;\n  }\n  const value = target.dataset.day;\n  if (value === undefined) {\n    return null;\n  }\n  return Number(value);\n}\n\nfunction firstDayOf(bar: HTMLElement) {\n  const value = getComputedStyle(bar).getPropertyValue('--first-day');\n  return Number(value);\n}\n\nfunction steppedDayOf(key: string, current: number, firstDay: number) {\n  if (key === 'ArrowRight') {\n    return Math.min(current + 1, TODAY);\n  }\n  if (key === 'ArrowLeft') {\n    return Math.max(current - 1, firstDay);\n  }\n  if (key === 'Home') {\n    return firstDay;\n  }\n  if (key === 'End') {\n    return TODAY;\n  }\n  return null;\n}\n\ntype UptimeBarProps = {\n  service: Service;\n  todayEvent: DayEvent | null;\n  /** The day the demonstration reads, shown while no pointer and no key reads another. */\n  demoDay: number | null;\n};\n\nfunction UptimeBar({ service, todayEvent, demoDay }: UptimeBarProps) {\n  const [pointerDay, setPointerDay] = useState<number | null>(null);\n  const [keyDay, setKeyDay] = useState<number | null>(null);\n  const [lastDay, setLastDay] = useState(TODAY);\n  const activeDay = pointerDay ?? keyDay ?? demoDay;\n  const isReading = activeDay !== null;\n  if (activeDay !== null && activeDay !== lastDay) {\n    setLastDay(activeDay);\n  }\n\n  function eventOf(day: number) {\n    const isToday = day === TODAY;\n    if (isToday && todayEvent) {\n      return todayEvent;\n    }\n    return dayEventOf(service.id, day);\n  }\n\n  const shownDay = activeDay ?? lastDay;\n  const shownEvent = eventOf(shownDay);\n  const shownDate = dateLabelOf(shownDay);\n  const shownWord = DAY_WORD[shownEvent.status];\n  const shownMinutes = minutesOf(shownEvent);\n  const bubbleStyle: BubbleStyle = { left: BUBBLE_LEFT, '--day': shownDay };\n  const isReadingByKeys = keyDay !== null;\n  const spokenReading = `${shownDate}: ${shownWord}. ${shownMinutes}`;\n\n  function point(event: React.PointerEvent<HTMLDivElement>) {\n    const day = dayOfTarget(event.target);\n    if (day !== null) {\n      setPointerDay(day);\n    }\n  }\n\n  function leave(event: React.PointerEvent<HTMLDivElement>) {\n    if (event.pointerType === 'mouse') {\n      setPointerDay(null);\n    }\n  }\n\n  function focus(event: React.FocusEvent<HTMLDivElement>) {\n    const isKeyboardFocus = event.currentTarget.matches(':focus-visible');\n    if (isKeyboardFocus) {\n      setKeyDay(lastDay);\n    }\n  }\n\n  function blur() {\n    setKeyDay(null);\n    setPointerDay(null);\n  }\n\n  function step(event: React.KeyboardEvent<HTMLDivElement>) {\n    if (event.key === 'Escape') {\n      setKeyDay(null);\n      return;\n    }\n    const firstDay = firstDayOf(event.currentTarget);\n    const current = keyDay ?? lastDay;\n    const next = steppedDayOf(event.key, current, firstDay);\n    if (next === null) {\n      return;\n    }\n    event.preventDefault();\n    setPointerDay(null);\n    setKeyDay(next);\n  }\n\n  return (\n    <div className='relative [--day-count:45] [--first-day:45] @md:[--day-count:90] @md:[--first-day:0]'>\n      <div\n        role='group'\n        tabIndex={0}\n        aria-label={`Uptime of ${service.name}, day by day. Use the arrow keys to read each day.`}\n        onPointerMove={point}\n        onPointerDown={point}\n        onPointerLeave={leave}\n        onFocus={focus}\n        onBlur={blur}\n        onKeyDown={step}\n        className='focus-visible:ring-ring/25 flex h-7 touch-pan-y items-stretch gap-px rounded-sm outline-none focus-visible:ring-[3px]'\n      >\n        {DAYS.map((day) => {\n          const event = eventOf(day);\n          const isPhoneDay = day >= FIRST_PHONE_DAY;\n          const isRead = isReading && day === activeDay;\n          return (\n            <span\n              key={day}\n              data-day={day}\n              className={cn(\n                'min-w-0 flex-1 rounded-[2px] transition-[translate,opacity,background-color] duration-100',\n                DAY_TONE[event.status],\n                cellLiftOf(isRead),\n                !isPhoneDay && 'hidden @md:block'\n              )}\n            />\n          );\n        })}\n      </div>\n      <div\n        aria-hidden='true'\n        style={bubbleStyle}\n        className='pointer-events-none absolute bottom-full z-10 mb-1.5 w-0'\n      >\n        <div\n          className={cn(\n            'surface-raised flex w-36 -translate-x-1/2 flex-col gap-0.5 rounded-lg px-2.5 py-1.5 text-xs',\n            'origin-bottom transition-[opacity,scale] duration-[125ms] ease-(--ease-out-strong)',\n            !isReading && 'scale-[0.97] opacity-0'\n          )}\n        >\n          <span className='text-muted-foreground tabular-nums'>\n            {shownDate}\n          </span>\n          <span className='font-medium'>{shownWord}</span>\n          <span className='text-muted-foreground tabular-nums'>\n            {shownMinutes}\n          </span>\n        </div>\n      </div>\n      <span aria-live='polite' className='sr-only'>\n        {isReadingByKeys && spokenReading}\n      </span>\n    </div>\n  );\n}\n\ntype ServiceRowProps = {\n  service: Service;\n  isSelected: boolean;\n  isDegraded: boolean;\n  isPressed: boolean;\n  todayEvent: DayEvent | null;\n  demoDay: number | null;\n  onSelect: (id: ServiceId) => void;\n};\n\nfunction ServiceRow({\n  service,\n  isSelected,\n  isDegraded,\n  isPressed,\n  todayEvent,\n  demoDay,\n  onSelect,\n}: ServiceRowProps) {\n  const lostToday = todayEvent?.minutes ?? 0;\n  const uptime = uptimeOf(service.id, lostToday);\n  const uptimeText = UPTIME_FORMAT.format(uptime);\n\n  return (\n    <li\n      className={cn(\n        'flex flex-col gap-2 rounded-lg px-2 pt-1 pb-2.5 transition-colors duration-200',\n        isSelected && 'bg-foreground/[0.03]'\n      )}\n    >\n      <button\n        type='button'\n        aria-pressed={isSelected}\n        onClick={() => onSelect(service.id)}\n        className={cn(\n          'focus-visible:ring-ring/25 -mx-1 flex min-h-11 cursor-pointer items-center gap-3 rounded-md px-1 text-start transition-[background-color,scale] duration-150 outline-none focus-visible:ring-[3px]',\n          rowToneOf(isSelected),\n          pressedQuietOf(isPressed)\n        )}\n      >\n        <span\n          aria-hidden='true'\n          className={cn(\n            'size-2 shrink-0 rounded-full transition-colors duration-300',\n            dotToneOf(isDegraded)\n          )}\n        />\n        <span className='flex min-w-0 flex-1 flex-col leading-tight'>\n          <span className='truncate text-[13px] font-medium'>\n            {service.name}\n          </span>\n          <span\n            className={cn(\n              'text-xs transition-colors duration-300',\n              stateToneOf(isDegraded)\n            )}\n          >\n            <WordRoll text={stateWordOf(isDegraded)} labels={STATE_WORDS} />\n          </span>\n        </span>\n        <span className='flex shrink-0 flex-col items-end leading-tight'>\n          <span className='text-[13px] font-medium tabular-nums'>\n            {uptimeText}%\n          </span>\n          <span className='text-muted-foreground text-xs'>\n            uptime over {DAY_COUNT} days\n          </span>\n        </span>\n      </button>\n      <UptimeBar service={service} todayEvent={todayEvent} demoDay={demoDay} />\n      <div\n        aria-hidden='true'\n        className='text-muted-foreground flex justify-between text-[11px]'\n      >\n        <span className='@md:hidden'>{PHONE_DAYS} days ago</span>\n        <span className='hidden @md:inline'>{DAY_COUNT} days ago</span>\n        <span>Today</span>\n      </div>\n    </li>\n  );\n}\n\ntype ServiceListProps = {\n  selected: ServiceId;\n  hasFaultToday: boolean;\n  isFaultOpen: boolean;\n  demoReading: { serviceId: ServiceId; day: number } | null;\n  pressed: string | null;\n  onSelect: (id: ServiceId) => void;\n};\n\nconst FAULT_TODAY: DayEvent = { status: 'degraded', minutes: FAULT_MINUTES };\n\nfunction todayEventOf(serviceId: ServiceId, hasFaultToday: boolean) {\n  const isHit = serviceId === 'models' && hasFaultToday;\n  if (isHit) {\n    return FAULT_TODAY;\n  }\n  return null;\n}\n\nfunction demoDayOf(\n  serviceId: ServiceId,\n  reading: { serviceId: ServiceId; day: number } | null\n) {\n  if (reading?.serviceId === serviceId) {\n    return reading.day;\n  }\n  return null;\n}\n\nexport function ServiceList({\n  selected,\n  hasFaultToday,\n  isFaultOpen,\n  demoReading,\n  pressed,\n  onSelect,\n}: ServiceListProps) {\n  return (\n    <section\n      aria-label='Services'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] @container rounded-xl p-1 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <ul className='flex flex-col gap-0.5'>\n        {SERVICES.map((service) => {\n          const isModels = service.id === 'models';\n          return (\n            <ServiceRow\n              key={service.id}\n              service={service}\n              isSelected={selected === service.id}\n              isDegraded={isModels && isFaultOpen}\n              isPressed={pressed === `service-${service.id}`}\n              todayEvent={todayEventOf(service.id, hasFaultToday)}\n              demoDay={demoDayOf(service.id, demoReading)}\n              onSelect={onSelect}\n            />\n          );\n        })}\n      </ul>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-03/services.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-03/latency-chart.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { seriesColorOf, type SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\n\nimport type { Service } from './data';\n\nconst VIEW_WIDTH = 1000;\n\nconst PLOT_HEIGHT = 168;\n\nconst MOVE: Transition = { duration: 0.45, ease: [0.77, 0, 0.175, 1] };\n\nconst INSTANT: Transition = { duration: 0 };\n\nconst P50_SERIES: SeriesSlot = 1;\n\nconst P95_SERIES: SeriesSlot = 2;\n\nconst TICK_SHARES = [1, 0.5, 0];\n\nfunction moveOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return MOVE;\n}\n\nfunction yOf(valueMs: number, topMs: number) {\n  const share = valueMs / topMs;\n  const bounded = Math.min(1, Math.max(0, share));\n  return PLOT_HEIGHT - bounded * PLOT_HEIGHT;\n}\n\nfunction commandOf(\n  valueMs: number,\n  hour: number,\n  count: number,\n  topMs: number\n) {\n  const lastHour = count - 1;\n  const x = (hour / lastHour) * VIEW_WIDTH;\n  const y = yOf(valueMs, topMs);\n  const point = `${x.toFixed(1)} ${y.toFixed(1)}`;\n  if (hour === 0) {\n    return `M${point}`;\n  }\n  return `L${point}`;\n}\n\nfunction pathOf(values: number[], topMs: number) {\n  const commands = values.map((valueMs, hour) =>\n    commandOf(valueMs, hour, values.length, topMs)\n  );\n  return commands.join(' ');\n}\n\n/** 80 ms, 900 ms, 2.4 s. */\nfunction formatMs(valueMs: number) {\n  if (valueMs < 1000) {\n    return `${valueMs} ms`;\n  }\n  const seconds = valueMs / 1000;\n  return `${seconds.toFixed(1)} s`;\n}\n\nfunction hourLabelOf(hour: number, count: number) {\n  const hoursAgo = count - 1 - hour;\n  if (hoursAgo === 0) {\n    return 'Now';\n  }\n  return `${hoursAgo} h ago`;\n}\n\nfunction p95ToneOf(isOverTarget: boolean) {\n  if (isOverTarget) {\n    return 'text-warning-foreground';\n  }\n  return 'text-foreground';\n}\n\ntype FigureProps = {\n  label: string;\n  series?: SeriesSlot;\n  valueMs: number;\n  className?: string;\n};\n\nfunction Figure({ label, series, valueMs, className }: FigureProps) {\n  return (\n    <div className='flex min-w-0 flex-col gap-0.5'>\n      <dt className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n        {series !== undefined && (\n          <span\n            aria-hidden='true'\n            style={{ backgroundColor: seriesColorOf(series) }}\n            className='size-2 shrink-0 rounded-full'\n          />\n        )}\n        {label}\n      </dt>\n      <dd\n        className={cn(\n          'text-lg leading-7 font-semibold transition-colors duration-300 @md:text-xl',\n          className\n        )}\n      >\n        <MotionNumber value={valueMs} suffix=' ms' />\n      </dd>\n    </div>\n  );\n}\n\ntype LatencyChartProps = {\n  service: Service;\n};\n\nexport function LatencyChart({ service }: LatencyChartProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const move = moveOf(shouldReduceMotion);\n  const hourCount = service.p50.length;\n  const lastHour = hourCount - 1;\n  const p50Now = service.p50[lastHour];\n  const p95Now = service.p95[lastHour];\n  const p50Path = pathOf(service.p50, service.topMs);\n  const p95Path = pathOf(service.p95, service.topMs);\n  const targetY = yOf(service.targetMs, service.topMs);\n  const targetStyle = { transform: `translateY(${targetY}px)` };\n  const plotStyle = { height: PLOT_HEIGHT };\n  const isOverTarget = p95Now > service.targetMs;\n  const title = `${service.name}: response time over 24 hours`;\n\n  return (\n    <section\n      aria-label='Response time'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col gap-4 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <header className='flex items-start justify-between gap-3'>\n        <div className='flex min-w-0 flex-col gap-0.5'>\n          <h2 className='text-sm font-medium'>\n            <Swap swapKey={service.id}>{service.name}</Swap>\n          </h2>\n          <p className='text-muted-foreground text-xs'>\n            <Swap swapKey={service.id}>{service.measure}, last 24 hours</Swap>\n          </p>\n        </div>\n        <Badge variant='secondary'>Illustrative</Badge>\n      </header>\n\n      <dl className='grid grid-cols-3 gap-3'>\n        <Figure label='p50 now' series={P50_SERIES} valueMs={p50Now} />\n        <Figure\n          label='p95 now'\n          series={P95_SERIES}\n          valueMs={p95Now}\n          className={p95ToneOf(isOverTarget)}\n        />\n        <Figure label='Target' valueMs={service.targetMs} />\n      </dl>\n\n      <div className='grid grid-cols-[2.75rem_minmax(0,1fr)]'>\n        <div aria-hidden='true' className='relative' style={plotStyle}>\n          {TICK_SHARES.map((share) => {\n            const tickMs = service.topMs * share;\n            const top = yOf(tickMs, service.topMs);\n            const label = formatMs(tickMs);\n            return (\n              <span\n                key={share}\n                className='text-muted-foreground absolute right-2.5 -translate-y-1/2 text-[11px] tabular-nums'\n                style={{ top }}\n              >\n                <Swap swapKey={label}>{label}</Swap>\n              </span>\n            );\n          })}\n        </div>\n        <div aria-hidden='true' className='relative' style={plotStyle}>\n          <svg\n            viewBox={`0 0 ${VIEW_WIDTH} ${PLOT_HEIGHT}`}\n            preserveAspectRatio='none'\n            className='absolute inset-0 size-full overflow-visible'\n          >\n            {TICK_SHARES.map((share) => {\n              const y = PLOT_HEIGHT - share * PLOT_HEIGHT;\n              return (\n                <line\n                  key={share}\n                  x1={0}\n                  x2={VIEW_WIDTH}\n                  y1={y}\n                  y2={y}\n                  strokeWidth={1}\n                  vectorEffect='non-scaling-stroke'\n                  className='stroke-border'\n                />\n              );\n            })}\n            <motion.path\n              initial={false}\n              animate={{ d: p95Path }}\n              transition={move}\n              fill='none'\n              strokeWidth={2}\n              strokeLinecap='round'\n              strokeLinejoin='round'\n              vectorEffect='non-scaling-stroke'\n              style={{ stroke: seriesColorOf(P95_SERIES) }}\n            />\n            <motion.path\n              initial={false}\n              animate={{ d: p50Path }}\n              transition={move}\n              fill='none'\n              strokeWidth={2}\n              strokeLinecap='round'\n              strokeLinejoin='round'\n              vectorEffect='non-scaling-stroke'\n              style={{ stroke: seriesColorOf(P50_SERIES) }}\n            />\n          </svg>\n          <div\n            style={targetStyle}\n            className='pointer-events-none absolute inset-x-0 top-0 transition-transform duration-[450ms] ease-(--ease-in-out-strong)'\n          >\n            <span className='bg-foreground/35 absolute inset-x-0 top-0 h-(--hairline)' />\n            <span className='text-muted-foreground absolute end-0 -top-4 text-[11px] leading-4'>\n              Target\n            </span>\n          </div>\n        </div>\n        <span aria-hidden='true' />\n        <div\n          aria-hidden='true'\n          className='text-muted-foreground mt-2 flex justify-between text-[11px]'\n        >\n          <span>24 h ago</span>\n          <span>12 h ago</span>\n          <span>Now</span>\n        </div>\n      </div>\n\n      <div className='sr-only'>\n        <table>\n          <caption>{title}</caption>\n          <thead>\n            <tr>\n              <th scope='col'>Hour</th>\n              <th scope='col'>p50</th>\n              <th scope='col'>p95</th>\n            </tr>\n          </thead>\n          <tbody>\n            {service.p50.map((p50Ms, hour) => (\n              <tr key={hour}>\n                <th scope='row'>{hourLabelOf(hour, hourCount)}</th>\n                <td>{formatMs(p50Ms)}</td>\n                <td>{formatMs(service.p95[hour])}</td>\n              </tr>\n            ))}\n          </tbody>\n        </table>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-03/latency-chart.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-03/incidents.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { Chip } from '@/registry/ndeko/ui/chip';\n\nimport {\n  LIVE_INCIDENT,\n  PAST_INCIDENTS,\n  serviceOf,\n  type Incident,\n  type IncidentUpdate,\n  type UpdateKind,\n} from './data';\n\nconst KIND_WORD: Record<UpdateKind, string> = {\n  investigating: 'Investigating',\n  identified: 'Identified',\n  monitoring: 'Monitoring',\n  resolved: 'Resolved',\n};\n\nconst KIND_COLOR: Record<UpdateKind, string> = {\n  investigating: 'var(--warning)',\n  identified: 'var(--warning)',\n  monitoring: 'var(--info)',\n  resolved: 'var(--success)',\n};\n\ntype UpdateRowProps = {\n  update: IncidentUpdate;\n  isLast: boolean;\n};\n\nfunction UpdateRow({ update, isLast }: UpdateRowProps) {\n  return (\n    <div className='relative flex gap-3 pb-3'>\n      {!isLast && (\n        <span\n          aria-hidden='true'\n          className='bg-border absolute top-4 bottom-0 left-1 w-px -translate-x-1/2'\n        />\n      )}\n      <span\n        aria-hidden='true'\n        className='bg-foreground/25 mt-1.5 size-2 shrink-0 rounded-full'\n      />\n      <div className='flex min-w-0 flex-1 flex-col gap-1'>\n        <p className='flex flex-wrap items-center gap-x-2 gap-y-1'>\n          <Chip color={KIND_COLOR[update.kind]}>{KIND_WORD[update.kind]}</Chip>\n          <span className='text-muted-foreground text-xs tabular-nums'>\n            {update.time} UTC\n          </span>\n        </p>\n        <p className='text-[13px] leading-relaxed'>{update.text}</p>\n      </div>\n    </div>\n  );\n}\n\ntype IncidentCardProps = {\n  incident: Incident;\n  /** How many of its updates are out. The newest sits on top. */\n  updatesOut: number;\n};\n\nfunction IncidentCard({ incident, updatesOut }: IncidentCardProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const service = serviceOf(incident.serviceId);\n  const shown = incident.updates.slice(0, updatesOut);\n  const newestFirst = [...shown].reverse();\n  const oldest = shown[0];\n\n  return (\n    <div className='flex flex-col gap-3 pb-5'>\n      <div className='flex flex-col gap-0.5'>\n        <h3 className='text-[13px] font-medium text-pretty'>\n          {incident.title}\n        </h3>\n        <p className='text-muted-foreground text-xs'>\n          {service.name} · {incident.date}\n        </p>\n      </div>\n      <ol className='flex flex-col'>\n        <AnimatePresence initial={false}>\n          {newestFirst.map((update) => (\n            <motion.li\n              key={update.kind}\n              className='overflow-hidden'\n              {...rowPresence}\n            >\n              <UpdateRow update={update} isLast={update === oldest} />\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ol>\n    </div>\n  );\n}\n\ntype IncidentsProps = {\n  /** How many updates of the live incident are out; none hides it. */\n  liveUpdatesOut: number;\n};\n\nexport function Incidents({ liveUpdatesOut }: IncidentsProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const hasLive = liveUpdatesOut > 0;\n\n  return (\n    <section aria-label='Incidents' className='flex flex-col gap-3'>\n      <h2 className='text-sm font-medium'>Incidents</h2>\n      <ul className='flex flex-col'>\n        <AnimatePresence initial={false}>\n          {hasLive && (\n            <motion.li\n              key={LIVE_INCIDENT.id}\n              className='overflow-hidden'\n              {...rowPresence}\n            >\n              <IncidentCard\n                incident={LIVE_INCIDENT}\n                updatesOut={liveUpdatesOut}\n              />\n            </motion.li>\n          )}\n        </AnimatePresence>\n        {PAST_INCIDENTS.map((incident) => (\n          <li key={incident.id}>\n            <IncidentCard\n              incident={incident}\n              updatesOut={incident.updates.length}\n            />\n          </li>\n        ))}\n      </ul>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-03/incidents.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-03/subscribe.tsx",
      "content": "'use client';\n\nimport { useAnimate } from 'motion/react';\nimport { useId } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport { BellIcon, CheckIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Fold } from '@/registry/ndeko/ui/chat-motion';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\n\nimport { isEmail, type Subscription } from './session';\n\nconst MORPH: Record<Subscription, MorphState> = {\n  idle: 'idle',\n  invalid: 'idle',\n  busy: 'busy',\n  done: 'done',\n};\n\nconst LABELS: Record<MorphState, string> = {\n  idle: 'Subscribe',\n  busy: 'Subscribing',\n  done: 'Subscribed',\n};\n\nconst NUDGE = { x: [0, -4, 4, 0] };\n\nconst NUDGE_TIMING = { duration: 0.28 };\n\nfunction describedByOf(isInvalid: boolean, errorId: string) {\n  if (isInvalid) {\n    return errorId;\n  }\n  return undefined;\n}\n\ntype SubscribeProps = {\n  email: string;\n  subscription: Subscription;\n  isPressed: boolean;\n  onEmailChange: (text: string) => void;\n  onSubscribe: () => void;\n  onUnsubscribe: () => void;\n};\n\nexport function Subscribe({\n  email,\n  subscription,\n  isPressed,\n  onEmailChange,\n  onSubscribe,\n  onUnsubscribe,\n}: SubscribeProps) {\n  const fieldId = useId();\n  const errorId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const [fieldRef, animate] = useAnimate<HTMLDivElement>();\n  const isInvalid = subscription === 'invalid';\n  const isDone = subscription === 'done';\n  const isLocked = subscription === 'busy' || isDone;\n\n  /** A refused address nudges the field 4px once; reduced motion keeps the message only. */\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    const isRefused = !isEmail(email);\n    if (isRefused && !shouldReduceMotion) {\n      animate(fieldRef.current, NUDGE, NUDGE_TIMING);\n    }\n    onSubscribe();\n  }\n\n  return (\n    <section\n      aria-label='Subscribe to updates'\n      className='bg-foreground/[0.03] dark:bg-foreground/[0.05] flex flex-col gap-3 rounded-xl p-4'\n    >\n      <div className='flex items-start gap-3'>\n        <span\n          aria-hidden='true'\n          className='keycap-3d text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded-md'\n        >\n          <BellIcon className='size-3.5' />\n        </span>\n        <div className='flex min-w-0 flex-col gap-0.5'>\n          <h2 className='text-sm font-medium'>Subscribe to updates</h2>\n          <p className='text-muted-foreground text-xs'>\n            One email when an incident opens and one when it is resolved\n          </p>\n        </div>\n      </div>\n      <form\n        noValidate\n        onSubmit={submit}\n        className='flex flex-col gap-2 @sm:flex-row @sm:items-start'\n      >\n        <div ref={fieldRef} className='flex min-w-0 flex-1 flex-col'>\n          <label htmlFor={fieldId} className='sr-only'>\n            Email for updates\n          </label>\n          <Input\n            id={fieldId}\n            type='email'\n            inputMode='email'\n            autoComplete='email'\n            placeholder='you@company.com'\n            value={email}\n            disabled={isLocked}\n            aria-invalid={isInvalid}\n            aria-describedby={describedByOf(isInvalid, errorId)}\n            onChange={(event) => onEmailChange(event.target.value)}\n          />\n        </div>\n        <MorphButton\n          type='submit'\n          state={MORPH[subscription]}\n          labels={LABELS}\n          className={pressedSolidOf(isPressed)}\n        />\n      </form>\n      <div aria-live='polite'>\n        <Fold open={isInvalid}>\n          <p id={errorId} className='text-destructive-ink text-xs'>\n            Enter an address like name@company.com\n          </p>\n        </Fold>\n        <Fold open={isDone}>\n          <div className='flex flex-wrap items-center gap-x-3 gap-y-1'>\n            <p className='flex min-w-0 items-center gap-1.5 text-xs'>\n              <CheckIcon className='text-success-foreground size-3.5 shrink-0' />\n              <span className='truncate'>Updates go to {email}</span>\n            </p>\n            <Button\n              type='button'\n              variant='ghost'\n              size='sm'\n              onClick={onUnsubscribe}\n              className='text-muted-foreground -my-1'\n            >\n              Unsubscribe\n            </Button>\n          </div>\n        </Fold>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-03/subscribe.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-03/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\n\nimport {\n  DEMO_EMAIL,\n  DEMO_READING,\n  LIVE_INCIDENT,\n  type ServiceId,\n} from './data';\n\nexport type Subscription = 'idle' | 'invalid' | 'busy' | 'done';\n\nexport type Reading = {\n  serviceId: ServiceId;\n  day: number;\n};\n\nexport type StatusState = {\n  selected: ServiceId;\n  /** How many updates of the live incident are out: 0 before it starts, 4 once it is resolved. */\n  updatesOut: number;\n  /** The day the demonstration reads on an uptime bar. */\n  reading: Reading | null;\n  email: string;\n  subscription: Subscription;\n};\n\nexport type StatusAction =\n  | { type: 'selected'; id: ServiceId }\n  | { type: 'updated'; updatesOut: number }\n  | { type: 'read'; reading: Reading | null }\n  | { type: 'typed'; text: string }\n  | { type: 'subscribe' }\n  | { type: 'subscribed' }\n  | { type: 'unsubscribed' };\n\ntype Step = SessionStep<StatusState, StatusAction>;\n\nexport const INITIAL: StatusState = {\n  selected: 'models',\n  updatesOut: 0,\n  reading: null,\n  email: '',\n  subscription: 'idle',\n};\n\nconst RESOLVED_AT = LIVE_INCIDENT.updates.length;\n\n/** The fault lasts from the first update until traffic moves to the second model. */\nconst TRAFFIC_MOVED_AT = 3;\n\nexport function isFaultOpen(state: StatusState) {\n  const hasStarted = state.updatesOut > 0;\n  const isResolved = state.updatesOut >= RESOLVED_AT;\n  return hasStarted && !isResolved;\n}\n\nexport function isSlowNow(state: StatusState) {\n  const hasStarted = state.updatesOut > 0;\n  const hasMoved = state.updatesOut >= TRAFFIC_MOVED_AT;\n  return hasStarted && !hasMoved;\n}\n\nexport function hasIncidentToday(state: StatusState) {\n  return state.updatesOut > 0;\n}\n\nconst EMAIL_SHAPE = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nexport function isEmail(text: string) {\n  const trimmed = text.trim();\n  return EMAIL_SHAPE.test(trimmed);\n}\n\n/** An update only follows the one before it, so the incident never skips a stage. */\nfunction updated(state: StatusState, updatesOut: number): StatusState {\n  const isNext = updatesOut === state.updatesOut + 1;\n  if (!isNext) {\n    return state;\n  }\n  return { ...state, updatesOut };\n}\n\nfunction typed(state: StatusState, text: string): StatusState {\n  const isLocked =\n    state.subscription === 'busy' || state.subscription === 'done';\n  if (isLocked) {\n    return state;\n  }\n  return { ...state, email: text, subscription: 'idle' };\n}\n\nfunction subscribe(state: StatusState): StatusState {\n  const isLocked =\n    state.subscription === 'busy' || state.subscription === 'done';\n  if (isLocked) {\n    return state;\n  }\n  if (!isEmail(state.email)) {\n    return { ...state, subscription: 'invalid' };\n  }\n  return { ...state, email: state.email.trim(), subscription: 'busy' };\n}\n\nfunction subscribed(state: StatusState): StatusState {\n  if (state.subscription !== 'busy') {\n    return state;\n  }\n  return { ...state, subscription: 'done' };\n}\n\nexport function reducer(state: StatusState, action: StatusAction): StatusState {\n  switch (action.type) {\n    case 'selected':\n      return { ...state, selected: action.id };\n    case 'updated':\n      return updated(state, action.updatesOut);\n    case 'read':\n      return { ...state, reading: action.reading };\n    case 'typed':\n      return typed(state, action.text);\n    case 'subscribe':\n      return subscribe(state);\n    case 'subscribed':\n      return subscribed(state);\n    case 'unsubscribed':\n      return { ...state, email: '', subscription: 'idle' };\n  }\n}\n\nconst CHUNK = 3;\n\nfunction delayOfChunk(index: number) {\n  if (index === 0) {\n    return 1300;\n  }\n  return 70;\n}\n\nfunction typingSteps(): Step[] {\n  const steps: Step[] = [];\n  const last = DEMO_EMAIL.length + CHUNK;\n  for (let end = CHUNK; end < last; end += CHUNK) {\n    const text = DEMO_EMAIL.slice(0, end);\n    const after = delayOfChunk(steps.length);\n    steps.push({ after, by: 'demo', action: { type: 'typed', text } });\n  }\n  return steps;\n}\n\nexport const CONFIRM_MS = 1000;\n\nexport const SCRIPT: Step[] = [\n  { after: 1500, action: { type: 'updated', updatesOut: 1 } },\n  { after: 1900, action: { type: 'updated', updatesOut: 2 } },\n  {\n    after: 1500,\n    by: 'demo',\n    press: 'service-vectors',\n    action: { type: 'selected', id: 'vectors' },\n  },\n  { after: 1300, by: 'demo', action: { type: 'read', reading: DEMO_READING } },\n  { after: 2000, by: 'demo', action: { type: 'read', reading: null } },\n  { after: 500, action: { type: 'updated', updatesOut: 3 } },\n  {\n    after: 1500,\n    by: 'demo',\n    press: 'service-models',\n    action: { type: 'selected', id: 'models' },\n  },\n  { after: 1900, action: { type: 'updated', updatesOut: 4 } },\n  ...typingSteps(),\n  { after: 500, by: 'demo', press: 'subscribe', action: { type: 'subscribe' } },\n  { after: CONFIRM_MS, action: { type: 'subscribed' } },\n];\n\n/** Under reduced motion the incident is resolved, with its four updates to read. */\nexport const RESTING: StatusState = { ...INITIAL, updatesOut: RESOLVED_AT };\n\nexport const LOOP_AFTER_MS = 3600;\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-03/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-03/data.ts",
      "content": "export const PRODUCT_NAME = 'Marlow';\n\nexport type ServiceId = 'models' | 'tools' | 'vectors' | 'runs';\n\nexport type Service = {\n  id: ServiceId;\n  name: string;\n  detail: string;\n  /** What the response time is measured on. */\n  measure: string;\n  targetMs: number;\n  /** The top of the chart for this service. */\n  topMs: number;\n  p50: number[];\n  p95: number[];\n};\n\nconst HOURS = 24;\n\n/** The shape of a working day: quiet at night, busy from mid-morning. */\nconst DAY_WAVE = [\n  0.82, 0.8, 0.79, 0.8, 0.84, 0.9, 0.98, 1.06, 1.12, 1.15, 1.13, 1.1, 1.12,\n  1.16, 1.14, 1.09, 1.04, 1, 0.97, 0.95, 0.92, 0.89, 0.86, 0.84,\n];\n\nconst JITTER = [\n  0, 0.03, -0.02, 0.01, -0.03, 0.02, 0.04, -0.01, 0.02, -0.02, 0.03, 0, -0.03,\n  0.02, 0.01, -0.01, 0.03, -0.02, 0, 0.02, -0.03, 0.01, 0.02, -0.01,\n];\n\nfunction seriesOf(baseMs: number, shift: number, swing: number) {\n  return DAY_WAVE.map((_, hour) => {\n    const wave = DAY_WAVE[(hour + shift) % HOURS];\n    const jitter = JITTER[(hour + shift * 3) % HOURS];\n    const lift = (wave - 1) * swing;\n    const factor = 1 + lift + jitter;\n    return Math.round(baseMs * factor);\n  });\n}\n\n/** Response times over the last 24 hours, one value per hour. Illustrative. */\nexport const SERVICES: Service[] = [\n  {\n    id: 'models',\n    name: 'Model endpoints',\n    detail: 'Lumen and Lumen Swift',\n    measure: 'Time to first token',\n    targetMs: 900,\n    topMs: 2400,\n    p50: seriesOf(520, 0, 1),\n    p95: seriesOf(760, 2, 1.1),\n  },\n  {\n    id: 'tools',\n    name: 'Tool gateway',\n    detail: 'Calls from agents to connected tools',\n    measure: 'Time per tool call',\n    targetMs: 250,\n    topMs: 400,\n    p50: seriesOf(110, 5, 1.6),\n    p95: seriesOf(186, 7, 1.8),\n  },\n  {\n    id: 'vectors',\n    name: 'Vector store',\n    detail: 'Search over indexed knowledge',\n    measure: 'Time per search',\n    targetMs: 80,\n    topMs: 120,\n    p50: seriesOf(38, 11, 0.7),\n    p95: seriesOf(61, 9, 0.9),\n  },\n  {\n    id: 'runs',\n    name: 'Agent runs',\n    detail: 'Queue and start of every run',\n    measure: 'Time to first step',\n    targetMs: 3000,\n    topMs: 5000,\n    p50: seriesOf(1400, 16, 1.3),\n    p95: seriesOf(2500, 14, 1.2),\n  },\n];\n\n/** How many of the last hours the capacity fault slowed, and by how much. */\nconst FAULT_HOURS = 3;\n\nconst FAULT_P50 = 1.5;\n\nconst FAULT_P95 = 2.5;\n\nfunction slowedTail(values: number[], factor: number) {\n  const firstSlowHour = values.length - FAULT_HOURS;\n  return values.map((value, hour) => {\n    if (hour < firstSlowHour) {\n      return value;\n    }\n    return Math.round(value * factor);\n  });\n}\n\nconst MODELS = SERVICES[0];\n\n/** The model endpoints while the fault lasts: the end of both lines lifts. */\nexport const MODELS_DURING_FAULT: Service = {\n  ...MODELS,\n  p50: slowedTail(MODELS.p50, FAULT_P50),\n  p95: slowedTail(MODELS.p95, FAULT_P95),\n};\n\nexport function serviceOf(id: ServiceId) {\n  const service = SERVICES.find((candidate) => candidate.id === id);\n  return service ?? MODELS;\n}\n\nexport const DAY_COUNT = 90;\n\nexport const TODAY = DAY_COUNT - 1;\n\nexport type DayStatus = 'ok' | 'degraded' | 'outage';\n\nexport type DayEvent = {\n  status: DayStatus;\n  minutes: number;\n};\n\nconst NO_EVENT: DayEvent = { status: 'ok', minutes: 0 };\n\n/** The days with an incident, by their place in the last 90 days. Illustrative. */\nconst EVENTS: Record<ServiceId, Record<number, DayEvent>> = {\n  models: {\n    23: { status: 'degraded', minutes: 18 },\n    61: { status: 'degraded', minutes: 41 },\n  },\n  tools: {\n    55: { status: 'outage', minutes: 12 },\n  },\n  vectors: {\n    12: { status: 'degraded', minutes: 9 },\n    74: { status: 'degraded', minutes: 33 },\n  },\n  runs: {\n    40: { status: 'outage', minutes: 6 },\n    55: { status: 'degraded', minutes: 12 },\n  },\n};\n\n/** How long the fault of the demo slows the model endpoints today. */\nexport const FAULT_MINUTES = 31;\n\nexport function dayEventOf(serviceId: ServiceId, day: number) {\n  return EVENTS[serviceId][day] ?? NO_EVENT;\n}\n\nconst MINUTES_PER_DAY = 1440;\n\nexport function uptimeOf(serviceId: ServiceId, extraMinutes: number) {\n  const events = Object.values(EVENTS[serviceId]);\n  let lostMinutes = extraMinutes;\n  for (const event of events) {\n    lostMinutes += event.minutes;\n  }\n  const totalMinutes = DAY_COUNT * MINUTES_PER_DAY;\n  const share = 1 - lostMinutes / totalMinutes;\n  return share * 100;\n}\n\nconst DAY_MS = 86_400_000;\n\n/** A fixed day, so the page reads the same on the server and in the browser. */\nconst TODAY_UTC = Date.UTC(2026, 10, 12);\n\nconst DATE_FORMAT = new Intl.DateTimeFormat('en-GB', {\n  day: 'numeric',\n  month: 'short',\n  timeZone: 'UTC',\n});\n\nexport function dateLabelOf(day: number) {\n  const daysAgo = TODAY - day;\n  const time = TODAY_UTC - daysAgo * DAY_MS;\n  return DATE_FORMAT.format(time);\n}\n\nexport type UpdateKind =\n  'investigating' | 'identified' | 'monitoring' | 'resolved';\n\nexport type IncidentUpdate = {\n  kind: UpdateKind;\n  time: string;\n  text: string;\n};\n\nexport type Incident = {\n  id: string;\n  title: string;\n  serviceId: ServiceId;\n  date: string;\n  updates: IncidentUpdate[];\n};\n\n/** The incident that unfolds in the demo, oldest update first. */\nexport const LIVE_INCIDENT: Incident = {\n  id: 'lumen-slow',\n  title: 'Slow replies from Lumen',\n  serviceId: 'models',\n  date: dateLabelOf(TODAY),\n  updates: [\n    {\n      kind: 'investigating',\n      time: '14:21',\n      text: 'Replies from Lumen take longer than usual. We are looking at the endpoint.',\n    },\n    {\n      kind: 'identified',\n      time: '14:29',\n      text: 'A capacity fault at the Lumen endpoint slows about a third of the requests.',\n    },\n    {\n      kind: 'monitoring',\n      time: '14:36',\n      text: 'New conversations now go to Lumen Swift. Replies are back under the target.',\n    },\n    {\n      kind: 'resolved',\n      time: '14:52',\n      text: 'Traffic moved to Lumen Swift while Lumen recovered. Lumen answers at its usual speed again.',\n    },\n  ],\n};\n\nexport const PAST_INCIDENTS: Incident[] = [\n  {\n    id: 'vector-slow',\n    title: 'Vector store answered slowly',\n    serviceId: 'vectors',\n    date: dateLabelOf(74),\n    updates: [\n      {\n        kind: 'identified',\n        time: '09:12',\n        text: 'A reindex of a large workspace took the search nodes over their memory limit.',\n      },\n      {\n        kind: 'resolved',\n        time: '09:45',\n        text: 'The reindex now runs in smaller batches. Searches were slow for 33 minutes.',\n      },\n    ],\n  },\n  {\n    id: 'gateway-refused',\n    title: 'Tool gateway refused new connections',\n    serviceId: 'tools',\n    date: dateLabelOf(55),\n    updates: [\n      {\n        kind: 'investigating',\n        time: '17:03',\n        text: 'Agents cannot reach their tools. Runs wait instead of failing.',\n      },\n      {\n        kind: 'resolved',\n        time: '17:15',\n        text: 'An expired certificate was replaced. Waiting runs picked up where they stopped.',\n      },\n    ],\n  },\n];\n\nexport const DEMO_EMAIL = 'mara@calderfreight.example';\n\n/** The day the demonstration reads on an uptime bar. */\nexport const DEMO_READING: { serviceId: ServiceId; day: number } = {\n  serviceId: 'vectors',\n  day: 74,\n};\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "agent-ops"
  ],
  "type": "registry:block"
}