storybook 9.0.0-rc.2 → 9.0.0-rc.3

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.
@@ -11,18 +11,18 @@ var Ae = Object.getOwnPropertyNames;
11
11
  var $e = Object.getPrototypeOf, Re = Object.prototype.hasOwnProperty;
12
12
  var f = (s, e) => X(s, "name", { value: e, configurable: !0 });
13
13
  var Le = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports);
14
- var Me = (s, e, i, t) => {
14
+ var Me = (s, e, r, t) => {
15
15
  if (e && typeof e == "object" || typeof e == "function")
16
- for (let r of Ae(e))
17
- !Re.call(s, r) && r !== i && X(s, r, { get: () => e[r], enumerable: !(t = Ve(e, r)) || t.enumerable });
16
+ for (let i of Ae(e))
17
+ !Re.call(s, i) && i !== r && X(s, i, { get: () => e[i], enumerable: !(t = Ve(e, i)) || t.enumerable });
18
18
  return s;
19
19
  };
20
- var U = (s, e, i) => (i = s != null ? ke($e(s)) : {}, Me(
20
+ var U = (s, e, r) => (r = s != null ? ke($e(s)) : {}, Me(
21
21
  // If the importer is in node compatibility mode or this is not an ESM
22
22
  // file that has been converted to a CommonJS file using a Babel-
23
23
  // compatible transform (i.e. "__esModule" has not been set), then set
24
24
  // "default" to the CommonJS "module.exports" for node compatibility.
25
- e || !s || !s.__esModule ? X(i, "default", { value: s, enumerable: !0 }) : i,
25
+ e || !s || !s.__esModule ? X(r, "default", { value: s, enumerable: !0 }) : r,
26
26
  s
27
27
  ));
28
28
 
@@ -32,36 +32,36 @@ var V = Le((k) => {
32
32
  Object.defineProperty(k, "__esModule", { value: !0 });
33
33
  k.dedent = void 0;
34
34
  function se(s) {
35
- for (var e = [], i = 1; i < arguments.length; i++)
36
- e[i - 1] = arguments[i];
35
+ for (var e = [], r = 1; r < arguments.length; r++)
36
+ e[r - 1] = arguments[r];
37
37
  var t = Array.from(typeof s == "string" ? [s] : s);
38
38
  t[t.length - 1] = t[t.length - 1].replace(/\r?\n([\t ]*)$/, "");
39
- var r = t.reduce(function(a, p) {
39
+ var i = t.reduce(function(l, p) {
40
40
  var d = p.match(/\n([\t ]+|(?!\s).)/g);
41
- return d ? a.concat(d.map(function(g) {
41
+ return d ? l.concat(d.map(function(m) {
42
42
  var x, b;
43
- return (b = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && b !== void 0 ? b : 0;
44
- })) : a;
43
+ return (b = (x = m.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && b !== void 0 ? b : 0;
44
+ })) : l;
45
45
  }, []);
46
- if (r.length) {
46
+ if (i.length) {
47
47
  var o = new RegExp(`
48
- [ ]{` + Math.min.apply(Math, r) + "}", "g");
49
- t = t.map(function(a) {
50
- return a.replace(o, `
48
+ [ ]{` + Math.min.apply(Math, i) + "}", "g");
49
+ t = t.map(function(l) {
50
+ return l.replace(o, `
51
51
  `);
52
52
  });
53
53
  }
54
54
  t[0] = t[0].replace(/^\r?\n/, "");
55
- var l = t[0];
56
- return e.forEach(function(a, p) {
57
- var d = l.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = a;
58
- typeof a == "string" && a.includes(`
59
- `) && (x = String(a).split(`
55
+ var a = t[0];
56
+ return e.forEach(function(l, p) {
57
+ var d = a.match(/(?:^|\n)( *)$/), m = d ? d[1] : "", x = l;
58
+ typeof l == "string" && l.includes(`
59
+ `) && (x = String(l).split(`
60
60
  `).map(function(b, y) {
61
- return y === 0 ? b : "" + g + b;
61
+ return y === 0 ? b : "" + m + b;
62
62
  }).join(`
63
- `)), l += x + t[p + 1];
64
- }), l;
63
+ `)), a += x + t[p + 1];
64
+ }), a;
65
65
  }
66
66
  f(se, "dedent");
67
67
  k.dedent = se;
@@ -84,10 +84,10 @@ import { isExportStory as ne, storyNameFromExport as oe, toId as ze } from "stor
84
84
  // src/csf-tools/findVarInitialization.ts
85
85
  import { types as A } from "storybook/internal/babel";
86
86
  var P = /* @__PURE__ */ f((s, e) => {
87
- let i = null, t = null;
88
- return e.body.find((r) => (A.isVariableDeclaration(r) ? t = r.declarations : A.isExportNamedDeclaration(r) && A.isVariableDeclaration(r.declaration) &&
89
- (t = r.declaration.declarations), t && t.find((o) => A.isVariableDeclarator(o) && A.isIdentifier(o.id) && o.id.name === s ? (i = o.init, !0) :
90
- !1))), i;
87
+ let r = null, t = null;
88
+ return e.body.find((i) => (A.isVariableDeclaration(i) ? t = i.declarations : A.isExportNamedDeclaration(i) && A.isVariableDeclaration(i.declaration) &&
89
+ (t = i.declaration.declarations), t && t.find((o) => A.isVariableDeclarator(o) && A.isIdentifier(o.id) && o.id.name === s ? (r = o.init, !0) :
90
+ !1))), r;
91
91
  }, "findVarInitialization");
92
92
 
93
93
  // src/csf-tools/CsfFile.ts
@@ -116,21 +116,21 @@ function le(s) {
116
116
  });
117
117
  }
118
118
  f(le, "parseTags");
119
- var I = /* @__PURE__ */ f((s, e) => {
120
- let i = "";
119
+ var v = /* @__PURE__ */ f((s, e) => {
120
+ let r = "";
121
121
  if (s.loc) {
122
- let { line: t, column: r } = s.loc?.start || {};
123
- i = `(line ${t}, col ${r})`;
122
+ let { line: t, column: i } = s.loc?.start || {};
123
+ r = `(line ${t}, col ${i})`;
124
124
  }
125
- return `${e || ""} ${i}`.trim();
126
- }, "formatLocation"), Qe = /* @__PURE__ */ f((s) => Ze.test(s), "isModuleMock"), ce = /* @__PURE__ */ f((s, e, i) => {
125
+ return `${e || ""} ${r}`.trim();
126
+ }, "formatLocation"), Qe = /* @__PURE__ */ f((s) => Ze.test(s), "isModuleMock"), ce = /* @__PURE__ */ f((s, e, r) => {
127
127
  let t = s;
128
128
  if (c.isCallExpression(s)) {
129
- let { callee: r, arguments: o } = s;
130
- if (c.isProgram(e) && c.isMemberExpression(r) && c.isIdentifier(r.object) && c.isIdentifier(r.property) && r.property.name === "bind" &&
129
+ let { callee: i, arguments: o } = s;
130
+ if (c.isProgram(e) && c.isMemberExpression(i) && c.isIdentifier(i.object) && c.isIdentifier(i.property) && i.property.name === "bind" &&
131
131
  (o.length === 0 || o.length === 1 && c.isObjectExpression(o[0]) && o[0].properties.length === 0)) {
132
- let l = r.object.name, a = P(l, e);
133
- a && (i._templates[l] = a, t = a);
132
+ let a = i.object.name, l = P(a, e);
133
+ l && (r._templates[a] = l, t = l);
134
134
  }
135
135
  }
136
136
  return c.isArrowFunctionExpression(t) || c.isFunctionDeclaration(t) ? t.params.length > 0 : !1;
@@ -143,18 +143,18 @@ var I = /* @__PURE__ */ f((s, e) => {
143
143
  });
144
144
  throw new Error(`Expected array of string literals: ${s}`);
145
145
  }, "parseExportsOrder"), pe = /* @__PURE__ */ f((s, e) => e.reduce(
146
- (i, t) => {
147
- let r = s[t];
148
- return r && (i[t] = r), i;
146
+ (r, t) => {
147
+ let i = s[t];
148
+ return i && (r[t] = i), r;
149
149
  },
150
150
  {}
151
151
  ), "sortExports"), Ye = /* @__PURE__ */ f((s) => {
152
152
  if (c.isArrowFunctionExpression(s) || c.isFunctionDeclaration(s)) {
153
153
  let e = s.params;
154
154
  if (e.length >= 1) {
155
- let [i] = e;
156
- if (c.isObjectPattern(i))
157
- return !!i.properties.find((t) => {
155
+ let [r] = e;
156
+ if (c.isObjectPattern(r))
157
+ return !!r.properties.find((t) => {
158
158
  if (c.isObjectProperty(t) && c.isIdentifier(t.key))
159
159
  return t.key.name === "mount";
160
160
  });
@@ -165,10 +165,10 @@ var I = /* @__PURE__ */ f((s, e) => {
165
165
  static {
166
166
  f(this, "NoMetaError");
167
167
  }
168
- constructor(e, i, t) {
169
- let r = "".trim();
168
+ constructor(e, r, t) {
169
+ let i = "".trim();
170
170
  super(O.dedent`
171
- CSF: ${e} ${I(i, t)}
171
+ CSF: ${e} ${v(r, t)}
172
172
 
173
173
  More info: https://storybook.js.org/docs/writing-stories#default-export
174
174
  `), this.name = this.constructor.name;
@@ -177,10 +177,10 @@ var I = /* @__PURE__ */ f((s, e) => {
177
177
  static {
178
178
  f(this, "MultipleMetaError");
179
179
  }
180
- constructor(e, i, t) {
181
- let r = `${e} ${I(i, t)}`.trim();
180
+ constructor(e, r, t) {
181
+ let i = `${e} ${v(r, t)}`.trim();
182
182
  super(O.dedent`
183
- CSF: ${e} ${I(i, t)}
183
+ CSF: ${e} ${v(r, t)}
184
184
 
185
185
  More info: https://storybook.js.org/docs/writing-stories#default-export
186
186
  `), this.name = this.constructor.name;
@@ -189,10 +189,10 @@ var I = /* @__PURE__ */ f((s, e) => {
189
189
  static {
190
190
  f(this, "MixedFactoryError");
191
191
  }
192
- constructor(e, i, t) {
193
- let r = `${e} ${I(i, t)}`.trim();
192
+ constructor(e, r, t) {
193
+ let i = `${e} ${v(r, t)}`.trim();
194
194
  super(O.dedent`
195
- CSF: ${e} ${I(i, t)}
195
+ CSF: ${e} ${v(r, t)}
196
196
 
197
197
  More info: https://storybook.js.org/docs/writing-stories#default-export
198
198
  `), this.name = this.constructor.name;
@@ -201,16 +201,16 @@ var I = /* @__PURE__ */ f((s, e) => {
201
201
  static {
202
202
  f(this, "BadMetaError");
203
203
  }
204
- constructor(e, i, t) {
205
- let r = "".trim();
204
+ constructor(e, r, t) {
205
+ let i = "".trim();
206
206
  super(O.dedent`
207
- CSF: ${e} ${I(i, t)}
207
+ CSF: ${e} ${v(r, t)}
208
208
 
209
209
  More info: https://storybook.js.org/docs/writing-stories#default-export
210
210
  `), this.name = this.constructor.name;
211
211
  }
212
212
  }, J = class {
213
- constructor(e, i, t) {
213
+ constructor(e, r, t) {
214
214
  this._stories = {};
215
215
  this._metaAnnotations = {};
216
216
  this._storyExports = {};
@@ -218,102 +218,102 @@ var I = /* @__PURE__ */ f((s, e) => {
218
218
  this._storyStatements = {};
219
219
  this._storyAnnotations = {};
220
220
  this._templates = {};
221
- this._ast = e, this._file = t, this._options = i, this.imports = [];
221
+ this._ast = e, this._file = t, this._options = r, this.imports = [];
222
222
  }
223
223
  static {
224
224
  f(this, "CsfFile");
225
225
  }
226
226
  _parseTitle(e) {
227
- let i = c.isIdentifier(e) ? P(e.name, this._ast.program) : e;
228
- if (c.isStringLiteral(i))
229
- return i.value;
230
- if (c.isTSSatisfiesExpression(i) && c.isStringLiteral(i.expression))
231
- return i.expression.value;
227
+ let r = c.isIdentifier(e) ? P(e.name, this._ast.program) : e;
228
+ if (c.isStringLiteral(r))
229
+ return r.value;
230
+ if (c.isTSSatisfiesExpression(r) && c.isStringLiteral(r.expression))
231
+ return r.expression.value;
232
232
  throw new Error(O.dedent`
233
- CSF: unexpected dynamic title ${I(i, this._options.fileName)}
233
+ CSF: unexpected dynamic title ${v(r, this._options.fileName)}
234
234
 
235
235
  More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
236
236
  `);
237
237
  }
238
- _parseMeta(e, i) {
238
+ _parseMeta(e, r) {
239
239
  if (this._metaNode)
240
240
  throw new K("multiple meta objects", e, this._options.fileName);
241
241
  this._metaNode = e;
242
242
  let t = {};
243
- e.properties.forEach((r) => {
244
- if (c.isIdentifier(r.key)) {
245
- if (this._metaAnnotations[r.key.name] = r.value, r.key.name === "title")
246
- t.title = this._parseTitle(r.value);
247
- else if (["includeStories", "excludeStories"].includes(r.key.name))
248
- t[r.key.name] = Je(r.value);
249
- else if (r.key.name === "component") {
250
- let o = r.value;
243
+ e.properties.forEach((i) => {
244
+ if (c.isIdentifier(i.key)) {
245
+ if (this._metaAnnotations[i.key.name] = i.value, i.key.name === "title")
246
+ t.title = this._parseTitle(i.value);
247
+ else if (["includeStories", "excludeStories"].includes(i.key.name))
248
+ t[i.key.name] = Je(i.value);
249
+ else if (i.key.name === "component") {
250
+ let o = i.value;
251
251
  if (c.isIdentifier(o)) {
252
- let a = o.name, p = i.body.find(
253
- (d) => c.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === a)
252
+ let l = o.name, p = r.body.find(
253
+ (d) => c.isImportDeclaration(d) && d.specifiers.find((m) => m.local.name === l)
254
254
  );
255
255
  if (p) {
256
256
  let { source: d } = p;
257
257
  c.isStringLiteral(d) && (this._rawComponentPath = d.value);
258
258
  }
259
259
  }
260
- let { code: l } = de.print(r.value, {});
261
- t.component = l;
262
- } else if (r.key.name === "tags") {
263
- let o = r.value;
260
+ let { code: a } = de.print(i.value, {});
261
+ t.component = a;
262
+ } else if (i.key.name === "tags") {
263
+ let o = i.value;
264
264
  c.isIdentifier(o) && (o = P(o.name, this._ast.program)), t.tags = le(o);
265
- } else if (r.key.name === "id")
266
- if (c.isStringLiteral(r.value))
267
- t.id = r.value.value;
265
+ } else if (i.key.name === "id")
266
+ if (c.isStringLiteral(i.value))
267
+ t.id = i.value.value;
268
268
  else
269
- throw new Error(`Unexpected component id: ${r.value}`);
269
+ throw new Error(`Unexpected component id: ${i.value}`);
270
270
  }
271
271
  }), this._meta = t;
272
272
  }
273
273
  getStoryExport(e) {
274
- let i = this._storyExports[e];
275
- if (i = c.isVariableDeclarator(i) ? i.init : i, c.isCallExpression(i)) {
276
- let { callee: t, arguments: r } = i;
277
- if (c.isMemberExpression(t) && c.isIdentifier(t.object) && c.isIdentifier(t.property) && t.property.name === "bind" && (r.length === 0 ||
278
- r.length === 1 && c.isObjectExpression(r[0]) && r[0].properties.length === 0)) {
274
+ let r = this._storyExports[e];
275
+ if (r = c.isVariableDeclarator(r) ? r.init : r, c.isCallExpression(r)) {
276
+ let { callee: t, arguments: i } = r;
277
+ if (c.isMemberExpression(t) && c.isIdentifier(t.object) && c.isIdentifier(t.property) && t.property.name === "bind" && (i.length === 0 ||
278
+ i.length === 1 && c.isObjectExpression(i[0]) && i[0].properties.length === 0)) {
279
279
  let { name: o } = t.object;
280
- i = this._templates[o];
280
+ r = this._templates[o];
281
281
  }
282
282
  }
283
- return i;
283
+ return r;
284
284
  }
285
285
  parse() {
286
286
  let e = this;
287
287
  if (Ge(this._ast, {
288
288
  ExportDefaultDeclaration: {
289
289
  enter(t) {
290
- let { node: r, parent: o } = t, l = c.isIdentifier(r.declaration) && c.isProgram(o);
291
- if (e._options.transformInlineMeta && !l && c.isExpression(r.declaration)) {
290
+ let { node: i, parent: o } = t, a = c.isIdentifier(i.declaration) && c.isProgram(o);
291
+ if (e._options.transformInlineMeta && !a && c.isExpression(i.declaration)) {
292
292
  let d = t.scope.generateUidIdentifier("meta");
293
293
  e._metaVariableName = d.name;
294
- let g = [
295
- c.variableDeclaration("const", [c.variableDeclarator(d, r.declaration)]),
294
+ let m = [
295
+ c.variableDeclaration("const", [c.variableDeclarator(d, i.declaration)]),
296
296
  c.exportDefaultDeclaration(d)
297
297
  ];
298
- g.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(g);
298
+ m.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(m);
299
299
  return;
300
300
  }
301
- let a, p;
302
- if (l) {
303
- let d = r.declaration.name;
301
+ let l, p;
302
+ if (a) {
303
+ let d = i.declaration.name;
304
304
  e._metaVariableName = d;
305
- let g = /* @__PURE__ */ f((x) => c.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
305
+ let m = /* @__PURE__ */ f((x) => c.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
306
306
  e._metaStatement = e._ast.program.body.find(
307
- (x) => c.isVariableDeclaration(x) && x.declarations.find(g)
307
+ (x) => c.isVariableDeclaration(x) && x.declarations.find(m)
308
308
  ), p = (e?._metaStatement?.declarations || []).find(
309
- g
309
+ m
310
310
  )?.init;
311
311
  } else
312
- e._metaStatement = r, p = r.declaration;
313
- if (c.isObjectExpression(p) ? a = p : (
312
+ e._metaStatement = i, p = i.declaration;
313
+ if (c.isObjectExpression(p) ? l = p : (
314
314
  // export default { ... } as Meta<...>
315
- (c.isTSAsExpression(p) || c.isTSSatisfiesExpression(p)) && c.isObjectExpression(p.expression) && (a = p.expression)
316
- ), a && c.isProgram(o) && e._parseMeta(a, o), e._metaStatement && !e._metaNode)
315
+ (c.isTSAsExpression(p) || c.isTSSatisfiesExpression(p)) && c.isObjectExpression(p.expression) && (l = p.expression)
316
+ ), l && c.isProgram(o) && e._parseMeta(l, o), e._metaStatement && !e._metaNode)
317
317
  throw new q(
318
318
  "default export must be an object",
319
319
  e._metaStatement,
@@ -324,23 +324,23 @@ var I = /* @__PURE__ */ f((s, e) => {
324
324
  },
325
325
  ExportNamedDeclaration: {
326
326
  enter(t) {
327
- let { node: r, parent: o } = t, l;
328
- c.isVariableDeclaration(r.declaration) ? l = r.declaration.declarations.filter((a) => c.isVariableDeclarator(a)) : c.isFunctionDeclaration(
329
- r.declaration) && (l = [r.declaration]), l ? l.forEach((a) => {
330
- if (c.isIdentifier(a.id)) {
331
- let p = !1, { name: d } = a.id;
332
- if (d === "__namedExportsOrder" && c.isVariableDeclarator(a)) {
333
- e._namedExportsOrder = He(a.init);
327
+ let { node: i, parent: o } = t, a;
328
+ c.isVariableDeclaration(i.declaration) ? a = i.declaration.declarations.filter((l) => c.isVariableDeclarator(l)) : c.isFunctionDeclaration(
329
+ i.declaration) && (a = [i.declaration]), a ? a.forEach((l) => {
330
+ if (c.isIdentifier(l.id)) {
331
+ let p = !1, { name: d } = l.id;
332
+ if (d === "__namedExportsOrder" && c.isVariableDeclarator(l)) {
333
+ e._namedExportsOrder = He(l.init);
334
334
  return;
335
335
  }
336
- e._storyExports[d] = a, e._storyPaths[d] = t, e._storyStatements[d] = r;
337
- let g = oe(d);
336
+ e._storyExports[d] = l, e._storyPaths[d] = t, e._storyStatements[d] = i;
337
+ let m = oe(d);
338
338
  e._storyAnnotations[d] ? ae.warn(
339
339
  `Unexpected annotations for "${d}" before story declaration`
340
340
  ) : e._storyAnnotations[d] = {};
341
341
  let x;
342
- if (c.isVariableDeclarator(a) ? x = c.isTSAsExpression(a.init) || c.isTSSatisfiesExpression(a.init) ? a.init.expression : a.init :
343
- x = a, c.isCallExpression(x) && c.isMemberExpression(x.callee) && c.isIdentifier(x.callee.property) && x.callee.property.name ===
342
+ if (c.isVariableDeclarator(l) ? x = c.isTSAsExpression(l.init) || c.isTSSatisfiesExpression(l.init) ? l.init.expression : l.init :
343
+ x = l, c.isCallExpression(x) && c.isMemberExpression(x.callee) && c.isIdentifier(x.callee.property) && x.callee.property.name ===
344
344
  "story" && (p = !0, x = x.arguments[0]), e._metaIsFactory && !p)
345
345
  throw new B(
346
346
  "expected factory story",
@@ -367,86 +367,90 @@ var I = /* @__PURE__ */ f((s, e) => {
367
367
  e
368
368
  );
369
369
  else if (y.key.name === "name" && c.isStringLiteral(y.value))
370
- g = y.value.value;
370
+ m = y.value.value;
371
371
  else if (y.key.name === "storyName" && c.isStringLiteral(y.value))
372
372
  ae.warn(
373
373
  `Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
374
374
  );
375
375
  else if (y.key.name === "parameters" && c.isObjectExpression(y.value)) {
376
- let h = y.value.properties.find(
376
+ let E = y.value.properties.find(
377
377
  (D) => c.isObjectProperty(D) && c.isIdentifier(D.key) && D.key.name === "__id"
378
378
  );
379
- h && (b.__id = h.value.value);
379
+ E && (b.__id = E.value.value);
380
380
  }
381
381
  e._storyAnnotations[d][y.key.name] = y.value;
382
382
  }
383
383
  })) : b.__isArgsStory = ce(x, o, e), e._stories[d] = {
384
384
  id: "FIXME",
385
- name: g,
385
+ name: m,
386
386
  parameters: b,
387
387
  __stats: {
388
388
  factory: p
389
389
  }
390
390
  };
391
391
  }
392
- }) : r.specifiers.length > 0 && r.specifiers.forEach((a) => {
393
- if (c.isExportSpecifier(a) && c.isIdentifier(a.exported)) {
394
- let { name: p } = a.exported, { name: d } = a.local, g = c.isProgram(o) ? P(a.local.name, o) : a.local;
392
+ }) : i.specifiers.length > 0 && i.specifiers.forEach((l) => {
393
+ if (c.isExportSpecifier(l) && c.isIdentifier(l.exported)) {
394
+ let { name: p } = l.exported, { name: d } = l.local, m = c.isProgram(o) ? P(d, o) : l.local;
395
395
  if (p === "default") {
396
396
  let x;
397
- c.isObjectExpression(g) ? x = g : (
397
+ c.isObjectExpression(m) ? x = m : (
398
398
  // export default { ... } as Meta<...>
399
- c.isTSAsExpression(g) && c.isObjectExpression(g.expression) && (x = g.expression)
399
+ c.isTSAsExpression(m) && c.isObjectExpression(m.expression) && (x = m.expression)
400
400
  ), x && c.isProgram(o) && e._parseMeta(x, o);
401
- } else
402
- e._storyAnnotations[p] = {}, e._storyStatements[p] = g, e._storyPaths[p] = t, e._stories[p] = {
401
+ } else {
402
+ let x = {}, b = m;
403
+ c.isObjectExpression(b) && b.properties.forEach((y) => {
404
+ c.isIdentifier(y.key) && (x[y.key.name] = y.value);
405
+ }), e._storyAnnotations[p] = x, e._storyStatements[p] = m, e._storyPaths[p] = t, e._stories[p] = {
403
406
  id: "FIXME",
404
407
  name: p,
405
408
  localName: d,
406
409
  parameters: {},
407
410
  __stats: {}
408
411
  };
412
+ }
409
413
  }
410
414
  });
411
415
  }
412
416
  },
413
417
  ExpressionStatement: {
414
- enter({ node: t, parent: r }) {
418
+ enter({ node: t, parent: i }) {
415
419
  let { expression: o } = t;
416
- if (c.isProgram(r) && c.isAssignmentExpression(o) && c.isMemberExpression(o.left) && c.isIdentifier(o.left.object) && c.isIdentifier(
420
+ if (c.isProgram(i) && c.isAssignmentExpression(o) && c.isMemberExpression(o.left) && c.isIdentifier(o.left.object) && c.isIdentifier(
417
421
  o.left.property)) {
418
- let l = o.left.object.name, a = o.left.property.name, p = o.right;
419
- if (e._storyAnnotations[l] && (a === "story" && c.isObjectExpression(p) ? p.properties.forEach((d) => {
420
- c.isIdentifier(d.key) && (e._storyAnnotations[l][d.key.name] = d.value);
421
- }) : e._storyAnnotations[l][a] = p), a === "storyName" && c.isStringLiteral(p)) {
422
- let d = p.value, g = e._stories[l];
423
- if (!g)
422
+ let a = o.left.object.name, l = o.left.property.name, p = o.right;
423
+ if (e._storyAnnotations[a] && (l === "story" && c.isObjectExpression(p) ? p.properties.forEach((d) => {
424
+ c.isIdentifier(d.key) && (e._storyAnnotations[a][d.key.name] = d.value);
425
+ }) : e._storyAnnotations[a][l] = p), l === "storyName" && c.isStringLiteral(p)) {
426
+ let d = p.value, m = e._stories[a];
427
+ if (!m)
424
428
  return;
425
- g.name = d;
429
+ m.name = d;
426
430
  }
427
431
  }
428
432
  }
429
433
  },
430
434
  CallExpression: {
431
435
  enter(t) {
432
- let { node: r } = t, { callee: o } = r;
436
+ let { node: i } = t, { callee: o } = i;
433
437
  if (c.isIdentifier(o) && o.name === "storiesOf")
434
438
  throw new Error(O.dedent`
435
- Unexpected \`storiesOf\` usage: ${I(r, e._options.fileName)}.
439
+ Unexpected \`storiesOf\` usage: ${v(i, e._options.fileName)}.
436
440
 
437
441
  SB8 does not support \`storiesOf\`.
438
442
  `);
439
- if (c.isMemberExpression(o) && c.isIdentifier(o.property) && o.property.name === "meta" && c.isIdentifier(o.object) && r.arguments.
443
+ if (c.isMemberExpression(o) && c.isIdentifier(o.property) && o.property.name === "meta" && c.isIdentifier(o.object) && i.arguments.
440
444
  length > 0) {
441
- let a = t.scope.getBinding(o.object.name)?.path?.parentPath?.node;
442
- if (c.isImportDeclaration(a))
443
- if (Ke(a.source.value)) {
444
- let p = r.arguments[0];
445
+ let l = t.scope.getBinding(o.object.name)?.path?.parentPath?.node;
446
+ if (c.isImportDeclaration(l))
447
+ if (Ke(l.source.value)) {
448
+ let p = i.arguments[0];
445
449
  e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
446
450
  } else
447
451
  throw new W(
448
452
  "meta() factory must be imported from .storybook/preview configuration",
449
- a,
453
+ l,
450
454
  e._options.fileName
451
455
  );
452
456
  }
@@ -454,37 +458,37 @@ var I = /* @__PURE__ */ f((s, e) => {
454
458
  },
455
459
  ImportDeclaration: {
456
460
  enter({ node: t }) {
457
- let { source: r } = t;
458
- if (c.isStringLiteral(r))
459
- e.imports.push(r.value);
461
+ let { source: i } = t;
462
+ if (c.isStringLiteral(i))
463
+ e.imports.push(i.value);
460
464
  else
461
465
  throw new Error("CSF: unexpected import source");
462
466
  }
463
467
  }
464
468
  }), !e._meta)
465
469
  throw new q("missing default export", e._ast, e._options.fileName);
466
- let i = Object.entries(e._stories);
470
+ let r = Object.entries(e._stories);
467
471
  if (e._meta.title = this._options.makeTitle(e._meta?.title), e._metaAnnotations.play && (e._meta.tags = [...e._meta.tags || [], "play-fn"]),
468
- e._stories = i.reduce(
469
- (t, [r, o]) => {
470
- if (!ne(r, e._meta))
472
+ e._stories = r.reduce(
473
+ (t, [i, o]) => {
474
+ if (!ne(i, e._meta))
471
475
  return t;
472
- let l = o.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, oe(r)), a = { ...o.parameters, __id: l }, { includeStories: p } = e.
476
+ let a = o.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, oe(i)), l = { ...o.parameters, __id: a }, { includeStories: p } = e.
473
477
  _meta || {};
474
- r === "__page" && (i.length === 1 || Array.isArray(p) && p.length === 1) && (a.docsOnly = !0), t[r] = { ...o, id: l, parameters: a };
475
- let d = e._storyAnnotations[r], { tags: g, play: x } = d;
476
- if (g) {
477
- let h = c.isIdentifier(g) ? P(g.name, this._ast.program) : g;
478
- t[r].tags = le(h);
478
+ i === "__page" && (r.length === 1 || Array.isArray(p) && p.length === 1) && (l.docsOnly = !0), t[i] = { ...o, id: a, parameters: l };
479
+ let d = e._storyAnnotations[i], { tags: m, play: x } = d;
480
+ if (m) {
481
+ let E = c.isIdentifier(m) ? P(m.name, this._ast.program) : m;
482
+ t[i].tags = le(E);
479
483
  }
480
- x && (t[r].tags = [...t[r].tags || [], "play-fn"]);
481
- let b = t[r].__stats;
482
- ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((h) => {
483
- b[h] = !!d[h] || !!e._metaAnnotations[h];
484
+ x && (t[i].tags = [...t[i].tags || [], "play-fn"]);
485
+ let b = t[i].__stats;
486
+ ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((E) => {
487
+ b[E] = !!d[E] || !!e._metaAnnotations[E];
484
488
  });
485
- let y = e.getStoryExport(r);
489
+ let y = e.getStoryExport(i);
486
490
  return b.storyFn = !!(c.isArrowFunctionExpression(y) || c.isFunctionDeclaration(y)), b.mount = Ye(d.play ?? e._metaAnnotations.play),
487
- b.moduleMock = !!e.imports.find((h) => Qe(h)), t;
491
+ b.moduleMock = !!e.imports.find((E) => Qe(E)), t;
488
492
  },
489
493
  {}
490
494
  ), Object.keys(e._storyExports).forEach((t) => {
@@ -492,11 +496,11 @@ var I = /* @__PURE__ */ f((s, e) => {
492
496
  }), e._namedExportsOrder) {
493
497
  let t = Object.keys(e._storyExports);
494
498
  e._storyExports = pe(e._storyExports, e._namedExportsOrder), e._stories = pe(e._stories, e._namedExportsOrder);
495
- let r = Object.keys(e._storyExports);
496
- if (t.length !== r.length)
499
+ let i = Object.keys(e._storyExports);
500
+ if (t.length !== i.length)
497
501
  throw new Error(
498
502
  `Missing exports after sort: ${t.filter(
499
- (o) => !r.includes(o)
503
+ (o) => !i.includes(o)
500
504
  )}`
501
505
  );
502
506
  }
@@ -515,17 +519,17 @@ var I = /* @__PURE__ */ f((s, e) => {
515
519
  O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
516
520
  Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
517
521
  );
518
- return Object.entries(this._stories).map(([i, t]) => {
519
- let r = [...this._meta?.tags ?? [], ...t.tags ?? []];
522
+ return Object.entries(this._stories).map(([r, t]) => {
523
+ let i = [...this._meta?.tags ?? [], ...t.tags ?? []];
520
524
  return {
521
525
  type: "story",
522
526
  importPath: e,
523
527
  rawComponentPath: this._rawComponentPath,
524
- exportName: i,
528
+ exportName: r,
525
529
  name: t.name,
526
530
  title: this.meta?.title,
527
531
  metaId: this.meta?.id,
528
- tags: r,
532
+ tags: i,
529
533
  __id: t.id,
530
534
  __stats: t.__stats
531
535
  };
@@ -534,16 +538,16 @@ var I = /* @__PURE__ */ f((s, e) => {
534
538
  }, et = /* @__PURE__ */ f(({
535
539
  code: s,
536
540
  filename: e = "",
537
- ast: i
538
- }) => new Be({ filename: e }, { code: s, ast: i ?? fe(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
539
- let i = fe(s), t = et({ code: s, filename: e.fileName, ast: i });
540
- return new J(i, e, t);
541
- }, "loadCsf"), me = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, i) => {
542
- let t = We(s._ast, e, i);
541
+ ast: r
542
+ }) => new Be({ filename: e }, { code: s, ast: r ?? fe(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
543
+ let r = fe(s), t = et({ code: s, filename: e.fileName, ast: r });
544
+ return new J(r, e, t);
545
+ }, "loadCsf"), ue = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, r) => {
546
+ let t = We(s._ast, e, r);
543
547
  return e.sourceMaps ? t : t.code;
544
548
  }, "formatCsf"), tt = /* @__PURE__ */ f((s, e = {}) => de.print(s._ast, e), "printCsf"), Ft = /* @__PURE__ */ f(async (s, e) => {
545
- let i = (await Ue(s, "utf-8")).toString();
546
- return Q(i, { ...e, fileName: s });
549
+ let r = (await Ue(s, "utf-8")).toString();
550
+ return Q(r, { ...e, fileName: s });
547
551
  }, "readCsf"), Ct = /* @__PURE__ */ f(async (s, e) => {
548
552
  if (!(e || s._options.fileName))
549
553
  throw new Error("Please specify a fileName for writeCsf");
@@ -555,7 +559,7 @@ var ye = U(V(), 1);
555
559
  import { readFile as rt, writeFile as it } from "node:fs/promises";
556
560
  import {
557
561
  babelParse as xe,
558
- generate as ue,
562
+ generate as me,
559
563
  recast as st,
560
564
  types as n,
561
565
  traverse as ge
@@ -563,66 +567,66 @@ import {
563
567
  var H = console, Y = /* @__PURE__ */ f(({
564
568
  expectedType: s,
565
569
  foundType: e,
566
- node: i
570
+ node: r
567
571
  }) => ye.dedent`
568
- CSF Parsing error: Expected '${s}' but found '${e}' instead in '${i?.type}'.
572
+ CSF Parsing error: Expected '${s}' but found '${e}' instead in '${r?.type}'.
569
573
  `, "getCsfParsingErrorMessage"), w = /* @__PURE__ */ f((s) => n.isIdentifier(s.key) ? s.key.name : n.isStringLiteral(s.key) ? s.key.value :
570
574
  null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSatisfiesExpression(s) ? G(s.expression) : s, "unwrap"), be = /* @__PURE__ */ f(
571
575
  (s, e) => {
572
576
  if (s.length === 0)
573
577
  return e;
574
578
  if (n.isObjectExpression(e)) {
575
- let [i, ...t] = s, r = e.properties.find((o) => w(o) === i);
576
- if (r)
577
- return be(t, r.value);
579
+ let [r, ...t] = s, i = e.properties.find((o) => w(o) === r);
580
+ if (i)
581
+ return be(t, i.value);
578
582
  }
579
- }, "_getPath"), Ee = /* @__PURE__ */ f((s, e) => {
583
+ }, "_getPath"), he = /* @__PURE__ */ f((s, e) => {
580
584
  if (s.length === 0) {
581
585
  if (n.isObjectExpression(e))
582
586
  return e.properties;
583
587
  throw new Error("Expected object expression");
584
588
  }
585
589
  if (n.isObjectExpression(e)) {
586
- let [i, ...t] = s, r = e.properties.find((o) => w(o) === i);
587
- if (r)
588
- return t.length === 0 ? e.properties : Ee(t, r.value);
590
+ let [r, ...t] = s, i = e.properties.find((o) => w(o) === r);
591
+ if (i)
592
+ return t.length === 0 ? e.properties : he(t, i.value);
589
593
  }
590
594
  }, "_getPathProperties"), z = /* @__PURE__ */ f((s, e) => {
591
- let i = null, t = null;
592
- return e.body.find((r) => (n.isVariableDeclaration(r) ? t = r.declarations : n.isExportNamedDeclaration(r) && n.isVariableDeclaration(r.declaration) &&
593
- (t = r.declaration.declarations), t && t.find((o) => n.isVariableDeclarator(o) && n.isIdentifier(o.id) && o.id.name === s ? (i = o, !0) : !1))),
594
- i;
595
+ let r = null, t = null;
596
+ return e.body.find((i) => (n.isVariableDeclaration(i) ? t = i.declarations : n.isExportNamedDeclaration(i) && n.isVariableDeclaration(i.declaration) &&
597
+ (t = i.declaration.declarations), t && t.find((o) => n.isVariableDeclarator(o) && n.isIdentifier(o.id) && o.id.name === s ? (r = o, !0) : !1))),
598
+ r;
595
599
  }, "_findVarDeclarator"), N = /* @__PURE__ */ f((s, e) => z(s, e)?.init, "_findVarInitialization"), R = /* @__PURE__ */ f((s, e) => {
596
600
  if (s.length === 0)
597
601
  return e;
598
- let [i, ...t] = s, r = R(t, e);
599
- return n.objectExpression([n.objectProperty(n.identifier(i), r)]);
600
- }, "_makeObjectExpression"), $ = /* @__PURE__ */ f((s, e, i) => {
601
- let [t, ...r] = s, o = i.properties.find(
602
- (l) => w(l) === t
602
+ let [r, ...t] = s, i = R(t, e);
603
+ return n.objectExpression([n.objectProperty(n.identifier(r), i)]);
604
+ }, "_makeObjectExpression"), $ = /* @__PURE__ */ f((s, e, r) => {
605
+ let [t, ...i] = s, o = r.properties.find(
606
+ (a) => w(a) === t
603
607
  );
604
- o ? n.isObjectExpression(o.value) && r.length > 0 ? $(r, e, o.value) : o.value = R(r, e) : i.properties.push(
605
- n.objectProperty(n.identifier(t), R(r, e))
608
+ o ? n.isObjectExpression(o.value) && i.length > 0 ? $(i, e, o.value) : o.value = R(i, e) : r.properties.push(
609
+ n.objectProperty(n.identifier(t), R(i, e))
606
610
  );
607
611
  }, "_updateExportNode"), Z = class {
608
- constructor(e, i, t) {
612
+ constructor(e, r, t) {
609
613
  this._exports = {};
610
614
  // FIXME: this is a hack. this is only used in the case where the user is
611
615
  // modifying a named export that's a scalar. The _exports map is not suitable
612
616
  // for that. But rather than refactor the whole thing, we just use this as a stopgap.
613
617
  this._exportDecls = {};
614
618
  this.hasDefaultExport = !1;
615
- this._ast = e, this._code = i, this.fileName = t;
619
+ this._ast = e, this._code = r, this.fileName = t;
616
620
  }
617
621
  static {
618
622
  f(this, "ConfigFile");
619
623
  }
620
624
  _parseExportsObject(e) {
621
- this._exportsObject = e, e.properties.forEach((i) => {
622
- let t = w(i);
625
+ this._exportsObject = e, e.properties.forEach((r) => {
626
+ let t = w(r);
623
627
  if (t) {
624
- let r = i.value;
625
- n.isIdentifier(r) && (r = N(r.name, this._ast.program)), this._exports[t] = r;
628
+ let i = r.value;
629
+ n.isIdentifier(i) && (i = N(i.name, this._ast.program)), this._exports[t] = i;
626
630
  }
627
631
  });
628
632
  }
@@ -630,59 +634,59 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
630
634
  let e = this;
631
635
  return ge(this._ast, {
632
636
  ExportDefaultDeclaration: {
633
- enter({ node: i, parent: t }) {
637
+ enter({ node: r, parent: t }) {
634
638
  e.hasDefaultExport = !0;
635
- let r = n.isIdentifier(i.declaration) && n.isProgram(t) ? N(i.declaration.name, t) : i.declaration;
636
- r = G(r), n.isCallExpression(r) && n.isObjectExpression(r.arguments[0]) && (r = r.arguments[0]), n.isObjectExpression(r) ? e._parseExportsObject(
637
- r) : H.warn(
639
+ let i = n.isIdentifier(r.declaration) && n.isProgram(t) ? N(r.declaration.name, t) : r.declaration;
640
+ i = G(i), n.isCallExpression(i) && n.isObjectExpression(i.arguments[0]) && (i = i.arguments[0]), n.isObjectExpression(i) ? e._parseExportsObject(
641
+ i) : H.warn(
638
642
  Y({
639
643
  expectedType: "ObjectExpression",
640
- foundType: r?.type,
641
- node: r || i.declaration
644
+ foundType: i?.type,
645
+ node: i || r.declaration
642
646
  })
643
647
  );
644
648
  }
645
649
  },
646
650
  ExportNamedDeclaration: {
647
- enter({ node: i, parent: t }) {
648
- if (n.isVariableDeclaration(i.declaration))
649
- i.declaration.declarations.forEach((r) => {
650
- if (n.isVariableDeclarator(r) && n.isIdentifier(r.id)) {
651
- let { name: o } = r.id, l = r.init;
652
- n.isIdentifier(l) && (l = N(l.name, t)), e._exports[o] = l, e._exportDecls[o] = r;
651
+ enter({ node: r, parent: t }) {
652
+ if (n.isVariableDeclaration(r.declaration))
653
+ r.declaration.declarations.forEach((i) => {
654
+ if (n.isVariableDeclarator(i) && n.isIdentifier(i.id)) {
655
+ let { name: o } = i.id, a = i.init;
656
+ n.isIdentifier(a) && (a = N(a.name, t)), e._exports[o] = a, e._exportDecls[o] = i;
653
657
  }
654
658
  });
655
- else if (n.isFunctionDeclaration(i.declaration)) {
656
- let r = i.declaration;
657
- if (n.isIdentifier(r.id)) {
658
- let { name: o } = r.id;
659
- e._exportDecls[o] = r;
659
+ else if (n.isFunctionDeclaration(r.declaration)) {
660
+ let i = r.declaration;
661
+ if (n.isIdentifier(i.id)) {
662
+ let { name: o } = i.id;
663
+ e._exportDecls[o] = i;
660
664
  }
661
- } else i.specifiers ? i.specifiers.forEach((r) => {
662
- if (n.isExportSpecifier(r) && n.isIdentifier(r.local) && n.isIdentifier(r.exported)) {
663
- let { name: o } = r.local, { name: l } = r.exported, a = z(o, t);
664
- a && (e._exports[l] = a.init, e._exportDecls[l] = a);
665
+ } else r.specifiers ? r.specifiers.forEach((i) => {
666
+ if (n.isExportSpecifier(i) && n.isIdentifier(i.local) && n.isIdentifier(i.exported)) {
667
+ let { name: o } = i.local, { name: a } = i.exported, l = z(o, t);
668
+ l && (e._exports[a] = l.init, e._exportDecls[a] = l);
665
669
  }
666
670
  }) : H.warn(
667
671
  Y({
668
672
  expectedType: "VariableDeclaration",
669
- foundType: i.declaration?.type,
670
- node: i.declaration
673
+ foundType: r.declaration?.type,
674
+ node: r.declaration
671
675
  })
672
676
  );
673
677
  }
674
678
  },
675
679
  ExpressionStatement: {
676
- enter({ node: i, parent: t }) {
677
- if (n.isAssignmentExpression(i.expression) && i.expression.operator === "=") {
678
- let { left: r, right: o } = i.expression;
679
- if (n.isMemberExpression(r) && n.isIdentifier(r.object) && r.object.name === "module" && n.isIdentifier(r.property) && r.property.
680
+ enter({ node: r, parent: t }) {
681
+ if (n.isAssignmentExpression(r.expression) && r.expression.operator === "=") {
682
+ let { left: i, right: o } = r.expression;
683
+ if (n.isMemberExpression(i) && n.isIdentifier(i.object) && i.object.name === "module" && n.isIdentifier(i.property) && i.property.
680
684
  name === "exports") {
681
- let l = o;
682
- n.isIdentifier(o) && (l = N(o.name, t)), l = G(l), n.isObjectExpression(l) ? (e._exportsObject = l, l.properties.forEach((a) => {
683
- let p = w(a);
685
+ let a = o;
686
+ n.isIdentifier(o) && (a = N(o.name, t)), a = G(a), n.isObjectExpression(a) ? (e._exportsObject = a, a.properties.forEach((l) => {
687
+ let p = w(l);
684
688
  if (p) {
685
- let d = a.value;
689
+ let d = l.value;
686
690
  n.isIdentifier(d) && (d = N(
687
691
  d.name,
688
692
  t
@@ -691,8 +695,8 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
691
695
  })) : H.warn(
692
696
  Y({
693
697
  expectedType: "ObjectExpression",
694
- foundType: l?.type,
695
- node: l
698
+ foundType: a?.type,
699
+ node: a
696
700
  })
697
701
  );
698
702
  }
@@ -700,27 +704,27 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
700
704
  }
701
705
  },
702
706
  CallExpression: {
703
- enter: /* @__PURE__ */ f(({ node: i }) => {
704
- n.isIdentifier(i.callee) && i.callee.name === "definePreview" && i.arguments.length === 1 && n.isObjectExpression(i.arguments[0]) &&
705
- e._parseExportsObject(i.arguments[0]);
707
+ enter: /* @__PURE__ */ f(({ node: r }) => {
708
+ n.isIdentifier(r.callee) && r.callee.name === "definePreview" && r.arguments.length === 1 && n.isObjectExpression(r.arguments[0]) &&
709
+ e._parseExportsObject(r.arguments[0]);
706
710
  }, "enter")
707
711
  }
708
712
  }), e;
709
713
  }
710
714
  getFieldNode(e) {
711
- let [i, ...t] = e, r = this._exports[i];
712
- if (r)
713
- return be(t, r);
715
+ let [r, ...t] = e, i = this._exports[r];
716
+ if (i)
717
+ return be(t, i);
714
718
  }
715
719
  getFieldProperties(e) {
716
- let [i, ...t] = e, r = this._exports[i];
717
- if (r)
718
- return Ee(t, r);
720
+ let [r, ...t] = e, i = this._exports[r];
721
+ if (i)
722
+ return he(t, i);
719
723
  }
720
724
  getFieldValue(e) {
721
- let i = this.getFieldNode(e);
722
- if (i) {
723
- let { code: t } = ue(i, {});
725
+ let r = this.getFieldNode(e);
726
+ if (r) {
727
+ let { code: t } = me(r, {});
724
728
  return (0, eval)(`(() => (${t}))()`);
725
729
  }
726
730
  }
@@ -730,32 +734,32 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
730
734
  } catch {
731
735
  }
732
736
  }
733
- setFieldNode(e, i) {
734
- let [t, ...r] = e, o = this._exports[t];
737
+ setFieldNode(e, r) {
738
+ let [t, ...i] = e, o = this._exports[t];
735
739
  if (this._exportsObject) {
736
740
  let p = this._exportsObject.properties.find((d) => w(d) === t);
737
741
  if (p && n.isIdentifier(p.value)) {
738
742
  let d = z(p.value.name, this._ast.program);
739
743
  if (d && n.isObjectExpression(d.init)) {
740
- $(r, i, d.init);
744
+ $(i, r, d.init);
741
745
  return;
742
746
  }
743
747
  }
744
- $(e, i, this._exportsObject), this._exports[e[0]] = i;
748
+ $(e, r, this._exportsObject), this._exports[e[0]] = r;
745
749
  return;
746
750
  }
747
- if (o && n.isObjectExpression(o) && r.length > 0) {
748
- $(r, i, o);
751
+ if (o && n.isObjectExpression(o) && i.length > 0) {
752
+ $(i, r, o);
749
753
  return;
750
754
  }
751
- let l = z(t, this._ast.program);
752
- if (l && n.isObjectExpression(l.init)) {
753
- $(r, i, l.init);
755
+ let a = z(t, this._ast.program);
756
+ if (a && n.isObjectExpression(a.init)) {
757
+ $(i, r, a.init);
754
758
  return;
755
759
  }
756
- if (o && r.length === 0 && this._exportDecls[e[0]]) {
757
- let a = this._exportDecls[e[0]];
758
- n.isVariableDeclarator(a) && (a.init = R([], i));
760
+ if (o && i.length === 0 && this._exportDecls[e[0]]) {
761
+ let l = this._exportDecls[e[0]];
762
+ n.isVariableDeclarator(l) && (l.init = R([], r));
759
763
  } else {
760
764
  if (this.hasDefaultExport)
761
765
  throw new Error(
@@ -764,10 +768,10 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
764
768
  )}" field as the default export is not an object in this file.`
765
769
  );
766
770
  {
767
- let a = R(r, i), p = n.exportNamedDeclaration(
768
- n.variableDeclaration("const", [n.variableDeclarator(n.identifier(t), a)])
771
+ let l = R(i, r), p = n.exportNamedDeclaration(
772
+ n.variableDeclaration("const", [n.variableDeclarator(n.identifier(t), l)])
769
773
  );
770
- this._exports[t] = a, this._ast.program.body.push(p);
774
+ this._exports[t] = l, this._ast.program.body.push(p);
771
775
  }
772
776
  }
773
777
  }
@@ -783,9 +787,9 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
783
787
  * @returns The name of a node in a given path, supporting the following formats:
784
788
  */
785
789
  getNameFromPath(e) {
786
- let i = this.getFieldNode(e);
787
- if (i)
788
- return this._getPresetValue(i, "name");
790
+ let r = this.getFieldNode(e);
791
+ if (r)
792
+ return this._getPresetValue(r, "name");
789
793
  }
790
794
  /**
791
795
  * Returns an array of names of a node in a given path, supporting the following formats:
@@ -801,19 +805,19 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
801
805
  * ```
802
806
  */
803
807
  getNamesFromPath(e) {
804
- let i = this.getFieldNode(e);
805
- if (!i)
808
+ let r = this.getFieldNode(e);
809
+ if (!r)
806
810
  return;
807
811
  let t = [];
808
- return n.isArrayExpression(i) && i.elements.forEach((r) => {
809
- t.push(this._getPresetValue(r, "name"));
812
+ return n.isArrayExpression(r) && r.elements.forEach((i) => {
813
+ t.push(this._getPresetValue(i, "name"));
810
814
  }), t;
811
815
  }
812
816
  _getPnpWrappedValue(e) {
813
817
  if (n.isCallExpression(e)) {
814
- let i = e.arguments[0];
815
- if (n.isStringLiteral(i))
816
- return i.value;
818
+ let r = e.arguments[0];
819
+ if (n.isStringLiteral(r))
820
+ return r.value;
817
821
  }
818
822
  }
819
823
  /**
@@ -822,63 +826,63 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
822
826
  * 1. `{ node: 'value' }`
823
827
  * 2. `{ node: { fallbackProperty: 'value' } }`
824
828
  */
825
- _getPresetValue(e, i) {
829
+ _getPresetValue(e, r) {
826
830
  let t;
827
- if (n.isStringLiteral(e) ? t = e.value : n.isObjectExpression(e) ? e.properties.forEach((r) => {
828
- n.isObjectProperty(r) && n.isIdentifier(r.key) && r.key.name === i && (n.isStringLiteral(r.value) ? t = r.value.value : t = this._getPnpWrappedValue(
829
- r.value)), n.isObjectProperty(r) && n.isStringLiteral(r.key) && r.key.value === "name" && n.isStringLiteral(r.value) && (t = r.value.value);
831
+ if (n.isStringLiteral(e) ? t = e.value : n.isObjectExpression(e) ? e.properties.forEach((i) => {
832
+ n.isObjectProperty(i) && n.isIdentifier(i.key) && i.key.name === r && (n.isStringLiteral(i.value) ? t = i.value.value : t = this._getPnpWrappedValue(
833
+ i.value)), n.isObjectProperty(i) && n.isStringLiteral(i.key) && i.key.value === "name" && n.isStringLiteral(i.value) && (t = i.value.value);
830
834
  }) : n.isCallExpression(e) && (t = this._getPnpWrappedValue(e)), !t)
831
835
  throw new Error(
832
- `The given node must be a string literal or an object expression with a "${i}" property that is a string literal.`
836
+ `The given node must be a string literal or an object expression with a "${r}" property that is a string literal.`
833
837
  );
834
838
  return t;
835
839
  }
836
840
  removeField(e) {
837
- let i = /* @__PURE__ */ f((r, o) => {
838
- let l = r.findIndex(
839
- (a) => n.isIdentifier(a.key) && a.key.name === o || n.isStringLiteral(a.key) && a.key.value === o
841
+ let r = /* @__PURE__ */ f((i, o) => {
842
+ let a = i.findIndex(
843
+ (l) => n.isIdentifier(l.key) && l.key.name === o || n.isStringLiteral(l.key) && l.key.value === o
840
844
  );
841
- l >= 0 && r.splice(l, 1);
845
+ a >= 0 && i.splice(a, 1);
842
846
  }, "removeProperty");
843
847
  if (e.length === 1) {
844
- let r = !1;
848
+ let i = !1;
845
849
  if (this._ast.program.body.forEach((o) => {
846
850
  if (n.isExportNamedDeclaration(o) && n.isVariableDeclaration(o.declaration)) {
847
- let l = o.declaration.declarations[0];
848
- n.isIdentifier(l.id) && l.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), r = !0);
851
+ let a = o.declaration.declarations[0];
852
+ n.isIdentifier(a.id) && a.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), i = !0);
849
853
  }
850
854
  if (n.isExportDefaultDeclaration(o)) {
851
- let l = o.declaration;
852
- if (n.isIdentifier(l) && (l = N(l.name, this._ast.program)), l = G(l), n.isObjectExpression(l)) {
853
- let a = l.properties;
854
- i(a, e[0]), r = !0;
855
+ let a = o.declaration;
856
+ if (n.isIdentifier(a) && (a = N(a.name, this._ast.program)), a = G(a), n.isObjectExpression(a)) {
857
+ let l = a.properties;
858
+ r(l, e[0]), i = !0;
855
859
  }
856
860
  }
857
861
  if (n.isExpressionStatement(o) && n.isAssignmentExpression(o.expression) && n.isMemberExpression(o.expression.left) && n.isIdentifier(
858
862
  o.expression.left.object) && o.expression.left.object.name === "module" && n.isIdentifier(o.expression.left.property) && o.expression.
859
863
  left.property.name === "exports" && n.isObjectExpression(o.expression.right)) {
860
- let l = o.expression.right.properties;
861
- i(l, e[0]), r = !0;
864
+ let a = o.expression.right.properties;
865
+ r(a, e[0]), i = !0;
862
866
  }
863
- }), r)
867
+ }), i)
864
868
  return;
865
869
  }
866
870
  let t = this.getFieldProperties(e);
867
871
  if (t) {
868
- let r = e.at(-1);
869
- i(t, r);
872
+ let i = e.at(-1);
873
+ r(t, i);
870
874
  }
871
875
  }
872
- appendValueToArray(e, i) {
873
- let t = this.valueToNode(i);
876
+ appendValueToArray(e, r) {
877
+ let t = this.valueToNode(r);
874
878
  t && this.appendNodeToArray(e, t);
875
879
  }
876
- appendNodeToArray(e, i) {
880
+ appendNodeToArray(e, r) {
877
881
  let t = this.getFieldNode(e);
878
882
  if (!t)
879
- this.setFieldNode(e, n.arrayExpression([i]));
883
+ this.setFieldNode(e, n.arrayExpression([r]));
880
884
  else if (n.isArrayExpression(t))
881
- t.elements.push(i);
885
+ t.elements.push(r);
882
886
  else
883
887
  throw new Error(`Expected array at '${e.join(".")}', got '${t.type}'`);
884
888
  }
@@ -886,23 +890,23 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
886
890
  * Specialized helper to remove addons or other array entries that can either be strings or
887
891
  * objects with a name property.
888
892
  */
889
- removeEntryFromArray(e, i) {
893
+ removeEntryFromArray(e, r) {
890
894
  let t = this.getFieldNode(e);
891
895
  if (t)
892
896
  if (n.isArrayExpression(t)) {
893
- let r = t.elements.findIndex((o) => n.isStringLiteral(o) ? o.value === i : n.isObjectExpression(o) ? this._getPresetValue(o, "name") ===
894
- i : this._getPnpWrappedValue(o) === i);
895
- if (r >= 0)
896
- t.elements.splice(r, 1);
897
+ let i = t.elements.findIndex((o) => n.isStringLiteral(o) ? o.value === r : n.isObjectExpression(o) ? this._getPresetValue(o, "name") ===
898
+ r : this._getPnpWrappedValue(o) === r);
899
+ if (i >= 0)
900
+ t.elements.splice(i, 1);
897
901
  else
898
- throw new Error(`Could not find '${i}' in array at '${e.join(".")}'`);
902
+ throw new Error(`Could not find '${r}' in array at '${e.join(".")}'`);
899
903
  } else
900
904
  throw new Error(`Expected array at '${e.join(".")}', got '${t.type}'`);
901
905
  }
902
906
  _inferQuotes() {
903
907
  if (!this._quotes) {
904
908
  let e = (this._ast.tokens || []).slice(0, 500).reduce(
905
- (i, t) => (t.type.label === "string" && (i[this._code[t.start]] += 1), i),
909
+ (r, t) => (t.type.label === "string" && (r[this._code[t.start]] += 1), r),
906
910
  { "'": 0, '"': 0 }
907
911
  );
908
912
  this._quotes = e["'"] > e['"'] ? "single" : "double";
@@ -910,14 +914,14 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
910
914
  return this._quotes;
911
915
  }
912
916
  valueToNode(e) {
913
- let i = this._inferQuotes(), t;
914
- if (i === "single") {
915
- let { code: r } = ue(n.valueToNode(e), { jsescOption: { quotes: i } }), o = xe(`const __x = ${r}`);
917
+ let r = this._inferQuotes(), t;
918
+ if (r === "single") {
919
+ let { code: i } = me(n.valueToNode(e), { jsescOption: { quotes: r } }), o = xe(`const __x = ${i}`);
916
920
  ge(o, {
917
921
  VariableDeclaration: {
918
- enter({ node: l }) {
919
- l.declarations.length === 1 && n.isVariableDeclarator(l.declarations[0]) && n.isIdentifier(l.declarations[0].id) && l.declarations[0].
920
- id.name === "__x" && (t = l.declarations[0].init);
922
+ enter({ node: a }) {
923
+ a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.isIdentifier(a.declarations[0].id) && a.declarations[0].
924
+ id.name === "__x" && (t = a.declarations[0].init);
921
925
  }
922
926
  }
923
927
  });
@@ -925,10 +929,10 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
925
929
  t = n.valueToNode(e);
926
930
  return t;
927
931
  }
928
- setFieldValue(e, i) {
929
- let t = this.valueToNode(i);
932
+ setFieldValue(e, r) {
933
+ let t = this.valueToNode(r);
930
934
  if (!t)
931
- throw new Error(`Unexpected value ${JSON.stringify(i)}`);
935
+ throw new Error(`Unexpected value ${JSON.stringify(r)}`);
932
936
  this.setFieldNode(e, t);
933
937
  }
934
938
  getBodyDeclarations() {
@@ -954,40 +958,42 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
954
958
  * import will be set. Otherwise, an array of named imports will be set
955
959
  * @param fromImport - The module to import from
956
960
  */
957
- setRequireImport(e, i) {
958
- let t = this._ast.program.body.find(
959
- (l) => n.isVariableDeclaration(l) && l.declarations.length === 1 && n.isVariableDeclarator(l.declarations[0]) && n.isCallExpression(l.
960
- declarations[0].init) && n.isIdentifier(l.declarations[0].init.callee) && l.declarations[0].init.callee.name === "require" && n.isStringLiteral(
961
- l.declarations[0].init.arguments[0]) && l.declarations[0].init.arguments[0].value === i
962
- ), r = /* @__PURE__ */ f((l) => n.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
963
- (a) => n.isObjectProperty(a) && n.isIdentifier(a.key) && a.key.name === l
964
- ), "hasRequireSpecifier"), o = /* @__PURE__ */ f((l, a) => l.declarations.length === 1 && n.isVariableDeclarator(l.declarations[0]) && n.
965
- isIdentifier(l.declarations[0].id) && l.declarations[0].id.name === a, "hasDefaultRequireSpecifier");
961
+ setRequireImport(e, r) {
962
+ let t = this._ast.program.body.find((a) => {
963
+ let l = n.isVariableDeclaration(a) && a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.isCallExpression(a.
964
+ declarations[0].init) && n.isIdentifier(a.declarations[0].init.callee) && a.declarations[0].init.callee.name === "require" && n.isStringLiteral(
965
+ a.declarations[0].init.arguments[0]) && (a.declarations[0].init.arguments[0].value === r || a.declarations[0].init.arguments[0].value ===
966
+ r.split("node:")[1]);
967
+ return l && (r = a.declarations[0].init.arguments[0].value), l;
968
+ }), i = /* @__PURE__ */ f((a) => n.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
969
+ (l) => n.isObjectProperty(l) && n.isIdentifier(l.key) && l.key.name === a
970
+ ), "hasRequireSpecifier"), o = /* @__PURE__ */ f((a, l) => a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.
971
+ isIdentifier(a.declarations[0].id) && a.declarations[0].id.name === l, "hasDefaultRequireSpecifier");
966
972
  if (typeof e == "string") {
967
- let l = /* @__PURE__ */ f(() => {
973
+ let a = /* @__PURE__ */ f(() => {
968
974
  this._ast.program.body.unshift(
969
975
  n.variableDeclaration("const", [
970
976
  n.variableDeclarator(
971
977
  n.identifier(e),
972
- n.callExpression(n.identifier("require"), [n.stringLiteral(i)])
978
+ n.callExpression(n.identifier("require"), [n.stringLiteral(r)])
973
979
  )
974
980
  ])
975
981
  );
976
982
  }, "addDefaultRequireSpecifier");
977
- t && o(t, e) || l();
978
- } else t ? e.forEach((l) => {
979
- r(l) || t.declarations[0].id.properties.push(
980
- n.objectProperty(n.identifier(l), n.identifier(l), void 0, !0)
983
+ t && o(t, e) || a();
984
+ } else t ? e.forEach((a) => {
985
+ i(a) || t.declarations[0].id.properties.push(
986
+ n.objectProperty(n.identifier(a), n.identifier(a), void 0, !0)
981
987
  );
982
988
  }) : this._ast.program.body.unshift(
983
989
  n.variableDeclaration("const", [
984
990
  n.variableDeclarator(
985
991
  n.objectPattern(
986
992
  e.map(
987
- (l) => n.objectProperty(n.identifier(l), n.identifier(l), void 0, !0)
993
+ (a) => n.objectProperty(n.identifier(a), n.identifier(a), void 0, !0)
988
994
  )
989
995
  ),
990
- n.callExpression(n.identifier("require"), [n.stringLiteral(i)])
996
+ n.callExpression(n.identifier("require"), [n.stringLiteral(r)])
991
997
  )
992
998
  ])
993
999
  );
@@ -1017,78 +1023,79 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
1017
1023
  * import will be set. Otherwise, an array of named imports will be set
1018
1024
  * @param fromImport - The module to import from
1019
1025
  */
1020
- setImport(e, i) {
1021
- let t = /* @__PURE__ */ f((p) => n.importSpecifier(n.identifier(p), n.identifier(p)), "getNewImportSpecifier"), r = /* @__PURE__ */ f((p, d) => p.
1026
+ setImport(e, r) {
1027
+ let t = this._ast.program.body.find((p) => {
1028
+ let d = n.isImportDeclaration(p) && (p.source.value === r || p.source.value === r.split("node:")[1]);
1029
+ return d && (r = p.source.value), d;
1030
+ }), i = /* @__PURE__ */ f((p) => n.importSpecifier(n.identifier(p), n.identifier(p)), "getNewImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.
1022
1031
  specifiers.find(
1023
- (g) => n.isImportSpecifier(g) && n.isIdentifier(g.imported) && g.imported.name === d
1024
- ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1025
- (g) => n.isImportNamespaceSpecifier(g) && n.isIdentifier(g.local) && g.local.name === d
1026
- ), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1027
- (g) => n.isImportDefaultSpecifier(g) && n.isIdentifier(g.local) && g.local.name === d
1028
- ), "hasDefaultImportSpecifier"), a = this._ast.program.body.find(
1029
- (p) => n.isImportDeclaration(p) && p.source.value === i
1030
- );
1031
- e === null ? a || this._ast.program.body.unshift(n.importDeclaration([], n.stringLiteral(i))) : typeof e == "string" ? a ? l(a, e) || a.
1032
- specifiers.push(
1032
+ (m) => n.isImportSpecifier(m) && n.isIdentifier(m.imported) && m.imported.name === d
1033
+ ), "hasImportSpecifier"), a = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1034
+ (m) => n.isImportNamespaceSpecifier(m) && n.isIdentifier(m.local) && m.local.name === d
1035
+ ), "hasNamespaceImportSpecifier");
1036
+ e === null ? t || this._ast.program.body.unshift(n.importDeclaration([], n.stringLiteral(r))) : typeof e == "string" ? t ? (/* @__PURE__ */ f(
1037
+ (p, d) => p.specifiers.find(
1038
+ (m) => n.isImportDefaultSpecifier(m) && n.isIdentifier(m.local) && m.local.name === d
1039
+ ), "hasDefaultImportSpecifier"))(t, e) || t.specifiers.push(
1033
1040
  n.importDefaultSpecifier(n.identifier(e))
1034
1041
  ) : this._ast.program.body.unshift(
1035
1042
  n.importDeclaration(
1036
1043
  [n.importDefaultSpecifier(n.identifier(e))],
1037
- n.stringLiteral(i)
1044
+ n.stringLiteral(r)
1038
1045
  )
1039
- ) : Array.isArray(e) ? a ? e.forEach((p) => {
1040
- r(a, p) || a.specifiers.push(t(p));
1046
+ ) : Array.isArray(e) ? t ? e.forEach((p) => {
1047
+ o(t, p) || t.specifiers.push(i(p));
1041
1048
  }) : this._ast.program.body.unshift(
1042
1049
  n.importDeclaration(
1043
- e.map(t),
1044
- n.stringLiteral(i)
1050
+ e.map(i),
1051
+ n.stringLiteral(r)
1045
1052
  )
1046
- ) : e.namespace && (a ? o(a, e.namespace) || a.specifiers.push(
1053
+ ) : e.namespace && (t ? a(t, e.namespace) || t.specifiers.push(
1047
1054
  n.importNamespaceSpecifier(n.identifier(e.namespace))
1048
1055
  ) : this._ast.program.body.unshift(
1049
1056
  n.importDeclaration(
1050
1057
  [n.importNamespaceSpecifier(n.identifier(e.namespace))],
1051
- n.stringLiteral(i)
1058
+ n.stringLiteral(r)
1052
1059
  )
1053
1060
  ));
1054
1061
  }
1055
1062
  }, nt = /* @__PURE__ */ f((s, e) => {
1056
- let i = xe(s);
1057
- return new Z(i, s, e);
1063
+ let r = xe(s);
1064
+ return new Z(r, s, e);
1058
1065
  }, "loadConfig"), ot = /* @__PURE__ */ f((s) => at(s).code, "formatConfig"), at = /* @__PURE__ */ f((s, e = {}) => st.print(s._ast, e), "pri\
1059
1066
  ntConfig"), $t = /* @__PURE__ */ f(async (s) => {
1060
1067
  let e = (await rt(s, "utf-8")).toString();
1061
1068
  return nt(e, s).parse();
1062
1069
  }, "readConfig"), Rt = /* @__PURE__ */ f(async (s, e) => {
1063
- let i = e || s.fileName;
1064
- if (!i)
1070
+ let r = e || s.fileName;
1071
+ if (!r)
1065
1072
  throw new Error("Please specify a fileName for writeConfig");
1066
- await it(i, ot(s));
1067
- }, "writeConfig"), Lt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((i) => n.isImportDeclaration(i) && i.source.value.includes("@sto\
1068
- rybook") && i.specifiers.some((t) => n.isImportSpecifier(t) && n.isIdentifier(t.imported) && t.imported.name === "definePreview")), "isCsfFa\
1073
+ await it(r, ot(s));
1074
+ }, "writeConfig"), Lt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((r) => n.isImportDeclaration(r) && r.source.value.includes("@sto\
1075
+ rybook") && r.specifiers.some((t) => n.isImportSpecifier(t) && n.isIdentifier(t.imported) && t.imported.name === "definePreview")), "isCsfFa\
1069
1076
  ctoryPreview");
1070
1077
 
1071
1078
  // src/csf-tools/getStorySortParameter.ts
1072
1079
  var je = U(V(), 1);
1073
- import { babelParse as lt, generate as he, types as E, traverse as ct } from "storybook/internal/babel";
1080
+ import { babelParse as lt, generate as Ee, types as h, traverse as ct } from "storybook/internal/babel";
1074
1081
  var pt = console, ee = /* @__PURE__ */ f((s, e) => {
1075
- let i;
1082
+ let r;
1076
1083
  return s.properties.forEach((t) => {
1077
- E.isIdentifier(t.key) && t.key.name === e && (i = t.value);
1078
- }), i;
1084
+ h.isIdentifier(t.key) && t.key.name === e && (r = t.value);
1085
+ }), r;
1079
1086
  }, "getValue"), te = /* @__PURE__ */ f((s) => {
1080
1087
  let e = L(s);
1081
- if (E.isArrayExpression(e))
1082
- return e.elements.map((i) => te(i));
1083
- if (E.isObjectExpression(e))
1084
- return e.properties.reduce((i, t) => (E.isIdentifier(t.key) && (i[t.key.name] = te(t.value)), i), {});
1085
- if (E.isLiteral(e))
1088
+ if (h.isArrayExpression(e))
1089
+ return e.elements.map((r) => te(r));
1090
+ if (h.isObjectExpression(e))
1091
+ return e.properties.reduce((r, t) => (h.isIdentifier(t.key) && (r[t.key.name] = te(t.value)), r), {});
1092
+ if (h.isLiteral(e))
1086
1093
  return e.value;
1087
- if (E.isIdentifier(e))
1094
+ if (h.isIdentifier(e))
1088
1095
  return F(e.name, !0);
1089
1096
  throw new Error(`Unknown node type ${e.type}`);
1090
1097
  }, "parseValue"), F = /* @__PURE__ */ f((s, e) => {
1091
- let i = je.dedent`
1098
+ let r = je.dedent`
1092
1099
  Unexpected '${s}'. Parameter 'options.storySort' should be defined inline e.g.:
1093
1100
 
1094
1101
  export default {
@@ -1100,159 +1107,159 @@ var pt = console, ee = /* @__PURE__ */ f((s, e) => {
1100
1107
  };
1101
1108
  `;
1102
1109
  if (e)
1103
- throw new Error(i);
1104
- pt.info(i);
1105
- }, "unsupported"), L = /* @__PURE__ */ f((s) => E.isTSAsExpression(s) || E.isTSSatisfiesExpression(s) ? s.expression : s, "stripTSModifiers"),
1110
+ throw new Error(r);
1111
+ pt.info(r);
1112
+ }, "unsupported"), L = /* @__PURE__ */ f((s) => h.isTSAsExpression(s) || h.isTSSatisfiesExpression(s) ? s.expression : s, "stripTSModifiers"),
1106
1113
  Se = /* @__PURE__ */ f((s) => {
1107
1114
  let e = L(s);
1108
- if (E.isObjectExpression(e)) {
1109
- let i = ee(e, "options");
1110
- if (i) {
1111
- if (E.isObjectExpression(i))
1112
- return ee(i, "storySort");
1115
+ if (h.isObjectExpression(e)) {
1116
+ let r = ee(e, "options");
1117
+ if (r) {
1118
+ if (h.isObjectExpression(r))
1119
+ return ee(r, "storySort");
1113
1120
  F("options", !0);
1114
1121
  }
1115
1122
  }
1116
1123
  }, "parseParameters"), _e = /* @__PURE__ */ f((s, e) => {
1117
- let i = L(s);
1118
- if (E.isObjectExpression(i)) {
1119
- let t = ee(i, "parameters");
1120
- if (E.isIdentifier(t) && (t = P(t.name, e)), t)
1124
+ let r = L(s);
1125
+ if (h.isObjectExpression(r)) {
1126
+ let t = ee(r, "parameters");
1127
+ if (h.isIdentifier(t) && (t = P(t.name, e)), t)
1121
1128
  return Se(t);
1122
1129
  } else
1123
1130
  F("default", !0);
1124
1131
  }, "parseDefault"), Wt = /* @__PURE__ */ f((s) => {
1125
1132
  if (!s.includes("storySort"))
1126
1133
  return;
1127
- let e, i = lt(s);
1128
- if (ct(i, {
1134
+ let e, r = lt(s);
1135
+ if (ct(r, {
1129
1136
  ExportNamedDeclaration: {
1130
1137
  enter({ node: t }) {
1131
- E.isVariableDeclaration(t.declaration) ? t.declaration.declarations.forEach((r) => {
1132
- if (E.isVariableDeclarator(r) && E.isIdentifier(r.id)) {
1133
- let { name: o } = r.id;
1134
- if (o === "parameters" && r.init) {
1135
- let l = L(r.init);
1136
- e = Se(l);
1138
+ h.isVariableDeclaration(t.declaration) ? t.declaration.declarations.forEach((i) => {
1139
+ if (h.isVariableDeclarator(i) && h.isIdentifier(i.id)) {
1140
+ let { name: o } = i.id;
1141
+ if (o === "parameters" && i.init) {
1142
+ let a = L(i.init);
1143
+ e = Se(a);
1137
1144
  }
1138
1145
  }
1139
- }) : t.specifiers.forEach((r) => {
1140
- E.isIdentifier(r.exported) && r.exported.name === "parameters" && F("parameters", !1);
1146
+ }) : t.specifiers.forEach((i) => {
1147
+ h.isIdentifier(i.exported) && i.exported.name === "parameters" && F("parameters", !1);
1141
1148
  });
1142
1149
  }
1143
1150
  },
1144
1151
  ExportDefaultDeclaration: {
1145
1152
  enter({ node: t }) {
1146
- let r = t.declaration;
1147
- E.isIdentifier(r) && (r = P(r.name, i.program)), r = L(r), E.isCallExpression(r) && E.isObjectExpression(r.arguments?.[0]) ? e = _e(
1148
- r.arguments[0], i.program) : E.isObjectExpression(r) ? e = _e(r, i.program) : F("default", !1);
1153
+ let i = t.declaration;
1154
+ h.isIdentifier(i) && (i = P(i.name, r.program)), i = L(i), h.isCallExpression(i) && h.isObjectExpression(i.arguments?.[0]) ? e = _e(
1155
+ i.arguments[0], r.program) : h.isObjectExpression(i) ? e = _e(i, r.program) : F("default", !1);
1149
1156
  }
1150
1157
  }
1151
1158
  }), !!e) {
1152
- if (E.isArrowFunctionExpression(e)) {
1153
- let { code: t } = he(e, {});
1159
+ if (h.isArrowFunctionExpression(e)) {
1160
+ let { code: t } = Ee(e, {});
1154
1161
  return (0, eval)(t);
1155
1162
  }
1156
- if (E.isFunctionExpression(e)) {
1157
- let { code: t } = he(e, {}), r = e.id?.name, o = `(a, b) => {
1163
+ if (h.isFunctionExpression(e)) {
1164
+ let { code: t } = Ee(e, {}), i = e.id?.name, o = `(a, b) => {
1158
1165
  ${t};
1159
- return ${r}(a, b)
1166
+ return ${i}(a, b)
1160
1167
  }`;
1161
1168
  return (0, eval)(o);
1162
1169
  }
1163
- return E.isLiteral(e) || E.isArrayExpression(e) || E.isObjectExpression(e) ? te(e) : F("storySort", !0);
1170
+ return h.isLiteral(e) || h.isArrayExpression(e) || h.isObjectExpression(e) ? te(e) : F("storySort", !0);
1164
1171
  }
1165
1172
  }, "getStorySortParameter");
1166
1173
 
1167
1174
  // src/csf-tools/enrichCsf.ts
1168
- import { generate as ft, types as u } from "storybook/internal/babel";
1169
- var dt = /* @__PURE__ */ f((s, e, i, t) => {
1170
- let r = e.getStoryExport(i), o = u.isCallExpression(r) && u.isMemberExpression(r.callee) && u.isIdentifier(r.callee.object) && r.callee.object.
1171
- name === "meta", l = !t?.disableSource && ut(r), a = !t?.disableDescription && Oe(e._storyStatements[i]), p = [], d = o ? u.memberExpression(
1172
- u.identifier(i), u.identifier("input")) : u.identifier(i), g = u.memberExpression(d, u.identifier("parameters"));
1173
- p.push(u.spreadElement(g));
1174
- let x = u.optionalMemberExpression(
1175
- g,
1176
- u.identifier("docs"),
1175
+ import { generate as ft, types as g } from "storybook/internal/babel";
1176
+ var dt = /* @__PURE__ */ f((s, e, r, t) => {
1177
+ let i = e.getStoryExport(r), o = g.isCallExpression(i) && g.isMemberExpression(i.callee) && g.isIdentifier(i.callee.object) && i.callee.object.
1178
+ name === "meta", a = !t?.disableSource && mt(i), l = !t?.disableDescription && Oe(e._storyStatements[r]), p = [], d = o ? g.memberExpression(
1179
+ g.identifier(r), g.identifier("input")) : g.identifier(r), m = g.memberExpression(d, g.identifier("parameters"));
1180
+ p.push(g.spreadElement(m));
1181
+ let x = g.optionalMemberExpression(
1182
+ m,
1183
+ g.identifier("docs"),
1177
1184
  !1,
1178
1185
  !0
1179
1186
  ), b = [];
1180
- if (l) {
1181
- let y = u.optionalMemberExpression(
1187
+ if (a) {
1188
+ let y = g.optionalMemberExpression(
1182
1189
  x,
1183
- u.identifier("source"),
1190
+ g.identifier("source"),
1184
1191
  !1,
1185
1192
  !0
1186
1193
  );
1187
1194
  b.push(
1188
- u.objectProperty(
1189
- u.identifier("source"),
1190
- u.objectExpression([
1191
- u.objectProperty(u.identifier("originalSource"), u.stringLiteral(l)),
1192
- u.spreadElement(y)
1195
+ g.objectProperty(
1196
+ g.identifier("source"),
1197
+ g.objectExpression([
1198
+ g.objectProperty(g.identifier("originalSource"), g.stringLiteral(a)),
1199
+ g.spreadElement(y)
1193
1200
  ])
1194
1201
  )
1195
1202
  );
1196
1203
  }
1197
- if (a) {
1198
- let y = u.optionalMemberExpression(
1204
+ if (l) {
1205
+ let y = g.optionalMemberExpression(
1199
1206
  x,
1200
- u.identifier("description"),
1207
+ g.identifier("description"),
1201
1208
  !1,
1202
1209
  !0
1203
1210
  );
1204
1211
  b.push(
1205
- u.objectProperty(
1206
- u.identifier("description"),
1207
- u.objectExpression([
1208
- u.objectProperty(u.identifier("story"), u.stringLiteral(a)),
1209
- u.spreadElement(y)
1212
+ g.objectProperty(
1213
+ g.identifier("description"),
1214
+ g.objectExpression([
1215
+ g.objectProperty(g.identifier("story"), g.stringLiteral(l)),
1216
+ g.spreadElement(y)
1210
1217
  ])
1211
1218
  )
1212
1219
  );
1213
1220
  }
1214
1221
  if (b.length > 0) {
1215
1222
  p.push(
1216
- u.objectProperty(
1217
- u.identifier("docs"),
1218
- u.objectExpression([u.spreadElement(x), ...b])
1223
+ g.objectProperty(
1224
+ g.identifier("docs"),
1225
+ g.objectExpression([g.spreadElement(x), ...b])
1219
1226
  )
1220
1227
  );
1221
- let y = u.expressionStatement(
1222
- u.assignmentExpression("=", g, u.objectExpression(p))
1228
+ let y = g.expressionStatement(
1229
+ g.assignmentExpression("=", m, g.objectExpression(p))
1223
1230
  );
1224
1231
  s._ast.program.body.push(y);
1225
1232
  }
1226
- }, "enrichCsfStory"), Pe = /* @__PURE__ */ f((s, e, i) => {
1233
+ }, "enrichCsfStory"), Pe = /* @__PURE__ */ f((s, e, r) => {
1227
1234
  if (!e.length) {
1228
1235
  s.properties.find(
1229
- (p) => u.isObjectProperty(p) && u.isIdentifier(p.key) && p.key.name === "component"
1230
- ) || s.properties.unshift(i);
1236
+ (p) => g.isObjectProperty(p) && g.isIdentifier(p.key) && p.key.name === "component"
1237
+ ) || s.properties.unshift(r);
1231
1238
  return;
1232
1239
  }
1233
- let [t, ...r] = e, o = s.properties.find(
1234
- (a) => u.isObjectProperty(a) && u.isIdentifier(a.key) && a.key.name === t && u.isObjectExpression(a.value)
1235
- ), l;
1236
- o ? l = o.value : (l = u.objectExpression([]), s.properties.push(u.objectProperty(u.identifier(t), l))), Pe(l, r, i);
1237
- }, "addComponentDescription"), mt = /* @__PURE__ */ f((s, e, i) => {
1238
- let t = !i?.disableDescription && Oe(e._metaStatement);
1240
+ let [t, ...i] = e, o = s.properties.find(
1241
+ (l) => g.isObjectProperty(l) && g.isIdentifier(l.key) && l.key.name === t && g.isObjectExpression(l.value)
1242
+ ), a;
1243
+ o ? a = o.value : (a = g.objectExpression([]), s.properties.push(g.objectProperty(g.identifier(t), a))), Pe(a, i, r);
1244
+ }, "addComponentDescription"), ut = /* @__PURE__ */ f((s, e, r) => {
1245
+ let t = !r?.disableDescription && Oe(e._metaStatement);
1239
1246
  if (t) {
1240
- let r = s._metaNode;
1241
- r && u.isObjectExpression(r) && Pe(
1242
- r,
1247
+ let i = s._metaNode;
1248
+ i && g.isObjectExpression(i) && Pe(
1249
+ i,
1243
1250
  ["parameters", "docs", "description"],
1244
- u.objectProperty(u.identifier("component"), u.stringLiteral(t))
1251
+ g.objectProperty(g.identifier("component"), g.stringLiteral(t))
1245
1252
  );
1246
1253
  }
1247
- }, "enrichCsfMeta"), Kt = /* @__PURE__ */ f((s, e, i) => {
1248
- mt(s, e, i), Object.keys(s._storyExports).forEach((t) => {
1249
- dt(s, e, t, i);
1254
+ }, "enrichCsfMeta"), Kt = /* @__PURE__ */ f((s, e, r) => {
1255
+ ut(s, e, r), Object.keys(s._storyExports).forEach((t) => {
1256
+ dt(s, e, t, r);
1250
1257
  });
1251
- }, "enrichCsf"), ut = /* @__PURE__ */ f((s) => {
1252
- let e = u.isVariableDeclarator(s) ? s.init : s, { code: i } = ft(e, {});
1253
- return i;
1254
- }, "extractSource"), Oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((i) => i.type === "CommentLine" || !i.value.startsWith(
1255
- "*") ? null : i.value.split(`
1258
+ }, "enrichCsf"), mt = /* @__PURE__ */ f((s) => {
1259
+ let e = g.isVariableDeclarator(s) ? s.init : s, { code: r } = ft(e, {});
1260
+ return r;
1261
+ }, "extractSource"), Oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((r) => r.type === "CommentLine" || !r.value.startsWith(
1262
+ "*") ? null : r.value.split(`
1256
1263
  `).map((t) => t.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
1257
1264
  `).trim()).filter(Boolean).join(`
1258
1265
  `) : "", "extractDescription");
@@ -1262,42 +1269,42 @@ import { babelParse as cr } from "storybook/internal/babel";
1262
1269
 
1263
1270
  // src/csf-tools/vitest-plugin/transformer.ts
1264
1271
  var re = U(V(), 1);
1265
- import { types as m } from "storybook/internal/babel";
1272
+ import { types as u } from "storybook/internal/babel";
1266
1273
  import { getStoryTitle as gt } from "storybook/internal/common";
1267
1274
  import { combineTags as xt } from "storybook/internal/csf";
1268
- var Ie = console, yt = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((i) => s?.includes(i)) || e.exclude.some((i) => s?.
1269
- includes(i))), "isValidTest");
1275
+ var ve = console, yt = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((r) => s?.includes(r)) || e.exclude.some((r) => s?.
1276
+ includes(r))), "isValidTest");
1270
1277
  async function bt({
1271
1278
  code: s,
1272
1279
  fileName: e,
1273
- configDir: i,
1280
+ configDir: r,
1274
1281
  stories: t,
1275
- tagsFilter: r,
1282
+ tagsFilter: i,
1276
1283
  previewLevelTags: o = []
1277
1284
  }) {
1278
1285
  if (!/\.stor(y|ies)\./.test(e))
1279
1286
  return s;
1280
- let a = Q(s, {
1287
+ let l = Q(s, {
1281
1288
  fileName: e,
1282
1289
  transformInlineMeta: !0,
1283
1290
  makeTitle: /* @__PURE__ */ f((_) => {
1284
1291
  let S = gt({
1285
1292
  storyFilePath: e,
1286
- configDir: i,
1293
+ configDir: r,
1287
1294
  stories: t,
1288
1295
  userTitle: _
1289
1296
  }) || "unknown";
1290
- return S === "unknown" && Ie.warn(
1297
+ return S === "unknown" && ve.warn(
1291
1298
  re.dedent`
1292
1299
  [Storybook]: Could not calculate story title for "${e}".
1293
- Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${i}".
1300
+ Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${r}".
1294
1301
  `
1295
1302
  ), S;
1296
1303
  }, "makeTitle")
1297
- }).parse(), p = a._ast, d = a._metaVariableName, g = a._metaNode, x = g.properties.find(
1298
- (_) => m.isObjectProperty(_) && m.isIdentifier(_.key) && _.key.name === "title"
1299
- ), b = m.stringLiteral(a._meta?.title || "unknown");
1300
- if (x ? m.isObjectProperty(x) && (x.value = b) : g.properties.push(m.objectProperty(m.identifier("title"), b)), !g || !a._meta)
1304
+ }).parse(), p = l._ast, d = l._metaVariableName, m = l._metaNode, x = m.properties.find(
1305
+ (_) => u.isObjectProperty(_) && u.isIdentifier(_.key) && _.key.name === "title"
1306
+ ), b = u.stringLiteral(l._meta?.title || "unknown");
1307
+ if (x ? u.isObjectProperty(x) && (x.value = b) : m.properties.push(u.objectProperty(u.identifier("title"), b)), !m || !l._meta)
1301
1308
  throw new Error(
1302
1309
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
1303
1310
 
@@ -1305,90 +1312,90 @@ Please make sure you have a default export with the meta object. If you are usin
1305
1312
  le an issue with details about your use case.`
1306
1313
  );
1307
1314
  let y = {};
1308
- Object.keys(a._stories).map((_) => {
1315
+ Object.keys(l._stories).map((_) => {
1309
1316
  let S = xt(
1310
1317
  "test",
1311
1318
  "dev",
1312
1319
  ...o,
1313
- ...a.meta?.tags || [],
1314
- ...a._stories[_].tags || []
1320
+ ...l.meta?.tags || [],
1321
+ ...l._stories[_].tags || []
1315
1322
  );
1316
- yt(S, r) && (y[_] = a._storyStatements[_]);
1323
+ yt(S, i) && (y[_] = l._storyStatements[_]);
1317
1324
  });
1318
- let h = a._file.path.scope.generateUidIdentifier("test"), D = a._file.path.scope.generateUidIdentifier("describe");
1325
+ let E = l._file.path.scope.generateUidIdentifier("test"), D = l._file.path.scope.generateUidIdentifier("describe");
1319
1326
  if (Object.keys(y).length === 0) {
1320
- let _ = m.expressionStatement(
1321
- m.callExpression(m.memberExpression(D, m.identifier("skip")), [
1322
- m.stringLiteral("No valid tests found")
1327
+ let _ = u.expressionStatement(
1328
+ u.callExpression(u.memberExpression(D, u.identifier("skip")), [
1329
+ u.stringLiteral("No valid tests found")
1323
1330
  ])
1324
1331
  );
1325
1332
  p.program.body.push(_);
1326
1333
  let S = [
1327
- m.importDeclaration(
1334
+ u.importDeclaration(
1328
1335
  [
1329
- m.importSpecifier(h, m.identifier("test")),
1330
- m.importSpecifier(D, m.identifier("describe"))
1336
+ u.importSpecifier(E, u.identifier("test")),
1337
+ u.importSpecifier(D, u.identifier("describe"))
1331
1338
  ],
1332
- m.stringLiteral("vitest")
1339
+ u.stringLiteral("vitest")
1333
1340
  )
1334
1341
  ];
1335
1342
  p.program.body.unshift(...S);
1336
1343
  } else {
1337
1344
  let ie = function() {
1338
- let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), v = m.memberExpression(
1339
- m.callExpression(m.memberExpression(_, m.identifier("getState")), []),
1340
- m.identifier("testPath")
1341
- ), C = m.memberExpression(
1342
- m.memberExpression(m.identifier("globalThis"), m.identifier("__vitest_worker__")),
1343
- m.identifier("filepath")
1344
- ), T = m.logicalExpression(
1345
+ let j = l._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), I = u.memberExpression(
1346
+ u.callExpression(u.memberExpression(_, u.identifier("getState")), []),
1347
+ u.identifier("testPath")
1348
+ ), C = u.memberExpression(
1349
+ u.memberExpression(u.identifier("globalThis"), u.identifier("__vitest_worker__")),
1350
+ u.identifier("filepath")
1351
+ ), T = u.logicalExpression(
1345
1352
  "??",
1346
1353
  // TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
1347
1354
  // https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
1348
1355
  C,
1349
- v
1350
- ), M = m.callExpression(
1351
- m.memberExpression(
1352
- m.callExpression(m.identifier("convertToFilePath"), [
1353
- m.memberExpression(
1354
- m.memberExpression(m.identifier("import"), m.identifier("meta")),
1355
- m.identifier("url")
1356
+ I
1357
+ ), M = u.callExpression(
1358
+ u.memberExpression(
1359
+ u.callExpression(u.identifier("convertToFilePath"), [
1360
+ u.memberExpression(
1361
+ u.memberExpression(u.identifier("import"), u.identifier("meta")),
1362
+ u.identifier("url")
1356
1363
  )
1357
1364
  ]),
1358
- m.identifier("includes")
1365
+ u.identifier("includes")
1359
1366
  ),
1360
1367
  [T]
1361
1368
  );
1362
- return { isRunningFromThisFileDeclaration: m.variableDeclaration("const", [
1363
- m.variableDeclarator(j, M)
1369
+ return { isRunningFromThisFileDeclaration: u.variableDeclaration("const", [
1370
+ u.variableDeclarator(j, M)
1364
1371
  ]), isRunningFromThisFileId: j };
1365
1372
  };
1366
- var Et = ie;
1373
+ var ht = ie;
1367
1374
  f(ie, "getTestGuardDeclaration");
1368
- let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), De = m.identifier(
1369
- JSON.stringify(r.skip)), { isRunningFromThisFileDeclaration: ve, isRunningFromThisFileId: Ne } = ie();
1370
- p.program.body.push(ve);
1375
+ let _ = l._file.path.scope.generateUidIdentifier("expect"), S = l._file.path.scope.generateUidIdentifier("testStory"), De = u.identifier(
1376
+ JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Ie, isRunningFromThisFileId: Ne } = ie();
1377
+ p.program.body.push(Ie);
1371
1378
  let we = /* @__PURE__ */ f(({
1372
1379
  localName: j,
1373
- exportName: v,
1380
+ exportName: I,
1374
1381
  testTitle: C,
1375
1382
  node: T
1376
1383
  }) => {
1377
- let M = m.expressionStatement(
1378
- m.callExpression(h, [
1379
- m.stringLiteral(C),
1380
- m.callExpression(S, [
1381
- m.stringLiteral(v),
1382
- m.identifier(j),
1383
- m.identifier(d),
1384
+ let M = u.expressionStatement(
1385
+ u.callExpression(E, [
1386
+ u.stringLiteral(C),
1387
+ u.callExpression(S, [
1388
+ u.stringLiteral(I),
1389
+ u.identifier(j),
1390
+ u.identifier(d),
1384
1391
  De
1385
1392
  ])
1386
1393
  ])
1387
1394
  );
1388
1395
  return M.loc = T.loc, M;
1389
- }, "getTestStatementForStory"), Fe = Object.entries(y).map(([j, v]) => {
1390
- if (v === null) {
1391
- Ie.warn(
1396
+ }, "getTestStatementForStory"), Fe = Object.entries(y).map(([j, I]) => {
1397
+ if (I === null) {
1398
+ ve.warn(
1392
1399
  re.dedent`
1393
1400
  [Storybook]: Could not transform "${j}" story into test at "${e}".
1394
1401
  Please make sure to define stories in the same file and not re-export stories coming from other files".
@@ -1396,29 +1403,29 @@ le an issue with details about your use case.`
1396
1403
  );
1397
1404
  return;
1398
1405
  }
1399
- let C = a._stories[j].localName ?? j, T = a._stories[j].name ?? j;
1400
- return we({ testTitle: T, localName: C, exportName: j, node: v });
1401
- }).filter((j) => !!j), Ce = m.ifStatement(Ne, m.blockStatement(Fe));
1406
+ let C = l._stories[j].localName ?? j, T = l._stories[j].name ?? j;
1407
+ return we({ testTitle: T, localName: C, exportName: j, node: I });
1408
+ }).filter((j) => !!j), Ce = u.ifStatement(Ne, u.blockStatement(Fe));
1402
1409
  p.program.body.push(Ce);
1403
1410
  let Te = [
1404
- m.importDeclaration(
1411
+ u.importDeclaration(
1405
1412
  [
1406
- m.importSpecifier(h, m.identifier("test")),
1407
- m.importSpecifier(_, m.identifier("expect"))
1413
+ u.importSpecifier(E, u.identifier("test")),
1414
+ u.importSpecifier(_, u.identifier("expect"))
1408
1415
  ],
1409
- m.stringLiteral("vitest")
1416
+ u.stringLiteral("vitest")
1410
1417
  ),
1411
- m.importDeclaration(
1418
+ u.importDeclaration(
1412
1419
  [
1413
- m.importSpecifier(S, m.identifier("testStory")),
1414
- m.importSpecifier(m.identifier("convertToFilePath"), m.identifier("convertToFilePath"))
1420
+ u.importSpecifier(S, u.identifier("testStory")),
1421
+ u.importSpecifier(u.identifier("convertToFilePath"), u.identifier("convertToFilePath"))
1415
1422
  ],
1416
- m.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1423
+ u.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1417
1424
  )
1418
1425
  ];
1419
1426
  p.program.body.unshift(...Te);
1420
1427
  }
1421
- return me(a, { sourceMaps: !0, sourceFileName: e }, s);
1428
+ return ue(l, { sourceMaps: !0, sourceFileName: e }, s);
1422
1429
  }
1423
1430
  f(bt, "vitestTransform");
1424
1431
  export {
@@ -1431,12 +1438,12 @@ export {
1431
1438
  cr as babelParse,
1432
1439
  et as babelParseFile,
1433
1440
  Kt as enrichCsf,
1434
- mt as enrichCsfMeta,
1441
+ ut as enrichCsfMeta,
1435
1442
  dt as enrichCsfStory,
1436
1443
  Oe as extractDescription,
1437
- ut as extractSource,
1444
+ mt as extractSource,
1438
1445
  ot as formatConfig,
1439
- me as formatCsf,
1446
+ ue as formatCsf,
1440
1447
  Wt as getStorySortParameter,
1441
1448
  Lt as isCsfFactoryPreview,
1442
1449
  Qe as isModuleMock,