@noma.to/qwik-testing-library 1.0.4 → 1.1.0

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