var Ge = Object.create;
var L = Object.defineProperty;
var Ve = Object.getOwnPropertyDescriptor;
var qe = Object.getOwnPropertyNames;
var Ke = Object.getPrototypeOf, Ye = Object.prototype.hasOwnProperty;
var s = (e, r) => L(e, "name", { value: r, configurable: !0 });
var Je = (e, r) => () => (r || e((r = { exports: {} }).exports, r), r.exports);
var Xe = (e, r, t, o) => {
  if (r && typeof r == "object" || typeof r == "function")
    for (let a of qe(r))
      !Ye.call(e, a) && a !== t && L(e, a, { get: () => r[a], enumerable: !(o = Ve(r, a)) || o.enumerable });
  return e;
};
var Ze = (e, r, t) => (t = e != null ? Ge(Ke(e)) : {}, Xe(
  // 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 ? L(t, "default", { value: e, enumerable: !0 }) : t,
  e
));

// ../node_modules/@ngard/tiny-isequal/index.js
var fe = Je((W) => {
  Object.defineProperty(W, "__esModule", { value: !0 }), W.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, []);
    };
  }();
});

// src/csf/toStartCaseStr.ts
function le(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(le, "toStartCaseStr");

// src/csf/includeConditionalArg.ts
var G = Ze(fe(), 1);
var ue = /* @__PURE__ */ s((e) => e.map((r) => typeof r < "u").filter(Boolean).length, "count"), Qe = /* @__PURE__ */ s((e, r) => {
  let { exists: t, eq: o, neq: a, truthy: n } = e;
  if (ue([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, G.isEqual)(r, o);
  if (typeof a < "u")
    return !(0, G.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"), er = /* @__PURE__ */ s((e, r, t) => {
  if (!e.if)
    return !0;
  let { arg: o, global: a } = e.if;
  if (ue([o, a]) !== 1)
    throw new Error(`Invalid conditional value ${JSON.stringify({ arg: o, global: a })}`);
  let n = o ? r[o] : t[a];
  return Qe(e.if, n);
}, "includeConditionalArg");

// src/csf/csf-factories.ts
import { combineTags as kr } from "storybook/internal/csf";

// src/preview-api/modules/addons/main.ts
import { global as V } from "@storybook/global";

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

// src/preview-api/modules/addons/main.ts
var J = class J {
  constructor() {
    this.getChannel = /* @__PURE__ */ s(() => {
      if (!this.channel) {
        let r = me();
        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());
    });
  }
};
s(J, "AddonStore");
var K = J, q = "__STORYBOOK_ADDONS_PREVIEW";
function tr() {
  return V[q] || (V[q] = new K()), V[q];
}
s(tr, "getAddonsStore");
var Y = tr();

// src/preview-api/modules/addons/hooks.ts
import { logger as qr } from "storybook/internal/client-logger";
import {
  FORCE_RE_RENDER as Yr,
  RESET_STORY_ARGS as Jr,
  STORY_RENDERED as ye,
  UPDATE_GLOBALS as Xr,
  UPDATE_STORY_ARGS as Zr
} from "storybook/internal/core-events";
import { global as X } from "@storybook/global";
var Q = class Q {
  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();
  }
  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(), Y.getChannel().on(ye, this.renderListener);
  }
  removeRenderListeners() {
    Y.getChannel().removeListener(ye, this.renderListener);
  }
};
s(Q, "HooksContext");
var B = Q;
function ge(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 = X.STORYBOOK_HOOKS_CONTEXT;
    X.STORYBOOK_HOOKS_CONTEXT = o;
    let c = e(...t);
    if (X.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(ge, "hookify");
var Z = 0, or = 25, Te = /* @__PURE__ */ s((e) => (r, t) => {
  let o = e(
    ge(r),
    t.map((a) => ge(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 (Z = 1; n.hasUpdates; )
      if (n.hasUpdates = !1, n.currentEffects = [], i = o(a), Z += 1, Z > or)
        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 N(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(N, "isPlainObject");

// ../node_modules/es-toolkit/dist/object/mapValues.mjs
function w(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(w, "mapValues");

// ../node_modules/es-toolkit/dist/object/pickBy.mjs
function ee(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(ee, "pickBy");

// src/preview-api/modules/store/args.ts
import { once as gt } from "storybook/internal/client-logger";

// ../node_modules/ts-dedent/esm/index.js
function F(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(F, "dedent");

// src/preview-api/modules/store/args.ts
var xt = Symbol("incompatible");
var ht = Symbol("Deeply equal");
var re = "UNTARGETED";
function xe({
  args: e,
  argTypes: r
}) {
  let t = {};
  return Object.entries(e).forEach(([o, a]) => {
    let { target: n = re } = r[o] || {};
    t[n] = t[n] || {}, t[n][o] = a;
  }), t;
}
s(xe, "groupArgsByTarget");

// src/preview-api/modules/store/csf/getValuesFromArgTypes.ts
var he = /* @__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 nr = /* @__PURE__ */ s((e) => typeof e == "string" ? { name: e } : e, "normalizeType"), sr = /* @__PURE__ */ s((e) => typeof e == "strin\
g" ? { type: e } : e, "normalizeControl"), ar = /* @__PURE__ */ s((e, r) => {
  let { type: t, control: o, ...a } = e, n = {
    name: r,
    ...a
  };
  return t && (n.type = nr(t)), o ? n.control = sr(o) : o === !1 && (n.control = { disable: !0 }), n;
}, "normalizeInputType"), O = /* @__PURE__ */ s((e) => w(e, ar), "normalizeInputTypes");

// src/preview-api/modules/store/csf/normalizeStory.ts
import { deprecate as ir, logger as pr } from "storybook/internal/client-logger";
import { storyNameFromExport as cr, toId as dr } from "storybook/internal/csf";

// 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 lr = F`
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 te(e, r, t) {
  let o = r, a = typeof r == "function" ? r : null, { story: n } = o;
  n && (pr.debug("deprecated story", n), ir(lr));
  let i = cr(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: k, play: E, tags: A = [], globals: R = {} } = o, u = c.__id || dr(t.id, i);
  return {
    moduleExport: r,
    id: u,
    name: p,
    tags: A,
    decorators: l,
    parameters: c,
    args: y,
    argTypes: O(f),
    loaders: m,
    beforeEach: h,
    afterEach: S,
    globals: R,
    ...k && { render: k },
    ...a && { userStoryFn: a },
    ...E && { play: E }
  };
}
s(te, "normalizeStory");

// src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts
import { sanitize as fr } from "storybook/internal/csf";
function Se(e, r = e.title, t) {
  let { id: o, argTypes: a } = e;
  return {
    id: fr(o || r),
    ...e,
    title: r,
    ...a && { argTypes: O(a) },
    parameters: {
      fileName: t,
      ...e.parameters
    }
  };
}
s(Se, "normalizeComponentAnnotations");

// src/preview-api/modules/store/csf/prepareStory.ts
import { combineTags as mr, includeConditionalArg as yr } from "storybook/internal/csf";
import { NoRenderFunctionError as gr } from "storybook/internal/preview-errors";
import { global as Tr } from "@storybook/global";
import { global as xr } from "@storybook/global";

// src/preview-api/modules/preview-web/render/mount-utils.ts
function be(e) {
  return e != null && ur(e).includes("mount");
}
s(be, "mountDestructured");
function ur(e) {
  let r = e.toString().match(/[^(]*\(([^)]*)/);
  if (!r)
    return [];
  let t = Ae(r[1]);
  if (!t.length)
    return [];
  let o = t[0];
  return o.startsWith("{") && o.endsWith("}") ? Ae(o.slice(1, -1).replace(/\s/g, "")).map((n) => n.replace(/:.*|=.*/g, "")) : [];
}
s(ur, "getUsedProps");
function Ae(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(Ae, "splitByComma");

// src/preview-api/modules/store/decorators.ts
function Re(e, r, t) {
  let o = t(e);
  return (a) => r(o, a);
}
s(Re, "decorateStory");
function Ce({
  componentId: e,
  title: r,
  kind: t,
  id: o,
  name: a,
  story: n,
  parameters: i,
  initialArgs: p,
  argTypes: l,
  ...c
} = {}) {
  return c;
}
s(Ce, "sanitizeStoryContextUpdate");
function oe(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,
      ...Ce(i)
    }, n(t.value);
  }, "bindWithContext"), a = r.reduce(
    (n, i) => Re(n, i, o),
    e
  );
  return (n) => (t.value = n, a(n));
}
s(oe, "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 : N(p) && N(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) => N(i)) ? o[a] = x(...n) : o[a] = n[n.length - 1];
  }), o;
}, "combineParameters");

// src/preview-api/modules/store/csf/prepareStory.ts
function ne(e, r, t) {
  let { moduleExport: o, id: a, name: n } = e || {}, i = hr(
    e,
    r,
    t
  ), p = /* @__PURE__ */ s(async (T) => {
    let C = {};
    for (let j of [
      d(t.loaders),
      d(r.loaders),
      d(e.loaders)
    ]) {
      if (T.abortSignal.aborted)
        return C;
      let M = await Promise.all(j.map((We) => We(T)));
      Object.assign(C, ...M);
    }
    return C;
  }, "applyLoaders"), l = /* @__PURE__ */ s(async (T) => {
    let C = new Array();
    for (let j of [
      ...d(t.beforeEach),
      ...d(r.beforeEach),
      ...d(e.beforeEach)
    ]) {
      if (T.abortSignal.aborted)
        return C;
      let M = await j(T);
      M && C.push(M);
    }
    return C;
  }, "applyBeforeEach"), c = /* @__PURE__ */ s(async (T) => {
    let C = [
      ...d(t.afterEach),
      ...d(r.afterEach),
      ...d(e.afterEach)
    ].reverse();
    for (let j of C) {
      if (T.abortSignal.aborted)
        return;
      await j(T);
    }
  }, "applyAfterEach"), y = /* @__PURE__ */ s((T) => T.originalStoryFn(T.args, T), "undecoratedStoryFn"), { applyDecorators: f = oe, runStep: m } = t,
  h = [
    ...d(e?.decorators),
    ...d(r?.decorators),
    ...d(t?.decorators)
  ], S = e?.userStoryFn || e?.render || r.render || t.render, k = Te(f)(y, h), E = /* @__PURE__ */ s((T) => k(T), "unboundStoryFn"), A = e?.
  play ?? r?.play, R = be(A);
  if (!S && !R)
    throw new gr({ 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: E,
    applyLoaders: p,
    applyBeforeEach: l,
    applyAfterEach: c,
    playFunction: A,
    runStep: m,
    mount: g,
    testingLibraryRender: b,
    renderToCanvas: t.renderToCanvas,
    usesMount: R
  };
}
s(ne, "prepareStory");
function hr(e, r, t) {
  let o = ["dev", "test"], a = xr.DOCS_OPTIONS?.autodocs === !0 ? ["autodocs"] : [], n = mr(
    ...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, R) => R({ ...m, argTypes: A }),
    m.argTypes
  );
  let h = { ...y };
  m.initialArgs = [...l].reduce(
    (A, R) => ({
      ...A,
      ...R({
        ...m,
        initialArgs: A
      })
    }),
    h
  );
  let { name: S, story: k, ...E } = m;
  return E;
}
s(hr, "preparePartialAnnotations");
function we(e) {
  let { args: r } = e, t = {
    ...e,
    allArgs: void 0,
    argsByTarget: void 0
  };
  if (Tr.FEATURES?.argTypeTargetsV7) {
    let n = xe(e);
    t = {
      ...e,
      allArgs: e.args,
      argsByTarget: n,
      args: n[re] || {}
    };
  }
  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 yr(l, o, t.globals) && (n[i] = p), n;
  }, {});
  return { ...t, unmappedArgs: r, args: a };
}
s(we, "prepareContext");

// src/preview-api/modules/store/inferArgTypes.ts
import { logger as Sr } from "storybook/internal/client-logger";
var se = /* @__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) ? (Sr.warn(F`
        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 ? se(e[0], r, new Set(
  t)) : { name: "other", value: "unknown" } } : { name: "object", value: w(e, (n) => se(n, r, new Set(t))) }) : { name: "object", value: {} };
}, "inferType"), ae = /* @__PURE__ */ s((e) => {
  let { id: r, argTypes: t = {}, initialArgs: o = {} } = e, a = w(o, (i, p) => ({
    name: p,
    type: se(i, `${r}.${p}`, /* @__PURE__ */ new Set())
  })), n = w(t, (i, p) => ({
    name: p
  }));
  return x(a, n, t);
}, "inferArgTypes");
ae.secondPass = !0;

// src/preview-api/modules/store/inferControls.ts
import { logger as Ar } from "storybook/internal/client-logger";

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

// src/preview-api/modules/store/inferControls.ts
var br = /* @__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" && Ar.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"), U = /* @__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 = ie(r, o, a), p = w(i, (l, c) => l?.type && br(l, c.toString(), n));
  return x(p, i);
}, "inferControls");
U.secondPass = !0;

// src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts
function _({
  argTypes: e,
  globalTypes: r,
  argTypesEnhancers: t,
  decorators: o,
  loaders: a,
  beforeEach: n,
  afterEach: i,
  initialGlobals: p,
  ...l
}) {
  return {
    ...e && { argTypes: O(e) },
    ...r && { globalTypes: O(r) },
    decorators: d(o),
    loaders: d(a),
    beforeEach: d(n),
    afterEach: d(i),
    argTypesEnhancers: [
      ...t || [],
      ae,
      // 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
      U
    ],
    initialGlobals: p,
    ...l
  };
}
s(_, "normalizeProjectAnnotations");

// src/preview-api/modules/store/csf/composeConfigs.ts
import { global as Rr } from "@storybook/global";

// src/preview-api/modules/store/csf/beforeAll.ts
var Pe = /* @__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 pe(e) {
  return async (r, t, o) => {
    await e.reduceRight(
      (n, i) => async () => i(r, n, o),
      async () => t(o)
    )();
  };
}
s(pe, "composeStepRunners");

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

// src/preview-api/modules/store/csf/portable-stories.ts
import { isExportStory as Lo } from "storybook/internal/csf";
import { getCoreAnnotations as Go } from "storybook/internal/csf";
import { MountMustBeDestructuredError as wr } from "storybook/internal/preview-errors";

// src/preview-api/modules/preview-web/render/animation-utils.ts
function ve() {
  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(ve, "isTestEnvironment");
function ke(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(ke, "pauseAnimations");
async function Oe(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, ...Fe(globalThis.document)], a = /* @__PURE__ */ s(async () => {
          if (r || e?.aborted)
            return;
          let n = o.flatMap((i) => i?.getAnimations?.() || []).filter((i) => i.playState === "running" && !Cr(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(Oe, "waitForAnimations");
function Fe(e) {
  return [e, ...e.querySelectorAll("*")].reduce((r, t) => ("shadowRoot" in t && t.shadowRoot && r.push(t.shadowRoot, ...Fe(t.shadowRoot)), r),
  []);
}
s(Fe, "getShadowRoots");
function Cr(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(Cr, "isInfiniteAnimation");

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

// src/preview-api/modules/store/csf/portable-stories.ts
var Er = "ComposedStory", Pr = "Unnamed Story";
var v = [];
function de(e, r, t, o, a) {
  if (e === void 0)
    throw new Error("Expected a story but received undefined.");
  r.title = r.title ?? Er;
  let n = Se(r), i = a || e.storyName || e.story?.name || e.name || Pr, p = te(
    i,
    e,
    n
  ), l = _(
    D([
      o ?? globalThis.globalProjectAnnotations ?? {},
      t ?? {}
    ])
  ), c = ne(
    p,
    n,
    l
  ), f = {
    ...he(l.globalTypes),
    ...l.initialGlobals,
    ...c.storyGlobals
  }, m = new $(), h = /* @__PURE__ */ s(() => {
    let u = we({
      hooks: new B(),
      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 && v.push(g);
    }), u.mount = c.mount(u), u;
  }, "initializeContext"), S, k = /* @__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"), E = /* @__PURE__ */ s((u) => {
    let g = h();
    return Object.assign(g, u), vr(c, g);
  }, "run"), A = c.playFunction ? k : 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 [...v].reverse())
          await g();
        v.length = 0;
        let u = h();
        u.loaded = await c.applyLoaders(u), v.push(...(await c.applyBeforeEach(u)).filter(Boolean)), S = u;
      }, "load"),
      globals: f,
      args: c.initialArgs,
      parameters: c.parameters,
      argTypes: c.argTypes,
      play: A,
      run: E,
      reporting: m,
      tags: c.tags
    }
  );
}
s(de, "composeStory");
async function vr(e, r) {
  for (let n of [...v].reverse())
    await n();
  if (v.length = 0, !r.canvasElement) {
    let n = document.createElement("div");
    globalThis?.document?.body?.appendChild(n), r.canvasElement = n, v.push(() => {
      globalThis?.document?.body?.contains(n) && globalThis?.document?.body?.removeChild(n);
    });
  }
  if (r.loaded = await e.applyLoaders(r), r.abortSignal.aborted)
    return;
  v.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 wr({ playFunction: t.toString() });
  }), await t(r));
  let a;
  ve() ? a = ke() : await Oe(r.abortSignal), await e.applyAfterEach(r), await a?.();
}
s(vr, "runStory");

// src/csf/core-annotations.ts
import je from "storybook/internal/component-testing/preview";
import Ne from "storybook/actions/preview";
import _e from "storybook/backgrounds/preview";
import Ie from "storybook/highlight/preview";
import ze from "storybook/measure/preview";
import De from "storybook/outline/preview";
import Me from "storybook/test/preview";
import Be from "storybook/viewport/preview";
function Ue() {
  return [
    // @ts-expect-error CJS fallback
    (ze.default ?? ze)(),
    // @ts-expect-error CJS fallback
    (_e.default ?? _e)(),
    // @ts-expect-error CJS fallback
    (Ie.default ?? Ie)(),
    // @ts-expect-error CJS fallback
    (De.default ?? De)(),
    // @ts-expect-error CJS fallback
    (Be.default ?? Be)(),
    // @ts-expect-error CJS fallback
    (Ne.default ?? Ne)(),
    // @ts-expect-error CJS fallback
    (je.default ?? je)(),
    // @ts-expect-error CJS fallback
    (Me.default ?? Me)()
  ];
}
s(Ue, "getCoreAnnotations");

// src/csf/csf-factories.ts
function Mn(e) {
  let r, t = {
    _tag: "Preview",
    input: e,
    get composed() {
      if (r)
        return r;
      let { addons: o, ...a } = e;
      return r = _(
        D([...Ue(), ...o ?? [], a])
      ), r;
    },
    meta(o) {
      return Or(o, this);
    }
  };
  return globalThis.globalProjectAnnotations = t.composed, t;
}
s(Mn, "definePreview");
function Bn(e) {
  return e;
}
s(Bn, "definePreviewAddon");
function Un(e) {
  return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Preview";
}
s(Un, "isPreview");
function Hn(e) {
  return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Meta";
}
s(Hn, "isMeta");
function Or(e, r) {
  return {
    _tag: "Meta",
    input: e,
    preview: r,
    get composed() {
      throw new Error("Not implemented");
    },
    story(t = {}) {
      return He(typeof t == "function" ? { render: t } : t, this);
    }
  };
}
s(Or, "defineMeta");
function $n(e) {
  return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Story";
}
s($n, "isStory");
function He(e, r) {
  let t, o = /* @__PURE__ */ s(() => (t || (t = de(
    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 He(
        {
          ...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: kr(...this.input.tags ?? [], ...a.tags ?? [])
        },
        this.meta
      );
    }
  };
}
s(He, "defineStory");

// src/csf/index.ts
var Fr = /* @__PURE__ */ s((e) => e.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g,
"-").replace(/^-+/, "").replace(/-+$/, ""), "sanitize"), $e = /* @__PURE__ */ s((e, r) => {
  let t = Fr(e);
  if (t === "")
    throw new Error(`Invalid ${r} '${e}', must include alphanumeric characters`);
  return t;
}, "sanitizeSafe"), Vn = /* @__PURE__ */ s((e, r) => `${$e(e, "kind")}${r ? `--${$e(r, "name")}` : ""}`, "toId"), qn = /* @__PURE__ */ s((e) => le(
e), "storyNameFromExport");
function Le(e, r) {
  return Array.isArray(r) ? r.includes(e) : e.match(r);
}
s(Le, "matches");
function Kn(e, { includeStories: r, excludeStories: t }) {
  return (
    // https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs
    e !== "__esModule" && (!r || Le(e, r)) && (!t || !Le(e, t))
  );
}
s(Kn, "isExportStory");
var Yn = /* @__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"), Jn = /* @__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");
export {
  Jn as combineTags,
  Mn as definePreview,
  Bn as definePreviewAddon,
  Ue as getCoreAnnotations,
  er as includeConditionalArg,
  Kn as isExportStory,
  Hn as isMeta,
  Un as isPreview,
  $n as isStory,
  Yn as parseKind,
  Fr as sanitize,
  qn as storyNameFromExport,
  Vn as toId
};
