{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "inspector",
  "title": "Inspector",
  "description": "X-ray for a page built with Ouro HX: outlines every Ouro component on the page with its name, linked to its docs, and lists them all for keyboard and screen reader users.",
  "registryDependencies": [
    "@ouro/button",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-reduced-motion",
    "@ouro/sheet"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/inspector/inspector-styles.ts",
      "content": "export { actionsClass, frameClass, isPartOf, itemFor, labelClass, layerClass, linkClass, listClass, outlineClass, pillClass, statusClass, tagClass };\n\n// Class strings and names for Inspector, apart from the component so its file exports only\n// components (React Fast Refresh). Class strings are literal so the app's Tailwind finds them.\n\n/**\n * The root names (`data-ouro`) that are not their registry item's name, by the item they belong\n * to. Roots that only position or hold an overlay (`-portal`, `-positioner`, `-backdrop`,\n * `-viewport`) are no component of their own and get no outline.\n * @claim \"Roots that only position or hold\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > does not outline itself, an overlay's wrappers, a hidden component or a part apart from its component)\n */\nconst aliases: Readonly<Record<string, string>> = {\n  \"avatar-group\": \"avatar\",\n  \"combobox-popup\": \"combobox\",\n  \"edit-sheet-discard\": \"edit-sheet\",\n  \"emoji-text\": \"emoji\",\n  \"form-message\": \"form\",\n  \"menu-bar\": \"menu\",\n  \"navigation-menu-popup\": \"navigation-menu\",\n  radio: \"radio-group\",\n  \"resizable-handle\": \"resizable\",\n  \"resizable-panel\": \"resizable\",\n  \"select-popup\": \"select\",\n  \"snap-pip-frame\": \"snap-pip\",\n  \"snap-pip-hint\": \"snap-pip\",\n  \"time-grid-nav\": \"time-grid\",\n  toast: \"toaster\",\n};\n\n/**\n * The registry item a component root belongs to, from its `data-ouro` name, or `null` for a root\n * that only positions an overlay.\n *\n * @internal\n */\nfunction itemFor(name: string): string | null {\n  if (/-(portal|positioner|backdrop|viewport)$/.test(name)) return null;\n  return aliases[name] ?? name;\n}\n\n/**\n * Whether a root is a part of the component around it rather than a component of its own: its name\n * is a part's (`radio`, `resizable-panel`, `form-message`) and the nearest root around it belongs\n * to the same item (a Radio in its RadioGroup). A part outside its component's root, like a popup in\n * a portal, counts as a component.\n *\n * @internal\n */\nfunction isPartOf(name: string, around: Element | null | undefined): boolean {\n  return name in aliases && !!around && itemFor(around.getAttribute(\"data-ouro\")!) === aliases[name];\n}\n\n/**\n * The layer over the page: it never takes a pointer (only the tags and the bar do), sits above\n * every overlay, fades in over `--ouro-duration-base` (at once with reduced motion), and hides\n * while its own list is open, so the list's sheet is never under an outline.\n *\n * @internal\n * @claim \"The layer over the page: it\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > lets a click through an outline reach the control underneath, and only the tags take a pointer)\n * @claim \"The layer over the page: it\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > fades in when it opens, and appears at once with reduced motion)\n * @claim \"The layer over the page: it\" registry/ouro/components/ouro/inspector/inspector-styles.ts verify:fileLine(registry/ouro/components/ouro/inspector/inspector-styles.ts, /\"pointer-events-none\\sfixed\\sinset-0\\sz-\\[calc\\(var\\(--ouro-layer\\)\\+1\\)\\]/)\n */\nconst layerClass =\n  \"pointer-events-none fixed inset-0 z-[calc(var(--ouro-layer)+1)] opacity-100 \" +\n  \"motion-safe:[transition:opacity_var(--ouro-duration-base)_var(--ouro-ease-out)] starting:data-starting-style:opacity-0 \" +\n  \"[body:has([data-ouro-inspector-list])_&]:invisible\";\n\n/**\n * One outline: placed by `transform` from its component's box, and hidden, tag and all, while nothing of it shows. @internal\n *\n * @claim \"One outline: placed by `transform` from\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > hides the outline and tag of a component scrolled out of view inside a box, and clips one partly out)\n * @claim \"One outline: placed by `transform` from\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > does not outline itself, an overlay's wrappers, a hidden component or a part apart from its component)\n */\nconst outlineClass = \"absolute top-0 left-0 will-change-transform data-clipped:invisible\";\n\n/**\n * An outline's frame: its edges, drawn in the primary color, with no fill and a gap wherever a line\n * of text crosses them, cut (`clip-path`) to the part of its component that shows.\n *\n * @internal\n * @claim \"An outline's frame: its edges, drawn\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > leaves every line of the page's text as readable as it was, in light and dark: outlines step around text, and tags sit clear of text and of each other)\n * @claim \"An outline's frame: its edges, drawn\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > hides the outline and tag of a component scrolled out of view inside a box, and clips one partly out)\n */\nconst frameClass =\n  \"absolute inset-0 fill-none stroke-[color-mix(in_oklab,var(--primary)_75%,transparent)] [shape-rendering:crispEdges] \" +\n  \"in-data-spotlight:stroke-primary in-data-spotlight:stroke-2\";\n\n/**\n * An outline's name tag, a link to its docs, by the part of its component that shows, where it\n * covers no text and no other tag (above its start corner when that is clear). It hides, and\n * takes no pointer, where nowhere is clear, and while something else (a menu, a select list) lies\n * over it or its corner.\n *\n * @internal\n * @claim \"It hides, and takes no pointer\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > hides the tag of a component an open select list covers, and leaves its options within reach)\n * @claim \"It hides, and takes no pointer\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > hides a tag an overlay lies over though its component shows)\n * @claim \"where it covers no text and\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > leaves every line of the page's text as readable as it was, in light and dark: outlines step around text, and tags sit clear of text and of each other)\n */\nconst tagClass =\n  \"pointer-events-auto absolute top-0 left-0 z-1 inline-flex max-w-48 items-center truncate rounded-ouro-sm px-1.5 \" +\n  \"font-mono text-[11px] leading-4 font-medium text-primary-foreground no-underline bg-primary \" +\n  \"data-covered:invisible data-crowded:invisible \" +\n  \"outline-ring outline-offset-1 focus-visible:outline-2 focus-visible:outline-solid pointer-fine:hover:underline\";\n\n/**\n * The bar at the bottom of the screen, a landmark named by X-ray's label: what X-ray shows, the list and the way out. It steps aside while a dialog is open.\n * It keeps clear of the phone's home indicator, of a TabBar that shows (`--ouro-inspector-tab-bar`, which X-ray measures) and of\n * any other chrome the app pins to the bottom of the screen: set `--ouro-inspector-bottom` (on `:root` or a parent) to the distance to keep.\n *\n * @internal\n * @claim \"It keeps clear of the phone's\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > sits above a TabBar that shows, and above the distance the app sets)\n */\nconst pillClass =\n  \"pointer-events-auto in-data-modal:invisible fixed inset-x-0 mx-auto flex w-fit max-w-[calc(100%-2rem)] flex-wrap items-center gap-1 \" +\n  \"bottom-[max(1rem,env(safe-area-inset-bottom),var(--ouro-inspector-bottom,0px),var(--ouro-inspector-tab-bar,0px))] \" +\n  \"rounded-ouro-3xl bg-popover p-1 ps-4 text-sm leading-5 text-popover-foreground shadow-(--shadow-lg) ring-1 ring-border/60\";\n\n/** X-ray's label, on one line. @internal */\nconst labelClass = \"shrink-0 py-1.5 font-medium whitespace-nowrap\";\n\n/** The bar's word on the spotlit item, cut short where the bar runs out of room. It stays in place while empty, so a screen reader hears it when it fills. @internal */\nconst statusClass = \"ms-1 me-2 min-w-0 grow truncate py-1.5 text-muted-foreground\";\n\n/**\n * The list and Close buttons, at the end of the bar. Where the spotlit item's name leaves them no room, as on a phone, they wrap to a row of their own below it, so the name has the width of the bar.\n *\n * @internal\n * @claim \"Where the spotlit item's name leaves\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > fits its bar on a phone as narrow as 320px: the label on one line, the spotlit item named in full, both buttons in reach)\n */\nconst actionsClass = \"ms-auto flex shrink-0 items-center gap-1\";\n\n/** The list of components in the sheet. @internal */\nconst listClass = \"m-0 grid list-none gap-1 p-0\";\n\n/** A Docs or Source link in the list. @internal */\nconst linkClass =\n  \"rounded-ouro-sm px-1 text-sm leading-5 font-medium text-foreground underline underline-offset-4 \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid\";\n",
      "type": "registry:ui",
      "target": "@components/ouro/inspector/inspector-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/inspector/inspector.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type JSX } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { actionsClass, frameClass, isPartOf, itemFor, labelClass, layerClass, linkClass, listClass, outlineClass, pillClass, statusClass, tagClass } from \"@/registry/ouro/components/ouro/inspector/inspector-styles\";\nimport { Sheet } from \"@/registry/ouro/components/ouro/sheet/sheet\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useReducedMotion } from \"@/registry/ouro/lib/ouro/use-reduced-motion\";\n\n/** Props for {@link Inspector}. */\nexport interface InspectorProps {\n  /**\n   * Whether X-ray is on: outlines over every Ouro component, and the bar with the list. Pair it with `onOpenChange`.\n   *\n   * @claim \"Whether X-ray is on: outlines over\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > outlines every Ouro component on the page, each tagged with its item and linked to its docs)\n   */\n  open: boolean;\n  /** Called with `false` when the person closes X-ray (its Close button, or Escape). */\n  onOpenChange: (open: boolean) => void;\n  /**\n   * The address of an item's docs page, from its registry name, where each tag and the list link.\n   * Without it they link to Ouro's public docs, `https://ui.ouroboros.bot/docs/<item>/`.\n   * @claim \"The address of an item's docs\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > outlines every Ouro component on the page, each tagged with its item and linked to its docs)\n   */\n  docsHref?: ((item: string) => string) | undefined;\n  /** The address of the source that renders a component, if you publish it: the list shows a Source link where this returns one. */\n  sourceHref?: ((item: string, element: Element) => string | undefined) | undefined;\n  /** What X-ray is called, on its bar and as its list's title. Translate it here. @default \"X-ray\" */\n  label?: string | undefined;\n  /**\n   * A registry item to point out, such as `\"button\"`: X-ray scrolls the first one in the page's `main` (or else the first anywhere) to the middle of the screen (at once with reduced motion) and draws its outline stronger, with its tag placed first. Its bar says which item it shows, or that the page has none, and points one out when it appears.\n   *\n   * @claim \"A registry item to point out\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > points out the spotlit item: scrolls the first one into view, draws its outline stronger and names it on the bar)\n   * @claim \"A registry item to point out\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > scrolls to the spotlit item at once with reduced motion)\n   * @claim \"A registry item to point out\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > prefers the first spotlit item in the page's main content to one in its header)\n   * @claim \"A registry item to point out\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector geometry > places the spotlit component's tag first, so it takes the best place)\n   * @claim \"Its bar says which item it\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > says when the page has no spotlit item, and points one out when it appears)\n   */\n  spotlight?: string | undefined;\n\n  /** Not a prop. Ouro UI uses `open` with `onOpenChange`: `<Inspector open={xray} onOpenChange={setXray}>`. */\n  isOpen?: { 'Use <Inspector open={xray} onOpenChange={setXray}>': never };\n  /** Not a prop. `onOpenChange` gets `false` when X-ray closes: `onOpenChange={setXray}`. */\n  onClose?: { 'Use onOpenChange={setXray}': never };\n}\n\n/** One component X-ray found: its root element, its registry item, and a key that stays with the element. */\ninterface Found {\n  key: number;\n  item: string;\n  element: Element;\n}\n\nconst keys = new WeakMap<Element, number>();\nlet lastKey = 0;\nconst keyOf = (element: Element) => {\n  let key = keys.get(element);\n  if (key === undefined) {\n    key = ++lastKey;\n    keys.set(element, key);\n  }\n  return key;\n};\n\n/** Whatever a modal dialog shuts off from the page while it is open: Base UI hides it from assistive technology, or makes it inert. */\nconst shutOff = '[aria-hidden=\"true\"], [inert]';\n\n/** The invisible backdrop Base UI lays over the page under a modal overlay, to catch a press outside it. Ouro's own backdrops carry a `data-ouro` name. */\nconst catcher = '[role=\"presentation\"][data-base-ui-inert]:not([data-ouro])';\n\n/**\n * Whether a modal dialog is open in front of the page, so what it shuts off is out of reach: X-ray's\n * own layer is shut off with the page, by a dialog whose portal holds Base UI's backdrop (a modal\n * one; X-ray's own list aside). A popover leaves the page alone, and so does an open combobox list.\n */\nconst modalOpen = (own: Element) =>\n  !!own.closest(shutOff) &&\n  [...document.querySelectorAll('[role=\"dialog\"], [role=\"alertdialog\"]')].some(\n    (dialog) => !dialog.closest(shutOff) && !dialog.querySelector(\"[data-ouro-inspector-list]\") && !!dialog.closest('[data-ouro$=\"-portal\"]')?.querySelector(catcher),\n  );\n\n/**\n * Whether a person can see an element: it and everything around it are rendered, not `visibility: hidden`, and not fully transparent.\n * @claim \"Whether a person can see an element\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > does not outline a component no one can see, and outlines it while hover or focus shows it)\n */\nconst seen = (element: Element) => element.checkVisibility({ visibilityProperty: true, opacityProperty: true });\n\n/**\n * The box a component shows on the screen: its own, or, where its own box has no area (a fixed\n * region its content is placed in, as a Toaster's is), the box its visible content fills, leaving\n * out a visually hidden child (`sr-only`, one pixel square). `null` while nothing in it shows, as in\n * a Toaster with no toast.\n * @claim \"where its own box has no area\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector geometry > outlines a component whose own box has no area by the box its visible content fills, and not at all while nothing in it shows)\n * @claim \"`null` while nothing in it shows\" test/inspector-toaster.test.tsx verify:testExists(test/inspector-toaster.test.tsx::Inspector over a Toaster > outlines a Toaster only while it shows a toast, around its toasts)\n */\nfunction shownBox(element: Element): DOMRect | null {\n  const box = element.getBoundingClientRect();\n  if (box.width > 0 && box.height > 0) return box;\n  // Stryker disable next-line ArrayDeclaration: anything put in place of a child with nothing showing has no width or height, so the filter after it drops it as it drops nothing.\n  const inside = [...element.children].filter(seen).flatMap((child) => shownBox(child) ?? []).filter((inner) => inner.width > 1 || inner.height > 1);\n  // Stryker disable next-line ConditionalExpression: with nothing inside, the box below spans from +Infinity to -Infinity, and every caller drops a box that small.\n  if (inside.length === 0) return null;\n  const left = Math.min(...inside.map((inner) => inner.left));\n  const top = Math.min(...inside.map((inner) => inner.top));\n  return new DOMRect(left, top, Math.max(...inside.map((inner) => inner.right)) - left, Math.max(...inside.map((inner) => inner.bottom)) - top);\n}\n\n/**\n * Every visible Ouro component root in the page, in document order, but X-ray's own, one behind an\n * open dialog, one no one can see (fully transparent, as an action shown only on hover is until\n * then, or with nothing in it showing), and a part's root inside its own component (a Radio in its\n * RadioGroup counts once).\n * @claim \"Every visible Ouro component root in\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > outlines every Ouro component on the page, each tagged with its item and linked to its docs)\n * @claim \"Every visible Ouro component root in\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > does not outline itself, an overlay's wrappers, a hidden component or a part apart from its component)\n * @claim \"one no one can see\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > does not outline a component no one can see, and outlines it while hover or focus shows it)\n * @claim \"or with nothing in it showing\" test/inspector-toaster.test.tsx verify:testExists(test/inspector-toaster.test.tsx::Inspector over a Toaster > outlines a Toaster only while it shows a toast, around its toasts)\n */\nfunction findComponents(own: Element, modal: boolean): Found[] {\n  const found: Found[] = [];\n  for (const element of document.querySelectorAll(\"[data-ouro]\")) {\n    if (own.contains(element) || element.closest('[data-ouro=\"sheet\"]')?.querySelector(\"[data-ouro-inspector-list]\")) continue;\n    const name = element.getAttribute(\"data-ouro\")!;\n    const item = itemFor(name);\n    if (item === null || isPartOf(name, element.parentElement?.closest(\"[data-ouro]\")) || (modal && element.closest(shutOff))) continue;\n    if (!seen(element)) continue;\n    const box = shownBox(element);\n    // A visually hidden root (`sr-only`, one pixel square) has nothing to outline; a one-pixel line (a Separator) has.\n    if (!box || (box.width <= 1 && box.height <= 1)) continue;\n    found.push({ key: keyOf(element), item, element });\n  }\n  return found;\n}\n\n/**\n * The component X-ray points out: the first of the item in the page's main content, so a page's\n * own Switch comes before the one in its header, or else the first anywhere.\n */\nfunction spotlitOf(components: Found[], spotlight: string | undefined): Found | undefined {\n  const all = components.filter((component) => component.item === spotlight);\n  return all.find((component) => component.element.closest(\"main\")) ?? all[0];\n}\n\n/** A box's edges on the screen. */\ninterface Edges {\n  top: number;\n  right: number;\n  bottom: number;\n  left: number;\n}\n\n/**\n * What X-ray reads once an update from a component or an ancestor: its position and direction, and the edges it clips its overflow to on each axis.\n *\n * @claim \"What X-ray reads once an update\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > clips by each box a component's overflow belongs to, from the start edge on either axis)\n */\ninterface Ancestor {\n  position: string;\n  rtl: boolean;\n  x: [number, number] | null;\n  y: [number, number] | null;\n}\n\nconst readAncestor = (element: Element, cache: Map<Element, Ancestor>): Ancestor => {\n  let ancestor = cache.get(element);\n  if (!ancestor) {\n    const style = getComputedStyle(element);\n    const box = element.getBoundingClientRect();\n    // Overflow clips to the padding box, inside the borders and any scrollbar.\n    const left = box.left + element.clientLeft;\n    const top = box.top + element.clientTop;\n    ancestor = {\n      position: style.position,\n      rtl: style.direction === \"rtl\",\n      x: style.overflowX === \"visible\" ? null : [left, left + element.clientWidth],\n      y: style.overflowY === \"visible\" ? null : [top, top + element.clientHeight],\n    };\n    cache.set(element, ancestor);\n  }\n  return ancestor;\n};\n\n/**\n * The part of a component's box that its ancestors let show: the box cut to every ancestor up its\n * containing blocks that clips its overflow (a scrolling list, a card that hides its overflow).\n * A positioned box escapes the overflow of the ancestors between it and its containing block, and a\n * fixed one all of them.\n * @claim \"The part of a component's box\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > hides the outline and tag of a component scrolled out of view inside a box, and clips one partly out)\n * @claim \"The part of a component's box\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > clips by each box a component's overflow belongs to, from the start edge on either axis)\n * @claim \"The part of a component's box\" https://www.w3.org/TR/CSS2/visufx.html#overflow verify:urlOk(https://www.w3.org/TR/CSS2/visufx.html#overflow)\n * @claim \"A positioned box escapes the overflow\" https://www.w3.org/TR/CSS2/visufx.html#overflow verify:urlOk(https://www.w3.org/TR/CSS2/visufx.html#overflow)\n */\nfunction visiblePart(element: Element, box: DOMRect, cache: Map<Element, Ancestor>): Edges {\n  const part = { top: box.top, right: box.right, bottom: box.bottom, left: box.left };\n  let position = readAncestor(element, cache).position;\n  for (let parent = element.parentElement; parent && parent !== document.body && position !== \"fixed\"; parent = parent.parentElement) {\n    const ancestor = readAncestor(parent, cache);\n    if (position === \"absolute\" && ancestor.position === \"static\") continue;\n    position = ancestor.position;\n    if (ancestor.x) {\n      part.left = Math.max(part.left, ancestor.x[0]);\n      part.right = Math.min(part.right, ancestor.x[1]);\n    }\n    if (ancestor.y) {\n      part.top = Math.max(part.top, ancestor.y[0]);\n      part.bottom = Math.min(part.bottom, ancestor.y[1]);\n    }\n  }\n  return part;\n}\n\n/**\n * The topmost element at a point on the screen, X-ray's own aside, and the invisible backdrop Base\n * UI lays over the page under a modal menu or list, which covers nothing a person sees. Ouro's own\n * backdrops, which dim the page, count.\n */\nconst topAt = (x: number, y: number, own: Element) => document.elementsFromPoint(x, y).find((element) => !own.contains(element) && !element.matches(catcher));\n\n/**\n * The component an element is part of: for a control, the component it is a control of (a linked\n * card's link, stretched over the card from inside its heading, is the card's), and otherwise the\n * nearest one around it.\n */\nfunction ownerOf(element: Element): Element | null {\n  const control = element.closest(\"[data-ouro-control]\")?.getAttribute(\"data-ouro-control\");\n  let owner = element.closest(\"[data-ouro]\");\n  while (owner && control !== undefined && itemFor(owner.getAttribute(\"data-ouro\")!) !== control) owner = owner.parentElement!.closest(\"[data-ouro]\");\n  return owner;\n}\n\n/**\n * Whether something lies over a component where its tag goes, so the tag would sit on that\n * instead: at the component's corner by the tag, an element that is neither the component's own,\n * nor the page around it showing through, nor part of a component around it (a linked card's\n * link); or, over the tag itself (its centre, `tag`), an overlay's popup (a menu, a select list)\n * the component is not in.\n */\nfunction covered(root: Element, part: Edges, rtl: boolean, tag: [number, number], own: Element): boolean {\n  const start = (offset: number) => (rtl ? part.right - offset : part.left + offset);\n  const corner = topAt(start(Math.min(4, (part.right - part.left) / 2)), part.top + Math.min(4, (part.bottom - part.top) / 2), own);\n  if (corner && !root.contains(corner) && !corner.contains(root) && !ownerOf(corner)?.contains(root)) return true;\n  // The tag's centre is on the screen, where the root element at least lies.\n  const overlay = topAt(tag[0], tag[1], own)!.closest('[data-ouro$=\"-portal\"]');\n  return !!overlay && !overlay.contains(root);\n}\n\n// Every line of text a person can see on the screen, but X-ray's own.\nfunction textLines(own: Element): Edges[] {\n  // Stryker disable next-line ArrayDeclaration: a string in the list has no edges, so it crosses no edge and lies over no place.\n  const lines: Edges[] = [];\n  const range = document.createRange();\n  const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);\n  for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n    const parent = node.parentElement!;\n    if (!node.textContent!.trim() || own.contains(parent) || !parent.checkVisibility({ visibilityProperty: true, opacityProperty: true })) continue;\n    range.selectNodeContents(node);\n    for (const box of range.getClientRects()) {\n      if (box.width > 0 && box.height > 0 && box.bottom > 0 && box.top < innerHeight) lines.push({ top: box.top, right: box.right, bottom: box.bottom, left: box.left });\n    }\n  }\n  return lines;\n}\n\n// Whether two boxes share any area.\nconst overlap = (a: Edges, b: Edges) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;\n\n// The frame's four edges as an SVG path in the outline's own pixels, with a gap wherever a line of\n// text crosses an edge, so a frame never draws over text and lowers its contrast.\nfunction framePath(box: DOMRect, lines: Edges[]): string {\n  const edges = [\n    { across: true, at: box.top, from: box.left, to: box.right },\n    { across: true, at: box.bottom - 1, from: box.left, to: box.right },\n    { across: false, at: box.left, from: box.top, to: box.bottom },\n    { across: false, at: box.right - 1, from: box.top, to: box.bottom },\n  ];\n  let path = \"\";\n  for (const { across, at, from, to } of edges) {\n    // The stretches of the edge a line of text crosses, a pixel wider on each side.\n    const gaps = lines\n      .filter((line) => (across ? line.top < at + 1 && line.bottom > at : line.left < at + 1 && line.right > at))\n      .map((line) => (across ? [line.left - 1, line.right + 1] : [line.top - 1, line.bottom + 1]) as [number, number])\n      .sort((a, b) => a[0] - b[0]);\n    let start = from;\n    for (const [gapStart, gapEnd] of [...gaps, [to, to] as [number, number]]) {\n      const end = Math.min(gapStart, to);\n      if (end > start) path += across ? `M${start - box.left} ${at - box.top + 0.5}H${end - box.left}` : `M${at - box.left + 0.5} ${start - box.top}V${end - box.top}`;\n      start = Math.max(start, gapEnd);\n    }\n  }\n  return path;\n}\n\n// Where a tag goes: the first place by its component's visible part, in this order, that is on the\n// screen and clear of text, of the tags placed before it and of X-ray's bar: above the start\n// corner, inside it, above the end corner, inside it, inside the bottom start corner, below it.\n// Above and below are only where a scrolling box does not cut that edge. `null` when nowhere is\n// clear, and the tag hides.\nfunction tagPlace(box: DOMRect, part: Edges, rtl: boolean, size: [number, number], clear: Edges[]): { x: number; y: number; inside: boolean } | null {\n  const [width, height] = size;\n  const start = rtl ? part.right - width : part.left;\n  const end = rtl ? part.left : part.right - width;\n  const above = part.top <= box.top;\n  const below = part.bottom >= box.bottom;\n  const places = [\n    above && { x: start, y: part.top - height, inside: false },\n    { x: start, y: part.top, inside: true },\n    above && { x: end, y: part.top - height, inside: false },\n    { x: end, y: part.top, inside: true },\n    { x: start, y: part.bottom - height, inside: true },\n    below && { x: start, y: part.bottom, inside: false },\n  ];\n  for (const place of places) {\n    // Stryker disable next-line ConditionalExpression: a place left out is false, whose edges are undefined, and no check below passes them.\n    if (!place) continue;\n    const at = { top: place.y, right: place.x + width, bottom: place.y + height, left: place.x };\n    if (at.left >= 0 && at.right <= innerWidth && at.top >= 0 && at.bottom <= innerHeight && !clear.some((other) => overlap(at, other))) return place;\n  }\n  return null;\n}\n\nconst sameComponents = (a: Found[], b: Found[]) => a.length === b.length && a.every((entry, index) => entry.key === b[index]!.key && entry.item === b[index]!.item);\n\n/** Whether anything in the page outside X-ray is still moving, so its outline follows it frame by frame. */\nconst moving = (own: Element) =>\n  document.getAnimations().some((animation) => {\n    const target = (animation.effect as KeyframeEffect | null)?.target;\n    return animation.playState === \"running\" && Number.isFinite(animation.effect!.getComputedTiming().iterations) && !(target && own.contains(target));\n  });\n\n/** The events after which something may show or hide though nothing in the page changed: a pointer moving onto an element, and focus coming or going. */\nconst reveals = [\"pointerover\", \"focusin\", \"focusout\"];\n\nconst noSubscription = () => () => {};\n\n/** Ouro's public docs page for an item. */\nconst ouroDocs = (item: string) => `https://ui.ouroboros.bot/docs/${item}/`;\n\n/**\n * X-ray for a page built with Ouro HX: outlines every Ouro component on the page with its name,\n * linked to its docs, and lists them all for keyboard and screen reader users. Each tag names the\n * component's registry item; the bar at the bottom opens the list (a `Sheet`), every component in\n * document order with its \"Docs\" and, from `sourceHref`, \"Source\" links. Outlines follow\n * their components through scrolling, resizing, overlays and changes to the page, measured once a\n * frame at most; they never take a pointer, so the page stays usable underneath, and only the tags\n * do. X-ray shows only what a person can see and reach: a component no one can see (fully\n * transparent, as an action shown only on hover or focus is until then, or a Toaster with no toast)\n * has no outline until it shows, an outline is cut to the part a scrolling\n * box lets show, a tag hides while a menu or a list lies over it, the page behind an open modal\n * dialog is left alone, and a part (a Radio) counts with\n * its component (its RadioGroup). X-ray never draws over the page's text: an outline's edge breaks\n * where a line of text crosses it, and a tag sits where it covers no text and no other tag, or\n * hides. Its bar is a landmark named by `label`. Escape or Close turns it off, once Escape has\n * closed any other overlay. It renders nothing on the server.\n *\n * The bar floats above the bottom of the screen and above a `TabBar` that shows. To keep it clear of\n * other chrome the app pins to the bottom, set `--ouro-inspector-bottom` to the distance to keep,\n * such as `:root { --ouro-inspector-bottom: 6rem; }`.\n *\n * Use your browser's developer tools instead when you need more than which component is where;\n * the `data-ouro`, `data-ouro-control` and `data-ouro-part` attributes X-ray reads are there too.\n *\n * @group App setup\n * @see https://ui.ouroboros.bot/docs/inspector\n *\n * @example\n * const [xray, setXray] = useState(false);\n * <Switch label=\"X-ray\" checked={xray} onCheckedChange={setXray} />\n * <Inspector open={xray} onOpenChange={setXray} />\n * <Inspector open={xray} onOpenChange={setXray} sourceHref={(item) => sourceOf(item)} />\n * @claim \"X-ray for a page built with\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > outlines every Ouro component on the page, each tagged with its item and linked to its docs)\n * @claim \"Each tag names the component's registry\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > lists every component in document order in its sheet, with docs and source links)\n * @claim \"Outlines follow their components through scrolling\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > follows its components as the page scrolls and resizes)\n * @claim \"Outlines follow their components through scrolling\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > lets a click through an outline reach the control underneath, and only the tags take a pointer)\n * @claim \"a component no one can see\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > does not outline a component no one can see, and outlines it while hover or focus shows it)\n * @claim \"a component no one can see\" test/inspector-toaster.test.tsx verify:testExists(test/inspector-toaster.test.tsx::Inspector over a Toaster > outlines a Toaster only while it shows a toast, around its toasts)\n * @claim \"X-ray never draws over the page's\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > leaves every line of the page's text as readable as it was, in light and dark: outlines step around text, and tags sit clear of text and of each other)\n * @claim \"The bar floats above the bottom\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > sits above a TabBar that shows, and above the distance the app sets)\n * @claim \"Its bar is a landmark named\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > puts its bar in a landmark named by its label)\n */\nexport function Inspector(props: InspectorProps): JSX.Element | null {\n  const {\n    open,\n    onOpenChange,\n    docsHref = ouroDocs,\n    sourceHref,\n    label = \"X-ray\",\n    spotlight,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    isOpen,\n    onClose,\n  } = props;\n  useDevWarnings(\n    \"Inspector\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !label && [\"label is empty; it names the bar and its list\", '<Inspector label=\"X-ray\">'],\n          isOpen !== undefined && [\"isOpen is not a prop\", \"<Inspector open={xray} onOpenChange={setXray}>\"],\n          onClose !== undefined && [\"onClose is not a prop; onOpenChange gets false when X-ray closes\", \"<Inspector open={xray} onOpenChange={setXray}>\"],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  // The server has no page to measure, so X-ray appears once the page has hydrated.\n  const client = useSyncExternalStore(\n    noSubscription,\n    () => true,\n    () => false,\n  );\n  if (!open || !client) return null;\n  return createPortal(<InspectorLayer onOpenChange={onOpenChange} docsHref={docsHref} sourceHref={sourceHref} label={label} spotlight={spotlight} />, document.body);\n}\n\n/** X-ray while it is on: the outlines, the bar and its list. */\nfunction InspectorLayer({\n  onOpenChange,\n  docsHref,\n  sourceHref,\n  label,\n  spotlight,\n}: Pick<InspectorProps, \"onOpenChange\" | \"sourceHref\" | \"spotlight\"> & { docsHref: (item: string) => string; label: string }): JSX.Element {\n  const layer = useRef<HTMLDivElement>(null);\n  const [outlines] = useState(() => new Map<number, HTMLElement>());\n  const [found, setFound] = useState<Found[]>([]);\n  // Whether X-ray has read the page once, so its bar never says a spotlit item is missing before it has looked.\n  const [measured, setMeasured] = useState(false);\n  // The spotlit item, read by `place`, which the measuring effect keeps from the first render.\n  const spotlightRef = useRef(spotlight);\n  useLayoutEffect(() => {\n    spotlightRef.current = spotlight;\n  });\n  const [entering, setEntering] = useState(true);\n  // Focus goes back where it was when X-ray closes from its own bar or Escape.\n  const [returnFocus] = useState(() => document.activeElement);\n\n  /**\n   * Puts each outline over its component, cut to the part of it that shows: every box read first,\n   * then every outline written, so the page lays out once. An outline with nothing showing hides,\n   * and so does its tag.\n   * @claim \"Puts each outline over its component\" registry/ouro/components/ouro/inspector/inspector.test.tsx verify:testExists(registry/ouro/components/ouro/inspector/inspector.test.tsx::Inspector > hides the outline and tag of a component scrolled out of view inside a box, and clips one partly out)\n   * @claim \"Puts each outline over its component\" registry/ouro/components/ouro/inspector/inspector.tsx verify:fileLine(registry/ouro/components/ouro/inspector/inspector.tsx, /const\\sboxes\\s=\\scomponents\\.map\\(\\(component\\)\\s=>\\sshownBox\\(component\\.element\\)\\s\\?\\?\\snew\\sDOMRect\\(\\)\\)/)\n   */\n  const place = (all: Found[]) => {\n    const own = layer.current!;\n    // An outline React has yet to render is placed once it has, from the layout effect below.\n    const components = all.filter((component) => outlines.has(component.key));\n    const ancestors = new Map<Element, Ancestor>();\n    // A component that stopped showing since it was found (a toast gone) has no box, and hides until the next measure drops it.\n    const boxes = components.map((component) => shownBox(component.element) ?? new DOMRect());\n    const parts = components.map((component, index) => visiblePart(component.element, boxes[index]!, ancestors));\n    const shown = parts.map((part) => part.right > part.left && part.bottom > part.top);\n    const lines = textLines(own);\n    const tags = components.map((component) => outlines.get(component.key)!.lastElementChild as HTMLElement);\n    const sizes = tags.map((tag): [number, number] => [tag.offsetWidth, tag.offsetHeight]);\n    // Each tag keeps clear of the page's text, of the tags placed before it, and of the bar.\n    const bar = own.querySelector(\"section\")!.getBoundingClientRect();\n    const clear: Edges[] = [...lines, { top: bar.top, right: bar.right, bottom: bar.bottom, left: bar.left }];\n    // The spotlit component's tag is placed first, so it takes the best place.\n    const chosen = spotlitOf(components, spotlightRef.current);\n    const first = components.findIndex((component) => component === chosen);\n    const order = components.map((_, index) => index);\n    // Stryker disable next-line EqualityOperator: moving the first component to the front leaves the order as it was.\n    if (first > 0) order.unshift(...order.splice(first, 1));\n    // Stryker disable next-line ArrayDeclaration: every index is written below, over anything the list starts with.\n    const places: ({ x: number; y: number; inside: boolean } | null)[] = [];\n    for (const index of order) {\n      const component = components[index]!;\n      const spot = shown[index] ? tagPlace(boxes[index]!, parts[index]!, ancestors.get(component.element)!.rtl, sizes[index]!, clear) : null;\n      if (spot) clear.push({ top: spot.y, right: spot.x + sizes[index]![0], bottom: spot.y + sizes[index]![1], left: spot.x });\n      places[index] = spot;\n    }\n    const covers = components.map((component, index) => {\n      const spot = places[index];\n      return !!spot && covered(component.element, parts[index]!, ancestors.get(component.element)!.rtl, [spot.x + sizes[index]![0] / 2, spot.y + sizes[index]![1] / 2], own);\n    });\n    const paths = components.map((_, index) => framePath(boxes[index]!, lines));\n    components.forEach((component, index) => {\n      const outline = outlines.get(component.key)!;\n      const box = boxes[index]!;\n      const part = parts[index]!;\n      outline.style.transform = `translate(${box.left}px, ${box.top}px)`;\n      outline.style.width = `${box.width}px`;\n      outline.style.height = `${box.height}px`;\n      outline.toggleAttribute(\"data-clipped\", !shown[index]);\n      const cut = [part.top - box.top, box.right - part.right, box.bottom - part.bottom, part.left - box.left];\n      const frame = outline.firstElementChild as HTMLElement;\n      frame.style.clipPath = cut.some(Boolean) ? `inset(${cut.join(\"px \")}px)` : \"\";\n      frame.querySelector(\"path\")!.setAttribute(\"d\", paths[index]!);\n      const tag = tags[index]!;\n      const spot = places[index];\n      tag.toggleAttribute(\"data-crowded\", !spot);\n      tag.toggleAttribute(\"data-inside\", !!spot?.inside);\n      tag.toggleAttribute(\"data-covered\", covers[index]!);\n      if (spot) tag.style.transform = `translate(${spot.x - box.left}px, ${spot.y - box.top}px)`;\n    });\n  };\n\n  useEffect(() => {\n    const own = layer.current!;\n    let frame = 0;\n    // Whether anything moved at the last measure.\n    let moved: boolean | undefined;\n    const observed = new Set<Element>();\n    const resizes = new ResizeObserver(() => schedule());\n    const update = () => {\n      frame = 0;\n      const modal = modalOpen(own);\n      // While a dialog shuts off the page, the bar (shut off with it) steps aside so it never covers the dialog.\n      own.toggleAttribute(\"data-modal\", modal);\n      // The bar sits a gap above a TabBar that shows, measured from the layer, which fills the screen.\n      const tabBar = [...document.querySelectorAll('[data-ouro=\"tab-bar\"] > nav:not([data-closed])')]\n        .map((bar) => bar.getBoundingClientRect())\n        .find((box) => box.height > 0);\n      if (tabBar) own.style.setProperty(\"--ouro-inspector-tab-bar\", `${own.getBoundingClientRect().bottom - tabBar.top + 8}px`);\n      else own.style.removeProperty(\"--ouro-inspector-tab-bar\");\n      const next = findComponents(own, modal);\n      for (const component of next) {\n        if (observed.has(component.element)) continue;\n        observed.add(component.element);\n        resizes.observe(component.element);\n      }\n      setFound((current) => (sameComponents(current, next) ? current : next));\n      setMeasured(true);\n      place(next);\n      // While anything moves, and once more the frame after: in the frame a transition ends, WebKit\n      // can still read the element's style from before it ended, with no animation left running,\n      // and nothing tells X-ray when the style catches up.\n      const now = moving(own);\n      if (now || moved) schedule();\n      moved = now;\n    };\n    const schedule = () => {\n      if (!frame) frame = requestAnimationFrame(update);\n    };\n    // X-ray's own writes (each outline's position) are no change to the page.\n    const mutations = new MutationObserver((records) => {\n      if (records.some((record) => !own.contains(record.target))) schedule();\n    });\n    mutations.observe(document.body, { subtree: true, childList: true, attributes: true, characterData: true });\n    addEventListener(\"scroll\", schedule, { capture: true, passive: true });\n    addEventListener(\"resize\", schedule);\n    // Hover and focus change what shows without changing the page: an action that appears on hover or focus.\n    for (const type of reveals) addEventListener(type, schedule, true);\n    schedule();\n    return () => {\n      cancelAnimationFrame(frame);\n      mutations.disconnect();\n      resizes.disconnect();\n      removeEventListener(\"scroll\", schedule, { capture: true });\n      removeEventListener(\"resize\", schedule);\n      for (const type of reveals) removeEventListener(type, schedule, true);\n    };\n    // `place` reads only the outlines map, which lives as long as the layer.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  // Outlines React has just rendered are placed before the browser paints them.\n  useLayoutEffect(() => place(found));\n\n  // The first spotlit component comes to the middle of the screen once per item, when X-ray first finds it.\n  const spotlit = spotlitOf(found, spotlight);\n  const pointedAt = useRef<string | undefined>(undefined);\n  const reduced = useReducedMotion();\n  useEffect(() => {\n    if (!spotlit || pointedAt.current === spotlit.item) return;\n    pointedAt.current = spotlit.item;\n    spotlit.element.scrollIntoView({ block: \"center\", inline: \"nearest\", behavior: reduced ? \"instant\" : \"smooth\" });\n  }, [spotlit, reduced]);\n\n  // The layer fades in from `@starting-style` while it carries `data-starting-style`, then drops it.\n  useEffect(() => {\n    const own = layer.current!;\n    let live = true;\n    void (async () => {\n      void getComputedStyle(own).opacity;\n      await new Promise((resolve) => requestAnimationFrame(resolve));\n      await Promise.allSettled(own.getAnimations().map((animation) => animation.finished));\n      if (live) setEntering(false);\n    })();\n    return () => {\n      live = false;\n    };\n  }, []);\n\n  const close = () => {\n    const active = document.activeElement;\n    if (returnFocus instanceof HTMLElement && returnFocus.isConnected && (active === document.body || layer.current!.contains(active))) returnFocus.focus();\n    onOpenChange(false);\n  };\n  const closeRef = useRef(close);\n  useLayoutEffect(() => {\n    closeRef.current = close;\n  });\n\n  // Escape turns X-ray off, unless it closes something else first: X-ray's own list, or another\n  // overlay. Overlays close on Escape as it bubbles to the document, and stop it or mark it handled,\n  // so X-ray listens after them, on the window, and leaves an Escape anything has handled.\n  useEffect(() => {\n    const onKeyDown = (event: KeyboardEvent) => {\n      if (event.key === \"Escape\" && !event.defaultPrevented) closeRef.current();\n    };\n    addEventListener(\"keydown\", onKeyDown);\n    return () => removeEventListener(\"keydown\", onKeyDown);\n  }, []);\n\n  const count = `${found.length} ${found.length === 1 ? \"component\" : \"components\"}`;\n  return (\n    <div ref={layer} data-ouro=\"inspector\" data-ouro-part=\"layer\" data-starting-style={entering ? \"\" : undefined} className={layerClass}>\n      <div aria-hidden=\"true\">\n        {found.map((component) => (\n          <div\n            key={component.key}\n            ref={(element) => {\n              if (element) outlines.set(component.key, element);\n              else outlines.delete(component.key);\n            }}\n            data-ouro-inspector-outline=\"\"\n            data-spotlight={component === spotlit ? \"\" : undefined}\n            className={outlineClass}\n          >\n            <div data-ouro-inspector-frame=\"\" className={frameClass}>\n              <svg className=\"absolute inset-0 size-full overflow-visible\">\n                <path d=\"\" />\n              </svg>\n            </div>\n            <a data-ouro-control=\"inspector\" data-ouro-part=\"tag\" href={docsHref(component.item)} target=\"_blank\" rel=\"noreferrer\" tabIndex={-1} className={tagClass}>\n              {component.item}\n            </a>\n          </div>\n        ))}\n      </div>\n      <section aria-label={label} className={pillClass}>\n        <span aria-hidden=\"true\" className={labelClass}>\n          {label}\n        </span>\n        {spotlight !== undefined && (\n          <span role=\"status\" className={statusClass}>\n            {measured && (spotlit ? `Showing ${spotlight}` : `No ${spotlight} on this page`)}\n          </span>\n        )}\n        <span className={actionsClass}>\n          <Sheet\n            title={label}\n            description=\"Every Ouro HX component on this page, in order.\"\n            trigger={\n              <Button variant=\"plain\" size=\"sm\" data-ouro-control=\"inspector\" data-ouro-part=\"list\">\n                {count}\n              </Button>\n            }\n          >\n            <ol data-ouro-inspector-list=\"\" className={listClass}>\n              {found.map((component) => {\n                const source = sourceHref?.(component.item, component.element);\n                return (\n                  <li key={component.key} className=\"flex min-h-9 items-center justify-between gap-3\">\n                    <code className=\"font-mono text-sm leading-5 text-foreground\">{component.item}</code>\n                    <span className=\"flex shrink-0 items-center gap-2\">\n                      <a data-ouro-control=\"inspector\" data-ouro-part=\"docs\" href={docsHref(component.item)} target=\"_blank\" rel=\"noreferrer\" className={linkClass}>\n                        Docs<span className=\"sr-only\"> for {component.item} (opens in a new tab)</span>\n                      </a>\n                      {source !== undefined && (\n                        <a data-ouro-control=\"inspector\" data-ouro-part=\"source\" href={source} target=\"_blank\" rel=\"noreferrer\" className={linkClass}>\n                          Source<span className=\"sr-only\"> of {component.item} (opens in a new tab)</span>\n                        </a>\n                      )}\n                    </span>\n                  </li>\n                );\n              })}\n            </ol>\n          </Sheet>\n          <Button variant=\"plain\" size=\"sm\" data-ouro-control=\"inspector\" data-ouro-part=\"close\" onClick={close}>\n            Close\n          </Button>\n        </span>\n      </section>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/inspector/inspector.tsx"
    }
  ],
  "docs": "X-ray for a page built with Ouro HX: outlines every Ouro component on the page with its name, linked to its docs, and lists them all for keyboard and screen reader users. Import: import { Inspector } from \"@/components/ouro/inspector/inspector\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: button, sheet, 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/inspector.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}