{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transcript-solid",
  "title": "Transcript (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/transcript.tsx",
      "content": "import { transcriptPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps } from \"@solidjs/web\";\nimport { Input, InputClear, InputGroup } from \"@ui-sdk/solid/input\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit, Show } from \"solid-js\";\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(props: TranscriptProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {props.children ?? (\n        <>\n          <TranscriptSearch />\n          <TranscriptViewport>\n            <TranscriptList />\n          </TranscriptViewport>\n        </>\n      )}\n    </parts.Root>\n  );\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\nfunction Marked(props: { segments: readonly { text: string; match: boolean }[] }) {\n  return (\n    <For each={props.segments} keyed={false}>\n      {(segment) => (\n        <Show when={segment().match} fallback={segment().text}>\n          <mark>{segment().text}</mark>\n        </Show>\n      )}\n    </For>\n  );\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(props: TranscriptSearchProps) {\n  return (\n    <parts.Search {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <InputGroup>\n            <Input\n              type=\"search\"\n              controller={state.controller}\n              defaultValue={state.defaultValue}\n              aria-label={state.label}\n              placeholder=\"Search\"\n              data-agent-hidden=\"\"\n            />\n            <TranscriptCount />\n            <InputClear aria-label=\"Clear search\" data-agent-hidden=\"\" />\n          </InputGroup>\n        ))}\n    </parts.Search>\n  );\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(props: TranscriptCountProps) {\n  return <parts.Count {...omit(props, \"children\")}>{props.children ?? ((state) => state.text)}</parts.Count>;\n}\n\nexport type TranscriptListProps = ComponentProps<typeof parts.List>;\n\n/** A `TranscriptSegment` for each segment in view, keyed by its id, unless you pass children. */\nexport function TranscriptList(props: TranscriptListProps) {\n  return (\n    <parts.List {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <For each={state.rows} keyed={(row) => row.key}>\n            {(row) => <TranscriptSegment value={row().key} />}\n          </For>\n        ))}\n    </parts.List>\n  );\n}\n\nexport type TranscriptSegmentProps = ComponentProps<typeof parts.Segment>;\n\n/** The segment whose id is `value`: its speaker, its time, and its text, unless you pass children. */\nexport function TranscriptSegment(props: TranscriptSegmentProps) {\n  return (\n    <parts.Segment {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <div data-transcript-header=\"\">\n              <TranscriptSpeaker />\n              <Show when={state.canSeek} fallback={<TranscriptTime />}>\n                <TranscriptSeek>\n                  <TranscriptTime />\n                </TranscriptSeek>\n              </Show>\n            </div>\n            <TranscriptText />\n          </>\n        ))}\n    </parts.Segment>\n  );\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(props: TranscriptSpeakerProps) {\n  return (\n    <parts.Speaker {...omit(props, \"children\")}>\n      {props.children ?? ((state) => <Marked segments={state.speaker} />)}\n    </parts.Speaker>\n  );\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(props: TranscriptTimeProps) {\n  return <parts.Time {...omit(props, \"children\")}>{props.children ?? ((state) => state.time)}</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(props: TranscriptTextProps) {\n  return (\n    <parts.Text {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <For each={state.words}>\n            {(value, index) => (\n              <>\n                {index() > 0 && \" \"}\n                <TranscriptWord value={value} />\n              </>\n            )}\n          </For>\n        ))}\n    </parts.Text>\n  );\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.\n */\nexport function TranscriptWord(props: TranscriptWordProps) {\n  return (\n    <parts.Word {...omit(props, \"children\")}>\n      {props.children ?? ((state) => <Marked segments={state.text} />)}\n    </parts.Word>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/transcript.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
