{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "time-grid",
  "title": "TimeGrid",
  "description": "A day, work week or week of hours, with events placed by their times: the calendar grid of a mail or meeting app.",
  "registryDependencies": [
    "@ouro/button",
    "@ouro/calendar",
    "@ouro/kbd",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-navigation-key",
    "@ouro/lib-router-link",
    "@ouro/lib-tones",
    "@ouro/lib-touch-target",
    "@ouro/lib-use-dev-messages",
    "@ouro/local-date",
    "@ouro/menu",
    "@ouro/scroll-area",
    "@ouro/tooltip"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/time-grid/time-grid-parts.tsx",
      "content": "\"use client\";\n\nimport type { JSX } from \"react\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { Kbd } from \"@/registry/ouro/components/ouro/kbd/kbd\";\nimport { Tooltip } from \"@/registry/ouro/components/ouro/tooltip/tooltip\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { addDays } from \"@/registry/ouro/components/ouro/calendar/calendar-styles\";\nimport { todayOn, type TimeGridView, zonedClock } from \"@/registry/ouro/components/ouro/time-grid/time-grid-styles\";\n\n/** Props for {@link TimeGridNav}. */\nexport interface TimeGridNavProps {\n  /** The ISO date the grid shows, as given to its `date`. */\n  date: string;\n  /** The grid's view, which sets how far Previous and Next move: a day, or a week. @default \"week\" */\n  view?: TimeGridView | undefined;\n  /** Called with the ISO date to show. Set the grid's `date` to it. */\n  onDateChange: (date: string) => void;\n  /** The grid's time zone, whose today Today goes to. @default the reader's own */\n  timeZone?: string | undefined;\n  /** The buttons' words, for other languages. @default { today: \"Today\", previous: \"Previous week\", next: \"Next week\" }, or \"day\" for a day's view */\n  labels?: { today?: string | undefined; previous?: string | undefined; next?: string | undefined } | undefined;\n  /** Layout only: margins and placement. Appearance classes warn in development. */\n  className?: string | undefined;\n}\n\nconst chevron = (d: string) => (\n  <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-4 rtl:-scale-x-100\">\n    <path d={d} />\n  </svg>\n);\n\n/**\n * Today, Previous and Next for a `TimeGrid`: three buttons that move its `date` by its view's\n * day or week, each with its keyboard shortcut in its tooltip. The grid takes the same keys\n * while focus is in it, with `onDateChange`: Page Up and ⌥↑ (Alt+↑) the period before, Page\n * Down and ⌥↓ the next, ⌥⇧Y (Alt+Shift+Y) today.\n *\n * Use your own buttons instead when the toolbar picks a month or a date as well; give the grid\n * `onDateChange` for its keys either way.\n *\n * @group Data\n * @see https://ui.ouroboros.bot/docs/time-grid\n *\n * @example\n * <TimeGridNav date={date} view={view} onDateChange={setDate} />\n * <TimeGrid label=\"Team calendar\" date={date} view={view} onDateChange={setDate} events={events} />\n * @claim \"three buttons that move its `date`\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGridNav > moves the date by the view's day or week and to today, with each key in its button's tooltip)\n * @claim \"The grid takes the same keys\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > moves to the next or previous period with Page Down and Page Up, or Alt with the arrows, and to today with Alt+Shift+Y)\n */\nexport function TimeGridNav(props: TimeGridNavProps): JSX.Element {\n  const { date, view, onDateChange, timeZone, labels, className } = props;\n  useAppearanceClassNameCheck(\n    \"TimeGridNav\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; TimeGridNav draws Ouro's own buttons`\n      : // Stryker disable next-line StringLiteral: production only; the check never runs there.\n        /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  const unit = view === \"day\" ? \"day\" : \"week\";\n  const step = view === \"day\" ? 1 : 7;\n  const today = labels?.today ?? \"Today\";\n  const previous = labels?.previous ?? `Previous ${unit}`;\n  const next = labels?.next ?? `Next ${unit}`;\n  const tip = (words: string, keys: string[]) => (\n    <span className=\"inline-flex items-center gap-2\">\n      {words}\n      <Kbd keys={keys} />\n    </span>\n  );\n  return (\n    <div data-ouro=\"time-grid-nav\" className={cn(\"inline-flex items-center gap-1\", className)}>\n      <Tooltip content={tip(today, [\"alt\", \"shift\", \"y\"])}>\n        <Button variant=\"outline\" size=\"sm\" onClick={() => onDateChange(todayOn(zonedClock(timeZone)))}>\n          {today}\n        </Button>\n      </Tooltip>\n      <Tooltip content={tip(previous, [\"alt\", \"up\"])}>\n        <Button variant=\"plain\" tone=\"secondary\" size=\"sm\" aria-label={previous} onClick={() => onDateChange(addDays(date, -step))}>\n          {chevron(\"M10 3.5L5.5 8l4.5 4.5\")}\n        </Button>\n      </Tooltip>\n      <Tooltip content={tip(next, [\"alt\", \"down\"])}>\n        <Button variant=\"plain\" tone=\"secondary\" size=\"sm\" aria-label={next} onClick={() => onDateChange(addDays(date, step))}>\n          {chevron(\"M6 3.5L10.5 8 6 12.5\")}\n        </Button>\n      </Tooltip>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/time-grid/time-grid-parts.tsx"
    },
    {
      "path": "registry/ouro/components/ouro/time-grid/time-grid-styles.ts",
      "content": "import { addDays, firstDayOfWeek, isIsoDate } from \"@/registry/ouro/components/ouro/calendar/calendar-styles\";\n\nexport {\n  allDayClass,\n  allDayLanes,\n  backgroundBarClass,\n  backgroundBarFillClass,\n  backgroundFillClass,\n  barStatusClass,\n  dayLength,\n  eventClass,\n  eventHitClass,\n  isIsoDate,\n  layoutDay,\n  lineCount,\n  minuteClock,\n  minVisibleMinutes,\n  plainFillClass,\n  slotSizes,\n  statuses,\n  periodShift,\n  stackMinWidth,\n  todayOn,\n  stacksOf,\n  statusClass,\n  stepTo,\n  timedClass,\n  toInstant,\n  toneBarClass,\n  toneFillClass,\n  toneSwatchClass,\n  tones,\n  viewDays,\n  views,\n  weekendDays,\n  zonedClock,\n};\nexport type { DayPlacement, LaneSpan, TimeGridStatus, TimeGridTone, TimeGridView, ZonedClock };\n\n// Date math, layout and class strings for TimeGrid, apart from the component so its file exports\n// only components (React Fast Refresh). Days are ISO dates (`\"2026-03-12\"`); a time of day is\n// minutes from that day's midnight on the wall clock of the grid's time zone. Class strings are\n// literal so the app's Tailwind finds them.\n\n/** Which days the grid shows. */\ntype TimeGridView = \"day\" | \"work-week\" | \"week\";\nconst views: readonly TimeGridView[] = [\"day\", \"work-week\", \"week\"];\n\n/** An event's colour: the theme's token names. */\ntype TimeGridTone = \"primary\" | \"secondary\" | \"success\" | \"warning\" | \"destructive\";\nconst tones: readonly TimeGridTone[] = [\"primary\", \"secondary\", \"success\", \"warning\", \"destructive\"];\n\n/** What an event does to the person's time, which sets how it is drawn and read. */\ntype TimeGridStatus = \"busy\" | \"tentative\" | \"free\" | \"unanswered\" | \"cancelled\";\nconst statuses: readonly TimeGridStatus[] = [\"busy\", \"tentative\", \"free\", \"unanswered\", \"cancelled\"];\n\n/** The lengths an empty slot can be, in minutes. */\nconst slotSizes: readonly number[] = [15, 30, 60];\n\n/** Minutes in a day on the grid. */\nconst dayLength = 1440;\n\n/**\n * The shortest an event is drawn, in minutes: room for one line of text. A shorter event still\n * takes this much room, so its text never runs into the next event.\n * @claim \"so its text never runs\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > draws an event at least half an hour tall, never past midnight, and spreads it where its neighbours end)\n */\nconst minVisibleMinutes = 30;\n\n/** An instant as a Date, or null when it is not one. */\nfunction toInstant(value: Date | string | number): Date | null {\n  const date = new Date(value);\n  return Number.isNaN(date.getTime()) ? null : date;\n}\n\n/** Where instants fall on the grid's wall clock, in one time zone. */\ninterface ZonedClock {\n  /** The day and the minutes from its midnight that an instant falls on. */\n  at(instant: number): { day: string; minutes: number };\n  /** The instant a day's wall-clock minute falls on. */\n  instant(day: string, minutes: number): Date;\n}\n\n/**\n * Where a key press moves the shown days, in days, for {@link TimeGrid}'s `onDateChange`, or 0 for\n * a key that does not: Page Down and ⌥↓ (Alt+↓) the next day or week, Page Up and ⌥↑ the one before.\n * @claim \"Page Down and ⌥↓ (Alt+↓) the next day or week\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > moves to the next or previous period with Page Down and Page Up, or Alt with the arrows, and to today with Alt+Shift+Y)\n */\nfunction periodShift(event: { key: string; altKey: boolean; ctrlKey: boolean; metaKey: boolean; shiftKey: boolean }, view: TimeGridView): number {\n  if (event.ctrlKey || event.metaKey || event.shiftKey) return 0;\n  const forward = event.key === \"PageDown\" || (event.altKey && event.key === \"ArrowDown\");\n  const back = event.key === \"PageUp\" || (event.altKey && event.key === \"ArrowUp\");\n  return (forward ? 1 : back ? -1 : 0) * (view === \"day\" ? 1 : 7);\n}\n\n/** Today's ISO date on a clock, read when it is called. */\nfunction todayOn(clock: ZonedClock): string {\n  return clock.at(Date.now()).day;\n}\n\n/** The wall clock of `timeZone` (an IANA name such as `\"Europe/Berlin\"`, or `undefined` for the reader's own). */\nfunction zonedClock(timeZone: string | undefined): ZonedClock {\n  const format = new Intl.DateTimeFormat(\"en-US\", {\n    timeZone,\n    hourCycle: \"h23\",\n    year: \"numeric\",\n    month: \"2-digit\",\n    day: \"2-digit\",\n    hour: \"2-digit\",\n    minute: \"2-digit\",\n  });\n  const at = (instant: number) => {\n    const part: Record<string, string> = {};\n    for (const { type, value } of format.formatToParts(instant)) part[type] = value;\n    return { day: `${part.year}-${part.month}-${part.day}`, minutes: Number(part.hour) * 60 + Number(part.minute) };\n  };\n  const wall = (day: string, minutes: number) => Date.parse(`${day}T00:00:00Z`) + minutes * 60_000;\n  return {\n    at,\n    instant(day, minutes) {\n      // Read the wall time as UTC, then move by the zone's offset there; the second pass settles\n      // an hour that a daylight saving change moves.\n      const target = wall(day, minutes);\n      let guess = target;\n      // Stryker disable next-line EqualityOperator: a third pass lands where the second did\n      for (let pass = 0; pass < 2; pass++) {\n        const seen = at(guess);\n        guess += target - wall(seen.day, seen.minutes);\n      }\n      return new Date(guess);\n    },\n  };\n}\n\n/** What Intl.Locale says about weeks, in browsers that have it. */\ntype WeekLocale = Intl.Locale & { getWeekInfo?: () => { weekend: number[] }; weekInfo?: { weekend: number[] } };\n\n/**\n * The weekend in a locale, as `Date.getUTCDay()` numbers (0 is Sunday). Without week information\n * (Firefox), Friday and Saturday where the week starts on Saturday, and Saturday and Sunday elsewhere.\n * @claim \"The weekend in a locale\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > finds the week's days from the locale, without its weekend for a work week)\n */\nfunction weekendDays(locale: string): number[] {\n  const intl = new Intl.Locale(locale) as WeekLocale;\n  const info = intl.getWeekInfo?.() ?? intl.weekInfo;\n  if (info) return info.weekend.map((day) => day % 7);\n  return firstDayOfWeek(locale) === 6 ? [5, 6] : [6, 0];\n}\n\n/** The weekday of an ISO date, as `Date.getUTCDay()` numbers it. */\nconst weekday = (day: string) => new Date(`${day}T00:00:00Z`).getUTCDay();\n\n/** The days a view shows around `date`: the day, or its week from the locale's first day, without the weekend for `work-week`. */\nfunction viewDays(date: string, view: TimeGridView, locale: string): string[] {\n  if (view === \"day\") return [date];\n  const start = addDays(date, -((weekday(date) - firstDayOfWeek(locale) + 7) % 7));\n  const week = Array.from({ length: 7 }, (_, index) => addDays(start, index));\n  if (view === \"week\") return week;\n  const weekend = weekendDays(locale);\n  return week.filter((day) => !weekend.includes(weekday(day)));\n}\n\n/** A timed event's place in its day's column. */\ninterface DayPlacement<Key> {\n  key: Key;\n  /** The minutes from midnight it is drawn from, and to. */\n  top: number;\n  bottom: number;\n  /** Its column in its group of overlapping events, how many columns it spreads over, and how many the group has. */\n  column: number;\n  span: number;\n  columns: number;\n}\n\n/**\n * The narrowest a day's labelled background event may be, in pixels, before its stack of\n * overlapping events is drawn as one count instead: narrower, its label would be cut to a few letters.\n * @claim \"The narrowest a day's labelled background event may be\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > draws a day's background events too narrow to read as one count that opens their list)\n */\nconst stackMinWidth = 96;\n\n/**\n * A day's placements in their stacks: the runs of events that overlap one another, directly or\n * through others, in the order `layoutDay` placed them.\n * @claim \"A day's placements in their stacks\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > draws a day's background events too narrow to read as one count that opens their list)\n */\nfunction stacksOf<Key>(placements: ReadonlyArray<DayPlacement<Key>>): Array<Array<DayPlacement<Key>>> {\n  const stacks: Array<Array<DayPlacement<Key>>> = [];\n  let end = -Infinity;\n  for (const placed of placements) {\n    if (placed.top >= end) stacks.push([]);\n    stacks.at(-1)!.push(placed);\n    end = Math.max(end, placed.bottom);\n  }\n  return stacks;\n}\n\n/**\n * Lays out one day's timed events side by side where they overlap. Events that overlap one\n * another, directly or through others, share the day's width in columns: each takes the first\n * column free at its start, then spreads over the columns beside it that nothing it overlaps\n * uses. Events are drawn at least `minVisibleMinutes` tall, and overlap as drawn.\n * @claim \"Lays out one day's\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > lays overlapping events side by side, spreading each over the columns free beside it)\n * @claim \"Events that overlap one\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > lays overlapping events side by side, spreading each over the columns free beside it)\n */\nfunction layoutDay<Key>(items: ReadonlyArray<{ key: Key; start: number; end: number }>): Array<DayPlacement<Key>> {\n  const drawn = items\n    .map(({ key, start, end }) => ({ key, top: start, bottom: Math.min(dayLength, Math.max(end, start + minVisibleMinutes)) }))\n    .sort((a, b) => a.top - b.top || b.bottom - a.bottom);\n  const placed: Array<DayPlacement<Key>> = [];\n  let group: Array<DayPlacement<Key>> = [];\n  let groupEnd = 0;\n  // Stryker disable next-line ArrayDeclaration: the first event closes an empty group, which empties it\n  let ends: number[] = [];\n  const close = () => {\n    for (const item of group) {\n      item.columns = ends.length;\n      // An event to the right that starts as this one ends would have taken this one's column, so\n      // `<` and `<=` read the same here.\n      // Stryker disable next-line EqualityOperator: no event in a later column starts as this one ends\n      const overlaps = (column: number) => group.some((other) => other.column === column && other.top < item.bottom && item.top < other.bottom);\n      while (item.column + item.span < ends.length && !overlaps(item.column + item.span)) item.span++;\n    }\n    placed.push(...group);\n    group = [];\n    ends = [];\n  };\n  for (const item of drawn) {\n    if (item.top >= groupEnd) close();\n    let column = ends.findIndex((end) => end <= item.top);\n    if (column === -1) column = ends.push(item.bottom) - 1;\n    else ends[column] = item.bottom;\n    group.push({ ...item, column, span: 1, columns: 1 });\n    groupEnd = Math.max(groupEnd, item.bottom);\n  }\n  close();\n  return placed;\n}\n\n/**\n * An all-day event's place in the all-day row.\n *\n * @claim \"place in the all-day row\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > stacks all-day events in the first row free across their days)\n */\ninterface LaneSpan<Key> {\n  key: Key;\n  /** The first and last day it covers, as indexes into the days shown, and its row. */\n  first: number;\n  last: number;\n  lane: number;\n}\n\n/**\n * Stacks all-day events in rows, each in the first row free across all the days it covers.\n *\n * @claim \"Stacks all-day events in rows\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > stacks all-day events in the first row free across their days)\n */\nfunction allDayLanes<Key>(items: ReadonlyArray<{ key: Key; first: number; last: number }>): Array<LaneSpan<Key>> {\n  const lanes: number[] = [];\n  return [...items]\n    .sort((a, b) => a.first - b.first || b.last - a.last)\n    .map((item) => {\n      let lane = lanes.findIndex((last) => last < item.first);\n      if (lane === -1) lane = lanes.push(item.last) - 1;\n      else lanes[lane] = item.last;\n      return { ...item, lane };\n    });\n}\n\n/**\n * How many 16px lines of text fit in an event drawn `minutes` tall, at the grid's shortest hour (48px), less its padding.\n *\n * @claim \"How many 16px lines\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > counts the lines an event's height holds)\n */\nfunction lineCount(minutes: number): number {\n  return Math.max(1, Math.floor(((minutes / 60) * 48 - 4) / 16));\n}\n\n/**\n * A clock the grids on a page share, moved on at each minute while any of them shows.\n *\n * @claim \"A clock the grids\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid date and layout math > keeps one clock for every grid, moved on at each minute and stopped when the last one goes)\n */\nfunction minuteClock(): { subscribe: (listener: () => void) => () => void; read: () => number } {\n  let now = 0;\n  const listeners = new Set<() => void>();\n  let timer: ReturnType<typeof setTimeout> | undefined;\n  const untilNextMinute = () => 60_000 - (now % 60_000);\n  const tick = () => {\n    now = Date.now();\n    timer = setTimeout(tick, untilNextMinute());\n    for (const each of [...listeners]) each();\n  };\n  return {\n    subscribe(listener) {\n      listeners.add(listener);\n      now = Date.now();\n      timer ??= setTimeout(tick, untilNextMinute());\n      return () => {\n        listeners.delete(listener);\n        if (listeners.size > 0) return;\n        clearTimeout(timer);\n        timer = undefined;\n      };\n    },\n    read: () => now,\n  };\n}\n\n/**\n * Where an arrow key goes from the event `from`: Up and Down to the one before or after in time\n * order, Left and Right (swapped right to left) to the nearest in time on the day before or after\n * that has events, Home and End to the first and the last.\n */\nfunction stepTo(pieces: ReadonlyArray<{ key: string; day: number; start: number }>, from: string, key: string, rtl: boolean): string | undefined {\n  const index = pieces.findIndex((piece) => piece.key === from);\n  const here = pieces[index]!;\n  if (key === \"ArrowDown\") return pieces[index + 1]?.key;\n  if (key === \"ArrowUp\") return pieces[index - 1]?.key;\n  if (key === \"Home\") return pieces[0]!.key;\n  if (key === \"End\") return pieces[pieces.length - 1]!.key;\n  if (key !== \"ArrowLeft\" && key !== \"ArrowRight\") return undefined;\n  const forward = (key === \"ArrowRight\") !== rtl;\n  const days = pieces.filter((piece) => (forward ? piece.day > here.day : piece.day < here.day));\n  if (days.length === 0) return undefined;\n  const day = forward ? days[0]!.day : days[days.length - 1]!.day;\n  return pieces\n    .filter((piece) => piece.day === day)\n    .reduce((best, piece) => (Math.abs(piece.start - here.start) < Math.abs(best.start - here.start) ? piece : best)).key;\n}\n\n/**\n * An event: its text from the top, and a bar in its tone on its start edge (each status sets the\n * border widths, `statusClass`). Keyboard focus is a ring outside the event, with a gap, as on\n * Ouro's other controls; the selected event has a line just inside its edge instead, so focus on\n * it still shows. Under forced colours every event keeps a border.\n * @claim \"Keyboard focus is a ring outside the event\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > draws keyboard focus apart from selection: a ring outside the event, where selection is a line just inside it)\n * @claim \"each status sets the\" registry/ouro/components/ouro/time-grid/time-grid-styles.ts verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid-styles.ts, /busy: \"border-0 border-s-3\"/)\n * @claim \"Under forced colours every event\" registry/ouro/components/ouro/time-grid/time-grid-styles.ts verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid-styles.ts, /forced-colors:border forced-colors:border-s-3/)\n */\nconst eventClass =\n  \"m-0 box-border flex min-w-0 flex-col rounded-ouro-md border-solid px-1.5 py-0.5 \" +\n  \"font-[inherit] text-start text-xs leading-4 text-foreground no-underline [overflow-wrap:anywhere] \" +\n  \"cursor-pointer select-none touch-manipulation [-webkit-tap-highlight-color:transparent] \" +\n  \"transition-colors duration-(--ouro-duration-fast) ease-(--ouro-ease-out) \" +\n  \"outline-ring outline-offset-2 focus-visible:z-30 focus-visible:outline-2 focus-visible:outline-solid \" +\n  \"aria-[current=true]:z-20 aria-[current=true]:shadow-[inset_0_0_0_2px_var(--foreground)] \" +\n  \"aria-expanded:z-20 aria-expanded:outline-2 aria-expanded:outline-solid aria-expanded:outline-primary \" +\n  \"forced-colors:border forced-colors:border-s-3 forced-colors:aria-[current=true]:bg-[Highlight] forced-colors:aria-[current=true]:text-[HighlightText]\";\n\n/** A timed event fills its place in the day's column, over the now line. */\nconst timedClass = \"absolute inset-0 z-10 scroll-mt-(--ouro-time-grid-head) @container/event\";\n\n/**\n * An all-day event: one line in the all-day row.\n *\n * @claim \"one line in the\" registry/ouro/components/ouro/time-grid/time-grid-styles.ts verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid-styles.ts, /allDayClass = \"relative h-5\\.5 w-full isolate\"/)\n */\nconst allDayClass = \"relative h-5.5 w-full isolate\";\n\n/**\n * Each tone's start bar, and the outline of a free or unanswered event.\n *\n * @claim \"Each tone's start bar\" registry/ouro/components/ouro/time-grid/time-grid-styles.ts verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid-styles.ts, /primary: \"border-primary\"/)\n */\nconst toneBarClass: Record<TimeGridTone, string> = {\n  primary: \"border-primary\",\n  secondary: \"border-muted-foreground\",\n  success: \"border-success\",\n  warning: \"border-warning\",\n  destructive: \"border-destructive\",\n};\n\n/**\n * A busy event's fill: the tone over the page (`--ouro-time-grid-tint`, 14%, and 24% in dark mode,\n * where a tint shows less), opaque so the now line passes under the text, and stronger under a\n * mouse or a press.\n * @claim \"A busy event's fill\" registry/ouro/components/ouro/time-grid/time-grid.tsx verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid.tsx, /\\[--ouro-time-grid-tint:14%\\].*dark:\\[--ouro-time-grid-tint:24%\\]/)\n */\nconst toneFillClass: Record<TimeGridTone, string> = {\n  primary:\n    \"bg-[color-mix(in_oklab,var(--primary)_var(--ouro-time-grid-tint),var(--background))] pointer-fine:hover:bg-[color-mix(in_oklab,var(--primary)_calc(var(--ouro-time-grid-tint)+8%),var(--background))] active:bg-[color-mix(in_oklab,var(--primary)_calc(var(--ouro-time-grid-tint)+12%),var(--background))]\",\n  secondary: \"bg-secondary pointer-fine:hover:bg-[color-mix(in_oklab,var(--foreground)_8%,var(--secondary))] active:bg-[color-mix(in_oklab,var(--foreground)_12%,var(--secondary))]\",\n  success:\n    \"bg-[color-mix(in_oklab,var(--success)_var(--ouro-time-grid-tint),var(--background))] pointer-fine:hover:bg-[color-mix(in_oklab,var(--success)_calc(var(--ouro-time-grid-tint)+8%),var(--background))] active:bg-[color-mix(in_oklab,var(--success)_calc(var(--ouro-time-grid-tint)+12%),var(--background))]\",\n  warning:\n    \"bg-[color-mix(in_oklab,var(--warning)_var(--ouro-time-grid-tint),var(--background))] pointer-fine:hover:bg-[color-mix(in_oklab,var(--warning)_calc(var(--ouro-time-grid-tint)+8%),var(--background))] active:bg-[color-mix(in_oklab,var(--warning)_calc(var(--ouro-time-grid-tint)+12%),var(--background))]\",\n  destructive:\n    \"bg-[color-mix(in_oklab,var(--destructive)_var(--ouro-time-grid-tint),var(--background))] pointer-fine:hover:bg-[color-mix(in_oklab,var(--destructive)_calc(var(--ouro-time-grid-tint)+8%),var(--background))] active:bg-[color-mix(in_oklab,var(--destructive)_calc(var(--ouro-time-grid-tint)+12%),var(--background))]\",\n};\n\n/**\n * The page-coloured fill of every status but busy.\n *\n * @claim \"The page-coloured fill of\" registry/ouro/components/ouro/time-grid/time-grid.tsx verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid.tsx, /status === \"busy\" \\? toneFillClass\\[tone\\] : plainFillClass/)\n */\nconst plainFillClass = \"bg-background pointer-fine:hover:bg-accent active:bg-accent\";\n\n/**\n * A background event's fill: a step off the page whatever its tone, so it reads as secondary\n * beside the person's own events; its tone is the bar on its start edge.\n * @claim \"A background event's fill\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > draws background events in a lane at each day's start, beside the person's own)\n */\nconst backgroundFillClass =\n  \"bg-[color-mix(in_oklab,var(--foreground)_4%,var(--background))] pointer-fine:hover:bg-[color-mix(in_oklab,var(--foreground)_9%,var(--background))] active:bg-[color-mix(in_oklab,var(--foreground)_12%,var(--background))]\";\n\n/**\n * A background event in a week: a press target as wide as its share of the lane, with no text,\n * around a slim bar in its tone (`backgroundBarFillClass`) that widens under a mouse.\n * @claim \"a press target as wide as\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > names a week's thin bars in a tooltip, and labels them in a day)\n */\nconst backgroundBarClass = \"group/bar border-0 bg-transparent p-0\";\n\n/**\n * An event's hit area: at least 24px square to a mouse too, invisible, from its top start corner\n * toward the end and down, so a short event, an all-day one and a week's bar a few pixels wide are\n * easy to point at without being drawn bigger. It grows away from the events placed before it,\n * which therefore stay under the pointer where they show, and a background event's stays under\n * the person's own events. It is the event's own `::before`, behind its text.\n * @claim \"An event's hit area\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > gives a week's thin bar a hit area at least 24px square to a mouse from its top corner, without growing the bar)\n * @claim \"An event's hit area\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > gives a short event and an all-day one a hit area at least 24px tall, without drawing them taller)\n */\nconst eventHitClass = \"before:absolute before:top-0 before:start-0 before:-z-1 before:size-[max(100%,1.5rem)] before:content-['']\";\n\n/**\n * The slim bar a week draws for a background event: 4px, and 6px under a mouse or while its popover is open, with no motion.\n *\n * @claim \"The slim bar a week draws\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > names a week's thin bars in a tooltip, and labels them in a day)\n */\nconst backgroundBarFillClass =\n  \"pointer-events-none absolute inset-y-0 start-0.5 box-border w-1 rounded-full border-solid pointer-fine:group-hover/bar:w-1.5 group-aria-expanded/bar:w-1.5\";\n\n/**\n * Each tone as a solid swatch, the bar's colour: mixed toward the page so a column of bars stays quiet.\n *\n * @claim \"Each tone as a solid swatch\" registry/ouro/components/ouro/time-grid/time-grid-styles.ts verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid-styles.ts, /primary: \"border-primary bg-\\[color-mix/)\n */\nconst toneSwatchClass: Record<TimeGridTone, string> = {\n  primary: \"border-primary bg-[color-mix(in_oklab,var(--primary)_60%,var(--background))]\",\n  secondary: \"border-muted-foreground bg-[color-mix(in_oklab,var(--muted-foreground)_60%,var(--background))]\",\n  success: \"border-success bg-[color-mix(in_oklab,var(--success)_60%,var(--background))]\",\n  warning: \"border-warning bg-[color-mix(in_oklab,var(--warning)_60%,var(--background))]\",\n  destructive: \"border-destructive bg-[color-mix(in_oklab,var(--destructive)_60%,var(--background))]\",\n};\n\n/**\n * A bar's status: busy is filled; every other status is an outline in the tone, dashed for an\n * answer still owed and dotted when cancelled. Under forced colours a filled bar is the text colour.\n * @claim \"every other status is an outline\" registry/ouro/components/ouro/time-grid/time-grid-styles.ts verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid-styles.ts, /unanswered: \"border bg-transparent border-dashed\"/)\n */\nconst barStatusClass: Record<TimeGridStatus, string> = {\n  busy: \"border-0 forced-colors:bg-[CanvasText]\",\n  tentative: \"border bg-transparent\",\n  free: \"border bg-transparent\",\n  unanswered: \"border bg-transparent border-dashed\",\n  cancelled: \"border bg-transparent border-dotted\",\n};\n\n/**\n * What each status adds. Tentative is hatched, with a dashed bar; free is outlined; an event\n * that needs an answer is outlined in dashes; a cancelled one has a dotted bar and is struck\n * through in muted text. The dashes and dots stay under forced colours.\n * @claim \"What each status adds\" registry/ouro/components/ouro/time-grid/time-grid-styles.ts verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid-styles.ts, /unanswered: \"border border-s-3 border-dashed\"/)\n */\nconst statusClass: Record<TimeGridStatus, string> = {\n  busy: \"border-0 border-s-3\",\n  tentative:\n    \"border-0 border-s-3 [border-inline-start-style:dashed] forced-colors:[border-inline-start-style:dashed] [background-image:repeating-linear-gradient(135deg,transparent_0_5px,color-mix(in_oklab,currentColor_4%,transparent)_5px_10px)]\",\n  free: \"border border-s-3\",\n  unanswered: \"border border-s-3 border-dashed\",\n  cancelled: \"border-0 border-s-3 [border-inline-start-style:dotted] forced-colors:[border-inline-start-style:dotted] text-[color-mix(in_oklab,var(--muted-foreground)_55%,var(--foreground))] line-through\",\n};\n",
      "type": "registry:ui",
      "target": "@components/ouro/time-grid/time-grid-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/time-grid/time-grid.tsx",
      "content": "\"use client\";\n\nimport {\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n  useSyncExternalStore,\n  type CSSProperties,\n  type HTMLAttributes,\n  type JSX,\n  type KeyboardEvent,\n  type MouseEvent,\n  type PointerEvent,\n  type ReactNode,\n  type Ref,\n} from \"react\";\nimport { Menu, MenuItem } from \"@/registry/ouro/components/ouro/menu/menu\";\nimport { ScrollArea } from \"@/registry/ouro/components/ouro/scroll-area/scroll-area\";\nimport { Tooltip } from \"@/registry/ouro/components/ouro/tooltip/tooltip\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { navigationKey } from \"@/registry/ouro/lib/ouro/navigation-key\";\nimport { RouterLink } from \"@/registry/ouro/lib/ouro/router-link\";\nimport { renamedTones } from \"@/registry/ouro/lib/ouro/tones\";\nimport { TouchTarget } from \"@/registry/ouro/lib/ouro/touch-target\";\nimport { useDevWarnings, type DevWarning } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { addDays } from \"@/registry/ouro/components/ouro/calendar/calendar-styles\";\nimport { inBrowser, onServer, subscribeNever } from \"@/registry/ouro/components/ouro/local-date/local-date-styles\";\nimport {\n  allDayClass,\n  allDayLanes,\n  backgroundBarClass,\n  backgroundBarFillClass,\n  backgroundFillClass,\n  barStatusClass,\n  dayLength,\n  eventClass,\n  eventHitClass,\n  isIsoDate,\n  layoutDay,\n  lineCount,\n  minuteClock,\n  stepTo,\n  plainFillClass,\n  slotSizes,\n  periodShift,\n  stackMinWidth,\n  todayOn,\n  stacksOf,\n  statusClass,\n  statuses,\n  timedClass,\n  toInstant,\n  toneBarClass,\n  toneFillClass,\n  toneSwatchClass,\n  tones,\n  viewDays,\n  views,\n  weekendDays,\n  zonedClock,\n  type DayPlacement,\n  type TimeGridStatus,\n  type TimeGridTone,\n  type TimeGridView,\n} from \"@/registry/ouro/components/ouro/time-grid/time-grid-styles\";\n\nexport type { TimeGridStatus, TimeGridTone, TimeGridView };\n\n/** One event on a {@link TimeGrid}. */\nexport interface TimeGridEvent {\n  /** Unique among the grid's events. `onEventSelect` gets the event back, and `selectedId` names it. */\n  id: string;\n  /** What the event is, shown first and read first: `\"Design review\"`. */\n  title: string;\n  /**\n   * When it starts: a `Date`, an ISO string or a timestamp in milliseconds. A calendar date with\n   * no time (`\"2026-03-12\"`) makes the event all day, on that day for every reader, in the\n   * all-day row.\n   * @claim \"makes the event all day\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > puts all-day events in their own row, across the days they cover)\n   */\n  start: Date | string | number;\n  /**\n   * When it ends. A timed event needs one. An all-day event's `end` is its last day, included\n   * (`\"2026-03-14\"` for three days from the 12th); without it the event is one day. A timed event\n   * 24 hours or longer goes in the all-day row across the days it covers.\n   * @claim \"is its last day\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > puts all-day events in their own row, across the days they cover)\n   * @claim \"24 hours or longer\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > puts a timed event of a day or more in the all-day row, and cuts one across midnight into each day)\n   */\n  end?: Date | string | number | undefined;\n  /** A second line where there is room: a place, a room, who organised it. Screen readers hear it last. */\n  description?: string | undefined;\n  /** Its colour, from your theme. @default \"primary\" */\n  tone?: TimeGridTone | (string & { 'danger is \"destructive\"; accent is \"primary\"; neutral is \"secondary\"': never }) | undefined;\n  /**\n   * What it does to the person's time. `busy` is filled; `tentative` is hatched; `free` is\n   * outlined; `unanswered`, an invitation still waiting for an answer, is outlined in dashes;\n   * `cancelled` is struck through. Screen readers hear every status but busy, in the words of\n   * `statusLabels`.\n   * @default \"busy\"\n   * @claim \"Screen readers hear every\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > names each event by the words it shows first, its title and its time, then its day, its status and its description)\n   */\n  status?: TimeGridStatus | (string & { 'Use \"busy\", \"tentative\", \"free\", \"unanswered\" or \"cancelled\"': never }) | undefined;\n  /** Makes the event a link to its page, through `OuroProvider`'s router link for a path in your app. */\n  href?: string | undefined;\n\n  /**\n   * Not a field. An all-day event's `start` is a date: `{ start: \"2026-03-12\" }`.\n   *\n   * @claim \"An all-day event's `start` is a date\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > development messages > names what is wrong with an event, and draws it in the defaults)\n   */\n  allDay?: { 'Pass start as a date: start: \"2026-03-12\"': never };\n  /** Not a field. Colours come from the theme: `{ tone: \"success\" }`. */\n  color?: { 'Use tone: \"success\"': never };\n}\n\n/** What {@link TimeGrid}'s `onEventSelect` gets besides the event. */\nexport interface TimeGridSelectDetails {\n  /** The event's element, to anchor a popover of your own to (`<Popover anchor={ref}>`). */\n  element: HTMLElement;\n  /** Whether it is one of `backgroundEvents`. */\n  background: boolean;\n}\n\n/** An empty stretch of time someone pressed, from {@link TimeGrid}'s `onSlotSelect`. */\nexport interface TimeGridSlot {\n  start: Date;\n  end: Date;\n}\n\n/**\n * The words screen readers hear for each status but busy.\n *\n * @claim \"The words screen readers hear for each status but busy\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > speaks the statuses in the words given)\n */\nexport type TimeGridStatusLabels = Partial<Record<Exclude<TimeGridStatus, \"busy\">, string>>;\n\n/** The props TimeGrid adds to the div attributes it passes through. */\nexport interface TimeGridOwnProps {\n  /**\n   * What the grid shows, read by screen readers as its name: `\"Team calendar\"`. Required,\n   * because a scrolling page of hours says nothing on its own. It is not shown.\n   */\n  label: string;\n  /**\n   * The events. Each shows on every day it covers that the grid shows; the rest are left out.\n   *\n   * @claim \"Each shows on every day\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > puts a timed event of a day or more in the all-day row, and cuts one across midnight into each day)\n   */\n  events: readonly TimeGridEvent[];\n  /**\n   * The day to show, as an ISO date (`\"2026-03-12\"`). `week` and `work-week` show the week it is\n   * in. Move it with your own Today, Previous and Next buttons.\n   */\n  date: string;\n  /**\n   * `day`, `work-week` (the week without the locale's weekend) or `week`, from the locale's\n   * first day of the week.\n   * @default \"week\"\n   */\n  view?: TimeGridView | (string & { 'Use \"day\", \"work-week\" or \"week\"': never }) | undefined;\n  /**\n   * The IANA time zone the grid's clock reads (`\"Europe/Berlin\"`): which day and hour each\n   * event falls on, where the now line is, and the times shown. Without it, the reader's own,\n   * once the page runs in the browser; the server writes UTC until then.\n   * @claim \"The IANA time zone\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > places each event by its times on the grid's clock, and moves it with the time zone)\n   */\n  timeZone?: string | undefined;\n  /**\n   * The BCP 47 locale for the day names, the hours (`\"9 AM\"`, `\"09\"`), the times and the first\n   * day of the week: `\"en-GB\"` starts weeks on Monday. The default is the same on the server and\n   * in the browser, so hydration matches.\n   * @default \"en-US\"\n   * @claim \"The BCP 47 locale\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > writes day names, hours and times in the locale)\n   */\n  locale?: string | undefined;\n  /**\n   * The current time, when your app keeps the clock (a demo, a test, a time it shares with\n   * other views). Without it, the grid reads the browser's clock and moves the now line each\n   * minute.\n   * @claim \"the grid reads the\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > follows the browser's clock without now, moving the line each minute)\n   */\n  now?: Date | string | number | undefined;\n  /**\n   * The working day, in hours from midnight (`{ start: 8.5, end: 17 }`). The hours outside it,\n   * and weekend days, are shaded, and the grid opens scrolled to its start unless today is\n   * shown, when it opens at now, or at today's first event when now is before it.\n   * @default { start: 8, end: 17 }\n   * @claim \"start: 8, end: 17\" registry/ouro/components/ouro/time-grid/time-grid.tsx verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid.tsx, /const defaultWorkingHours = \\{ start: 8, end: 17 \\}/)\n   */\n  workingHours?: { start: number; end: number } | undefined;\n  /** The selected event's id: it gets an outline and `aria-current`. */\n  selectedId?: string | null | undefined;\n  /**\n   * Called with the event when someone presses it, or presses Enter on it, and with its element\n   * and whether it is a background event, so a popover of your own can point at it.\n   * @claim \"and with its element\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > tells onEventSelect which element was pressed, and marks the one whose popover is open)\n   */\n  onEventSelect?: ((event: TimeGridEvent, details: TimeGridSelectDetails) => void) | undefined;\n  /**\n   * Called with the ISO date to show when a key moves the days while focus is in the grid: Page\n   * Down and ⌥↓ (Alt+↓) the next day or week, Page Up and ⌥↑ the one before, and ⌥⇧Y\n   * (Alt+Shift+Y) today, as in Teams. Set `date` to it. `TimeGridNav` gives the same moves as\n   * buttons, with these keys in their tooltips.\n   * @claim \"Called with the ISO date to show when a key moves the days\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > moves to the next or previous period with Page Down and Page Up, or Alt with the arrows, and to today with Alt+Shift+Y)\n   */\n  onDateChange?: ((date: string) => void) | undefined;\n  /**\n   * Events that are not the person's own, such as a shared calendar, a colleague's or a room's.\n   * Each day draws them in a lane of their own at its start, beside the person's events: thin\n   * bars that name themselves in a tooltip in a week, and labelled ones in a day. Each is a\n   * button that `onEventSelect` gets, reached with the arrow keys like the others. Timed events\n   * only: those that are all day, or 24 hours or longer, are left out.\n   * @claim \"Each day draws them in a lane\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > draws background events in a lane at each day's start, beside the person's own)\n   * @claim \"thin bars that name themselves\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > names a week's thin bars in a tooltip, and labels them in a day)\n   * @claim \"reached with the arrow keys\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > takes the arrow keys through background events in time order with the rest)\n   * @claim \"those that are all day\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > development messages > names a background event that is all day, and leaves it out)\n   */\n  backgroundEvents?: readonly TimeGridEvent[] | undefined;\n  /**\n   * What the background events are, heard after each one's title, time and day, and as the name\n   * of each day's lane: `\"Shared calendar\"`. Translate it with your app.\n   * @default \"Other calendars\"\n   * @claim \"heard after each one's title, time and day\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > draws background events in a lane at each day's start, beside the person's own)\n   */\n  backgroundLabel?: string | undefined;\n  /**\n   * The words on a stack of a day's background events drawn as one: in a day too narrow to label\n   * each of them, overlapping background events show as one block with their count, which opens\n   * their list. Translate it with your app.\n   * @default (count) => `${count} events`\n   * @claim \"overlapping background events show as one block\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > draws a day's background events too narrow to read as one count that opens their list)\n   */\n  stackLabel?: ((count: number) => string) | undefined;\n  /**\n   * The id of the event whose popover of your own is open: it says so to screen readers\n   * (`aria-expanded`) and gets an outline until you clear it.\n   * @claim \"it says so to screen readers\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > tells onEventSelect which element was pressed, and marks the one whose popover is open)\n   */\n  expandedId?: string | null | undefined;\n  /**\n   * Content of your own under each day's header, such as a count or a load bar. It gets the day\n   * as an ISO date. Screen readers read it, so give a bar words of its own.\n   * @claim \"Content of your own under each day's header\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid background events > puts the app's summary under each day's header, where screen readers read it)\n   */\n  renderDaySummary?: ((day: string) => ReactNode) | undefined;\n  /**\n   * Called when someone presses an empty part of a day, with the slot under the pointer, for a\n   * new event there. A mouse shows the slot before the press. Slots answer a pointer only, so\n   * give keyboards a New event button of your own as well.\n   */\n  onSlotSelect?: ((slot: TimeGridSlot) => void) | undefined;\n  /**\n   * How long a slot `onSlotSelect` gets is, in minutes: 15, 30 or 60. @default 30\n   *\n   * @claim \"How long a slot\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > presses an empty slot with onSlotSelect, and shows a mouse the slot first)\n   */\n  slotMinutes?: 15 | 30 | 60 | (number & { \"Use 15, 30 or 60\": never }) | undefined;\n  /**\n   * The all-day row's name, shown beside it and heard in each all-day event's name. Translate it with your app. @default \"All day\"\n   *\n   * @claim \"The all-day row's name\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > writes day names, hours and times in the locale)\n   */\n  allDayLabel?: string | undefined;\n  /**\n   * The words screen readers hear for each status, after the event's title. Translate them with\n   * your app.\n   * @default { tentative: \"tentative\", free: \"free\", unanswered: \"needs your answer\", cancelled: \"cancelled\" }\n   * @claim \"The words screen readers hear for each status, after\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > speaks the statuses in the words given)\n   */\n  statusLabels?: TimeGridStatusLabels | undefined;\n  /** Something small drawn where the now line meets the hours: a mascot, an avatar. Decoration only; screen readers skip it. */\n  nowAdornment?: ReactNode;\n  /**\n   * Layout only: the grid's height (`h-full`, `h-[40rem]`), width and margins. Appearance classes\n   * warn in development. In a grid taller than a day, the hours grow so the day ends at its foot.\n   * @claim \"In a grid taller than a day, the hours grow\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > grows its hours to fill a grid taller than a day, so the day ends at the grid's foot, and shrinks them back with it)\n   */\n  className?: string | undefined;\n  /** The grid's root element. */\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. The view is `view`: `<TimeGrid view=\"work-week\">`, which your app keeps. */\n  defaultView?: { 'Use view=\"work-week\"': never };\n  /** Not a prop. The day is `date`, which your app keeps: `<TimeGrid date=\"2026-03-12\">`. */\n  defaultDate?: { 'Use date=\"2026-03-12\"': never };\n  /** Not a prop. Ouro UI uses `onEventSelect`, which gets the event. */\n  onSelectEvent?: { \"Use onEventSelect={(event) => open(event.id)}\": never };\n  /** Not a prop. Ouro UI uses `onSlotSelect`, which gets `{ start, end }`. */\n  onSelectSlot?: { \"Use onSlotSelect={({ start, end }) => create(start, end)}\": never };\n  /** Not a prop. The grid opens at the start of `workingHours`, or at now when today shows. */\n  scrollToTime?: { \"Use workingHours={{ start: 8, end: 17 }}\": never };\n}\n\n/** Props for {@link TimeGrid}: its own props and the div attributes it passes through to the root. */\nexport type TimeGridProps = Omit<HTMLAttributes<HTMLDivElement>, keyof TimeGridOwnProps> & TimeGridOwnProps;\n\n// Busy, the usual, goes unsaid.\nconst defaultStatusLabels: Record<TimeGridStatus, string> = { busy: \"\", tentative: \"tentative\", free: \"free\", unanswered: \"needs your answer\", cancelled: \"cancelled\" };\n/** `value` when it is one of `list`, else `fallback`. */\nconst oneOf = <Name extends string>(list: readonly Name[], value: string | undefined, fallback: Name): Name => ((list as readonly (string | undefined)[]).includes(value) ? (value as Name) : fallback);\nconst defaultWorkingHours = { start: 8, end: 17 };\n\nconst clock = minuteClock();\n// Stryker disable next-line ArrowFunction: the server's time only has to be no time, which 0 and undefined both are\nconst serverNow = () => 0;\n\n// An event's time and description: muted text mixed toward the foreground, further than on a\n// plain muted surface, because a dark theme colour tints the fill under it.\nconst mutedClass = \"text-[color-mix(in_oklab,var(--muted-foreground)_55%,var(--foreground))]\";\nconst mutedLineClass = \"truncate text-[color-mix(in_oklab,var(--muted-foreground)_55%,var(--foreground))]\";\n\n// The default for backgroundEvents: one array, so the layout is worked out again only when the events change.\nconst noEvents: readonly TimeGridEvent[] = [];\n\n/**\n * One drawn piece of an event: a timed event has one per day it covers; an all-day event, one.\n *\n * @claim \"One drawn piece of\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > puts a timed event of a day or more in the all-day row, and cuts one across midnight into each day)\n */\ninterface Piece {\n  key: string;\n  event: TimeGridEvent;\n  /** The index of its (first) day among those shown. */\n  day: number;\n  /**\n   * Minutes from that day's midnight it starts and ends; for an all-day event, -1 (so it comes first) to the day's end.\n   *\n   * @claim \"Minutes from that day's\" registry/ouro/components/ouro/time-grid/time-grid.tsx verify:fileLine(registry/ouro/components/ouro/time-grid/time-grid.tsx, /start: -1, end: dayLength/)\n   */\n  start: number;\n  end: number;\n  /** What a screen reader hears after its title and time: its day or days. */\n  when: string[];\n  /** Its status, `busy` for one the grid does not know. */\n  status: TimeGridStatus;\n  /** Whether it is one of `backgroundEvents`. */\n  background: boolean;\n}\n\nconst utcDate = (day: string) => new Date(`${day}T00:00:00Z`);\n// Node's ICU spaces a range with thin (U+2009) and narrow (U+202F) spaces where browsers put plain ones.\nconst plainSpaces = (text: string) => text.replace(/[\\u2009\\u202f]/g, \" \");\nconst between = (low: number, value: number, high: number) => Math.min(high, Math.max(low, value));\n/** A length in minutes as a share of the grid's hour height. */\nconst minutesTall = (minutes: number) => `calc(var(--ouro-time-grid-hour) * ${minutes / 60})`;\n\n/**\n * A day, work week or week of hours, with events placed by their times: the calendar grid of\n * a mail or meeting app. Each day has a column under a header, today's marked; all-day events\n * have a row of their own; hours run down the side in the locale's words. Events that overlap sit side by\n * side, each a button (a link with `href`) that shows its title first and is named for screen\n * readers by the words it shows, in their order, then its day and its status (\"Design review,\n * 9:00 – 10:00 AM, Thursday, needs your answer\"). Its lines are separate words even where a column\n * stacks them, so the name holds what it shows and a speech-input user can say it to press it\n * (WCAG 2.5.3, Label in Name). The grid is one Tab stop: the arrow keys move through events in time\n * order (Up and Down) and across days (Left and Right), Home and End go to the first and the\n * last, and Enter opens one. It opens scrolled to now or to the working day (to today's first\n * event when now is before it), and a now line\n * runs across today, under events so it never crosses their text.\n *\n * Use `Calendar` instead to pick a date from a month, and `Table` or `ItemGroup` for an agenda\n * list of events.\n *\n * @group Data\n * @see https://ui.ouroboros.bot/docs/time-grid\n *\n * @example\n * <TimeGrid\n *   label=\"Team calendar\"\n *   date=\"2026-03-12\"\n *   view=\"work-week\"\n *   events={[{ id: \"1\", title: \"Design review\", start: \"2026-03-12T09:00:00Z\", end: \"2026-03-12T10:00:00Z\", status: \"unanswered\" }]}\n *   onEventSelect={(event) => open(event.id)}\n *   className=\"h-[40rem]\"\n * />\n * @claim \"Each day has a column\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > draws a week of days from the locale's first day, each a list named by its date, today marked)\n * @claim \"Its lines are separate words\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid label in name > shows each event's lines as words its name holds in order, on one line, two or three) verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid label in name > the same event with its lines run together fails the rule, so the check can fail)\n * @claim \"Events that overlap sit side\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > shares a day's width between overlapping events)\n * @claim \"It opens scrolled to now\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > runs the now line across today, under the events, with the time beside it)\n * @claim \"It opens scrolled to now\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > opens at today's first event when now is before it, rather than at empty hours before now)\n */\nexport function TimeGrid(props: TimeGridProps): JSX.Element {\n  const {\n    label,\n    events,\n    date,\n    view: viewProp = \"week\",\n    timeZone,\n    locale = \"en-US\",\n    now: nowProp,\n    workingHours: workingHoursProp,\n    selectedId,\n    onEventSelect,\n    backgroundEvents = noEvents,\n    backgroundLabel = \"Other calendars\",\n    stackLabel = (count: number) => `${count} events`,\n    expandedId,\n    renderDaySummary,\n    onSlotSelect,\n    slotMinutes: slotProp = 30,\n    allDayLabel = \"All day\",\n    statusLabels,\n    nowAdornment,\n    className,\n    ref,\n    style,\n    onKeyDown: onKeyDownProp,\n    onDateChange,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    defaultView,\n    defaultDate,\n    onSelectEvent,\n    onSelectSlot,\n    scrollToTime,\n    ...rest\n  } = props;\n  const view = oneOf(views, viewProp, \"week\");\n  const slotMinutes = slotSizes.includes(slotProp) ? slotProp : 30;\n  const workingHours =\n    workingHoursProp && workingHoursProp.start >= 0 && workingHoursProp.end <= 24 && workingHoursProp.start < workingHoursProp.end ? workingHoursProp : defaultWorkingHours;\n  const nowGiven = toInstant(nowProp ?? Number.NaN);\n\n  // The reader's time zone and clock are the browser's: the server and hydration write UTC with\n  // no now, so the markup matches wherever the server runs; the browser then fills them in.\n  const hydrated = useSyncExternalStore(subscribeNever, inBrowser, onServer);\n  const ticking = useSyncExternalStore(nowGiven ? subscribeNever : clock.subscribe, clock.read, serverNow);\n  const nowTime = nowGiven ? nowGiven.getTime() : ticking;\n  const zone = timeZone ?? (hydrated ? undefined : \"UTC\");\n\n  const days = useMemo(() => (isIsoDate(date) ? viewDays(date, view, locale) : []), [date, view, locale]);\n  const weekend = weekendDays(locale);\n  const formats = useMemo(\n    () => ({\n      clock: zonedClock(zone),\n      hour: new Intl.DateTimeFormat(locale, { hour: \"numeric\", timeZone: \"UTC\" }),\n      time: new Intl.DateTimeFormat(locale, { hour: \"numeric\", minute: \"2-digit\", timeZone: zone }),\n      acrossDays: new Intl.DateTimeFormat(locale, { weekday: \"long\", month: \"long\", day: \"numeric\", hour: \"numeric\", minute: \"2-digit\", timeZone: zone }),\n      weekdayShort: new Intl.DateTimeFormat(locale, { weekday: \"short\", timeZone: \"UTC\" }),\n      weekdayLong: new Intl.DateTimeFormat(locale, { weekday: \"long\", timeZone: \"UTC\" }),\n      dayNumber: new Intl.DateTimeFormat(locale, { day: \"numeric\", timeZone: \"UTC\" }),\n      fullDay: new Intl.DateTimeFormat(locale, { weekday: \"long\", month: \"long\", day: \"numeric\", timeZone: \"UTC\" }),\n    }),\n    [zone, locale],\n  );\n  const nowAt = nowTime > 0 ? formats.clock.at(nowTime) : null;\n  const todayIndex = nowAt ? days.indexOf(nowAt.day) : -1;\n\n  const words = { ...defaultStatusLabels, ...statusLabels };\n  // Two times of day. Across midnight Intl would add both dates, so the times are joined instead. Node's ICU spaces a\n  // range with thin and narrow spaces where browsers put plain ones, so a server's range would not hydrate: it is\n  // written with plain spaces everywhere (plainSpaces).\n  const rangeText = (format: Intl.DateTimeFormat, start: Date, end: Date) =>\n    formats.clock.at(start.getTime()).day === formats.clock.at(end.getTime()).day\n      ? plainSpaces(format.formatRange(start, end))\n      : `${format.format(start)} – ${format.format(end)}`;\n  // The events cut into what each shown day draws, in the order the arrow keys take them. Laid out once per change\n  // to the events, the days or their formats, not on every render (an arrow key, a clock tick, a measure).\n  const { pieces, problems, allDay, timed, behind, hasBackground } = useMemo(() => {\n    const problems: DevWarning[] = [];\n    const pieces: Piece[] = [];\n    const allDaySpans: Array<{ key: string; first: number; last: number }> = [];\n    const timedItems: Array<Array<{ key: string; start: number; end: number }>> = days.map(() => []);\n    // An all-day event's days: its weekday, or the dates it runs between.\n    const daysText = (first: string, last: string) => (first === last ? formats.weekdayLong.format(utcDate(first)) : plainSpaces(formats.fullDay.formatRange(utcDate(first), utcDate(last))));\n    // The shown days from `from` to `to`, as indexes, or null when none of them shows.\n    const spanOf = (from: string, to: string) => {\n      const first = days.findIndex((day) => day >= from);\n      const last = days.findLastIndex((day) => day <= to);\n      return first === -1 || first > last ? null : { first, last };\n    };\n    const backgroundItems: Array<Array<{ key: string; start: number; end: number }>> = days.map(() => []);\n    const place = (list: readonly TimeGridEvent[], background: boolean) => {\n      const seen = new Set<string>();\n      const prefix = background ? \"bg:\" : \"\";\n      for (const [index, event] of list.entries()) {\n        // A repeated id still gets keys of its own, so React keeps every event.\n        const id = seen.has(event.id) ? `${event.id}#${index}` : event.id;\n        const status = oneOf(statuses, event.status, \"busy\");\n        if (process.env.NODE_ENV !== \"production\" && id !== event.id) problems.push([`two ${background ? \"background events\" : \"events\"} have id \"${event.id}\"`, \"give each event its own id\"]);\n        seen.add(event.id);\n        if (isIsoDate(event.start)) {\n          if (background) {\n            /* istanbul ignore else @preserve -- the else path exists only in production bundles */\n            if (process.env.NODE_ENV !== \"production\") problems.push([`background event \"${event.id}\" is all day, and background events are timed`, \"pass it in events, or give it a start and end time\"]);\n            continue;\n          }\n          const startsOn = event.start;\n          // Stryker disable next-line EqualityOperator: an end on the start day is the start day either way\n          const endsOn = isIsoDate(event.end) && event.end > startsOn ? event.end : startsOn;\n          const span = spanOf(startsOn, endsOn);\n          if (!span) continue;\n          const key = `all:${id}`;\n          pieces.push({ key, event, status, background, day: span.first, start: -1, end: dayLength, when: [daysText(startsOn, endsOn), allDayLabel] });\n          allDaySpans.push({ key, ...span });\n          continue;\n        }\n        const start = toInstant(event.start);\n        const end = toInstant(event.end ?? Number.NaN);\n        /* istanbul ignore else @preserve -- the else path exists only in production bundles; scripts/dev-strip.test.mjs covers it */\n        if (process.env.NODE_ENV !== \"production\") {\n          if (!start) problems.push([`event \"${event.id}\" has start=${JSON.stringify(event.start)}, which is not a date`, '{ start: \"2026-03-12T09:00:00Z\" }, or start: \"2026-03-12\" for all day']);\n          else if (!end) problems.push([`event \"${event.id}\" has no end`, '{ start, end: \"2026-03-12T10:00:00Z\" }']);\n          else if (end < start) problems.push([`event \"${event.id}\" ends before it starts`, \"{ start, end } with end after start\"]);\n        }\n        if (!start || !end || end < start) continue;\n        const from = formats.clock.at(start.getTime());\n        const to = formats.clock.at(end.getTime());\n        // An event that ends at midnight ends on the day before.\n        const lastDay = to.minutes === 0 && end > start ? addDays(to.day, -1) : to.day;\n        // A day or more of time goes in the all-day row, across the days it covers; whole days from\n        // midnight read as all-day events do.\n        if (end.getTime() - start.getTime() >= dayLength * 60_000) {\n          if (background) {\n            /* istanbul ignore else @preserve -- the else path exists only in production bundles */\n            if (process.env.NODE_ENV !== \"production\") problems.push([`background event \"${event.id}\" lasts a day or more, and background events are shorter`, \"pass it in events, or give it a start and end time\"]);\n            continue;\n          }\n          const span = spanOf(from.day, lastDay);\n          if (!span) continue;\n          const key = `all:${id}`;\n          const when = from.minutes === 0 && to.minutes === 0 ? [daysText(from.day, lastDay), allDayLabel] : [plainSpaces(formats.acrossDays.formatRange(start, end))];\n          pieces.push({ key, event, status, background, day: span.first, start: -1, end: dayLength, when });\n          allDaySpans.push({ key, ...span });\n          continue;\n        }\n        // The time itself is heard as the event shows it, right after its title.\n        const when = from.day === lastDay ? [formats.weekdayLong.format(utcDate(from.day))] : [plainSpaces(formats.acrossDays.formatRange(start, end))];\n        days.forEach((day, column) => {\n          if (day < from.day || day > lastDay) return;\n          const key = `${prefix}${column}:${id}`;\n          const top = day === from.day ? from.minutes : 0;\n          const bottom = day === to.day ? to.minutes : dayLength;\n          pieces.push({ key, event, status, background, day: column, start: top, end: bottom, when });\n          (background ? backgroundItems : timedItems)[column]!.push({ key, start: top, end: bottom });\n        });\n      }\n    };\n    place(events, false);\n    place(backgroundEvents, true);\n    // A background event comes after the person's own that start with it.\n    pieces.sort((a, b) => a.day - b.day || a.start - b.start || Number(a.background) - Number(b.background) || b.end - a.end);\n    const allDay = allDayLanes(allDaySpans);\n    const timed = timedItems.map((items) => layoutDay(items));\n    const behind = backgroundItems.map((items) => layoutDay(items));\n    const hasBackground = backgroundItems.some((items) => items.length > 0);\n    return { pieces, problems, allDay, timed, behind, hasBackground };\n  }, [events, backgroundEvents, days, formats, allDayLabel]);\n\n  useAppearanceClassNameCheck(\n    \"TimeGrid\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? '<TimeGrid className=\"h-[40rem]\" />, and set colors in your theme\\'s CSS variables, or tone on an event'\n      : // Stryker disable next-line StringLiteral: production only; the check never runs there.\n        /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"TimeGrid\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !label && [\"label is required; it names the grid for screen readers\", '<TimeGrid label=\"Team calendar\">'],\n          !isIsoDate(date) && [`date=${JSON.stringify(String(date))} is not an ISO date (YYYY-MM-DD)`, '<TimeGrid date=\"2026-03-12\">'],\n          !(views as readonly string[]).includes(viewProp) && [`view=\"${String(viewProp)}\" is not a view; use \"day\", \"work-week\" or \"week\"`, '<TimeGrid view=\"week\">'],\n          nowProp !== undefined && !nowGiven && [`now=${JSON.stringify(nowProp)} is not a date`, \"<TimeGrid now={new Date()}>, or leave it out to follow the clock\"],\n          workingHoursProp !== undefined && workingHours !== workingHoursProp && [\n            `workingHours=${JSON.stringify(workingHoursProp)} is not a working day; start and end are hours from 0 to 24, start first`,\n            \"<TimeGrid workingHours={{ start: 8, end: 17 }}>\",\n          ],\n          slotMinutes !== slotProp && [`slotMinutes={${String(slotProp)}} is not a slot length; use 15, 30 or 60`, \"<TimeGrid slotMinutes={30}>\"],\n          ...problems,\n          ...[...events, ...backgroundEvents].flatMap((event): DevWarning[] => [\n            event.tone !== undefined && !(tones as readonly string[]).includes(event.tone) && [\n              `event \"${event.id}\": tone=\"${String(event.tone)}\" is not a tone; use \"primary\", \"secondary\", \"success\", \"warning\" or \"destructive\"`,\n              `{ tone: \"${Object.hasOwn(renamedTones, event.tone) ? renamedTones[event.tone] : \"primary\"}\" }`,\n            ],\n            event.status !== undefined && !(statuses as readonly string[]).includes(event.status) && [\n              `event \"${event.id}\": status=\"${String(event.status)}\" is not a status; use \"busy\", \"tentative\", \"free\", \"unanswered\" or \"cancelled\"`,\n              '{ status: \"tentative\" }',\n            ],\n            event.allDay !== undefined && [`event \"${event.id}\": allDay is not a field; an all-day event's start is a date`, '{ start: \"2026-03-12\" }'],\n            event.color !== undefined && [`event \"${event.id}\": color is not a field; colours come from the theme`, '{ tone: \"success\" }'],\n          ]),\n          defaultView !== undefined && [\"defaultView is not a prop; the app keeps the view\", '<TimeGrid view=\"work-week\">'],\n          defaultDate !== undefined && [\"defaultDate is not a prop; the app keeps the date\", '<TimeGrid date=\"2026-03-12\">'],\n          onSelectEvent !== undefined && [\"onSelectEvent is not a prop\", \"<TimeGrid onEventSelect={(event) => open(event.id)}>\"],\n          onSelectSlot !== undefined && [\"onSelectSlot is not a prop\", \"<TimeGrid onSlotSelect={({ start, end }) => create(start, end)}>\"],\n          scrollToTime !== undefined && [\"scrollToTime is not a prop; the grid opens at now or at the working day's start\", \"<TimeGrid workingHours={{ start: 8, end: 17 }}>\"],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  // A week's background events are bars too thin for text; a day has room to label them.\n  const labelBackground = view === \"day\";\n  // In a day, a stack of background events too narrow to label each is drawn as one count that\n  // opens their list. It needs the lane's width, which only a measure knows; server HTML, and\n  // the first render before it, draw each event.\n  const [laneWidth, setLaneWidth] = useState(0);\n  // The stacks in each day, and each folded event's stack by its key (the stack goes by its first event's key):\n  // worked out once per layout and lane width.\n  const { stacks, stackOf } = useMemo(() => {\n    const stacks = behind.map((placements) =>\n      // Stryker disable next-line ConditionalExpression,EqualityOperator: an unmeasured lane is measured before the first paint, which decides either way.\n      labelBackground && laneWidth > 0\n        ? // Stryker disable next-line ConditionalExpression,EqualityOperator,ArithmeticOperator: a lone event spans the whole lane, at least 7rem, so it is never too narrow; one exactly at the minimum reads either way; an event spread over columns sits beside narrower ones.\n          stacksOf(placements).filter((stack) => stack.length > 1 && stack.some((placed) => (laneWidth * placed.span) / placed.columns < stackMinWidth))\n        : [],\n    );\n    return { stacks, stackOf: new Map(stacks.flat().flatMap((stack) => stack.map((placed) => [placed.key, stack] as const))) };\n  }, [behind, labelBackground, laneWidth]);\n  const reachable = pieces.filter((piece) => (stackOf.get(piece.key)?.[0]!.key ?? piece.key) === piece.key);\n\n  // The event with the Tab stop: the last one moved to, else the selected one, else the first.\n  const [active, setActive] = useState<string | null>(null);\n  const stopFor = (key: string | undefined) => stackOf.get(key as string)?.[0]!.key ?? key;\n  const tabStop = stopFor(pieces.find((piece) => piece.key === active)?.key ?? pieces.find((piece) => piece.event.id === selectedId)?.key ?? pieces[0]?.key);\n\n  const rootRef = useRef<HTMLDivElement | null>(null);\n  const setRoot = (element: HTMLDivElement | null) => {\n    rootRef.current = element;\n    if (typeof ref === \"function\") return ref(element);\n    if (ref) ref.current = element;\n  };\n\n  // Open at now when today shows, else half an hour before the working day: once for each set\n  // of days, and again when today moves (the browser first knows the time, or midnight passes).\n  // Before today's first event, open at it instead, as at the working day, so the grid does not\n  // open on empty hours before now; now stays in view when the event is close.\n  const scrollKey = `${days[0]}:${days.length}:${todayIndex}`;\n  // Where today's first event starts, in minutes, or -1 with none today, which is never after now.\n  const firstToday = todayIndex >= 0 && timed[todayIndex]!.length > 0 ? Math.min(...timed[todayIndex]!.map((placed) => placed.top)) : -1;\n  // Stryker disable next-line EqualityOperator,ConditionalExpression: any form of this flag changes exactly when today gains or loses its events, which is all the scroll reads it for.\n  const noneToday = firstToday < 0;\n  // Where the grid last opened, so today's events arriving after it opened (fetched after mount)\n  // move it once more, unless the reader has scrolled since.\n  const opened = useRef<{ key: string; top: number } | null>(null);\n  useLayoutEffect(() => {\n    const viewport = rootRef.current!.querySelector<HTMLElement>(\"[data-scroll-viewport]\")!;\n    const body = rootRef.current!.querySelector<HTMLElement>(\"[data-ouro-time-grid-body]\")!;\n    // The observer's first callback runs after layout and before the first paint, so the grid opens scrolled and the commit reads nothing.\n    const open = () => {\n      // Stryker disable next-line EqualityOperator: a scroll of exactly a pixel is a rounding either way.\n      if (opened.current?.key === scrollKey && Math.abs(viewport.scrollTop - opened.current.top) > 1) return;\n      const minutes = todayIndex < 0 ? workingHours.start * 60 - 30 : firstToday > nowAt!.minutes ? Math.max(nowAt!.minutes - 90, firstToday - 30) : nowAt!.minutes - 90;\n      viewport.scrollTop = (between(0, minutes, dayLength) / dayLength) * body.offsetHeight;\n      opened.current = { key: scrollKey, top: viewport.scrollTop };\n    };\n    const observer = new ResizeObserver(() => {\n      // Stryker disable next-line CallExpression: a later resize that runs open again lands on the place the reader left, which its guard keeps.\n      observer.disconnect();\n      open();\n    });\n    observer.observe(body);\n    // Stryker disable next-line ArrowFunction: once the grid is gone, nothing reads what the observer would set.\n    return () => observer.disconnect();\n    // Only the days shown, whether today is among them, and whether today has events move the scroll.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [scrollKey, noneToday]);\n\n  // In a grid taller than a day, the hours grow to share the room under the header, so the day\n  // ends at the grid's foot rather than above it. Neither height depends on the hours'.\n  const summaries = Boolean(renderDaySummary);\n  useLayoutEffect(() => {\n    const root = rootRef.current!;\n    const viewport = root.querySelector<HTMLElement>(\"[data-scroll-viewport]\")!;\n    const head = root.querySelector<HTMLElement>(\"[data-ouro-time-grid-head]\")!;\n    const fill = () => {\n      const headHeight = head.offsetHeight;\n      // The app's day summaries make the header as tall as they are, which only a measure knows; events scrolled into view stop below it.\n      if (summaries) root.style.setProperty(\"--ouro-time-grid-head\", `${headHeight}px`);\n      root.style.setProperty(\"--ouro-time-grid-fill\", `${(viewport.clientHeight - headHeight) / 24}px`);\n    };\n    const observer = new ResizeObserver(fill);\n    // Stryker disable next-line CallExpression: a change that resizes the room in a test resizes the header's sticky box with it, which measures again.\n    observer.observe(viewport);\n    observer.observe(head);\n    // Stryker disable next-line ArrowFunction: once the grid is gone, nothing reads what the observer would set.\n    return () => observer.disconnect();\n  },\n  [summaries]);\n\n  // The day's background lane, measured for its stacks (above). Every day's lane is as wide.\n  const hasLane = labelBackground && hasBackground;\n  useLayoutEffect(() => {\n    if (!hasLane) return;\n    const lane = rootRef.current!.querySelector<HTMLElement>(\"[data-ouro-time-grid-background]\")!;\n    const measure = () => setLaneWidth(lane.getBoundingClientRect().width);\n    const observer = new ResizeObserver(measure);\n    observer.observe(lane);\n    // Stryker disable next-line ArrowFunction: once the lane is gone, nothing reads what the observer would set.\n    return () => observer.disconnect();\n  }, [hasLane]);\n\n  const focusPiece = (key: string) => {\n    setActive(key);\n    rootRef.current!.querySelector<HTMLElement>(`[data-ouro-event-key=\"${CSS.escape(key)}\"]`)!.focus();\n  };\n\n  const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n    onKeyDownProp?.(event);\n    if (onDateChange && !event.defaultPrevented) {\n      const shift = periodShift(event, view);\n      // ⌥⇧Y by its physical key, since Option changes the character on a Mac.\n      const today = event.altKey && event.shiftKey && !event.ctrlKey && !event.metaKey && event.code === \"KeyY\";\n      if (shift !== 0 || today) {\n        event.preventDefault();\n        onDateChange(today ? todayOn(formats.clock) : addDays(date, shift));\n        return;\n      }\n    }\n    const key = (event.target as HTMLElement).dataset.ouroEventKey;\n    // ⌘↑ and ⌘↓ on a Mac are its Home and End. Shift changes nothing here.\n    const pressed = navigationKey({ key: event.key, altKey: event.altKey, ctrlKey: event.ctrlKey, metaKey: event.metaKey, shiftKey: false });\n    if (key === undefined || event.defaultPrevented) return;\n    // A modified key the grid leaves alone is null, which moves to no event.\n    const next = stepTo(reachable, key, pressed as string, getComputedStyle(event.currentTarget).direction === \"rtl\");\n    if (next === undefined) return;\n    event.preventDefault();\n    focusPiece(next);\n  };\n\n  const [hover, setHover] = useState<{ day: number; minutes: number } | null>(null);\n  const slotAt = (event: MouseEvent<HTMLElement>) => {\n    const box = event.currentTarget.getBoundingClientRect();\n    const minutes = Math.floor((((event.clientY - box.top) / box.height) * dayLength) / slotMinutes) * slotMinutes;\n    return between(0, minutes, dayLength - slotMinutes);\n  };\n  // The preview spans one slot across its day's column, so it is left off where one of the person's own timed\n  // events covers that slot: the card (opaque, above the slots) would hide its text. Background events sit in\n  // the lane the preview starts after, so they never cover it.\n  const coveredAt = (column: number, from: number) => timed[column]!.some((placed) => placed.top < from + slotMinutes && placed.bottom > from);\n\n  const columns = `var(--ouro-time-grid-gutter) repeat(${Math.max(days.length, 1)}, minmax(0, 1fr))`;\n  const lanes = allDay.reduce((most, piece) => Math.max(most, piece.lane + 1), 1);\n  const nowTop = nowAt ? minutesTall(nowAt.minutes) : undefined;\n  // The now label leaves out AM and PM, which the hours beside it already show, so it fits the gutter.\n  const nowText = formats.time\n    .formatToParts(nowTime)\n    .filter((part) => part.type !== \"dayPeriod\")\n    .map((part) => part.value)\n    .join(\"\")\n    .trim();\n  const hourLabels = Array.from({ length: 23 }, (_, index) => index + 1).filter((hour) => !nowAt || todayIndex < 0 || Math.abs(hour * 60 - nowAt.minutes) > 20);\n\n  const renderEvent = (piece: Piece, placed?: { top: number; bottom: number }) => {\n    const { event, status, background } = piece;\n    const bar = background && !labelBackground;\n    const tone = oneOf(tones, event.tone, \"primary\");\n    const lines = placed ? lineCount(placed.bottom - placed.top) : 1;\n    const start = placed ? toInstant(event.start)! : null;\n    const end = placed ? toInstant(event.end!)! : null;\n    // The time as the event shows it, for its name: one line shows only the start, so the end follows it there.\n    const shownTime = !start ? null : lines > 1 || start.getTime() === end!.getTime() ? rangeText(formats.time, start, end!) : `${formats.time.format(start)} – ${formats.time.format(end!)}`;\n    const content =\n      !placed || lines === 1 ? (\n        <span className=\"truncate\">\n          <span dir=\"auto\" className=\"font-medium\">\n            {event.title}\n          </span>\n          {start ? (\n            <>\n              {\" \"}\n              <span className={mutedClass}>{formats.time.format(start)}</span>\n            </>\n          ) : null}\n        </span>\n      ) : (\n        // A space between the lines, which a column doesn't draw, keeps them separate words in the\n        // event's visible text, as its name says them (WCAG 2.5.3, Label in Name).\n        <>\n          <span dir=\"auto\" className=\"line-clamp-(--ouro-lines) font-medium @max-[6rem]/event:block @max-[6rem]/event:truncate\" style={{ \"--ouro-lines\": Math.max(1, lines - (lines >= 3 && event.description ? 2 : 1)) } as CSSProperties}>\n            {event.title}\n          </span>{\" \"}\n          <span className={mutedLineClass}>{rangeText(formats.time, start!, end!)}</span>\n          {lines >= 3 && event.description ? (\n            <>\n              {\" \"}\n              <span dir=\"auto\" className={mutedLineClass}>\n                {event.description}\n              </span>\n            </>\n          ) : null}\n        </>\n      );\n    const shared = {\n      \"data-ouro-event-key\": piece.key,\n      \"data-status\": status,\n      \"data-tone\": tone,\n      \"data-background\": background ? \"\" : undefined,\n      tabIndex: piece.key === tabStop ? 0 : -1,\n      \"aria-label\": spoken(piece, shownTime, !bar && lines >= 3, background ? backgroundLabel : null, words[status]),\n      \"aria-current\": event.id === selectedId ? (\"true\" as const) : undefined,\n      \"aria-expanded\": event.id === expandedId ? true : undefined,\n      \"aria-haspopup\": event.id === expandedId ? (\"dialog\" as const) : undefined,\n      className: cn(\n        eventClass,\n        eventHitClass,\n        bar ? backgroundBarClass : [toneBarClass[tone], background ? backgroundFillClass : status === \"busy\" ? toneFillClass[tone] : plainFillClass, statusClass[status]],\n        placed ? timedClass : allDayClass,\n        // Under the person's own events, so a background event's touch target never covers them.\n        background && \"z-[9]\",\n      ),\n      onClick: (click: MouseEvent<HTMLElement>) => {\n        setActive(piece.key);\n        onEventSelect?.(event, { element: click.currentTarget, background });\n      },\n    };\n    const body = (\n      <>\n        <TouchTarget />\n        {bar ? (\n          <span aria-hidden=\"true\" data-ouro-time-grid-bar=\"\" className={cn(backgroundBarFillClass, toneSwatchClass[tone], barStatusClass[status])} />\n        ) : (\n          <span className=\"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden\">{content}</span>\n        )}\n      </>\n    );\n    const control =\n      event.href === undefined ? (\n        <button type=\"button\" data-ouro-control=\"time-grid\" data-ouro-part=\"event\" {...shared}>\n          {body}\n        </button>\n      ) : (\n        <RouterLink href={event.href} data-ouro-control=\"time-grid\" data-ouro-part=\"event-link\" {...shared}>\n          {body}\n        </RouterLink>\n      );\n    // A bar names itself to a mouse and to keyboard focus; screen readers hear its name.\n    return bar ? (\n      <Tooltip\n        content={\n          <>\n            <span className=\"block tabular-nums\">{rangeText(formats.time, start!, end!)}</span>\n            <span dir=\"auto\" className=\"block font-medium\">\n              {event.title}\n            </span>\n          </>\n        }\n      >\n        {control}\n      </Tooltip>\n    ) : (\n      control\n    );\n  };\n\n  // One day's events, each in its place among those it overlaps.\n  const placedItems = (placements: ReadonlyArray<DayPlacement<string>>) =>\n    placements.map((placed) => {\n      const share = 100 / placed.columns;\n      return (\n        <li\n          key={placed.key}\n          className=\"pointer-events-auto absolute pe-px\"\n          style={{\n            top: minutesTall(placed.top),\n            height: `calc(${minutesTall(placed.bottom - placed.top)} - 1px)`,\n            insetInlineStart: `${placed.column * share}%`,\n            width: `${placed.span * share}%`,\n          }}\n        >\n          {renderEvent(pieces.find((piece) => piece.key === placed.key)!, placed)}\n        </li>\n      );\n    });\n\n  // A stack of a day's background events drawn as one: their count and their time, which opens\n  // their list, each item choosing its event as a press on it would.\n  const stackItem = (stack: ReadonlyArray<DayPlacement<string>>) => {\n    const members = stack.map((placed) => pieces.find((piece) => piece.key === placed.key)!);\n    const key = stack[0]!.key;\n    const top = Math.min(...stack.map((placed) => placed.top));\n    const bottom = Math.max(...stack.map((placed) => placed.bottom));\n    const starts = members.map((piece) => toInstant(piece.event.start)!.getTime());\n    const ends = members.map((piece) => toInstant(piece.event.end!)!.getTime());\n    const element = () => rootRef.current!.querySelector<HTMLElement>(`[data-ouro-event-key=\"${CSS.escape(key)}\"]`)!;\n    return (\n      <li key={key} className=\"pointer-events-auto absolute inset-x-0 pe-px\" style={{ top: minutesTall(top), height: `calc(${minutesTall(bottom - top)} - 1px)` }}>\n        <Menu\n          side=\"right\"\n          trigger={\n            <button\n              type=\"button\"\n              data-ouro-control=\"time-grid\"\n              data-ouro-part=\"stack\"\n              data-ouro-event-key={key}\n              data-background=\"\"\n              tabIndex={key === tabStop ? 0 : -1}\n              aria-current={members.some((piece) => piece.event.id === selectedId) ? \"true\" : undefined}\n              // The arrows move through the grid, as from any event; Enter and Space press it, which opens the list.\n              onKeyDown={(event: KeyboardEvent<HTMLButtonElement>) => (event as typeof event & { preventBaseUIHandler: () => void }).preventBaseUIHandler()}\n              onFocus={() => setActive(key)}\n              className={cn(eventClass, eventHitClass, toneBarClass.secondary, backgroundFillClass, statusClass.busy, timedClass, \"z-[9]\")}\n            >\n              <TouchTarget />\n              <span className=\"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden\">\n                <span className=\"truncate font-medium\">{stackLabel(stack.length)}</span>{\" \"}\n                <span className={mutedLineClass}>{rangeText(formats.time, new Date(Math.min(...starts)), new Date(Math.max(...ends)))}</span>\n              </span>\n            </button>\n          }\n        >\n          {members.map((piece) => (\n            <MenuItem key={piece.key} href={piece.event.href} onClick={() => onEventSelect?.(piece.event, { element: element(), background: true })}>\n              <span dir=\"auto\">{piece.event.title}</span>\n              <span className={mutedClass}> {rangeText(formats.time, toInstant(piece.event.start)!, toInstant(piece.event.end!)!)}</span>\n            </MenuItem>\n          ))}\n        </Menu>\n      </li>\n    );\n  };\n\n  return (\n    <div\n      {...rest}\n      ref={setRoot}\n      data-ouro=\"time-grid\"\n      data-view={view}\n      className={cn(\n        \"relative box-border flex h-144 min-h-0 min-w-0 flex-col text-foreground\",\n        \"[--ouro-time-grid-gutter:4rem] [--ouro-time-grid-hour:max(3rem,var(--ouro-time-grid-fill,0px))] [--ouro-time-grid-tint:14%] pointer-coarse:[--ouro-time-grid-hour:max(3.5rem,var(--ouro-time-grid-fill,0px))] dark:[--ouro-time-grid-tint:24%]\",\n        className,\n      )}\n      style={\n        {\n          ...(renderDaySummary ? {} : { \"--ouro-time-grid-head\": `${3.75 + lanes * 1.5}rem` }),\n          \"--ouro-time-grid-lane\": labelBackground ? \"max(7rem, 40%)\" : \"0.75rem\",\n          ...style,\n        } as CSSProperties\n      }\n      onKeyDown={onKeyDown}\n    >\n      <ScrollArea label={label} className=\"min-h-0 flex-1\">\n        <div data-ouro-time-grid-head=\"\" className=\"sticky top-0 z-40 grid border-0 border-b border-solid border-border bg-background\" style={{ gridTemplateColumns: columns }}>\n          <div aria-hidden=\"true\" />\n          {days.map((day, index) => (\n            <div\n              key={day}\n              aria-hidden=\"true\"\n              data-today={index === todayIndex ? \"\" : undefined}\n              className=\"group/day @container/day min-w-0 border-0 border-s border-solid border-border\"\n            >\n              <span className=\"flex min-w-0 items-center gap-1.5 overflow-hidden px-2 py-1.5 @max-[4.5rem]/day:flex-col @max-[4.5rem]/day:gap-0.5 @max-[4.5rem]/day:px-0.5\">\n              <span className=\"inline-flex size-7 shrink-0 items-center justify-center rounded-full text-base leading-none font-semibold tabular-nums group-data-today/day:bg-primary group-data-today/day:text-primary-foreground forced-colors:group-data-today/day:border-2 forced-colors:group-data-today/day:border-solid\">\n                {\n                  // Stryker disable next-line ConditionalExpression: in the locales tested the day comes first; the search is for one where it does not\n                  formats.dayNumber.formatToParts(utcDate(day)).find((part) => part.type === \"day\")!.value\n                }\n              </span>\n              <span className=\"truncate text-xs text-muted-foreground group-data-today/day:font-medium group-data-today/day:text-foreground\">{formats.weekdayShort.format(utcDate(day))}</span>\n              </span>\n            </div>\n          ))}\n          {renderDaySummary ? (\n            <>\n              <div aria-hidden=\"true\" />\n              {days.map((day) => (\n                <div key={day} role=\"group\" aria-label={formats.fullDay.format(utcDate(day))} data-ouro-time-grid-summary=\"\" className=\"min-w-0 border-0 border-s border-solid border-border px-2 pb-1 text-xs text-muted-foreground\">\n                  {renderDaySummary(day)}\n                </div>\n              ))}\n            </>\n          ) : null}\n          <div aria-hidden=\"true\" className=\"flex items-start justify-end py-1 pe-2 text-[11px] leading-5 text-muted-foreground\">\n            {allDayLabel}\n          </div>\n          {allDay.length > 0 ? (\n            <ul\n              role=\"list\"\n              aria-label={allDayLabel}\n              className=\"m-0 grid list-none auto-rows-[1.375rem] gap-y-0.5 p-0 py-1\"\n              style={{ gridColumn: \"2 / -1\", gridTemplateColumns: `repeat(${Math.max(days.length, 1)}, minmax(0, 1fr))`, minHeight: `${lanes * 1.5 + 0.5}rem` }}\n            >\n              {allDay.map((span) => (\n                <li key={span.key} className=\"min-w-0 px-0.5\" style={{ gridColumn: `${span.first + 1} / ${span.last + 2}`, gridRow: span.lane + 1 }}>\n                  {renderEvent(pieces.find((piece) => piece.key === span.key)!)}\n                </li>\n              ))}\n            </ul>\n          ) : (\n            <div aria-hidden=\"true\" style={{ minHeight: \"2rem\" }} />\n          )}\n        </div>\n        <div data-ouro-time-grid-body=\"\" className=\"relative grid\" style={{ gridTemplateColumns: columns, height: minutesTall(dayLength) }}>\n          <div aria-hidden=\"true\" className=\"relative\">\n            {hourLabels.map((hour) => (\n              <span key={hour} className=\"absolute end-2 -translate-y-1/2 text-[11px] leading-4 whitespace-nowrap text-muted-foreground tabular-nums\" style={{ top: minutesTall(hour * 60) }}>\n                {formats.hour.format(Date.UTC(2026, 0, 1, hour))}\n              </span>\n            ))}\n            {nowAt && todayIndex >= 0 ? (\n              <span data-ouro-time-grid-now-label=\"\" className=\"absolute end-1 flex -translate-y-1/2 flex-col items-end gap-0.5\" style={{ top: nowTop }}>\n                {nowAdornment ? <span className=\"absolute end-0 bottom-full mb-0.5\">{nowAdornment}</span> : null}\n                <span className=\"rounded-ouro-sm bg-background px-0.5 text-[11px] leading-4 font-semibold whitespace-nowrap text-destructive tabular-nums\">\n                  {nowText}\n                </span>\n              </span>\n            ) : null}\n          </div>\n          {days.map((day, index) => {\n            const off = weekend.includes(utcDate(day).getUTCDay());\n            return (\n              <div key={day} className=\"relative min-w-0 border-0 border-s border-solid border-border\">\n                <div\n                  aria-hidden=\"true\"\n                  className=\"pointer-events-none absolute inset-0 [background-image:linear-gradient(to_bottom,var(--border)_1px,transparent_1px),linear-gradient(to_bottom,color-mix(in_oklab,var(--border)_50%,transparent)_1px,transparent_1px)] [background-position:0_0,0_calc(var(--ouro-time-grid-hour)/2)] [background-size:100%_var(--ouro-time-grid-hour)]\"\n                />\n                {off ? (\n                  <div aria-hidden=\"true\" data-ouro-time-grid-off=\"\" className=\"pointer-events-none absolute inset-0 bg-[color-mix(in_oklab,var(--foreground)_4%,transparent)]\" />\n                ) : (\n                  <>\n                    <div aria-hidden=\"true\" data-ouro-time-grid-off=\"\" className=\"pointer-events-none absolute inset-x-0 top-0 bg-[color-mix(in_oklab,var(--foreground)_4%,transparent)]\" style={{ height: minutesTall(workingHours.start * 60) }} />\n                    <div aria-hidden=\"true\" data-ouro-time-grid-off=\"\" className=\"pointer-events-none absolute inset-x-0 bottom-0 bg-[color-mix(in_oklab,var(--foreground)_4%,transparent)]\" style={{ top: minutesTall(workingHours.end * 60) }} />\n                  </>\n                )}\n                {onSlotSelect ? (\n                  <div\n                    aria-hidden=\"true\"\n                    data-ouro-time-grid-slots=\"\"\n                    className=\"absolute inset-0 cursor-cell\"\n                    onPointerMove={(event: PointerEvent<HTMLDivElement>) => setHover(event.pointerType === \"mouse\" ? { day: index, minutes: slotAt(event) } : null)}\n                    onPointerLeave={() => setHover(null)}\n                    onClick={(event) => {\n                      const minutes = slotAt(event);\n                      onSlotSelect({ start: formats.clock.instant(day, minutes), end: formats.clock.instant(day, minutes + slotMinutes) });\n                    }}\n                  >\n                    {hover?.day === index && !coveredAt(index, hover.minutes) ? (\n                      <span\n                        data-ouro-time-grid-slot=\"\"\n                        className={cn(\n                          \"pointer-events-none absolute box-border rounded-ouro-md border border-dashed border-primary px-1.5 text-[11px] leading-4 text-muted-foreground\",\n                          hasBackground ? \"start-(--ouro-time-grid-lane) ms-0.5 end-0.5\" : \"inset-x-0.5\",\n                        )}\n                        style={{ top: minutesTall(hover.minutes), height: minutesTall(slotMinutes) }}\n                      >\n                        {formats.time.format(formats.clock.instant(day, hover.minutes))}\n                      </span>\n                    ) : null}\n                  </div>\n                ) : null}\n                {nowAt && todayIndex >= 0 ? (\n                  <div\n                    aria-hidden=\"true\"\n                    data-ouro-time-grid-now={index === todayIndex ? \"today\" : \"\"}\n                    className={cn(\n                      \"pointer-events-none absolute inset-x-0 z-5 -translate-y-px border-0 border-t border-solid\",\n                      index === todayIndex ? \"border-t-2 border-destructive\" : \"border-destructive/35\",\n                    )}\n                    style={{ top: nowTop }}\n                  >\n                    {index === todayIndex ? <span className=\"absolute -start-1.5 -top-1.5 size-2.5 rounded-full bg-destructive forced-colors:bg-[CanvasText]\" /> : null}\n                  </div>\n                ) : null}\n                {timed[index]!.length > 0 ? (\n                  <ul\n                    role=\"list\"\n                    aria-label={formats.fullDay.format(utcDate(day))}\n                    aria-current={index === todayIndex ? \"date\" : undefined}\n                    className={cn(\"pointer-events-none absolute inset-0 m-0 list-none p-0\", hasBackground && \"start-(--ouro-time-grid-lane)\")}\n                  >\n                    {placedItems(timed[index]!)}\n                  </ul>\n                ) : null}\n                {behind[index]!.length > 0 ? (\n                  <ul\n                    role=\"list\"\n                    aria-label={`${formats.fullDay.format(utcDate(day))}, ${backgroundLabel}`}\n                    data-ouro-time-grid-background=\"\"\n                    className={cn(\n                      \"pointer-events-none absolute inset-y-0 start-0 m-0 box-border w-(--ouro-time-grid-lane) list-none p-0\",\n                      // A day's wide lane keeps apart from the person's own with a dashed edge.\n                      labelBackground && \"border-0 border-e border-dashed border-border\",\n                    )}\n                  >\n                    {placedItems(behind[index]!.filter((placed) => !stackOf.has(placed.key)))}\n                    {stacks[index]!.map(stackItem)}\n                  </ul>\n                ) : null}\n              </div>\n            );\n          })}\n        </div>\n      </ScrollArea>\n    </div>\n  );\n}\n\n/**\n * What a screen reader hears for an event: first the words it shows, in the order it shows them\n * (its title, its time and, when it has room, its description), then its day, what background\n * events are, its status and a description it has no room to show.\n * @claim \"What a screen reader hears for an event\" registry/ouro/components/ouro/time-grid/time-grid.test.tsx verify:testExists(registry/ouro/components/ouro/time-grid/time-grid.test.tsx::TimeGrid > shows the title first, then the time and the description as the event's height allows)\n */\nfunction spoken(piece: Piece, time: string | null, roomy: boolean, background: string | null, status: string): string {\n  const { description } = piece.event;\n  return [piece.event.title, time, roomy ? description : null, ...piece.when, background, status, roomy ? null : description].filter(Boolean).join(\", \");\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/time-grid/time-grid.tsx"
    }
  ],
  "docs": "A day, work week or week of hours, with events placed by their times: the calendar grid of a mail or meeting app. Import: import { TimeGrid } from \"@/components/ouro/time-grid/time-grid\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: button, calendar, kbd, local-date, menu, scroll-area, tooltip, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/time-grid.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}