{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transcript",
  "title": "Transcript",
  "description": "Speaker-labelled, timed segments with search, marking the segment and word playing and seeking on a press.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/transcript.tsx",
      "content": "\"use client\";\n\nimport { type TranscriptSearchState, transcriptPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { Input, InputClear, InputGroup } from \"@ui-sdk/react/input\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport { type ComponentProps, Fragment, memo } from \"react\";\n\nconst parts = createParts(transcriptPrimitive, {\n  root: \"div\",\n  search: \"div\",\n  count: \"span\",\n  viewport: \"div\",\n  list: \"div\",\n  segment: \"div\",\n  speaker: \"span\",\n  seek: \"button\",\n  time: \"span\",\n  text: \"p\",\n  word: \"span\",\n});\n\nexport type TranscriptProps = ComponentProps<typeof parts.Root>;\n\n/**\n * Speaker-labelled, timed segments with a search, marking the segment and word playing at `currentTime`. Any\n * `children` replace the default parts.\n */\nexport function Transcript({ children, ...props }: TranscriptProps) {\n  return <parts.Root {...props}>{children !== undefined ? children : DEFAULT_PARTS}</parts.Root>;\n}\n\n/** A time as a button that seeks to its segment, rendered only while `onSeek` is set. Holds a `TranscriptTime`. */\nexport const TranscriptSeek = parts.Seek;\n/** Scrolls the segments. Holds a `TranscriptList`. */\nexport const TranscriptViewport = parts.Viewport;\n\nconst marked = (segments: { text: string; match: boolean }[]) =>\n  segments.map((segment, index) => (segment.match ? <mark key={index}>{segment.text}</mark> : segment.text));\n\nconst searchField = ({ controller, defaultValue, label }: TranscriptSearchState) => (\n  <InputGroup>\n    <Input\n      type=\"search\"\n      controller={controller}\n      defaultValue={defaultValue}\n      aria-label={label}\n      placeholder=\"Search\"\n      data-agent-hidden=\"\"\n    />\n    <TranscriptCount />\n    <InputClear aria-label=\"Clear search\" data-agent-hidden=\"\" />\n  </InputGroup>\n);\n\nexport type TranscriptSearchProps = ComponentProps<typeof parts.Search>;\n\n/** A search field with the match count and a clear button, unless you pass children. Pass the state to UI SDK Input. */\nexport function TranscriptSearch({ children = searchField, ...props }: TranscriptSearchProps) {\n  return <parts.Search {...props}>{children}</parts.Search>;\n}\n\nexport type TranscriptCountProps = ComponentProps<typeof parts.Count>;\n\n/** \"3 matches\" while there's a search, unless you pass children. */\nexport function TranscriptCount({ children = ({ text }) => text, ...props }: TranscriptCountProps) {\n  return <parts.Count {...props}>{children}</parts.Count>;\n}\n\nexport type TranscriptListProps = ComponentProps<typeof parts.List>;\n\n/** A `TranscriptSegment` for each segment in view, unless you pass children. */\nexport function TranscriptList({\n  children = ({ rows }) => rows.map((row) => <TranscriptSegment key={row.key} value={row.key} />),\n  ...props\n}: TranscriptListProps) {\n  return <parts.List {...props}>{children}</parts.List>;\n}\n\nexport type TranscriptSegmentProps = ComponentProps<typeof parts.Segment>;\n\n/**\n * The segment whose id is `value`: its speaker, its time, and its text, unless you pass children. Memoized, so\n * segments playback doesn't reach aren't rendered again.\n */\nexport const TranscriptSegment = memo(function TranscriptSegment({\n  children = ({ canSeek }) => (\n    <>\n      <div data-transcript-header=\"\">\n        <TranscriptSpeaker />\n        {canSeek ? (\n          <TranscriptSeek>\n            <TranscriptTime />\n          </TranscriptSeek>\n        ) : (\n          <TranscriptTime />\n        )}\n      </div>\n      <TranscriptText />\n    </>\n  ),\n  ...props\n}: TranscriptSegmentProps) {\n  return <parts.Segment {...props}>{children}</parts.Segment>;\n});\n\nexport type TranscriptSpeakerProps = ComponentProps<typeof parts.Speaker>;\n\n/** The speaker, with what the search matched marked, unless you pass children. */\nexport function TranscriptSpeaker({\n  children = ({ speaker }) => marked(speaker),\n  ...props\n}: TranscriptSpeakerProps) {\n  return <parts.Speaker {...props}>{children}</parts.Speaker>;\n}\n\nexport type TranscriptTimeProps = ComponentProps<typeof parts.Time>;\n\n/** When the segment starts, like \"1:05\", unless you pass children. */\nexport function TranscriptTime({ children = ({ time }) => time, ...props }: TranscriptTimeProps) {\n  return <parts.Time {...props}>{children}</parts.Time>;\n}\n\nexport type TranscriptTextProps = ComponentProps<typeof parts.Text>;\n\n/** A `TranscriptWord` for each of the segment's words, a space apart, or its whole text, unless you pass children. */\nexport function TranscriptText({\n  children = ({ words }) =>\n    words.map((value, index) => (\n      <Fragment key={value}>\n        {index > 0 && \" \"}\n        <TranscriptWord value={value} />\n      </Fragment>\n    )),\n  ...props\n}: TranscriptTextProps) {\n  return <parts.Text {...props}>{children}</parts.Text>;\n}\n\nexport type TranscriptWordProps = ComponentProps<typeof parts.Word>;\n\n/**\n * The word whose `value` is `\"<segment id>/<index>\"`, or a segment's whole text without words, with what the search\n * matched marked, unless you pass children. Memoized, so only the words playback starts and stops render again.\n */\nexport const TranscriptWord = memo(function TranscriptWord({\n  children = ({ text }) => marked(text),\n  ...props\n}: TranscriptWordProps) {\n  return <parts.Word {...props}>{children}</parts.Word>;\n});\n\n// Shared, so playback doesn't render the default parts' wrappers again.\nconst DEFAULT_PARTS = (\n  <>\n    <TranscriptSearch />\n    <TranscriptViewport>\n      <TranscriptList />\n    </TranscriptViewport>\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/transcript.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
