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 L } from "storybook/preview-api";

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

// 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";

// src/actions/constants.ts
var m = "storybook/actions", Y = `${m}/panel`, b = `${m}/action-event`, $ = `${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"), P = /* @__PURE__ */ n((t) => !!(typeof t == "object" && t && O(t, (e) => /^Synthetic(?:Base)?Event$/.test(e.constructor.name)) &&
typeof t.persist == "function"), "isReactSyntheticEvent"), S = /* @__PURE__ */ n((t) => {
  if (P(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");
function g(t, e = {}) {
  let o = {
    ...E,
    ...e
  }, r = /* @__PURE__ */ n(function(...s) {
    if (e.implicit) {
      let u = ("__STORYBOOK_PREVIEW__" in R ? 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 = Date.now().toString(36) + Math.random().toString(36).substring(2), p = 5, l = s.map(S), D = s.length > 1 ? l :
    l[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 w = /* @__PURE__ */ n((t, e) => typeof e[t] > "u" && !(t in e), "isInInitialArgs"), v = /* @__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, l]) => (w(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]) => (w(a, e) && (s[a] = g(typeof c.action ==
  "string" ? c.action : a)), s), {});
}, "addActionsFromArgTypes");

// src/actions/addArgs.ts
var F = [
  T,
  v
];

// src/actions/loaders.ts
var f = {};
x(f, {
  loaders: () => M
});
import { onMockCall as C } from "storybook/test/spy";
var _ = !1, W = /* @__PURE__ */ n((t) => {
  let { parameters: e } = t;
  e?.actions?.disable || _ || (C((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"), M = [W];

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