@researai/deepscientist 1.5.15 → 1.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +385 -104
  2. package/bin/ds.js +1241 -110
  3. package/docs/en/00_QUICK_START.md +100 -19
  4. package/docs/en/01_SETTINGS_REFERENCE.md +34 -1
  5. package/docs/en/02_START_RESEARCH_GUIDE.md +7 -0
  6. package/docs/en/05_TUI_GUIDE.md +6 -0
  7. package/docs/en/06_RUNTIME_AND_CANVAS.md +4 -3
  8. package/docs/en/09_DOCTOR.md +25 -8
  9. package/docs/en/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +63 -13
  10. package/docs/en/15_CODEX_PROVIDER_SETUP.md +37 -11
  11. package/docs/en/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  12. package/docs/en/19_LOCAL_BROWSER_AUTH.md +70 -0
  13. package/docs/en/20_WORKSPACE_MODES_GUIDE.md +250 -0
  14. package/docs/en/21_LOCAL_MODEL_BACKENDS_GUIDE.md +283 -0
  15. package/docs/en/91_DEVELOPMENT.md +237 -0
  16. package/docs/en/README.md +24 -2
  17. package/docs/zh/00_QUICK_START.md +89 -19
  18. package/docs/zh/01_SETTINGS_REFERENCE.md +34 -1
  19. package/docs/zh/02_START_RESEARCH_GUIDE.md +7 -0
  20. package/docs/zh/05_TUI_GUIDE.md +6 -0
  21. package/docs/zh/09_DOCTOR.md +26 -9
  22. package/docs/zh/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +63 -13
  23. package/docs/zh/15_CODEX_PROVIDER_SETUP.md +37 -11
  24. package/docs/zh/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  25. package/docs/zh/19_LOCAL_BROWSER_AUTH.md +68 -0
  26. package/docs/zh/20_WORKSPACE_MODES_GUIDE.md +251 -0
  27. package/docs/zh/21_LOCAL_MODEL_BACKENDS_GUIDE.md +281 -0
  28. package/docs/zh/README.md +24 -2
  29. package/install.sh +46 -4
  30. package/package.json +2 -1
  31. package/pyproject.toml +1 -1
  32. package/src/deepscientist/__init__.py +1 -1
  33. package/src/deepscientist/acp/envelope.py +6 -0
  34. package/src/deepscientist/artifact/service.py +647 -22
  35. package/src/deepscientist/bash_exec/service.py +234 -9
  36. package/src/deepscientist/bridges/connectors.py +8 -2
  37. package/src/deepscientist/cli.py +115 -19
  38. package/src/deepscientist/codex_cli_compat.py +367 -22
  39. package/src/deepscientist/config/models.py +2 -1
  40. package/src/deepscientist/config/service.py +183 -13
  41. package/src/deepscientist/daemon/api/handlers.py +255 -31
  42. package/src/deepscientist/daemon/api/router.py +9 -0
  43. package/src/deepscientist/daemon/app.py +1146 -105
  44. package/src/deepscientist/diagnostics/__init__.py +6 -0
  45. package/src/deepscientist/diagnostics/runner_failures.py +130 -0
  46. package/src/deepscientist/doctor.py +207 -3
  47. package/src/deepscientist/gitops/__init__.py +10 -1
  48. package/src/deepscientist/gitops/diff.py +129 -0
  49. package/src/deepscientist/gitops/service.py +4 -1
  50. package/src/deepscientist/mcp/server.py +39 -0
  51. package/src/deepscientist/prompts/builder.py +275 -34
  52. package/src/deepscientist/quest/layout.py +15 -2
  53. package/src/deepscientist/quest/service.py +707 -55
  54. package/src/deepscientist/quest/stage_views.py +6 -1
  55. package/src/deepscientist/runners/codex.py +143 -43
  56. package/src/deepscientist/shared.py +19 -0
  57. package/src/deepscientist/skills/__init__.py +2 -2
  58. package/src/deepscientist/skills/installer.py +196 -5
  59. package/src/deepscientist/skills/registry.py +66 -0
  60. package/src/prompts/connectors/qq.md +18 -8
  61. package/src/prompts/connectors/weixin.md +16 -6
  62. package/src/prompts/contracts/shared_interaction.md +14 -2
  63. package/src/prompts/system.md +23 -5
  64. package/src/prompts/system_copilot.md +56 -0
  65. package/src/skills/analysis-campaign/SKILL.md +1 -0
  66. package/src/skills/baseline/SKILL.md +8 -0
  67. package/src/skills/decision/SKILL.md +8 -0
  68. package/src/skills/experiment/SKILL.md +8 -0
  69. package/src/skills/figure-polish/SKILL.md +1 -0
  70. package/src/skills/finalize/SKILL.md +1 -0
  71. package/src/skills/idea/SKILL.md +1 -0
  72. package/src/skills/intake-audit/SKILL.md +8 -0
  73. package/src/skills/mentor/SKILL.md +217 -0
  74. package/src/skills/mentor/references/correction-rules.md +210 -0
  75. package/src/skills/mentor/references/knowledge-profile.md +91 -0
  76. package/src/skills/mentor/references/persona-profile.md +138 -0
  77. package/src/skills/mentor/references/taste-profile.md +128 -0
  78. package/src/skills/mentor/references/thought-style-profile.md +138 -0
  79. package/src/skills/mentor/references/work-profile.md +289 -0
  80. package/src/skills/mentor/references/workflow-profile.md +240 -0
  81. package/src/skills/optimize/SKILL.md +1 -0
  82. package/src/skills/rebuttal/SKILL.md +1 -0
  83. package/src/skills/review/SKILL.md +1 -0
  84. package/src/skills/scout/SKILL.md +8 -0
  85. package/src/skills/write/SKILL.md +1 -0
  86. package/src/tui/dist/app/AppContainer.js +19 -11
  87. package/src/tui/dist/index.js +4 -1
  88. package/src/tui/dist/lib/api.js +33 -3
  89. package/src/tui/package.json +1 -1
  90. package/src/ui/dist/assets/AiManusChatView-Bv-Z8YpU.js +204 -0
  91. package/src/ui/dist/assets/AnalysisPlugin-BCKAfjba.js +1 -0
  92. package/src/ui/dist/assets/CliPlugin-BCKcpc35.js +109 -0
  93. package/src/ui/dist/assets/CodeEditorPlugin-DbOfSJ8K.js +2 -0
  94. package/src/ui/dist/assets/CodeViewerPlugin-CbaFRrUU.js +270 -0
  95. package/src/ui/dist/assets/DocViewerPlugin-DAjLVeQD.js +7 -0
  96. package/src/ui/dist/assets/GitCommitViewerPlugin-CIUqbUDO.js +1 -0
  97. package/src/ui/dist/assets/GitDiffViewerPlugin-CQACjoAA.js +6 -0
  98. package/src/ui/dist/assets/GitSnapshotViewer-0r4nLPke.js +30 -0
  99. package/src/ui/dist/assets/ImageViewerPlugin-nBOmI2v_.js +26 -0
  100. package/src/ui/dist/assets/LabCopilotPanel-BHxOxF4z.js +14 -0
  101. package/src/ui/dist/assets/LabPlugin-BKoZGs95.js +22 -0
  102. package/src/ui/dist/assets/LatexPlugin-ZwtV8pIp.js +25 -0
  103. package/src/ui/dist/assets/MarkdownViewerPlugin-DKqVfKyW.js +128 -0
  104. package/src/ui/dist/assets/MarketplacePlugin-BwxStZ9D.js +13 -0
  105. package/src/ui/dist/assets/NotebookEditor-BEQhaQbt.js +81 -0
  106. package/src/ui/dist/assets/{NotebookEditor-CccQYZjX.css → NotebookEditor-BHH8rdGj.css} +1 -1
  107. package/src/ui/dist/assets/NotebookEditor-BOr3x3Ej.css +1 -0
  108. package/src/ui/dist/assets/NotebookEditor-DB9N_T9q.js +361 -0
  109. package/src/ui/dist/assets/PdfLoader-Cy5jtWrr.css +1 -0
  110. package/src/ui/dist/assets/PdfLoader-eWBONbQP.js +16 -0
  111. package/src/ui/dist/assets/PdfMarkdownPlugin-D22YOZL3.js +1 -0
  112. package/src/ui/dist/assets/PdfViewerPlugin-c-RK9DLM.js +17 -0
  113. package/src/ui/dist/assets/PdfViewerPlugin-nwwE-fjJ.css +1 -0
  114. package/src/ui/dist/assets/SearchPlugin-CxF9ytAx.js +16 -0
  115. package/src/ui/dist/assets/SearchPlugin-DA4en4hK.css +1 -0
  116. package/src/ui/dist/assets/TextViewerPlugin-C5xqeeUH.js +54 -0
  117. package/src/ui/dist/assets/VNCViewer-BoLGLnHz.js +11 -0
  118. package/src/ui/dist/assets/bot-DREQOxzP.js +6 -0
  119. package/src/ui/dist/assets/browser-CTB2jwNe.js +8 -0
  120. package/src/ui/dist/assets/chevron-up-C9Qpx4DE.js +6 -0
  121. package/src/ui/dist/assets/code-WlFHE7z_.js +6 -0
  122. package/src/ui/dist/assets/file-content-BZMz3RYp.js +1 -0
  123. package/src/ui/dist/assets/file-diff-panel-CQhw0jS2.js +1 -0
  124. package/src/ui/dist/assets/file-jump-queue-DA-SdG__.js +1 -0
  125. package/src/ui/dist/assets/file-socket-CfQPKQKj.js +1 -0
  126. package/src/ui/dist/assets/git-commit-horizontal-DxZ8DCZh.js +6 -0
  127. package/src/ui/dist/assets/image-Bgl4VIyx.js +6 -0
  128. package/src/ui/dist/assets/index-BpV6lusQ.css +33 -0
  129. package/src/ui/dist/assets/index-CBNVuWcP.js +2496 -0
  130. package/src/ui/dist/assets/index-CwNu1aH4.js +11 -0
  131. package/src/ui/dist/assets/index-DrUnlf6K.js +1 -0
  132. package/src/ui/dist/assets/index-NW-h8VzN.js +1 -0
  133. package/src/ui/dist/assets/monaco-CiHMMNH_.js +1 -0
  134. package/src/ui/dist/assets/pdf-effect-queue-J8OnM0jE.js +6 -0
  135. package/src/ui/dist/assets/plugin-monaco-C8UgLomw.js +19 -0
  136. package/src/ui/dist/assets/plugin-notebook-HbW2K-1c.js +169 -0
  137. package/src/ui/dist/assets/plugin-pdf-CR8hgQBV.js +357 -0
  138. package/src/ui/dist/assets/plugin-terminal-MXFIPun8.js +227 -0
  139. package/src/ui/dist/assets/popover-CLc0pPP8.js +1 -0
  140. package/src/ui/dist/assets/project-sync-C9IdzdZW.js +1 -0
  141. package/src/ui/dist/assets/select-Cs2PmzwL.js +11 -0
  142. package/src/ui/dist/assets/sigma-ClKcHAXm.js +6 -0
  143. package/src/ui/dist/assets/trash-DwpbFr3w.js +11 -0
  144. package/src/ui/dist/assets/useCliAccess-NQ8m0Let.js +1 -0
  145. package/src/ui/dist/assets/useFileDiffOverlay-FuhcnKiw.js +1 -0
  146. package/src/ui/dist/assets/wrap-text-BC-Hltpd.js +11 -0
  147. package/src/ui/dist/assets/zoom-out-E_gaeAxL.js +11 -0
  148. package/src/ui/dist/index.html +5 -2
  149. package/src/ui/dist/assets/AiManusChatView-DDjbFnbt.js +0 -26597
  150. package/src/ui/dist/assets/AnalysisPlugin-Yb5IdmaU.js +0 -123
  151. package/src/ui/dist/assets/CliPlugin-e64sreyu.js +0 -31037
  152. package/src/ui/dist/assets/CodeEditorPlugin-C4D2TIkU.js +0 -427
  153. package/src/ui/dist/assets/CodeViewerPlugin-BVoNZIvC.js +0 -905
  154. package/src/ui/dist/assets/DocViewerPlugin-CLChbllo.js +0 -278
  155. package/src/ui/dist/assets/GitDiffViewerPlugin-C4xeFyFQ.js +0 -2661
  156. package/src/ui/dist/assets/ImageViewerPlugin-OiMUAcLi.js +0 -500
  157. package/src/ui/dist/assets/LabCopilotPanel-BjD2ThQF.js +0 -4104
  158. package/src/ui/dist/assets/LabPlugin-DQPg-NrB.js +0 -2677
  159. package/src/ui/dist/assets/LatexPlugin-CI05XAV9.js +0 -1792
  160. package/src/ui/dist/assets/MarkdownViewerPlugin-DpeBLYZf.js +0 -308
  161. package/src/ui/dist/assets/MarketplacePlugin-DolE58Q2.js +0 -413
  162. package/src/ui/dist/assets/NotebookEditor-7Qm2rSWD.js +0 -4214
  163. package/src/ui/dist/assets/NotebookEditor-C1kWaxKi.js +0 -84873
  164. package/src/ui/dist/assets/NotebookEditor-C3VQ7ylN.css +0 -1405
  165. package/src/ui/dist/assets/PdfLoader-BfOHw8Zw.js +0 -25468
  166. package/src/ui/dist/assets/PdfLoader-C-Y707R3.css +0 -49
  167. package/src/ui/dist/assets/PdfMarkdownPlugin-BulDREv1.js +0 -409
  168. package/src/ui/dist/assets/PdfViewerPlugin-C-daaOaL.js +0 -3095
  169. package/src/ui/dist/assets/PdfViewerPlugin-DQ11QcSf.css +0 -3627
  170. package/src/ui/dist/assets/SearchPlugin-CjpaiJ3A.js +0 -741
  171. package/src/ui/dist/assets/SearchPlugin-DDMrGDkh.css +0 -379
  172. package/src/ui/dist/assets/TextViewerPlugin-BxIyqPQC.js +0 -472
  173. package/src/ui/dist/assets/VNCViewer-HAg9mF7M.js +0 -18821
  174. package/src/ui/dist/assets/awareness-C0NPR2Dj.js +0 -292
  175. package/src/ui/dist/assets/bot-0DYntytV.js +0 -21
  176. package/src/ui/dist/assets/browser-BAcuE0Xj.js +0 -2895
  177. package/src/ui/dist/assets/code-B20Slj_w.js +0 -17
  178. package/src/ui/dist/assets/file-content-DT24KFma.js +0 -377
  179. package/src/ui/dist/assets/file-diff-panel-DK13YPql.js +0 -92
  180. package/src/ui/dist/assets/file-jump-queue-r5XKgJEV.js +0 -16
  181. package/src/ui/dist/assets/file-socket-B4T2o4nR.js +0 -58
  182. package/src/ui/dist/assets/function-B5QZkkHC.js +0 -1895
  183. package/src/ui/dist/assets/image-DSeR_sDS.js +0 -18
  184. package/src/ui/dist/assets/index-BrFje2Uk.js +0 -120
  185. package/src/ui/dist/assets/index-BwRJaoTl.js +0 -25
  186. package/src/ui/dist/assets/index-D_E4281X.js +0 -221322
  187. package/src/ui/dist/assets/index-DnYB3xb1.js +0 -159
  188. package/src/ui/dist/assets/index-G7AcWcMu.css +0 -12594
  189. package/src/ui/dist/assets/monaco-LExaAN3Y.js +0 -623
  190. package/src/ui/dist/assets/pdf-effect-queue-BJk5okWJ.js +0 -47
  191. package/src/ui/dist/assets/pdf_viewer-e0g1is2C.js +0 -8206
  192. package/src/ui/dist/assets/popover-D3Gg_FoV.js +0 -476
  193. package/src/ui/dist/assets/project-sync-C_ygLlVU.js +0 -297
  194. package/src/ui/dist/assets/select-CpAK6uWm.js +0 -1690
  195. package/src/ui/dist/assets/sigma-DEccaSgk.js +0 -22
  196. package/src/ui/dist/assets/square-check-big-uUfyVsbD.js +0 -17
  197. package/src/ui/dist/assets/trash-CXvwwSe8.js +0 -32
  198. package/src/ui/dist/assets/useCliAccess-Bnop4mgR.js +0 -957
  199. package/src/ui/dist/assets/useFileDiffOverlay-B8eUAX0I.js +0 -53
  200. package/src/ui/dist/assets/wrap-text-9vbOBpkW.js +0 -35
  201. package/src/ui/dist/assets/yjs-DncrqiZ8.js +0 -11243
  202. package/src/ui/dist/assets/zoom-out-BgVMmOW4.js +0 -34
@@ -1,2661 +0,0 @@
1
- import { w as createLucideIcon, aK as inferWorkspaceContentKindFromMetadata, v as BUILTIN_PLUGINS, aL as getPluginIdFromMimeType, aM as getPluginIdFromExtension, r as reactExports, j as jsxRuntimeExports, u as useI18n, b as cn, a as useWorkspaceSurfaceStore, aN as useQuery, k as FileText, aO as Button, g as RefreshCw, aP as buildQuestFileNodeFromDocument, W as toFilesResourcePath, aQ as client } from './index-D_E4281X.js';
2
- import ImageViewerPlugin from './ImageViewerPlugin-OiMUAcLi.js';
3
- import MarkdownViewerPlugin from './MarkdownViewerPlugin-DpeBLYZf.js';
4
- import { N as NotebookEditor } from './NotebookEditor-7Qm2rSWD.js';
5
- import PdfViewerPlugin from './PdfViewerPlugin-C-daaOaL.js';
6
- import './image-DSeR_sDS.js';
7
- import './zoom-out-BgVMmOW4.js';
8
- import './code-B20Slj_w.js';
9
- import './NotebookEditor-C1kWaxKi.js';
10
- import './function-B5QZkkHC.js';
11
- import './yjs-DncrqiZ8.js';
12
- import './project-sync-C_ygLlVU.js';
13
- import './square-check-big-uUfyVsbD.js';
14
- import './popover-D3Gg_FoV.js';
15
- import './trash-CXvwwSe8.js';
16
- import './sigma-DEccaSgk.js';
17
- import './useFileDiffOverlay-B8eUAX0I.js';
18
- import './file-diff-panel-DK13YPql.js';
19
- import './file-socket-B4T2o4nR.js';
20
- import './pdf-effect-queue-BJk5okWJ.js';
21
- import './PdfLoader-BfOHw8Zw.js';
22
- import './index-BwRJaoTl.js';
23
-
24
- /**
25
- * @license lucide-react v0.511.0 - ISC
26
- *
27
- * This source code is licensed under the ISC license.
28
- * See the LICENSE file in the root directory of this source tree.
29
- */
30
-
31
-
32
- const __iconNode = [
33
- ["circle", { cx: "18", cy: "18", r: "3", key: "1xkwt0" }],
34
- ["circle", { cx: "6", cy: "6", r: "3", key: "1lh9wr" }],
35
- ["path", { d: "M13 6h3a2 2 0 0 1 2 2v7", key: "1yeb86" }],
36
- ["path", { d: "M11 18H8a2 2 0 0 1-2-2V9", key: "19pyzm" }]
37
- ];
38
- const GitCompare = createLucideIcon("git-compare", __iconNode);
39
-
40
- function basename(path) {
41
- const raw = String(path || "").trim();
42
- if (!raw) return "";
43
- const parts = raw.split("/").filter(Boolean);
44
- return parts[parts.length - 1] || raw;
45
- }
46
- function detectSnapshotPluginId(document) {
47
- const fileName = basename(document?.path);
48
- const mimeType = String(document?.mime_type || "").trim();
49
- return (mimeType ? getPluginIdFromMimeType(mimeType) : void 0) || (fileName ? getPluginIdFromExtension(fileName) : void 0) || null;
50
- }
51
- function inferSnapshotPreviewKind(document) {
52
- const pluginId = detectSnapshotPluginId(document);
53
- const fileName = basename(document?.path).toLowerCase();
54
- if (fileName.endsWith(".md") || fileName.endsWith(".markdown") || fileName.endsWith(".mdx")) {
55
- return "markdown";
56
- }
57
- if (pluginId === BUILTIN_PLUGINS.PDF_VIEWER) return "pdf";
58
- if (pluginId === BUILTIN_PLUGINS.IMAGE_VIEWER) return "image";
59
- if (pluginId === BUILTIN_PLUGINS.NOTEBOOK) return "notebook";
60
- return "plain";
61
- }
62
- function inferSnapshotContentKind(document) {
63
- return inferWorkspaceContentKindFromMetadata({
64
- mimeType: document?.mime_type,
65
- resourceName: document?.path,
66
- resourcePath: document?.path
67
- }) || "file";
68
- }
69
- function formatGitDiffPathLabel(path, oldPath, fallback = "Diff") {
70
- if (path && oldPath && path !== oldPath) {
71
- return `${oldPath} → ${path}`;
72
- }
73
- return path || fallback;
74
- }
75
-
76
- function ownKeys(e, r) {
77
- var t = Object.keys(e);
78
- if (Object.getOwnPropertySymbols) {
79
- var o = Object.getOwnPropertySymbols(e);
80
- r && (o = o.filter(function(r2) {
81
- return Object.getOwnPropertyDescriptor(e, r2).enumerable;
82
- })), t.push.apply(t, o);
83
- }
84
- return t;
85
- }
86
- function _objectSpread2(e) {
87
- for (var r = 1; r < arguments.length; r++) {
88
- var t = null != arguments[r] ? arguments[r] : {};
89
- r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
90
- _defineProperty$1(e, r2, t[r2]);
91
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
92
- Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
93
- });
94
- }
95
- return e;
96
- }
97
- function _defineProperty$1(obj, key, value) {
98
- return (key = function(arg) {
99
- var key2 = function(input, hint) {
100
- if ("object" != typeof input || null === input) return input;
101
- var prim = input[Symbol.toPrimitive];
102
- if (void 0 !== prim) {
103
- var res = prim.call(input, hint);
104
- if ("object" != typeof res) return res;
105
- throw new TypeError("@@toPrimitive must return a primitive value.");
106
- }
107
- return ("string" === hint ? String : Number)(input);
108
- }(arg, "string");
109
- return "symbol" == typeof key2 ? key2 : String(key2);
110
- }(key)) in obj ? Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }) : obj[key] = value, obj;
111
- }
112
- function _objectWithoutProperties(source, excluded) {
113
- if (null == source) return {};
114
- var key, i, target = function(source2, excluded2) {
115
- if (null == source2) return {};
116
- var key2, i2, target2 = {}, sourceKeys = Object.keys(source2);
117
- for (i2 = 0; i2 < sourceKeys.length; i2++) key2 = sourceKeys[i2], excluded2.indexOf(key2) >= 0 || (target2[key2] = source2[key2]);
118
- return target2;
119
- }(source, excluded);
120
- if (Object.getOwnPropertySymbols) {
121
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
122
- for (i = 0; i < sourceSymbolKeys.length; i++) key = sourceSymbolKeys[i], excluded.indexOf(key) >= 0 || Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
123
- }
124
- return target;
125
- }
126
- function _slicedToArray(arr, i) {
127
- return _arrayWithHoles(arr) || function(r, l) {
128
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
129
- if (null != t) {
130
- var e, n, i2, u, a = [], f = true, o = false;
131
- try {
132
- if (i2 = (t = t.call(r)).next, 0 === l) {
133
- if (Object(t) !== t) return;
134
- f = false;
135
- } else for (; !(f = (e = i2.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
136
- } catch (r2) {
137
- o = true, n = r2;
138
- } finally {
139
- try {
140
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
141
- } finally {
142
- if (o) throw n;
143
- }
144
- }
145
- return a;
146
- }
147
- }(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
148
- }
149
- function _toArray(arr) {
150
- return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
151
- }
152
- function _toConsumableArray(arr) {
153
- return function(arr2) {
154
- if (Array.isArray(arr2)) return _arrayLikeToArray(arr2);
155
- }(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || function() {
156
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
157
- }();
158
- }
159
- function _arrayWithHoles(arr) {
160
- if (Array.isArray(arr)) return arr;
161
- }
162
- function _iterableToArray(iter) {
163
- if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
164
- }
165
- function _unsupportedIterableToArray(o, minLen) {
166
- if (o) {
167
- if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
168
- var n = Object.prototype.toString.call(o).slice(8, -1);
169
- return "Object" === n && o.constructor && (n = o.constructor.name), "Map" === n || "Set" === n ? Array.from(o) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? _arrayLikeToArray(o, minLen) : void 0;
170
- }
171
- }
172
- function _arrayLikeToArray(arr, len) {
173
- (null == len || len > arr.length) && (len = arr.length);
174
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
175
- return arr2;
176
- }
177
- function _nonIterableRest() {
178
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
179
- }
180
- function _createForOfIteratorHelper(o, allowArrayLike) {
181
- var it = "undefined" != typeof Symbol && o[Symbol.iterator] || o["@@iterator"];
182
- if (!it) {
183
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) {
184
- it && (o = it);
185
- var i = 0, F = function() {
186
- };
187
- return { s: F, n: function() {
188
- return i >= o.length ? { done: true } : { done: false, value: o[i++] };
189
- }, e: function(e) {
190
- throw e;
191
- }, f: F };
192
- }
193
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
194
- }
195
- var err, normalCompletion = true, didErr = false;
196
- return { s: function() {
197
- it = it.call(o);
198
- }, n: function() {
199
- var step = it.next();
200
- return normalCompletion = step.done, step;
201
- }, e: function(e) {
202
- didErr = true, err = e;
203
- }, f: function() {
204
- try {
205
- normalCompletion || null == it.return || it.return();
206
- } finally {
207
- if (didErr) throw err;
208
- }
209
- } };
210
- }
211
- var commonjsGlobal = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
212
- function createCommonjsModule(fn, module) {
213
- return fn(module = { exports: {} }, module.exports), module.exports;
214
- }
215
- var classnames = createCommonjsModule(function(module) {
216
- /*!
217
- Copyright (c) 2018 Jed Watson.
218
- Licensed under the MIT License (MIT), see
219
- http://jedwatson.github.io/classnames
220
- */
221
- !function() {
222
- var hasOwn = {}.hasOwnProperty;
223
- function classNames() {
224
- for (var classes = [], i = 0; i < arguments.length; i++) {
225
- var arg = arguments[i];
226
- if (arg) {
227
- var argType = typeof arg;
228
- if ("string" === argType || "number" === argType) classes.push(arg);
229
- else if (Array.isArray(arg)) {
230
- if (arg.length) {
231
- var inner = classNames.apply(null, arg);
232
- inner && classes.push(inner);
233
- }
234
- } else if ("object" === argType) {
235
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
236
- classes.push(arg.toString());
237
- continue;
238
- }
239
- for (var key in arg) hasOwn.call(arg, key) && arg[key] && classes.push(key);
240
- }
241
- }
242
- }
243
- return classes.join(" ");
244
- }
245
- module.exports ? (classNames.default = classNames, module.exports = classNames) : window.classNames = classNames;
246
- }();
247
- }), DEFAULT_CONTEXT_VALUE = { hunkClassName: "", lineClassName: "", gutterClassName: "", codeClassName: "", monotonous: false, gutterType: "default", viewType: "split", widgets: {}, hideGutter: false, selectedChanges: [], generateAnchorID: function() {
248
- }, generateLineClassName: function() {
249
- }, renderGutter: function(_ref) {
250
- var renderDefault = _ref.renderDefault;
251
- return (0, _ref.wrapInAnchor)(renderDefault());
252
- }, codeEvents: {}, gutterEvents: {} }, ContextType = reactExports.createContext(DEFAULT_CONTEXT_VALUE), Provider = ContextType.Provider, useDiffSettings = function() {
253
- return reactExports.useContext(ContextType);
254
- }, gitdiffParser = createCommonjsModule(function(module, exports$1) {
255
- !function(root) {
256
- function parsePathFromFirstLine(line) {
257
- var filesStr = line.slice(11), oldPath = null, newPath = null;
258
- switch (filesStr.indexOf('"')) {
259
- case -1:
260
- oldPath = (segs = filesStr.split(" "))[0].slice(2), newPath = segs[1].slice(2);
261
- break;
262
- case 0:
263
- var nextQuoteIndex = filesStr.indexOf('"', 2);
264
- oldPath = filesStr.slice(3, nextQuoteIndex);
265
- var newQuoteIndex = filesStr.indexOf('"', nextQuoteIndex + 1);
266
- newPath = newQuoteIndex < 0 ? filesStr.slice(nextQuoteIndex + 4) : filesStr.slice(newQuoteIndex + 3, -1);
267
- break;
268
- default:
269
- var segs;
270
- oldPath = (segs = filesStr.split(" "))[0].slice(2), newPath = segs[1].slice(3, -1);
271
- }
272
- return { oldPath, newPath };
273
- }
274
- var parser = { parse: function(source) {
275
- for (var currentInfo, currentHunk, changeOldLine, changeNewLine, paths, infos = [], stat = 2, lines = source.split("\n"), linesLen = lines.length, i = 0; i < linesLen; ) {
276
- var line = lines[i];
277
- if (0 === line.indexOf("diff --git")) {
278
- currentInfo = { hunks: [], oldEndingNewLine: true, newEndingNewLine: true, oldPath: (paths = parsePathFromFirstLine(line)).oldPath, newPath: paths.newPath }, infos.push(currentInfo);
279
- var simiLine, currentInfoType = null;
280
- simiLoop: for (; simiLine = lines[++i]; ) {
281
- var spaceIndex = simiLine.indexOf(" "), infoType = spaceIndex > -1 ? simiLine.slice(0, spaceIndex) : infoType;
282
- switch (infoType) {
283
- case "diff":
284
- i--;
285
- break simiLoop;
286
- case "deleted":
287
- case "new":
288
- var leftStr = simiLine.slice(spaceIndex + 1);
289
- 0 === leftStr.indexOf("file mode") && (currentInfo["new" === infoType ? "newMode" : "oldMode"] = leftStr.slice(10));
290
- break;
291
- case "similarity":
292
- currentInfo.similarity = parseInt(simiLine.split(" ")[2], 10);
293
- break;
294
- case "index":
295
- var segs = simiLine.slice(spaceIndex + 1).split(" "), revs = segs[0].split("..");
296
- currentInfo.oldRevision = revs[0], currentInfo.newRevision = revs[1], segs[1] && (currentInfo.oldMode = currentInfo.newMode = segs[1]);
297
- break;
298
- case "copy":
299
- case "rename":
300
- var infoStr = simiLine.slice(spaceIndex + 1);
301
- 0 === infoStr.indexOf("from") ? currentInfo.oldPath = infoStr.slice(5) : currentInfo.newPath = infoStr.slice(3), currentInfoType = infoType;
302
- break;
303
- case "---":
304
- var oldPath = simiLine.slice(spaceIndex + 1), newPath = lines[++i].slice(4);
305
- "/dev/null" === oldPath ? (newPath = newPath.slice(2), currentInfoType = "add") : "/dev/null" === newPath ? (oldPath = oldPath.slice(2), currentInfoType = "delete") : (currentInfoType = "modify", oldPath = oldPath.slice(2), newPath = newPath.slice(2)), oldPath && (currentInfo.oldPath = oldPath), newPath && (currentInfo.newPath = newPath), stat = 5;
306
- break simiLoop;
307
- }
308
- }
309
- currentInfo.type = currentInfoType || "modify";
310
- } else if (0 === line.indexOf("Binary")) currentInfo.isBinary = true, currentInfo.type = line.indexOf("/dev/null and") >= 0 ? "add" : line.indexOf("and /dev/null") >= 0 ? "delete" : "modify", stat = 2, currentInfo = null;
311
- else if (5 === stat) if (0 === line.indexOf("@@")) {
312
- var match = /^@@\s+-([0-9]+)(,([0-9]+))?\s+\+([0-9]+)(,([0-9]+))?/.exec(line);
313
- currentHunk = { content: line, oldStart: match[1] - 0, newStart: match[4] - 0, oldLines: match[3] - 0 || 1, newLines: match[6] - 0 || 1, changes: [] }, currentInfo.hunks.push(currentHunk), changeOldLine = currentHunk.oldStart, changeNewLine = currentHunk.newStart;
314
- } else {
315
- var typeChar = line.slice(0, 1), change = { content: line.slice(1) };
316
- switch (typeChar) {
317
- case "+":
318
- change.type = "insert", change.isInsert = true, change.lineNumber = changeNewLine, changeNewLine++;
319
- break;
320
- case "-":
321
- change.type = "delete", change.isDelete = true, change.lineNumber = changeOldLine, changeOldLine++;
322
- break;
323
- case " ":
324
- change.type = "normal", change.isNormal = true, change.oldLineNumber = changeOldLine, change.newLineNumber = changeNewLine, changeOldLine++, changeNewLine++;
325
- break;
326
- case "\\":
327
- var lastChange = currentHunk.changes[currentHunk.changes.length - 1];
328
- lastChange.isDelete || (currentInfo.newEndingNewLine = false), lastChange.isInsert || (currentInfo.oldEndingNewLine = false);
329
- }
330
- change.type && currentHunk.changes.push(change);
331
- }
332
- i++;
333
- }
334
- return infos;
335
- } };
336
- module.exports = parser;
337
- }();
338
- });
339
- function isInsert(change) {
340
- return "insert" === change.type;
341
- }
342
- function isDelete(change) {
343
- return "delete" === change.type;
344
- }
345
- function isNormal(change) {
346
- return "normal" === change.type;
347
- }
348
- function mapHunk(hunk, options) {
349
- var changes = "zip" === options.nearbySequences ? function(changes2) {
350
- var _changes$reduce = changes2.reduce(function(_ref, current2, i) {
351
- var _ref2 = _slicedToArray(_ref, 3), result = _ref2[0], last = _ref2[1], lastDeletionIndex = _ref2[2];
352
- return last ? isInsert(current2) && lastDeletionIndex >= 0 ? (result.splice(lastDeletionIndex + 1, 0, current2), [result, current2, lastDeletionIndex + 2]) : (result.push(current2), [result, current2, isDelete(current2) && isDelete(last) ? lastDeletionIndex : i]) : (result.push(current2), [result, current2, isDelete(current2) ? i : -1]);
353
- }, [[], null, -1]);
354
- return _slicedToArray(_changes$reduce, 1)[0];
355
- }(hunk.changes) : hunk.changes;
356
- return _objectSpread2(_objectSpread2({}, hunk), {}, { isPlain: false, changes });
357
- }
358
- function parseDiff(text) {
359
- var options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, diffText2 = function(text2) {
360
- if (text2.startsWith("diff --git")) return text2;
361
- var indexOfFirstLineBreak = text2.indexOf("\n"), indexOfSecondLineBreak = text2.indexOf("\n", indexOfFirstLineBreak + 1), firstLine = text2.slice(0, indexOfFirstLineBreak), secondLine = text2.slice(indexOfFirstLineBreak + 1, indexOfSecondLineBreak), oldPath = firstLine.split(" ").slice(1, -3).join(" "), newPath = secondLine.split(" ").slice(1, -3).join(" ");
362
- return ["diff --git a/".concat(oldPath, " b/").concat(newPath), "index 1111111..2222222 100644", "--- a/".concat(oldPath), "+++ b/".concat(newPath), text2.slice(indexOfSecondLineBreak + 1)].join("\n");
363
- }(text.trimStart());
364
- return gitdiffParser.parse(diffText2).map(function(file) {
365
- return function(file2, options2) {
366
- var hunks = file2.hunks.map(function(hunk) {
367
- return mapHunk(hunk, options2);
368
- });
369
- return _objectSpread2(_objectSpread2({}, file2), {}, { hunks });
370
- }(file, options);
371
- });
372
- }
373
- function first(array) {
374
- return array[0];
375
- }
376
- function last$1(array) {
377
- return array[array.length - 1];
378
- }
379
- function sideToProperty(side) {
380
- return ["".concat(side, "Start"), "".concat(side, "Lines")];
381
- }
382
- function computeLineNumberFactory(side) {
383
- return "old" === side ? function(change) {
384
- return isInsert(change) ? -1 : isNormal(change) ? change.oldLineNumber : change.lineNumber;
385
- } : function(change) {
386
- return isDelete(change) ? -1 : isNormal(change) ? change.newLineNumber : change.lineNumber;
387
- };
388
- }
389
- function isInHunkFactory(startProperty, linesProperty) {
390
- return function(hunk, lineNumber) {
391
- var start = hunk[startProperty], end = start + hunk[linesProperty];
392
- return lineNumber >= start && lineNumber < end;
393
- };
394
- }
395
- function isBetweenHunksFactory(startProperty, linesProperty) {
396
- return function(previousHunk, nextHunk, lineNumber) {
397
- var start = previousHunk[startProperty] + previousHunk[linesProperty], end = nextHunk[startProperty];
398
- return lineNumber >= start && lineNumber < end;
399
- };
400
- }
401
- function findChangeByLineNumberFactory(side) {
402
- var computeLineNumber = computeLineNumberFactory(side), findContainerHunk = function(side2) {
403
- var _sideToProperty2 = _slicedToArray(sideToProperty(side2), 2), isInHunk = isInHunkFactory(_sideToProperty2[0], _sideToProperty2[1]);
404
- return function(hunks, lineNumber) {
405
- return hunks.find(function(hunk) {
406
- return isInHunk(hunk, lineNumber);
407
- });
408
- };
409
- }(side);
410
- return function(hunks, lineNumber) {
411
- var containerHunk = findContainerHunk(hunks, lineNumber);
412
- if (containerHunk) return containerHunk.changes.find(function(change) {
413
- return computeLineNumber(change) === lineNumber;
414
- });
415
- };
416
- }
417
- function getCorrespondingLineNumberFactory(baseSide) {
418
- var anotherSide = "old" === baseSide ? "new" : "old", _sideToProperty4 = _slicedToArray(sideToProperty(baseSide), 2), baseStart = _sideToProperty4[0], baseLines = _sideToProperty4[1], _sideToProperty6 = _slicedToArray(sideToProperty(anotherSide), 2), correspondingStart = _sideToProperty6[0], correspondingLines = _sideToProperty6[1], baseLineNumber = computeLineNumberFactory(baseSide), correspondingLineNumber = computeLineNumberFactory(anotherSide), isInHunk = isInHunkFactory(baseStart, baseLines), isBetweenHunks = isBetweenHunksFactory(baseStart, baseLines);
419
- return function(hunks, lineNumber) {
420
- var firstHunk = first(hunks);
421
- if (lineNumber < firstHunk[baseStart]) {
422
- var spanFromStart = firstHunk[baseStart] - lineNumber;
423
- return firstHunk[correspondingStart] - spanFromStart;
424
- }
425
- var lastHunk = last$1(hunks);
426
- if (lastHunk[baseStart] + lastHunk[baseLines] <= lineNumber) {
427
- var spanFromEnd = lineNumber - lastHunk[baseStart] - lastHunk[baseLines];
428
- return lastHunk[correspondingStart] + lastHunk[correspondingLines] + spanFromEnd;
429
- }
430
- for (var i = 0; i < hunks.length; i++) {
431
- var currentHunk = hunks[i], nextHunk = hunks[i + 1];
432
- if (isInHunk(currentHunk, lineNumber)) {
433
- var changeIndex = currentHunk.changes.findIndex(function(change2) {
434
- return baseLineNumber(change2) === lineNumber;
435
- }), change = currentHunk.changes[changeIndex];
436
- if (isNormal(change)) return correspondingLineNumber(change);
437
- var possibleCorrespondingChangeIndex = isDelete(change) ? changeIndex + 1 : changeIndex - 1, possibleCorrespondingChange = currentHunk.changes[possibleCorrespondingChangeIndex];
438
- if (!possibleCorrespondingChange) return -1;
439
- var negativeChangeType = isInsert(change) ? "delete" : "insert";
440
- return possibleCorrespondingChange.type === negativeChangeType ? correspondingLineNumber(possibleCorrespondingChange) : -1;
441
- }
442
- if (isBetweenHunks(currentHunk, nextHunk, lineNumber)) {
443
- var _spanFromEnd = lineNumber - currentHunk[baseStart] - currentHunk[baseLines];
444
- return currentHunk[correspondingStart] + currentHunk[correspondingLines] + _spanFromEnd;
445
- }
446
- }
447
- throw new Error("Unexpected line position ".concat(lineNumber));
448
- };
449
- }
450
- var _baseFindIndex = function(array, predicate, fromIndex, fromRight) {
451
- for (var length = array.length, index2 = fromIndex + (-1); ++index2 < length; ) if (predicate(array[index2], index2, array)) return index2;
452
- return -1;
453
- };
454
- var _listCacheClear = function() {
455
- this.__data__ = [], this.size = 0;
456
- };
457
- var eq_1 = function(value, other) {
458
- return value === other || value != value && other != other;
459
- };
460
- var _assocIndexOf = function(array, key) {
461
- for (var length = array.length; length--; ) if (eq_1(array[length][0], key)) return length;
462
- return -1;
463
- }, splice = Array.prototype.splice;
464
- var _listCacheDelete = function(key) {
465
- var data = this.__data__, index2 = _assocIndexOf(data, key);
466
- return !(index2 < 0) && (index2 == data.length - 1 ? data.pop() : splice.call(data, index2, 1), --this.size, true);
467
- };
468
- var _listCacheGet = function(key) {
469
- var data = this.__data__, index2 = _assocIndexOf(data, key);
470
- return index2 < 0 ? void 0 : data[index2][1];
471
- };
472
- var _listCacheHas = function(key) {
473
- return _assocIndexOf(this.__data__, key) > -1;
474
- };
475
- var _listCacheSet = function(key, value) {
476
- var data = this.__data__, index2 = _assocIndexOf(data, key);
477
- return index2 < 0 ? (++this.size, data.push([key, value])) : data[index2][1] = value, this;
478
- };
479
- function ListCache(entries) {
480
- var index2 = -1, length = null == entries ? 0 : entries.length;
481
- for (this.clear(); ++index2 < length; ) {
482
- var entry = entries[index2];
483
- this.set(entry[0], entry[1]);
484
- }
485
- }
486
- ListCache.prototype.clear = _listCacheClear, ListCache.prototype.delete = _listCacheDelete, ListCache.prototype.get = _listCacheGet, ListCache.prototype.has = _listCacheHas, ListCache.prototype.set = _listCacheSet;
487
- var _ListCache = ListCache;
488
- var _stackClear = function() {
489
- this.__data__ = new _ListCache(), this.size = 0;
490
- };
491
- var _stackDelete = function(key) {
492
- var data = this.__data__, result = data.delete(key);
493
- return this.size = data.size, result;
494
- };
495
- var _stackGet = function(key) {
496
- return this.__data__.get(key);
497
- };
498
- var _stackHas = function(key) {
499
- return this.__data__.has(key);
500
- }, _freeGlobal = "object" == typeof commonjsGlobal && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal, freeSelf = "object" == typeof self && self && self.Object === Object && self, _root = _freeGlobal || freeSelf || Function("return this")(), _Symbol = _root.Symbol, objectProto$d = Object.prototype, hasOwnProperty$a = objectProto$d.hasOwnProperty, nativeObjectToString$1 = objectProto$d.toString, symToStringTag$1 = _Symbol ? _Symbol.toStringTag : void 0;
501
- var _getRawTag = function(value) {
502
- var isOwn = hasOwnProperty$a.call(value, symToStringTag$1), tag = value[symToStringTag$1];
503
- try {
504
- value[symToStringTag$1] = void 0;
505
- var unmasked = true;
506
- } catch (e) {
507
- }
508
- var result = nativeObjectToString$1.call(value);
509
- return unmasked && (isOwn ? value[symToStringTag$1] = tag : delete value[symToStringTag$1]), result;
510
- }, nativeObjectToString = Object.prototype.toString;
511
- var _objectToString = function(value) {
512
- return nativeObjectToString.call(value);
513
- }, symToStringTag = _Symbol ? _Symbol.toStringTag : void 0;
514
- var _baseGetTag = function(value) {
515
- return null == value ? void 0 === value ? "[object Undefined]" : "[object Null]" : symToStringTag && symToStringTag in Object(value) ? _getRawTag(value) : _objectToString(value);
516
- };
517
- var isObject_1 = function(value) {
518
- var type = typeof value;
519
- return null != value && ("object" == type || "function" == type);
520
- };
521
- var isFunction_1 = function(value) {
522
- if (!isObject_1(value)) return false;
523
- var tag = _baseGetTag(value);
524
- return "[object Function]" == tag || "[object GeneratorFunction]" == tag || "[object AsyncFunction]" == tag || "[object Proxy]" == tag;
525
- }, _coreJsData = _root["__core-js_shared__"], maskSrcKey = function() {
526
- var uid2 = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || "");
527
- return uid2 ? "Symbol(src)_1." + uid2 : "";
528
- }();
529
- var _isMasked = function(func) {
530
- return !!maskSrcKey && maskSrcKey in func;
531
- }, funcToString$1 = Function.prototype.toString;
532
- var _toSource = function(func) {
533
- if (null != func) {
534
- try {
535
- return funcToString$1.call(func);
536
- } catch (e) {
537
- }
538
- try {
539
- return func + "";
540
- } catch (e) {
541
- }
542
- }
543
- return "";
544
- }, reIsHostCtor = /^\[object .+?Constructor\]$/, funcProto = Function.prototype, objectProto$b = Object.prototype, funcToString = funcProto.toString, hasOwnProperty$9 = objectProto$b.hasOwnProperty, reIsNative = RegExp("^" + funcToString.call(hasOwnProperty$9).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
545
- var _baseIsNative = function(value) {
546
- return !(!isObject_1(value) || _isMasked(value)) && (isFunction_1(value) ? reIsNative : reIsHostCtor).test(_toSource(value));
547
- };
548
- var _getValue = function(object, key) {
549
- return null == object ? void 0 : object[key];
550
- };
551
- var _getNative = function(object, key) {
552
- var value = _getValue(object, key);
553
- return _baseIsNative(value) ? value : void 0;
554
- }, _Map = _getNative(_root, "Map"), _nativeCreate = _getNative(Object, "create");
555
- var _hashClear = function() {
556
- this.__data__ = _nativeCreate ? _nativeCreate(null) : {}, this.size = 0;
557
- };
558
- var _hashDelete = function(key) {
559
- var result = this.has(key) && delete this.__data__[key];
560
- return this.size -= result ? 1 : 0, result;
561
- }, hasOwnProperty$8 = Object.prototype.hasOwnProperty;
562
- var _hashGet = function(key) {
563
- var data = this.__data__;
564
- if (_nativeCreate) {
565
- var result = data[key];
566
- return "__lodash_hash_undefined__" === result ? void 0 : result;
567
- }
568
- return hasOwnProperty$8.call(data, key) ? data[key] : void 0;
569
- }, hasOwnProperty$7 = Object.prototype.hasOwnProperty;
570
- var _hashHas = function(key) {
571
- var data = this.__data__;
572
- return _nativeCreate ? void 0 !== data[key] : hasOwnProperty$7.call(data, key);
573
- };
574
- var _hashSet = function(key, value) {
575
- var data = this.__data__;
576
- return this.size += this.has(key) ? 0 : 1, data[key] = _nativeCreate && void 0 === value ? "__lodash_hash_undefined__" : value, this;
577
- };
578
- function Hash(entries) {
579
- var index2 = -1, length = null == entries ? 0 : entries.length;
580
- for (this.clear(); ++index2 < length; ) {
581
- var entry = entries[index2];
582
- this.set(entry[0], entry[1]);
583
- }
584
- }
585
- Hash.prototype.clear = _hashClear, Hash.prototype.delete = _hashDelete, Hash.prototype.get = _hashGet, Hash.prototype.has = _hashHas, Hash.prototype.set = _hashSet;
586
- var _Hash = Hash;
587
- var _mapCacheClear = function() {
588
- this.size = 0, this.__data__ = { hash: new _Hash(), map: new (_Map || _ListCache)(), string: new _Hash() };
589
- };
590
- var _isKeyable = function(value) {
591
- var type = typeof value;
592
- return "string" == type || "number" == type || "symbol" == type || "boolean" == type ? "__proto__" !== value : null === value;
593
- };
594
- var _getMapData = function(map, key) {
595
- var data = map.__data__;
596
- return _isKeyable(key) ? data["string" == typeof key ? "string" : "hash"] : data.map;
597
- };
598
- var _mapCacheDelete = function(key) {
599
- var result = _getMapData(this, key).delete(key);
600
- return this.size -= result ? 1 : 0, result;
601
- };
602
- var _mapCacheGet = function(key) {
603
- return _getMapData(this, key).get(key);
604
- };
605
- var _mapCacheHas = function(key) {
606
- return _getMapData(this, key).has(key);
607
- };
608
- var _mapCacheSet = function(key, value) {
609
- var data = _getMapData(this, key), size = data.size;
610
- return data.set(key, value), this.size += data.size == size ? 0 : 1, this;
611
- };
612
- function MapCache(entries) {
613
- var index2 = -1, length = null == entries ? 0 : entries.length;
614
- for (this.clear(); ++index2 < length; ) {
615
- var entry = entries[index2];
616
- this.set(entry[0], entry[1]);
617
- }
618
- }
619
- MapCache.prototype.clear = _mapCacheClear, MapCache.prototype.delete = _mapCacheDelete, MapCache.prototype.get = _mapCacheGet, MapCache.prototype.has = _mapCacheHas, MapCache.prototype.set = _mapCacheSet;
620
- var _MapCache = MapCache;
621
- var _stackSet = function(key, value) {
622
- var data = this.__data__;
623
- if (data instanceof _ListCache) {
624
- var pairs = data.__data__;
625
- if (!_Map || pairs.length < 199) return pairs.push([key, value]), this.size = ++data.size, this;
626
- data = this.__data__ = new _MapCache(pairs);
627
- }
628
- return data.set(key, value), this.size = data.size, this;
629
- };
630
- function Stack(entries) {
631
- var data = this.__data__ = new _ListCache(entries);
632
- this.size = data.size;
633
- }
634
- Stack.prototype.clear = _stackClear, Stack.prototype.delete = _stackDelete, Stack.prototype.get = _stackGet, Stack.prototype.has = _stackHas, Stack.prototype.set = _stackSet;
635
- var _Stack = Stack;
636
- var _setCacheAdd = function(value) {
637
- return this.__data__.set(value, "__lodash_hash_undefined__"), this;
638
- };
639
- var _setCacheHas = function(value) {
640
- return this.__data__.has(value);
641
- };
642
- function SetCache(values) {
643
- var index2 = -1, length = null == values ? 0 : values.length;
644
- for (this.__data__ = new _MapCache(); ++index2 < length; ) this.add(values[index2]);
645
- }
646
- SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd, SetCache.prototype.has = _setCacheHas;
647
- var _SetCache = SetCache;
648
- var _arraySome = function(array, predicate) {
649
- for (var index2 = -1, length = null == array ? 0 : array.length; ++index2 < length; ) if (predicate(array[index2], index2, array)) return true;
650
- return false;
651
- };
652
- var _cacheHas = function(cache, key) {
653
- return cache.has(key);
654
- };
655
- var _equalArrays = function(array, other, bitmask, customizer, equalFunc, stack) {
656
- var isPartial = 1 & bitmask, arrLength = array.length, othLength = other.length;
657
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) return false;
658
- var arrStacked = stack.get(array), othStacked = stack.get(other);
659
- if (arrStacked && othStacked) return arrStacked == other && othStacked == array;
660
- var index2 = -1, result = true, seen = 2 & bitmask ? new _SetCache() : void 0;
661
- for (stack.set(array, other), stack.set(other, array); ++index2 < arrLength; ) {
662
- var arrValue = array[index2], othValue = other[index2];
663
- if (customizer) var compared = isPartial ? customizer(othValue, arrValue, index2, other, array, stack) : customizer(arrValue, othValue, index2, array, other, stack);
664
- if (void 0 !== compared) {
665
- if (compared) continue;
666
- result = false;
667
- break;
668
- }
669
- if (seen) {
670
- if (!_arraySome(other, function(othValue2, othIndex) {
671
- if (!_cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) return seen.push(othIndex);
672
- })) {
673
- result = false;
674
- break;
675
- }
676
- } else if (arrValue !== othValue && !equalFunc(arrValue, othValue, bitmask, customizer, stack)) {
677
- result = false;
678
- break;
679
- }
680
- }
681
- return stack.delete(array), stack.delete(other), result;
682
- }, _Uint8Array = _root.Uint8Array;
683
- var _mapToArray = function(map) {
684
- var index2 = -1, result = Array(map.size);
685
- return map.forEach(function(value, key) {
686
- result[++index2] = [key, value];
687
- }), result;
688
- };
689
- var _setToArray = function(set) {
690
- var index2 = -1, result = Array(set.size);
691
- return set.forEach(function(value) {
692
- result[++index2] = value;
693
- }), result;
694
- }, symbolProto$1 = _Symbol ? _Symbol.prototype : void 0, symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : void 0;
695
- var _equalByTag = function(object, other, tag, bitmask, customizer, equalFunc, stack) {
696
- switch (tag) {
697
- case "[object DataView]":
698
- if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) return false;
699
- object = object.buffer, other = other.buffer;
700
- case "[object ArrayBuffer]":
701
- return !(object.byteLength != other.byteLength || !equalFunc(new _Uint8Array(object), new _Uint8Array(other)));
702
- case "[object Boolean]":
703
- case "[object Date]":
704
- case "[object Number]":
705
- return eq_1(+object, +other);
706
- case "[object Error]":
707
- return object.name == other.name && object.message == other.message;
708
- case "[object RegExp]":
709
- case "[object String]":
710
- return object == other + "";
711
- case "[object Map]":
712
- var convert = _mapToArray;
713
- case "[object Set]":
714
- var isPartial = 1 & bitmask;
715
- if (convert || (convert = _setToArray), object.size != other.size && !isPartial) return false;
716
- var stacked = stack.get(object);
717
- if (stacked) return stacked == other;
718
- bitmask |= 2, stack.set(object, other);
719
- var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
720
- return stack.delete(object), result;
721
- case "[object Symbol]":
722
- if (symbolValueOf) return symbolValueOf.call(object) == symbolValueOf.call(other);
723
- }
724
- return false;
725
- };
726
- var _arrayPush = function(array, values) {
727
- for (var index2 = -1, length = values.length, offset = array.length; ++index2 < length; ) array[offset + index2] = values[index2];
728
- return array;
729
- }, isArray_1 = Array.isArray;
730
- var _baseGetAllKeys = function(object, keysFunc, symbolsFunc) {
731
- var result = keysFunc(object);
732
- return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
733
- };
734
- var _arrayFilter = function(array, predicate) {
735
- for (var index2 = -1, length = null == array ? 0 : array.length, resIndex = 0, result = []; ++index2 < length; ) {
736
- var value = array[index2];
737
- predicate(value, index2, array) && (result[resIndex++] = value);
738
- }
739
- return result;
740
- };
741
- var stubArray_1 = function() {
742
- return [];
743
- }, propertyIsEnumerable$1 = Object.prototype.propertyIsEnumerable, nativeGetSymbols = Object.getOwnPropertySymbols, _getSymbols = nativeGetSymbols ? function(object) {
744
- return null == object ? [] : (object = Object(object), _arrayFilter(nativeGetSymbols(object), function(symbol) {
745
- return propertyIsEnumerable$1.call(object, symbol);
746
- }));
747
- } : stubArray_1;
748
- var _baseTimes = function(n, iteratee) {
749
- for (var index2 = -1, result = Array(n); ++index2 < n; ) result[index2] = iteratee(index2);
750
- return result;
751
- };
752
- var isObjectLike_1 = function(value) {
753
- return null != value && "object" == typeof value;
754
- };
755
- var _baseIsArguments = function(value) {
756
- return isObjectLike_1(value) && "[object Arguments]" == _baseGetTag(value);
757
- }, objectProto$7 = Object.prototype, hasOwnProperty$6 = objectProto$7.hasOwnProperty, propertyIsEnumerable = objectProto$7.propertyIsEnumerable, isArguments_1 = _baseIsArguments(/* @__PURE__ */ function() {
758
- return arguments;
759
- }()) ? _baseIsArguments : function(value) {
760
- return isObjectLike_1(value) && hasOwnProperty$6.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
761
- };
762
- var stubFalse_1 = function() {
763
- return false;
764
- }, isBuffer_1 = createCommonjsModule(function(module, exports$1) {
765
- var freeExports = exports$1 && !exports$1.nodeType && exports$1, freeModule = freeExports && module && !module.nodeType && module, Buffer = freeModule && freeModule.exports === freeExports ? _root.Buffer : void 0, isBuffer = (Buffer ? Buffer.isBuffer : void 0) || stubFalse_1;
766
- module.exports = isBuffer;
767
- }), reIsUint = /^(?:0|[1-9]\d*)$/;
768
- var _isIndex = function(value, length) {
769
- var type = typeof value;
770
- return !!(length = null == length ? 9007199254740991 : length) && ("number" == type || "symbol" != type && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
771
- };
772
- var isLength_1 = function(value) {
773
- return "number" == typeof value && value > -1 && value % 1 == 0 && value <= 9007199254740991;
774
- }, typedArrayTags = {};
775
- typedArrayTags["[object Float32Array]"] = typedArrayTags["[object Float64Array]"] = typedArrayTags["[object Int8Array]"] = typedArrayTags["[object Int16Array]"] = typedArrayTags["[object Int32Array]"] = typedArrayTags["[object Uint8Array]"] = typedArrayTags["[object Uint8ClampedArray]"] = typedArrayTags["[object Uint16Array]"] = typedArrayTags["[object Uint32Array]"] = true, typedArrayTags["[object Arguments]"] = typedArrayTags["[object Array]"] = typedArrayTags["[object ArrayBuffer]"] = typedArrayTags["[object Boolean]"] = typedArrayTags["[object DataView]"] = typedArrayTags["[object Date]"] = typedArrayTags["[object Error]"] = typedArrayTags["[object Function]"] = typedArrayTags["[object Map]"] = typedArrayTags["[object Number]"] = typedArrayTags["[object Object]"] = typedArrayTags["[object RegExp]"] = typedArrayTags["[object Set]"] = typedArrayTags["[object String]"] = typedArrayTags["[object WeakMap]"] = false;
776
- var _baseIsTypedArray = function(value) {
777
- return isObjectLike_1(value) && isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
778
- };
779
- var _baseUnary = function(func) {
780
- return function(value) {
781
- return func(value);
782
- };
783
- }, _nodeUtil = createCommonjsModule(function(module, exports$1) {
784
- var freeExports = exports$1 && !exports$1.nodeType && exports$1, freeModule = freeExports && module && !module.nodeType && module, freeProcess = freeModule && freeModule.exports === freeExports && _freeGlobal.process, nodeUtil = function() {
785
- try {
786
- var types = freeModule && freeModule.require && freeModule.require("util").types;
787
- return types || freeProcess && freeProcess.binding && freeProcess.binding("util");
788
- } catch (e) {
789
- }
790
- }();
791
- module.exports = nodeUtil;
792
- }), nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray, isTypedArray_1 = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray, hasOwnProperty$5 = Object.prototype.hasOwnProperty;
793
- var _arrayLikeKeys = function(value, inherited) {
794
- var isArr = isArray_1(value), isArg = !isArr && isArguments_1(value), isBuff = !isArr && !isArg && isBuffer_1(value), isType = !isArr && !isArg && !isBuff && isTypedArray_1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? _baseTimes(value.length, String) : [], length = result.length;
795
- for (var key in value) !hasOwnProperty$5.call(value, key) || skipIndexes && ("length" == key || isBuff && ("offset" == key || "parent" == key) || isType && ("buffer" == key || "byteLength" == key || "byteOffset" == key) || _isIndex(key, length)) || result.push(key);
796
- return result;
797
- }, objectProto$5 = Object.prototype;
798
- var _isPrototype = function(value) {
799
- var Ctor = value && value.constructor;
800
- return value === ("function" == typeof Ctor && Ctor.prototype || objectProto$5);
801
- };
802
- var _nativeKeys = /* @__PURE__ */ function(func, transform) {
803
- return function(arg) {
804
- return func(transform(arg));
805
- };
806
- }(Object.keys, Object), hasOwnProperty$4 = Object.prototype.hasOwnProperty;
807
- var _baseKeys = function(object) {
808
- if (!_isPrototype(object)) return _nativeKeys(object);
809
- var result = [];
810
- for (var key in Object(object)) hasOwnProperty$4.call(object, key) && "constructor" != key && result.push(key);
811
- return result;
812
- };
813
- var isArrayLike_1 = function(value) {
814
- return null != value && isLength_1(value.length) && !isFunction_1(value);
815
- };
816
- var keys_1 = function(object) {
817
- return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
818
- };
819
- var _getAllKeys = function(object) {
820
- return _baseGetAllKeys(object, keys_1, _getSymbols);
821
- }, hasOwnProperty$3 = Object.prototype.hasOwnProperty;
822
- var _equalObjects = function(object, other, bitmask, customizer, equalFunc, stack) {
823
- var isPartial = 1 & bitmask, objProps = _getAllKeys(object), objLength = objProps.length;
824
- if (objLength != _getAllKeys(other).length && !isPartial) return false;
825
- for (var index2 = objLength; index2--; ) {
826
- var key = objProps[index2];
827
- if (!(isPartial ? key in other : hasOwnProperty$3.call(other, key))) return false;
828
- }
829
- var objStacked = stack.get(object), othStacked = stack.get(other);
830
- if (objStacked && othStacked) return objStacked == other && othStacked == object;
831
- var result = true;
832
- stack.set(object, other), stack.set(other, object);
833
- for (var skipCtor = isPartial; ++index2 < objLength; ) {
834
- var objValue = object[key = objProps[index2]], othValue = other[key];
835
- if (customizer) var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
836
- if (!(void 0 === compared ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
837
- result = false;
838
- break;
839
- }
840
- skipCtor || (skipCtor = "constructor" == key);
841
- }
842
- if (result && !skipCtor) {
843
- var objCtor = object.constructor, othCtor = other.constructor;
844
- objCtor == othCtor || !("constructor" in object) || !("constructor" in other) || "function" == typeof objCtor && objCtor instanceof objCtor && "function" == typeof othCtor && othCtor instanceof othCtor || (result = false);
845
- }
846
- return stack.delete(object), stack.delete(other), result;
847
- }, _DataView = _getNative(_root, "DataView"), _Promise = _getNative(_root, "Promise"), _Set = _getNative(_root, "Set"), _WeakMap = _getNative(_root, "WeakMap"), dataViewCtorString = _toSource(_DataView), mapCtorString = _toSource(_Map), promiseCtorString = _toSource(_Promise), setCtorString = _toSource(_Set), weakMapCtorString = _toSource(_WeakMap), getTag = _baseGetTag;
848
- (_DataView && "[object DataView]" != getTag(new _DataView(new ArrayBuffer(1))) || _Map && "[object Map]" != getTag(new _Map()) || _Promise && "[object Promise]" != getTag(_Promise.resolve()) || _Set && "[object Set]" != getTag(new _Set()) || _WeakMap && "[object WeakMap]" != getTag(new _WeakMap())) && (getTag = function(value) {
849
- var result = _baseGetTag(value), Ctor = "[object Object]" == result ? value.constructor : void 0, ctorString = Ctor ? _toSource(Ctor) : "";
850
- if (ctorString) switch (ctorString) {
851
- case dataViewCtorString:
852
- return "[object DataView]";
853
- case mapCtorString:
854
- return "[object Map]";
855
- case promiseCtorString:
856
- return "[object Promise]";
857
- case setCtorString:
858
- return "[object Set]";
859
- case weakMapCtorString:
860
- return "[object WeakMap]";
861
- }
862
- return result;
863
- });
864
- var _getTag = getTag, objectTag = "[object Object]", hasOwnProperty$2 = Object.prototype.hasOwnProperty;
865
- var _baseIsEqualDeep = function(object, other, bitmask, customizer, equalFunc, stack) {
866
- var objIsArr = isArray_1(object), othIsArr = isArray_1(other), objTag = objIsArr ? "[object Array]" : _getTag(object), othTag = othIsArr ? "[object Array]" : _getTag(other), objIsObj = (objTag = "[object Arguments]" == objTag ? objectTag : objTag) == objectTag, othIsObj = (othTag = "[object Arguments]" == othTag ? objectTag : othTag) == objectTag, isSameTag = objTag == othTag;
867
- if (isSameTag && isBuffer_1(object)) {
868
- if (!isBuffer_1(other)) return false;
869
- objIsArr = true, objIsObj = false;
870
- }
871
- if (isSameTag && !objIsObj) return stack || (stack = new _Stack()), objIsArr || isTypedArray_1(object) ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack) : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
872
- if (!(1 & bitmask)) {
873
- var objIsWrapped = objIsObj && hasOwnProperty$2.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty$2.call(other, "__wrapped__");
874
- if (objIsWrapped || othIsWrapped) {
875
- var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
876
- return stack || (stack = new _Stack()), equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
877
- }
878
- }
879
- return !!isSameTag && (stack || (stack = new _Stack()), _equalObjects(object, other, bitmask, customizer, equalFunc, stack));
880
- };
881
- var _baseIsEqual = function baseIsEqual(value, other, bitmask, customizer, stack) {
882
- return value === other || (null == value || null == other || !isObjectLike_1(value) && !isObjectLike_1(other) ? value != value && other != other : _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack));
883
- };
884
- var _baseIsMatch = function(object, source, matchData, customizer) {
885
- var index2 = matchData.length, length = index2;
886
- if (null == object) return !length;
887
- for (object = Object(object); index2--; ) {
888
- var data = matchData[index2];
889
- if (data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) return false;
890
- }
891
- for (; ++index2 < length; ) {
892
- var key = (data = matchData[index2])[0], objValue = object[key], srcValue = data[1];
893
- if (data[2]) {
894
- if (void 0 === objValue && !(key in object)) return false;
895
- } else {
896
- var stack = new _Stack();
897
- var result;
898
- if (!(void 0 === result ? _baseIsEqual(srcValue, objValue, 3, customizer, stack) : result)) return false;
899
- }
900
- }
901
- return true;
902
- };
903
- var _isStrictComparable = function(value) {
904
- return value == value && !isObject_1(value);
905
- };
906
- var _getMatchData = function(object) {
907
- for (var result = keys_1(object), length = result.length; length--; ) {
908
- var key = result[length], value = object[key];
909
- result[length] = [key, value, _isStrictComparable(value)];
910
- }
911
- return result;
912
- };
913
- var _matchesStrictComparable = function(key, srcValue) {
914
- return function(object) {
915
- return null != object && (object[key] === srcValue && (void 0 !== srcValue || key in Object(object)));
916
- };
917
- };
918
- var _baseMatches = function(source) {
919
- var matchData = _getMatchData(source);
920
- return 1 == matchData.length && matchData[0][2] ? _matchesStrictComparable(matchData[0][0], matchData[0][1]) : function(object) {
921
- return object === source || _baseIsMatch(object, source, matchData);
922
- };
923
- };
924
- var isSymbol_1 = function(value) {
925
- return "symbol" == typeof value || isObjectLike_1(value) && "[object Symbol]" == _baseGetTag(value);
926
- }, reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
927
- var _isKey = function(value, object) {
928
- if (isArray_1(value)) return false;
929
- var type = typeof value;
930
- return !("number" != type && "symbol" != type && "boolean" != type && null != value && !isSymbol_1(value)) || (reIsPlainProp.test(value) || !reIsDeepProp.test(value) || null != object && value in Object(object));
931
- };
932
- function memoize(func, resolver) {
933
- if ("function" != typeof func || null != resolver && "function" != typeof resolver) throw new TypeError("Expected a function");
934
- var memoized = function() {
935
- var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
936
- if (cache.has(key)) return cache.get(key);
937
- var result = func.apply(this, args);
938
- return memoized.cache = cache.set(key, result) || cache, result;
939
- };
940
- return memoized.cache = new (memoize.Cache || _MapCache)(), memoized;
941
- }
942
- memoize.Cache = _MapCache;
943
- var memoize_1 = memoize;
944
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, reEscapeChar = /\\(\\)?/g, _stringToPath = function(func) {
945
- var result = memoize_1(func, function(key) {
946
- return 500 === cache.size && cache.clear(), key;
947
- }), cache = result.cache;
948
- return result;
949
- }(function(string) {
950
- var result = [];
951
- return 46 === string.charCodeAt(0) && result.push(""), string.replace(rePropName, function(match, number, quote, subString) {
952
- result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
953
- }), result;
954
- });
955
- var _arrayMap = function(array, iteratee) {
956
- for (var index2 = -1, length = null == array ? 0 : array.length, result = Array(length); ++index2 < length; ) result[index2] = iteratee(array[index2], index2, array);
957
- return result;
958
- }, symbolProto = _Symbol ? _Symbol.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
959
- var _baseToString = function baseToString(value) {
960
- if ("string" == typeof value) return value;
961
- if (isArray_1(value)) return _arrayMap(value, baseToString) + "";
962
- if (isSymbol_1(value)) return symbolToString ? symbolToString.call(value) : "";
963
- var result = value + "";
964
- return "0" == result && 1 / value == -Infinity ? "-0" : result;
965
- };
966
- var toString_1 = function(value) {
967
- return null == value ? "" : _baseToString(value);
968
- };
969
- var _castPath = function(value, object) {
970
- return isArray_1(value) ? value : _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
971
- };
972
- var _toKey = function(value) {
973
- if ("string" == typeof value || isSymbol_1(value)) return value;
974
- var result = value + "";
975
- return "0" == result && 1 / value == -Infinity ? "-0" : result;
976
- };
977
- var _baseGet = function(object, path) {
978
- for (var index2 = 0, length = (path = _castPath(path, object)).length; null != object && index2 < length; ) object = object[_toKey(path[index2++])];
979
- return index2 && index2 == length ? object : void 0;
980
- };
981
- var get_1 = function(object, path, defaultValue) {
982
- var result = null == object ? void 0 : _baseGet(object, path);
983
- return void 0 === result ? defaultValue : result;
984
- };
985
- var _baseHasIn = function(object, key) {
986
- return null != object && key in Object(object);
987
- };
988
- var _hasPath = function(object, path, hasFunc) {
989
- for (var index2 = -1, length = (path = _castPath(path, object)).length, result = false; ++index2 < length; ) {
990
- var key = _toKey(path[index2]);
991
- if (!(result = null != object && hasFunc(object, key))) break;
992
- object = object[key];
993
- }
994
- return result || ++index2 != length ? result : !!(length = null == object ? 0 : object.length) && isLength_1(length) && _isIndex(key, length) && (isArray_1(object) || isArguments_1(object));
995
- };
996
- var hasIn_1 = function(object, path) {
997
- return null != object && _hasPath(object, path, _baseHasIn);
998
- };
999
- var _baseMatchesProperty = function(path, srcValue) {
1000
- return _isKey(path) && _isStrictComparable(srcValue) ? _matchesStrictComparable(_toKey(path), srcValue) : function(object) {
1001
- var objValue = get_1(object, path);
1002
- return void 0 === objValue && objValue === srcValue ? hasIn_1(object, path) : _baseIsEqual(srcValue, objValue, 3);
1003
- };
1004
- };
1005
- var identity_1 = function(value) {
1006
- return value;
1007
- };
1008
- var _baseProperty = function(key) {
1009
- return function(object) {
1010
- return null == object ? void 0 : object[key];
1011
- };
1012
- };
1013
- var _basePropertyDeep = function(path) {
1014
- return function(object) {
1015
- return _baseGet(object, path);
1016
- };
1017
- };
1018
- var property_1 = function(path) {
1019
- return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
1020
- };
1021
- var _baseIteratee = function(value) {
1022
- return "function" == typeof value ? value : null == value ? identity_1 : "object" == typeof value ? isArray_1(value) ? _baseMatchesProperty(value[0], value[1]) : _baseMatches(value) : property_1(value);
1023
- }, reWhitespace = /\s/;
1024
- var _trimmedEndIndex = function(string) {
1025
- for (var index2 = string.length; index2-- && reWhitespace.test(string.charAt(index2)); ) ;
1026
- return index2;
1027
- }, reTrimStart = /^\s+/;
1028
- var _baseTrim = function(string) {
1029
- return string ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
1030
- }, reIsBadHex = /^[-+]0x[0-9a-f]+$/i, reIsBinary = /^0b[01]+$/i, reIsOctal = /^0o[0-7]+$/i, freeParseInt = parseInt;
1031
- var toNumber_1 = function(value) {
1032
- if ("number" == typeof value) return value;
1033
- if (isSymbol_1(value)) return NaN;
1034
- if (isObject_1(value)) {
1035
- var other = "function" == typeof value.valueOf ? value.valueOf() : value;
1036
- value = isObject_1(other) ? other + "" : other;
1037
- }
1038
- if ("string" != typeof value) return 0 === value ? value : +value;
1039
- value = _baseTrim(value);
1040
- var isBinary = reIsBinary.test(value);
1041
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NaN : +value;
1042
- };
1043
- var toFinite_1 = function(value) {
1044
- return value ? Infinity === (value = toNumber_1(value)) || -Infinity === value ? 17976931348623157e292 * (value < 0 ? -1 : 1) : value == value ? value : 0 : 0 === value ? value : 0;
1045
- };
1046
- var toInteger_1 = function(value) {
1047
- var result = toFinite_1(value), remainder = result % 1;
1048
- return result == result ? remainder ? result - remainder : result : 0;
1049
- };
1050
- function getChangeKey(change) {
1051
- if (!change) throw new Error("change is not provided");
1052
- if (isNormal(change)) return "N".concat(change.oldLineNumber);
1053
- var prefix = isInsert(change) ? "I" : "D";
1054
- return "".concat(prefix).concat(change.lineNumber);
1055
- }
1056
- getCorrespondingLineNumberFactory("old");
1057
- var computeOldLineNumber = computeLineNumberFactory("old"), computeNewLineNumber = computeLineNumberFactory("new"); findChangeByLineNumberFactory("old"); findChangeByLineNumberFactory("new"); getCorrespondingLineNumberFactory("new"); getCorrespondingLineNumberFactory("old"); var _defineProperty = function() {
1058
- try {
1059
- var func = _getNative(Object, "defineProperty");
1060
- return func({}, "", {}), func;
1061
- } catch (e) {
1062
- }
1063
- }();
1064
- var _baseAssignValue = function(object, key, value) {
1065
- "__proto__" == key && _defineProperty ? _defineProperty(object, key, { configurable: true, enumerable: true, value, writable: true }) : object[key] = value;
1066
- };
1067
- var _createBaseFor = function(fromRight) {
1068
- return function(object, iteratee, keysFunc) {
1069
- for (var index2 = -1, iterable = Object(object), props = keysFunc(object), length = props.length; length--; ) {
1070
- var key = props[++index2];
1071
- if (false === iteratee(iterable[key], key, iterable)) break;
1072
- }
1073
- return object;
1074
- };
1075
- }, _baseFor = _createBaseFor();
1076
- var _baseForOwn = function(object, iteratee) {
1077
- return object && _baseFor(object, iteratee, keys_1);
1078
- };
1079
- var mapValues_1 = function(object, iteratee) {
1080
- var result = {};
1081
- return iteratee = _baseIteratee(iteratee), _baseForOwn(object, function(value, key, object2) {
1082
- _baseAssignValue(result, key, iteratee(value, key, object2));
1083
- }), result;
1084
- }, _excluded$7 = ["changeKey", "text", "tokens", "renderToken"], defaultRenderToken = function defaultRenderToken2(_ref, i) {
1085
- var type = _ref.type, value = _ref.value, markType = _ref.markType, properties = _ref.properties, className = _ref.className, children = _ref.children, renderWithClassName = function(className2) {
1086
- return jsxRuntimeExports.jsx("span", { className: className2, children: value || children && children.map(defaultRenderToken2) }, i);
1087
- };
1088
- switch (type) {
1089
- case "text":
1090
- return value;
1091
- case "mark":
1092
- return renderWithClassName("diff-code-mark diff-code-mark-".concat(markType));
1093
- case "edit":
1094
- return renderWithClassName("diff-code-edit");
1095
- default:
1096
- var legacyClassName = properties && properties.className;
1097
- return renderWithClassName(classnames(className || legacyClassName));
1098
- }
1099
- };
1100
- function isEmptyToken(tokens) {
1101
- if (!Array.isArray(tokens)) return true;
1102
- if (tokens.length > 1) return false;
1103
- if (1 === tokens.length) {
1104
- var token = _slicedToArray(tokens, 1)[0];
1105
- return "text" === token.type && !token.value;
1106
- }
1107
- return true;
1108
- }
1109
- function CodeCell(props) {
1110
- var changeKey = props.changeKey, text = props.text, tokens = props.tokens, renderToken = props.renderToken, attributes = _objectWithoutProperties(props, _excluded$7), actualRenderToken = renderToken ? function(token, i) {
1111
- return renderToken(token, defaultRenderToken, i);
1112
- } : defaultRenderToken;
1113
- return jsxRuntimeExports.jsx("td", _objectSpread2(_objectSpread2({}, attributes), {}, { "data-change-key": changeKey, children: tokens ? isEmptyToken(tokens) ? " " : tokens.map(actualRenderToken) : text || " " }));
1114
- }
1115
- var CodeCell$1 = reactExports.memo(CodeCell);
1116
- function renderDefaultBy(change, side) {
1117
- return function() {
1118
- var lineNumber = "old" === side ? computeOldLineNumber(change) : computeNewLineNumber(change);
1119
- return -1 === lineNumber ? void 0 : lineNumber;
1120
- };
1121
- }
1122
- function wrapInAnchorBy(gutterAnchor, anchorTarget) {
1123
- return function(element) {
1124
- return gutterAnchor && element ? jsxRuntimeExports.jsx("a", { href: anchorTarget ? "#" + anchorTarget : void 0, children: element }) : element;
1125
- };
1126
- }
1127
- function composeCallback(own, custom) {
1128
- return custom ? function(e) {
1129
- own(), custom(e);
1130
- } : own;
1131
- }
1132
- function useBoundCallbacks(callbacks, arg, hoverOn, hoverOff) {
1133
- return reactExports.useMemo(function() {
1134
- var output = mapValues_1(callbacks, function(fn) {
1135
- return function(e) {
1136
- return fn && fn(arg, e);
1137
- };
1138
- });
1139
- return output.onMouseEnter = composeCallback(hoverOn, output.onMouseEnter), output.onMouseLeave = composeCallback(hoverOff, output.onMouseLeave), output;
1140
- }, [callbacks, hoverOn, hoverOff, arg]);
1141
- }
1142
- function renderGutterCell(className, change, changeKey, side, gutterAnchor, anchorTarget, events, inHoverState, renderGutter) {
1143
- var gutterOptions = { change, side, inHoverState, renderDefault: renderDefaultBy(change, side), wrapInAnchor: wrapInAnchorBy(gutterAnchor, anchorTarget) };
1144
- return jsxRuntimeExports.jsx("td", _objectSpread2(_objectSpread2({ className }, events), {}, { "data-change-key": changeKey, children: renderGutter(gutterOptions) }));
1145
- }
1146
- function UnifiedChange(props) {
1147
- var _useState2, value, setValue, change = props.change, selected = props.selected, tokens = props.tokens, className = props.className, generateLineClassName = props.generateLineClassName, gutterClassName = props.gutterClassName, codeClassName = props.codeClassName, gutterEvents = props.gutterEvents, codeEvents = props.codeEvents, hideGutter = props.hideGutter, gutterAnchor = props.gutterAnchor, generateAnchorID = props.generateAnchorID, renderToken = props.renderToken, renderGutter = props.renderGutter, type = change.type, content = change.content, changeKey = getChangeKey(change), _useBoolean = (_useState2 = _slicedToArray(reactExports.useState(false), 2), value = _useState2[0], setValue = _useState2[1], [value, reactExports.useCallback(function() {
1148
- return setValue(true);
1149
- }, []), reactExports.useCallback(function() {
1150
- return setValue(false);
1151
- }, [])]), _useBoolean2 = _slicedToArray(_useBoolean, 3), hover = _useBoolean2[0], hoverOn = _useBoolean2[1], hoverOff = _useBoolean2[2], eventArg = reactExports.useMemo(function() {
1152
- return { change };
1153
- }, [change]), boundGutterEvents = useBoundCallbacks(gutterEvents, eventArg, hoverOn, hoverOff), boundCodeEvents = useBoundCallbacks(codeEvents, eventArg, hoverOn, hoverOff), anchorID = generateAnchorID(change), lineClassName = generateLineClassName({ changes: [change], defaultGenerate: function() {
1154
- return className;
1155
- } }), gutterClassNameValue = classnames("diff-gutter", "diff-gutter-".concat(type), gutterClassName, { "diff-gutter-selected": selected }), codeClassNameValue = classnames("diff-code", "diff-code-".concat(type), codeClassName, { "diff-code-selected": selected });
1156
- return jsxRuntimeExports.jsxs("tr", { id: anchorID, className: classnames("diff-line", lineClassName), children: [!hideGutter && renderGutterCell(gutterClassNameValue, change, changeKey, "old", gutterAnchor, anchorID, boundGutterEvents, hover, renderGutter), !hideGutter && renderGutterCell(gutterClassNameValue, change, changeKey, "new", gutterAnchor, anchorID, boundGutterEvents, hover, renderGutter), jsxRuntimeExports.jsx(CodeCell$1, _objectSpread2({ className: codeClassNameValue, changeKey, text: content, tokens, renderToken }, boundCodeEvents))] });
1157
- }
1158
- var UnifiedChange$1 = reactExports.memo(UnifiedChange);
1159
- function UnifiedWidget(_ref) {
1160
- var hideGutter = _ref.hideGutter, element = _ref.element;
1161
- return jsxRuntimeExports.jsx("tr", { className: "diff-widget", children: jsxRuntimeExports.jsx("td", { colSpan: hideGutter ? 1 : 3, className: "diff-widget-content", children: element }) });
1162
- }
1163
- var _excluded$6 = ["hideGutter", "selectedChanges", "tokens", "lineClassName"], _excluded2$2 = ["hunk", "widgets", "className"];
1164
- function UnifiedHunk(props) {
1165
- var hunk = props.hunk, widgets = props.widgets, className = props.className, childrenProps = _objectWithoutProperties(props, _excluded2$2), elements = function(changes, widgets2) {
1166
- return changes.reduce(function(elements2, change) {
1167
- var key = getChangeKey(change);
1168
- elements2.push(["change", key, change]);
1169
- var widget = widgets2[key];
1170
- return widget && elements2.push(["widget", key, widget]), elements2;
1171
- }, []);
1172
- }(hunk.changes, widgets);
1173
- return jsxRuntimeExports.jsx("tbody", { className: classnames("diff-hunk", className), children: elements.map(function(element) {
1174
- return function(_ref, props2) {
1175
- var _ref2 = _slicedToArray(_ref, 3), type = _ref2[0], key = _ref2[1], value = _ref2[2], hideGutter = props2.hideGutter, selectedChanges = props2.selectedChanges, tokens = props2.tokens, lineClassName = props2.lineClassName, changeProps = _objectWithoutProperties(props2, _excluded$6);
1176
- if ("change" === type) {
1177
- var side = isDelete(value) ? "old" : "new", lineNumber = isDelete(value) ? computeOldLineNumber(value) : computeNewLineNumber(value), tokensOfLine = tokens ? tokens[side][lineNumber - 1] : null;
1178
- return jsxRuntimeExports.jsx(UnifiedChange$1, _objectSpread2({ className: lineClassName, change: value, hideGutter, selected: selectedChanges.includes(key), tokens: tokensOfLine }, changeProps), "change".concat(key));
1179
- }
1180
- return "widget" === type ? jsxRuntimeExports.jsx(UnifiedWidget, { hideGutter, element: value }, "widget".concat(key)) : null;
1181
- }(element, childrenProps);
1182
- }) });
1183
- }
1184
- var SIDE_OLD = 0;
1185
- function useCallbackOnSide(side, setHover, change, customCallbacks) {
1186
- var markHover = reactExports.useCallback(function() {
1187
- return setHover(side);
1188
- }, [side, setHover]), unmarkHover = reactExports.useCallback(function() {
1189
- return setHover("");
1190
- }, [setHover]);
1191
- return reactExports.useMemo(function() {
1192
- var callbacks = mapValues_1(customCallbacks, function(fn) {
1193
- return function(e) {
1194
- return fn && fn({ side, change }, e);
1195
- };
1196
- });
1197
- return callbacks.onMouseEnter = composeCallback(markHover, callbacks.onMouseEnter), callbacks.onMouseLeave = composeCallback(unmarkHover, callbacks.onMouseLeave), callbacks;
1198
- }, [change, customCallbacks, markHover, side, unmarkHover]);
1199
- }
1200
- function renderCells(args) {
1201
- var change = args.change, side = args.side, selected = args.selected, tokens = args.tokens, gutterClassName = args.gutterClassName, codeClassName = args.codeClassName, gutterEvents = args.gutterEvents, codeEvents = args.codeEvents, anchorID = args.anchorID, gutterAnchor = args.gutterAnchor, gutterAnchorTarget = args.gutterAnchorTarget, hideGutter = args.hideGutter, hover = args.hover, renderToken = args.renderToken, renderGutter = args.renderGutter;
1202
- if (!change) {
1203
- var _gutterClassNameValue = classnames("diff-gutter", "diff-gutter-omit", gutterClassName), _codeClassNameValue = classnames("diff-code", "diff-code-omit", codeClassName);
1204
- return [!hideGutter && jsxRuntimeExports.jsx("td", { className: _gutterClassNameValue }, "gutter"), jsxRuntimeExports.jsx("td", { className: _codeClassNameValue }, "code")];
1205
- }
1206
- var type = change.type, content = change.content, changeKey = getChangeKey(change), sideName = side === SIDE_OLD ? "old" : "new", gutterProps = _objectSpread2({ id: anchorID || void 0, className: classnames("diff-gutter", "diff-gutter-".concat(type), _defineProperty$1({ "diff-gutter-selected": selected }, "diff-line-hover-" + sideName, hover), gutterClassName), children: renderGutter({ change, side: sideName, inHoverState: hover, renderDefault: renderDefaultBy(change, sideName), wrapInAnchor: wrapInAnchorBy(gutterAnchor, gutterAnchorTarget) }) }, gutterEvents), codeClassNameValue = classnames("diff-code", "diff-code-".concat(type), _defineProperty$1({ "diff-code-selected": selected }, "diff-line-hover-" + sideName, hover), codeClassName);
1207
- return [!hideGutter && jsxRuntimeExports.jsx("td", _objectSpread2(_objectSpread2({}, gutterProps), {}, { "data-change-key": changeKey }), "gutter"), jsxRuntimeExports.jsx(CodeCell$1, _objectSpread2({ className: codeClassNameValue, changeKey, text: content, tokens, renderToken }, codeEvents), "code")];
1208
- }
1209
- function SplitChange(props) {
1210
- var className = props.className, oldChange = props.oldChange, newChange = props.newChange, oldSelected = props.oldSelected, newSelected = props.newSelected, oldTokens = props.oldTokens, newTokens = props.newTokens, monotonous = props.monotonous, gutterClassName = props.gutterClassName, codeClassName = props.codeClassName, gutterEvents = props.gutterEvents, codeEvents = props.codeEvents, hideGutter = props.hideGutter, generateAnchorID = props.generateAnchorID, generateLineClassName = props.generateLineClassName, gutterAnchor = props.gutterAnchor, renderToken = props.renderToken, renderGutter = props.renderGutter, _useState2 = _slicedToArray(reactExports.useState(""), 2), hover = _useState2[0], setHover = _useState2[1], oldGutterEvents = useCallbackOnSide("old", setHover, oldChange, gutterEvents), newGutterEvents = useCallbackOnSide("new", setHover, newChange, gutterEvents), oldCodeEvents = useCallbackOnSide("old", setHover, oldChange, codeEvents), newCodeEvents = useCallbackOnSide("new", setHover, newChange, codeEvents), oldAnchorID = oldChange && generateAnchorID(oldChange), newAnchorID = newChange && generateAnchorID(newChange), lineClassName = generateLineClassName({ changes: [oldChange, newChange], defaultGenerate: function() {
1211
- return className;
1212
- } }), commons = { monotonous, hideGutter, gutterClassName, codeClassName, gutterEvents, codeEvents, renderToken, renderGutter }, oldArgs = _objectSpread2(_objectSpread2({}, commons), {}, { change: oldChange, side: SIDE_OLD, selected: oldSelected, tokens: oldTokens, gutterEvents: oldGutterEvents, codeEvents: oldCodeEvents, anchorID: oldAnchorID, gutterAnchor, gutterAnchorTarget: oldAnchorID, hover: "old" === hover }), newArgs = _objectSpread2(_objectSpread2({}, commons), {}, { change: newChange, side: 1, selected: newSelected, tokens: newTokens, gutterEvents: newGutterEvents, codeEvents: newCodeEvents, anchorID: oldChange === newChange ? null : newAnchorID, gutterAnchor, gutterAnchorTarget: oldChange === newChange ? oldAnchorID : newAnchorID, hover: "new" === hover });
1213
- if (monotonous) return jsxRuntimeExports.jsx("tr", { className: classnames("diff-line", lineClassName), children: renderCells(oldChange ? oldArgs : newArgs) });
1214
- var lineTypeClassName = /* @__PURE__ */ function(oldChange2, newChange2) {
1215
- return oldChange2 && !newChange2 ? "diff-line-old-only" : !oldChange2 && newChange2 ? "diff-line-new-only" : oldChange2 === newChange2 ? "diff-line-normal" : "diff-line-compare";
1216
- }(oldChange, newChange);
1217
- return jsxRuntimeExports.jsxs("tr", { className: classnames("diff-line", lineTypeClassName, lineClassName), children: [renderCells(oldArgs), renderCells(newArgs)] });
1218
- }
1219
- var SplitChange$1 = reactExports.memo(SplitChange);
1220
- function SplitWidget(_ref) {
1221
- var hideGutter = _ref.hideGutter, oldElement = _ref.oldElement, newElement = _ref.newElement;
1222
- return _ref.monotonous ? jsxRuntimeExports.jsx("tr", { className: "diff-widget", children: jsxRuntimeExports.jsx("td", { colSpan: hideGutter ? 1 : 2, className: "diff-widget-content", children: oldElement || newElement }) }) : oldElement === newElement ? jsxRuntimeExports.jsx("tr", { className: "diff-widget", children: jsxRuntimeExports.jsx("td", { colSpan: hideGutter ? 2 : 4, className: "diff-widget-content", children: oldElement }) }) : jsxRuntimeExports.jsxs("tr", { className: "diff-widget", children: [jsxRuntimeExports.jsx("td", { colSpan: hideGutter ? 1 : 2, className: "diff-widget-content", children: oldElement }), jsxRuntimeExports.jsx("td", { colSpan: hideGutter ? 1 : 2, className: "diff-widget-content", children: newElement })] });
1223
- }
1224
- var _excluded$5 = ["selectedChanges", "monotonous", "hideGutter", "tokens", "lineClassName"], _excluded2$1 = ["hunk", "widgets", "className"];
1225
- function keyForPair(x, y) {
1226
- return (x ? getChangeKey(x) : "00") + (y ? getChangeKey(y) : "00");
1227
- }
1228
- function SplitHunk(props) {
1229
- var hunk = props.hunk, widgets = props.widgets, className = props.className, childrenProps = _objectWithoutProperties(props, _excluded2$1), elements = function(changes, widgets2) {
1230
- for (var findWidget = function(change) {
1231
- if (!change) return null;
1232
- var key2 = getChangeKey(change);
1233
- return widgets2[key2] || null;
1234
- }, elements2 = [], i = 0; i < changes.length; i++) {
1235
- var current2 = changes[i];
1236
- if (isNormal(current2)) elements2.push(["change", keyForPair(current2, current2), current2, current2]);
1237
- else if (isDelete(current2)) {
1238
- var next = changes[i + 1];
1239
- next && isInsert(next) ? (i += 1, elements2.push(["change", keyForPair(current2, next), current2, next])) : elements2.push(["change", keyForPair(current2, null), current2, null]);
1240
- } else elements2.push(["change", keyForPair(null, current2), null, current2]);
1241
- var rowChanges = elements2[elements2.length - 1], oldWidget = findWidget(rowChanges[2]), newWidget = findWidget(rowChanges[3]);
1242
- if (oldWidget || newWidget) {
1243
- var key = rowChanges[1];
1244
- elements2.push(["widget", key, oldWidget, newWidget]);
1245
- }
1246
- }
1247
- return elements2;
1248
- }(hunk.changes, widgets);
1249
- return jsxRuntimeExports.jsx("tbody", { className: classnames("diff-hunk", className), children: elements.map(function(item) {
1250
- return function(_ref, props2) {
1251
- var _ref2 = _slicedToArray(_ref, 4), type = _ref2[0], key = _ref2[1], oldValue = _ref2[2], newValue = _ref2[3], selectedChanges = props2.selectedChanges, monotonous = props2.monotonous, hideGutter = props2.hideGutter, tokens = props2.tokens, lineClassName = props2.lineClassName, changeProps = _objectWithoutProperties(props2, _excluded$5);
1252
- if ("change" === type) {
1253
- var oldSelected = !!oldValue && selectedChanges.includes(getChangeKey(oldValue)), newSelected = !!newValue && selectedChanges.includes(getChangeKey(newValue)), oldTokens = oldValue && tokens ? tokens.old[computeOldLineNumber(oldValue) - 1] : null, newTokens = newValue && tokens ? tokens.new[computeNewLineNumber(newValue) - 1] : null;
1254
- return jsxRuntimeExports.jsx(SplitChange$1, _objectSpread2({ className: lineClassName, oldChange: oldValue, newChange: newValue, monotonous, hideGutter, oldSelected, newSelected, oldTokens, newTokens }, changeProps), "change".concat(key));
1255
- }
1256
- return "widget" === type ? jsxRuntimeExports.jsx(SplitWidget, { monotonous, hideGutter, oldElement: oldValue, newElement: newValue }, "widget".concat(key)) : null;
1257
- }(item, childrenProps);
1258
- }) });
1259
- }
1260
- var _excluded$4 = ["gutterType", "hunkClassName"];
1261
- function Hunk(_ref) {
1262
- var hunk = _ref.hunk, _useDiffSettings = useDiffSettings(), gutterType = _useDiffSettings.gutterType, hunkClassName = _useDiffSettings.hunkClassName, context = _objectWithoutProperties(_useDiffSettings, _excluded$4), hideGutter = "none" === gutterType, gutterAnchor = "anchor" === gutterType, RenderingHunk = "unified" === context.viewType ? UnifiedHunk : SplitHunk;
1263
- return jsxRuntimeExports.jsx(RenderingHunk, _objectSpread2(_objectSpread2({}, context), {}, { hunk, hideGutter, gutterAnchor, className: hunkClassName }));
1264
- }
1265
- function noop() {
1266
- }
1267
- function setUserSelectStyle(element, selectable) {
1268
- var value = selectable ? "auto" : "none";
1269
- element instanceof HTMLElement && element.style.userSelect !== value && (element.style.userSelect = value);
1270
- }
1271
- function defaultRenderChildren(hunks) {
1272
- return hunks.map(function(hunk) {
1273
- return jsxRuntimeExports.jsx(Hunk, { hunk }, function(hunk2) {
1274
- return "-".concat(hunk2.oldStart, ",").concat(hunk2.oldLines, " +").concat(hunk2.newStart, ",").concat(hunk2.newLines);
1275
- }(hunk));
1276
- });
1277
- }
1278
- function Diff(props) {
1279
- var diffType = props.diffType, hunks = props.hunks, optimizeSelection = props.optimizeSelection, className = props.className, _props$hunkClassName = props.hunkClassName, hunkClassName = void 0 === _props$hunkClassName ? DEFAULT_CONTEXT_VALUE.hunkClassName : _props$hunkClassName, _props$lineClassName = props.lineClassName, lineClassName = void 0 === _props$lineClassName ? DEFAULT_CONTEXT_VALUE.lineClassName : _props$lineClassName, _props$generateLineCl = props.generateLineClassName, generateLineClassName = void 0 === _props$generateLineCl ? DEFAULT_CONTEXT_VALUE.generateLineClassName : _props$generateLineCl, _props$gutterClassNam = props.gutterClassName, gutterClassName = void 0 === _props$gutterClassNam ? DEFAULT_CONTEXT_VALUE.gutterClassName : _props$gutterClassNam, _props$codeClassName = props.codeClassName, codeClassName = void 0 === _props$codeClassName ? DEFAULT_CONTEXT_VALUE.codeClassName : _props$codeClassName, _props$gutterType = props.gutterType, gutterType = void 0 === _props$gutterType ? DEFAULT_CONTEXT_VALUE.gutterType : _props$gutterType, _props$viewType = props.viewType, viewType = void 0 === _props$viewType ? DEFAULT_CONTEXT_VALUE.viewType : _props$viewType, _props$gutterEvents = props.gutterEvents, gutterEvents = void 0 === _props$gutterEvents ? DEFAULT_CONTEXT_VALUE.gutterEvents : _props$gutterEvents, _props$codeEvents = props.codeEvents, codeEvents = void 0 === _props$codeEvents ? DEFAULT_CONTEXT_VALUE.codeEvents : _props$codeEvents, _props$generateAnchor = props.generateAnchorID, generateAnchorID = void 0 === _props$generateAnchor ? DEFAULT_CONTEXT_VALUE.generateAnchorID : _props$generateAnchor, _props$selectedChange = props.selectedChanges, selectedChanges = void 0 === _props$selectedChange ? DEFAULT_CONTEXT_VALUE.selectedChanges : _props$selectedChange, _props$widgets = props.widgets, widgets = void 0 === _props$widgets ? DEFAULT_CONTEXT_VALUE.widgets : _props$widgets, _props$renderGutter = props.renderGutter, renderGutter = void 0 === _props$renderGutter ? DEFAULT_CONTEXT_VALUE.renderGutter : _props$renderGutter, tokens = props.tokens, renderToken = props.renderToken, _props$children = props.children, children = void 0 === _props$children ? defaultRenderChildren : _props$children, root = reactExports.useRef(null), enableColumnSelection = reactExports.useCallback(function(_ref) {
1280
- var target = _ref.target;
1281
- if (0 === _ref.button) {
1282
- var closestCell = function(target2, className2) {
1283
- for (var current2 = target2; current2 && current2 !== document.documentElement && !current2.classList.contains(className2); ) current2 = current2.parentElement;
1284
- return current2 === document.documentElement ? null : current2;
1285
- }(target, "diff-code");
1286
- if (closestCell && closestCell.parentElement) {
1287
- var selection = window.getSelection();
1288
- selection && selection.removeAllRanges();
1289
- var index2 = _toConsumableArray(closestCell.parentElement.children).indexOf(closestCell);
1290
- if (1 === index2 || 3 === index2) {
1291
- var _step, _iterator = _createForOfIteratorHelper(root.current ? root.current.querySelectorAll(".diff-line") : []);
1292
- try {
1293
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
1294
- var cells = _step.value.children;
1295
- setUserSelectStyle(cells[1], 1 === index2), setUserSelectStyle(cells[3], 3 === index2);
1296
- }
1297
- } catch (err) {
1298
- _iterator.e(err);
1299
- } finally {
1300
- _iterator.f();
1301
- }
1302
- }
1303
- }
1304
- }
1305
- }, []), hideGutter = "none" === gutterType, monotonous = "add" === diffType || "delete" === diffType, onTableMouseDown = "split" === viewType && !monotonous && optimizeSelection ? enableColumnSelection : noop, cols = reactExports.useMemo(function() {
1306
- return jsxRuntimeExports.jsxs("colgroup", "unified" === viewType ? { children: [!hideGutter && jsxRuntimeExports.jsx("col", { className: "diff-gutter-col" }), !hideGutter && jsxRuntimeExports.jsx("col", { className: "diff-gutter-col" }), jsxRuntimeExports.jsx("col", {})] } : monotonous ? { children: [!hideGutter && jsxRuntimeExports.jsx("col", { className: "diff-gutter-col" }), jsxRuntimeExports.jsx("col", {})] } : { children: [!hideGutter && jsxRuntimeExports.jsx("col", { className: "diff-gutter-col" }), jsxRuntimeExports.jsx("col", {}), !hideGutter && jsxRuntimeExports.jsx("col", { className: "diff-gutter-col" }), jsxRuntimeExports.jsx("col", {})] });
1307
- }, [viewType, monotonous, hideGutter]), settingsContextValue = reactExports.useMemo(function() {
1308
- return { hunkClassName, lineClassName, generateLineClassName, gutterClassName, codeClassName, monotonous, hideGutter, viewType, gutterType, codeEvents, gutterEvents, generateAnchorID, selectedChanges, widgets, renderGutter, tokens, renderToken };
1309
- }, [codeClassName, codeEvents, generateAnchorID, gutterClassName, gutterEvents, gutterType, hideGutter, hunkClassName, lineClassName, generateLineClassName, monotonous, renderGutter, renderToken, selectedChanges, tokens, viewType, widgets]);
1310
- return jsxRuntimeExports.jsx(Provider, { value: settingsContextValue, children: jsxRuntimeExports.jsxs("table", { ref: root, className: classnames("diff", "diff-".concat(viewType), className), onMouseDown: onTableMouseDown, children: [cols, children(hunks)] }) });
1311
- }
1312
- var index = reactExports.memo(Diff);
1313
- function SplitDecoration(props) {
1314
- var hideGutter = props.hideGutter, monotonous = props.monotonous, className = props.className, gutterClassName = props.gutterClassName, contentClassName = props.contentClassName, children = props.children, computedClassName = classnames("diff-decoration", className), computedGutterClassName = classnames("diff-decoration-gutter", gutterClassName), computedContentClassName = classnames("diff-decoration-content", contentClassName), columnCount = (hideGutter ? 2 : 4) / (monotonous ? 2 : 1), headerContentColSpan = columnCount - (hideGutter ? 0 : 1);
1315
- if (1 === reactExports.Children.count(children)) return jsxRuntimeExports.jsx("tbody", { className: computedClassName, children: jsxRuntimeExports.jsx("tr", { children: jsxRuntimeExports.jsx("td", { colSpan: columnCount, className: computedContentClassName, children }) }) });
1316
- var _children = _slicedToArray(children, 2), gutter = _children[0], content = _children[1];
1317
- return jsxRuntimeExports.jsx("tbody", { className: computedClassName, children: jsxRuntimeExports.jsxs("tr", { children: [!hideGutter && jsxRuntimeExports.jsx("td", { className: computedGutterClassName, children: gutter }), jsxRuntimeExports.jsx("td", { colSpan: headerContentColSpan, className: computedContentClassName, children: content })] }) });
1318
- }
1319
- function UnifiedDecoration(props) {
1320
- var hideGutter = props.hideGutter, className = props.className, gutterClassName = props.gutterClassName, contentClassName = props.contentClassName, children = props.children, computedClassName = classnames("diff-decoration", className), computedGutterClassName = classnames("diff-decoration-gutter", gutterClassName), computedContentClassName = classnames("diff-decoration-content", contentClassName);
1321
- if (1 === reactExports.Children.count(children)) return jsxRuntimeExports.jsx("tbody", { className: computedClassName, children: jsxRuntimeExports.jsx("tr", { children: jsxRuntimeExports.jsx("td", { colSpan: hideGutter ? 1 : 3, className: computedContentClassName, children }) }) });
1322
- var _children = _slicedToArray(children, 2), gutter = _children[0], content = _children[1];
1323
- return jsxRuntimeExports.jsx("tbody", { className: computedClassName, children: jsxRuntimeExports.jsxs("tr", { children: [!hideGutter && jsxRuntimeExports.jsx("td", { colSpan: 2, className: computedGutterClassName, children: gutter }), jsxRuntimeExports.jsx("td", { className: computedContentClassName, children: content })] }) });
1324
- }
1325
- function Decoration(props) {
1326
- var _props$className = props.className, className = void 0 === _props$className ? "" : _props$className, _props$gutterClassNam = props.gutterClassName, gutterClassName = void 0 === _props$gutterClassNam ? "" : _props$gutterClassNam, _props$contentClassNa = props.contentClassName, contentClassName = void 0 === _props$contentClassNa ? "" : _props$contentClassNa, children = props.children, _useDiffSettings = useDiffSettings(), viewType = _useDiffSettings.viewType, gutterType = _useDiffSettings.gutterType, monotonous = _useDiffSettings.monotonous, RenderingDecoration = "split" === viewType ? SplitDecoration : UnifiedDecoration; reactExports.Children.count(children); var hideGutter = "none" === gutterType;
1327
- return jsxRuntimeExports.jsx(RenderingDecoration, { hideGutter, monotonous, className, gutterClassName, contentClassName, children });
1328
- }
1329
- var _arrayAggregator = function(array, setter, iteratee, accumulator) {
1330
- for (var index2 = -1, length = null == array ? 0 : array.length; ++index2 < length; ) {
1331
- var value = array[index2];
1332
- setter(accumulator, value, iteratee(value), array);
1333
- }
1334
- return accumulator;
1335
- };
1336
- var _createBaseEach = function(eachFunc, fromRight) {
1337
- return function(collection, iteratee) {
1338
- if (null == collection) return collection;
1339
- if (!isArrayLike_1(collection)) return eachFunc(collection, iteratee);
1340
- for (var length = collection.length, index2 = -1, iterable = Object(collection); (++index2 < length) && false !== iteratee(iterable[index2], index2, iterable); ) ;
1341
- return collection;
1342
- };
1343
- }, _baseEach = _createBaseEach(_baseForOwn);
1344
- var _baseAggregator = function(collection, setter, iteratee, accumulator) {
1345
- return _baseEach(collection, function(value, key, collection2) {
1346
- setter(accumulator, value, iteratee(value), collection2);
1347
- }), accumulator;
1348
- };
1349
- var _createAggregator = function(setter, initializer) {
1350
- return function(collection, iteratee) {
1351
- var func = isArray_1(collection) ? _arrayAggregator : _baseAggregator, accumulator = initializer ? initializer() : {};
1352
- return func(collection, setter, _baseIteratee(iteratee), accumulator);
1353
- };
1354
- }, keyBy_1 = _createAggregator(function(result, value, key) {
1355
- _baseAssignValue(result, key, value);
1356
- }), spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : void 0;
1357
- var _isFlattenable = function(value) {
1358
- return isArray_1(value) || isArguments_1(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
1359
- };
1360
- var _baseFlatten = function baseFlatten(array, depth, predicate, isStrict, result) {
1361
- var index2 = -1, length = array.length;
1362
- for (predicate || (predicate = _isFlattenable), result || (result = []); ++index2 < length; ) {
1363
- var value = array[index2];
1364
- predicate(value) ? _arrayPush(result, value) : (result[result.length] = value);
1365
- }
1366
- return result;
1367
- };
1368
- var _baseMap = function(collection, iteratee) {
1369
- var index2 = -1, result = isArrayLike_1(collection) ? Array(collection.length) : [];
1370
- return _baseEach(collection, function(value, key, collection2) {
1371
- result[++index2] = iteratee(value, key, collection2);
1372
- }), result;
1373
- };
1374
- var map_1 = function(collection, iteratee) {
1375
- return (isArray_1(collection) ? _arrayMap : _baseMap)(collection, _baseIteratee(iteratee));
1376
- };
1377
- var flatMap_1 = function(collection, iteratee) {
1378
- return _baseFlatten(map_1(collection, iteratee));
1379
- };
1380
- function applyHunk(linesOfCode, _ref) {
1381
- var newStart = _ref.newStart, _changes$reduce = _ref.changes.reduce(function(_ref2, change) {
1382
- var _ref3 = _slicedToArray(_ref2, 2), lines = _ref3[0], cursor = _ref3[1];
1383
- return isDelete(change) ? (lines.splice(cursor, 1), [lines, cursor]) : (isInsert(change) && lines.splice(cursor, 0, change.content), [lines, cursor + 1]);
1384
- }, [linesOfCode, newStart - 1]);
1385
- return _slicedToArray(_changes$reduce, 1)[0];
1386
- }
1387
- function mapChanges(changes, side, toValue) {
1388
- if (!changes.length) return [];
1389
- var computeLineNumber = "old" === side ? computeOldLineNumber : computeNewLineNumber, changesByLineNumber = keyBy_1(changes, computeLineNumber), maxLineNumber = computeLineNumber(changes[changes.length - 1]);
1390
- return Array.from({ length: maxLineNumber }).map(function(value, i) {
1391
- return toValue(changesByLineNumber[i + 1]);
1392
- });
1393
- }
1394
- function toTextPair(hunks) {
1395
- var _groupChanges = function(hunks2) {
1396
- return flatMap_1(hunks2, function(hunk) {
1397
- return hunk.changes;
1398
- }).reduce(function(_ref4, change) {
1399
- var _ref5 = _slicedToArray(_ref4, 2), oldChanges2 = _ref5[0], newChanges2 = _ref5[1];
1400
- return isNormal(change) ? (oldChanges2.push(change), newChanges2.push(change)) : isDelete(change) ? oldChanges2.push(change) : newChanges2.push(change), [oldChanges2, newChanges2];
1401
- }, [[], []]);
1402
- }(hunks), _groupChanges2 = _slicedToArray(_groupChanges, 2), oldChanges = _groupChanges2[0], newChanges = _groupChanges2[1], toText = function(change) {
1403
- return change ? change.content : "";
1404
- };
1405
- return [mapChanges(oldChanges, "old", toText).join("\n"), mapChanges(newChanges, "new", toText).join("\n")];
1406
- }
1407
- function createRoot(children) {
1408
- return { type: "root", children };
1409
- }
1410
- function toTokenTrees(hunks, options) {
1411
- if (options.oldSource) {
1412
- var newSource = function(oldSource, hunks2) {
1413
- return hunks2.reduce(applyHunk, oldSource.split("\n")).join("\n");
1414
- }(options.oldSource, hunks), highlightText = options.highlight ? function(text) {
1415
- return options.refractor.highlight(text, options.language);
1416
- } : function(text) {
1417
- return [{ type: "text", value: text }];
1418
- };
1419
- return [createRoot(highlightText(options.oldSource)), createRoot(highlightText(newSource))];
1420
- }
1421
- var _toTextPair2 = _slicedToArray(toTextPair(hunks), 2), oldText = _toTextPair2[0], newText = _toTextPair2[1], toTree = options.highlight ? function(text) {
1422
- return createRoot(options.refractor.highlight(text, options.language));
1423
- } : function(text) {
1424
- return createRoot([{ type: "text", value: text }]);
1425
- };
1426
- return [toTree(oldText), toTree(newText)];
1427
- }
1428
- function clone(path) {
1429
- return path.map(function(node) {
1430
- return _objectSpread2({}, node);
1431
- });
1432
- }
1433
- function replace(path, leaf) {
1434
- return [].concat(_toConsumableArray(clone(path.slice(0, -1))), [leaf]);
1435
- }
1436
- function leafOf(path) {
1437
- var last = path[path.length - 1];
1438
- if ("text" === last.type) return last;
1439
- throw new Error("Invalid token path with leaf of type ".concat(last.type));
1440
- }
1441
- function split(path, splitStart, splitEnd, wrapSplitNode) {
1442
- var parents = path.slice(0, -1), leaf = leafOf(path), output = [];
1443
- if (splitEnd <= 0 || splitStart >= (null == leaf ? void 0 : leaf.value.length)) return [path];
1444
- var split2 = function(start, end) {
1445
- var value = leaf.value.slice(start, end);
1446
- return [].concat(_toConsumableArray(parents), [_objectSpread2(_objectSpread2({}, leaf), {}, { value })]);
1447
- };
1448
- if (splitStart > 0) {
1449
- var head = split2(0, splitStart);
1450
- output.push(clone(head));
1451
- }
1452
- var body = split2(Math.max(splitStart, 0), splitEnd);
1453
- if (output.push(wrapSplitNode ? function(path2, parent) {
1454
- return [parent].concat(_toConsumableArray(clone(path2)));
1455
- }(body, wrapSplitNode) : clone(body)), splitEnd < leaf.value.length) {
1456
- var tail = split2(splitEnd);
1457
- output.push(clone(tail));
1458
- }
1459
- return output;
1460
- }
1461
- var _excluded$3 = ["children"];
1462
- function treeToPathList(node) {
1463
- var output = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [], path = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : [];
1464
- if (node.children) {
1465
- var children = node.children, nodeToUse = _objectWithoutProperties(node, _excluded$3);
1466
- path.push(nodeToUse);
1467
- var _step, _iterator = _createForOfIteratorHelper(children);
1468
- try {
1469
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
1470
- treeToPathList(_step.value, output, path);
1471
- }
1472
- } catch (err) {
1473
- _iterator.e(err);
1474
- } finally {
1475
- _iterator.f();
1476
- }
1477
- path.pop();
1478
- } else output.push(clone([].concat(_toConsumableArray(path.slice(1)), [node])));
1479
- return output;
1480
- }
1481
- function splitByLineBreak(paths) {
1482
- return paths.reduce(function(lines, path) {
1483
- var currentLine = lines[lines.length - 1], _splitPathToLines = function(path2) {
1484
- var leaf = leafOf(path2);
1485
- return leaf.value.includes("\n") ? leaf.value.split("\n").map(function(line) {
1486
- return replace(path2, _objectSpread2(_objectSpread2({}, leaf), {}, { value: line }));
1487
- }) : [path2];
1488
- }(path), _splitPathToLines2 = _toArray(_splitPathToLines), currentRemaining = _splitPathToLines2[0], nextLines = _splitPathToLines2.slice(1);
1489
- return [].concat(_toConsumableArray(lines.slice(0, -1)), [[].concat(_toConsumableArray(currentLine), [currentRemaining])], _toConsumableArray(nextLines.map(function(path2) {
1490
- return [path2];
1491
- })));
1492
- }, [[]]);
1493
- }
1494
- function normalizeToLines(tree) {
1495
- return splitByLineBreak(treeToPathList(tree));
1496
- }
1497
- var isEqualWith_1 = function(value, other, customizer) {
1498
- var result = (customizer = "function" == typeof customizer ? customizer : void 0) ? customizer(value, other) : void 0;
1499
- return void 0 === result ? _baseIsEqual(value, other, void 0, customizer) : !!result;
1500
- };
1501
- var isEqual_1 = function(value, other) {
1502
- return _baseIsEqual(value, other);
1503
- };
1504
- var last_1 = function(array) {
1505
- var length = null == array ? 0 : array.length;
1506
- return length ? array[length - 1] : void 0;
1507
- };
1508
- function attachNode(parent, node) {
1509
- if (!parent.children) throw new Error("parent node missing children property");
1510
- var x, y, previousSibling = last_1(parent.children);
1511
- return previousSibling && (y = node, (x = previousSibling).type === y.type && ("text" === x.type || x.children && y.children && isEqualWith_1(x, y, function(x2, y2, name) {
1512
- return "chlidren" === name || isEqual_1(x2, y2);
1513
- }))) ? parent.children[parent.children.length - 1] = function(x2, y2) {
1514
- return "value" in x2 && "value" in y2 ? _objectSpread2(_objectSpread2({}, x2), {}, { value: "".concat(x2.value).concat(y2.value) }) : x2;
1515
- }(previousSibling, node) : parent.children.push(node), parent.children[parent.children.length - 1];
1516
- }
1517
- function backToTree(pathList) {
1518
- var _step, root = { type: "root", children: [] }, _iterator = _createForOfIteratorHelper(pathList);
1519
- try {
1520
- var _loop = function() {
1521
- var path = _step.value;
1522
- path.reduce(function(parent, node, i) {
1523
- return attachNode(parent, i === path.length - 1 ? _objectSpread2({}, node) : _objectSpread2(_objectSpread2({}, node), {}, { children: [] }));
1524
- }, root);
1525
- };
1526
- for (_iterator.s(); !(_step = _iterator.n()).done; ) _loop();
1527
- } catch (err) {
1528
- _iterator.e(err);
1529
- } finally {
1530
- _iterator.f();
1531
- }
1532
- return root;
1533
- }
1534
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty, groupBy_1 = _createAggregator(function(result, value, key) {
1535
- hasOwnProperty$1.call(result, key) ? result[key].push(value) : _baseAssignValue(result, key, [value]);
1536
- }), hasOwnProperty = Object.prototype.hasOwnProperty;
1537
- var isEmpty_1 = function(value) {
1538
- if (null == value) return true;
1539
- if (isArrayLike_1(value) && (isArray_1(value) || "string" == typeof value || "function" == typeof value.splice || isBuffer_1(value) || isTypedArray_1(value) || isArguments_1(value))) return !value.length;
1540
- var tag = _getTag(value);
1541
- if ("[object Map]" == tag || "[object Set]" == tag) return !value.size;
1542
- if (_isPrototype(value)) return !_baseKeys(value).length;
1543
- for (var key in value) if (hasOwnProperty.call(value, key)) return false;
1544
- return true;
1545
- }, splitPathToEncloseRange = function(paths, node) {
1546
- var start = node.start, length = node.length, rangeEnd = start + length, _paths$reduce = paths.reduce(function(_ref, path) {
1547
- var _ref2 = _slicedToArray(_ref, 2), output = _ref2[0], nodeStart = _ref2[1], nodeEnd = nodeStart + leafOf(path).value.length;
1548
- if (nodeStart > rangeEnd || nodeEnd < start) output.push(path);
1549
- else {
1550
- var segments = split(path, start - nodeStart, rangeEnd - nodeStart, node);
1551
- output.push.apply(output, _toConsumableArray(segments));
1552
- }
1553
- return [output, nodeEnd];
1554
- }, [[], 0]);
1555
- return _slicedToArray(_paths$reduce, 1)[0];
1556
- };
1557
- function process$1(linesOfPaths, ranges) {
1558
- var rangesByLine = groupBy_1(ranges, "lineNumber");
1559
- return linesOfPaths.map(function(line, i) {
1560
- return function(paths, ranges2) {
1561
- return isEmpty_1(ranges2) ? paths : ranges2.reduce(splitPathToEncloseRange, paths);
1562
- }(line, rangesByLine[i + 1]);
1563
- });
1564
- }
1565
- function pickRanges(oldRanges, newRanges) {
1566
- return function(_ref3) {
1567
- var _ref4 = _slicedToArray(_ref3, 2), oldLinesOfPaths = _ref4[0], newLinesOfPaths = _ref4[1];
1568
- return [process$1(oldLinesOfPaths, oldRanges), process$1(newLinesOfPaths, newRanges)];
1569
- };
1570
- }
1571
- var flatten_1 = function(array) {
1572
- return (null == array ? 0 : array.length) ? _baseFlatten(array) : [];
1573
- }, nativeMax = Math.max;
1574
- var findIndex_1 = function(array, predicate, fromIndex) {
1575
- var length = null == array ? 0 : array.length;
1576
- if (!length) return -1;
1577
- var index2 = null == fromIndex ? 0 : toInteger_1(fromIndex);
1578
- return index2 < 0 && (index2 = nativeMax(length + index2, 0)), _baseFindIndex(array, _baseIteratee(predicate), index2);
1579
- }, diffMatchPatch = createCommonjsModule(function(module) {
1580
- var diff_match_patch = function() {
1581
- this.Diff_Timeout = 1, this.Diff_EditCost = 4, this.Match_Threshold = 0.5, this.Match_Distance = 1e3, this.Patch_DeleteThreshold = 0.5, this.Patch_Margin = 4, this.Match_MaxBits = 32;
1582
- };
1583
- diff_match_patch.Diff = function(op, text) {
1584
- return [op, text];
1585
- }, diff_match_patch.prototype.diff_main = function(text1, text2, opt_checklines, opt_deadline) {
1586
- void 0 === opt_deadline && (opt_deadline = this.Diff_Timeout <= 0 ? Number.MAX_VALUE : (/* @__PURE__ */ new Date()).getTime() + 1e3 * this.Diff_Timeout);
1587
- var deadline = opt_deadline;
1588
- if (null == text1 || null == text2) throw new Error("Null input. (diff_main)");
1589
- if (text1 == text2) return text1 ? [new diff_match_patch.Diff(0, text1)] : [];
1590
- void 0 === opt_checklines && (opt_checklines = true);
1591
- var checklines = opt_checklines, commonlength = this.diff_commonPrefix(text1, text2), commonprefix = text1.substring(0, commonlength);
1592
- text1 = text1.substring(commonlength), text2 = text2.substring(commonlength), commonlength = this.diff_commonSuffix(text1, text2);
1593
- var commonsuffix = text1.substring(text1.length - commonlength);
1594
- text1 = text1.substring(0, text1.length - commonlength), text2 = text2.substring(0, text2.length - commonlength);
1595
- var diffs = this.diff_compute_(text1, text2, checklines, deadline);
1596
- return commonprefix && diffs.unshift(new diff_match_patch.Diff(0, commonprefix)), commonsuffix && diffs.push(new diff_match_patch.Diff(0, commonsuffix)), this.diff_cleanupMerge(diffs), diffs;
1597
- }, diff_match_patch.prototype.diff_compute_ = function(text1, text2, checklines, deadline) {
1598
- var diffs;
1599
- if (!text1) return [new diff_match_patch.Diff(1, text2)];
1600
- if (!text2) return [new diff_match_patch.Diff(-1, text1)];
1601
- var longtext = text1.length > text2.length ? text1 : text2, shorttext = text1.length > text2.length ? text2 : text1, i = longtext.indexOf(shorttext);
1602
- if (-1 != i) return diffs = [new diff_match_patch.Diff(1, longtext.substring(0, i)), new diff_match_patch.Diff(0, shorttext), new diff_match_patch.Diff(1, longtext.substring(i + shorttext.length))], text1.length > text2.length && (diffs[0][0] = diffs[2][0] = -1), diffs;
1603
- if (1 == shorttext.length) return [new diff_match_patch.Diff(-1, text1), new diff_match_patch.Diff(1, text2)];
1604
- var hm = this.diff_halfMatch_(text1, text2);
1605
- if (hm) {
1606
- var text1_a = hm[0], text1_b = hm[1], text2_a = hm[2], text2_b = hm[3], mid_common = hm[4], diffs_a = this.diff_main(text1_a, text2_a, checklines, deadline), diffs_b = this.diff_main(text1_b, text2_b, checklines, deadline);
1607
- return diffs_a.concat([new diff_match_patch.Diff(0, mid_common)], diffs_b);
1608
- }
1609
- return checklines && text1.length > 100 && text2.length > 100 ? this.diff_lineMode_(text1, text2, deadline) : this.diff_bisect_(text1, text2, deadline);
1610
- }, diff_match_patch.prototype.diff_lineMode_ = function(text1, text2, deadline) {
1611
- var a = this.diff_linesToChars_(text1, text2);
1612
- text1 = a.chars1, text2 = a.chars2;
1613
- var linearray = a.lineArray, diffs = this.diff_main(text1, text2, false, deadline);
1614
- this.diff_charsToLines_(diffs, linearray), this.diff_cleanupSemantic(diffs), diffs.push(new diff_match_patch.Diff(0, ""));
1615
- for (var pointer = 0, count_delete = 0, count_insert = 0, text_delete = "", text_insert = ""; pointer < diffs.length; ) {
1616
- switch (diffs[pointer][0]) {
1617
- case 1:
1618
- count_insert++, text_insert += diffs[pointer][1];
1619
- break;
1620
- case -1:
1621
- count_delete++, text_delete += diffs[pointer][1];
1622
- break;
1623
- case 0:
1624
- if (count_delete >= 1 && count_insert >= 1) {
1625
- diffs.splice(pointer - count_delete - count_insert, count_delete + count_insert), pointer = pointer - count_delete - count_insert;
1626
- for (var subDiff = this.diff_main(text_delete, text_insert, false, deadline), j = subDiff.length - 1; j >= 0; j--) diffs.splice(pointer, 0, subDiff[j]);
1627
- pointer += subDiff.length;
1628
- }
1629
- count_insert = 0, count_delete = 0, text_delete = "", text_insert = "";
1630
- }
1631
- pointer++;
1632
- }
1633
- return diffs.pop(), diffs;
1634
- }, diff_match_patch.prototype.diff_bisect_ = function(text1, text2, deadline) {
1635
- for (var text1_length = text1.length, text2_length = text2.length, max_d = Math.ceil((text1_length + text2_length) / 2), v_offset = max_d, v_length = 2 * max_d, v1 = new Array(v_length), v2 = new Array(v_length), x = 0; x < v_length; x++) v1[x] = -1, v2[x] = -1;
1636
- v1[v_offset + 1] = 0, v2[v_offset + 1] = 0;
1637
- for (var delta = text1_length - text2_length, front = delta % 2 != 0, k1start = 0, k1end = 0, k2start = 0, k2end = 0, d = 0; d < max_d && !((/* @__PURE__ */ new Date()).getTime() > deadline); d++) {
1638
- for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
1639
- for (var k1_offset = v_offset + k1, y1 = (x1 = k1 == -d || k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1] ? v1[k1_offset + 1] : v1[k1_offset - 1] + 1) - k1; x1 < text1_length && y1 < text2_length && text1.charAt(x1) == text2.charAt(y1); ) x1++, y1++;
1640
- if (v1[k1_offset] = x1, x1 > text1_length) k1end += 2;
1641
- else if (y1 > text2_length) k1start += 2;
1642
- else if (front) {
1643
- if ((k2_offset = v_offset + delta - k1) >= 0 && k2_offset < v_length && -1 != v2[k2_offset]) {
1644
- if (x1 >= (x2 = text1_length - v2[k2_offset])) return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
1645
- }
1646
- }
1647
- }
1648
- for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
1649
- for (var x2, k2_offset = v_offset + k2, y2 = (x2 = k2 == -d || k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1] ? v2[k2_offset + 1] : v2[k2_offset - 1] + 1) - k2; x2 < text1_length && y2 < text2_length && text1.charAt(text1_length - x2 - 1) == text2.charAt(text2_length - y2 - 1); ) x2++, y2++;
1650
- if (v2[k2_offset] = x2, x2 > text1_length) k2end += 2;
1651
- else if (y2 > text2_length) k2start += 2;
1652
- else if (!front) {
1653
- if ((k1_offset = v_offset + delta - k2) >= 0 && k1_offset < v_length && -1 != v1[k1_offset]) {
1654
- var x1;
1655
- y1 = v_offset + (x1 = v1[k1_offset]) - k1_offset;
1656
- if (x1 >= (x2 = text1_length - x2)) return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
1657
- }
1658
- }
1659
- }
1660
- }
1661
- return [new diff_match_patch.Diff(-1, text1), new diff_match_patch.Diff(1, text2)];
1662
- }, diff_match_patch.prototype.diff_bisectSplit_ = function(text1, text2, x, y, deadline) {
1663
- var text1a = text1.substring(0, x), text2a = text2.substring(0, y), text1b = text1.substring(x), text2b = text2.substring(y), diffs = this.diff_main(text1a, text2a, false, deadline), diffsb = this.diff_main(text1b, text2b, false, deadline);
1664
- return diffs.concat(diffsb);
1665
- }, diff_match_patch.prototype.diff_linesToChars_ = function(text1, text2) {
1666
- var lineArray = [], lineHash = {};
1667
- function diff_linesToCharsMunge_(text) {
1668
- for (var chars = "", lineStart = 0, lineEnd = -1, lineArrayLength = lineArray.length; lineEnd < text.length - 1; ) {
1669
- -1 == (lineEnd = text.indexOf("\n", lineStart)) && (lineEnd = text.length - 1);
1670
- var line = text.substring(lineStart, lineEnd + 1);
1671
- (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : void 0 !== lineHash[line]) ? chars += String.fromCharCode(lineHash[line]) : (lineArrayLength == maxLines && (line = text.substring(lineStart), lineEnd = text.length), chars += String.fromCharCode(lineArrayLength), lineHash[line] = lineArrayLength, lineArray[lineArrayLength++] = line), lineStart = lineEnd + 1;
1672
- }
1673
- return chars;
1674
- }
1675
- lineArray[0] = "";
1676
- var maxLines = 4e4, chars1 = diff_linesToCharsMunge_(text1);
1677
- return maxLines = 65535, { chars1, chars2: diff_linesToCharsMunge_(text2), lineArray };
1678
- }, diff_match_patch.prototype.diff_charsToLines_ = function(diffs, lineArray) {
1679
- for (var i = 0; i < diffs.length; i++) {
1680
- for (var chars = diffs[i][1], text = [], j = 0; j < chars.length; j++) text[j] = lineArray[chars.charCodeAt(j)];
1681
- diffs[i][1] = text.join("");
1682
- }
1683
- }, diff_match_patch.prototype.diff_commonPrefix = function(text1, text2) {
1684
- if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) return 0;
1685
- for (var pointermin = 0, pointermax = Math.min(text1.length, text2.length), pointermid = pointermax, pointerstart = 0; pointermin < pointermid; ) text1.substring(pointerstart, pointermid) == text2.substring(pointerstart, pointermid) ? pointerstart = pointermin = pointermid : pointermax = pointermid, pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
1686
- return pointermid;
1687
- }, diff_match_patch.prototype.diff_commonSuffix = function(text1, text2) {
1688
- if (!text1 || !text2 || text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) return 0;
1689
- for (var pointermin = 0, pointermax = Math.min(text1.length, text2.length), pointermid = pointermax, pointerend = 0; pointermin < pointermid; ) text1.substring(text1.length - pointermid, text1.length - pointerend) == text2.substring(text2.length - pointermid, text2.length - pointerend) ? pointerend = pointermin = pointermid : pointermax = pointermid, pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
1690
- return pointermid;
1691
- }, diff_match_patch.prototype.diff_commonOverlap_ = function(text1, text2) {
1692
- var text1_length = text1.length, text2_length = text2.length;
1693
- if (0 == text1_length || 0 == text2_length) return 0;
1694
- text1_length > text2_length ? text1 = text1.substring(text1_length - text2_length) : text1_length < text2_length && (text2 = text2.substring(0, text1_length));
1695
- var text_length = Math.min(text1_length, text2_length);
1696
- if (text1 == text2) return text_length;
1697
- for (var best = 0, length = 1; ; ) {
1698
- var pattern = text1.substring(text_length - length), found = text2.indexOf(pattern);
1699
- if (-1 == found) return best;
1700
- length += found, 0 != found && text1.substring(text_length - length) != text2.substring(0, length) || (best = length, length++);
1701
- }
1702
- }, diff_match_patch.prototype.diff_halfMatch_ = function(text1, text2) {
1703
- if (this.Diff_Timeout <= 0) return null;
1704
- var longtext = text1.length > text2.length ? text1 : text2, shorttext = text1.length > text2.length ? text2 : text1;
1705
- if (longtext.length < 4 || 2 * shorttext.length < longtext.length) return null;
1706
- var dmp = this;
1707
- function diff_halfMatchI_(longtext2, shorttext2, i) {
1708
- for (var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b, seed = longtext2.substring(i, i + Math.floor(longtext2.length / 4)), j = -1, best_common = ""; -1 != (j = shorttext2.indexOf(seed, j + 1)); ) {
1709
- var prefixLength = dmp.diff_commonPrefix(longtext2.substring(i), shorttext2.substring(j)), suffixLength = dmp.diff_commonSuffix(longtext2.substring(0, i), shorttext2.substring(0, j));
1710
- best_common.length < suffixLength + prefixLength && (best_common = shorttext2.substring(j - suffixLength, j) + shorttext2.substring(j, j + prefixLength), best_longtext_a = longtext2.substring(0, i - suffixLength), best_longtext_b = longtext2.substring(i + prefixLength), best_shorttext_a = shorttext2.substring(0, j - suffixLength), best_shorttext_b = shorttext2.substring(j + prefixLength));
1711
- }
1712
- return 2 * best_common.length >= longtext2.length ? [best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b, best_common] : null;
1713
- }
1714
- var hm, text1_a, text1_b, text2_a, text2_b, hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4)), hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2));
1715
- return hm1 || hm2 ? (hm = hm2 ? hm1 && hm1[4].length > hm2[4].length ? hm1 : hm2 : hm1, text1.length > text2.length ? (text1_a = hm[0], text1_b = hm[1], text2_a = hm[2], text2_b = hm[3]) : (text2_a = hm[0], text2_b = hm[1], text1_a = hm[2], text1_b = hm[3]), [text1_a, text1_b, text2_a, text2_b, hm[4]]) : null;
1716
- }, diff_match_patch.prototype.diff_cleanupSemantic = function(diffs) {
1717
- for (var changes = false, equalities = [], equalitiesLength = 0, lastEquality = null, pointer = 0, length_insertions1 = 0, length_deletions1 = 0, length_insertions2 = 0, length_deletions2 = 0; pointer < diffs.length; ) 0 == diffs[pointer][0] ? (equalities[equalitiesLength++] = pointer, length_insertions1 = length_insertions2, length_deletions1 = length_deletions2, length_insertions2 = 0, length_deletions2 = 0, lastEquality = diffs[pointer][1]) : (1 == diffs[pointer][0] ? length_insertions2 += diffs[pointer][1].length : length_deletions2 += diffs[pointer][1].length, lastEquality && lastEquality.length <= Math.max(length_insertions1, length_deletions1) && lastEquality.length <= Math.max(length_insertions2, length_deletions2) && (diffs.splice(equalities[equalitiesLength - 1], 0, new diff_match_patch.Diff(-1, lastEquality)), diffs[equalities[equalitiesLength - 1] + 1][0] = 1, equalitiesLength--, pointer = --equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1, length_insertions1 = 0, length_deletions1 = 0, length_insertions2 = 0, length_deletions2 = 0, lastEquality = null, changes = true)), pointer++;
1718
- for (changes && this.diff_cleanupMerge(diffs), this.diff_cleanupSemanticLossless(diffs), pointer = 1; pointer < diffs.length; ) {
1719
- if (-1 == diffs[pointer - 1][0] && 1 == diffs[pointer][0]) {
1720
- var deletion = diffs[pointer - 1][1], insertion = diffs[pointer][1], overlap_length1 = this.diff_commonOverlap_(deletion, insertion), overlap_length2 = this.diff_commonOverlap_(insertion, deletion);
1721
- overlap_length1 >= overlap_length2 ? (overlap_length1 >= deletion.length / 2 || overlap_length1 >= insertion.length / 2) && (diffs.splice(pointer, 0, new diff_match_patch.Diff(0, insertion.substring(0, overlap_length1))), diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlap_length1), diffs[pointer + 1][1] = insertion.substring(overlap_length1), pointer++) : (overlap_length2 >= deletion.length / 2 || overlap_length2 >= insertion.length / 2) && (diffs.splice(pointer, 0, new diff_match_patch.Diff(0, deletion.substring(0, overlap_length2))), diffs[pointer - 1][0] = 1, diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlap_length2), diffs[pointer + 1][0] = -1, diffs[pointer + 1][1] = deletion.substring(overlap_length2), pointer++), pointer++;
1722
- }
1723
- pointer++;
1724
- }
1725
- }, diff_match_patch.prototype.diff_cleanupSemanticLossless = function(diffs) {
1726
- function diff_cleanupSemanticScore_(one, two) {
1727
- if (!one || !two) return 6;
1728
- var char1 = one.charAt(one.length - 1), char2 = two.charAt(0), nonAlphaNumeric1 = char1.match(diff_match_patch.nonAlphaNumericRegex_), nonAlphaNumeric2 = char2.match(diff_match_patch.nonAlphaNumericRegex_), whitespace1 = nonAlphaNumeric1 && char1.match(diff_match_patch.whitespaceRegex_), whitespace2 = nonAlphaNumeric2 && char2.match(diff_match_patch.whitespaceRegex_), lineBreak1 = whitespace1 && char1.match(diff_match_patch.linebreakRegex_), lineBreak2 = whitespace2 && char2.match(diff_match_patch.linebreakRegex_), blankLine1 = lineBreak1 && one.match(diff_match_patch.blanklineEndRegex_), blankLine2 = lineBreak2 && two.match(diff_match_patch.blanklineStartRegex_);
1729
- return blankLine1 || blankLine2 ? 5 : lineBreak1 || lineBreak2 ? 4 : nonAlphaNumeric1 && !whitespace1 && whitespace2 ? 3 : whitespace1 || whitespace2 ? 2 : nonAlphaNumeric1 || nonAlphaNumeric2 ? 1 : 0;
1730
- }
1731
- for (var pointer = 1; pointer < diffs.length - 1; ) {
1732
- if (0 == diffs[pointer - 1][0] && 0 == diffs[pointer + 1][0]) {
1733
- var equality1 = diffs[pointer - 1][1], edit = diffs[pointer][1], equality2 = diffs[pointer + 1][1], commonOffset = this.diff_commonSuffix(equality1, edit);
1734
- if (commonOffset) {
1735
- var commonString = edit.substring(edit.length - commonOffset);
1736
- equality1 = equality1.substring(0, equality1.length - commonOffset), edit = commonString + edit.substring(0, edit.length - commonOffset), equality2 = commonString + equality2;
1737
- }
1738
- for (var bestEquality1 = equality1, bestEdit = edit, bestEquality2 = equality2, bestScore = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2); edit.charAt(0) === equality2.charAt(0); ) {
1739
- equality1 += edit.charAt(0), edit = edit.substring(1) + equality2.charAt(0), equality2 = equality2.substring(1);
1740
- var score = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
1741
- score >= bestScore && (bestScore = score, bestEquality1 = equality1, bestEdit = edit, bestEquality2 = equality2);
1742
- }
1743
- diffs[pointer - 1][1] != bestEquality1 && (bestEquality1 ? diffs[pointer - 1][1] = bestEquality1 : (diffs.splice(pointer - 1, 1), pointer--), diffs[pointer][1] = bestEdit, bestEquality2 ? diffs[pointer + 1][1] = bestEquality2 : (diffs.splice(pointer + 1, 1), pointer--));
1744
- }
1745
- pointer++;
1746
- }
1747
- }, diff_match_patch.nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/, diff_match_patch.whitespaceRegex_ = /\s/, diff_match_patch.linebreakRegex_ = /[\r\n]/, diff_match_patch.blanklineEndRegex_ = /\n\r?\n$/, diff_match_patch.blanklineStartRegex_ = /^\r?\n\r?\n/, diff_match_patch.prototype.diff_cleanupEfficiency = function(diffs) {
1748
- for (var changes = false, equalities = [], equalitiesLength = 0, lastEquality = null, pointer = 0, pre_ins = false, pre_del = false, post_ins = false, post_del = false; pointer < diffs.length; ) 0 == diffs[pointer][0] ? (diffs[pointer][1].length < this.Diff_EditCost && (post_ins || post_del) ? (equalities[equalitiesLength++] = pointer, pre_ins = post_ins, pre_del = post_del, lastEquality = diffs[pointer][1]) : (equalitiesLength = 0, lastEquality = null), post_ins = post_del = false) : (-1 == diffs[pointer][0] ? post_del = true : post_ins = true, lastEquality && (pre_ins && pre_del && post_ins && post_del || lastEquality.length < this.Diff_EditCost / 2 && pre_ins + pre_del + post_ins + post_del == 3) && (diffs.splice(equalities[equalitiesLength - 1], 0, new diff_match_patch.Diff(-1, lastEquality)), diffs[equalities[equalitiesLength - 1] + 1][0] = 1, equalitiesLength--, lastEquality = null, pre_ins && pre_del ? (post_ins = post_del = true, equalitiesLength = 0) : (pointer = --equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1, post_ins = post_del = false), changes = true)), pointer++;
1749
- changes && this.diff_cleanupMerge(diffs);
1750
- }, diff_match_patch.prototype.diff_cleanupMerge = function(diffs) {
1751
- diffs.push(new diff_match_patch.Diff(0, ""));
1752
- for (var commonlength, pointer = 0, count_delete = 0, count_insert = 0, text_delete = "", text_insert = ""; pointer < diffs.length; ) switch (diffs[pointer][0]) {
1753
- case 1:
1754
- count_insert++, text_insert += diffs[pointer][1], pointer++;
1755
- break;
1756
- case -1:
1757
- count_delete++, text_delete += diffs[pointer][1], pointer++;
1758
- break;
1759
- case 0:
1760
- count_delete + count_insert > 1 ? (0 !== count_delete && 0 !== count_insert && (0 !== (commonlength = this.diff_commonPrefix(text_insert, text_delete)) && (pointer - count_delete - count_insert > 0 && 0 == diffs[pointer - count_delete - count_insert - 1][0] ? diffs[pointer - count_delete - count_insert - 1][1] += text_insert.substring(0, commonlength) : (diffs.splice(0, 0, new diff_match_patch.Diff(0, text_insert.substring(0, commonlength))), pointer++), text_insert = text_insert.substring(commonlength), text_delete = text_delete.substring(commonlength)), 0 !== (commonlength = this.diff_commonSuffix(text_insert, text_delete)) && (diffs[pointer][1] = text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1], text_insert = text_insert.substring(0, text_insert.length - commonlength), text_delete = text_delete.substring(0, text_delete.length - commonlength))), pointer -= count_delete + count_insert, diffs.splice(pointer, count_delete + count_insert), text_delete.length && (diffs.splice(pointer, 0, new diff_match_patch.Diff(-1, text_delete)), pointer++), text_insert.length && (diffs.splice(pointer, 0, new diff_match_patch.Diff(1, text_insert)), pointer++), pointer++) : 0 !== pointer && 0 == diffs[pointer - 1][0] ? (diffs[pointer - 1][1] += diffs[pointer][1], diffs.splice(pointer, 1)) : pointer++, count_insert = 0, count_delete = 0, text_delete = "", text_insert = "";
1761
- }
1762
- "" === diffs[diffs.length - 1][1] && diffs.pop();
1763
- var changes = false;
1764
- for (pointer = 1; pointer < diffs.length - 1; ) 0 == diffs[pointer - 1][0] && 0 == diffs[pointer + 1][0] && (diffs[pointer][1].substring(diffs[pointer][1].length - diffs[pointer - 1][1].length) == diffs[pointer - 1][1] ? (diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length), diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1], diffs.splice(pointer - 1, 1), changes = true) : diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) == diffs[pointer + 1][1] && (diffs[pointer - 1][1] += diffs[pointer + 1][1], diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1], diffs.splice(pointer + 1, 1), changes = true)), pointer++;
1765
- changes && this.diff_cleanupMerge(diffs);
1766
- }, diff_match_patch.prototype.diff_xIndex = function(diffs, loc) {
1767
- var x, chars1 = 0, chars2 = 0, last_chars1 = 0, last_chars2 = 0;
1768
- for (x = 0; x < diffs.length && (1 !== diffs[x][0] && (chars1 += diffs[x][1].length), -1 !== diffs[x][0] && (chars2 += diffs[x][1].length), !(chars1 > loc)); x++) last_chars1 = chars1, last_chars2 = chars2;
1769
- return diffs.length != x && -1 === diffs[x][0] ? last_chars2 : last_chars2 + (loc - last_chars1);
1770
- }, diff_match_patch.prototype.diff_prettyHtml = function(diffs) {
1771
- for (var html = [], pattern_amp = /&/g, pattern_lt = /</g, pattern_gt = />/g, pattern_para = /\n/g, x = 0; x < diffs.length; x++) {
1772
- var op = diffs[x][0], text = diffs[x][1].replace(pattern_amp, "&amp;").replace(pattern_lt, "&lt;").replace(pattern_gt, "&gt;").replace(pattern_para, "&para;<br>");
1773
- switch (op) {
1774
- case 1:
1775
- html[x] = '<ins style="background:#e6ffe6;">' + text + "</ins>";
1776
- break;
1777
- case -1:
1778
- html[x] = '<del style="background:#ffe6e6;">' + text + "</del>";
1779
- break;
1780
- case 0:
1781
- html[x] = "<span>" + text + "</span>";
1782
- }
1783
- }
1784
- return html.join("");
1785
- }, diff_match_patch.prototype.diff_text1 = function(diffs) {
1786
- for (var text = [], x = 0; x < diffs.length; x++) 1 !== diffs[x][0] && (text[x] = diffs[x][1]);
1787
- return text.join("");
1788
- }, diff_match_patch.prototype.diff_text2 = function(diffs) {
1789
- for (var text = [], x = 0; x < diffs.length; x++) -1 !== diffs[x][0] && (text[x] = diffs[x][1]);
1790
- return text.join("");
1791
- }, diff_match_patch.prototype.diff_levenshtein = function(diffs) {
1792
- for (var levenshtein = 0, insertions = 0, deletions = 0, x = 0; x < diffs.length; x++) {
1793
- var op = diffs[x][0], data = diffs[x][1];
1794
- switch (op) {
1795
- case 1:
1796
- insertions += data.length;
1797
- break;
1798
- case -1:
1799
- deletions += data.length;
1800
- break;
1801
- case 0:
1802
- levenshtein += Math.max(insertions, deletions), insertions = 0, deletions = 0;
1803
- }
1804
- }
1805
- return levenshtein += Math.max(insertions, deletions);
1806
- }, diff_match_patch.prototype.diff_toDelta = function(diffs) {
1807
- for (var text = [], x = 0; x < diffs.length; x++) switch (diffs[x][0]) {
1808
- case 1:
1809
- text[x] = "+" + encodeURI(diffs[x][1]);
1810
- break;
1811
- case -1:
1812
- text[x] = "-" + diffs[x][1].length;
1813
- break;
1814
- case 0:
1815
- text[x] = "=" + diffs[x][1].length;
1816
- }
1817
- return text.join(" ").replace(/%20/g, " ");
1818
- }, diff_match_patch.prototype.diff_fromDelta = function(text1, delta) {
1819
- for (var diffs = [], diffsLength = 0, pointer = 0, tokens = delta.split(/\t/g), x = 0; x < tokens.length; x++) {
1820
- var param = tokens[x].substring(1);
1821
- switch (tokens[x].charAt(0)) {
1822
- case "+":
1823
- try {
1824
- diffs[diffsLength++] = new diff_match_patch.Diff(1, decodeURI(param));
1825
- } catch (ex) {
1826
- throw new Error("Illegal escape in diff_fromDelta: " + param);
1827
- }
1828
- break;
1829
- case "-":
1830
- case "=":
1831
- var n = parseInt(param, 10);
1832
- if (isNaN(n) || n < 0) throw new Error("Invalid number in diff_fromDelta: " + param);
1833
- var text = text1.substring(pointer, pointer += n);
1834
- "=" == tokens[x].charAt(0) ? diffs[diffsLength++] = new diff_match_patch.Diff(0, text) : diffs[diffsLength++] = new diff_match_patch.Diff(-1, text);
1835
- break;
1836
- default:
1837
- if (tokens[x]) throw new Error("Invalid diff operation in diff_fromDelta: " + tokens[x]);
1838
- }
1839
- }
1840
- if (pointer != text1.length) throw new Error("Delta length (" + pointer + ") does not equal source text length (" + text1.length + ").");
1841
- return diffs;
1842
- }, diff_match_patch.prototype.match_main = function(text, pattern, loc) {
1843
- if (null == text || null == pattern || null == loc) throw new Error("Null input. (match_main)");
1844
- return loc = Math.max(0, Math.min(loc, text.length)), text == pattern ? 0 : text.length ? text.substring(loc, loc + pattern.length) == pattern ? loc : this.match_bitap_(text, pattern, loc) : -1;
1845
- }, diff_match_patch.prototype.match_bitap_ = function(text, pattern, loc) {
1846
- if (pattern.length > this.Match_MaxBits) throw new Error("Pattern too long for this browser.");
1847
- var s = this.match_alphabet_(pattern), dmp = this;
1848
- function match_bitapScore_(e, x) {
1849
- var accuracy = e / pattern.length, proximity = Math.abs(loc - x);
1850
- return dmp.Match_Distance ? accuracy + proximity / dmp.Match_Distance : proximity ? 1 : accuracy;
1851
- }
1852
- var score_threshold = this.Match_Threshold, best_loc = text.indexOf(pattern, loc);
1853
- -1 != best_loc && (score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold), -1 != (best_loc = text.lastIndexOf(pattern, loc + pattern.length)) && (score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold)));
1854
- var bin_min, bin_mid, matchmask = 1 << pattern.length - 1;
1855
- best_loc = -1;
1856
- for (var last_rd, bin_max = pattern.length + text.length, d = 0; d < pattern.length; d++) {
1857
- for (bin_min = 0, bin_mid = bin_max; bin_min < bin_mid; ) match_bitapScore_(d, loc + bin_mid) <= score_threshold ? bin_min = bin_mid : bin_max = bin_mid, bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min);
1858
- bin_max = bin_mid;
1859
- var start = Math.max(1, loc - bin_mid + 1), finish = Math.min(loc + bin_mid, text.length) + pattern.length, rd = Array(finish + 2);
1860
- rd[finish + 1] = (1 << d) - 1;
1861
- for (var j = finish; j >= start; j--) {
1862
- var charMatch = s[text.charAt(j - 1)];
1863
- if (rd[j] = 0 === d ? (rd[j + 1] << 1 | 1) & charMatch : (rd[j + 1] << 1 | 1) & charMatch | (last_rd[j + 1] | last_rd[j]) << 1 | 1 | last_rd[j + 1], rd[j] & matchmask) {
1864
- var score = match_bitapScore_(d, j - 1);
1865
- if (score <= score_threshold) {
1866
- if (score_threshold = score, !((best_loc = j - 1) > loc)) break;
1867
- start = Math.max(1, 2 * loc - best_loc);
1868
- }
1869
- }
1870
- }
1871
- if (match_bitapScore_(d + 1, loc) > score_threshold) break;
1872
- last_rd = rd;
1873
- }
1874
- return best_loc;
1875
- }, diff_match_patch.prototype.match_alphabet_ = function(pattern) {
1876
- for (var s = {}, i = 0; i < pattern.length; i++) s[pattern.charAt(i)] = 0;
1877
- for (i = 0; i < pattern.length; i++) s[pattern.charAt(i)] |= 1 << pattern.length - i - 1;
1878
- return s;
1879
- }, diff_match_patch.prototype.patch_addContext_ = function(patch, text) {
1880
- if (0 != text.length) {
1881
- if (null === patch.start2) throw Error("patch not initialized");
1882
- for (var pattern = text.substring(patch.start2, patch.start2 + patch.length1), padding = 0; text.indexOf(pattern) != text.lastIndexOf(pattern) && pattern.length < this.Match_MaxBits - this.Patch_Margin - this.Patch_Margin; ) padding += this.Patch_Margin, pattern = text.substring(patch.start2 - padding, patch.start2 + patch.length1 + padding);
1883
- padding += this.Patch_Margin;
1884
- var prefix = text.substring(patch.start2 - padding, patch.start2);
1885
- prefix && patch.diffs.unshift(new diff_match_patch.Diff(0, prefix));
1886
- var suffix = text.substring(patch.start2 + patch.length1, patch.start2 + patch.length1 + padding);
1887
- suffix && patch.diffs.push(new diff_match_patch.Diff(0, suffix)), patch.start1 -= prefix.length, patch.start2 -= prefix.length, patch.length1 += prefix.length + suffix.length, patch.length2 += prefix.length + suffix.length;
1888
- }
1889
- }, diff_match_patch.prototype.patch_make = function(a, opt_b, opt_c) {
1890
- var text1, diffs;
1891
- if ("string" == typeof a && "string" == typeof opt_b && void 0 === opt_c) text1 = a, (diffs = this.diff_main(text1, opt_b, true)).length > 2 && (this.diff_cleanupSemantic(diffs), this.diff_cleanupEfficiency(diffs));
1892
- else if (a && "object" == typeof a && void 0 === opt_b && void 0 === opt_c) diffs = a, text1 = this.diff_text1(diffs);
1893
- else if ("string" == typeof a && opt_b && "object" == typeof opt_b && void 0 === opt_c) text1 = a, diffs = opt_b;
1894
- else {
1895
- if ("string" != typeof a || "string" != typeof opt_b || !opt_c || "object" != typeof opt_c) throw new Error("Unknown call format to patch_make.");
1896
- text1 = a, diffs = opt_c;
1897
- }
1898
- if (0 === diffs.length) return [];
1899
- for (var patches = [], patch = new diff_match_patch.patch_obj(), patchDiffLength = 0, char_count1 = 0, char_count2 = 0, prepatch_text = text1, postpatch_text = text1, x = 0; x < diffs.length; x++) {
1900
- var diff_type = diffs[x][0], diff_text = diffs[x][1];
1901
- switch (patchDiffLength || 0 === diff_type || (patch.start1 = char_count1, patch.start2 = char_count2), diff_type) {
1902
- case 1:
1903
- patch.diffs[patchDiffLength++] = diffs[x], patch.length2 += diff_text.length, postpatch_text = postpatch_text.substring(0, char_count2) + diff_text + postpatch_text.substring(char_count2);
1904
- break;
1905
- case -1:
1906
- patch.length1 += diff_text.length, patch.diffs[patchDiffLength++] = diffs[x], postpatch_text = postpatch_text.substring(0, char_count2) + postpatch_text.substring(char_count2 + diff_text.length);
1907
- break;
1908
- case 0:
1909
- diff_text.length <= 2 * this.Patch_Margin && patchDiffLength && diffs.length != x + 1 ? (patch.diffs[patchDiffLength++] = diffs[x], patch.length1 += diff_text.length, patch.length2 += diff_text.length) : diff_text.length >= 2 * this.Patch_Margin && patchDiffLength && (this.patch_addContext_(patch, prepatch_text), patches.push(patch), patch = new diff_match_patch.patch_obj(), patchDiffLength = 0, prepatch_text = postpatch_text, char_count1 = char_count2);
1910
- }
1911
- 1 !== diff_type && (char_count1 += diff_text.length), -1 !== diff_type && (char_count2 += diff_text.length);
1912
- }
1913
- return patchDiffLength && (this.patch_addContext_(patch, prepatch_text), patches.push(patch)), patches;
1914
- }, diff_match_patch.prototype.patch_deepCopy = function(patches) {
1915
- for (var patchesCopy = [], x = 0; x < patches.length; x++) {
1916
- var patch = patches[x], patchCopy = new diff_match_patch.patch_obj();
1917
- patchCopy.diffs = [];
1918
- for (var y = 0; y < patch.diffs.length; y++) patchCopy.diffs[y] = new diff_match_patch.Diff(patch.diffs[y][0], patch.diffs[y][1]);
1919
- patchCopy.start1 = patch.start1, patchCopy.start2 = patch.start2, patchCopy.length1 = patch.length1, patchCopy.length2 = patch.length2, patchesCopy[x] = patchCopy;
1920
- }
1921
- return patchesCopy;
1922
- }, diff_match_patch.prototype.patch_apply = function(patches, text) {
1923
- if (0 == patches.length) return [text, []];
1924
- patches = this.patch_deepCopy(patches);
1925
- var nullPadding = this.patch_addPadding(patches);
1926
- text = nullPadding + text + nullPadding, this.patch_splitMax(patches);
1927
- for (var delta = 0, results = [], x = 0; x < patches.length; x++) {
1928
- var start_loc, text2, expected_loc = patches[x].start2 + delta, text1 = this.diff_text1(patches[x].diffs), end_loc = -1;
1929
- if (text1.length > this.Match_MaxBits ? -1 != (start_loc = this.match_main(text, text1.substring(0, this.Match_MaxBits), expected_loc)) && (-1 == (end_loc = this.match_main(text, text1.substring(text1.length - this.Match_MaxBits), expected_loc + text1.length - this.Match_MaxBits)) || start_loc >= end_loc) && (start_loc = -1) : start_loc = this.match_main(text, text1, expected_loc), -1 == start_loc) results[x] = false, delta -= patches[x].length2 - patches[x].length1;
1930
- else if (results[x] = true, delta = start_loc - expected_loc, text1 == (text2 = -1 == end_loc ? text.substring(start_loc, start_loc + text1.length) : text.substring(start_loc, end_loc + this.Match_MaxBits))) text = text.substring(0, start_loc) + this.diff_text2(patches[x].diffs) + text.substring(start_loc + text1.length);
1931
- else {
1932
- var diffs = this.diff_main(text1, text2, false);
1933
- if (text1.length > this.Match_MaxBits && this.diff_levenshtein(diffs) / text1.length > this.Patch_DeleteThreshold) results[x] = false;
1934
- else {
1935
- this.diff_cleanupSemanticLossless(diffs);
1936
- for (var index2, index1 = 0, y = 0; y < patches[x].diffs.length; y++) {
1937
- var mod = patches[x].diffs[y];
1938
- 0 !== mod[0] && (index2 = this.diff_xIndex(diffs, index1)), 1 === mod[0] ? text = text.substring(0, start_loc + index2) + mod[1] + text.substring(start_loc + index2) : -1 === mod[0] && (text = text.substring(0, start_loc + index2) + text.substring(start_loc + this.diff_xIndex(diffs, index1 + mod[1].length))), -1 !== mod[0] && (index1 += mod[1].length);
1939
- }
1940
- }
1941
- }
1942
- }
1943
- return [text = text.substring(nullPadding.length, text.length - nullPadding.length), results];
1944
- }, diff_match_patch.prototype.patch_addPadding = function(patches) {
1945
- for (var paddingLength = this.Patch_Margin, nullPadding = "", x = 1; x <= paddingLength; x++) nullPadding += String.fromCharCode(x);
1946
- for (x = 0; x < patches.length; x++) patches[x].start1 += paddingLength, patches[x].start2 += paddingLength;
1947
- var patch = patches[0], diffs = patch.diffs;
1948
- if (0 == diffs.length || 0 != diffs[0][0]) diffs.unshift(new diff_match_patch.Diff(0, nullPadding)), patch.start1 -= paddingLength, patch.start2 -= paddingLength, patch.length1 += paddingLength, patch.length2 += paddingLength;
1949
- else if (paddingLength > diffs[0][1].length) {
1950
- var extraLength = paddingLength - diffs[0][1].length;
1951
- diffs[0][1] = nullPadding.substring(diffs[0][1].length) + diffs[0][1], patch.start1 -= extraLength, patch.start2 -= extraLength, patch.length1 += extraLength, patch.length2 += extraLength;
1952
- }
1953
- if (0 == (diffs = (patch = patches[patches.length - 1]).diffs).length || 0 != diffs[diffs.length - 1][0]) diffs.push(new diff_match_patch.Diff(0, nullPadding)), patch.length1 += paddingLength, patch.length2 += paddingLength;
1954
- else if (paddingLength > diffs[diffs.length - 1][1].length) {
1955
- extraLength = paddingLength - diffs[diffs.length - 1][1].length;
1956
- diffs[diffs.length - 1][1] += nullPadding.substring(0, extraLength), patch.length1 += extraLength, patch.length2 += extraLength;
1957
- }
1958
- return nullPadding;
1959
- }, diff_match_patch.prototype.patch_splitMax = function(patches) {
1960
- for (var patch_size = this.Match_MaxBits, x = 0; x < patches.length; x++) if (!(patches[x].length1 <= patch_size)) {
1961
- var bigpatch = patches[x];
1962
- patches.splice(x--, 1);
1963
- for (var start1 = bigpatch.start1, start2 = bigpatch.start2, precontext = ""; 0 !== bigpatch.diffs.length; ) {
1964
- var patch = new diff_match_patch.patch_obj(), empty = true;
1965
- for (patch.start1 = start1 - precontext.length, patch.start2 = start2 - precontext.length, "" !== precontext && (patch.length1 = patch.length2 = precontext.length, patch.diffs.push(new diff_match_patch.Diff(0, precontext))); 0 !== bigpatch.diffs.length && patch.length1 < patch_size - this.Patch_Margin; ) {
1966
- var diff_type = bigpatch.diffs[0][0], diff_text = bigpatch.diffs[0][1];
1967
- 1 === diff_type ? (patch.length2 += diff_text.length, start2 += diff_text.length, patch.diffs.push(bigpatch.diffs.shift()), empty = false) : -1 === diff_type && 1 == patch.diffs.length && 0 == patch.diffs[0][0] && diff_text.length > 2 * patch_size ? (patch.length1 += diff_text.length, start1 += diff_text.length, empty = false, patch.diffs.push(new diff_match_patch.Diff(diff_type, diff_text)), bigpatch.diffs.shift()) : (diff_text = diff_text.substring(0, patch_size - patch.length1 - this.Patch_Margin), patch.length1 += diff_text.length, start1 += diff_text.length, 0 === diff_type ? (patch.length2 += diff_text.length, start2 += diff_text.length) : empty = false, patch.diffs.push(new diff_match_patch.Diff(diff_type, diff_text)), diff_text == bigpatch.diffs[0][1] ? bigpatch.diffs.shift() : bigpatch.diffs[0][1] = bigpatch.diffs[0][1].substring(diff_text.length));
1968
- }
1969
- precontext = (precontext = this.diff_text2(patch.diffs)).substring(precontext.length - this.Patch_Margin);
1970
- var postcontext = this.diff_text1(bigpatch.diffs).substring(0, this.Patch_Margin);
1971
- "" !== postcontext && (patch.length1 += postcontext.length, patch.length2 += postcontext.length, 0 !== patch.diffs.length && 0 === patch.diffs[patch.diffs.length - 1][0] ? patch.diffs[patch.diffs.length - 1][1] += postcontext : patch.diffs.push(new diff_match_patch.Diff(0, postcontext))), empty || patches.splice(++x, 0, patch);
1972
- }
1973
- }
1974
- }, diff_match_patch.prototype.patch_toText = function(patches) {
1975
- for (var text = [], x = 0; x < patches.length; x++) text[x] = patches[x];
1976
- return text.join("");
1977
- }, diff_match_patch.prototype.patch_fromText = function(textline) {
1978
- var patches = [];
1979
- if (!textline) return patches;
1980
- for (var text = textline.split("\n"), textPointer = 0, patchHeader = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/; textPointer < text.length; ) {
1981
- var m = text[textPointer].match(patchHeader);
1982
- if (!m) throw new Error("Invalid patch string: " + text[textPointer]);
1983
- var patch = new diff_match_patch.patch_obj();
1984
- for (patches.push(patch), patch.start1 = parseInt(m[1], 10), "" === m[2] ? (patch.start1--, patch.length1 = 1) : "0" == m[2] ? patch.length1 = 0 : (patch.start1--, patch.length1 = parseInt(m[2], 10)), patch.start2 = parseInt(m[3], 10), "" === m[4] ? (patch.start2--, patch.length2 = 1) : "0" == m[4] ? patch.length2 = 0 : (patch.start2--, patch.length2 = parseInt(m[4], 10)), textPointer++; textPointer < text.length; ) {
1985
- var sign = text[textPointer].charAt(0);
1986
- try {
1987
- var line = decodeURI(text[textPointer].substring(1));
1988
- } catch (ex) {
1989
- throw new Error("Illegal escape in patch_fromText: " + line);
1990
- }
1991
- if ("-" == sign) patch.diffs.push(new diff_match_patch.Diff(-1, line));
1992
- else if ("+" == sign) patch.diffs.push(new diff_match_patch.Diff(1, line));
1993
- else if (" " == sign) patch.diffs.push(new diff_match_patch.Diff(0, line));
1994
- else {
1995
- if ("@" == sign) break;
1996
- if ("" !== sign) throw new Error('Invalid patch mode "' + sign + '" in: ' + line);
1997
- }
1998
- textPointer++;
1999
- }
2000
- }
2001
- return patches;
2002
- }, (diff_match_patch.patch_obj = function() {
2003
- this.diffs = [], this.start1 = null, this.start2 = null, this.length1 = 0, this.length2 = 0;
2004
- }).prototype.toString = function() {
2005
- for (var op, text = ["@@ -" + (0 === this.length1 ? this.start1 + ",0" : 1 == this.length1 ? this.start1 + 1 : this.start1 + 1 + "," + this.length1) + " +" + (0 === this.length2 ? this.start2 + ",0" : 1 == this.length2 ? this.start2 + 1 : this.start2 + 1 + "," + this.length2) + " @@\n"], x = 0; x < this.diffs.length; x++) {
2006
- switch (this.diffs[x][0]) {
2007
- case 1:
2008
- op = "+";
2009
- break;
2010
- case -1:
2011
- op = "-";
2012
- break;
2013
- case 0:
2014
- op = " ";
2015
- }
2016
- text[x + 1] = op + encodeURI(this.diffs[x][1]) + "\n";
2017
- }
2018
- return text.join("").replace(/%20/g, " ");
2019
- }, module.exports = diff_match_patch, module.exports.diff_match_patch = diff_match_patch, module.exports.DIFF_DELETE = -1, module.exports.DIFF_INSERT = 1, module.exports.DIFF_EQUAL = 0;
2020
- }), DIFF_EQUAL = diffMatchPatch.DIFF_EQUAL, DIFF_DELETE = diffMatchPatch.DIFF_DELETE, DIFF_INSERT = diffMatchPatch.DIFF_INSERT;
2021
- function findChangeBlocks(changes) {
2022
- var start = findIndex_1(changes, function(change) {
2023
- return !isNormal(change);
2024
- });
2025
- if (-1 === start) return [];
2026
- var end = findIndex_1(changes, function(change) {
2027
- return !!isNormal(change);
2028
- }, start);
2029
- return -1 === end ? [changes.slice(start)] : [changes.slice(start, end)].concat(_toConsumableArray(findChangeBlocks(changes.slice(end))));
2030
- }
2031
- function splitDiffToLines(diffs) {
2032
- return diffs.reduce(function(lines, _ref3) {
2033
- var _ref4 = _slicedToArray(_ref3, 2), type = _ref4[0], _currentLines$map2 = _toArray(_ref4[1].split("\n").map(function(line) {
2034
- return [type, line];
2035
- })), currentLineRemaining = _currentLines$map2[0], nextLines = _currentLines$map2.slice(1);
2036
- return [].concat(_toConsumableArray(lines.slice(0, -1)), [[].concat(_toConsumableArray(lines[lines.length - 1]), [currentLineRemaining])], _toConsumableArray(nextLines.map(function(line) {
2037
- return [line];
2038
- })));
2039
- }, [[]]);
2040
- }
2041
- function diffsToEdits(diffs, lineNumber) {
2042
- return diffs.reduce(function(output, diff) {
2043
- var _output = _slicedToArray(output, 2), edits = _output[0], start = _output[1], _diff2 = _slicedToArray(diff, 2), type = _diff2[0], value = _diff2[1];
2044
- if (type !== DIFF_EQUAL) {
2045
- var edit = { type: "edit", lineNumber, start, length: value.length };
2046
- edits.push(edit);
2047
- }
2048
- return [edits, start + value.length];
2049
- }, [[], 0])[0];
2050
- }
2051
- function convertToLinesOfEdits(linesOfDiffs, startLineNumber) {
2052
- return flatMap_1(linesOfDiffs, function(diffs, i) {
2053
- return diffsToEdits(diffs, startLineNumber + i);
2054
- });
2055
- }
2056
- function diffText(x, y) {
2057
- var dmp = new diffMatchPatch(), diffs = dmp.diff_main(x, y);
2058
- return dmp.diff_cleanupSemantic(diffs), diffs.length <= 1 ? [[], []] : function(diffs2) {
2059
- return diffs2.reduce(function(_ref, diff) {
2060
- var _ref2 = _slicedToArray(_ref, 2), oldDiffs = _ref2[0], newDiffs = _ref2[1];
2061
- switch (_slicedToArray(diff, 1)[0]) {
2062
- case DIFF_INSERT:
2063
- newDiffs.push(diff);
2064
- break;
2065
- case DIFF_DELETE:
2066
- oldDiffs.push(diff);
2067
- break;
2068
- default:
2069
- oldDiffs.push(diff), newDiffs.push(diff);
2070
- }
2071
- return [oldDiffs, newDiffs];
2072
- }, [[], []]);
2073
- }(diffs);
2074
- }
2075
- function diffChangeBlock(changes) {
2076
- var _changes$reduce = changes.reduce(function(_ref5, change) {
2077
- var _ref6 = _slicedToArray(_ref5, 2), oldSource = _ref6[0], newSource = _ref6[1];
2078
- return isDelete(change) ? [oldSource + (oldSource ? "\n" : "") + change.content, newSource] : [oldSource, newSource + (newSource ? "\n" : "") + change.content];
2079
- }, ["", ""]), _changes$reduce2 = _slicedToArray(_changes$reduce, 2), _diffText2 = _slicedToArray(diffText(_changes$reduce2[0], _changes$reduce2[1]), 2), oldDiffs = _diffText2[0], newDiffs = _diffText2[1];
2080
- if (0 === oldDiffs.length && 0 === newDiffs.length) return [[], []];
2081
- var getLineNumber = function(change) {
2082
- if (change && !isNormal(change)) return change.lineNumber;
2083
- }, oldStartLineNumber = getLineNumber(changes.find(isDelete)), newStartLineNumber = getLineNumber(changes.find(isInsert));
2084
- if (void 0 === oldStartLineNumber || void 0 === newStartLineNumber) throw new Error("Could not find start line number for edit");
2085
- return [convertToLinesOfEdits(splitDiffToLines(oldDiffs), oldStartLineNumber), convertToLinesOfEdits(splitDiffToLines(newDiffs), newStartLineNumber)];
2086
- }
2087
- function diffByLine(changes) {
2088
- var _changes$reduce3 = changes.reduce(function(_ref7, currentChange) {
2089
- var _ref8 = _slicedToArray(_ref7, 3), oldEdits = _ref8[0], newEdits = _ref8[1], previousChange = _ref8[2];
2090
- if (!previousChange || !isDelete(previousChange) || !isInsert(currentChange)) return [oldEdits, newEdits, currentChange];
2091
- var _diffText4 = _slicedToArray(diffText(previousChange.content, currentChange.content), 2), oldDiffs = _diffText4[0], newDiffs = _diffText4[1];
2092
- return [oldEdits.concat(diffsToEdits(oldDiffs, previousChange.lineNumber)), newEdits.concat(diffsToEdits(newDiffs, currentChange.lineNumber)), currentChange];
2093
- }, [[], [], null]), _changes$reduce4 = _slicedToArray(_changes$reduce3, 2);
2094
- return [_changes$reduce4[0], _changes$reduce4[1]];
2095
- }
2096
- function markEdits(hunks) {
2097
- var _ref9$type = (arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}).type, findEdits = "block" === (void 0 === _ref9$type ? "block" : _ref9$type) ? diffChangeBlock : diffByLine, _changeBlocks$map$red = flatMap_1(hunks.map(function(hunk) {
2098
- return hunk.changes;
2099
- }), findChangeBlocks).map(findEdits).reduce(function(_ref10, _ref11) {
2100
- var _ref12 = _slicedToArray(_ref10, 2), oldEdits2 = _ref12[0], newEdits2 = _ref12[1], _ref13 = _slicedToArray(_ref11, 2), currentOld = _ref13[0], currentNew = _ref13[1];
2101
- return [oldEdits2.concat(currentOld), newEdits2.concat(currentNew)];
2102
- }, [[], []]), _changeBlocks$map$red2 = _slicedToArray(_changeBlocks$map$red, 2), oldEdits = _changeBlocks$map$red2[0], newEdits = _changeBlocks$map$red2[1];
2103
- return pickRanges(flatten_1(oldEdits), flatten_1(newEdits));
2104
- }
2105
- var _excluded$2 = ["enhancers"], tokenize = function(hunks) {
2106
- var pair, _ref = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, _ref$enhancers = _ref.enhancers, enhancers = void 0 === _ref$enhancers ? [] : _ref$enhancers, _toTokenTrees2 = _slicedToArray(toTokenTrees(hunks, _objectWithoutProperties(_ref, _excluded$2)), 2), oldTokenTree = _toTokenTrees2[0], newTokenTree = _toTokenTrees2[1], _ref2 = [normalizeToLines(oldTokenTree), normalizeToLines(newTokenTree)], _enhance = (pair = [_ref2[0], _ref2[1]], enhancers.reduce(function(input, enhance) {
2107
- return enhance(input);
2108
- }, pair)), _enhance2 = _slicedToArray(_enhance, 2), oldEnhanced = _enhance2[0], newEnhanced = _enhance2[1], _ref3 = [oldEnhanced.map(backToTree), newEnhanced.map(backToTree)], newTrees = _ref3[1];
2109
- return { old: _ref3[0].map(function(root) {
2110
- var _root$children;
2111
- return null !== (_root$children = root.children) && void 0 !== _root$children ? _root$children : [];
2112
- }), new: newTrees.map(function(root) {
2113
- var _root$children2;
2114
- return null !== (_root$children2 = root.children) && void 0 !== _root$children2 ? _root$children2 : [];
2115
- }) };
2116
- };
2117
-
2118
- function mapDiffType(status) {
2119
- switch (String(status || "").trim().toLowerCase()) {
2120
- case "added":
2121
- case "add":
2122
- return "add";
2123
- case "deleted":
2124
- case "delete":
2125
- return "delete";
2126
- case "renamed":
2127
- case "rename":
2128
- return "rename";
2129
- case "copied":
2130
- case "copy":
2131
- return "copy";
2132
- default:
2133
- return "modify";
2134
- }
2135
- }
2136
- function normalizeDiffStatus(status) {
2137
- return String(status || "").trim().toLowerCase();
2138
- }
2139
- function buildFallbackDiff(payload) {
2140
- const oldPath = payload.old_path || payload.path;
2141
- const newPath = payload.path;
2142
- const status = normalizeDiffStatus(payload.status);
2143
- const previousPathHeader = status === "added" || status === "add" ? "/dev/null" : `a/${oldPath}`;
2144
- const nextPathHeader = status === "deleted" || status === "delete" ? "/dev/null" : `b/${newPath}`;
2145
- const header = [
2146
- `diff --git a/${oldPath} b/${newPath}`,
2147
- `--- ${previousPathHeader}`,
2148
- `+++ ${nextPathHeader}`
2149
- ];
2150
- return [...header, ...payload.lines].join("\n");
2151
- }
2152
- function buildUnifiedDiff(payload) {
2153
- if (!payload.lines.length) return "";
2154
- const firstLine = String(payload.lines[0] || "");
2155
- const oldPath = payload.old_path || payload.path;
2156
- const newPath = payload.path;
2157
- if (firstLine.startsWith("diff --git ")) {
2158
- return payload.lines.join("\n");
2159
- }
2160
- if (firstLine.startsWith("--- ") || firstLine.startsWith("Binary files ")) {
2161
- return [`diff --git a/${oldPath} b/${newPath}`, ...payload.lines].join("\n");
2162
- }
2163
- return buildFallbackDiff(payload);
2164
- }
2165
- function formatPathLabel(diff, fallback) {
2166
- const displayPath = "display_path" in diff && typeof diff.display_path === "string" && diff.display_path.trim() ? diff.display_path.trim() : diff.path;
2167
- return formatGitDiffPathLabel(displayPath, diff.old_path, fallback);
2168
- }
2169
- function parseSingleFile(text) {
2170
- if (!text.trim()) return null;
2171
- try {
2172
- const files = parseDiff(text, { nearbySequences: "zip" });
2173
- return files[0] ?? null;
2174
- } catch {
2175
- return null;
2176
- }
2177
- }
2178
- function GitDiffViewer({
2179
- diff,
2180
- className,
2181
- pathLabel
2182
- }) {
2183
- const { t } = useI18n("workspace");
2184
- const diffText = reactExports.useMemo(() => diff ? buildUnifiedDiff(diff) : "", [diff]);
2185
- const parsed = reactExports.useMemo(() => parseSingleFile(diffText), [diffText]);
2186
- const tokens = reactExports.useMemo(() => {
2187
- if (!parsed?.hunks.length) return null;
2188
- try {
2189
- return tokenize(parsed.hunks, {
2190
- enhancers: [markEdits(parsed.hunks, { type: "line" })]
2191
- });
2192
- } catch {
2193
- return null;
2194
- }
2195
- }, [parsed]);
2196
- const resolvedPathLabel = diff ? pathLabel || formatPathLabel(diff, t("git_viewer_diff", void 0, "Diff")) : null;
2197
- if (!diff) {
2198
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm leading-7 text-muted-foreground", children: t("git_diff_none_selected", void 0, "No patch selected.") });
2199
- }
2200
- if (diff.binary) {
2201
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-testid": "git-unified-diff-viewer", className: cn("ds-stage-diff-shell", className), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ds-stage-diff-filehead", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
2202
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate text-[13px] font-medium text-foreground", children: resolvedPathLabel }),
2203
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 text-[11px] text-muted-foreground", children: t("git_diff_binary_changed", void 0, "Binary file changed.") })
2204
- ] }) }) });
2205
- }
2206
- if (!parsed || !parsed.hunks.length) {
2207
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-testid": "git-unified-diff-viewer", className: cn("ds-stage-diff-shell", className), children: [
2208
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ds-stage-diff-filehead", children: [
2209
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
2210
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate text-[13px] font-medium text-foreground", children: resolvedPathLabel }),
2211
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 text-[11px] text-muted-foreground", children: String(diff.status || "modified") })
2212
- ] }),
2213
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 text-[11px]", children: [
2214
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-emerald-700 dark:text-emerald-300", children: [
2215
- "+",
2216
- diff.added || 0
2217
- ] }),
2218
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-rose-700 dark:text-rose-300", children: [
2219
- "-",
2220
- diff.removed || 0
2221
- ] })
2222
- ] })
2223
- ] }),
2224
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "feed-scrollbar overflow-x-auto overflow-y-visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "min-w-max px-4 py-3 font-mono text-[12px] leading-6 text-foreground", children: diff.lines.join("\n") || t("git_diff_no_patch_lines", void 0, "No patch lines available.") }) })
2225
- ] });
2226
- }
2227
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-testid": "git-unified-diff-viewer", className: cn("ds-stage-diff-shell", className), children: [
2228
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ds-stage-diff-filehead", children: [
2229
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
2230
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate text-[13px] font-medium text-foreground", children: resolvedPathLabel }),
2231
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 text-[11px] text-muted-foreground", children: [
2232
- String(diff.status || "modified"),
2233
- " · ",
2234
- diff.base,
2235
- " → ",
2236
- diff.head
2237
- ] })
2238
- ] }),
2239
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 text-[11px]", children: [
2240
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-emerald-700 dark:text-emerald-300", children: [
2241
- "+",
2242
- diff.added || 0
2243
- ] }),
2244
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-rose-700 dark:text-rose-300", children: [
2245
- "-",
2246
- diff.removed || 0
2247
- ] })
2248
- ] })
2249
- ] }),
2250
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "feed-scrollbar overflow-x-auto overflow-y-visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-w-max", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2251
- index,
2252
- {
2253
- viewType: "unified",
2254
- diffType: parsed.type || mapDiffType(diff.status),
2255
- hunks: parsed.hunks,
2256
- gutterType: "default",
2257
- tokens,
2258
- className: "ds-github-diff-table",
2259
- children: (hunks) => hunks.flatMap((hunk) => [
2260
- /* @__PURE__ */ jsxRuntimeExports.jsx(Decoration, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ds-github-diff-hunk", children: hunk.content }) }, `decoration-${hunk.content}`),
2261
- /* @__PURE__ */ jsxRuntimeExports.jsx(Hunk, { hunk }, `hunk-${hunk.content}`)
2262
- ])
2263
- }
2264
- ) }) }),
2265
- diff.truncated ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-t border-black/[0.06] px-4 py-2 text-[11px] text-muted-foreground dark:border-white/[0.08]", children: t("git_diff_patch_truncated", void 0, "Patch output is truncated.") }) : null
2266
- ] });
2267
- }
2268
-
2269
- function resolveSnapshotRevision(document) {
2270
- const gitRevision = document?.meta?.git_revision;
2271
- if (typeof gitRevision === "string" && gitRevision.trim()) {
2272
- return gitRevision.trim();
2273
- }
2274
- const revision = String(document?.revision || "").trim();
2275
- return revision || null;
2276
- }
2277
- function GitSnapshotViewer({
2278
- document,
2279
- className
2280
- }) {
2281
- const { t } = useI18n("workspace");
2282
- const lines = reactExports.useMemo(() => String(document?.content || "").split("\n"), [document?.content]);
2283
- const revision = resolveSnapshotRevision(document);
2284
- const isBinaryLike = !document?.content && !document?.encoding && Number(document?.size_bytes || 0) > 0;
2285
- if (!document) {
2286
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm leading-7 text-muted-foreground", children: t("git_snapshot_none_selected", void 0, "No snapshot selected.") });
2287
- }
2288
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-testid": "git-snapshot-viewer", className: cn("ds-stage-diff-shell", className), children: [
2289
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ds-stage-diff-filehead", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
2290
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate text-[13px] font-medium text-foreground", children: document.path || document.title || t("git_viewer_snapshot", void 0, "Snapshot") }),
2291
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground", children: [
2292
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t("git_snapshot_meta_label", void 0, "Snapshot") }),
2293
- revision ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
2294
- "· ",
2295
- revision
2296
- ] }) : null,
2297
- document.mime_type ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
2298
- "· ",
2299
- document.mime_type
2300
- ] }) : null,
2301
- typeof document.size_bytes === "number" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
2302
- "· ",
2303
- document.size_bytes,
2304
- " bytes"
2305
- ] }) : null
2306
- ] })
2307
- ] }) }),
2308
- isBinaryLike ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-8 text-sm text-muted-foreground", children: t(
2309
- "git_snapshot_binary_unavailable",
2310
- void 0,
2311
- "Snapshot preview is unavailable for binary files."
2312
- ) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "feed-scrollbar overflow-x-auto overflow-y-visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-w-max", children: lines.length === 1 && lines[0] === "" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 font-mono text-[12px] leading-6 text-muted-foreground", children: t("git_snapshot_empty_file", void 0, "File is empty.") }) : lines.map((line, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
2313
- "div",
2314
- {
2315
- className: "grid grid-cols-[64px_minmax(0,1fr)] border-b border-black/[0.05] font-mono text-[12px] leading-6 text-foreground last:border-b-0 dark:border-white/[0.06]",
2316
- children: [
2317
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "select-none border-r border-black/[0.06] bg-black/[0.02] px-3 py-0.5 text-right text-[11px] text-muted-foreground dark:border-white/[0.06] dark:bg-white/[0.03]", children: index + 1 }),
2318
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "whitespace-pre px-4 py-0.5", children: line || " " })
2319
- ]
2320
- },
2321
- `snapshot-line-${index + 1}`
2322
- )) }) })
2323
- ] });
2324
- }
2325
-
2326
- const normalizeBoolean = (value) => {
2327
- if (typeof value === "boolean") return value;
2328
- return null;
2329
- };
2330
- const normalizeNumber = (value) => {
2331
- if (typeof value === "number" && Number.isFinite(value)) return value;
2332
- return null;
2333
- };
2334
- const normalizeString = (value) => {
2335
- if (typeof value !== "string") return null;
2336
- const trimmed = value.trim();
2337
- return trimmed || null;
2338
- };
2339
- const isFileChangeDiffPayload = (value) => Boolean(value && "available" in value);
2340
- function GitSnapshotContent({
2341
- document,
2342
- projectId,
2343
- parentTabId
2344
- }) {
2345
- const clearWorkspaceTabState = useWorkspaceSurfaceStore((state) => state.clearTabState);
2346
- const clearWorkspaceTabReferences = useWorkspaceSurfaceStore((state) => state.clearTabReferences);
2347
- const previewKind = reactExports.useMemo(() => inferSnapshotPreviewKind(document), [document]);
2348
- const snapshotFileNode = reactExports.useMemo(
2349
- () => document ? buildQuestFileNodeFromDocument(projectId, document) : null,
2350
- [document, projectId]
2351
- );
2352
- const previewTabId = reactExports.useMemo(
2353
- () => `${parentTabId}::snapshot-preview::${previewKind}`,
2354
- [parentTabId, previewKind]
2355
- );
2356
- const pluginProps = reactExports.useMemo(() => {
2357
- if (!snapshotFileNode) return null;
2358
- const resourcePath = snapshotFileNode.path ? toFilesResourcePath(snapshotFileNode.path) : void 0;
2359
- const fileMeta = {
2360
- updatedAt: snapshotFileNode.updatedAt,
2361
- sizeBytes: snapshotFileNode.size,
2362
- mimeType: snapshotFileNode.mimeType
2363
- };
2364
- return {
2365
- context: {
2366
- type: previewKind === "notebook" ? "notebook" : "file",
2367
- resourceId: snapshotFileNode.id,
2368
- resourceName: snapshotFileNode.name,
2369
- resourcePath,
2370
- mimeType: snapshotFileNode.mimeType,
2371
- customData: {
2372
- projectId,
2373
- readonly: true,
2374
- readOnlyMode: true,
2375
- size: snapshotFileNode.size,
2376
- fileMeta
2377
- }
2378
- },
2379
- tabId: previewTabId,
2380
- setDirty: () => void 0,
2381
- setTitle: () => void 0
2382
- };
2383
- }, [previewKind, previewTabId, projectId, snapshotFileNode]);
2384
- reactExports.useEffect(() => {
2385
- return () => {
2386
- clearWorkspaceTabReferences(previewTabId);
2387
- clearWorkspaceTabState(previewTabId);
2388
- };
2389
- }, [clearWorkspaceTabReferences, clearWorkspaceTabState, previewTabId]);
2390
- if (!document || previewKind === "plain" || !pluginProps) {
2391
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
2392
- GitSnapshotViewer,
2393
- {
2394
- document,
2395
- className: "border border-black/[0.06] bg-white/[0.92] shadow-none dark:border-white/[0.08] dark:bg-[rgba(24,26,31,0.92)]"
2396
- }
2397
- );
2398
- }
2399
- if (previewKind === "markdown") {
2400
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(MarkdownViewerPlugin, { ...pluginProps }) });
2401
- }
2402
- if (previewKind === "notebook") {
2403
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(NotebookEditor, { ...pluginProps, className: "h-full" }) });
2404
- }
2405
- if (previewKind === "pdf") {
2406
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PdfViewerPlugin, { ...pluginProps }) });
2407
- }
2408
- if (previewKind === "image") {
2409
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ImageViewerPlugin, { ...pluginProps }) });
2410
- }
2411
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
2412
- GitSnapshotViewer,
2413
- {
2414
- document,
2415
- className: "border border-black/[0.06] bg-white/[0.92] shadow-none dark:border-white/[0.08] dark:bg-[rgba(24,26,31,0.92)]"
2416
- }
2417
- );
2418
- }
2419
- function GitDiffViewerPlugin({
2420
- context,
2421
- tabId,
2422
- setTitle
2423
- }) {
2424
- const { t } = useI18n("workspace");
2425
- const custom = context.customData ?? {};
2426
- const updateWorkspaceTabState = useWorkspaceSurfaceStore((state) => state.updateTabState);
2427
- const projectId = normalizeString(custom.projectId);
2428
- const resolver = custom.resolver === "file_change" ? "file_change" : "git";
2429
- const initialMode = custom.initialMode === "snapshot" ? "snapshot" : "diff";
2430
- const base = normalizeString(custom.base);
2431
- const head = normalizeString(custom.head);
2432
- const path = normalizeString(custom.path);
2433
- const queryPath = normalizeString(custom.queryPath);
2434
- const displayPath = normalizeString(custom.displayPath);
2435
- const runId = normalizeString(custom.runId);
2436
- const eventId = normalizeString(custom.eventId);
2437
- const status = normalizeString(custom.status);
2438
- const oldPath = normalizeString(custom.oldPath);
2439
- const added = normalizeNumber(custom.added);
2440
- const removed = normalizeNumber(custom.removed);
2441
- const snapshotRevision = normalizeString(custom.snapshotRevision);
2442
- const snapshotDocumentId = normalizeString(custom.snapshotDocumentId);
2443
- const hasValidDiffContext = resolver === "file_change" ? Boolean(projectId && runId && queryPath) : Boolean(projectId && base && head && path);
2444
- const resolvedSnapshotDocumentId = snapshotDocumentId || (snapshotRevision && path ? `git::${snapshotRevision}::${path}` : null);
2445
- const hasValidSnapshotContext = Boolean(projectId && resolvedSnapshotDocumentId);
2446
- const explicitAllowSnapshot = normalizeBoolean(custom.allowSnapshot);
2447
- const explicitAllowDiff = normalizeBoolean(custom.allowDiff);
2448
- const allowSnapshot = explicitAllowSnapshot ?? hasValidSnapshotContext;
2449
- const allowDiff = explicitAllowDiff ?? hasValidDiffContext;
2450
- const [viewMode, setViewMode] = reactExports.useState(() => {
2451
- if (initialMode === "snapshot" && allowSnapshot) return "snapshot";
2452
- return "diff";
2453
- });
2454
- reactExports.useEffect(() => {
2455
- if (viewMode === "snapshot" && !allowSnapshot && allowDiff) {
2456
- setViewMode("diff");
2457
- return;
2458
- }
2459
- if (viewMode === "diff" && !allowDiff && allowSnapshot) {
2460
- setViewMode("snapshot");
2461
- }
2462
- }, [allowDiff, allowSnapshot, viewMode]);
2463
- const snapshotQuery = useQuery({
2464
- queryKey: ["git-diff-viewer", "snapshot", projectId, resolvedSnapshotDocumentId],
2465
- queryFn: () => client.openDocument(projectId, resolvedSnapshotDocumentId),
2466
- enabled: Boolean(projectId && resolvedSnapshotDocumentId && allowSnapshot && viewMode === "snapshot"),
2467
- staleTime: 3e4
2468
- });
2469
- const diffQuery = useQuery({
2470
- queryKey: ["git-diff-viewer", "diff", resolver, projectId, base, head, path, queryPath, runId, eventId],
2471
- queryFn: () => resolver === "file_change" ? client.fileChangeDiff(projectId, runId, queryPath, eventId || void 0) : client.gitDiffFile(projectId, base, head, path),
2472
- enabled: Boolean(hasValidDiffContext && allowDiff && viewMode === "diff"),
2473
- staleTime: 3e4
2474
- });
2475
- const mergedDiff = reactExports.useMemo(() => {
2476
- const payload = diffQuery.data ?? null;
2477
- if (!payload) return payload;
2478
- if (resolver === "file_change") {
2479
- return {
2480
- ...payload,
2481
- display_path: (isFileChangeDiffPayload(payload) ? payload.display_path : null) || displayPath || void 0,
2482
- run_id: isFileChangeDiffPayload(payload) ? payload.run_id || runId || void 0 : runId || void 0,
2483
- event_id: isFileChangeDiffPayload(payload) ? payload.event_id || eventId || void 0 : eventId || void 0
2484
- };
2485
- }
2486
- if (!path || !base || !head) return payload;
2487
- return {
2488
- ...payload,
2489
- path,
2490
- base,
2491
- head,
2492
- old_path: payload.old_path || oldPath || void 0,
2493
- status: payload.status || status || void 0,
2494
- added: payload.added ?? added ?? void 0,
2495
- removed: payload.removed ?? removed ?? void 0
2496
- };
2497
- }, [added, base, diffQuery.data, displayPath, eventId, head, oldPath, path, removed, resolver, runId, status]);
2498
- const resolvedBase = mergedDiff?.base || base || "";
2499
- const resolvedHead = mergedDiff?.head || head || "";
2500
- const resolvedStatus = mergedDiff?.status || status || "modified";
2501
- const resolvedOldPath = mergedDiff?.old_path || oldPath || null;
2502
- const resolvedAdded = mergedDiff?.added ?? added;
2503
- const resolvedRemoved = mergedDiff?.removed ?? removed;
2504
- const snapshotContentKind = reactExports.useMemo(
2505
- () => inferSnapshotContentKind(snapshotQuery.data),
2506
- [snapshotQuery.data]
2507
- );
2508
- const snapshotPreviewKind = reactExports.useMemo(
2509
- () => inferSnapshotPreviewKind(snapshotQuery.data),
2510
- [snapshotQuery.data]
2511
- );
2512
- const resolvedPathLabel = resolver === "file_change" ? (isFileChangeDiffPayload(mergedDiff) ? mergedDiff.display_path : null) || displayPath || mergedDiff?.path || queryPath || t("git_viewer_diff", void 0, "Diff") : formatGitDiffPathLabel(
2513
- path || mergedDiff?.path || displayPath,
2514
- resolvedOldPath,
2515
- t("git_viewer_diff", void 0, "Diff")
2516
- );
2517
- reactExports.useEffect(() => {
2518
- setTitle(resolvedPathLabel);
2519
- }, [resolvedPathLabel, setTitle]);
2520
- reactExports.useEffect(() => {
2521
- updateWorkspaceTabState(tabId, {
2522
- contentKind: viewMode === "snapshot" ? snapshotContentKind : "code",
2523
- documentMode: viewMode,
2524
- isReadOnly: true,
2525
- resourceName: resolvedPathLabel,
2526
- resourcePath: viewMode === "snapshot" ? snapshotQuery.data?.path || path || void 0 : mergedDiff?.path || path || queryPath || void 0
2527
- });
2528
- }, [
2529
- mergedDiff?.path,
2530
- path,
2531
- queryPath,
2532
- resolvedPathLabel,
2533
- snapshotContentKind,
2534
- snapshotQuery.data?.path,
2535
- tabId,
2536
- updateWorkspaceTabState,
2537
- viewMode
2538
- ]);
2539
- const unavailableMessage = resolver === "file_change" && isFileChangeDiffPayload(mergedDiff) && !mergedDiff.available ? mergedDiff.message || t("git_viewer_historical_patch_unavailable", void 0, "Historical patch unavailable.") : null;
2540
- const currentQuery = viewMode === "snapshot" ? snapshotQuery : diffQuery;
2541
- const useEmbeddedSnapshotShell = viewMode === "snapshot" && Boolean(snapshotQuery.data) && snapshotPreviewKind !== "plain";
2542
- if (!projectId || !hasValidSnapshotContext && !hasValidDiffContext) {
2543
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center px-6 text-sm text-muted-foreground", children: t("git_viewer_missing_context", void 0, "Missing diff context.") });
2544
- }
2545
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2546
- "div",
2547
- {
2548
- "data-testid": "git-diff-viewer-plugin",
2549
- className: "flex h-full min-h-0 flex-col bg-[rgba(250,248,244,0.86)] dark:bg-[rgba(18,20,24,0.92)]",
2550
- children: [
2551
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-b border-black/[0.06] px-6 py-5 dark:border-white/[0.08]", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4", children: [
2552
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
2553
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground", children: [
2554
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1", children: [
2555
- viewMode === "snapshot" ? /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(GitCompare, { className: "h-3.5 w-3.5" }),
2556
- viewMode === "snapshot" ? t("git_viewer_snapshot", void 0, "Snapshot") : resolver === "file_change" ? t("git_viewer_historical_diff", void 0, "Historical Diff") : t("git_viewer_diff", void 0, "Diff")
2557
- ] }),
2558
- viewMode === "diff" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2559
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "·" }),
2560
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: resolvedStatus })
2561
- ] }) : null
2562
- ] }),
2563
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 break-words text-[24px] font-semibold tracking-[-0.03em] text-foreground", children: resolvedPathLabel }),
2564
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-3 text-sm text-muted-foreground", children: [
2565
- viewMode === "snapshot" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2566
- snapshotRevision ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: snapshotRevision }) : null,
2567
- allowDiff && resolvedBase ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: resolvedBase }) : null,
2568
- allowDiff && resolvedBase && resolvedHead ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "→" }) : null,
2569
- allowDiff && resolvedHead ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: resolvedHead }) : null
2570
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2571
- resolvedBase ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: resolvedBase }) : null,
2572
- resolvedBase && resolvedHead ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "→" }) : null,
2573
- resolvedHead ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: resolvedHead }) : null
2574
- ] }),
2575
- resolvedAdded != null ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-emerald-700 dark:text-emerald-300", children: [
2576
- "+",
2577
- resolvedAdded
2578
- ] }) : null,
2579
- resolvedRemoved != null ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-rose-700 dark:text-rose-300", children: [
2580
- "-",
2581
- resolvedRemoved
2582
- ] }) : null
2583
- ] })
2584
- ] }),
2585
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
2586
- allowSnapshot || allowDiff ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-full border border-black/[0.08] bg-white/[0.86] p-1 dark:border-white/[0.1] dark:bg-white/[0.03]", children: [
2587
- allowSnapshot ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2588
- "button",
2589
- {
2590
- type: "button",
2591
- onClick: () => setViewMode("snapshot"),
2592
- "data-testid": "git-diff-viewer-snapshot-toggle",
2593
- className: cn(
2594
- "rounded-full px-3 py-1.5 text-[12px] font-medium transition-colors",
2595
- viewMode === "snapshot" ? "bg-black/[0.06] text-foreground dark:bg-white/[0.12]" : "text-muted-foreground hover:text-foreground"
2596
- ),
2597
- children: t("git_viewer_snapshot", void 0, "Snapshot")
2598
- }
2599
- ) : null,
2600
- allowDiff ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2601
- "button",
2602
- {
2603
- type: "button",
2604
- onClick: () => setViewMode("diff"),
2605
- "data-testid": "git-diff-viewer-diff-toggle",
2606
- className: cn(
2607
- "rounded-full px-3 py-1.5 text-[12px] font-medium transition-colors",
2608
- viewMode === "diff" ? "bg-black/[0.06] text-foreground dark:bg-white/[0.12]" : "text-muted-foreground hover:text-foreground"
2609
- ),
2610
- children: t("git_viewer_diff", void 0, "Diff")
2611
- }
2612
- ) : null
2613
- ] }) : null,
2614
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
2615
- Button,
2616
- {
2617
- type: "button",
2618
- size: "sm",
2619
- variant: "outline",
2620
- onClick: () => {
2621
- void currentQuery.refetch();
2622
- },
2623
- className: "h-9 rounded-full border-black/[0.08] bg-white/[0.86] px-3 text-[12px] shadow-none hover:bg-black/[0.03] dark:border-white/[0.1] dark:bg-white/[0.03] dark:hover:bg-white/[0.06]",
2624
- children: [
2625
- /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: cn("mr-1.5 h-3.5 w-3.5", currentQuery.isFetching && "animate-spin") }),
2626
- t("explorer_refresh")
2627
- ]
2628
- }
2629
- )
2630
- ] })
2631
- ] }) }),
2632
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2633
- "div",
2634
- {
2635
- className: cn(
2636
- "min-h-0 flex-1 px-6 py-6",
2637
- useEmbeddedSnapshotShell ? "overflow-hidden" : "overflow-y-auto"
2638
- ),
2639
- children: viewMode === "snapshot" ? !allowSnapshot || !hasValidSnapshotContext ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-[20px] border border-black/[0.08] bg-white/[0.82] px-4 py-4 text-sm leading-7 text-muted-foreground dark:border-white/[0.08] dark:bg-white/[0.04]", children: t("git_viewer_snapshot_unavailable", void 0, "Snapshot preview is unavailable for this file.") }) : snapshotQuery.isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm leading-7 text-muted-foreground", children: t("git_viewer_loading_snapshot", void 0, "Loading snapshot…") }) : snapshotQuery.isError ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-[20px] border border-rose-200/80 bg-rose-50/70 px-4 py-4 text-sm text-rose-700 dark:border-rose-400/20 dark:bg-rose-500/10 dark:text-rose-200", children: t("git_viewer_failed_snapshot", void 0, "Failed to load snapshot.") }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
2640
- GitSnapshotContent,
2641
- {
2642
- document: snapshotQuery.data,
2643
- projectId,
2644
- parentTabId: tabId
2645
- }
2646
- ) : !allowDiff || !hasValidDiffContext ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-[20px] border border-black/[0.08] bg-white/[0.82] px-4 py-4 text-sm leading-7 text-muted-foreground dark:border-white/[0.08] dark:bg-white/[0.04]", children: t("git_viewer_diff_unavailable", void 0, "Diff preview is unavailable for this file.") }) : diffQuery.isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm leading-7 text-muted-foreground", children: t("git_viewer_loading_diff", void 0, "Loading patch…") }) : diffQuery.isError ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-[20px] border border-rose-200/80 bg-rose-50/70 px-4 py-4 text-sm text-rose-700 dark:border-rose-400/20 dark:bg-rose-500/10 dark:text-rose-200", children: t("git_viewer_failed_diff", void 0, "Failed to load diff.") }) : unavailableMessage ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-[20px] border border-black/[0.08] bg-white/[0.82] px-4 py-4 text-sm leading-7 text-muted-foreground dark:border-white/[0.08] dark:bg-white/[0.04]", children: unavailableMessage }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
2647
- GitDiffViewer,
2648
- {
2649
- diff: mergedDiff,
2650
- pathLabel: resolvedPathLabel,
2651
- className: "border border-black/[0.06] bg-white/[0.92] shadow-none dark:border-white/[0.08] dark:bg-[rgba(24,26,31,0.92)]"
2652
- }
2653
- )
2654
- }
2655
- )
2656
- ]
2657
- }
2658
- );
2659
- }
2660
-
2661
- export { GitDiffViewerPlugin as default };