@git-diff-view/react 0.1.3 → 0.1.5

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 (59) hide show
  1. package/dist/cjs/index.development.js +497 -503
  2. package/dist/cjs/index.development.js.map +1 -1
  3. package/dist/cjs/index.production.js +497 -503
  4. package/dist/cjs/index.production.js.map +1 -1
  5. package/dist/css/diff-view-pure.css +111 -0
  6. package/dist/css/diff-view.css +111 -0
  7. package/dist/esm/index.mjs +499 -506
  8. package/dist/esm/index.mjs.map +1 -1
  9. package/index.d.ts +239 -7
  10. package/package.json +2 -2
  11. package/src/_com.css +99 -0
  12. package/src/components/DiffAddWidget.tsx +4 -3
  13. package/src/components/DiffContent.tsx +6 -6
  14. package/src/components/DiffExpand.tsx +0 -2
  15. package/src/components/DiffNoNewLine.tsx +0 -2
  16. package/src/components/DiffSplitContentLineNormal.tsx +3 -4
  17. package/src/components/DiffSplitContentLineWrap.tsx +9 -10
  18. package/src/components/DiffSplitExtendLineNormal.tsx +3 -3
  19. package/src/components/DiffSplitExtendLineWrap.tsx +4 -4
  20. package/src/components/DiffSplitHunkLineNormal.tsx +0 -1
  21. package/src/components/DiffSplitHunkLineWrap.tsx +0 -1
  22. package/src/components/DiffSplitView.tsx +0 -1
  23. package/src/components/DiffSplitViewNormal.tsx +13 -12
  24. package/src/components/DiffSplitViewWrap.tsx +10 -10
  25. package/src/components/DiffSplitWidgetLineNormal.tsx +2 -2
  26. package/src/components/DiffSplitWidgetLineWrap.tsx +12 -2
  27. package/src/components/DiffUnifiedContentLine.tsx +1 -2
  28. package/src/components/DiffUnifiedExtendLine.tsx +4 -5
  29. package/src/components/DiffUnifiedHunkLine.tsx +0 -1
  30. package/src/components/DiffUnifiedView.tsx +9 -9
  31. package/src/components/DiffUnifiedWidgetLine.tsx +2 -2
  32. package/src/components/DiffView.tsx +26 -20
  33. package/src/components/DiffViewContext.ts +2 -0
  34. package/src/components/DiffViewWithMultiSelect.tsx +321 -0
  35. package/src/components/DiffWidgetContext.ts +4 -2
  36. package/src/components/tools.ts +6 -5
  37. package/src/components/v2/DiffSplitContentLineNormal_v2.tsx +4 -5
  38. package/src/components/v2/DiffSplitContentLineWrap_v2.tsx +11 -12
  39. package/src/components/v2/DiffSplitExtendLineNormal_v2.tsx +3 -3
  40. package/src/components/v2/DiffSplitExtendLineWrap_v2.tsx +4 -4
  41. package/src/components/v2/DiffSplitHunkLineNormal_v2.tsx +0 -1
  42. package/src/components/v2/DiffSplitHunkLineWrap_v2.tsx +0 -1
  43. package/src/components/v2/DiffSplitViewLineNormal_v2.tsx +0 -1
  44. package/src/components/v2/DiffSplitViewLineWrap_v2.tsx +0 -1
  45. package/src/components/v2/DiffSplitViewNormal_v2.tsx +9 -8
  46. package/src/components/v2/DiffSplitViewWrap_v2.tsx +5 -5
  47. package/src/components/v2/DiffSplitView_v2.tsx +0 -1
  48. package/src/components/v2/DiffSplitWidgetLineNormal_v2.tsx +2 -3
  49. package/src/components/v2/DiffSplitWidgetLineWrap_v2.tsx +4 -5
  50. package/src/hooks/useCallbackRef.ts +13 -0
  51. package/src/hooks/useDomWidth.ts +5 -5
  52. package/src/hooks/useIsMounted.ts +1 -0
  53. package/src/hooks/useSyncHeight.ts +3 -3
  54. package/src/hooks/useTextWidth.ts +1 -1
  55. package/src/hooks/useUnmount.ts +1 -0
  56. package/src/hooks/useUpdateEffect.ts +15 -0
  57. package/src/index.ts +1 -2
  58. package/styles/diff-view-pure.css +111 -0
  59. package/styles/diff-view.css +111 -0
@@ -1,9 +1,10 @@
1
1
  'use client';
2
- import { SplitSide, DiffLineType, getSyntaxDiffTemplate, getSyntaxLineTemplate, getPlainDiffTemplate, getPlainLineTemplate, checkDiffLineIncludeChange, composeLen, getSplitContentLines, getUnifiedContentLine, _cacheMap, DiffFile, highlighter } from '@git-diff-view/core';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { SplitSide, DiffLineType, getSyntaxDiffTemplate, getSyntaxLineTemplate, getPlainDiffTemplate, getPlainLineTemplate, checkDiffLineIncludeChange, composeLen, getSplitContentLines, getUnifiedContentLine, _cacheMap, DiffFile, highlighter, multiSelectClassNames, createDiffMultiSelectManager } from '@git-diff-view/core';
3
4
  export * from '@git-diff-view/core';
4
5
  export { SplitSide } from '@git-diff-view/core';
5
6
  import * as React from 'react';
6
- import { useState, useEffect, useRef, useLayoutEffect, createContext, useContext, memo, Fragment, useMemo, useCallback, forwardRef, useImperativeHandle } from 'react';
7
+ import { useState, useEffect, useRef, useLayoutEffect, createContext, useContext, memo, Fragment as Fragment$1, useMemo, useCallback, forwardRef, useImperativeHandle } from 'react';
7
8
  import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
8
9
  import { createStore, ref } from 'reactivity-store';
9
10
 
@@ -24,40 +25,6 @@ PERFORMANCE OF THIS SOFTWARE.
24
25
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
25
26
 
26
27
 
27
- function __rest(s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- }
38
-
39
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
40
- var e = new Error(message);
41
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
42
- };
43
-
44
- /******************************************************************************
45
- Copyright (c) Microsoft Corporation.
46
-
47
- Permission to use, copy, modify, and/or distribute this software for any
48
- purpose with or without fee is hereby granted.
49
-
50
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
51
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
52
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
53
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
54
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
55
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
56
- PERFORMANCE OF THIS SOFTWARE.
57
- ***************************************************************************** */
58
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
59
-
60
-
61
28
  function __classPrivateFieldGet(receiver, state, kind, f) {
62
29
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
63
30
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -89,7 +56,7 @@ class TextMeasure {
89
56
  _TextMeasure_map.set(this, {});
90
57
  }
91
58
  measure(text, font) {
92
- const currentKey = getStableKey(font, text);
59
+ const currentKey = getStableKey(font || {}, text);
93
60
  if (__classPrivateFieldGet(this, _TextMeasure_map, "f")[currentKey]) {
94
61
  return __classPrivateFieldGet(this, _TextMeasure_map, "f")[currentKey];
95
62
  }
@@ -205,7 +172,7 @@ const getDiffIdFromElement = (element) => {
205
172
  while (el) {
206
173
  if (el.getAttribute && el.getAttribute("data-component") === "git-diff-view") {
207
174
  const ele = el.querySelector(".diff-view-wrapper");
208
- return ele.getAttribute("id");
175
+ return ele === null || ele === void 0 ? void 0 : ele.getAttribute("id");
209
176
  }
210
177
  el = el.parentElement;
211
178
  }
@@ -251,6 +218,7 @@ var DiffModeEnum;
251
218
  const useIsMounted = () => {
252
219
  const [isMounted, setIsMounted] = useState(false);
253
220
  useEffect(() => {
221
+ // eslint-disable-next-line react-hooks/set-state-in-effect
254
222
  setIsMounted(true);
255
223
  }, []);
256
224
  return isMounted;
@@ -258,6 +226,7 @@ const useIsMounted = () => {
258
226
 
259
227
  const useUnmount = (cb, deps) => {
260
228
  const ref = useRef(cb);
229
+ // eslint-disable-next-line react-hooks/refs
261
230
  ref.current = cb;
262
231
  // eslint-disable-next-line react-hooks/exhaustive-deps
263
232
  useEffect(() => ref.current, deps);
@@ -268,7 +237,7 @@ const useSafeLayout = isClient ? useLayoutEffect : useEffect;
268
237
 
269
238
  const useTextWidth = ({ text, font, }) => {
270
239
  const [width, setWidth] = useState(() => {
271
- const fontSize = parseInt(font.fontSize);
240
+ const fontSize = parseInt(font.fontSize || "13");
272
241
  let baseSize = 6;
273
242
  baseSize += fontSize > 10 ? (fontSize - 10) * 0.6 : 0;
274
243
  return baseSize * text.length;
@@ -281,42 +250,39 @@ const useTextWidth = ({ text, font, }) => {
281
250
  };
282
251
 
283
252
  const DiffSplitAddWidget = ({ side, className, lineNumber, onWidgetClick, onOpenAddWidget, }) => {
284
- return (React.createElement("div", { "data-add-widget": SplitSide[side], className: "diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
253
+ return (jsx("div", { "data-add-widget": SplitSide[side], className: "diff-add-widget-wrapper invisible select-none transition-transform hover:scale-110 group-hover:visible" +
285
254
  (className ? " " + className : ""), style: {
286
255
  width: `calc(var(${diffFontSizeName}) * 1.4)`,
287
256
  height: `calc(var(${diffFontSizeName}) * 1.4)`,
288
257
  top: `calc(var(${diffFontSizeName}) * 0.1)`,
289
- } },
290
- React.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
258
+ }, children: jsx("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
291
259
  color: `var(${addWidgetColorName})`,
292
260
  backgroundColor: `var(${addWidgetBGName})`,
293
- }, onClick: () => {
261
+ }, onMouseDown: (e) => {
262
+ e.stopPropagation();
294
263
  onOpenAddWidget(lineNumber, side);
295
264
  onWidgetClick === null || onWidgetClick === void 0 ? void 0 : onWidgetClick(lineNumber, side);
296
- } }, "+")));
265
+ }, children: "+" }) }));
297
266
  };
298
267
  const DiffUnifiedAddWidget = ({ lineNumber, side, onWidgetClick, onOpenAddWidget, }) => {
299
- return (React.createElement("div", { "data-add-widget": SplitSide[side], className: "diff-add-widget-wrapper invisible absolute left-[100%] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible", style: {
268
+ return (jsx("div", { "data-add-widget": SplitSide[side], className: "diff-add-widget-wrapper invisible absolute left-[100%] translate-x-[-50%] select-none transition-transform hover:scale-110 group-hover:visible", style: {
300
269
  width: `calc(var(${diffFontSizeName}) * 1.4)`,
301
270
  height: `calc(var(${diffFontSizeName}) * 1.4)`,
302
271
  top: `calc(var(${diffFontSizeName}) * 0.1)`,
303
- } },
304
- React.createElement("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
272
+ }, children: jsx("button", { className: "diff-add-widget z-[1] flex h-full w-full origin-center cursor-pointer items-center justify-center rounded-md text-[1.2em]", style: {
305
273
  color: `var(${addWidgetColorName})`,
306
274
  backgroundColor: `var(${addWidgetBGName})`,
307
- }, onClick: () => {
275
+ }, onMouseDown: (e) => {
276
+ e.stopPropagation();
308
277
  onOpenAddWidget(lineNumber, side);
309
278
  onWidgetClick === null || onWidgetClick === void 0 ? void 0 : onWidgetClick(lineNumber, side);
310
- } }, "+")));
279
+ }, children: "+" }) }));
311
280
  };
312
281
 
313
282
  const DiffNoNewLine = () => {
314
- return (React.createElement("svg", { "aria-label": "No newline at end of file", role: "img", viewBox: "0 0 16 16", version: "1.1", fill: "currentColor" },
315
- React.createElement("path", { d: "M4.25 7.25a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z" }),
316
- React.createElement("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z" })));
283
+ return (jsxs("svg", { "aria-label": "No newline at end of file", role: "img", viewBox: "0 0 16 16", version: "1.1", fill: "currentColor", children: [jsx("path", { d: "M4.25 7.25a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z" }), jsx("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z" })] }));
317
284
  };
318
285
 
319
- /* eslint-disable max-lines */
320
286
  const temp = {};
321
287
  const formatStringToCamelCase = (str) => {
322
288
  if (str.startsWith("--"))
@@ -348,73 +314,65 @@ const DiffString = ({ rawLine, diffLine, operator, plainLine, enableWrap, }) =>
348
314
  if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
349
315
  const isNewLineSymbolChanged = changes.newLineSymbol;
350
316
  if (!(diffLine === null || diffLine === void 0 ? void 0 : diffLine.plainTemplate) && typeof getPlainDiffTemplate === "function") {
351
- getPlainDiffTemplate({ diffLine, rawLine, operator });
317
+ getPlainDiffTemplate({ diffLine: diffLine, rawLine, operator: operator });
352
318
  }
353
319
  if (diffLine === null || diffLine === void 0 ? void 0 : diffLine.plainTemplate) {
354
- return (React.createElement("span", { className: "diff-line-content-raw" },
355
- React.createElement("span", { "data-template": true, dangerouslySetInnerHTML: { __html: diffLine.plainTemplate } }),
356
- isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (React.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block !text-red-500" : "inline-block align-middle !text-red-500", style: {
357
- width: `var(${diffFontSizeName})`,
358
- height: `var(${diffFontSizeName})`,
359
- } },
360
- React.createElement(DiffNoNewLine, null)))));
320
+ return (jsxs("span", { className: "diff-line-content-raw", children: [jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: diffLine.plainTemplate } }), isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (jsx("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block !text-red-500" : "inline-block align-middle !text-red-500", style: {
321
+ width: `var(${diffFontSizeName})`,
322
+ height: `var(${diffFontSizeName})`,
323
+ }, children: jsx(DiffNoNewLine, {}) }))] }));
361
324
  }
362
325
  }
363
326
  if (plainLine && !(plainLine === null || plainLine === void 0 ? void 0 : plainLine.template)) {
327
+ // eslint-disable-next-line react-hooks/immutability
364
328
  plainLine.template = getPlainLineTemplate(plainLine.value);
365
329
  }
366
330
  if (plainLine === null || plainLine === void 0 ? void 0 : plainLine.template) {
367
- return (React.createElement("span", { className: "diff-line-content-raw" },
368
- React.createElement("span", { "data-template": true, dangerouslySetInnerHTML: { __html: plainLine.template } })));
331
+ return (jsx("span", { className: "diff-line-content-raw", children: jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: plainLine.template } }) }));
369
332
  }
370
- return React.createElement("span", { className: "diff-line-content-raw" }, rawLine);
333
+ return jsx("span", { className: "diff-line-content-raw", children: rawLine });
371
334
  };
372
335
  const DiffSyntax = ({ rawLine, diffFile, diffLine, operator, syntaxLine, enableWrap, }) => {
373
336
  var _a;
374
337
  if (!syntaxLine) {
375
- return React.createElement(DiffString, { rawLine: rawLine, diffLine: diffLine, operator: operator, enableWrap: enableWrap });
338
+ return jsx(DiffString, { rawLine: rawLine, diffLine: diffLine, operator: operator, enableWrap: enableWrap });
376
339
  }
377
340
  const changes = diffLine === null || diffLine === void 0 ? void 0 : diffLine.changes;
378
341
  if (changes === null || changes === void 0 ? void 0 : changes.hasLineChange) {
379
342
  const isNewLineSymbolChanged = changes.newLineSymbol;
380
343
  if (!(diffLine === null || diffLine === void 0 ? void 0 : diffLine.syntaxTemplate) && typeof getSyntaxDiffTemplate === "function") {
381
- getSyntaxDiffTemplate({ diffFile, diffLine, syntaxLine, operator });
344
+ getSyntaxDiffTemplate({ diffFile, diffLine: diffLine, syntaxLine, operator: operator });
382
345
  }
383
346
  if (diffLine === null || diffLine === void 0 ? void 0 : diffLine.syntaxTemplate) {
384
- return (React.createElement("span", { className: "diff-line-syntax-raw" },
385
- React.createElement("span", { "data-template": true, dangerouslySetInnerHTML: { __html: diffLine.syntaxTemplate } }),
386
- isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (React.createElement("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block !text-red-500" : "inline-block align-middle !text-red-500", style: {
387
- width: `var(${diffFontSizeName})`,
388
- height: `var(${diffFontSizeName})`,
389
- } },
390
- React.createElement(DiffNoNewLine, null)))));
347
+ return (jsxs("span", { className: "diff-line-syntax-raw", children: [jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: diffLine.syntaxTemplate } }), isNewLineSymbolChanged === NewLineSymbol.NEWLINE && (jsx("span", { "data-no-newline-at-end-of-file-symbol": true, className: enableWrap ? "block !text-red-500" : "inline-block align-middle !text-red-500", style: {
348
+ width: `var(${diffFontSizeName})`,
349
+ height: `var(${diffFontSizeName})`,
350
+ }, children: jsx(DiffNoNewLine, {}) }))] }));
391
351
  }
392
352
  }
393
353
  if (!syntaxLine.template) {
354
+ // eslint-disable-next-line react-hooks/immutability
394
355
  syntaxLine.template = getSyntaxLineTemplate(syntaxLine);
395
356
  }
396
357
  if (syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.template) {
397
- return (React.createElement("span", { className: "diff-line-syntax-raw" },
398
- React.createElement("span", { "data-template": true, dangerouslySetInnerHTML: { __html: syntaxLine.template } })));
358
+ return (jsx("span", { className: "diff-line-syntax-raw", children: jsx("span", { "data-template": true, dangerouslySetInnerHTML: { __html: syntaxLine.template } }) }));
399
359
  }
400
- return (React.createElement("span", { className: "diff-line-syntax-raw" }, (_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.map(({ node, wrapper }, index) => {
401
- var _a, _b, _c;
402
- return (React.createElement("span", { key: index, "data-start": node.startIndex, "data-end": node.endIndex, className: (_b = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.join(" "), style: getStyleObjectFromString(((_c = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _c === void 0 ? void 0 : _c.style) || "") }, node.value));
403
- })));
360
+ return (jsx("span", { className: "diff-line-syntax-raw", children: (_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.map(({ node, wrapper }, index) => {
361
+ var _a, _b, _c;
362
+ return (jsx("span", { "data-start": node.startIndex, "data-end": node.endIndex, className: (_b = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.join(" "), style: getStyleObjectFromString(((_c = wrapper === null || wrapper === void 0 ? void 0 : wrapper.properties) === null || _c === void 0 ? void 0 : _c.style) || ""), children: node.value }, index));
363
+ }) }));
404
364
  };
405
365
  const DiffContent = ({ diffFile, diffLine, rawLine, plainLine, syntaxLine, enableWrap, enableHighlight, }) => {
406
366
  var _a;
407
367
  const isAdded = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === DiffLineType.Add;
408
368
  const isDelete = (diffLine === null || diffLine === void 0 ? void 0 : diffLine.type) === DiffLineType.Delete;
409
- const isMaxLineLengthToIgnoreSyntax = ((_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.length) > 150;
410
- return (React.createElement("div", { className: "diff-line-content-item pl-[2.0em]",
369
+ const isMaxLineLengthToIgnoreSyntax = syntaxLine && ((_a = syntaxLine === null || syntaxLine === void 0 ? void 0 : syntaxLine.nodeList) === null || _a === void 0 ? void 0 : _a.length) > 150;
370
+ return (jsxs("div", { className: "diff-line-content-item pl-[2.0em]",
411
371
  // data-val={rawLine}
412
372
  style: {
413
373
  whiteSpace: enableWrap ? "pre-wrap" : "pre",
414
374
  wordBreak: enableWrap ? "break-all" : "initial",
415
- } },
416
- React.createElement("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]" }, isAdded ? "+" : isDelete ? "-" : " "),
417
- enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (React.createElement(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffFile: diffFile, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (React.createElement(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, enableWrap: enableWrap }))));
375
+ }, children: [jsx("span", { "data-operator": isAdded ? "+" : isDelete ? "-" : undefined, className: "diff-line-content-operator ml-[-1.5em] inline-block w-[1.5em] select-none indent-[0.2em]", children: isAdded ? "+" : isDelete ? "-" : " " }), enableHighlight && syntaxLine && !isMaxLineLengthToIgnoreSyntax ? (jsx(DiffSyntax, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffFile: diffFile, diffLine: diffLine, syntaxLine: syntaxLine, enableWrap: enableWrap })) : (jsx(DiffString, { operator: isAdded ? "add" : isDelete ? "del" : undefined, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, enableWrap: enableWrap }))] }));
418
376
  };
419
377
 
420
378
  const DiffViewContext = createContext(null);
@@ -426,7 +384,7 @@ DiffWidgetContext.displayName = "DiffWidgetContext";
426
384
  const useDiffWidgetContext = () => useContext(DiffWidgetContext);
427
385
 
428
386
  const InternalDiffSplitLine$1 = ({ index, diffFile, lineNumber, side, enableAddWidget, enableHighlight, }) => {
429
- var _a, _b;
387
+ var _a, _b, _c, _d, _e;
430
388
  const getCurrentSyntaxLine = side === SplitSide.old ? diffFile.getOldSyntaxLine : diffFile.getNewSyntaxLine;
431
389
  const getCurrentPlainLine = side === SplitSide.old ? diffFile.getOldPlainLine : diffFile.getNewPlainLine;
432
390
  const oldLine = diffFile.getSplitLeftLine(index);
@@ -443,28 +401,22 @@ const InternalDiffSplitLine$1 = ({ index, diffFile, lineNumber, side, enableAddW
443
401
  const setWidget = useWidget.getReadonlyState().setWidget;
444
402
  const contentBG = getContentBG(isAdded, isDelete, hasDiff);
445
403
  const lineNumberBG = getLineNumberBG(isAdded, isDelete, hasDiff);
446
- const syntaxLine = getCurrentSyntaxLine(currentLine.lineNumber);
447
- const plainLine = getCurrentPlainLine(currentLine.lineNumber);
448
- return (React.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff || !hasContent ? "diff" : "plain", "data-side": SplitSide[side], className: "diff-line" + (hasContent ? " group" : "") }, hasContent ? (React.createElement(React.Fragment, null,
449
- React.createElement("td", { className: `diff-line-${SplitSide[side]}-num sticky left-0 z-[1] w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`, style: {
450
- backgroundColor: lineNumberBG,
451
- color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
452
- width: `var(${diffAsideWidthName})`,
453
- minWidth: `var(${diffAsideWidthName})`,
454
- maxWidth: `var(${diffAsideWidthName})`,
455
- } },
456
- hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
457
- React.createElement("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, currentLine.lineNumber)),
458
- React.createElement("td", { className: `diff-line-${SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG } },
459
- React.createElement(DiffContent, { enableWrap: false, diffFile: diffFile, rawLine: (currentLine === null || currentLine === void 0 ? void 0 : currentLine.value) || "", diffLine: currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight })))) : (React.createElement("td", { className: `diff-line-${SplitSide[side]}-placeholder select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
460
- React.createElement("span", null, "\u2002")))));
404
+ const syntaxLine = getCurrentSyntaxLine((_c = currentLine.lineNumber) !== null && _c !== void 0 ? _c : -1);
405
+ const plainLine = getCurrentPlainLine((_d = currentLine.lineNumber) !== null && _d !== void 0 ? _d : -1);
406
+ return (jsx("tr", { "data-line": lineNumber, "data-state": hasDiff || !hasContent ? "diff" : "plain", "data-side": SplitSide[side], className: "diff-line" + (hasContent ? " group" : ""), children: hasContent ? (jsxs(Fragment, { children: [jsxs("td", { className: `diff-line-${SplitSide[side]}-num sticky left-0 z-[1] w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top`, style: {
407
+ backgroundColor: lineNumberBG,
408
+ color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
409
+ width: `var(${diffAsideWidthName})`,
410
+ minWidth: `var(${diffAsideWidthName})`,
411
+ maxWidth: `var(${diffAsideWidthName})`,
412
+ }, children: [hasDiff && enableAddWidget && (jsx(DiffSplitAddWidget, { index: index, lineNumber: (_e = currentLine.lineNumber) !== null && _e !== void 0 ? _e : -1, side: side, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })), jsx("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 }, children: currentLine.lineNumber })] }), jsx("td", { className: `diff-line-${SplitSide[side]}-content pr-[10px] align-top`, style: { backgroundColor: contentBG }, children: jsx(DiffContent, { enableWrap: false, diffFile: diffFile, rawLine: (currentLine === null || currentLine === void 0 ? void 0 : currentLine.value) || "", diffLine: currentLine === null || currentLine === void 0 ? void 0 : currentLine.diff, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight }) })] })) : (jsx("td", { className: `diff-line-${SplitSide[side]}-placeholder select-none`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsx("span", { children: "\u2002" }) })) }));
461
413
  };
462
414
  const DiffSplitContentLine$1 = ({ index, diffFile, lineNumber, side, enableAddWidget, enableHighlight, }) => {
463
415
  const getCurrentLine = side === SplitSide.old ? diffFile.getSplitLeftLine : diffFile.getSplitRightLine;
464
416
  const currentLine = getCurrentLine(index);
465
417
  if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.isHidden)
466
418
  return null;
467
- return (React.createElement(InternalDiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }));
419
+ return (jsx(InternalDiffSplitLine$1, { index: index, diffFile: diffFile, lineNumber: lineNumber, side: side, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }));
468
420
  };
469
421
 
470
422
  const useDomWidth = ({ selector, enable }) => {
@@ -490,10 +442,10 @@ const useDomWidth = ({ selector, enable }) => {
490
442
  };
491
443
  cb();
492
444
  const cleanCb = () => {
493
- var _a;
494
- typedWrapper.__observeCallback.delete(cb);
495
- if (typedWrapper.__observeCallback.size === 0) {
496
- (_a = typedWrapper.__observeInstance) === null || _a === void 0 ? void 0 : _a.disconnect();
445
+ var _a, _b, _c;
446
+ (_a = typedWrapper === null || typedWrapper === void 0 ? void 0 : typedWrapper.__observeCallback) === null || _a === void 0 ? void 0 : _a.delete(cb);
447
+ if (((_b = typedWrapper === null || typedWrapper === void 0 ? void 0 : typedWrapper.__observeCallback) === null || _b === void 0 ? void 0 : _b.size) === 0) {
448
+ (_c = typedWrapper.__observeInstance) === null || _c === void 0 ? void 0 : _c.disconnect();
497
449
  typedWrapper.removeAttribute("data-observe");
498
450
  delete typedWrapper.__observeCallback;
499
451
  delete typedWrapper.__observeInstance;
@@ -505,7 +457,7 @@ const useDomWidth = ({ selector, enable }) => {
505
457
  }
506
458
  typedWrapper.__observeCallback = new Set();
507
459
  typedWrapper.__observeCallback.add(cb);
508
- const observer = new ResizeObserver(() => typedWrapper.__observeCallback.forEach((cb) => cb()));
460
+ const observer = new ResizeObserver(() => { var _a; return (_a = typedWrapper === null || typedWrapper === void 0 ? void 0 : typedWrapper.__observeCallback) === null || _a === void 0 ? void 0 : _a.forEach((cb) => cb()); });
509
461
  typedWrapper.__observeInstance = observer;
510
462
  observer.observe(typedWrapper);
511
463
  typedWrapper.setAttribute("data-observe", "height");
@@ -548,10 +500,10 @@ const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
548
500
  };
549
501
  cb();
550
502
  const cleanCb = () => {
551
- var _a;
552
- typedTarget.__observeCallback.delete(cb);
553
- if (typedTarget.__observeCallback.size === 0) {
554
- (_a = typedTarget.__observeInstance) === null || _a === void 0 ? void 0 : _a.disconnect();
503
+ var _a, _b, _c;
504
+ (_a = typedTarget === null || typedTarget === void 0 ? void 0 : typedTarget.__observeCallback) === null || _a === void 0 ? void 0 : _a.delete(cb);
505
+ if (((_b = typedTarget === null || typedTarget === void 0 ? void 0 : typedTarget.__observeCallback) === null || _b === void 0 ? void 0 : _b.size) === 0) {
506
+ (_c = typedTarget.__observeInstance) === null || _c === void 0 ? void 0 : _c.disconnect();
555
507
  typedTarget.removeAttribute("data-observe");
556
508
  delete typedTarget.__observeCallback;
557
509
  delete typedTarget.__observeInstance;
@@ -563,7 +515,7 @@ const useSyncHeight = ({ selector, wrapper, side, enable, }) => {
563
515
  }
564
516
  typedTarget.__observeCallback = new Set();
565
517
  typedTarget.__observeCallback.add(cb);
566
- const observer = new ResizeObserver(() => typedTarget.__observeCallback.forEach((cb) => cb()));
518
+ const observer = new ResizeObserver(() => { var _a; return (_a = typedTarget === null || typedTarget === void 0 ? void 0 : typedTarget.__observeCallback) === null || _a === void 0 ? void 0 : _a.forEach((cb) => cb()); });
567
519
  typedTarget.__observeInstance = observer;
568
520
  observer.observe(target);
569
521
  target.setAttribute("data-observe", "height");
@@ -588,7 +540,7 @@ const InternalDiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLine
588
540
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
589
541
  diffFile,
590
542
  side,
591
- lineNumber: currentLineNumber,
543
+ lineNumber: currentLineNumber !== null && currentLineNumber !== void 0 ? currentLineNumber : -1,
592
544
  data: currentExtend === null || currentExtend === void 0 ? void 0 : currentExtend.data,
593
545
  onUpdate: diffFile.notifyAll,
594
546
  }));
@@ -604,19 +556,17 @@ const InternalDiffSplitExtendLine$1 = ({ index, diffFile, oldLineExtend, newLine
604
556
  });
605
557
  if (!renderExtendLine)
606
558
  return null;
607
- return (React.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": SplitSide[side], className: "diff-line diff-line-extend" }, currentSideHasExtend ? (React.createElement("td", { className: `diff-line-extend-${SplitSide[side]}-content p-0`, colSpan: 2 },
608
- React.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": SplitSide[side], className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width } }, width > 0 && currentExtendRendered))) : (React.createElement("td", { className: `diff-line-extend-${SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
609
- React.createElement("div", { "data-line": `${lineNumber}-extend-content`, "data-side": SplitSide[side] })))));
559
+ return (jsx("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", "data-side": SplitSide[side], className: "diff-line diff-line-extend", children: currentSideHasExtend ? (jsx("td", { className: `diff-line-extend-${SplitSide[side]}-content p-0`, colSpan: 2, children: jsx("div", { "data-line": `${lineNumber}-extend-content`, "data-side": SplitSide[side], className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width }, children: width > 0 && currentExtendRendered }) })) : (jsx("td", { className: `diff-line-extend-${SplitSide[side]}-placeholder select-none p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsx("div", { "data-line": `${lineNumber}-extend-content`, "data-side": SplitSide[side] }) })) }));
610
560
  };
611
561
  const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
612
562
  const { useDiffContext } = useDiffViewContext();
613
563
  const oldLine = diffFile.getSplitLeftLine(index);
614
564
  const newLine = diffFile.getSplitRightLine(index);
615
565
  const { oldLineExtend, newLineExtend } = useDiffContext(React.useCallback((s) => {
616
- var _a, _b, _c, _d;
566
+ var _a, _b, _c, _d, _e, _f;
617
567
  return ({
618
- oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber],
619
- newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber],
568
+ oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[(_c = oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber) !== null && _c !== void 0 ? _c : -1],
569
+ newLineExtend: (_e = (_d = s.extendData) === null || _d === void 0 ? void 0 : _d.newFile) === null || _e === void 0 ? void 0 : _e[(_f = newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber) !== null && _f !== void 0 ? _f : -1],
620
570
  });
621
571
  }, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
622
572
  const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
@@ -626,20 +576,17 @@ const DiffSplitExtendLine$1 = ({ index, diffFile, side, lineNumber, }) => {
626
576
  const currentIsShow = hasExtend && (!currentLine.isHidden || !enableExpand);
627
577
  if (!currentIsShow)
628
578
  return null;
629
- return (React.createElement(InternalDiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
579
+ return (jsx(InternalDiffSplitExtendLine$1, { side: side, index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
630
580
  };
631
581
 
632
582
  const ExpandDown = ({ className }) => {
633
- return (React.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
634
- React.createElement("path", { d: "m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
583
+ return (jsx("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className, children: jsx("path", { d: "m8.177 14.323 2.896-2.896a.25.25 0 0 0-.177-.427H8.75V7.764a.75.75 0 1 0-1.5 0V11H5.104a.25.25 0 0 0-.177.427l2.896 2.896a.25.25 0 0 0 .354 0ZM2.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75ZM8.25 5a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 4.25a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5a.75.75 0 0 1 .75.75Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" }) }));
635
584
  };
636
585
  const ExpandUp = ({ className }) => {
637
- return (React.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
638
- React.createElement("path", { d: "M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z" })));
586
+ return (jsx("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className, children: jsx("path", { d: "M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z" }) }));
639
587
  };
640
588
  const ExpandAll = ({ className }) => {
641
- return (React.createElement("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className },
642
- React.createElement("path", { d: "m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
589
+ return (jsx("svg", { "aria-hidden": "true", height: "16", viewBox: "0 0 16 16", version: "1.1", width: "16", className: className, children: jsx("path", { d: "m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" }) }));
643
590
  };
644
591
 
645
592
  const InternalDiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, }) => {
@@ -658,26 +605,15 @@ const InternalDiffSplitHunkLineGitHub = ({ index, diffFile, side, lineNumber, })
658
605
  currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
659
606
  const isFirstLine = currentHunk && currentHunk.isFirst;
660
607
  const isLastLine = currentHunk && currentHunk.isLast;
661
- return (React.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": SplitSide[side], className: "diff-line diff-line-hunk" }, enableHunkAction ? (React.createElement(React.Fragment, null,
662
- React.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
663
- backgroundColor: `var(${hunkLineNumberBGName})`,
664
- color: `var(${plainLineNumberColorName})`,
665
- width: `var(${diffAsideWidthName})`,
666
- minWidth: `var(${diffAsideWidthName})`,
667
- maxWidth: `var(${diffAsideWidthName})`,
668
- } }, couldExpand ? (isFirstLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
669
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
670
- React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
671
- React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
672
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
673
- React.createElement(ExpandDown, { className: "fill-current" })),
674
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
675
- React.createElement(ExpandUp, { className: "fill-current" }))))) : (React.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
676
- React.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
677
- React.createElement("div", { className: "pl-[1.5em]", style: {
678
- color: `var(${hunkContentColorName})`,
679
- } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)))) : (React.createElement("td", { className: "diff-line-hunk-placeholder select-none", colSpan: 2, style: { backgroundColor: `var(${hunkContentBGName})` } },
680
- React.createElement("div", { className: "min-h-[28px]" }, "\u2002")))));
608
+ return (jsx("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": SplitSide[side], className: "diff-line diff-line-hunk", children: enableHunkAction ? (jsxs(Fragment, { children: [jsx("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
609
+ backgroundColor: `var(${hunkLineNumberBGName})`,
610
+ color: `var(${plainLineNumberColorName})`,
611
+ width: `var(${diffAsideWidthName})`,
612
+ minWidth: `var(${diffAsideWidthName})`,
613
+ maxWidth: `var(${diffAsideWidthName})`,
614
+ }, children: couldExpand ? (isFirstLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsx("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsx(ExpandAll, { className: "fill-current" }) })) : (jsxs(Fragment, { children: [jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) }), jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsx("div", { className: "pl-[1.5em]", style: {
615
+ color: `var(${hunkContentColorName})`,
616
+ }, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] })) : (jsx("td", { className: "diff-line-hunk-placeholder select-none", colSpan: 2, style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsx("div", { className: "min-h-[28px]", children: "\u2002" }) })) }));
681
617
  };
682
618
  const InternalDiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, }) => {
683
619
  var _a;
@@ -694,25 +630,15 @@ const InternalDiffSplitHunkLineGitLab = ({ index, diffFile, side, lineNumber, })
694
630
  currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
695
631
  const isFirstLine = currentHunk && currentHunk.isFirst;
696
632
  const isLastLine = currentHunk && currentHunk.isLast;
697
- return (React.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": SplitSide[side], className: "diff-line diff-line-hunk" },
698
- React.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
699
- backgroundColor: `var(${hunkLineNumberBGName})`,
700
- color: `var(${plainLineNumberColorName})`,
701
- width: `var(${diffAsideWidthName})`,
702
- minWidth: `var(${diffAsideWidthName})`,
703
- maxWidth: `var(${diffAsideWidthName})`,
704
- } }, couldExpand ? (isFirstLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
705
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
706
- React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
707
- React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
708
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
709
- React.createElement(ExpandDown, { className: "fill-current" })),
710
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
711
- React.createElement(ExpandUp, { className: "fill-current" }))))) : (React.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
712
- React.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
713
- React.createElement("div", { className: "pl-[1.5em]", style: {
714
- color: `var(${hunkContentColorName})`,
715
- } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
633
+ return (jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", "data-side": SplitSide[side], className: "diff-line diff-line-hunk", children: [jsx("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[40px] select-none p-[1px]", style: {
634
+ backgroundColor: `var(${hunkLineNumberBGName})`,
635
+ color: `var(${plainLineNumberColorName})`,
636
+ width: `var(${diffAsideWidthName})`,
637
+ minWidth: `var(${diffAsideWidthName})`,
638
+ maxWidth: `var(${diffAsideWidthName})`,
639
+ }, children: couldExpand ? (isFirstLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsx("button", { className: "diff-widget-tooltip relative flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsx(ExpandAll, { className: "fill-current" }) })) : (jsxs(Fragment, { children: [jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) }), jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsx("div", { className: "pl-[1.5em]", style: {
640
+ color: `var(${hunkContentColorName})`,
641
+ }, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] }));
716
642
  };
717
643
  const InternalDiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
718
644
  const { useDiffContext } = useDiffViewContext();
@@ -720,10 +646,10 @@ const InternalDiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) =>
720
646
  if (diffViewMode === DiffModeEnum.SplitGitHub ||
721
647
  diffViewMode === DiffModeEnum.Split ||
722
648
  diffViewMode === DiffModeEnum.Unified) {
723
- return React.createElement(InternalDiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
649
+ return jsx(InternalDiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
724
650
  }
725
651
  else {
726
- return React.createElement(InternalDiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
652
+ return jsx(InternalDiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
727
653
  }
728
654
  };
729
655
  const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
@@ -734,10 +660,11 @@ const DiffSplitHunkLine$1 = ({ index, diffFile, side, lineNumber, }) => {
734
660
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
735
661
  if (!currentIsShow && !currentIsPureHunk)
736
662
  return null;
737
- return React.createElement(InternalDiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
663
+ return jsx(InternalDiffSplitHunkLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber });
738
664
  };
739
665
 
740
666
  const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
667
+ var _a;
741
668
  const { useWidget } = useDiffWidgetContext();
742
669
  const { useDiffContext } = useDiffViewContext();
743
670
  const oldLine = diffFile.getSplitLeftLine(index);
@@ -756,14 +683,14 @@ const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) =
756
683
  (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
757
684
  diffFile,
758
685
  side,
759
- lineNumber: currentLine.lineNumber,
686
+ lineNumber: (_a = currentLine.lineNumber) !== null && _a !== void 0 ? _a : -1,
760
687
  onClose: () => setWidget({}),
761
688
  }));
762
689
  useSyncHeight({
763
690
  selector: `div[data-line="${lineNumber}-widget-content"]`,
764
691
  wrapper: `tr[data-line="${lineNumber}-widget"]`,
765
692
  side: SplitSide[currentHasWidget ? side : otherSide],
766
- enable: hasWidget && typeof renderWidgetLine === "function",
693
+ enable: !!hasWidget && typeof renderWidgetLine === "function",
767
694
  });
768
695
  const width = useDomWidth({
769
696
  selector: side === SplitSide.old ? ".old-diff-table-wrapper" : ".new-diff-table-wrapper",
@@ -771,9 +698,7 @@ const InternalDiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) =
771
698
  });
772
699
  if (!renderWidgetLine)
773
700
  return null;
774
- return (React.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", "data-side": SplitSide[side], className: "diff-line diff-line-widget" }, currentHasWidget ? (React.createElement("td", { className: `diff-line-widget-${SplitSide[side]}-content p-0`, colSpan: 2 },
775
- React.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": SplitSide[side], className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width } }, width > 0 && currentWidgetRendered))) : (React.createElement("td", { className: `diff-line-widget-${SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
776
- React.createElement("div", { "data-line": `${lineNumber}-widget-content`, "data-side": SplitSide[side] })))));
701
+ return (jsx("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", "data-side": SplitSide[side], className: "diff-line diff-line-widget", children: currentHasWidget ? (jsx("td", { className: `diff-line-widget-${SplitSide[side]}-content p-0`, colSpan: 2, children: jsx("div", { "data-line": `${lineNumber}-widget-content`, "data-side": SplitSide[side], className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width }, children: width > 0 && currentWidgetRendered }) })) : (jsx("td", { className: `diff-line-widget-${SplitSide[side]}-placeholder p-0`, style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsx("div", { "data-line": `${lineNumber}-widget-content`, "data-side": SplitSide[side] }) })) }));
777
702
  };
778
703
  // TODO! improve performance
779
704
  const DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
@@ -790,38 +715,19 @@ const DiffSplitWidgetLine$1 = ({ index, side, diffFile, lineNumber, }) => {
790
715
  }, [diffFile, index]), (p, c) => p === c);
791
716
  if (!currentIsShow)
792
717
  return null;
793
- return React.createElement(InternalDiffSplitWidgetLine$1, { index: index, side: side, diffFile: diffFile, lineNumber: lineNumber });
718
+ return jsx(InternalDiffSplitWidgetLine$1, { index: index, side: side, diffFile: diffFile, lineNumber: lineNumber });
794
719
  };
795
720
 
796
- /* eslint-disable @typescript-eslint/ban-ts-comment */
797
721
  const DiffSplitViewTable = ({ side, diffFile, enableAddWidget, enableHighlight, onMouseDown, }) => {
798
722
  const className = side === SplitSide.new ? "new-diff-table" : "old-diff-table";
799
723
  const lines = getSplitContentLines(diffFile);
800
- return (React.createElement("table", { className: className + " w-full border-collapse border-spacing-0", "data-mode": SplitSide[side] },
801
- React.createElement("colgroup", null,
802
- React.createElement("col", { className: `diff-table-${SplitSide[side]}-num-col` }),
803
- React.createElement("col", { className: `diff-table-${SplitSide[side]}-content-col` })),
804
- React.createElement("thead", { className: "hidden" },
805
- React.createElement("tr", null,
806
- React.createElement("th", { scope: "col" },
807
- SplitSide[side],
808
- " line number"),
809
- React.createElement("th", { scope: "col" },
810
- SplitSide[side],
811
- " line content"))),
812
- React.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
813
- lines.map((line) => (React.createElement(Fragment, { key: line.index },
814
- React.createElement(DiffSplitHunkLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
815
- React.createElement(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }),
816
- React.createElement(DiffSplitWidgetLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }),
817
- React.createElement(DiffSplitExtendLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile })))),
818
- React.createElement(DiffSplitHunkLine$1, { side: side, index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))));
724
+ return (jsxs("table", { className: className + " w-full border-collapse border-spacing-0", "data-mode": SplitSide[side], children: [jsxs("colgroup", { children: [jsx("col", { className: `diff-table-${SplitSide[side]}-num-col` }), jsx("col", { className: `diff-table-${SplitSide[side]}-content-col` })] }), jsx("thead", { className: "hidden", children: jsxs("tr", { children: [jsxs("th", { scope: "col", children: [SplitSide[side], " line number"] }), jsxs("th", { scope: "col", children: [SplitSide[side], " line content"] })] }) }), jsxs("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown, children: [lines.map((line) => (jsxs(Fragment$1, { children: [jsx(DiffSplitHunkLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }), jsx(DiffSplitContentLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }), jsx(DiffSplitWidgetLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile }), jsx(DiffSplitExtendLine$1, { index: line.index, side: side, lineNumber: line.lineNumber, diffFile: diffFile })] }, line.index))), jsx(DiffSplitHunkLine$1, { side: side, index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile })] })] }));
819
725
  };
820
726
  const DiffSplitViewNormal = memo(({ diffFile }) => {
821
727
  const ref1 = useRef(null);
822
728
  const ref2 = useRef(null);
823
- const ref = useRef();
824
- const tempRef = useRef();
729
+ const ref = useRef(null);
730
+ const tempRef = useRef(undefined);
825
731
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
826
732
  const { useDiffContext } = useDiffViewContext();
827
733
  const { fontSize, enableAddWidget, enableHighlight } = useDiffContext.useShallowStableSelector((s) => ({
@@ -891,40 +797,34 @@ const DiffSplitViewNormal = memo(({ diffFile }) => {
891
797
  ele = ele.parentElement;
892
798
  }
893
799
  };
894
- return (React.createElement("div", { className: "split-diff-view split-diff-view-normal flex w-full basis-[50%]" },
895
- React.createElement("style", { "data-select-style": true, ref: ref }),
896
- React.createElement("div", { className: "old-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
897
- // @ts-ignore
898
- [diffAsideWidthName]: `${Math.round(width)}px`,
899
- overscrollBehaviorX: "none",
900
- fontFamily: "Menlo, Consolas, monospace",
901
- fontSize: `var(${diffFontSizeName})`,
902
- } },
903
- React.createElement(DiffSplitViewTable, { side: SplitSide.old, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight, onMouseDown: onMouseDown })),
904
- React.createElement("div", { className: "diff-split-line w-[1.5px]", style: { backgroundColor: `var(${borderColorName})` } }),
905
- React.createElement("div", { className: "new-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
906
- // @ts-ignore
907
- [diffAsideWidthName]: `${Math.round(width)}px`,
908
- overscrollBehaviorX: "none",
909
- fontFamily: "Menlo, Consolas, monospace",
910
- fontSize: `var(${diffFontSizeName})`,
911
- } },
912
- React.createElement(DiffSplitViewTable, { side: SplitSide.new, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight, onMouseDown: onMouseDown }))));
800
+ return (jsxs("div", { className: "split-diff-view split-diff-view-normal flex w-full basis-[50%]", children: [jsx("style", { "data-select-style": true, ref: ref }), jsx("div", { className: "old-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref1, style: {
801
+ // @ts-ignore
802
+ [diffAsideWidthName]: `${Math.round(width)}px`,
803
+ overscrollBehaviorX: "none",
804
+ fontFamily: "Menlo, Consolas, monospace",
805
+ fontSize: `var(${diffFontSizeName})`,
806
+ }, children: jsx(DiffSplitViewTable, { side: SplitSide.old, diffFile: diffFile, enableAddWidget: !!enableAddWidget, enableHighlight: !!enableHighlight, onMouseDown: onMouseDown }) }), jsx("div", { className: "diff-split-line w-[1.5px]", style: { backgroundColor: `var(${borderColorName})` } }), jsx("div", { className: "new-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", ref: ref2, style: {
807
+ // @ts-ignore
808
+ [diffAsideWidthName]: `${Math.round(width)}px`,
809
+ overscrollBehaviorX: "none",
810
+ fontFamily: "Menlo, Consolas, monospace",
811
+ fontSize: `var(${diffFontSizeName})`,
812
+ }, children: jsx(DiffSplitViewTable, { side: SplitSide.new, diffFile: diffFile, enableAddWidget: !!enableAddWidget, enableHighlight: !!enableHighlight, onMouseDown: onMouseDown }) })] }));
913
813
  });
914
814
  DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
915
815
 
916
816
  const InternalDiffSplitLine = ({ index, diffFile, lineNumber, enableAddWidget, enableHighlight, }) => {
917
- var _a, _b;
817
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
918
818
  const oldLine = diffFile.getSplitLeftLine(index);
919
819
  const newLine = diffFile.getSplitRightLine(index);
920
- const oldSyntaxLine = diffFile.getOldSyntaxLine(oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber);
921
- const oldPlainLine = diffFile.getOldPlainLine(oldLine.lineNumber);
922
- const newSyntaxLine = diffFile.getNewSyntaxLine(newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber);
923
- const newPlainLine = diffFile.getNewPlainLine(newLine.lineNumber);
820
+ const oldSyntaxLine = diffFile.getOldSyntaxLine((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber) !== null && _a !== void 0 ? _a : -1);
821
+ const oldPlainLine = diffFile.getOldPlainLine((_b = oldLine.lineNumber) !== null && _b !== void 0 ? _b : -1);
822
+ const newSyntaxLine = diffFile.getNewSyntaxLine((_c = newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber) !== null && _c !== void 0 ? _c : -1);
823
+ const newPlainLine = diffFile.getNewPlainLine((_d = newLine.lineNumber) !== null && _d !== void 0 ? _d : -1);
924
824
  const hasDiff = !!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || !!(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
925
825
  const hasChange = checkDiffLineIncludeChange(oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) || checkDiffLineIncludeChange(newLine === null || newLine === void 0 ? void 0 : newLine.diff);
926
- const oldLineIsDelete = ((_a = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _a === void 0 ? void 0 : _a.type) === DiffLineType.Delete;
927
- const newLineIsAdded = ((_b = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _b === void 0 ? void 0 : _b.type) === DiffLineType.Add;
826
+ const oldLineIsDelete = ((_e = oldLine === null || oldLine === void 0 ? void 0 : oldLine.diff) === null || _e === void 0 ? void 0 : _e.type) === DiffLineType.Delete;
827
+ const newLineIsAdded = ((_f = newLine === null || newLine === void 0 ? void 0 : newLine.diff) === null || _f === void 0 ? void 0 : _f.type) === DiffLineType.Add;
928
828
  const { useDiffContext } = useDiffViewContext();
929
829
  const onAddWidgetClick = useDiffContext.getReadonlyState().onAddWidgetClick;
930
830
  const { useWidget } = useDiffWidgetContext();
@@ -935,45 +835,30 @@ const InternalDiffSplitLine = ({ index, diffFile, lineNumber, enableAddWidget, e
935
835
  const oldLineNumberBG = getLineNumberBG(false, oldLineIsDelete, hasDiff);
936
836
  const newLineContentBG = getContentBG(newLineIsAdded, false, hasDiff);
937
837
  const newLineNumberBG = getLineNumberBG(newLineIsAdded, false, hasDiff);
938
- return (React.createElement("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line" },
939
- hasOldLine ? (React.createElement(React.Fragment, null,
940
- React.createElement("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": SplitSide[SplitSide.old], style: {
941
- backgroundColor: oldLineNumberBG,
942
- color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
943
- } },
944
- hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
945
- React.createElement("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, oldLine.lineNumber)),
946
- React.createElement("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": SplitSide[SplitSide.old], style: { backgroundColor: oldLineContentBG } },
947
- hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: oldLine.lineNumber, side: SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
948
- React.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value, diffLine: oldLine.diff, plainLine: oldPlainLine, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })))) : (React.createElement("td", { className: "diff-line-old-placeholder select-none", "data-side": SplitSide[SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 },
949
- React.createElement("span", null, "\u2002"))),
950
- hasNewLine ? (React.createElement(React.Fragment, null,
951
- React.createElement("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] pl-[10px] pr-[10px] text-right align-top", "data-side": SplitSide[SplitSide.new], style: {
952
- backgroundColor: newLineNumberBG,
953
- color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
838
+ return (jsxs("tr", { "data-line": lineNumber, "data-state": hasDiff ? "diff" : "plain", className: "diff-line", children: [hasOldLine ? (jsxs(Fragment, { children: [jsxs("td", { className: "diff-line-old-num group relative w-[1%] min-w-[40px] select-none pl-[10px] pr-[10px] text-right align-top", "data-side": SplitSide[SplitSide.old], style: {
839
+ backgroundColor: oldLineNumberBG,
840
+ color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
841
+ }, children: [hasDiff && enableAddWidget && (jsx(DiffSplitAddWidget, { index: index, lineNumber: (_g = oldLine.lineNumber) !== null && _g !== void 0 ? _g : -1, side: SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })), jsx("span", { "data-line-num": oldLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 }, children: oldLine.lineNumber })] }), jsxs("td", { className: "diff-line-old-content group relative pr-[10px] align-top", "data-side": SplitSide[SplitSide.old], style: { backgroundColor: oldLineContentBG }, children: [hasDiff && enableAddWidget && (jsx(DiffSplitAddWidget, { index: index, lineNumber: (_h = oldLine.lineNumber) !== null && _h !== void 0 ? _h : -1, side: SplitSide.old, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })), jsx(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: oldLine.value || "", diffLine: oldLine.diff, plainLine: oldPlainLine, syntaxLine: oldSyntaxLine, enableHighlight: enableHighlight })] })] })) : (jsx("td", { className: "diff-line-old-placeholder select-none", "data-side": SplitSide[SplitSide.old], style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2, children: jsx("span", { children: "\u2002" }) })), hasNewLine ? (jsxs(Fragment, { children: [jsxs("td", { className: "diff-line-new-num group relative w-[1%] min-w-[40px] select-none border-l-[1px] pl-[10px] pr-[10px] text-right align-top", "data-side": SplitSide[SplitSide.new], style: {
842
+ backgroundColor: newLineNumberBG,
843
+ color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
844
+ borderLeftColor: `var(${borderColorName})`,
845
+ borderLeftStyle: "solid",
846
+ }, children: [hasDiff && enableAddWidget && (jsx(DiffSplitAddWidget, { index: index, lineNumber: (_j = newLine.lineNumber) !== null && _j !== void 0 ? _j : -1, side: SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })), jsx("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 }, children: newLine.lineNumber })] }), jsxs("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": SplitSide[SplitSide.new], style: { backgroundColor: newLineContentBG }, children: [hasDiff && enableAddWidget && (jsx(DiffSplitAddWidget, { index: index, lineNumber: (_k = newLine.lineNumber) !== null && _k !== void 0 ? _k : -1, side: SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })), jsx(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, plainLine: newPlainLine, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })] })] })) : (jsx("td", { className: "diff-line-new-placeholder select-none border-l-[1px]", style: {
847
+ backgroundColor: `var(${emptyBGName})`,
954
848
  borderLeftColor: `var(${borderColorName})`,
955
849
  borderLeftStyle: "solid",
956
- } },
957
- hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute left-[100%] z-[1] translate-x-[-50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
958
- React.createElement("span", { "data-line-num": newLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, newLine.lineNumber)),
959
- React.createElement("td", { className: "diff-line-new-content group relative pr-[10px] align-top", "data-side": SplitSide[SplitSide.new], style: { backgroundColor: newLineContentBG } },
960
- hasDiff && enableAddWidget && (React.createElement(DiffSplitAddWidget, { index: index, lineNumber: newLine.lineNumber, side: SplitSide.new, diffFile: diffFile, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, className: "absolute right-[100%] z-[1] translate-x-[50%]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
961
- React.createElement(DiffContent, { enableWrap: true, diffFile: diffFile, rawLine: newLine.value || "", diffLine: newLine.diff, plainLine: newPlainLine, syntaxLine: newSyntaxLine, enableHighlight: enableHighlight })))) : (React.createElement("td", { className: "diff-line-new-placeholder select-none border-l-[1px]", style: {
962
- backgroundColor: `var(${emptyBGName})`,
963
- borderLeftColor: `var(${borderColorName})`,
964
- borderLeftStyle: "solid",
965
- }, "data-side": SplitSide[SplitSide.new], colSpan: 2 },
966
- React.createElement("span", null, "\u2002")))));
850
+ }, "data-side": SplitSide[SplitSide.new], colSpan: 2, children: jsx("span", { children: "\u2002" }) }))] }));
967
851
  };
968
852
  const DiffSplitContentLine = ({ index, diffFile, lineNumber, enableAddWidget, enableHighlight, }) => {
969
853
  const oldLine = diffFile.getSplitLeftLine(index);
970
854
  const newLine = diffFile.getSplitRightLine(index);
971
855
  if ((oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && (newLine === null || newLine === void 0 ? void 0 : newLine.isHidden))
972
856
  return null;
973
- return (React.createElement(InternalDiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }));
857
+ return (jsx(InternalDiffSplitLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }));
974
858
  };
975
859
 
976
860
  const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExtend, newLineExtend, }) => {
861
+ var _a, _b;
977
862
  const { useDiffContext } = useDiffViewContext();
978
863
  const oldLine = diffFile.getSplitLeftLine(index);
979
864
  const newLine = diffFile.getSplitRightLine(index);
@@ -985,7 +870,7 @@ const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExten
985
870
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
986
871
  diffFile,
987
872
  side: SplitSide.old,
988
- lineNumber: oldLine.lineNumber,
873
+ lineNumber: (_a = oldLine.lineNumber) !== null && _a !== void 0 ? _a : -1,
989
874
  data: oldLineExtend.data,
990
875
  onUpdate: diffFile.notifyAll,
991
876
  }));
@@ -993,29 +878,25 @@ const InternalDiffSplitExtendLine = ({ index, diffFile, lineNumber, oldLineExten
993
878
  (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
994
879
  diffFile,
995
880
  side: SplitSide.new,
996
- lineNumber: newLine.lineNumber,
881
+ lineNumber: (_b = newLine.lineNumber) !== null && _b !== void 0 ? _b : -1,
997
882
  data: newLineExtend.data,
998
883
  onUpdate: diffFile.notifyAll,
999
884
  }));
1000
- return (React.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
1001
- oldExtendRendered ? (React.createElement("td", { className: "diff-line-extend-old-content p-0", colSpan: 2 },
1002
- React.createElement("div", { className: "diff-line-extend-wrapper" }, oldExtendRendered))) : (React.createElement("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 })),
1003
- newExtendRendered ? (React.createElement("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" }, colSpan: 2 },
1004
- React.createElement("div", { className: "diff-line-extend-wrapper" }, newExtendRendered))) : (React.createElement("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] p-0", style: {
1005
- backgroundColor: `var(${emptyBGName})`,
1006
- borderLeftColor: `var(${borderColorName})`,
1007
- borderLeftStyle: "solid",
1008
- }, colSpan: 2 }))));
885
+ return (jsxs("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend", children: [oldExtendRendered ? (jsx("td", { className: "diff-line-extend-old-content p-0", colSpan: 2, children: jsx("div", { className: "diff-line-extend-wrapper", children: oldExtendRendered }) })) : (jsx("td", { className: "diff-line-extend-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 })), newExtendRendered ? (jsx("td", { className: "diff-line-extend-new-content border-l-[1px] p-0", style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" }, colSpan: 2, children: jsx("div", { className: "diff-line-extend-wrapper", children: newExtendRendered }) })) : (jsx("td", { className: "diff-line-extend-new-placeholder select-none border-l-[1px] p-0", style: {
886
+ backgroundColor: `var(${emptyBGName})`,
887
+ borderLeftColor: `var(${borderColorName})`,
888
+ borderLeftStyle: "solid",
889
+ }, colSpan: 2 }))] }));
1009
890
  };
1010
891
  const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
1011
892
  const { useDiffContext } = useDiffViewContext();
1012
893
  const oldLine = diffFile.getSplitLeftLine(index);
1013
894
  const newLine = diffFile.getSplitRightLine(index);
1014
895
  const { oldLineExtend, newLineExtend } = useDiffContext(React.useCallback((s) => {
1015
- var _a, _b, _c, _d;
896
+ var _a, _b, _c, _d, _e, _f;
1016
897
  return ({
1017
- oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber],
1018
- newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber],
898
+ oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[(_c = oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber) !== null && _c !== void 0 ? _c : -1],
899
+ newLineExtend: (_e = (_d = s.extendData) === null || _d === void 0 ? void 0 : _d.newFile) === null || _e === void 0 ? void 0 : _e[(_f = newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber) !== null && _f !== void 0 ? _f : -1],
1019
900
  });
1020
901
  }, [oldLine === null || oldLine === void 0 ? void 0 : oldLine.lineNumber, newLine === null || newLine === void 0 ? void 0 : newLine.lineNumber]));
1021
902
  const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
@@ -1024,7 +905,7 @@ const DiffSplitExtendLine = ({ index, diffFile, lineNumber, }) => {
1024
905
  const currentIsShow = hasExtend && ((!(oldLine === null || oldLine === void 0 ? void 0 : oldLine.isHidden) && !(newLine === null || newLine === void 0 ? void 0 : newLine.isHidden)) || !enableExpand);
1025
906
  if (!currentIsShow)
1026
907
  return null;
1027
- return (React.createElement(InternalDiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
908
+ return (jsx(InternalDiffSplitExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
1028
909
  };
1029
910
 
1030
911
  const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
@@ -1037,22 +918,12 @@ const DiffSplitHunkLineGitHub = ({ index, diffFile, lineNumber, }) => {
1037
918
  currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
1038
919
  const isFirstLine = currentHunk && currentHunk.isFirst;
1039
920
  const isLastLine = currentHunk && currentHunk.isLast;
1040
- return (React.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
1041
- React.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
1042
- backgroundColor: `var(${hunkLineNumberBGName})`,
1043
- color: `var(${plainLineNumberColorName})`,
1044
- } }, couldExpand ? (isFirstLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1045
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1046
- React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
1047
- React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
1048
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1049
- React.createElement(ExpandDown, { className: "fill-current" })),
1050
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1051
- React.createElement(ExpandUp, { className: "fill-current" }))))) : (React.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1052
- React.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3 },
1053
- React.createElement("div", { className: "pl-[1.5em]", style: {
1054
- color: `var(${hunkContentColorName})`,
1055
- } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
921
+ return (jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk", children: [jsx("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
922
+ backgroundColor: `var(${hunkLineNumberBGName})`,
923
+ color: `var(${plainLineNumberColorName})`,
924
+ }, children: couldExpand ? (isFirstLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsx(ExpandAll, { className: "fill-current" }) })) : (jsxs(Fragment, { children: [jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) }), jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, colSpan: 3, children: jsx("div", { className: "pl-[1.5em]", style: {
925
+ color: `var(${hunkContentColorName})`,
926
+ }, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] }));
1056
927
  };
1057
928
  const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
1058
929
  var _a, _b;
@@ -1064,39 +935,19 @@ const DiffSplitHunkLineGitLab = ({ index, diffFile, lineNumber, }) => {
1064
935
  currentHunk.splitInfo.endHiddenIndex - currentHunk.splitInfo.startHiddenIndex < composeLen;
1065
936
  const isFirstLine = currentHunk && currentHunk.isFirst;
1066
937
  const isLastLine = currentHunk && currentHunk.isLast;
1067
- return (React.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
1068
- React.createElement("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
1069
- backgroundColor: `var(${hunkLineNumberBGName})`,
1070
- color: `var(${plainLineNumberColorName})`,
1071
- } }, couldExpand ? (isFirstLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1072
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1073
- React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
1074
- React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
1075
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1076
- React.createElement(ExpandDown, { className: "fill-current" })),
1077
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1078
- React.createElement(ExpandUp, { className: "fill-current" }))))) : (React.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1079
- React.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1080
- React.createElement("div", { className: "pl-[1.5em]", style: {
1081
- color: `var(${hunkContentColorName})`,
1082
- } }, ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text)),
1083
- React.createElement("td", { className: "diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
1084
- backgroundColor: `var(${hunkLineNumberBGName})`,
1085
- color: `var(${plainLineNumberColorName})`,
1086
- borderLeftColor: `var(${borderColorName})`,
1087
- borderLeftStyle: "solid",
1088
- } }, couldExpand ? (isFirstLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1089
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1090
- React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index) },
1091
- React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
1092
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index) },
1093
- React.createElement(ExpandDown, { className: "fill-current" })),
1094
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
1095
- React.createElement(ExpandUp, { className: "fill-current" }))))) : (React.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1096
- React.createElement("td", { className: "diff-line-hunk-content relative pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1097
- React.createElement("div", { className: "pl-[1.5em]", style: {
1098
- color: `var(${hunkContentColorName})`,
1099
- } }, ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text))));
938
+ return (jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk", children: [jsx("td", { className: "diff-line-hunk-action relative w-[1%] min-w-[40px] select-none p-[1px]", style: {
939
+ backgroundColor: `var(${hunkLineNumberBGName})`,
940
+ color: `var(${plainLineNumberColorName})`,
941
+ }, children: couldExpand ? (isFirstLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsx(ExpandAll, { className: "fill-current" }) })) : (jsxs(Fragment, { children: [jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) }), jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsx("div", { className: "pl-[1.5em]", style: {
942
+ color: `var(${hunkContentColorName})`,
943
+ }, children: ((_a = currentHunk.splitInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) }), jsx("td", { className: "diff-line-hunk-action relative z-[1] w-[1%] min-w-[40px] select-none border-l-[1px] p-[1px]", style: {
944
+ backgroundColor: `var(${hunkLineNumberBGName})`,
945
+ color: `var(${plainLineNumberColorName})`,
946
+ borderLeftColor: `var(${borderColorName})`,
947
+ borderLeftStyle: "solid",
948
+ }, children: couldExpand ? (isFirstLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onSplitHunkExpand("all", index), children: jsx(ExpandAll, { className: "fill-current" }) })) : (jsxs(Fragment, { children: [jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onSplitHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) }), jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsx("td", { className: "diff-line-hunk-content relative pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsx("div", { className: "pl-[1.5em]", style: {
949
+ color: `var(${hunkContentColorName})`,
950
+ }, children: ((_b = currentHunk.splitInfo) === null || _b === void 0 ? void 0 : _b.plainText) || currentHunk.text }) })] }));
1100
951
  };
1101
952
  const InternalDiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1102
953
  const { useDiffContext } = useDiffViewContext();
@@ -1104,10 +955,10 @@ const InternalDiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1104
955
  if (diffViewMode === DiffModeEnum.SplitGitHub ||
1105
956
  diffViewMode === DiffModeEnum.Split ||
1106
957
  diffViewMode === DiffModeEnum.Unified) {
1107
- return React.createElement(DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, lineNumber: lineNumber });
958
+ return jsx(DiffSplitHunkLineGitHub, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1108
959
  }
1109
960
  else {
1110
- return React.createElement(DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, lineNumber: lineNumber });
961
+ return jsx(DiffSplitHunkLineGitLab, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1111
962
  }
1112
963
  };
1113
964
  const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
@@ -1118,10 +969,11 @@ const DiffSplitHunkLine = ({ index, diffFile, lineNumber, }) => {
1118
969
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.splitInfo;
1119
970
  if (!currentIsShow && !currentIsPureHunk)
1120
971
  return null;
1121
- return React.createElement(InternalDiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
972
+ return jsx(InternalDiffSplitHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1122
973
  };
1123
974
 
1124
975
  const InternalDiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
976
+ var _a, _b;
1125
977
  const { useWidget } = useDiffWidgetContext();
1126
978
  const setWidget = useWidget.getReadonlyState().setWidget;
1127
979
  const { useDiffContext } = useDiffViewContext();
@@ -1133,20 +985,26 @@ const InternalDiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1133
985
  const oldLineWidget = oldLine.lineNumber && widgetSide === SplitSide.old && widgetLineNumber === oldLine.lineNumber;
1134
986
  const newLineWidget = newLine.lineNumber && widgetSide === SplitSide.new && widgetLineNumber === newLine.lineNumber;
1135
987
  const oldWidgetRendered = oldLineWidget &&
1136
- (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.old, lineNumber: oldLine.lineNumber, onClose: () => setWidget({}) }));
988
+ (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
989
+ diffFile,
990
+ side: SplitSide.old,
991
+ lineNumber: (_a = oldLine.lineNumber) !== null && _a !== void 0 ? _a : -1,
992
+ onClose: () => setWidget({}),
993
+ }));
1137
994
  const newWidgetRendered = newLineWidget &&
1138
- (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.new, lineNumber: newLine.lineNumber, onClose: () => setWidget({}) }));
995
+ (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({
996
+ diffFile,
997
+ side: SplitSide.new,
998
+ lineNumber: (_b = newLine.lineNumber) !== null && _b !== void 0 ? _b : -1,
999
+ onClose: () => setWidget({}),
1000
+ }));
1139
1001
  if (!renderWidgetLine)
1140
1002
  return null;
1141
- return (React.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget" },
1142
- oldWidgetRendered ? (React.createElement("td", { className: "diff-line-widget-old-content p-0", colSpan: 2 },
1143
- React.createElement("div", { className: "diff-line-widget-wrapper" }, oldWidgetRendered))) : (React.createElement("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 })),
1144
- newWidgetRendered ? (React.createElement("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" } },
1145
- React.createElement("div", { className: "diff-line-widget-wrapper" }, newWidgetRendered))) : (React.createElement("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] p-0", style: {
1146
- backgroundColor: `var(${emptyBGName})`,
1147
- borderLeftColor: `var(${borderColorName})`,
1148
- borderLeftStyle: "solid",
1149
- }, colSpan: 2 }))));
1003
+ return (jsxs("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget", children: [oldWidgetRendered ? (jsx("td", { className: "diff-line-widget-old-content p-0", colSpan: 2, children: jsx("div", { className: "diff-line-widget-wrapper", children: oldWidgetRendered }) })) : (jsx("td", { className: "diff-line-widget-old-placeholder select-none p-0", style: { backgroundColor: `var(${emptyBGName})` }, colSpan: 2 })), newWidgetRendered ? (jsx("td", { className: "diff-line-widget-new-content border-l-[1px] p-0", colSpan: 2, style: { borderLeftColor: `var(${borderColorName})`, borderLeftStyle: "solid" }, children: jsx("div", { className: "diff-line-widget-wrapper", children: newWidgetRendered }) })) : (jsx("td", { className: "diff-line-widget-new-placeholder select-none border-l-[1px] p-0", style: {
1004
+ backgroundColor: `var(${emptyBGName})`,
1005
+ borderLeftColor: `var(${borderColorName})`,
1006
+ borderLeftStyle: "solid",
1007
+ }, colSpan: 2 }))] }));
1150
1008
  };
1151
1009
  // TODO! improve performance
1152
1010
  const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
@@ -1163,15 +1021,14 @@ const DiffSplitWidgetLine = ({ index, diffFile, lineNumber, }) => {
1163
1021
  }, [diffFile, index]), (p, c) => p === c);
1164
1022
  if (!currentIsShow)
1165
1023
  return null;
1166
- return React.createElement(InternalDiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1024
+ return jsx(InternalDiffSplitWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1167
1025
  };
1168
1026
 
1169
- /* eslint-disable @typescript-eslint/ban-ts-comment */
1170
1027
  const DiffSplitViewWrap = memo(({ diffFile }) => {
1171
1028
  const splitLineLength = Math.max(diffFile.splitLineLength, diffFile.fileLineLength);
1172
1029
  const { useDiffContext } = useDiffViewContext();
1173
1030
  const ref = useRef(null);
1174
- const tempRef = useRef();
1031
+ const tempRef = useRef(undefined);
1175
1032
  const { fontSize, enableAddWidget, enableHighlight } = useDiffContext.useShallowStableSelector((s) => ({
1176
1033
  fontSize: s.fontSize,
1177
1034
  enableAddWidget: s.enableAddWidget,
@@ -1234,33 +1091,12 @@ const DiffSplitViewWrap = memo(({ diffFile }) => {
1234
1091
  ele = ele.parentElement;
1235
1092
  }
1236
1093
  };
1237
- return (React.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full" },
1238
- React.createElement("div", { className: "diff-table-wrapper w-full", style: {
1094
+ return (jsx("div", { className: "split-diff-view split-diff-view-wrap w-full", children: jsxs("div", { className: "diff-table-wrapper w-full", style: {
1239
1095
  // @ts-ignore
1240
1096
  [diffAsideWidthName]: `${Math.round(width)}px`,
1241
1097
  fontFamily: "Menlo, Consolas, monospace",
1242
1098
  fontSize: `var(${diffFontSizeName})`,
1243
- } },
1244
- React.createElement("style", { "data-select-style": true, ref: ref }),
1245
- React.createElement("table", { className: "diff-table w-full table-fixed border-collapse border-spacing-0" },
1246
- React.createElement("colgroup", null,
1247
- React.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
1248
- React.createElement("col", { className: "diff-table-old-content-col" }),
1249
- React.createElement("col", { className: "diff-table-new-num-col", width: Math.round(width) }),
1250
- React.createElement("col", { className: "diff-table-new-content-col" })),
1251
- React.createElement("thead", { className: "hidden" },
1252
- React.createElement("tr", null,
1253
- React.createElement("th", { scope: "col" }, "old line number"),
1254
- React.createElement("th", { scope: "col" }, "old line content"),
1255
- React.createElement("th", { scope: "col" }, "new line number"),
1256
- React.createElement("th", { scope: "col" }, "new line content"))),
1257
- React.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
1258
- lines.map((line) => (React.createElement(Fragment, { key: line.index },
1259
- React.createElement(DiffSplitHunkLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1260
- React.createElement(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: enableAddWidget, enableHighlight: enableHighlight }),
1261
- React.createElement(DiffSplitWidgetLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }),
1262
- React.createElement(DiffSplitExtendLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile })))),
1263
- React.createElement(DiffSplitHunkLine, { index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile }))))));
1099
+ }, children: [jsx("style", { "data-select-style": true, ref: ref }), jsxs("table", { className: "diff-table w-full table-fixed border-collapse border-spacing-0", children: [jsxs("colgroup", { children: [jsx("col", { className: "diff-table-old-num-col", width: Math.round(width) }), jsx("col", { className: "diff-table-old-content-col" }), jsx("col", { className: "diff-table-new-num-col", width: Math.round(width) }), jsx("col", { className: "diff-table-new-content-col" })] }), jsx("thead", { className: "hidden", children: jsxs("tr", { children: [jsx("th", { scope: "col", children: "old line number" }), jsx("th", { scope: "col", children: "old line content" }), jsx("th", { scope: "col", children: "new line number" }), jsx("th", { scope: "col", children: "new line content" })] }) }), jsxs("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown, children: [lines.map((line) => (jsxs(Fragment$1, { children: [jsx(DiffSplitHunkLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }), jsx(DiffSplitContentLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile, enableAddWidget: !!enableAddWidget, enableHighlight: !!enableHighlight }), jsx(DiffSplitWidgetLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile }), jsx(DiffSplitExtendLine, { index: line.index, lineNumber: line.lineNumber, diffFile: diffFile })] }, line.index))), jsx(DiffSplitHunkLine, { index: diffFile.splitLineLength, lineNumber: diffFile.splitLineLength, diffFile: diffFile })] })] })] }) }));
1264
1100
  });
1265
1101
  DiffSplitViewWrap.displayName = "DiffSplitViewWrap";
1266
1102
 
@@ -1284,10 +1120,11 @@ const createDiffConfigStore = (props, diffFileId) => {
1284
1120
  const fontSize = ref(props.diffViewFontSize);
1285
1121
  const setFontSize = (_fontSize) => (fontSize.value = _fontSize);
1286
1122
  const extendData = ref({
1287
- oldFile: Object.assign({}, (_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile),
1288
- newFile: Object.assign({}, (_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile),
1123
+ oldFile: { ...(_a = props.extendData) === null || _a === void 0 ? void 0 : _a.oldFile },
1124
+ newFile: { ...(_b = props.extendData) === null || _b === void 0 ? void 0 : _b.newFile },
1289
1125
  });
1290
- const setExtendData = (_extendData) => {
1126
+ const setExtendData = (__extendData) => {
1127
+ const _extendData = __extendData || {};
1291
1128
  const existOldKeys = Object.keys(extendData.value.oldFile || {});
1292
1129
  const inComingOldKeys = Object.keys(_extendData.oldFile || {});
1293
1130
  for (const key of existOldKeys) {
@@ -1382,45 +1219,30 @@ const DiffSplitView = memo(({ diffFile }) => {
1382
1219
  useEffect(() => {
1383
1220
  onCreateUseWidgetHook === null || onCreateUseWidgetHook === void 0 ? void 0 : onCreateUseWidgetHook(useWidget);
1384
1221
  }, [useWidget, onCreateUseWidgetHook]);
1385
- return (React.createElement(DiffWidgetContext.Provider, { value: contextValue }, enableWrap ? React.createElement(DiffSplitViewWrap, { diffFile: diffFile }) : React.createElement(DiffSplitViewNormal, { diffFile: diffFile })));
1222
+ return (jsx(DiffWidgetContext.Provider, { value: contextValue, children: enableWrap ? jsx(DiffSplitViewWrap, { diffFile: diffFile }) : jsx(DiffSplitViewNormal, { diffFile: diffFile }) }));
1386
1223
  });
1387
1224
  DiffSplitView.displayName = "DiffSplitView";
1388
1225
 
1389
1226
  const DiffUnifiedOldLine = ({ index, diffLine, rawLine, plainLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1390
- return (React.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1391
- React.createElement("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1392
- color: `var(${plainLineNumberColorName})`,
1393
- backgroundColor: `var(${delLineNumberBGName})`,
1394
- width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1395
- maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1396
- minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1397
- } },
1398
- enableAddWidget && (React.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1399
- React.createElement("div", { className: "flex" },
1400
- React.createElement("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber),
1401
- React.createElement("span", { className: "w-[10px] shrink-0" }),
1402
- React.createElement("span", { className: "inline-block w-[50%]" }))),
1403
- React.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` } },
1404
- React.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }))));
1227
+ return (jsxs("tr", { "data-line": index, "data-state": "diff", className: "diff-line group", children: [jsxs("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1228
+ color: `var(${plainLineNumberColorName})`,
1229
+ backgroundColor: `var(${delLineNumberBGName})`,
1230
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1231
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1232
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1233
+ }, children: [enableAddWidget && (jsx(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })), jsxs("div", { className: "flex", children: [jsx("span", { "data-line-old-num": lineNumber, className: "inline-block w-[50%]", children: lineNumber }), jsx("span", { className: "w-[10px] shrink-0" }), jsx("span", { className: "inline-block w-[50%]" })] })] }), jsx("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${delContentBGName})` }, children: jsx(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }) })] }));
1405
1234
  };
1406
1235
  const DiffUnifiedNewLine = ({ index, diffLine, rawLine, plainLine, syntaxLine, lineNumber, diffFile, setWidget, enableWrap, enableAddWidget, enableHighlight, onAddWidgetClick, }) => {
1407
- return (React.createElement("tr", { "data-line": index, "data-state": "diff", className: "diff-line group" },
1408
- React.createElement("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1409
- color: `var(${plainLineNumberColorName})`,
1410
- backgroundColor: `var(${addLineNumberBGName})`,
1411
- width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1412
- maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1413
- minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1414
- } },
1415
- enableAddWidget && (React.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1416
- React.createElement("div", { className: "flex" },
1417
- React.createElement("span", { className: "inline-block w-[50%]" }),
1418
- React.createElement("span", { className: "w-[10px] shrink-0" }),
1419
- React.createElement("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]" }, lineNumber))),
1420
- React.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` } },
1421
- React.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }))));
1236
+ return (jsxs("tr", { "data-line": index, "data-state": "diff", className: "diff-line group", children: [jsxs("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1237
+ color: `var(${plainLineNumberColorName})`,
1238
+ backgroundColor: `var(${addLineNumberBGName})`,
1239
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1240
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1241
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1242
+ }, children: [enableAddWidget && (jsx(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })), jsxs("div", { className: "flex", children: [jsx("span", { className: "inline-block w-[50%]" }), jsx("span", { className: "w-[10px] shrink-0" }), jsx("span", { "data-line-new-num": lineNumber, className: "inline-block w-[50%]", children: lineNumber })] })] }), jsx("td", { className: "diff-line-content pr-[10px] align-top", style: { backgroundColor: `var(${addContentBGName})` }, children: jsx(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }) })] }));
1422
1243
  };
1423
1244
  const InternalDiffUnifiedLine = ({ index, diffFile, lineNumber, enableWrap, enableAddWidget, enableHighlight, }) => {
1245
+ var _a;
1424
1246
  const unifiedLine = diffFile.getUnifiedLine(index);
1425
1247
  const { useDiffContext } = useDiffViewContext();
1426
1248
  const onAddWidgetClick = useDiffContext.getReadonlyState().onAddWidgetClick;
@@ -1444,40 +1266,33 @@ const InternalDiffUnifiedLine = ({ index, diffFile, lineNumber, enableWrap, enab
1444
1266
  : undefined;
1445
1267
  if (hasChange) {
1446
1268
  if (unifiedLine.oldLineNumber) {
1447
- return (React.createElement(DiffUnifiedOldLine, { index: lineNumber, enableWrap: enableWrap, diffFile: diffFile, rawLine: rawLine, diffLine: diffLine, setWidget: setWidget, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.oldLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
1269
+ return (jsx(DiffUnifiedOldLine, { index: lineNumber, enableWrap: enableWrap, diffFile: diffFile, rawLine: rawLine, diffLine: diffLine, setWidget: setWidget, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.oldLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
1448
1270
  }
1449
1271
  else {
1450
- return (React.createElement(DiffUnifiedNewLine, { index: lineNumber, enableWrap: enableWrap, rawLine: rawLine, diffLine: diffLine, diffFile: diffFile, setWidget: setWidget, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.newLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
1272
+ return (jsx(DiffUnifiedNewLine, { index: lineNumber, enableWrap: enableWrap, rawLine: rawLine, diffLine: diffLine, diffFile: diffFile, setWidget: setWidget, plainLine: plainLine, syntaxLine: syntaxLine, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget, lineNumber: unifiedLine.newLineNumber, onAddWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); } }));
1451
1273
  }
1452
1274
  }
1453
1275
  else {
1454
- return (React.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
1455
- React.createElement("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1456
- color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
1457
- width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1458
- maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1459
- minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1460
- backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
1461
- } },
1462
- enableAddWidget && hasDiff && (React.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
1463
- React.createElement("div", { className: "flex opacity-[0.5]" },
1464
- React.createElement("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]" }, unifiedLine.oldLineNumber),
1465
- React.createElement("span", { className: "w-[10px] shrink-0" }),
1466
- React.createElement("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]" }, unifiedLine.newLineNumber))),
1467
- React.createElement("td", { className: "diff-line-content pr-[10px] align-top", style: {
1468
- backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
1469
- } },
1470
- React.createElement(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }))));
1276
+ return (jsxs("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group", children: [jsxs("td", { className: "diff-line-num sticky left-0 z-[1] w-[1%] min-w-[100px] select-none whitespace-nowrap pl-[10px] pr-[10px] text-right align-top", style: {
1277
+ color: `var(${hasDiff ? plainLineNumberColorName : expandLineNumberColorName})`,
1278
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1279
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1280
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1281
+ backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
1282
+ }, children: [enableAddWidget && hasDiff && (jsx(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: (_a = unifiedLine.newLineNumber) !== null && _a !== void 0 ? _a : -1, side: SplitSide.new, onWidgetClick: (...props) => { var _a; return (_a = onAddWidgetClick.current) === null || _a === void 0 ? void 0 : _a.call(onAddWidgetClick, ...props); }, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })), jsxs("div", { className: "flex opacity-[0.5]", children: [jsx("span", { "data-line-old-num": unifiedLine.oldLineNumber, className: "inline-block w-[50%]", children: unifiedLine.oldLineNumber }), jsx("span", { className: "w-[10px] shrink-0" }), jsx("span", { "data-line-new-num": unifiedLine.newLineNumber, className: "inline-block w-[50%]", children: unifiedLine.newLineNumber })] })] }), jsx("td", { className: "diff-line-content pr-[10px] align-top", style: {
1283
+ backgroundColor: hasDiff ? `var(${plainContentBGName})` : `var(${expandContentBGName})`,
1284
+ }, children: jsx(DiffContent, { enableWrap: enableWrap, diffFile: diffFile, enableHighlight: enableHighlight, rawLine: rawLine, diffLine: diffLine, plainLine: plainLine, syntaxLine: syntaxLine }) })] }));
1471
1285
  }
1472
1286
  };
1473
1287
  const DiffUnifiedContentLine = ({ index, diffFile, lineNumber, enableWrap, enableHighlight, enableAddWidget, }) => {
1474
1288
  const unifiedLine = diffFile.getUnifiedLine(index);
1475
1289
  if (unifiedLine === null || unifiedLine === void 0 ? void 0 : unifiedLine.isHidden)
1476
1290
  return null;
1477
- return (React.createElement(InternalDiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget }));
1291
+ return (jsx(InternalDiffUnifiedLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget }));
1478
1292
  };
1479
1293
 
1480
1294
  const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap, oldLineExtend, newLineExtend, }) => {
1295
+ var _a, _b;
1481
1296
  const { useDiffContext } = useDiffViewContext();
1482
1297
  const renderExtendLine = useDiffContext.useShallowStableSelector((s) => s.renderExtendLine);
1483
1298
  const unifiedItem = diffFile.getUnifiedLine(index);
@@ -1488,44 +1303,40 @@ const InternalDiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap
1488
1303
  });
1489
1304
  if (!renderExtendLine)
1490
1305
  return null;
1491
- return (React.createElement("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend" },
1492
- React.createElement("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2 },
1493
- React.createElement("div", { className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width } },
1494
- (enableWrap ? true : width > 0) &&
1495
- (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== undefined &&
1496
- (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== null &&
1497
- (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
1498
- diffFile,
1499
- side: SplitSide.old,
1500
- lineNumber: unifiedItem.oldLineNumber,
1501
- data: oldLineExtend.data,
1502
- onUpdate: diffFile.notifyAll,
1503
- })),
1504
- (enableWrap ? true : width > 0) &&
1505
- (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== undefined &&
1506
- (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== null &&
1507
- (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
1508
- diffFile,
1509
- side: SplitSide.new,
1510
- lineNumber: unifiedItem.newLineNumber,
1511
- data: newLineExtend.data,
1512
- onUpdate: diffFile.notifyAll,
1513
- }))))));
1306
+ return (jsx("tr", { "data-line": `${lineNumber}-extend`, "data-state": "extend", className: "diff-line diff-line-extend", children: jsx("td", { className: "diff-line-extend-content p-0 align-top", colSpan: 2, children: jsxs("div", { className: "diff-line-extend-wrapper sticky left-0 z-[1]", style: { width }, children: [(enableWrap ? true : width > 0) &&
1307
+ (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== undefined &&
1308
+ (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) !== null &&
1309
+ (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
1310
+ diffFile,
1311
+ side: SplitSide.old,
1312
+ lineNumber: (_a = unifiedItem.oldLineNumber) !== null && _a !== void 0 ? _a : -1,
1313
+ data: oldLineExtend.data,
1314
+ onUpdate: diffFile.notifyAll,
1315
+ })), (enableWrap ? true : width > 0) &&
1316
+ (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== undefined &&
1317
+ (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data) !== null &&
1318
+ (renderExtendLine === null || renderExtendLine === void 0 ? void 0 : renderExtendLine({
1319
+ diffFile,
1320
+ side: SplitSide.new,
1321
+ lineNumber: (_b = unifiedItem.newLineNumber) !== null && _b !== void 0 ? _b : -1,
1322
+ data: newLineExtend.data,
1323
+ onUpdate: diffFile.notifyAll,
1324
+ }))] }) }) }));
1514
1325
  };
1515
1326
  const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
1516
1327
  const { useDiffContext } = useDiffViewContext();
1517
1328
  const unifiedItem = diffFile.getUnifiedLine(index);
1518
1329
  const { oldLineExtend, newLineExtend } = useDiffContext(useCallback((s) => {
1519
- var _a, _b, _c, _d;
1330
+ var _a, _b, _c, _d, _e, _f;
1520
1331
  return ({
1521
- oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.oldLineNumber],
1522
- newLineExtend: (_d = (_c = s.extendData) === null || _c === void 0 ? void 0 : _c.newFile) === null || _d === void 0 ? void 0 : _d[unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.newLineNumber],
1332
+ oldLineExtend: (_b = (_a = s.extendData) === null || _a === void 0 ? void 0 : _a.oldFile) === null || _b === void 0 ? void 0 : _b[(_c = unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.oldLineNumber) !== null && _c !== void 0 ? _c : -1],
1333
+ newLineExtend: (_e = (_d = s.extendData) === null || _d === void 0 ? void 0 : _d.newFile) === null || _e === void 0 ? void 0 : _e[(_f = unifiedItem === null || unifiedItem === void 0 ? void 0 : unifiedItem.newLineNumber) !== null && _f !== void 0 ? _f : -1],
1523
1334
  });
1524
1335
  }, [unifiedItem.oldLineNumber, unifiedItem.newLineNumber]));
1525
1336
  const hasExtend = (oldLineExtend === null || oldLineExtend === void 0 ? void 0 : oldLineExtend.data) || (newLineExtend === null || newLineExtend === void 0 ? void 0 : newLineExtend.data);
1526
1337
  if (!hasExtend || !unifiedItem || unifiedItem.isHidden)
1527
1338
  return null;
1528
- return (React.createElement(InternalDiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
1339
+ return (jsx(InternalDiffUnifiedExtendLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap, oldLineExtend: oldLineExtend, newLineExtend: newLineExtend }));
1529
1340
  };
1530
1341
 
1531
1342
  const InternalDiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
@@ -1540,27 +1351,17 @@ const InternalDiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1540
1351
  currentHunk.unifiedInfo.endHiddenIndex - currentHunk.unifiedInfo.startHiddenIndex < composeLen;
1541
1352
  const isFirstLine = currentHunk && currentHunk.isFirst;
1542
1353
  const isLastLine = currentHunk && currentHunk.isLast;
1543
- return (React.createElement("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk" },
1544
- React.createElement("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[100px] select-none p-[1px]", style: {
1545
- backgroundColor: `var(${hunkLineNumberBGName})`,
1546
- color: `var(${plainLineNumberColorName})`,
1547
- width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1548
- maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1549
- minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1550
- } }, couldExpand ? (isFirstLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1551
- React.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1552
- React.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index) },
1553
- React.createElement(ExpandAll, { className: "fill-current" }))) : (React.createElement(React.Fragment, null,
1554
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
1555
- React.createElement(ExpandDown, { className: "fill-current" })),
1556
- React.createElement("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
1557
- React.createElement(ExpandUp, { className: "fill-current" }))))) : (React.createElement("div", { className: "min-h-[28px]" }, "\u2002"))),
1558
- React.createElement("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` } },
1559
- React.createElement("div", { className: "pl-[1.5em]", style: {
1560
- whiteSpace: enableWrap ? "pre-wrap" : "pre",
1561
- wordBreak: enableWrap ? "break-all" : "initial",
1562
- color: `var(${hunkContentColorName})`,
1563
- } }, ((_a = currentHunk.unifiedInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text))));
1354
+ return (jsxs("tr", { "data-line": `${lineNumber}-hunk`, "data-state": "hunk", className: "diff-line diff-line-hunk", children: [jsx("td", { className: "diff-line-hunk-action sticky left-0 w-[1%] min-w-[100px] select-none p-[1px]", style: {
1355
+ backgroundColor: `var(${hunkLineNumberBGName})`,
1356
+ color: `var(${plainLineNumberColorName})`,
1357
+ width: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1358
+ maxWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1359
+ minWidth: `calc(calc(var(${diffAsideWidthName}) + 5px) * 2)`,
1360
+ }, children: couldExpand ? (isFirstLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })) : isLastLine ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) })) : isExpandAll ? (jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[6px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index), children: jsx(ExpandAll, { className: "fill-current" }) })) : (jsxs(Fragment, { children: [jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index), children: jsx(ExpandDown, { className: "fill-current" }) }), jsx("button", { className: "diff-widget-tooltip flex w-full cursor-pointer items-center justify-center rounded-[2px] py-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index), children: jsx(ExpandUp, { className: "fill-current" }) })] }))) : (jsx("div", { className: "min-h-[28px]", children: "\u2002" })) }), jsx("td", { className: "diff-line-hunk-content pr-[10px] align-middle", style: { backgroundColor: `var(${hunkContentBGName})` }, children: jsx("div", { className: "pl-[1.5em]", style: {
1361
+ whiteSpace: enableWrap ? "pre-wrap" : "pre",
1362
+ wordBreak: enableWrap ? "break-all" : "initial",
1363
+ color: `var(${hunkContentColorName})`,
1364
+ }, children: ((_a = currentHunk.unifiedInfo) === null || _a === void 0 ? void 0 : _a.plainText) || currentHunk.text }) })] }));
1564
1365
  };
1565
1366
  const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1566
1367
  const currentHunk = diffFile.getUnifiedHunkLine(index);
@@ -1570,10 +1371,11 @@ const DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
1570
1371
  const currentIsPureHunk = currentHunk && diffFile._getIsPureDiffRender() && !currentHunk.unifiedInfo;
1571
1372
  if (!currentIsShow && !currentIsPureHunk)
1572
1373
  return null;
1573
- return React.createElement(InternalDiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1374
+ return jsx(InternalDiffUnifiedHunkLine, { index: index, diffFile: diffFile, lineNumber: lineNumber });
1574
1375
  };
1575
1376
 
1576
1377
  const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
1378
+ var _a, _b;
1577
1379
  const { useWidget } = useDiffWidgetContext();
1578
1380
  const setWidget = useWidget.getReadonlyState().setWidget;
1579
1381
  const unifiedItem = diffFile.getUnifiedLine(index);
@@ -1591,15 +1393,11 @@ const InternalDiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap
1591
1393
  });
1592
1394
  if (!renderWidgetLine)
1593
1395
  return null;
1594
- return (React.createElement("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget" },
1595
- React.createElement("td", { className: "diff-line-widget-content p-0", colSpan: 2 },
1596
- React.createElement("div", { className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width } },
1597
- (enableWrap ? true : width > 0) &&
1598
- oldWidget &&
1599
- (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.old, lineNumber: unifiedItem.oldLineNumber, onClose })),
1600
- (enableWrap ? true : width > 0) &&
1601
- newWidget &&
1602
- (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.new, lineNumber: unifiedItem.newLineNumber, onClose }))))));
1396
+ return (jsx("tr", { "data-line": `${lineNumber}-widget`, "data-state": "widget", className: "diff-line diff-line-widget", children: jsx("td", { className: "diff-line-widget-content p-0", colSpan: 2, children: jsxs("div", { className: "diff-line-widget-wrapper sticky left-0 z-[1]", style: { width }, children: [(enableWrap ? true : width > 0) &&
1397
+ oldWidget &&
1398
+ (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.old, lineNumber: (_a = unifiedItem.oldLineNumber) !== null && _a !== void 0 ? _a : -1, onClose })), (enableWrap ? true : width > 0) &&
1399
+ newWidget &&
1400
+ (renderWidgetLine === null || renderWidgetLine === void 0 ? void 0 : renderWidgetLine({ diffFile, side: SplitSide.new, lineNumber: (_b = unifiedItem.newLineNumber) !== null && _b !== void 0 ? _b : -1, onClose }))] }) }) }));
1603
1401
  };
1604
1402
  const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) => {
1605
1403
  const { useWidget } = useDiffWidgetContext();
@@ -1614,14 +1412,13 @@ const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, enableWrap, }) =>
1614
1412
  }, [diffFile, index]), (p, c) => p === c);
1615
1413
  if (!currentIsShow)
1616
1414
  return null;
1617
- return (React.createElement(InternalDiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap }));
1415
+ return (jsx(InternalDiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, enableWrap: enableWrap }));
1618
1416
  };
1619
1417
 
1620
- /* eslint-disable @typescript-eslint/ban-ts-comment */
1621
1418
  const DiffUnifiedView = memo(({ diffFile }) => {
1622
1419
  const { useDiffContext } = useDiffViewContext();
1623
1420
  const ref = useRef(null);
1624
- const tempRef = useRef();
1421
+ const tempRef = useRef(undefined);
1625
1422
  const useDiffContextRef = useRef(useDiffContext);
1626
1423
  useDiffContextRef.current = useDiffContext;
1627
1424
  // performance optimization
@@ -1694,30 +1491,12 @@ const DiffUnifiedView = memo(({ diffFile }) => {
1694
1491
  ele = ele.parentElement;
1695
1492
  }
1696
1493
  };
1697
- return (React.createElement(DiffWidgetContext.Provider, { value: contextValue },
1698
- React.createElement("div", { className: `unified-diff-view ${enableWrap ? "unified-diff-view-wrap" : "unified-diff-view-normal"} w-full` },
1699
- React.createElement("style", { "data-select-style": true, ref: ref }),
1700
- React.createElement("div", { className: "unified-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", style: {
1701
- // @ts-ignore
1702
- [diffAsideWidthName]: `${Math.round(width)}px`,
1703
- fontFamily: "Menlo, Consolas, monospace",
1704
- fontSize: `var(${diffFontSizeName})`,
1705
- } },
1706
- React.createElement("table", { className: `unified-diff-table w-full border-collapse border-spacing-0 ${enableWrap ? "table-fixed" : ""}` },
1707
- React.createElement("colgroup", null,
1708
- React.createElement("col", { className: "unified-diff-table-num-col" }),
1709
- React.createElement("col", { className: "unified-diff-table-content-col" })),
1710
- React.createElement("thead", { className: "hidden" },
1711
- React.createElement("tr", null,
1712
- React.createElement("th", { scope: "col" }, "line number"),
1713
- React.createElement("th", { scope: "col" }, "line content"))),
1714
- React.createElement("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown },
1715
- lines.map((item) => (React.createElement(Fragment, { key: item.index },
1716
- React.createElement(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
1717
- React.createElement(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap, enableHighlight: enableHighlight, enableAddWidget: enableAddWidget }),
1718
- React.createElement(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap }),
1719
- React.createElement(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: enableWrap })))),
1720
- React.createElement(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })))))));
1494
+ return (jsx(DiffWidgetContext.Provider, { value: contextValue, children: jsxs("div", { className: `unified-diff-view ${enableWrap ? "unified-diff-view-wrap" : "unified-diff-view-normal"} w-full`, children: [jsx("style", { "data-select-style": true, ref: ref }), jsx("div", { className: "unified-diff-table-wrapper diff-table-scroll-container w-full overflow-x-auto overflow-y-hidden", style: {
1495
+ // @ts-ignore
1496
+ [diffAsideWidthName]: `${Math.round(width)}px`,
1497
+ fontFamily: "Menlo, Consolas, monospace",
1498
+ fontSize: `var(${diffFontSizeName})`,
1499
+ }, children: jsxs("table", { className: `unified-diff-table w-full border-collapse border-spacing-0 ${enableWrap ? "table-fixed" : ""}`, children: [jsxs("colgroup", { children: [jsx("col", { className: "unified-diff-table-num-col" }), jsx("col", { className: "unified-diff-table-content-col" })] }), jsx("thead", { className: "hidden", children: jsxs("tr", { children: [jsx("th", { scope: "col", children: "line number" }), jsx("th", { scope: "col", children: "line content" })] }) }), jsxs("tbody", { className: "diff-table-body leading-[1.6]", onMouseDownCapture: onMouseDown, children: [lines.map((item) => (jsxs(Fragment$1, { children: [jsx(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }), jsx(DiffUnifiedContentLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: !!enableWrap, enableHighlight: !!enableHighlight, enableAddWidget: !!enableAddWidget }), jsx(DiffUnifiedWidgetLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: !!enableWrap }), jsx(DiffUnifiedExtendLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile, enableWrap: !!enableWrap })] }, item.index))), jsx(DiffUnifiedHunkLine, { index: diffFile.unifiedLineLength, lineNumber: diffFile.unifiedLineLength, diffFile: diffFile })] })] }) })] }) }));
1721
1500
  });
1722
1501
  DiffUnifiedView.displayName = "DiffUnifiedView";
1723
1502
 
@@ -1741,13 +1520,13 @@ const InternalDiffView = (props) => {
1741
1520
  setMounted(isMounted);
1742
1521
  }
1743
1522
  if (diffViewAddWidget !== enableAddWidget) {
1744
- setEnableAddWidget(diffViewAddWidget);
1523
+ setEnableAddWidget(!!diffViewAddWidget);
1745
1524
  }
1746
1525
  if (diffViewHighlight !== enableHighlight) {
1747
- setEnableHighlight(diffViewHighlight);
1526
+ setEnableHighlight(!!diffViewHighlight);
1748
1527
  }
1749
1528
  if (diffViewWrap !== enableWrap) {
1750
- setEnableWrap(diffViewWrap);
1529
+ setEnableWrap(!!diffViewWrap);
1751
1530
  }
1752
1531
  if (extendData) {
1753
1532
  setExtendData(extendData);
@@ -1783,21 +1562,20 @@ const InternalDiffView = (props) => {
1783
1562
  onCreateUseWidgetHook,
1784
1563
  ]);
1785
1564
  useEffect(() => {
1786
- useDiffContext.getReadonlyState().setDom(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
1565
+ if (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) {
1566
+ useDiffContext.getReadonlyState().setDom(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
1567
+ }
1787
1568
  }, [useDiffContext, wrapperRef]);
1788
1569
  const value = useMemo(() => ({ useDiffContext }), [useDiffContext]);
1789
- return (React.createElement(DiffViewContext.Provider, { value: value },
1790
- React.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.1.3", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef },
1791
- React.createElement("div", { className: "diff-style-root", style: {
1570
+ return (jsx(DiffViewContext.Provider, { value: value, children: jsx("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-theme": diffFile._getTheme() || "light", "data-version": "0.1.5", "data-highlighter": diffFile._getHighlighterName(), ref: wrapperRef, children: jsx("div", { className: "diff-style-root", style: {
1792
1571
  // @ts-ignore
1793
1572
  [diffFontSizeName]: diffViewFontSize + "px",
1794
- } },
1795
- React.createElement("div", { id: isMounted ? `diff-root${diffFileId}` : undefined, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style }, diffViewMode & DiffModeEnum.Split ? (React.createElement(DiffSplitView, { diffFile: diffFile })) : (React.createElement(DiffUnifiedView, { diffFile: diffFile })))))));
1573
+ }, children: jsx("div", { id: isMounted ? `diff-root${diffFileId}` : undefined, className: "diff-view-wrapper" + (className ? ` ${className}` : ""), style: style, children: diffViewMode & DiffModeEnum.Split ? (jsx(DiffSplitView, { diffFile: diffFile })) : (jsx(DiffUnifiedView, { diffFile: diffFile })) }) }) }) }));
1796
1574
  };
1797
1575
  const MemoedInternalDiffView = memo(InternalDiffView);
1798
1576
  const DiffViewWithRef = (props, ref) => {
1799
1577
  var _a, _b;
1800
- const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile } = props, restProps = __rest(props, ["registerHighlighter", "data", "diffViewTheme", "diffFile"]);
1578
+ const { registerHighlighter, data, diffViewTheme, diffFile: _diffFile, ...restProps } = props;
1801
1579
  const diffFile = useMemo(() => {
1802
1580
  var _a, _b, _c, _d, _e, _f;
1803
1581
  if (_diffFile) {
@@ -1814,8 +1592,10 @@ const DiffViewWithRef = (props, ref) => {
1814
1592
  return null;
1815
1593
  }, [data, _diffFile]);
1816
1594
  const diffFileRef = useRef(diffFile);
1817
- const wrapperRef = useRef();
1595
+ const wrapperRef = useRef(null);
1596
+ // eslint-disable-next-line react-hooks/refs
1818
1597
  if (diffFileRef.current && diffFileRef.current !== diffFile) {
1598
+ // eslint-disable-next-line react-hooks/refs
1819
1599
  (_b = (_a = diffFileRef.current).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
1820
1600
  diffFileRef.current = diffFile;
1821
1601
  }
@@ -1872,12 +1652,225 @@ const DiffViewWithRef = (props, ref) => {
1872
1652
  useImperativeHandle(ref, () => ({ getDiffFileInstance: () => diffFile }), [diffFile]);
1873
1653
  if (!diffFile)
1874
1654
  return null;
1875
- return (React.createElement(MemoedInternalDiffView, Object.assign({ key: diffFile.getId() }, restProps, { diffFile: diffFile, isMounted: isMounted, wrapperRef: wrapperRef, diffViewTheme: diffViewTheme, diffViewMode: restProps.diffViewMode || DiffModeEnum.SplitGitHub, diffViewFontSize: restProps.diffViewFontSize || 14 })));
1655
+ return (jsx(MemoedInternalDiffView, { ...restProps, diffFile: diffFile, isMounted: isMounted, wrapperRef: wrapperRef, diffViewTheme: diffViewTheme, diffViewMode: restProps.diffViewMode || DiffModeEnum.SplitGitHub, diffViewFontSize: restProps.diffViewFontSize || 14 }, diffFile.getId()));
1876
1656
  };
1877
1657
  const InnerDiffView = forwardRef(DiffViewWithRef);
1878
1658
  InnerDiffView.displayName = "DiffView";
1879
1659
  const DiffView = InnerDiffView;
1880
- const version = "0.1.3";
1660
+ const version = "0.1.5";
1661
+
1662
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
1663
+ const useCallbackRef = (cb) => {
1664
+ const cbRef = useRef(cb);
1665
+ // eslint-disable-next-line react-hooks/refs
1666
+ cbRef.current = cb;
1667
+ return useCallback((...args) => {
1668
+ var _a;
1669
+ return (_a = cbRef.current) === null || _a === void 0 ? void 0 : _a.call(cbRef, ...args);
1670
+ }, []);
1671
+ };
1672
+
1673
+ const useUpdateEffect = (effect, deps) => {
1674
+ const isMounted = useRef(false);
1675
+ useEffect(() => {
1676
+ if (isMounted.current) {
1677
+ return effect();
1678
+ }
1679
+ isMounted.current = true;
1680
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1681
+ }, deps);
1682
+ };
1683
+
1684
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
1685
+ const InternalDiffViewWithMultiSelect = (props, ref) => {
1686
+ const { enableMultiSelect = true, extendData, onMultiSelectComplete, onMultiSelectChange, scopeMultiSelectToHunk, renderWidgetLine, onAddWidgetClick, diffViewMode = DiffModeEnum.SplitGitHub, ...restProps } = props;
1687
+ const memoSelectChange = useCallbackRef(onMultiSelectChange);
1688
+ const memoSelectComplete = useCallbackRef(onMultiSelectComplete);
1689
+ const memoScopeSelectToHunk = useCallbackRef(scopeMultiSelectToHunk);
1690
+ const containerRef = useRef(null);
1691
+ const diffViewRef = useRef(null);
1692
+ const managerRef = useRef(null);
1693
+ const multiResultRef = useRef(undefined);
1694
+ const isUnifiedMode = !(diffViewMode & DiffModeEnum.Split);
1695
+ const updateMultiResult = useCallback((result) => {
1696
+ var _a;
1697
+ multiResultRef.current = result;
1698
+ (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.setPreselectedLines(result || { old: [], new: [] });
1699
+ }, []);
1700
+ useUpdateEffect(() => {
1701
+ updateMultiResult(undefined);
1702
+ }, [props.diffViewWrap, diffViewMode]);
1703
+ const getDiffFile = useCallback(() => {
1704
+ var _a, _b;
1705
+ return (_b = (_a = diffViewRef.current) === null || _a === void 0 ? void 0 : _a.getDiffFileInstance()) !== null && _b !== void 0 ? _b : null;
1706
+ }, []);
1707
+ useEffect(() => {
1708
+ var _a;
1709
+ const container = containerRef.current;
1710
+ const diffFile = getDiffFile();
1711
+ if (!container || !diffFile || !enableMultiSelect) {
1712
+ (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
1713
+ managerRef.current = null;
1714
+ return;
1715
+ }
1716
+ const managerOptions = {
1717
+ enabled: enableMultiSelect,
1718
+ isUnifiedMode,
1719
+ selectedClassName: multiSelectClassNames.selected,
1720
+ onSelectionChange: (range, state) => {
1721
+ var _a, _b;
1722
+ if (state.isSelecting) {
1723
+ (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.classList.add(multiSelectClassNames.selecting);
1724
+ }
1725
+ else {
1726
+ (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.classList.remove(multiSelectClassNames.selecting);
1727
+ }
1728
+ if (state.isSelecting && multiResultRef.current) {
1729
+ updateMultiResult(undefined);
1730
+ }
1731
+ memoSelectChange === null || memoSelectChange === void 0 ? void 0 : memoSelectChange(range, state);
1732
+ },
1733
+ onSelectionComplete: (result) => {
1734
+ var _a;
1735
+ (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.classList.remove(multiSelectClassNames.selecting);
1736
+ if (result && result.lines.length > 0) {
1737
+ memoSelectComplete === null || memoSelectComplete === void 0 ? void 0 : memoSelectComplete(result);
1738
+ const finalResult = {
1739
+ [result.range.side]: [result.range.startLineNumber, result.range.endLineNumber],
1740
+ };
1741
+ updateMultiResult(finalResult);
1742
+ }
1743
+ else {
1744
+ updateMultiResult(undefined);
1745
+ }
1746
+ },
1747
+ scopeToHunk: memoScopeSelectToHunk,
1748
+ };
1749
+ if (managerRef.current) {
1750
+ managerRef.current.updateContainer(container);
1751
+ managerRef.current.updateDiffFile(diffFile);
1752
+ managerRef.current.updateOptions(managerOptions);
1753
+ }
1754
+ else {
1755
+ managerRef.current = createDiffMultiSelectManager(container, diffFile, managerOptions);
1756
+ }
1757
+ return () => {
1758
+ var _a;
1759
+ (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
1760
+ managerRef.current = null;
1761
+ };
1762
+ }, [
1763
+ enableMultiSelect,
1764
+ isUnifiedMode,
1765
+ memoScopeSelectToHunk,
1766
+ memoSelectChange,
1767
+ memoSelectComplete,
1768
+ getDiffFile,
1769
+ updateMultiResult,
1770
+ ]);
1771
+ const convertedExtendData = useMemo(() => {
1772
+ if (!extendData)
1773
+ return undefined;
1774
+ const result = {};
1775
+ if (extendData.oldFile) {
1776
+ result.oldFile = {};
1777
+ for (const [key, value] of Object.entries(extendData.oldFile)) {
1778
+ result.oldFile[key] = { data: value.data };
1779
+ }
1780
+ }
1781
+ if (extendData.newFile) {
1782
+ result.newFile = {};
1783
+ for (const [key, value] of Object.entries(extendData.newFile)) {
1784
+ result.newFile[key] = { data: value.data };
1785
+ }
1786
+ }
1787
+ return result;
1788
+ }, [extendData]);
1789
+ const internalRenderWidgetLine = useCallback(({ lineNumber, side, diffFile, onClose, }) => {
1790
+ var _a;
1791
+ if (!renderWidgetLine)
1792
+ return null;
1793
+ const sideKey = side === SplitSide.old ? "old" : "new";
1794
+ const multiResultItem = (_a = multiResultRef.current) === null || _a === void 0 ? void 0 : _a[sideKey];
1795
+ const fromLineNumber = multiResultItem ? Math.min(...multiResultItem) : lineNumber;
1796
+ const toLineNumber = multiResultItem ? Math.max(...multiResultItem) : lineNumber;
1797
+ return renderWidgetLine({
1798
+ lineNumber: toLineNumber,
1799
+ fromLineNumber,
1800
+ side,
1801
+ diffFile,
1802
+ onClose,
1803
+ });
1804
+ }, [renderWidgetLine]);
1805
+ const getSelectionResult = useCallback(() => {
1806
+ var _a, _b;
1807
+ return (_b = (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.getSelectionResult()) !== null && _b !== void 0 ? _b : null;
1808
+ }, []);
1809
+ const getSelectionState = useCallback(() => {
1810
+ var _a, _b;
1811
+ return ((_b = (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.getState()) !== null && _b !== void 0 ? _b : {
1812
+ isSelecting: false,
1813
+ startInfo: null,
1814
+ currentRange: null,
1815
+ });
1816
+ }, []);
1817
+ const clearSelection = useCallback(() => {
1818
+ var _a;
1819
+ (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.clearSelection();
1820
+ }, []);
1821
+ const setPreselectedLines = updateMultiResult;
1822
+ useImperativeHandle(ref, () => ({
1823
+ getDiffFileInstance: getDiffFile,
1824
+ getSelectionResult,
1825
+ getSelectionState,
1826
+ clearSelection,
1827
+ setPreselectedLines,
1828
+ }), [getDiffFile, getSelectionResult, getSelectionState, clearSelection, setPreselectedLines]);
1829
+ return (jsx("div", { ref: containerRef, className: "diff-multiselect-wrapper", children: jsx(DiffView, { ref: diffViewRef, ...restProps, diffViewMode: diffViewMode, extendData: convertedExtendData, onAddWidgetClick: (lineNum, side) => {
1830
+ var _a;
1831
+ (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.clearSelection();
1832
+ const multiResult = multiResultRef.current;
1833
+ if (multiResult) {
1834
+ const currentSide = SplitSide[side];
1835
+ const currentMultiResult = multiResult[currentSide];
1836
+ const otherSide = currentSide === "new" ? "old" : "new";
1837
+ const otherMultiResult = multiResult[otherSide];
1838
+ if (currentMultiResult === null || currentMultiResult === void 0 ? void 0 : currentMultiResult.length) {
1839
+ const max = Math.max(...currentMultiResult);
1840
+ if (max === lineNum) {
1841
+ const finalResult = { [currentSide]: currentMultiResult };
1842
+ updateMultiResult(finalResult);
1843
+ onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({ lineNumber: max, fromLineNumber: Math.min(...currentMultiResult), side });
1844
+ return;
1845
+ }
1846
+ }
1847
+ if (isUnifiedMode && (otherMultiResult === null || otherMultiResult === void 0 ? void 0 : otherMultiResult.length)) {
1848
+ const max = Math.max(...otherMultiResult);
1849
+ const diffFile = getDiffFile();
1850
+ const index = diffFile.getUnifiedLineIndexByLineNumber(lineNum, side);
1851
+ const unifiedItem = diffFile.getUnifiedLine(index);
1852
+ const otherSideLineNum = side === SplitSide.old ? unifiedItem.newLineNumber : unifiedItem.oldLineNumber;
1853
+ if (max === otherSideLineNum) {
1854
+ const finalResult = { [otherSide]: otherMultiResult };
1855
+ updateMultiResult(finalResult);
1856
+ onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({
1857
+ lineNumber: max,
1858
+ fromLineNumber: Math.min(...otherMultiResult),
1859
+ side: otherSide === "old" ? SplitSide.old : SplitSide.new,
1860
+ });
1861
+ return;
1862
+ }
1863
+ }
1864
+ updateMultiResult(undefined);
1865
+ onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({ lineNumber: lineNum, fromLineNumber: lineNum, side });
1866
+ }
1867
+ else {
1868
+ updateMultiResult(undefined);
1869
+ onAddWidgetClick === null || onAddWidgetClick === void 0 ? void 0 : onAddWidgetClick({ lineNumber: lineNum, fromLineNumber: lineNum, side });
1870
+ }
1871
+ }, renderWidgetLine: renderWidgetLine ? internalRenderWidgetLine : undefined }) }));
1872
+ };
1873
+ const DiffViewWithMultiSelect = forwardRef(InternalDiffViewWithMultiSelect);
1881
1874
 
1882
- export { DiffModeEnum, DiffView, version };
1875
+ export { DiffModeEnum, DiffView, DiffViewWithMultiSelect, version };
1883
1876
  //# sourceMappingURL=index.mjs.map