"use strict";
var T = Object.defineProperty;
var A = Object.getOwnPropertyDescriptor;
var Y = Object.getOwnPropertyNames;
var N = Object.prototype.hasOwnProperty;
var n = (t, e) => T(t, "name", { value: e, configurable: !0 });
var K = (t, e) => {
  for (var r in e)
    T(t, r, { get: e[r], enumerable: !0 });
}, B = (t, e, r, s) => {
  if (e && typeof e == "object" || typeof e == "function")
    for (let o of Y(e))
      !N.call(t, o) && o !== r && T(t, o, { get: () => e[o], enumerable: !(s = A(e, o)) || s.enumerable });
  return t;
};
var U = (t) => B(T({}, "__esModule", { value: !0 }), t);

// src/test/spy.ts
var oe = {};
K(oe, {
  clearAllMocks: () => Z,
  fn: () => X,
  isMockFunction: () => j,
  mocked: () => ne,
  mocks: () => O,
  onMockCall: () => J,
  resetAllMocks: () => ee,
  restoreAllMocks: () => te,
  spyOn: () => Q
});
module.exports = U(oe);

// ../node_modules/tinyspy/dist/index.js
function I(t, e) {
  if (!t)
    throw new Error(e);
}
n(I, "d");
function g(t, e) {
  return typeof e === t;
}
n(g, "y");
function W(t) {
  return t instanceof Promise;
}
n(W, "w");
function w(t, e, r) {
  Object.defineProperty(t, e, r);
}
n(w, "f");
function h(t, e, r) {
  Object.defineProperty(t, e, { value: r });
}
n(h, "l");
var v = Symbol.for("tinyspy:spy"), $ = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ n((t) => {
  t.called = !1, t.callCount = 0, t.calls = [], t.results = [], t.resolves = [], t.next = [];
}, "P"), z = /* @__PURE__ */ n((t) => (w(t, v, { value: { reset: /* @__PURE__ */ n(() => q(t[v]), "reset") } }), t[v]), "K"), M = /* @__PURE__ */ n(
(t) => t[v] || z(t), "T");
function G(t) {
  I(
    g("function", t) || g("undefined", t),
    "cannot spy on a non-function value"
  );
  let e = /* @__PURE__ */ n(function(...s) {
    let o = M(e);
    o.called = !0, o.callCount++, o.calls.push(s);
    let p = o.next.shift();
    if (p) {
      o.results.push(p);
      let [c, y] = p;
      if (c === "ok")
        return y;
      throw y;
    }
    let i, f = "ok", a = o.results.length;
    if (o.impl)
      try {
        new.target ? i = Reflect.construct(o.impl, s, new.target) : i = o.impl.apply(this, s), f = "ok";
      } catch (c) {
        throw i = c, f = "error", o.results.push([f, c]), c;
      }
    let m = [f, i];
    return W(i) && i.then(
      (c) => o.resolves[a] = ["ok", c],
      (c) => o.resolves[a] = ["error", c]
    ), o.results.push(m), i;
  }, "t");
  h(e, "_isMockFunction", !0), h(e, "length", t ? t.length : 0), h(e, "name", t && t.name || "spy");
  let r = M(e);
  return r.reset(), r.impl = t, e;
}
n(G, "m");
var C = /* @__PURE__ */ n((t, e) => Object.getOwnPropertyDescriptor(t, e), "k"), _ = /* @__PURE__ */ n((t, e) => {
  e != null && typeof e == "function" && e.prototype != null && Object.setPrototypeOf(t.prototype, e.prototype);
}, "O");
function P(t, e, r) {
  I(
    !g("undefined", t),
    "spyOn could not find an object to spy upon"
  ), I(
    g("object", t) || g("function", t),
    "cannot spyOn on a primitive value"
  );
  let [s, o] = (() => {
    if (!g("object", e))
      return [e, "value"];
    if ("getter" in e && "setter" in e)
      throw new Error("cannot spy on both getter and setter");
    if ("getter" in e)
      return [e.getter, "get"];
    if ("setter" in e)
      return [e.setter, "set"];
    throw new Error("specify getter or setter to spy on");
  })(), p = C(t, s), i = Object.getPrototypeOf(t), f = i && C(i, s), a = p || f;
  I(
    a || s in t,
    `${String(s)} does not exist`
  );
  let m = !1;
  o === "value" && a && !a.value && a.get && (o = "get", m = !0, r = a.get());
  let c;
  a ? c = a[o] : o !== "value" ? c = /* @__PURE__ */ n(() => t[s], "o") : c = t[s];
  let y = /* @__PURE__ */ n((k) => {
    let { value: S, ...d } = a || {
      configurable: !0,
      writable: !0
    };
    o !== "value" && delete d.writable, d[o] = k, w(t, s, d);
  }, "g"), x = /* @__PURE__ */ n(() => a ? w(t, s, a) : y(c), "b");
  r || (r = c);
  let l = G(r);
  o === "value" && _(l, c);
  let u = l[v];
  return h(u, "restore", x), h(u, "getOriginal", () => m ? c() : c), h(u, "willCall", (k) => (u.impl = k, l)), y(
    m ? () => (_(l, r), l) : l
  ), $.add(l), l;
}
n(P, "C");

// ../node_modules/@vitest/spy/dist/index.js
var O = /* @__PURE__ */ new Set();
function j(t) {
  return typeof t == "function" && "_isMockFunction" in t && t._isMockFunction;
}
n(j, "isMockFunction");
function D(t, e, r) {
  let o = r ? { [{
    get: "getter",
    set: "setter"
  }[r]]: e } : e, p = P(t, o);
  return F(p);
}
n(D, "spyOn");
var H = 0;
function F(t) {
  let e = t, r, s = [], o = [], p = [], i = M(t), f = {
    get calls() {
      return i.calls;
    },
    get contexts() {
      return o;
    },
    get instances() {
      return s;
    },
    get invocationCallOrder() {
      return p;
    },
    get results() {
      return i.results.map(([l, u]) => ({ type: l === "error" ? "throw" : "return", value: u }));
    },
    get settledResults() {
      return i.resolves.map(([l, u]) => ({ type: l === "error" ? "rejected" : "fulfilled", value: u }));
    },
    get lastCall() {
      return i.calls[i.calls.length - 1];
    }
  }, a = [], m = !1;
  function c(...l) {
    return s.push(this), o.push(this), p.push(++H), (m ? r : a.shift() || r || i.getOriginal() || (() => {
    })).apply(this, l);
  }
  n(c, "mockCall");
  let y = e.name;
  e.getMockName = () => y || "vi.fn()", e.mockName = (l) => (y = l, e), e.mockClear = () => (i.reset(), s = [], o = [], p = [], e), e.mockReset =
  () => (e.mockClear(), r = void 0, a = [], e), e.mockRestore = () => (e.mockReset(), i.restore(), e), e.getMockImplementation = () => m ? r :
  a.at(0) || r, e.mockImplementation = (l) => (r = l, i.willCall(c), e), e.mockImplementationOnce = (l) => (a.push(l), e);
  function x(l, u) {
    let k = r;
    r = l, i.willCall(c), m = !0;
    let S = /* @__PURE__ */ n(() => {
      r = k, m = !1;
    }, "reset"), d = u();
    return d instanceof Promise ? d.then(() => (S(), e)) : (S(), e);
  }
  return n(x, "withImplementation"), e.withImplementation = x, e.mockReturnThis = () => e.mockImplementation(function() {
    return this;
  }), e.mockReturnValue = (l) => e.mockImplementation(() => l), e.mockReturnValueOnce = (l) => e.mockImplementationOnce(() => l), e.mockResolvedValue =
  (l) => e.mockImplementation(() => Promise.resolve(l)), e.mockResolvedValueOnce = (l) => e.mockImplementationOnce(() => Promise.resolve(l)),
  e.mockRejectedValue = (l) => e.mockImplementation(() => Promise.reject(l)), e.mockRejectedValueOnce = (l) => e.mockImplementationOnce(() => Promise.
  reject(l)), Object.defineProperty(e, "mock", {
    get: /* @__PURE__ */ n(() => f, "get")
  }), i.willCall(c), O.add(e), e;
}
n(F, "enhanceSpy");
function R(t) {
  let e = F(P({
    spy: t || function() {
    }
  }, "spy"));
  return t && e.mockImplementation(t), e;
}
n(R, "fn");

// src/test/spy.ts
var b = globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ || /* @__PURE__ */ new Set();
globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ = b;
function J(t) {
  return b.add(t), () => void b.delete(t);
}
n(J, "onMockCall");
var Q = /* @__PURE__ */ n((...t) => {
  let e = D(...t);
  return V(e);
}, "spyOn");
function X(t) {
  let e = t ? R(t) : R();
  return V(e);
}
n(X, "fn");
function V(t) {
  let e = L(t), r = e.mockImplementation.bind(null);
  return e.mockImplementation = (s) => L(r(s)), e;
}
n(V, "reactiveMock");
function L(t) {
  let e = M(t), r = e.impl;
  return e.willCall(function(...s) {
    return b.forEach((o) => o(t, s)), r?.apply(this, s);
  }), t;
}
n(L, "listenWhenCalled");
function Z() {
  O.forEach((t) => t.mockClear());
}
n(Z, "clearAllMocks");
function ee() {
  O.forEach((t) => t.mockReset());
}
n(ee, "resetAllMocks");
function te() {
  O.forEach((t) => t.mockRestore());
}
n(te, "restoreAllMocks");
function ne(t, e = {}) {
  return t;
}
n(ne, "mocked");
