storybook 9.1.13 → 9.1.14

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 (33) hide show
  1. package/dist/babel/index.cjs +22495 -21246
  2. package/dist/babel/index.d.ts +672 -336
  3. package/dist/babel/index.js +22534 -21285
  4. package/dist/bin/index.cjs +42 -43
  5. package/dist/bin/index.js +42 -43
  6. package/dist/cli/bin/index.cjs +1 -1
  7. package/dist/cli/bin/index.js +1 -1
  8. package/dist/cli/index.cjs +27120 -25868
  9. package/dist/cli/index.js +27267 -26015
  10. package/dist/common/index.cjs +57 -58
  11. package/dist/common/index.d.ts +0 -1
  12. package/dist/common/index.js +103 -104
  13. package/dist/components/index.cjs +4464 -4353
  14. package/dist/components/index.js +3290 -3181
  15. package/dist/core-server/index.cjs +7388 -7318
  16. package/dist/core-server/index.js +7597 -7529
  17. package/dist/core-server/presets/common-preset.cjs +20127 -19935
  18. package/dist/core-server/presets/common-preset.js +20203 -20011
  19. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.cjs +306 -518
  20. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +302 -525
  21. package/dist/csf-tools/index.cjs +150 -144
  22. package/dist/csf-tools/index.js +401 -395
  23. package/dist/manager/globals-runtime.js +16578 -16469
  24. package/dist/manager-api/index.cjs +1 -1
  25. package/dist/manager-api/index.js +1 -1
  26. package/dist/node-logger/index.cjs +71 -71
  27. package/dist/node-logger/index.js +71 -71
  28. package/dist/preview/runtime.js +240 -240
  29. package/dist/telemetry/index.cjs +1 -1
  30. package/dist/telemetry/index.js +1 -1
  31. package/dist/test/index.cjs +267 -267
  32. package/dist/test/index.js +240 -240
  33. package/package.json +1 -1
@@ -4,301 +4,75 @@ import { dirname as ESM_COMPAT_dirname } from 'node:path';
4
4
  const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
5
5
  const __dirname = ESM_COMPAT_dirname(__filename);
6
6
  const require = ESM_COMPAT_Module.createRequire(import.meta.url);
7
- var mt = Object.create;
8
- var it = Object.defineProperty;
9
- var yt = Object.getOwnPropertyDescriptor;
10
- var bt = Object.getOwnPropertyNames;
11
- var wt = Object.getPrototypeOf, _t = Object.prototype.hasOwnProperty;
12
- var d = (c, t) => it(c, "name", { value: t, configurable: !0 });
13
- var vt = (c, t) => () => (t || c((t = { exports: {} }).exports, t), t.exports);
14
- var Ct = (c, t, e, i) => {
15
- if (t && typeof t == "object" || typeof t == "function")
16
- for (let n of bt(t))
17
- !_t.call(c, n) && n !== e && it(c, n, { get: () => t[n], enumerable: !(i = yt(t, n)) || i.enumerable });
18
- return c;
19
- };
20
- var St = (c, t, e) => (e = c != null ? mt(wt(c)) : {}, Ct(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- t || !c || !c.__esModule ? it(e, "default", { value: c, enumerable: !0 }) : e,
26
- c
27
- ));
7
+ var q = Object.defineProperty;
8
+ var u = (l, t) => q(l, "name", { value: t, configurable: !0 });
28
9
 
29
- // ../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
30
- var lt = vt((J, ot) => {
31
- (function(c, t) {
32
- typeof J == "object" && typeof ot < "u" ? t(J) : typeof define == "function" && define.amd ? define(["exports"], t) : (c = typeof globalThis <
33
- "u" ? globalThis : c || self, t(c.sourcemapCodec = {}));
34
- })(J, function(c) {
35
- "use strict";
36
- let i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", n = new Uint8Array(64), o = new Uint8Array(128);
37
- for (let f = 0; f < i.length; f++) {
38
- let a = i.charCodeAt(f);
39
- n[f] = a, o[a] = f;
40
- }
41
- function r(f, a) {
42
- let s = 0, h = 0, g = 0;
43
- do {
44
- let _ = f.next();
45
- g = o[_], s |= (g & 31) << h, h += 5;
46
- } while (g & 32);
47
- let m = s & 1;
48
- return s >>>= 1, m && (s = -2147483648 | -s), a + s;
49
- }
50
- d(r, "decodeInteger");
51
- function l(f, a, s) {
52
- let h = a - s;
53
- h = h < 0 ? -h << 1 | 1 : h << 1;
54
- do {
55
- let g = h & 31;
56
- h >>>= 5, h > 0 && (g |= 32), f.write(n[g]);
57
- } while (h > 0);
58
- return a;
59
- }
60
- d(l, "encodeInteger");
61
- function u(f, a) {
62
- return f.pos >= a ? !1 : f.peek() !== 44;
63
- }
64
- d(u, "hasMoreVlq");
65
- let p = 1024 * 16, R = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
66
- decode(f) {
67
- return Buffer.from(f.buffer, f.byteOffset, f.byteLength).toString();
68
- }
69
- } : {
70
- decode(f) {
71
- let a = "";
72
- for (let s = 0; s < f.length; s++)
73
- a += String.fromCharCode(f[s]);
74
- return a;
75
- }
76
- };
77
- class D {
78
- static {
79
- d(this, "StringWriter");
80
- }
81
- constructor() {
82
- this.pos = 0, this.out = "", this.buffer = new Uint8Array(p);
83
- }
84
- write(a) {
85
- let { buffer: s } = this;
86
- s[this.pos++] = a, this.pos === p && (this.out += R.decode(s), this.pos = 0);
87
- }
88
- flush() {
89
- let { buffer: a, out: s, pos: h } = this;
90
- return h > 0 ? s + R.decode(a.subarray(0, h)) : s;
91
- }
92
- }
93
- class W {
94
- static {
95
- d(this, "StringReader");
96
- }
97
- constructor(a) {
98
- this.pos = 0, this.buffer = a;
99
- }
100
- next() {
101
- return this.buffer.charCodeAt(this.pos++);
102
- }
103
- peek() {
104
- return this.buffer.charCodeAt(this.pos);
105
- }
106
- indexOf(a) {
107
- let { buffer: s, pos: h } = this, g = s.indexOf(a, h);
108
- return g === -1 ? s.length : g;
109
- }
110
- }
111
- let tt = [];
112
- function P(f) {
113
- let { length: a } = f, s = new W(f), h = [], g = [], m = 0;
114
- for (; s.pos < a; s.pos++) {
115
- m = r(s, m);
116
- let _ = r(s, 0);
117
- if (!u(s, a)) {
118
- let k = g.pop();
119
- k[2] = m, k[3] = _;
120
- continue;
121
- }
122
- let b = r(s, 0), w = r(s, 0) & 1 ? [m, _, 0, 0, b, r(s, 0)] : [m, _, 0, 0, b], x = tt;
123
- if (u(s, a)) {
124
- x = [];
125
- do {
126
- let k = r(s, 0);
127
- x.push(k);
128
- } while (u(s, a));
129
- }
130
- w.vars = x, h.push(w), g.push(w);
131
- }
132
- return h;
133
- }
134
- d(P, "decodeOriginalScopes");
135
- function I(f) {
136
- let a = new D();
137
- for (let s = 0; s < f.length; )
138
- s = L(f, s, a, [0]);
139
- return a.flush();
140
- }
141
- d(I, "encodeOriginalScopes");
142
- function L(f, a, s, h) {
143
- let g = f[a], { 0: m, 1: _, 2: b, 3: S, 4: C, vars: w } = g;
144
- a > 0 && s.write(44), h[0] = l(s, m, h[0]), l(s, _, 0), l(s, C, 0);
145
- let x = g.length === 6 ? 1 : 0;
146
- l(s, x, 0), g.length === 6 && l(s, g[5], 0);
147
- for (let k of w)
148
- l(s, k, 0);
149
- for (a++; a < f.length; ) {
150
- let k = f[a], { 0: y, 1: E } = k;
151
- if (y > b || y === b && E >= S)
152
- break;
153
- a = L(f, a, s, h);
154
- }
155
- return s.write(44), h[0] = l(s, b, h[0]), l(s, S, 0), a;
156
- }
157
- d(L, "_encodeOriginalScopes");
158
- function j(f) {
159
- let { length: a } = f, s = new W(f), h = [], g = [], m = 0, _ = 0, b = 0, S = 0, C = 0, w = 0, x = 0, k = 0;
160
- do {
161
- let y = s.indexOf(";"), E = 0;
162
- for (; s.pos < y; s.pos++) {
163
- if (E = r(s, E), !u(s, y)) {
164
- let O = g.pop();
165
- O[2] = m, O[3] = E;
166
- continue;
167
- }
168
- let A = r(s, 0), Y = A & 1, G = A & 2, K = A & 4, rt = null, et = tt, M;
169
- if (Y) {
170
- let O = r(s, _);
171
- b = r(s, _ === O ? b : 0), _ = O, M = [m, E, 0, 0, O, b];
172
- } else
173
- M = [m, E, 0, 0];
174
- if (M.isScope = !!K, G) {
175
- let O = S, U = C;
176
- S = r(s, S);
177
- let z = O === S;
178
- C = r(s, z ? C : 0), w = r(s, z && U === C ? w : 0), rt = [S, C, w];
179
- }
180
- if (M.callsite = rt, u(s, y)) {
181
- et = [];
182
- do {
183
- x = m, k = E;
184
- let O = r(s, 0), U;
185
- if (O < -1) {
186
- U = [[r(s, 0)]];
187
- for (let z = -1; z > O; z--) {
188
- let pt = x;
189
- x = r(s, x), k = r(s, x === pt ? k : 0);
190
- let gt = r(s, 0);
191
- U.push([gt, x, k]);
192
- }
193
- } else
194
- U = [[O]];
195
- et.push(U);
196
- } while (u(s, y));
197
- }
198
- M.bindings = et, h.push(M), g.push(M);
199
- }
200
- m++, s.pos = y + 1;
201
- } while (s.pos < a);
202
- return h;
203
- }
204
- d(j, "decodeGeneratedRanges");
205
- function $(f) {
206
- if (f.length === 0)
207
- return "";
208
- let a = new D();
209
- for (let s = 0; s < f.length; )
210
- s = T(f, s, a, [0, 0, 0, 0, 0, 0, 0]);
211
- return a.flush();
212
- }
213
- d($, "encodeGeneratedRanges");
214
- function T(f, a, s, h) {
215
- let g = f[a], { 0: m, 1: _, 2: b, 3: S, isScope: C, callsite: w, bindings: x } = g;
216
- h[0] < m ? (v(s, h[0], m), h[0] = m, h[1] = 0) : a > 0 && s.write(44), h[1] = l(s, g[1], h[1]);
217
- let k = (g.length === 6 ? 1 : 0) | (w ? 2 : 0) | (C ? 4 : 0);
218
- if (l(s, k, 0), g.length === 6) {
219
- let { 4: y, 5: E } = g;
220
- y !== h[2] && (h[3] = 0), h[2] = l(s, y, h[2]), h[3] = l(s, E, h[3]);
221
- }
222
- if (w) {
223
- let { 0: y, 1: E, 2: A } = g.callsite;
224
- y !== h[4] ? (h[5] = 0, h[6] = 0) : E !== h[5] && (h[6] = 0), h[4] = l(s, y, h[4]), h[5] = l(s, E, h[5]), h[6] = l(s, A, h[6]);
225
- }
226
- if (x)
227
- for (let y of x) {
228
- y.length > 1 && l(s, -y.length, 0);
229
- let E = y[0][0];
230
- l(s, E, 0);
231
- let A = m, Y = _;
232
- for (let G = 1; G < y.length; G++) {
233
- let K = y[G];
234
- A = l(s, K[1], A), Y = l(s, K[2], Y), l(s, K[0], 0);
235
- }
236
- }
237
- for (a++; a < f.length; ) {
238
- let y = f[a], { 0: E, 1: A } = y;
239
- if (E > b || E === b && A >= S)
240
- break;
241
- a = T(f, a, s, h);
242
- }
243
- return h[0] < b ? (v(s, h[0], b), h[0] = b, h[1] = 0) : s.write(44), h[1] = l(s, S, h[1]), a;
244
- }
245
- d(T, "_encodeGeneratedRanges");
246
- function v(f, a, s) {
247
- do
248
- f.write(59);
249
- while (++a < s);
250
- }
251
- d(v, "catchupLine");
252
- function N(f) {
253
- let { length: a } = f, s = new W(f), h = [], g = 0, m = 0, _ = 0, b = 0, S = 0;
254
- do {
255
- let C = s.indexOf(";"), w = [], x = !0, k = 0;
256
- for (g = 0; s.pos < C; ) {
257
- let y;
258
- g = r(s, g), g < k && (x = !1), k = g, u(s, C) ? (m = r(s, m), _ = r(s, _), b = r(s, b), u(s, C) ? (S = r(s, S), y = [g, m, _, b, S]) :
259
- y = [g, m, _, b]) : y = [g], w.push(y), s.pos++;
260
- }
261
- x || B(w), h.push(w), s.pos = C + 1;
262
- } while (s.pos <= a);
263
- return h;
264
- }
265
- d(N, "decode");
266
- function B(f) {
267
- f.sort(F);
268
- }
269
- d(B, "sort");
270
- function F(f, a) {
271
- return f[0] - a[0];
272
- }
273
- d(F, "sortComparator");
274
- function dt(f) {
275
- let a = new D(), s = 0, h = 0, g = 0, m = 0;
276
- for (let _ = 0; _ < f.length; _++) {
277
- let b = f[_];
278
- if (_ > 0 && a.write(59), b.length === 0)
279
- continue;
280
- let S = 0;
281
- for (let C = 0; C < b.length; C++) {
282
- let w = b[C];
283
- C > 0 && a.write(44), S = l(a, w[0], S), w.length !== 1 && (s = l(a, w[1], s), h = l(a, w[2], h), g = l(a, w[3], g), w.length !== 4 &&
284
- (m = l(a, w[4], m)));
285
- }
286
- }
287
- return a.flush();
288
- }
289
- d(dt, "encode"), c.decode = N, c.decodeGeneratedRanges = j, c.decodeOriginalScopes = P, c.encode = dt, c.encodeGeneratedRanges = $, c.encodeOriginalScopes =
290
- I, Object.defineProperty(c, "__esModule", { value: !0 });
291
- });
292
- });
10
+ // ../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
11
+ var W = 44, G = 59, R = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", j = new Uint8Array(64), K = new Uint8Array(128);
12
+ for (let l = 0; l < R.length; l++) {
13
+ let t = R.charCodeAt(l);
14
+ j[l] = t, K[t] = l;
15
+ }
16
+ function w(l, t, e) {
17
+ let i = t - e;
18
+ i = i < 0 ? -i << 1 | 1 : i << 1;
19
+ do {
20
+ let n = i & 31;
21
+ i >>>= 5, i > 0 && (n |= 32), l.write(j[n]);
22
+ } while (i > 0);
23
+ return t;
24
+ }
25
+ u(w, "encodeInteger");
26
+ var A = 1024 * 16, D = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
27
+ decode(l) {
28
+ return Buffer.from(l.buffer, l.byteOffset, l.byteLength).toString();
29
+ }
30
+ } : {
31
+ decode(l) {
32
+ let t = "";
33
+ for (let e = 0; e < l.length; e++)
34
+ t += String.fromCharCode(l[e]);
35
+ return t;
36
+ }
37
+ }, z = class {
38
+ static {
39
+ u(this, "StringWriter");
40
+ }
41
+ constructor() {
42
+ this.pos = 0, this.out = "", this.buffer = new Uint8Array(A);
43
+ }
44
+ write(l) {
45
+ let { buffer: t } = this;
46
+ t[this.pos++] = l, this.pos === A && (this.out += D.decode(t), this.pos = 0);
47
+ }
48
+ flush() {
49
+ let { buffer: l, out: t, pos: e } = this;
50
+ return e > 0 ? t + D.decode(l.subarray(0, e)) : t;
51
+ }
52
+ };
53
+ function M(l) {
54
+ let t = new z(), e = 0, i = 0, n = 0, r = 0;
55
+ for (let s = 0; s < l.length; s++) {
56
+ let o = l[s];
57
+ if (s > 0 && t.write(G), o.length === 0) continue;
58
+ let a = 0;
59
+ for (let h = 0; h < o.length; h++) {
60
+ let f = o[h];
61
+ h > 0 && t.write(W), a = w(t, f[0], a), f.length !== 1 && (e = w(t, f[1], e), i = w(t, f[2], i), n = w(t, f[3], n), f.length !== 4 && (r =
62
+ w(t, f[4], r)));
63
+ }
64
+ }
65
+ return t.flush();
66
+ }
67
+ u(M, "encode");
293
68
 
294
69
  // ../node_modules/magic-string/dist/magic-string.es.mjs
295
- var ht = St(lt(), 1);
296
- var Q = class c {
70
+ var E = class l {
297
71
  static {
298
- d(this, "BitSet");
72
+ u(this, "BitSet");
299
73
  }
300
74
  constructor(t) {
301
- this.bits = t instanceof c ? t.bits.slice() : [];
75
+ this.bits = t instanceof l ? t.bits.slice() : [];
302
76
  }
303
77
  add(t) {
304
78
  this.bits[t >> 5] |= 1 << (t & 31);
@@ -306,9 +80,9 @@ var Q = class c {
306
80
  has(t) {
307
81
  return !!(this.bits[t >> 5] & 1 << (t & 31));
308
82
  }
309
- }, X = class c {
83
+ }, I = class l {
310
84
  static {
311
- d(this, "Chunk");
85
+ u(this, "Chunk");
312
86
  }
313
87
  constructor(t, e, i) {
314
88
  this.start = t, this.end = e, this.original = i, this.intro = "", this.outro = "", this.content = i, this.storeName = !1, this.edited = !1,
@@ -321,7 +95,7 @@ var Q = class c {
321
95
  this.intro = this.intro + t;
322
96
  }
323
97
  clone() {
324
- let t = new c(this.start, this.end, this.original);
98
+ let t = new l(this.start, this.end, this.original);
325
99
  return t.intro = this.intro, t.outro = this.outro, t.content = this.content, t.storeName = this.storeName, t.edited = this.edited, t;
326
100
  }
327
101
  contains(t) {
@@ -352,9 +126,9 @@ var Q = class c {
352
126
  split(t) {
353
127
  let e = t - this.start, i = this.original.slice(0, e), n = this.original.slice(e);
354
128
  this.original = i;
355
- let o = new c(t, this.end, n);
356
- return o.outro = this.outro, this.outro = "", this.end = t, this.edited ? (o.edit("", !1), this.content = "") : this.content = i, o.next =
357
- this.next, o.next && (o.next.previous = o), o.previous = this, this.next = o, o;
129
+ let r = new l(t, this.end, n);
130
+ return r.outro = this.outro, this.outro = "", this.end = t, this.edited ? (r.edit("", !1), this.content = "") : this.content = i, r.next =
131
+ this.next, r.next && (r.next.previous = r), r.previous = this, this.next = r, r;
358
132
  }
359
133
  toString() {
360
134
  return this.intro + this.content + this.outro;
@@ -379,45 +153,45 @@ var Q = class c {
379
153
  } else if (this.edit("", void 0, !0), this.outro = this.outro.replace(t, ""), this.outro.length) return !0;
380
154
  }
381
155
  };
382
- function xt() {
383
- return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (c) => globalThis.btoa(unescape(encodeURIComponent(c))) : typeof Buffer ==
384
- "function" ? (c) => Buffer.from(c, "utf-8").toString("base64") : () => {
156
+ function H() {
157
+ return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (l) => globalThis.btoa(unescape(encodeURIComponent(l))) : typeof Buffer ==
158
+ "function" ? (l) => Buffer.from(l, "utf-8").toString("base64") : () => {
385
159
  throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
386
160
  };
387
161
  }
388
- d(xt, "getBtoa");
389
- var kt = /* @__PURE__ */ xt(), nt = class {
162
+ u(H, "getBtoa");
163
+ var V = /* @__PURE__ */ H(), P = class {
390
164
  static {
391
- d(this, "SourceMap");
165
+ u(this, "SourceMap");
392
166
  }
393
167
  constructor(t) {
394
168
  this.version = 3, this.file = t.file, this.sources = t.sources, this.sourcesContent = t.sourcesContent, this.names = t.names, this.mappings =
395
- (0, ht.encode)(t.mappings), typeof t.x_google_ignoreList < "u" && (this.x_google_ignoreList = t.x_google_ignoreList), typeof t.debugId <
396
- "u" && (this.debugId = t.debugId);
169
+ M(t.mappings), typeof t.x_google_ignoreList < "u" && (this.x_google_ignoreList = t.x_google_ignoreList), typeof t.debugId < "u" && (this.
170
+ debugId = t.debugId);
397
171
  }
398
172
  toString() {
399
173
  return JSON.stringify(this);
400
174
  }
401
175
  toUrl() {
402
- return "data:application/json;charset=utf-8;base64," + kt(this.toString());
176
+ return "data:application/json;charset=utf-8;base64," + V(this.toString());
403
177
  }
404
178
  };
405
- function Et(c) {
406
- let t = c.split(`
407
- `), e = t.filter((o) => /^\t+/.test(o)), i = t.filter((o) => /^ {2,}/.test(o));
179
+ function Y(l) {
180
+ let t = l.split(`
181
+ `), e = t.filter((r) => /^\t+/.test(r)), i = t.filter((r) => /^ {2,}/.test(r));
408
182
  if (e.length === 0 && i.length === 0)
409
183
  return null;
410
184
  if (e.length >= i.length)
411
185
  return " ";
412
- let n = i.reduce((o, r) => {
413
- let l = /^ +/.exec(r)[0].length;
414
- return Math.min(l, o);
186
+ let n = i.reduce((r, s) => {
187
+ let o = /^ +/.exec(s)[0].length;
188
+ return Math.min(o, r);
415
189
  }, 1 / 0);
416
190
  return new Array(n + 1).join(" ");
417
191
  }
418
- d(Et, "guessIndent");
419
- function It(c, t) {
420
- let e = c.split(/[/\\]/), i = t.split(/[/\\]/);
192
+ u(Y, "guessIndent");
193
+ function J(l, t) {
194
+ let e = l.split(/[/\\]/), i = t.split(/[/\\]/);
421
195
  for (e.pop(); e[0] === i[0]; )
422
196
  e.shift(), i.shift();
423
197
  if (e.length) {
@@ -426,31 +200,31 @@ function It(c, t) {
426
200
  }
427
201
  return e.concat(i).join("/");
428
202
  }
429
- d(It, "getRelativePath");
430
- var Lt = Object.prototype.toString;
431
- function Pt(c) {
432
- return Lt.call(c) === "[object Object]";
203
+ u(J, "getRelativePath");
204
+ var Q = Object.prototype.toString;
205
+ function X(l) {
206
+ return Q.call(l) === "[object Object]";
433
207
  }
434
- d(Pt, "isObject");
435
- function at(c) {
436
- let t = c.split(`
208
+ u(X, "isObject");
209
+ function $(l) {
210
+ let t = l.split(`
437
211
  `), e = [];
438
212
  for (let i = 0, n = 0; i < t.length; i++)
439
213
  e.push(n), n += t[i].length + 1;
440
- return /* @__PURE__ */ d(function(n) {
441
- let o = 0, r = e.length;
442
- for (; o < r; ) {
443
- let p = o + r >> 1;
444
- n < e[p] ? r = p : o = p + 1;
445
- }
446
- let l = o - 1, u = n - e[l];
447
- return { line: l, column: u };
214
+ return /* @__PURE__ */ u(function(n) {
215
+ let r = 0, s = e.length;
216
+ for (; r < s; ) {
217
+ let h = r + s >> 1;
218
+ n < e[h] ? s = h : r = h + 1;
219
+ }
220
+ let o = r - 1, a = n - e[o];
221
+ return { line: o, column: a };
448
222
  }, "locate");
449
223
  }
450
- d(at, "getLocator");
451
- var Nt = /\w/, st = class {
224
+ u($, "getLocator");
225
+ var Z = /\w/, O = class {
452
226
  static {
453
- d(this, "Mappings");
227
+ u(this, "Mappings");
454
228
  }
455
229
  constructor(t) {
456
230
  this.hires = t, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] =
@@ -458,35 +232,35 @@ var Nt = /\w/, st = class {
458
232
  }
459
233
  addEdit(t, e, i, n) {
460
234
  if (e.length) {
461
- let o = e.length - 1, r = e.indexOf(`
462
- `, 0), l = -1;
463
- for (; r >= 0 && o > r; ) {
464
- let p = [this.generatedCodeColumn, t, i.line, i.column];
465
- n >= 0 && p.push(n), this.rawSegments.push(p), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [],
466
- this.generatedCodeColumn = 0, l = r, r = e.indexOf(`
467
- `, r + 1);
235
+ let r = e.length - 1, s = e.indexOf(`
236
+ `, 0), o = -1;
237
+ for (; s >= 0 && r > s; ) {
238
+ let h = [this.generatedCodeColumn, t, i.line, i.column];
239
+ n >= 0 && h.push(n), this.rawSegments.push(h), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [],
240
+ this.generatedCodeColumn = 0, o = s, s = e.indexOf(`
241
+ `, s + 1);
468
242
  }
469
- let u = [this.generatedCodeColumn, t, i.line, i.column];
470
- n >= 0 && u.push(n), this.rawSegments.push(u), this.advance(e.slice(l + 1));
243
+ let a = [this.generatedCodeColumn, t, i.line, i.column];
244
+ n >= 0 && a.push(n), this.rawSegments.push(a), this.advance(e.slice(o + 1));
471
245
  } else this.pending && (this.rawSegments.push(this.pending), this.advance(e));
472
246
  this.pending = null;
473
247
  }
474
- addUneditedChunk(t, e, i, n, o) {
475
- let r = e.start, l = !0, u = !1;
476
- for (; r < e.end; ) {
477
- if (i[r] === `
248
+ addUneditedChunk(t, e, i, n, r) {
249
+ let s = e.start, o = !0, a = !1;
250
+ for (; s < e.end; ) {
251
+ if (i[s] === `
478
252
  `)
479
253
  n.line += 1, n.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn =
480
- 0, l = !0, u = !1;
254
+ 0, o = !0, a = !1;
481
255
  else {
482
- if (this.hires || l || o.has(r)) {
483
- let p = [this.generatedCodeColumn, t, n.line, n.column];
484
- this.hires === "boundary" ? Nt.test(i[r]) ? u || (this.rawSegments.push(p), u = !0) : (this.rawSegments.push(p), u = !1) : this.rawSegments.
485
- push(p);
256
+ if (this.hires || o || r.has(s)) {
257
+ let h = [this.generatedCodeColumn, t, n.line, n.column];
258
+ this.hires === "boundary" ? Z.test(i[s]) ? a || (this.rawSegments.push(h), a = !0) : (this.rawSegments.push(h), a = !1) : this.rawSegments.
259
+ push(h);
486
260
  }
487
- n.column += 1, this.generatedCodeColumn += 1, l = !1;
261
+ n.column += 1, this.generatedCodeColumn += 1, o = !1;
488
262
  }
489
- r += 1;
263
+ s += 1;
490
264
  }
491
265
  this.pending = null;
492
266
  }
@@ -501,17 +275,17 @@ var Nt = /\w/, st = class {
501
275
  }
502
276
  this.generatedCodeColumn += e[e.length - 1].length;
503
277
  }
504
- }, H = `
505
- `, q = {
278
+ }, _ = `
279
+ `, b = {
506
280
  insertLeft: !1,
507
281
  insertRight: !1,
508
282
  storeName: !1
509
- }, Z = class c {
283
+ }, L = class l {
510
284
  static {
511
- d(this, "MagicString");
285
+ u(this, "MagicString");
512
286
  }
513
287
  constructor(t, e = {}) {
514
- let i = new X(0, t.length, t);
288
+ let i = new I(0, t.length, t);
515
289
  Object.defineProperties(this, {
516
290
  original: { writable: !0, value: t },
517
291
  outro: { writable: !0, value: "" },
@@ -523,7 +297,7 @@ var Nt = /\w/, st = class {
523
297
  byEnd: { writable: !0, value: {} },
524
298
  filename: { writable: !0, value: e.filename },
525
299
  indentExclusionRanges: { writable: !0, value: e.indentExclusionRanges },
526
- sourcemapLocations: { writable: !0, value: new Q() },
300
+ sourcemapLocations: { writable: !0, value: new E() },
527
301
  storedNames: { writable: !0, value: {} },
528
302
  indentStr: { writable: !0, value: void 0 },
529
303
  ignoreList: { writable: !0, value: e.ignoreList },
@@ -550,31 +324,31 @@ var Nt = /\w/, st = class {
550
324
  return i ? i.appendRight(e) : this.outro += e, this;
551
325
  }
552
326
  clone() {
553
- let t = new c(this.original, { filename: this.filename, offset: this.offset }), e = this.firstChunk, i = t.firstChunk = t.lastSearchedChunk =
327
+ let t = new l(this.original, { filename: this.filename, offset: this.offset }), e = this.firstChunk, i = t.firstChunk = t.lastSearchedChunk =
554
328
  e.clone();
555
329
  for (; e; ) {
556
330
  t.byStart[i.start] = i, t.byEnd[i.end] = i;
557
- let n = e.next, o = n && n.clone();
558
- o && (i.next = o, o.previous = i, i = o), e = n;
331
+ let n = e.next, r = n && n.clone();
332
+ r && (i.next = r, r.previous = i, i = r), e = n;
559
333
  }
560
334
  return t.lastChunk = i, this.indentExclusionRanges && (t.indentExclusionRanges = this.indentExclusionRanges.slice()), t.sourcemapLocations =
561
- new Q(this.sourcemapLocations), t.intro = this.intro, t.outro = this.outro, t;
335
+ new E(this.sourcemapLocations), t.intro = this.intro, t.outro = this.outro, t;
562
336
  }
563
337
  generateDecodedMap(t) {
564
338
  t = t || {};
565
- let e = 0, i = Object.keys(this.storedNames), n = new st(t.hires), o = at(this.original);
566
- return this.intro && n.advance(this.intro), this.firstChunk.eachNext((r) => {
567
- let l = o(r.start);
568
- r.intro.length && n.advance(r.intro), r.edited ? n.addEdit(
339
+ let e = 0, i = Object.keys(this.storedNames), n = new O(t.hires), r = $(this.original);
340
+ return this.intro && n.advance(this.intro), this.firstChunk.eachNext((s) => {
341
+ let o = r(s.start);
342
+ s.intro.length && n.advance(s.intro), s.edited ? n.addEdit(
569
343
  e,
570
- r.content,
571
- l,
572
- r.storeName ? i.indexOf(r.original) : -1
573
- ) : n.addUneditedChunk(e, r, this.original, l, this.sourcemapLocations), r.outro.length && n.advance(r.outro);
574
- }), {
344
+ s.content,
345
+ o,
346
+ s.storeName ? i.indexOf(s.original) : -1
347
+ ) : n.addUneditedChunk(e, s, this.original, o, this.sourcemapLocations), s.outro.length && n.advance(s.outro);
348
+ }), this.outro && n.advance(this.outro), {
575
349
  file: t.file ? t.file.split(/[/\\]/).pop() : void 0,
576
350
  sources: [
577
- t.source ? It(t.file || "", t.source) : t.file || ""
351
+ t.source ? J(t.file || "", t.source) : t.file || ""
578
352
  ],
579
353
  sourcesContent: t.includeContent ? [this.original] : void 0,
580
354
  names: i,
@@ -583,10 +357,10 @@ var Nt = /\w/, st = class {
583
357
  };
584
358
  }
585
359
  generateMap(t) {
586
- return new nt(this.generateDecodedMap(t));
360
+ return new P(this.generateDecodedMap(t));
587
361
  }
588
362
  _ensureindentStr() {
589
- this.indentStr === void 0 && (this.indentStr = Et(this.original));
363
+ this.indentStr === void 0 && (this.indentStr = Y(this.original));
590
364
  }
591
365
  _getRawIndentString() {
592
366
  return this._ensureindentStr(), this.indentStr;
@@ -596,33 +370,33 @@ var Nt = /\w/, st = class {
596
370
  }
597
371
  indent(t, e) {
598
372
  let i = /^[^\r\n]/gm;
599
- if (Pt(t) && (e = t, t = void 0), t === void 0 && (this._ensureindentStr(), t = this.indentStr || " "), t === "") return this;
373
+ if (X(t) && (e = t, t = void 0), t === void 0 && (this._ensureindentStr(), t = this.indentStr || " "), t === "") return this;
600
374
  e = e || {};
601
375
  let n = {};
602
- e.exclude && (typeof e.exclude[0] == "number" ? [e.exclude] : e.exclude).forEach((R) => {
603
- for (let D = R[0]; D < R[1]; D += 1)
604
- n[D] = !0;
376
+ e.exclude && (typeof e.exclude[0] == "number" ? [e.exclude] : e.exclude).forEach((f) => {
377
+ for (let C = f[0]; C < f[1]; C += 1)
378
+ n[C] = !0;
605
379
  });
606
- let o = e.indentStart !== !1, r = /* @__PURE__ */ d((p) => o ? `${t}${p}` : (o = !0, p), "replacer");
607
- this.intro = this.intro.replace(i, r);
608
- let l = 0, u = this.firstChunk;
609
- for (; u; ) {
610
- let p = u.end;
611
- if (u.edited)
612
- n[l] || (u.content = u.content.replace(i, r), u.content.length && (o = u.content[u.content.length - 1] === `
380
+ let r = e.indentStart !== !1, s = /* @__PURE__ */ u((h) => r ? `${t}${h}` : (r = !0, h), "replacer");
381
+ this.intro = this.intro.replace(i, s);
382
+ let o = 0, a = this.firstChunk;
383
+ for (; a; ) {
384
+ let h = a.end;
385
+ if (a.edited)
386
+ n[o] || (a.content = a.content.replace(i, s), a.content.length && (r = a.content[a.content.length - 1] === `
613
387
  `));
614
388
  else
615
- for (l = u.start; l < p; ) {
616
- if (!n[l]) {
617
- let R = this.original[l];
618
- R === `
619
- ` ? o = !0 : R !== "\r" && o && (o = !1, l === u.start || (this._splitChunk(u, l), u = u.next), u.prependRight(t));
389
+ for (o = a.start; o < h; ) {
390
+ if (!n[o]) {
391
+ let f = this.original[o];
392
+ f === `
393
+ ` ? r = !0 : f !== "\r" && r && (r = !1, o === a.start || (this._splitChunk(a, o), a = a.next), a.prependRight(t));
620
394
  }
621
- l += 1;
395
+ o += 1;
622
396
  }
623
- l = u.end, u = u.next;
397
+ o = a.end, a = a.next;
624
398
  }
625
- return this.outro = this.outro.replace(i, r), this;
399
+ return this.outro = this.outro.replace(i, s), this;
626
400
  }
627
401
  insert() {
628
402
  throw new Error(
@@ -630,25 +404,25 @@ var Nt = /\w/, st = class {
630
404
  );
631
405
  }
632
406
  insertLeft(t, e) {
633
- return q.insertLeft || (console.warn(
407
+ return b.insertLeft || (console.warn(
634
408
  "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
635
- ), q.insertLeft = !0), this.appendLeft(t, e);
409
+ ), b.insertLeft = !0), this.appendLeft(t, e);
636
410
  }
637
411
  insertRight(t, e) {
638
- return q.insertRight || (console.warn(
412
+ return b.insertRight || (console.warn(
639
413
  "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
640
- ), q.insertRight = !0), this.prependRight(t, e);
414
+ ), b.insertRight = !0), this.prependRight(t, e);
641
415
  }
642
416
  move(t, e, i) {
643
417
  if (t = t + this.offset, e = e + this.offset, i = i + this.offset, i >= t && i <= e) throw new Error("Cannot move a selection inside its\
644
418
  elf");
645
419
  this._split(t), this._split(e), this._split(i);
646
- let n = this.byStart[t], o = this.byEnd[e], r = n.previous, l = o.next, u = this.byStart[i];
647
- if (!u && o === this.lastChunk) return this;
648
- let p = u ? u.previous : this.lastChunk;
649
- return r && (r.next = l), l && (l.previous = r), p && (p.next = n), u && (u.previous = o), n.previous || (this.firstChunk = o.next), o.next ||
650
- (this.lastChunk = n.previous, this.lastChunk.next = null), n.previous = p, o.next = u || null, p || (this.firstChunk = n), u || (this.lastChunk =
651
- o), this;
420
+ let n = this.byStart[t], r = this.byEnd[e], s = n.previous, o = r.next, a = this.byStart[i];
421
+ if (!a && r === this.lastChunk) return this;
422
+ let h = a ? a.previous : this.lastChunk;
423
+ return s && (s.next = o), o && (o.previous = s), h && (h.next = n), a && (a.previous = r), n.previous || (this.firstChunk = r.next), r.next ||
424
+ (this.lastChunk = n.previous, this.lastChunk.next = null), n.previous = h, r.next = a || null, h || (this.firstChunk = n), a || (this.lastChunk =
425
+ r), this;
652
426
  }
653
427
  overwrite(t, e, i, n) {
654
428
  return n = n || {}, this.update(t, e, i, { ...n, overwrite: !n.contentOnly });
@@ -664,30 +438,30 @@ elf");
664
438
  throw new Error(
665
439
  "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
666
440
  );
667
- this._split(t), this._split(e), n === !0 && (q.storeName || (console.warn(
441
+ this._split(t), this._split(e), n === !0 && (b.storeName || (console.warn(
668
442
  "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
669
- ), q.storeName = !0), n = { storeName: !0 });
670
- let o = n !== void 0 ? n.storeName : !1, r = n !== void 0 ? n.overwrite : !1;
671
- if (o) {
672
- let p = this.original.slice(t, e);
673
- Object.defineProperty(this.storedNames, p, {
443
+ ), b.storeName = !0), n = { storeName: !0 });
444
+ let r = n !== void 0 ? n.storeName : !1, s = n !== void 0 ? n.overwrite : !1;
445
+ if (r) {
446
+ let h = this.original.slice(t, e);
447
+ Object.defineProperty(this.storedNames, h, {
674
448
  writable: !0,
675
449
  value: !0,
676
450
  enumerable: !0
677
451
  });
678
452
  }
679
- let l = this.byStart[t], u = this.byEnd[e];
680
- if (l) {
681
- let p = l;
682
- for (; p !== u; ) {
683
- if (p.next !== this.byStart[p.end])
453
+ let o = this.byStart[t], a = this.byEnd[e];
454
+ if (o) {
455
+ let h = o;
456
+ for (; h !== a; ) {
457
+ if (h.next !== this.byStart[h.end])
684
458
  throw new Error("Cannot overwrite across a split point");
685
- p = p.next, p.edit("", !1);
459
+ h = h.next, h.edit("", !1);
686
460
  }
687
- l.edit(i, o, !r);
461
+ o.edit(i, r, !s);
688
462
  } else {
689
- let p = new X(t, e, "").edit(i, o);
690
- u.next = p, p.previous = u;
463
+ let h = new I(t, e, "").edit(i, r);
464
+ a.next = h, h.previous = a;
691
465
  }
692
466
  return this;
693
467
  }
@@ -746,24 +520,24 @@ elf");
746
520
  return this.intro.length ? this.intro[this.intro.length - 1] : "";
747
521
  }
748
522
  lastLine() {
749
- let t = this.outro.lastIndexOf(H);
523
+ let t = this.outro.lastIndexOf(_);
750
524
  if (t !== -1) return this.outro.substr(t + 1);
751
525
  let e = this.outro, i = this.lastChunk;
752
526
  do {
753
527
  if (i.outro.length > 0) {
754
- if (t = i.outro.lastIndexOf(H), t !== -1) return i.outro.substr(t + 1) + e;
528
+ if (t = i.outro.lastIndexOf(_), t !== -1) return i.outro.substr(t + 1) + e;
755
529
  e = i.outro + e;
756
530
  }
757
531
  if (i.content.length > 0) {
758
- if (t = i.content.lastIndexOf(H), t !== -1) return i.content.substr(t + 1) + e;
532
+ if (t = i.content.lastIndexOf(_), t !== -1) return i.content.substr(t + 1) + e;
759
533
  e = i.content + e;
760
534
  }
761
535
  if (i.intro.length > 0) {
762
- if (t = i.intro.lastIndexOf(H), t !== -1) return i.intro.substr(t + 1) + e;
536
+ if (t = i.intro.lastIndexOf(_), t !== -1) return i.intro.substr(t + 1) + e;
763
537
  e = i.intro + e;
764
538
  }
765
539
  } while (i = i.previous);
766
- return t = this.intro.lastIndexOf(H), t !== -1 ? this.intro.substr(t + 1) + e : this.intro + e;
540
+ return t = this.intro.lastIndexOf(_), t !== -1 ? this.intro.substr(t + 1) + e : this.intro + e;
767
541
  }
768
542
  slice(t = 0, e = this.original.length - this.offset) {
769
543
  if (t = t + this.offset, e = e + this.offset, this.original.length !== 0) {
@@ -778,14 +552,14 @@ elf");
778
552
  }
779
553
  if (n && n.edited && n.start !== t)
780
554
  throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);
781
- let o = n;
555
+ let r = n;
782
556
  for (; n; ) {
783
- n.intro && (o !== n || n.start === t) && (i += n.intro);
784
- let r = n.start < e && n.end >= e;
785
- if (r && n.edited && n.end !== e)
557
+ n.intro && (r !== n || n.start === t) && (i += n.intro);
558
+ let s = n.start < e && n.end >= e;
559
+ if (s && n.edited && n.end !== e)
786
560
  throw new Error(`Cannot use replaced character ${e} as slice end anchor.`);
787
- let l = o === n ? t - n.start : 0, u = r ? n.content.length + e - n.end : n.content.length;
788
- if (i += n.content.slice(l, u), n.outro && (!r || n.end === e) && (i += n.outro), r)
561
+ let o = r === n ? t - n.start : 0, a = s ? n.content.length + e - n.end : n.content.length;
562
+ if (i += n.content.slice(o, a), n.outro && (!s || n.end === e) && (i += n.outro), s)
789
563
  break;
790
564
  n = n.next;
791
565
  }
@@ -798,15 +572,16 @@ elf");
798
572
  }
799
573
  _split(t) {
800
574
  if (this.byStart[t] || this.byEnd[t]) return;
801
- let e = this.lastSearchedChunk, i = t > e.end;
575
+ let e = this.lastSearchedChunk, i = e, n = t > e.end;
802
576
  for (; e; ) {
803
577
  if (e.contains(t)) return this._splitChunk(e, t);
804
- e = i ? this.byStart[e.end] : this.byEnd[e.start];
578
+ if (e = n ? this.byStart[e.end] : this.byEnd[e.start], e === i) return;
579
+ i = e;
805
580
  }
806
581
  }
807
582
  _splitChunk(t, e) {
808
583
  if (t.edited && t.content.length) {
809
- let n = at(this.original)(e);
584
+ let n = $(this.original)(e);
810
585
  throw new Error(
811
586
  `Cannot split a chunk that has already been edited (${n.line}:${n.column} \u2013 "${t.original}")`
812
587
  );
@@ -847,9 +622,9 @@ elf");
847
622
  if (this.outro = this.outro.replace(e, ""), this.outro.length) return !0;
848
623
  let i = this.lastChunk;
849
624
  do {
850
- let n = i.end, o = i.trimEnd(e);
625
+ let n = i.end, r = i.trimEnd(e);
851
626
  if (i.end !== n && (this.lastChunk === i && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.
852
- byEnd[i.next.end] = i.next), o) return !0;
627
+ byEnd[i.next.end] = i.next), r) return !0;
853
628
  i = i.previous;
854
629
  } while (i);
855
630
  return !1;
@@ -862,9 +637,9 @@ elf");
862
637
  if (this.intro = this.intro.replace(e, ""), this.intro.length) return !0;
863
638
  let i = this.firstChunk;
864
639
  do {
865
- let n = i.end, o = i.trimStart(e);
640
+ let n = i.end, r = i.trimStart(e);
866
641
  if (i.end !== n && (i === this.lastChunk && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.
867
- byEnd[i.next.end] = i.next), o) return !0;
642
+ byEnd[i.next.end] = i.next), r) return !0;
868
643
  i = i.next;
869
644
  } while (i);
870
645
  return !1;
@@ -876,44 +651,46 @@ elf");
876
651
  return this.original !== this.toString();
877
652
  }
878
653
  _replaceRegexp(t, e) {
879
- function i(o, r) {
880
- return typeof e == "string" ? e.replace(/\$(\$|&|\d+)/g, (l, u) => u === "$" ? "$" : u === "&" ? o[0] : +u < o.length ? o[+u] : `$${u}`) :
881
- e(...o, o.index, r, o.groups);
882
- }
883
- d(i, "getReplacement");
884
- function n(o, r) {
885
- let l, u = [];
886
- for (; l = o.exec(r); )
887
- u.push(l);
888
- return u;
654
+ function i(r, s) {
655
+ return typeof e == "string" ? e.replace(/\$(\$|&|\d+)/g, (o, a) => a === "$" ? "$" : a === "&" ? r[0] : +a < r.length ? r[+a] : `$${a}`) :
656
+ e(...r, r.index, s, r.groups);
657
+ }
658
+ u(i, "getReplacement");
659
+ function n(r, s) {
660
+ let o, a = [];
661
+ for (; o = r.exec(s); )
662
+ a.push(o);
663
+ return a;
889
664
  }
890
- if (d(n, "matchAll"), t.global)
891
- n(t, this.original).forEach((r) => {
892
- if (r.index != null) {
893
- let l = i(r, this.original);
894
- l !== r[0] && this.overwrite(r.index, r.index + r[0].length, l);
665
+ if (u(n, "matchAll"), t.global)
666
+ n(t, this.original).forEach((s) => {
667
+ if (s.index != null) {
668
+ let o = i(s, this.original);
669
+ o !== s[0] && this.overwrite(s.index, s.index + s[0].length, o);
895
670
  }
896
671
  });
897
672
  else {
898
- let o = this.original.match(t);
899
- if (o && o.index != null) {
900
- let r = i(o, this.original);
901
- r !== o[0] && this.overwrite(o.index, o.index + o[0].length, r);
673
+ let r = this.original.match(t);
674
+ if (r && r.index != null) {
675
+ let s = i(r, this.original);
676
+ s !== r[0] && this.overwrite(r.index, r.index + r[0].length, s);
902
677
  }
903
678
  }
904
679
  return this;
905
680
  }
906
681
  _replaceString(t, e) {
907
682
  let { original: i } = this, n = i.indexOf(t);
908
- return n !== -1 && this.overwrite(n, n + t.length, e), this;
683
+ return n !== -1 && (typeof e == "function" && (e = e(t, n, i)), t !== e && this.overwrite(n, n + t.length, e)), this;
909
684
  }
910
685
  replace(t, e) {
911
686
  return typeof t == "string" ? this._replaceString(t, e) : this._replaceRegexp(t, e);
912
687
  }
913
688
  _replaceAllString(t, e) {
914
689
  let { original: i } = this, n = t.length;
915
- for (let o = i.indexOf(t); o !== -1; o = i.indexOf(t, o + n))
916
- i.slice(o, o + n) !== e && this.overwrite(o, o + n, e);
690
+ for (let r = i.indexOf(t); r !== -1; r = i.indexOf(t, r + n)) {
691
+ let s = i.slice(r, r + n), o = e;
692
+ typeof e == "function" && (o = e(s, r, i)), s !== o && this.overwrite(r, r + n, o);
693
+ }
917
694
  return this;
918
695
  }
919
696
  replaceAll(t, e) {
@@ -928,106 +705,106 @@ elf");
928
705
  };
929
706
 
930
707
  // src/core-server/presets/vitePlugins/vite-inject-mocker/constants.ts
931
- var ut = "__vitest_mocker__";
708
+ var T = "__vitest_mocker__";
932
709
 
933
710
  // src/core-server/mocking-utils/esmWalker.ts
934
- function V(c) {
935
- return c.type === "Identifier" ? c.name : c.raw;
711
+ function v(l) {
712
+ return l.type === "Identifier" ? l.name : l.raw;
936
713
  }
937
- d(V, "getArbitraryModuleIdentifier");
714
+ u(v, "getArbitraryModuleIdentifier");
938
715
 
939
716
  // src/core-server/mocking-utils/automock.ts
940
- function ct(c, t, e) {
941
- return At(c, t ? "autospy" : "automock", e, {
942
- globalThisAccessor: JSON.stringify(ut)
717
+ function B(l, t, e) {
718
+ return it(l, t ? "autospy" : "automock", e, {
719
+ globalThisAccessor: JSON.stringify(T)
943
720
  });
944
721
  }
945
- d(ct, "getAutomockCode");
946
- function At(c, t, e, i = {}) {
947
- let n = i.globalThisAccessor || '"__vitest_mocker__"', o = e(c), r = new Z(c), l = [], u = 0;
948
- for (let P of o.body) {
949
- if (P.type === "ExportAllDeclaration")
722
+ u(B, "getAutomockCode");
723
+ function it(l, t, e, i = {}) {
724
+ let n = i.globalThisAccessor || '"__vitest_mocker__"', r = e(l), s = new L(l), o = [], a = 0;
725
+ for (let g of r.body) {
726
+ if (g.type === "ExportAllDeclaration")
950
727
  throw new Error(
951
728
  "automocking files with `export *` is not supported in browser mode because it cannot be statically analysed"
952
729
  );
953
- if (P.type === "ExportNamedDeclaration") {
954
- let j = function(v) {
955
- if (v.type === "Identifier")
956
- l.push({ name: v.name });
957
- else if (v.type === "ArrayPattern")
958
- v.elements.forEach((N) => {
959
- N && j(N);
730
+ if (g.type === "ExportNamedDeclaration") {
731
+ let y = function(c) {
732
+ if (c.type === "Identifier")
733
+ o.push({ name: c.name });
734
+ else if (c.type === "ArrayPattern")
735
+ c.elements.forEach((m) => {
736
+ m && y(m);
960
737
  });
961
- else if (v.type === "ObjectPattern")
962
- v.properties.forEach((N) => {
963
- N.type === "RestElement" ? j(N) : N.type === "Property" && j(N.value);
738
+ else if (c.type === "ObjectPattern")
739
+ c.properties.forEach((m) => {
740
+ m.type === "RestElement" ? y(m) : m.type === "Property" && y(m.value);
964
741
  });
965
- else if (v.type === "RestElement")
966
- j(v.argument);
742
+ else if (c.type === "RestElement")
743
+ y(c.argument);
967
744
  else {
968
- if (v.type === "AssignmentPattern")
745
+ if (c.type === "AssignmentPattern")
969
746
  throw new Error("AssignmentPattern is not supported. Please open a new bug report.");
970
- if (v.type === "MemberExpression")
747
+ if (c.type === "MemberExpression")
971
748
  throw new Error("MemberExpression is not supported. Please open a new bug report.");
972
749
  }
973
750
  };
974
- var tt = j;
975
- d(j, "traversePattern");
976
- let I = P, L = I.declaration;
977
- L && (L.type === "FunctionDeclaration" ? l.push({ name: L.id.name }) : L.type === "VariableDeclaration" ? L.declarations.forEach((v) => {
978
- j(v.id);
979
- }) : L.type === "ClassDeclaration" && l.push({ name: L.id.name }), r.remove(I.start, L.start));
980
- let $ = I.specifiers || [], T = I.source;
981
- if (!T && $.length)
982
- $.forEach((v) => {
983
- l.push({
984
- alias: V(v.exported),
985
- name: V(v.local)
751
+ var st = y;
752
+ u(y, "traversePattern");
753
+ let d = g, p = d.declaration;
754
+ p && (p.type === "FunctionDeclaration" ? o.push({ name: p.id.name }) : p.type === "VariableDeclaration" ? p.declarations.forEach((c) => {
755
+ y(c.id);
756
+ }) : p.type === "ClassDeclaration" && o.push({ name: p.id.name }), s.remove(d.start, p.start));
757
+ let x = d.specifiers || [], N = d.source;
758
+ if (!N && x.length)
759
+ x.forEach((c) => {
760
+ o.push({
761
+ alias: v(c.exported),
762
+ name: v(c.local)
986
763
  });
987
- }), r.remove(I.start, I.end);
988
- else if (T && $.length) {
989
- let v = [];
990
- $.forEach((B) => {
991
- let F = `__vitest_imported_${u++}__`;
992
- v.push([V(B.local), F]), l.push({
993
- name: F,
994
- alias: V(B.exported)
764
+ }), s.remove(d.start, d.end);
765
+ else if (N && x.length) {
766
+ let c = [];
767
+ x.forEach((S) => {
768
+ let k = `__vitest_imported_${a++}__`;
769
+ c.push([v(S.local), k]), o.push({
770
+ name: k,
771
+ alias: v(S.exported)
995
772
  });
996
773
  });
997
- let N = `import { ${v.map(([B, F]) => `${B} as ${F}`).join(", ")} } from '${T.value}'`;
998
- r.overwrite(I.start, I.end, N);
774
+ let m = `import { ${c.map(([S, k]) => `${S} as ${k}`).join(", ")} } from '${N.value}'`;
775
+ s.overwrite(d.start, d.end, m);
999
776
  }
1000
777
  }
1001
- if (P.type === "ExportDefaultDeclaration") {
1002
- let I = P, L = I.declaration;
1003
- l.push({ name: "__vitest_default", alias: "default" }), r.overwrite(I.start, L.start, "const __vitest_default = ");
778
+ if (g.type === "ExportDefaultDeclaration") {
779
+ let d = g, p = d.declaration;
780
+ o.push({ name: "__vitest_default", alias: "default" }), s.overwrite(d.start, p.start, "const __vitest_default = ");
1004
781
  }
1005
782
  }
1006
- let p = `
783
+ let h = `
1007
784
  const __vitest_current_es_module__ = {
1008
785
  __esModule: true,
1009
- ${l.map(({ name: P }) => `["${P}"]: ${P},`).join(`
786
+ ${o.map(({ name: g }) => `["${g}"]: ${g},`).join(`
1010
787
  `)}
1011
788
  }
1012
789
  const __vitest_mocked_module__ = globalThis[${n}].mockObject(__vitest_current_es_module__, "${t}")
1013
- `, R = l.map(({ name: P }, I) => `const __vitest_mocked_${I}__ = __vitest_mocked_module__["${P}"]`).join(`
1014
- `), W = `
790
+ `, f = o.map(({ name: g }, d) => `const __vitest_mocked_${d}__ = __vitest_mocked_module__["${g}"]`).join(`
791
+ `), U = `
1015
792
  export {
1016
- ${l.map(({ name: P, alias: I }, L) => ` __vitest_mocked_${L}__ as ${I || P},`).join(`
793
+ ${o.map(({ name: g, alias: d }, p) => ` __vitest_mocked_${p}__ as ${d || g},`).join(`
1017
794
  `)}
1018
795
  }
1019
796
  `;
1020
- return r.append(p + R + W), r;
797
+ return s.append(h + f + U), s;
1021
798
  }
1022
- d(At, "automockModule");
799
+ u(it, "automockModule");
1023
800
 
1024
801
  // src/core-server/mocking-utils/extract.ts
1025
- import { readFileSync as ue } from "node:fs";
1026
- import { generate as fe, parser as Dt, types as de } from "storybook/internal/babel";
1027
- import { logger as ge } from "storybook/internal/node-logger";
1028
- import { telemetry as ye } from "storybook/internal/telemetry";
1029
- import { transformSync as we } from "esbuild";
1030
- var ft = /* @__PURE__ */ d((c) => Dt.parse(c, {
802
+ import { readFileSync as $t } from "node:fs";
803
+ import { generate as Bt, parser as nt, types as Ft } from "storybook/internal/babel";
804
+ import { logger as qt } from "storybook/internal/node-logger";
805
+ import { telemetry as Gt } from "storybook/internal/telemetry";
806
+ import { transformSync as zt } from "esbuild";
807
+ var F = /* @__PURE__ */ u((l) => nt.parse(l, {
1031
808
  sourceType: "module",
1032
809
  // Enable plugins to handle modern JavaScript features, including TSX.
1033
810
  plugins: ["typescript", "jsx", "classProperties", "objectRestSpread"],
@@ -1035,11 +812,11 @@ var ft = /* @__PURE__ */ d((c) => Dt.parse(c, {
1035
812
  }).program, "babelParser");
1036
813
 
1037
814
  // src/core-server/presets/webpack/loaders/webpack-automock-loader.ts
1038
- function jt(c) {
815
+ function rt(l) {
1039
816
  let e = this.getOptions().spy === "true";
1040
- return ct(c, e, ft).toString();
817
+ return B(l, e, F).toString();
1041
818
  }
1042
- d(jt, "webpackAutomockLoader");
819
+ u(rt, "webpackAutomockLoader");
1043
820
  export {
1044
- jt as default
821
+ rt as default
1045
822
  };