atomaric 0.0.77 → 0.0.79

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.
package/build/atomaric.js CHANGED
@@ -1,391 +1,914 @@
1
- let k = () => {
1
+ let Je = () => {
2
2
  throw "call configureAtomaric() before all!";
3
3
  };
4
- const _ = {}, Se = (t) => {
5
- _.useSyncExternalStore = k = t.useSyncExternalStore, _.keyPathSeparator = t.keyPathSeparator, _.securifyKeyLevel = t.securifyKeyLevel, _.securifyValueLevel = t.securifyValueLevel;
6
- }, ne = (t) => k(t.subscribe, t.get), ie = (t) => t.set, xe = (t) => t.setDeferred, be = (t) => t.get, De = (t) => t.do, $e = (t) => [ne(t), ie(t)], _e = (t, e) => new pe(t, e);
7
- class V {
8
- constructor(e) {
9
- if (e)
4
+ const T = {}, Ot = (e) => {
5
+ T.useSyncExternalStore = Je = e.useSyncExternalStore, T.keyPathSeparator = e.keyPathSeparator, T.securifyKeyLevel = e.securifyKeyLevel, T.securifyValueLevel = e.securifyValueLevel;
6
+ }, ft = (e) => Je(e.subscribe, e.get), lt = (e) => e.set, jt = (e) => e.setDeferred, Bt = (e) => e.get, Wt = (e) => e.do, qt = (e) => [ft(e), lt(e)], Gt = (e, t) => new Rt(e, t);
7
+ class F {
8
+ constructor(t) {
9
+ if (t)
10
10
  return new Proxy(this, {
11
- get: (i, s) => s in this ? i[s] : e[s]
11
+ get: (r, n) => n in this ? r[n] : t[n]
12
12
  });
13
13
  }
14
14
  }
15
- const ce = (t, e) => {
16
- const i = (s, n, c) => new Proxy(s, {
17
- get: (l, h, p) => {
18
- const g = c === 0 && e.get != null ? e.get(l, h, p) : l[h];
19
- return typeof g == "object" && g !== null ? i(
20
- Array.isArray(g) ? g.slice(0) : { ...g },
21
- n.concat(Array.isArray(l) ? +h : h),
22
- c + 1
23
- ) : g;
15
+ var Ye = Symbol.for("immer-nothing"), Ve = Symbol.for("immer-draftable"), m = Symbol.for("immer-state"), dt = process.env.NODE_ENV !== "production" ? [
16
+ // All error codes, starting by 0:
17
+ function(e) {
18
+ return `The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`;
19
+ },
20
+ function(e) {
21
+ 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 '${e}'`;
22
+ },
23
+ "This object has been frozen and should not be mutated",
24
+ function(e) {
25
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + e;
26
+ },
27
+ "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
28
+ "Immer forbids circular references",
29
+ "The first or second argument to `produce` must be a function",
30
+ "The third argument to `produce` must be a function or undefined",
31
+ "First argument to `createDraft` must be a plain object, an array, or an immerable object",
32
+ "First argument to `finishDraft` must be a draft returned by `createDraft`",
33
+ function(e) {
34
+ return `'current' expects a draft, got: ${e}`;
35
+ },
36
+ "Object.defineProperty() cannot be used on an Immer draft",
37
+ "Object.setPrototypeOf() cannot be used on an Immer draft",
38
+ "Immer only supports deleting array indices",
39
+ "Immer only supports setting array indices and the 'length' property",
40
+ function(e) {
41
+ return `'original' expects a draft, got: ${e}`;
42
+ }
43
+ // Note: if more errors are added, the errorOffset in Patches.ts should be increased
44
+ // See Patches.ts for additional errors
45
+ ] : [];
46
+ function g(e, ...t) {
47
+ if (process.env.NODE_ENV !== "production") {
48
+ const r = dt[e], n = v(r) ? r.apply(null, t) : r;
49
+ throw new Error(`[Immer] ${n}`);
50
+ }
51
+ throw new Error(
52
+ `[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`
53
+ );
54
+ }
55
+ var w = Object, U = w.getPrototypeOf, X = "constructor", ie = "prototype", Se = "configurable", Z = "enumerable", J = "writable", B = "value", M = (e) => !!e && !!e[m];
56
+ function C(e) {
57
+ var t;
58
+ return e ? Qe(e) || ce(e) || !!e[Ve] || !!((t = e[X]) != null && t[Ve]) || ae(e) || ue(e) : !1;
59
+ }
60
+ var ht = w[ie][X].toString(), Ue = /* @__PURE__ */ new WeakMap();
61
+ function Qe(e) {
62
+ if (!e || !Ee(e))
63
+ return !1;
64
+ const t = U(e);
65
+ if (t === null || t === w[ie])
66
+ return !0;
67
+ const r = w.hasOwnProperty.call(t, X) && t[X];
68
+ if (r === Object)
69
+ return !0;
70
+ if (!v(r))
71
+ return !1;
72
+ let n = Ue.get(r);
73
+ return n === void 0 && (n = Function.toString.call(r), Ue.set(r, n)), n === ht;
74
+ }
75
+ function oe(e, t, r = !0) {
76
+ G(e) === 0 ? (r ? Reflect.ownKeys(e) : w.keys(e)).forEach((s) => {
77
+ t(s, e[s], e);
78
+ }) : e.forEach((n, s) => t(s, n, e));
79
+ }
80
+ function G(e) {
81
+ const t = e[m];
82
+ return t ? t.type_ : ce(e) ? 1 : ae(e) ? 2 : ue(e) ? 3 : 0;
83
+ }
84
+ var Oe = (e, t, r = G(e)) => r === 2 ? e.has(t) : w[ie].hasOwnProperty.call(e, t), Pe = (e, t, r = G(e)) => (
85
+ // @ts-ignore
86
+ r === 2 ? e.get(t) : e[t]
87
+ ), ee = (e, t, r, n = G(e)) => {
88
+ n === 2 ? e.set(t, r) : n === 3 ? e.add(r) : e[t] = r;
89
+ };
90
+ function _t(e, t) {
91
+ return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
92
+ }
93
+ var ce = Array.isArray, ae = (e) => e instanceof Map, ue = (e) => e instanceof Set, Ee = (e) => typeof e == "object", v = (e) => typeof e == "function", ge = (e) => typeof e == "boolean";
94
+ function yt(e) {
95
+ const t = +e;
96
+ return Number.isInteger(t) && String(t) === e;
97
+ }
98
+ var I = (e) => e.copy_ || e.base_, Fe = (e) => e.modified_ ? e.copy_ : e.base_;
99
+ function Ae(e, t) {
100
+ if (ae(e))
101
+ return new Map(e);
102
+ if (ue(e))
103
+ return new Set(e);
104
+ if (ce(e))
105
+ return Array[ie].slice.call(e);
106
+ const r = Qe(e);
107
+ if (t === !0 || t === "class_only" && !r) {
108
+ const n = w.getOwnPropertyDescriptors(e);
109
+ delete n[m];
110
+ let s = Reflect.ownKeys(n);
111
+ for (let i = 0; i < s.length; i++) {
112
+ const c = s[i], u = n[c];
113
+ u[J] === !1 && (u[J] = !0, u[Se] = !0), (u.get || u.set) && (n[c] = {
114
+ [Se]: !0,
115
+ [J]: !0,
116
+ // could live with !!desc.set as well here...
117
+ [Z]: u[Z],
118
+ [B]: e[c]
119
+ });
120
+ }
121
+ return w.create(U(e), n);
122
+ } else {
123
+ const n = U(e);
124
+ if (n !== null && r)
125
+ return { ...e };
126
+ const s = w.create(n);
127
+ return w.assign(s, e);
128
+ }
129
+ }
130
+ function Ne(e, t = !1) {
131
+ return fe(e) || M(e) || !C(e) || (G(e) > 1 && w.defineProperties(e, {
132
+ set: K,
133
+ add: K,
134
+ clear: K,
135
+ delete: K
136
+ }), w.freeze(e), t && oe(
137
+ e,
138
+ (r, n) => {
139
+ Ne(n, !0);
24
140
  },
25
- set: (l, h, p) => (e.onSet(l, n, h, p, l[h]) && (l[h] = p), !0)
141
+ !1
142
+ )), e;
143
+ }
144
+ function pt() {
145
+ g(2);
146
+ }
147
+ var K = {
148
+ [B]: pt
149
+ };
150
+ function fe(e) {
151
+ return e === null || !Ee(e) ? !0 : w.isFrozen(e);
152
+ }
153
+ var te = "MapSet", be = "Patches", je = "ArrayMethods", Xe = {};
154
+ function E(e) {
155
+ const t = Xe[e];
156
+ return t || g(0, e), t;
157
+ }
158
+ var Be = (e) => !!Xe[e], W, Ze = () => W, mt = (e, t) => ({
159
+ drafts_: [],
160
+ parent_: e,
161
+ immer_: t,
162
+ // Whenever the modified draft contains a draft from another scope, we
163
+ // need to prevent auto-freezing so the unowned draft can be finalized.
164
+ canAutoFreeze_: !0,
165
+ unfinalizedDrafts_: 0,
166
+ handledSet_: /* @__PURE__ */ new Set(),
167
+ processedForPatches_: /* @__PURE__ */ new Set(),
168
+ mapSetPlugin_: Be(te) ? E(te) : void 0,
169
+ arrayMethodsPlugin_: Be(je) ? E(je) : void 0
170
+ });
171
+ function We(e, t) {
172
+ t && (e.patchPlugin_ = E(be), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
173
+ }
174
+ function De(e) {
175
+ Ie(e), e.drafts_.forEach(gt), e.drafts_ = null;
176
+ }
177
+ function Ie(e) {
178
+ e === W && (W = e.parent_);
179
+ }
180
+ var qe = (e) => W = mt(W, e);
181
+ function gt(e) {
182
+ const t = e[m];
183
+ t.type_ === 0 || t.type_ === 1 ? t.revoke_() : t.revoked_ = !0;
184
+ }
185
+ function Ge(e, t) {
186
+ t.unfinalizedDrafts_ = t.drafts_.length;
187
+ const r = t.drafts_[0];
188
+ if (e !== void 0 && e !== r) {
189
+ r[m].modified_ && (De(t), g(4)), C(e) && (e = He(t, e));
190
+ const { patchPlugin_: s } = t;
191
+ s && s.generateReplacementPatches_(
192
+ r[m].base_,
193
+ e,
194
+ t
195
+ );
196
+ } else
197
+ e = He(t, r);
198
+ return wt(t, e, !0), De(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_), e !== Ye ? e : void 0;
199
+ }
200
+ function He(e, t) {
201
+ if (fe(t))
202
+ return t;
203
+ const r = t[m];
204
+ if (!r)
205
+ return re(t, e.handledSet_, e);
206
+ if (!le(r, e))
207
+ return t;
208
+ if (!r.modified_)
209
+ return r.base_;
210
+ if (!r.finalized_) {
211
+ const { callbacks_: n } = r;
212
+ if (n)
213
+ for (; n.length > 0; )
214
+ n.pop()(e);
215
+ rt(r, e);
216
+ }
217
+ return r.copy_;
218
+ }
219
+ function wt(e, t, r = !1) {
220
+ !e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && Ne(t, r);
221
+ }
222
+ function et(e) {
223
+ e.finalized_ = !0, e.scope_.unfinalizedDrafts_--;
224
+ }
225
+ var le = (e, t) => e.scope_ === t, St = [];
226
+ function tt(e, t, r, n) {
227
+ const s = I(e), i = e.type_;
228
+ if (n !== void 0 && Pe(s, n, i) === t) {
229
+ ee(s, n, r, i);
230
+ return;
231
+ }
232
+ if (!e.draftLocations_) {
233
+ const u = e.draftLocations_ = /* @__PURE__ */ new Map();
234
+ oe(s, (y, d) => {
235
+ if (M(d)) {
236
+ const h = u.get(d) || [];
237
+ h.push(y), u.set(d, h);
238
+ }
239
+ });
240
+ }
241
+ const c = e.draftLocations_.get(t) ?? St;
242
+ for (const u of c)
243
+ ee(s, u, r, i);
244
+ }
245
+ function Pt(e, t, r) {
246
+ e.callbacks_.push(function(s) {
247
+ var u;
248
+ const i = t;
249
+ if (!i || !le(i, s))
250
+ return;
251
+ (u = s.mapSetPlugin_) == null || u.fixSetContents(i);
252
+ const c = Fe(i);
253
+ tt(e, i.draft_ ?? i, c, r), rt(i, s);
254
+ });
255
+ }
256
+ function rt(e, t) {
257
+ var n;
258
+ if (e.modified_ && !e.finalized_ && (e.type_ === 3 || e.type_ === 1 && e.allIndicesReassigned_ || (((n = e.assigned_) == null ? void 0 : n.size) ?? 0) > 0)) {
259
+ const { patchPlugin_: s } = t;
260
+ if (s) {
261
+ const i = s.getPath(e);
262
+ i && s.generatePatches_(e, i, t);
263
+ }
264
+ et(e);
265
+ }
266
+ }
267
+ function At(e, t, r) {
268
+ const { scope_: n } = e;
269
+ if (M(r)) {
270
+ const s = r[m];
271
+ le(s, n) && s.callbacks_.push(function() {
272
+ Y(e);
273
+ const c = Fe(s);
274
+ tt(e, r, c, t);
275
+ });
276
+ } else C(r) && e.callbacks_.push(function() {
277
+ const i = I(e);
278
+ e.type_ === 3 ? i.has(r) && re(r, n.handledSet_, n) : Pe(i, t, e.type_) === r && n.drafts_.length > 1 && (e.assigned_.get(t) ?? !1) === !0 && e.copy_ && re(
279
+ Pe(e.copy_, t, e.type_),
280
+ n.handledSet_,
281
+ n
282
+ );
26
283
  });
27
- return i(t, [], 0);
284
+ }
285
+ function re(e, t, r) {
286
+ return !r.immer_.autoFreeze_ && r.unfinalizedDrafts_ < 1 || M(e) || t.has(e) || !C(e) || fe(e) || (t.add(e), oe(e, (n, s) => {
287
+ if (M(s)) {
288
+ const i = s[m];
289
+ if (le(i, r)) {
290
+ const c = Fe(i);
291
+ ee(e, n, c, e.type_), et(i);
292
+ }
293
+ } else C(s) && re(s, t, r);
294
+ })), e;
295
+ }
296
+ function bt(e, t) {
297
+ const r = ce(e), n = {
298
+ type_: r ? 1 : 0,
299
+ // Track which produce call this is associated with.
300
+ scope_: t ? t.scope_ : Ze(),
301
+ // True for both shallow and deep changes.
302
+ modified_: !1,
303
+ // Used during finalization.
304
+ finalized_: !1,
305
+ // Track which properties have been assigned (true) or deleted (false).
306
+ // actually instantiated in `prepareCopy()`
307
+ assigned_: void 0,
308
+ // The parent draft state.
309
+ parent_: t,
310
+ // The base state.
311
+ base_: e,
312
+ // The base proxy.
313
+ draft_: null,
314
+ // set below
315
+ // The base copy with any updated values.
316
+ copy_: null,
317
+ // Called by the `produce` function.
318
+ revoke_: null,
319
+ isManual_: !1,
320
+ // `callbacks` actually gets assigned in `createProxy`
321
+ callbacks_: void 0
322
+ };
323
+ let s = n, i = ne;
324
+ r && (s = [n], i = q);
325
+ const { revoke: c, proxy: u } = Proxy.revocable(s, i);
326
+ return n.draft_ = u, n.revoke_ = c, [u, n];
327
+ }
328
+ var ne = {
329
+ get(e, t) {
330
+ if (t === m)
331
+ return e;
332
+ let r = e.scope_.arrayMethodsPlugin_;
333
+ const n = e.type_ === 1 && typeof t == "string";
334
+ if (n && r != null && r.isArrayOperationMethod(t))
335
+ return r.createMethodInterceptor(e, t);
336
+ const s = I(e);
337
+ if (!Oe(s, t, e.type_))
338
+ return Dt(e, s, t);
339
+ const i = s[t];
340
+ if (e.finalized_ || !C(i) || n && e.operationMethod && (r != null && r.isMutatingArrayMethod(
341
+ e.operationMethod
342
+ )) && yt(t))
343
+ return i;
344
+ if (i === we(e.base_, t)) {
345
+ Y(e);
346
+ const c = e.type_ === 1 ? +t : t, u = Me(e.scope_, i, e, c);
347
+ return e.copy_[c] = u;
348
+ }
349
+ return i;
350
+ },
351
+ has(e, t) {
352
+ return t in I(e);
353
+ },
354
+ ownKeys(e) {
355
+ return Reflect.ownKeys(I(e));
356
+ },
357
+ set(e, t, r) {
358
+ const n = nt(I(e), t);
359
+ if (n != null && n.set)
360
+ return n.set.call(e.draft_, r), !0;
361
+ if (!e.modified_) {
362
+ const s = we(I(e), t), i = s == null ? void 0 : s[m];
363
+ if (i && i.base_ === r)
364
+ return e.copy_[t] = r, e.assigned_.set(t, !1), !0;
365
+ if (_t(r, s) && (r !== void 0 || Oe(e.base_, t, e.type_)))
366
+ return !0;
367
+ Y(e), Ce(e);
368
+ }
369
+ return e.copy_[t] === r && // special case: handle new props with value 'undefined'
370
+ (r !== void 0 || t in e.copy_) || // special case: NaN
371
+ Number.isNaN(r) && Number.isNaN(e.copy_[t]) || (e.copy_[t] = r, e.assigned_.set(t, !0), At(e, t, r)), !0;
372
+ },
373
+ deleteProperty(e, t) {
374
+ return Y(e), we(e.base_, t) !== void 0 || t in e.base_ ? (e.assigned_.set(t, !1), Ce(e)) : e.assigned_.delete(t), e.copy_ && delete e.copy_[t], !0;
375
+ },
376
+ // Note: We never coerce `desc.value` into an Immer draft, because we can't make
377
+ // the same guarantee in ES5 mode.
378
+ getOwnPropertyDescriptor(e, t) {
379
+ const r = I(e), n = Reflect.getOwnPropertyDescriptor(r, t);
380
+ return n && {
381
+ [J]: !0,
382
+ [Se]: e.type_ !== 1 || t !== "length",
383
+ [Z]: n[Z],
384
+ [B]: r[t]
385
+ };
386
+ },
387
+ defineProperty() {
388
+ g(11);
389
+ },
390
+ getPrototypeOf(e) {
391
+ return U(e.base_);
392
+ },
393
+ setPrototypeOf() {
394
+ g(12);
395
+ }
396
+ }, q = {};
397
+ for (let e in ne) {
398
+ let t = ne[e];
399
+ q[e] = function() {
400
+ const r = arguments;
401
+ return r[0] = r[0][0], t.apply(this, r);
402
+ };
403
+ }
404
+ q.deleteProperty = function(e, t) {
405
+ return process.env.NODE_ENV !== "production" && isNaN(parseInt(t)) && g(13), q.set.call(this, e, t, void 0);
28
406
  };
29
- class O extends V {
30
- constructor() {
31
- super(...arguments), this.updateValue = (e, i) => {
32
- const s = Array.isArray(e) ? e.slice(0) : { ...e };
33
- let n = !1;
34
- const c = ce(e, {
35
- onSet: (l, h, p, g, w) => {
36
- if (g === w) return !0;
37
- let m = s;
38
- n = !0;
39
- for (const f of h) {
40
- const d = m[f];
41
- m = m[f] = Array.isArray(d) ? d.slice() : { ...d };
42
- }
43
- return m[p] = g, !0;
407
+ q.set = function(e, t, r) {
408
+ return process.env.NODE_ENV !== "production" && t !== "length" && isNaN(parseInt(t)) && g(14), ne.set.call(this, e[0], t, r, e[0]);
409
+ };
410
+ function we(e, t) {
411
+ const r = e[m];
412
+ return (r ? I(r) : e)[t];
413
+ }
414
+ function Dt(e, t, r) {
415
+ var s;
416
+ const n = nt(t, r);
417
+ return n ? B in n ? n[B] : (
418
+ // This is a very special case, if the prop is a getter defined by the
419
+ // prototype, we should invoke it with the draft as context!
420
+ (s = n.get) == null ? void 0 : s.call(e.draft_)
421
+ ) : void 0;
422
+ }
423
+ function nt(e, t) {
424
+ if (!(t in e))
425
+ return;
426
+ let r = U(e);
427
+ for (; r; ) {
428
+ const n = Object.getOwnPropertyDescriptor(r, t);
429
+ if (n)
430
+ return n;
431
+ r = U(r);
432
+ }
433
+ }
434
+ function Ce(e) {
435
+ e.modified_ || (e.modified_ = !0, e.parent_ && Ce(e.parent_));
436
+ }
437
+ function Y(e) {
438
+ e.copy_ || (e.assigned_ = /* @__PURE__ */ new Map(), e.copy_ = Ae(
439
+ e.base_,
440
+ e.scope_.immer_.useStrictShallowCopy_
441
+ ));
442
+ }
443
+ var It = class {
444
+ constructor(e) {
445
+ this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1, this.produce = (t, r, n) => {
446
+ if (v(t) && !v(r)) {
447
+ const i = r;
448
+ r = t;
449
+ const c = this;
450
+ return function(y = i, ...d) {
451
+ return c.produce(y, (h) => r.call(this, h, ...d));
452
+ };
453
+ }
454
+ v(r) || g(6), n !== void 0 && !v(n) && g(7);
455
+ let s;
456
+ if (C(t)) {
457
+ const i = qe(this), c = Me(i, t, void 0);
458
+ let u = !0;
459
+ try {
460
+ s = r(c), u = !1;
461
+ } finally {
462
+ u ? De(i) : Ie(i);
44
463
  }
45
- });
46
- return i(c), n ? s : e;
47
- };
464
+ return We(i, n), Ge(s, i);
465
+ } else if (!t || !Ee(t)) {
466
+ if (s = r(t), s === void 0 && (s = t), s === Ye && (s = void 0), this.autoFreeze_ && Ne(s, !0), n) {
467
+ const i = [], c = [];
468
+ E(be).generateReplacementPatches_(t, s, {
469
+ patches_: i,
470
+ inversePatches_: c
471
+ }), n(i, c);
472
+ }
473
+ return s;
474
+ } else
475
+ g(1, t);
476
+ }, this.produceWithPatches = (t, r) => {
477
+ if (v(t))
478
+ return (c, ...u) => this.produceWithPatches(c, (y) => t(y, ...u));
479
+ let n, s;
480
+ return [this.produce(t, r, (c, u) => {
481
+ n = c, s = u;
482
+ }), n, s];
483
+ }, ge(e == null ? void 0 : e.autoFreeze) && this.setAutoFreeze(e.autoFreeze), ge(e == null ? void 0 : e.useStrictShallowCopy) && this.setUseStrictShallowCopy(e.useStrictShallowCopy), ge(e == null ? void 0 : e.useStrictIteration) && this.setUseStrictIteration(e.useStrictIteration);
484
+ }
485
+ createDraft(e) {
486
+ C(e) || g(8), M(e) && (e = Ct(e));
487
+ const t = qe(this), r = Me(t, e, void 0);
488
+ return r[m].isManual_ = !0, Ie(t), r;
489
+ }
490
+ finishDraft(e, t) {
491
+ const r = e && e[m];
492
+ (!r || !r.isManual_) && g(9);
493
+ const { scope_: n } = r;
494
+ return We(n, t), Ge(void 0, n);
495
+ }
496
+ /**
497
+ * Pass true to automatically freeze all copies created by Immer.
498
+ *
499
+ * By default, auto-freezing is enabled.
500
+ */
501
+ setAutoFreeze(e) {
502
+ this.autoFreeze_ = e;
503
+ }
504
+ /**
505
+ * Pass true to enable strict shallow copy.
506
+ *
507
+ * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
508
+ */
509
+ setUseStrictShallowCopy(e) {
510
+ this.useStrictShallowCopy_ = e;
511
+ }
512
+ /**
513
+ * Pass false to use faster iteration that skips non-enumerable properties
514
+ * but still handles symbols for compatibility.
515
+ *
516
+ * By default, strict iteration is enabled (includes all own properties).
517
+ */
518
+ setUseStrictIteration(e) {
519
+ this.useStrictIteration_ = e;
48
520
  }
521
+ shouldUseStrictIteration() {
522
+ return this.useStrictIteration_;
523
+ }
524
+ applyPatches(e, t) {
525
+ let r;
526
+ for (r = t.length - 1; r >= 0; r--) {
527
+ const s = t[r];
528
+ if (s.path.length === 0 && s.op === "replace") {
529
+ e = s.value;
530
+ break;
531
+ }
532
+ }
533
+ r > -1 && (t = t.slice(r + 1));
534
+ const n = E(be).applyPatches_;
535
+ return M(e) ? n(e, t) : this.produce(
536
+ e,
537
+ (s) => n(s, t)
538
+ );
539
+ }
540
+ };
541
+ function Me(e, t, r, n) {
542
+ const [s, i] = ae(t) ? E(te).proxyMap_(t, r) : ue(t) ? E(te).proxySet_(t, r) : bt(t, r);
543
+ return ((r == null ? void 0 : r.scope_) ?? Ze()).drafts_.push(s), i.callbacks_ = (r == null ? void 0 : r.callbacks_) ?? [], i.key_ = n, r && n !== void 0 ? Pt(r, i, n) : i.callbacks_.push(function(y) {
544
+ var h;
545
+ (h = y.mapSetPlugin_) == null || h.fixSetContents(i);
546
+ const { patchPlugin_: d } = y;
547
+ i.modified_ && d && d.generatePatches_(i, [], y);
548
+ }), s;
49
549
  }
50
- class oe extends O {
51
- constructor(e, i) {
52
- super(i), this.a = e, this.push = (...s) => {
53
- s.length !== 0 && this.a.set(this.a.get().concat(s));
54
- }, this.unshift = (...s) => {
55
- s.length !== 0 && this.a.set(s.concat(this.a.get()));
56
- }, this.update = (s) => {
57
- const n = this.a.get(), c = this.updateValue(n, s);
58
- c !== n && this.a.set(c);
59
- }, this.filter = (s) => {
60
- const n = this.a.get().filter(s ?? ae);
61
- n.length !== this.a.get().length && this.a.set(n);
62
- }, this.add = (s) => {
63
- this.a.get().includes(s) || this.a.set(this.a.get().concat([s]));
64
- }, this.removeFirst = (s) => {
65
- const n = this.a.get().indexOf(s);
66
- if (n < 0) return;
67
- const c = this.a.get().slice(0);
68
- c.splice(n, 1), this.a.set(c);
69
- }, this.toggle = (s, n) => {
70
- const c = this.a.get().slice(), l = c.indexOf(s);
71
- l < 0 ? n ? c.unshift(s) : c.push(s) : c.splice(l, 1), this.a.set(c);
550
+ function Ct(e) {
551
+ return M(e) || g(10, e), st(e);
552
+ }
553
+ function st(e) {
554
+ if (!C(e) || fe(e))
555
+ return e;
556
+ const t = e[m];
557
+ let r, n = !0;
558
+ if (t) {
559
+ if (!t.modified_)
560
+ return t.base_;
561
+ t.finalized_ = !0, r = Ae(e, t.scope_.immer_.useStrictShallowCopy_), n = t.scope_.immer_.shouldUseStrictIteration();
562
+ } else
563
+ r = Ae(e, !0);
564
+ return oe(
565
+ r,
566
+ (s, i) => {
567
+ ee(r, s, st(i));
568
+ },
569
+ n
570
+ ), t && (t.finalized_ = !1), r;
571
+ }
572
+ var Mt = new It(), it = Mt.produce;
573
+ class zt extends F {
574
+ constructor(t, r) {
575
+ super(r), this.a = t, this.push = (...n) => {
576
+ n.length !== 0 && this.a.set(this.a.get().concat(n));
577
+ }, this.unshift = (...n) => {
578
+ n.length !== 0 && this.a.set(n.concat(this.a.get()));
579
+ }, this.update = (n) => {
580
+ const s = this.a.get(), i = it(s, (c) => void n(c));
581
+ i !== s && this.a.set(i);
582
+ }, this.filter = (n) => {
583
+ const s = this.a.get().filter(n ?? xt);
584
+ s.length !== this.a.get().length && this.a.set(s);
585
+ }, this.add = (n) => {
586
+ this.a.get().includes(n) || this.a.set(this.a.get().concat([n]));
587
+ }, this.removeFirst = (n) => {
588
+ const s = this.a.get().indexOf(n);
589
+ if (s < 0) return;
590
+ const i = this.a.get().slice(0);
591
+ i.splice(s, 1), this.a.set(i);
592
+ }, this.toggle = (n, s) => {
593
+ const i = this.a.get().slice(), c = i.indexOf(n);
594
+ c < 0 ? s ? i.unshift(n) : i.push(n) : i.splice(c, 1), this.a.set(i);
72
595
  };
73
596
  }
74
597
  }
75
- const ae = (t) => t;
76
- class ue extends V {
77
- constructor(e, i) {
78
- super(i), this.a = e, this.toggle = () => {
598
+ const xt = (e) => e;
599
+ class vt extends F {
600
+ constructor(t, r) {
601
+ super(r), this.a = t, this.toggle = () => {
79
602
  this.a.set(!this.a.get());
80
603
  };
81
604
  }
82
605
  }
83
- class le extends V {
84
- constructor(e, i) {
85
- super(i), this.a = e, this.setValue = (s, n) => {
86
- if (this.a.get().get(s) === n) return;
87
- const c = new Map(this.a.get());
88
- c.set(s, n), this.a.set(c);
89
- }, this.setIfNo = (s, n) => {
90
- if (this.a.get().has(s)) return;
91
- const c = new Map(this.a.get());
92
- c.set(s, n), this.a.set(c);
93
- }, this.delete = (s) => {
94
- if (!this.a.get().has(s)) return;
95
- const n = new Map(this.a.get());
96
- n.delete(s), this.a.set(n);
97
- }, this.toggle = (s, n) => {
98
- const c = new Map(this.a.get());
99
- c.has(s) ? c.delete(s) : c.set(s, n), this.a.set(c);
606
+ class Tt extends F {
607
+ constructor(t, r) {
608
+ super(r), this.a = t, this.setValue = (n, s) => {
609
+ if (this.a.get().get(n) === s) return;
610
+ const i = new Map(this.a.get());
611
+ i.set(n, s), this.a.set(i);
612
+ }, this.setIfNo = (n, s) => {
613
+ if (this.a.get().has(n)) return;
614
+ const i = new Map(this.a.get());
615
+ i.set(n, s), this.a.set(i);
616
+ }, this.delete = (n) => {
617
+ if (!this.a.get().has(n)) return;
618
+ const s = new Map(this.a.get());
619
+ s.delete(n), this.a.set(s);
620
+ }, this.toggle = (n, s) => {
621
+ const i = new Map(this.a.get());
622
+ i.has(n) ? i.delete(n) : i.set(n, s), this.a.set(i);
100
623
  }, this.clear = () => {
101
624
  this.a.set(/* @__PURE__ */ new Map());
102
- }, this.a = e;
625
+ }, this.a = t;
103
626
  }
104
627
  }
105
- class fe extends V {
106
- constructor(e, i) {
107
- super(i), this.a = e, this.increment = (s) => {
108
- this.a.set(+this.a.get() + (s ?? 1));
628
+ class Et extends F {
629
+ constructor(t, r) {
630
+ super(r), this.a = t, this.increment = (n) => {
631
+ this.a.set(+this.a.get() + (n ?? 1));
109
632
  };
110
633
  }
111
634
  }
112
- class he extends O {
113
- constructor(e, i) {
114
- super(i), this.a = e, this.setPartial = (s) => this.a.set((n) => ({
115
- ...n,
116
- ...typeof s == "function" ? s(this.a.get()) : s
117
- })), this.update = (s) => {
118
- const n = this.a.get(), c = this.updateValue(n, s);
119
- c !== n && this.a.set(c);
120
- }, this.setDeepPartial = (s, n, c, l = _.keyPathSeparator || ".") => {
121
- if (!l) return;
122
- if (s.includes(l)) {
123
- let g = s.split(l);
124
- const w = g[g.length - 1];
125
- g = g.slice(0, -1);
126
- const m = { ...this.a.get() };
127
- let f = m, d = c;
128
- for (const y of g) {
129
- d = d == null ? void 0 : d[Array.isArray(d) ? "0" : y];
130
- const D = f[v(f, y)] ?? (Array.isArray(d) ? [] : {});
131
- if (D == null || typeof D != "object") {
132
- if (c == null) throw "Incorrect path for setDeepPartial";
133
- const S = typeof n == "function" ? n(void 0) : n;
134
- this.a.get()[s] !== S && this.setPartial({ [s]: S });
635
+ class Ft extends F {
636
+ constructor(t, r) {
637
+ super(r), this.a = t, this.setPartial = (n) => this.a.set((s) => ({
638
+ ...s,
639
+ ...typeof n == "function" ? n(this.a.get()) : n
640
+ })), this.update = (n) => {
641
+ const s = this.a.get(), i = it(s, (c) => void n(c));
642
+ i !== s && this.a.set(i);
643
+ }, this.setDeepPartial = (n, s, i, c = T.keyPathSeparator || ".") => {
644
+ if (!c) return;
645
+ if (n.includes(c)) {
646
+ let d = n.split(c);
647
+ const h = d[d.length - 1];
648
+ d = d.slice(0, -1);
649
+ const O = { ...this.a.get() };
650
+ let _ = O, p = i;
651
+ for (const S of d) {
652
+ p = p == null ? void 0 : p[Array.isArray(p) ? "0" : S];
653
+ const z = _[Ke(_, S)] ?? (Array.isArray(p) ? [] : {});
654
+ if (z == null || typeof z != "object") {
655
+ if (i == null) throw "Incorrect path for setDeepPartial";
656
+ const A = typeof s == "function" ? s(void 0) : s;
657
+ this.a.get()[n] !== A && this.setPartial({ [n]: A });
135
658
  return;
136
659
  }
137
- f = f[v(f, y)] = Array.isArray(D) ? [...D] : { ...D };
660
+ _ = _[Ke(_, S)] = Array.isArray(z) ? [...z] : { ...z };
138
661
  }
139
- const E = f[w];
140
- f[w] = typeof n == "function" ? n(f[w]) : n, E !== f[w] && this.a.set(m);
662
+ const H = _[h];
663
+ _[h] = typeof s == "function" ? s(_[h]) : s, H !== _[h] && this.a.set(O);
141
664
  return;
142
665
  }
143
- const h = this.a.get()[s], p = typeof n == "function" ? n(h) : n;
144
- p !== h && this.setPartial({ [s]: p });
666
+ const u = this.a.get()[n], y = typeof s == "function" ? s(u) : s;
667
+ y !== u && this.setPartial({ [n]: y });
145
668
  };
146
669
  }
147
670
  }
148
- const v = (t, e) => Array.isArray(t) ? `${+e}` : e;
149
- class de extends V {
150
- constructor(e, i) {
151
- super(i), this.a = e, this.add = (s) => {
152
- this.a.get().has(s) || this.a.set(new Set(this.a.get()).add(s));
153
- }, this.delete = (s) => {
154
- if (!this.a.get().has(s)) return;
155
- const n = new Set(this.a.get());
156
- n.delete(s), this.a.set(n);
157
- }, this.toggle = (s) => {
158
- const n = new Set(this.a.get());
159
- n.has(s) ? n.delete(s) : n.add(s), this.a.set(n);
671
+ const Ke = (e, t) => Array.isArray(e) ? `${+t}` : t;
672
+ class Nt extends F {
673
+ constructor(t, r) {
674
+ super(r), this.a = t, this.add = (n) => {
675
+ this.a.get().has(n) || this.a.set(new Set(this.a.get()).add(n));
676
+ }, this.delete = (n) => {
677
+ if (!this.a.get().has(n)) return;
678
+ const s = new Set(this.a.get());
679
+ s.delete(n), this.a.set(s);
680
+ }, this.toggle = (n) => {
681
+ const s = new Set(this.a.get());
682
+ s.has(n) ? s.delete(n) : s.add(n), this.a.set(s);
160
683
  }, this.clear = () => {
161
684
  this.a.set(/* @__PURE__ */ new Set());
162
- }, this.a = e;
685
+ }, this.a = t;
163
686
  }
164
687
  }
165
- const ge = (t, e, i) => {
166
- const s = typeof i == "object" && i != null && "do" in i ? i.do(
167
- (c, l) => e.set(c, l),
168
- () => e.get(),
169
- e,
170
- (c, l, h) => e.setDeferred(c, l, h)
171
- ) : null, n = {};
172
- return s && Object.keys(s).forEach((c) => Object.defineProperty(n, c, { get: () => s[c] })), typeof t == "number" ? new fe(e, s) : typeof t == "boolean" ? new ue(e, s) : Array.isArray(t) ? new oe(e, s) : t instanceof Set ? new de(e, s) : t instanceof Map ? new le(e, s) : t instanceof Object ? new he(e, s) : new V(s);
688
+ const $t = (e, t, r) => {
689
+ const n = typeof r == "object" && r != null && "do" in r ? r.do(
690
+ (i, c) => t.set(i, c),
691
+ () => t.get(),
692
+ t,
693
+ (i, c, u) => t.setDeferred(i, c, u)
694
+ ) : null, s = {};
695
+ return n && Object.keys(n).forEach((i) => Object.defineProperty(s, i, { get: () => n[i] })), typeof e == "number" ? new Et(t, n) : typeof e == "boolean" ? new vt(t, n) : Array.isArray(e) ? new zt(t, n) : e instanceof Set ? new Nt(t, n) : e instanceof Map ? new Tt(t, n) : e instanceof Object ? new Ft(t, n) : new F(n);
173
696
  };
174
- class pe {
175
- constructor(e, i) {
176
- e = typeof e == "function" ? e() : e;
177
- const s = (r) => g = r, n = () => g, c = /* @__PURE__ */ new Set(), l = (r) => r(f());
178
- let h = !0, p = !1, g = e, w, m = () => {
179
- }, f = () => n(), d = null, E = () => {
180
- const r = ge(e, y, i);
181
- return E = () => r, r;
697
+ class Rt {
698
+ constructor(t, r) {
699
+ t = typeof t == "function" ? t() : t;
700
+ const n = (o) => d = o, s = () => d, i = /* @__PURE__ */ new Set(), c = (o) => o(_());
701
+ let u = !0, y = !1, d = t, h, O = () => {
702
+ }, _ = () => s(), p = null, H = () => {
703
+ const o = $t(t, S, r);
704
+ return H = () => o, o;
182
705
  };
183
- const y = new Proxy(this, {
184
- get: (r, u) => u === "do" ? E() : r[u],
185
- set: we
186
- }), D = () => {
187
- h = !0, p !== !0 && m(f()), p = !1;
706
+ const S = new Proxy(this, {
707
+ get: (o, l) => l === "do" ? H() : o[l],
708
+ set: kt
709
+ }), z = () => {
710
+ u = !0, y !== !0 && O(_()), y = !1;
188
711
  try {
189
- H.postMessage({ key: a, value: n() });
712
+ ze.postMessage({ key: f, value: s() });
190
713
  } catch {
191
714
  }
192
- }, S = (r, u) => {
193
- const x = typeof r == "function" ? r(f()) : r;
194
- x !== f() && (s(x), p = u, h && (h = !1, c.forEach(l), queueMicrotask(D)));
715
+ }, A = (o, l) => {
716
+ const b = typeof o == "function" ? o(_()) : o;
717
+ b !== _() && (n(b), y = l, u && (u = !1, i.forEach(c), queueMicrotask(z)));
195
718
  };
196
- this.set = (r, u) => S(r, u), this.get = () => f(), this.initialValue = e, this.isInitialValue = () => e === n(), this.subscribe = (r) => (c.add(r), () => {
197
- c.delete(r);
719
+ this.set = (o, l) => A(o, l), this.get = () => _(), this.initialValue = t, this.isInitialValue = () => t === s(), this.subscribe = (o) => (i.add(o), () => {
720
+ i.delete(o);
198
721
  }), this.reset = () => {
199
- S(e, !0);
722
+ A(t, !0);
200
723
  };
201
- const re = (r, u) => {
202
- S(r, u), w = void 0;
724
+ const ut = (o, l) => {
725
+ A(o, l), h = void 0;
203
726
  };
204
- if (this.setDeferred = (r, u = 500, x, b = !0) => {
205
- b && w === void 0 && S(r, x), clearTimeout(w), w = setTimeout(re, u, r, x);
206
- }, i == null) return y;
207
- let A = null, j = null, q = !0, F = !0, N = !1, $ = 0, M = 0, K = -1, T = e instanceof Set ? (r) => new Set(r) : e instanceof Map ? (r) => new Map(r) : (r) => r, I = e instanceof Set ? (r) => {
208
- if (r instanceof Set) return Array.from(r);
209
- throw console.error(r), "The value is not Set instance";
210
- } : e instanceof Map ? (r) => {
211
- if (r instanceof Map) {
212
- const u = [];
213
- return r.forEach((x, b) => u.push([b, x])), u;
727
+ if (this.setDeferred = (o, l = 500, b, D = !0) => {
728
+ D && h === void 0 && A(o, b), clearTimeout(h), h = setTimeout(ut, l, o, b);
729
+ }, r == null) return S;
730
+ let P = null, j = null, he = !0, _e = !0, ye = !1, x = 0, N = 0, $e = -1, $ = t instanceof Set ? (o) => new Set(o) : t instanceof Map ? (o) => new Map(o) : (o) => o, R = t instanceof Set ? (o) => {
731
+ if (o instanceof Set) return Array.from(o);
732
+ throw console.error(o), "The value is not Set instance";
733
+ } : t instanceof Map ? (o) => {
734
+ if (o instanceof Map) {
735
+ const l = [];
736
+ return o.forEach((b, D) => l.push([D, b])), l;
214
737
  }
215
- throw console.error(r), "The value is not Set instance";
216
- } : (r) => r;
217
- if (typeof i == "string")
218
- A = i;
219
- else if ("storeKey" in i)
220
- q = i.warnOnDuplicateStoreKey ?? q, F = i.listenStorageChanges ?? F, A = i.storeKey, T = i.unzipValue ?? T, I = i.zipValue ?? I, N = i.unchangable ?? N, $ = i.securifyKeyLevel ?? _.securifyKeyLevel ?? $, M = i.securifyValueLevel ?? _.securifyValueLevel ?? M, j = i.exp ?? j;
221
- else return y;
222
- const B = $ ? L(A, $) : A, a = `${M ? J : C}${B}`;
223
- if ($) {
224
- const r = `${C}${A}`;
225
- r in o && (o[a] = o[r], delete o[r]);
738
+ throw console.error(o), "The value is not Set instance";
739
+ } : (o) => o;
740
+ if (typeof r == "string")
741
+ P = r;
742
+ else if ("storeKey" in r)
743
+ he = r.warnOnDuplicateStoreKey ?? he, _e = r.listenStorageChanges ?? _e, P = r.storeKey, $ = r.unzipValue ?? $, R = r.zipValue ?? R, ye = r.unchangable ?? ye, x = r.securifyKeyLevel ?? T.securifyKeyLevel ?? x, N = r.securifyValueLevel ?? T.securifyValueLevel ?? N, j = r.exp ?? j;
744
+ else return S;
745
+ const pe = x ? k(P, x) : P, f = `${N ? xe : L}${pe}`;
746
+ if (x) {
747
+ const o = `${L}${P}`;
748
+ o in a && (a[f] = a[o], delete a[o]);
226
749
  } else {
227
- const r = `${C}${L(A, $)}`;
228
- r in o && (o[a] = o[r], delete o[r]);
750
+ const o = `${L}${k(P, x)}`;
751
+ o in a && (a[f] = a[o], delete a[o]);
229
752
  }
230
- const W = j === null || !(j(y, a in o) instanceof Date) ? (r) => L([I(r)], 0) : (r) => (d ?? (d = {}), d.exp = j(y, a in o).getTime(), d.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout(K), clearTimeout(ee[a]), K = setTimeout(() => this.reset(), d.exp - Date.now())), d.exp = Math.trunc(d.exp / 1e3), L([I(r), d], 0));
231
- if (M) {
232
- const r = `${C}${B}`, u = I, x = T;
233
- if (I = (b) => {
753
+ const me = j === null || !(j(S, f in a) instanceof Date) ? (o) => k([R(o)], 0) : (o) => (p ?? (p = {}), p.exp = j(S, f in a).getTime(), p.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout($e), clearTimeout(ot[f]), $e = setTimeout(() => this.reset(), p.exp - Date.now())), p.exp = Math.trunc(p.exp / 1e3), k([R(o), p], 0));
754
+ if (N) {
755
+ const o = `${L}${pe}`, l = R, b = $;
756
+ if (R = (D) => {
234
757
  try {
235
- return L([u(b)], M);
758
+ return k([l(D)], N);
236
759
  } catch {
237
- return delete o[a], "";
760
+ return delete a[f], "";
238
761
  }
239
- }, r in o) {
240
- const b = `${C}${L(A, $)}`;
762
+ }, o in a) {
763
+ const D = `${L}${k(P, x)}`;
241
764
  try {
242
- o[b] = W(T(z(o[r], 0)[0])), delete o[r];
765
+ a[D] = me($(Q(a[o], 0)[0])), delete a[o];
243
766
  } catch {
244
767
  }
245
768
  }
246
- T = (b) => {
769
+ $ = (D) => {
247
770
  try {
248
- return x(z(b, M)[0]);
771
+ return b(Q(D, N)[0]);
249
772
  } catch {
250
- return delete o[a], "";
773
+ return delete a[f], "";
251
774
  }
252
775
  };
253
- } else delete o[`${J}${B}`];
254
- const X = (r) => {
255
- const u = z(r, 0);
256
- return d = u[1], T(u[0]);
776
+ } else delete a[`${xe}${pe}`];
777
+ const Re = (o) => {
778
+ const l = Q(o, 0);
779
+ return p = l[1], $(l[0]);
257
780
  };
258
- let Y = !0;
259
- if (G[a] = y, o[`atom/${A}`] && (o[a] || (o[a] = `[${o[`atom/${A}`]}]`), delete o[`atom/${A}`]), f = () => {
260
- if (f = n, Y) {
261
- Y = !1;
781
+ let ke = !0;
782
+ if (ve[f] = S, a[`atom/${P}`] && (a[f] || (a[f] = `[${a[`atom/${P}`]}]`), delete a[`atom/${P}`]), _ = () => {
783
+ if (_ = s, ke) {
784
+ ke = !1;
262
785
  try {
263
- s(a in o ? X(o[a]) : e);
786
+ n(f in a ? Re(a[f]) : t);
264
787
  } catch {
265
- console.warn("Invalid json value", o[a]);
788
+ console.warn("Invalid json value", a[f]);
266
789
  }
267
790
  }
268
- return n();
269
- }, m = (r) => {
270
- if (r === e) {
791
+ return s();
792
+ }, O = (o) => {
793
+ if (o === t) {
271
794
  this.reset();
272
795
  return;
273
796
  }
274
- o[a] = W(r);
797
+ a[f] = me(o);
275
798
  }, this.reset = () => {
276
- delete o[a], S(e, !0);
277
- }, q && P[a] !== void 0 && console.warn("Duplicate Atom key", A), F)
278
- if (N) {
279
- let r = !1, u;
280
- U[a] = this, P[a] = () => {
281
- clearTimeout(u), u = setTimeout(() => r = !1, 10), !r && (r = !0, o[a] = W(n()));
799
+ delete a[f], A(t, !0);
800
+ }, he && V[f] !== void 0 && console.warn("Duplicate Atom key", P), _e)
801
+ if (ye) {
802
+ let o = !1, l;
803
+ de[f] = this, V[f] = () => {
804
+ clearTimeout(l), l = setTimeout(() => o = !1, 10), !o && (o = !0, a[f] = me(s()));
282
805
  };
283
806
  } else
284
- P[a] = (r) => {
285
- if (r.newValue === null) {
807
+ V[f] = (o) => {
808
+ if (o.newValue === null) {
286
809
  this.reset();
287
810
  return;
288
811
  }
289
812
  try {
290
- S(X(r.newValue));
813
+ A(Re(o.newValue));
291
814
  } catch {
292
- console.warn("Invalid json value", r.newValue);
815
+ console.warn("Invalid json value", o.newValue);
293
816
  }
294
817
  };
295
- return y;
818
+ return S;
296
819
  }
297
820
  }
298
- let H;
821
+ let ze;
299
822
  try {
300
- H = new BroadcastChannel("updateHere"), H.addEventListener("message", (t) => {
301
- var e;
302
- (e = U[t.data.key]) == null || e.set(t.data.value, !0);
823
+ ze = new BroadcastChannel("updateHere"), ze.addEventListener("message", (e) => {
824
+ var t;
825
+ (t = de[e.data.key]) == null || t.set(e.data.value, !0);
303
826
  });
304
827
  } catch {
305
828
  }
306
- const o = localStorage, P = {}, U = {}, we = (t, e) => {
307
- throw `${e} is readonly property`;
829
+ const a = localStorage, V = {}, de = {}, kt = (e, t) => {
830
+ throw `${t} is readonly property`;
308
831
  };
309
- window.addEventListener("storage", (t) => {
310
- var e;
311
- t.key === null || t.newValue === t.oldValue || (e = P[t.key]) == null || e.call(P, t);
832
+ window.addEventListener("storage", (e) => {
833
+ var t;
834
+ e.key === null || e.newValue === e.oldValue || (t = V[e.key]) == null || t.call(V, e);
312
835
  });
313
- const ye = o.setItem.bind(o), Ae = o.removeItem.bind(o);
314
- o.setItem = (t, e) => {
315
- U[t] === void 0 && ye.call(o, t, e);
836
+ const Lt = a.setItem.bind(a), Vt = a.removeItem.bind(a);
837
+ a.setItem = (e, t) => {
838
+ de[e] === void 0 && Lt.call(a, e, t);
316
839
  };
317
- o.removeItem = (t) => {
318
- U[t] === void 0 && Ae.call(o, t);
840
+ a.removeItem = (e) => {
841
+ de[e] === void 0 && Vt.call(a, e);
319
842
  };
320
- const me = /"exp":\s*(\d+)/, C = "atom\\", J = "atom`s\\", G = {}, ee = {}, te = /[a-z]/gi, R = 5, Q = {};
321
- for (let t = 54; t < 80; t++) {
322
- if (t === 68 || t === 72 || t === 55) continue;
323
- const e = String.fromCharCode(t + 43).toUpperCase(), i = String.fromCharCode(t + 43).toLowerCase();
324
- Q[e] = i, Q[i] = e;
325
- }
326
- const se = (t) => Q[t] ?? t, L = /* @__PURE__ */ (() => {
327
- const t = [
328
- (e) => JSON.stringify(e),
329
- (e) => btoa(encodeURI(t[0](e))),
330
- (e) => {
331
- const i = t[1](e);
332
- return `${i.slice(0, R)}${i.slice(R).replace(te, se)}`;
843
+ const Ut = /"exp":\s*(\d+)/, L = "atom\\", xe = "atom`s\\", ve = {}, ot = {}, ct = /[a-z]/gi, se = 5, Te = {};
844
+ for (let e = 54; e < 80; e++) {
845
+ if (e === 68 || e === 72 || e === 55) continue;
846
+ const t = String.fromCharCode(e + 43).toUpperCase(), r = String.fromCharCode(e + 43).toLowerCase();
847
+ Te[t] = r, Te[r] = t;
848
+ }
849
+ const at = (e) => Te[e] ?? e, k = /* @__PURE__ */ (() => {
850
+ const e = [
851
+ (t) => JSON.stringify(t),
852
+ (t) => btoa(encodeURI(e[0](t))),
853
+ (t) => {
854
+ const r = e[1](t);
855
+ return `${r.slice(0, se)}${r.slice(se).replace(ct, at)}`;
333
856
  },
334
- (e) => btoa(t[2](e))
857
+ (t) => btoa(e[2](t))
335
858
  ];
336
- return (e, i) => {
859
+ return (t, r) => {
337
860
  try {
338
- return t[i](e);
339
- } catch (s) {
340
- if (i === 0) throw s;
341
- return t[0](e);
861
+ return e[r](t);
862
+ } catch (n) {
863
+ if (r === 0) throw n;
864
+ return e[0](t);
342
865
  }
343
866
  };
344
- })(), z = /* @__PURE__ */ (() => {
345
- const t = [
346
- (e) => JSON.parse(e),
347
- (e) => t[0](decodeURI(atob(e))),
348
- (e) => t[1](
349
- `${e.slice(0, R)}${e.slice(R).replace(te, se)}`
867
+ })(), Q = /* @__PURE__ */ (() => {
868
+ const e = [
869
+ (t) => JSON.parse(t),
870
+ (t) => e[0](decodeURI(atob(t))),
871
+ (t) => e[1](
872
+ `${t.slice(0, se)}${t.slice(se).replace(ct, at)}`
350
873
  ),
351
- (e) => t[2](atob(e))
874
+ (t) => e[2](atob(t))
352
875
  ];
353
- return (e, i) => {
876
+ return (t, r) => {
354
877
  try {
355
- return t[i](e);
356
- } catch (s) {
357
- if (i === 0) throw s;
358
- return t[0](e);
878
+ return e[r](t);
879
+ } catch (n) {
880
+ if (r === 0) throw n;
881
+ return e[0](t);
359
882
  }
360
883
  };
361
884
  })();
362
885
  setTimeout(() => {
363
- Object.keys(o).forEach((t) => {
364
- var s;
365
- if (typeof o[t] != "string" || !t.startsWith(C) && !t.startsWith(J)) return;
366
- const e = (s = o[t].match(me)) == null ? void 0 : s[1];
367
- if (!e || +e * 1e3 - Date.now() > 24 * 60 * 60 * 1e3) return;
368
- const i = z(o[t], 0);
369
- !Array.isArray(i) || i[1] == null || !("exp" in i[1]) || i[1].exp !== e || (ee[t] = setTimeout(() => {
370
- G[t] ? G[t].reset() : delete o[t];
371
- }, +e * 1e3 - Date.now()));
886
+ Object.keys(a).forEach((e) => {
887
+ var n;
888
+ if (typeof a[e] != "string" || !e.startsWith(L) && !e.startsWith(xe)) return;
889
+ const t = (n = a[e].match(Ut)) == null ? void 0 : n[1];
890
+ if (!t || +t * 1e3 - Date.now() > 24 * 60 * 60 * 1e3) return;
891
+ const r = Q(a[e], 0);
892
+ !Array.isArray(r) || r[1] == null || !("exp" in r[1]) || r[1].exp !== t || (ot[e] = setTimeout(() => {
893
+ ve[e] ? ve[e].reset() : delete a[e];
894
+ }, +t * 1e3 - Date.now()));
372
895
  });
373
896
  }, 1e3);
374
897
  export {
375
- pe as Atom,
376
- oe as AtomArrayDoActions,
377
- ue as AtomBooleanDoActions,
378
- le as AtomMapDoActions,
379
- fe as AtomNumberDoActions,
380
- he as AtomObjectDoActions,
381
- de as AtomSetDoActions,
382
- _e as atom,
383
- Se as configureAtomaric,
384
- _ as configuredOptions,
385
- $e as useAtom,
386
- De as useAtomDo,
387
- be as useAtomGet,
388
- ie as useAtomSet,
389
- xe as useAtomSetDeferred,
390
- ne as useAtomValue
898
+ Rt as Atom,
899
+ zt as AtomArrayDoActions,
900
+ vt as AtomBooleanDoActions,
901
+ Tt as AtomMapDoActions,
902
+ Et as AtomNumberDoActions,
903
+ Ft as AtomObjectDoActions,
904
+ Nt as AtomSetDoActions,
905
+ Gt as atom,
906
+ Ot as configureAtomaric,
907
+ T as configuredOptions,
908
+ qt as useAtom,
909
+ Wt as useAtomDo,
910
+ Bt as useAtomGet,
911
+ lt as useAtomSet,
912
+ jt as useAtomSetDeferred,
913
+ ft as useAtomValue
391
914
  };