"use strict";
var a = Object.defineProperty;
var x = Object.getOwnPropertyDescriptor;
var R = Object.getOwnPropertyNames;
var j = Object.prototype.hasOwnProperty;
var r = (t, o) => a(t, "name", { value: o, configurable: !0 });
var I = (t, o) => {
  for (var n in o)
    a(t, n, { get: o[n], enumerable: !0 });
}, P = (t, o, n, e) => {
  if (o && typeof o == "object" || typeof o == "function")
    for (let i of R(o))
      !j.call(t, i) && i !== n && a(t, i, { get: () => o[i], enumerable: !(e = x(o, i)) || e.enumerable });
  return t;
};
var S = (t) => P(a({}, "__esModule", { value: !0 }), t);

// src/actions/index.ts
var K = {};
I(K, {
  ADDON_ID: () => m,
  CLEAR_ID: () => C,
  CYCLIC_KEY: () => F,
  EVENT_ID: () => y,
  PANEL_ID: () => k,
  PARAM_KEY: () => T,
  action: () => l,
  actions: () => B,
  config: () => s,
  configureActions: () => V
});
module.exports = S(K);

// src/actions/constants.ts
var T = "actions", m = "storybook/actions", k = `${m}/panel`, y = `${m}/action-event`, C = `${m}/action-clear`, F = "$___storybook.isCyclic";

// src/actions/runtime/action.ts
var A = require("storybook/internal/preview-errors"), f = require("@storybook/global"), O = require("storybook/preview-api"), h = require("uuid");

// src/actions/runtime/configureActions.ts
var s = {
  depth: 10,
  clearOnStoryChange: !0,
  limit: 50
}, V = /* @__PURE__ */ r((t = {}) => {
  Object.assign(s, t);
}, "configureActions");

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

// src/actions/runtime/actions.ts
var B = /* @__PURE__ */ r((...t) => {
  let o = s, n = t;
  n.length === 1 && Array.isArray(n[0]) && ([n] = n), n.length !== 1 && typeof n[n.length - 1] != "string" && (o = {
    ...s,
    ...n.pop()
  });
  let e = n[0];
  (n.length !== 1 || typeof e == "string") && (e = {}, n.forEach((c) => {
    e[c] = c;
  }));
  let i = {};
  return Object.keys(e).forEach((c) => {
    i[c] = l(e[c], o);
  }), i;
}, "actions");
