var h = Object.defineProperty;
var n = (t, e) => h(t, "name", { value: e, configurable: !0 });
var x = (t, e) => {
  for (var o in e)
    h(t, o, { get: e[o], enumerable: !0 });
};

// src/actions/preview.ts
import { definePreview as N } from "storybook/preview-api";

// src/actions/addArgs.ts
var l = {};
x(l, {
  argsEnhancers: () => W
});

// src/actions/runtime/action.ts
import { ImplicitActionsDuringRendering as I } from "storybook/internal/preview-errors";
import { global as R } from "@storybook/global";
import { addons as j } from "storybook/preview-api";
import { v4 as P } from "uuid";

// src/actions/constants.ts
var m = "storybook/actions", B = `${m}/panel`, b = `${m}/action-event`, K = `${m}/action-clear`;

// src/actions/runtime/configureActions.ts
var E = {
  depth: 10,
  clearOnStoryChange: !0,
  limit: 50
};

// src/actions/runtime/action.ts
var O = /* @__PURE__ */ n((t, e) => {
  let o = Object.getPrototypeOf(t);
  return !o || e(o) ? o : O(o, e);
}, "findProto"), S = /* @__PURE__ */ n((t) => !!(typeof t == "object" && t && O(t, (e) => /^Synthetic(?:Base)?Event$/.test(e.constructor.name)) &&
typeof t.persist == "function"), "isReactSyntheticEvent"), F = /* @__PURE__ */ n((t) => {
  if (S(t)) {
    let e = Object.create(
      t.constructor.prototype,
      Object.getOwnPropertyDescriptors(t)
    );
    e.persist();
    let o = Object.getOwnPropertyDescriptor(e, "view"), r = o?.value;
    return typeof r == "object" && r?.constructor.name === "Window" && Object.defineProperty(e, "view", {
      ...o,
      value: Object.create(r.constructor.prototype)
    }), e;
  }
  return t;
}, "serializeArg"), C = /* @__PURE__ */ n(() => typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? P() : (
  // pseudo random id, example response lo1e7zm4832bkr7yfl7
  Date.now().toString(36) + Math.random().toString(36).substring(2)
), "generateId");
function g(t, e = {}) {
  let o = {
    ...E,
    ...e
  }, r = /* @__PURE__ */ n(function(...s) {
    if (e.implicit) {
      let u = ("__STORYBOOK_PREVIEW__" in R ? (
        // eslint-disable-next-line no-underscore-dangle
        R.__STORYBOOK_PREVIEW__
      ) : void 0)?.storyRenders.find(
        (d) => d.phase === "playing" || d.phase === "rendering"
      );
      if (u) {
        let d = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, A = new I({
          phase: u.phase,
          name: t,
          deprecated: d
        });
        if (d)
          console.warn(A);
        else
          throw A;
      }
    }
    let a = j.getChannel(), c = C(), p = 5, y = s.map(F), D = s.length > 1 ? y : y[0], k = {
      id: c,
      count: 0,
      data: { name: t, args: D },
      options: {
        ...o,
        maxDepth: p + (o.depth || 3)
      }
    };
    a.emit(b, k);
  }, "actionHandler");
  return r.isAction = !0, r.implicit = e.implicit, r;
}
n(g, "action");

// src/actions/addArgsHelpers.ts
var v = /* @__PURE__ */ n((t, e) => typeof e[t] > "u" && !(t in e), "isInInitialArgs"), w = /* @__PURE__ */ n((t) => {
  let {
    initialArgs: e,
    argTypes: o,
    id: r,
    parameters: { actions: i }
  } = t;
  if (!i || i.disable || !i.argTypesRegex || !o)
    return {};
  let s = new RegExp(i.argTypesRegex);
  return Object.entries(o).filter(
    ([c]) => !!s.test(c)
  ).reduce((c, [p, y]) => (v(p, e) && (c[p] = g(p, { implicit: !0, id: r })), c), {});
}, "inferActionsFromArgTypesRegex"), T = /* @__PURE__ */ n((t) => {
  let {
    initialArgs: e,
    argTypes: o,
    parameters: { actions: r }
  } = t;
  return r?.disable || !o ? {} : Object.entries(o).filter(([s, a]) => !!a.action).reduce((s, [a, c]) => (v(a, e) && (s[a] = g(typeof c.action ==
  "string" ? c.action : a)), s), {});
}, "addActionsFromArgTypes");

// src/actions/addArgs.ts
var W = [
  T,
  w
];

// src/actions/loaders.ts
var f = {};
x(f, {
  loaders: () => V
});
import { onMockCall as M } from "storybook/test/spy";
var _ = !1, L = /* @__PURE__ */ n((t) => {
  let { parameters: e } = t;
  e?.actions?.disable || _ || (M((o, r) => {
    let i = o.getMockName();
    i !== "spy" && (!/^next\/.*::/.test(i) || [
      "next/router::useRouter()",
      "next/navigation::useRouter()",
      "next/navigation::redirect",
      "next/cache::",
      "next/headers::cookies().set",
      "next/headers::cookies().delete",
      "next/headers::headers().set",
      "next/headers::headers().delete"
    ].some((s) => i.startsWith(s))) && g(i)(r);
  }), _ = !0);
}, "logActionsWhenMockCalled"), V = [L];

// src/actions/preview.ts
var dt = /* @__PURE__ */ n(() => N({
  ...l,
  ...f
}), "default");
export {
  dt as default
};
