import { effect as le, computed as U, untracked as x, batch as X, signal as fe } from "../../../../../@preact_signals-core@1.12.0/node_modules/@preact/signals-core/dist/signals-core.module.js";
import { Signal as Ie } from "../../../../../@preact_signals-core@1.12.0/node_modules/@preact/signals-core/dist/signals-core.module.js";
var _e = Object.create, G = Object.defineProperty, he = Object.defineProperties, pe = Object.getOwnPropertyDescriptor, ve = Object.getOwnPropertyDescriptors, Y = Object.getOwnPropertySymbols, de = Object.prototype.hasOwnProperty, ge = Object.prototype.propertyIsEnumerable, Oe = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), O = (e) => {
  throw TypeError(e);
}, A = (e, t, r) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, ye = (e, t) => {
  for (var r in t || (t = {}))
    de.call(t, r) && A(e, r, t[r]);
  if (Y)
    for (var r of Y(t))
      ge.call(t, r) && A(e, r, t[r]);
  return e;
}, we = (e, t) => he(e, ve(t)), Z = (e, t) => G(e, "name", { value: t, configurable: !0 }), Pe = (e) => {
  var t;
  return [, , , _e((t = void 0) != null ? t : null)];
}, ee = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], P = (e) => e !== void 0 && typeof e != "function" ? O("Function expected") : e, Se = (e, t, r, i, n) => ({ kind: ee[e], name: t, metadata: i, addInitializer: (a) => r._ ? O("Already initialized") : n.push(P(a || null)) }), te = (e, t) => A(t, Oe("metadata"), e[3]), d = (e, t, r, i) => {
  for (var n = 0, a = e[t >> 1], p = a && a.length; n < p; n++) t & 1 ? a[n].call(r) : i = a[n].call(r, i);
  return i;
}, y = (e, t, r, i, n, a) => {
  var p, l, L, w, j, s = t & 7, m = !!(t & 8), h = !!(t & 16), D = s > 3 ? e.length + 1 : s ? m ? 1 : 2 : 0, Q = ee[s + 5], R = s > 3 && (e[D - 1] = []), ue = e[D] || (e[D] = []), _ = s && (!h && !m && (n = n.prototype), s < 5 && (s > 3 || !h) && pe(s < 4 ? n : { get [r]() {
    return f(this, a);
  }, set [r](u) {
    return v(this, a, u);
  } }, r));
  s ? h && s < 4 && Z(a, (s > 2 ? "set " : s > 1 ? "get " : "") + r) : Z(n, r);
  for (var M = i.length - 1; M >= 0; M--)
    w = Se(s, r, L = {}, e[3], ue), s && (w.static = m, w.private = h, j = w.access = { has: h ? (u) => ke(n, u) : (u) => r in u }, s ^ 3 && (j.get = h ? (u) => (s ^ 1 ? f : je)(u, n, s ^ 4 ? a : _.get) : (u) => u[r]), s > 2 && (j.set = h ? (u, V) => v(u, n, V, s ^ 4 ? a : _.set) : (u, V) => u[r] = V)), l = (0, i[M])(s ? s < 4 ? h ? a : _[Q] : s > 4 ? void 0 : { get: _.get, set: _.set } : n, w), L._ = 1, s ^ 4 || l === void 0 ? P(l) && (s > 4 ? R.unshift(l) : s ? h ? a = l : _[Q] = l : n = l) : typeof l != "object" || l === null ? O("Object expected") : (P(p = l.get) && (_.get = p), P(p = l.set) && (_.set = p), P(p = l.init) && R.unshift(p));
  return s || te(e, n), _ && G(n, r, _), h ? s ^ 4 ? a : _ : n;
}, N = (e, t, r) => t.has(e) || O("Cannot " + r), ke = (e, t) => Object(t) !== t ? O('Cannot use the "in" operator on this value') : e.has(t), f = (e, t, r) => (N(e, t, "read from private field"), r ? r.call(e) : t.get(e)), S = (e, t, r) => t.has(e) ? O("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), v = (e, t, r, i) => (N(e, t, "write to private field"), i ? i.call(e, r) : t.set(e, r), r), je = (e, t, r) => (N(e, t, "access private method"), r);
function me(e, t) {
  if (t) {
    let r;
    return U(() => {
      const i = e();
      return i && r && t(r, i) ? r : (r = i, i);
    });
  }
  return U(e);
}
function $(e, t) {
  if (Object.is(e, t))
    return !0;
  if (e === null || t === null) return !1;
  if (typeof e == "function" && typeof t == "function")
    return e === t;
  if (e instanceof Set && t instanceof Set) {
    if (e.size !== t.size)
      return !1;
    for (const r of e)
      if (!t.has(r))
        return !1;
    return !0;
  }
  if (Array.isArray(e))
    return !Array.isArray(t) || e.length !== t.length ? !1 : !e.some(
      (i, n) => !$(i, t[n])
    );
  if (typeof e == "object" && typeof t == "object") {
    const r = Object.keys(e), i = Object.keys(t);
    return r.length !== i.length ? !1 : !r.some(
      (a) => !$(e[a], t[a])
    );
  }
  return !1;
}
function W({ get: e }, t) {
  return {
    init(r) {
      return fe(r);
    },
    get() {
      return e.call(this).value;
    },
    set(r) {
      const i = e.call(this);
      i.peek() !== r && (i.value = r);
    }
  };
}
function Me(e, t) {
  const r = /* @__PURE__ */ new WeakMap();
  return function() {
    let i = r.get(this);
    return i || (i = me(e.bind(this)), r.set(this, i)), i.value;
  };
}
function z(e = !0) {
  return function(t, r) {
    r.addInitializer(function() {
      const i = r.kind === "field" ? this : r.static ? this : Object.getPrototypeOf(this), n = Object.getOwnPropertyDescriptor(i, r.name);
      n && Object.defineProperty(i, r.name, we(ye({}, n), { enumerable: e }));
    });
  };
}
function Ve(...e) {
  const t = e.map(le);
  return () => t.forEach((r) => r());
}
var re, ie, se, ne, ae, oe, c, T, E, C, q, o, B, b, ce, F, J, I, H, K;
oe = [W], ae = [W], ne = [W], se = [z()], ie = [z()], re = [z()];
var k = class {
  constructor(e, t = Object.is) {
    this.defaultValue = e, this.equals = t, d(c, 5, this), S(this, o), S(this, T, d(c, 8, this)), d(c, 11, this), S(this, B, d(c, 12, this)), d(c, 15, this), S(this, J, d(c, 16, this)), d(c, 19, this), this.reset = this.reset.bind(this), this.reset();
  }
  get current() {
    return f(this, o, H);
  }
  get initial() {
    return f(this, o, C);
  }
  get previous() {
    return f(this, o, ce);
  }
  /** Set the current value */
  set current(e) {
    const t = x(() => f(this, o, H));
    e && t && this.equals(t, e) || X(() => {
      f(this, o, C) || v(this, o, e, q), v(this, o, t, F), v(this, o, e, K);
    });
  }
  /** Reset the state to the initial value */
  reset(e = this.defaultValue) {
    X(() => {
      v(this, o, void 0, F), v(this, o, e, q), v(this, o, e, K);
    });
  }
};
c = Pe();
T = /* @__PURE__ */ new WeakMap();
o = /* @__PURE__ */ new WeakSet();
B = /* @__PURE__ */ new WeakMap();
J = /* @__PURE__ */ new WeakMap();
E = y(c, 20, "#initial", oe, o, T), C = E.get, q = E.set;
b = y(c, 20, "#previous", ae, o, B), ce = b.get, F = b.set;
I = y(c, 20, "#current", ne, o, J), H = I.get, K = I.set;
y(c, 2, "current", se, k);
y(c, 2, "initial", ie, k);
y(c, 2, "previous", re, k);
te(c, k);
function We(e) {
  return x(() => {
    const t = {};
    for (const r in e)
      t[r] = e[r];
    return t;
  });
}
var g, ze = class {
  constructor() {
    S(this, g, /* @__PURE__ */ new WeakMap());
  }
  get(e, t) {
    var r;
    return e ? (r = f(this, g).get(e)) == null ? void 0 : r.get(t) : void 0;
  }
  set(e, t, r) {
    var i;
    if (e)
      return f(this, g).has(e) || f(this, g).set(e, /* @__PURE__ */ new Map()), (i = f(this, g).get(e)) == null ? void 0 : i.set(t, r);
  }
  clear(e) {
    var t;
    return e ? (t = f(this, g).get(e)) == null ? void 0 : t.clear() : void 0;
  }
};
g = /* @__PURE__ */ new WeakMap();
export {
  Ie as Signal,
  k as ValueHistory,
  ze as WeakStore,
  X as batch,
  me as computed,
  $ as deepEqual,
  Me as derived,
  le as effect,
  Ve as effects,
  z as enumerable,
  W as reactive,
  fe as signal,
  We as snapshot,
  x as untracked
};
//# sourceMappingURL=index.js.map
