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

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

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

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

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