@mhmo91/schmancy 0.2.142 → 0.2.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/card.cjs +1 -1
  2. package/dist/card.js +1 -1
  3. package/dist/content-drawer.cjs +1 -1
  4. package/dist/content-drawer.js +1 -1
  5. package/dist/{context-array-CSGdoQ1W.js → context-object-CISes2bD.js} +415 -317
  6. package/dist/context-object-CISes2bD.js.map +1 -0
  7. package/dist/context-object-CP7HbDFQ.cjs +2 -0
  8. package/dist/context-object-CP7HbDFQ.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +89 -87
  11. package/dist/nav-drawer.cjs +1 -1
  12. package/dist/nav-drawer.js +1 -1
  13. package/dist/selector-hook-Bvne--oy.cjs +2 -0
  14. package/dist/selector-hook-Bvne--oy.cjs.map +1 -0
  15. package/dist/selector-hook-D_HTD-GV.js +344 -0
  16. package/dist/selector-hook-D_HTD-GV.js.map +1 -0
  17. package/dist/store.cjs +1 -1
  18. package/dist/store.js +40 -38
  19. package/dist/teleport.cjs +1 -1
  20. package/dist/{teleport.component-Du14Yyxz.js → teleport.component-B6W2UN_u.js} +2 -2
  21. package/dist/{teleport.component-Du14Yyxz.js.map → teleport.component-B6W2UN_u.js.map} +1 -1
  22. package/dist/{teleport.component-Vicu2fPa.cjs → teleport.component-Cgtrv4bU.cjs} +2 -2
  23. package/dist/{teleport.component-Vicu2fPa.cjs.map → teleport.component-Cgtrv4bU.cjs.map} +1 -1
  24. package/dist/teleport.js +1 -1
  25. package/package.json +1 -1
  26. package/types/src/store/context-create.d.ts +2 -2
  27. package/types/src/store/context-object.d.ts +6 -0
  28. package/types/src/store/immer-integration.d.ts +1 -7
  29. package/types/src/store/index.d.ts +2 -0
  30. package/types/src/store/store.class.d.ts +6 -0
  31. package/dist/context-array-BrljBA5R.cjs +0 -2
  32. package/dist/context-array-BrljBA5R.cjs.map +0 -1
  33. package/dist/context-array-CSGdoQ1W.js.map +0 -1
  34. package/dist/selector-hook-0691Losv.js +0 -323
  35. package/dist/selector-hook-0691Losv.js.map +0 -1
  36. package/dist/selector-hook-SzNTYQII.cjs +0 -2
  37. package/dist/selector-hook-SzNTYQII.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { Subject as ue, BehaviorSubject as q, throttleTime as ie } from "rxjs";
2
- var oe = Symbol.for("immer-nothing"), H = Symbol.for("immer-draftable"), u = Symbol.for("immer-state"), le = process.env.NODE_ENV !== "production" ? [function(t) {
1
+ import { Subject as pe, BehaviorSubject as Q, throttleTime as oe } from "rxjs";
2
+ var ce = Symbol.for("immer-nothing"), $ = Symbol.for("immer-draftable"), l = Symbol.for("immer-state"), fe = process.env.NODE_ENV !== "production" ? [function(t) {
3
3
  return `The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`;
4
4
  }, function(t) {
5
5
  return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`;
@@ -12,220 +12,220 @@ var oe = Symbol.for("immer-nothing"), H = Symbol.for("immer-draftable"), u = Sym
12
12
  }] : [];
13
13
  function _(t, ...e) {
14
14
  if (process.env.NODE_ENV !== "production") {
15
- const r = le[t], s = typeof r == "function" ? r.apply(null, e) : r;
15
+ const r = fe[t], s = typeof r == "function" ? r.apply(null, e) : r;
16
16
  throw new Error(`[Immer] ${s}`);
17
17
  }
18
18
  throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`);
19
19
  }
20
- var $ = Object.getPrototypeOf;
20
+ var E = Object.getPrototypeOf;
21
21
  function w(t) {
22
- return !!t && !!t[u];
22
+ return !!t && !!t[l];
23
23
  }
24
24
  function v(t) {
25
25
  var e;
26
- return !!t && (ae(t) || Array.isArray(t) || !!t[H] || !!((e = t.constructor) != null && e[H]) || I(t) || A(t));
26
+ return !!t && (he(t) || Array.isArray(t) || !!t[$] || !!((e = t.constructor) != null && e[$]) || A(t) || R(t));
27
27
  }
28
- var de = Object.prototype.constructor.toString();
29
- function ae(t) {
28
+ var ye = Object.prototype.constructor.toString();
29
+ function he(t) {
30
30
  if (!t || typeof t != "object") return !1;
31
- const e = $(t);
31
+ const e = E(t);
32
32
  if (e === null) return !0;
33
33
  const r = Object.hasOwnProperty.call(e, "constructor") && e.constructor;
34
- return r === Object || typeof r == "function" && Function.toString.call(r) === de;
34
+ return r === Object || typeof r == "function" && Function.toString.call(r) === ye;
35
35
  }
36
36
  function P(t, e) {
37
- M(t) === 0 ? Reflect.ownKeys(t).forEach((r) => {
37
+ T(t) === 0 ? Reflect.ownKeys(t).forEach((r) => {
38
38
  e(r, t[r], t);
39
39
  }) : t.forEach((r, s) => e(s, r, t));
40
40
  }
41
- function M(t) {
42
- const e = t[u];
43
- return e ? e.type_ : Array.isArray(t) ? 1 : I(t) ? 2 : A(t) ? 3 : 0;
41
+ function T(t) {
42
+ const e = t[l];
43
+ return e ? e.type_ : Array.isArray(t) ? 1 : A(t) ? 2 : R(t) ? 3 : 0;
44
44
  }
45
- function B(t, e) {
46
- return M(t) === 2 ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
45
+ function C(t, e) {
46
+ return T(t) === 2 ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
47
47
  }
48
- function ce(t, e, r) {
49
- const s = M(t);
48
+ function ue(t, e, r) {
49
+ const s = T(t);
50
50
  s === 2 ? t.set(e, r) : s === 3 ? t.add(r) : t[e] = r;
51
51
  }
52
- function I(t) {
52
+ function A(t) {
53
53
  return t instanceof Map;
54
54
  }
55
- function A(t) {
55
+ function R(t) {
56
56
  return t instanceof Set;
57
57
  }
58
58
  function f(t) {
59
59
  return t.copy_ || t.base_;
60
60
  }
61
- function C(t, e) {
62
- if (I(t)) return new Map(t);
63
- if (A(t)) return new Set(t);
61
+ function J(t, e) {
62
+ if (A(t)) return new Map(t);
63
+ if (R(t)) return new Set(t);
64
64
  if (Array.isArray(t)) return Array.prototype.slice.call(t);
65
- const r = ae(t);
65
+ const r = he(t);
66
66
  if (e === !0 || e === "class_only" && !r) {
67
67
  const s = Object.getOwnPropertyDescriptors(t);
68
- delete s[u];
68
+ delete s[l];
69
69
  let n = Reflect.ownKeys(s);
70
70
  for (let a = 0; a < n.length; a++) {
71
71
  const h = n[a], c = s[h];
72
72
  c.writable === !1 && (c.writable = !0, c.configurable = !0), (c.get || c.set) && (s[h] = { configurable: !0, writable: !0, enumerable: c.enumerable, value: t[h] });
73
73
  }
74
- return Object.create($(t), s);
74
+ return Object.create(E(t), s);
75
75
  }
76
76
  {
77
- const s = $(t);
77
+ const s = E(t);
78
78
  if (s !== null && r) return { ...t };
79
79
  const n = Object.create(s);
80
80
  return Object.assign(n, t);
81
81
  }
82
82
  }
83
- function G(t, e = !1) {
84
- return R(t) || w(t) || !v(t) || (M(t) > 1 && (t.set = t.add = t.clear = t.delete = pe), Object.freeze(t), e && Object.entries(t).forEach(([r, s]) => G(s, !0))), t;
83
+ function X(t, e = !1) {
84
+ return F(t) || w(t) || !v(t) || (T(t) > 1 && (t.set = t.add = t.clear = t.delete = _e), Object.freeze(t), e && Object.entries(t).forEach(([r, s]) => X(s, !0))), t;
85
85
  }
86
- function pe() {
86
+ function _e() {
87
87
  _(2);
88
88
  }
89
- function R(t) {
89
+ function F(t) {
90
90
  return Object.isFrozen(t);
91
91
  }
92
- var N, J = {};
92
+ var j, U = {};
93
93
  function S(t) {
94
- const e = J[t];
94
+ const e = U[t];
95
95
  return e || _(0, t), e;
96
96
  }
97
- function D() {
98
- return N;
97
+ function N() {
98
+ return j;
99
99
  }
100
100
  function Y(t, e) {
101
101
  e && (S("Patches"), t.patches_ = [], t.inversePatches_ = [], t.patchListener_ = e);
102
102
  }
103
- function U(t) {
104
- K(t), t.drafts_.forEach(fe), t.drafts_ = null;
105
- }
106
103
  function K(t) {
107
- t === N && (N = t.parent_);
104
+ W(t), t.drafts_.forEach(be), t.drafts_ = null;
105
+ }
106
+ function W(t) {
107
+ t === j && (j = t.parent_);
108
108
  }
109
109
  function Z(t) {
110
- return N = { drafts_: [], parent_: N, immer_: t, canAutoFreeze_: !0, unfinalizedDrafts_: 0 };
110
+ return j = { drafts_: [], parent_: j, immer_: t, canAutoFreeze_: !0, unfinalizedDrafts_: 0 };
111
111
  }
112
- function fe(t) {
113
- const e = t[u];
112
+ function be(t) {
113
+ const e = t[l];
114
114
  e.type_ === 0 || e.type_ === 1 ? e.revoke_() : e.revoked_ = !0;
115
115
  }
116
- function Q(t, e) {
116
+ function H(t, e) {
117
117
  e.unfinalizedDrafts_ = e.drafts_.length;
118
118
  const r = e.drafts_[0];
119
- return t !== void 0 && t !== r ? (r[u].modified_ && (U(e), _(4)), v(t) && (t = T(e, t), e.parent_ || j(e, t)), e.patches_ && S("Patches").generateReplacementPatches_(r[u].base_, t, e.patches_, e.inversePatches_)) : t = T(e, r, []), U(e), e.patches_ && e.patchListener_(e.patches_, e.inversePatches_), t !== oe ? t : void 0;
119
+ return t !== void 0 && t !== r ? (r[l].modified_ && (K(e), _(4)), v(t) && (t = z(e, t), e.parent_ || M(e, t)), e.patches_ && S("Patches").generateReplacementPatches_(r[l].base_, t, e.patches_, e.inversePatches_)) : t = z(e, r, []), K(e), e.patches_ && e.patchListener_(e.patches_, e.inversePatches_), t !== ce ? t : void 0;
120
120
  }
121
- function T(t, e, r) {
122
- if (R(e)) return e;
123
- const s = e[u];
121
+ function z(t, e, r) {
122
+ if (F(e)) return e;
123
+ const s = e[l];
124
124
  if (!s) return P(e, (n, a) => ee(t, s, e, n, a, r)), e;
125
125
  if (s.scope_ !== t) return e;
126
- if (!s.modified_) return j(t, s.base_, !0), s.base_;
126
+ if (!s.modified_) return M(t, s.base_, !0), s.base_;
127
127
  if (!s.finalized_) {
128
128
  s.finalized_ = !0, s.scope_.unfinalizedDrafts_--;
129
129
  const n = s.copy_;
130
130
  let a = n, h = !1;
131
- s.type_ === 3 && (a = new Set(n), n.clear(), h = !0), P(a, (c, i) => ee(t, s, n, c, i, r, h)), j(t, n, !1), r && t.patches_ && S("Patches").generatePatches_(s, r, t.patches_, t.inversePatches_);
131
+ s.type_ === 3 && (a = new Set(n), n.clear(), h = !0), P(a, (c, i) => ee(t, s, n, c, i, r, h)), M(t, n, !1), r && t.patches_ && S("Patches").generatePatches_(s, r, t.patches_, t.inversePatches_);
132
132
  }
133
133
  return s.copy_;
134
134
  }
135
135
  function ee(t, e, r, s, n, a, h) {
136
136
  if (process.env.NODE_ENV !== "production" && n === r && _(5), w(n)) {
137
- const c = T(t, n, a && e && e.type_ !== 3 && !B(e.assigned_, s) ? a.concat(s) : void 0);
138
- if (ce(r, s, c), !w(c)) return;
137
+ const c = z(t, n, a && e && e.type_ !== 3 && !C(e.assigned_, s) ? a.concat(s) : void 0);
138
+ if (ue(r, s, c), !w(c)) return;
139
139
  t.canAutoFreeze_ = !1;
140
140
  } else h && r.add(n);
141
- if (v(n) && !R(n)) {
141
+ if (v(n) && !F(n)) {
142
142
  if (!t.immer_.autoFreeze_ && t.unfinalizedDrafts_ < 1) return;
143
- T(t, n), e && e.scope_.parent_ || typeof s == "symbol" || !Object.prototype.propertyIsEnumerable.call(r, s) || j(t, n);
143
+ z(t, n), e && e.scope_.parent_ || typeof s == "symbol" || !Object.prototype.propertyIsEnumerable.call(r, s) || M(t, n);
144
144
  }
145
145
  }
146
- function j(t, e, r = !1) {
147
- !t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ && G(e, r);
146
+ function M(t, e, r = !1) {
147
+ !t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ && X(e, r);
148
148
  }
149
149
  var L = { get(t, e) {
150
- if (e === u) return t;
150
+ if (e === l) return t;
151
151
  const r = f(t);
152
- if (!B(r, e)) return function(n, a, h) {
152
+ if (!C(r, e)) return function(n, a, h) {
153
153
  var i;
154
154
  const c = te(a, h);
155
155
  return c ? "value" in c ? c.value : (i = c.get) == null ? void 0 : i.call(n.draft_) : void 0;
156
156
  }(t, r, e);
157
157
  const s = r[e];
158
- return t.finalized_ || !v(s) ? s : s === F(t.base_, e) ? (V(t), t.copy_[e] = z(s, t)) : s;
158
+ return t.finalized_ || !v(s) ? s : s === V(t.base_, e) ? (B(t), t.copy_[e] = I(s, t)) : s;
159
159
  }, has: (t, e) => e in f(t), ownKeys: (t) => Reflect.ownKeys(f(t)), set(t, e, r) {
160
160
  const s = te(f(t), e);
161
161
  if (s != null && s.set) return s.set.call(t.draft_, r), !0;
162
162
  if (!t.modified_) {
163
- const h = F(f(t), e), c = h == null ? void 0 : h[u];
163
+ const h = V(f(t), e), c = h == null ? void 0 : h[l];
164
164
  if (c && c.base_ === r) return t.copy_[e] = r, t.assigned_[e] = !1, !0;
165
- if (((n = r) === (a = h) ? n !== 0 || 1 / n == 1 / a : n != n && a != a) && (r !== void 0 || B(t.base_, e))) return !0;
166
- V(t), m(t);
165
+ if (((n = r) === (a = h) ? n !== 0 || 1 / n == 1 / a : n != n && a != a) && (r !== void 0 || C(t.base_, e))) return !0;
166
+ B(t), g(t);
167
167
  }
168
168
  var n, a;
169
169
  return t.copy_[e] === r && (r !== void 0 || e in t.copy_) || Number.isNaN(r) && Number.isNaN(t.copy_[e]) || (t.copy_[e] = r, t.assigned_[e] = !0), !0;
170
- }, deleteProperty: (t, e) => (F(t.base_, e) !== void 0 || e in t.base_ ? (t.assigned_[e] = !1, V(t), m(t)) : delete t.assigned_[e], t.copy_ && delete t.copy_[e], !0), getOwnPropertyDescriptor(t, e) {
170
+ }, deleteProperty: (t, e) => (V(t.base_, e) !== void 0 || e in t.base_ ? (t.assigned_[e] = !1, B(t), g(t)) : delete t.assigned_[e], t.copy_ && delete t.copy_[e], !0), getOwnPropertyDescriptor(t, e) {
171
171
  const r = f(t), s = Reflect.getOwnPropertyDescriptor(r, e);
172
172
  return s && { writable: !0, configurable: t.type_ !== 1 || e !== "length", enumerable: s.enumerable, value: r[e] };
173
173
  }, defineProperty() {
174
174
  _(11);
175
- }, getPrototypeOf: (t) => $(t.base_), setPrototypeOf() {
175
+ }, getPrototypeOf: (t) => E(t.base_), setPrototypeOf() {
176
176
  _(12);
177
- } }, E = {};
178
- function F(t, e) {
179
- const r = t[u];
177
+ } }, x = {};
178
+ function V(t, e) {
179
+ const r = t[l];
180
180
  return (r ? f(r) : t)[e];
181
181
  }
182
182
  function te(t, e) {
183
183
  if (!(e in t)) return;
184
- let r = $(t);
184
+ let r = E(t);
185
185
  for (; r; ) {
186
186
  const s = Object.getOwnPropertyDescriptor(r, e);
187
187
  if (s) return s;
188
- r = $(r);
188
+ r = E(r);
189
189
  }
190
190
  }
191
- function m(t) {
192
- t.modified_ || (t.modified_ = !0, t.parent_ && m(t.parent_));
191
+ function g(t) {
192
+ t.modified_ || (t.modified_ = !0, t.parent_ && g(t.parent_));
193
193
  }
194
- function V(t) {
195
- t.copy_ || (t.copy_ = C(t.base_, t.scope_.immer_.useStrictShallowCopy_));
194
+ function B(t) {
195
+ t.copy_ || (t.copy_ = J(t.base_, t.scope_.immer_.useStrictShallowCopy_));
196
196
  }
197
197
  P(L, (t, e) => {
198
- E[t] = function() {
198
+ x[t] = function() {
199
199
  return arguments[0] = arguments[0][0], e.apply(this, arguments);
200
200
  };
201
- }), E.deleteProperty = function(t, e) {
202
- return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) && _(13), E.set.call(this, t, e, void 0);
203
- }, E.set = function(t, e, r) {
201
+ }), x.deleteProperty = function(t, e) {
202
+ return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) && _(13), x.set.call(this, t, e, void 0);
203
+ }, x.set = function(t, e, r) {
204
204
  return process.env.NODE_ENV !== "production" && e !== "length" && isNaN(parseInt(e)) && _(14), L.set.call(this, t[0], e, r, t[0]);
205
205
  };
206
- function z(t, e) {
207
- const r = I(t) ? S("MapSet").proxyMap_(t, e) : A(t) ? S("MapSet").proxySet_(t, e) : function(s, n) {
208
- const a = Array.isArray(s), h = { type_: a ? 1 : 0, scope_: n ? n.scope_ : D(), modified_: !1, finalized_: !1, assigned_: {}, parent_: n, base_: s, draft_: null, copy_: null, revoke_: null, isManual_: !1 };
206
+ function I(t, e) {
207
+ const r = A(t) ? S("MapSet").proxyMap_(t, e) : R(t) ? S("MapSet").proxySet_(t, e) : function(s, n) {
208
+ const a = Array.isArray(s), h = { type_: a ? 1 : 0, scope_: n ? n.scope_ : N(), modified_: !1, finalized_: !1, assigned_: {}, parent_: n, base_: s, draft_: null, copy_: null, revoke_: null, isManual_: !1 };
209
209
  let c = h, i = L;
210
- a && (c = [h], i = E);
210
+ a && (c = [h], i = x);
211
211
  const { revoke: o, proxy: p } = Proxy.revocable(c, i);
212
212
  return h.draft_ = p, h.revoke_ = o, p;
213
213
  }(t, e);
214
- return (e ? e.scope_ : D()).drafts_.push(r), r;
214
+ return (e ? e.scope_ : N()).drafts_.push(r), r;
215
215
  }
216
- function he(t) {
217
- if (!v(t) || R(t)) return t;
218
- const e = t[u];
216
+ function le(t) {
217
+ if (!v(t) || F(t)) return t;
218
+ const e = t[l];
219
219
  let r;
220
220
  if (e) {
221
221
  if (!e.modified_) return e.base_;
222
- e.finalized_ = !0, r = C(t, e.scope_.immer_.useStrictShallowCopy_);
223
- } else r = C(t, !0);
222
+ e.finalized_ = !0, r = J(t, e.scope_.immer_.useStrictShallowCopy_);
223
+ } else r = J(t, !0);
224
224
  return P(r, (s, n) => {
225
- ce(r, s, he(n));
225
+ ue(r, s, le(n));
226
226
  }), e && (e.finalized_ = !1), r;
227
227
  }
228
- var g = new class {
228
+ var de, re, se, b = new class {
229
229
  constructor(t) {
230
230
  this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.produce = (e, r, s) => {
231
231
  if (typeof e == "function" && typeof r != "function") {
@@ -238,17 +238,17 @@ var g = new class {
238
238
  }
239
239
  let n;
240
240
  if (typeof r != "function" && _(6), s !== void 0 && typeof s != "function" && _(7), v(e)) {
241
- const a = Z(this), h = z(e, void 0);
241
+ const a = Z(this), h = I(e, void 0);
242
242
  let c = !0;
243
243
  try {
244
244
  n = r(h), c = !1;
245
245
  } finally {
246
- c ? U(a) : K(a);
246
+ c ? K(a) : W(a);
247
247
  }
248
- return Y(a, s), Q(n, a);
248
+ return Y(a, s), H(n, a);
249
249
  }
250
250
  if (!e || typeof e != "object") {
251
- if (n = r(e), n === void 0 && (n = e), n === oe && (n = void 0), this.autoFreeze_ && G(n, !0), s) {
251
+ if (n = r(e), n === void 0 && (n = e), n === ce && (n = void 0), this.autoFreeze_ && X(n, !0), s) {
252
252
  const a = [], h = [];
253
253
  S("Patches").generateReplacementPatches_(e, n, a, h), s(a, h);
254
254
  }
@@ -265,16 +265,16 @@ var g = new class {
265
265
  }
266
266
  createDraft(t) {
267
267
  v(t) || _(8), w(t) && (t = function(s) {
268
- return w(s) || _(10, s), he(s);
268
+ return w(s) || _(10, s), le(s);
269
269
  }(t));
270
- const e = Z(this), r = z(t, void 0);
271
- return r[u].isManual_ = !0, K(e), r;
270
+ const e = Z(this), r = I(t, void 0);
271
+ return r[l].isManual_ = !0, W(e), r;
272
272
  }
273
273
  finishDraft(t, e) {
274
- const r = t && t[u];
274
+ const r = t && t[l];
275
275
  r && r.isManual_ || _(9);
276
276
  const { scope_: s } = r;
277
- return Y(s, e), Q(void 0, s);
277
+ return Y(s, e), H(void 0, s);
278
278
  }
279
279
  setAutoFreeze(t) {
280
280
  this.autoFreeze_ = t;
@@ -295,17 +295,17 @@ var g = new class {
295
295
  const s = S("Patches").applyPatches_;
296
296
  return w(t) ? s(t, e) : this.produce(t, (n) => s(n, e));
297
297
  }
298
- }(), d = g.produce;
299
- g.produceWithPatches.bind(g), g.setAutoFreeze.bind(g), g.setUseStrictShallowCopy.bind(g), g.applyPatches.bind(g), g.createDraft.bind(g), g.finishDraft.bind(g);
300
- class l extends Error {
298
+ }(), d = b.produce;
299
+ b.produceWithPatches.bind(b), b.setAutoFreeze.bind(b), b.setUseStrictShallowCopy.bind(b), b.applyPatches.bind(b), b.createDraft.bind(b), b.finishDraft.bind(b);
300
+ class u extends Error {
301
301
  constructor(e, r, s) {
302
- super(e), this.name = "StoreError", this.cause = r, this.context = s, this.timestamp = /* @__PURE__ */ new Date(), Error.captureStackTrace && Error.captureStackTrace(this, l);
302
+ super(e), this.name = "StoreError", this.cause = r, this.context = s, this.timestamp = /* @__PURE__ */ new Date(), Error.captureStackTrace && Error.captureStackTrace(this, u);
303
303
  }
304
304
  toJSON() {
305
305
  return { name: this.name, message: this.message, cause: this.cause, context: this.context, timestamp: this.timestamp.toISOString(), stack: this.stack };
306
306
  }
307
307
  }
308
- class ye {
308
+ class me {
309
309
  constructor() {
310
310
  this.data = null;
311
311
  }
@@ -319,7 +319,7 @@ class ye {
319
319
  this.data = null;
320
320
  }
321
321
  }
322
- class _e {
322
+ class ge {
323
323
  constructor(e) {
324
324
  this.key = e;
325
325
  }
@@ -335,14 +335,14 @@ class _e {
335
335
  try {
336
336
  localStorage.setItem(this.key, JSON.stringify(e));
337
337
  } catch (r) {
338
- throw new l(`Failed to save to localStorage (${this.key})`, r);
338
+ throw new u(`Failed to save to localStorage (${this.key})`, r);
339
339
  }
340
340
  }
341
341
  async clear() {
342
342
  localStorage.removeItem(this.key);
343
343
  }
344
344
  }
345
- class ge {
345
+ class ve {
346
346
  constructor(e) {
347
347
  this.key = e;
348
348
  }
@@ -358,7 +358,7 @@ class ge {
358
358
  try {
359
359
  sessionStorage.setItem(this.key, JSON.stringify(e));
360
360
  } catch (r) {
361
- throw new l(`Failed to save to sessionStorage (${this.key})`, r);
361
+ throw new u(`Failed to save to sessionStorage (${this.key})`, r);
362
362
  }
363
363
  }
364
364
  async clear() {
@@ -405,7 +405,7 @@ const y = class y {
405
405
  };
406
406
  });
407
407
  } catch (r) {
408
- throw new l(`Failed to save to IndexedDB (${this.key})`, r);
408
+ throw new u(`Failed to save to IndexedDB (${this.key})`, r);
409
409
  }
410
410
  }
411
411
  async clear() {
@@ -420,65 +420,65 @@ const y = class y {
420
420
  };
421
421
  });
422
422
  } catch (e) {
423
- throw new l(`Failed to clear from IndexedDB (${this.key})`, e);
423
+ throw new u(`Failed to clear from IndexedDB (${this.key})`, e);
424
424
  }
425
425
  }
426
426
  };
427
427
  y.DB_NAME = "StoreDB", y.STORE_NAME = "states", y.DB_VERSION = 1;
428
- let W = y;
429
- function be(t, e) {
428
+ let G = y;
429
+ function Se(t, e) {
430
430
  switch (t) {
431
431
  case "local":
432
- return new _e(e);
433
- case "session":
434
432
  return new ge(e);
433
+ case "session":
434
+ return new ve(e);
435
435
  case "indexeddb":
436
- return new W(e);
436
+ return new G(e);
437
437
  default:
438
- return new ye();
438
+ return new me();
439
439
  }
440
440
  }
441
441
  (function() {
442
442
  class t extends Map {
443
443
  constructor(i, o) {
444
- super(), this[u] = { type_: 2, parent_: o, scope_: o ? o.scope_ : D(), modified_: !1, finalized_: !1, copy_: void 0, assigned_: void 0, base_: i, draft_: this, isManual_: !1, revoked_: !1 };
444
+ super(), this[l] = { type_: 2, parent_: o, scope_: o ? o.scope_ : N(), modified_: !1, finalized_: !1, copy_: void 0, assigned_: void 0, base_: i, draft_: this, isManual_: !1, revoked_: !1 };
445
445
  }
446
446
  get size() {
447
- return f(this[u]).size;
447
+ return f(this[l]).size;
448
448
  }
449
449
  has(i) {
450
- return f(this[u]).has(i);
450
+ return f(this[l]).has(i);
451
451
  }
452
452
  set(i, o) {
453
- const p = this[u];
454
- return n(p), f(p).has(i) && f(p).get(i) === o || (e(p), m(p), p.assigned_.set(i, !0), p.copy_.set(i, o), p.assigned_.set(i, !0)), this;
453
+ const p = this[l];
454
+ return n(p), f(p).has(i) && f(p).get(i) === o || (e(p), g(p), p.assigned_.set(i, !0), p.copy_.set(i, o), p.assigned_.set(i, !0)), this;
455
455
  }
456
456
  delete(i) {
457
457
  if (!this.has(i)) return !1;
458
- const o = this[u];
459
- return n(o), e(o), m(o), o.base_.has(i) ? o.assigned_.set(i, !1) : o.assigned_.delete(i), o.copy_.delete(i), !0;
458
+ const o = this[l];
459
+ return n(o), e(o), g(o), o.base_.has(i) ? o.assigned_.set(i, !1) : o.assigned_.delete(i), o.copy_.delete(i), !0;
460
460
  }
461
461
  clear() {
462
- const i = this[u];
463
- n(i), f(i).size && (e(i), m(i), i.assigned_ = /* @__PURE__ */ new Map(), P(i.base_, (o) => {
462
+ const i = this[l];
463
+ n(i), f(i).size && (e(i), g(i), i.assigned_ = /* @__PURE__ */ new Map(), P(i.base_, (o) => {
464
464
  i.assigned_.set(o, !1);
465
465
  }), i.copy_.clear());
466
466
  }
467
467
  forEach(i, o) {
468
- f(this[u]).forEach((p, b, me) => {
469
- i.call(o, this.get(b), b, this);
468
+ f(this[l]).forEach((p, m, we) => {
469
+ i.call(o, this.get(m), m, this);
470
470
  });
471
471
  }
472
472
  get(i) {
473
- const o = this[u];
473
+ const o = this[l];
474
474
  n(o);
475
475
  const p = f(o).get(i);
476
476
  if (o.finalized_ || !v(p) || p !== o.base_.get(i)) return p;
477
- const b = z(p, o);
478
- return e(o), o.copy_.set(i, b), b;
477
+ const m = I(p, o);
478
+ return e(o), o.copy_.set(i, m), m;
479
479
  }
480
480
  keys() {
481
- return f(this[u]).keys();
481
+ return f(this[l]).keys();
482
482
  }
483
483
  values() {
484
484
  const i = this.keys();
@@ -505,34 +505,34 @@ function be(t, e) {
505
505
  }
506
506
  class r extends Set {
507
507
  constructor(i, o) {
508
- super(), this[u] = { type_: 3, parent_: o, scope_: o ? o.scope_ : D(), modified_: !1, finalized_: !1, copy_: void 0, base_: i, draft_: this, drafts_: /* @__PURE__ */ new Map(), revoked_: !1, isManual_: !1 };
508
+ super(), this[l] = { type_: 3, parent_: o, scope_: o ? o.scope_ : N(), modified_: !1, finalized_: !1, copy_: void 0, base_: i, draft_: this, drafts_: /* @__PURE__ */ new Map(), revoked_: !1, isManual_: !1 };
509
509
  }
510
510
  get size() {
511
- return f(this[u]).size;
511
+ return f(this[l]).size;
512
512
  }
513
513
  has(i) {
514
- const o = this[u];
514
+ const o = this[l];
515
515
  return n(o), o.copy_ ? !!o.copy_.has(i) || !(!o.drafts_.has(i) || !o.copy_.has(o.drafts_.get(i))) : o.base_.has(i);
516
516
  }
517
517
  add(i) {
518
- const o = this[u];
519
- return n(o), this.has(i) || (s(o), m(o), o.copy_.add(i)), this;
518
+ const o = this[l];
519
+ return n(o), this.has(i) || (s(o), g(o), o.copy_.add(i)), this;
520
520
  }
521
521
  delete(i) {
522
522
  if (!this.has(i)) return !1;
523
- const o = this[u];
524
- return n(o), s(o), m(o), o.copy_.delete(i) || !!o.drafts_.has(i) && o.copy_.delete(o.drafts_.get(i));
523
+ const o = this[l];
524
+ return n(o), s(o), g(o), o.copy_.delete(i) || !!o.drafts_.has(i) && o.copy_.delete(o.drafts_.get(i));
525
525
  }
526
526
  clear() {
527
- const i = this[u];
528
- n(i), f(i).size && (s(i), m(i), i.copy_.clear());
527
+ const i = this[l];
528
+ n(i), f(i).size && (s(i), g(i), i.copy_.clear());
529
529
  }
530
530
  values() {
531
- const i = this[u];
531
+ const i = this[l];
532
532
  return n(i), s(i), i.copy_.values();
533
533
  }
534
534
  entries() {
535
- const i = this[u];
535
+ const i = this[l];
536
536
  return n(i), s(i), i.copy_.entries();
537
537
  }
538
538
  keys() {
@@ -543,14 +543,14 @@ function be(t, e) {
543
543
  }
544
544
  forEach(i, o) {
545
545
  const p = this.values();
546
- let b = p.next();
547
- for (; !b.done; ) i.call(o, b.value, b.value, this), b = p.next();
546
+ let m = p.next();
547
+ for (; !m.done; ) i.call(o, m.value, m.value, this), m = p.next();
548
548
  }
549
549
  }
550
550
  function s(c) {
551
551
  c.copy_ || (c.copy_ = /* @__PURE__ */ new Set(), c.base_.forEach((i) => {
552
552
  if (v(i)) {
553
- const o = z(i, c);
553
+ const o = I(i, c);
554
554
  c.drafts_.set(i, o), c.copy_.add(o);
555
555
  } else c.copy_.add(i);
556
556
  }));
@@ -563,11 +563,18 @@ function be(t, e) {
563
563
  return new t(c, i);
564
564
  }, proxySet_: function(c, i) {
565
565
  return new r(c, i);
566
- } }, J[a = "MapSet"] || (J[a] = h);
567
- })();
568
- class X {
566
+ } }, U[a = "MapSet"] || (U[a] = h);
567
+ })(), de = $;
568
+ class q {
569
569
  constructor(e, r, s) {
570
- this.storageType = e, this.key = r, this._ready = !1, this._destroy$ = new ue(), this.error$ = new q(null), this.defaultValue = d(s, (n) => n), this.$ = new q(this.defaultValue), this.storage = be(e, r), e === "memory" ? this._ready = !0 : this.initializeFromStorage();
570
+ let n;
571
+ this.storageType = e, this.key = r, this[de] = !0, this._ready = !1, this._destroy$ = new pe(), this.error$ = new Q(null), n = s instanceof Map ? new Map(s) : Array.isArray(s) ? [...s] : s && typeof s == "object" ? { ...s } : s;
572
+ try {
573
+ this.defaultValue = this.isImmerDraftable(n) ? d(n, (a) => a) : n;
574
+ } catch {
575
+ this.defaultValue = n;
576
+ }
577
+ this.$ = new Q(this.defaultValue), this.storage = Se(e, r), e === "memory" ? this._ready = !0 : this.initializeFromStorage();
571
578
  }
572
579
  get ready() {
573
580
  return this._ready;
@@ -578,35 +585,48 @@ class X {
578
585
  get value() {
579
586
  return this.$.getValue();
580
587
  }
588
+ isImmerDraftable(e) {
589
+ return e !== null && typeof e == "object" && (Array.isArray(e) || e instanceof Map || e instanceof Set || Object.getPrototypeOf(e) === Object.prototype || e[$] === !0);
590
+ }
581
591
  destroy() {
582
592
  this._destroy$.next(), this._destroy$.complete(), this.$.complete(), this.error$.complete();
583
593
  }
584
594
  replace(e) {
585
- const r = d(e, (s) => s);
586
- this.updateState(r);
595
+ try {
596
+ const r = this.isImmerDraftable(e) ? d(e, (s) => s) : e;
597
+ this.updateState(r);
598
+ } catch (r) {
599
+ const s = new u(`Error replacing state in ${this.key}`, r);
600
+ this.error$.next(s), this.updateState(e);
601
+ }
587
602
  }
588
603
  updateState(e) {
589
604
  try {
590
- const r = d(e, (s) => s);
591
- this.$.next(r), this.storageType !== "memory" && this.persistToStorage(r).catch((s) => {
592
- const n = new l(`Error saving to ${this.storageType} storage for ${this.key}`, s);
605
+ let r;
606
+ r = this.isImmerDraftable(e) ? d(e, (s) => s) : e, this.$.next(r), this.storageType !== "memory" && this.persistToStorage(r).catch((s) => {
607
+ const n = new u(`Error saving to ${this.storageType} storage for ${this.key}`, s);
593
608
  this.error$.next(n);
594
609
  });
595
610
  } catch (r) {
596
- const s = new l(`Error updating state in ${this.key}`, r);
597
- this.error$.next(s);
611
+ const s = new u(`Error updating state in ${this.key}`, r);
612
+ this.error$.next(s), this.$.next(e);
598
613
  }
599
614
  }
600
615
  async initializeFromStorage() {
601
616
  try {
602
617
  const e = await this.storage.load();
603
618
  if (e) {
604
- const r = this.processStoredValue(e), s = d(r, (n) => n);
605
- this.updateState(s);
619
+ const r = this.processStoredValue(e);
620
+ try {
621
+ const s = this.isImmerDraftable(r) ? d(r, (n) => n) : r;
622
+ this.updateState(s);
623
+ } catch {
624
+ this.updateState(r);
625
+ }
606
626
  }
607
627
  this._ready = !0;
608
628
  } catch (e) {
609
- const r = new l(`Error loading from ${this.storageType} storage for ${this.key}`, e);
629
+ const r = new u(`Error loading from ${this.storageType} storage for ${this.key}`, e);
610
630
  this.error$.next(r), this._ready = !0;
611
631
  }
612
632
  }
@@ -617,151 +637,18 @@ class X {
617
637
  return this.storage.save(e);
618
638
  }
619
639
  }
620
- const x = class x extends X {
621
- static getInstance(e, r, s) {
622
- const n = `${e}:${r}`;
623
- return this.instances.has(n) || this.instances.set(n, new x(e, r, s)), this.instances.get(n);
624
- }
625
- set(e, r) {
626
- try {
627
- const s = d(this.value, (n) => {
628
- n.set(e, r);
629
- });
630
- this.updateState(s), this.error$.next(null);
631
- } catch (s) {
632
- const n = new l(`Error setting value for key ${e} in ${this.key}`, s);
633
- this.error$.next(n);
634
- }
635
- }
636
- delete(e) {
637
- try {
638
- const r = d(this.value, (s) => {
639
- s.delete(e);
640
- });
641
- this.updateState(r), this.error$.next(null);
642
- } catch (r) {
643
- const s = new l(`Error deleting key ${e} from ${this.key}`, r);
644
- this.error$.next(s);
645
- }
646
- }
647
- clear() {
648
- this.updateState(/* @__PURE__ */ new Map());
649
- }
650
- batchUpdate(e) {
651
- try {
652
- const r = d(this.value, (s) => {
653
- Object.entries(e).forEach(([n, a]) => {
654
- s.set(n, a);
655
- });
656
- });
657
- this.updateState(r), this.error$.next(null);
658
- } catch (r) {
659
- const s = new l(`Error batch updating in ${this.key}`, r);
660
- this.error$.next(s);
661
- }
662
- }
663
- update(e, r) {
664
- try {
665
- const s = d(this.value, (n) => {
666
- const a = n.get(e);
667
- a !== void 0 && r(a);
668
- });
669
- this.updateState(s), this.error$.next(null);
670
- } catch (s) {
671
- const n = new l(`Error updating item ${e} in ${this.key}`, s);
672
- this.error$.next(n);
673
- }
674
- }
675
- constructor(e, r, s) {
676
- super(e, r, s), e !== "memory" && this.setupPersistence();
677
- }
678
- setupPersistence() {
679
- this.$.pipe(ie(100, void 0, { leading: !0, trailing: !0 })).subscribe((e) => {
680
- this.storage.save(e).catch((r) => {
681
- const s = new l(`Error saving to ${this.storageType} storage for ${this.key}`, r);
682
- this.error$.next(s);
683
- });
684
- });
685
- }
686
- setupDevTools() {
687
- typeof window < "u" && (window.__STORES__ = window.__STORES__ || {}, window.__STORES__[this.key] = { getState: () => this.value, set: this.set.bind(this), delete: this.delete.bind(this), clear: this.clear.bind(this), batchUpdate: this.batchUpdate.bind(this), update: this.update.bind(this), subscribe: (e) => {
688
- const r = this.$.subscribe(e);
689
- return () => r.unsubscribe();
690
- } });
691
- }
692
- };
693
- x.type = "collection", x.instances = /* @__PURE__ */ new Map();
694
- let re = x;
695
- const k = class k extends X {
696
- static getInstance(e, r, s) {
697
- const n = `${e}:${r}`;
698
- return this.instances.has(n) || this.instances.set(n, new k(e, r, s)), this.instances.get(n);
699
- }
700
- set(e, r = !0) {
701
- try {
702
- const s = d(this.value, (n) => {
703
- if (!r) return e;
704
- Object.assign(n, e);
705
- });
706
- this.updateState(s), this.error$.next(null);
707
- } catch (s) {
708
- const n = new l(`Error updating store: ${this.key}`, s, { value: e, merge: r });
709
- this.error$.next(n);
710
- }
711
- }
712
- clear() {
713
- const e = d(this.defaultValue, (r) => r);
714
- this.set(e, !1);
715
- }
716
- delete(e) {
717
- const r = d(this.value, (s) => {
718
- delete s[e];
719
- });
720
- this.updateState(r);
721
- }
722
- setPath(e, r) {
723
- try {
724
- const s = d(this.value, (n) => {
725
- const a = e.split(".");
726
- let h = n;
727
- for (let c = 0; c < a.length - 1; c++) {
728
- const i = a[c];
729
- (h[i] === void 0 || typeof h[i] != "object") && (h[i] = {}), h = h[i];
730
- }
731
- h[a[a.length - 1]] = r;
732
- });
733
- this.updateState(s), this.error$.next(null);
734
- } catch (s) {
735
- const n = new l(`Error setting path ${e} in ${this.key}`, s);
736
- this.error$.next(n);
737
- }
738
- }
739
- processStoredValue(e) {
740
- return d(this.defaultValue, (r) => {
741
- Object.assign(r, e);
742
- });
743
- }
744
- setupDevTools() {
745
- typeof window < "u" && (window.__STORES__ = window.__STORES__ || {}, window.__STORES__[this.key] = { getState: () => this.value, set: this.set.bind(this), delete: this.delete.bind(this), clear: this.clear.bind(this), setPath: this.setPath.bind(this), subscribe: (e) => {
746
- const r = this.$.subscribe(e);
747
- return () => r.unsubscribe();
748
- } });
749
- }
750
- };
751
- k.type = "object", k.instances = /* @__PURE__ */ new Map();
752
- let se = k;
753
- const O = class O extends X {
640
+ const k = class k extends q {
754
641
  static getInstance(e, r, s = []) {
755
642
  const n = `${e}:${r}`;
756
- return this.instances.has(n) || this.instances.set(n, new O(e, r, s)), this.instances.get(n);
643
+ return this.instances.has(n) || this.instances.set(n, new k(e, r, s)), this.instances.get(n);
757
644
  }
758
645
  constructor(e, r, s = []) {
759
646
  super(e, r, s), e !== "memory" && this.setupPersistence();
760
647
  }
761
648
  setupPersistence() {
762
- this.$.pipe(ie(100, void 0, { leading: !0, trailing: !0 })).subscribe((e) => {
649
+ this.$.pipe(oe(100, void 0, { leading: !0, trailing: !0 })).subscribe((e) => {
763
650
  this.storage.save(e).catch((r) => {
764
- const s = new l(`Error saving to ${this.storageType} storage for ${this.key}`, r);
651
+ const s = new u(`Error saving to ${this.storageType} storage for ${this.key}`, r);
765
652
  this.error$.next(s);
766
653
  });
767
654
  });
@@ -773,7 +660,7 @@ const O = class O extends X {
773
660
  });
774
661
  this.updateState(r), this.error$.next(null);
775
662
  } catch (r) {
776
- const s = new l(`Error pushing items in ${this.key}`, r);
663
+ const s = new u(`Error pushing items in ${this.key}`, r);
777
664
  this.error$.next(s);
778
665
  }
779
666
  }
@@ -784,7 +671,7 @@ const O = class O extends X {
784
671
  });
785
672
  return this.updateState(r), this.error$.next(null), e;
786
673
  } catch (e) {
787
- const r = new l(`Error popping item from ${this.key}`, e);
674
+ const r = new u(`Error popping item from ${this.key}`, e);
788
675
  return void this.error$.next(r);
789
676
  }
790
677
  }
@@ -795,7 +682,7 @@ const O = class O extends X {
795
682
  });
796
683
  this.updateState(r), this.error$.next(null);
797
684
  } catch (r) {
798
- const s = new l(`Error unshifting items in ${this.key}`, r);
685
+ const s = new u(`Error unshifting items in ${this.key}`, r);
799
686
  this.error$.next(s);
800
687
  }
801
688
  }
@@ -806,7 +693,7 @@ const O = class O extends X {
806
693
  });
807
694
  return this.updateState(r), this.error$.next(null), e;
808
695
  } catch (e) {
809
- const r = new l(`Error shifting item from ${this.key}`, e);
696
+ const r = new u(`Error shifting item from ${this.key}`, e);
810
697
  return void this.error$.next(r);
811
698
  }
812
699
  }
@@ -818,7 +705,7 @@ const O = class O extends X {
818
705
  });
819
706
  this.updateState(s), this.error$.next(null);
820
707
  } catch (s) {
821
- const n = new l(`Error setting item at index ${e} in ${this.key}`, s);
708
+ const n = new u(`Error setting item at index ${e} in ${this.key}`, s);
822
709
  this.error$.next(n);
823
710
  }
824
711
  }
@@ -832,7 +719,7 @@ const O = class O extends X {
832
719
  });
833
720
  return this.updateState(a), this.error$.next(null), n;
834
721
  } catch (n) {
835
- const a = new l(`Error splicing items in ${this.key}`, n);
722
+ const a = new u(`Error splicing items in ${this.key}`, n);
836
723
  return this.error$.next(a), [];
837
724
  }
838
725
  }
@@ -847,7 +734,7 @@ const O = class O extends X {
847
734
  }
848
735
  return this.error$.next(null), !1;
849
736
  } catch (s) {
850
- const n = new l(`Error removing item in ${this.key}`, s);
737
+ const n = new u(`Error removing item in ${this.key}`, s);
851
738
  return this.error$.next(n), !1;
852
739
  }
853
740
  }
@@ -856,7 +743,7 @@ const O = class O extends X {
856
743
  const r = d(e, (s) => s);
857
744
  this.updateState(r), this.error$.next(null);
858
745
  } catch (r) {
859
- const s = new l(`Error replacing array in ${this.key}`, r);
746
+ const s = new u(`Error replacing array in ${this.key}`, r);
860
747
  this.error$.next(s);
861
748
  }
862
749
  }
@@ -867,7 +754,7 @@ const O = class O extends X {
867
754
  });
868
755
  this.updateState(s), this.error$.next(null);
869
756
  } catch (r) {
870
- const s = new l(`Error filtering array in ${this.key}`, r);
757
+ const s = new u(`Error filtering array in ${this.key}`, r);
871
758
  this.error$.next(s);
872
759
  }
873
760
  }
@@ -881,7 +768,7 @@ const O = class O extends X {
881
768
  });
882
769
  this.updateState(s), this.error$.next(null);
883
770
  } catch (r) {
884
- const s = new l(`Error sorting array in ${this.key}`, r);
771
+ const s = new u(`Error sorting array in ${this.key}`, r);
885
772
  this.error$.next(s);
886
773
  }
887
774
  }
@@ -893,7 +780,7 @@ const O = class O extends X {
893
780
  });
894
781
  this.updateState(s), this.error$.next(null);
895
782
  } catch (s) {
896
- const n = new l(`Error updating item at index ${e} in ${this.key}`, s);
783
+ const n = new u(`Error updating item at index ${e} in ${this.key}`, s);
897
784
  this.error$.next(n);
898
785
  }
899
786
  }
@@ -907,17 +794,228 @@ const O = class O extends X {
907
794
  } });
908
795
  }
909
796
  };
910
- O.type = "array", O.instances = /* @__PURE__ */ new Map();
911
- let ne = O;
797
+ k.type = "array", k.instances = /* @__PURE__ */ new Map();
798
+ let ne = k;
799
+ const O = class O extends q {
800
+ static getInstance(e, r, s) {
801
+ const n = `${e}:${r}`;
802
+ return this.instances.has(n) || this.instances.set(n, new O(e, r, s)), this.instances.get(n);
803
+ }
804
+ set(e, r) {
805
+ try {
806
+ const s = d(this.value, (n) => {
807
+ n.set(e, r);
808
+ });
809
+ this.updateState(s), this.error$.next(null);
810
+ } catch (s) {
811
+ const n = new u(`Error setting value for key ${e} in ${this.key}`, s);
812
+ this.error$.next(n);
813
+ }
814
+ }
815
+ delete(e) {
816
+ try {
817
+ const r = d(this.value, (s) => {
818
+ s.delete(e);
819
+ });
820
+ this.updateState(r), this.error$.next(null);
821
+ } catch (r) {
822
+ const s = new u(`Error deleting key ${e} from ${this.key}`, r);
823
+ this.error$.next(s);
824
+ }
825
+ }
826
+ clear() {
827
+ this.updateState(/* @__PURE__ */ new Map());
828
+ }
829
+ batchUpdate(e) {
830
+ try {
831
+ const r = d(this.value, (s) => {
832
+ Object.entries(e).forEach(([n, a]) => {
833
+ s.set(n, a);
834
+ });
835
+ });
836
+ this.updateState(r), this.error$.next(null);
837
+ } catch (r) {
838
+ const s = new u(`Error batch updating in ${this.key}`, r);
839
+ this.error$.next(s);
840
+ }
841
+ }
842
+ update(e, r) {
843
+ try {
844
+ const s = d(this.value, (n) => {
845
+ const a = n.get(e);
846
+ a !== void 0 && r(a);
847
+ });
848
+ this.updateState(s), this.error$.next(null);
849
+ } catch (s) {
850
+ const n = new u(`Error updating item ${e} in ${this.key}`, s);
851
+ this.error$.next(n);
852
+ }
853
+ }
854
+ constructor(e, r, s) {
855
+ super(e, r, s), e !== "memory" && this.setupPersistence();
856
+ }
857
+ setupPersistence() {
858
+ this.$.pipe(oe(100, void 0, { leading: !0, trailing: !0 })).subscribe((e) => {
859
+ this.storage.save(e).catch((r) => {
860
+ const s = new u(`Error saving to ${this.storageType} storage for ${this.key}`, r);
861
+ this.error$.next(s);
862
+ });
863
+ });
864
+ }
865
+ setupDevTools() {
866
+ typeof window < "u" && (window.__STORES__ = window.__STORES__ || {}, window.__STORES__[this.key] = { getState: () => this.value, set: this.set.bind(this), delete: this.delete.bind(this), clear: this.clear.bind(this), batchUpdate: this.batchUpdate.bind(this), update: this.update.bind(this), subscribe: (e) => {
867
+ const r = this.$.subscribe(e);
868
+ return () => r.unsubscribe();
869
+ } });
870
+ }
871
+ };
872
+ O.type = "collection", O.instances = /* @__PURE__ */ new Map();
873
+ let ie = O;
874
+ const D = class D extends (se = q, re = $, se) {
875
+ constructor() {
876
+ super(...arguments), this[re] = !0;
877
+ }
878
+ static getInstance(e, r, s) {
879
+ const n = `${e}:${r}`;
880
+ return this.instances.has(n) || this.instances.set(n, new D(e, r, s)), this.instances.get(n);
881
+ }
882
+ set(e, r = !0) {
883
+ try {
884
+ if (!this.isImmerDraftable(this.value)) {
885
+ const n = r ? { ...this.value, ...e } : e;
886
+ return this.updateState(n), void this.error$.next(null);
887
+ }
888
+ const s = d(this.value, (n) => {
889
+ if (r) {
890
+ if (e == null) return;
891
+ try {
892
+ Object.assign(n, e);
893
+ } catch {
894
+ Object.keys(e).forEach((h) => {
895
+ n[h] = e[h];
896
+ });
897
+ }
898
+ } else try {
899
+ return e;
900
+ } catch {
901
+ return e;
902
+ }
903
+ });
904
+ this.updateState(s), this.error$.next(null);
905
+ } catch (s) {
906
+ const n = new u(`Error updating store: ${this.key}`, s, { value: e, merge: r });
907
+ this.error$.next(n);
908
+ try {
909
+ const a = r ? { ...this.value, ...e } : e;
910
+ this.updateState(a);
911
+ } catch {
912
+ }
913
+ }
914
+ }
915
+ clear() {
916
+ try {
917
+ if (this.isImmerDraftable(this.defaultValue)) {
918
+ const e = d(this.defaultValue, (r) => r);
919
+ this.set(e, !1);
920
+ } else this.set(this.defaultValue, !1);
921
+ } catch (e) {
922
+ const r = new u(`Error clearing store: ${this.key}`, e);
923
+ this.error$.next(r), this.updateState(this.defaultValue);
924
+ }
925
+ }
926
+ delete(e) {
927
+ try {
928
+ if (!this.isImmerDraftable(this.value)) {
929
+ const s = { ...this.value };
930
+ return delete s[e], void this.updateState(s);
931
+ }
932
+ const r = d(this.value, (s) => {
933
+ delete s[e];
934
+ });
935
+ this.updateState(r);
936
+ } catch (r) {
937
+ const s = new u(`Error deleting key ${String(e)} from store: ${this.key}`, r);
938
+ this.error$.next(s);
939
+ try {
940
+ const n = { ...this.value };
941
+ delete n[e], this.updateState(n);
942
+ } catch {
943
+ }
944
+ }
945
+ }
946
+ setPath(e, r) {
947
+ try {
948
+ if (!e) return;
949
+ if (!this.isImmerDraftable(this.value)) {
950
+ const n = e.split("."), a = { ...this.value };
951
+ let h = a;
952
+ for (let c = 0; c < n.length - 1; c++) {
953
+ const i = n[c];
954
+ h[i] === void 0 ? h[i] = {} : typeof h[i] == "object" && h[i] !== null || (h[i] = {}), h = h[i];
955
+ }
956
+ return h[n[n.length - 1]] = r, void this.updateState(a);
957
+ }
958
+ const s = d(this.value, (n) => {
959
+ const a = e.split(".");
960
+ let h = n;
961
+ for (let i = 0; i < a.length - 1; i++) {
962
+ const o = a[i];
963
+ h[o] === void 0 ? h[o] = {} : typeof h[o] == "object" && h[o] !== null || (h[o] = {}), h = h[o];
964
+ }
965
+ const c = a[a.length - 1];
966
+ try {
967
+ h[c] = r;
968
+ } catch {
969
+ h[c] = r;
970
+ }
971
+ });
972
+ this.updateState(s), this.error$.next(null);
973
+ } catch (s) {
974
+ const n = new u(`Error setting path ${e} in ${this.key}`, s);
975
+ this.error$.next(n);
976
+ try {
977
+ const a = e.split("."), h = { ...this.value };
978
+ let c = h;
979
+ for (let i = 0; i < a.length - 1; i++) {
980
+ const o = a[i];
981
+ c[o] === void 0 ? c[o] = {} : typeof c[o] == "object" && c[o] !== null || (c[o] = {}), c = c[o];
982
+ }
983
+ c[a[a.length - 1]] = r, this.updateState(h);
984
+ } catch {
985
+ }
986
+ }
987
+ }
988
+ processStoredValue(e) {
989
+ try {
990
+ return this.isImmerDraftable(this.defaultValue) && this.isImmerDraftable(e) ? d(this.defaultValue, (r) => {
991
+ Object.assign(r, e);
992
+ }) : { ...this.defaultValue, ...e };
993
+ } catch {
994
+ return e;
995
+ }
996
+ }
997
+ setupDevTools() {
998
+ typeof window < "u" && (window.__STORES__ = window.__STORES__ || {}, window.__STORES__[this.key] = { getState: () => this.value, set: this.set.bind(this), delete: this.delete.bind(this), clear: this.clear.bind(this), setPath: this.setPath.bind(this), subscribe: (e) => {
999
+ const r = this.$.subscribe(e);
1000
+ return () => r.unsubscribe();
1001
+ } });
1002
+ }
1003
+ isImmerDraftable(e) {
1004
+ return e !== null && typeof e == "object" && (super.isImmerDraftable(e) || e[$] === !0);
1005
+ }
1006
+ };
1007
+ D.type = "object", D.instances = /* @__PURE__ */ new Map();
1008
+ let ae = D;
912
1009
  export {
913
- W as I,
914
- _e as L,
915
- ye as M,
916
- se as S,
917
- ge as a,
918
- l as b,
919
- be as c,
920
- re as d,
921
- ne as e
1010
+ q as B,
1011
+ G as I,
1012
+ ge as L,
1013
+ me as M,
1014
+ ne as S,
1015
+ ae as a,
1016
+ ve as b,
1017
+ Se as c,
1018
+ u as d,
1019
+ ie as e
922
1020
  };
923
- //# sourceMappingURL=context-array-CSGdoQ1W.js.map
1021
+ //# sourceMappingURL=context-object-CISes2bD.js.map