{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "time-slot-picker",
  "title": "Time Slot Picker",
  "description": "Pick from the times somebody else has said are free: the offered slots arranged under the day they fall on, in a stated time zone, with the ones already taken still on show and the choice checked against the latest availability rather than assumed to still hold. Reach for it on any screen where a person picks a time out of what is left — booking an appointment, consultation or viewing; scheduling an interview, screening call or demo; a clinic, dentist, vet or salon; a delivery, collection or installation window; a meeting room, court, pitch, studio or piece of equipment; a test drive, fitting or tasting; a tutoring or coaching session; an exam, test centre or vaccination slot; a callback window on a support form; and the second step of every “pick a date, then pick a time” flow. Common asks it answers: “time slot picker react”, “appointment time picker react”, “booking slot component react”, “availability picker react”, “available times grid react”, “slot picker from api”, “shadcn time slot picker”, “shadcn booking component”, “shadcn appointment picker”, “calendly style time picker react”, “cal.com slot picker alternative”, “react time slot selection component”, “choose a time from available slots”, “timezone aware time slot picker”, “booking shows the wrong time timezone”, “slots grouped by day in the wrong timezone”, “utc slot appears on the previous day”, “slot one hour out daylight saving”, “duplicate 1:30 when the clocks go back”, “two slots show the same time dst”, “slot taken while user was booking”, “selected slot no longer available react”, “optimistic booking conflict ui”, “stale availability selected slot”, “disable booked time slots react”, “grey out unavailable times”, “no availability message booking ui”, “fully booked day message”, “empty day no slots ui”, “minimum notice period booking”, “lead time before booking react”, “hide past time slots today”, “date now hydration mismatch react”, “accessible time slot picker”, “listbox roving tabindex react”, “aria-selected time slot buttons”, “keyboard navigation time slots”, “予約 時間枠 選択 react”, “空き時間 選択 ui”, “予約枠 コンポーネント”, “タイムゾーン 予約 時刻 ずれ”, “枠が埋まった 表示”, “受付時間 選択 フォーム”, “面談 日程 時間 選択”. Official shadcn/ui has nothing of the kind, measured today rather than remembered. Fetching every entry in its registry — 65 listed, 62 fetchable, code-block, questionnaire and trace 404 on both style tracks — and searching all 223,287 bytes of files[].content, availability, booking, appointment, timeSlot, reserve, unavailable, capacity, waitlist and timezone are every one of them a zero hit. slot is not zero and is worth unfolding rather than rounding: it returns 444, and all 444 are shadcn's own data-slot mechanism — 386 the literal attribute, 58 more inside Tailwind variants such as has-data-[slot=alert-dialog-media] that select on it. Not one is a time slot. Its calendar is a react-day-picker wrapper that picks a day and has no notion of what is free within one. The decision everything else follows from: a slot is an instant, and the display zone is a separate, stated thing. Pass start with its offset and the component places it; the zone it shows the times in is a prop, defaults to the runtime's, and is printed under the picker, because the failure this component exists to prevent is a person turning up an hour out while every screen they saw looked right. Which calendar day a slot belongs to is then worked out in that zone and not in UTC — 23:30 UTC is half past eight the next morning in Tokyo, so grouping on the UTC date files it under a heading a day too early. The day key is built with a locale pinned to the Gregorian calendar and Latin digits, which is not fussiness: asked for the year of this instant, th-TH answers 2569, ja-JP-u-ca-japanese answers 8, ar-EG answers it in Arabic-Indic digits and fa-IR answers 1405-08-29, a different day of a different month. A timestamp that arrives without an offset is read in the display zone rather than on the machine, and reported. Date.parse has two different rules for the two offset-less forms — a date-time such as \"2026-11-20T09:00\" is read as machine-local, a date alone as UTC — so a server rendering this page and the browser that hydrates it disagree about the same string, which is a hydration mismatch that only shows up for people in other countries. slotIssues names it, along with an unreadable start, an end at or before its start, two slots sharing an id, and two bookable slots over the same time. Twice a year two different slots read exactly alike, and it is measured rather than imagined: 05:30 and 06:30 UTC on 1 November 2026 both format as “1:30 AM” in New York, because that hour comes round twice and both halves of it are ordinary bookable slots. Where two labels on a day collide the zone abbreviation goes on the ones that collide — EDT beside EST — and nowhere else. The other half is that availability is already out of date by the time it is read. A slot that was free when the page rendered is taken by somebody else a moment later, and the tick on screen then points at something that does not exist. Keeping it posts a booking the server will refuse; clearing it quietly loses the person's answer with nothing said. So the selection is reconciled against the latest slots on every render: what has gone comes out of the value, is named in a notice with its day as well as its time, is handed to onLostSelection, and — the part that actually matters — is left out of the hidden inputs, so a form never posts a slot somebody else holds. A taken slot stays in the list, reachable, marked aria-disabled rather than with the disabled attribute and carrying its reason, because “what about nine o'clock” and “there is nothing at nine” are different questions and only a slot that is still there can answer the first. A day with nothing to offer gets one of four sentences rather than a blank, and they are not interchangeable: no times at all, fully booked, these have passed, or nothing anywhere. A day whose times have all been and gone says so even when some of them had also been booked, because “fully booked” would tell the reader a cancellation might free one and nothing can. Past slots are hidden by default but the day's state is computed from what was offered, so a day emptied by that filter still says why it is empty instead of reporting itself as having nothing. And now is a prop, not a clock reading: a component that calls Date.now() renders one thing on the server and another in the browser a moment later, and can never be tested twice with the same answer. Left out, nothing is past and nothing is too soon. Three smaller things that each hide a real difference when they go the other way. A day that mixes lengths shows every slot as a range, because “9:00” and “9:00” are the half hour and the hour that start at the same minute; a day of one length shows start times, with the range still in the accessible name. A slot that ends at midnight stays on the day it started, since a slot runs up to its end and not through it, and reading the boundary itself files the last half hour of every day under tomorrow. And the whole list is one tab stop: a week of half hours is eighty tab presses otherwise, so it is a listbox with a roving tabindex, each day a group named by its heading, left and right walking the slots in time order and running on into the next day, up and down jumping a whole day over the ones with nothing on them, Home and End to the ends, and movement clamping rather than wrapping. Within this registry the neighbours are each the other way round or another grain: weekly-hours sets the opening times a business decides, where this picks from what is left of them; time-input types a time into a field; recurrence-input edits how often something repeats; date-range-preset picks a period to look at; month-picker and calendar-heatmap work a coarser grain; timezone-select chooses a zone rather than displaying in one; duration-input measures a length. None of them offers a set of times to choose between. The API: slots is { id?, start, end?, durationMinutes?, taken?, note?, reason? }[] and is required, because availability is the server's answer and a component that invented a grid of half hours would be offering times nobody can have; days lists calendar dates to show even when empty, which is the only way a day with nothing free can be shown at all; value and onValueChange make it controlled, or defaultValue uncontrolled, with multiple and max for more than one; timeZone, locale, hour12, dayFormat and a full labels object cover the display, and now, minLeadMinutes, hidePastSlots and defaultDurationMinutes cover what is bookable; name posts the surviving ids through a plain form or a server action. The hard parts are exported as pure functions so a confirmation screen, a reminder email, a server route or a test can have the same answers without mounting anything: resolveTimeSlots, reconcileSlotSelection, toggleSlotSelection, slotIssues, nextAvailableSlot and nextSlotFocus. Styled entirely with shadcn tokens (primary, primary-foreground, input, background, accent, accent-foreground, border, muted-foreground, destructive, ring) so it follows light and dark mode, and it ships zero npm dependencies — no date library, no time-zone library, no icon package.",
  "files": [
    {
      "path": "registry/ui/time-slot-picker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/**\n * One offered slot, as the server hands it over.\n *\n * This component never generates slots. Availability is the server's answer to \"what is still free\",\n * it depends on other people's bookings, and a component that invented a 9-to-5 grid of half hours\n * would be offering times nobody can have. So `slots` is required and the component only ever\n * arranges, labels and selects what it is given.\n */\nexport interface TimeSlot {\n  /**\n   * Stable identity, and what the value is made of. Defaults to the start instant in ISO form, which\n   * is unique as long as two slots do not start at the same moment — pass your own id when they can\n   * (two rooms, two practitioners, the same half hour).\n   */\n  id?: string\n  /**\n   * When the slot starts. A `Date`, epoch milliseconds, or an ISO 8601 string.\n   *\n   * Carry the offset — `\"2026-11-20T09:00:00Z\"` or `\"2026-11-20T09:00:00+09:00\"`. A string without\n   * one does not name a moment, and the two offset-less forms are not even read the same way by\n   * `Date.parse`: a date-time such as `\"2026-11-20T09:00\"` is read in the *machine's* zone, while a\n   * date alone, `\"2026-11-20\"`, is read as UTC. Both are accepted here and both are read in this\n   * component's `timeZone` instead, so the picker shows the same times on every machine — and both\n   * are reported by `slotIssues` so the shape can be fixed at the source rather than relied on.\n   */\n  start: string | number | Date\n  /** When it ends. Same forms as `start`. Takes precedence over `durationMinutes`. */\n  end?: string | number | Date\n  /** How long it runs, when the end is not spelled out. */\n  durationMinutes?: number\n  /** Already booked. The slot is still shown and still reachable, so a person can see it existed. */\n  taken?: boolean\n  /** Short extra text on the slot — \"2 left\", \"Online only\", a price. */\n  note?: string\n  /**\n   * Why this slot cannot be taken, in your own words. Shown and announced in place of the built-in\n   * reason, so \"Held for members until Friday\" reaches the person who needs it.\n   */\n  reason?: string\n}\n\n/** Why a slot refuses to be selected. `\"\"` when it is free to take. */\nexport type SlotBlock = \"\" | \"taken\" | \"past\" | \"lead\"\n\n/** A slot after parsing, with every label this component will show already computed. */\nexport interface ResolvedSlot {\n  id: string\n  /** Start as epoch milliseconds — the one representation that is the same everywhere. */\n  start: number\n  /** End as epoch milliseconds, or `null` when the caller only gave a start. */\n  end: number | null\n  /** Length in minutes, or `null` when there is no end to measure to. */\n  durationMinutes: number | null\n  /** The calendar day this slot starts on, `\"YYYY-MM-DD\"`, read in the display zone. */\n  dayKey: string\n  /** The start time as the locale writes it. */\n  startLabel: string\n  /** The end time as the locale writes it, or `\"\"` with no end. */\n  endLabel: string\n  /** Shown on the slot: the start alone, or the range when the day mixes lengths. */\n  label: string\n  /**\n   * The zone abbreviation, set only when two slots on the same day would otherwise read alike —\n   * which happens for real when the clocks go back and 1:30 comes round twice.\n   */\n  zoneLabel: string\n  /** The end falls on the next calendar day in the display zone. */\n  endsNextDay: boolean\n  taken: boolean\n  /** Starts in the past, measured against the `now` you passed — never against the clock. */\n  past: boolean\n  /** Starts too soon to be bookable, by `minLeadMinutes`. */\n  tooSoon: boolean\n  block: SlotBlock\n  /** `true` when it can be taken: nothing blocks it. */\n  selectable: boolean\n  /** Why it is blocked, ready to show — the caller's `reason` when they gave one. */\n  reason: string\n  note: string\n}\n\n/** Why a day has nothing to offer, which is not one message but four. */\nexport type DayState = \"available\" | \"fullyBooked\" | \"past\" | \"empty\"\n\nexport interface ResolvedDay {\n  /** `\"YYYY-MM-DD\"` in the display zone. */\n  key: string\n  /** The day as the locale writes it. */\n  label: string\n  /** The slots to show, in time order. Past ones are left out when `hidePastSlots` is on. */\n  slots: ResolvedSlot[]\n  /** How many of them can be taken. */\n  available: number\n  /** How many the caller offered for this day, including any the view is hiding. */\n  offered: number\n  state: DayState\n}\n\nexport interface SlotIssue {\n  kind:\n    | \"unparsable-start\"\n    | \"unparsable-end\"\n    | \"no-offset\"\n    | \"backwards\"\n    | \"duplicate-id\"\n    | \"overlap\"\n    | \"bad-day\"\n    | \"lead-without-now\"\n  /** The slot id, the day string, or `\"\"` for an issue about the call as a whole. */\n  subject: string\n  message: string\n}\n\nexport interface ResolvedTimeSlots {\n  /** The zone the times are shown in — the one asked for, or the runtime's if that was unusable. */\n  timeZone: string\n  /** That zone in words, for the caption: \"Japan Standard Time\". */\n  zoneName: string\n  days: ResolvedDay[]\n  /** Every shown slot id in reading order — what the arrow keys walk. */\n  order: string[]\n  byId: Record<string, ResolvedSlot>\n  /** How many slots can be taken across every day. */\n  available: number\n}\n\nexport interface TimeSlotPickerLabels {\n  /** Accessible name for the list of times. */\n  list: string\n  /** The caption under the picker. Gets the zone in words and the IANA id. */\n  timeZoneNote: (zoneName: string, timeZone: string) => string\n  /** A day the caller listed with no slots on it at all. */\n  dayEmpty: string\n  /** A day whose slots are all taken. */\n  dayFullyBooked: string\n  /** A day whose slots have all been and gone. */\n  dayPast: string\n  /** Nothing to offer anywhere. */\n  nothingAvailable: string\n  taken: string\n  past: string\n  tooSoon: string\n  /** The range in an accessible name: start, this word, end. */\n  to: string\n  endsNextDay: string\n  announceSelected: (slot: string) => string\n  announceCleared: (slot: string) => string\n  announceRefused: (slot: string, reason: string) => string\n  announceMax: (max: number) => string\n  /** The notice shown when a chosen slot is no longer on offer. */\n  lost: (slots: string[]) => string\n}\n\nexport const defaultTimeSlotPickerLabels: TimeSlotPickerLabels = {\n  list: \"Available times\",\n  timeZoneNote: (zoneName, timeZone) => `Times shown in ${zoneName} (${timeZone})`,\n  dayEmpty: \"No times available\",\n  dayFullyBooked: \"Fully booked\",\n  dayPast: \"These times have passed\",\n  nothingAvailable: \"No times are available.\",\n  taken: \"Already taken\",\n  past: \"This time has passed\",\n  tooSoon: \"Too soon to book\",\n  to: \"to\",\n  endsNextDay: \"ends the next day\",\n  announceSelected: (slot) => `${slot} selected`,\n  announceCleared: (slot) => `${slot} cleared`,\n  announceRefused: (slot, reason) => `${slot} cannot be selected: ${reason}`,\n  announceMax: (max) => `You can choose at most ${max}`,\n  lost: (slots) =>\n    slots.length === 1\n      ? `${slots[0]} is no longer available. Please choose another time.`\n      : `${slots.join(\", \")} are no longer available. Please choose other times.`,\n}\n\n// A locale fixed to the Gregorian calendar and Latin digits, used for every machine-readable date\n// this file builds. Reading the parts under the caller's own locale looks right and is wrong in a\n// way nothing downstream can recover from: `th-TH` answers 2569 for 2026, `ja-JP-u-ca-japanese`\n// answers 8, `ar-EG` answers ٢٠٢٦, and `fa-IR` answers 1405-08-29 — a different day of a different\n// month. The day key has to be the same string for the same day everywhere, because it is what\n// groups the slots and what the caller writes in `days`.\nconst KEY_LOCALE = \"en-US-u-ca-gregory-nu-latn\"\n\nconst MS_PER_MINUTE = 60_000\nconst DAY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/\n\n/** An ISO 8601 date-time that names a moment: it carries `Z` or a numeric offset. */\nconst ZONED = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:?\\d{2})$/i\n/** An ISO 8601 date, or date and time, with no zone on it — a wall clock, not a moment. */\nconst WALL = /^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?)?$/\n\nfunction partsOf(fmt: Intl.DateTimeFormat, ms: number): Record<string, string> {\n  const out: Record<string, string> = {}\n  for (const part of fmt.formatToParts(new Date(ms))) {\n    if (part.type !== \"literal\") out[part.type] = part.value\n  }\n  return out\n}\n\n/**\n * Whether this runtime will accept the zone. An unknown IANA name makes `Intl.DateTimeFormat` throw\n * a `RangeError`, and a picker is not the place to find that out — a typo in a prop would take the\n * whole page down rather than show the times in the wrong zone.\n */\nfunction usableZone(timeZone: string | undefined): string | null {\n  if (timeZone === undefined || timeZone === \"\") return null\n  try {\n    new Intl.DateTimeFormat(KEY_LOCALE, { timeZone })\n    return timeZone\n  } catch {\n    return null\n  }\n}\n\nfunction runtimeZone(): string {\n  try {\n    return new Intl.DateTimeFormat().resolvedOptions().timeZone || \"UTC\"\n  } catch {\n    return \"UTC\"\n  }\n}\n\n/**\n * How far the zone is from UTC at that moment, in milliseconds.\n *\n * Read the instant's wall clock in the zone, then read those same fields back as though they were\n * UTC: the difference between the two is the offset. It is the only way to get at an offset for an\n * arbitrary zone and an arbitrary date, and it has to be per-instant rather than per-zone because\n * the answer changes twice a year in most of the world.\n */\nfunction zoneOffsetMs(timeZone: string, ms: number): number {\n  const fmt = new Intl.DateTimeFormat(KEY_LOCALE, {\n    timeZone,\n    hour12: false,\n    year: \"numeric\",\n    month: \"2-digit\",\n    day: \"2-digit\",\n    hour: \"2-digit\",\n    minute: \"2-digit\",\n    second: \"2-digit\",\n  })\n  const p = partsOf(fmt, ms)\n  // Some runtimes have answered \"24\" for midnight under `hour12: false`. Current ones answer \"00\",\n  // but a stray 24 here would move a slot a whole day, so it is folded rather than trusted.\n  const hour = p.hour === \"24\" ? 0 : Number(p.hour)\n  const asUtc = Date.UTC(\n    Number(p.year),\n    Number(p.month) - 1,\n    Number(p.day),\n    hour,\n    Number(p.minute),\n    Number(p.second)\n  )\n  return asUtc - ms\n}\n\n/**\n * The moment a wall clock names in a zone.\n *\n * Subtracting the offset once is not enough: the offset has to be the one in force at the *answer*,\n * not at the guess, or every slot on the far side of a clock change lands an hour out. One\n * correction pass settles that, because the two offsets differ by at most the size of the jump.\n *\n * The two days a year that have no single answer are resolved rather than refused — an hour that\n * comes round twice takes the first of the two, an hour that never happens takes the instant the\n * clock skipped to. Either way the same input always gives the same output, which is what a server\n * rendering this and a browser hydrating it need from each other.\n */\nfunction instantFromWall(\n  timeZone: string,\n  year: number,\n  month: number,\n  day: number,\n  hour: number,\n  minute: number,\n  second: number\n): number {\n  const wall = Date.UTC(year, month - 1, day, hour, minute, second)\n  const once = wall - zoneOffsetMs(timeZone, wall)\n  return wall - zoneOffsetMs(timeZone, once)\n}\n\ninterface ParsedInstant {\n  ms: number\n  /** The input named a wall clock with no zone, so the display zone was used to place it. */\n  assumed: boolean\n}\n\nfunction parseInstant(input: string | number | Date | undefined, timeZone: string): ParsedInstant | null {\n  if (input === undefined || input === null) return null\n  if (input instanceof Date) {\n    const ms = input.getTime()\n    return Number.isFinite(ms) ? { ms, assumed: false } : null\n  }\n  if (typeof input === \"number\") {\n    return Number.isFinite(input) ? { ms: input, assumed: false } : null\n  }\n  if (typeof input !== \"string\") return null\n  const text = input.trim()\n  if (text === \"\") return null\n  if (ZONED.test(text)) {\n    const ms = Date.parse(text)\n    return Number.isFinite(ms) ? { ms, assumed: false } : null\n  }\n  const wall = WALL.exec(text)\n  if (wall !== null) {\n    const month = Number(wall[2])\n    const day = Number(wall[3])\n    const hour = wall[4] === undefined ? 0 : Number(wall[4])\n    const minute = wall[5] === undefined ? 0 : Number(wall[5])\n    const second = wall[6] === undefined ? 0 : Number(wall[6])\n    if (month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || minute > 59 || second > 59) {\n      return null\n    }\n    return { ms: instantFromWall(timeZone, Number(wall[1]), month, day, hour, minute, second), assumed: true }\n  }\n  // Anything else — \"Nov 20 2026 9am\", a locale string — is handed to the engine, which is allowed\n  // to read it however it likes. Accepted so a caller is not stuck, with no claim about the zone.\n  const ms = Date.parse(text)\n  return Number.isFinite(ms) ? { ms, assumed: true } : null\n}\n\nfunction dayKeyOf(timeZone: string, ms: number): string {\n  const fmt = new Intl.DateTimeFormat(KEY_LOCALE, {\n    timeZone,\n    year: \"numeric\",\n    month: \"2-digit\",\n    day: \"2-digit\",\n  })\n  const p = partsOf(fmt, ms)\n  return `${p.year}-${p.month}-${p.day}`\n}\n\nfunction makeTimeFormat(\n  locale: string | undefined,\n  timeZone: string,\n  hour12: boolean | undefined,\n  extra?: Intl.DateTimeFormatOptions\n): Intl.DateTimeFormat {\n  const options: Intl.DateTimeFormatOptions = { timeZone, hour: \"numeric\", minute: \"2-digit\", ...extra }\n  if (hour12 !== undefined) options.hour12 = hour12\n  try {\n    return new Intl.DateTimeFormat(locale, options)\n  } catch {\n    return new Intl.DateTimeFormat(undefined, options)\n  }\n}\n\nfunction makeFormat(\n  locale: string | undefined,\n  options: Intl.DateTimeFormatOptions\n): Intl.DateTimeFormat {\n  try {\n    return new Intl.DateTimeFormat(locale, options)\n  } catch {\n    return new Intl.DateTimeFormat(undefined, options)\n  }\n}\n\nfunction zoneWord(\n  locale: string | undefined,\n  timeZone: string,\n  style: \"long\" | \"short\",\n  ms: number\n): string {\n  const fmt = makeFormat(locale, { timeZone, timeZoneName: style, hour: \"numeric\" })\n  const found = fmt.formatToParts(new Date(ms)).find((part) => part.type === \"timeZoneName\")\n  return found === undefined ? timeZone : found.value\n}\n\nexport interface ResolveTimeSlotsOptions {\n  slots: TimeSlot[]\n  /**\n   * Days to show even when they have no slots, as `\"YYYY-MM-DD\"` in the display zone.\n   *\n   * Without this a day with nothing free cannot be shown at all — no slot means nothing to derive a\n   * day from, and inventing one would be inventing the calendar. Days carrying slots are always\n   * shown whether or not they are listed here, because quietly dropping a bookable time is worse\n   * than showing a day the caller did not ask for.\n   */\n  days?: string[]\n  /** IANA zone the times are shown in. Defaults to the runtime's, and says which in the caption. */\n  timeZone?: string\n  locale?: string\n  hour12?: boolean\n  /**\n   * The moment \"now\" is measured from. Left out, nothing is past and nothing is too soon.\n   *\n   * It is a prop and not a clock reading on purpose: a component that reads `Date.now()` renders\n   * differently on the server and in the browser a moment later, which is a hydration mismatch, and\n   * it can never be tested twice with the same answer.\n   */\n  now?: string | number | Date\n  /** Minutes of notice required. A slot starting inside the window is shown but cannot be taken. */\n  minLeadMinutes?: number\n  /** Leave slots that have already started out of the list. On by default. */\n  hidePastSlots?: boolean\n  /** Length to use for a slot that gives neither `end` nor `durationMinutes`. */\n  defaultDurationMinutes?: number\n  /** Formatting for the day headings. */\n  dayFormat?: Intl.DateTimeFormatOptions\n  labels?: Partial<TimeSlotPickerLabels>\n}\n\n/**\n * Arranges the offered slots into days with every label worked out.\n *\n * Exported because a confirmation screen, an email or a server route wants the same labels in the\n * same zone without mounting a picker, and because the awkward parts — which day a slot belongs to,\n * which two slots read alike — are then assertable on their own.\n */\nexport function resolveTimeSlots(options: ResolveTimeSlotsOptions): ResolvedTimeSlots {\n  const {\n    slots,\n    days: requestedDays,\n    locale,\n    hour12,\n    minLeadMinutes = 0,\n    hidePastSlots = true,\n    defaultDurationMinutes,\n    dayFormat,\n  } = options\n  const labels = { ...defaultTimeSlotPickerLabels, ...options.labels }\n  const timeZone = usableZone(options.timeZone) ?? runtimeZone()\n\n  const nowParsed = parseInstant(options.now, timeZone)\n  const now = nowParsed === null ? null : nowParsed.ms\n  const leadUntil = now === null ? null : now + Math.max(0, minLeadMinutes) * MS_PER_MINUTE\n\n  const timeFmt = makeTimeFormat(locale, timeZone, hour12)\n  const dayFmt = makeFormat(locale, {\n    timeZone,\n    weekday: \"long\",\n    year: \"numeric\",\n    month: \"long\",\n    day: \"numeric\",\n    ...dayFormat,\n  })\n\n  // Parse first, sort by the instant, and only then group. Sorting the input strings instead would\n  // put \"2026-11-20T23:00+09:00\" after \"2026-11-20T15:00Z\" — the same moment written two ways.\n  const parsed: ResolvedSlot[] = []\n  const seen = new Set<string>()\n  // Guarded rather than trusted: the types say this is an array, and this function is also called\n  // straight from whatever a fetch handed back, where \"no slots\" arrives as undefined about as often\n  // as it arrives as [].\n  for (const slot of Array.isArray(slots) ? slots : []) {\n    const start = parseInstant(slot.start, timeZone)\n    if (start === null) continue\n    const endParsed =\n      slot.end !== undefined\n        ? parseInstant(slot.end, timeZone)\n        : slot.durationMinutes !== undefined && Number.isFinite(slot.durationMinutes)\n          ? { ms: start.ms + slot.durationMinutes * MS_PER_MINUTE, assumed: false }\n          : defaultDurationMinutes !== undefined && Number.isFinite(defaultDurationMinutes)\n            ? { ms: start.ms + defaultDurationMinutes * MS_PER_MINUTE, assumed: false }\n            : null\n    // An end at or before the start is not a range; it is bad data. Dropped to a start-only slot so\n    // the label reads \"9:00\" rather than \"9:00 to 8:30\", and reported by `slotIssues`.\n    const end = endParsed !== null && endParsed.ms > start.ms ? endParsed.ms : null\n\n    const id = slot.id !== undefined && slot.id !== \"\" ? slot.id : new Date(start.ms).toISOString()\n    // The first of two slots sharing an id wins. Keeping both would give the value an entry that\n    // selects two things at once, and nothing downstream could tell them apart.\n    if (seen.has(id)) continue\n    seen.add(id)\n\n    const taken = slot.taken === true\n    const past = now !== null && start.ms < now\n    const tooSoon = !past && leadUntil !== null && start.ms < leadUntil\n    const block: SlotBlock = taken ? \"taken\" : past ? \"past\" : tooSoon ? \"lead\" : \"\"\n    const builtInReason =\n      block === \"taken\" ? labels.taken : block === \"past\" ? labels.past : block === \"lead\" ? labels.tooSoon : \"\"\n\n    parsed.push({\n      id,\n      start: start.ms,\n      end,\n      durationMinutes: end === null ? null : Math.round((end - start.ms) / MS_PER_MINUTE),\n      dayKey: dayKeyOf(timeZone, start.ms),\n      startLabel: timeFmt.format(new Date(start.ms)),\n      endLabel: end === null ? \"\" : timeFmt.format(new Date(end)),\n      label: \"\",\n      zoneLabel: \"\",\n      // Measured from the last moment inside the slot rather than from the end itself, because a\n      // slot runs up to its end and not through it: 23:30–00:00 is the last half hour of the day,\n      // and reading the boundary itself would file every slot that ends at midnight under tomorrow.\n      endsNextDay: end !== null && dayKeyOf(timeZone, end - 1) !== dayKeyOf(timeZone, start.ms),\n      taken,\n      past,\n      tooSoon,\n      block,\n      selectable: block === \"\",\n      reason: slot.reason !== undefined && slot.reason !== \"\" ? slot.reason : builtInReason,\n      note: slot.note ?? \"\",\n    })\n  }\n  parsed.sort((a, b) => a.start - b.start || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))\n\n  const byDay = new Map<string, ResolvedSlot[]>()\n  for (const key of requestedDays ?? []) {\n    if (DAY_PATTERN.test(key)) byDay.set(key, [])\n  }\n  for (const slot of parsed) {\n    const bucket = byDay.get(slot.dayKey)\n    if (bucket === undefined) byDay.set(slot.dayKey, [slot])\n    else bucket.push(slot)\n  }\n\n  const days: ResolvedDay[] = []\n  const order: string[] = []\n  const byId: Record<string, ResolvedSlot> = {}\n  let available = 0\n\n  for (const key of Array.from(byDay.keys()).sort()) {\n    const offered = byDay.get(key) ?? []\n    const shown = hidePastSlots ? offered.filter((slot) => !slot.past) : offered.slice()\n\n    // The range is shown on every slot of a day that mixes lengths, and only then. With one length\n    // the start time says everything and the range is noise; with two, a start alone hides the\n    // difference between the half hour and the hour that begin at the same minute.\n    const lengths = new Set(shown.map((slot) => slot.durationMinutes))\n    const showRange = lengths.size > 1\n\n    // Two slots can read exactly alike, and not as a curiosity: when the clocks go back, 1:30 comes\n    // round twice, and both halves of that hour are ordinary bookable slots. Measured rather than\n    // assumed — en-US formats 05:30Z and 06:30Z on 2026-11-01 as \"1:30 AM\" both times. The zone\n    // abbreviation goes on the ones that collide, so the pair differ, and not on the rest.\n    const labelCount = new Map<string, number>()\n    for (const slot of shown) {\n      labelCount.set(slot.startLabel, (labelCount.get(slot.startLabel) ?? 0) + 1)\n    }\n\n    const daySlots = shown.map((slot) => {\n      const collides = (labelCount.get(slot.startLabel) ?? 0) > 1\n      const resolved: ResolvedSlot = {\n        ...slot,\n        zoneLabel: collides ? zoneWord(locale, timeZone, \"short\", slot.start) : \"\",\n        label: showRange && slot.endLabel !== \"\" ? `${slot.startLabel} – ${slot.endLabel}` : slot.startLabel,\n      }\n      byId[resolved.id] = resolved\n      order.push(resolved.id)\n      return resolved\n    })\n\n    const dayAvailable = daySlots.filter((slot) => slot.selectable).length\n    available += dayAvailable\n\n    const state: DayState =\n      offered.length === 0\n        ? \"empty\"\n        : dayAvailable > 0\n          ? \"available\"\n          : offered.every((slot) => slot.past)\n            ? \"past\"\n            : \"fullyBooked\"\n\n    const [year, month, day] = key.split(\"-\").map(Number)\n    days.push({\n      key,\n      // Noon rather than midnight: the label is formatted in the display zone, and midnight is the\n      // one time of day a zone shift can move to the day before.\n      label: dayFmt.format(new Date(Date.UTC(year, month - 1, day, 12))),\n      slots: daySlots,\n      available: dayAvailable,\n      offered: offered.length,\n      state,\n    })\n  }\n\n  return {\n    timeZone,\n    zoneName: zoneWord(locale, timeZone, \"long\", parsed.length > 0 ? parsed[0].start : Date.UTC(2026, 0, 1)),\n    days,\n    order,\n    byId,\n    available,\n  }\n}\n\n/**\n * What is wrong with the data, named rather than guessed around.\n *\n * None of these stops the picker rendering. They are here because every one of them is a mistake at\n * the source that looks like a mistake in the component — a slot an hour out, a slot that cannot be\n * selected, two slots that select together — and the only cheap way to find that out is to ask.\n */\nexport function slotIssues(\n  slots: TimeSlot[],\n  options: { timeZone?: string; now?: string | number | Date; minLeadMinutes?: number } = {}\n): SlotIssue[] {\n  const timeZone = usableZone(options.timeZone) ?? runtimeZone()\n  const issues: SlotIssue[] = []\n  const seen = new Set<string>()\n  const spans: { id: string; start: number; end: number }[] = []\n\n  if (options.minLeadMinutes !== undefined && options.minLeadMinutes > 0 && options.now === undefined) {\n    issues.push({\n      kind: \"lead-without-now\",\n      subject: \"\",\n      message: \"minLeadMinutes needs `now` to measure from, so no slot is being held back.\",\n    })\n  }\n\n  for (const slot of Array.isArray(slots) ? slots : []) {\n    const start = parseInstant(slot.start, timeZone)\n    const label = slot.id !== undefined && slot.id !== \"\" ? slot.id : String(slot.start)\n    if (start === null) {\n      issues.push({\n        kind: \"unparsable-start\",\n        subject: label,\n        message: `Cannot read ${JSON.stringify(slot.start)} as a time, so this slot is not shown.`,\n      })\n      continue\n    }\n    const id = slot.id !== undefined && slot.id !== \"\" ? slot.id : new Date(start.ms).toISOString()\n    if (seen.has(id)) {\n      issues.push({\n        kind: \"duplicate-id\",\n        subject: id,\n        message: \"Two slots share this id, so only the first is shown. Give them ids of their own.\",\n      })\n      continue\n    }\n    seen.add(id)\n\n    if (start.assumed) {\n      issues.push({\n        kind: \"no-offset\",\n        subject: id,\n        message: `${JSON.stringify(slot.start)} carries no UTC offset, so it is being read in ${timeZone}.`,\n      })\n    }\n\n    let end: number | null = null\n    if (slot.end !== undefined) {\n      const parsedEnd = parseInstant(slot.end, timeZone)\n      if (parsedEnd === null) {\n        issues.push({\n          kind: \"unparsable-end\",\n          subject: id,\n          message: `Cannot read ${JSON.stringify(slot.end)} as a time, so this slot has no end.`,\n        })\n      } else {\n        end = parsedEnd.ms\n        if (parsedEnd.assumed) {\n          issues.push({\n            kind: \"no-offset\",\n            subject: id,\n            message: `${JSON.stringify(slot.end)} carries no UTC offset, so it is being read in ${timeZone}.`,\n          })\n        }\n        if (parsedEnd.ms <= start.ms) {\n          issues.push({\n            kind: \"backwards\",\n            subject: id,\n            message: \"The end is at or before the start, so this slot is shown as a start time only.\",\n          })\n        }\n      }\n    } else if (slot.durationMinutes !== undefined) {\n      if (!Number.isFinite(slot.durationMinutes) || slot.durationMinutes <= 0) {\n        issues.push({\n          kind: \"backwards\",\n          subject: id,\n          message: \"durationMinutes is not a positive number, so this slot is shown as a start time only.\",\n        })\n      } else {\n        end = start.ms + slot.durationMinutes * MS_PER_MINUTE\n      }\n    }\n\n    if (end !== null && slot.taken !== true) spans.push({ id, start: start.ms, end })\n  }\n\n  // Only among slots somebody could actually take: a free slot overlapping a booked one is how a\n  // calendar offers the hour either side of an appointment, and flagging that would be noise.\n  spans.sort((a, b) => a.start - b.start)\n  for (let i = 1; i < spans.length; i++) {\n    const previous = spans[i - 1]\n    const current = spans[i]\n    if (current.start < previous.end) {\n      issues.push({\n        kind: \"overlap\",\n        subject: current.id,\n        message: `Overlaps ${previous.id}, so both can be taken for the same time.`,\n      })\n    }\n  }\n\n  return issues\n}\n\nexport interface SlotReconciliation {\n  /** The selection with everything unavailable taken out — what is safe to submit. */\n  value: string[]\n  /** The ids that went, in the order they were given. */\n  lost: string[]\n}\n\n/**\n * Drops the parts of a selection the latest slots no longer support.\n *\n * This is the whole reason a picker needs anything beyond a list of buttons. A slot is free when the\n * page renders and taken a moment later by somebody else, and the choice already on screen is then\n * a choice of something that does not exist. Keeping it ticked posts a booking that will be refused;\n * clearing it quietly loses the person's answer with nothing said. So it comes out of the value and\n * is handed back under `lost`, for the caller to say out loud.\n */\nexport function reconcileSlotSelection(\n  selected: readonly string[],\n  resolved: ResolvedTimeSlots\n): SlotReconciliation {\n  const value: string[] = []\n  const lost: string[] = []\n  const kept = new Set<string>()\n  for (const id of selected) {\n    if (kept.has(id)) continue\n    kept.add(id)\n    const slot = resolved.byId[id]\n    if (slot !== undefined && slot.selectable) value.push(id)\n    else lost.push(id)\n  }\n  return { value, lost }\n}\n\n/** Why a press changed nothing. */\nexport type SlotRefusal = \"missing\" | \"taken\" | \"past\" | \"lead\" | \"max\"\n\nexport interface SlotToggle {\n  value: string[]\n  added: string[]\n  removed: string[]\n  refused: SlotRefusal | null\n}\n\n/**\n * The next selection after a press, and nothing else.\n *\n * Deselecting is always allowed, including for a slot that has since been taken: refusing to let go\n * of something unavailable would strand the person on it.\n */\nexport function toggleSlotSelection(\n  selected: readonly string[],\n  id: string,\n  options: { resolved: ResolvedTimeSlots; multiple?: boolean; max?: number }\n): SlotToggle {\n  const { resolved, multiple = false, max } = options\n  const current = reconcileSlotSelection(selected, resolved).value\n  const unchanged = { value: current, added: [], removed: [] }\n\n  if (current.indexOf(id) !== -1) {\n    return { value: current.filter((other) => other !== id), added: [], removed: [id], refused: null }\n  }\n\n  const slot = resolved.byId[id]\n  if (slot === undefined) return { ...unchanged, refused: \"missing\" }\n  if (slot.taken) return { ...unchanged, refused: \"taken\" }\n  if (slot.past) return { ...unchanged, refused: \"past\" }\n  if (slot.tooSoon) return { ...unchanged, refused: \"lead\" }\n\n  if (!multiple) {\n    return { value: [id], added: [id], removed: current.filter((other) => other !== id), refused: null }\n  }\n  if (max !== undefined && current.length >= max) return { ...unchanged, refused: \"max\" }\n\n  // Kept in the order the slots are offered rather than the order they were pressed, so the value\n  // reads as a schedule and two people picking the same three times produce the same value.\n  const next = current.concat(id)\n  const rank = new Map(resolved.order.map((other, index) => [other, index]))\n  next.sort((a, b) => (rank.get(a) ?? 0) - (rank.get(b) ?? 0))\n  return { value: next, added: [id], removed: [], refused: null }\n}\n\n/** The first slot anybody could take, for a \"next available\" link. `null` when there is none. */\nexport function nextAvailableSlot(resolved: ResolvedTimeSlots): ResolvedSlot | null {\n  for (const id of resolved.order) {\n    const slot = resolved.byId[id]\n    if (slot !== undefined && slot.selectable) return slot\n  }\n  return null\n}\n\n/**\n * Where the focus goes for a key press, or `null` when it stays put.\n *\n * Left and right walk the slots in time order and run on into the next day, because that is how the\n * list reads; up and down jump a whole day, because that is the other thing somebody wants from a\n * list of days. Movement clamps at both ends rather than wrapping — a wrap from the last slot of the\n * month back to the first looks like the list reset itself.\n *\n * Slots nobody can take are walked onto rather than skipped. A reader who cannot reach the 9:00\n * somebody else has booked has no way to find out it was ever there, and \"nothing at 9\" and \"9 is\n * gone\" are different answers to the only question being asked.\n */\nexport function nextSlotFocus(\n  resolved: ResolvedTimeSlots,\n  current: string | null,\n  key: string\n): string | null {\n  const { order } = resolved\n  if (order.length === 0) return null\n  const at = current === null ? -1 : order.indexOf(current)\n  const step = (to: number): string | null => {\n    const clamped = Math.max(0, Math.min(to, order.length - 1))\n    return order[clamped] === current ? null : order[clamped]\n  }\n  const dayStep = (delta: number): string | null => {\n    const from = at === -1 ? 0 : at\n    const slot = resolved.byId[order[from]]\n    if (slot === undefined) return null\n    const index = resolved.days.findIndex((day) => day.key === slot.dayKey)\n    for (let i = index + delta; i >= 0 && i < resolved.days.length; i += delta) {\n      const day = resolved.days[i]\n      if (day.slots.length > 0) return day.slots[0].id\n    }\n    return null\n  }\n\n  switch (key) {\n    case \"ArrowRight\":\n      return step(at + 1)\n    case \"ArrowLeft\":\n      return at === -1 ? step(0) : step(at - 1)\n    case \"ArrowDown\":\n      return dayStep(1)\n    case \"ArrowUp\":\n      return dayStep(-1)\n    case \"Home\":\n      return step(0)\n    case \"End\":\n      return step(order.length - 1)\n    default:\n      return null\n  }\n}\n\nexport interface TimeSlotPickerProps extends ResolveTimeSlotsOptions {\n  /** Controlled selection, as slot ids. Holds at most one id unless `multiple` is set. */\n  value?: string[]\n  /** Starting selection when uncontrolled. */\n  defaultValue?: string[]\n  /** Fires with the next selection and the slots that moved. Never fires for a refused press. */\n  onValueChange?: (value: string[], change: { added: ResolvedSlot[]; removed: ResolvedSlot[] }) => void\n  /** Let more than one slot be chosen. */\n  multiple?: boolean\n  /** Most slots that may be chosen at once. Further presses are refused and said out loud. */\n  max?: number\n  /**\n   * Fires with the ids that had to be dropped because the slots behind them are no longer on offer.\n   * Use it to clear the ids from your own copy of the value, or to put the person back on the step\n   * where they choose.\n   */\n  onLostSelection?: (lost: string[]) => void\n  /** Hide the \"times shown in …\" caption. The zone is still used; it just stops being stated. */\n  showTimeZone?: boolean\n  /** Turn off the live region that announces each selection. */\n  announce?: boolean\n  disabled?: boolean\n  /** Posts the chosen ids as hidden inputs of this name, so a plain form or server action gets them. */\n  name?: string\n  \"aria-label\"?: string\n  className?: string\n  classNames?: {\n    day?: string\n    dayLabel?: string\n    slots?: string\n    slot?: string\n    note?: string\n    caption?: string\n    notice?: string\n  }\n}\n\n/**\n * Choose from the times somebody else has said are free.\n *\n * The component holds two things that a list of buttons cannot. One is the zone: every slot is an\n * instant, the display zone is stated on screen, and which calendar day a slot belongs to is worked\n * out in that zone — a 23:30 UTC slot is tomorrow in Tokyo, and grouping by the UTC date puts it\n * under the wrong heading. The other is that availability goes stale while it is being read, so the\n * selection is reconciled against the latest slots on every render and anything that has gone is\n * taken out of the value, named in a notice, and left out of what a form would post.\n */\nexport function TimeSlotPicker({\n  slots,\n  days,\n  value,\n  defaultValue,\n  onValueChange,\n  multiple = false,\n  max,\n  onLostSelection,\n  timeZone,\n  locale,\n  hour12,\n  now,\n  minLeadMinutes = 0,\n  hidePastSlots = true,\n  defaultDurationMinutes,\n  dayFormat,\n  labels: labelOverrides,\n  showTimeZone = true,\n  announce = true,\n  disabled = false,\n  name,\n  className,\n  classNames,\n  \"aria-label\": ariaLabel,\n}: TimeSlotPickerProps) {\n  const labels = React.useMemo(\n    () => ({ ...defaultTimeSlotPickerLabels, ...labelOverrides }),\n    [labelOverrides]\n  )\n  const isControlled = value !== undefined\n  const [inner, setInner] = React.useState<string[]>(() => (defaultValue ?? []).slice())\n  const selected = isControlled ? value : inner\n\n  const resolved = React.useMemo(\n    () =>\n      resolveTimeSlots({\n        slots,\n        days,\n        timeZone,\n        locale,\n        hour12,\n        now,\n        minLeadMinutes,\n        hidePastSlots,\n        defaultDurationMinutes,\n        dayFormat,\n        labels,\n      }),\n    [\n      slots,\n      days,\n      timeZone,\n      locale,\n      hour12,\n      now,\n      minLeadMinutes,\n      hidePastSlots,\n      defaultDurationMinutes,\n      dayFormat,\n      labels,\n    ]\n  )\n\n  const { value: usable, lost } = reconcileSlotSelection(selected, resolved)\n  const usableSet = new Set(usable)\n\n  const reactId = React.useId()\n  const [message, setMessage] = React.useState(\"\")\n  const [focusId, setFocusId] = React.useState<string | null>(null)\n  const nodes = React.useRef(new Map<string, { focus?: () => void }>())\n\n  // One tab stop. Which slot it lands on is derived rather than stored, so a slot that disappears\n  // between renders cannot leave the list with no reachable stop: the chosen one, else the first\n  // that can be taken, else the first there is.\n  const activeId = (() => {\n    if (focusId !== null && resolved.byId[focusId] !== undefined) return focusId\n    if (usable.length > 0) return usable[0]\n    const next = nextAvailableSlot(resolved)\n    if (next !== null) return next.id\n    return resolved.order.length > 0 ? resolved.order[0] : null\n  })()\n\n  // Said once per change, not once per render. Without the guard this fires on every pass, and a\n  // caller clearing its own value from it would be told again about what it just cleared.\n  const toldAbout = React.useRef<string | null>(null)\n  const lostKey = lost.join(\"\\u0000\")\n  React.useEffect(() => {\n    if (toldAbout.current === lostKey) return\n    toldAbout.current = lostKey\n    if (lost.length > 0) onLostSelection?.(lost)\n  })\n\n  const fullLabel = (slot: ResolvedSlot): string => {\n    const day = resolved.days.find((each) => each.key === slot.dayKey)\n    const time = slot.endLabel === \"\" ? slot.startLabel : `${slot.startLabel} ${labels.to} ${slot.endLabel}`\n    return day === undefined ? time : `${day.label}, ${time}`\n  }\n\n  const lostLabels = lost.map((id) => {\n    const slot = resolved.byId[id]\n    return slot === undefined ? id : fullLabel(slot)\n  })\n\n  function press(slot: ResolvedSlot) {\n    if (disabled) return\n    const result = toggleSlotSelection(selected, slot.id, { resolved, multiple, max })\n    if (result.refused !== null) {\n      setMessage(\n        result.refused === \"max\" && max !== undefined\n          ? labels.announceMax(max)\n          : labels.announceRefused(fullLabel(slot), slot.reason)\n      )\n      return\n    }\n    if (!isControlled) setInner(result.value)\n    setMessage(\n      result.added.length > 0 ? labels.announceSelected(fullLabel(slot)) : labels.announceCleared(fullLabel(slot))\n    )\n    onValueChange?.(result.value, {\n      added: result.added.map((id) => resolved.byId[id]).filter((each): each is ResolvedSlot => each !== undefined),\n      removed: result.removed\n        .map((id) => resolved.byId[id])\n        .filter((each): each is ResolvedSlot => each !== undefined),\n    })\n  }\n\n  function onKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n    if (event.key === \"Enter\" || event.key === \" \") {\n      const slot = activeId === null ? undefined : resolved.byId[activeId]\n      if (slot !== undefined) {\n        // Space scrolls the page by default, and these are divs rather than buttons, so neither key\n        // activates on its own.\n        event.preventDefault()\n        press(slot)\n      }\n      return\n    }\n    const next = nextSlotFocus(resolved, activeId, event.key)\n    if (next === null) return\n    event.preventDefault()\n    setFocusId(next)\n    nodes.current.get(next)?.focus?.()\n  }\n\n  const dayLabelId = (key: string) => `${reactId}-${key}`\n  const reasonId = (id: string) => `${reactId}-why-${id}`\n\n  return (\n    <div className={cn(\"w-full text-sm\", className)}>\n      {showTimeZone ? (\n        <p className={cn(\"mb-2 text-xs text-muted-foreground\", classNames?.caption)}>\n          {labels.timeZoneNote(resolved.zoneName, resolved.timeZone)}\n        </p>\n      ) : null}\n\n      <div\n        role=\"listbox\"\n        aria-multiselectable={multiple ? true : undefined}\n        aria-label={ariaLabel ?? labels.list}\n        aria-disabled={disabled ? true : undefined}\n        onKeyDown={onKeyDown}\n        className={cn(\"space-y-4\", disabled && \"opacity-50\")}\n      >\n        {resolved.days.length === 0 ? (\n          <p className=\"text-muted-foreground\">{labels.nothingAvailable}</p>\n        ) : null}\n\n        {resolved.days.map((day) => (\n          <div key={day.key} role=\"group\" aria-labelledby={dayLabelId(day.key)} className={classNames?.day}>\n            <h3\n              id={dayLabelId(day.key)}\n              className={cn(\"mb-2 font-medium text-foreground\", classNames?.dayLabel)}\n            >\n              {day.label}\n            </h3>\n\n            {/* Said whenever there is nothing to take, and not only when there is nothing to show.\n                A day holding six struck-through slots and no sentence is the same silent blank as an\n                empty one: the reader has to work along every slot to find out that the answer is no.\n                It also keeps the three sentences reachable — written as the alternative to the grid,\n                \"fully booked\" could never appear at all, because a booked slot is still on screen\n                and the only way to empty a day's grid is for its times to have passed. */}\n            {day.state === \"available\" ? null : (\n              <p className=\"mb-2 text-muted-foreground\">\n                {day.state === \"fullyBooked\"\n                  ? labels.dayFullyBooked\n                  : day.state === \"past\"\n                    ? labels.dayPast\n                    : labels.dayEmpty}\n              </p>\n            )}\n\n            {day.slots.length === 0 ? null : (\n              <div\n                className={cn(\n                  \"grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4\",\n                  classNames?.slots\n                )}\n              >\n                {day.slots.map((slot) => {\n                  const isSelected = usableSet.has(slot.id)\n                  const blocked = !slot.selectable\n                  // The day is not repeated here: the slot sits in a group named by the day\n                  // heading, which is what a reader is told on the way in. It *is* repeated in the\n                  // announcements and the notice below, which are read with no group around them —\n                  // \"9:00 AM selected\" on its own does not say which day was just taken.\n                  const slotName =\n                    (slot.endLabel === \"\"\n                      ? slot.startLabel\n                      : `${slot.startLabel} ${labels.to} ${slot.endLabel}`) +\n                    (slot.zoneLabel === \"\" ? \"\" : ` ${slot.zoneLabel}`) +\n                    (slot.endsNextDay ? `, ${labels.endsNextDay}` : \"\")\n                  return (\n                    <div\n                      key={slot.id}\n                      ref={(node) => {\n                        if (node === null) nodes.current.delete(slot.id)\n                        else nodes.current.set(slot.id, node)\n                      }}\n                      role=\"option\"\n                      aria-selected={isSelected}\n                      // `aria-disabled` rather than the `disabled` attribute, and rather than\n                      // leaving the slot out: a taken slot is the answer to \"what about 9:00\", and\n                      // it can only be that answer if it is still reachable and still says why.\n                      aria-disabled={blocked || disabled ? true : undefined}\n                      aria-describedby={slot.reason === \"\" ? undefined : reasonId(slot.id)}\n                      aria-label={slotName}\n                      tabIndex={slot.id === activeId ? 0 : -1}\n                      onClick={() => press(slot)}\n                      className={cn(\n                        \"flex cursor-pointer select-none flex-col items-center rounded-md border px-3 py-2 text-center tabular-nums transition-colors\",\n                        \"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n                        isSelected\n                          ? \"border-primary bg-primary text-primary-foreground\"\n                          : \"border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n                        blocked &&\n                          !isSelected &&\n                          \"cursor-not-allowed border-dashed text-muted-foreground line-through hover:bg-background hover:text-muted-foreground\",\n                        disabled && \"cursor-not-allowed\",\n                        classNames?.slot\n                      )}\n                    >\n                      <span>\n                        {slot.label}\n                        {slot.zoneLabel === \"\" ? null : (\n                          <span className=\"ml-1 text-xs font-normal opacity-70\">{slot.zoneLabel}</span>\n                        )}\n                      </span>\n                      {slot.note === \"\" ? null : (\n                        <span className={cn(\"text-xs opacity-70\", classNames?.note)}>{slot.note}</span>\n                      )}\n                      {slot.reason === \"\" ? null : (\n                        <span id={reasonId(slot.id)} className=\"sr-only\">\n                          {slot.reason}\n                        </span>\n                      )}\n                    </div>\n                  )\n                })}\n              </div>\n            )}\n          </div>\n        ))}\n      </div>\n\n      {/* Mounted whether or not anything was lost, so the sentence that appears in it is a change to\n          a live region and gets read, rather than a new region nobody is watching. */}\n      <p\n        role=\"status\"\n        className={cn(\n          \"mt-2 text-sm text-destructive\",\n          lostLabels.length === 0 && \"sr-only\",\n          classNames?.notice\n        )}\n      >\n        {lostLabels.length === 0 ? \"\" : labels.lost(lostLabels)}\n      </p>\n\n      {announce ? (\n        <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n          {message}\n        </span>\n      ) : null}\n\n      {name !== undefined\n        ? // Only what survived reconciliation. The point of the whole exercise is that the form does\n          // not post a slot somebody else already has.\n          usable.map((id) => <input key={id} type=\"hidden\" name={name} value={id} />)\n        : null}\n    </div>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui",
  "docs": "Install any pulld component by name: add \"@pulld\": \"https://pulld.pages.dev/r/{name}.json\" to the registries block in components.json, then `npx shadcn add @pulld/<name>`. All 149 components: https://pulld.pages.dev/?utm_source=cli"
}
