{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "message",
  "title": "Message",
  "description": "One message in a chat: who wrote it, their avatar and what they wrote, with any attachments under it.",
  "registryDependencies": [
    "@ouro/avatar",
    "@ouro/button",
    "@ouro/kbd",
    "@ouro/lib-announce",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-key-shortcuts",
    "@ouro/lib-row-hover",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-platform",
    "@ouro/menu",
    "@ouro/skeleton",
    "@ouro/tooltip"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/message/message-parts.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useLayoutEffect, useState, type CSSProperties, type FocusEvent, type JSX, type KeyboardEvent, type RefObject, type SVGProps } from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { Kbd } from \"@/registry/ouro/components/ouro/kbd/kbd\";\nimport type { MenuAnchor, MenuEntry } from \"@/registry/ouro/components/ouro/menu/menu\";\nimport type { MessageAction } from \"@/registry/ouro/components/ouro/message/message\";\nimport { Tooltip } from \"@/registry/ouro/components/ouro/tooltip/tooltip\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { ariaKeyShortcuts } from \"@/registry/ouro/lib/ouro/key-shortcuts\";\nimport { useRowHover, type RowLayer, type RowMenuAt } from \"@/registry/ouro/lib/ouro/row-hover\";\nimport { usePlatform } from \"@/registry/ouro/lib/ouro/use-platform\";\n\n// The action bar: a small raised pill above the bubble's top corner (over a post's top end)\n// or beside the bubble's top end, shown on hover (a mouse's only), while focus is in the message,\n// after a tap, and while its menu is open; keyboard focus shows it at once. A mouse over the\n// hidden bar is over the message, which shows it; on a touch screen the hidden bar lets taps\n// through, so a tap on the message above never lands on it.\nconst barClass =\n  \"z-10 flex items-center gap-0.5 rounded-ouro-lg bg-popover p-0.5 text-popover-foreground ring-1 ring-border/60 shadow-(--shadow-lg) forced-colors:border forced-colors:border-solid \" +\n  \"opacity-0 transition-opacity duration-(--ouro-duration-fast) ease-[ease] \" +\n  \"pointer-fine:group-hover/message:opacity-100 group-focus-within/message:opacity-100 group-focus-within/message:transition-none \" +\n  \"group-data-ouro-message-active/message:opacity-100 data-menu-open:opacity-100 \" +\n  \"pointer-coarse:pointer-events-none pointer-coarse:group-focus-within/message:pointer-events-auto \" +\n  \"pointer-coarse:group-data-ouro-message-active/message:pointer-events-auto pointer-coarse:data-menu-open:pointer-events-auto\";\n\n\n/** The bar's buttons that can take focus, in order. */\nconst buttons = (bar: HTMLElement) => [...bar.querySelectorAll<HTMLElement>(\"[data-ouro-message-action]:not(:disabled)\")];\n\n// The menu button's key in the bar's roving focus, apart from the actions' keys by its leading space.\n// Stryker disable next-line StringLiteral: any key no action uses works the same.\nconst MENU_KEY = \" menu\";\n\ntype MenuModule = typeof import(\"@/registry/ouro/components/ouro/menu/menu\");\n\n// Menu's code, loaded once, as the first bar with a menu mounts, so a press opens the menu at once.\nlet menuModule: Promise<MenuModule> | undefined;\nlet menuLoaded: MenuModule | undefined;\nconst loadMenu = () => (menuModule ??= import(\"@/registry/ouro/components/ouro/menu/menu\").then((module) => (menuLoaded = module)));\n\n/**\n * What a message in a `MessageList` gives the list's one action bar and menu, in place of drawing its own.\n *\n * @internal\n */\nexport interface MessageBarData {\n  actions: readonly MessageAction[];\n  menu: readonly MenuEntry[] | undefined;\n  reactions: readonly MessageAction[] | undefined;\n  /** The toolbar's name. */\n  label: string;\n  /** The menu button's name. */\n  menuLabel: string;\n  /** The menu's own name, for the menu the list opens. */\n  menuName: string;\n  /** The name of the row of reactions at the top of the menu. */\n  reactionsLabel: string;\n  start: boolean;\n  post: boolean;\n  beside: string | undefined;\n  /** Where in the message the bar goes. */\n  slot: () => HTMLElement | null;\n}\n\n/** The reactions at the top of a message's menu, as a row of menu items named by their labels, then the rest of its entries. */\nfunction MessageMenuItems({ M, reactions, entries, label }: { M: MenuModule; reactions: readonly MessageAction[] | undefined; entries: readonly MenuEntry[] | undefined; label: string }): JSX.Element {\n  const shown = reactions ?? [];\n  // Left and right move along the row, as they would along a toolbar; up and down are the menu's, through every item.\n  const keyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n    const items = [...event.currentTarget.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"])')];\n    const at = items.indexOf(event.target as HTMLElement);\n    const rtl = getComputedStyle(event.currentTarget).direction === \"rtl\";\n    const step = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1 }[event.key];\n    if (step === undefined || at < 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    items[(at + step + items.length) % items.length]!.focus();\n  };\n  return (\n    <>\n      {shown.length > 0 && (\n        <div\n          role=\"group\"\n          aria-label={label}\n          data-ouro-message-menu-reactions=\"\"\n          onKeyDown={keyDown}\n          // Each reaction's shortcut sits under its emoji, small, so the row keeps its width; the emoji share one line.\n          className=\"flex items-center gap-0.5 pb-1 [&>[role=menuitem]]:flex-1 [&>[role=menuitem]]:flex-col [&>[role=menuitem]]:gap-0.5 [&>[role=menuitem]]:px-1.5 [&>[role=menuitem]>kbd]:ms-0 [&>[role=menuitem]>kbd]:text-[0.625rem] [&>[role=menuitem]>kbd]:text-foreground\"\n        >\n          {shown.map((reaction) => (\n            <M.MenuItem key={reaction.key} onClick={reaction.onClick} disabled={reaction.disabled} shortcut={reaction.shortcut}>\n              <span aria-hidden=\"true\" data-ouro-message-menu-reaction={reaction.key} className=\"inline-flex size-5 items-center justify-center text-lg leading-none [&>svg]:size-5\">\n                {reaction.icon}\n              </span>\n              <span className=\"sr-only\">{reaction.label}</span>\n            </M.MenuItem>\n          ))}\n        </div>\n      )}\n      {shown.length > 0 && entries !== undefined && entries.length > 0 && <M.MenuSeparator />}\n      <M.MenuEntries entries={entries ?? []} />\n    </>\n  );\n}\n\n/**\n * The action bar of `Message`: a toolbar of icon buttons with tooltips, and the menu button\n * last. One Tab stop: the arrow keys, Home and End move between its buttons. Message loads this\n * file only for a message with actions or a menu.\n *\n * @internal\n */\nexport function MessageActionBar({\n  actions,\n  menu,\n  reactions,\n  // Stryker disable next-line StringLiteral: Message always passes its own label, and the list's bar opens the list's menu, which takes the label from the message's data.\n  reactionsLabel = \"Reactions\",\n  label,\n  menuLabel,\n  start,\n  post,\n  beside,\n  onMenu,\n  row,\n}: {\n  actions: readonly MessageAction[];\n  menu: readonly MenuEntry[] | undefined;\n  /** The reactions at the top of the menu. */\n  reactions?: readonly MessageAction[] | undefined;\n  reactionsLabel?: string | undefined;\n  label: string;\n  menuLabel: string;\n  start: boolean;\n  /** Over a post's top end, a little lower than over a bubble, since a post's name line is its top. */\n  post: boolean;\n  /**\n   * Beside the bubble rather than over its corner: the space from the bubble's end to the\n   * message's (`start`: from the message's start to the bubble's), less `beside`, the room the\n   * avatar's column takes before the bubble. Undefined puts the bar over the corner.\n   */\n  beside?: string | undefined;\n  /**\n   * The bar is a MessageList's shared bar, on the message it is over: shown while it is there, and its\n   * menu button opens the list's shared menu, from this button.\n   */\n  onMenu?: ((button: HTMLElement) => void) | undefined;\n  /** The message a shared bar is on; the Tab stop the bar remembers belongs to that message. */\n  row?: Element | undefined;\n}): JSX.Element {\n  const platform = usePlatform();\n  const [menuOpen, setMenuOpen] = useState(false);\n  // Menu, once this bar's menu button has been pressed: until then the button stands alone.\n  const [M, setM] = useState<MenuModule | undefined>(undefined);\n  const openMenu = () =>\n    void loadMenu().then((Loaded) => {\n      setM(() => Loaded);\n      setMenuOpen(true);\n    });\n  const layered = onMenu !== undefined;\n  const hasMenu = (menu !== undefined && menu.length > 0) || (reactions !== undefined && reactions.length > 0);\n  // Fetched now, not on the first press, so nobody waits for the menu's code; it stays off the first\n  // paint. After every render, so a bar that gains a menu fetches it too; loadMenu fetches once.\n  useEffect(() => {\n    if (hasMenu) void loadMenu();\n  });\n  const keys = actions.filter((action) => !action.disabled).map((action) => action.key);\n  if (hasMenu) keys.push(MENU_KEY);\n  const [current, setCurrent] = useState<{ row: Element | undefined; key: string } | undefined>(undefined);\n  const tabStop = keys.find((key) => current !== undefined && current.row === row && key === current.key) ?? keys[0];\n  const keyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n    const list = buttons(event.currentTarget);\n    const at = list.indexOf(event.target as HTMLElement);\n    if (at < 0) return;\n    const rtl = getComputedStyle(event.currentTarget).direction === \"rtl\";\n    const step = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1 }[event.key];\n    const next = event.key === \"Home\" ? 0 : event.key === \"End\" ? list.length - 1 : step === undefined ? undefined : (at + step + list.length) % list.length;\n    if (next === undefined) return;\n    event.preventDefault();\n    list[next]!.focus();\n  };\n  const focus = (event: FocusEvent<HTMLDivElement>) => {\n    const key = (event.target as HTMLElement).getAttribute(\"data-ouro-message-action\");\n    // Stryker disable next-line ConditionalExpression: only the bar's buttons take focus, and a key of null falls back to the first button anyway.\n    if (key !== null) setCurrent({ row, key });\n  };\n  const iconButton = \"w-(--ouro-button-h) px-0\";\n  const more = <MoreIcon aria-hidden=\"true\" className=\"size-4\" />;\n  const bar = (\n    <div\n      role=\"toolbar\"\n      aria-label={label}\n      data-ouro-message-actions=\"\"\n      data-ouro-row-layer={layered && beside === undefined ? \"\" : undefined}\n      data-menu-open={menuOpen ? \"\" : undefined}\n      onKeyDown={keyDown}\n      onFocus={focus}\n      className={cn(layered ? layerClass : barClass, beside === undefined ? [\"absolute\", start ? \"start-2\" : \"end-2\", post ? \"-top-5\" : \"-top-8\"] : \"pointer-events-auto\")}\n      // A little way from the bubble while there is room; with none, the auto margin goes and the bar ends at the message's edge.\n      // Stryker disable next-line ConditionalExpression: a bar over the corner is placed by one inset, so these margins would move it nowhere.\n      style={beside === undefined ? undefined : { marginInline: start ? \"auto 0.25rem\" : \"0.25rem auto\" }}\n    >\n      {actions.map((action) => {\n        const button = (\n          <Button\n            data-ouro-control=\"message\"\n            data-ouro-part=\"action\"\n            data-ouro-message-action={action.key}\n            tone=\"secondary\"\n            variant=\"plain\"\n            size=\"sm\"\n            aria-label={action.label}\n            aria-keyshortcuts={action.shortcut === undefined ? undefined : ariaKeyShortcuts(action.shortcut as readonly string[], platform)}\n            disabled={action.disabled}\n            tabIndex={action.key === tabStop ? 0 : -1}\n            onClick={action.onClick}\n            className={iconButton}\n          >\n            <span aria-hidden=\"true\" className=\"inline-flex size-4 items-center justify-center text-base leading-none [&>svg]:size-4\">\n              {action.icon}\n            </span>\n          </Button>\n        );\n        return (\n          <Tooltip\n            key={action.key}\n            content={\n              action.shortcut === undefined ? (\n                action.label\n              ) : (\n                <span className=\"inline-flex items-center gap-1.5\">\n                  {action.label}\n                  <Kbd keys={action.shortcut as readonly string[]} aria-hidden=\"true\" />\n                </span>\n              )\n            }\n          >\n            {button}\n          </Tooltip>\n        );\n      })}\n      {hasMenu &&\n        (M && !layered ? (\n          <M.Menu\n            open={menuOpen}\n            onOpenChange={setMenuOpen}\n            // No tooltip here: one reopened as focus comes back from the menu would cover the bar of\n            // the message below, and the row of dots needs no words.\n            trigger={\n              <Button\n                data-ouro-control=\"message\"\n                data-ouro-part=\"menu\"\n                data-ouro-message-action={MENU_KEY}\n                tone=\"secondary\"\n                variant=\"plain\"\n                size=\"sm\"\n                aria-label={menuLabel}\n                tabIndex={tabStop === MENU_KEY ? 0 : -1}\n                className={iconButton}\n              >\n                {more}\n              </Button>\n            }\n          >\n            {/* The reactions on top, if any, then the rest: with none, just the menu's entries. */}\n            <MessageMenuItems M={M} reactions={reactions} entries={menu} label={reactionsLabel} />\n          </M.Menu>\n        ) : (\n          <Button\n            data-ouro-control=\"message\"\n            data-ouro-part=\"menu\"\n            data-ouro-message-action={MENU_KEY}\n            tone=\"secondary\"\n            variant=\"plain\"\n            size=\"sm\"\n            aria-label={menuLabel}\n            tabIndex={tabStop === MENU_KEY ? 0 : -1}\n            className={iconButton}\n            aria-haspopup=\"menu\"\n            aria-expanded={false}\n            // Menu's trigger takes this button's place, and Menu gives it focus when it closes. In a\n            // MessageList, the list's one menu opens instead.\n            onClick={layered ? (event) => onMenu(event.currentTarget) : openMenu}\n          >\n            {more}\n          </Button>\n        ))}\n    </div>\n  );\n  if (beside === undefined) return bar;\n  // The room beside the bubble, level with its top, out to the message's edge: 100cqw is the\n  // message's width (Message makes it a container) and 100% the bubble's.\n  const room: CSSProperties = {\n    position: \"absolute\",\n    top: 0,\n    ...(start ? { insetInlineEnd: \"100%\" } : { insetInlineStart: \"100%\" }),\n    width: `calc(100cqw - 100% - ${beside})`,\n    display: \"flex\",\n    // Where the bar does not fit, it ends at the message's edge (flex-start, the default, before the user's own bubble).\n    justifyContent: start ? undefined : \"flex-end\",\n    pointerEvents: \"none\",\n  };\n  return (\n    // Stryker disable next-line StringLiteral: the list finds its layer by the attribute alone ([data-ouro-row-layer]), never by its value.\n    <div data-ouro-message-actions-room=\"\" data-ouro-row-layer={layered ? \"\" : undefined} style={room}>\n      {bar}\n    </div>\n  );\n}\n\n// Loaded with this file: the list's one bar shows as soon as the pointer is over a message.\nconst layerClass =\n  \"z-10 flex items-center gap-0.5 rounded-ouro-lg bg-popover p-0.5 text-popover-foreground ring-1 ring-border/60 shadow-(--shadow-lg) forced-colors:border forced-colors:border-solid\";\n\n/**\n * A MessageList's shared action bar and menu: the bar on the message the pointer is over (or that\n * has keyboard focus, or was tapped), in that message's place for it, and the menu, which opens from\n * the bar's menu button, a right-click on a message, or `Shift+F10` or the context-menu key on one.\n * The list renders this once, whatever its length, and loads it with the first message that has\n * actions.\n *\n * @internal\n */\nexport function MessageBarLayer({ scroller, layer }: { scroller: RefObject<HTMLElement | null>; layer: RowLayer<MessageBarData> }): JSX.Element {\n  // The menu that opened, with Menu's code, which comes before it opens.\n  const [opened, setOpened] = useState<{ M: MenuModule; row: HTMLElement; data: MessageBarData; anchor: MenuAnchor; open: boolean } | null>(null);\n  // A virtual element for where the menu opens: the bar goes as it opens, so a box measured now.\n  const show = (row: HTMLElement, data: MessageBarData, anchor: MenuAnchor) => {\n    const open = (Loaded: MenuModule) => {\n      hover.hold(true);\n      setOpened({ M: Loaded, row, data, anchor, open: true });\n    };\n    // Loaded already (the bar's first showing loads it), it opens within this event, before the next frame.\n    if (menuLoaded) flushSync(() => open(menuLoaded!));\n    else void loadMenu().then(open);\n  };\n  const fromRow = (row: HTMLElement, at: RowMenuAt) => {\n    const data = layer.get(row)!;\n    if (!hasMenuEntries(data)) return false;\n    // From the keyboard, at the message's end: where its bar's menu button would be. A message with menu entries has a bar, so its slot is there in the message.\n    const box = data.slot()!;\n    show(row, data, at ?? frozen(box));\n    return true;\n  };\n  const hover = useRowHover(scroller, layer, { menu: fromRow });\n  const data = hover.row ? layer.get(hover.row) : undefined;\n  const slot = data?.slot() ?? null;\n  // One bar for the list, drawn once and moved from message to message: its element goes into the slot of the message it\n  // is on, and out of the page while it is on none. Moving to another message only updates it, so it is in place within\n  // the pointer's event, before the next frame, even on a slow computer; drawing a new bar for each would build every\n  // button and tooltip again.\n  const [host] = useState(() =>\n    // Stryker disable next-line ConditionalExpression,StringLiteral: no browser has an undefined document, so the test browsers cannot reach the server-render branch (null); the host's className is on the next line, where its mutants are tested.\n    typeof document === \"undefined\"\n      ? /* istanbul ignore next @preserve -- server only */ null\n      : barHost(),\n  );\n  const [shown, setShown] = useState<{ row: HTMLElement; data: MessageBarData } | null>(null);\n  // Stryker disable next-line ConditionalExpression,LogicalOperator: the slot is found only through the row's data, and the data only through the row, so a slot holds the other two.\n  const on = hover.row !== null && data !== undefined && slot !== null ? { row: hover.row, data } : null;\n  // Each message gives the layer a new data object on every render, so new data comes with a move to another message too.\n  if (on !== null && (shown === null || shown.data !== on.data)) setShown(on);\n  // The message a bar beside its bubble is on measures its width (100cqw) while the bar is there, and only then: the browser\n  // styles a container's insides as it lays the container out, which a list paid for each message it drew as it opened.\n  const [contained] = useState<{ row: HTMLElement | null }>(() => ({ row: null }));\n  useLayoutEffect(() => {\n    /* istanbul ignore if @preserve -- server only */\n    // Stryker disable next-line ConditionalExpression: the host is null only where there is no document (a server's render), and layout effects run only in a browser.\n    if (host === null) return;\n    if (slot === null) host.parentNode?.removeChild(host);\n    else if (host.parentNode !== slot) slot.appendChild(host);\n    contain(contained, on !== null && on.data.beside !== undefined ? on.row : null);\n  });\n  // Stryker disable next-line ArrayDeclaration: host and contained are state that is never set, so [host, contained] and [] run this effect alike.\n  useLayoutEffect(() => () => (host!.remove(), contain(contained, null)), [host, contained]);\n  // The menu's code, once the bar first shows, so the menu then opens at once.\n  // Stryker disable next-line ConditionalExpression,EqualityOperator: the layer mounts as the first row takes it, and the bar shows in that same commit or the next, so fetching a moment before it shows is the same fetch.\n  const showing = slot !== null;\n  useEffect(() => {\n    // Stryker disable next-line ConditionalExpression: the layer mounts as the first row takes it, and the bar shows in that same commit or the next, so fetching a moment before it shows is the same fetch.\n    if (showing) void loadMenu();\n  }, [showing]);\n  const close = (open: boolean) => {\n    /* istanbul ignore if @preserve -- Base UI asks this only to close: show() opens the menu */\n    // Stryker disable next-line ConditionalExpression: the menu is opened by show() and asks only to close.\n    if (open) return;\n    hover.hold(false);\n    setOpened((previous) => previous && { ...previous, open: false });\n  };\n  return (\n    <>\n      {\n        // The portal is there from the layer's first render, empty until a message is shown: React gives a portal's\n        // element its event listeners the first time it renders into it, and in WebKit a wheel listener restyles the\n        // whole page (151 ms on a long conversation), which then landed on the pointer's first move onto a message.\n        // Stryker disable next-line ConditionalExpression: the host is null only where there is no document (a server's render), and the layer arrives in a browser.\n        host !== null &&\n        createPortal(\n          shown !== null && <MessageActionBar\n            row={shown.row}\n            actions={shown.data.actions}\n            menu={shown.data.menu}\n            reactions={shown.data.reactions}\n            label={shown.data.label}\n            menuLabel={shown.data.menuLabel}\n            start={shown.data.start}\n            post={shown.data.post}\n            beside={shown.data.beside}\n            onMenu={(button) => show(shown.row, shown.data, frozen(button))}\n          />,\n          host,\n        )}\n      {opened !== null && (\n        <opened.M.Menu\n          anchor={opened.anchor}\n          open={opened.open}\n          onOpenChange={close}\n          aria-label={opened.data.menuName}\n          returnFocus={opened.row}\n          side=\"bottom\"\n          align=\"end\"\n        >\n          <MessageMenuItems M={opened.M} reactions={opened.data.reactions} entries={opened.data.menu} label={opened.data.reactionsLabel} />\n        </opened.M.Menu>\n      )}\n    </>\n  );\n}\n\n/** Moves the size container, for the room beside a bubble, from the message it was on to `row`, or takes it off when `row` is null. */\nfunction contain(contained: { row: HTMLElement | null }, row: HTMLElement | null): void {\n  // Stryker disable next-line ConditionalExpression: taking the container off a row and putting it back leaves the same style; this only spares the writes on each render.\n  if (contained.row === row) return;\n  const previous = contained.row;\n  if (previous !== null) {\n    previous.style.removeProperty(\"container-type\");\n    if (previous.getAttribute(\"style\") === \"\") previous.removeAttribute(\"style\");\n  }\n  row?.style.setProperty(\"container-type\", \"inline-size\");\n  contained.row = row;\n}\n\nconst hasMenuEntries = (data: MessageBarData) => (data.menu !== undefined && data.menu.length > 0) || (data.reactions !== undefined && data.reactions.length > 0);\n\n/**\n * The element the list's one bar renders into, moved from message to message: it draws no box of its own, and its\n * marker tells the list that a change in it, or its move, is the bar's alone.\n *\n * @claim \"it draws no box of its own\" registry/ouro/components/ouro/message/message-list.actions.test.tsx verify:testExists(registry/ouro/components/ouro/message/message-list.actions.test.tsx::MessageList actions > opens the menu within the event once its code has loaded, and draws the bar's host as no box of its own)\n */\nfunction barHost(): HTMLSpanElement {\n  const host = document.createElement(\"span\");\n  host.className = \"contents\";\n  // Stryker disable next-line StringLiteral: the list finds the host by the attribute alone ([data-ouro-message-bar-slot]), never by its value.\n  host.dataset[\"ouroMessageBarSlot\"] = \"\";\n  return host;\n}\n\n/** An element's box as it is now, for a menu that stays where it opened after the element goes. */\nfunction frozen(element: Element): MenuAnchor {\n  const box = element.getBoundingClientRect();\n  return { getBoundingClientRect: () => box };\n}\n\n/** A row of dots: more actions. */\nfunction MoreIcon(props: SVGProps<SVGSVGElement>): JSX.Element {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" {...props}>\n      <circle cx=\"5\" cy=\"12\" r=\"1.75\" />\n      <circle cx=\"12\" cy=\"12\" r=\"1.75\" />\n      <circle cx=\"19\" cy=\"12\" r=\"1.75\" />\n    </svg>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/message/message-parts.tsx"
    },
    {
      "path": "registry/ouro/components/ouro/message/message.tsx",
      "content": "\"use client\";\n\nimport {\n  isValidElement,\n  type CSSProperties,\n  useContext,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useRef,\n  useState,\n  type HTMLAttributes,\n  type JSX,\n  type MouseEvent,\n  type PointerEvent,\n  type ReactElement,\n  type ReactNode,\n  type Ref,\n  type SVGProps,\n} from \"react\";\nimport { Avatar, type AvatarPresence } from \"@/registry/ouro/components/ouro/avatar/avatar\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { Skeleton } from \"@/registry/ouro/components/ouro/skeleton/skeleton\";\nimport type { MenuEntry, MenuShortcut } from \"@/registry/ouro/components/ouro/menu/menu\";\nimport type { MessageActionBar, MessageBarData } from \"@/registry/ouro/components/ouro/message/message-parts\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { announce } from \"@/registry/ouro/lib/ouro/announce\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { RowLayerContext } from \"@/registry/ouro/lib/ouro/row-hover\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** Who wrote a message: the person using the app, the assistant, or the app itself. */\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\n/**\n * How a message is laid out: `default` for a conversation with an assistant, `chat` for a chat\n * between people, `post` for a post in a channel, and `reply` for a reply in its thread.\n */\nexport type MessageVariant = \"default\" | \"chat\" | \"post\" | \"reply\";\n\n/**\n * Where a `chat` or `reply` message's action bar sits: `corner` over the bubble's top corner, raised\n * over the line above it, or `beside` the bubble, past its end and level with its top.\n */\nexport type MessageActionsPlacement = \"corner\" | \"beside\";\n\n/**\n * How a `chat` message's bubble, or a `reply` drawn as one, looks: `filled`, the user's own in the\n * primary color and others' on the muted surface, round with a small corner toward the sender; or\n * `raised`, others' on a raised card and the user's own in a tint of the primary color.\n */\nexport type MessageBubble = \"filled\" | \"raised\";\n\n/** One action in a message's action bar: an icon button with a tooltip. */\nexport interface MessageAction {\n  /** Identifies the action among the message's actions (\"reply\"). */\n  key: string;\n  /** The button's name, which its tooltip shows too: \"Reply\". */\n  label: string;\n  /** What the button shows: an icon element (`<ReplyIcon />`) or an emoji. Screen readers hear `label` instead. */\n  icon: ReactNode;\n  /** Runs when the action is pressed. */\n  onClick: (event: MouseEvent<HTMLElement>) => void;\n  /** Shown, but cannot be pressed: an action the app has turned off for now. */\n  disabled?: boolean | undefined;\n  /**\n   * The keys that run it, as `Kbd` takes them (`[\"1\"]`), shown after its name in its tooltip and\n   * under its emoji in the menu's row of reactions, and given to screen readers. It only shows the keys; bind them in your app.\n   * @claim \"shown after its name in its tooltip\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > shows each action's shortcut in its tooltip and under its reaction in the menu, and gives it to screen readers)\n   */\n  shortcut?: MenuShortcut | undefined;\n}\n\n/** The message a message replies to, for Message's `quote`: who wrote it and a line of what they wrote. */\nexport interface MessageQuote {\n  /** Who wrote the quoted message: \"Ana Lind\", or \"You\". */\n  author: string;\n  /**\n   * What they wrote, or its start. One line shows, cut with an ellipsis.\n   * @claim \"One line shows, cut with\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message quote > shows the quote at the top of the message: a bar, the author in semibold and the excerpt on one line, cut with an ellipsis)\n   */\n  excerpt: string;\n  /** The author's picture, before the name: an `Avatar` element, `<Avatar name=\"Ana\" src={url} alt=\"\" size=\"xs\" />`. */\n  avatar?: ReactElement | undefined;\n  /**\n   * Makes the quote a button that shows the quoted message, as by scrolling to it. In a `MessageList`, which may not\n   * have drawn a message far up a long conversation, call its `actionsRef.current.reveal(id, { focus: true })`.\n   */\n  onActivate?: (() => void) | undefined;\n  /** What screen readers hear in place of the author's name, before the excerpt. @default `Quoting ${author}` */\n  label?: string | undefined;\n}\n\n/** The props Message adds to the `<article>` attributes it passes through. */\nexport interface MessageOwnProps {\n  /**\n   * Who wrote it. `user` is the person using the app: their messages sit at the end, in\n   * the primary color. `assistant` is anyone else, such as an agent, at the start. `system`\n   * is the app's own note (\"Ana joined\"), centered and quiet.\n   */\n  role: MessageRole | (string & { 'Use \"user\", \"assistant\" or \"system\"': never });\n  /**\n   * How the message is laid out. `default` suits a conversation with an assistant. `chat`\n   * suits people writing to each other: others' messages at the start under their name and\n   * time, the user's own at the end with only the time, each bubble at most 85% of the row's\n   * width and 36rem, so a line stays readable in a wide window. `chat` also suits a channel without threads, which reads as a chat.\n   * `post` is a post in a threaded channel, unboxed: the author's name and time, an optional\n   * `subject`, the text, then the `footer` and the `thread` under it, with room around it and\n   * a hairline from the text's start to the end between it and a post just before it. `bubble`\n   * sets how a `chat` message's bubble looks, and draws a `reply` as one. `reply`\n   * is a reply in a thread: the same line of name and time, with the text unboxed under it,\n   * starting where a post's text starts. In `post` and `reply` the user's own messages sit at\n   * the start too.\n   * @default \"default\"\n   *\n   * @claim \"`chat` suits people writing to each\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > fills the user's own bubble with the primary color and puts others' on the muted surface by default, each round with a smaller corner toward its sender)\n   * @claim \"each bubble at most 85% of\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message rows > keeps a bubble to 85% of its row and 36rem, however wide the window)\n   * @claim \"`post` is a post in a\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message post > is unboxed, with the name and time over the subject and text, and the footer and thread under them)\n   * @claim \"a hairline from the text's start\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message post > draws a hairline from the text's start to the end between two posts, and none above the first)\n   * @claim \"`reply` is a reply in a\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message post > lays a reply out unboxed under its name and time, at the start for everyone)\n   * @claim \"starting where a post's text starts\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message post > starts a reply's text where a post's text starts)\n   */\n  variant?: MessageVariant | (string & { 'Use \"default\", \"chat\", \"post\" or \"reply\"': never }) | undefined;\n  /**\n   * How a `chat` message's bubble looks. `filled`, the default, is a messaging app's: the user's\n   * own message filled as a primary button is (`--ouro-action`, else the primary color), others'\n   * on the muted surface, each round with a smaller corner toward its sender, with an edge that\n   * forced colors draw. Inside the user's own bubble, the theme's colors follow the fill, so a\n   * link (underlined), a mention, a quote, a button or a focus ring in it stays readable on it; on others', a link or mention in the primary color is\n   * a shade nearer the text color, so it keeps 4.5:1 on the muted surface. `raised` is a workplace chat's: others' messages on a raised card with\n   * a hairline and a small shadow, the user's own in a tint of the primary color. A `reply` with a\n   * `bubble` is laid out as a chat's message, for a thread that reads as a chat: the user's own at\n   * the end, others' at the start under their name, each in a bubble of that look. A `reply`\n   * without one stays unboxed, and `default` and `post` ignore it.\n   * @default \"filled\" on a `chat` message; unboxed on a `reply`\n   *\n   * @claim \"`filled`, the default, is a messaging\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > fills the user's own bubble with the primary color and puts others' on the muted surface by default, each round with a smaller corner toward its sender)\n   * @claim \"on others', a link or mention\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > keeps a link in the primary color at 4.5:1 or more on others' muted bubble)\n   * @claim \"own message filled as a primary button\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > fills the user's own bubble as a primary button is, from --ouro-action when the theme sets it)\n   * @claim \"with an edge that\" registry/ouro/components/ouro/message/message.test.tsx verify:fileLine(registry/ouro/components/ouro/message/message.test.tsx, /chromiumOnly\\(\"keeps both filled bubbles' edges under forced colors\"/)\n   * @claim \"link (underlined), a mention\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > underlines a link in the user's own filled bubble, and gives both filled bubbles a clear edge)\n   * @claim \"the theme's colors follow the fill\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > keeps the primary color readable inside the user's filled bubble: a link or mention in it takes the bubble's text color)\n   * @claim \"A `reply` with a\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > draws a reply given a bubble as a chat's message: the user's own filled at the end, others' at the start, and a reply without one unboxed)\n   * @claim \"`raised` is a workplace chat's\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > puts others' messages at the start on a raised bubble under their name and time, and the user's own at the end in a tint)\n   */\n  bubble?: MessageBubble | (string & { 'Use \"filled\" or \"raised\"': never }) | undefined;\n  /**\n   * The author's name. Screen readers hear it before the message, and the avatar's\n   * initials come from it. Required, so every message says who wrote it. The user's own\n   * name is read but not shown.\n   *\n   * Pass `null` while the name is still loading: a name-sized Skeleton line takes the name's\n   * place on its line, the avatar shimmers in its own shape, and screen readers hear\n   * `nameLoadingLabel`. Nothing moves when the name arrives.\n   * @claim \"Required, so every message says who\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message > is an article that says who wrote it, then what they wrote)\n   * @claim \"Required, so every message says who\" registry/ouro/components/ouro/message/message.test-d.ts verify:fileLine(registry/ouro/components/ouro/message/message.test-d.ts, /expectTypeOf<\\{\\srole:\\s\"user\"\\s\\}>\\(\\)\\.not\\.toExtend<MessageProps>/)\n   * @claim \"Pass `null` while the name is\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message > holds the name's place with a name-sized line while it loads, so nothing moves when it arrives)\n   */\n  name: string | null;\n  /** What screen readers hear while `name` is `null`, for other languages. @default \"Name loading\" */\n  nameLoadingLabel?: string | undefined;\n  /**\n   * What shows as the author's name in place of `name`, when plain text cannot draw it: their\n   * name with its emoji as pictures (`<EmojiText text={person.name} catalogue={catalogue} />`).\n   * `name` stays what screen readers hear and the avatar's initials come from.\n   *\n   * @claim \"`name` stays what screen readers hear\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message > shows nameContent as the author's name, while screen readers hear name and the initials come from it)\n   */\n  nameContent?: ReactNode;\n  /**\n   * A quiet tag after the author's name, such as \"AI agent\" for an agent or \"Guest\": small and\n   * muted beside the name, not a badge, and read after it (\"Halden, AI agent\"). Where the name\n   * is hidden (a `continued` message, the user's own `chat` messages) the tag is too, and both\n   * are still read.\n   * @claim \"A quiet tag after the author's\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message name tag > shows a quiet tag after the name in every layout, read after the name)\n   * @claim \"Where the name is hidden\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message name tag > hides the tag with the name, and still reads it)\n   */\n  nameTag?: string | undefined;\n  /**\n   * The author's picture URL. Without it the avatar shows initials; `false` shows no avatar.\n   * For the author's presence, pass `presence`. Pass an `Avatar` element instead for a square\n   * avatar or a color of your own: `avatar={<Avatar name=\"Ana\" src={url} alt=\"\" size=\"sm\" />}`\n   * (`alt=\"\"`, since the name is written beside it). In `chat`, the user's own messages show\n   * no avatar.\n   *\n   * @claim \"In `chat`, the user's own\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > shows an Avatar element the app passes, and no avatar on the user's own chat messages)\n   * @claim \"Pass an `Avatar` element instead for\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > shows an Avatar element the app passes, and no avatar on the user's own chat messages)\n   * @claim \"Without it the avatar shows initials\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message > shows the author's avatar from main's Avatar, silent because the name is written)\n   * @claim \"Without it the avatar shows initials\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message > shows a system message centered and quiet, without avatar or bubble)\n   */\n  avatar?: string | false | ReactElement | undefined;\n  /**\n   * When it was written, already formatted for the reader (\"9:41 AM\"), shown after the name.\n   * Format it in the browser after hydration, so the server and the reader's clock agree.\n   */\n  time?: string | undefined;\n  /** The same moment for machines, as an ISO date (`2026-05-01T09:41`): the `<time>` element's `dateTime`. */\n  dateTime?: string | undefined;\n  /**\n   * The message follows one from the same author: no avatar and no name line, so a run of\n   * messages reads as one. Its time shows beside it on hover and focus. Screen readers still\n   * hear the name and time. Not for `post`: every post shows its author.\n   *\n   * @claim \"Not for `post`: every post shows\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message post > keeps its avatar and name when continued, since every post shows its author)\n   * @claim \"The message follows one from the\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message chat > groups a continued message under the one before, without avatar or name, its time on hover)\n   */\n  continued?: boolean | undefined;\n  /** A post's subject, in semibold above its text. `post` only. */\n  subject?: ReactNode;\n  /** The message: text, or rich content such as a list or a code block. */\n  children?: ReactNode;\n  /**\n   * A short line above the message, before its quote and its text, saying where the message\n   * stands, such as \"Replied in thread\" over the message it replied to. Screen readers hear it\n   * first in the message's content, before the quote. Nothing shows when it is undefined, null,\n   * false or empty. For example: `<Message role=\"user\" name=\"Ana\" context=\"Replied in thread\" quote={{ author: \"Fen\", excerpt: \"Ship it?\" }}>Yes</Message>`.\n   *\n   * @claim \"Screen readers hear it first in the message's content\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message context > is read before the quote and the text)\n   */\n  context?: ReactNode | undefined;\n  /**\n   * The message this one replies to, at the top of the bubble or post, above the text: a bar,\n   * the author and a line of what they wrote, as Composer's `quote` shows it before the reply\n   * is sent. Screen readers hear it first, as \"Quoting Ana: …\". With `onActivate` it is a\n   * button, to show the quoted message.\n   *\n   * @claim \"as Composer's `quote` shows it\" registry/ouro/components/ouro/composer/composer.test.tsx verify:testExists(registry/ouro/components/ouro/composer/composer.test.tsx::Composer quote > looks as Message's quote does once the reply is sent)\n   * @claim \"Screen readers hear it first, as\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message quote > is read before the text, as the label and the excerpt)\n   * @claim \"With `onActivate` it is a button\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message quote > is a button with onActivate, named by the quote, which keyboard and pointer press)\n   */\n  quote?: MessageQuote | undefined;\n  /**\n   * Files and pictures sent with the message, shown under it: `<Attachment>` elements, and\n   * pictures as `<Lightbox layout=\"mosaic\">`, which keeps them to a chat's size and opens them\n   * full size.\n   */\n  attachments?: ReactNode;\n  /** Under the message: its reactions (`<ReactionBar>`), \"Edited\", whether it was delivered or seen. */\n  footer?: ReactNode;\n  /** Under a post, or a message in a channel without threads: its thread, as a `<ThreadSummary>`. */\n  thread?: ReactNode;\n  /**\n   * The message's actions, as icon buttons with tooltips in a small bar at the bubble's top end\n   * (`actionsPlacement`) or over a post's top end. The bar shows while the pointer is over\n   * the message, while focus is in it, and after a tap on a touch screen. It is a toolbar: one Tab stop, with the arrow\n   * keys moving between its buttons. In a `MessageList` the list draws one bar for all its\n   * messages, on the message the pointer is over (or that keyboard focus is in, or was tapped), and\n   * hides it as the pointer leaves, the list scrolls under it, the window loses focus or the menu opens,\n   * so at most one bar shows and none stays behind. Escape hides it.\n   *\n   * @claim \"In a `MessageList` the list draws\" registry/ouro/components/ouro/message/message-list.actions.test.tsx verify:testExists(registry/ouro/components/ouro/message/message-list.actions.test.tsx::MessageList actions > draws one bar for the whole list, on the message the pointer is over, and listens the same for a hundred messages as for two)\n   * @claim \"so at most one bar shows\" registry/ouro/components/ouro/message/message-list.actions.test.tsx verify:testExists(registry/ouro/components/ouro/message/message-list.actions.test.tsx::MessageList actions > hides the bar when the list scrolls under the pointer, and never shows more than one)\n   * @claim \"It is a toolbar: one Tab\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > is one Tab stop, and the arrow keys, Home and End move between its buttons)\n   * @claim \"The bar shows while the pointer\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > shows the bar on hover and while focus is in the message, and hides it otherwise)\n   */\n  actions?: readonly MessageAction[] | undefined;\n  /**\n   * Where the action bar sits on a `chat` or `reply` message. `beside` puts it just past the\n   * bubble's end, level with its top, so it covers neither the name nor the message and stays\n   * with the bubble however wide the row; where the row has no room left, it ends at the row's\n   * edge, over the bubble's corner. On the user's own `chat` message it sits before the bubble.\n   * `corner` puts it over the bubble's top corner, raised over the line above. A `post`'s bar is\n   * over its top end, and the default layout's over its bubble's corner.\n   *\n   * @default \"beside\" on a `reply`, \"corner\" on a `chat`\n   * @claim \"`beside` puts it just past the\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > puts a reply's bar beside its text, level with its top, clear of the name)\n   * @claim \"where the row has no room left\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > ends a bar beside a bubble at the row's edge when the bubble fills the row, with an avatar or without, right to left too)\n   * @claim \"On the user's own `chat` message\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > puts a chat bar beside the bubble when asked: past others' bubbles, before the user's own)\n   */\n  actionsPlacement?: MessageActionsPlacement | (string & { 'Use \"corner\" or \"beside\"': never }) | undefined;\n  /**\n   * More actions, in a menu that opens from the last button in the action bar: the same\n   * entries as Menu's `items`, each with an optional `icon` before its label and its `shortcut` at its end. The bar stays while the menu is open. The bar renders in the\n   * browser once its code loads, so server HTML has the message without it; Menu's code loads as\n   * soon as a bar with a menu is on the page, so the first press opens it without a wait. In a `MessageList`, the list has one menu for all its\n   * messages: the bar's menu button, a right-click on the message (except on a field, a link, a picture or\n   * selected text, which keep the browser's menu) and Shift+F10 or the context-menu key on it all open it, named by `actionsMenuLabel`, and\n   * closing it puts focus back on the message.\n   *\n   * @claim \"In a `MessageList`, the list has one menu\" registry/ouro/components/ouro/message/message-list.actions.test.tsx verify:testExists(registry/ouro/components/ouro/message/message-list.actions.test.tsx::MessageList actions > opens one menu from the bar's button and a right-click, with the reactions on top, and the same menu again for another message)\n   * @claim \"Menu's code loads as soon as\" registry/ouro/components/ouro/message/message.warm.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.warm.test.tsx::Message's menu code > is fetched as a bar with a menu mounts, before anyone presses its button)\n   * @claim \"Shift+F10 or the context-menu key\" registry/ouro/components/ouro/message/message-list.actions.test.tsx verify:testExists(registry/ouro/components/ouro/message/message-list.actions.test.tsx::MessageList actions > opens the menu from the keyboard on the focused message, and Escape puts focus back on it)\n   * @claim \"More actions, in a menu that\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > opens the menu from the last button, and keeps the bar while it is open)\n   */\n  menu?: readonly MenuEntry[] | undefined;\n  /**\n   * Reactions at the top of the message's menu, as a row of emoji: each an action whose `icon` is the\n   * emoji and whose `label` names it (\"Like\"). Left and right move along the row. Put one that opens\n   * a picker of every reaction last (\"More reactions\").\n   * @claim \"Reactions at the top of the\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message actions > puts the quick reactions at the top of the menu, named, and the arrow keys move along them)\n   */\n  quickReactions?: readonly MessageAction[] | undefined;\n  /** What screen readers hear for the row of reactions in the menu, for other languages. @default \"Reactions\" */\n  quickReactionsLabel?: string | undefined;\n  /** What screen readers hear for the action bar, for other languages. @default \"Message actions\" */\n  actionsLabel?: string | undefined;\n  /** What screen readers hear for the menu a `MessageList` opens for the message. @default `Message actions for ${name}` */\n  actionsMenuLabel?: string | undefined;\n  /** The menu button's name, for other languages. @default \"More actions\" */\n  menuLabel?: string | undefined;\n  /**\n   * The reply is still being written. The message is `aria-busy`, an empty one shows a\n   * typing indicator, and `MessageList` announces it once, when streaming ends.\n   */\n  streaming?: boolean | undefined;\n  /** What screen readers hear for the typing indicator, for other languages. @default \"Writing\" */\n  streamingLabel?: string | undefined;\n  /**\n   * The message did not send, and what the person can do about it: `{ onRetry, onDelete }`. A\n   * calm marker under it says \"Not sent\" beside Retry and Delete buttons, and stays until the app\n   * clears `failed`, so a failed send never goes quiet. Screen readers hear the marker as the\n   * message's description. It appears at once, with no motion. To put the text back in a\n   * `Composer` instead, set the Composer's `value` to it and delete the message.\n   * @claim \"A calm marker under it says\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message not sent > marks the message not sent under its bubble, with Retry and Delete, and describes the message with it)\n   * @claim \"and stays until the app clears\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message not sent > offers Retry alone without onDelete, and goes once the app clears failed)\n   * @claim \"Screen readers hear the marker as\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message not sent > keeps the app's own description beside the marker's)\n   * @claim \"It appears at once, with no\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message not sent > shows the marker at once, with nothing animating, under reduced motion too)\n   */\n  failed?: MessageFailed | false | undefined;\n  /**\n   * The person sent it and the app has not heard back yet. Only a send that takes longer than a\n   * second shows it: a small clock fades in beside the message, or after the time on a post or\n   * reply, taking no room, so a quick send never flashes and confirming it moves nothing. Screen\n   * readers hear \"Sending\" once, after that second, and as the message's description while it\n   * lasts. `failed` takes its place.\n   * @claim \"a small clock fades in beside the message\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > shows a %s %s message's clock %s its bubble after a second, taking no room)\n   * @claim \"or after the time on a post or\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > puts a pending %s's clock after its time, on the same line, taking no room)\n   * @claim \"taking no room\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > puts a continued reply's clock in its gutter, clear of a long first line)\n   * @claim \"Only a send that takes longer\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > still waits its second inside OuroProvider's reduced motion, which ends every transition)\n   * @claim \"once, after that second\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > announcements > says Sending once a second has passed, once for every message pending together)\n   * @claim \"once, after that second\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > announcements > says nothing for a send confirmed within the second)\n   * @claim \"`failed` takes its place\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > describes a pending message as Sending once it shows, gives way to failed, and drops the description once confirmed)\n   */\n  pending?: boolean | undefined;\n  /**\n   * When the pending send started, as `Date.now()` gave it. A `MessageList` draws a long\n   * conversation's messages again as the reader scrolls; with this, a pending message drawn again\n   * after its second shows its clock at once and says nothing again.\n   * @claim \"with this, a pending message drawn again\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message pending > announcements > shows the clock at once and says nothing for a message drawn again after its second)\n   */\n  pendingSince?: number | undefined;\n  /** What screen readers hear for a `pending` message, for other languages. @default \"Sending\" */\n  pendingLabel?: string | undefined;\n  /** What the marker under a `failed` message says, for other languages. @default \"Not sent\" */\n  failedLabel?: string | undefined;\n  /** The name of a `failed` message's retry button, for other languages. @default \"Retry\" */\n  retryLabel?: string | undefined;\n  /** The name of a `failed` message's delete button, for other languages. @default \"Delete\" */\n  deleteLabel?: string | undefined;\n  /** Layout only: margins (`mt-4`). Appearance classes warn in development; the colors follow `role`. */\n  className?: string | undefined;\n  ref?: Ref<HTMLElement> | undefined;\n\n  /** Not a prop. Who wrote it is `role`: `<Message role=\"user\" name=\"Ana\">`. */\n  from?: { 'Use <Message role=\"user\" name=\"Ana\">': never };\n  /** Not a prop. The author is `name`: `<Message role=\"user\" name=\"Ana\">`. */\n  sender?: { 'Use <Message role=\"user\" name=\"Ana\">': never };\n  /** Not a prop. The author is `name`: `<Message role=\"user\" name=\"Ana\">`. */\n  author?: { 'Use <Message role=\"user\" name=\"Ana\">': never };\n  /** Not a prop. The message is the children: `<Message role=\"user\" name=\"Ana\">Hi</Message>`. */\n  content?: { 'Use <Message role=\"user\" name=\"Ana\">Hi</Message>': never };\n  /** Not a prop. The user's own messages are `role=\"user\"`: `<Message role=\"user\" variant=\"chat\">`. */\n  own?: { 'Use <Message role=\"user\" variant=\"chat\">': never };\n  /** Not a prop. The time is `time`, formatted: `<Message time=\"9:41 AM\" dateTime={iso}>`. */\n  timestamp?: { 'Use <Message time=\"9:41 AM\" dateTime={iso}>': never };\n  /** Not a prop. The message this one replies to is `quote`: `<Message quote={{ author: \"Ana\", excerpt: \"Lunch?\" }}>`. */\n  replyTo?: { 'Use <Message quote={{ author: \"Ana\", excerpt: \"Lunch?\" }}>': never };\n  /** Not a prop. A message that did not send is `failed`: `<Message role=\"user\" failed={{ onRetry: retry }}>`. */\n  error?: { 'Use <Message role=\"user\" failed={{ onRetry: retry }}>': never };\n  /** Not a prop. A message that did not send is `failed`: `<Message role=\"user\" failed={{ onRetry: retry }}>`. */\n  status?: { 'Use <Message role=\"user\" failed={{ onRetry: retry }}>': never };\n  /** Not a prop. Retry is part of `failed`: `<Message role=\"user\" failed={{ onRetry: retry }}>`. */\n  onRetry?: { 'Use <Message role=\"user\" failed={{ onRetry: retry }}>': never };\n}\n\n/** What the person can do about a message of their own that did not send: `Message`'s `failed`. */\nexport interface MessageFailed {\n  /**\n   * Sends the message again. Required, so a message that did not send always offers another try.\n   * @claim \"Required, so a message that\" registry/ouro/components/ouro/message/message.test-d.ts verify:fileLine(registry/ouro/components/ouro/message/message.test-d.ts, /failed:\\s\\{\\sonDelete:\\s\\(\\)\\s=>\\svoid\\s\\}\\s\\}>\\(\\)\\.not\\.toExtend<MessageProps>/)\n   */\n  onRetry: () => void;\n  /** Deletes the message that did not send. Leave it out to offer Retry alone. */\n  onDelete?: (() => void) | undefined;\n}\n\n/** A Message whose avatar shows the author's presence, and the words it says. */\nexport interface MessagePresenceProps {\n  /**\n   * The author's presence, as Avatar's dot on the avatar's lower end corner: available,\n   * busy, away, do not disturb, offline or out of office, each in its own shape and tone. It\n   * shows wherever the avatar does, so not on a `continued` message or the user's own `chat`\n   * messages. With an `Avatar` element as `avatar`, pass `presence` to that Avatar instead.\n   * @claim \"as Avatar's dot on the avatar's\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message presence > shows the author's presence on the avatar in every variant, and says it)\n   * @claim \"It shows wherever the avatar does\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message presence > shows no dot where there is no avatar)\n   */\n  presence: AvatarPresence | (string & { 'dnd is \"do-not-disturb\"; ooo is \"out-of-office\"': never });\n  /**\n   * What the dot says, such as \"Busy\" or \"In a meeting\". Screen readers hear it on the avatar,\n   * as Avatar reads a presence beside a written name. Required with `presence`, so no dot is\n   * silent.\n   * @claim \"Screen readers hear it on the\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message presence > shows the author's presence on the avatar in every variant, and says it)\n   * @claim \"Required with `presence`, so no dot\" registry/ouro/components/ouro/message/message.test-d.ts verify:fileLine(registry/ouro/components/ouro/message/message.test-d.ts, /presence:\\s\"busy\"\\s\\}>\\(\\)\\.not\\.toExtend<MessageProps>/)\n   */\n  presenceLabel: string;\n}\n\n/** A Message without a presence dot. */\nexport interface MessageNoPresenceProps {\n  /** Leave it out for no dot; pass it with `presenceLabel` to show one. */\n  presence?: undefined;\n  /** Read only with `presence`. */\n  presenceLabel?: string | undefined;\n}\n\n/**\n * Props for {@link Message}: its own props, `presence` with `presenceLabel` or neither, and the\n * `<article>` attributes it passes through.\n */\nexport type MessageProps = Omit<HTMLAttributes<HTMLElement>, keyof MessageOwnProps | \"content\" | \"presence\" | \"presenceLabel\"> &\n  MessageOwnProps &\n  (MessagePresenceProps | MessageNoPresenceProps);\n\nconst roles = [\"user\", \"assistant\", \"system\"] as const;\n\nconst variants = [\"default\", \"chat\", \"post\", \"reply\"] as const;\n\nconst placements = [\"corner\", \"beside\"] as const;\n\nconst bubbles = {\n  user: \"rounded-ouro-2xl rounded-ee-ouro-md bg-primary px-3.5 py-2 text-primary-foreground\",\n  assistant: \"rounded-ouro-2xl rounded-es-ouro-md bg-muted px-3.5 py-2 text-foreground\",\n  system: \"bg-transparent text-center text-muted-foreground\",\n} as const;\n\n// A raised surface: the theme's card with its hairline and small shadow, for a chat's bubbles.\nconst raised = \"bg-card text-card-foreground ring-1 ring-border/60 shadow-(--shadow-sm)\";\n\n// The user's filled bubble is drawn as a primary button is (`--ouro-action`, else the primary color), and inside it\n// the theme's colors follow the fill, so a link, a mention, a quote, a card, a code block or a button in it stays\n// readable: the primary color, the foreground, the muted text, a primary button and the focus ring read as the\n// bubble's text color; the card, muted and accent surfaces as the fill, the accent a shade lighter for a hover; and a\n// primary button's hover and press as shades of its text color. The message sets the fill and its text color\n// (bubbleColors), because the bubble re-points the colors for what is inside it (filledColors). These are inline\n// custom properties, not classes, so they add nothing to an app's stylesheet.\nconst bubbleColors = {\n  \"--ouro-bubble\": \"var(--ouro-action,var(--primary))\",\n  \"--ouro-bubble-ink\": \"var(--ouro-action-foreground,var(--primary-foreground))\",\n} as CSSProperties;\nconst filledColors = {\n  \"--primary\": \"var(--ouro-bubble-ink)\",\n  \"--primary-foreground\": \"var(--ouro-bubble)\",\n  \"--foreground\": \"var(--ouro-bubble-ink)\",\n  \"--muted-foreground\": \"var(--ouro-bubble-ink)\",\n  \"--muted\": \"var(--ouro-bubble)\",\n  \"--card\": \"var(--ouro-bubble)\",\n  \"--card-foreground\": \"var(--ouro-bubble-ink)\",\n  \"--accent\": \"color-mix(in oklab,var(--ouro-bubble-ink) 12%,var(--ouro-bubble))\",\n  \"--ring\": \"var(--ouro-bubble-ink)\",\n  \"--ouro-action\": \"var(--ouro-bubble-ink)\",\n  \"--ouro-action-foreground\": \"var(--ouro-bubble)\",\n  \"--ouro-action-hover\": \"color-mix(in oklab,var(--ouro-bubble-ink) 88%,var(--ouro-bubble))\",\n  \"--ouro-action-active\": \"color-mix(in oklab,var(--ouro-bubble-ink) 76%,var(--ouro-bubble))\",\n} as CSSProperties;\n// Selected text inverts, so it shows on the fill; a link, in the text's own color there, is underlined.\nconst filledInk = \"bg-(--ouro-bubble) text-(--ouro-bubble-ink) selection:bg-(--ouro-bubble-ink) selection:text-(--ouro-bubble) [&_a]:underline\";\n// On others' bubble, the muted surface: the primary, success and muted text colors take a little of the foreground, so\n// a link, a mention, a success mark or a table's header keeps 4.5:1 on it, as it has on the page. The message mixes\n// them (mutedColors) and the bubble reads them (mutedInk): a variable can't be mixed from itself.\nconst mutedColors = {\n  \"--ouro-bubble-link\": \"color-mix(in oklab,var(--primary) 85%,var(--foreground))\",\n  \"--ouro-bubble-success\": \"color-mix(in oklab,var(--success) 85%,var(--foreground))\",\n  \"--ouro-bubble-quiet\": \"color-mix(in oklab,var(--muted-foreground) 85%,var(--foreground))\",\n} as CSSProperties;\nconst mutedInk = {\n  \"--primary\": \"var(--ouro-bubble-link)\",\n  \"--success\": \"var(--ouro-bubble-success)\",\n  \"--muted-foreground\": \"var(--ouro-bubble-quiet)\",\n} as CSSProperties;\n\nconst layouts = {\n  filled: {\n    // A transparent border, which forced colours draw, so a bubble that is only a fill keeps its edge there.\n    user: `rounded-ouro-2xl rounded-ee-ouro-md border border-solid border-transparent px-3 py-2 ${filledInk}`,\n    assistant: \"rounded-ouro-2xl rounded-es-ouro-md border border-solid border-transparent bg-muted px-3 py-2 text-foreground\",\n  },\n  raised: {\n    user: \"rounded-ouro-lg bg-[color-mix(in_oklab,var(--primary)_12%,var(--card))] px-3 py-2 text-foreground\",\n    assistant: `rounded-ouro-lg px-3 py-2 ${raised}`,\n  },\n} as const;\n\nconst bubbleLooks = [\"filled\", \"raised\"] as const;\n\n// A post's line after its name line: one each, in order after the name line (and an unanswered post's Reply beside it).\nconst postRow = \"order-3 basis-full\";\n\n// A post or a reply: the avatar's column (w-8) and the gap after it (gap-3), where the text starts.\nconst peopleGutter = \"2.75rem\";\n\n// Between two posts, a hairline from the text's start to the end, midway between them as MessageList spaces them (16px,\n// and each post's 4px): a border, which forced colours keep. In a MessageList each post sits in a slot of its own (a\n// box it does not draw), so there the posts are each in the slot after the other's.\nconst postHairline =\n  \"[[data-variant=post]+[data-variant=post]_&]:before:absolute [[data-variant=post]+[data-variant=post]_&]:before:inset-x-0 \" +\n  \"[[data-variant=post]+[data-variant=post]_&]:before:-top-3 [[data-variant=post]+[data-variant=post]_&]:before:border-0 \" +\n  \"[[data-variant=post]+[data-variant=post]_&]:before:border-t [[data-variant=post]+[data-variant=post]_&]:before:border-solid \" +\n  \"[[data-variant=post]+[data-variant=post]_&]:before:border-border [[data-variant=post]+[data-variant=post]_&]:before:content-[''] \" +\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:absolute \" +\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:inset-x-0 \" +\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:-top-3 \" +\n  // Stryker disable next-line StringLiteral: the tests' page loads Tailwind's base styles, which give ::before a solid border of no width; an app without them needs this.\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:border-0 \" +\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:border-t \" +\n  // Stryker disable next-line StringLiteral: the tests' page loads Tailwind's base styles, which give ::before a solid border of no width; an app without them needs this.\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:border-solid \" +\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:border-border \" +\n  // Stryker disable next-line StringLiteral: Tailwind gives every before: utility content: var(--tw-content), so the line draws without this class too.\n  \"[[data-ouro-message-list-slot]:has(>[data-variant=post])+[data-ouro-message-list-slot]>[data-variant=post]_&]:before:content-['']\";\n\n// The action bar's code, loaded once, the first time a message with actions or a menu mounts: a\n// page whose messages have no bar never loads it, nor the Tooltip and Menu it uses.\nlet barModule: Promise<typeof MessageActionBar> | undefined;\nconst loadBar = () => (barModule ??= import(\"@/registry/ouro/components/ouro/message/message-parts\").then((module) => module.MessageActionBar));\n\n// The ring a message shows when it has keyboard focus, as one in a MessageList takes: the focus\n// outline Ouro's controls have, with rounded corners, since the message's own box is bare.\nconst focusRing = \"rounded-ouro-lg outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid\";\n\n/**\n * The author's name as text, or the app's content for it shown while screen readers hear the text.\n * While the name loads (`loading` is its label), the label laid out invisibly gives the line its\n * height and baseline and the placeholder its width, and a Skeleton line shows over it.\n */\nfunction authorName(name: string, content: ReactNode, loading: string | undefined): ReactNode {\n  if (loading !== undefined) {\n    return (\n      <span data-ouro-message-name-loading=\"\" className=\"relative inline-block max-w-full\">\n        <span aria-hidden=\"true\" className=\"invisible\">\n          {loading}\n        </span>\n        <span aria-hidden=\"true\" className=\"absolute inset-0 flex items-center\">\n          <Skeleton shape=\"text\" />\n        </span>\n        <span className=\"sr-only\">{loading}</span>\n      </span>\n    );\n  }\n  if (content === undefined) return name;\n  return (\n    <>\n      <span aria-hidden=\"true\">{content}</span>\n      <span className=\"sr-only\">{name}</span>\n    </>\n  );\n}\n\n/**\n * One message in a chat: who wrote it, their avatar and what they wrote, with any\n * attachments under it. `role` places and colors it: the user's own messages at the end\n * in the primary color, the assistant's at the start, the app's `system` notes centered.\n * `streaming` marks a reply still being written. `variant` lays it out for a chat between\n * people (`chat`), a channel post (`post`) or a reply in a thread (`reply`), with the time\n * beside the name, `continued` runs, a `footer` for reactions and an action bar.\n *\n * Use it inside `MessageList`, which keeps the newest message in view and announces new\n * ones. Use `Alert` instead for a notice that is not part of a conversation, and\n * `toast()` for a passing confirmation.\n *\n * @group Chat\n * @see https://ui.ouroboros.bot/docs/message\n *\n * @example\n * <Message role=\"user\" name={user.name} avatar={user.photoUrl}>How long do I rest the dough?</Message>\n * <Message role=\"assistant\" name=\"Ouro\" streaming={!reply.done}>{reply.text}</Message>\n * <Message variant=\"chat\" role=\"assistant\" name=\"Grace\" time=\"9:41 AM\" footer={<ReactionBar reactions={reactions} />} actions={[{ key: \"reply\", label: \"Reply\", icon: <ReplyIcon />, onClick: reply }]}>Lunch?</Message>\n * <Message variant=\"post\" role=\"assistant\" name=\"Grace\" time=\"9:41 AM\" subject=\"Launch plan\" thread={<ThreadSummary count={2} onOpen={open} />}>Notes inside.</Message>\n */\nexport function Message(props: MessageProps): JSX.Element {\n  const {\n    role: roleProp,\n    name: nameProp,\n    nameLoadingLabel = \"Name loading\",\n    nameContent,\n    nameTag,\n    variant: variantProp = \"default\",\n    bubble: bubbleProp,\n    avatar,\n    presence,\n    presenceLabel,\n    time,\n    dateTime,\n    continued: continuedProp = false,\n    subject,\n    children,\n    context,\n    quote,\n    attachments,\n    footer,\n    thread,\n    actions,\n    actionsPlacement,\n    menu,\n    quickReactions,\n    quickReactionsLabel = \"Reactions\",\n    actionsLabel = \"Message actions\",\n    actionsMenuLabel,\n    menuLabel = \"More actions\",\n    streaming = false,\n    streamingLabel = \"Writing\",\n    failed = false,\n    pending = false,\n    pendingLabel = \"Sending\",\n    pendingSince,\n    failedLabel = \"Not sent\",\n    retryLabel = \"Retry\",\n    deleteLabel = \"Delete\",\n    className,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    from,\n    sender,\n    author,\n    content,\n    own,\n    timestamp,\n    replyTo,\n    error,\n    status,\n    onRetry,\n    ...rest\n  } = props;\n  const name = nameProp ?? \"\";\n  const nameLoading = nameProp === null;\n  // A role that is not one of Ouro UI's (a type error) warns and renders as the assistant's.\n  const role = (roles as readonly string[]).includes(roleProp) ? (roleProp as MessageRole) : \"assistant\";\n  const variant = (variants as readonly string[]).includes(variantProp) ? (variantProp as MessageVariant) : \"default\";\n  const bubble = (bubbleLooks as readonly string[]).includes(bubbleProp as string) ? (bubbleProp as MessageBubble) : \"filled\";\n  // A chat's message is a bubble; a reply is one when it is given a bubble, laid out as a chat's.\n  const bubbled = variant === \"chat\" || (variant === \"reply\" && bubbleProp !== undefined);\n  const shape = bubbled ? \"chat\" : variant;\n  // Stryker disable next-line StringLiteral: only \"beside\" is read; any other placement is the corner.\n  const placement = (placements as readonly unknown[]).includes(actionsPlacement) ? (actionsPlacement as MessageActionsPlacement) : variant === \"reply\" ? \"beside\" : \"corner\";\n  useAppearanceClassNameCheck(\n    \"Message\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; the bubble color follows role`\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Message\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          nameProp === undefined && [\"name is missing, so screen readers cannot say who wrote it\", `<Message role=\"${role}\" name=\"Ouro\">`],\n          role !== roleProp && [`role=\"${String(roleProp)}\" is not a role; use \"user\", \"assistant\" or \"system\"`, '<Message role=\"assistant\" name=\"Ouro\">'],\n          variant !== variantProp && [`variant=\"${String(variantProp)}\" is not a variant; use \"default\", \"chat\", \"post\" or \"reply\"`, '<Message variant=\"chat\" role=\"assistant\" name=\"Grace\">'],\n          bubbleProp !== undefined && bubble !== bubbleProp && [`bubble=\"${String(bubbleProp)}\" is not a bubble; use \"filled\" or \"raised\"`, '<Message variant=\"chat\" bubble=\"raised\">'],\n          actionsPlacement !== undefined &&\n            placement !== actionsPlacement && [`actionsPlacement=\"${String(actionsPlacement)}\" is not a placement; use \"corner\" or \"beside\"`, '<Message variant=\"chat\" actionsPlacement=\"beside\">'],\n          from !== undefined && [\"from is not a prop\", '<Message role=\"user\" name=\"Ana\">'],\n          (sender !== undefined || author !== undefined) && [`${sender !== undefined ? \"sender\" : \"author\"} is not a prop`, '<Message role=\"user\" name=\"Ana\">'],\n          content !== undefined && [\"content is not a prop; the message is the children\", '<Message role=\"user\" name=\"Ana\">Hi</Message>'],\n          own !== undefined && [\"own is not a prop; the user's own messages are role=\\\"user\\\"\", '<Message role=\"user\" variant=\"chat\">'],\n          timestamp !== undefined && [\"timestamp is not a prop\", '<Message time=\"9:41 AM\" dateTime={iso}>'],\n          replyTo !== undefined && [\"replyTo is not a prop; the message this one replies to is quote\", '<Message quote={{ author: \"Ana\", excerpt: \"Lunch?\" }}>'],\n          (error !== undefined || status !== undefined || onRetry !== undefined) && [\n            `${error !== undefined ? \"error\" : status !== undefined ? \"status\" : \"onRetry\"} is not a prop; a message that did not send is failed`,\n            '<Message role=\"user\" failed={{ onRetry: retry }}>',\n          ],\n          variant === \"post\" && continuedProp && [\"a post is never continued: every post shows its author\", '<Message variant=\"reply\" continued>'],\n          variant !== \"post\" && subject !== undefined && [\"subject shows only on a post\", '<Message variant=\"post\" subject=\"Launch plan\">'],\n          presence !== undefined &&\n            isValidElement(avatar) && [\n              \"presence does not reach an Avatar element passed as avatar; give that Avatar the presence\",\n              `avatar={<Avatar name=${nameLoading ? \"{null}\" : `\"${name}\"`} alt=\"\" size=\"sm\" presence=\"${presence}\" presenceLabel=\"${wordsFor(presence, presenceLabel)}\" />}`,\n            ],\n          presence !== undefined &&\n            !presenceLabel && [\n              \"presenceLabel is missing, so screen readers hear no presence\",\n              `<Message presence=\"${presence}\" presenceLabel=\"${wordsFor(presence, presenceLabel)}\">`,\n            ],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  // Tapped on a touch screen: the action bar shows until a press lands outside the message.\n  const [active, setActive] = useState(false);\n  // The message's element, kept in a ref rather than state: setting state as the element mounts would draw every\n  // message of a list again, in a second commit, as the list opens.\n  const element = useRef<HTMLElement | null>(null);\n  useEffect(() => {\n    // Stryker disable next-line ConditionalExpression: listening while inactive would only set it inactive again.\n    if (!active) return;\n    const away = (event: Event) => {\n      if (!element.current!.contains(event.target as Node)) setActive(false);\n    };\n    document.addEventListener(\"pointerdown\", away);\n    return () => document.removeEventListener(\"pointerdown\", away);\n  }, [active]);\n  const hasBar =\n    (actions !== undefined && actions.length > 0) || (menu !== undefined && menu.length > 0) || (quickReactions !== undefined && quickReactions.length > 0);\n  // In a MessageList, the list draws one bar for all its messages: this message gives it what to show, and where.\n  const layer = useContext(RowLayerContext);\n  const layered = layer !== null && hasBar;\n  const tap = (event: PointerEvent<HTMLElement>) => {\n    rest.onPointerUp?.(event);\n    // A tap on a control is the control's; the message itself takes a tabindex in a MessageList, and a tap on it is the message's.\n    const control = (event.target as Element).closest(\"a, button, input, textarea, select, [tabindex]\");\n    if (hasBar && !layered && event.pointerType === \"touch\" && (control === null || control === event.currentTarget)) setActive(true);\n  };\n  const ref = (node: HTMLElement | null) => {\n    element.current = node;\n    const forwarded = props.ref;\n    if (typeof forwarded === \"function\") forwarded(node);\n    else if (forwarded) forwarded.current = node;\n  };\n\n  // Not sent: a line under the bubble that says so, with Retry and Delete, and the message's description.\n  const failedId = useId();\n  const isFailed = failed !== false;\n  // Sending: a marker that shows once the send has taken a while, and the same once for screen readers.\n  const pendingId = useId();\n  const isPending = pending && !isFailed && role !== \"system\";\n  // The second is timed here, not by a CSS delay, so an app's own reduced motion (OuroProvider's, which ends every\n  // transition at once) never shows a quick send's clock.\n  const [shown, setShown] = useState(false);\n  useEffect(() => {\n    if (!isPending) return;\n    let quiet: (() => void) | undefined;\n    const show = () => {\n      setShown(true);\n      quiet = announce(pendingLabel);\n    };\n    // A message drawn again after its second was already heard: its clock shows at once, and nothing is said.\n    const waited = pendingSince === undefined ? 0 : Date.now() - pendingSince;\n    // eslint-disable-next-line react-hooks/set-state-in-effect\n    if (waited >= PENDING_DELAY) setShown(true);\n    const timer = waited >= PENDING_DELAY ? undefined : setTimeout(show, PENDING_DELAY - waited);\n    return () => {\n      clearTimeout(timer);\n      quiet?.();\n      setShown(false);\n    };\n  }, [isPending, pendingSince, pendingLabel]);\n  const showing = isPending && shown;\n  const marker = isFailed ? failedId : showing ? pendingId : undefined;\n  const describedBy = marker ? [rest[\"aria-describedby\"], marker].filter(Boolean).join(\" \") : rest[\"aria-describedby\"];\n  // Retry pressed: when the app clears failed, the marker goes with the focused button, so focus\n  // goes to the message rather than the page.\n  // Stryker disable next-line BooleanLiteral: the first run of the effect below, at mount, finds no element yet and clears it either way.\n  const retried = useRef(false);\n  useLayoutEffect(() => {\n    if (isFailed || !retried.current) return;\n    retried.current = false;\n    const article = element.current!;\n    if (document.activeElement !== document.body) return;\n    if (!article.hasAttribute(\"tabindex\")) article.setAttribute(\"tabindex\", \"-1\");\n    // Stryker disable next-line ObjectLiteral,BooleanLiteral: it keeps the page where the reader pressed Retry; whether a browser scrolls a partly shown message into view on focus differs by engine, so no test can tell.\n    article.focus({ preventScroll: true });\n  }, [isFailed]);\n  // Beside a bubble, out of the flow, or after a post's or reply's time on its line: it takes no room, so going moves nothing.\n  const sending = (place: string) =>\n    showing && (\n      <span data-ouro-message-pending=\"\" className={cn(pendingClass, place)}>\n        <PendingIcon aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n        <span id={pendingId} className=\"sr-only\">\n          {pendingLabel}\n        </span>\n      </span>\n    );\n  const notSent = failed !== false && (\n    <div data-ouro-message-failed=\"\" className={cn(\"flex max-w-full flex-wrap items-center gap-x-1 text-xs\", variant === \"post\" && postRow)}>\n      <span id={failedId} className=\"inline-flex items-center gap-1 font-medium text-destructive\">\n        <NotSentIcon aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n        {failedLabel}\n      </span>\n      <Button data-ouro-control=\"message\" data-ouro-part=\"retry\" tone=\"primary\" variant=\"plain\" size=\"sm\" onClick={() => ((retried.current = true), failed.onRetry())}>\n        {retryLabel}\n      </Button>\n      {failed.onDelete && (\n        <Button data-ouro-control=\"message\" data-ouro-part=\"delete\" tone=\"secondary\" variant=\"plain\" size=\"sm\" onClick={failed.onDelete}>\n          {deleteLabel}\n        </Button>\n      )}\n    </div>\n  );\n\n  const empty = children === undefined || children === null || children === false || children === \"\";\n  const body = streaming && empty ? typing(streamingLabel) : children;\n  const quoted = quote && quoteBox(quote);\n  // A context that is nothing draws no line and leaves no gap above the quote.\n  const hasContext = context !== undefined && context !== null && typeof context !== \"boolean\" && context !== \"\";\n  // Muted as the quote's excerpt is, except on a default message's own primary bubble: that bubble does not re-point\n  // the muted token, and a muted line on the primary fill fails 4.5:1, so it takes the bubble's text color.\n  const primaryBubble = role === \"user\" && variant === \"default\";\n  const contextLine = hasContext ? (\n    <div\n      data-ouro-message-context=\"\"\n      className={cn(\"m-0 mb-1 text-xs\", !primaryBubble && \"text-[color-mix(in_oklab,var(--muted-foreground)_80%,var(--foreground))]\")}\n    >\n      {context}\n    </div>\n  ) : null;\n  // The bar's code, with Tooltip, loads in the browser for a message that has a bar.\n  const [Bar, setBar] = useState<typeof MessageActionBar | undefined>(undefined);\n  useEffect(() => {\n    // Stryker disable next-line ConditionalExpression,LogicalOperator: `Bar` only reaches the render when `!layered` (the ternary a few lines down shows it only there), so loading it when `layered` instead (as `||` would, and as a forced-true condition does) can never be seen in what the message draws; the bar's code for a message without one renders nothing either way; site/e2e/catalog.spec.ts holds a page without bars to never loading it.\n    if (hasBar && !layered) void loadBar().then((Loaded) => setBar(() => Loaded));\n  }, [hasBar, layered]);\n  // The box the bar sits in: the bubble's own, or a post's body. In a MessageList, the list puts its one bar there.\n  const slot = useRef<HTMLDivElement | null>(null);\n  // Beside the bubble: a chat or reply message's own layout, with the room before the bubble that the\n  // avatar's column takes when it is at the start (w-8, and the row's gap-2 in a chat or gap-3 in a reply).\n  const beside =\n    placement === \"beside\" && (variant === \"chat\" || variant === \"reply\") && role !== \"system\"\n      ? avatar === false || (shape === \"chat\" && role === \"user\")\n        ? \"0px\"\n        : shape === \"reply\"\n          ? peopleGutter\n          : \"2.5rem\"\n      : undefined;\n  const start = shape === \"chat\" && role === \"user\";\n  const bar = layered ? null : hasBar && Bar ? (\n    <Bar\n      actions={actions ?? []}\n      menu={menu}\n      reactions={quickReactions}\n      reactionsLabel={quickReactionsLabel}\n      label={actionsLabel}\n      menuLabel={menuLabel}\n      start={start}\n      post={variant === \"post\"}\n      beside={beside}\n    />\n  ) : null;\n  // Room for a bar around the bubble: the message's own bar, or the list's, which goes in while it is on this message.\n  const room = layered || bar !== null;\n  // What the list's bar and menu show for this message, given again on every render, so they show what it shows now.\n  // The element the list knows this message by, so the cleanup below takes out the one it set. A mounted message keeps\n  // one element: both of its branches draw an article in the same place, so React keeps the node when it switches.\n  const registered = useRef<HTMLElement | null>(null);\n  useLayoutEffect(() => {\n    if (!layered) return;\n    const article = element.current!;\n    registered.current = article;\n    const data: MessageBarData = {\n      actions: actions ?? [],\n      menu,\n      reactions: quickReactions,\n      label: actionsLabel,\n      menuLabel,\n      menuName: actionsMenuLabel ?? (name ? `Message actions for ${name}` : \"Message actions\"),\n      reactionsLabel: quickReactionsLabel,\n      start,\n      post: variant === \"post\",\n      beside,\n      slot: () => slot.current,\n    };\n    layer.set(article, data);\n  });\n  useLayoutEffect(() => {\n    if (!layered) return;\n    return () => {\n      layer.delete(registered.current!);\n      registered.current = null;\n    };\n  }, [layer, layered]);\n\n  if (variant === \"default\" || role === \"system\") {\n    const continued = continuedProp && role !== \"system\";\n    const bubble = (\n      // Stryker disable next-line ConditionalExpression,EqualityOperator,LogicalOperator,StringLiteral: on a fine pointer the article is text-sm already; the touch tests hold the system note's smaller text.\n      <div data-ouro-message-content=\"\" className={cn(\"max-w-full leading-relaxed [overflow-wrap:anywhere]\", bubbles[role], role === \"system\" && \"text-sm\")}>\n        {contextLine}\n        {quoted}\n        {body}\n      </div>\n    );\n    return (\n      <article\n        {...rest}\n        ref={ref}\n        data-ouro=\"message\"\n        data-role={role}\n        data-variant={variant === \"default\" ? undefined : variant}\n        data-continued={continued ? \"\" : undefined}\n        data-ouro-message-active={active ? \"\" : undefined}\n        aria-busy={streaming || rest[\"aria-busy\"]}\n        aria-describedby={describedBy}\n        onPointerUp={tap}\n        className={cn(\n          \"group/message box-border flex w-full min-w-0 items-end gap-2 text-base pointer-fine:text-sm\",\n          focusRing,\n          role === \"user\" && \"flex-row-reverse\",\n          role === \"system\" && \"justify-center\",\n          className,\n        )}\n      >\n        {role !== \"system\" && avatar !== false && (continued ? <span aria-hidden=\"true\" className=\"w-8 shrink-0\" /> : avatarSlot(avatar, nameLoading ? null : name, presence, presenceLabel, \"mb-0.5\"))}\n        <div\n          className={cn(\n            \"relative flex max-w-[min(85%,42rem)] min-w-0 flex-col gap-1\",\n            role === \"user\" ? \"items-end\" : role === \"system\" ? \"items-center\" : \"items-start\",\n          )}\n        >\n          <span data-ouro-message-author=\"\" className={role === \"assistant\" && !continued ? \"px-1 text-xs font-medium text-muted-foreground\" : \"sr-only\"}>\n            {authorName(name, nameContent, nameLoading ? nameLoadingLabel : undefined)}\n            {nameTag && <span className=\"sr-only\">, </span>}\n            {nameTag && (\n              <span data-ouro-message-name-tag=\"\" className=\"ms-1.5 font-normal\">\n                {nameTag}\n              </span>\n            )}\n            {time !== undefined && <span className=\"sr-only\">, </span>}\n            {time !== undefined && (\n              <time dateTime={dateTime} className=\"ms-1.5 font-normal tabular-nums\">\n                {time}\n              </time>\n            )}\n          </span>\n          {room ? (\n            <div ref={slot} className=\"relative flex max-w-full flex-col\">\n              {bubble}\n              {bar}\n            </div>\n          ) : (\n            bubble\n          )}\n          {attachments !== undefined && attachments !== null && (\n            <div data-ouro-message-attachments=\"\" className={cn(\"flex max-w-full flex-wrap gap-2\", role === \"user\" && \"justify-end\")}>\n              {attachments}\n            </div>\n          )}\n          {notSent}\n          {sending(role === \"user\" ? \"absolute end-full bottom-0 me-2\" : \"absolute start-full bottom-0 ms-2\")}\n          {extra(\"footer\", role === \"user\", false, footer)}\n          {extra(\"thread\", role === \"user\", false, thread)}\n        </div>\n      </article>\n    );\n  }\n\n  // chat, post and reply: the avatar's column at the start, then a line of name and time over the message.\n  const mine = role === \"user\";\n  const end = shape === \"chat\" && mine;\n  const continued = continuedProp && variant !== \"post\";\n  const post = variant === \"post\";\n  // A post or a reply names its author in the text's size; a chat's bubbles carry a smaller line above them.\n  const people = shape !== \"chat\";\n  // In chat the user's own name is not shown (the side says whose it is), only the time.\n  const nameShown = !continued && !end;\n  const header = (\n    <span data-ouro-message-header=\"\" className={continued ? \"sr-only\" : cn(\"flex max-w-full min-w-0 items-baseline gap-2\", people ? \"text-sm\" : \"px-0.5 text-xs\", post && \"order-1\")}>\n      <span data-ouro-message-author=\"\" className={nameShown ? \"truncate font-semibold text-foreground\" : \"sr-only\"}>\n        {authorName(name, nameContent, nameLoading ? nameLoadingLabel : undefined)}\n      </span>\n      {nameTag && (\n        <span data-ouro-message-name-tag=\"\" className={nameShown ? cn(\"shrink-0 text-muted-foreground\", people && \"text-xs\") : \"sr-only\"}>\n          <span className=\"sr-only\">, </span>\n          {nameTag}\n        </span>\n      )}\n      {time !== undefined && <span className=\"sr-only\">, </span>}\n      {time !== undefined && (\n        <time dateTime={dateTime} className={cn(\"shrink-0 text-muted-foreground tabular-nums\", people && \"text-xs\")}>\n          {time}\n        </time>\n      )}\n      {people && sending(\"self-center\")}\n    </span>\n  );\n  // A chat's bubble; a post's and a reply's text sits on the page, unboxed.\n  const surface = shape === \"chat\" ? layouts[bubble][mine ? \"user\" : \"assistant\"] : undefined;\n  // A filled bubble's colors, as inline custom properties: the message sets them, and the bubble re-points the theme's.\n  const filled = shape === \"chat\" && bubble === \"filled\";\n  const ownColors = filled ? (mine ? bubbleColors : mutedColors) : undefined;\n  const surfaceColors = filled ? (mine ? filledColors : mutedInk) : undefined;\n  // A bar beside the bubble measures the message's width (100cqw), so the message is a container. In a MessageList the\n  // list makes it one only while its bar is on it.\n  const containerStyle = hasBar && !layered && beside !== undefined ? { containerType: \"inline-size\" as const } : undefined;\n  const articleStyle = { ...rest.style, ...ownColors, ...containerStyle };\n  const titled = post && subject !== undefined && subject !== null;\n  // A message of pictures or files alone draws no empty bubble above them.\n  const worded = !empty || streaming || quote !== undefined || titled || hasContext;\n  // Hidden rather than left out when empty: MessageList reads every message's text from it.\n  const contentBox = (\n    <div data-ouro-message-content=\"\" hidden={!worded} style={surfaceColors} className={cn(\"box-border max-w-full min-w-0 leading-relaxed [overflow-wrap:anywhere]\", surface)}>\n      {contextLine}\n      {titled && (\n        <p data-ouro-message-subject=\"\" className=\"m-0 mb-0.5 font-[family-name:var(--font-heading,inherit)] text-base leading-snug font-semibold\">\n          {subject}\n        </p>\n      )}\n      {quoted}\n      {body}\n    </div>\n  );\n  return (\n    <article\n      {...rest}\n      ref={ref}\n      data-ouro=\"message\"\n      data-role={role}\n      data-variant={variant}\n      data-bubble={bubbled ? bubble : undefined}\n      data-continued={continued ? \"\" : undefined}\n      data-ouro-message-active={active ? \"\" : undefined}\n      aria-busy={streaming || rest[\"aria-busy\"]}\n      aria-describedby={describedBy}\n      onPointerUp={tap}\n      style={articleStyle}\n      className={cn(\n        \"group/message box-border flex w-full min-w-0 items-start text-base pointer-fine:text-sm\",\n        people ? \"gap-3\" : \"gap-2\",\n        // With MessageList's 16px between messages, 24px between one post's last line and the next one's name.\n        post && \"py-1\",\n        focusRing,\n        end && \"flex-row-reverse\",\n        className,\n      )}\n    >\n      {!end && avatar !== false && (\n        <span data-ouro-message-gutter=\"\" className=\"flex w-8 shrink-0 justify-center\">\n          {continued ? (\n            showing ? (\n              // A continued reply's line holds its text, so its clock sits in the gutter, where its time shows on hover.\n              <PendingIcon data-ouro-message-pending-gutter=\"\" aria-hidden=\"true\" className={cn(pendingClass, \"mt-1.5 size-3.5\")} />\n            ) : (\n              time !== undefined && (\n              <time\n                aria-hidden=\"true\"\n                dateTime={dateTime}\n                className=\"mt-2.5 text-[0.625rem] leading-none whitespace-nowrap text-muted-foreground tabular-nums opacity-0 transition-opacity duration-(--ouro-duration-fast) ease-[ease] pointer-fine:group-hover/message:opacity-100 group-focus-within/message:opacity-100\"\n              >\n                {time}\n              </time>\n              )\n            )\n          ) : (\n            avatarSlot(avatar, nameLoading ? null : name, presence, presenceLabel)\n          )}\n        </span>\n      )}\n      <div\n        ref={post ? slot : undefined}\n        data-ouro-message-body=\"\"\n        className={cn(\n          \"relative flex min-w-0 gap-1\",\n          // A post's rows wrap in a row, so an unanswered post's Reply ends its name line and the rest take a line each.\n          post ? \"flex-row flex-wrap items-center gap-x-2\" : \"flex-col\",\n          shape === \"chat\" ? \"max-w-[min(85%,36rem)]\" : \"flex-1\",\n          !post && (end ? \"items-end\" : \"items-start\"),\n          post && postHairline,\n        )}\n      >\n        {header}\n        {!post && !room && worded ? (\n          contentBox\n        ) : (\n          <div ref={post ? undefined : slot} className={cn(\"relative box-border flex max-w-full min-w-0 flex-col\", end ? \"items-end\" : \"items-start\", post && postRow)}>\n            {contentBox}\n            {!post && bar}\n          </div>\n        )}\n        {attachments !== undefined && attachments !== null && (\n          <div data-ouro-message-attachments=\"\" className={cn(\"flex w-full max-w-full min-w-0 flex-wrap gap-2\", end && \"justify-end\", post && [\"mt-1\", postRow])}>\n            {attachments}\n          </div>\n        )}\n        {notSent}\n        {shape === \"chat\" && sending(end ? \"absolute end-full bottom-0 me-1.5\" : \"absolute start-full bottom-0 ms-1.5\")}\n        {extra(\"footer\", end, post, footer)}\n        {extra(\"thread\", end, post, thread)}\n        {post && bar}\n      </div>\n    </article>\n  );\n}\n\n/**\n * The author's avatar: the Avatar element the app passed, or one drawn from the picture URL and\n * name, with the author's presence. A missing label still says the presence, as Avatar would.\n */\nfunction avatarSlot(avatar: string | ReactElement | undefined, name: string | null, presence: string | undefined, presenceLabel: string | undefined, className?: string): JSX.Element {\n  if (isValidElement(avatar)) return avatar;\n  const dot = presence === undefined ? {} : { presence: presence as AvatarPresence, presenceLabel: presenceLabel || presence.replaceAll(\"-\", \" \") };\n  return <Avatar name={name} src={avatar} alt=\"\" size=\"sm\" className={className} {...dot} />;\n}\n\n// The quote: a box on the muted surface with a hairline, as Composer's quote (composer.tsx).\nconst quoteClass =\n  \"m-0 mb-2 flex min-w-0 items-center gap-2 rounded-ouro-md bg-muted p-1.5 ring-1 ring-border/60 forced-colors:border forced-colors:border-solid\";\n// The quote as a button: it highlights while hovered rather than scaling, as a wide row does, and\n// with two lines of text it is taller than a touch target already.\nconst quoteButtonClass =\n  \"box-border w-full cursor-pointer border-0 text-start font-[inherit] text-inherit pointer-fine:hover:bg-accent \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid\";\n\n/**\n * The message a message replies to: the bar, the avatar, the author and the excerpt. Screen\n * readers hear the label (\"Quoting Ana\") in place of the author's name, then the excerpt.\n */\nfunction quoteBox(quote: MessageQuote): JSX.Element {\n  const body = (\n    <>\n      <span aria-hidden=\"true\" data-ouro-message-quote-bar=\"\" className=\"w-1 shrink-0 self-stretch rounded-full bg-primary forced-colors:bg-[Highlight]\" />\n      {quote.avatar}\n      <span className=\"flex min-w-0 flex-1 flex-col\">\n        <span className=\"sr-only\">{quote.label ?? `Quoting ${quote.author}`}: </span>\n        <span aria-hidden=\"true\" data-ouro-message-quote-author=\"\" className=\"truncate text-xs font-semibold text-foreground\">\n          {quote.author}\n        </span>\n        <span data-ouro-message-quote-excerpt=\"\" className=\"truncate text-sm text-[color-mix(in_oklab,var(--muted-foreground)_80%,var(--foreground))]\">\n          {quote.excerpt}\n        </span>\n      </span>\n    </>\n  );\n  return quote.onActivate ? (\n    <button type=\"button\" data-ouro-control=\"message\" data-ouro-part=\"quote\" data-ouro-message-quote=\"\" onClick={quote.onActivate} className={cn(quoteClass, quoteButtonClass)}>\n      {body}\n    </button>\n  ) : (\n    <blockquote data-ouro-message-quote=\"\" className={quoteClass}>\n      {body}\n    </blockquote>\n  );\n}\n\n/** The words a presence's fix suggests: the app's own label, else the presence's name (\"Do not disturb\"). */\nfunction wordsFor(presence: string, label: string | undefined): string {\n  return label || `${presence[0]!.toUpperCase()}${presence.slice(1).replaceAll(\"-\", \" \")}`;\n}\n\n/**\n * A row under the message (its footer or thread), or nothing when the app passed nothing. A post's rows keep a little\n * more room, and a post's thread that is only Reply (nobody has replied) ends the name line instead.\n */\nfunction extra(slot: \"footer\" | \"thread\", end: boolean, post: boolean, children: ReactNode): JSX.Element | null {\n  if (children === undefined || children === null || children === false) return null;\n  return (\n    <div\n      {...{ [`data-ouro-message-${slot}`]: \"\" }}\n      className={cn(\n        \"flex max-w-full min-w-0 flex-wrap items-center gap-2\",\n        end && \"justify-end\",\n        post && [\"mt-1\", postRow],\n        post && slot === \"thread\" && \"has-data-ouro-thread-summary-unanswered:order-2 has-data-ouro-thread-summary-unanswered:mt-0 has-data-ouro-thread-summary-unanswered:basis-auto\",\n      )}\n    >\n      {children}\n    </div>\n  );\n}\n\n/** A circle with an exclamation mark: the message did not send. */\n/** How long a send runs before it shows as pending. */\nconst PENDING_DELAY = 1000;\n\n// Fades in as it mounts (from @starting-style): an opacity change, so it runs with reduced motion too.\nconst pendingClass =\n  \"pointer-events-none flex shrink-0 items-center text-[color-mix(in_oklab,var(--muted-foreground)_80%,var(--foreground))] \" +\n  \"transition-opacity duration-(--ouro-duration-fast) ease-[ease] starting:opacity-0\";\n\nfunction PendingIcon(props: SVGProps<SVGSVGElement>): JSX.Element {\n  return (\n    <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" {...props}>\n      <circle cx=\"10\" cy=\"10\" r=\"7.5\" />\n      <path d=\"M10 6v4l2.5 2\" />\n    </svg>\n  );\n}\n\nfunction NotSentIcon(props: SVGProps<SVGSVGElement>): JSX.Element {\n  return (\n    <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" {...props}>\n      <circle cx=\"10\" cy=\"10\" r=\"7.5\" />\n      <path d=\"M10 6.5v4.5M10 13.75v.01\" />\n    </svg>\n  );\n}\n\nconst typingDot = \"size-1.5 animate-[ouro-pulse_1.2s_ease-in-out_infinite] rounded-full bg-current\";\n\n/**\n * Three dots that pulse in turn (opacity only, so reduced motion keeps them), with a spoken label.\n *\n * @claim \"Three dots that pulse in turn\" registry/ouro/components/ouro/message/message.tsx verify:fileLine(registry/ouro/components/ouro/message/message.tsx, /animate-\\[ouro-pulse_1\\.2s_ease-in-out_infinite\\]/)\n * @claim \"Three dots that pulse in turn\" registry/ouro/theme/ouro-base.css verify:fileLine(registry/ouro/theme/ouro-base.css, /^@keyframes\\souro-pulse\\s\\{/)\n * @claim \"Three dots that pulse in turn\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message > is busy while streaming, with a typing indicator the app can name)\n */\nfunction typing(label: string): JSX.Element {\n  return (\n    <span data-ouro-message-typing=\"\" className=\"inline-flex h-[1lh] items-center gap-1\">\n      <span aria-hidden=\"true\" className={typingDot} />\n      <span aria-hidden=\"true\" className={typingDot} style={{ animationDelay: \"0.2s\" }} />\n      <span aria-hidden=\"true\" className={typingDot} style={{ animationDelay: \"0.4s\" }} />\n      <span className=\"sr-only\">{label}</span>\n    </span>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/message/message.tsx"
    }
  ],
  "docs": "One message in a chat: who wrote it, their avatar and what they wrote, with any attachments under it. Import: import { Message } from \"@/components/ouro/message/message\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: avatar, button, kbd, menu, skeleton, tooltip, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/message.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}