{
  "schemaVersion": 1,
  "target": "react",
  "name": "diff-viewer",
  "version": "0.1.0",
  "category": "ai-elements",
  "title": "Diff Viewer",
  "description": "What an agent changed in a file, diffed locally from old and new text or read from a unified diff, in unified or split layout with word highlights, folded unchanged lines, and optional per hunk Accept and Reject.",
  "tags": [
    "ai",
    "agent",
    "diff",
    "code",
    "review",
    "patch",
    "changes"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {},
  "registryDependencies": [],
  "docsPath": "/components/diff-viewer",
  "props": [
    {
      "name": "path",
      "type": "string",
      "description": "File path for the header. Read from the patch when unset."
    },
    {
      "name": "oldText / newText",
      "type": "string",
      "description": "The file before and after. Diffed in the browser with a Myers line diff and a word diff inside changed line pairs. Use \"\" for a new or deleted file."
    },
    {
      "name": "patch",
      "type": "string",
      "description": "A unified diff for the file, used instead of oldText and newText."
    },
    {
      "name": "oldPath",
      "type": "string",
      "description": "Previous path, shown as old → new for a rename."
    },
    {
      "name": "view / defaultView / onViewChange",
      "type": "\"unified\" | \"split\"",
      "default": "\"unified\"",
      "description": "Layout. Split falls back to unified below 560px of width."
    },
    {
      "name": "viewToggle",
      "type": "boolean",
      "default": "true",
      "description": "Shows the Unified and Split switch in the header."
    },
    {
      "name": "context",
      "type": "number",
      "default": "3",
      "description": "Unchanged lines kept around each change; the rest fold into Show N lines rows."
    },
    {
      "name": "onDecisionChange",
      "type": "(hunk, decision: \"accepted\" | \"rejected\" | null) => void",
      "description": "Shows Accept and Reject on each hunk. null means Undo."
    },
    {
      "name": "decisions",
      "type": "Record<number, \"accepted\" | \"rejected\">",
      "description": "Controlled hunk decisions by hunk index."
    },
    {
      "name": "hunkActions",
      "type": "boolean",
      "default": "onDecisionChange is set",
      "description": "Shows hunk actions with local state."
    },
    {
      "name": "defaultCollapsed",
      "type": "boolean",
      "default": "false",
      "description": "Starts with the file body folded under its header."
    },
    {
      "name": "wrap",
      "type": "boolean",
      "default": "false",
      "description": "Soft wraps long lines in the unified layout instead of scrolling them."
    },
    {
      "name": "DiffViewerList",
      "type": "{ files?: DiffFile[]; patch?: string; title?; onDecisionChange?(path, hunk, decision) }",
      "description": "Several files with a summary line, total counts, and one shared layout switch. Accepts a multi file git diff."
    },
    {
      "name": "diffLines / parsePatch",
      "type": "functions",
      "description": "The diff and the unified diff parser on their own."
    }
  ],
  "accessibility": [
    "Each file is a labeled region (Changes to path). The header is a button with aria-expanded that folds the body.",
    "Added and removed lines carry visually hidden Added and Removed prefixes; the + and − signs and line numbers are hidden from screen readers, and color is never the only signal.",
    "Addition and deletion counts are read as lines added and lines removed; the five block bar is decorative.",
    "Show N lines rows, Accept, Reject, and Undo are native buttons; the layout switch is a radio group.",
    "Accepting or rejecting a hunk folds its lines (aria-hidden and invisible) and leaves a summary row with Undo, so the decision stays reachable.",
    "With reduced motion the fold reveal, hunk fold, and header chevron change instantly."
  ],
  "states": [
    "unified",
    "split",
    "collapsed",
    "accepted",
    "rejected",
    "new file",
    "no changes"
  ],
  "files": [
    {
      "path": "agent/diff-viewer.tsx",
      "content": "\"use client\";\n\nimport { type ComponentProps, type ReactNode, useEffect, useId, useMemo, useRef, useState } from \"react\";\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nconst ease = \"ease-[cubic-bezier(0.23,1,0.32,1)]\";\n\n/*\n * Diff viewer: what an agent changed in a file.\n *\n * Give it the old and new text and it computes a line diff locally (Myers, O((N+M)D)), then a\n * word diff inside each changed line pair. Or give it a unified diff string. Unchanged stretches\n * fold into \"Show N lines\" rows that open with a height reveal; an accepted or rejected hunk\n * folds itself away into a one line summary you can undo.\n */\n\n// ---------------------------------------------------------------------------\n// Diffing\n\nexport type DiffLineKind = \"context\" | \"add\" | \"del\";\n\nexport interface DiffPart {\n  text: string;\n  /** True when this run differs from the paired line. */\n  changed: boolean;\n}\n\nexport interface DiffLine {\n  kind: DiffLineKind;\n  text: string;\n  oldNumber?: number;\n  newNumber?: number;\n  /** Word level runs, present on changed lines that pair with a similar line. */\n  parts?: DiffPart[];\n}\n\ntype Op = \"equal\" | \"insert\" | \"delete\";\n\n/** Myers' greedy shortest edit script. Snapshots only the live diagonal window to keep memory linear in D. */\nfunction myers<T>(a: T[], b: T[]): Op[] {\n  // Trim the common prefix and suffix; most agent edits touch a small middle.\n  let start = 0;\n  while (start < a.length && start < b.length && a[start] === b[start]) start++;\n  let endA = a.length;\n  let endB = b.length;\n  while (endA > start && endB > start && a[endA - 1] === b[endB - 1]) {\n    endA--;\n    endB--;\n  }\n  const head: Op[] = Array.from({ length: start }, () => \"equal\");\n  const tail: Op[] = Array.from({ length: a.length - endA }, () => \"equal\");\n  const x0 = a.slice(start, endA);\n  const y0 = b.slice(start, endB);\n  const n = x0.length;\n  const m = y0.length;\n  if (n === 0) return [...head, ...Array.from({ length: m }, (): Op => \"insert\"), ...tail];\n  if (m === 0) return [...head, ...Array.from({ length: n }, (): Op => \"delete\"), ...tail];\n\n  const max = n + m;\n  const off = max + 1;\n  const v = new Int32Array(2 * max + 3);\n  const trace: Int32Array[] = [];\n  let found = -1;\n  outer: for (let d = 0; d <= max; d++) {\n    trace.push(v.slice(off - d - 1, off + d + 2));\n    for (let k = -d; k <= d; k += 2) {\n      let x = k === -d || (k !== d && v[off + k - 1]! < v[off + k + 1]!) ? v[off + k + 1]! : v[off + k - 1]! + 1;\n      let y = x - k;\n      while (x < n && y < m && x0[x] === y0[y]) {\n        x++;\n        y++;\n      }\n      v[off + k] = x;\n      if (x >= n && y >= m) {\n        found = d;\n        break outer;\n      }\n    }\n  }\n\n  const ops: Op[] = [];\n  let x = n;\n  let y = m;\n  for (let d = found; d >= 0; d--) {\n    const snap = trace[d]!;\n    const at = (k: number) => snap[k + d + 1]!;\n    const k = x - y;\n    const prevK = k === -d || (k !== d && at(k - 1) < at(k + 1)) ? k + 1 : k - 1;\n    const prevX = d === 0 ? 0 : at(prevK);\n    const prevY = prevX - prevK;\n    while (x > prevX && y > prevY) {\n      ops.push(\"equal\");\n      x--;\n      y--;\n    }\n    if (d > 0) {\n      ops.push(x === prevX ? \"insert\" : \"delete\");\n      x = prevX;\n      y = prevY;\n    }\n  }\n  ops.reverse();\n  return [...head, ...ops, ...tail];\n}\n\nfunction splitLines(text: string): string[] {\n  if (text === \"\") return [];\n  const lines = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n  if (lines[lines.length - 1] === \"\") lines.pop();\n  return lines;\n}\n\nconst tokenPattern = /\\s+|[\\p{L}\\p{N}_]+|[^\\s\\p{L}\\p{N}_]/gu;\n\n/** Word level runs for a removed and an added line. Returns nothing when the lines share too little to be worth marking. */\nfunction diffWords(before: string, after: string): [DiffPart[], DiffPart[]] | null {\n  const a = before.match(tokenPattern) ?? [];\n  const b = after.match(tokenPattern) ?? [];\n  const ops = myers(a, b);\n  const left: DiffPart[] = [];\n  const right: DiffPart[] = [];\n  const push = (into: DiffPart[], text: string, changed: boolean) => {\n    const last = into[into.length - 1];\n    if (last && last.changed === changed) last.text += text;\n    else into.push({ text, changed });\n  };\n  let i = 0;\n  let j = 0;\n  let shared = 0;\n  for (const op of ops) {\n    if (op === \"equal\") {\n      shared += a[i]!.trim() ? a[i]!.length : 0;\n      push(left, a[i++]!, false);\n      push(right, b[j++]!, false);\n    } else if (op === \"delete\") push(left, a[i++]!, true);\n    else push(right, b[j++]!, true);\n  }\n  // A line that was mostly rewritten reads better as a plain removed and added pair.\n  const longest = Math.max(before.trim().length, after.trim().length);\n  if (longest === 0) return null;\n  const ratio = shared / longest;\n  const runs = left.filter((part) => part.changed).length + right.filter((part) => part.changed).length;\n  // Few changed runs (an appended clause, a wrapped call) highlight well; scattered edits turn to confetti.\n  if (ratio < 0.4 || (ratio < 0.75 && runs > 4)) return null;\n  return [left, right];\n}\n\n/** Puts every removed line of a change run before its added lines and pairs them for word highlights. */\nfunction pairRun(dels: DiffLine[], adds: DiffLine[]) {\n  for (let i = 0; i < Math.min(dels.length, adds.length); i++) {\n    const words = diffWords(dels[i]!.text, adds[i]!.text);\n    if (words) {\n      dels[i]!.parts = words[0];\n      adds[i]!.parts = words[1];\n    }\n  }\n}\n\n/** Every line of the new file plus the removed ones, in reading order, with line numbers and word runs. */\nexport function diffLines(oldText: string, newText: string): DiffLine[] {\n  const a = splitLines(oldText);\n  const b = splitLines(newText);\n  const ops = myers(a, b);\n  const out: DiffLine[] = [];\n  let i = 0;\n  let j = 0;\n  let dels: DiffLine[] = [];\n  let adds: DiffLine[] = [];\n  const flush = () => {\n    pairRun(dels, adds);\n    out.push(...dels, ...adds);\n    dels = [];\n    adds = [];\n  };\n  for (const op of ops) {\n    if (op === \"equal\") {\n      flush();\n      out.push({ kind: \"context\", text: b[j]!, oldNumber: ++i, newNumber: ++j });\n    } else if (op === \"delete\") dels.push({ kind: \"del\", text: a[i]!, oldNumber: ++i });\n    else adds.push({ kind: \"add\", text: b[j]!, newNumber: ++j });\n  }\n  flush();\n  return out;\n}\n\n// ---------------------------------------------------------------------------\n// Unified diff parsing\n\nexport interface PatchHunk {\n  header: string;\n  oldStart: number;\n  newStart: number;\n  lines: DiffLine[];\n}\n\nexport interface PatchFile {\n  oldPath?: string;\n  newPath?: string;\n  hunks: PatchHunk[];\n}\n\nconst hunkHeader = /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(.*)$/;\n\n/** Parses a unified diff (git or plain) into files and hunks. Hunk line counts decide where each hunk ends. */\nexport function parsePatch(patch: string): PatchFile[] {\n  const files: PatchFile[] = [];\n  let file: PatchFile | null = null;\n  let hunk: PatchHunk | null = null;\n  let oldNo = 0;\n  let newNo = 0;\n  let oldLeft = 0;\n  let newLeft = 0;\n  let dels: DiffLine[] = [];\n  let adds: DiffLine[] = [];\n  const flush = () => {\n    if (hunk) {\n      pairRun(dels, adds);\n      hunk.lines.push(...dels, ...adds);\n    }\n    dels = [];\n    adds = [];\n  };\n  const startFile = () => {\n    file = { hunks: [] };\n    files.push(file);\n    return file;\n  };\n  const clean = (path: string) => {\n    const value = path.trim().split(\"\\t\")[0]!;\n    return value === \"/dev/null\" ? undefined : value.replace(/^[ab]\\//, \"\");\n  };\n\n  for (const raw of patch.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\")) {\n    if (hunk && (oldLeft > 0 || newLeft > 0)) {\n      const sign = raw.charAt(0);\n      const text = raw.slice(1);\n      if (sign === \"+\") {\n        adds.push({ kind: \"add\", text, newNumber: newNo++ });\n        newLeft--;\n      } else if (sign === \"-\") {\n        dels.push({ kind: \"del\", text, oldNumber: oldNo++ });\n        oldLeft--;\n      } else if (sign === \" \" || raw === \"\") {\n        flush();\n        hunk.lines.push({ kind: \"context\", text, oldNumber: oldNo++, newNumber: newNo++ });\n        oldLeft--;\n        newLeft--;\n      }\n      // \"\\ No newline at end of file\" carries no line.\n      if (oldLeft <= 0 && newLeft <= 0) {\n        flush();\n        hunk = null;\n      }\n      continue;\n    }\n    if (raw.startsWith(\"diff --git \")) {\n      const current = startFile();\n      const match = /^diff --git a\\/(.+) b\\/(.+)$/.exec(raw);\n      if (match) {\n        current.oldPath = match[1];\n        current.newPath = match[2];\n      }\n    } else if (raw.startsWith(\"--- \")) {\n      const current: PatchFile = file && (file as PatchFile).hunks.length === 0 ? file : startFile();\n      current.oldPath = clean(raw.slice(4));\n    } else if (raw.startsWith(\"+++ \")) {\n      (file ?? startFile()).newPath = clean(raw.slice(4));\n    } else {\n      const header = hunkHeader.exec(raw);\n      if (!header) continue;\n      oldNo = Number(header[1]);\n      newNo = Number(header[3]);\n      oldLeft = header[2] === undefined ? 1 : Number(header[2]);\n      newLeft = header[4] === undefined ? 1 : Number(header[4]);\n      hunk = { header: raw, oldStart: oldNo, newStart: newNo, lines: [] };\n      (file ?? startFile()).hunks.push(hunk);\n      if (oldLeft <= 0 && newLeft <= 0) hunk = null;\n    }\n  }\n  flush();\n  return files;\n}\n\n// ---------------------------------------------------------------------------\n// Segments: hunks with folded unchanged stretches between them\n\ntype Segment =\n  | { type: \"hunk\"; index: number; header: string; lines: DiffLine[] }\n  | { type: \"gap\"; key: string; lines: DiffLine[] | null; count: number; edge: \"start\" | \"middle\" | \"end\" };\n\nfunction headerFor(lines: DiffLine[]): string {\n  const oldLines = lines.filter((line) => line.kind !== \"add\");\n  const newLines = lines.filter((line) => line.kind !== \"del\");\n  const oldStart = oldLines[0]?.oldNumber ?? (lines.find((line) => line.oldNumber)?.oldNumber ?? 1) - 1;\n  const newStart = newLines[0]?.newNumber ?? (lines.find((line) => line.newNumber)?.newNumber ?? 1) - 1;\n  return `@@ -${oldStart},${oldLines.length} +${newStart},${newLines.length} @@`;\n}\n\nfunction segmentsFromLines(lines: DiffLine[], context: number): Segment[] {\n  const ranges: [number, number][] = [];\n  lines.forEach((line, index) => {\n    if (line.kind === \"context\") return;\n    const from = Math.max(0, index - context);\n    const to = Math.min(lines.length - 1, index + context);\n    const last = ranges[ranges.length - 1];\n    // Folding fewer than four lines saves nothing, so close gaps merge into one hunk.\n    if (last && from <= last[1] + 4) last[1] = Math.max(last[1], to);\n    else ranges.push([from, to]);\n  });\n  const out: Segment[] = [];\n  let cursor = 0;\n  ranges.forEach(([from, to], index) => {\n    if (from > cursor) out.push({ type: \"gap\", key: `g${cursor}`, lines: lines.slice(cursor, from), count: from - cursor, edge: cursor === 0 ? \"start\" : \"middle\" });\n    const slice = lines.slice(from, to + 1);\n    out.push({ type: \"hunk\", index, header: headerFor(slice), lines: slice });\n    cursor = to + 1;\n  });\n  if (cursor < lines.length && ranges.length > 0) out.push({ type: \"gap\", key: `g${cursor}`, lines: lines.slice(cursor), count: lines.length - cursor, edge: \"end\" });\n  return out;\n}\n\nfunction segmentsFromPatch(file: PatchFile): Segment[] {\n  const out: Segment[] = [];\n  let nextNew = 1;\n  file.hunks.forEach((hunk, index) => {\n    const hidden = hunk.newStart - nextNew;\n    if (hidden > 0 && index > 0) out.push({ type: \"gap\", key: `p${index}`, lines: null, count: hidden, edge: \"middle\" });\n    out.push({ type: \"hunk\", index, header: hunk.header, lines: hunk.lines });\n    const newLines = hunk.lines.filter((line) => line.kind !== \"del\").length;\n    nextNew = hunk.newStart + newLines;\n  });\n  return out;\n}\n\nfunction countLines(lines: DiffLine[]) {\n  let additions = 0;\n  let deletions = 0;\n  for (const line of lines) {\n    if (line.kind === \"add\") additions++;\n    else if (line.kind === \"del\") deletions++;\n  }\n  return { additions, deletions };\n}\n\n// ---------------------------------------------------------------------------\n// Component\n\nexport type DiffView = \"unified\" | \"split\";\nexport type HunkDecision = \"accepted\" | \"rejected\";\n\nexport interface DiffViewerProps extends Omit<ComponentProps<\"section\">, \"children\"> {\n  /** File path shown in the header, for example `src/billing/proration.ts`. */\n  path?: string;\n  /** Previous path when the file was renamed. */\n  oldPath?: string;\n  /** The file before the change. Pair with `newText`; use `\"\"` for a new file. */\n  oldText?: string;\n  /** The file after the change. */\n  newText?: string;\n  /** A unified diff for this file, used instead of `oldText` and `newText`. Paths come from it when `path` is unset. */\n  patch?: string;\n  /** Controlled layout. */\n  view?: DiffView;\n  /** Initial layout when uncontrolled. Split falls back to unified below 560px of width. */\n  defaultView?: DiffView;\n  onViewChange?: (view: DiffView) => void;\n  /** Shows the Unified and Split switch in the header. */\n  viewToggle?: boolean;\n  /** Unchanged lines kept around each change. */\n  context?: number;\n  /** Controlled hunk decisions, keyed by hunk index. */\n  decisions?: Record<number, HunkDecision | undefined>;\n  /** Called when a hunk is accepted, rejected, or undone (`null`). Shows the Accept and Reject actions. */\n  onDecisionChange?: (hunk: number, decision: HunkDecision | null) => void;\n  /** Shows hunk actions even without `onDecisionChange`, with local state. */\n  hunkActions?: boolean;\n  /** Starts with the file body collapsed. */\n  defaultCollapsed?: boolean;\n  /** Soft wraps long lines in the unified layout instead of scrolling. Split always wraps. */\n  wrap?: boolean;\n}\n\n/** One file's changes with a header, line numbers, folded unchanged lines, and optional per hunk Accept and Reject. */\nexport function DiffViewer({\n  path,\n  oldPath,\n  oldText,\n  newText,\n  patch,\n  view: viewProp,\n  defaultView = \"unified\",\n  onViewChange,\n  viewToggle = true,\n  context = 3,\n  decisions: decisionsProp,\n  onDecisionChange,\n  hunkActions,\n  defaultCollapsed = false,\n  wrap = false,\n  className,\n  ...props\n}: DiffViewerProps) {\n  const parsed = useMemo(() => {\n    if (patch != null) {\n      const file = parsePatch(patch)[0] ?? { hunks: [] };\n      const lines = file.hunks.flatMap((hunk) => hunk.lines);\n      return {\n        segments: segmentsFromPatch(file),\n        ...countLines(lines),\n        path: path ?? file.newPath ?? file.oldPath ?? \"\",\n        oldPath: oldPath ?? (file.oldPath !== file.newPath ? file.oldPath : undefined),\n        status: !file.oldPath && file.newPath ? \"added\" : file.oldPath && !file.newPath ? \"deleted\" : undefined,\n      };\n    }\n    const lines = diffLines(oldText ?? \"\", newText ?? \"\");\n    return {\n      segments: segmentsFromLines(lines, context),\n      ...countLines(lines),\n      path: path ?? \"\",\n      oldPath,\n      status: !oldText && newText ? \"added\" : oldText && !newText ? \"deleted\" : undefined,\n    };\n  }, [patch, oldText, newText, context, path, oldPath]);\n\n  const [localView, setLocalView] = useState<DiffView>(defaultView);\n  const requested = viewProp ?? localView;\n  const ref = useRef<HTMLElement>(null);\n  const narrow = useNarrow(ref, 560);\n  const view: DiffView = narrow ? \"unified\" : requested;\n\n  const [localDecisions, setLocalDecisions] = useState<Record<number, HunkDecision | undefined>>({});\n  const decisions = decisionsProp ?? localDecisions;\n  const showActions = hunkActions ?? onDecisionChange !== undefined;\n  const decide = (index: number, decision: HunkDecision | null) => {\n    if (decisionsProp === undefined) setLocalDecisions((current) => ({ ...current, [index]: decision ?? undefined }));\n    onDecisionChange?.(index, decision);\n  };\n\n  const [collapsed, setCollapsed] = useState(defaultCollapsed);\n  const bodyId = useId();\n  const hunks = parsed.segments.filter((segment) => segment.type === \"hunk\").length;\n  const reviewed = Object.values(decisions).filter(Boolean).length;\n\n  return (\n    <section\n      ref={ref}\n      aria-label={parsed.path ? `Changes to ${parsed.path}` : \"Changes\"}\n      className={cx(\n        \"overflow-hidden rounded-xl border border-zinc-950/10 bg-white text-left text-zinc-950 shadow-[0_1px_2px_rgb(0_0_0/0.04)]\",\n        \"dark:border-white/10 dark:bg-black dark:text-white dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.06)]\",\n        className,\n      )}\n      {...props}\n    >\n      <header className=\"flex min-h-11 items-center gap-2 py-1.5 pr-2 pl-1.5\">\n        <button\n          type=\"button\"\n          aria-expanded={!collapsed}\n          aria-controls={bodyId}\n          onClick={() => setCollapsed((value) => !value)}\n          className={cx(\n            \"group flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-lg py-1 pr-2 pl-1 text-left\",\n            \"transition-colors duration-150 ease-out hover:bg-zinc-950/[0.04] motion-reduce:transition-none dark:hover:bg-white/[0.06]\",\n            \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n          )}\n        >\n          <svg\n            aria-hidden=\"true\"\n            viewBox=\"0 0 16 16\"\n            fill=\"none\"\n            className={`size-4 shrink-0 text-zinc-400 transition-[rotate] duration-200 ${ease} group-aria-expanded:rotate-90 motion-reduce:transition-none dark:text-zinc-500`}\n          >\n            <path d=\"m6.25 4.5 3.5 3.5-3.5 3.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n          </svg>\n          <FilePath path={parsed.path} oldPath={parsed.oldPath} />\n          {parsed.status ? (\n            <span className=\"shrink-0 rounded-md border border-zinc-950/10 px-1.5 text-[11px] leading-[18px] text-zinc-500 dark:border-white/10\">\n              {parsed.status === \"added\" ? \"New\" : \"Deleted\"}\n            </span>\n          ) : null}\n        </button>\n        {showActions && hunks > 0 ? (\n          <span className=\"hidden shrink-0 font-mono text-[11px] text-zinc-500 tabular-nums sm:inline\">\n            {reviewed}/{hunks} reviewed\n          </span>\n        ) : null}\n        <DiffStat additions={parsed.additions} deletions={parsed.deletions} />\n        {viewToggle && !narrow ? <ViewSwitch value={view} onChange={(next) => (viewProp === undefined ? setLocalView(next) : null, onViewChange?.(next))} /> : null}\n      </header>\n\n      <div\n        id={bodyId}\n        className={cx(\n          \"grid transition-[grid-template-rows,visibility] motion-reduce:transition-none\",\n          ease,\n          collapsed ? \"invisible grid-rows-[0fr] duration-180\" : \"visible grid-rows-[1fr] duration-220\",\n        )}\n      >\n        <div className=\"min-h-0 overflow-hidden\">\n          <div className=\"border-t border-zinc-950/[0.07] font-mono text-xs leading-5 dark:border-white/[0.08]\">\n            {parsed.segments.length === 0 ? (\n              <p className=\"px-4 py-3 font-sans text-sm text-zinc-500\">No changes</p>\n            ) : (\n              parsed.segments.map((segment) =>\n                segment.type === \"gap\" ? (\n                  <Gap key={segment.key} segment={segment} view={view} wrap={wrap} />\n                ) : (\n                  <Hunk\n                    key={`h${segment.index}`}\n                    segment={segment}\n                    view={view}\n                    wrap={wrap}\n                    actions={showActions}\n                    decision={decisions[segment.index]}\n                    onDecide={(decision) => decide(segment.index, decision)}\n                  />\n                ),\n              )\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nfunction FilePath({ path, oldPath }: { path: string; oldPath?: string }) {\n  const split = (value: string) => {\n    const at = value.lastIndexOf(\"/\");\n    return at < 0 ? [\"\", value] : [value.slice(0, at + 1), value.slice(at + 1)];\n  };\n  const [dir, name] = split(path);\n  return (\n    <span className=\"flex min-w-0 items-baseline font-mono text-[13px] leading-6\">\n      {oldPath ? (\n        <>\n          <span className=\"min-w-0 truncate text-zinc-500\">{oldPath}</span>\n          <span aria-label=\"renamed to\" className=\"shrink-0 px-1.5 text-zinc-400 dark:text-zinc-600\">\n            →\n          </span>\n        </>\n      ) : null}\n      {/* The folder gives way first; the file name only truncates once the folder is gone. */}\n      <span className=\"min-w-0 shrink-[100] truncate text-zinc-500\">{dir}</span>\n      <span className=\"min-w-0 truncate font-medium\">{name}</span>\n    </span>\n  );\n}\n\n/** Counts plus a five block bar of the add and remove share. */\nfunction DiffStat({ additions, deletions }: { additions: number; deletions: number }) {\n  const total = additions + deletions;\n  const green = total === 0 ? 0 : Math.round((additions / total) * 5);\n  const red = total === 0 ? 0 : Math.min(5 - green, Math.max(deletions > 0 ? 1 : 0, Math.round((deletions / total) * 5)));\n  return (\n    <span className=\"flex shrink-0 items-center gap-2 font-mono text-xs tabular-nums\">\n      <span className=\"text-emerald-600 dark:text-emerald-400\">\n        +{additions}\n        <span className=\"sr-only\"> lines added,</span>\n      </span>\n      <span className=\"text-red-600 dark:text-red-400\">\n        −{deletions}\n        <span className=\"sr-only\"> lines removed</span>\n      </span>\n      <span aria-hidden=\"true\" className=\"hidden gap-0.5 min-[420px]:flex\">\n        {Array.from({ length: 5 }, (_, index) => (\n          <span\n            key={index}\n            className={cx(\n              \"size-2 rounded-[2px]\",\n              index < green ? \"bg-emerald-500\" : index < green + red ? \"bg-red-500\" : \"bg-zinc-950/10 dark:bg-white/15\",\n            )}\n          />\n        ))}\n      </span>\n    </span>\n  );\n}\n\nfunction ViewSwitch({ value, onChange }: { value: DiffView; onChange: (view: DiffView) => void }) {\n  const name = useId();\n  return (\n    <fieldset className=\"flex shrink-0 rounded-lg border border-zinc-950/10 p-0.5 dark:border-white/10\">\n      <legend className=\"sr-only\">Diff layout</legend>\n      {([\"unified\", \"split\"] as const).map((option) => (\n        <label key={option} className=\"relative\">\n          <input type=\"radio\" name={name} value={option} checked={value === option} onChange={() => onChange(option)} className=\"peer sr-only\" />\n          <span\n            className={cx(\n              \"block cursor-pointer rounded-md px-2 py-0.5 text-xs font-medium text-zinc-500 capitalize select-none\",\n              \"transition-colors duration-150 ease-out hover:text-zinc-950 motion-reduce:transition-none dark:hover:text-white\",\n              \"peer-checked:bg-zinc-950/[0.06] peer-checked:text-zinc-950 dark:peer-checked:bg-white/[0.09] dark:peer-checked:text-white\",\n              \"peer-focus-visible:outline-2 peer-focus-visible:outline-solid peer-focus-visible:outline-offset-1 peer-focus-visible:outline-sky-500\",\n            )}\n          >\n            {option}\n          </span>\n        </label>\n      ))}\n    </fieldset>\n  );\n}\n\nconst rowTone: Record<DiffLineKind, string> = {\n  context: \"\",\n  add: \"bg-emerald-500/[0.08] dark:bg-emerald-400/[0.09]\",\n  del: \"bg-red-500/[0.08] dark:bg-red-400/[0.09]\",\n};\nconst numberTone: Record<DiffLineKind, string> = {\n  context: \"text-zinc-400 dark:text-zinc-600\",\n  add: \"text-emerald-700/70 dark:text-emerald-400/60\",\n  del: \"text-red-700/70 dark:text-red-400/60\",\n};\nconst markTone: Record<Exclude<DiffLineKind, \"context\">, string> = {\n  add: \"bg-emerald-500/20 dark:bg-emerald-400/25\",\n  del: \"bg-red-500/20 dark:bg-red-400/25\",\n};\nconst signs: Record<DiffLineKind, { glyph: string; label: string; tone: string }> = {\n  context: { glyph: \" \", label: \"\", tone: \"\" },\n  add: { glyph: \"+\", label: \"Added\", tone: \"text-emerald-600 dark:text-emerald-400\" },\n  del: { glyph: \"−\", label: \"Removed\", tone: \"text-red-600 dark:text-red-400\" },\n};\n\nfunction Content({ line }: { line: DiffLine }) {\n  if (!line.parts || line.kind === \"context\") return <>{line.text || \" \"}</>;\n  const tone = markTone[line.kind];\n  return (\n    <>\n      {line.parts.map((part, index) =>\n        part.changed ? (\n          <mark key={index} className={cx(\"rounded-[3px] text-inherit\", tone)}>\n            {part.text}\n          </mark>\n        ) : (\n          <span key={index}>{part.text}</span>\n        ),\n      )}\n    </>\n  );\n}\n\nfunction Sign({ kind }: { kind: DiffLineKind }) {\n  const sign = signs[kind];\n  return (\n    <span className={cx(\"w-5 shrink-0 text-center select-none\", sign.tone)}>\n      <span aria-hidden=\"true\">{sign.glyph}</span>\n      {sign.label ? <span className=\"sr-only\">{sign.label}: </span> : null}\n    </span>\n  );\n}\n\nfunction Num({ value, kind, width }: { value?: number; kind: DiffLineKind; width: number }) {\n  return (\n    <span aria-hidden=\"true\" style={{ minWidth: `${width + 2}ch` }} className={cx(\"shrink-0 px-2 text-right tabular-nums select-none\", numberTone[kind])}>\n      {value ?? \"\"}\n    </span>\n  );\n}\n\nfunction digits(lines: DiffLine[]) {\n  let max = 0;\n  for (const line of lines) max = Math.max(max, line.oldNumber ?? 0, line.newNumber ?? 0);\n  return String(max).length;\n}\n\n/** The lines of a hunk or an opened fold, in the chosen layout. */\nfunction Lines({ lines, view, wrap, width }: { lines: DiffLine[]; view: DiffView; wrap: boolean; width: number }) {\n  const text = \"text-zinc-800 dark:text-zinc-200\";\n  if (view === \"unified\") {\n    return (\n      <div className={cx(!wrap && \"overflow-x-auto\")}>\n        <div className={cx(!wrap && \"w-max min-w-full\")}>\n          {lines.map((line, index) => (\n            <div key={index} className={cx(\"flex\", rowTone[line.kind])}>\n              <Num value={line.oldNumber} kind={line.kind} width={width} />\n              <Num value={line.newNumber} kind={line.kind} width={width} />\n              <Sign kind={line.kind} />\n              <span className={cx(\"min-w-0 flex-1 pr-4\", text, wrap ? \"whitespace-pre-wrap wrap-anywhere\" : \"whitespace-pre\")}>\n                <Content line={line} />\n              </span>\n            </div>\n          ))}\n        </div>\n      </div>\n    );\n  }\n\n  // Split: removed lines on the left, added on the right, paired row by row within each change run.\n  const rows: [DiffLine | null, DiffLine | null][] = [];\n  for (let i = 0; i < lines.length; ) {\n    const line = lines[i]!;\n    if (line.kind === \"context\") {\n      rows.push([line, line]);\n      i++;\n      continue;\n    }\n    const dels: DiffLine[] = [];\n    const adds: DiffLine[] = [];\n    while (i < lines.length && lines[i]!.kind === \"del\") dels.push(lines[i++]!);\n    while (i < lines.length && lines[i]!.kind === \"add\") adds.push(lines[i++]!);\n    for (let r = 0; r < Math.max(dels.length, adds.length); r++) rows.push([dels[r] ?? null, adds[r] ?? null]);\n  }\n  const empty =\n    \"bg-[repeating-linear-gradient(135deg,transparent_0_5px,rgb(9_9_11/0.035)_5px_6px)] dark:bg-[repeating-linear-gradient(135deg,transparent_0_5px,rgb(255_255_255/0.05)_5px_6px)]\";\n  const side = (line: DiffLine | null, which: \"old\" | \"new\") =>\n    line ? (\n      <div className={cx(\"flex min-w-0\", rowTone[line.kind])}>\n        <Num value={which === \"old\" ? line.oldNumber : line.newNumber} kind={line.kind} width={width} />\n        <Sign kind={line.kind} />\n        <span className={cx(\"min-w-0 flex-1 pr-3 whitespace-pre-wrap wrap-anywhere\", text)}>\n          <Content line={line} />\n        </span>\n      </div>\n    ) : (\n      <div aria-hidden=\"true\" className={empty} />\n    );\n  return (\n    <div>\n      {rows.map(([left, right], index) => (\n        <div key={index} className=\"grid grid-cols-2 divide-x divide-zinc-950/[0.07] dark:divide-white/[0.08]\">\n          {side(left, \"old\")}\n          {side(right, \"new\")}\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction Gap({ segment, view, wrap }: { segment: Extract<Segment, { type: \"gap\" }>; view: DiffView; wrap: boolean }) {\n  const [open, setOpen] = useState(false);\n  const label = `${segment.count} unchanged ${segment.count === 1 ? \"line\" : \"lines\"}`;\n  if (open && segment.lines) {\n    return (\n      <div\n        className={cx(\n          \"grid grid-rows-[1fr] opacity-100 transition-[grid-template-rows,opacity] duration-300 motion-reduce:transition-none\",\n          ease,\n          \"starting:grid-rows-[0fr] starting:opacity-0\",\n        )}\n      >\n        <div className=\"min-h-0 overflow-hidden\">\n          <Lines lines={segment.lines} view={view} wrap={wrap} width={digits(segment.lines)} />\n        </div>\n      </div>\n    );\n  }\n  const base = \"flex h-8 w-full items-center gap-2 border-y border-zinc-950/[0.07] bg-zinc-950/[0.02] px-3 font-sans text-xs text-zinc-500 first:border-t-0 last:border-b-0 dark:border-white/[0.08] dark:bg-white/[0.025]\";\n  if (!segment.lines) return <div className={base}>{label}</div>;\n  return (\n    <button\n      type=\"button\"\n      onClick={() => setOpen(true)}\n      className={cx(\n        base,\n        \"group cursor-pointer text-left transition-colors duration-150 ease-out hover:bg-zinc-950/[0.04] hover:text-zinc-950 motion-reduce:transition-none\",\n        \"dark:hover:bg-white/[0.06] dark:hover:text-white\",\n        \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-sky-500\",\n      )}\n    >\n      <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-4 shrink-0\">\n        {segment.edge === \"start\" ? (\n          <path d=\"M5 6.5 8 3.5l3 3M8 3.5v9\" />\n        ) : segment.edge === \"end\" ? (\n          <path d=\"M5 9.5l3 3 3-3M8 12.5v-9\" />\n        ) : (\n          <path d=\"M5 5.5 8 2.75l3 2.75M5 10.5l3 2.75 3-2.75\" />\n        )}\n      </svg>\n      Show {label}\n    </button>\n  );\n}\n\nfunction Hunk({\n  segment,\n  view,\n  wrap,\n  actions,\n  decision,\n  onDecide,\n}: {\n  segment: Extract<Segment, { type: \"hunk\" }>;\n  view: DiffView;\n  wrap: boolean;\n  actions: boolean;\n  decision?: HunkDecision;\n  onDecide: (decision: HunkDecision | null) => void;\n}) {\n  const decided = decision !== undefined;\n  const changed = segment.lines.filter((line) => line.kind !== \"context\").length;\n  const [, at, rest] = /^(@@[^@]*@@)(.*)$/.exec(segment.header) ?? [null, segment.header, \"\"];\n\n  return (\n    <div data-decision={decision} className=\"border-t border-zinc-950/[0.07] first:border-t-0 dark:border-white/[0.08]\">\n      <div className=\"flex min-h-9 items-center gap-2 px-3 py-1\">\n        <span className=\"min-w-0 flex-1 truncate text-zinc-500\">\n          {at}\n          {rest ? <span className=\"font-sans text-zinc-500\"> {rest.trim()}</span> : null}\n        </span>\n        {actions ? (\n          decided ? (\n            <span key={decision} className={cx(\"flex shrink-0 items-center gap-2 font-sans transition-[opacity,translate] duration-200 motion-reduce:transition-none\", ease, \"starting:translate-y-0.5 starting:opacity-0\")}>\n              <span className={cx(\"flex items-center gap-1.5 text-xs font-medium\", decision === \"accepted\" ? \"text-emerald-600 dark:text-emerald-400\" : \"text-zinc-500\")}>\n                <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-4\">\n                  <circle cx=\"8\" cy=\"8\" r=\"6.25\" />\n                  {decision === \"accepted\" ? <path d=\"m5.5 8.25 1.75 1.75 3.25-3.75\" /> : <path d=\"m6 6 4 4M10 6l-4 4\" />}\n                </svg>\n                <span>\n                  {decision === \"accepted\" ? \"Accepted\" : \"Rejected\"}\n                  <span className=\"font-normal text-zinc-500 tabular-nums max-[400px]:hidden\">\n                    , {changed} {changed === 1 ? \"line\" : \"lines\"}\n                  </span>\n                </span>\n              </span>\n              <HunkButton onClick={() => onDecide(null)}>Undo</HunkButton>\n            </span>\n          ) : (\n            <span className=\"flex shrink-0 items-center gap-1 font-sans\">\n              <HunkButton onClick={() => onDecide(\"rejected\")} aria-label={`Reject hunk ${segment.header}`}>\n                Reject\n              </HunkButton>\n              <HunkButton primary onClick={() => onDecide(\"accepted\")} aria-label={`Accept hunk ${segment.header}`}>\n                <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"-ml-0.5 size-3.5\">\n                  <path d=\"m3.75 8.5 2.75 2.75 5.75-6.5\" />\n                </svg>\n                Accept\n              </HunkButton>\n            </span>\n          )\n        ) : null}\n      </div>\n      {/* Deciding folds the hunk away; undo reopens it. */}\n      <div\n        aria-hidden={decided || undefined}\n        className={cx(\n          \"grid transition-[grid-template-rows,opacity,visibility] motion-reduce:transition-none\",\n          ease,\n          decided ? \"invisible grid-rows-[0fr] opacity-0 duration-260\" : \"visible grid-rows-[1fr] opacity-100 duration-220\",\n        )}\n      >\n        <div className=\"min-h-0 overflow-hidden\">\n          <Lines lines={segment.lines} view={view} wrap={wrap} width={digits(segment.lines)} />\n        </div>\n      </div>\n    </div>\n  );\n}\n\nfunction HunkButton({ primary = false, className, ...props }: ComponentProps<\"button\"> & { primary?: boolean }) {\n  return (\n    <button\n      type=\"button\"\n      className={cx(\n        \"inline-flex h-6 cursor-pointer items-center gap-1 rounded-md px-2 text-xs font-medium whitespace-nowrap select-none\",\n        \"transition-[background-color,border-color,color,scale] duration-150 ease-out active:duration-100 motion-safe:active:scale-[0.97] motion-reduce:transition-none\",\n        \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n        primary\n          ? \"border border-zinc-950/12 bg-white text-zinc-950 hover:border-zinc-950/20 hover:bg-zinc-950/[0.03] dark:border-white/15 dark:bg-black dark:text-white dark:hover:border-white/25 dark:hover:bg-white/[0.06]\"\n          : \"text-zinc-600 hover:bg-zinc-950/[0.04] hover:text-zinc-950 dark:text-zinc-400 dark:hover:bg-white/[0.06] dark:hover:text-white\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** True while the element is narrower than `px`. Starts false so server and first client render agree. */\nfunction useNarrow(ref: { current: HTMLElement | null }, px: number) {\n  const [narrow, setNarrow] = useState(false);\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(([entry]) => entry && setNarrow(entry.contentRect.width < px));\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [ref, px]);\n  return narrow;\n}\n\n// ---------------------------------------------------------------------------\n// Multi file list\n\nexport interface DiffFile {\n  /** Stable key. Defaults to the path. */\n  id?: string;\n  path?: string;\n  oldPath?: string;\n  oldText?: string;\n  newText?: string;\n  /** A unified diff for this file. */\n  patch?: string;\n}\n\nexport interface DiffViewerListProps extends Omit<ComponentProps<\"div\">, \"children\" | \"title\"> {\n  /** The changed files. Pass either this or `patch`. */\n  files?: DiffFile[];\n  /** A multi file unified diff, such as the output of `git diff`. */\n  patch?: string;\n  view?: DiffView;\n  defaultView?: DiffView;\n  onViewChange?: (view: DiffView) => void;\n  context?: number;\n  /** Called with the file path when a hunk is accepted, rejected, or undone. Shows hunk actions. */\n  onDecisionChange?: (path: string, hunk: number, decision: HunkDecision | null) => void;\n  hunkActions?: boolean;\n  /** Paths that start collapsed. */\n  defaultCollapsed?: string[];\n  /** Heading slot, for example a commit message. Defaults to the number of files changed. */\n  title?: ReactNode;\n}\n\n/** Several files' changes with a summary line and one shared Unified and Split switch. */\nexport function DiffViewerList({\n  files: filesProp,\n  patch,\n  view: viewProp,\n  defaultView = \"unified\",\n  onViewChange,\n  context,\n  onDecisionChange,\n  hunkActions,\n  defaultCollapsed = [],\n  title,\n  className,\n  ...props\n}: DiffViewerListProps) {\n  const files = useMemo<DiffFile[]>(() => {\n    if (filesProp) return filesProp;\n    if (!patch) return [];\n    // Re-split the patch per file so each viewer parses only its own part.\n    const chunks = patch.split(/^(?=diff --git )/m).filter((chunk) => chunk.trim());\n    return chunks.map((chunk) => ({ patch: chunk }));\n  }, [filesProp, patch]);\n\n  const totals = useMemo(() => {\n    let additions = 0;\n    let deletions = 0;\n    for (const file of files) {\n      const lines = file.patch != null ? parsePatch(file.patch).flatMap((item) => item.hunks.flatMap((hunk) => hunk.lines)) : diffLines(file.oldText ?? \"\", file.newText ?? \"\");\n      const counts = countLines(lines);\n      additions += counts.additions;\n      deletions += counts.deletions;\n    }\n    return { additions, deletions };\n  }, [files]);\n\n  const [localView, setLocalView] = useState<DiffView>(defaultView);\n  const view = viewProp ?? localView;\n  const ref = useRef<HTMLDivElement>(null);\n  const narrow = useNarrow(ref, 560);\n\n  return (\n    <div ref={ref} className={cx(\"flex w-full flex-col gap-3\", className)} {...props}>\n      <div className=\"flex min-h-8 items-center gap-3\">\n        <h3 className=\"min-w-0 flex-1 truncate text-sm font-medium text-zinc-950 dark:text-white\">\n          {title ?? `${files.length} ${files.length === 1 ? \"file\" : \"files\"} changed`}\n        </h3>\n        <DiffStat {...totals} />\n        {!narrow ? <ViewSwitch value={view} onChange={(next) => (viewProp === undefined ? setLocalView(next) : null, onViewChange?.(next))} /> : null}\n      </div>\n      {files.map((file, index) => {\n        const key = file.id ?? file.path ?? `file-${index}`;\n        const resolvedPath = file.path ?? (file.patch ? (parsePatch(file.patch)[0]?.newPath ?? parsePatch(file.patch)[0]?.oldPath) : undefined) ?? key;\n        return (\n          <DiffViewer\n            key={key}\n            {...file}\n            view={view}\n            viewToggle={false}\n            context={context}\n            hunkActions={hunkActions}\n            onDecisionChange={onDecisionChange ? (hunk, decision) => onDecisionChange(resolvedPath, hunk, decision) : undefined}\n            defaultCollapsed={defaultCollapsed.includes(resolvedPath)}\n          />\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { DiffViewer } from \"@/components/shaken/agent/diff-viewer\";\n\nconst before = `type InvoiceLine = { description: string; amount: number };\n\nconst round = (value: number) => Math.round(value * 100) / 100;\n\nexport interface ProrationInput {\n  lines: InvoiceLine[];\n  daysUsed: number;\n  daysInPeriod: number;\n}\n\n/**\n * Prorates each line for the days used in the period.\n */\nexport function prorate({ lines, daysUsed, daysInPeriod }: ProrationInput) {\n  const share = daysUsed / daysInPeriod;\n  const prorated = lines.map((line) => ({\n    ...line,\n    amount: round(line.amount * share),\n  }));\n  const total = prorated.reduce((sum, line) => sum + line.amount, 0);\n  return { lines: prorated, total };\n}\n\nexport function describe(total: number, currency: string) {\n  return new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency }).format(total);\n}\n`;\n\nconst after = `type InvoiceLine = { description: string; amount: number };\n\nconst round = (value: number) => Math.round(value * 100) / 100;\n\nexport interface ProrationInput {\n  lines: InvoiceLine[];\n  daysUsed: number;\n  daysInPeriod: number;\n}\n\n/**\n * Prorates each line for the days used in the period. Rounds once, after the sum,\n * so half cents on separate lines cannot both round down.\n */\nexport function prorate({ lines, daysUsed, daysInPeriod }: ProrationInput) {\n  const share = daysUsed / daysInPeriod;\n  const prorated = lines.map((line) => ({\n    ...line,\n    amount: line.amount * share,\n  }));\n  const total = round(prorated.reduce((sum, line) => sum + line.amount, 0));\n  return { lines: prorated.map((line) => ({ ...line, amount: round(line.amount) })), total };\n}\n\nexport function describe(total: number, currency: string) {\n  return new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency }).format(total);\n}\n`;\n\nexport default function DiffViewerExample() {\n  return <DiffViewer path=\"src/billing/proration.ts\" oldText={before} newText={after} context={2} hunkActions className=\"w-full max-w-3xl\" />;\n}\n"
  }
}
