{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "terminal-vue",
  "title": "Terminal (Vue)",
  "description": "A command and its output in ANSI colors, following the end as it streams, with its approval, exit code and duration.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/confirmation-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/terminal.ts",
      "content": "import { type AnsiSpan, type TerminalApprovalState, terminalPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { defineComponent, h } from \"vue\";\nimport { Confirmation } from \"./confirmation\";\n\nconst parts = createParts(terminalPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  icon: \"span\",\n  title: \"span\",\n  exit: \"span\",\n  meta: \"span\",\n  approval: \"div\",\n  content: \"div\",\n  command: \"div\",\n  copy: \"button\",\n  viewport: \"div\",\n  output: \"div\",\n  line: \"div\",\n  jump: \"button\",\n});\n\n// `$stable` tells Vue these slots never change, so a part that renders again doesn't render the parts inside it.\nconst stable = (slot: () => unknown) => ({ default: slot, $stable: true });\n\n// A part that fills an empty default slot from its state.\nconst withDefault = <Part>(part: Part, name: string, fill: (state: never) => unknown) =>\n  defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(part as never, attrs, {\n          ...slots,\n          default: slots.default ?? (({ state }: { state: never }) => fill(state)),\n        });\n    },\n  }) as unknown as Part;\n\nexport const TerminalTrigger = parts.Trigger;\nexport const TerminalIcon = parts.Icon;\nexport const TerminalContent = parts.Content;\nexport const TerminalCopy = parts.Copy;\n/** Scrolls the output and follows its end. Holds a `TerminalOutput`. */\nexport const TerminalViewport = parts.Viewport;\n\n/** The command, or the `label`, or \"Run <command>?\" while the approval waits, unless you fill the default slot. */\nexport const TerminalTitle = withDefault(\n  parts.Title,\n  \"TerminalTitle\",\n  (state: { spans: readonly string[] }) =>\n    state.spans.map((piece, index) => (index % 2 ? h(\"code\", { key: index }, piece) : piece)),\n);\n\n/** \"Exit N\" once there's an exit code other than 0, unless you fill the default slot. */\nexport const TerminalExit = withDefault(parts.Exit, \"TerminalExit\", (state: { text: string }) => state.text);\n\n/** \"Waiting for approval\" while the approval waits, else the duration as \"6 sec\", unless you fill the default slot. */\nexport const TerminalMeta = withDefault(parts.Meta, \"TerminalMeta\", (state: { text: string }) => state.text);\n\n/**\n * A Confirmation for the command's approval while it has one: the choices whose callbacks are set while the request\n * waits, then what was decided. Fill the slot to render it yourself.\n */\n// Slot state is a proxy with no keys of its own, so the Confirmation's props are read one by one.\nexport const TerminalApproval = withDefault(\n  parts.Approval,\n  \"TerminalApproval\",\n  (state: TerminalApprovalState) =>\n    h(Confirmation, {\n      approval: state.approval,\n      label: state.label,\n      onApprove: state.onApprove,\n      onDeny: state.onDeny,\n      onAlwaysAllow: state.onAlwaysAllow,\n      reason: state.reason,\n      approveLabel: state.approveLabel,\n      alwaysLabel: state.alwaysLabel,\n      alwaysTarget: state.alwaysTarget,\n      alwaysScope: state.alwaysScope,\n      alwaysDetail: state.alwaysDetail,\n      risk: state.risk,\n      riskText: state.riskText,\n      focusFallback: state.focusFallback,\n      motion: state.motion,\n    }),\n);\n\n/**\n * The command after its prompt, which the stylesheet draws, unless you fill the default slot. Present only while a\n * `label` replaces the command as the title.\n */\nexport const TerminalCommand = withDefault(\n  parts.Command,\n  \"TerminalCommand\",\n  (state: { command: string }) => state.command,\n);\n\nconst spanStyle = (span: AnsiSpan) =>\n  span.fg || span.bg ? { color: span.fg, backgroundColor: span.bg } : undefined;\n\nconst spans = ({ state }: { state: { spans: readonly AnsiSpan[] } }) =>\n  state.spans.map((span, index) =>\n    h(\n      \"span\",\n      {\n        key: index,\n        style: spanStyle(span),\n        \"data-bold\": span.bold ? \"\" : undefined,\n        \"data-dim\": span.dim ? \"\" : undefined,\n        \"data-italic\": span.italic ? \"\" : undefined,\n        \"data-underline\": span.underline ? \"\" : undefined,\n        \"data-strike\": span.strike ? \"\" : undefined,\n      },\n      span.text,\n    ),\n  );\n\n/**\n * One line of output, its `index`th, as styled spans, unless you fill the default slot. A line renders again only\n * when its own spans change, since Vue renders a child again only when its props do.\n */\nexport const TerminalLine = defineComponent({\n  name: \"TerminalLine\",\n  inheritAttrs: false,\n  props: { index: { type: Number, required: true }, value: String },\n  setup(props, { attrs, slots }) {\n    return () =>\n      h(\n        parts.Line,\n        { ...attrs, index: props.index, value: props.value ?? String(props.index) },\n        { ...slots, default: slots.default ?? spans },\n      );\n  },\n}) as unknown as typeof parts.Line;\n\n/** A `TerminalLine` for each line in view, unless you fill the default slot. */\nexport const TerminalOutput = withDefault(\n  parts.Output,\n  \"TerminalOutput\",\n  (state: { rows: readonly { index: number }[] }) =>\n    state.rows.map((row) => h(TerminalLine, { key: row.index, index: row.index })),\n);\n\n/** Shown while the reader has scrolled away from the end. \"Jump to latest\", unless you fill the default slot. */\nexport const TerminalJump = withDefault(parts.Jump, \"TerminalJump\", () => \"Jump to latest\");\n\nconst defaultParts = () => [\n  h(\n    TerminalTrigger,\n    null,\n    stable(() => [h(TerminalIcon), h(TerminalTitle), h(TerminalExit), h(TerminalMeta)]),\n  ),\n  h(TerminalApproval),\n  h(\n    TerminalContent,\n    null,\n    stable(() =>\n      h(\"div\", { \"data-terminal-screen\": \"\", \"data-kind-code\": \"\" }, [\n        h(\"div\", { \"data-terminal-header\": \"\" }, [h(TerminalCommand), h(TerminalCopy)]),\n        h(\n          TerminalViewport,\n          null,\n          stable(() => h(TerminalOutput)),\n        ),\n        h(TerminalJump),\n      ]),\n    ),\n  ),\n];\n\n/**\n * A command and its output as a step: the command, its exit code and duration, its approval while it has one, then\n * the output with its ANSI colors, following its end while it streams. A default slot replaces the default parts.\n */\nexport const Terminal = defineComponent({\n  name: \"Terminal\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () => h(parts.Root, attrs, { ...slots, default: slots.default ?? defaultParts });\n  },\n}) as unknown as typeof parts.Root;\n",
      "type": "registry:ui",
      "target": "@ui/vue/terminal.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
