use-abcd 0.2.1 → 1.1.0

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 (40) hide show
  1. package/README.md +459 -85
  2. package/dist/App.d.ts +2 -0
  3. package/dist/cache.d.ts +12 -0
  4. package/dist/cache.test.d.ts +1 -0
  5. package/dist/chunks/client-VrsFvEIA.js +144 -0
  6. package/dist/chunks/client-VrsFvEIA.js.map +1 -0
  7. package/dist/chunks/types-Dy4rYb2N.js +19 -0
  8. package/dist/chunks/types-Dy4rYb2N.js.map +1 -0
  9. package/dist/collection.d.ts +54 -0
  10. package/dist/collection.e2e.test.d.ts +1 -0
  11. package/dist/examples/OptimisticComments.d.ts +2 -0
  12. package/dist/examples/PaginatedUsers.d.ts +2 -0
  13. package/dist/examples/Products.d.ts +2 -0
  14. package/dist/fetch-handler.d.ts +34 -0
  15. package/dist/fetch-handler.test.d.ts +1 -0
  16. package/dist/index.d.ts +14 -0
  17. package/dist/index.js +2283 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/item.d.ts +21 -0
  20. package/dist/main.d.ts +1 -0
  21. package/dist/mocks/browser.d.ts +1 -0
  22. package/dist/mocks/handlers.d.ts +2 -0
  23. package/dist/runtime/client.d.ts +51 -0
  24. package/dist/runtime/client.js +16 -0
  25. package/dist/runtime/client.js.map +1 -0
  26. package/dist/runtime/client.test.d.ts +1 -0
  27. package/dist/runtime/index.d.ts +5 -0
  28. package/dist/runtime/server.d.ts +33 -0
  29. package/dist/runtime/server.js +121 -0
  30. package/dist/runtime/server.js.map +1 -0
  31. package/dist/runtime/server.test.d.ts +1 -0
  32. package/dist/runtime/types.d.ts +70 -0
  33. package/dist/sync-queue.d.ts +29 -0
  34. package/dist/sync-queue.test.d.ts +1 -0
  35. package/dist/types.d.ts +61 -0
  36. package/dist/useCrud.d.ts +28 -169
  37. package/dist/useItem.d.ts +11 -0
  38. package/dist/utils.d.ts +4 -0
  39. package/package.json +25 -7
  40. package/dist/useCrud.js +0 -2135
package/dist/index.js ADDED
@@ -0,0 +1,2283 @@
1
+ import { useSyncExternalStore as ue, useEffect as Xt, useCallback as Xe } from "react";
2
+ import { c as so } from "./chunks/types-Dy4rYb2N.js";
3
+ import { c as ao, b as co, a as uo, f as fo, d as lo, s as ho } from "./chunks/client-VrsFvEIA.js";
4
+ const g = {
5
+ Remove: "remove",
6
+ Replace: "replace",
7
+ Add: "add"
8
+ }, Ot = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Yt = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), fe = Symbol.iterator, M = {
9
+ mutable: "mutable",
10
+ immutable: "immutable"
11
+ }, De = {};
12
+ function te(e, t) {
13
+ return e instanceof Map ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
14
+ }
15
+ function Ye(e, t) {
16
+ if (t in e) {
17
+ let n = Reflect.getPrototypeOf(e);
18
+ for (; n; ) {
19
+ const r = Reflect.getOwnPropertyDescriptor(n, t);
20
+ if (r)
21
+ return r;
22
+ n = Reflect.getPrototypeOf(n);
23
+ }
24
+ }
25
+ }
26
+ function He(e) {
27
+ return Object.getPrototypeOf(e) === Set.prototype;
28
+ }
29
+ function Ne(e) {
30
+ return Object.getPrototypeOf(e) === Map.prototype;
31
+ }
32
+ function C(e) {
33
+ var t;
34
+ return (t = e.copy) !== null && t !== void 0 ? t : e.original;
35
+ }
36
+ function q(e) {
37
+ return !!h(e);
38
+ }
39
+ function h(e) {
40
+ return typeof e != "object" ? null : e?.[Ot];
41
+ }
42
+ function Le(e) {
43
+ var t;
44
+ const n = h(e);
45
+ return n ? (t = n.copy) !== null && t !== void 0 ? t : n.original : e;
46
+ }
47
+ function T(e, t) {
48
+ if (!e || typeof e != "object")
49
+ return !1;
50
+ let n;
51
+ return Object.getPrototypeOf(e) === Object.prototype || Array.isArray(e) || e instanceof Map || e instanceof Set || !!t?.mark && ((n = t.mark(e, M)) === M.immutable || typeof n == "function");
52
+ }
53
+ function At(e, t = []) {
54
+ if (Object.hasOwnProperty.call(e, "key")) {
55
+ const n = e.parent.copy, r = h(F(n, e.key));
56
+ if (r !== null && r?.original !== e.original)
57
+ return null;
58
+ const i = e.parent.type === 3, s = i ? Array.from(e.parent.setMap.keys()).indexOf(e.key) : e.key;
59
+ if (!(i && n.size > s || te(n, s)))
60
+ return null;
61
+ t.push(s);
62
+ }
63
+ if (e.parent)
64
+ return At(e.parent, t);
65
+ t.reverse();
66
+ try {
67
+ Vt(e.copy, t);
68
+ } catch {
69
+ return null;
70
+ }
71
+ return t;
72
+ }
73
+ function Q(e) {
74
+ return Array.isArray(e) ? 1 : e instanceof Map ? 2 : e instanceof Set ? 3 : 0;
75
+ }
76
+ function F(e, t) {
77
+ return Q(e) === 2 ? e.get(t) : e[t];
78
+ }
79
+ function ae(e, t, n) {
80
+ Q(e) === 2 ? e.set(t, n) : e[t] = n;
81
+ }
82
+ function Oe(e, t) {
83
+ const n = h(e);
84
+ return (n ? C(n) : e)[t];
85
+ }
86
+ function j(e, t) {
87
+ return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
88
+ }
89
+ function Ee(e) {
90
+ if (e)
91
+ for (; e.finalities.revoke.length > 0; )
92
+ e.finalities.revoke.pop()();
93
+ }
94
+ function B(e, t) {
95
+ return t ? e : [""].concat(e).map((n) => {
96
+ const r = `${n}`;
97
+ return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
98
+ }).join("/");
99
+ }
100
+ function Vt(e, t) {
101
+ for (let n = 0; n < t.length - 1; n += 1) {
102
+ const r = t[n];
103
+ if (e = F(Q(e) === 3 ? Array.from(e) : e, r), typeof e != "object")
104
+ throw new Error(`Cannot resolve patch at '${t.join("/")}'.`);
105
+ }
106
+ return e;
107
+ }
108
+ function Zt(e) {
109
+ const t = Object.create(Object.getPrototypeOf(e));
110
+ return Reflect.ownKeys(e).forEach((n) => {
111
+ let r = Reflect.getOwnPropertyDescriptor(e, n);
112
+ if (r.enumerable && r.configurable && r.writable) {
113
+ t[n] = e[n];
114
+ return;
115
+ }
116
+ r.writable || (r.writable = !0, r.configurable = !0), (r.get || r.set) && (r = {
117
+ configurable: !0,
118
+ writable: !0,
119
+ enumerable: r.enumerable,
120
+ value: e[n]
121
+ }), Reflect.defineProperty(t, n, r);
122
+ }), t;
123
+ }
124
+ const Jt = Object.prototype.propertyIsEnumerable;
125
+ function Ct(e, t) {
126
+ let n;
127
+ if (Array.isArray(e))
128
+ return Array.prototype.concat.call(e);
129
+ if (e instanceof Set) {
130
+ if (!He(e)) {
131
+ const r = Object.getPrototypeOf(e).constructor;
132
+ return new r(e.values());
133
+ }
134
+ return Set.prototype.difference ? Set.prototype.difference.call(e, /* @__PURE__ */ new Set()) : new Set(e.values());
135
+ } else if (e instanceof Map) {
136
+ if (!Ne(e)) {
137
+ const r = Object.getPrototypeOf(e).constructor;
138
+ return new r(e);
139
+ }
140
+ return new Map(e);
141
+ } else if (t?.mark && (n = t.mark(e, M), n !== void 0) && n !== M.mutable) {
142
+ if (n === M.immutable)
143
+ return Zt(e);
144
+ if (typeof n == "function") {
145
+ if (t.enablePatches || t.enableAutoFreeze)
146
+ throw new Error("You can't use mark and patches or auto freeze together.");
147
+ return n();
148
+ }
149
+ throw new Error(`Unsupported mark result: ${n}`);
150
+ } else if (typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype) {
151
+ const r = {};
152
+ return Object.keys(e).forEach((i) => {
153
+ r[i] = e[i];
154
+ }), Object.getOwnPropertySymbols(e).forEach((i) => {
155
+ Jt.call(e, i) && (r[i] = e[i]);
156
+ }), r;
157
+ } else
158
+ throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
159
+ }
160
+ function S(e) {
161
+ e.copy || (e.copy = Ct(e.original, e.options));
162
+ }
163
+ function ee(e) {
164
+ if (!T(e))
165
+ return Le(e);
166
+ if (Array.isArray(e))
167
+ return e.map(ee);
168
+ if (e instanceof Map) {
169
+ const n = Array.from(e.entries()).map(([r, i]) => [
170
+ r,
171
+ ee(i)
172
+ ]);
173
+ if (!Ne(e)) {
174
+ const r = Object.getPrototypeOf(e).constructor;
175
+ return new r(n);
176
+ }
177
+ return new Map(n);
178
+ }
179
+ if (e instanceof Set) {
180
+ const n = Array.from(e).map(ee);
181
+ if (!He(e)) {
182
+ const r = Object.getPrototypeOf(e).constructor;
183
+ return new r(n);
184
+ }
185
+ return new Set(n);
186
+ }
187
+ const t = Object.create(Object.getPrototypeOf(e));
188
+ for (const n in e)
189
+ t[n] = ee(e[n]);
190
+ return t;
191
+ }
192
+ function le(e) {
193
+ return q(e) ? ee(e) : e;
194
+ }
195
+ function x(e) {
196
+ var t;
197
+ e.assignedMap = (t = e.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), e.operated || (e.operated = !0, e.parent && x(e.parent));
198
+ }
199
+ function Ve() {
200
+ throw new Error("Cannot modify frozen object");
201
+ }
202
+ function X(e, t, n, r, i) {
203
+ {
204
+ n = n ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], i = i ?? [];
205
+ const o = n.has(e) ? n.get(e) : e;
206
+ if (r.length > 0) {
207
+ const a = r.indexOf(o);
208
+ if (o && typeof o == "object" && a !== -1)
209
+ throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, a).map((c, u) => {
210
+ if (typeof c == "symbol")
211
+ return `[${c.toString()}]`;
212
+ const f = r[u];
213
+ return typeof c == "object" && (f instanceof Map || f instanceof Set) ? Array.from(f.keys()).indexOf(c) : c;
214
+ }).join("/")}`);
215
+ r.push(o), i.push(t);
216
+ } else
217
+ r.push(o);
218
+ }
219
+ if (Object.isFrozen(e) || q(e)) {
220
+ r.pop(), i.pop();
221
+ return;
222
+ }
223
+ switch (Q(e)) {
224
+ case 2:
225
+ for (const [a, c] of e)
226
+ X(a, a, n, r, i), X(c, a, n, r, i);
227
+ e.set = e.clear = e.delete = Ve;
228
+ break;
229
+ case 3:
230
+ for (const a of e)
231
+ X(a, a, n, r, i);
232
+ e.add = e.clear = e.delete = Ve;
233
+ break;
234
+ case 1:
235
+ Object.freeze(e);
236
+ let o = 0;
237
+ for (const a of e)
238
+ X(a, o, n, r, i), o += 1;
239
+ break;
240
+ default:
241
+ Object.freeze(e), Object.keys(e).forEach((a) => {
242
+ const c = e[a];
243
+ X(c, a, n, r, i);
244
+ });
245
+ }
246
+ r.pop(), i.pop();
247
+ }
248
+ function qe(e, t) {
249
+ const n = Q(e);
250
+ if (n === 0)
251
+ Reflect.ownKeys(e).forEach((r) => {
252
+ t(r, e[r], e);
253
+ });
254
+ else if (n === 1) {
255
+ let r = 0;
256
+ for (const i of e)
257
+ t(r, i, e), r += 1;
258
+ } else
259
+ e.forEach((r, i) => t(i, r, e));
260
+ }
261
+ function Mt(e, t, n) {
262
+ if (q(e) || !T(e, n) || t.has(e) || Object.isFrozen(e))
263
+ return;
264
+ const r = e instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
265
+ if (t.add(e), qe(e, (s, o) => {
266
+ var a;
267
+ if (q(o)) {
268
+ const c = h(o);
269
+ S(c);
270
+ const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
271
+ ae(r ? i : e, s, u);
272
+ } else
273
+ Mt(o, t, n);
274
+ }), i) {
275
+ const s = e, o = Array.from(s);
276
+ s.clear(), o.forEach((a) => {
277
+ s.add(i.has(a) ? i.get(a) : a);
278
+ });
279
+ }
280
+ }
281
+ function kt(e, t) {
282
+ const n = e.type === 3 ? e.setMap : e.copy;
283
+ e.finalities.revoke.length > 1 && e.assignedMap.get(t) && n && Mt(F(n, t), e.finalities.handledSet, e.options);
284
+ }
285
+ function Pe(e) {
286
+ e.type === 3 && e.copy && (e.copy.clear(), e.setMap.forEach((t) => {
287
+ e.copy.add(Le(t));
288
+ }));
289
+ }
290
+ function Te(e, t, n, r) {
291
+ if (e.operated && e.assignedMap && e.assignedMap.size > 0 && !e.finalized) {
292
+ if (n && r) {
293
+ const s = At(e);
294
+ s && t(e, s, n, r);
295
+ }
296
+ e.finalized = !0;
297
+ }
298
+ }
299
+ function Ge(e, t, n, r) {
300
+ const i = h(n);
301
+ i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
302
+ var a;
303
+ const c = e.type === 3 ? e.setMap : e.copy;
304
+ if (j(F(c, t), n)) {
305
+ let u = i.original;
306
+ i.copy && (u = i.copy), Pe(e), Te(e, r, s, o), e.options.enableAutoFreeze && (e.options.updatedValues = (a = e.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), e.options.updatedValues.set(u, i.original)), ae(c, t, u);
307
+ }
308
+ }), e.options.enableAutoFreeze && i.finalities !== e.finalities && (e.options.enableAutoFreeze = !1)), T(n, e.options) && e.finalities.draft.push(() => {
309
+ const s = e.type === 3 ? e.setMap : e.copy;
310
+ j(F(s, t), n) && kt(e, t);
311
+ });
312
+ }
313
+ function en(e, t, n, r, i) {
314
+ let { original: s, assignedMap: o, options: a } = e, c = e.copy;
315
+ c.length < s.length && ([s, c] = [c, s], [n, r] = [r, n]);
316
+ for (let u = 0; u < s.length; u += 1)
317
+ if (o.get(u.toString()) && c[u] !== s[u]) {
318
+ const f = t.concat([u]), l = B(f, i);
319
+ n.push({
320
+ op: g.Replace,
321
+ path: l,
322
+ // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
323
+ value: le(c[u])
324
+ }), r.push({
325
+ op: g.Replace,
326
+ path: l,
327
+ // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
328
+ value: le(s[u])
329
+ });
330
+ }
331
+ for (let u = s.length; u < c.length; u += 1) {
332
+ const f = t.concat([u]), l = B(f, i);
333
+ n.push({
334
+ op: g.Add,
335
+ path: l,
336
+ // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
337
+ value: le(c[u])
338
+ });
339
+ }
340
+ if (s.length < c.length) {
341
+ const { arrayLengthAssignment: u = !0 } = a.enablePatches;
342
+ if (u) {
343
+ const f = t.concat(["length"]), l = B(f, i);
344
+ r.push({
345
+ op: g.Replace,
346
+ path: l,
347
+ value: s.length
348
+ });
349
+ } else
350
+ for (let f = c.length; s.length < f; f -= 1) {
351
+ const l = t.concat([f - 1]), d = B(l, i);
352
+ r.push({
353
+ op: g.Remove,
354
+ path: d
355
+ });
356
+ }
357
+ }
358
+ }
359
+ function tn({ original: e, copy: t, assignedMap: n }, r, i, s, o) {
360
+ n.forEach((a, c) => {
361
+ const u = F(e, c), f = le(F(t, c)), l = a ? te(e, c) ? g.Replace : g.Add : g.Remove;
362
+ if (j(u, f) && l === g.Replace)
363
+ return;
364
+ const d = r.concat(c), y = B(d, o);
365
+ i.push(l === g.Remove ? { op: l, path: y } : { op: l, path: y, value: f }), s.push(l === g.Add ? { op: g.Remove, path: y } : l === g.Remove ? { op: g.Add, path: y, value: u } : { op: g.Replace, path: y, value: u });
366
+ });
367
+ }
368
+ function nn({ original: e, copy: t }, n, r, i, s) {
369
+ let o = 0;
370
+ e.forEach((a) => {
371
+ if (!t.has(a)) {
372
+ const c = n.concat([o]), u = B(c, s);
373
+ r.push({
374
+ op: g.Remove,
375
+ path: u,
376
+ value: a
377
+ }), i.unshift({
378
+ op: g.Add,
379
+ path: u,
380
+ value: a
381
+ });
382
+ }
383
+ o += 1;
384
+ }), o = 0, t.forEach((a) => {
385
+ if (!e.has(a)) {
386
+ const c = n.concat([o]), u = B(c, s);
387
+ r.push({
388
+ op: g.Add,
389
+ path: u,
390
+ value: a
391
+ }), i.unshift({
392
+ op: g.Remove,
393
+ path: u,
394
+ value: a
395
+ });
396
+ }
397
+ o += 1;
398
+ });
399
+ }
400
+ function re(e, t, n, r) {
401
+ const { pathAsArray: i = !0 } = e.options.enablePatches;
402
+ switch (e.type) {
403
+ case 0:
404
+ case 2:
405
+ return tn(e, t, n, r, i);
406
+ case 1:
407
+ return en(e, t, n, r, i);
408
+ case 3:
409
+ return nn(e, t, n, r, i);
410
+ }
411
+ }
412
+ const he = (e, t, n = !1) => {
413
+ if (typeof e == "object" && e !== null && (!T(e, t) || n))
414
+ throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
415
+ }, xe = {
416
+ get size() {
417
+ return C(h(this)).size;
418
+ },
419
+ has(e) {
420
+ return C(h(this)).has(e);
421
+ },
422
+ set(e, t) {
423
+ const n = h(this), r = C(n);
424
+ return (!r.has(e) || !j(r.get(e), t)) && (S(n), x(n), n.assignedMap.set(e, !0), n.copy.set(e, t), Ge(n, e, t, re)), this;
425
+ },
426
+ delete(e) {
427
+ if (!this.has(e))
428
+ return !1;
429
+ const t = h(this);
430
+ return S(t), x(t), t.original.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.copy.delete(e), !0;
431
+ },
432
+ clear() {
433
+ const e = h(this);
434
+ if (this.size) {
435
+ S(e), x(e), e.assignedMap = /* @__PURE__ */ new Map();
436
+ for (const [t] of e.original)
437
+ e.assignedMap.set(t, !1);
438
+ e.copy.clear();
439
+ }
440
+ },
441
+ forEach(e, t) {
442
+ const n = h(this);
443
+ C(n).forEach((r, i) => {
444
+ e.call(t, this.get(i), i, this);
445
+ });
446
+ },
447
+ get(e) {
448
+ var t, n;
449
+ const r = h(this), i = C(r).get(e), s = ((n = (t = r.options).mark) === null || n === void 0 ? void 0 : n.call(t, i, M)) === M.mutable;
450
+ if (r.options.strict && he(i, r.options, s), s || r.finalized || !T(i, r.options) || i !== r.original.get(e))
451
+ return i;
452
+ const o = De.createDraft({
453
+ original: i,
454
+ parentDraft: r,
455
+ key: e,
456
+ finalities: r.finalities,
457
+ options: r.options
458
+ });
459
+ return S(r), r.copy.set(e, o), o;
460
+ },
461
+ keys() {
462
+ return C(h(this)).keys();
463
+ },
464
+ values() {
465
+ const e = this.keys();
466
+ return {
467
+ [fe]: () => this.values(),
468
+ next: () => {
469
+ const t = e.next();
470
+ return t.done ? t : {
471
+ done: !1,
472
+ value: this.get(t.value)
473
+ };
474
+ }
475
+ };
476
+ },
477
+ entries() {
478
+ const e = this.keys();
479
+ return {
480
+ [fe]: () => this.entries(),
481
+ next: () => {
482
+ const t = e.next();
483
+ if (t.done)
484
+ return t;
485
+ const n = this.get(t.value);
486
+ return {
487
+ done: !1,
488
+ value: [t.value, n]
489
+ };
490
+ }
491
+ };
492
+ },
493
+ [fe]() {
494
+ return this.entries();
495
+ }
496
+ }, rn = Reflect.ownKeys(xe), Ze = (e, t, { isValuesIterator: n }) => () => {
497
+ var r, i;
498
+ const s = t.next();
499
+ if (s.done)
500
+ return s;
501
+ const o = s.value;
502
+ let a = e.setMap.get(o);
503
+ const c = h(a), u = ((i = (r = e.options).mark) === null || i === void 0 ? void 0 : i.call(r, a, M)) === M.mutable;
504
+ if (e.options.strict && he(o, e.options, u), !u && !c && T(o, e.options) && !e.finalized && e.original.has(o)) {
505
+ const f = De.createDraft({
506
+ original: o,
507
+ parentDraft: e,
508
+ key: o,
509
+ finalities: e.finalities,
510
+ options: e.options
511
+ });
512
+ e.setMap.set(o, f), a = f;
513
+ } else c && (a = c.proxy);
514
+ return {
515
+ done: !1,
516
+ value: n ? a : [a, a]
517
+ };
518
+ }, pe = {
519
+ get size() {
520
+ return h(this).setMap.size;
521
+ },
522
+ has(e) {
523
+ const t = h(this);
524
+ if (t.setMap.has(e))
525
+ return !0;
526
+ S(t);
527
+ const n = h(e);
528
+ return !!(n && t.setMap.has(n.original));
529
+ },
530
+ add(e) {
531
+ const t = h(this);
532
+ return this.has(e) || (S(t), x(t), t.assignedMap.set(e, !0), t.setMap.set(e, e), Ge(t, e, e, re)), this;
533
+ },
534
+ delete(e) {
535
+ if (!this.has(e))
536
+ return !1;
537
+ const t = h(this);
538
+ S(t), x(t);
539
+ const n = h(e);
540
+ return n && t.setMap.has(n.original) ? (t.assignedMap.set(n.original, !1), t.setMap.delete(n.original)) : (!n && t.setMap.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.setMap.delete(e));
541
+ },
542
+ clear() {
543
+ if (!this.size)
544
+ return;
545
+ const e = h(this);
546
+ S(e), x(e);
547
+ for (const t of e.original)
548
+ e.assignedMap.set(t, !1);
549
+ e.setMap.clear();
550
+ },
551
+ values() {
552
+ const e = h(this);
553
+ S(e);
554
+ const t = e.setMap.keys();
555
+ return {
556
+ [Symbol.iterator]: () => this.values(),
557
+ next: Ze(e, t, { isValuesIterator: !0 })
558
+ };
559
+ },
560
+ entries() {
561
+ const e = h(this);
562
+ S(e);
563
+ const t = e.setMap.keys();
564
+ return {
565
+ [Symbol.iterator]: () => this.entries(),
566
+ next: Ze(e, t, {
567
+ isValuesIterator: !1
568
+ })
569
+ };
570
+ },
571
+ keys() {
572
+ return this.values();
573
+ },
574
+ [fe]() {
575
+ return this.values();
576
+ },
577
+ forEach(e, t) {
578
+ const n = this.values();
579
+ let r = n.next();
580
+ for (; !r.done; )
581
+ e.call(t, r.value, r.value, this), r = n.next();
582
+ }
583
+ };
584
+ Set.prototype.difference && Object.assign(pe, {
585
+ intersection(e) {
586
+ return Set.prototype.intersection.call(new Set(this.values()), e);
587
+ },
588
+ union(e) {
589
+ return Set.prototype.union.call(new Set(this.values()), e);
590
+ },
591
+ difference(e) {
592
+ return Set.prototype.difference.call(new Set(this.values()), e);
593
+ },
594
+ symmetricDifference(e) {
595
+ return Set.prototype.symmetricDifference.call(new Set(this.values()), e);
596
+ },
597
+ isSubsetOf(e) {
598
+ return Set.prototype.isSubsetOf.call(new Set(this.values()), e);
599
+ },
600
+ isSupersetOf(e) {
601
+ return Set.prototype.isSupersetOf.call(new Set(this.values()), e);
602
+ },
603
+ isDisjointFrom(e) {
604
+ return Set.prototype.isDisjointFrom.call(new Set(this.values()), e);
605
+ }
606
+ });
607
+ const sn = Reflect.ownKeys(pe), Et = {
608
+ get(e, t, n) {
609
+ var r, i;
610
+ const s = (r = e.copy) === null || r === void 0 ? void 0 : r[t];
611
+ if (s && e.finalities.draftsCache.has(s))
612
+ return s;
613
+ if (t === Ot)
614
+ return e;
615
+ let o;
616
+ if (e.options.mark) {
617
+ const u = t === "size" && (e.original instanceof Map || e.original instanceof Set) ? Reflect.get(e.original, t) : Reflect.get(e.original, t, n);
618
+ if (o = e.options.mark(u, M), o === M.mutable)
619
+ return e.options.strict && he(u, e.options, !0), u;
620
+ }
621
+ const a = C(e);
622
+ if (a instanceof Map && rn.includes(t))
623
+ return t === "size" ? Object.getOwnPropertyDescriptor(xe, "size").get.call(e.proxy) : xe[t].bind(e.proxy);
624
+ if (a instanceof Set && sn.includes(t))
625
+ return t === "size" ? Object.getOwnPropertyDescriptor(pe, "size").get.call(e.proxy) : pe[t].bind(e.proxy);
626
+ if (!te(a, t)) {
627
+ const u = Ye(a, t);
628
+ return u ? "value" in u ? u.value : (
629
+ // !case: support for getter
630
+ (i = u.get) === null || i === void 0 ? void 0 : i.call(e.proxy)
631
+ ) : void 0;
632
+ }
633
+ const c = a[t];
634
+ if (e.options.strict && he(c, e.options), e.finalized || !T(c, e.options))
635
+ return c;
636
+ if (c === Oe(e.original, t)) {
637
+ if (S(e), e.copy[t] = Ue({
638
+ original: e.original[t],
639
+ parentDraft: e,
640
+ key: e.type === 1 ? Number(t) : t,
641
+ finalities: e.finalities,
642
+ options: e.options
643
+ }), typeof o == "function") {
644
+ const u = h(e.copy[t]);
645
+ return S(u), x(u), u.copy;
646
+ }
647
+ return e.copy[t];
648
+ }
649
+ return q(c) && e.finalities.draftsCache.add(c), c;
650
+ },
651
+ set(e, t, n) {
652
+ var r;
653
+ if (e.type === 3 || e.type === 2)
654
+ throw new Error("Map/Set draft does not support any property assignment.");
655
+ let i;
656
+ if (e.type === 1 && t !== "length" && !(Number.isInteger(i = Number(t)) && i >= 0 && (t === 0 || i === 0 || String(i) === String(t))))
657
+ throw new Error("Only supports setting array indices and the 'length' property.");
658
+ const s = Ye(C(e), t);
659
+ if (s?.set)
660
+ return s.set.call(e.proxy, n), !0;
661
+ const o = Oe(C(e), t), a = h(o);
662
+ return a && j(a.original, n) ? (e.copy[t] = n, e.assignedMap = (r = e.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), e.assignedMap.set(t, !1), !0) : (j(n, o) && (n !== void 0 || te(e.original, t)) || (S(e), x(e), te(e.original, t) && j(n, e.original[t]) ? e.assignedMap.delete(t) : e.assignedMap.set(t, !0), e.copy[t] = n, Ge(e, t, n, re)), !0);
663
+ },
664
+ has(e, t) {
665
+ return t in C(e);
666
+ },
667
+ ownKeys(e) {
668
+ return Reflect.ownKeys(C(e));
669
+ },
670
+ getOwnPropertyDescriptor(e, t) {
671
+ const n = C(e), r = Reflect.getOwnPropertyDescriptor(n, t);
672
+ return r && {
673
+ writable: !0,
674
+ configurable: e.type !== 1 || t !== "length",
675
+ enumerable: r.enumerable,
676
+ value: n[t]
677
+ };
678
+ },
679
+ getPrototypeOf(e) {
680
+ return Reflect.getPrototypeOf(e.original);
681
+ },
682
+ setPrototypeOf() {
683
+ throw new Error("Cannot call 'setPrototypeOf()' on drafts");
684
+ },
685
+ defineProperty() {
686
+ throw new Error("Cannot call 'defineProperty()' on drafts");
687
+ },
688
+ deleteProperty(e, t) {
689
+ var n;
690
+ return e.type === 1 ? Et.set.call(this, e, t, void 0, e.proxy) : (Oe(e.original, t) !== void 0 || t in e.original ? (S(e), x(e), e.assignedMap.set(t, !1)) : (e.assignedMap = (n = e.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), e.assignedMap.delete(t)), e.copy && delete e.copy[t], !0);
691
+ }
692
+ };
693
+ function Ue(e) {
694
+ const { original: t, parentDraft: n, key: r, finalities: i, options: s } = e, o = Q(t), a = {
695
+ type: o,
696
+ finalized: !1,
697
+ parent: n,
698
+ original: t,
699
+ copy: null,
700
+ proxy: null,
701
+ finalities: i,
702
+ options: s,
703
+ // Mapping of draft Set items to their corresponding draft values.
704
+ setMap: o === 3 ? new Map(t.entries()) : void 0
705
+ };
706
+ (r || "key" in e) && (a.key = r);
707
+ const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, Et);
708
+ if (i.revoke.push(u), a.proxy = c, n) {
709
+ const f = n;
710
+ f.finalities.draft.push((l, d) => {
711
+ var y, m;
712
+ const O = h(c);
713
+ let v = f.type === 3 ? f.setMap : f.copy;
714
+ const w = F(v, r), b = h(w);
715
+ if (b) {
716
+ let A = b.original;
717
+ b.operated && (A = Le(w)), Pe(b), Te(b, re, l, d), f.options.enableAutoFreeze && (f.options.updatedValues = (y = f.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), f.options.updatedValues.set(A, b.original)), ae(v, r, A);
718
+ }
719
+ (m = O.callbacks) === null || m === void 0 || m.forEach((A) => {
720
+ A(l, d);
721
+ });
722
+ });
723
+ } else {
724
+ const f = h(c);
725
+ f.finalities.draft.push((l, d) => {
726
+ Pe(f), Te(f, re, l, d);
727
+ });
728
+ }
729
+ return c;
730
+ }
731
+ De.createDraft = Ue;
732
+ function on(e, t, n, r, i) {
733
+ var s;
734
+ const o = h(e), a = (s = o?.original) !== null && s !== void 0 ? s : e, c = !!t.length;
735
+ if (o?.operated)
736
+ for (; o.finalities.draft.length > 0; )
737
+ o.finalities.draft.pop()(n, r);
738
+ const u = c ? t[0] : o ? o.operated ? o.copy : o.original : e;
739
+ return o && Ee(o), i && X(u, u, o?.options.updatedValues), [
740
+ u,
741
+ n && c ? [{ op: g.Replace, path: [], value: t[0] }] : n,
742
+ r && c ? [{ op: g.Replace, path: [], value: a }] : r
743
+ ];
744
+ }
745
+ function an(e, t) {
746
+ var n;
747
+ const r = {
748
+ draft: [],
749
+ revoke: [],
750
+ handledSet: /* @__PURE__ */ new WeakSet(),
751
+ draftsCache: /* @__PURE__ */ new WeakSet()
752
+ };
753
+ let i, s;
754
+ t.enablePatches && (i = [], s = []);
755
+ const a = ((n = t.mark) === null || n === void 0 ? void 0 : n.call(t, e, M)) === M.mutable || !T(e, t) ? e : Ue({
756
+ original: e,
757
+ parentDraft: null,
758
+ finalities: r,
759
+ options: t
760
+ });
761
+ return [
762
+ a,
763
+ (c = []) => {
764
+ const [u, f, l] = on(a, c, i, s, t.enableAutoFreeze);
765
+ return t.enablePatches ? [u, f, l] : u;
766
+ }
767
+ ];
768
+ }
769
+ function Ie(e) {
770
+ const { rootDraft: t, value: n, useRawReturn: r = !1, isRoot: i = !0 } = e;
771
+ qe(n, (s, o, a) => {
772
+ const c = h(o);
773
+ if (c && t && c.finalities === t.finalities) {
774
+ e.isContainDraft = !0;
775
+ const u = c.original;
776
+ if (a instanceof Set) {
777
+ const f = Array.from(a);
778
+ a.clear(), f.forEach((l) => a.add(s === l ? u : l));
779
+ } else
780
+ ae(a, s, u);
781
+ } else typeof o == "object" && o !== null && (e.value = o, e.isRoot = !1, Ie(e));
782
+ }), i && (e.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
783
+ }
784
+ function Pt(e) {
785
+ var t;
786
+ const n = h(e);
787
+ if (!T(e, n?.options))
788
+ return e;
789
+ const r = Q(e);
790
+ if (n && !n.operated)
791
+ return n.original;
792
+ let i;
793
+ function s() {
794
+ i = r === 2 ? Ne(e) ? new Map(e) : new (Object.getPrototypeOf(e)).constructor(e) : r === 3 ? Array.from(n.setMap.values()) : Ct(e, n?.options);
795
+ }
796
+ if (n) {
797
+ n.finalized = !0;
798
+ try {
799
+ s();
800
+ } finally {
801
+ n.finalized = !1;
802
+ }
803
+ } else
804
+ i = e;
805
+ if (qe(i, (o, a) => {
806
+ if (n && j(F(n.original, o), a))
807
+ return;
808
+ const c = Pt(a);
809
+ c !== a && (i === e && s(), ae(i, o, c));
810
+ }), r === 3) {
811
+ const o = (t = n?.original) !== null && t !== void 0 ? t : i;
812
+ return He(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
813
+ }
814
+ return i;
815
+ }
816
+ function Je(e) {
817
+ if (!q(e))
818
+ throw new Error(`current() is only used for Draft, parameter: ${e}`);
819
+ return Pt(e);
820
+ }
821
+ const cn = (e) => function t(n, r, i) {
822
+ var s, o, a;
823
+ if (typeof n == "function" && typeof r != "function")
824
+ return function(p, ...R) {
825
+ return t(p, (N) => n.call(this, N, ...R), r);
826
+ };
827
+ const c = n, u = r;
828
+ let f = i;
829
+ if (typeof r != "function" && (f = r), f !== void 0 && Object.prototype.toString.call(f) !== "[object Object]")
830
+ throw new Error(`Invalid options: ${f}, 'options' should be an object.`);
831
+ f = Object.assign(Object.assign({}, e), f);
832
+ const l = q(c) ? Je(c) : c, d = Array.isArray(f.mark) ? ((p, R) => {
833
+ for (const N of f.mark) {
834
+ if (typeof N != "function")
835
+ throw new Error(`Invalid mark: ${N}, 'mark' should be a function.`);
836
+ const J = N(p, R);
837
+ if (J)
838
+ return J;
839
+ }
840
+ }) : f.mark, y = (s = f.enablePatches) !== null && s !== void 0 ? s : !1, m = (o = f.strict) !== null && o !== void 0 ? o : !1, v = {
841
+ enableAutoFreeze: (a = f.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
842
+ mark: d,
843
+ strict: m,
844
+ enablePatches: y
845
+ };
846
+ if (!T(l, v) && typeof l == "object" && l !== null)
847
+ throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
848
+ const [w, b] = an(l, v);
849
+ if (typeof r != "function") {
850
+ if (!T(l, v))
851
+ throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
852
+ return [w, b];
853
+ }
854
+ let A;
855
+ try {
856
+ A = u(w);
857
+ } catch (p) {
858
+ throw Ee(h(w)), p;
859
+ }
860
+ const G = (p) => {
861
+ const R = h(w);
862
+ if (!q(p)) {
863
+ if (p !== void 0 && !j(p, w) && R?.operated)
864
+ throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
865
+ const J = p?.[Yt];
866
+ if (J) {
867
+ const Wt = J[0];
868
+ return v.strict && typeof p == "object" && p !== null && Ie({
869
+ rootDraft: R,
870
+ value: p,
871
+ useRawReturn: !0
872
+ }), b([Wt]);
873
+ }
874
+ if (p !== void 0)
875
+ return typeof p == "object" && p !== null && Ie({ rootDraft: R, value: p }), b([p]);
876
+ }
877
+ if (p === w || p === void 0)
878
+ return b([]);
879
+ const N = h(p);
880
+ if (v === N.options) {
881
+ if (N.operated)
882
+ throw new Error("Cannot return a modified child draft.");
883
+ return b([Je(p)]);
884
+ }
885
+ return b([p]);
886
+ };
887
+ return A instanceof Promise ? A.then(G, (p) => {
888
+ throw Ee(h(w)), p;
889
+ }) : G(A);
890
+ }, P = cn();
891
+ Object.prototype.constructor.toString();
892
+ var Tt = typeof global == "object" && global && global.Object === Object && global, un = typeof self == "object" && self && self.Object === Object && self, z = Tt || un || Function("return this")(), I = z.Symbol, xt = Object.prototype, fn = xt.hasOwnProperty, ln = xt.toString, k = I ? I.toStringTag : void 0;
893
+ function hn(e) {
894
+ var t = fn.call(e, k), n = e[k];
895
+ try {
896
+ e[k] = void 0;
897
+ var r = !0;
898
+ } catch {
899
+ }
900
+ var i = ln.call(e);
901
+ return r && (t ? e[k] = n : delete e[k]), i;
902
+ }
903
+ var pn = Object.prototype, dn = pn.toString;
904
+ function _n(e) {
905
+ return dn.call(e);
906
+ }
907
+ var yn = "[object Null]", bn = "[object Undefined]", ke = I ? I.toStringTag : void 0;
908
+ function V(e) {
909
+ return e == null ? e === void 0 ? bn : yn : ke && ke in Object(e) ? hn(e) : _n(e);
910
+ }
911
+ function Y(e) {
912
+ return e != null && typeof e == "object";
913
+ }
914
+ var gn = "[object Symbol]";
915
+ function _e(e) {
916
+ return typeof e == "symbol" || Y(e) && V(e) == gn;
917
+ }
918
+ function It(e, t) {
919
+ for (var n = -1, r = e == null ? 0 : e.length, i = Array(r); ++n < r; )
920
+ i[n] = t(e[n], n, e);
921
+ return i;
922
+ }
923
+ var E = Array.isArray, et = I ? I.prototype : void 0, tt = et ? et.toString : void 0;
924
+ function Rt(e) {
925
+ if (typeof e == "string")
926
+ return e;
927
+ if (E(e))
928
+ return It(e, Rt) + "";
929
+ if (_e(e))
930
+ return tt ? tt.call(e) : "";
931
+ var t = e + "";
932
+ return t == "0" && 1 / e == -1 / 0 ? "-0" : t;
933
+ }
934
+ var mn = /\s/;
935
+ function wn(e) {
936
+ for (var t = e.length; t-- && mn.test(e.charAt(t)); )
937
+ ;
938
+ return t;
939
+ }
940
+ var vn = /^\s+/;
941
+ function Sn(e) {
942
+ return e && e.slice(0, wn(e) + 1).replace(vn, "");
943
+ }
944
+ function ie(e) {
945
+ var t = typeof e;
946
+ return e != null && (t == "object" || t == "function");
947
+ }
948
+ var nt = NaN, On = /^[-+]0x[0-9a-f]+$/i, An = /^0b[01]+$/i, Cn = /^0o[0-7]+$/i, Mn = parseInt;
949
+ function En(e) {
950
+ if (typeof e == "number")
951
+ return e;
952
+ if (_e(e))
953
+ return nt;
954
+ if (ie(e)) {
955
+ var t = typeof e.valueOf == "function" ? e.valueOf() : e;
956
+ e = ie(t) ? t + "" : t;
957
+ }
958
+ if (typeof e != "string")
959
+ return e === 0 ? e : +e;
960
+ e = Sn(e);
961
+ var n = An.test(e);
962
+ return n || Cn.test(e) ? Mn(e.slice(2), n ? 2 : 8) : On.test(e) ? nt : +e;
963
+ }
964
+ var rt = 1 / 0, Pn = 17976931348623157e292;
965
+ function Tn(e) {
966
+ if (!e)
967
+ return e === 0 ? e : 0;
968
+ if (e = En(e), e === rt || e === -rt) {
969
+ var t = e < 0 ? -1 : 1;
970
+ return t * Pn;
971
+ }
972
+ return e === e ? e : 0;
973
+ }
974
+ function xn(e) {
975
+ var t = Tn(e), n = t % 1;
976
+ return t === t ? n ? t - n : t : 0;
977
+ }
978
+ function In(e) {
979
+ return e;
980
+ }
981
+ var Rn = "[object AsyncFunction]", jn = "[object Function]", $n = "[object GeneratorFunction]", Fn = "[object Proxy]";
982
+ function jt(e) {
983
+ if (!ie(e))
984
+ return !1;
985
+ var t = V(e);
986
+ return t == jn || t == $n || t == Rn || t == Fn;
987
+ }
988
+ var Ae = z["__core-js_shared__"], it = (function() {
989
+ var e = /[^.]+$/.exec(Ae && Ae.keys && Ae.keys.IE_PROTO || "");
990
+ return e ? "Symbol(src)_1." + e : "";
991
+ })();
992
+ function zn(e) {
993
+ return !!it && it in e;
994
+ }
995
+ var Dn = Function.prototype, Hn = Dn.toString;
996
+ function W(e) {
997
+ if (e != null) {
998
+ try {
999
+ return Hn.call(e);
1000
+ } catch {
1001
+ }
1002
+ try {
1003
+ return e + "";
1004
+ } catch {
1005
+ }
1006
+ }
1007
+ return "";
1008
+ }
1009
+ var Nn = /[\\^$.*+?()[\]{}|]/g, Ln = /^\[object .+?Constructor\]$/, qn = Function.prototype, Gn = Object.prototype, Un = qn.toString, Bn = Gn.hasOwnProperty, Kn = RegExp(
1010
+ "^" + Un.call(Bn).replace(Nn, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
1011
+ );
1012
+ function Qn(e) {
1013
+ if (!ie(e) || zn(e))
1014
+ return !1;
1015
+ var t = jt(e) ? Kn : Ln;
1016
+ return t.test(W(e));
1017
+ }
1018
+ function Wn(e, t) {
1019
+ return e?.[t];
1020
+ }
1021
+ function Z(e, t) {
1022
+ var n = Wn(e, t);
1023
+ return Qn(n) ? n : void 0;
1024
+ }
1025
+ var Re = Z(z, "WeakMap");
1026
+ function Xn(e, t, n, r) {
1027
+ for (var i = e.length, s = n + -1; ++s < i; )
1028
+ if (t(e[s], s, e))
1029
+ return s;
1030
+ return -1;
1031
+ }
1032
+ var Yn = 9007199254740991, Vn = /^(?:0|[1-9]\d*)$/;
1033
+ function $t(e, t) {
1034
+ var n = typeof e;
1035
+ return t = t ?? Yn, !!t && (n == "number" || n != "symbol" && Vn.test(e)) && e > -1 && e % 1 == 0 && e < t;
1036
+ }
1037
+ function Ft(e, t) {
1038
+ return e === t || e !== e && t !== t;
1039
+ }
1040
+ var Zn = 9007199254740991;
1041
+ function Be(e) {
1042
+ return typeof e == "number" && e > -1 && e % 1 == 0 && e <= Zn;
1043
+ }
1044
+ function ye(e) {
1045
+ return e != null && Be(e.length) && !jt(e);
1046
+ }
1047
+ var Jn = Object.prototype;
1048
+ function kn(e) {
1049
+ var t = e && e.constructor, n = typeof t == "function" && t.prototype || Jn;
1050
+ return e === n;
1051
+ }
1052
+ function er(e, t) {
1053
+ for (var n = -1, r = Array(e); ++n < e; )
1054
+ r[n] = t(n);
1055
+ return r;
1056
+ }
1057
+ var tr = "[object Arguments]";
1058
+ function st(e) {
1059
+ return Y(e) && V(e) == tr;
1060
+ }
1061
+ var zt = Object.prototype, nr = zt.hasOwnProperty, rr = zt.propertyIsEnumerable, Ke = st(/* @__PURE__ */ (function() {
1062
+ return arguments;
1063
+ })()) ? st : function(e) {
1064
+ return Y(e) && nr.call(e, "callee") && !rr.call(e, "callee");
1065
+ };
1066
+ function ir() {
1067
+ return !1;
1068
+ }
1069
+ var Dt = typeof exports == "object" && exports && !exports.nodeType && exports, ot = Dt && typeof module == "object" && module && !module.nodeType && module, sr = ot && ot.exports === Dt, at = sr ? z.Buffer : void 0, or = at ? at.isBuffer : void 0, je = or || ir, ar = "[object Arguments]", cr = "[object Array]", ur = "[object Boolean]", fr = "[object Date]", lr = "[object Error]", hr = "[object Function]", pr = "[object Map]", dr = "[object Number]", _r = "[object Object]", yr = "[object RegExp]", br = "[object Set]", gr = "[object String]", mr = "[object WeakMap]", wr = "[object ArrayBuffer]", vr = "[object DataView]", Sr = "[object Float32Array]", Or = "[object Float64Array]", Ar = "[object Int8Array]", Cr = "[object Int16Array]", Mr = "[object Int32Array]", Er = "[object Uint8Array]", Pr = "[object Uint8ClampedArray]", Tr = "[object Uint16Array]", xr = "[object Uint32Array]", _ = {};
1070
+ _[Sr] = _[Or] = _[Ar] = _[Cr] = _[Mr] = _[Er] = _[Pr] = _[Tr] = _[xr] = !0;
1071
+ _[ar] = _[cr] = _[wr] = _[ur] = _[vr] = _[fr] = _[lr] = _[hr] = _[pr] = _[dr] = _[_r] = _[yr] = _[br] = _[gr] = _[mr] = !1;
1072
+ function Ir(e) {
1073
+ return Y(e) && Be(e.length) && !!_[V(e)];
1074
+ }
1075
+ function Rr(e) {
1076
+ return function(t) {
1077
+ return e(t);
1078
+ };
1079
+ }
1080
+ var Ht = typeof exports == "object" && exports && !exports.nodeType && exports, ne = Ht && typeof module == "object" && module && !module.nodeType && module, jr = ne && ne.exports === Ht, Ce = jr && Tt.process, ct = (function() {
1081
+ try {
1082
+ var e = ne && ne.require && ne.require("util").types;
1083
+ return e || Ce && Ce.binding && Ce.binding("util");
1084
+ } catch {
1085
+ }
1086
+ })(), ut = ct && ct.isTypedArray, Nt = ut ? Rr(ut) : Ir, $r = Object.prototype, Fr = $r.hasOwnProperty;
1087
+ function zr(e, t) {
1088
+ var n = E(e), r = !n && Ke(e), i = !n && !r && je(e), s = !n && !r && !i && Nt(e), o = n || r || i || s, a = o ? er(e.length, String) : [], c = a.length;
1089
+ for (var u in e)
1090
+ Fr.call(e, u) && !(o && // Safari 9 has enumerable `arguments.length` in strict mode.
1091
+ (u == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1092
+ i && (u == "offset" || u == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1093
+ s && (u == "buffer" || u == "byteLength" || u == "byteOffset") || // Skip index properties.
1094
+ $t(u, c))) && a.push(u);
1095
+ return a;
1096
+ }
1097
+ function Dr(e, t) {
1098
+ return function(n) {
1099
+ return e(t(n));
1100
+ };
1101
+ }
1102
+ var Hr = Dr(Object.keys, Object), Nr = Object.prototype, Lr = Nr.hasOwnProperty;
1103
+ function qr(e) {
1104
+ if (!kn(e))
1105
+ return Hr(e);
1106
+ var t = [];
1107
+ for (var n in Object(e))
1108
+ Lr.call(e, n) && n != "constructor" && t.push(n);
1109
+ return t;
1110
+ }
1111
+ function be(e) {
1112
+ return ye(e) ? zr(e) : qr(e);
1113
+ }
1114
+ var Gr = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Ur = /^\w*$/;
1115
+ function Qe(e, t) {
1116
+ if (E(e))
1117
+ return !1;
1118
+ var n = typeof e;
1119
+ return n == "number" || n == "symbol" || n == "boolean" || e == null || _e(e) ? !0 : Ur.test(e) || !Gr.test(e) || t != null && e in Object(t);
1120
+ }
1121
+ var se = Z(Object, "create");
1122
+ function Br() {
1123
+ this.__data__ = se ? se(null) : {}, this.size = 0;
1124
+ }
1125
+ function Kr(e) {
1126
+ var t = this.has(e) && delete this.__data__[e];
1127
+ return this.size -= t ? 1 : 0, t;
1128
+ }
1129
+ var Qr = "__lodash_hash_undefined__", Wr = Object.prototype, Xr = Wr.hasOwnProperty;
1130
+ function Yr(e) {
1131
+ var t = this.__data__;
1132
+ if (se) {
1133
+ var n = t[e];
1134
+ return n === Qr ? void 0 : n;
1135
+ }
1136
+ return Xr.call(t, e) ? t[e] : void 0;
1137
+ }
1138
+ var Vr = Object.prototype, Zr = Vr.hasOwnProperty;
1139
+ function Jr(e) {
1140
+ var t = this.__data__;
1141
+ return se ? t[e] !== void 0 : Zr.call(t, e);
1142
+ }
1143
+ var kr = "__lodash_hash_undefined__";
1144
+ function ei(e, t) {
1145
+ var n = this.__data__;
1146
+ return this.size += this.has(e) ? 0 : 1, n[e] = se && t === void 0 ? kr : t, this;
1147
+ }
1148
+ function K(e) {
1149
+ var t = -1, n = e == null ? 0 : e.length;
1150
+ for (this.clear(); ++t < n; ) {
1151
+ var r = e[t];
1152
+ this.set(r[0], r[1]);
1153
+ }
1154
+ }
1155
+ K.prototype.clear = Br;
1156
+ K.prototype.delete = Kr;
1157
+ K.prototype.get = Yr;
1158
+ K.prototype.has = Jr;
1159
+ K.prototype.set = ei;
1160
+ function ti() {
1161
+ this.__data__ = [], this.size = 0;
1162
+ }
1163
+ function ge(e, t) {
1164
+ for (var n = e.length; n--; )
1165
+ if (Ft(e[n][0], t))
1166
+ return n;
1167
+ return -1;
1168
+ }
1169
+ var ni = Array.prototype, ri = ni.splice;
1170
+ function ii(e) {
1171
+ var t = this.__data__, n = ge(t, e);
1172
+ if (n < 0)
1173
+ return !1;
1174
+ var r = t.length - 1;
1175
+ return n == r ? t.pop() : ri.call(t, n, 1), --this.size, !0;
1176
+ }
1177
+ function si(e) {
1178
+ var t = this.__data__, n = ge(t, e);
1179
+ return n < 0 ? void 0 : t[n][1];
1180
+ }
1181
+ function oi(e) {
1182
+ return ge(this.__data__, e) > -1;
1183
+ }
1184
+ function ai(e, t) {
1185
+ var n = this.__data__, r = ge(n, e);
1186
+ return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this;
1187
+ }
1188
+ function D(e) {
1189
+ var t = -1, n = e == null ? 0 : e.length;
1190
+ for (this.clear(); ++t < n; ) {
1191
+ var r = e[t];
1192
+ this.set(r[0], r[1]);
1193
+ }
1194
+ }
1195
+ D.prototype.clear = ti;
1196
+ D.prototype.delete = ii;
1197
+ D.prototype.get = si;
1198
+ D.prototype.has = oi;
1199
+ D.prototype.set = ai;
1200
+ var oe = Z(z, "Map");
1201
+ function ci() {
1202
+ this.size = 0, this.__data__ = {
1203
+ hash: new K(),
1204
+ map: new (oe || D)(),
1205
+ string: new K()
1206
+ };
1207
+ }
1208
+ function ui(e) {
1209
+ var t = typeof e;
1210
+ return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
1211
+ }
1212
+ function me(e, t) {
1213
+ var n = e.__data__;
1214
+ return ui(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
1215
+ }
1216
+ function fi(e) {
1217
+ var t = me(this, e).delete(e);
1218
+ return this.size -= t ? 1 : 0, t;
1219
+ }
1220
+ function li(e) {
1221
+ return me(this, e).get(e);
1222
+ }
1223
+ function hi(e) {
1224
+ return me(this, e).has(e);
1225
+ }
1226
+ function pi(e, t) {
1227
+ var n = me(this, e), r = n.size;
1228
+ return n.set(e, t), this.size += n.size == r ? 0 : 1, this;
1229
+ }
1230
+ function H(e) {
1231
+ var t = -1, n = e == null ? 0 : e.length;
1232
+ for (this.clear(); ++t < n; ) {
1233
+ var r = e[t];
1234
+ this.set(r[0], r[1]);
1235
+ }
1236
+ }
1237
+ H.prototype.clear = ci;
1238
+ H.prototype.delete = fi;
1239
+ H.prototype.get = li;
1240
+ H.prototype.has = hi;
1241
+ H.prototype.set = pi;
1242
+ var di = "Expected a function";
1243
+ function We(e, t) {
1244
+ if (typeof e != "function" || t != null && typeof t != "function")
1245
+ throw new TypeError(di);
1246
+ var n = function() {
1247
+ var r = arguments, i = t ? t.apply(this, r) : r[0], s = n.cache;
1248
+ if (s.has(i))
1249
+ return s.get(i);
1250
+ var o = e.apply(this, r);
1251
+ return n.cache = s.set(i, o) || s, o;
1252
+ };
1253
+ return n.cache = new (We.Cache || H)(), n;
1254
+ }
1255
+ We.Cache = H;
1256
+ var _i = 500;
1257
+ function yi(e) {
1258
+ var t = We(e, function(r) {
1259
+ return n.size === _i && n.clear(), r;
1260
+ }), n = t.cache;
1261
+ return t;
1262
+ }
1263
+ var bi = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, gi = /\\(\\)?/g, mi = yi(function(e) {
1264
+ var t = [];
1265
+ return e.charCodeAt(0) === 46 && t.push(""), e.replace(bi, function(n, r, i, s) {
1266
+ t.push(i ? s.replace(gi, "$1") : r || n);
1267
+ }), t;
1268
+ });
1269
+ function wi(e) {
1270
+ return e == null ? "" : Rt(e);
1271
+ }
1272
+ function Lt(e, t) {
1273
+ return E(e) ? e : Qe(e, t) ? [e] : mi(wi(e));
1274
+ }
1275
+ function we(e) {
1276
+ if (typeof e == "string" || _e(e))
1277
+ return e;
1278
+ var t = e + "";
1279
+ return t == "0" && 1 / e == -1 / 0 ? "-0" : t;
1280
+ }
1281
+ function qt(e, t) {
1282
+ t = Lt(t, e);
1283
+ for (var n = 0, r = t.length; e != null && n < r; )
1284
+ e = e[we(t[n++])];
1285
+ return n && n == r ? e : void 0;
1286
+ }
1287
+ function vi(e, t, n) {
1288
+ var r = e == null ? void 0 : qt(e, t);
1289
+ return r === void 0 ? n : r;
1290
+ }
1291
+ function Gt(e, t) {
1292
+ for (var n = -1, r = t.length, i = e.length; ++n < r; )
1293
+ e[i + n] = t[n];
1294
+ return e;
1295
+ }
1296
+ var ft = I ? I.isConcatSpreadable : void 0;
1297
+ function Si(e) {
1298
+ return E(e) || Ke(e) || !!(ft && e && e[ft]);
1299
+ }
1300
+ function Oi(e, t, n, r, i) {
1301
+ var s = -1, o = e.length;
1302
+ for (n || (n = Si), i || (i = []); ++s < o; ) {
1303
+ var a = e[s];
1304
+ n(a) ? Gt(i, a) : i[i.length] = a;
1305
+ }
1306
+ return i;
1307
+ }
1308
+ function Ai() {
1309
+ this.__data__ = new D(), this.size = 0;
1310
+ }
1311
+ function Ci(e) {
1312
+ var t = this.__data__, n = t.delete(e);
1313
+ return this.size = t.size, n;
1314
+ }
1315
+ function Mi(e) {
1316
+ return this.__data__.get(e);
1317
+ }
1318
+ function Ei(e) {
1319
+ return this.__data__.has(e);
1320
+ }
1321
+ var Pi = 200;
1322
+ function Ti(e, t) {
1323
+ var n = this.__data__;
1324
+ if (n instanceof D) {
1325
+ var r = n.__data__;
1326
+ if (!oe || r.length < Pi - 1)
1327
+ return r.push([e, t]), this.size = ++n.size, this;
1328
+ n = this.__data__ = new H(r);
1329
+ }
1330
+ return n.set(e, t), this.size = n.size, this;
1331
+ }
1332
+ function $(e) {
1333
+ var t = this.__data__ = new D(e);
1334
+ this.size = t.size;
1335
+ }
1336
+ $.prototype.clear = Ai;
1337
+ $.prototype.delete = Ci;
1338
+ $.prototype.get = Mi;
1339
+ $.prototype.has = Ei;
1340
+ $.prototype.set = Ti;
1341
+ function xi(e, t) {
1342
+ for (var n = -1, r = e == null ? 0 : e.length, i = 0, s = []; ++n < r; ) {
1343
+ var o = e[n];
1344
+ t(o, n, e) && (s[i++] = o);
1345
+ }
1346
+ return s;
1347
+ }
1348
+ function Ii() {
1349
+ return [];
1350
+ }
1351
+ var Ri = Object.prototype, ji = Ri.propertyIsEnumerable, lt = Object.getOwnPropertySymbols, $i = lt ? function(e) {
1352
+ return e == null ? [] : (e = Object(e), xi(lt(e), function(t) {
1353
+ return ji.call(e, t);
1354
+ }));
1355
+ } : Ii;
1356
+ function Fi(e, t, n) {
1357
+ var r = t(e);
1358
+ return E(e) ? r : Gt(r, n(e));
1359
+ }
1360
+ function ht(e) {
1361
+ return Fi(e, be, $i);
1362
+ }
1363
+ var $e = Z(z, "DataView"), Fe = Z(z, "Promise"), ze = Z(z, "Set"), pt = "[object Map]", zi = "[object Object]", dt = "[object Promise]", _t = "[object Set]", yt = "[object WeakMap]", bt = "[object DataView]", Di = W($e), Hi = W(oe), Ni = W(Fe), Li = W(ze), qi = W(Re), L = V;
1364
+ ($e && L(new $e(new ArrayBuffer(1))) != bt || oe && L(new oe()) != pt || Fe && L(Fe.resolve()) != dt || ze && L(new ze()) != _t || Re && L(new Re()) != yt) && (L = function(e) {
1365
+ var t = V(e), n = t == zi ? e.constructor : void 0, r = n ? W(n) : "";
1366
+ if (r)
1367
+ switch (r) {
1368
+ case Di:
1369
+ return bt;
1370
+ case Hi:
1371
+ return pt;
1372
+ case Ni:
1373
+ return dt;
1374
+ case Li:
1375
+ return _t;
1376
+ case qi:
1377
+ return yt;
1378
+ }
1379
+ return t;
1380
+ });
1381
+ var gt = z.Uint8Array, Gi = "__lodash_hash_undefined__";
1382
+ function Ui(e) {
1383
+ return this.__data__.set(e, Gi), this;
1384
+ }
1385
+ function Bi(e) {
1386
+ return this.__data__.has(e);
1387
+ }
1388
+ function de(e) {
1389
+ var t = -1, n = e == null ? 0 : e.length;
1390
+ for (this.__data__ = new H(); ++t < n; )
1391
+ this.add(e[t]);
1392
+ }
1393
+ de.prototype.add = de.prototype.push = Ui;
1394
+ de.prototype.has = Bi;
1395
+ function Ki(e, t) {
1396
+ for (var n = -1, r = e == null ? 0 : e.length; ++n < r; )
1397
+ if (t(e[n], n, e))
1398
+ return !0;
1399
+ return !1;
1400
+ }
1401
+ function Qi(e, t) {
1402
+ return e.has(t);
1403
+ }
1404
+ var Wi = 1, Xi = 2;
1405
+ function Ut(e, t, n, r, i, s) {
1406
+ var o = n & Wi, a = e.length, c = t.length;
1407
+ if (a != c && !(o && c > a))
1408
+ return !1;
1409
+ var u = s.get(e), f = s.get(t);
1410
+ if (u && f)
1411
+ return u == t && f == e;
1412
+ var l = -1, d = !0, y = n & Xi ? new de() : void 0;
1413
+ for (s.set(e, t), s.set(t, e); ++l < a; ) {
1414
+ var m = e[l], O = t[l];
1415
+ if (r)
1416
+ var v = o ? r(O, m, l, t, e, s) : r(m, O, l, e, t, s);
1417
+ if (v !== void 0) {
1418
+ if (v)
1419
+ continue;
1420
+ d = !1;
1421
+ break;
1422
+ }
1423
+ if (y) {
1424
+ if (!Ki(t, function(w, b) {
1425
+ if (!Qi(y, b) && (m === w || i(m, w, n, r, s)))
1426
+ return y.push(b);
1427
+ })) {
1428
+ d = !1;
1429
+ break;
1430
+ }
1431
+ } else if (!(m === O || i(m, O, n, r, s))) {
1432
+ d = !1;
1433
+ break;
1434
+ }
1435
+ }
1436
+ return s.delete(e), s.delete(t), d;
1437
+ }
1438
+ function Yi(e) {
1439
+ var t = -1, n = Array(e.size);
1440
+ return e.forEach(function(r, i) {
1441
+ n[++t] = [i, r];
1442
+ }), n;
1443
+ }
1444
+ function Vi(e) {
1445
+ var t = -1, n = Array(e.size);
1446
+ return e.forEach(function(r) {
1447
+ n[++t] = r;
1448
+ }), n;
1449
+ }
1450
+ var Zi = 1, Ji = 2, ki = "[object Boolean]", es = "[object Date]", ts = "[object Error]", ns = "[object Map]", rs = "[object Number]", is = "[object RegExp]", ss = "[object Set]", os = "[object String]", as = "[object Symbol]", cs = "[object ArrayBuffer]", us = "[object DataView]", mt = I ? I.prototype : void 0, Me = mt ? mt.valueOf : void 0;
1451
+ function fs(e, t, n, r, i, s, o) {
1452
+ switch (n) {
1453
+ case us:
1454
+ if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset)
1455
+ return !1;
1456
+ e = e.buffer, t = t.buffer;
1457
+ case cs:
1458
+ return !(e.byteLength != t.byteLength || !s(new gt(e), new gt(t)));
1459
+ case ki:
1460
+ case es:
1461
+ case rs:
1462
+ return Ft(+e, +t);
1463
+ case ts:
1464
+ return e.name == t.name && e.message == t.message;
1465
+ case is:
1466
+ case os:
1467
+ return e == t + "";
1468
+ case ns:
1469
+ var a = Yi;
1470
+ case ss:
1471
+ var c = r & Zi;
1472
+ if (a || (a = Vi), e.size != t.size && !c)
1473
+ return !1;
1474
+ var u = o.get(e);
1475
+ if (u)
1476
+ return u == t;
1477
+ r |= Ji, o.set(e, t);
1478
+ var f = Ut(a(e), a(t), r, i, s, o);
1479
+ return o.delete(e), f;
1480
+ case as:
1481
+ if (Me)
1482
+ return Me.call(e) == Me.call(t);
1483
+ }
1484
+ return !1;
1485
+ }
1486
+ var ls = 1, hs = Object.prototype, ps = hs.hasOwnProperty;
1487
+ function ds(e, t, n, r, i, s) {
1488
+ var o = n & ls, a = ht(e), c = a.length, u = ht(t), f = u.length;
1489
+ if (c != f && !o)
1490
+ return !1;
1491
+ for (var l = c; l--; ) {
1492
+ var d = a[l];
1493
+ if (!(o ? d in t : ps.call(t, d)))
1494
+ return !1;
1495
+ }
1496
+ var y = s.get(e), m = s.get(t);
1497
+ if (y && m)
1498
+ return y == t && m == e;
1499
+ var O = !0;
1500
+ s.set(e, t), s.set(t, e);
1501
+ for (var v = o; ++l < c; ) {
1502
+ d = a[l];
1503
+ var w = e[d], b = t[d];
1504
+ if (r)
1505
+ var A = o ? r(b, w, d, t, e, s) : r(w, b, d, e, t, s);
1506
+ if (!(A === void 0 ? w === b || i(w, b, n, r, s) : A)) {
1507
+ O = !1;
1508
+ break;
1509
+ }
1510
+ v || (v = d == "constructor");
1511
+ }
1512
+ if (O && !v) {
1513
+ var G = e.constructor, p = t.constructor;
1514
+ G != p && "constructor" in e && "constructor" in t && !(typeof G == "function" && G instanceof G && typeof p == "function" && p instanceof p) && (O = !1);
1515
+ }
1516
+ return s.delete(e), s.delete(t), O;
1517
+ }
1518
+ var _s = 1, wt = "[object Arguments]", vt = "[object Array]", ce = "[object Object]", ys = Object.prototype, St = ys.hasOwnProperty;
1519
+ function bs(e, t, n, r, i, s) {
1520
+ var o = E(e), a = E(t), c = o ? vt : L(e), u = a ? vt : L(t);
1521
+ c = c == wt ? ce : c, u = u == wt ? ce : u;
1522
+ var f = c == ce, l = u == ce, d = c == u;
1523
+ if (d && je(e)) {
1524
+ if (!je(t))
1525
+ return !1;
1526
+ o = !0, f = !1;
1527
+ }
1528
+ if (d && !f)
1529
+ return s || (s = new $()), o || Nt(e) ? Ut(e, t, n, r, i, s) : fs(e, t, c, n, r, i, s);
1530
+ if (!(n & _s)) {
1531
+ var y = f && St.call(e, "__wrapped__"), m = l && St.call(t, "__wrapped__");
1532
+ if (y || m) {
1533
+ var O = y ? e.value() : e, v = m ? t.value() : t;
1534
+ return s || (s = new $()), i(O, v, n, r, s);
1535
+ }
1536
+ }
1537
+ return d ? (s || (s = new $()), ds(e, t, n, r, i, s)) : !1;
1538
+ }
1539
+ function ve(e, t, n, r, i) {
1540
+ return e === t ? !0 : e == null || t == null || !Y(e) && !Y(t) ? e !== e && t !== t : bs(e, t, n, r, ve, i);
1541
+ }
1542
+ var gs = 1, ms = 2;
1543
+ function ws(e, t, n, r) {
1544
+ var i = n.length, s = i;
1545
+ if (e == null)
1546
+ return !s;
1547
+ for (e = Object(e); i--; ) {
1548
+ var o = n[i];
1549
+ if (o[2] ? o[1] !== e[o[0]] : !(o[0] in e))
1550
+ return !1;
1551
+ }
1552
+ for (; ++i < s; ) {
1553
+ o = n[i];
1554
+ var a = o[0], c = e[a], u = o[1];
1555
+ if (o[2]) {
1556
+ if (c === void 0 && !(a in e))
1557
+ return !1;
1558
+ } else {
1559
+ var f = new $(), l;
1560
+ if (!(l === void 0 ? ve(u, c, gs | ms, r, f) : l))
1561
+ return !1;
1562
+ }
1563
+ }
1564
+ return !0;
1565
+ }
1566
+ function Bt(e) {
1567
+ return e === e && !ie(e);
1568
+ }
1569
+ function vs(e) {
1570
+ for (var t = be(e), n = t.length; n--; ) {
1571
+ var r = t[n], i = e[r];
1572
+ t[n] = [r, i, Bt(i)];
1573
+ }
1574
+ return t;
1575
+ }
1576
+ function Kt(e, t) {
1577
+ return function(n) {
1578
+ return n == null ? !1 : n[e] === t && (t !== void 0 || e in Object(n));
1579
+ };
1580
+ }
1581
+ function Ss(e) {
1582
+ var t = vs(e);
1583
+ return t.length == 1 && t[0][2] ? Kt(t[0][0], t[0][1]) : function(n) {
1584
+ return n === e || ws(n, e, t);
1585
+ };
1586
+ }
1587
+ function Os(e, t) {
1588
+ return e != null && t in Object(e);
1589
+ }
1590
+ function As(e, t, n) {
1591
+ t = Lt(t, e);
1592
+ for (var r = -1, i = t.length, s = !1; ++r < i; ) {
1593
+ var o = we(t[r]);
1594
+ if (!(s = e != null && n(e, o)))
1595
+ break;
1596
+ e = e[o];
1597
+ }
1598
+ return s || ++r != i ? s : (i = e == null ? 0 : e.length, !!i && Be(i) && $t(o, i) && (E(e) || Ke(e)));
1599
+ }
1600
+ function Cs(e, t) {
1601
+ return e != null && As(e, t, Os);
1602
+ }
1603
+ var Ms = 1, Es = 2;
1604
+ function Ps(e, t) {
1605
+ return Qe(e) && Bt(t) ? Kt(we(e), t) : function(n) {
1606
+ var r = vi(n, e);
1607
+ return r === void 0 && r === t ? Cs(n, e) : ve(t, r, Ms | Es);
1608
+ };
1609
+ }
1610
+ function Ts(e) {
1611
+ return function(t) {
1612
+ return t?.[e];
1613
+ };
1614
+ }
1615
+ function xs(e) {
1616
+ return function(t) {
1617
+ return qt(t, e);
1618
+ };
1619
+ }
1620
+ function Is(e) {
1621
+ return Qe(e) ? Ts(we(e)) : xs(e);
1622
+ }
1623
+ function Se(e) {
1624
+ return typeof e == "function" ? e : e == null ? In : typeof e == "object" ? E(e) ? Ps(e[0], e[1]) : Ss(e) : Is(e);
1625
+ }
1626
+ function Rs(e) {
1627
+ return function(t, n, r) {
1628
+ for (var i = -1, s = Object(t), o = r(t), a = o.length; a--; ) {
1629
+ var c = o[++i];
1630
+ if (n(s[c], c, s) === !1)
1631
+ break;
1632
+ }
1633
+ return t;
1634
+ };
1635
+ }
1636
+ var js = Rs();
1637
+ function $s(e, t) {
1638
+ return e && js(e, t, be);
1639
+ }
1640
+ function Fs(e, t) {
1641
+ return function(n, r) {
1642
+ if (n == null)
1643
+ return n;
1644
+ if (!ye(n))
1645
+ return e(n, r);
1646
+ for (var i = n.length, s = -1, o = Object(n); ++s < i && r(o[s], s, o) !== !1; )
1647
+ ;
1648
+ return n;
1649
+ };
1650
+ }
1651
+ var Qt = Fs($s);
1652
+ function zs(e) {
1653
+ var t = e == null ? 0 : e.length;
1654
+ return t ? e[t - 1] : void 0;
1655
+ }
1656
+ function Ds(e, t) {
1657
+ for (var n = -1, r = e == null ? 0 : e.length; ++n < r; )
1658
+ if (!t(e[n], n, e))
1659
+ return !1;
1660
+ return !0;
1661
+ }
1662
+ function Hs(e, t) {
1663
+ var n = !0;
1664
+ return Qt(e, function(r, i, s) {
1665
+ return n = !!t(r, i, s), n;
1666
+ }), n;
1667
+ }
1668
+ function Ns(e, t, n) {
1669
+ var r = E(e) ? Ds : Hs;
1670
+ return r(e, Se(t));
1671
+ }
1672
+ function Ls(e) {
1673
+ return function(t, n, r) {
1674
+ var i = Object(t);
1675
+ if (!ye(t)) {
1676
+ var s = Se(n);
1677
+ t = be(t), n = function(a) {
1678
+ return s(i[a], a, i);
1679
+ };
1680
+ }
1681
+ var o = e(t, n, r);
1682
+ return o > -1 ? i[s ? t[o] : o] : void 0;
1683
+ };
1684
+ }
1685
+ var qs = Math.max;
1686
+ function Gs(e, t, n) {
1687
+ var r = e == null ? 0 : e.length;
1688
+ if (!r)
1689
+ return -1;
1690
+ var i = n == null ? 0 : xn(n);
1691
+ return i < 0 && (i = qs(r + i, 0)), Xn(e, Se(t), i);
1692
+ }
1693
+ var Us = Ls(Gs);
1694
+ function Bs(e, t) {
1695
+ var n = -1, r = ye(e) ? Array(e.length) : [];
1696
+ return Qt(e, function(i, s, o) {
1697
+ r[++n] = t(i, s, o);
1698
+ }), r;
1699
+ }
1700
+ function Ks(e, t) {
1701
+ var n = E(e) ? It : Bs;
1702
+ return n(e, Se(t));
1703
+ }
1704
+ function Qs(e, t) {
1705
+ return Oi(Ks(e, t));
1706
+ }
1707
+ function Ws(e) {
1708
+ for (var t = -1, n = e == null ? 0 : e.length, r = {}; ++t < n; ) {
1709
+ var i = e[t];
1710
+ r[i[0]] = i[1];
1711
+ }
1712
+ return r;
1713
+ }
1714
+ function Xs(e, t) {
1715
+ return ve(e, t);
1716
+ }
1717
+ const Ys = (e, t) => {
1718
+ if (!e.length) return [t];
1719
+ const n = zs(e);
1720
+ return n.type === "create" && t.type === "delete" ? null : n.type === "create" && t.type === "update" ? [{ ...n, data: t.data }] : n.type === "update" && t.type === "update" ? [...e.slice(0, -1), t] : n.type === "update" && t.type === "delete" ? [...e, t] : [t];
1721
+ };
1722
+ class Vs {
1723
+ _config;
1724
+ _state;
1725
+ _subscribers = /* @__PURE__ */ new Set();
1726
+ _debounceTimer = null;
1727
+ _abortController = null;
1728
+ constructor(t) {
1729
+ this._config = t, this._state = {
1730
+ queue: /* @__PURE__ */ new Map(),
1731
+ inFlight: /* @__PURE__ */ new Map(),
1732
+ errors: /* @__PURE__ */ new Map(),
1733
+ isPaused: !1,
1734
+ isSyncing: !1
1735
+ };
1736
+ }
1737
+ enqueue(t) {
1738
+ this._updateState((n) => {
1739
+ const r = [...n.queue.get(t.id) ?? []], i = Ys(r, t);
1740
+ i ? n.queue.set(t.id, i) : n.queue.delete(t.id), n.errors.delete(t.id);
1741
+ }), this._scheduleFlush();
1742
+ }
1743
+ pause() {
1744
+ this._updateState((t) => {
1745
+ t.isPaused = !0;
1746
+ }), this._clearTimer();
1747
+ }
1748
+ resume() {
1749
+ this._updateState((t) => {
1750
+ t.isPaused = !1;
1751
+ }), this._state.queue.size > 0 && this._scheduleFlush();
1752
+ }
1753
+ retryAll() {
1754
+ const t = this._state.errors;
1755
+ t.size !== 0 && (this._updateState((n) => {
1756
+ for (const [r, i] of t)
1757
+ n.queue.has(r) || n.queue.set(r, i.operations);
1758
+ n.errors.clear();
1759
+ }), this._scheduleFlush());
1760
+ }
1761
+ retry(t) {
1762
+ const n = this._state.errors.get(t);
1763
+ n && (this._updateState((r) => {
1764
+ r.queue.has(t) || r.queue.set(t, n.operations), r.errors.delete(t);
1765
+ }), this._scheduleFlush());
1766
+ }
1767
+ resetRetries(t) {
1768
+ this._state.errors.has(t) && this._updateState((n) => {
1769
+ const r = n.errors.get(t);
1770
+ r && (r.retries = 0);
1771
+ });
1772
+ }
1773
+ getState() {
1774
+ return this._state;
1775
+ }
1776
+ subscribe(t) {
1777
+ return this._subscribers.add(t), () => this._subscribers.delete(t);
1778
+ }
1779
+ _updateState(t) {
1780
+ this._state = P(this._state, t), this._subscribers.forEach((n) => n());
1781
+ }
1782
+ _scheduleFlush() {
1783
+ this._state.isPaused || this._state.isSyncing || (this._clearTimer(), this._debounceTimer = setTimeout(() => this._flush(), this._config.debounce));
1784
+ }
1785
+ _clearTimer() {
1786
+ this._debounceTimer && (clearTimeout(this._debounceTimer), this._debounceTimer = null);
1787
+ }
1788
+ async _flush() {
1789
+ const { isPaused: t, isSyncing: n, queue: r } = this._state;
1790
+ if (t || n || r.size === 0) return;
1791
+ this._updateState((s) => {
1792
+ s.inFlight = new Map(r), s.queue = /* @__PURE__ */ new Map(), s.isSyncing = !0;
1793
+ });
1794
+ const i = Qs([...this._state.inFlight.values()]);
1795
+ this._abortController = new AbortController();
1796
+ try {
1797
+ const s = await this._config.onSync(i, this._abortController.signal);
1798
+ this._processResults(Ws(s.map((o) => [o.id, o])));
1799
+ } catch (s) {
1800
+ this._handleError(s);
1801
+ }
1802
+ this._abortController = null, this._state.queue.size > 0 && !this._state.isPaused && this._scheduleFlush();
1803
+ }
1804
+ _processResults(t) {
1805
+ const n = this._state.inFlight, r = [];
1806
+ this._updateState((i) => {
1807
+ for (const [s, o] of n)
1808
+ if (Ns(o, (c) => t[c.id]?.status === "success")) {
1809
+ i.errors.delete(s);
1810
+ for (const c of o) {
1811
+ const u = t[c.id];
1812
+ c.type === "create" && u?.newId && u.newId !== c.id && r.push({ tempId: c.id, newId: u.newId });
1813
+ }
1814
+ } else {
1815
+ const c = (i.errors.get(s)?.retries ?? 0) + 1;
1816
+ c < this._config.maxRetries && !i.queue.has(s) && i.queue.set(s, o);
1817
+ const u = Us(o, (f) => t[f.id]?.status !== "success");
1818
+ i.errors.set(s, {
1819
+ error: t[u?.id ?? ""]?.error ?? "Unknown error",
1820
+ retries: c,
1821
+ operations: o
1822
+ });
1823
+ }
1824
+ i.inFlight = /* @__PURE__ */ new Map(), i.isSyncing = !1;
1825
+ }), r.length > 0 && this._config.onIdRemap && this._config.onIdRemap(r);
1826
+ }
1827
+ _handleError(t) {
1828
+ const n = this._state.inFlight, r = this._abortController?.signal.aborted, i = t instanceof Error ? t.message : String(t);
1829
+ this._updateState((s) => {
1830
+ for (const [o, a] of n)
1831
+ if (r)
1832
+ s.queue.has(o) || s.queue.set(o, a);
1833
+ else {
1834
+ const c = (s.errors.get(o)?.retries ?? 0) + 1;
1835
+ c < this._config.maxRetries && !s.queue.has(o) && s.queue.set(o, a), s.errors.set(o, {
1836
+ error: i,
1837
+ retries: c,
1838
+ operations: a
1839
+ });
1840
+ }
1841
+ s.inFlight = /* @__PURE__ */ new Map(), s.isSyncing = !1;
1842
+ });
1843
+ }
1844
+ }
1845
+ class Zs {
1846
+ _cache = /* @__PURE__ */ new Map();
1847
+ _capacity;
1848
+ _ttl;
1849
+ constructor(t, n) {
1850
+ this._capacity = t, this._ttl = n;
1851
+ }
1852
+ get(t) {
1853
+ const n = this._cache.get(t);
1854
+ return n ? Date.now() - n.ts > this._ttl ? (this._cache.delete(t), null) : (this._cache.delete(t), this._cache.set(t, n), n.data) : null;
1855
+ }
1856
+ set(t, n) {
1857
+ if (this._cache.has(t))
1858
+ this._cache.delete(t);
1859
+ else if (this._cache.size >= this._capacity) {
1860
+ const r = this._cache.keys().next().value;
1861
+ r !== void 0 && this._cache.delete(r);
1862
+ }
1863
+ this._cache.set(t, { data: n, ts: Date.now() });
1864
+ }
1865
+ invalidate(t) {
1866
+ this._cache.delete(t);
1867
+ }
1868
+ clear() {
1869
+ this._cache.clear();
1870
+ }
1871
+ has(t) {
1872
+ return this.get(t) !== null;
1873
+ }
1874
+ get size() {
1875
+ return this._cache.size;
1876
+ }
1877
+ }
1878
+ class Js {
1879
+ _config;
1880
+ _cache;
1881
+ _state = { status: "idle", items: [] };
1882
+ _subscribers = /* @__PURE__ */ new Set();
1883
+ _abortController = null;
1884
+ _currentContext = null;
1885
+ constructor(t) {
1886
+ this._config = { retries: 0, ...t }, this._cache = new Zs(t.cacheCapacity, t.cacheTtl);
1887
+ }
1888
+ _getCacheKey = (t) => JSON.stringify([this._config.id, t]);
1889
+ _setState(t) {
1890
+ this._state = P(this._state, (n) => {
1891
+ Object.assign(n, t);
1892
+ }), this._subscribers.forEach((n) => n());
1893
+ }
1894
+ async _fetchWithRetry(t, n) {
1895
+ const r = this._config.retries;
1896
+ let i;
1897
+ for (let s = 0; s <= r; s++) {
1898
+ if (n.aborted) throw new DOMException("Aborted", "AbortError");
1899
+ try {
1900
+ return s > 0 && this._setState({ retryCount: s }), await this._config.onFetch(t, n);
1901
+ } catch (o) {
1902
+ if (i = o, n.aborted || s === r) throw o;
1903
+ }
1904
+ }
1905
+ throw i;
1906
+ }
1907
+ async fetch(t) {
1908
+ const n = this._getCacheKey(t), r = this._cache.get(n);
1909
+ if (r !== null)
1910
+ return this._currentContext = t, this._setState({ status: "idle", items: r, error: void 0, retryCount: void 0 }), r;
1911
+ this._abortController?.abort("New fetch request started");
1912
+ const i = new AbortController();
1913
+ this._abortController = i, this._currentContext = t, this._setState({ status: "fetching", error: void 0, retryCount: void 0 });
1914
+ try {
1915
+ const s = await this._fetchWithRetry(t, i.signal);
1916
+ return this._cache.set(n, s), this._abortController = null, this._setState({ status: "idle", items: s, error: void 0, retryCount: void 0 }), s;
1917
+ } catch (s) {
1918
+ if (i.signal.aborted) return this._state.items;
1919
+ throw this._abortController = null, this._setState({
1920
+ status: "error",
1921
+ error: s instanceof Error ? s.message : String(s)
1922
+ }), s;
1923
+ }
1924
+ }
1925
+ async refresh(t) {
1926
+ const n = t ?? this._currentContext;
1927
+ if (!n) throw new Error("No context provided for refresh");
1928
+ return this._cache.invalidate(this._getCacheKey(n)), this.fetch(n);
1929
+ }
1930
+ invalidateCache() {
1931
+ this._cache.clear();
1932
+ }
1933
+ invalidateCacheForContext(t) {
1934
+ this._cache.invalidate(this._getCacheKey(t));
1935
+ }
1936
+ getState = () => this._state;
1937
+ getContext = () => this._currentContext;
1938
+ isFetching = () => this._state.status === "fetching";
1939
+ subscribe(t) {
1940
+ return this._subscribers.add(t), () => {
1941
+ this._subscribers.delete(t);
1942
+ };
1943
+ }
1944
+ }
1945
+ class ks {
1946
+ _collection;
1947
+ _id;
1948
+ _cachedStatus = null;
1949
+ _refCount = 0;
1950
+ constructor(t, n) {
1951
+ this._collection = t, this._id = n;
1952
+ }
1953
+ // Reference counting for lifecycle management
1954
+ _retain() {
1955
+ this._refCount++;
1956
+ }
1957
+ _release() {
1958
+ this._refCount--, this._refCount <= 0 && this._collection._releaseItem(this._id);
1959
+ }
1960
+ get refCount() {
1961
+ return this._refCount;
1962
+ }
1963
+ get id() {
1964
+ return this._id;
1965
+ }
1966
+ get data() {
1967
+ return this._collection.getState().items.get(this._id);
1968
+ }
1969
+ update(t) {
1970
+ this._collection.update(this._id, t);
1971
+ }
1972
+ remove() {
1973
+ this._collection.remove(this._id);
1974
+ }
1975
+ getStatus() {
1976
+ const t = this._collection.getItemStatus(this._id);
1977
+ return Xs(this._cachedStatus, t) || (this._cachedStatus = t), this._cachedStatus;
1978
+ }
1979
+ exists() {
1980
+ return this._collection.getState().items.has(this._id);
1981
+ }
1982
+ // Expose collection for useItem hook
1983
+ get collection() {
1984
+ return this._collection;
1985
+ }
1986
+ // Internal method to update ID after server assigns permanent ID
1987
+ // Called by Collection when handling ID remapping
1988
+ _updateId(t) {
1989
+ this._id = t;
1990
+ }
1991
+ }
1992
+ class U {
1993
+ // Global cache of collection instances by id
1994
+ static _cache = /* @__PURE__ */ new Map();
1995
+ // Get or create a collection instance
1996
+ static get(t) {
1997
+ const n = U._cache.get(t.id);
1998
+ if (n)
1999
+ return n;
2000
+ const r = new U(t);
2001
+ return U._cache.set(t.id, r), r;
2002
+ }
2003
+ // Clear a specific collection from cache
2004
+ static clear(t) {
2005
+ U._cache.delete(t);
2006
+ }
2007
+ // Clear all collections from cache
2008
+ static clearAll() {
2009
+ U._cache.clear();
2010
+ }
2011
+ id;
2012
+ config;
2013
+ _state;
2014
+ _syncQueue;
2015
+ _fetchHandler;
2016
+ _itemCache = /* @__PURE__ */ new Map();
2017
+ _subscribers = /* @__PURE__ */ new Set();
2018
+ _hasInitialized = !1;
2019
+ _batchMode = !1;
2020
+ constructor(t) {
2021
+ this.id = t.id, this.config = t;
2022
+ const n = async (s) => s.map((o) => ({ id: o.id, status: "success" }));
2023
+ this._syncQueue = new Vs({
2024
+ debounce: t.syncDebounce ?? 300,
2025
+ maxRetries: t.syncRetries ?? 3,
2026
+ onSync: t.onSync ?? n,
2027
+ onIdRemap: (s) => this._handleIdRemap(s)
2028
+ }), this._fetchHandler = new Js({
2029
+ id: t.id,
2030
+ cacheCapacity: t.cacheCapacity ?? 10,
2031
+ cacheTtl: t.cacheTtl ?? 6e4,
2032
+ retries: t.fetchRetries ?? 0,
2033
+ onFetch: t.onFetch
2034
+ });
2035
+ const r = this._syncQueue.getState(), i = this._fetchHandler.getState();
2036
+ this._state = {
2037
+ context: t.initialContext,
2038
+ items: /* @__PURE__ */ new Map(),
2039
+ syncState: "idle",
2040
+ loading: !1,
2041
+ syncing: !1,
2042
+ syncQueue: r,
2043
+ fetchStatus: i.status,
2044
+ fetchError: i.error
2045
+ }, this._syncQueue.subscribe(() => {
2046
+ this._onSyncQueueChange();
2047
+ }), this._fetchHandler.subscribe(() => {
2048
+ this._onFetchChange();
2049
+ }), this._initialFetch();
2050
+ }
2051
+ // Getters for convenience (read from state)
2052
+ get context() {
2053
+ return this._state.context;
2054
+ }
2055
+ get items() {
2056
+ return this._state.items;
2057
+ }
2058
+ get loading() {
2059
+ return this._state.loading;
2060
+ }
2061
+ get syncing() {
2062
+ return this._state.syncing;
2063
+ }
2064
+ get syncQueue() {
2065
+ return this._state.syncQueue;
2066
+ }
2067
+ // Subscribe to state changes
2068
+ subscribe(t) {
2069
+ return this._subscribers.add(t), () => {
2070
+ this._subscribers.delete(t);
2071
+ };
2072
+ }
2073
+ // Get current state (for useSyncExternalStore) - returns cached reference
2074
+ getState() {
2075
+ return this._state;
2076
+ }
2077
+ // Get item status from sync queue state
2078
+ getItemStatus(t) {
2079
+ const { queue: n, inFlight: r, errors: i } = this._state.syncQueue, s = r.get(t);
2080
+ if (s && s.length > 0)
2081
+ return {
2082
+ type: s[s.length - 1].type,
2083
+ status: "syncing",
2084
+ retries: i.get(t)?.retries ?? 0
2085
+ };
2086
+ const o = n.get(t);
2087
+ if (o && o.length > 0) {
2088
+ const c = o[o.length - 1], u = i.get(t);
2089
+ return {
2090
+ type: c.type,
2091
+ status: u ? "error" : "pending",
2092
+ retries: u?.retries ?? 0,
2093
+ error: u?.error
2094
+ };
2095
+ }
2096
+ const a = i.get(t);
2097
+ return a ? {
2098
+ type: "update",
2099
+ status: "error",
2100
+ retries: a.retries,
2101
+ error: a.error
2102
+ } : null;
2103
+ }
2104
+ // Create a new item (local-first)
2105
+ create(t) {
2106
+ const n = this.config.getId(t);
2107
+ this._state = P(this._state, (r) => {
2108
+ r.items.set(n, t);
2109
+ }), this._fetchHandler.invalidateCache(), this._notifySubscribers(), this._syncQueue.enqueue({ id: n, type: "create", data: t });
2110
+ }
2111
+ // Update an existing item (local-first)
2112
+ update(t, n) {
2113
+ const r = this._state.items.get(t);
2114
+ if (!r) return;
2115
+ const i = P(r, n);
2116
+ this._state = P(this._state, (s) => {
2117
+ s.items.set(t, i);
2118
+ }), this._fetchHandler.invalidateCache(), this._notifySubscribers(), this._syncQueue.enqueue({ id: t, type: "update", data: i });
2119
+ }
2120
+ // Remove an item (local-first)
2121
+ remove(t) {
2122
+ const n = this._state.items.get(t);
2123
+ n && (this._state = P(this._state, (r) => {
2124
+ r.items.delete(t);
2125
+ }), this._itemCache.delete(t), this._fetchHandler.invalidateCache(), this._notifySubscribers(), this._syncQueue.enqueue({ id: t, type: "delete", data: n }));
2126
+ }
2127
+ // Get Item reference (cached) - automatically retains the item
2128
+ getItem(t) {
2129
+ let n = this._itemCache.get(t);
2130
+ return n || (n = new ks(this, t), this._itemCache.set(t, n)), n._retain(), n;
2131
+ }
2132
+ // Release item from cache when ref count reaches zero
2133
+ _releaseItem(t) {
2134
+ this._itemCache.delete(t);
2135
+ }
2136
+ // Update context and refetch
2137
+ setContext(t) {
2138
+ const n = this._state.context, r = P(n, t);
2139
+ n !== r && (this._state = P(this._state, (i) => {
2140
+ i.context = r;
2141
+ }), this._fetchHandler.fetch(r), this._notifySubscribers());
2142
+ }
2143
+ // Force refresh (bypass cache)
2144
+ async refresh() {
2145
+ this._fetchHandler.invalidateCache(), await this._fetchHandler.fetch(this._state.context);
2146
+ }
2147
+ // SyncQueue controls
2148
+ pauseSync() {
2149
+ this._syncQueue.pause();
2150
+ }
2151
+ resumeSync() {
2152
+ this._syncQueue.resume(), this._fetchHandler.invalidateCache(), this._fetchHandler.fetch(this._state.context);
2153
+ }
2154
+ retrySync(t) {
2155
+ t ? this._syncQueue.retry(t) : this._syncQueue.retryAll();
2156
+ }
2157
+ // Private methods
2158
+ async _initialFetch() {
2159
+ this._hasInitialized || (this._hasInitialized = !0, await this._fetchHandler.fetch(this._state.context));
2160
+ }
2161
+ _onSyncQueueChange() {
2162
+ const t = this._syncQueue.getState();
2163
+ this._updateSyncState(t);
2164
+ }
2165
+ _onFetchChange() {
2166
+ const t = this._fetchHandler.getState();
2167
+ this._state = P(this._state, (n) => {
2168
+ n.fetchStatus = t.status, n.fetchError = t.error, n.loading = t.status === "fetching", n.syncState = this._computeSyncState(t.status, n.syncQueue.isSyncing);
2169
+ const { queue: r, inFlight: i } = this._state.syncQueue, s = /* @__PURE__ */ new Map();
2170
+ for (const o of t.items) {
2171
+ const a = this.config.getId(o);
2172
+ s.set(a, o);
2173
+ }
2174
+ for (const [o, a] of r) {
2175
+ const c = a[a.length - 1];
2176
+ (c.type === "create" || c.type === "update") && s.set(o, c.data);
2177
+ }
2178
+ for (const [o, a] of i) {
2179
+ const c = a[a.length - 1];
2180
+ (c.type === "create" || c.type === "update") && s.set(o, c.data);
2181
+ }
2182
+ n.items = s;
2183
+ }), this._notifySubscribers();
2184
+ }
2185
+ _updateSyncState(t) {
2186
+ this._state = P(this._state, (n) => {
2187
+ n.syncQueue = t, n.syncing = t.isSyncing, n.syncState = this._computeSyncState(n.fetchStatus, t.isSyncing);
2188
+ }), this._notifySubscribers();
2189
+ }
2190
+ _computeSyncState(t, n) {
2191
+ return t === "fetching" ? "fetching" : n ? "syncing" : "idle";
2192
+ }
2193
+ _notifySubscribers() {
2194
+ if (!this._batchMode)
2195
+ for (const t of this._subscribers)
2196
+ t();
2197
+ }
2198
+ _handleIdRemap(t) {
2199
+ if (t.length === 0) return;
2200
+ const { setId: n } = this.config;
2201
+ this._state = P(this._state, (r) => {
2202
+ for (const { tempId: i, newId: s } of t) {
2203
+ const o = r.items.get(i);
2204
+ if (o) {
2205
+ let a;
2206
+ n ? a = n(o, s) : (o.id = s, a = o), r.items.delete(i), r.items.set(s, a);
2207
+ }
2208
+ }
2209
+ });
2210
+ for (const { tempId: r, newId: i } of t) {
2211
+ const s = this._itemCache.get(r);
2212
+ s && (s._updateId(i), this._itemCache.delete(r), this._itemCache.set(i, s));
2213
+ }
2214
+ this._notifySubscribers();
2215
+ }
2216
+ }
2217
+ function to(e) {
2218
+ const t = U.get(e), n = ue(
2219
+ (r) => t.subscribe(r),
2220
+ () => t.getState(),
2221
+ () => t.getState()
2222
+ );
2223
+ return {
2224
+ // State (all from single immutable state object)
2225
+ items: n.items,
2226
+ context: n.context,
2227
+ syncState: n.syncState,
2228
+ syncQueue: n.syncQueue,
2229
+ loading: n.loading,
2230
+ syncing: n.syncing,
2231
+ fetchStatus: n.fetchStatus,
2232
+ fetchError: n.fetchError,
2233
+ // Item operations
2234
+ create: (r) => t.create(r),
2235
+ update: (r, i) => t.update(r, i),
2236
+ remove: (r) => t.remove(r),
2237
+ getItem: (r) => t.getItem(r),
2238
+ getItemStatus: (r) => t.getItemStatus(r),
2239
+ // Context & refresh
2240
+ setContext: (r) => t.setContext(r),
2241
+ refresh: () => t.refresh(),
2242
+ // Sync controls
2243
+ pauseSync: () => t.pauseSync(),
2244
+ resumeSync: () => t.resumeSync(),
2245
+ retrySync: (r) => t.retrySync(r)
2246
+ };
2247
+ }
2248
+ function no(e) {
2249
+ Xt(() => () => {
2250
+ queueMicrotask(() => e._release());
2251
+ }, [e]);
2252
+ const t = ue(
2253
+ (o) => e.collection.subscribe(o),
2254
+ () => e.data,
2255
+ () => e.data
2256
+ ), n = ue(
2257
+ (o) => e.collection.subscribe(o),
2258
+ () => e.getStatus(),
2259
+ () => e.getStatus()
2260
+ ), r = ue(
2261
+ (o) => e.collection.subscribe(o),
2262
+ () => e.exists(),
2263
+ () => e.exists()
2264
+ ), i = Xe((o) => e.update(o), [e]), s = Xe(() => e.remove(), [e]);
2265
+ return { data: t, status: n, update: i, remove: s, exists: r };
2266
+ }
2267
+ export {
2268
+ Zs as Cache,
2269
+ U as Collection,
2270
+ Js as FetchHandler,
2271
+ ks as Item,
2272
+ Vs as SyncQueue,
2273
+ so as categorizeResults,
2274
+ ao as createSyncClient,
2275
+ co as createSyncClientFromEndpoint,
2276
+ uo as createSyncClientWithStats,
2277
+ fo as fetchToSyncResult,
2278
+ lo as syncError,
2279
+ ho as syncSuccess,
2280
+ to as useCrud,
2281
+ no as useItem
2282
+ };
2283
+ //# sourceMappingURL=index.js.map