"use strict";
var dr = Object.create;
var N = Object.defineProperty;
var lr = Object.getOwnPropertyDescriptor;
var fr = Object.getOwnPropertyNames;
var ur = Object.getPrototypeOf, mr = Object.prototype.hasOwnProperty;
var s = (e, r) => N(e, "name", { value: r, configurable: !0 });
var Re = (e, r) => () => (r || e((r = { exports: {} }).exports, r), r.exports), yr = (e, r) => {
  for (var t in r)
    N(e, t, { get: r[t], enumerable: !0 });
}, Ce = (e, r, t, o) => {
  if (r && typeof r == "object" || typeof r == "function")
    for (let a of fr(r))
      !mr.call(e, a) && a !== t && N(e, a, { get: () => r[a], enumerable: !(o = lr(r, a)) || o.enumerable });
  return e;
};
var R = (e, r, t) => (t = e != null ? dr(ur(e)) : {}, Ce(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  r || !e || !e.__esModule ? N(t, "default", { value: e, enumerable: !0 }) : t,
  e
)), gr = (e) => Ce(N({}, "__esModule", { value: !0 }), e);

// ../node_modules/@ngard/tiny-isequal/index.js
var Ee = Re((Z) => {
  Object.defineProperty(Z, "__esModule", { value: !0 }), Z.isEqual = /* @__PURE__ */ function() {
    var e = Object.prototype.toString, r = Object.getPrototypeOf, t = Object.getOwnPropertySymbols ? function(o) {
      return Object.keys(o).concat(Object.getOwnPropertySymbols(o));
    } : Object.keys;
    return function(o, a) {
      return (/* @__PURE__ */ s(function n(i, p, l) {
        var c, y, f, m = e.call(i), h = e.call(p);
        if (i === p) return !0;
        if (i == null || p == null) return !1;
        if (l.indexOf(i) > -1 && l.indexOf(p) > -1) return !0;
        if (l.push(i, p), m != h || (c = t(i), y = t(p), c.length != y.length || c.some(function(S) {
          return !n(i[S], p[S], l);
        }))) return !1;
        switch (m.slice(8, -1)) {
          case "Symbol":
            return i.valueOf() == p.valueOf();
          case "Date":
          case "Number":
            return +i == +p || +i != +i && +p != +p;
          case "RegExp":
          case "Function":
          case "String":
          case "Boolean":
            return "" + i == "" + p;
          case "Set":
          case "Map":
            c = i.entries(), y = p.entries();
            do
              if (!n((f = c.next()).value, y.next().value, l)) return !1;
            while (!f.done);
            return !0;
          case "ArrayBuffer":
            i = new Uint8Array(i), p = new Uint8Array(p);
          case "DataView":
            i = new Uint8Array(i.buffer), p = new Uint8Array(p.buffer);
          case "Float32Array":
          case "Float64Array":
          case "Int8Array":
          case "Int16Array":
          case "Int32Array":
          case "Uint8Array":
          case "Uint16Array":
          case "Uint32Array":
          case "Uint8ClampedArray":
          case "Arguments":
          case "Array":
            if (i.length != p.length) return !1;
            for (f = 0; f < i.length; f++) if ((f in i || f in p) && (f in i != f in p || !n(i[f], p[f], l))) return !1;
            return !0;
          case "Object":
            return n(r(i), r(p), l);
          default:
            return !1;
        }
      }, "n"))(o, a, []);
    };
  }();
});

// ../node_modules/ts-dedent/dist/index.js
var D = Re((z) => {
  "use strict";
  Object.defineProperty(z, "__esModule", { value: !0 });
  z.dedent = void 0;
  function _e(e) {
    for (var r = [], t = 1; t < arguments.length; t++)
      r[t - 1] = arguments[t];
    var o = Array.from(typeof e == "string" ? [e] : e);
    o[o.length - 1] = o[o.length - 1].replace(/\r?\n([\t ]*)$/, "");
    var a = o.reduce(function(p, l) {
      var c = l.match(/\n([\t ]+|(?!\s).)/g);
      return c ? p.concat(c.map(function(y) {
        var f, m;
        return (m = (f = y.match(/[\t ]/g)) === null || f === void 0 ? void 0 : f.length) !== null && m !== void 0 ? m : 0;
      })) : p;
    }, []);
    if (a.length) {
      var n = new RegExp(`
[	 ]{` + Math.min.apply(Math, a) + "}", "g");
      o = o.map(function(p) {
        return p.replace(n, `
`);
      });
    }
    o[0] = o[0].replace(/^\r?\n/, "");
    var i = o[0];
    return r.forEach(function(p, l) {
      var c = i.match(/(?:^|\n)( *)$/), y = c ? c[1] : "", f = p;
      typeof p == "string" && p.includes(`
`) && (f = String(p).split(`
`).map(function(m, h) {
        return h === 0 ? m : "" + y + m;
      }).join(`
`)), i += f + o[l + 1];
    }), i;
  }
  s(_e, "dedent");
  z.dedent = _e;
  z.default = _e;
});

// src/csf/index.ts
var Kr = {};
yr(Kr, {
  combineTags: () => qr,
  definePreview: () => Dr,
  definePreviewAddon: () => Mr,
  getCoreAnnotations: () => be,
  includeConditionalArg: () => ve,
  isExportStory: () => Gr,
  isMeta: () => Ur,
  isPreview: () => Br,
  isStory: () => $r,
  parseKind: () => Vr,
  sanitize: () => pr,
  storyNameFromExport: () => Wr,
  toId: () => Lr
});
module.exports = gr(Kr);

// src/csf/toStartCaseStr.ts
function we(e) {
  return e.replace(/_/g, " ").replace(/-/g, " ").replace(/\./g, " ").replace(/([^\n])([A-Z])([a-z])/g, (r, t, o, a) => `${t} ${o}${a}`).replace(
  /([a-z])([A-Z])/g, (r, t, o) => `${t} ${o}`).replace(/([a-z])([0-9])/gi, (r, t, o) => `${t} ${o}`).replace(/([0-9])([a-z])/gi, (r, t, o) => `${t}\
 ${o}`).replace(/(\s|^)(\w)/g, (r, t, o) => `${t}${o.toUpperCase()}`).replace(/ +/g, " ").trim();
}
s(we, "toStartCaseStr");

// src/csf/includeConditionalArg.ts
var Q = R(Ee(), 1);
var Pe = /* @__PURE__ */ s((e) => e.map((r) => typeof r < "u").filter(Boolean).length, "count"), Tr = /* @__PURE__ */ s((e, r) => {
  let { exists: t, eq: o, neq: a, truthy: n } = e;
  if (Pe([t, o, a, n]) > 1)
    throw new Error(`Invalid conditional test ${JSON.stringify({ exists: t, eq: o, neq: a })}`);
  if (typeof o < "u")
    return (0, Q.isEqual)(r, o);
  if (typeof a < "u")
    return !(0, Q.isEqual)(r, a);
  if (typeof t < "u") {
    let p = typeof r < "u";
    return t ? p : !p;
  }
  return (typeof n > "u" ? !0 : n) ? !!r : !r;
}, "testValue"), ve = /* @__PURE__ */ s((e, r, t) => {
  if (!e.if)
    return !0;
  let { arg: o, global: a } = e.if;
  if (Pe([o, a]) !== 1)
    throw new Error(`Invalid conditional value ${JSON.stringify({ arg: o, global: a })}`);
  let n = o ? r[o] : t[a];
  return Tr(e.if, n);
}, "includeConditionalArg");

// src/csf/csf-factories.ts
var nr = require("storybook/internal/csf");

// src/preview-api/modules/addons/main.ts
var L = require("@storybook/global");

// src/preview-api/modules/addons/storybook-channel-mock.ts
var ke = require("storybook/internal/channels");
function Oe() {
  let e = {
    setHandler: /* @__PURE__ */ s(() => {
    }, "setHandler"),
    send: /* @__PURE__ */ s(() => {
    }, "send")
  };
  return new ke.Channel({ transport: e });
}
s(Oe, "mockChannel");

// src/preview-api/modules/addons/main.ts
var re = class {
  constructor() {
    this.getChannel = /* @__PURE__ */ s(() => {
      if (!this.channel) {
        let r = Oe();
        return this.setChannel(r), r;
      }
      return this.channel;
    }, "getChannel");
    this.ready = /* @__PURE__ */ s(() => this.promise, "ready");
    this.hasChannel = /* @__PURE__ */ s(() => !!this.channel, "hasChannel");
    this.setChannel = /* @__PURE__ */ s((r) => {
      this.channel = r, this.resolve();
    }, "setChannel");
    this.promise = new Promise((r) => {
      this.resolve = () => r(this.getChannel());
    });
  }
  static {
    s(this, "AddonStore");
  }
}, ee = "__STORYBOOK_ADDONS_PREVIEW";
function xr() {
  return L.global[ee] || (L.global[ee] = new re()), L.global[ee];
}
s(xr, "getAddonsStore");
var te = xr();

// src/preview-api/modules/addons/hooks.ts
var hr = require("storybook/internal/client-logger"), F = require("storybook/internal/core-events"), W = require("@storybook/global");
var G = class {
  constructor() {
    this.hookListsMap = void 0;
    this.mountedDecorators = void 0;
    this.prevMountedDecorators = void 0;
    this.currentHooks = void 0;
    this.nextHookIndex = void 0;
    this.currentPhase = void 0;
    this.currentEffects = void 0;
    this.prevEffects = void 0;
    this.currentDecoratorName = void 0;
    this.hasUpdates = void 0;
    this.currentContext = void 0;
    this.renderListener = /* @__PURE__ */ s((r) => {
      r === this.currentContext?.id && (this.triggerEffects(), this.currentContext = null, this.removeRenderListeners());
    }, "renderListener");
    this.init();
  }
  static {
    s(this, "HooksContext");
  }
  init() {
    this.hookListsMap = /* @__PURE__ */ new WeakMap(), this.mountedDecorators = /* @__PURE__ */ new Set(), this.prevMountedDecorators = /* @__PURE__ */ new Set(),
    this.currentHooks = [], this.nextHookIndex = 0, this.currentPhase = "NONE", this.currentEffects = [], this.prevEffects = [], this.currentDecoratorName =
    null, this.hasUpdates = !1, this.currentContext = null;
  }
  clean() {
    this.prevEffects.forEach((r) => {
      r.destroy && r.destroy();
    }), this.init(), this.removeRenderListeners();
  }
  getNextHook() {
    let r = this.currentHooks[this.nextHookIndex];
    return this.nextHookIndex += 1, r;
  }
  triggerEffects() {
    this.prevEffects.forEach((r) => {
      !this.currentEffects.includes(r) && r.destroy && r.destroy();
    }), this.currentEffects.forEach((r) => {
      this.prevEffects.includes(r) || (r.destroy = r.create());
    }), this.prevEffects = this.currentEffects, this.currentEffects = [];
  }
  addRenderListeners() {
    this.removeRenderListeners(), te.getChannel().on(F.STORY_RENDERED, this.renderListener);
  }
  removeRenderListeners() {
    te.getChannel().removeListener(F.STORY_RENDERED, this.renderListener);
  }
};
function Fe(e) {
  let r = /* @__PURE__ */ s((...t) => {
    let { hooks: o } = typeof t[0] == "function" ? t[1] : t[0], a = o.currentPhase, n = o.currentHooks, i = o.nextHookIndex, p = o.currentDecoratorName;
    o.currentDecoratorName = e.name, o.prevMountedDecorators.has(e) ? (o.currentPhase = "UPDATE", o.currentHooks = o.hookListsMap.get(e) || []) :
    (o.currentPhase = "MOUNT", o.currentHooks = [], o.hookListsMap.set(e, o.currentHooks), o.prevMountedDecorators.add(e)), o.nextHookIndex =
    0;
    let l = W.global.STORYBOOK_HOOKS_CONTEXT;
    W.global.STORYBOOK_HOOKS_CONTEXT = o;
    let c = e(...t);
    if (W.global.STORYBOOK_HOOKS_CONTEXT = l, o.currentPhase === "UPDATE" && o.getNextHook() != null)
      throw new Error(
        "Rendered fewer hooks than expected. This may be caused by an accidental early return statement."
      );
    return o.currentPhase = a, o.currentHooks = n, o.nextHookIndex = i, o.currentDecoratorName = p, c;
  }, "hookified");
  return r.originalFn = e, r;
}
s(Fe, "hookify");
var oe = 0, Sr = 25, je = /* @__PURE__ */ s((e) => (r, t) => {
  let o = e(
    Fe(r),
    t.map((a) => Fe(a))
  );
  return (a) => {
    let { hooks: n } = a;
    n.prevMountedDecorators ??= /* @__PURE__ */ new Set(), n.mountedDecorators = /* @__PURE__ */ new Set([r, ...t]), n.currentContext = a, n.
    hasUpdates = !1;
    let i = o(a);
    for (oe = 1; n.hasUpdates; )
      if (n.hasUpdates = !1, n.currentEffects = [], i = o(a), oe += 1, oe > Sr)
        throw new Error(
          "Too many re-renders. Storybook limits the number of renders to prevent an infinite loop."
        );
    return n.addRenderListeners(), i;
  };
}, "applyHooks");

// ../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
function I(e) {
  if (!e || typeof e != "object")
    return !1;
  let r = Object.getPrototypeOf(e);
  return r === null || r === Object.prototype || Object.getPrototypeOf(r) === null ? Object.prototype.toString.call(e) === "[object Object]" :
  !1;
}
s(I, "isPlainObject");

// ../node_modules/es-toolkit/dist/object/mapValues.mjs
function E(e, r) {
  let t = {}, o = Object.keys(e);
  for (let a = 0; a < o.length; a++) {
    let n = o[a], i = e[n];
    t[n] = r(i, n, e);
  }
  return t;
}
s(E, "mapValues");

// ../node_modules/es-toolkit/dist/object/pickBy.mjs
function ne(e, r) {
  let t = {}, o = Object.keys(e);
  for (let a = 0; a < o.length; a++) {
    let n = o[a], i = e[n];
    r(i, n) && (t[n] = i);
  }
  return t;
}
s(ne, "pickBy");

// src/preview-api/modules/store/args.ts
var Ar = require("storybook/internal/client-logger");
var br = R(D(), 1);
var bt = Symbol("incompatible");
var Rt = Symbol("Deeply equal");
var se = "UNTARGETED";
function Ne({
  args: e,
  argTypes: r
}) {
  let t = {};
  return Object.entries(e).forEach(([o, a]) => {
    let { target: n = se } = r[o] || {};
    t[n] = t[n] || {}, t[n][o] = a;
  }), t;
}
s(Ne, "groupArgsByTarget");

// src/preview-api/modules/store/csf/getValuesFromArgTypes.ts
var Ie = /* @__PURE__ */ s((e = {}) => Object.entries(e).reduce((r, [t, { defaultValue: o }]) => (typeof o < "u" && (r[t] = o), r), {}), "ge\
tValuesFromArgTypes");

// src/preview-api/modules/store/csf/normalizeInputTypes.ts
var Rr = /* @__PURE__ */ s((e) => typeof e == "string" ? { name: e } : e, "normalizeType"), Cr = /* @__PURE__ */ s((e) => typeof e == "strin\
g" ? { type: e } : e, "normalizeControl"), wr = /* @__PURE__ */ s((e, r) => {
  let { type: t, control: o, ...a } = e, n = {
    name: r,
    ...a
  };
  return t && (n.type = Rr(t)), o ? n.control = Cr(o) : o === !1 && (n.control = { disable: !0 }), n;
}, "normalizeInputType"), j = /* @__PURE__ */ s((e) => E(e, wr), "normalizeInputTypes");

// src/preview-api/modules/store/csf/normalizeStory.ts
var V = require("storybook/internal/client-logger"), q = require("storybook/internal/csf"), ze = R(D(), 1);

// src/preview-api/modules/store/csf/normalizeArrays.ts
var d = /* @__PURE__ */ s((e) => Array.isArray(e) ? e : e ? [e] : [], "normalizeArrays");

// src/preview-api/modules/store/csf/normalizeStory.ts
var Er = ze.dedent`
CSF .story annotations deprecated; annotate story functions directly:
- StoryFn.story.name => StoryFn.storyName
- StoryFn.story.(parameters|decorators) => StoryFn.(parameters|decorators)
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations for details and codemod.
`;
function ae(e, r, t) {
  let o = r, a = typeof r == "function" ? r : null, { story: n } = o;
  n && (V.logger.debug("deprecated story", n), (0, V.deprecate)(Er));
  let i = (0, q.storyNameFromExport)(e), p = typeof o != "function" && o.name || o.storyName || n?.name || i, l = [
    ...d(o.decorators),
    ...d(n?.decorators)
  ], c = { ...n?.parameters, ...o.parameters }, y = { ...n?.args, ...o.args }, f = { ...n?.argTypes, ...o.argTypes }, m = [...d(o.loaders), ...d(
  n?.loaders)], h = [
    ...d(o.beforeEach),
    ...d(n?.beforeEach)
  ], S = [
    ...d(o.afterEach),
    ...d(n?.afterEach)
  ], { render: O, play: P, tags: A = [], globals: C = {} } = o, u = c.__id || (0, q.toId)(t.id, i);
  return {
    moduleExport: r,
    id: u,
    name: p,
    tags: A,
    decorators: l,
    parameters: c,
    args: y,
    argTypes: j(f),
    loaders: m,
    beforeEach: h,
    afterEach: S,
    globals: C,
    ...O && { render: O },
    ...a && { userStoryFn: a },
    ...P && { play: P }
  };
}
s(ae, "normalizeStory");

// src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts
var De = require("storybook/internal/csf");
function Me(e, r = e.title, t) {
  let { id: o, argTypes: a } = e;
  return {
    id: (0, De.sanitize)(o || r),
    ...e,
    title: r,
    ...a && { argTypes: j(a) },
    parameters: {
      fileName: t,
      ...e.parameters
    }
  };
}
s(Me, "normalizeComponentAnnotations");

// src/preview-api/modules/store/csf/prepareStory.ts
var K = require("storybook/internal/csf"), Le = require("storybook/internal/preview-errors"), We = require("@storybook/global"), Ge = require("@storybook/global");

// src/preview-api/modules/preview-web/render/mount-utils.ts
function Ue(e) {
  return e != null && Pr(e).includes("mount");
}
s(Ue, "mountDestructured");
function Pr(e) {
  let r = e.toString().match(/[^(]*\(([^)]*)/);
  if (!r)
    return [];
  let t = Be(r[1]);
  if (!t.length)
    return [];
  let o = t[0];
  return o.startsWith("{") && o.endsWith("}") ? Be(o.slice(1, -1).replace(/\s/g, "")).map((n) => n.replace(/:.*|=.*/g, "")) : [];
}
s(Pr, "getUsedProps");
function Be(e) {
  let r = [], t = [], o = 0;
  for (let n = 0; n < e.length; n++)
    if (e[n] === "{" || e[n] === "[")
      t.push(e[n] === "{" ? "}" : "]");
    else if (e[n] === t[t.length - 1])
      t.pop();
    else if (!t.length && e[n] === ",") {
      let i = e.substring(o, n).trim();
      i && r.push(i), o = n + 1;
    }
  let a = e.substring(o).trim();
  return a && r.push(a), r;
}
s(Be, "splitByComma");

// src/preview-api/modules/store/decorators.ts
function He(e, r, t) {
  let o = t(e);
  return (a) => r(o, a);
}
s(He, "decorateStory");
function $e({
  componentId: e,
  title: r,
  kind: t,
  id: o,
  name: a,
  story: n,
  parameters: i,
  initialArgs: p,
  argTypes: l,
  ...c
} = {}) {
  return c;
}
s($e, "sanitizeStoryContextUpdate");
function ie(e, r) {
  let t = {}, o = /* @__PURE__ */ s((n) => (i) => {
    if (!t.value)
      throw new Error("Decorated function called without init");
    return t.value = {
      ...t.value,
      ...$e(i)
    }, n(t.value);
  }, "bindWithContext"), a = r.reduce(
    (n, i) => He(n, i, o),
    e
  );
  return (n) => (t.value = n, a(n));
}
s(ie, "defaultDecorateStory");

// src/preview-api/modules/store/parameters.ts
var x = /* @__PURE__ */ s((...e) => {
  let r = {}, t = e.filter(Boolean), o = t.reduce((a, n) => (Object.entries(n).forEach(([i, p]) => {
    let l = a[i];
    Array.isArray(p) || typeof l > "u" ? a[i] = p : I(p) && I(l) ? r[i] = !0 : typeof p < "u" && (a[i] = p);
  }), a), {});
  return Object.keys(r).forEach((a) => {
    let n = t.filter(Boolean).map((i) => i[a]).filter((i) => typeof i < "u");
    n.every((i) => I(i)) ? o[a] = x(...n) : o[a] = n[n.length - 1];
  }), o;
}, "combineParameters");

// src/preview-api/modules/store/csf/prepareStory.ts
function pe(e, r, t) {
  let { moduleExport: o, id: a, name: n } = e || {}, i = vr(
    e,
    r,
    t
  ), p = /* @__PURE__ */ s(async (T) => {
    let w = {};
    for (let _ of [
      d(t.loaders),
      d(r.loaders),
      d(e.loaders)
    ]) {
      if (T.abortSignal.aborted)
        return w;
      let $ = await Promise.all(_.map((cr) => cr(T)));
      Object.assign(w, ...$);
    }
    return w;
  }, "applyLoaders"), l = /* @__PURE__ */ s(async (T) => {
    let w = new Array();
    for (let _ of [
      ...d(t.beforeEach),
      ...d(r.beforeEach),
      ...d(e.beforeEach)
    ]) {
      if (T.abortSignal.aborted)
        return w;
      let $ = await _(T);
      $ && w.push($);
    }
    return w;
  }, "applyBeforeEach"), c = /* @__PURE__ */ s(async (T) => {
    let w = [
      ...d(t.afterEach),
      ...d(r.afterEach),
      ...d(e.afterEach)
    ].reverse();
    for (let _ of w) {
      if (T.abortSignal.aborted)
        return;
      await _(T);
    }
  }, "applyAfterEach"), y = /* @__PURE__ */ s((T) => T.originalStoryFn(T.args, T), "undecoratedStoryFn"), { applyDecorators: f = ie, runStep: m } = t,
  h = [
    ...d(e?.decorators),
    ...d(r?.decorators),
    ...d(t?.decorators)
  ], S = e?.userStoryFn || e?.render || r.render || t.render, O = je(f)(y, h), P = /* @__PURE__ */ s((T) => O(T), "unboundStoryFn"), A = e?.
  play ?? r?.play, C = Ue(A);
  if (!S && !C)
    throw new Le.NoRenderFunctionError({ id: a });
  let u = /* @__PURE__ */ s((T) => async () => (await T.renderToCanvas(), T.canvas), "defaultMount"), g = e.mount ?? r.mount ?? t.mount ?? u,
  b = t.testingLibraryRender;
  return {
    storyGlobals: {},
    ...i,
    moduleExport: o,
    id: a,
    name: n,
    story: n,
    originalStoryFn: S,
    undecoratedStoryFn: y,
    unboundStoryFn: P,
    applyLoaders: p,
    applyBeforeEach: l,
    applyAfterEach: c,
    playFunction: A,
    runStep: m,
    mount: g,
    testingLibraryRender: b,
    renderToCanvas: t.renderToCanvas,
    usesMount: C
  };
}
s(pe, "prepareStory");
function vr(e, r, t) {
  let o = ["dev", "test"], a = Ge.global.DOCS_OPTIONS?.autodocs === !0 ? ["autodocs"] : [], n = (0, K.combineTags)(
    ...o,
    ...a,
    ...t.tags ?? [],
    ...r.tags ?? [],
    ...e?.tags ?? []
  ), i = x(
    t.parameters,
    r.parameters,
    e?.parameters
  ), { argTypesEnhancers: p = [], argsEnhancers: l = [] } = t, c = x(
    t.argTypes,
    r.argTypes,
    e?.argTypes
  );
  if (e) {
    let A = e?.userStoryFn || e?.render || r.render || t.render;
    i.__isArgsStory = A && A.length > 0;
  }
  let y = {
    ...t.args,
    ...r.args,
    ...e?.args
  }, f = {
    ...r.globals,
    ...e?.globals
  }, m = {
    componentId: r.id,
    title: r.title,
    kind: r.title,
    // Back compat
    id: e?.id || r.id,
    // if there's no story name, we create a fake one since enhancers expect a name
    name: e?.name || "__meta",
    story: e?.name || "__meta",
    // Back compat
    component: r.component,
    subcomponents: r.subcomponents,
    tags: n,
    parameters: i,
    initialArgs: y,
    argTypes: c,
    storyGlobals: f
  };
  m.argTypes = p.reduce(
    (A, C) => C({ ...m, argTypes: A }),
    m.argTypes
  );
  let h = { ...y };
  m.initialArgs = [...l].reduce(
    (A, C) => ({
      ...A,
      ...C({
        ...m,
        initialArgs: A
      })
    }),
    h
  );
  let { name: S, story: O, ...P } = m;
  return P;
}
s(vr, "preparePartialAnnotations");
function Ve(e) {
  let { args: r } = e, t = {
    ...e,
    allArgs: void 0,
    argsByTarget: void 0
  };
  if (We.global.FEATURES?.argTypeTargetsV7) {
    let n = Ne(e);
    t = {
      ...e,
      allArgs: e.args,
      argsByTarget: n,
      args: n[se] || {}
    };
  }
  let o = Object.entries(t.args).reduce((n, [i, p]) => {
    if (!t.argTypes[i]?.mapping)
      return n[i] = p, n;
    let l = /* @__PURE__ */ s((c) => {
      let y = t.argTypes[i].mapping;
      return y && c in y ? y[c] : c;
    }, "mappingFn");
    return n[i] = Array.isArray(p) ? p.map(l) : l(p), n;
  }, {}), a = Object.entries(o).reduce((n, [i, p]) => {
    let l = t.argTypes[i] || {};
    return (0, K.includeConditionalArg)(l, o, t.globals) && (n[i] = p), n;
  }, {});
  return { ...t, unmappedArgs: r, args: a };
}
s(Ve, "prepareContext");

// src/preview-api/modules/store/inferArgTypes.ts
var qe = require("storybook/internal/client-logger");
var Ke = R(D(), 1);
var ce = /* @__PURE__ */ s((e, r, t) => {
  let o = typeof e;
  switch (o) {
    case "boolean":
    case "string":
    case "number":
    case "function":
    case "symbol":
      return { name: o };
    default:
      break;
  }
  return e ? t.has(e) ? (qe.logger.warn(Ke.dedent`
        We've detected a cycle in arg '${r}'. Args should be JSON-serializable.

        Consider using the mapping feature or fully custom args:
        - Mapping: https://storybook.js.org/docs/writing-stories/args#mapping-to-complex-arg-values
        - Custom args: https://storybook.js.org/docs/essentials/controls#fully-custom-args
      `), { name: "other", value: "cyclic object" }) : (t.add(e), Array.isArray(e) ? { name: "array", value: e.length > 0 ? ce(e[0], r, new Set(
  t)) : { name: "other", value: "unknown" } } : { name: "object", value: E(e, (n) => ce(n, r, new Set(t))) }) : { name: "object", value: {} };
}, "inferType"), de = /* @__PURE__ */ s((e) => {
  let { id: r, argTypes: t = {}, initialArgs: o = {} } = e, a = E(o, (i, p) => ({
    name: p,
    type: ce(i, `${r}.${p}`, /* @__PURE__ */ new Set())
  })), n = E(t, (i, p) => ({
    name: p
  }));
  return x(a, n, t);
}, "inferArgTypes");
de.secondPass = !0;

// src/preview-api/modules/store/inferControls.ts
var Je = require("storybook/internal/client-logger");

// src/preview-api/modules/store/filterArgTypes.ts
var Ye = /* @__PURE__ */ s((e, r) => Array.isArray(r) ? r.includes(e) : e.match(r), "matches"), le = /* @__PURE__ */ s((e, r, t) => !r && !t ?
e : e && ne(e, (o, a) => {
  let n = o.name || a.toString();
  return !!(!r || Ye(n, r)) && (!t || !Ye(n, t));
}), "filterArgTypes");

// src/preview-api/modules/store/inferControls.ts
var kr = /* @__PURE__ */ s((e, r, t) => {
  let { type: o, options: a } = e;
  if (o) {
    if (t.color && t.color.test(r)) {
      let n = o.name;
      if (n === "string")
        return { control: { type: "color" } };
      n !== "enum" && Je.logger.warn(
        `Addon controls: Control of type color only supports string, received "${n}" instead`
      );
    }
    if (t.date && t.date.test(r))
      return { control: { type: "date" } };
    switch (o.name) {
      case "array":
        return { control: { type: "object" } };
      case "boolean":
        return { control: { type: "boolean" } };
      case "string":
        return { control: { type: "text" } };
      case "number":
        return { control: { type: "number" } };
      case "enum": {
        let { value: n } = o;
        return { control: { type: n?.length <= 5 ? "radio" : "select" }, options: n };
      }
      case "function":
      case "symbol":
        return null;
      default:
        return { control: { type: a ? "select" : "object" } };
    }
  }
}, "inferControl"), Y = /* @__PURE__ */ s((e) => {
  let {
    argTypes: r,
    parameters: { __isArgsStory: t, controls: { include: o = null, exclude: a = null, matchers: n = {} } = {} }
  } = e;
  if (!t)
    return r;
  let i = le(r, o, a), p = E(i, (l, c) => l?.type && kr(l, c.toString(), n));
  return x(p, i);
}, "inferControls");
Y.secondPass = !0;

// src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts
function M({
  argTypes: e,
  globalTypes: r,
  argTypesEnhancers: t,
  decorators: o,
  loaders: a,
  beforeEach: n,
  afterEach: i,
  initialGlobals: p,
  ...l
}) {
  return {
    ...e && { argTypes: j(e) },
    ...r && { globalTypes: j(r) },
    decorators: d(o),
    loaders: d(a),
    beforeEach: d(n),
    afterEach: d(i),
    argTypesEnhancers: [
      ...t || [],
      de,
      // There's an architectural decision to be made regarding embedded addons in core:
      //
      // Option 1: Keep embedded addons but ensure consistency by moving addon-specific code
      // (like inferControls) to live alongside the addon code itself. This maintains the
      // concept of core addons while improving code organization.
      //
      // Option 2: Fully integrate these addons into core, potentially moving UI components
      // into the manager and treating them as core features rather than addons. This is a
      // bigger architectural change requiring careful consideration.
      //
      // For now, we're keeping inferControls here as we need time to properly evaluate
      // these options and their implications. Some features (like Angular's cleanArgsDecorator)
      // currently rely on this behavior.
      //
      // TODO: Make an architectural decision on the handling of core addons
      Y
    ],
    initialGlobals: p,
    ...l
  };
}
s(M, "normalizeProjectAnnotations");

// src/preview-api/modules/store/csf/composeConfigs.ts
var Ze = require("@storybook/global");

// src/preview-api/modules/store/csf/beforeAll.ts
var Xe = /* @__PURE__ */ s((e) => async () => {
  let r = [];
  for (let t of e) {
    let o = await t();
    o && r.unshift(o);
  }
  return async () => {
    for (let t of r)
      await t();
  };
}, "composeBeforeAllHooks");

// src/preview-api/modules/store/csf/stepRunners.ts
function fe(e) {
  return async (r, t, o) => {
    await e.reduceRight(
      (n, i) => async () => i(r, n, o),
      async () => t(o)
    )();
  };
}
s(fe, "composeStepRunners");

// src/preview-api/modules/store/csf/composeConfigs.ts
function U(e, r) {
  return e.map((t) => t.default?.[r] ?? t[r]).filter(Boolean);
}
s(U, "getField");
function v(e, r, t = {}) {
  return U(e, r).reduce((o, a) => {
    let n = d(a);
    return t.reverseFileOrder ? [...n, ...o] : [...o, ...n];
  }, []);
}
s(v, "getArrayField");
function J(e, r) {
  return Object.assign({}, ...U(e, r));
}
s(J, "getObjectField");
function B(e, r) {
  return U(e, r).pop();
}
s(B, "getSingletonField");
function H(e) {
  let r = v(e, "argTypesEnhancers"), t = U(e, "runStep"), o = v(e, "beforeAll");
  return {
    parameters: x(...U(e, "parameters")),
    decorators: v(e, "decorators", {
      reverseFileOrder: !(Ze.global.FEATURES?.legacyDecoratorFileOrder ?? !1)
    }),
    args: J(e, "args"),
    argsEnhancers: v(e, "argsEnhancers"),
    argTypes: J(e, "argTypes"),
    argTypesEnhancers: [
      ...r.filter((a) => !a.secondPass),
      ...r.filter((a) => a.secondPass)
    ],
    initialGlobals: J(e, "initialGlobals"),
    globalTypes: J(e, "globalTypes"),
    loaders: v(e, "loaders"),
    beforeAll: Xe(o),
    beforeEach: v(e, "beforeEach"),
    afterEach: v(e, "afterEach"),
    render: B(e, "render"),
    renderToCanvas: B(e, "renderToCanvas"),
    applyDecorators: B(e, "applyDecorators"),
    runStep: fe(t),
    tags: v(e, "tags"),
    mount: B(e, "mount"),
    testingLibraryRender: B(e, "testingLibraryRender")
  };
}
s(H, "composeConfigs");

// src/preview-api/modules/store/csf/portable-stories.ts
var Fr = require("storybook/internal/csf"), jr = require("storybook/internal/csf"), or = require("storybook/internal/preview-errors"), _r = R(D(), 1);

// src/preview-api/modules/preview-web/render/animation-utils.ts
function Qe() {
  try {
    return (
      // @ts-expect-error this property exists in certain environments
      !!globalThis.__vitest_browser__ || // @ts-expect-error this property exists in certain environments
      !!globalThis.__playwright__binding__
    );
  } catch {
    return !1;
  }
}
s(Qe, "isTestEnvironment");
function er(e = !0) {
  if (!("document" in globalThis && "createElement" in globalThis.document))
    return () => {
    };
  let r = document.createElement("style");
  r.textContent = `*, *:before, *:after {
    animation: none !important;
  }`, document.head.appendChild(r);
  let t = document.createElement("style");
  return t.textContent = `*, *:before, *:after {
    animation-delay: 0s !important;
    animation-direction: ${e ? "reverse" : "normal"} !important;
    animation-play-state: paused !important;
    transition: none !important;
  }`, document.head.appendChild(t), document.body.clientHeight, document.head.removeChild(r), () => {
    t.parentNode?.removeChild(t);
  };
}
s(er, "pauseAnimations");
async function rr(e) {
  if (!("document" in globalThis && "getAnimations" in globalThis.document && "querySelectorAll" in globalThis.document))
    return;
  let r = !1;
  await Promise.race([
    // After 50ms, retrieve any running animations and wait for them to finish
    // If new animations are created while waiting, we'll wait for them too
    new Promise((t) => {
      setTimeout(() => {
        let o = [globalThis.document, ...tr(globalThis.document)], a = /* @__PURE__ */ s(async () => {
          if (r || e?.aborted)
            return;
          let n = o.flatMap((i) => i?.getAnimations?.() || []).filter((i) => i.playState === "running" && !Or(i));
          n.length > 0 && (await Promise.all(n.map((i) => i.finished)), await a());
        }, "checkAnimationsFinished");
        a().then(t);
      }, 100);
    }),
    // If animations don't finish within the timeout, continue without waiting
    new Promise(
      (t) => setTimeout(() => {
        r = !0, t(void 0);
      }, 5e3)
    )
  ]);
}
s(rr, "waitForAnimations");
function tr(e) {
  return [e, ...e.querySelectorAll("*")].reduce((r, t) => ("shadowRoot" in t && t.shadowRoot && r.push(t.shadowRoot, ...tr(t.shadowRoot)), r),
  []);
}
s(tr, "getShadowRoots");
function Or(e) {
  if (e instanceof CSSAnimation && e.effect instanceof KeyframeEffect && e.effect.target) {
    let r = getComputedStyle(e.effect.target, e.effect.pseudoElement), t = r.animationName?.split(", ").indexOf(e.animationName);
    return r.animationIterationCount.split(", ")[t] === "infinite";
  }
  return !1;
}
s(Or, "isInfiniteAnimation");

// src/preview-api/modules/store/reporter-api.ts
var X = class {
  constructor() {
    this.reports = [];
  }
  static {
    s(this, "ReporterAPI");
  }
  async addReport(r) {
    this.reports.push(r);
  }
};

// src/preview-api/modules/store/csf/portable-stories.ts
var Nr = "ComposedStory", Ir = "Unnamed Story";
var k = [];
function ue(e, r, t, o, a) {
  if (e === void 0)
    throw new Error("Expected a story but received undefined.");
  r.title = r.title ?? Nr;
  let n = Me(r), i = a || e.storyName || e.story?.name || e.name || Ir, p = ae(
    i,
    e,
    n
  ), l = M(
    H([
      o ?? globalThis.globalProjectAnnotations ?? {},
      t ?? {}
    ])
  ), c = pe(
    p,
    n,
    l
  ), f = {
    ...Ie(l.globalTypes),
    ...l.initialGlobals,
    ...c.storyGlobals
  }, m = new X(), h = /* @__PURE__ */ s(() => {
    let u = Ve({
      hooks: new G(),
      globals: f,
      args: { ...c.initialArgs },
      viewMode: "story",
      reporting: m,
      loaded: {},
      abortSignal: new AbortController().signal,
      step: /* @__PURE__ */ s((g, b) => c.runStep(g, b, u), "step"),
      canvasElement: null,
      canvas: {},
      userEvent: {},
      globalTypes: l.globalTypes,
      ...c,
      context: null,
      mount: null
    });
    return u.parameters.__isPortableStory = !0, u.context = u, c.renderToCanvas && (u.renderToCanvas = async () => {
      let g = await c.renderToCanvas?.(
        {
          componentId: c.componentId,
          title: c.title,
          id: c.id,
          name: c.name,
          tags: c.tags,
          showMain: /* @__PURE__ */ s(() => {
          }, "showMain"),
          showError: /* @__PURE__ */ s((b) => {
            throw new Error(`${b.title}
${b.description}`);
          }, "showError"),
          showException: /* @__PURE__ */ s((b) => {
            throw b;
          }, "showException"),
          forceRemount: !0,
          storyContext: u,
          storyFn: /* @__PURE__ */ s(() => c.unboundStoryFn(u), "storyFn"),
          unboundStoryFn: c.unboundStoryFn
        },
        u.canvasElement
      );
      g && k.push(g);
    }), u.mount = c.mount(u), u;
  }, "initializeContext"), S, O = /* @__PURE__ */ s(async (u) => {
    let g = h();
    return g.canvasElement ??= globalThis?.document?.body, S && (g.loaded = S.loaded), Object.assign(g, u), c.playFunction(g);
  }, "play"), P = /* @__PURE__ */ s((u) => {
    let g = h();
    return Object.assign(g, u), zr(c, g);
  }, "run"), A = c.playFunction ? O : void 0;
  return Object.assign(
    /* @__PURE__ */ s(function(g) {
      let b = h();
      return S && (b.loaded = S.loaded), b.args = {
        ...b.initialArgs,
        ...g
      }, c.unboundStoryFn(b);
    }, "storyFn"),
    {
      id: c.id,
      storyName: i,
      load: /* @__PURE__ */ s(async () => {
        for (let g of [...k].reverse())
          await g();
        k.length = 0;
        let u = h();
        u.loaded = await c.applyLoaders(u), k.push(...(await c.applyBeforeEach(u)).filter(Boolean)), S = u;
      }, "load"),
      globals: f,
      args: c.initialArgs,
      parameters: c.parameters,
      argTypes: c.argTypes,
      play: A,
      run: P,
      reporting: m,
      tags: c.tags
    }
  );
}
s(ue, "composeStory");
async function zr(e, r) {
  for (let n of [...k].reverse())
    await n();
  if (k.length = 0, !r.canvasElement) {
    let n = document.createElement("div");
    globalThis?.document?.body?.appendChild(n), r.canvasElement = n, k.push(() => {
      globalThis?.document?.body?.contains(n) && globalThis?.document?.body?.removeChild(n);
    });
  }
  if (r.loaded = await e.applyLoaders(r), r.abortSignal.aborted)
    return;
  k.push(...(await e.applyBeforeEach(r)).filter(Boolean));
  let t = e.playFunction, o = e.usesMount;
  if (o || await r.mount(), r.abortSignal.aborted)
    return;
  t && (o || (r.mount = async () => {
    throw new or.MountMustBeDestructuredError({ playFunction: t.toString() });
  }), await t(r));
  let a;
  Qe() ? a = er() : await rr(r.abortSignal), await e.applyAfterEach(r), await a?.();
}
s(zr, "runStory");

// src/csf/core-annotations.ts
var me = R(require("storybook/internal/component-testing/preview"), 1), ye = R(require("storybook/actions/preview"), 1), ge = R(require("storybook/backgrounds/preview"), 1),
Te = R(require("storybook/highlight/preview"), 1), xe = R(require("storybook/measure/preview"), 1), he = R(require("storybook/outline/preview"), 1),
Se = R(require("storybook/test/preview"), 1), Ae = R(require("storybook/viewport/preview"), 1);
function be() {
  return [
    // @ts-expect-error CJS fallback
    (xe.default.default ?? xe.default)(),
    // @ts-expect-error CJS fallback
    (ge.default.default ?? ge.default)(),
    // @ts-expect-error CJS fallback
    (Te.default.default ?? Te.default)(),
    // @ts-expect-error CJS fallback
    (he.default.default ?? he.default)(),
    // @ts-expect-error CJS fallback
    (Ae.default.default ?? Ae.default)(),
    // @ts-expect-error CJS fallback
    (ye.default.default ?? ye.default)(),
    // @ts-expect-error CJS fallback
    (me.default.default ?? me.default)(),
    // @ts-expect-error CJS fallback
    (Se.default.default ?? Se.default)()
  ];
}
s(be, "getCoreAnnotations");

// src/csf/csf-factories.ts
function Dr(e) {
  let r, t = {
    _tag: "Preview",
    input: e,
    get composed() {
      if (r)
        return r;
      let { addons: o, ...a } = e;
      return r = M(
        H([...be(), ...o ?? [], a])
      ), r;
    },
    meta(o) {
      return Hr(o, this);
    }
  };
  return globalThis.globalProjectAnnotations = t.composed, t;
}
s(Dr, "definePreview");
function Mr(e) {
  return e;
}
s(Mr, "definePreviewAddon");
function Br(e) {
  return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Preview";
}
s(Br, "isPreview");
function Ur(e) {
  return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Meta";
}
s(Ur, "isMeta");
function Hr(e, r) {
  return {
    _tag: "Meta",
    input: e,
    preview: r,
    get composed() {
      throw new Error("Not implemented");
    },
    story(t = {}) {
      return sr(typeof t == "function" ? { render: t } : t, this);
    }
  };
}
s(Hr, "defineMeta");
function $r(e) {
  return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Story";
}
s($r, "isStory");
function sr(e, r) {
  let t, o = /* @__PURE__ */ s(() => (t || (t = ue(
    e,
    r.input,
    void 0,
    r.preview.composed
  )), t), "compose");
  return {
    _tag: "Story",
    input: e,
    meta: r,
    __compose: o,
    get composed() {
      throw new Error("Not implemented");
    },
    get play() {
      return e.play ?? r.input?.play ?? (async () => {
      });
    },
    get run() {
      return o().run ?? (async () => {
      });
    },
    extend(a) {
      return sr(
        {
          ...this.input,
          ...a,
          args: { ...this.input.args, ...a.args },
          argTypes: x(this.input.argTypes, a.argTypes),
          afterEach: [
            ...d(this.input?.afterEach ?? []),
            ...d(a.afterEach ?? [])
          ],
          beforeEach: [
            ...d(this.input?.beforeEach ?? []),
            ...d(a.beforeEach ?? [])
          ],
          decorators: [
            ...d(this.input?.decorators ?? []),
            ...d(a.decorators ?? [])
          ],
          globals: { ...this.input.globals, ...a.globals },
          loaders: [
            ...d(this.input?.loaders ?? []),
            ...d(a.loaders ?? [])
          ],
          parameters: x(this.input.parameters, a.parameters),
          tags: (0, nr.combineTags)(...this.input.tags ?? [], ...a.tags ?? [])
        },
        this.meta
      );
    }
  };
}
s(sr, "defineStory");

// src/csf/index.ts
var pr = /* @__PURE__ */ s((e) => e.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g,
"-").replace(/^-+/, "").replace(/-+$/, ""), "sanitize"), ar = /* @__PURE__ */ s((e, r) => {
  let t = pr(e);
  if (t === "")
    throw new Error(`Invalid ${r} '${e}', must include alphanumeric characters`);
  return t;
}, "sanitizeSafe"), Lr = /* @__PURE__ */ s((e, r) => `${ar(e, "kind")}${r ? `--${ar(r, "name")}` : ""}`, "toId"), Wr = /* @__PURE__ */ s((e) => we(
e), "storyNameFromExport");
function ir(e, r) {
  return Array.isArray(r) ? r.includes(e) : e.match(r);
}
s(ir, "matches");
function Gr(e, { includeStories: r, excludeStories: t }) {
  return (
    // https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs
    e !== "__esModule" && (!r || ir(e, r)) && (!t || !ir(e, t))
  );
}
s(Gr, "isExportStory");
var Vr = /* @__PURE__ */ s((e, { rootSeparator: r, groupSeparator: t }) => {
  let [o, a] = e.split(r, 2), n = (a || e).split(t).filter((i) => !!i);
  return {
    root: a ? o : null,
    groups: n
  };
}, "parseKind"), qr = /* @__PURE__ */ s((...e) => {
  let r = e.reduce((t, o) => (o.startsWith("!") ? t.delete(o.slice(1)) : t.add(o), t), /* @__PURE__ */ new Set());
  return Array.from(r);
}, "combineTags");
