{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "diff-vue",
  "title": "Diff (Vue)",
  "description": "One file's changes or a run's, with Keep and Undo for each file and change, and Keep all and Undo all.",
  "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"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/diff.ts",
      "content": "import {\n  codeSpans,\n  type DiffLineView,\n  type DiffPiece,\n  type DiffTableRow,\n  diffPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { defineComponent, h } from \"vue\";\n\nconst parts = createParts(diffPrimitive, {\n  root: \"div\",\n  summary: \"div\",\n  \"summary-title\": \"div\",\n  \"summary-counts\": \"span\",\n  \"summary-mark\": \"span\",\n  \"summary-progress\": \"div\",\n  \"summary-outcome\": \"div\",\n  \"summary-actions\": \"div\",\n  \"undo-all\": \"button\",\n  \"keep-all\": \"button\",\n  \"undo-all-question\": \"span\",\n  \"undo-all-cancel\": \"button\",\n  \"undo-all-confirm\": \"button\",\n  \"summary-error\": \"div\",\n  list: \"div\",\n  file: \"div\",\n  \"file-trigger\": \"button\",\n  \"file-path\": \"span\",\n  \"file-old-path\": \"span\",\n  \"file-status\": \"span\",\n  \"file-counts\": \"span\",\n  \"file-mark\": \"span\",\n  \"file-actions\": \"div\",\n  \"file-undo\": \"button\",\n  \"file-keep\": \"button\",\n  \"file-outcome\": \"span\",\n  \"file-error\": \"span\",\n  \"file-content\": \"div\",\n  \"file-note\": \"div\",\n  viewport: \"div\",\n  table: \"div\",\n  head: \"div\",\n  column: \"span\",\n  change: \"div\",\n  \"change-title\": \"div\",\n  \"change-undo\": \"button\",\n  \"change-keep\": \"button\",\n  \"change-outcome\": \"span\",\n  \"change-error\": \"span\",\n  line: \"div\",\n  \"old-number\": \"span\",\n  \"new-number\": \"span\",\n  sign: \"span\",\n  code: \"span\",\n  collapsed: \"button\",\n  \"collapsed-text\": \"span\",\n  \"show-all\": \"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\ntype Text = { text: string };\nconst text = (state: Text) => state.text;\n\n// Text with its backticks as `code`.\nconst withCode = (value: string) =>\n  codeSpans(value).map((piece, index) => (index % 2 ? h(\"code\", { key: index }, piece) : piece));\n\nconst running = () => h(\"span\", { \"data-status-mark\": \"\", \"data-status\": \"running\", \"aria-hidden\": \"true\" });\nconst pending = () =>\n  h(\"span\", {\n    \"data-kind-pending-mark\": \"\",\n    \"data-status-mark\": \"\",\n    \"data-status\": \"running\",\n    \"aria-hidden\": \"true\",\n  });\n\nconst counts = (state: { added: string; removed: string; name: string }) => {\n  const { added, removed } = state;\n  return [\n    h(\"span\", { \"aria-hidden\": \"true\" }, [\n      added ? h(\"span\", { \"data-diff-added\": \"\" }, added) : null,\n      added && removed ? \" \" : null,\n      removed ? h(\"span\", { \"data-diff-removed\": \"\" }, removed) : null,\n    ]),\n    h(\"span\", { \"data-diff-hidden\": \"\" }, state.name),\n  ];\n};\n\nconst outcome = (state: { text: string; working: boolean }) => [state.working ? running() : null, state.text];\n\n/** The title, counts, progress and Keep all and Undo all, above several files. */\nexport const DiffSummary = parts.Summary;\n/** The running mark while a patch streams. */\nexport const DiffSummaryMark = parts.SummaryMark;\n/** Holds Undo all and Keep all, or Undo all's question. */\nexport const DiffSummaryActions = parts.SummaryActions;\n/** Holds a file's Keep, Undo, outcome and error, at one width. */\nexport const DiffFileActions = parts.FileActions;\n/** The running mark in place of a file's counts while its patch streams. */\nexport const DiffFileMark = parts.FileMark;\n/** A file's lines, opened by its row. */\nexport const DiffFileContent = parts.FileContent;\n/** Scrolls a file's lines. Holds a `DiffTable`. */\nexport const DiffViewport = parts.Viewport;\n/** The screen-reader column headers. */\nexport const DiffHead = parts.Head;\n/** Opens and closes the file's lines. Holds its path, status and counts. */\nexport const DiffFileTrigger = parts.FileTrigger;\n/** The line's number in the old file, drawn from `data-line`, so a copy holds only code. */\nexport const DiffOldNumber = parts.OldNumber;\n/** The line's number in the new file, drawn from `data-line`. */\nexport const DiffNewNumber = parts.NewNumber;\n/** `+` or `−`, drawn from `data-sign`. */\nexport const DiffSign = parts.Sign;\n\n/** \"4 files changed\", \"Editing 2 files\" or \"All changes reviewed\", unless you fill the default slot. */\nexport const DiffSummaryTitle = withDefault(parts.SummaryTitle, \"DiffSummaryTitle\", text);\n\n/** \"+120 −8\", read as \"120 additions, 8 deletions\", unless you fill the default slot. */\nexport const DiffSummaryCounts = withDefault(parts.SummaryCounts, \"DiffSummaryCounts\", counts);\n\n/** \"2 of 4 reviewed\", then \"3 kept, 1 undone\", unless you fill the default slot. */\nexport const DiffSummaryProgress = withDefault(parts.SummaryProgress, \"DiffSummaryProgress\", text);\n\n/** \"3 kept, 1 undone\" once every change is reviewed, unless you fill the default slot. */\nexport const DiffSummaryOutcome = withDefault(parts.SummaryOutcome, \"DiffSummaryOutcome\", text);\n\n/** Asks before undoing every undecided file. \"Undo all\", unless you fill the default slot. */\nexport const DiffUndoAll = withDefault(parts.UndoAll, \"DiffUndoAll\", text);\n\n/** \"Keep all\", unless you fill the default slot. */\nexport const DiffKeepAll = withDefault(parts.KeepAll, \"DiffKeepAll\", (state: Text) => [\n  pending(),\n  state.text,\n]);\n\n/** \"Undo all 4 files? This can't be undone.\", unless you fill the default slot. */\nexport const DiffUndoAllQuestion = withDefault(\n  parts.UndoAllQuestion,\n  \"DiffUndoAllQuestion\",\n  (state: { text: string; warning: string }) => [\n    state.text,\n    \" \",\n    h(\"span\", { \"data-diff-warning\": \"\" }, state.warning),\n  ],\n);\n\n/** \"Cancel\", unless you fill the default slot. */\nexport const DiffUndoAllCancel = withDefault(parts.UndoAllCancel, \"DiffUndoAllCancel\", text);\n\n/** Undoes every undecided file. \"Undo all\", unless you fill the default slot. */\nexport const DiffUndoAllConfirm = withDefault(parts.UndoAllConfirm, \"DiffUndoAllConfirm\", (state: Text) => [\n  pending(),\n  state.text,\n]);\n\n/** \"Couldn't undo all changes\", unless you fill the default slot. */\nexport const DiffSummaryError = withDefault(parts.SummaryError, \"DiffSummaryError\", text);\n\n/** The path, cut at its start when it's long so the file name stays, unless you fill the default slot. */\nexport const DiffFilePath = withDefault(parts.FilePath, \"DiffFilePath\", (state: Text) =>\n  h(\"bdi\", state.text),\n);\n\n/** \"from old/path.ts\" for a rename, unless you fill the default slot. */\nexport const DiffFileOldPath = withDefault(parts.FileOldPath, \"DiffFileOldPath\", (state: Text) =>\n  h(\"bdi\", state.text),\n);\n\n/** \"Added\", \"Deleted\" or \"Renamed\", unless you fill the default slot. Absent for a modified file. */\nexport const DiffFileStatus = withDefault(parts.FileStatus, \"DiffFileStatus\", text);\n\n/** \"+4 −2\", read as \"4 additions, 2 deletions\", unless you fill the default slot. */\nexport const DiffFileCounts = withDefault(parts.FileCounts, \"DiffFileCounts\", counts);\n\n/** \"Undo\", named with the path, unless you fill the default slot. */\nexport const DiffFileUndo = withDefault(parts.FileUndo, \"DiffFileUndo\", text);\n\n/** \"Keep\", named with the path, unless you fill the default slot. */\nexport const DiffFileKeep = withDefault(parts.FileKeep, \"DiffFileKeep\", text);\n\n/** \"Kept\", \"Undone\", \"Keeping…\" or \"Undoing…\" in the buttons' place, unless you fill the default slot. */\nexport const DiffFileOutcome = withDefault(parts.FileOutcome, \"DiffFileOutcome\", outcome);\n\n/** \"Couldn't undo `auth.ts`\", unless you fill the default slot. */\nexport const DiffFileError = withDefault(parts.FileError, \"DiffFileError\", (state: Text) =>\n  withCode(state.text),\n);\n\n/** \"Binary file, not shown\" or \"Renamed, no changes\" in place of lines, unless you fill the default slot. */\nexport const DiffFileNote = withDefault(parts.FileNote, \"DiffFileNote\", text);\n\n/** A column's name for screen readers, unless you fill the default slot. */\nexport const DiffColumn = withDefault(parts.Column, \"DiffColumn\", text);\n\nexport const DiffChangeUndo = withDefault(parts.ChangeUndo, \"DiffChangeUndo\", text);\nexport const DiffChangeKeep = withDefault(parts.ChangeKeep, \"DiffChangeKeep\", text);\nexport const DiffChangeOutcome = withDefault(parts.ChangeOutcome, \"DiffChangeOutcome\", outcome);\nexport const DiffChangeError = withDefault(parts.ChangeError, \"DiffChangeError\", text);\n\n/** The change's words, then its error, Undo, Keep and outcome, unless you fill the default slot. */\nexport const DiffChangeTitle = withDefault(parts.ChangeTitle, \"DiffChangeTitle\", (state: Text) => [\n  h(\"span\", { \"data-diff-change-text\": \"\" }, state.text),\n  h(DiffChangeError),\n  h(DiffChangeUndo),\n  h(DiffChangeKeep),\n  h(DiffChangeOutcome),\n]);\n\n/**\n * A change's header row, \"Change 1 of 2 · line 19\" with its Keep and Undo, unless you fill the default slot. Renders\n * again only when its props change.\n */\nexport const DiffChange = withDefault(parts.Change, \"DiffChange\", () => h(DiffChangeTitle));\n\n/** \"Show 12 lines\", unless you fill the default slot. Its name says where they are. */\nexport const DiffCollapsed = withDefault(parts.Collapsed, \"DiffCollapsed\", text);\n\n/** The collapsed lines, hidden until find in page matches one, unless you fill the default slot. */\nexport const DiffCollapsedText = withDefault(parts.CollapsedText, \"DiffCollapsedText\", text);\n\nconst piece = (part: DiffPiece, index: number) =>\n  h(\n    \"span\",\n    {\n      key: index,\n      style: part.color ? { color: part.color } : undefined,\n      \"data-diff-changed\": part.changed ? \"\" : undefined,\n      \"data-italic\": part.fontStyle === \"italic\" ? \"\" : undefined,\n      \"data-bold\": part.fontStyle === \"bold\" ? \"\" : undefined,\n    },\n    part.text,\n  );\n\nconst code = (line: DiffLineView | undefined) => {\n  if (!line) return null;\n  if (line.kind === \"collapsed\") return [h(DiffCollapsed), h(DiffCollapsedText)];\n  const pieces = line.pieces.map(piece);\n  return [\n    line.prefix ? h(\"span\", { \"data-diff-hidden\": \"\" }, `${line.prefix} `) : null,\n    line.kind === \"add\" ? h(\"ins\", pieces) : line.kind === \"remove\" ? h(\"del\", pieces) : pieces,\n  ];\n};\n\n/**\n * The line's code, in `ins` or `del` with its changed words marked and hidden words for screen readers, or a\n * collapsed run's `DiffCollapsed` and `DiffCollapsedText`, unless you fill the default slot.\n */\nexport const DiffCode = withDefault(parts.Code, \"DiffCode\", (state: { line: DiffLineView | undefined }) =>\n  code(state.line),\n);\n\n/** A line: its numbers, its sign and its code, unless you fill the default slot. Renders again only when its props change. */\nexport const DiffLine = withDefault(parts.Line, \"DiffLine\", () => [\n  h(DiffOldNumber),\n  h(DiffNewNumber),\n  h(DiffSign),\n  h(DiffCode),\n]);\n\n/** The column headers, then a `DiffChange` or `DiffLine` for each row, unless you fill the default slot. */\nexport const DiffTable = withDefault(\n  parts.Table,\n  \"DiffTable\",\n  (state: { rows: readonly DiffTableRow[]; columns: readonly string[] }) => {\n    const { columns } = state;\n    return [\n      h(DiffHead, null, () => columns.map((column) => h(DiffColumn, { key: column, value: column }))),\n      ...state.rows.map((row) =>\n        h(row.change ? DiffChange : DiffLine, { key: row.key, value: row.key } as never),\n      ),\n    ];\n  },\n);\n\n/** \"Show full diff (6,400 lines)\" for a file cut off at 2,000 rows, unless you fill the default slot. */\nexport const DiffShowAll = withDefault(parts.ShowAll, \"DiffShowAll\", text);\n\nconst fileParts = () => [\n  h(\n    DiffFileTrigger,\n    null,\n    stable(() => [\n      h(\"span\", { \"data-diff-name\": \"\" }, [h(DiffFilePath), h(DiffFileOldPath)]),\n      h(DiffFileStatus),\n      h(DiffFileCounts),\n      h(DiffFileMark),\n    ]),\n  ),\n  h(\n    DiffFileActions,\n    null,\n    stable(() => [h(DiffFileError), h(DiffFileUndo), h(DiffFileKeep), h(DiffFileOutcome)]),\n  ),\n  h(\n    DiffFileContent,\n    null,\n    stable(() => [\n      h(DiffFileNote),\n      h(\n        DiffViewport,\n        null,\n        stable(() => [h(DiffTable), h(DiffShowAll)]),\n      ),\n    ]),\n  ),\n];\n\n/**\n * The file whose path is `value`: its row and its lines, unless you fill the default slot. Renders again only when\n * its props change, so a file that didn't change isn't rendered again when another streams.\n */\nexport const DiffFile = withDefault(parts.File, \"DiffFile\", fileParts);\n\n/** A `DiffFile` for each file, unless you fill the default slot. */\nexport const DiffList = withDefault(parts.List, \"DiffList\", (state: { paths: readonly string[] }) =>\n  state.paths.map((path) => h(DiffFile, { key: path, value: path })),\n);\n\nconst defaultParts = () => [\n  h(\n    DiffSummary,\n    null,\n    stable(() => [\n      h(\"div\", { \"data-diff-heading\": \"\" }, [\n        h(DiffSummaryTitle),\n        h(DiffSummaryCounts),\n        h(DiffSummaryProgress),\n        h(DiffSummaryOutcome),\n      ]),\n      h(DiffSummaryMark),\n      h(\n        DiffSummaryActions,\n        null,\n        stable(() => [\n          h(DiffUndoAllQuestion),\n          h(DiffUndoAll),\n          h(DiffKeepAll),\n          h(DiffUndoAllCancel),\n          h(DiffUndoAllConfirm),\n        ]),\n      ),\n      h(DiffSummaryError),\n    ]),\n  ),\n  h(DiffList),\n];\n\n/**\n * One file's changes, or a run's: a summary with Keep all and Undo all, then each file's row with its own Keep and\n * Undo, opening to its lines. A default slot replaces the default parts.\n */\nexport const Diff = defineComponent({\n  name: \"Diff\",\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/diff.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
