@sdxc/ui 2026.11.11 → 2026.11.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +114 -61
  2. package/dist/app/app-shell-toggle.d.ts +2 -0
  3. package/dist/app/app-shell-toggle.js +5 -2
  4. package/dist/app/app-shell.d.ts +25 -1
  5. package/dist/app/app-shell.js +73 -38
  6. package/dist/app/auto-refresh.d.ts +2 -0
  7. package/dist/app/auto-refresh.js +3 -3
  8. package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
  9. package/dist/app/behaviors/refresh-schedule.js +4 -3
  10. package/dist/app/board.d.ts +123 -0
  11. package/dist/app/board.js +224 -0
  12. package/dist/app/chart.d.ts +2 -2
  13. package/dist/app/chart.js +7 -3
  14. package/dist/app/check-runs.d.ts +116 -0
  15. package/dist/app/check-runs.js +201 -0
  16. package/dist/app/code-view.d.ts +172 -0
  17. package/dist/app/code-view.js +414 -0
  18. package/dist/app/command-palette.d.ts +38 -3
  19. package/dist/app/command-palette.js +53 -5
  20. package/dist/app/contribution-graph.d.ts +106 -0
  21. package/dist/app/contribution-graph.js +289 -0
  22. package/dist/app/detail-sheet.d.ts +7 -0
  23. package/dist/app/detail-sheet.js +7 -7
  24. package/dist/app/diff.d.ts +200 -0
  25. package/dist/app/diff.js +702 -0
  26. package/dist/app/filter-bar.d.ts +20 -0
  27. package/dist/app/filter-bar.js +35 -15
  28. package/dist/app/filter-menu.d.ts +144 -0
  29. package/dist/app/filter-menu.js +480 -0
  30. package/dist/app/gantt.d.ts +108 -0
  31. package/dist/app/gantt.js +420 -0
  32. package/dist/app/index.d.ts +20 -0
  33. package/dist/app/index.js +20 -0
  34. package/dist/app/log-viewer.d.ts +120 -0
  35. package/dist/app/log-viewer.js +384 -0
  36. package/dist/app/merge-box.d.ts +97 -0
  37. package/dist/app/merge-box.js +227 -0
  38. package/dist/app/mixins/app-shell-controls.d.ts +4 -1
  39. package/dist/app/mixins/app-shell-controls.js +64 -4
  40. package/dist/app/mixins/auto-refresh.d.ts +5 -2
  41. package/dist/app/mixins/auto-refresh.js +9 -3
  42. package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
  43. package/dist/app/mixins/close-popover-on-submit.js +32 -0
  44. package/dist/app/mixins/code-view-selection.d.ts +60 -0
  45. package/dist/app/mixins/code-view-selection.js +276 -0
  46. package/dist/app/mixins/command-palette.d.ts +15 -4
  47. package/dist/app/mixins/command-palette.js +94 -6
  48. package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
  49. package/dist/app/mixins/contribution-graph-keys.js +155 -0
  50. package/dist/app/mixins/diff-interactions.d.ts +72 -0
  51. package/dist/app/mixins/diff-interactions.js +269 -0
  52. package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
  53. package/dist/app/mixins/filter-menu-keys.js +91 -0
  54. package/dist/app/mixins/gantt-today.d.ts +17 -0
  55. package/dist/app/mixins/gantt-today.js +50 -0
  56. package/dist/app/mixins/log-viewer.d.ts +29 -0
  57. package/dist/app/mixins/log-viewer.js +347 -0
  58. package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
  59. package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
  60. package/dist/app/mixins/save-bar-sync.d.ts +7 -1
  61. package/dist/app/mixins/save-bar-sync.js +23 -4
  62. package/dist/app/mixins/save-status-sync.js +23 -1
  63. package/dist/app/mixins/split-view.js +1 -1
  64. package/dist/app/mixins/submit-on-close.d.ts +17 -0
  65. package/dist/app/mixins/submit-on-close.js +52 -0
  66. package/dist/app/mixins/tree-filter.d.ts +44 -0
  67. package/dist/app/mixins/tree-filter.js +111 -0
  68. package/dist/app/mixins/tree-navigation.d.ts +50 -0
  69. package/dist/app/mixins/tree-navigation.js +216 -0
  70. package/dist/app/optimistic-toggle.d.ts +8 -0
  71. package/dist/app/optimistic-toggle.js +3 -2
  72. package/dist/app/page-header.d.ts +18 -3
  73. package/dist/app/page-header.js +105 -50
  74. package/dist/app/profile-picker.d.ts +47 -0
  75. package/dist/app/profile-picker.js +104 -0
  76. package/dist/app/review-thread.d.ts +115 -0
  77. package/dist/app/review-thread.js +116 -0
  78. package/dist/app/save-bar.d.ts +5 -0
  79. package/dist/app/save-bar.js +1 -1
  80. package/dist/app/save-status.js +1 -1
  81. package/dist/app/settings-layout.d.ts +5 -0
  82. package/dist/app/settings-layout.js +5 -5
  83. package/dist/app/skeleton.d.ts +9 -0
  84. package/dist/app/skeleton.js +28 -0
  85. package/dist/app/split-view.d.ts +4 -0
  86. package/dist/app/split-view.js +3 -3
  87. package/dist/app/styles/code-tokens.d.ts +24 -0
  88. package/dist/app/styles/code-tokens.js +47 -0
  89. package/dist/app/tab-bar.d.ts +59 -0
  90. package/dist/app/tab-bar.js +111 -0
  91. package/dist/app/tree.d.ts +111 -14
  92. package/dist/app/tree.js +202 -15
  93. package/dist/app/utils/ansi.d.ts +55 -0
  94. package/dist/app/utils/ansi.js +157 -0
  95. package/dist/app/utils/diff-rows.d.ts +82 -0
  96. package/dist/app/utils/diff-rows.js +209 -0
  97. package/dist/app/utils/fuzzy-path.d.ts +58 -0
  98. package/dist/app/utils/fuzzy-path.js +202 -0
  99. package/dist/app/utils/line-range.d.ts +48 -0
  100. package/dist/app/utils/line-range.js +61 -0
  101. package/dist/app/utils/log-lines.d.ts +107 -0
  102. package/dist/app/utils/log-lines.js +170 -0
  103. package/dist/app/utils/tree-filter.d.ts +19 -0
  104. package/dist/app/utils/tree-filter.js +26 -0
  105. package/dist/app/view-options.d.ts +2 -0
  106. package/dist/app/view-options.js +2 -2
  107. package/dist/chat/activity.d.ts +72 -0
  108. package/dist/chat/activity.js +184 -0
  109. package/dist/chat/composer-submit.d.ts +38 -0
  110. package/dist/chat/composer-submit.js +44 -0
  111. package/dist/chat/composer.d.ts +47 -0
  112. package/dist/chat/composer.js +100 -0
  113. package/dist/chat/index.d.ts +6 -0
  114. package/dist/chat/index.js +6 -0
  115. package/dist/chat/mixins/composer-send.d.ts +32 -0
  116. package/dist/chat/mixins/composer-send.js +121 -0
  117. package/dist/chat/mixins/reveal-stream.d.ts +68 -0
  118. package/dist/chat/mixins/reveal-stream.js +184 -0
  119. package/dist/chat/mixins/stream-target.d.ts +18 -0
  120. package/dist/chat/mixins/stream-target.js +38 -0
  121. package/dist/components/button.js +7 -1
  122. package/dist/components/character-count.d.ts +44 -0
  123. package/dist/components/character-count.js +68 -0
  124. package/dist/components/index.d.ts +2 -0
  125. package/dist/components/index.js +2 -0
  126. package/dist/components/label-chip.d.ts +42 -0
  127. package/dist/components/label-chip.js +86 -0
  128. package/dist/components/property-list.d.ts +9 -2
  129. package/dist/components/property-list.js +37 -10
  130. package/dist/components/textarea.js +6 -1
  131. package/dist/components/timeline.d.ts +62 -5
  132. package/dist/components/timeline.js +124 -5
  133. package/dist/docs/code-block.js +8 -31
  134. package/dist/docs/file-tree.js +3 -48
  135. package/dist/landing/case-study.d.ts +79 -0
  136. package/dist/landing/case-study.js +162 -0
  137. package/dist/landing/contributor-wall.d.ts +72 -0
  138. package/dist/landing/contributor-wall.js +129 -0
  139. package/dist/landing/countdown.d.ts +88 -0
  140. package/dist/landing/countdown.js +91 -0
  141. package/dist/landing/episode-player.d.ts +87 -0
  142. package/dist/landing/episode-player.js +113 -0
  143. package/dist/landing/faq-band.d.ts +3 -2
  144. package/dist/landing/faq-band.js +4 -3
  145. package/dist/landing/index.d.ts +7 -0
  146. package/dist/landing/index.js +7 -0
  147. package/dist/landing/landing-header.js +15 -4
  148. package/dist/landing/mixins/countdown-tick.d.ts +29 -0
  149. package/dist/landing/mixins/countdown-tick.js +65 -0
  150. package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
  151. package/dist/landing/mixins/usage-estimate-live.js +120 -0
  152. package/dist/landing/phone-frame.d.ts +2 -1
  153. package/dist/landing/price-list.d.ts +68 -0
  154. package/dist/landing/price-list.js +125 -0
  155. package/dist/landing/scroll-scene.d.ts +59 -0
  156. package/dist/landing/scroll-scene.js +70 -0
  157. package/dist/landing/sponsor-wall.d.ts +30 -6
  158. package/dist/landing/sponsor-wall.js +70 -14
  159. package/dist/landing/typed-terminal.d.ts +24 -6
  160. package/dist/landing/typed-terminal.js +22 -14
  161. package/dist/landing/usage-estimate.d.ts +127 -0
  162. package/dist/landing/usage-estimate.js +164 -0
  163. package/dist/landing/utils/countdown.d.ts +33 -0
  164. package/dist/landing/utils/countdown.js +42 -0
  165. package/dist/landing/utils/pause-toggle.d.ts +2 -1
  166. package/dist/mixins/character-count.d.ts +62 -0
  167. package/dist/mixins/character-count.js +139 -0
  168. package/dist/mixins/index.d.ts +6 -2
  169. package/dist/mixins/index.js +6 -2
  170. package/dist/mixins/invoker-fields.d.ts +18 -0
  171. package/dist/mixins/invoker-fields.js +60 -0
  172. package/dist/mixins/media-sync.d.ts +58 -0
  173. package/dist/mixins/media-sync.js +102 -0
  174. package/dist/mixins/menu-keys.d.ts +11 -0
  175. package/dist/mixins/menu-keys.js +79 -70
  176. package/dist/mixins/sortable.d.ts +96 -0
  177. package/dist/mixins/sortable.js +433 -0
  178. package/dist/utils/code-lines.d.ts +26 -0
  179. package/dist/utils/code-lines.js +29 -0
  180. package/dist/utils/file-icon.d.ts +31 -0
  181. package/dist/utils/file-icon.js +60 -0
  182. package/dist/utils/index.d.ts +2 -0
  183. package/dist/utils/index.js +2 -0
  184. package/dist/utils/write-cookie.d.ts +15 -15
  185. package/dist/utils/write-cookie.js +10 -16
  186. package/dist/video/episode-list.d.ts +48 -0
  187. package/dist/video/episode-list.js +161 -0
  188. package/dist/video/index.d.ts +15 -0
  189. package/dist/video/index.js +15 -0
  190. package/dist/video/mixins/video-player-sync.d.ts +27 -0
  191. package/dist/video/mixins/video-player-sync.js +413 -0
  192. package/dist/video/mixins/video-shelf-steps.d.ts +20 -0
  193. package/dist/video/mixins/video-shelf-steps.js +79 -0
  194. package/dist/video/title-hero.d.ts +51 -0
  195. package/dist/video/title-hero.js +170 -0
  196. package/dist/video/utils/timeline.d.ts +55 -0
  197. package/dist/video/utils/timeline.js +90 -0
  198. package/dist/video/video-card.d.ts +51 -0
  199. package/dist/video/video-card.js +135 -0
  200. package/dist/video/video-player.d.ts +261 -0
  201. package/dist/video/video-player.js +927 -0
  202. package/dist/video/video-shelf.d.ts +58 -0
  203. package/dist/video/video-shelf.js +155 -0
  204. package/package.json +6 -3
@@ -0,0 +1,702 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { ChevronDownIcon, CopyIcon, UnfoldVerticalIcon } from "@sdxc/icons";
3
+ import { visuallyHidden } from "@sdxc/u/a11y";
4
+ import { bg, borderEdge, fg, outline } from "@sdxc/u/color";
5
+ import { rounded } from "@sdxc/u/effects";
6
+ import { cursor, mergeMix, raw } from "@sdxc/u/general";
7
+ import { center, flexWrap, hstack, shrink, vstack } from "@sdxc/u/layout";
8
+ import { motionSafe } from "@sdxc/u/responsive";
9
+ import { bs, is, minIs, p, pb, pi } from "@sdxc/u/size";
10
+ import { focusVisible, hover, when } from "@sdxc/u/state";
11
+ import { font, tabularNums, text, weight } from "@sdxc/u/typography";
12
+ import { clientEntry } from "remix/component";
13
+ import { panelChrome } from "../styles/panel-chrome.js";
14
+ import { segmentedItem, segmentedTrack } from "../styles/segmented-control.js";
15
+ import { diffInteractions } from "./mixins/diff-interactions.js";
16
+ import { CODE_TOKEN_PALETTE, codeTokenRules } from "./styles/code-tokens.js";
17
+ import { changeBlocks, hunkHeader, hunkTokens, markRuns, pathHash, splitRows, } from "./utils/diff-rows.js";
18
+ export { DIFF_COMMENT_EVENT } from "./mixins/diff-interactions.js";
19
+ export { changeBlocks, hunkHeader, splitRows } from "./utils/diff-rows.js";
20
+ /**
21
+ * Lines per `<tbody>` chunk. Each chunk is skipped by `content-visibility` until it nears the
22
+ * screen, so a long diff lays out only what is read, while find-in-page and line anchors still
23
+ * reach every line because every line is in the document.
24
+ */
25
+ const DEFAULT_CHUNK_SIZE = 200;
26
+ /** Changed lines past which a file renders collapsed, behind the app's "Load diff". */
27
+ const DEFAULT_LARGE_THRESHOLD = 400;
28
+ /** Height of one unwrapped line, which a skipped chunk reserves per line. */
29
+ const LINE_HEIGHT = "var(--diff-line-height, 1.25rem)";
30
+ /** Container width below which unified lines wrap instead of scrolling sideways. */
31
+ const WRAP_WIDTH = "40rem";
32
+ /** Container width below which the split view lays its rows out as unified ones. */
33
+ const SPLIT_WIDTH = "48rem";
34
+ /** Selector for a cell of a line row, which leaves out the full-width hunk and thread cells. */
35
+ const LINE_CELL = "td:not([colspan])";
36
+ /** The letter each file status draws, the shape that tells statuses apart beside their tone. */
37
+ const STATUS_LETTERS = {
38
+ added: "A",
39
+ modified: "M",
40
+ deleted: "D",
41
+ renamed: "R",
42
+ copied: "C",
43
+ };
44
+ /** The semantic tone each file status paints its letter in. */
45
+ const STATUS_TONES = {
46
+ added: "success",
47
+ modified: "warning",
48
+ deleted: "danger",
49
+ renamed: "brand",
50
+ copied: "brand",
51
+ };
52
+ /**
53
+ * Without script each `+` links to `commentHref`; mapping `@sdxc/ui/app/diff` runs one
54
+ * {@link DiffInteractions} for every file, turning `+`, drags and copy into `DIFF_COMMENT_EVENT`.
55
+ * Set `--diff-font-size`, `--diff-line-height` and the `--diff-add-*`/`--diff-del-*` tints.
56
+ *
57
+ * @param handle Runtime handle carrying the root's props.
58
+ * @returns The render function producing the root.
59
+ * @example
60
+ * <Diff labels={{ copied: t("copied") }}>
61
+ * <Diff.Toolbar view={view} unifiedHref="?diff=unified" splitHref="?diff=split" viewed={2} total={files.length} labels={toolbarLabels} />
62
+ * {files.map((file) => <Diff.File path={file.newPath} oldPath={file.oldPath} status={file.status} additions={file.additions} deletions={file.deletions} hunks={parseHunks(text, file)} language="ts" view={view} labels={fileLabels} />)}
63
+ * </Diff>
64
+ */
65
+ export function Diff(handle) {
66
+ return () => {
67
+ let { children, labels, mix, ...rest } = handle.props;
68
+ return (_jsxs("div", { ...rest, "data-slot": "diff", mix: mergeMix([vstack({ gap: 4 }), minIs(0)], mix), children: [children, _jsx(DiffInteractions, { labels: labels })] }));
69
+ };
70
+ }
71
+ /**
72
+ * Client island every {@link Diff} renders once: a status region the `diffInteractions()`
73
+ * mixin speaks through, which listens on the whole root for line gestures and copy buttons.
74
+ * Loads from `@sdxc/ui/app/diff#DiffInteractions` once the app's browser entry maps it.
75
+ */
76
+ export const DiffInteractions = clientEntry("@sdxc/ui/app/diff#DiffInteractions", function DiffInteractions(handle) {
77
+ return () => (_jsx("span", { role: "status", "data-slot": "diff-status", mix: [visuallyHidden(), diffInteractions({ copied: handle.props.labels.copied })] }));
78
+ });
79
+ /**
80
+ * Renders the bar above the files: the unified/split switch as two GET links carried in the
81
+ * address, the app's own controls, then "n / N files viewed" with a bar that fills as the
82
+ * review burns down.
83
+ *
84
+ * @param handle Runtime handle carrying the toolbar's props.
85
+ * @returns The render function producing the toolbar.
86
+ * @example <Diff.Toolbar view="split" unifiedHref="?diff=unified" splitHref="?diff=split" target="main" viewed={3} total={12} labels={{ view: "Diff view", unified: "Unified", split: "Split", filesViewed: "files viewed" }} />
87
+ */
88
+ Diff.Toolbar = function DiffToolbar(handle) {
89
+ return () => {
90
+ let { children, labels, mix, splitHref, target, total, unifiedHref, view, viewed, ...rest } = handle.props;
91
+ let views = [
92
+ ["unified", unifiedHref, labels.unified],
93
+ ["split", splitHref, labels.split],
94
+ ];
95
+ return (_jsxs("div", { ...rest, "data-slot": "diff-toolbar", mix: mergeMix([hstack({ gap: 3, align: "center", justify: "between" }), flexWrap("wrap"), text("sm")], mix), children: [_jsx("nav", { "aria-label": labels.view, mix: [segmentedTrack(), hstack({ align: "center" })], children: views.map(([name, href, label]) => (_jsx("a", { href: href, "data-rmx-target": target, "aria-current": name === view ? "page" : undefined, mix: [
96
+ hstack({ align: "center" }),
97
+ bs(7),
98
+ pi(2.5),
99
+ segmentedItem({ selected: '&[aria-current="page"]' }),
100
+ raw({ textDecoration: "none" }),
101
+ ], children: label }))) }), children, total === undefined ? null : (_jsxs("span", { "data-slot": "diff-progress", mix: [hstack({ gap: 2, align: "center" }), fg("neutral.muted"), tabularNums()], children: [_jsx("span", { children: `${viewed ?? 0} / ${total} ${labels.filesViewed}` }), _jsx("progress", { value: viewed ?? 0, max: Math.max(total, 1), "aria-label": labels.filesViewed, mix: [
102
+ is(16),
103
+ bs(1.5),
104
+ raw({
105
+ appearance: "none",
106
+ border: "none",
107
+ borderRadius: "999px",
108
+ overflow: "hidden",
109
+ backgroundColor: "var(--ui-neutral-bg-tint, var(--ui-neutral-border))",
110
+ "&::-webkit-progress-bar": { backgroundColor: "transparent" },
111
+ "&::-webkit-progress-value": { backgroundColor: "var(--ui-success-fg)" },
112
+ "&::-moz-progress-bar": { backgroundColor: "var(--ui-success-fg)" },
113
+ }),
114
+ ] })] }))] }));
115
+ };
116
+ };
117
+ /**
118
+ * Renders one file's card: a `<details>` whose summary carries the chevron, status, path,
119
+ * counts and five-block bar, with copy, `⋯` and "Viewed" beside it, then the lines or the note
120
+ * standing in for them. A collapsed, viewed or large file renders closed, like a checklist.
121
+ *
122
+ * @param handle Runtime handle carrying the card's props.
123
+ * @returns The render function producing the card.
124
+ * @example
125
+ * <Diff.File path="app/routes.ts" status="modified" additions={12} deletions={3} hunks={hunks} language="ts" view="split"
126
+ * viewed={viewedPaths.has("app/routes.ts")} viewedControl={<OptimisticToggle … />} threads={{ R14: <ReviewThread … /> }}
127
+ * commentHref={(path, side, line) => `?comment=${path}:${side}${line}`} labels={labels} />
128
+ * @example <Diff.File path="dist/app.js" status="modified" additions={9000} deletions={8800} load={<LazyFrame src={`/diff/${sha}/dist/app.js`} />} labels={labels} />
129
+ */
130
+ Diff.File = function DiffFile(handle) {
131
+ return () => {
132
+ let { additions, binary, chunkSize, collapsed, commentHref, deletions, expandHref, hunks, id, labels, language, largeThreshold = DEFAULT_LARGE_THRESHOLD, lineHref, load, menu, mix, oldPath, path, status, threads, tooLarge, view, viewed, viewedControl, ...rest } = handle.props;
133
+ let fileId = id ?? `diff-${pathHash(path)}`;
134
+ let large = load !== undefined && additions + deletions > largeThreshold;
135
+ let open = !(collapsed || viewed || large);
136
+ let moved = oldPath !== undefined && oldPath !== path;
137
+ return (_jsxs("section", { ...rest, id: fileId, "data-slot": "diff-file", "data-path": path, "data-status": status, "data-viewed": viewed ? "" : undefined, "data-large": large ? "" : undefined, mix: mergeMix([
138
+ panelChrome(),
139
+ minIs(0),
140
+ raw({
141
+ display: "grid",
142
+ gridTemplateColumns: "minmax(0, 1fr) auto",
143
+ gridTemplateRows: "auto auto",
144
+ overflow: "clip",
145
+ backgroundColor: "var(--diff-bg)",
146
+ "--diff-bg": "var(--ui-surface-raised, var(--ui-bg, Canvas))",
147
+ }),
148
+ ], mix), children: [_jsxs("div", { "data-slot": "diff-file-actions", mix: [
149
+ hstack({ gap: 1, align: "center" }),
150
+ pi(2),
151
+ bg("neutral.bg-tint"),
152
+ text("xs"),
153
+ raw({
154
+ gridColumn: 2,
155
+ gridRow: 1,
156
+ alignSelf: "stretch",
157
+ position: "relative",
158
+ zIndex: 1,
159
+ }),
160
+ ], children: [_jsx("button", { type: "button", "data-action": "copy-path", "data-path": path, "aria-label": labels.copyPath, title: labels.copyPath, mix: [
161
+ center(),
162
+ is(7),
163
+ bs(7),
164
+ rounded("sm"),
165
+ fg("neutral.muted"),
166
+ raw({
167
+ display: "none",
168
+ border: "none",
169
+ background: "none",
170
+ padding: 0,
171
+ cursor: "pointer",
172
+ }),
173
+ when("[data-diff-live] &", raw({ display: "inline-flex" })),
174
+ hover(bg("neutral.bg-tint-hover")),
175
+ when("&[data-copied]", fg("success")),
176
+ focusVisible(outline({ color: "brand.ring", offset: 2 })),
177
+ ], children: _jsx(CopyIcon, { size: 14, "aria-hidden": "true" }) }), menu, viewedControl] }), _jsxs("details", { open: open, "data-slot": "diff-file-details", mix: [
178
+ raw({
179
+ gridColumn: "1 / -1",
180
+ gridRow: "1 / -1",
181
+ display: "grid",
182
+ gridTemplateColumns: "subgrid",
183
+ gridTemplateRows: "subgrid",
184
+ minInlineSize: 0,
185
+ "&::details-content": { gridColumn: "1 / -1", gridRow: 2, minInlineSize: 0 },
186
+ }),
187
+ ], children: [_jsxs("summary", { "data-slot": "diff-file-header", mix: [
188
+ hstack({ gap: 2, align: "center" }),
189
+ flexWrap("wrap"),
190
+ minIs(0),
191
+ pi(3),
192
+ pb(2),
193
+ bg("neutral.bg-tint"),
194
+ cursor("pointer"),
195
+ text("sm"),
196
+ raw({
197
+ gridColumn: 1,
198
+ gridRow: 1,
199
+ minBlockSize: "2.75rem",
200
+ listStyle: "none",
201
+ "&::-webkit-details-marker": { display: "none" },
202
+ }),
203
+ focusVisible(outline({ color: "brand.ring", offset: -2 })),
204
+ ], children: [_jsx(ChevronDownIcon, { size: 16, "aria-hidden": "true", mix: [
205
+ shrink(0),
206
+ fg("neutral.muted"),
207
+ raw({ rotate: "-90deg" }),
208
+ motionSafe(raw({ transition: "rotate 150ms ease" })),
209
+ when(":is(details[open] > summary) > &", raw({ rotate: "0deg" })),
210
+ ] }), _jsx("span", { "data-slot": "diff-file-status", "aria-hidden": "true", mix: [
211
+ center(),
212
+ shrink(0),
213
+ is(4),
214
+ bs(4),
215
+ rounded("sm"),
216
+ raw({ border: "1px solid currentColor", fontSize: "0.625rem", lineHeight: 1 }),
217
+ fg(STATUS_TONES[status]),
218
+ weight(600),
219
+ ], children: STATUS_LETTERS[status] }), _jsx("span", { mix: [visuallyHidden()], children: labels.statuses[status] }), _jsx("span", { "data-slot": "diff-file-path", mix: [
220
+ minIs(0),
221
+ font("mono"),
222
+ text("xs"),
223
+ weight(600),
224
+ fg("neutral.emphasis"),
225
+ raw({ overflowWrap: "anywhere" }),
226
+ ], children: moved ? `${oldPath} → ${path}` : path }), _jsxs("span", { "data-slot": "diff-file-counts", mix: [hstack({ gap: 1.5, align: "center" }), text("xs"), tabularNums()], children: [_jsx("span", { mix: [visuallyHidden()], children: labels.changes(additions, deletions) }), _jsx("span", { "aria-hidden": "true", mix: [fg("success")], children: `+${additions}` }), _jsx("span", { "aria-hidden": "true", mix: [fg("danger")], children: `−${deletions}` }), _jsx("span", { "data-slot": "diff-file-bar", "aria-hidden": "true", mix: [
227
+ hstack({ gap: 0.5 }),
228
+ raw({
229
+ "& > span": {
230
+ inlineSize: "0.5rem",
231
+ blockSize: "0.5rem",
232
+ borderRadius: "1px",
233
+ backgroundColor: "var(--ui-neutral-border)",
234
+ },
235
+ "& > [data-block='add']": { backgroundColor: "var(--ui-success-fg)" },
236
+ "& > [data-block='del']": { backgroundColor: "var(--ui-danger-fg)" },
237
+ }),
238
+ ], children: changeBlocks(additions, deletions).map((block) => (_jsx("span", { "data-block": block }))) })] })] }), _jsx("div", { "data-slot": "diff-file-body", mix: [borderEdge("block-start", { color: "neutral.border", width: 1, style: "solid" })], children: fileBody({
239
+ additions,
240
+ binary,
241
+ chunkSize,
242
+ commentHref,
243
+ deletions,
244
+ expandHref,
245
+ fileId,
246
+ hunks,
247
+ labels,
248
+ language,
249
+ large,
250
+ lineHref,
251
+ load,
252
+ path,
253
+ threads,
254
+ tooLarge,
255
+ view,
256
+ }) })] })] }));
257
+ };
258
+ };
259
+ /**
260
+ * The card's body, by cause: a binary file and a dropped patch say why there are no lines, a
261
+ * large file shows the app's `load` slot, a change without lines says so, and anything else
262
+ * draws its hunks.
263
+ */
264
+ function fileBody(input) {
265
+ let { binary, hunks, labels, large, load, tooLarge } = input;
266
+ let note = (message, slot) => (_jsxs("div", { "data-slot": "diff-file-note", mix: [
267
+ vstack({ gap: 2, align: "center" }),
268
+ p(4),
269
+ text("sm"),
270
+ fg("neutral.muted"),
271
+ raw({ textAlign: "center" }),
272
+ ], children: [_jsx("p", { mix: [raw({ margin: 0 })], children: message }), slot] }));
273
+ if (binary)
274
+ return note(labels.binary);
275
+ if (tooLarge)
276
+ return note(labels.tooLarge);
277
+ if (large)
278
+ return note(labels.largeDiff, load);
279
+ if (!hunks || hunks.length === 0)
280
+ return labels.empty ? note(labels.empty) : null;
281
+ return (_jsx(Diff.Hunks, { path: input.path, hunks: hunks, language: input.language, view: input.view, fileId: input.fileId, threads: input.threads, lineHref: input.lineHref, commentHref: input.commentHref, expandHref: input.expandHref, chunkSize: input.chunkSize, labels: labels }));
282
+ }
283
+ /**
284
+ * Renders hunks as one table without a card, for {@link Diff.File} and for a thread's excerpt
285
+ * or suggestion. Split draws old and new side by side and, once its container is narrower
286
+ * than 48rem, lays the same markup out as unified: two number columns, then the code.
287
+ *
288
+ * @param handle Runtime handle carrying the hunks' props.
289
+ * @returns The render function producing the table.
290
+ * @example <Diff.Hunks path="app/routes.ts" hunks={excerpt} language="ts" labels={{ columns }} />
291
+ */
292
+ Diff.Hunks = function DiffHunks(handle) {
293
+ return () => {
294
+ let { anchored = true, chunkSize = DEFAULT_CHUNK_SIZE, commentHref, expandHref, fileId, hunks, labels, language, lineHref, mix, path, threads, view = "unified", ...rest } = handle.props;
295
+ let anchor = fileId ?? `diff-${pathHash(path)}`;
296
+ let scope = {
297
+ anchor,
298
+ anchored,
299
+ path,
300
+ view,
301
+ columns: view === "split" ? 4 : 3,
302
+ lineHref: lineHref ?? ((side, line) => `#${anchor}${side}${line}`),
303
+ commentHref,
304
+ threads,
305
+ expandHref,
306
+ labels,
307
+ stop: { open: true },
308
+ };
309
+ let widest = 1;
310
+ for (let hunk of hunks) {
311
+ widest = Math.max(widest, hunk.oldStart + hunk.oldLines, hunk.newStart + hunk.newLines);
312
+ }
313
+ let digits = Math.max(2, String(widest).length);
314
+ let entries = hunks.flatMap((hunk, index) => hunkEntries(hunk, index, language, scope));
315
+ let quote = view === "unified" &&
316
+ threads === undefined &&
317
+ hunks.every((hunk) => hunk.lines.every((line) => line.kind === "context" && line.old === line.new));
318
+ return (_jsx("div", { ...rest, "data-slot": "diff-hunks", "data-view": view, mix: mergeMix([
319
+ minIs(0),
320
+ raw({
321
+ container: "diff / inline-size",
322
+ "--diff-bg": "var(--ui-surface-raised, var(--ui-bg, Canvas))",
323
+ backgroundColor: "var(--diff-bg)",
324
+ }),
325
+ ], mix), children: _jsx("div", { "data-slot": "diff-scroll", dir: "ltr", mix: [raw({ overflowX: "auto", overscrollBehaviorInline: "contain" })], children: _jsxs("table", { "aria-label": path, mix: [tableRules(view, digits, quote)], children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: labels.columns.oldNumber }), view === "split" ? _jsx("th", { scope: "col", children: labels.columns.oldText }) : null, _jsx("th", { scope: "col", children: labels.columns.newNumber }), _jsx("th", { scope: "col", children: labels.columns.change })] }) }), chunks(entries, chunkSize).map((chunk) => (_jsx("tbody", { mix: [
326
+ raw({
327
+ containIntrinsicBlockSize: `auto calc(${chunk.lines} * ${LINE_HEIGHT})`,
328
+ }),
329
+ ], children: chunk.rows })))] }) }) }));
330
+ };
331
+ };
332
+ /**
333
+ * Groups rows into chunks of about `size` lines; a chunk ends only after a whole row, so a
334
+ * thread stays with its line.
335
+ */
336
+ function chunks(entries, size) {
337
+ let result = [];
338
+ let current = { rows: [], lines: 0 };
339
+ for (let entry of entries) {
340
+ current.rows.push(entry.row);
341
+ current.lines += entry.lines;
342
+ if (current.lines >= size) {
343
+ result.push(current);
344
+ current = { rows: [], lines: 0 };
345
+ }
346
+ }
347
+ if (current.rows.length > 0)
348
+ result.push(current);
349
+ return result;
350
+ }
351
+ /**
352
+ * One hunk's rows: its header (with the expand link), then its lines as the view draws them,
353
+ * each followed by the threads keyed to it. Rows are plain local render values built in one
354
+ * loop, since a diff can hold tens of thousands of them, with no component instance per row.
355
+ */
356
+ function hunkEntries(hunk, index, language, scope) {
357
+ let runs = hunkTokens(hunk, language);
358
+ let entries = [
359
+ {
360
+ lines: 1,
361
+ row: (_jsx("tr", { "data-hunk": "", children: _jsxs("td", { colSpan: scope.columns, children: [scope.expandHref ? (_jsx("a", { href: scope.expandHref(hunk, index), "data-slot": "diff-expand", "aria-label": scope.labels.expandContext, title: scope.labels.expandContext, children: _jsx(UnfoldVerticalIcon, { size: 14, "aria-hidden": "true" }) })) : null, hunkHeader(hunk)] }) })),
362
+ },
363
+ ];
364
+ let thread = (side, line) => {
365
+ let node = line === undefined ? undefined : scope.threads?.[`${side}${line}`];
366
+ if (node === undefined)
367
+ return;
368
+ entries.push({
369
+ lines: 2,
370
+ row: (_jsx("tr", { "data-thread": "", children: _jsx("td", { colSpan: scope.columns, children: node }) })),
371
+ });
372
+ };
373
+ if (scope.view === "split") {
374
+ for (let pair of splitRows(hunk.lines)) {
375
+ entries.push({ lines: 1, row: splitRow(hunk, pair, runs, scope) });
376
+ let oldLine = pair.old === undefined ? undefined : hunk.lines[pair.old];
377
+ let newLine = pair.new === undefined ? undefined : hunk.lines[pair.new];
378
+ if (oldLine?.kind === "del")
379
+ thread("L", oldLine.old);
380
+ thread("R", newLine?.new);
381
+ }
382
+ return entries;
383
+ }
384
+ for (let [position, line] of hunk.lines.entries()) {
385
+ let side = line.kind === "del" ? "L" : "R";
386
+ let number = side === "L" ? line.old : line.new;
387
+ entries.push({
388
+ lines: 1,
389
+ row: (_jsxs("tr", { "data-kind": line.kind === "context" ? undefined : line.kind, children: [numberCell(scope, "L", line.old), numberCell(scope, "R", line.new), codeCell(scope, side, number, runs[position] ?? [], line.words)] })),
390
+ });
391
+ if (line.kind !== "add")
392
+ thread("L", line.old);
393
+ thread("R", line.new);
394
+ }
395
+ return entries;
396
+ }
397
+ /**
398
+ * One split row: the old side's number and code, then the new side's. A side with no line in
399
+ * the pair draws two filler cells, which the narrow layout hides.
400
+ */
401
+ function splitRow(hunk, pair, runs, scope) {
402
+ let oldLine = pair.old === undefined ? undefined : hunk.lines[pair.old];
403
+ let newLine = pair.new === undefined ? undefined : hunk.lines[pair.new];
404
+ let filler = [_jsx("td", { "data-filler": "" }), _jsx("td", { "data-filler": "" })];
405
+ return (_jsxs("tr", { "data-old": oldLine?.kind === "del" ? "del" : undefined, "data-new": newLine?.kind === "add" ? "add" : undefined, children: [oldLine
406
+ ? [
407
+ numberCell(scope, "L", oldLine.old),
408
+ codeCell(scope, "L", oldLine.old, runs[pair.old] ?? [], oldLine.words),
409
+ ]
410
+ : filler, newLine
411
+ ? [
412
+ numberCell(scope, "R", newLine.new),
413
+ codeCell(scope, "R", newLine.new, runs[pair.new] ?? [], newLine.words),
414
+ ]
415
+ : filler] }));
416
+ }
417
+ /**
418
+ * A line number's `tabindex`: the first one a table draws is its one Tab stop, and the arrow
419
+ * keys move it from there. Comment links stay in the Tab order until script takes them out,
420
+ * so a keyboard reaches every line's comment form without script.
421
+ */
422
+ function tabStop(scope) {
423
+ if (!scope.stop.open)
424
+ return -1;
425
+ scope.stop.open = false;
426
+ return 0;
427
+ }
428
+ /** A number cell: an empty link painted from `data-line-number`, so a copy takes only code. */
429
+ function numberCell(scope, side, line) {
430
+ if (line === undefined)
431
+ return _jsx("td", {});
432
+ if (!scope.anchored) {
433
+ return (_jsx("td", { children: _jsx("span", { "data-line-number": line }) }));
434
+ }
435
+ return (_jsx("td", { children: _jsx("a", { id: `${scope.anchor}${side}${line}`, href: scope.lineHref(side, line), "data-line-number": line, tabIndex: tabStop(scope) }) }));
436
+ }
437
+ /**
438
+ * A code cell: the `+` link that starts a comment on the line (when the table takes
439
+ * comments), then its runs with changed words in `<mark>`s. The sign is painted by the
440
+ * table's rules from the row's kind.
441
+ */
442
+ function codeCell(scope, side, line, runs, words) {
443
+ let comment = scope.commentHref && line !== undefined ? (_jsx("a", { href: scope.commentHref(scope.path, side, line), "data-comment": `${side}${line}`, "aria-label": scope.labels.addComment?.(side, line) })) : null;
444
+ return (_jsxs("td", { children: [comment, codeNodes(runs, words)] }));
445
+ }
446
+ /**
447
+ * A line's runs as nodes: plain text stays a text node, a highlighted run is one
448
+ * `span.token.<type>`, and a changed span wraps its runs in one `<mark>`.
449
+ */
450
+ function codeNodes(runs, words) {
451
+ let nodes = [];
452
+ let marked;
453
+ for (let piece of markRuns(normalize(runs), words)) {
454
+ let node = piece.type === "plain" ? (piece.value) : (_jsx("span", { className: `token ${piece.type}`, children: piece.value }));
455
+ if (piece.marked) {
456
+ if (marked === undefined) {
457
+ marked = [];
458
+ nodes.push(_jsx("mark", { children: marked }));
459
+ }
460
+ marked.push(node);
461
+ }
462
+ else {
463
+ marked = undefined;
464
+ nodes.push(node);
465
+ }
466
+ }
467
+ return nodes;
468
+ }
469
+ /** Turns runs of a type the palette does not paint into plain runs, so they merge as text. */
470
+ function normalize(runs) {
471
+ return runs.map((run) => CODE_TOKEN_PALETTE[run.type] ? run : { type: "plain", value: run.value });
472
+ }
473
+ /**
474
+ * Every rule the table and its rows follow, set once on the table so no row carries a class of
475
+ * its own. Chunks lay their rows out on one grid of fixed tracks, so columns line up across
476
+ * chunks while each chunk can be skipped on its own; row kinds color cells and paint signs.
477
+ *
478
+ * @param view Which layout the rows follow.
479
+ * @param digits Digits the widest line number needs.
480
+ * @param quote Whether every line is unchanged at the same number, which draws one number column.
481
+ */
482
+ function tableRules(view, digits, quote = false) {
483
+ let numberWidth = `calc(${digits}ch + 1.25rem)`;
484
+ let numbers = quote ? numberWidth : `${numberWidth} ${numberWidth}`;
485
+ let mixWith = (tone, amount, fallback) => `var(${fallback}, color-mix(in oklab, var(--ui-${tone}-fg) ${amount}%, var(--diff-bg)))`;
486
+ let add = mixWith("success", 12, "--diff-add-bg");
487
+ let addNumber = mixWith("success", 22, "--diff-add-number-bg");
488
+ let addWord = mixWith("success", 34, "--diff-add-word-bg");
489
+ let del = mixWith("danger", 10, "--diff-del-bg");
490
+ let delNumber = mixWith("danger", 20, "--diff-del-number-bg");
491
+ let delWord = mixWith("danger", 30, "--diff-del-word-bg");
492
+ let band = mixWith("brand", 16, "--diff-selected-bg");
493
+ let shared = {
494
+ margin: 0,
495
+ borderCollapse: "collapse",
496
+ fontFamily: "var(--ui-font-mono, ui-monospace, monospace)",
497
+ fontVariantLigatures: "none",
498
+ fontSize: "var(--diff-font-size, 0.75rem)",
499
+ lineHeight: LINE_HEIGHT,
500
+ color: "var(--ui-neutral-fg-emphasis)",
501
+ tabSize: 4,
502
+ "& > thead": {
503
+ position: "absolute",
504
+ inlineSize: "1px",
505
+ blockSize: "1px",
506
+ overflow: "hidden",
507
+ clipPath: "inset(50%)",
508
+ whiteSpace: "nowrap",
509
+ },
510
+ "& > tbody > tr": { display: "contents" },
511
+ "& > tbody > tr > td": { padding: 0, verticalAlign: "top" },
512
+ [`& > tbody > tr > ${LINE_CELL}`]: { backgroundColor: "var(--diff-bg)" },
513
+ "& > tbody > tr > td[colspan]": {
514
+ gridColumn: "1 / -1",
515
+ position: "sticky",
516
+ insetInlineStart: 0,
517
+ maxInlineSize: "100cqi",
518
+ boxSizing: "border-box",
519
+ },
520
+ "& > tbody > tr[data-hunk] > td": {
521
+ display: "flex",
522
+ alignItems: "center",
523
+ gap: "0.5rem",
524
+ paddingInline: "0.75rem",
525
+ paddingBlock: "0.25rem",
526
+ backgroundColor: mixWith("brand", 8, "--diff-hunk-bg"),
527
+ color: "var(--ui-neutral-fg-muted)",
528
+ whiteSpace: "pre",
529
+ overflow: "hidden",
530
+ textOverflow: "ellipsis",
531
+ },
532
+ "& > tbody > tr > td > [data-slot='diff-expand']": {
533
+ display: "inline-flex",
534
+ color: "inherit",
535
+ borderRadius: "var(--ui-radius-sm, 0.25rem)",
536
+ },
537
+ "& > tbody > tr > td > [data-slot='diff-expand']:hover": { color: "var(--ui-brand-fg)" },
538
+ "& > tbody > tr[data-thread] > td": {
539
+ paddingBlock: "0.5rem",
540
+ paddingInline: "0.75rem",
541
+ whiteSpace: "normal",
542
+ fontFamily: "var(--ui-font-sans, system-ui, sans-serif)",
543
+ fontSize: "0.875rem",
544
+ lineHeight: 1.5,
545
+ backgroundColor: "var(--diff-bg)",
546
+ borderBlock: "1px solid var(--ui-neutral-border)",
547
+ },
548
+ "& > tbody > tr > td > [data-line-number]": {
549
+ display: "block",
550
+ paddingInline: "0.5rem",
551
+ textAlign: "end",
552
+ color: "var(--ui-neutral-fg-muted)",
553
+ textDecoration: "none",
554
+ cursor: "pointer",
555
+ outline: "none",
556
+ userSelect: "none",
557
+ },
558
+ "& > tbody > tr > td > [data-line-number]::before": { content: "attr(data-line-number)" },
559
+ "& > tbody > tr > td > a[data-line-number]:hover": { color: "var(--ui-neutral-fg-emphasis)" },
560
+ "& > tbody > tr > td > a[data-line-number]:focus-visible": {
561
+ boxShadow: "inset 0 0 0 2px var(--ui-brand-ring, var(--ui-brand-fg))",
562
+ borderRadius: "var(--ui-radius-sm, 0.25rem)",
563
+ },
564
+ "& > tbody > tr > td > a[data-comment]": {
565
+ position: "absolute",
566
+ insetInlineStart: "0.125rem",
567
+ insetBlockStart: `calc((${LINE_HEIGHT} - 1.125rem) / 2)`,
568
+ display: "grid",
569
+ placeItems: "center",
570
+ inlineSize: "1.125rem",
571
+ blockSize: "1.125rem",
572
+ borderRadius: "var(--ui-radius-sm, 0.25rem)",
573
+ backgroundColor: "var(--ui-brand-bg-solid, var(--ui-brand-fg))",
574
+ color: "var(--ui-brand-fg-on-solid, white)",
575
+ fontFamily: "var(--ui-font-sans, system-ui, sans-serif)",
576
+ fontWeight: 600,
577
+ fontSize: "0.875rem",
578
+ lineHeight: 1,
579
+ textDecoration: "none",
580
+ opacity: 0,
581
+ cursor: "pointer",
582
+ userSelect: "none",
583
+ zIndex: 1,
584
+ },
585
+ "& > tbody > tr > td > a[data-comment]::before": { content: '"+"' },
586
+ "& > tbody > tr:hover > td > a[data-comment], & > tbody > tr:focus-within > td > a[data-comment], & > tbody > tr > td > a[data-comment]:focus-visible": { opacity: 1 },
587
+ "& > tbody > tr > td > a[data-comment]:focus-visible": {
588
+ outline: "2px solid var(--ui-brand-ring, var(--ui-brand-fg))",
589
+ outlineOffset: "1px",
590
+ },
591
+ "& > tbody > tr > td > mark": { color: "inherit", borderRadius: "2px" },
592
+ ...codeTokenRules(),
593
+ };
594
+ let selection = {
595
+ [`& > tbody > tr[data-selected] > ${LINE_CELL}, & > tbody > tr:has(> td > a:target) > ${LINE_CELL}`]: {
596
+ backgroundColor: band,
597
+ },
598
+ };
599
+ if (view === "split") {
600
+ return raw(Object.assign({}, shared, {
601
+ display: "block",
602
+ inlineSize: "100%",
603
+ "& > tbody": {
604
+ display: "grid",
605
+ contentVisibility: "auto",
606
+ gridTemplateColumns: `${numberWidth} minmax(0, 1fr) ${numberWidth} minmax(0, 1fr)`,
607
+ },
608
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(2n)`]: codeCellRules("pre-wrap"),
609
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(3)`]: {
610
+ borderInlineStart: "1px solid var(--ui-neutral-border)",
611
+ },
612
+ "& > tbody > tr > td[data-filler]": {
613
+ backgroundColor: "var(--diff-filler-bg, var(--ui-neutral-bg-tint, var(--diff-bg)))",
614
+ },
615
+ [`& > tbody > tr[data-old] > ${LINE_CELL}:nth-child(-n+2)`]: { backgroundColor: del },
616
+ [`& > tbody > tr[data-old] > ${LINE_CELL}:nth-child(1)`]: { backgroundColor: delNumber },
617
+ "& > tbody > tr[data-old] > td:nth-child(2)::before": { content: '"-"' },
618
+ "& > tbody > tr[data-old] > td:nth-child(2) mark": { backgroundColor: delWord },
619
+ [`& > tbody > tr[data-new] > ${LINE_CELL}:nth-child(n+3)`]: { backgroundColor: add },
620
+ [`& > tbody > tr[data-new] > ${LINE_CELL}:nth-child(3)`]: { backgroundColor: addNumber },
621
+ "& > tbody > tr[data-new] > td:nth-child(4)::before": { content: '"+"' },
622
+ "& > tbody > tr[data-new] > td:nth-child(4) mark": { backgroundColor: addWord },
623
+ [`@container diff (max-width: ${SPLIT_WIDTH})`]: {
624
+ "& > tbody": { gridTemplateColumns: `${numberWidth} ${numberWidth} minmax(0, 1fr)` },
625
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(1)`]: { gridColumn: 1 },
626
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(2)`]: { gridColumn: 3 },
627
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(3)`]: {
628
+ gridColumn: 2,
629
+ borderInlineStart: "none",
630
+ },
631
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(4)`]: { gridColumn: 3 },
632
+ "& > tbody > tr > td[data-filler]": { display: "none" },
633
+ "& > tbody > tr[data-old] > td:nth-child(1)": { gridColumn: "1 / span 2" },
634
+ "& > tbody > tr[data-old] > td:nth-child(1) > [data-line-number]": {
635
+ inlineSize: "50%",
636
+ },
637
+ "& > tbody > tr[data-new] > td:nth-child(3)": { gridColumn: "1 / span 2" },
638
+ "& > tbody > tr[data-new] > td:nth-child(3) > [data-line-number]": {
639
+ marginInlineStart: "50%",
640
+ },
641
+ "& > tbody > tr:not([data-old], [data-new], [data-hunk], [data-thread]) > td:nth-child(2)": {
642
+ display: "none",
643
+ },
644
+ },
645
+ }, selection));
646
+ }
647
+ return raw(Object.assign({}, shared, {
648
+ display: "block",
649
+ inlineSize: "max-content",
650
+ minInlineSize: "100%",
651
+ "& > tbody": {
652
+ display: "grid",
653
+ contentVisibility: "auto",
654
+ gridTemplateColumns: `${numbers} 1fr`,
655
+ },
656
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(-n+2)`]: { position: "sticky", zIndex: 1 },
657
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(1)`]: quote
658
+ ? { display: "none" }
659
+ : { insetInlineStart: 0 },
660
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(2)`]: {
661
+ insetInlineStart: quote ? 0 : numberWidth,
662
+ },
663
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(3)`]: codeCellRules("pre"),
664
+ [`& > tbody > tr[data-kind="add"] > ${LINE_CELL}`]: { backgroundColor: add },
665
+ [`& > tbody > tr[data-kind="add"] > ${LINE_CELL}:nth-child(-n+2)`]: {
666
+ backgroundColor: addNumber,
667
+ },
668
+ '& > tbody > tr[data-kind="add"] > td:nth-child(3)::before': { content: '"+"' },
669
+ '& > tbody > tr[data-kind="add"] mark': { backgroundColor: addWord },
670
+ [`& > tbody > tr[data-kind="del"] > ${LINE_CELL}`]: { backgroundColor: del },
671
+ [`& > tbody > tr[data-kind="del"] > ${LINE_CELL}:nth-child(-n+2)`]: {
672
+ backgroundColor: delNumber,
673
+ },
674
+ '& > tbody > tr[data-kind="del"] > td:nth-child(3)::before': { content: '"-"' },
675
+ '& > tbody > tr[data-kind="del"] mark': { backgroundColor: delWord },
676
+ [`@container diff (max-width: ${WRAP_WIDTH})`]: {
677
+ "&": { inlineSize: "100%" },
678
+ "& > tbody": { gridTemplateColumns: `${numbers} minmax(0, 1fr)` },
679
+ [`& > tbody > tr > ${LINE_CELL}:nth-child(3)`]: {
680
+ whiteSpace: "pre-wrap",
681
+ overflowWrap: "anywhere",
682
+ minInlineSize: 0,
683
+ },
684
+ },
685
+ }, selection));
686
+ }
687
+ /** A code cell: room on its start side for the sign and the `+`, and how its text wraps. */
688
+ function codeCellRules(whiteSpace) {
689
+ return {
690
+ position: "relative",
691
+ minInlineSize: 0,
692
+ paddingInline: "1.5rem 1rem",
693
+ whiteSpace,
694
+ overflowWrap: whiteSpace === "pre" ? "normal" : "anywhere",
695
+ "&::before": {
696
+ position: "absolute",
697
+ insetInlineStart: "0.5rem",
698
+ color: "var(--ui-neutral-fg-muted)",
699
+ userSelect: "none",
700
+ },
701
+ };
702
+ }