@farming-labs/theme 0.0.24 → 0.0.26

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 (53) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +26 -1
  2. package/dist/docs-api.mjs +3 -1
  3. package/dist/docs-layout.mjs +9 -4
  4. package/dist/get-app-dir.d.mts +9 -0
  5. package/dist/get-app-dir.mjs +16 -0
  6. package/dist/get-app-dir.test.d.mts +1 -0
  7. package/dist/get-app-dir.test.mjs +41 -0
  8. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +77 -0
  9. package/dist/node_modules/.pnpm/@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.mjs +1356 -0
  10. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.mjs +1119 -0
  11. package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.mjs +1091 -0
  12. package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/index.mjs +4 -0
  13. package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/utils.mjs +3 -0
  14. package/dist/node_modules/.pnpm/@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.mjs +1821 -0
  15. package/dist/node_modules/.pnpm/@vitest_spy@3.2.4/node_modules/@vitest/spy/dist/index.mjs +171 -0
  16. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.mjs +124 -0
  17. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/diff.mjs +1334 -0
  18. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.mjs +105 -0
  19. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/helpers.mjs +118 -0
  20. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/index.mjs +455 -0
  21. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/source-map.mjs +168 -0
  22. package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.mjs +3087 -0
  23. package/dist/node_modules/.pnpm/js-tokens@9.0.1/node_modules/js-tokens/index.mjs +384 -0
  24. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.mjs +11 -0
  25. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.mjs +16 -0
  26. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.mjs +11 -0
  27. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.mjs +15 -0
  28. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.mjs +13 -0
  29. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.mjs +34 -0
  30. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.mjs +12 -0
  31. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.mjs +122 -0
  32. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.mjs +39 -0
  33. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.mjs +99 -0
  34. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.mjs +25 -0
  35. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.mjs +14 -0
  36. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.mjs +21 -0
  37. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.mjs +5 -0
  38. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.mjs +12 -0
  39. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.mjs +18 -0
  40. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.mjs +25 -0
  41. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.mjs +8 -0
  42. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.mjs +30 -0
  43. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +939 -0
  44. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +81 -0
  45. package/dist/node_modules/.pnpm/strip-literal@3.1.0/node_modules/strip-literal/dist/index.mjs +51 -0
  46. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.mjs +81 -0
  47. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.mjs +9 -0
  48. package/dist/node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.mjs +125 -0
  49. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@22.19.11_jiti@2.6.1_lightningcss@1.30.2_terser@5.46.0_yaml@2.8.2/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.mjs +8 -0
  50. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@22.19.11_jiti@2.6.1_lightningcss@1.30.2_terser@5.46.0_yaml@2.8.2/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.mjs +50 -0
  51. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@22.19.11_jiti@2.6.1_lightningcss@1.30.2_terser@5.46.0_yaml@2.8.2/node_modules/vitest/dist/chunks/utils.XdZDrNZV.mjs +48 -0
  52. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@22.19.11_jiti@2.6.1_lightningcss@1.30.2_terser@5.46.0_yaml@2.8.2/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.mjs +2613 -0
  53. package/package.json +6 -3
@@ -0,0 +1,1821 @@
1
+ import { format, plugins } from "../../../../../@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.mjs";
2
+ import { resolve as resolve$2 } from "../../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs";
3
+
4
+ //#region ../../node_modules/.pnpm/@vitest+snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js
5
+ const comma = ",".charCodeAt(0);
6
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
7
+ const intToChar = new Uint8Array(64);
8
+ const charToInt = new Uint8Array(128);
9
+ for (let i = 0; i < 64; i++) {
10
+ const c = chars.charCodeAt(i);
11
+ intToChar[i] = c;
12
+ charToInt[c] = i;
13
+ }
14
+ function decodeInteger(reader, relative) {
15
+ let value = 0;
16
+ let shift = 0;
17
+ let integer = 0;
18
+ do {
19
+ integer = charToInt[reader.next()];
20
+ value |= (integer & 31) << shift;
21
+ shift += 5;
22
+ } while (integer & 32);
23
+ const shouldNegate = value & 1;
24
+ value >>>= 1;
25
+ if (shouldNegate) value = -2147483648 | -value;
26
+ return relative + value;
27
+ }
28
+ function hasMoreVlq(reader, max) {
29
+ if (reader.pos >= max) return false;
30
+ return reader.peek() !== comma;
31
+ }
32
+ var StringReader = class {
33
+ constructor(buffer) {
34
+ this.pos = 0;
35
+ this.buffer = buffer;
36
+ }
37
+ next() {
38
+ return this.buffer.charCodeAt(this.pos++);
39
+ }
40
+ peek() {
41
+ return this.buffer.charCodeAt(this.pos);
42
+ }
43
+ indexOf(char) {
44
+ const { buffer, pos } = this;
45
+ const idx = buffer.indexOf(char, pos);
46
+ return idx === -1 ? buffer.length : idx;
47
+ }
48
+ };
49
+ function decode(mappings) {
50
+ const { length } = mappings;
51
+ const reader = new StringReader(mappings);
52
+ const decoded = [];
53
+ let genColumn = 0;
54
+ let sourcesIndex = 0;
55
+ let sourceLine = 0;
56
+ let sourceColumn = 0;
57
+ let namesIndex = 0;
58
+ do {
59
+ const semi = reader.indexOf(";");
60
+ const line = [];
61
+ let sorted = true;
62
+ let lastCol = 0;
63
+ genColumn = 0;
64
+ while (reader.pos < semi) {
65
+ let seg;
66
+ genColumn = decodeInteger(reader, genColumn);
67
+ if (genColumn < lastCol) sorted = false;
68
+ lastCol = genColumn;
69
+ if (hasMoreVlq(reader, semi)) {
70
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
71
+ sourceLine = decodeInteger(reader, sourceLine);
72
+ sourceColumn = decodeInteger(reader, sourceColumn);
73
+ if (hasMoreVlq(reader, semi)) {
74
+ namesIndex = decodeInteger(reader, namesIndex);
75
+ seg = [
76
+ genColumn,
77
+ sourcesIndex,
78
+ sourceLine,
79
+ sourceColumn,
80
+ namesIndex
81
+ ];
82
+ } else seg = [
83
+ genColumn,
84
+ sourcesIndex,
85
+ sourceLine,
86
+ sourceColumn
87
+ ];
88
+ } else seg = [genColumn];
89
+ line.push(seg);
90
+ reader.pos++;
91
+ }
92
+ if (!sorted) sort(line);
93
+ decoded.push(line);
94
+ reader.pos = semi + 1;
95
+ } while (reader.pos <= length);
96
+ return decoded;
97
+ }
98
+ function sort(line) {
99
+ line.sort(sortComparator$1);
100
+ }
101
+ function sortComparator$1(a, b) {
102
+ return a[0] - b[0];
103
+ }
104
+ const schemeRegex = /^[\w+.-]+:\/\//;
105
+ /**
106
+ * Matches the parts of a URL:
107
+ * 1. Scheme, including ":", guaranteed.
108
+ * 2. User/password, including "@", optional.
109
+ * 3. Host, guaranteed.
110
+ * 4. Port, including ":", optional.
111
+ * 5. Path, including "/", optional.
112
+ * 6. Query, including "?", optional.
113
+ * 7. Hash, including "#", optional.
114
+ */
115
+ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
116
+ /**
117
+ * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
118
+ * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
119
+ *
120
+ * 1. Host, optional.
121
+ * 2. Path, which may include "/", guaranteed.
122
+ * 3. Query, including "?", optional.
123
+ * 4. Hash, including "#", optional.
124
+ */
125
+ const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
126
+ var UrlType;
127
+ (function(UrlType) {
128
+ UrlType[UrlType["Empty"] = 1] = "Empty";
129
+ UrlType[UrlType["Hash"] = 2] = "Hash";
130
+ UrlType[UrlType["Query"] = 3] = "Query";
131
+ UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
132
+ UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
133
+ UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
134
+ UrlType[UrlType["Absolute"] = 7] = "Absolute";
135
+ })(UrlType || (UrlType = {}));
136
+ function isAbsoluteUrl(input) {
137
+ return schemeRegex.test(input);
138
+ }
139
+ function isSchemeRelativeUrl(input) {
140
+ return input.startsWith("//");
141
+ }
142
+ function isAbsolutePath(input) {
143
+ return input.startsWith("/");
144
+ }
145
+ function isFileUrl(input) {
146
+ return input.startsWith("file:");
147
+ }
148
+ function isRelative(input) {
149
+ return /^[.?#]/.test(input);
150
+ }
151
+ function parseAbsoluteUrl(input) {
152
+ const match = urlRegex.exec(input);
153
+ return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
154
+ }
155
+ function parseFileUrl(input) {
156
+ const match = fileRegex.exec(input);
157
+ const path = match[2];
158
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
159
+ }
160
+ function makeUrl(scheme, user, host, port, path, query, hash) {
161
+ return {
162
+ scheme,
163
+ user,
164
+ host,
165
+ port,
166
+ path,
167
+ query,
168
+ hash,
169
+ type: UrlType.Absolute
170
+ };
171
+ }
172
+ function parseUrl(input) {
173
+ if (isSchemeRelativeUrl(input)) {
174
+ const url = parseAbsoluteUrl("http:" + input);
175
+ url.scheme = "";
176
+ url.type = UrlType.SchemeRelative;
177
+ return url;
178
+ }
179
+ if (isAbsolutePath(input)) {
180
+ const url = parseAbsoluteUrl("http://foo.com" + input);
181
+ url.scheme = "";
182
+ url.host = "";
183
+ url.type = UrlType.AbsolutePath;
184
+ return url;
185
+ }
186
+ if (isFileUrl(input)) return parseFileUrl(input);
187
+ if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
188
+ const url = parseAbsoluteUrl("http://foo.com/" + input);
189
+ url.scheme = "";
190
+ url.host = "";
191
+ url.type = input ? input.startsWith("?") ? UrlType.Query : input.startsWith("#") ? UrlType.Hash : UrlType.RelativePath : UrlType.Empty;
192
+ return url;
193
+ }
194
+ function stripPathFilename(path) {
195
+ if (path.endsWith("/..")) return path;
196
+ const index = path.lastIndexOf("/");
197
+ return path.slice(0, index + 1);
198
+ }
199
+ function mergePaths(url, base) {
200
+ normalizePath(base, base.type);
201
+ if (url.path === "/") url.path = base.path;
202
+ else url.path = stripPathFilename(base.path) + url.path;
203
+ }
204
+ /**
205
+ * The path can have empty directories "//", unneeded parents "foo/..", or current directory
206
+ * "foo/.". We need to normalize to a standard representation.
207
+ */
208
+ function normalizePath(url, type) {
209
+ const rel = type <= UrlType.RelativePath;
210
+ const pieces = url.path.split("/");
211
+ let pointer = 1;
212
+ let positive = 0;
213
+ let addTrailingSlash = false;
214
+ for (let i = 1; i < pieces.length; i++) {
215
+ const piece = pieces[i];
216
+ if (!piece) {
217
+ addTrailingSlash = true;
218
+ continue;
219
+ }
220
+ addTrailingSlash = false;
221
+ if (piece === ".") continue;
222
+ if (piece === "..") {
223
+ if (positive) {
224
+ addTrailingSlash = true;
225
+ positive--;
226
+ pointer--;
227
+ } else if (rel) pieces[pointer++] = piece;
228
+ continue;
229
+ }
230
+ pieces[pointer++] = piece;
231
+ positive++;
232
+ }
233
+ let path = "";
234
+ for (let i = 1; i < pointer; i++) path += "/" + pieces[i];
235
+ if (!path || addTrailingSlash && !path.endsWith("/..")) path += "/";
236
+ url.path = path;
237
+ }
238
+ /**
239
+ * Attempts to resolve `input` URL/path relative to `base`.
240
+ */
241
+ function resolve$1(input, base) {
242
+ if (!input && !base) return "";
243
+ const url = parseUrl(input);
244
+ let inputType = url.type;
245
+ if (base && inputType !== UrlType.Absolute) {
246
+ const baseUrl = parseUrl(base);
247
+ const baseType = baseUrl.type;
248
+ switch (inputType) {
249
+ case UrlType.Empty: url.hash = baseUrl.hash;
250
+ case UrlType.Hash: url.query = baseUrl.query;
251
+ case UrlType.Query:
252
+ case UrlType.RelativePath: mergePaths(url, baseUrl);
253
+ case UrlType.AbsolutePath:
254
+ url.user = baseUrl.user;
255
+ url.host = baseUrl.host;
256
+ url.port = baseUrl.port;
257
+ case UrlType.SchemeRelative: url.scheme = baseUrl.scheme;
258
+ }
259
+ if (baseType > inputType) inputType = baseType;
260
+ }
261
+ normalizePath(url, inputType);
262
+ const queryHash = url.query + url.hash;
263
+ switch (inputType) {
264
+ case UrlType.Hash:
265
+ case UrlType.Query: return queryHash;
266
+ case UrlType.RelativePath: {
267
+ const path = url.path.slice(1);
268
+ if (!path) return queryHash || ".";
269
+ if (isRelative(base || input) && !isRelative(path)) return "./" + path + queryHash;
270
+ return path + queryHash;
271
+ }
272
+ case UrlType.AbsolutePath: return url.path + queryHash;
273
+ default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
274
+ }
275
+ }
276
+ function resolve(input, base) {
277
+ if (base && !base.endsWith("/")) base += "/";
278
+ return resolve$1(input, base);
279
+ }
280
+ /**
281
+ * Removes everything after the last "/", but leaves the slash.
282
+ */
283
+ function stripFilename(path) {
284
+ if (!path) return "";
285
+ const index = path.lastIndexOf("/");
286
+ return path.slice(0, index + 1);
287
+ }
288
+ const COLUMN = 0;
289
+ const SOURCES_INDEX = 1;
290
+ const SOURCE_LINE = 2;
291
+ const SOURCE_COLUMN = 3;
292
+ const NAMES_INDEX = 4;
293
+ function maybeSort(mappings, owned) {
294
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
295
+ if (unsortedIndex === mappings.length) return mappings;
296
+ if (!owned) mappings = mappings.slice();
297
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) mappings[i] = sortSegments(mappings[i], owned);
298
+ return mappings;
299
+ }
300
+ function nextUnsortedSegmentLine(mappings, start) {
301
+ for (let i = start; i < mappings.length; i++) if (!isSorted(mappings[i])) return i;
302
+ return mappings.length;
303
+ }
304
+ function isSorted(line) {
305
+ for (let j = 1; j < line.length; j++) if (line[j][COLUMN] < line[j - 1][COLUMN]) return false;
306
+ return true;
307
+ }
308
+ function sortSegments(line, owned) {
309
+ if (!owned) line = line.slice();
310
+ return line.sort(sortComparator);
311
+ }
312
+ function sortComparator(a, b) {
313
+ return a[COLUMN] - b[COLUMN];
314
+ }
315
+ let found = false;
316
+ /**
317
+ * A binary search implementation that returns the index if a match is found.
318
+ * If no match is found, then the left-index (the index associated with the item that comes just
319
+ * before the desired index) is returned. To maintain proper sort order, a splice would happen at
320
+ * the next index:
321
+ *
322
+ * ```js
323
+ * const array = [1, 3];
324
+ * const needle = 2;
325
+ * const index = binarySearch(array, needle, (item, needle) => item - needle);
326
+ *
327
+ * assert.equal(index, 0);
328
+ * array.splice(index + 1, 0, needle);
329
+ * assert.deepEqual(array, [1, 2, 3]);
330
+ * ```
331
+ */
332
+ function binarySearch(haystack, needle, low, high) {
333
+ while (low <= high) {
334
+ const mid = low + (high - low >> 1);
335
+ const cmp = haystack[mid][COLUMN] - needle;
336
+ if (cmp === 0) {
337
+ found = true;
338
+ return mid;
339
+ }
340
+ if (cmp < 0) low = mid + 1;
341
+ else high = mid - 1;
342
+ }
343
+ found = false;
344
+ return low - 1;
345
+ }
346
+ function upperBound(haystack, needle, index) {
347
+ for (let i = index + 1; i < haystack.length; index = i++) if (haystack[i][COLUMN] !== needle) break;
348
+ return index;
349
+ }
350
+ function lowerBound(haystack, needle, index) {
351
+ for (let i = index - 1; i >= 0; index = i--) if (haystack[i][COLUMN] !== needle) break;
352
+ return index;
353
+ }
354
+ function memoizedState() {
355
+ return {
356
+ lastKey: -1,
357
+ lastNeedle: -1,
358
+ lastIndex: -1
359
+ };
360
+ }
361
+ /**
362
+ * This overly complicated beast is just to record the last tested line/column and the resulting
363
+ * index, allowing us to skip a few tests if mappings are monotonically increasing.
364
+ */
365
+ function memoizedBinarySearch(haystack, needle, state, key) {
366
+ const { lastKey, lastNeedle, lastIndex } = state;
367
+ let low = 0;
368
+ let high = haystack.length - 1;
369
+ if (key === lastKey) {
370
+ if (needle === lastNeedle) {
371
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
372
+ return lastIndex;
373
+ }
374
+ if (needle >= lastNeedle) low = lastIndex === -1 ? 0 : lastIndex;
375
+ else high = lastIndex;
376
+ }
377
+ state.lastKey = key;
378
+ state.lastNeedle = needle;
379
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
380
+ }
381
+ const LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
382
+ const COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
383
+ const LEAST_UPPER_BOUND = -1;
384
+ const GREATEST_LOWER_BOUND = 1;
385
+ var TraceMap = class {
386
+ constructor(map, mapUrl) {
387
+ const isString = typeof map === "string";
388
+ if (!isString && map._decodedMemo) return map;
389
+ const parsed = isString ? JSON.parse(map) : map;
390
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
391
+ this.version = version;
392
+ this.file = file;
393
+ this.names = names || [];
394
+ this.sourceRoot = sourceRoot;
395
+ this.sources = sources;
396
+ this.sourcesContent = sourcesContent;
397
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
398
+ const from = resolve(sourceRoot || "", stripFilename(mapUrl));
399
+ this.resolvedSources = sources.map((s) => resolve(s || "", from));
400
+ const { mappings } = parsed;
401
+ if (typeof mappings === "string") {
402
+ this._encoded = mappings;
403
+ this._decoded = void 0;
404
+ } else {
405
+ this._encoded = void 0;
406
+ this._decoded = maybeSort(mappings, isString);
407
+ }
408
+ this._decodedMemo = memoizedState();
409
+ this._bySources = void 0;
410
+ this._bySourceMemos = void 0;
411
+ }
412
+ };
413
+ /**
414
+ * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
415
+ * with public access modifiers.
416
+ */
417
+ function cast(map) {
418
+ return map;
419
+ }
420
+ /**
421
+ * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
422
+ */
423
+ function decodedMappings(map) {
424
+ var _a;
425
+ return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
426
+ }
427
+ /**
428
+ * A higher-level API to find the source/line/column associated with a generated line/column
429
+ * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
430
+ * `source-map` library.
431
+ */
432
+ function originalPositionFor(map, needle) {
433
+ let { line, column, bias } = needle;
434
+ line--;
435
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
436
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
437
+ const decoded = decodedMappings(map);
438
+ if (line >= decoded.length) return OMapping(null, null, null, null);
439
+ const segments = decoded[line];
440
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
441
+ if (index === -1) return OMapping(null, null, null, null);
442
+ const segment = segments[index];
443
+ if (segment.length === 1) return OMapping(null, null, null, null);
444
+ const { names, resolvedSources } = map;
445
+ return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
446
+ }
447
+ function OMapping(source, line, column, name) {
448
+ return {
449
+ source,
450
+ line,
451
+ column,
452
+ name
453
+ };
454
+ }
455
+ function traceSegmentInternal(segments, memo, line, column, bias) {
456
+ let index = memoizedBinarySearch(segments, column, memo, line);
457
+ if (found) index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
458
+ else if (bias === LEAST_UPPER_BOUND) index++;
459
+ if (index === -1 || index === segments.length) return -1;
460
+ return index;
461
+ }
462
+ /**
463
+ * Get original stacktrace without source map support the most performant way.
464
+ * - Create only 1 stack frame.
465
+ * - Rewrite prepareStackTrace to bypass "support-stack-trace" (usually takes ~250ms).
466
+ */
467
+ function notNullish(v) {
468
+ return v != null;
469
+ }
470
+ function isPrimitive(value) {
471
+ return value === null || typeof value !== "function" && typeof value !== "object";
472
+ }
473
+ function isObject(item) {
474
+ return item != null && typeof item === "object" && !Array.isArray(item);
475
+ }
476
+ /**
477
+ * If code starts with a function call, will return its last index, respecting arguments.
478
+ * This will return 25 - last ending character of toMatch ")"
479
+ * Also works with callbacks
480
+ * ```
481
+ * toMatch({ test: '123' });
482
+ * toBeAliased('123')
483
+ * ```
484
+ */
485
+ function getCallLastIndex(code) {
486
+ let charIndex = -1;
487
+ let inString = null;
488
+ let startedBracers = 0;
489
+ let endedBracers = 0;
490
+ let beforeChar = null;
491
+ while (charIndex <= code.length) {
492
+ beforeChar = code[charIndex];
493
+ charIndex++;
494
+ const char = code[charIndex];
495
+ if ((char === "\"" || char === "'" || char === "`") && beforeChar !== "\\") {
496
+ if (inString === char) inString = null;
497
+ else if (!inString) inString = char;
498
+ }
499
+ if (!inString) {
500
+ if (char === "(") startedBracers++;
501
+ if (char === ")") endedBracers++;
502
+ }
503
+ if (startedBracers && endedBracers && startedBracers === endedBracers) return charIndex;
504
+ }
505
+ return null;
506
+ }
507
+ const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
508
+ const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
509
+ const stackIgnorePatterns = [
510
+ "node:internal",
511
+ /\/packages\/\w+\/dist\//,
512
+ /\/@vitest\/\w+\/dist\//,
513
+ "/vitest/dist/",
514
+ "/vitest/src/",
515
+ "/vite-node/dist/",
516
+ "/vite-node/src/",
517
+ "/node_modules/chai/",
518
+ "/node_modules/tinypool/",
519
+ "/node_modules/tinyspy/",
520
+ "/deps/chunk-",
521
+ "/deps/@vitest",
522
+ "/deps/loupe",
523
+ "/deps/chai",
524
+ /node:\w+/,
525
+ /__vitest_test__/,
526
+ /__vitest_browser__/,
527
+ /\/deps\/vitest_/
528
+ ];
529
+ function extractLocation(urlLike) {
530
+ if (!urlLike.includes(":")) return [urlLike];
531
+ const parts = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/^\(|\)$/g, ""));
532
+ if (!parts) return [urlLike];
533
+ let url = parts[1];
534
+ if (url.startsWith("async ")) url = url.slice(6);
535
+ if (url.startsWith("http:") || url.startsWith("https:")) {
536
+ const urlObj = new URL(url);
537
+ urlObj.searchParams.delete("import");
538
+ urlObj.searchParams.delete("browserv");
539
+ url = urlObj.pathname + urlObj.hash + urlObj.search;
540
+ }
541
+ if (url.startsWith("/@fs/")) {
542
+ const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
543
+ url = url.slice(isWindows ? 5 : 4);
544
+ }
545
+ return [
546
+ url,
547
+ parts[2] || void 0,
548
+ parts[3] || void 0
549
+ ];
550
+ }
551
+ function parseSingleFFOrSafariStack(raw) {
552
+ let line = raw.trim();
553
+ if (SAFARI_NATIVE_CODE_REGEXP.test(line)) return null;
554
+ if (line.includes(" > eval")) line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
555
+ if (!line.includes("@") && !line.includes(":")) return null;
556
+ const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
557
+ const matches = line.match(functionNameRegex);
558
+ const functionName = matches && matches[1] ? matches[1] : void 0;
559
+ const [url, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ""));
560
+ if (!url || !lineNumber || !columnNumber) return null;
561
+ return {
562
+ file: url,
563
+ method: functionName || "",
564
+ line: Number.parseInt(lineNumber),
565
+ column: Number.parseInt(columnNumber)
566
+ };
567
+ }
568
+ function parseSingleV8Stack(raw) {
569
+ let line = raw.trim();
570
+ if (!CHROME_IE_STACK_REGEXP.test(line)) return null;
571
+ if (line.includes("(eval ")) line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
572
+ let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
573
+ const location = sanitizedLine.match(/ (\(.+\)$)/);
574
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
575
+ const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
576
+ let method = location && sanitizedLine || "";
577
+ let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
578
+ if (!file || !lineNumber || !columnNumber) return null;
579
+ if (method.startsWith("async ")) method = method.slice(6);
580
+ if (file.startsWith("file://")) file = file.slice(7);
581
+ file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve$2(file);
582
+ if (method) method = method.replace(/__vite_ssr_import_\d+__\./g, "");
583
+ return {
584
+ method,
585
+ file,
586
+ line: Number.parseInt(lineNumber),
587
+ column: Number.parseInt(columnNumber)
588
+ };
589
+ }
590
+ function parseStacktrace(stack, options = {}) {
591
+ const { ignoreStackEntries = stackIgnorePatterns } = options;
592
+ return (!CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack)).map((stack) => {
593
+ var _options$getSourceMap;
594
+ if (options.getUrlId) stack.file = options.getUrlId(stack.file);
595
+ const map = (_options$getSourceMap = options.getSourceMap) === null || _options$getSourceMap === void 0 ? void 0 : _options$getSourceMap.call(options, stack.file);
596
+ if (!map || typeof map !== "object" || !map.version) return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
597
+ const { line, column, source, name } = originalPositionFor(new TraceMap(map), stack);
598
+ let file = stack.file;
599
+ if (source) {
600
+ const fileUrl = stack.file.startsWith("file://") ? stack.file : `file://${stack.file}`;
601
+ const sourceRootUrl = map.sourceRoot ? new URL(map.sourceRoot, fileUrl) : fileUrl;
602
+ file = new URL(source, sourceRootUrl).pathname;
603
+ if (file.match(/\/\w:\//)) file = file.slice(1);
604
+ }
605
+ if (shouldFilter(ignoreStackEntries, file)) return null;
606
+ if (line != null && column != null) return {
607
+ line,
608
+ column,
609
+ file,
610
+ method: name || stack.method
611
+ };
612
+ return stack;
613
+ }).filter((s) => s != null);
614
+ }
615
+ function shouldFilter(ignoreStackEntries, file) {
616
+ return ignoreStackEntries.some((p) => file.match(p));
617
+ }
618
+ function parseFFOrSafariStackTrace(stack) {
619
+ return stack.split("\n").map((line) => parseSingleFFOrSafariStack(line)).filter(notNullish);
620
+ }
621
+ function parseV8Stacktrace(stack) {
622
+ return stack.split("\n").map((line) => parseSingleV8Stack(line)).filter(notNullish);
623
+ }
624
+ function parseErrorStacktrace(e, options = {}) {
625
+ if (!e || isPrimitive(e)) return [];
626
+ if (e.stacks) return e.stacks;
627
+ const stackStr = e.stack || "";
628
+ let stackFrames = typeof stackStr === "string" ? parseStacktrace(stackStr, options) : [];
629
+ if (!stackFrames.length) {
630
+ const e_ = e;
631
+ if (e_.fileName != null && e_.lineNumber != null && e_.columnNumber != null) stackFrames = parseStacktrace(`${e_.fileName}:${e_.lineNumber}:${e_.columnNumber}`, options);
632
+ if (e_.sourceURL != null && e_.line != null && e_._column != null) stackFrames = parseStacktrace(`${e_.sourceURL}:${e_.line}:${e_.column}`, options);
633
+ }
634
+ if (options.frameFilter) stackFrames = stackFrames.filter((f) => options.frameFilter(e, f) !== false);
635
+ e.stacks = stackFrames;
636
+ return stackFrames;
637
+ }
638
+ try {
639
+ const { getPromiseDetails, kPending, kRejected } = process.binding("util");
640
+ if (Array.isArray(getPromiseDetails(Promise.resolve()))) {}
641
+ } catch (notNode) {}
642
+ const { AsymmetricMatcher: AsymmetricMatcher$1, DOMCollection: DOMCollection$1, DOMElement: DOMElement$1, Immutable: Immutable$1, ReactElement: ReactElement$1, ReactTestComponent: ReactTestComponent$1 } = plugins;
643
+ function getDefaultExportFromCjs(x) {
644
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
645
+ }
646
+ var jsTokens_1;
647
+ var hasRequiredJsTokens;
648
+ function requireJsTokens() {
649
+ if (hasRequiredJsTokens) return jsTokens_1;
650
+ hasRequiredJsTokens = 1;
651
+ var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/uy, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
652
+ Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
653
+ Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/uy;
654
+ StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
655
+ NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
656
+ Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
657
+ WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/uy;
658
+ LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
659
+ MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
660
+ SingleLineComment = /\/\/.*/y;
661
+ JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
662
+ JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/uy;
663
+ JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
664
+ JSXText = /[^<>{}]+/y;
665
+ TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
666
+ TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
667
+ KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
668
+ KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
669
+ Newline = RegExp(LineTerminatorSequence.source);
670
+ jsTokens_1 = function* (input, { jsx = false } = {}) {
671
+ var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
672
+ ({length} = input);
673
+ lastIndex = 0;
674
+ lastSignificantToken = "";
675
+ stack = [{ tag: "JS" }];
676
+ braces = [];
677
+ parenNesting = 0;
678
+ postfixIncDec = false;
679
+ while (lastIndex < length) {
680
+ mode = stack[stack.length - 1];
681
+ switch (mode.tag) {
682
+ case "JS":
683
+ case "JSNonExpressionParen":
684
+ case "InterpolationInTemplate":
685
+ case "InterpolationInJSX":
686
+ if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
687
+ RegularExpressionLiteral.lastIndex = lastIndex;
688
+ if (match = RegularExpressionLiteral.exec(input)) {
689
+ lastIndex = RegularExpressionLiteral.lastIndex;
690
+ lastSignificantToken = match[0];
691
+ postfixIncDec = true;
692
+ yield {
693
+ type: "RegularExpressionLiteral",
694
+ value: match[0],
695
+ closed: match[1] !== void 0 && match[1] !== "\\"
696
+ };
697
+ continue;
698
+ }
699
+ }
700
+ Punctuator.lastIndex = lastIndex;
701
+ if (match = Punctuator.exec(input)) {
702
+ punctuator = match[0];
703
+ nextLastIndex = Punctuator.lastIndex;
704
+ nextLastSignificantToken = punctuator;
705
+ switch (punctuator) {
706
+ case "(":
707
+ if (lastSignificantToken === "?NonExpressionParenKeyword") stack.push({
708
+ tag: "JSNonExpressionParen",
709
+ nesting: parenNesting
710
+ });
711
+ parenNesting++;
712
+ postfixIncDec = false;
713
+ break;
714
+ case ")":
715
+ parenNesting--;
716
+ postfixIncDec = true;
717
+ if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
718
+ stack.pop();
719
+ nextLastSignificantToken = "?NonExpressionParenEnd";
720
+ postfixIncDec = false;
721
+ }
722
+ break;
723
+ case "{":
724
+ Punctuator.lastIndex = 0;
725
+ isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
726
+ braces.push(isExpression);
727
+ postfixIncDec = false;
728
+ break;
729
+ case "}":
730
+ switch (mode.tag) {
731
+ case "InterpolationInTemplate":
732
+ if (braces.length === mode.nesting) {
733
+ Template.lastIndex = lastIndex;
734
+ match = Template.exec(input);
735
+ lastIndex = Template.lastIndex;
736
+ lastSignificantToken = match[0];
737
+ if (match[1] === "${") {
738
+ lastSignificantToken = "?InterpolationInTemplate";
739
+ postfixIncDec = false;
740
+ yield {
741
+ type: "TemplateMiddle",
742
+ value: match[0]
743
+ };
744
+ } else {
745
+ stack.pop();
746
+ postfixIncDec = true;
747
+ yield {
748
+ type: "TemplateTail",
749
+ value: match[0],
750
+ closed: match[1] === "`"
751
+ };
752
+ }
753
+ continue;
754
+ }
755
+ break;
756
+ case "InterpolationInJSX": if (braces.length === mode.nesting) {
757
+ stack.pop();
758
+ lastIndex += 1;
759
+ lastSignificantToken = "}";
760
+ yield {
761
+ type: "JSXPunctuator",
762
+ value: "}"
763
+ };
764
+ continue;
765
+ }
766
+ }
767
+ postfixIncDec = braces.pop();
768
+ nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
769
+ break;
770
+ case "]":
771
+ postfixIncDec = true;
772
+ break;
773
+ case "++":
774
+ case "--":
775
+ nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
776
+ break;
777
+ case "<":
778
+ if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
779
+ stack.push({ tag: "JSXTag" });
780
+ lastIndex += 1;
781
+ lastSignificantToken = "<";
782
+ yield {
783
+ type: "JSXPunctuator",
784
+ value: punctuator
785
+ };
786
+ continue;
787
+ }
788
+ postfixIncDec = false;
789
+ break;
790
+ default: postfixIncDec = false;
791
+ }
792
+ lastIndex = nextLastIndex;
793
+ lastSignificantToken = nextLastSignificantToken;
794
+ yield {
795
+ type: "Punctuator",
796
+ value: punctuator
797
+ };
798
+ continue;
799
+ }
800
+ Identifier.lastIndex = lastIndex;
801
+ if (match = Identifier.exec(input)) {
802
+ lastIndex = Identifier.lastIndex;
803
+ nextLastSignificantToken = match[0];
804
+ switch (match[0]) {
805
+ case "for":
806
+ case "if":
807
+ case "while":
808
+ case "with": if (lastSignificantToken !== "." && lastSignificantToken !== "?.") nextLastSignificantToken = "?NonExpressionParenKeyword";
809
+ }
810
+ lastSignificantToken = nextLastSignificantToken;
811
+ postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
812
+ yield {
813
+ type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
814
+ value: match[0]
815
+ };
816
+ continue;
817
+ }
818
+ StringLiteral.lastIndex = lastIndex;
819
+ if (match = StringLiteral.exec(input)) {
820
+ lastIndex = StringLiteral.lastIndex;
821
+ lastSignificantToken = match[0];
822
+ postfixIncDec = true;
823
+ yield {
824
+ type: "StringLiteral",
825
+ value: match[0],
826
+ closed: match[2] !== void 0
827
+ };
828
+ continue;
829
+ }
830
+ NumericLiteral.lastIndex = lastIndex;
831
+ if (match = NumericLiteral.exec(input)) {
832
+ lastIndex = NumericLiteral.lastIndex;
833
+ lastSignificantToken = match[0];
834
+ postfixIncDec = true;
835
+ yield {
836
+ type: "NumericLiteral",
837
+ value: match[0]
838
+ };
839
+ continue;
840
+ }
841
+ Template.lastIndex = lastIndex;
842
+ if (match = Template.exec(input)) {
843
+ lastIndex = Template.lastIndex;
844
+ lastSignificantToken = match[0];
845
+ if (match[1] === "${") {
846
+ lastSignificantToken = "?InterpolationInTemplate";
847
+ stack.push({
848
+ tag: "InterpolationInTemplate",
849
+ nesting: braces.length
850
+ });
851
+ postfixIncDec = false;
852
+ yield {
853
+ type: "TemplateHead",
854
+ value: match[0]
855
+ };
856
+ } else {
857
+ postfixIncDec = true;
858
+ yield {
859
+ type: "NoSubstitutionTemplate",
860
+ value: match[0],
861
+ closed: match[1] === "`"
862
+ };
863
+ }
864
+ continue;
865
+ }
866
+ break;
867
+ case "JSXTag":
868
+ case "JSXTagEnd":
869
+ JSXPunctuator.lastIndex = lastIndex;
870
+ if (match = JSXPunctuator.exec(input)) {
871
+ lastIndex = JSXPunctuator.lastIndex;
872
+ nextLastSignificantToken = match[0];
873
+ switch (match[0]) {
874
+ case "<":
875
+ stack.push({ tag: "JSXTag" });
876
+ break;
877
+ case ">":
878
+ stack.pop();
879
+ if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
880
+ nextLastSignificantToken = "?JSX";
881
+ postfixIncDec = true;
882
+ } else stack.push({ tag: "JSXChildren" });
883
+ break;
884
+ case "{":
885
+ stack.push({
886
+ tag: "InterpolationInJSX",
887
+ nesting: braces.length
888
+ });
889
+ nextLastSignificantToken = "?InterpolationInJSX";
890
+ postfixIncDec = false;
891
+ break;
892
+ case "/": if (lastSignificantToken === "<") {
893
+ stack.pop();
894
+ if (stack[stack.length - 1].tag === "JSXChildren") stack.pop();
895
+ stack.push({ tag: "JSXTagEnd" });
896
+ }
897
+ }
898
+ lastSignificantToken = nextLastSignificantToken;
899
+ yield {
900
+ type: "JSXPunctuator",
901
+ value: match[0]
902
+ };
903
+ continue;
904
+ }
905
+ JSXIdentifier.lastIndex = lastIndex;
906
+ if (match = JSXIdentifier.exec(input)) {
907
+ lastIndex = JSXIdentifier.lastIndex;
908
+ lastSignificantToken = match[0];
909
+ yield {
910
+ type: "JSXIdentifier",
911
+ value: match[0]
912
+ };
913
+ continue;
914
+ }
915
+ JSXString.lastIndex = lastIndex;
916
+ if (match = JSXString.exec(input)) {
917
+ lastIndex = JSXString.lastIndex;
918
+ lastSignificantToken = match[0];
919
+ yield {
920
+ type: "JSXString",
921
+ value: match[0],
922
+ closed: match[2] !== void 0
923
+ };
924
+ continue;
925
+ }
926
+ break;
927
+ case "JSXChildren":
928
+ JSXText.lastIndex = lastIndex;
929
+ if (match = JSXText.exec(input)) {
930
+ lastIndex = JSXText.lastIndex;
931
+ lastSignificantToken = match[0];
932
+ yield {
933
+ type: "JSXText",
934
+ value: match[0]
935
+ };
936
+ continue;
937
+ }
938
+ switch (input[lastIndex]) {
939
+ case "<":
940
+ stack.push({ tag: "JSXTag" });
941
+ lastIndex++;
942
+ lastSignificantToken = "<";
943
+ yield {
944
+ type: "JSXPunctuator",
945
+ value: "<"
946
+ };
947
+ continue;
948
+ case "{":
949
+ stack.push({
950
+ tag: "InterpolationInJSX",
951
+ nesting: braces.length
952
+ });
953
+ lastIndex++;
954
+ lastSignificantToken = "?InterpolationInJSX";
955
+ postfixIncDec = false;
956
+ yield {
957
+ type: "JSXPunctuator",
958
+ value: "{"
959
+ };
960
+ continue;
961
+ }
962
+ }
963
+ WhiteSpace.lastIndex = lastIndex;
964
+ if (match = WhiteSpace.exec(input)) {
965
+ lastIndex = WhiteSpace.lastIndex;
966
+ yield {
967
+ type: "WhiteSpace",
968
+ value: match[0]
969
+ };
970
+ continue;
971
+ }
972
+ LineTerminatorSequence.lastIndex = lastIndex;
973
+ if (match = LineTerminatorSequence.exec(input)) {
974
+ lastIndex = LineTerminatorSequence.lastIndex;
975
+ postfixIncDec = false;
976
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) lastSignificantToken = "?NoLineTerminatorHere";
977
+ yield {
978
+ type: "LineTerminatorSequence",
979
+ value: match[0]
980
+ };
981
+ continue;
982
+ }
983
+ MultiLineComment.lastIndex = lastIndex;
984
+ if (match = MultiLineComment.exec(input)) {
985
+ lastIndex = MultiLineComment.lastIndex;
986
+ if (Newline.test(match[0])) {
987
+ postfixIncDec = false;
988
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) lastSignificantToken = "?NoLineTerminatorHere";
989
+ }
990
+ yield {
991
+ type: "MultiLineComment",
992
+ value: match[0],
993
+ closed: match[1] !== void 0
994
+ };
995
+ continue;
996
+ }
997
+ SingleLineComment.lastIndex = lastIndex;
998
+ if (match = SingleLineComment.exec(input)) {
999
+ lastIndex = SingleLineComment.lastIndex;
1000
+ postfixIncDec = false;
1001
+ yield {
1002
+ type: "SingleLineComment",
1003
+ value: match[0]
1004
+ };
1005
+ continue;
1006
+ }
1007
+ firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
1008
+ lastIndex += firstCodePoint.length;
1009
+ lastSignificantToken = firstCodePoint;
1010
+ postfixIncDec = false;
1011
+ yield {
1012
+ type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
1013
+ value: firstCodePoint
1014
+ };
1015
+ }
1016
+ };
1017
+ return jsTokens_1;
1018
+ }
1019
+ requireJsTokens();
1020
+ var reservedWords = {
1021
+ keyword: [
1022
+ "break",
1023
+ "case",
1024
+ "catch",
1025
+ "continue",
1026
+ "debugger",
1027
+ "default",
1028
+ "do",
1029
+ "else",
1030
+ "finally",
1031
+ "for",
1032
+ "function",
1033
+ "if",
1034
+ "return",
1035
+ "switch",
1036
+ "throw",
1037
+ "try",
1038
+ "var",
1039
+ "const",
1040
+ "while",
1041
+ "with",
1042
+ "new",
1043
+ "this",
1044
+ "super",
1045
+ "class",
1046
+ "extends",
1047
+ "export",
1048
+ "import",
1049
+ "null",
1050
+ "true",
1051
+ "false",
1052
+ "in",
1053
+ "instanceof",
1054
+ "typeof",
1055
+ "void",
1056
+ "delete"
1057
+ ],
1058
+ strict: [
1059
+ "implements",
1060
+ "interface",
1061
+ "let",
1062
+ "package",
1063
+ "private",
1064
+ "protected",
1065
+ "public",
1066
+ "static",
1067
+ "yield"
1068
+ ]
1069
+ };
1070
+ new Set(reservedWords.keyword);
1071
+ new Set(reservedWords.strict);
1072
+ var h = Object.entries({
1073
+ reset: [0, 0],
1074
+ bold: [
1075
+ 1,
1076
+ 22,
1077
+ "\x1B[22m\x1B[1m"
1078
+ ],
1079
+ dim: [
1080
+ 2,
1081
+ 22,
1082
+ "\x1B[22m\x1B[2m"
1083
+ ],
1084
+ italic: [3, 23],
1085
+ underline: [4, 24],
1086
+ inverse: [7, 27],
1087
+ hidden: [8, 28],
1088
+ strikethrough: [9, 29],
1089
+ black: [30, 39],
1090
+ red: [31, 39],
1091
+ green: [32, 39],
1092
+ yellow: [33, 39],
1093
+ blue: [34, 39],
1094
+ magenta: [35, 39],
1095
+ cyan: [36, 39],
1096
+ white: [37, 39],
1097
+ gray: [90, 39],
1098
+ bgBlack: [40, 49],
1099
+ bgRed: [41, 49],
1100
+ bgGreen: [42, 49],
1101
+ bgYellow: [43, 49],
1102
+ bgBlue: [44, 49],
1103
+ bgMagenta: [45, 49],
1104
+ bgCyan: [46, 49],
1105
+ bgWhite: [47, 49],
1106
+ blackBright: [90, 39],
1107
+ redBright: [91, 39],
1108
+ greenBright: [92, 39],
1109
+ yellowBright: [93, 39],
1110
+ blueBright: [94, 39],
1111
+ magentaBright: [95, 39],
1112
+ cyanBright: [96, 39],
1113
+ whiteBright: [97, 39],
1114
+ bgBlackBright: [100, 49],
1115
+ bgRedBright: [101, 49],
1116
+ bgGreenBright: [102, 49],
1117
+ bgYellowBright: [103, 49],
1118
+ bgBlueBright: [104, 49],
1119
+ bgMagentaBright: [105, 49],
1120
+ bgCyanBright: [106, 49],
1121
+ bgWhiteBright: [107, 49]
1122
+ });
1123
+ function a(n) {
1124
+ return String(n);
1125
+ }
1126
+ a.open = "";
1127
+ a.close = "";
1128
+ function C(n = false) {
1129
+ let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
1130
+ return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
1131
+ }
1132
+ function p(n = false) {
1133
+ let e = C(n), i = (r, t, c, o) => {
1134
+ let l = "", s = 0;
1135
+ do
1136
+ l += r.substring(s, o) + c, s = o + t.length, o = r.indexOf(t, s);
1137
+ while (~o);
1138
+ return l + r.substring(s);
1139
+ }, g = (r, t, c = r) => {
1140
+ let o = (l) => {
1141
+ let s = String(l), b = s.indexOf(t, r.length);
1142
+ return ~b ? r + i(s, t, c, b) + t : r + s + t;
1143
+ };
1144
+ return o.open = r, o.close = t, o;
1145
+ }, u = { isColorSupported: e }, d = (r) => `\x1B[${r}m`;
1146
+ for (let [r, t] of h) u[r] = e ? g(d(t[0]), d(t[1]), t[2]) : a;
1147
+ return u;
1148
+ }
1149
+ p();
1150
+ const lineSplitRE = /\r?\n/;
1151
+ function positionToOffset(source, lineNumber, columnNumber) {
1152
+ const lines = source.split(lineSplitRE);
1153
+ const nl = /\r\n/.test(source) ? 2 : 1;
1154
+ let start = 0;
1155
+ if (lineNumber > lines.length) return source.length;
1156
+ for (let i = 0; i < lineNumber - 1; i++) start += lines[i].length + nl;
1157
+ return start + columnNumber;
1158
+ }
1159
+ function offsetToLineNumber(source, offset) {
1160
+ if (offset > source.length) throw new Error(`offset is longer than source length! offset ${offset} > length ${source.length}`);
1161
+ const lines = source.split(lineSplitRE);
1162
+ const nl = /\r\n/.test(source) ? 2 : 1;
1163
+ let counted = 0;
1164
+ let line = 0;
1165
+ for (; line < lines.length; line++) {
1166
+ const lineLength = lines[line].length + nl;
1167
+ if (counted + lineLength >= offset) break;
1168
+ counted += lineLength;
1169
+ }
1170
+ return line + 1;
1171
+ }
1172
+ async function saveInlineSnapshots(environment, snapshots) {
1173
+ const MagicString = (await import("../../../../../magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs")).default;
1174
+ const files = new Set(snapshots.map((i) => i.file));
1175
+ await Promise.all(Array.from(files).map(async (file) => {
1176
+ const snaps = snapshots.filter((i) => i.file === file);
1177
+ const code = await environment.readSnapshotFile(file);
1178
+ const s = new MagicString(code);
1179
+ for (const snap of snaps) replaceInlineSnap(code, s, positionToOffset(code, snap.line, snap.column), snap.snapshot);
1180
+ const transformed = s.toString();
1181
+ if (transformed !== code) await environment.saveSnapshotFile(file, transformed);
1182
+ }));
1183
+ }
1184
+ const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*\{/;
1185
+ function replaceObjectSnap(code, s, index, newSnap) {
1186
+ let _code = code.slice(index);
1187
+ const startMatch = startObjectRegex.exec(_code);
1188
+ if (!startMatch) return false;
1189
+ _code = _code.slice(startMatch.index);
1190
+ let callEnd = getCallLastIndex(_code);
1191
+ if (callEnd === null) return false;
1192
+ callEnd += index + startMatch.index;
1193
+ const shapeEnd = getObjectShapeEndIndex(code, index + startMatch.index + startMatch[0].length);
1194
+ const snap = `, ${prepareSnapString(newSnap, code, index)}`;
1195
+ if (shapeEnd === callEnd) s.appendLeft(callEnd, snap);
1196
+ else s.overwrite(shapeEnd, callEnd, snap);
1197
+ return true;
1198
+ }
1199
+ function getObjectShapeEndIndex(code, index) {
1200
+ let startBraces = 1;
1201
+ let endBraces = 0;
1202
+ while (startBraces !== endBraces && index < code.length) {
1203
+ const s = code[index++];
1204
+ if (s === "{") startBraces++;
1205
+ else if (s === "}") endBraces++;
1206
+ }
1207
+ return index;
1208
+ }
1209
+ function prepareSnapString(snap, source, index) {
1210
+ const lineNumber = offsetToLineNumber(source, index);
1211
+ const indent = source.split(lineSplitRE)[lineNumber - 1].match(/^\s*/)[0] || "";
1212
+ const indentNext = indent.includes(" ") ? `${indent}\t` : `${indent} `;
1213
+ const lines = snap.trim().replace(/\\/g, "\\\\").split(/\n/g);
1214
+ const isOneline = lines.length <= 1;
1215
+ const quote = "`";
1216
+ if (isOneline) return `${quote}${lines.join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}${quote}`;
1217
+ return `${quote}\n${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}\n${indent}${quote}`;
1218
+ }
1219
+ const toMatchInlineName = "toMatchInlineSnapshot";
1220
+ const toThrowErrorMatchingInlineName = "toThrowErrorMatchingInlineSnapshot";
1221
+ function getCodeStartingAtIndex(code, index) {
1222
+ const indexInline = index - 21;
1223
+ if (code.slice(indexInline, index) === toMatchInlineName) return {
1224
+ code: code.slice(indexInline),
1225
+ index: indexInline
1226
+ };
1227
+ const indexThrowInline = index - 34;
1228
+ if (code.slice(index - indexThrowInline, index) === toThrowErrorMatchingInlineName) return {
1229
+ code: code.slice(index - indexThrowInline),
1230
+ index: index - indexThrowInline
1231
+ };
1232
+ return {
1233
+ code: code.slice(index),
1234
+ index
1235
+ };
1236
+ }
1237
+ const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*[\w$]*(['"`)])/;
1238
+ function replaceInlineSnap(code, s, currentIndex, newSnap) {
1239
+ const { code: codeStartingAtIndex, index } = getCodeStartingAtIndex(code, currentIndex);
1240
+ const startMatch = startRegex.exec(codeStartingAtIndex);
1241
+ const firstKeywordMatch = /toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/.exec(codeStartingAtIndex);
1242
+ if (!startMatch || startMatch.index !== (firstKeywordMatch === null || firstKeywordMatch === void 0 ? void 0 : firstKeywordMatch.index)) return replaceObjectSnap(code, s, index, newSnap);
1243
+ const quote = startMatch[1];
1244
+ const startIndex = index + startMatch.index + startMatch[0].length;
1245
+ const snapString = prepareSnapString(newSnap, code, index);
1246
+ if (quote === ")") {
1247
+ s.appendRight(startIndex - 1, snapString);
1248
+ return true;
1249
+ }
1250
+ const endMatch = new RegExp(`(?:^|[^\\\\])${quote}`).exec(code.slice(startIndex));
1251
+ if (!endMatch) return false;
1252
+ const endIndex = startIndex + endMatch.index + endMatch[0].length;
1253
+ s.overwrite(startIndex - 1, endIndex, snapString);
1254
+ return true;
1255
+ }
1256
+ const INDENTATION_REGEX = /^([^\S\n]*)\S/m;
1257
+ function stripSnapshotIndentation(inlineSnapshot) {
1258
+ const match = inlineSnapshot.match(INDENTATION_REGEX);
1259
+ if (!match || !match[1]) return inlineSnapshot;
1260
+ const indentation = match[1];
1261
+ const lines = inlineSnapshot.split(/\n/g);
1262
+ if (lines.length <= 2) return inlineSnapshot;
1263
+ if (lines[0].trim() !== "" || lines[lines.length - 1].trim() !== "") return inlineSnapshot;
1264
+ for (let i = 1; i < lines.length - 1; i++) if (lines[i] !== "") {
1265
+ if (lines[i].indexOf(indentation) !== 0) return inlineSnapshot;
1266
+ lines[i] = lines[i].substring(indentation.length);
1267
+ }
1268
+ lines[lines.length - 1] = "";
1269
+ inlineSnapshot = lines.join("\n");
1270
+ return inlineSnapshot;
1271
+ }
1272
+ async function saveRawSnapshots(environment, snapshots) {
1273
+ await Promise.all(snapshots.map(async (snap) => {
1274
+ if (!snap.readonly) await environment.saveSnapshotFile(snap.file, snap.snapshot);
1275
+ }));
1276
+ }
1277
+ var naturalCompare$1 = { exports: {} };
1278
+ var hasRequiredNaturalCompare;
1279
+ function requireNaturalCompare() {
1280
+ if (hasRequiredNaturalCompare) return naturalCompare$1.exports;
1281
+ hasRequiredNaturalCompare = 1;
1282
+ /*
1283
+ * @version 1.4.0
1284
+ * @date 2015-10-26
1285
+ * @stability 3 - Stable
1286
+ * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
1287
+ * @license MIT License
1288
+ */
1289
+ var naturalCompare = function(a, b) {
1290
+ var i, codeA, codeB = 1, posA = 0, posB = 0, alphabet = String.alphabet;
1291
+ function getCode(str, pos, code) {
1292
+ if (code) {
1293
+ for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
1294
+ return +str.slice(pos - 1, i);
1295
+ }
1296
+ code = alphabet && alphabet.indexOf(str.charAt(pos));
1297
+ return code > -1 ? code + 76 : (code = str.charCodeAt(pos) || 0, code < 45 || code > 127) ? code : code < 46 ? 65 : code < 48 ? code - 1 : code < 58 ? code + 18 : code < 65 ? code - 11 : code < 91 ? code + 11 : code < 97 ? code - 37 : code < 123 ? code + 5 : code - 63;
1298
+ }
1299
+ if ((a += "") != (b += "")) for (; codeB;) {
1300
+ codeA = getCode(a, posA++);
1301
+ codeB = getCode(b, posB++);
1302
+ if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
1303
+ codeA = getCode(a, posA, posA);
1304
+ codeB = getCode(b, posB, posA = i);
1305
+ posB = i;
1306
+ }
1307
+ if (codeA != codeB) return codeA < codeB ? -1 : 1;
1308
+ }
1309
+ return 0;
1310
+ };
1311
+ try {
1312
+ naturalCompare$1.exports = naturalCompare;
1313
+ } catch (e) {
1314
+ String.naturalCompare = naturalCompare;
1315
+ }
1316
+ return naturalCompare$1.exports;
1317
+ }
1318
+ var naturalCompare = /* @__PURE__ */ getDefaultExportFromCjs(requireNaturalCompare());
1319
+ const serialize$1 = (val, config, indentation, depth, refs, printer) => {
1320
+ const name = val.getMockName();
1321
+ const nameString = name === "vi.fn()" ? "" : ` ${name}`;
1322
+ let callsString = "";
1323
+ if (val.mock.calls.length !== 0) {
1324
+ const indentationNext = indentation + config.indent;
1325
+ callsString = ` {${config.spacingOuter}${indentationNext}"calls": ${printer(val.mock.calls, config, indentationNext, depth, refs)}${config.min ? ", " : ","}${config.spacingOuter}${indentationNext}"results": ${printer(val.mock.results, config, indentationNext, depth, refs)}${config.min ? "" : ","}${config.spacingOuter}${indentation}}`;
1326
+ }
1327
+ return `[MockFunction${nameString}]${callsString}`;
1328
+ };
1329
+ const test = (val) => val && !!val._isMockFunction;
1330
+ const plugin = {
1331
+ serialize: serialize$1,
1332
+ test
1333
+ };
1334
+ const { DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent, AsymmetricMatcher } = plugins;
1335
+ let PLUGINS = [
1336
+ ReactTestComponent,
1337
+ ReactElement,
1338
+ DOMElement,
1339
+ DOMCollection,
1340
+ Immutable,
1341
+ AsymmetricMatcher,
1342
+ plugin
1343
+ ];
1344
+ function addSerializer(plugin) {
1345
+ PLUGINS = [plugin].concat(PLUGINS);
1346
+ }
1347
+ function getSerializers() {
1348
+ return PLUGINS;
1349
+ }
1350
+ function testNameToKey(testName, count) {
1351
+ return `${testName} ${count}`;
1352
+ }
1353
+ function keyToTestName(key) {
1354
+ if (!/ \d+$/.test(key)) throw new Error("Snapshot keys must end with a number.");
1355
+ return key.replace(/ \d+$/, "");
1356
+ }
1357
+ function getSnapshotData(content, options) {
1358
+ const update = options.updateSnapshot;
1359
+ const data = Object.create(null);
1360
+ let snapshotContents = "";
1361
+ let dirty = false;
1362
+ if (content != null) try {
1363
+ snapshotContents = content;
1364
+ new Function("exports", snapshotContents)(data);
1365
+ } catch {}
1366
+ if ((update === "all" || update === "new") && snapshotContents) dirty = true;
1367
+ return {
1368
+ data,
1369
+ dirty
1370
+ };
1371
+ }
1372
+ function addExtraLineBreaks(string) {
1373
+ return string.includes("\n") ? `\n${string}\n` : string;
1374
+ }
1375
+ function removeExtraLineBreaks(string) {
1376
+ return string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
1377
+ }
1378
+ const escapeRegex = true;
1379
+ const printFunctionName = false;
1380
+ function serialize(val, indent = 2, formatOverrides = {}) {
1381
+ return normalizeNewlines(format(val, {
1382
+ escapeRegex,
1383
+ indent,
1384
+ plugins: getSerializers(),
1385
+ printFunctionName,
1386
+ ...formatOverrides
1387
+ }));
1388
+ }
1389
+ function escapeBacktickString(str) {
1390
+ return str.replace(/`|\\|\$\{/g, "\\$&");
1391
+ }
1392
+ function printBacktickString(str) {
1393
+ return `\`${escapeBacktickString(str)}\``;
1394
+ }
1395
+ function normalizeNewlines(string) {
1396
+ return string.replace(/\r\n|\r/g, "\n");
1397
+ }
1398
+ async function saveSnapshotFile(environment, snapshotData, snapshotPath) {
1399
+ const snapshots = Object.keys(snapshotData).sort(naturalCompare).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
1400
+ const content = `${environment.getHeader()}\n\n${snapshots.join("\n\n")}\n`;
1401
+ const oldContent = await environment.readSnapshotFile(snapshotPath);
1402
+ if (oldContent != null && oldContent === content) return;
1403
+ await environment.saveSnapshotFile(snapshotPath, content);
1404
+ }
1405
+ function deepMergeArray(target = [], source = []) {
1406
+ const mergedOutput = Array.from(target);
1407
+ source.forEach((sourceElement, index) => {
1408
+ const targetElement = mergedOutput[index];
1409
+ if (Array.isArray(target[index])) mergedOutput[index] = deepMergeArray(target[index], sourceElement);
1410
+ else if (isObject(targetElement)) mergedOutput[index] = deepMergeSnapshot(target[index], sourceElement);
1411
+ else mergedOutput[index] = sourceElement;
1412
+ });
1413
+ return mergedOutput;
1414
+ }
1415
+ /**
1416
+ * Deep merge, but considers asymmetric matchers. Unlike base util's deep merge,
1417
+ * will merge any object-like instance.
1418
+ * Compatible with Jest's snapshot matcher. Should not be used outside of snapshot.
1419
+ *
1420
+ * @example
1421
+ * ```ts
1422
+ * toMatchSnapshot({
1423
+ * name: expect.stringContaining('text')
1424
+ * })
1425
+ * ```
1426
+ */
1427
+ function deepMergeSnapshot(target, source) {
1428
+ if (isObject(target) && isObject(source)) {
1429
+ const mergedOutput = { ...target };
1430
+ Object.keys(source).forEach((key) => {
1431
+ if (isObject(source[key]) && !source[key].$$typeof) if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] });
1432
+ else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
1433
+ else if (Array.isArray(source[key])) mergedOutput[key] = deepMergeArray(target[key], source[key]);
1434
+ else Object.assign(mergedOutput, { [key]: source[key] });
1435
+ });
1436
+ return mergedOutput;
1437
+ } else if (Array.isArray(target) && Array.isArray(source)) return deepMergeArray(target, source);
1438
+ return target;
1439
+ }
1440
+ var DefaultMap = class extends Map {
1441
+ constructor(defaultFn, entries) {
1442
+ super(entries);
1443
+ this.defaultFn = defaultFn;
1444
+ }
1445
+ get(key) {
1446
+ if (!this.has(key)) this.set(key, this.defaultFn(key));
1447
+ return super.get(key);
1448
+ }
1449
+ };
1450
+ var CounterMap = class extends DefaultMap {
1451
+ constructor() {
1452
+ super(() => 0);
1453
+ }
1454
+ _total;
1455
+ valueOf() {
1456
+ return this._total = this.total();
1457
+ }
1458
+ increment(key) {
1459
+ if (typeof this._total !== "undefined") this._total++;
1460
+ this.set(key, this.get(key) + 1);
1461
+ }
1462
+ total() {
1463
+ if (typeof this._total !== "undefined") return this._total;
1464
+ let total = 0;
1465
+ for (const x of this.values()) total += x;
1466
+ return total;
1467
+ }
1468
+ };
1469
+ function isSameStackPosition(x, y) {
1470
+ return x.file === y.file && x.column === y.column && x.line === y.line;
1471
+ }
1472
+ var SnapshotState = class SnapshotState {
1473
+ _counters = new CounterMap();
1474
+ _dirty;
1475
+ _updateSnapshot;
1476
+ _snapshotData;
1477
+ _initialData;
1478
+ _inlineSnapshots;
1479
+ _inlineSnapshotStacks;
1480
+ _testIdToKeys = new DefaultMap(() => []);
1481
+ _rawSnapshots;
1482
+ _uncheckedKeys;
1483
+ _snapshotFormat;
1484
+ _environment;
1485
+ _fileExists;
1486
+ expand;
1487
+ _added = new CounterMap();
1488
+ _matched = new CounterMap();
1489
+ _unmatched = new CounterMap();
1490
+ _updated = new CounterMap();
1491
+ get added() {
1492
+ return this._added;
1493
+ }
1494
+ set added(value) {
1495
+ this._added._total = value;
1496
+ }
1497
+ get matched() {
1498
+ return this._matched;
1499
+ }
1500
+ set matched(value) {
1501
+ this._matched._total = value;
1502
+ }
1503
+ get unmatched() {
1504
+ return this._unmatched;
1505
+ }
1506
+ set unmatched(value) {
1507
+ this._unmatched._total = value;
1508
+ }
1509
+ get updated() {
1510
+ return this._updated;
1511
+ }
1512
+ set updated(value) {
1513
+ this._updated._total = value;
1514
+ }
1515
+ constructor(testFilePath, snapshotPath, snapshotContent, options) {
1516
+ this.testFilePath = testFilePath;
1517
+ this.snapshotPath = snapshotPath;
1518
+ const { data, dirty } = getSnapshotData(snapshotContent, options);
1519
+ this._fileExists = snapshotContent != null;
1520
+ this._initialData = { ...data };
1521
+ this._snapshotData = { ...data };
1522
+ this._dirty = dirty;
1523
+ this._inlineSnapshots = [];
1524
+ this._inlineSnapshotStacks = [];
1525
+ this._rawSnapshots = [];
1526
+ this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
1527
+ this.expand = options.expand || false;
1528
+ this._updateSnapshot = options.updateSnapshot;
1529
+ this._snapshotFormat = {
1530
+ printBasicPrototype: false,
1531
+ escapeString: false,
1532
+ ...options.snapshotFormat
1533
+ };
1534
+ this._environment = options.snapshotEnvironment;
1535
+ }
1536
+ static async create(testFilePath, options) {
1537
+ const snapshotPath = await options.snapshotEnvironment.resolvePath(testFilePath);
1538
+ return new SnapshotState(testFilePath, snapshotPath, await options.snapshotEnvironment.readSnapshotFile(snapshotPath), options);
1539
+ }
1540
+ get environment() {
1541
+ return this._environment;
1542
+ }
1543
+ markSnapshotsAsCheckedForTest(testName) {
1544
+ this._uncheckedKeys.forEach((uncheckedKey) => {
1545
+ if (/ \d+$| > /.test(uncheckedKey.slice(testName.length))) this._uncheckedKeys.delete(uncheckedKey);
1546
+ });
1547
+ }
1548
+ clearTest(testId) {
1549
+ this._inlineSnapshots = this._inlineSnapshots.filter((s) => s.testId !== testId);
1550
+ this._inlineSnapshotStacks = this._inlineSnapshotStacks.filter((s) => s.testId !== testId);
1551
+ for (const key of this._testIdToKeys.get(testId)) {
1552
+ const name = keyToTestName(key);
1553
+ const count = this._counters.get(name);
1554
+ if (count > 0) {
1555
+ if (key in this._snapshotData || key in this._initialData) this._snapshotData[key] = this._initialData[key];
1556
+ this._counters.set(name, count - 1);
1557
+ }
1558
+ }
1559
+ this._testIdToKeys.delete(testId);
1560
+ this.added.delete(testId);
1561
+ this.updated.delete(testId);
1562
+ this.matched.delete(testId);
1563
+ this.unmatched.delete(testId);
1564
+ }
1565
+ _inferInlineSnapshotStack(stacks) {
1566
+ const promiseIndex = stacks.findIndex((i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/));
1567
+ if (promiseIndex !== -1) return stacks[promiseIndex + 3];
1568
+ const stackIndex = stacks.findIndex((i) => i.method.includes("__INLINE_SNAPSHOT__"));
1569
+ return stackIndex !== -1 ? stacks[stackIndex + 2] : null;
1570
+ }
1571
+ _addSnapshot(key, receivedSerialized, options) {
1572
+ this._dirty = true;
1573
+ if (options.stack) this._inlineSnapshots.push({
1574
+ snapshot: receivedSerialized,
1575
+ testId: options.testId,
1576
+ ...options.stack
1577
+ });
1578
+ else if (options.rawSnapshot) this._rawSnapshots.push({
1579
+ ...options.rawSnapshot,
1580
+ snapshot: receivedSerialized
1581
+ });
1582
+ else this._snapshotData[key] = receivedSerialized;
1583
+ }
1584
+ async save() {
1585
+ const hasExternalSnapshots = Object.keys(this._snapshotData).length;
1586
+ const hasInlineSnapshots = this._inlineSnapshots.length;
1587
+ const hasRawSnapshots = this._rawSnapshots.length;
1588
+ const isEmpty = !hasExternalSnapshots && !hasInlineSnapshots && !hasRawSnapshots;
1589
+ const status = {
1590
+ deleted: false,
1591
+ saved: false
1592
+ };
1593
+ if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
1594
+ if (hasExternalSnapshots) {
1595
+ await saveSnapshotFile(this._environment, this._snapshotData, this.snapshotPath);
1596
+ this._fileExists = true;
1597
+ }
1598
+ if (hasInlineSnapshots) await saveInlineSnapshots(this._environment, this._inlineSnapshots);
1599
+ if (hasRawSnapshots) await saveRawSnapshots(this._environment, this._rawSnapshots);
1600
+ status.saved = true;
1601
+ } else if (!hasExternalSnapshots && this._fileExists) {
1602
+ if (this._updateSnapshot === "all") {
1603
+ await this._environment.removeSnapshotFile(this.snapshotPath);
1604
+ this._fileExists = false;
1605
+ }
1606
+ status.deleted = true;
1607
+ }
1608
+ return status;
1609
+ }
1610
+ getUncheckedCount() {
1611
+ return this._uncheckedKeys.size || 0;
1612
+ }
1613
+ getUncheckedKeys() {
1614
+ return Array.from(this._uncheckedKeys);
1615
+ }
1616
+ removeUncheckedKeys() {
1617
+ if (this._updateSnapshot === "all" && this._uncheckedKeys.size) {
1618
+ this._dirty = true;
1619
+ this._uncheckedKeys.forEach((key) => delete this._snapshotData[key]);
1620
+ this._uncheckedKeys.clear();
1621
+ }
1622
+ }
1623
+ match({ testId, testName, received, key, inlineSnapshot, isInline, error, rawSnapshot }) {
1624
+ this._counters.increment(testName);
1625
+ const count = this._counters.get(testName);
1626
+ if (!key) key = testNameToKey(testName, count);
1627
+ this._testIdToKeys.get(testId).push(key);
1628
+ if (!(isInline && this._snapshotData[key] !== void 0)) this._uncheckedKeys.delete(key);
1629
+ let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, void 0, this._snapshotFormat);
1630
+ if (!rawSnapshot) receivedSerialized = addExtraLineBreaks(receivedSerialized);
1631
+ if (rawSnapshot) {
1632
+ if (rawSnapshot.content && rawSnapshot.content.match(/\r\n/) && !receivedSerialized.match(/\r\n/)) rawSnapshot.content = normalizeNewlines(rawSnapshot.content);
1633
+ }
1634
+ const expected = isInline ? inlineSnapshot : rawSnapshot ? rawSnapshot.content : this._snapshotData[key];
1635
+ const expectedTrimmed = rawSnapshot ? expected : expected === null || expected === void 0 ? void 0 : expected.trim();
1636
+ const pass = expectedTrimmed === (rawSnapshot ? receivedSerialized : receivedSerialized.trim());
1637
+ const hasSnapshot = expected !== void 0;
1638
+ const snapshotIsPersisted = isInline || this._fileExists || rawSnapshot && rawSnapshot.content != null;
1639
+ if (pass && !isInline && !rawSnapshot) this._snapshotData[key] = receivedSerialized;
1640
+ let stack;
1641
+ if (isInline) {
1642
+ var _this$environment$pro, _this$environment;
1643
+ const stacks = parseErrorStacktrace(error || /* @__PURE__ */ new Error("snapshot"), { ignoreStackEntries: [] });
1644
+ const _stack = this._inferInlineSnapshotStack(stacks);
1645
+ if (!_stack) throw new Error(`@vitest/snapshot: Couldn't infer stack frame for inline snapshot.\n${JSON.stringify(stacks)}`);
1646
+ stack = ((_this$environment$pro = (_this$environment = this.environment).processStackTrace) === null || _this$environment$pro === void 0 ? void 0 : _this$environment$pro.call(_this$environment, _stack)) || _stack;
1647
+ stack.column--;
1648
+ const snapshotsWithSameStack = this._inlineSnapshotStacks.filter((s) => isSameStackPosition(s, stack));
1649
+ if (snapshotsWithSameStack.length > 0) {
1650
+ this._inlineSnapshots = this._inlineSnapshots.filter((s) => !isSameStackPosition(s, stack));
1651
+ const differentSnapshot = snapshotsWithSameStack.find((s) => s.snapshot !== receivedSerialized);
1652
+ if (differentSnapshot) throw Object.assign(/* @__PURE__ */ new Error("toMatchInlineSnapshot with different snapshots cannot be called at the same location"), {
1653
+ actual: receivedSerialized,
1654
+ expected: differentSnapshot.snapshot
1655
+ });
1656
+ }
1657
+ this._inlineSnapshotStacks.push({
1658
+ ...stack,
1659
+ testId,
1660
+ snapshot: receivedSerialized
1661
+ });
1662
+ }
1663
+ if (hasSnapshot && this._updateSnapshot === "all" || (!hasSnapshot || !snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
1664
+ if (this._updateSnapshot === "all") if (!pass) {
1665
+ if (hasSnapshot) this.updated.increment(testId);
1666
+ else this.added.increment(testId);
1667
+ this._addSnapshot(key, receivedSerialized, {
1668
+ stack,
1669
+ testId,
1670
+ rawSnapshot
1671
+ });
1672
+ } else this.matched.increment(testId);
1673
+ else {
1674
+ this._addSnapshot(key, receivedSerialized, {
1675
+ stack,
1676
+ testId,
1677
+ rawSnapshot
1678
+ });
1679
+ this.added.increment(testId);
1680
+ }
1681
+ return {
1682
+ actual: "",
1683
+ count,
1684
+ expected: "",
1685
+ key,
1686
+ pass: true
1687
+ };
1688
+ } else if (!pass) {
1689
+ this.unmatched.increment(testId);
1690
+ return {
1691
+ actual: rawSnapshot ? receivedSerialized : removeExtraLineBreaks(receivedSerialized),
1692
+ count,
1693
+ expected: expectedTrimmed !== void 0 ? rawSnapshot ? expectedTrimmed : removeExtraLineBreaks(expectedTrimmed) : void 0,
1694
+ key,
1695
+ pass: false
1696
+ };
1697
+ } else {
1698
+ this.matched.increment(testId);
1699
+ return {
1700
+ actual: "",
1701
+ count,
1702
+ expected: "",
1703
+ key,
1704
+ pass: true
1705
+ };
1706
+ }
1707
+ }
1708
+ async pack() {
1709
+ const snapshot = {
1710
+ filepath: this.testFilePath,
1711
+ added: 0,
1712
+ fileDeleted: false,
1713
+ matched: 0,
1714
+ unchecked: 0,
1715
+ uncheckedKeys: [],
1716
+ unmatched: 0,
1717
+ updated: 0
1718
+ };
1719
+ const uncheckedCount = this.getUncheckedCount();
1720
+ const uncheckedKeys = this.getUncheckedKeys();
1721
+ if (uncheckedCount) this.removeUncheckedKeys();
1722
+ const status = await this.save();
1723
+ snapshot.fileDeleted = status.deleted;
1724
+ snapshot.added = this.added.total();
1725
+ snapshot.matched = this.matched.total();
1726
+ snapshot.unmatched = this.unmatched.total();
1727
+ snapshot.updated = this.updated.total();
1728
+ snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
1729
+ snapshot.uncheckedKeys = Array.from(uncheckedKeys);
1730
+ return snapshot;
1731
+ }
1732
+ };
1733
+ function createMismatchError(message, expand, actual, expected) {
1734
+ const error = new Error(message);
1735
+ Object.defineProperty(error, "actual", {
1736
+ value: actual,
1737
+ enumerable: true,
1738
+ configurable: true,
1739
+ writable: true
1740
+ });
1741
+ Object.defineProperty(error, "expected", {
1742
+ value: expected,
1743
+ enumerable: true,
1744
+ configurable: true,
1745
+ writable: true
1746
+ });
1747
+ Object.defineProperty(error, "diffOptions", { value: { expand } });
1748
+ return error;
1749
+ }
1750
+ var SnapshotClient = class {
1751
+ snapshotStateMap = /* @__PURE__ */ new Map();
1752
+ constructor(options = {}) {
1753
+ this.options = options;
1754
+ }
1755
+ async setup(filepath, options) {
1756
+ if (this.snapshotStateMap.has(filepath)) return;
1757
+ this.snapshotStateMap.set(filepath, await SnapshotState.create(filepath, options));
1758
+ }
1759
+ async finish(filepath) {
1760
+ const result = await this.getSnapshotState(filepath).pack();
1761
+ this.snapshotStateMap.delete(filepath);
1762
+ return result;
1763
+ }
1764
+ skipTest(filepath, testName) {
1765
+ this.getSnapshotState(filepath).markSnapshotsAsCheckedForTest(testName);
1766
+ }
1767
+ clearTest(filepath, testId) {
1768
+ this.getSnapshotState(filepath).clearTest(testId);
1769
+ }
1770
+ getSnapshotState(filepath) {
1771
+ const state = this.snapshotStateMap.get(filepath);
1772
+ if (!state) throw new Error(`The snapshot state for '${filepath}' is not found. Did you call 'SnapshotClient.setup()'?`);
1773
+ return state;
1774
+ }
1775
+ assert(options) {
1776
+ const { filepath, name, testId = name, message, isInline = false, properties, inlineSnapshot, error, errorMessage, rawSnapshot } = options;
1777
+ let { received } = options;
1778
+ if (!filepath) throw new Error("Snapshot cannot be used outside of test");
1779
+ const snapshotState = this.getSnapshotState(filepath);
1780
+ if (typeof properties === "object") {
1781
+ if (typeof received !== "object" || !received) throw new Error("Received value must be an object when the matcher has properties");
1782
+ try {
1783
+ var _this$options$isEqual, _this$options;
1784
+ if (!(((_this$options$isEqual = (_this$options = this.options).isEqual) === null || _this$options$isEqual === void 0 ? void 0 : _this$options$isEqual.call(_this$options, received, properties)) ?? false)) throw createMismatchError("Snapshot properties mismatched", snapshotState.expand, received, properties);
1785
+ else received = deepMergeSnapshot(received, properties);
1786
+ } catch (err) {
1787
+ err.message = errorMessage || "Snapshot mismatched";
1788
+ throw err;
1789
+ }
1790
+ }
1791
+ const testName = [name, ...message ? [message] : []].join(" > ");
1792
+ const { actual, expected, key, pass } = snapshotState.match({
1793
+ testId,
1794
+ testName,
1795
+ received,
1796
+ isInline,
1797
+ error,
1798
+ inlineSnapshot,
1799
+ rawSnapshot
1800
+ });
1801
+ if (!pass) throw createMismatchError(`Snapshot \`${key || "unknown"}\` mismatched`, snapshotState.expand, rawSnapshot ? actual : actual === null || actual === void 0 ? void 0 : actual.trim(), rawSnapshot ? expected : expected === null || expected === void 0 ? void 0 : expected.trim());
1802
+ }
1803
+ async assertRaw(options) {
1804
+ if (!options.rawSnapshot) throw new Error("Raw snapshot is required");
1805
+ const { filepath, rawSnapshot } = options;
1806
+ if (rawSnapshot.content == null) {
1807
+ if (!filepath) throw new Error("Snapshot cannot be used outside of test");
1808
+ const snapshotState = this.getSnapshotState(filepath);
1809
+ options.filepath || (options.filepath = filepath);
1810
+ rawSnapshot.file = await snapshotState.environment.resolveRawPath(filepath, rawSnapshot.file);
1811
+ rawSnapshot.content = await snapshotState.environment.readSnapshotFile(rawSnapshot.file) ?? void 0;
1812
+ }
1813
+ return this.assert(options);
1814
+ }
1815
+ clear() {
1816
+ this.snapshotStateMap.clear();
1817
+ }
1818
+ };
1819
+
1820
+ //#endregion
1821
+ export { SnapshotClient, addSerializer, stripSnapshotIndentation };