@jcheesepkg/nanobot 0.8.7 → 0.8.9

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 (99) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +7 -0
  2. package/dist/agent/tools/flex.test.d.mts +1 -0
  3. package/dist/agent/tools/flex.test.mjs +258 -0
  4. package/dist/agent/tools/flex.test.mjs.map +1 -0
  5. package/dist/channels/line.d.mts +3 -1
  6. package/dist/channels/line.d.mts.map +1 -1
  7. package/dist/channels/line.mjs +56 -6
  8. package/dist/channels/line.mjs.map +1 -1
  9. package/dist/channels/line.test.d.mts +1 -0
  10. package/dist/channels/line.test.mjs +202 -0
  11. package/dist/channels/line.test.mjs.map +1 -0
  12. package/dist/config/schema.d.mts +18 -18
  13. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
  14. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  15. package/dist/node_modules/@vitest/expect/dist/index.mjs +1257 -0
  16. package/dist/node_modules/@vitest/expect/dist/index.mjs.map +1 -0
  17. package/dist/node_modules/@vitest/pretty-format/dist/index.mjs +815 -0
  18. package/dist/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -0
  19. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.mjs +43 -0
  20. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.mjs.map +1 -0
  21. package/dist/node_modules/@vitest/runner/dist/index.mjs +563 -0
  22. package/dist/node_modules/@vitest/runner/dist/index.mjs.map +1 -0
  23. package/dist/node_modules/@vitest/runner/dist/utils.mjs +3 -0
  24. package/dist/node_modules/@vitest/snapshot/dist/index.mjs +1736 -0
  25. package/dist/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -0
  26. package/dist/node_modules/@vitest/snapshot/node_modules/pathe/dist/shared/pathe.ff20891b.mjs +82 -0
  27. package/dist/node_modules/@vitest/snapshot/node_modules/pathe/dist/shared/pathe.ff20891b.mjs.map +1 -0
  28. package/dist/node_modules/@vitest/spy/dist/index.mjs +139 -0
  29. package/dist/node_modules/@vitest/spy/dist/index.mjs.map +1 -0
  30. package/dist/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.mjs +119 -0
  31. package/dist/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.mjs.map +1 -0
  32. package/dist/node_modules/@vitest/utils/dist/diff.mjs +1227 -0
  33. package/dist/node_modules/@vitest/utils/dist/diff.mjs.map +1 -0
  34. package/dist/node_modules/@vitest/utils/dist/error.mjs +92 -0
  35. package/dist/node_modules/@vitest/utils/dist/error.mjs.map +1 -0
  36. package/dist/node_modules/@vitest/utils/dist/helpers.mjs +113 -0
  37. package/dist/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -0
  38. package/dist/node_modules/@vitest/utils/dist/index.mjs +455 -0
  39. package/dist/node_modules/@vitest/utils/dist/index.mjs.map +1 -0
  40. package/dist/node_modules/@vitest/utils/dist/source-map.mjs +164 -0
  41. package/dist/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -0
  42. package/dist/node_modules/chai/index.mjs +3088 -0
  43. package/dist/node_modules/chai/index.mjs.map +1 -0
  44. package/dist/node_modules/loupe/lib/arguments.mjs +12 -0
  45. package/dist/node_modules/loupe/lib/arguments.mjs.map +1 -0
  46. package/dist/node_modules/loupe/lib/array.mjs +17 -0
  47. package/dist/node_modules/loupe/lib/array.mjs.map +1 -0
  48. package/dist/node_modules/loupe/lib/bigint.mjs +12 -0
  49. package/dist/node_modules/loupe/lib/bigint.mjs.map +1 -0
  50. package/dist/node_modules/loupe/lib/class.mjs +16 -0
  51. package/dist/node_modules/loupe/lib/class.mjs.map +1 -0
  52. package/dist/node_modules/loupe/lib/date.mjs +14 -0
  53. package/dist/node_modules/loupe/lib/date.mjs.map +1 -0
  54. package/dist/node_modules/loupe/lib/error.mjs +35 -0
  55. package/dist/node_modules/loupe/lib/error.mjs.map +1 -0
  56. package/dist/node_modules/loupe/lib/function.mjs +13 -0
  57. package/dist/node_modules/loupe/lib/function.mjs.map +1 -0
  58. package/dist/node_modules/loupe/lib/helpers.mjs +123 -0
  59. package/dist/node_modules/loupe/lib/helpers.mjs.map +1 -0
  60. package/dist/node_modules/loupe/lib/html.mjs +40 -0
  61. package/dist/node_modules/loupe/lib/html.mjs.map +1 -0
  62. package/dist/node_modules/loupe/lib/index.mjs +100 -0
  63. package/dist/node_modules/loupe/lib/index.mjs.map +1 -0
  64. package/dist/node_modules/loupe/lib/map.mjs +26 -0
  65. package/dist/node_modules/loupe/lib/map.mjs.map +1 -0
  66. package/dist/node_modules/loupe/lib/number.mjs +15 -0
  67. package/dist/node_modules/loupe/lib/number.mjs.map +1 -0
  68. package/dist/node_modules/loupe/lib/object.mjs +22 -0
  69. package/dist/node_modules/loupe/lib/object.mjs.map +1 -0
  70. package/dist/node_modules/loupe/lib/promise.mjs +6 -0
  71. package/dist/node_modules/loupe/lib/promise.mjs.map +1 -0
  72. package/dist/node_modules/loupe/lib/regexp.mjs +13 -0
  73. package/dist/node_modules/loupe/lib/regexp.mjs.map +1 -0
  74. package/dist/node_modules/loupe/lib/set.mjs +19 -0
  75. package/dist/node_modules/loupe/lib/set.mjs.map +1 -0
  76. package/dist/node_modules/loupe/lib/string.mjs +26 -0
  77. package/dist/node_modules/loupe/lib/string.mjs.map +1 -0
  78. package/dist/node_modules/loupe/lib/symbol.mjs +9 -0
  79. package/dist/node_modules/loupe/lib/symbol.mjs.map +1 -0
  80. package/dist/node_modules/loupe/lib/typedarray.mjs +31 -0
  81. package/dist/node_modules/loupe/lib/typedarray.mjs.map +1 -0
  82. package/dist/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
  83. package/dist/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
  84. package/dist/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.mjs +82 -0
  85. package/dist/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.mjs.map +1 -0
  86. package/dist/node_modules/tinyrainbow/dist/node.mjs +9 -0
  87. package/dist/node_modules/tinyrainbow/dist/node.mjs.map +1 -0
  88. package/dist/node_modules/tinyspy/dist/index.mjs +79 -0
  89. package/dist/node_modules/tinyspy/dist/index.mjs.map +1 -0
  90. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.mjs +9 -0
  91. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.mjs.map +1 -0
  92. package/dist/node_modules/vitest/dist/chunks/date.W2xKR2qe.mjs +51 -0
  93. package/dist/node_modules/vitest/dist/chunks/date.W2xKR2qe.mjs.map +1 -0
  94. package/dist/node_modules/vitest/dist/chunks/utils.C8RiOc4B.mjs +49 -0
  95. package/dist/node_modules/vitest/dist/chunks/utils.C8RiOc4B.mjs.map +1 -0
  96. package/dist/node_modules/vitest/dist/chunks/vi.DgezovHB.mjs +2425 -0
  97. package/dist/node_modules/vitest/dist/chunks/vi.DgezovHB.mjs.map +1 -0
  98. package/package.json +1 -1
  99. package/skills/skill-creator/SKILL.md +29 -0
@@ -0,0 +1,1227 @@
1
+ import { p } from "../../../tinyrainbow/dist/node.mjs";
2
+ import { format, plugins } from "../../pretty-format/dist/index.mjs";
3
+ import "../../../loupe/lib/index.mjs";
4
+ import { getDefaultExportFromCjs, stringify } from "./chunk-_commonjsHelpers.mjs";
5
+ import { deepClone, getOwnProperties, getType as getType$1 } from "./helpers.mjs";
6
+
7
+ //#region node_modules/@vitest/utils/dist/diff.js
8
+ const DIFF_DELETE = -1;
9
+ const DIFF_INSERT = 1;
10
+ const DIFF_EQUAL = 0;
11
+ var Diff = class {
12
+ 0;
13
+ 1;
14
+ constructor(op, text) {
15
+ this[0] = op;
16
+ this[1] = text;
17
+ }
18
+ };
19
+ const diff_commonPrefix = function(text1, text2) {
20
+ if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) return 0;
21
+ let pointermin = 0;
22
+ let pointermax = Math.min(text1.length, text2.length);
23
+ let pointermid = pointermax;
24
+ let pointerstart = 0;
25
+ while (pointermin < pointermid) {
26
+ if (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) {
27
+ pointermin = pointermid;
28
+ pointerstart = pointermin;
29
+ } else pointermax = pointermid;
30
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
31
+ }
32
+ return pointermid;
33
+ };
34
+ const diff_commonSuffix = function(text1, text2) {
35
+ if (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) return 0;
36
+ let pointermin = 0;
37
+ let pointermax = Math.min(text1.length, text2.length);
38
+ let pointermid = pointermax;
39
+ let pointerend = 0;
40
+ while (pointermin < pointermid) {
41
+ if (text1.substring(text1.length - pointermid, text1.length - pointerend) === text2.substring(text2.length - pointermid, text2.length - pointerend)) {
42
+ pointermin = pointermid;
43
+ pointerend = pointermin;
44
+ } else pointermax = pointermid;
45
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
46
+ }
47
+ return pointermid;
48
+ };
49
+ const diff_commonOverlap_ = function(text1, text2) {
50
+ const text1_length = text1.length;
51
+ const text2_length = text2.length;
52
+ if (text1_length === 0 || text2_length === 0) return 0;
53
+ if (text1_length > text2_length) text1 = text1.substring(text1_length - text2_length);
54
+ else if (text1_length < text2_length) text2 = text2.substring(0, text1_length);
55
+ const text_length = Math.min(text1_length, text2_length);
56
+ if (text1 === text2) return text_length;
57
+ let best = 0;
58
+ let length = 1;
59
+ while (true) {
60
+ const pattern = text1.substring(text_length - length);
61
+ const found = text2.indexOf(pattern);
62
+ if (found === -1) return best;
63
+ length += found;
64
+ if (found === 0 || text1.substring(text_length - length) === text2.substring(0, length)) {
65
+ best = length;
66
+ length++;
67
+ }
68
+ }
69
+ };
70
+ const diff_cleanupSemantic = function(diffs) {
71
+ let changes = false;
72
+ const equalities = [];
73
+ let equalitiesLength = 0;
74
+ let lastEquality = null;
75
+ let pointer = 0;
76
+ let length_insertions1 = 0;
77
+ let length_deletions1 = 0;
78
+ let length_insertions2 = 0;
79
+ let length_deletions2 = 0;
80
+ while (pointer < diffs.length) {
81
+ if (diffs[pointer][0] === DIFF_EQUAL) {
82
+ equalities[equalitiesLength++] = pointer;
83
+ length_insertions1 = length_insertions2;
84
+ length_deletions1 = length_deletions2;
85
+ length_insertions2 = 0;
86
+ length_deletions2 = 0;
87
+ lastEquality = diffs[pointer][1];
88
+ } else {
89
+ if (diffs[pointer][0] === DIFF_INSERT) length_insertions2 += diffs[pointer][1].length;
90
+ else length_deletions2 += diffs[pointer][1].length;
91
+ if (lastEquality && lastEquality.length <= Math.max(length_insertions1, length_deletions1) && lastEquality.length <= Math.max(length_insertions2, length_deletions2)) {
92
+ diffs.splice(equalities[equalitiesLength - 1], 0, new Diff(DIFF_DELETE, lastEquality));
93
+ diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
94
+ equalitiesLength--;
95
+ equalitiesLength--;
96
+ pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
97
+ length_insertions1 = 0;
98
+ length_deletions1 = 0;
99
+ length_insertions2 = 0;
100
+ length_deletions2 = 0;
101
+ lastEquality = null;
102
+ changes = true;
103
+ }
104
+ }
105
+ pointer++;
106
+ }
107
+ if (changes) diff_cleanupMerge(diffs);
108
+ diff_cleanupSemanticLossless(diffs);
109
+ pointer = 1;
110
+ while (pointer < diffs.length) {
111
+ if (diffs[pointer - 1][0] === DIFF_DELETE && diffs[pointer][0] === DIFF_INSERT) {
112
+ const deletion = diffs[pointer - 1][1];
113
+ const insertion = diffs[pointer][1];
114
+ const overlap_length1 = diff_commonOverlap_(deletion, insertion);
115
+ const overlap_length2 = diff_commonOverlap_(insertion, deletion);
116
+ if (overlap_length1 >= overlap_length2) {
117
+ if (overlap_length1 >= deletion.length / 2 || overlap_length1 >= insertion.length / 2) {
118
+ diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, insertion.substring(0, overlap_length1)));
119
+ diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlap_length1);
120
+ diffs[pointer + 1][1] = insertion.substring(overlap_length1);
121
+ pointer++;
122
+ }
123
+ } else if (overlap_length2 >= deletion.length / 2 || overlap_length2 >= insertion.length / 2) {
124
+ diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, deletion.substring(0, overlap_length2)));
125
+ diffs[pointer - 1][0] = DIFF_INSERT;
126
+ diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlap_length2);
127
+ diffs[pointer + 1][0] = DIFF_DELETE;
128
+ diffs[pointer + 1][1] = deletion.substring(overlap_length2);
129
+ pointer++;
130
+ }
131
+ pointer++;
132
+ }
133
+ pointer++;
134
+ }
135
+ };
136
+ const nonAlphaNumericRegex_ = /[^a-z0-9]/i;
137
+ const whitespaceRegex_ = /\s/;
138
+ const linebreakRegex_ = /[\r\n]/;
139
+ const blanklineEndRegex_ = /\n\r?\n$/;
140
+ const blanklineStartRegex_ = /^\r?\n\r?\n/;
141
+ function diff_cleanupSemanticLossless(diffs) {
142
+ let pointer = 1;
143
+ while (pointer < diffs.length - 1) {
144
+ if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {
145
+ let equality1 = diffs[pointer - 1][1];
146
+ let edit = diffs[pointer][1];
147
+ let equality2 = diffs[pointer + 1][1];
148
+ const commonOffset = diff_commonSuffix(equality1, edit);
149
+ if (commonOffset) {
150
+ const commonString = edit.substring(edit.length - commonOffset);
151
+ equality1 = equality1.substring(0, equality1.length - commonOffset);
152
+ edit = commonString + edit.substring(0, edit.length - commonOffset);
153
+ equality2 = commonString + equality2;
154
+ }
155
+ let bestEquality1 = equality1;
156
+ let bestEdit = edit;
157
+ let bestEquality2 = equality2;
158
+ let bestScore = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
159
+ while (edit.charAt(0) === equality2.charAt(0)) {
160
+ equality1 += edit.charAt(0);
161
+ edit = edit.substring(1) + equality2.charAt(0);
162
+ equality2 = equality2.substring(1);
163
+ const score = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
164
+ if (score >= bestScore) {
165
+ bestScore = score;
166
+ bestEquality1 = equality1;
167
+ bestEdit = edit;
168
+ bestEquality2 = equality2;
169
+ }
170
+ }
171
+ if (diffs[pointer - 1][1] !== bestEquality1) {
172
+ if (bestEquality1) diffs[pointer - 1][1] = bestEquality1;
173
+ else {
174
+ diffs.splice(pointer - 1, 1);
175
+ pointer--;
176
+ }
177
+ diffs[pointer][1] = bestEdit;
178
+ if (bestEquality2) diffs[pointer + 1][1] = bestEquality2;
179
+ else {
180
+ diffs.splice(pointer + 1, 1);
181
+ pointer--;
182
+ }
183
+ }
184
+ }
185
+ pointer++;
186
+ }
187
+ }
188
+ function diff_cleanupMerge(diffs) {
189
+ diffs.push(new Diff(DIFF_EQUAL, ""));
190
+ let pointer = 0;
191
+ let count_delete = 0;
192
+ let count_insert = 0;
193
+ let text_delete = "";
194
+ let text_insert = "";
195
+ let commonlength;
196
+ while (pointer < diffs.length) switch (diffs[pointer][0]) {
197
+ case DIFF_INSERT:
198
+ count_insert++;
199
+ text_insert += diffs[pointer][1];
200
+ pointer++;
201
+ break;
202
+ case DIFF_DELETE:
203
+ count_delete++;
204
+ text_delete += diffs[pointer][1];
205
+ pointer++;
206
+ break;
207
+ case DIFF_EQUAL:
208
+ if (count_delete + count_insert > 1) {
209
+ if (count_delete !== 0 && count_insert !== 0) {
210
+ commonlength = diff_commonPrefix(text_insert, text_delete);
211
+ if (commonlength !== 0) {
212
+ if (pointer - count_delete - count_insert > 0 && diffs[pointer - count_delete - count_insert - 1][0] === DIFF_EQUAL) diffs[pointer - count_delete - count_insert - 1][1] += text_insert.substring(0, commonlength);
213
+ else {
214
+ diffs.splice(0, 0, new Diff(DIFF_EQUAL, text_insert.substring(0, commonlength)));
215
+ pointer++;
216
+ }
217
+ text_insert = text_insert.substring(commonlength);
218
+ text_delete = text_delete.substring(commonlength);
219
+ }
220
+ commonlength = diff_commonSuffix(text_insert, text_delete);
221
+ if (commonlength !== 0) {
222
+ diffs[pointer][1] = text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1];
223
+ text_insert = text_insert.substring(0, text_insert.length - commonlength);
224
+ text_delete = text_delete.substring(0, text_delete.length - commonlength);
225
+ }
226
+ }
227
+ pointer -= count_delete + count_insert;
228
+ diffs.splice(pointer, count_delete + count_insert);
229
+ if (text_delete.length) {
230
+ diffs.splice(pointer, 0, new Diff(DIFF_DELETE, text_delete));
231
+ pointer++;
232
+ }
233
+ if (text_insert.length) {
234
+ diffs.splice(pointer, 0, new Diff(DIFF_INSERT, text_insert));
235
+ pointer++;
236
+ }
237
+ pointer++;
238
+ } else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
239
+ diffs[pointer - 1][1] += diffs[pointer][1];
240
+ diffs.splice(pointer, 1);
241
+ } else pointer++;
242
+ count_insert = 0;
243
+ count_delete = 0;
244
+ text_delete = "";
245
+ text_insert = "";
246
+ break;
247
+ }
248
+ if (diffs[diffs.length - 1][1] === "") diffs.pop();
249
+ let changes = false;
250
+ pointer = 1;
251
+ while (pointer < diffs.length - 1) {
252
+ if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {
253
+ if (diffs[pointer][1].substring(diffs[pointer][1].length - diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
254
+ diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length);
255
+ diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
256
+ diffs.splice(pointer - 1, 1);
257
+ changes = true;
258
+ } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) === diffs[pointer + 1][1]) {
259
+ diffs[pointer - 1][1] += diffs[pointer + 1][1];
260
+ diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1];
261
+ diffs.splice(pointer + 1, 1);
262
+ changes = true;
263
+ }
264
+ }
265
+ pointer++;
266
+ }
267
+ if (changes) diff_cleanupMerge(diffs);
268
+ }
269
+ function diff_cleanupSemanticScore_(one, two) {
270
+ if (!one || !two) return 6;
271
+ const char1 = one.charAt(one.length - 1);
272
+ const char2 = two.charAt(0);
273
+ const nonAlphaNumeric1 = char1.match(nonAlphaNumericRegex_);
274
+ const nonAlphaNumeric2 = char2.match(nonAlphaNumericRegex_);
275
+ const whitespace1 = nonAlphaNumeric1 && char1.match(whitespaceRegex_);
276
+ const whitespace2 = nonAlphaNumeric2 && char2.match(whitespaceRegex_);
277
+ const lineBreak1 = whitespace1 && char1.match(linebreakRegex_);
278
+ const lineBreak2 = whitespace2 && char2.match(linebreakRegex_);
279
+ const blankLine1 = lineBreak1 && one.match(blanklineEndRegex_);
280
+ const blankLine2 = lineBreak2 && two.match(blanklineStartRegex_);
281
+ if (blankLine1 || blankLine2) return 5;
282
+ else if (lineBreak1 || lineBreak2) return 4;
283
+ else if (nonAlphaNumeric1 && !whitespace1 && whitespace2) return 3;
284
+ else if (whitespace1 || whitespace2) return 2;
285
+ else if (nonAlphaNumeric1 || nonAlphaNumeric2) return 1;
286
+ return 0;
287
+ }
288
+ const NO_DIFF_MESSAGE = "Compared values have no visual difference.";
289
+ const SIMILAR_MESSAGE = "Compared values serialize to the same structure.\nPrinting internal object structure without calling `toJSON` instead.";
290
+ var build = {};
291
+ var hasRequiredBuild;
292
+ function requireBuild() {
293
+ if (hasRequiredBuild) return build;
294
+ hasRequiredBuild = 1;
295
+ Object.defineProperty(build, "__esModule", { value: true });
296
+ build.default = diffSequence;
297
+ /**
298
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
299
+ *
300
+ * This source code is licensed under the MIT license found in the
301
+ * LICENSE file in the root directory of this source tree.
302
+ *
303
+ */
304
+ const pkg = "diff-sequences";
305
+ const NOT_YET_SET = 0;
306
+ const countCommonItemsF = (aIndex, aEnd, bIndex, bEnd, isCommon) => {
307
+ let nCommon = 0;
308
+ while (aIndex < aEnd && bIndex < bEnd && isCommon(aIndex, bIndex)) {
309
+ aIndex += 1;
310
+ bIndex += 1;
311
+ nCommon += 1;
312
+ }
313
+ return nCommon;
314
+ };
315
+ const countCommonItemsR = (aStart, aIndex, bStart, bIndex, isCommon) => {
316
+ let nCommon = 0;
317
+ while (aStart <= aIndex && bStart <= bIndex && isCommon(aIndex, bIndex)) {
318
+ aIndex -= 1;
319
+ bIndex -= 1;
320
+ nCommon += 1;
321
+ }
322
+ return nCommon;
323
+ };
324
+ const extendPathsF = (d, aEnd, bEnd, bF, isCommon, aIndexesF, iMaxF) => {
325
+ let iF = 0;
326
+ let kF = -d;
327
+ let aFirst = aIndexesF[iF];
328
+ let aIndexPrev1 = aFirst;
329
+ aIndexesF[iF] += countCommonItemsF(aFirst + 1, aEnd, bF + aFirst - kF + 1, bEnd, isCommon);
330
+ const nF = d < iMaxF ? d : iMaxF;
331
+ for (iF += 1, kF += 2; iF <= nF; iF += 1, kF += 2) {
332
+ if (iF !== d && aIndexPrev1 < aIndexesF[iF]) aFirst = aIndexesF[iF];
333
+ else {
334
+ aFirst = aIndexPrev1 + 1;
335
+ if (aEnd <= aFirst) return iF - 1;
336
+ }
337
+ aIndexPrev1 = aIndexesF[iF];
338
+ aIndexesF[iF] = aFirst + countCommonItemsF(aFirst + 1, aEnd, bF + aFirst - kF + 1, bEnd, isCommon);
339
+ }
340
+ return iMaxF;
341
+ };
342
+ const extendPathsR = (d, aStart, bStart, bR, isCommon, aIndexesR, iMaxR) => {
343
+ let iR = 0;
344
+ let kR = d;
345
+ let aFirst = aIndexesR[iR];
346
+ let aIndexPrev1 = aFirst;
347
+ aIndexesR[iR] -= countCommonItemsR(aStart, aFirst - 1, bStart, bR + aFirst - kR - 1, isCommon);
348
+ const nR = d < iMaxR ? d : iMaxR;
349
+ for (iR += 1, kR -= 2; iR <= nR; iR += 1, kR -= 2) {
350
+ if (iR !== d && aIndexesR[iR] < aIndexPrev1) aFirst = aIndexesR[iR];
351
+ else {
352
+ aFirst = aIndexPrev1 - 1;
353
+ if (aFirst < aStart) return iR - 1;
354
+ }
355
+ aIndexPrev1 = aIndexesR[iR];
356
+ aIndexesR[iR] = aFirst - countCommonItemsR(aStart, aFirst - 1, bStart, bR + aFirst - kR - 1, isCommon);
357
+ }
358
+ return iMaxR;
359
+ };
360
+ const extendOverlappablePathsF = (d, aStart, aEnd, bStart, bEnd, isCommon, aIndexesF, iMaxF, aIndexesR, iMaxR, division) => {
361
+ const bF = bStart - aStart;
362
+ const aLength = aEnd - aStart;
363
+ const baDeltaLength = bEnd - bStart - aLength;
364
+ const kMinOverlapF = -baDeltaLength - (d - 1);
365
+ const kMaxOverlapF = -baDeltaLength + (d - 1);
366
+ let aIndexPrev1 = NOT_YET_SET;
367
+ const nF = d < iMaxF ? d : iMaxF;
368
+ for (let iF = 0, kF = -d; iF <= nF; iF += 1, kF += 2) {
369
+ const insert = iF === 0 || iF !== d && aIndexPrev1 < aIndexesF[iF];
370
+ const aLastPrev = insert ? aIndexesF[iF] : aIndexPrev1;
371
+ const aFirst = insert ? aLastPrev : aLastPrev + 1;
372
+ const bFirst = bF + aFirst - kF;
373
+ const nCommonF = countCommonItemsF(aFirst + 1, aEnd, bFirst + 1, bEnd, isCommon);
374
+ const aLast = aFirst + nCommonF;
375
+ aIndexPrev1 = aIndexesF[iF];
376
+ aIndexesF[iF] = aLast;
377
+ if (kMinOverlapF <= kF && kF <= kMaxOverlapF) {
378
+ const iR = (d - 1 - (kF + baDeltaLength)) / 2;
379
+ if (iR <= iMaxR && aIndexesR[iR] - 1 <= aLast) {
380
+ const bLastPrev = bF + aLastPrev - (insert ? kF + 1 : kF - 1);
381
+ const nCommonR = countCommonItemsR(aStart, aLastPrev, bStart, bLastPrev, isCommon);
382
+ const aIndexPrevFirst = aLastPrev - nCommonR;
383
+ const bIndexPrevFirst = bLastPrev - nCommonR;
384
+ const aEndPreceding = aIndexPrevFirst + 1;
385
+ const bEndPreceding = bIndexPrevFirst + 1;
386
+ division.nChangePreceding = d - 1;
387
+ if (d - 1 === aEndPreceding + bEndPreceding - aStart - bStart) {
388
+ division.aEndPreceding = aStart;
389
+ division.bEndPreceding = bStart;
390
+ } else {
391
+ division.aEndPreceding = aEndPreceding;
392
+ division.bEndPreceding = bEndPreceding;
393
+ }
394
+ division.nCommonPreceding = nCommonR;
395
+ if (nCommonR !== 0) {
396
+ division.aCommonPreceding = aEndPreceding;
397
+ division.bCommonPreceding = bEndPreceding;
398
+ }
399
+ division.nCommonFollowing = nCommonF;
400
+ if (nCommonF !== 0) {
401
+ division.aCommonFollowing = aFirst + 1;
402
+ division.bCommonFollowing = bFirst + 1;
403
+ }
404
+ const aStartFollowing = aLast + 1;
405
+ const bStartFollowing = bFirst + nCommonF + 1;
406
+ division.nChangeFollowing = d - 1;
407
+ if (d - 1 === aEnd + bEnd - aStartFollowing - bStartFollowing) {
408
+ division.aStartFollowing = aEnd;
409
+ division.bStartFollowing = bEnd;
410
+ } else {
411
+ division.aStartFollowing = aStartFollowing;
412
+ division.bStartFollowing = bStartFollowing;
413
+ }
414
+ return true;
415
+ }
416
+ }
417
+ }
418
+ return false;
419
+ };
420
+ const extendOverlappablePathsR = (d, aStart, aEnd, bStart, bEnd, isCommon, aIndexesF, iMaxF, aIndexesR, iMaxR, division) => {
421
+ const bR = bEnd - aEnd;
422
+ const aLength = aEnd - aStart;
423
+ const baDeltaLength = bEnd - bStart - aLength;
424
+ const kMinOverlapR = baDeltaLength - d;
425
+ const kMaxOverlapR = baDeltaLength + d;
426
+ let aIndexPrev1 = NOT_YET_SET;
427
+ const nR = d < iMaxR ? d : iMaxR;
428
+ for (let iR = 0, kR = d; iR <= nR; iR += 1, kR -= 2) {
429
+ const insert = iR === 0 || iR !== d && aIndexesR[iR] < aIndexPrev1;
430
+ const aLastPrev = insert ? aIndexesR[iR] : aIndexPrev1;
431
+ const aFirst = insert ? aLastPrev : aLastPrev - 1;
432
+ const bFirst = bR + aFirst - kR;
433
+ const nCommonR = countCommonItemsR(aStart, aFirst - 1, bStart, bFirst - 1, isCommon);
434
+ const aLast = aFirst - nCommonR;
435
+ aIndexPrev1 = aIndexesR[iR];
436
+ aIndexesR[iR] = aLast;
437
+ if (kMinOverlapR <= kR && kR <= kMaxOverlapR) {
438
+ const iF = (d + (kR - baDeltaLength)) / 2;
439
+ if (iF <= iMaxF && aLast - 1 <= aIndexesF[iF]) {
440
+ const bLast = bFirst - nCommonR;
441
+ division.nChangePreceding = d;
442
+ if (d === aLast + bLast - aStart - bStart) {
443
+ division.aEndPreceding = aStart;
444
+ division.bEndPreceding = bStart;
445
+ } else {
446
+ division.aEndPreceding = aLast;
447
+ division.bEndPreceding = bLast;
448
+ }
449
+ division.nCommonPreceding = nCommonR;
450
+ if (nCommonR !== 0) {
451
+ division.aCommonPreceding = aLast;
452
+ division.bCommonPreceding = bLast;
453
+ }
454
+ division.nChangeFollowing = d - 1;
455
+ if (d === 1) {
456
+ division.nCommonFollowing = 0;
457
+ division.aStartFollowing = aEnd;
458
+ division.bStartFollowing = bEnd;
459
+ } else {
460
+ const bLastPrev = bR + aLastPrev - (insert ? kR - 1 : kR + 1);
461
+ const nCommonF = countCommonItemsF(aLastPrev, aEnd, bLastPrev, bEnd, isCommon);
462
+ division.nCommonFollowing = nCommonF;
463
+ if (nCommonF !== 0) {
464
+ division.aCommonFollowing = aLastPrev;
465
+ division.bCommonFollowing = bLastPrev;
466
+ }
467
+ const aStartFollowing = aLastPrev + nCommonF;
468
+ const bStartFollowing = bLastPrev + nCommonF;
469
+ if (d - 1 === aEnd + bEnd - aStartFollowing - bStartFollowing) {
470
+ division.aStartFollowing = aEnd;
471
+ division.bStartFollowing = bEnd;
472
+ } else {
473
+ division.aStartFollowing = aStartFollowing;
474
+ division.bStartFollowing = bStartFollowing;
475
+ }
476
+ }
477
+ return true;
478
+ }
479
+ }
480
+ }
481
+ return false;
482
+ };
483
+ const divide = (nChange, aStart, aEnd, bStart, bEnd, isCommon, aIndexesF, aIndexesR, division) => {
484
+ const bF = bStart - aStart;
485
+ const bR = bEnd - aEnd;
486
+ const aLength = aEnd - aStart;
487
+ const bLength = bEnd - bStart;
488
+ const baDeltaLength = bLength - aLength;
489
+ let iMaxF = aLength;
490
+ let iMaxR = aLength;
491
+ aIndexesF[0] = aStart - 1;
492
+ aIndexesR[0] = aEnd;
493
+ if (baDeltaLength % 2 === 0) {
494
+ const dMin = (nChange || baDeltaLength) / 2;
495
+ const dMax = (aLength + bLength) / 2;
496
+ for (let d = 1; d <= dMax; d += 1) {
497
+ iMaxF = extendPathsF(d, aEnd, bEnd, bF, isCommon, aIndexesF, iMaxF);
498
+ if (d < dMin) iMaxR = extendPathsR(d, aStart, bStart, bR, isCommon, aIndexesR, iMaxR);
499
+ else if (extendOverlappablePathsR(d, aStart, aEnd, bStart, bEnd, isCommon, aIndexesF, iMaxF, aIndexesR, iMaxR, division)) return;
500
+ }
501
+ } else {
502
+ const dMin = ((nChange || baDeltaLength) + 1) / 2;
503
+ const dMax = (aLength + bLength + 1) / 2;
504
+ let d = 1;
505
+ iMaxF = extendPathsF(d, aEnd, bEnd, bF, isCommon, aIndexesF, iMaxF);
506
+ for (d += 1; d <= dMax; d += 1) {
507
+ iMaxR = extendPathsR(d - 1, aStart, bStart, bR, isCommon, aIndexesR, iMaxR);
508
+ if (d < dMin) iMaxF = extendPathsF(d, aEnd, bEnd, bF, isCommon, aIndexesF, iMaxF);
509
+ else if (extendOverlappablePathsF(d, aStart, aEnd, bStart, bEnd, isCommon, aIndexesF, iMaxF, aIndexesR, iMaxR, division)) return;
510
+ }
511
+ }
512
+ /* istanbul ignore next */
513
+ throw new Error(`${pkg}: no overlap aStart=${aStart} aEnd=${aEnd} bStart=${bStart} bEnd=${bEnd}`);
514
+ };
515
+ const findSubsequences = (nChange, aStart, aEnd, bStart, bEnd, transposed, callbacks, aIndexesF, aIndexesR, division) => {
516
+ if (bEnd - bStart < aEnd - aStart) {
517
+ transposed = !transposed;
518
+ if (transposed && callbacks.length === 1) {
519
+ const { foundSubsequence, isCommon } = callbacks[0];
520
+ callbacks[1] = {
521
+ foundSubsequence: (nCommon, bCommon, aCommon) => {
522
+ foundSubsequence(nCommon, aCommon, bCommon);
523
+ },
524
+ isCommon: (bIndex, aIndex) => isCommon(aIndex, bIndex)
525
+ };
526
+ }
527
+ const tStart = aStart;
528
+ const tEnd = aEnd;
529
+ aStart = bStart;
530
+ aEnd = bEnd;
531
+ bStart = tStart;
532
+ bEnd = tEnd;
533
+ }
534
+ const { foundSubsequence, isCommon } = callbacks[transposed ? 1 : 0];
535
+ divide(nChange, aStart, aEnd, bStart, bEnd, isCommon, aIndexesF, aIndexesR, division);
536
+ const { nChangePreceding, aEndPreceding, bEndPreceding, nCommonPreceding, aCommonPreceding, bCommonPreceding, nCommonFollowing, aCommonFollowing, bCommonFollowing, nChangeFollowing, aStartFollowing, bStartFollowing } = division;
537
+ if (aStart < aEndPreceding && bStart < bEndPreceding) findSubsequences(nChangePreceding, aStart, aEndPreceding, bStart, bEndPreceding, transposed, callbacks, aIndexesF, aIndexesR, division);
538
+ if (nCommonPreceding !== 0) foundSubsequence(nCommonPreceding, aCommonPreceding, bCommonPreceding);
539
+ if (nCommonFollowing !== 0) foundSubsequence(nCommonFollowing, aCommonFollowing, bCommonFollowing);
540
+ if (aStartFollowing < aEnd && bStartFollowing < bEnd) findSubsequences(nChangeFollowing, aStartFollowing, aEnd, bStartFollowing, bEnd, transposed, callbacks, aIndexesF, aIndexesR, division);
541
+ };
542
+ const validateLength = (name, arg) => {
543
+ if (typeof arg !== "number") throw new TypeError(`${pkg}: ${name} typeof ${typeof arg} is not a number`);
544
+ if (!Number.isSafeInteger(arg)) throw new RangeError(`${pkg}: ${name} value ${arg} is not a safe integer`);
545
+ if (arg < 0) throw new RangeError(`${pkg}: ${name} value ${arg} is a negative integer`);
546
+ };
547
+ const validateCallback = (name, arg) => {
548
+ const type = typeof arg;
549
+ if (type !== "function") throw new TypeError(`${pkg}: ${name} typeof ${type} is not a function`);
550
+ };
551
+ function diffSequence(aLength, bLength, isCommon, foundSubsequence) {
552
+ validateLength("aLength", aLength);
553
+ validateLength("bLength", bLength);
554
+ validateCallback("isCommon", isCommon);
555
+ validateCallback("foundSubsequence", foundSubsequence);
556
+ const nCommonF = countCommonItemsF(0, aLength, 0, bLength, isCommon);
557
+ if (nCommonF !== 0) foundSubsequence(nCommonF, 0, 0);
558
+ if (aLength !== nCommonF || bLength !== nCommonF) {
559
+ const aStart = nCommonF;
560
+ const bStart = nCommonF;
561
+ const nCommonR = countCommonItemsR(aStart, aLength - 1, bStart, bLength - 1, isCommon);
562
+ const aEnd = aLength - nCommonR;
563
+ const bEnd = bLength - nCommonR;
564
+ const nCommonFR = nCommonF + nCommonR;
565
+ if (aLength !== nCommonFR && bLength !== nCommonFR) findSubsequences(0, aStart, aEnd, bStart, bEnd, false, [{
566
+ foundSubsequence,
567
+ isCommon
568
+ }], [NOT_YET_SET], [NOT_YET_SET], {
569
+ aCommonFollowing: NOT_YET_SET,
570
+ aCommonPreceding: NOT_YET_SET,
571
+ aEndPreceding: NOT_YET_SET,
572
+ aStartFollowing: NOT_YET_SET,
573
+ bCommonFollowing: NOT_YET_SET,
574
+ bCommonPreceding: NOT_YET_SET,
575
+ bEndPreceding: NOT_YET_SET,
576
+ bStartFollowing: NOT_YET_SET,
577
+ nChangeFollowing: NOT_YET_SET,
578
+ nChangePreceding: NOT_YET_SET,
579
+ nCommonFollowing: NOT_YET_SET,
580
+ nCommonPreceding: NOT_YET_SET
581
+ });
582
+ if (nCommonR !== 0) foundSubsequence(nCommonR, aEnd, bEnd);
583
+ }
584
+ }
585
+ return build;
586
+ }
587
+ var diffSequences = /* @__PURE__ */ getDefaultExportFromCjs(requireBuild());
588
+ function formatTrailingSpaces(line, trailingSpaceFormatter) {
589
+ return line.replace(/\s+$/, (match) => trailingSpaceFormatter(match));
590
+ }
591
+ function printDiffLine(line, isFirstOrLast, color, indicator, trailingSpaceFormatter, emptyFirstOrLastLinePlaceholder) {
592
+ return line.length !== 0 ? color(`${indicator} ${formatTrailingSpaces(line, trailingSpaceFormatter)}`) : indicator !== " " ? color(indicator) : isFirstOrLast && emptyFirstOrLastLinePlaceholder.length !== 0 ? color(`${indicator} ${emptyFirstOrLastLinePlaceholder}`) : "";
593
+ }
594
+ function printDeleteLine(line, isFirstOrLast, { aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder }) {
595
+ return printDiffLine(line, isFirstOrLast, aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
596
+ }
597
+ function printInsertLine(line, isFirstOrLast, { bColor, bIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder }) {
598
+ return printDiffLine(line, isFirstOrLast, bColor, bIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
599
+ }
600
+ function printCommonLine(line, isFirstOrLast, { commonColor, commonIndicator, commonLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder }) {
601
+ return printDiffLine(line, isFirstOrLast, commonColor, commonIndicator, commonLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
602
+ }
603
+ function createPatchMark(aStart, aEnd, bStart, bEnd, { patchColor }) {
604
+ return patchColor(`@@ -${aStart + 1},${aEnd - aStart} +${bStart + 1},${bEnd - bStart} @@`);
605
+ }
606
+ function joinAlignedDiffsNoExpand(diffs, options) {
607
+ const iLength = diffs.length;
608
+ const nContextLines = options.contextLines;
609
+ const nContextLines2 = nContextLines + nContextLines;
610
+ let jLength = iLength;
611
+ let hasExcessAtStartOrEnd = false;
612
+ let nExcessesBetweenChanges = 0;
613
+ let i = 0;
614
+ while (i !== iLength) {
615
+ const iStart = i;
616
+ while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
617
+ if (iStart !== i) if (iStart === 0) {
618
+ if (i > nContextLines) {
619
+ jLength -= i - nContextLines;
620
+ hasExcessAtStartOrEnd = true;
621
+ }
622
+ } else if (i === iLength) {
623
+ const n = i - iStart;
624
+ if (n > nContextLines) {
625
+ jLength -= n - nContextLines;
626
+ hasExcessAtStartOrEnd = true;
627
+ }
628
+ } else {
629
+ const n = i - iStart;
630
+ if (n > nContextLines2) {
631
+ jLength -= n - nContextLines2;
632
+ nExcessesBetweenChanges += 1;
633
+ }
634
+ }
635
+ while (i !== iLength && diffs[i][0] !== DIFF_EQUAL) i += 1;
636
+ }
637
+ const hasPatch = nExcessesBetweenChanges !== 0 || hasExcessAtStartOrEnd;
638
+ if (nExcessesBetweenChanges !== 0) jLength += nExcessesBetweenChanges + 1;
639
+ else if (hasExcessAtStartOrEnd) jLength += 1;
640
+ const jLast = jLength - 1;
641
+ const lines = [];
642
+ let jPatchMark = 0;
643
+ if (hasPatch) lines.push("");
644
+ let aStart = 0;
645
+ let bStart = 0;
646
+ let aEnd = 0;
647
+ let bEnd = 0;
648
+ const pushCommonLine = (line) => {
649
+ const j = lines.length;
650
+ lines.push(printCommonLine(line, j === 0 || j === jLast, options));
651
+ aEnd += 1;
652
+ bEnd += 1;
653
+ };
654
+ const pushDeleteLine = (line) => {
655
+ const j = lines.length;
656
+ lines.push(printDeleteLine(line, j === 0 || j === jLast, options));
657
+ aEnd += 1;
658
+ };
659
+ const pushInsertLine = (line) => {
660
+ const j = lines.length;
661
+ lines.push(printInsertLine(line, j === 0 || j === jLast, options));
662
+ bEnd += 1;
663
+ };
664
+ i = 0;
665
+ while (i !== iLength) {
666
+ let iStart = i;
667
+ while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
668
+ if (iStart !== i) if (iStart === 0) {
669
+ if (i > nContextLines) {
670
+ iStart = i - nContextLines;
671
+ aStart = iStart;
672
+ bStart = iStart;
673
+ aEnd = aStart;
674
+ bEnd = bStart;
675
+ }
676
+ for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
677
+ } else if (i === iLength) {
678
+ const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
679
+ for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
680
+ } else {
681
+ const nCommon = i - iStart;
682
+ if (nCommon > nContextLines2) {
683
+ const iEnd = iStart + nContextLines;
684
+ for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
685
+ lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
686
+ jPatchMark = lines.length;
687
+ lines.push("");
688
+ const nOmit = nCommon - nContextLines2;
689
+ aStart = aEnd + nOmit;
690
+ bStart = bEnd + nOmit;
691
+ aEnd = aStart;
692
+ bEnd = bStart;
693
+ for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
694
+ } else for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
695
+ }
696
+ while (i !== iLength && diffs[i][0] === DIFF_DELETE) {
697
+ pushDeleteLine(diffs[i][1]);
698
+ i += 1;
699
+ }
700
+ while (i !== iLength && diffs[i][0] === DIFF_INSERT) {
701
+ pushInsertLine(diffs[i][1]);
702
+ i += 1;
703
+ }
704
+ }
705
+ if (hasPatch) lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
706
+ return lines.join("\n");
707
+ }
708
+ function joinAlignedDiffsExpand(diffs, options) {
709
+ return diffs.map((diff, i, diffs2) => {
710
+ const line = diff[1];
711
+ const isFirstOrLast = i === 0 || i === diffs2.length - 1;
712
+ switch (diff[0]) {
713
+ case DIFF_DELETE: return printDeleteLine(line, isFirstOrLast, options);
714
+ case DIFF_INSERT: return printInsertLine(line, isFirstOrLast, options);
715
+ default: return printCommonLine(line, isFirstOrLast, options);
716
+ }
717
+ }).join("\n");
718
+ }
719
+ const noColor = (string) => string;
720
+ const DIFF_CONTEXT_DEFAULT = 5;
721
+ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
722
+ function getDefaultOptions() {
723
+ return {
724
+ aAnnotation: "Expected",
725
+ aColor: p.green,
726
+ aIndicator: "-",
727
+ bAnnotation: "Received",
728
+ bColor: p.red,
729
+ bIndicator: "+",
730
+ changeColor: p.inverse,
731
+ changeLineTrailingSpaceColor: noColor,
732
+ commonColor: p.dim,
733
+ commonIndicator: " ",
734
+ commonLineTrailingSpaceColor: noColor,
735
+ compareKeys: void 0,
736
+ contextLines: DIFF_CONTEXT_DEFAULT,
737
+ emptyFirstOrLastLinePlaceholder: "",
738
+ expand: true,
739
+ includeChangeCounts: false,
740
+ omitAnnotationLines: false,
741
+ patchColor: p.yellow,
742
+ truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
743
+ truncateAnnotation: "... Diff result is truncated",
744
+ truncateAnnotationColor: noColor
745
+ };
746
+ }
747
+ function getCompareKeys(compareKeys) {
748
+ return compareKeys && typeof compareKeys === "function" ? compareKeys : void 0;
749
+ }
750
+ function getContextLines(contextLines) {
751
+ return typeof contextLines === "number" && Number.isSafeInteger(contextLines) && contextLines >= 0 ? contextLines : DIFF_CONTEXT_DEFAULT;
752
+ }
753
+ function normalizeDiffOptions(options = {}) {
754
+ return {
755
+ ...getDefaultOptions(),
756
+ ...options,
757
+ compareKeys: getCompareKeys(options.compareKeys),
758
+ contextLines: getContextLines(options.contextLines)
759
+ };
760
+ }
761
+ function isEmptyString(lines) {
762
+ return lines.length === 1 && lines[0].length === 0;
763
+ }
764
+ function countChanges(diffs) {
765
+ let a = 0;
766
+ let b = 0;
767
+ diffs.forEach((diff) => {
768
+ switch (diff[0]) {
769
+ case DIFF_DELETE:
770
+ a += 1;
771
+ break;
772
+ case DIFF_INSERT:
773
+ b += 1;
774
+ break;
775
+ }
776
+ });
777
+ return {
778
+ a,
779
+ b
780
+ };
781
+ }
782
+ function printAnnotation({ aAnnotation, aColor, aIndicator, bAnnotation, bColor, bIndicator, includeChangeCounts, omitAnnotationLines }, changeCounts) {
783
+ if (omitAnnotationLines) return "";
784
+ let aRest = "";
785
+ let bRest = "";
786
+ if (includeChangeCounts) {
787
+ const aCount = String(changeCounts.a);
788
+ const bCount = String(changeCounts.b);
789
+ const baAnnotationLengthDiff = bAnnotation.length - aAnnotation.length;
790
+ const aAnnotationPadding = " ".repeat(Math.max(0, baAnnotationLengthDiff));
791
+ const bAnnotationPadding = " ".repeat(Math.max(0, -baAnnotationLengthDiff));
792
+ const baCountLengthDiff = bCount.length - aCount.length;
793
+ const aCountPadding = " ".repeat(Math.max(0, baCountLengthDiff));
794
+ const bCountPadding = " ".repeat(Math.max(0, -baCountLengthDiff));
795
+ aRest = `${aAnnotationPadding} ${aIndicator} ${aCountPadding}${aCount}`;
796
+ bRest = `${bAnnotationPadding} ${bIndicator} ${bCountPadding}${bCount}`;
797
+ }
798
+ const a = `${aIndicator} ${aAnnotation}${aRest}`;
799
+ const b = `${bIndicator} ${bAnnotation}${bRest}`;
800
+ return `${aColor(a)}
801
+ ${bColor(b)}
802
+
803
+ `;
804
+ }
805
+ function printDiffLines(diffs, truncated, options) {
806
+ return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options)) + (truncated ? options.truncateAnnotationColor(`
807
+ ${options.truncateAnnotation}`) : "");
808
+ }
809
+ function diffLinesUnified(aLines, bLines, options) {
810
+ const normalizedOptions = normalizeDiffOptions(options);
811
+ const [diffs, truncated] = diffLinesRaw(isEmptyString(aLines) ? [] : aLines, isEmptyString(bLines) ? [] : bLines, normalizedOptions);
812
+ return printDiffLines(diffs, truncated, normalizedOptions);
813
+ }
814
+ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options) {
815
+ if (isEmptyString(aLinesDisplay) && isEmptyString(aLinesCompare)) {
816
+ aLinesDisplay = [];
817
+ aLinesCompare = [];
818
+ }
819
+ if (isEmptyString(bLinesDisplay) && isEmptyString(bLinesCompare)) {
820
+ bLinesDisplay = [];
821
+ bLinesCompare = [];
822
+ }
823
+ if (aLinesDisplay.length !== aLinesCompare.length || bLinesDisplay.length !== bLinesCompare.length) return diffLinesUnified(aLinesDisplay, bLinesDisplay, options);
824
+ const [diffs, truncated] = diffLinesRaw(aLinesCompare, bLinesCompare, options);
825
+ let aIndex = 0;
826
+ let bIndex = 0;
827
+ diffs.forEach((diff) => {
828
+ switch (diff[0]) {
829
+ case DIFF_DELETE:
830
+ diff[1] = aLinesDisplay[aIndex];
831
+ aIndex += 1;
832
+ break;
833
+ case DIFF_INSERT:
834
+ diff[1] = bLinesDisplay[bIndex];
835
+ bIndex += 1;
836
+ break;
837
+ default:
838
+ diff[1] = bLinesDisplay[bIndex];
839
+ aIndex += 1;
840
+ bIndex += 1;
841
+ }
842
+ });
843
+ return printDiffLines(diffs, truncated, normalizeDiffOptions(options));
844
+ }
845
+ function diffLinesRaw(aLines, bLines, options) {
846
+ const truncate = (options == null ? void 0 : options.truncateThreshold) ?? false;
847
+ const truncateThreshold = Math.max(Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0), 0);
848
+ const aLength = truncate ? Math.min(aLines.length, truncateThreshold) : aLines.length;
849
+ const bLength = truncate ? Math.min(bLines.length, truncateThreshold) : bLines.length;
850
+ const truncated = aLength !== aLines.length || bLength !== bLines.length;
851
+ const isCommon = (aIndex2, bIndex2) => aLines[aIndex2] === bLines[bIndex2];
852
+ const diffs = [];
853
+ let aIndex = 0;
854
+ let bIndex = 0;
855
+ const foundSubsequence = (nCommon, aCommon, bCommon) => {
856
+ for (; aIndex !== aCommon; aIndex += 1) diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
857
+ for (; bIndex !== bCommon; bIndex += 1) diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
858
+ for (; nCommon !== 0; nCommon -= 1, aIndex += 1, bIndex += 1) diffs.push(new Diff(DIFF_EQUAL, bLines[bIndex]));
859
+ };
860
+ diffSequences(aLength, bLength, isCommon, foundSubsequence);
861
+ for (; aIndex !== aLength; aIndex += 1) diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
862
+ for (; bIndex !== bLength; bIndex += 1) diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
863
+ return [diffs, truncated];
864
+ }
865
+ function getType(value) {
866
+ if (value === void 0) return "undefined";
867
+ else if (value === null) return "null";
868
+ else if (Array.isArray(value)) return "array";
869
+ else if (typeof value === "boolean") return "boolean";
870
+ else if (typeof value === "function") return "function";
871
+ else if (typeof value === "number") return "number";
872
+ else if (typeof value === "string") return "string";
873
+ else if (typeof value === "bigint") return "bigint";
874
+ else if (typeof value === "object") {
875
+ if (value != null) {
876
+ if (value.constructor === RegExp) return "regexp";
877
+ else if (value.constructor === Map) return "map";
878
+ else if (value.constructor === Set) return "set";
879
+ else if (value.constructor === Date) return "date";
880
+ }
881
+ return "object";
882
+ } else if (typeof value === "symbol") return "symbol";
883
+ throw new Error(`value of unknown type: ${value}`);
884
+ }
885
+ function getNewLineSymbol(string) {
886
+ return string.includes("\r\n") ? "\r\n" : "\n";
887
+ }
888
+ function diffStrings(a, b, options) {
889
+ const truncate = (options == null ? void 0 : options.truncateThreshold) ?? false;
890
+ const truncateThreshold = Math.max(Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0), 0);
891
+ let aLength = a.length;
892
+ let bLength = b.length;
893
+ if (truncate) {
894
+ const aMultipleLines = a.includes("\n");
895
+ const bMultipleLines = b.includes("\n");
896
+ const aNewLineSymbol = getNewLineSymbol(a);
897
+ const bNewLineSymbol = getNewLineSymbol(b);
898
+ const _a = aMultipleLines ? `${a.split(aNewLineSymbol, truncateThreshold).join(aNewLineSymbol)}
899
+ ` : a;
900
+ const _b = bMultipleLines ? `${b.split(bNewLineSymbol, truncateThreshold).join(bNewLineSymbol)}
901
+ ` : b;
902
+ aLength = _a.length;
903
+ bLength = _b.length;
904
+ }
905
+ const truncated = aLength !== a.length || bLength !== b.length;
906
+ const isCommon = (aIndex2, bIndex2) => a[aIndex2] === b[bIndex2];
907
+ let aIndex = 0;
908
+ let bIndex = 0;
909
+ const diffs = [];
910
+ const foundSubsequence = (nCommon, aCommon, bCommon) => {
911
+ if (aIndex !== aCommon) diffs.push(new Diff(DIFF_DELETE, a.slice(aIndex, aCommon)));
912
+ if (bIndex !== bCommon) diffs.push(new Diff(DIFF_INSERT, b.slice(bIndex, bCommon)));
913
+ aIndex = aCommon + nCommon;
914
+ bIndex = bCommon + nCommon;
915
+ diffs.push(new Diff(DIFF_EQUAL, b.slice(bCommon, bIndex)));
916
+ };
917
+ diffSequences(aLength, bLength, isCommon, foundSubsequence);
918
+ if (aIndex !== aLength) diffs.push(new Diff(DIFF_DELETE, a.slice(aIndex)));
919
+ if (bIndex !== bLength) diffs.push(new Diff(DIFF_INSERT, b.slice(bIndex)));
920
+ return [diffs, truncated];
921
+ }
922
+ function concatenateRelevantDiffs(op, diffs, changeColor) {
923
+ return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op && diff[1].length !== 0 ? changeColor(diff[1]) : ""), "");
924
+ }
925
+ var ChangeBuffer = class {
926
+ op;
927
+ line;
928
+ lines;
929
+ changeColor;
930
+ constructor(op, changeColor) {
931
+ this.op = op;
932
+ this.line = [];
933
+ this.lines = [];
934
+ this.changeColor = changeColor;
935
+ }
936
+ pushSubstring(substring) {
937
+ this.pushDiff(new Diff(this.op, substring));
938
+ }
939
+ pushLine() {
940
+ this.lines.push(this.line.length !== 1 ? new Diff(this.op, concatenateRelevantDiffs(this.op, this.line, this.changeColor)) : this.line[0][0] === this.op ? this.line[0] : new Diff(this.op, this.line[0][1]));
941
+ this.line.length = 0;
942
+ }
943
+ isLineEmpty() {
944
+ return this.line.length === 0;
945
+ }
946
+ pushDiff(diff) {
947
+ this.line.push(diff);
948
+ }
949
+ align(diff) {
950
+ const string = diff[1];
951
+ if (string.includes("\n")) {
952
+ const substrings = string.split("\n");
953
+ const iLast = substrings.length - 1;
954
+ substrings.forEach((substring, i) => {
955
+ if (i < iLast) {
956
+ this.pushSubstring(substring);
957
+ this.pushLine();
958
+ } else if (substring.length !== 0) this.pushSubstring(substring);
959
+ });
960
+ } else this.pushDiff(diff);
961
+ }
962
+ moveLinesTo(lines) {
963
+ if (!this.isLineEmpty()) this.pushLine();
964
+ lines.push(...this.lines);
965
+ this.lines.length = 0;
966
+ }
967
+ };
968
+ var CommonBuffer = class {
969
+ deleteBuffer;
970
+ insertBuffer;
971
+ lines;
972
+ constructor(deleteBuffer, insertBuffer) {
973
+ this.deleteBuffer = deleteBuffer;
974
+ this.insertBuffer = insertBuffer;
975
+ this.lines = [];
976
+ }
977
+ pushDiffCommonLine(diff) {
978
+ this.lines.push(diff);
979
+ }
980
+ pushDiffChangeLines(diff) {
981
+ const isDiffEmpty = diff[1].length === 0;
982
+ if (!isDiffEmpty || this.deleteBuffer.isLineEmpty()) this.deleteBuffer.pushDiff(diff);
983
+ if (!isDiffEmpty || this.insertBuffer.isLineEmpty()) this.insertBuffer.pushDiff(diff);
984
+ }
985
+ flushChangeLines() {
986
+ this.deleteBuffer.moveLinesTo(this.lines);
987
+ this.insertBuffer.moveLinesTo(this.lines);
988
+ }
989
+ align(diff) {
990
+ const op = diff[0];
991
+ const string = diff[1];
992
+ if (string.includes("\n")) {
993
+ const substrings = string.split("\n");
994
+ const iLast = substrings.length - 1;
995
+ substrings.forEach((substring, i) => {
996
+ if (i === 0) {
997
+ const subdiff = new Diff(op, substring);
998
+ if (this.deleteBuffer.isLineEmpty() && this.insertBuffer.isLineEmpty()) {
999
+ this.flushChangeLines();
1000
+ this.pushDiffCommonLine(subdiff);
1001
+ } else {
1002
+ this.pushDiffChangeLines(subdiff);
1003
+ this.flushChangeLines();
1004
+ }
1005
+ } else if (i < iLast) this.pushDiffCommonLine(new Diff(op, substring));
1006
+ else if (substring.length !== 0) this.pushDiffChangeLines(new Diff(op, substring));
1007
+ });
1008
+ } else this.pushDiffChangeLines(diff);
1009
+ }
1010
+ getLines() {
1011
+ this.flushChangeLines();
1012
+ return this.lines;
1013
+ }
1014
+ };
1015
+ function getAlignedDiffs(diffs, changeColor) {
1016
+ const deleteBuffer = new ChangeBuffer(DIFF_DELETE, changeColor);
1017
+ const insertBuffer = new ChangeBuffer(DIFF_INSERT, changeColor);
1018
+ const commonBuffer = new CommonBuffer(deleteBuffer, insertBuffer);
1019
+ diffs.forEach((diff) => {
1020
+ switch (diff[0]) {
1021
+ case DIFF_DELETE:
1022
+ deleteBuffer.align(diff);
1023
+ break;
1024
+ case DIFF_INSERT:
1025
+ insertBuffer.align(diff);
1026
+ break;
1027
+ default: commonBuffer.align(diff);
1028
+ }
1029
+ });
1030
+ return commonBuffer.getLines();
1031
+ }
1032
+ function hasCommonDiff(diffs, isMultiline) {
1033
+ if (isMultiline) {
1034
+ const iLast = diffs.length - 1;
1035
+ return diffs.some((diff, i) => diff[0] === DIFF_EQUAL && (i !== iLast || diff[1] !== "\n"));
1036
+ }
1037
+ return diffs.some((diff) => diff[0] === DIFF_EQUAL);
1038
+ }
1039
+ function diffStringsUnified(a, b, options) {
1040
+ if (a !== b && a.length !== 0 && b.length !== 0) {
1041
+ const isMultiline = a.includes("\n") || b.includes("\n");
1042
+ const [diffs, truncated] = diffStringsRaw(isMultiline ? `${a}
1043
+ ` : a, isMultiline ? `${b}
1044
+ ` : b, true, options);
1045
+ if (hasCommonDiff(diffs, isMultiline)) {
1046
+ const optionsNormalized = normalizeDiffOptions(options);
1047
+ return printDiffLines(getAlignedDiffs(diffs, optionsNormalized.changeColor), truncated, optionsNormalized);
1048
+ }
1049
+ }
1050
+ return diffLinesUnified(a.split("\n"), b.split("\n"), options);
1051
+ }
1052
+ function diffStringsRaw(a, b, cleanup, options) {
1053
+ const [diffs, truncated] = diffStrings(a, b, options);
1054
+ if (cleanup) diff_cleanupSemantic(diffs);
1055
+ return [diffs, truncated];
1056
+ }
1057
+ function getCommonMessage(message, options) {
1058
+ const { commonColor } = normalizeDiffOptions(options);
1059
+ return commonColor(message);
1060
+ }
1061
+ const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
1062
+ const PLUGINS = [
1063
+ ReactTestComponent,
1064
+ ReactElement,
1065
+ DOMElement,
1066
+ DOMCollection,
1067
+ Immutable,
1068
+ AsymmetricMatcher
1069
+ ];
1070
+ const FORMAT_OPTIONS = { plugins: PLUGINS };
1071
+ const FALLBACK_FORMAT_OPTIONS = {
1072
+ callToJSON: false,
1073
+ maxDepth: 10,
1074
+ plugins: PLUGINS
1075
+ };
1076
+ function diff(a, b, options) {
1077
+ if (Object.is(a, b)) return "";
1078
+ const aType = getType(a);
1079
+ let expectedType = aType;
1080
+ let omitDifference = false;
1081
+ if (aType === "object" && typeof a.asymmetricMatch === "function") {
1082
+ if (a.$$typeof !== Symbol.for("jest.asymmetricMatcher")) return;
1083
+ if (typeof a.getExpectedType !== "function") return;
1084
+ expectedType = a.getExpectedType();
1085
+ omitDifference = expectedType === "string";
1086
+ }
1087
+ if (expectedType !== getType(b)) {
1088
+ const { aAnnotation, aColor, aIndicator, bAnnotation, bColor, bIndicator } = normalizeDiffOptions(options);
1089
+ const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
1090
+ const aDisplay = format(a, formatOptions);
1091
+ const bDisplay = format(b, formatOptions);
1092
+ return `${`${aColor(`${aIndicator} ${aAnnotation}:`)}
1093
+ ${aDisplay}`}
1094
+
1095
+ ${`${bColor(`${bIndicator} ${bAnnotation}:`)}
1096
+ ${bDisplay}`}`;
1097
+ }
1098
+ if (omitDifference) return;
1099
+ switch (aType) {
1100
+ case "string": return diffLinesUnified(a.split("\n"), b.split("\n"), options);
1101
+ case "boolean":
1102
+ case "number": return comparePrimitive(a, b, options);
1103
+ case "map": return compareObjects(sortMap(a), sortMap(b), options);
1104
+ case "set": return compareObjects(sortSet(a), sortSet(b), options);
1105
+ default: return compareObjects(a, b, options);
1106
+ }
1107
+ }
1108
+ function comparePrimitive(a, b, options) {
1109
+ const aFormat = format(a, FORMAT_OPTIONS);
1110
+ const bFormat = format(b, FORMAT_OPTIONS);
1111
+ return aFormat === bFormat ? "" : diffLinesUnified(aFormat.split("\n"), bFormat.split("\n"), options);
1112
+ }
1113
+ function sortMap(map) {
1114
+ return new Map(Array.from(map.entries()).sort());
1115
+ }
1116
+ function sortSet(set) {
1117
+ return new Set(Array.from(set.values()).sort());
1118
+ }
1119
+ function compareObjects(a, b, options) {
1120
+ let difference;
1121
+ let hasThrown = false;
1122
+ try {
1123
+ difference = getObjectsDifference(a, b, getFormatOptions(FORMAT_OPTIONS, options), options);
1124
+ } catch {
1125
+ hasThrown = true;
1126
+ }
1127
+ const noDiffMessage = getCommonMessage(NO_DIFF_MESSAGE, options);
1128
+ if (difference === void 0 || difference === noDiffMessage) {
1129
+ difference = getObjectsDifference(a, b, getFormatOptions(FALLBACK_FORMAT_OPTIONS, options), options);
1130
+ if (difference !== noDiffMessage && !hasThrown) difference = `${getCommonMessage(SIMILAR_MESSAGE, options)}
1131
+
1132
+ ${difference}`;
1133
+ }
1134
+ return difference;
1135
+ }
1136
+ function getFormatOptions(formatOptions, options) {
1137
+ const { compareKeys } = normalizeDiffOptions(options);
1138
+ return {
1139
+ ...formatOptions,
1140
+ compareKeys
1141
+ };
1142
+ }
1143
+ function getObjectsDifference(a, b, formatOptions, options) {
1144
+ const formatOptionsZeroIndent = {
1145
+ ...formatOptions,
1146
+ indent: 0
1147
+ };
1148
+ const aCompare = format(a, formatOptionsZeroIndent);
1149
+ const bCompare = format(b, formatOptionsZeroIndent);
1150
+ if (aCompare === bCompare) return getCommonMessage(NO_DIFF_MESSAGE, options);
1151
+ else {
1152
+ const aDisplay = format(a, formatOptions);
1153
+ const bDisplay = format(b, formatOptions);
1154
+ return diffLinesUnified2(aDisplay.split("\n"), bDisplay.split("\n"), aCompare.split("\n"), bCompare.split("\n"), options);
1155
+ }
1156
+ }
1157
+ const MAX_DIFF_STRING_LENGTH = 2e4;
1158
+ function isAsymmetricMatcher(data) {
1159
+ return getType$1(data) === "Object" && typeof data.asymmetricMatch === "function";
1160
+ }
1161
+ function isReplaceable(obj1, obj2) {
1162
+ const obj1Type = getType$1(obj1);
1163
+ return obj1Type === getType$1(obj2) && (obj1Type === "Object" || obj1Type === "Array");
1164
+ }
1165
+ function printDiffOrStringify(expected, received, options) {
1166
+ const { aAnnotation, bAnnotation } = normalizeDiffOptions(options);
1167
+ if (typeof expected === "string" && typeof received === "string" && expected.length > 0 && received.length > 0 && expected.length <= MAX_DIFF_STRING_LENGTH && received.length <= MAX_DIFF_STRING_LENGTH && expected !== received) {
1168
+ if (expected.includes("\n") || received.includes("\n")) return diffStringsUnified(received, expected, options);
1169
+ const [diffs] = diffStringsRaw(received, expected, true);
1170
+ const hasCommonDiff = diffs.some((diff2) => diff2[0] === DIFF_EQUAL);
1171
+ const printLabel = getLabelPrinter(aAnnotation, bAnnotation);
1172
+ return `${printLabel(aAnnotation) + printExpected(getCommonAndChangedSubstrings(diffs, DIFF_DELETE, hasCommonDiff))}
1173
+ ${printLabel(bAnnotation) + printReceived(getCommonAndChangedSubstrings(diffs, DIFF_INSERT, hasCommonDiff))}`;
1174
+ }
1175
+ const { replacedExpected, replacedActual } = replaceAsymmetricMatcher(deepClone(expected, { forceWritable: true }), deepClone(received, { forceWritable: true }));
1176
+ return diff(replacedExpected, replacedActual, options);
1177
+ }
1178
+ function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE__ */ new WeakSet(), expectedReplaced = /* @__PURE__ */ new WeakSet()) {
1179
+ if (!isReplaceable(actual, expected)) return {
1180
+ replacedActual: actual,
1181
+ replacedExpected: expected
1182
+ };
1183
+ if (actualReplaced.has(actual) || expectedReplaced.has(expected)) return {
1184
+ replacedActual: actual,
1185
+ replacedExpected: expected
1186
+ };
1187
+ actualReplaced.add(actual);
1188
+ expectedReplaced.add(expected);
1189
+ getOwnProperties(expected).forEach((key) => {
1190
+ const expectedValue = expected[key];
1191
+ const actualValue = actual[key];
1192
+ if (isAsymmetricMatcher(expectedValue)) {
1193
+ if (expectedValue.asymmetricMatch(actualValue)) actual[key] = expectedValue;
1194
+ } else if (isAsymmetricMatcher(actualValue)) {
1195
+ if (actualValue.asymmetricMatch(expectedValue)) expected[key] = actualValue;
1196
+ } else if (isReplaceable(actualValue, expectedValue)) {
1197
+ const replaced = replaceAsymmetricMatcher(actualValue, expectedValue, actualReplaced, expectedReplaced);
1198
+ actual[key] = replaced.replacedActual;
1199
+ expected[key] = replaced.replacedExpected;
1200
+ }
1201
+ });
1202
+ return {
1203
+ replacedActual: actual,
1204
+ replacedExpected: expected
1205
+ };
1206
+ }
1207
+ function getLabelPrinter(...strings) {
1208
+ const maxLength = strings.reduce((max, string) => string.length > max ? string.length : max, 0);
1209
+ return (string) => `${string}: ${" ".repeat(maxLength - string.length)}`;
1210
+ }
1211
+ const SPACE_SYMBOL = "·";
1212
+ function replaceTrailingSpaces(text) {
1213
+ return text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
1214
+ }
1215
+ function printReceived(object) {
1216
+ return p.red(replaceTrailingSpaces(stringify(object)));
1217
+ }
1218
+ function printExpected(value) {
1219
+ return p.green(replaceTrailingSpaces(stringify(value)));
1220
+ }
1221
+ function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
1222
+ return diffs.reduce((reduced, diff2) => reduced + (diff2[0] === DIFF_EQUAL ? diff2[1] : diff2[0] === op ? hasCommonDiff ? p.inverse(diff2[1]) : diff2[1] : ""), "");
1223
+ }
1224
+
1225
+ //#endregion
1226
+ export { diff, printDiffOrStringify };
1227
+ //# sourceMappingURL=diff.mjs.map