{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "thread-summary",
  "title": "ThreadSummary",
  "description": "The line under a post that leads to its thread: who replied, \"N replies\" (a button that opens the thread) and when the last reply came.",
  "registryDependencies": [
    "@ouro/avatar",
    "@ouro/button",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/message/thread-summary.tsx",
      "content": "\"use client\";\n\nimport type { HTMLAttributes, JSX, MouseEvent, Ref, SVGProps } from \"react\";\nimport { Avatar, AvatarGroup } from \"@/registry/ouro/components/ouro/avatar/avatar\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** Someone who replied in a thread: their name, and their picture if there is one. */\nexport interface ThreadReplier {\n  /** Their name, for the avatar's initials and for screen readers. */\n  name: string;\n  /** Their picture's URL. Without it the avatar shows initials. */\n  src?: string | undefined;\n}\n\n/** The props ThreadSummary adds to the `<div>` attributes it passes through. */\nexport interface ThreadSummaryOwnProps {\n  /**\n   * How many replies the thread has. With none, the summary is a single small \"Reply\" button\n   * that opens the thread to write the first one. As a post's `thread`, that button sits at the\n   * end of the post's line of name and time, so it adds no row. Where a mouse or trackpad points,\n   * it shows only while the pointer is over the post or focus is in it; on a touch screen it\n   * always shows, in the same place.\n   *\n   * @claim \"With none, the summary is a\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > is a single Reply button with no replies yet)\n   * @claim \"that button sits at the\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message post > puts Reply at the end of the name line when nobody has replied, adding no row)\n   * @claim \"it shows only while the pointer\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > shows Reply in a message only while the pointer is over it or focus is in it, keeping its place)\n   * @claim \"on a touch screen it always\" registry/ouro/components/ouro/message/thread-summary.touch.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.touch.test.tsx::always shows Reply in a message on a touch screen)\n   */\n  count: number;\n  /** Opens the thread, with the click event, so the app can check `event.isTrusted`. */\n  onOpen: (event: MouseEvent<HTMLElement>) => void;\n  /**\n   * Who replied, in the order to show them. The first three show as small overlapping faces: the\n   * picture, or one initial on the person's colour; the count beside them says how many replied in all.\n   *\n   * @claim \"The first three show as small\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > shows who replied, a button with the count that opens the thread, and the last reply's time)\n   * @claim \"or one initial on the person's\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > shows three faces at most, each a picture or one initial, and no further count)\n   */\n  repliers?: readonly ThreadReplier[] | undefined;\n  /** When the last reply came, already formatted for the reader (\"7:44 AM\"). */\n  lastReply?: string | undefined;\n  /** The same moment for machines, as an ISO date: the `<time>` element's `dateTime`. */\n  lastReplyDateTime?: string | undefined;\n  /**\n   * The button's words for a count, for other languages.\n   * @default (count) => count === 1 ? \"1 reply\" : `${count} replies`\n   */\n  repliesLabel?: ((count: number) => string) | undefined;\n  /**\n   * What screen readers hear for the button, when its words alone (\"2 replies\") would repeat\n   * from post to post: \"2 replies to Riley's post Settings mockups\". Start it with the words the\n   * button shows, so speech input that says them still finds it (WCAG's label in name).\n   * @claim \"What screen readers hear for the\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > names its button for screen readers with label, keeping the words it shows)\n   * @claim \"Start it with the words the\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary development messages > says when label leaves out the words the button shows)\n   * @claim \"Start it with the words the\" https://www.w3.org/WAI/WCAG22/Understanding/label-in-name verify:urlOk(https://www.w3.org/WAI/WCAG22/Understanding/label-in-name)\n   */\n  label?: string | undefined;\n  /** The button's words before anyone has replied, for other languages. @default \"Reply\" */\n  replyLabel?: string | undefined;\n  /**\n   * The words around the last reply's time, for other languages.\n   * @default (time) => `Last reply ${time}`\n   */\n  lastReplyLabel?: ((time: string) => string) | undefined;\n  /** What screen readers hear for the repliers' avatars, for other languages. @default \"Replied\" */\n  repliersLabel?: string | undefined;\n  /** Layout only: margins (`mt-1`). Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. The thread opens with `onOpen`: `<ThreadSummary count={2} onOpen={openThread}>`. */\n  onClick?: { 'Use onOpen={openThread}': never };\n  /** Not a prop. The number of replies is `count`: `<ThreadSummary count={replies.length}>`. */\n  replyCount?: { 'Use count={replies.length}': never };\n}\n\n/** Props for {@link ThreadSummary}: its own props and the `<div>` attributes it passes through. */\nexport type ThreadSummaryProps = Omit<HTMLAttributes<HTMLDivElement>, keyof ThreadSummaryOwnProps> & ThreadSummaryOwnProps;\n\nconst defaultReplies = (count: number) => (count === 1 ? \"1 reply\" : `${count} replies`);\n\n// Reply, before anyone has replied, in a message where a mouse points: hidden until the pointer is over the message or\n// focus is in it, in its place all along (only its opacity changes), and at once for the keyboard. `:where` keeps\n// the hiding rule weaker than the message's hover and focus, which show it. A post puts it at the end of its name line\n// (`data-ouro-thread-summary-unanswered`), as small as that line.\nconst quietReply =\n  \"transition-opacity duration-(--ouro-duration-fast) ease-[ease] pointer-fine:[:where([data-ouro=message])_&]:opacity-0 \" +\n  \"pointer-fine:group-hover/message:opacity-100 group-focus-within/message:opacity-100 group-focus-within/message:transition-none\";\nconst defaultLast = (time: string) => `Last reply ${time}`;\n\n/**\n * The line under a post that leads to its thread: who replied, \"N replies\" (a button that\n * opens the thread) and when the last reply came. Before anyone has replied it is a quiet\n * \"Reply\" button with a reply arrow, to start the thread, which ends a post's name line and\n * shows on hover and focus where a mouse points.\n *\n * Pass it to `Message`'s `thread`, under a `variant=\"post\"` message, or a `chat` message in a\n * channel without threads whose message has replies. Use `Button` instead for\n * an action that is not about a thread, and `AvatarGroup` alone to show who is in something.\n *\n * @group Chat\n * @see https://ui.ouroboros.bot/docs/thread-summary\n *\n * @example\n * <ThreadSummary count={thread.replies.length} repliers={thread.repliers} lastReply={formatTime(thread.lastReplyAt)} onOpen={() => openThread(thread.id)} />\n * @claim \"Before anyone has replied it is\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > is a single Reply button with no replies yet)\n * @claim \"which ends a post's name line\" registry/ouro/components/ouro/message/message.test.tsx verify:testExists(registry/ouro/components/ouro/message/message.test.tsx::Message post > puts Reply at the end of the name line when nobody has replied, adding no row)\n * @claim \"shows on hover and focus where\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > shows Reply in a message only while the pointer is over it or focus is in it, keeping its place)\n * @claim \"The line under a\" registry/ouro/components/ouro/message/thread-summary.test.tsx verify:testExists(registry/ouro/components/ouro/message/thread-summary.test.tsx::ThreadSummary > shows who replied, a button with the count that opens the thread, and the last reply's time)\n */\nexport function ThreadSummary(props: ThreadSummaryProps): JSX.Element {\n  const {\n    count,\n    onOpen,\n    repliers,\n    lastReply,\n    lastReplyDateTime,\n    repliesLabel = defaultReplies,\n    replyLabel = \"Reply\",\n    lastReplyLabel = defaultLast,\n    repliersLabel = \"Replied\",\n    label,\n    className,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    onClick,\n    replyCount,\n    ...rest\n  } = props;\n  useAppearanceClassNameCheck(\n    \"ThreadSummary\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; ThreadSummary takes its colors from the theme`\n      : // Stryker disable next-line StringLiteral: production only; the check never runs there.\n        /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  const replied = count > 0;\n  const shown = replied ? repliesLabel(count) : replyLabel;\n  useDevWarnings(\n    \"ThreadSummary\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          label !== undefined &&\n            !label.toLowerCase().startsWith(shown.toLowerCase()) && [\n              `label \"${label}\" does not start with the button's words \"${shown}\", so speech input that says them misses it`,\n              `<ThreadSummary count={${count}} label=\"${shown} to Riley's post\">`,\n            ],\n          onOpen === undefined && [\"onOpen is missing, so the button opens nothing\", \"<ThreadSummary count={2} onOpen={openThread}>\"],\n          onClick !== undefined && [\"onClick is not a prop\", \"<ThreadSummary count={2} onOpen={openThread}>\"],\n          replyCount !== undefined && [\"replyCount is not a prop\", \"<ThreadSummary count={replies.length}>\"],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  const faces = replied && repliers !== undefined && repliers.length > 0;\n  return (\n    <div\n      {...rest}\n      data-ouro=\"thread-summary\"\n      // Stryker disable next-line StringLiteral: styles and tests read only whether the attribute is there, never its value.\n      data-ouro-thread-summary-unanswered={replied ? undefined : \"\"}\n      className={cn(\"box-border flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1\", !replied && quietReply, className)}\n    >\n      {faces && (\n        <AvatarGroup label={repliersLabel} size=\"xs\">\n          {/* Two letters at this size are noise: one initial, on the person's own colour, or their picture. */}\n          {repliers.slice(0, 3).map((replier, index) => (\n            <Avatar key={`${replier.name}-${index}`} name={replier.name} src={replier.src} initials={[...replier.name.trim()][0]} />\n          ))}\n        </AvatarGroup>\n      )}\n      <Button\n        data-ouro-control=\"thread-summary\"\n        data-ouro-part=\"open\"\n        variant=\"plain\"\n        size=\"sm\"\n        startIcon={replied ? undefined : ReplyIcon}\n        aria-label={label}\n        onClick={(event) => onOpen?.(event)}\n        // The label lines up with the text above it, or sits just after the avatars; where a mouse points, the row is\n        // a line of small type rather than a button's height, so a post keeps little room under it.\n        className={cn(\n          faces ? \"-ms-1\" : \"-ms-(--ouro-button-px)\",\n          replied ? \"pointer-fine:h-6\" : \"[:where([data-ouro=message])_&]:-ms-1 [:where([data-ouro=message])_&]:h-5 [:where([data-ouro=message])_&]:px-1.5\",\n        )}\n      >\n        {shown}\n      </Button>\n      {replied && lastReply !== undefined && (\n        <time dateTime={lastReplyDateTime} className=\"text-xs text-muted-foreground tabular-nums\">\n          {lastReplyLabel(lastReply)}\n        </time>\n      )}\n    </div>\n  );\n}\n\n/** An arrow curving back: reply. */\nfunction ReplyIcon(props: SVGProps<SVGSVGElement>): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" {...props}>\n      <path d=\"m9 14-5-5 5-5\" />\n      <path d=\"M4 9h10.5a5.5 5.5 0 0 1 0 11H11\" />\n    </svg>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/message/thread-summary.tsx"
    }
  ],
  "docs": "The line under a post that leads to its thread: who replied, \"N replies\" (a button that opens the thread) and when the last reply came. Import: import { ThreadSummary } from \"@/components/ouro/message/thread-summary\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: avatar, button, skeleton, 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/thread-summary.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}