storybook 9.0.0-alpha.15 → 9.0.0-alpha.17

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