@instantdb/react-common 0.22.83 → 0.22.84-experimental.drewh-entity-caching.20106835282.1

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.
@@ -1,5 +1,5 @@
1
- import Sr, { useRef as ze, useCallback as de, useSyncExternalStore as Mt, useEffect as ge, useMemo as Rt, useState as Or } from "react";
2
- var $t = { exports: {} }, $e = {};
1
+ import Or, { useRef as ze, useCallback as de, useSyncExternalStore as Rt, useEffect as ge, useMemo as $t, useState as Er } from "react";
2
+ var xt = { exports: {} }, $e = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.min.js
@@ -9,11 +9,11 @@ var $t = { exports: {} }, $e = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var Un;
13
- function Ni() {
14
- if (Un) return $e;
15
- Un = 1;
16
- var t = Sr, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
12
+ var Ln;
13
+ function Ki() {
14
+ if (Ln) return $e;
15
+ Ln = 1;
16
+ var t = Or, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
17
17
  function o(u, a, d) {
18
18
  var c, f = {}, l = null, p = null;
19
19
  d !== void 0 && (l = "" + d), a.key !== void 0 && (l = "" + a.key), a.ref !== void 0 && (p = a.ref);
@@ -23,10 +23,10 @@ function Ni() {
23
23
  }
24
24
  return $e.Fragment = n, $e.jsx = o, $e.jsxs = o, $e;
25
25
  }
26
- var xe = {}, Ln;
27
- function Ki() {
28
- if (Ln) return xe;
29
- Ln = 1;
26
+ var xe = {}, Fn;
27
+ function qi() {
28
+ if (Fn) return xe;
29
+ Fn = 1;
30
30
  var t = {};
31
31
  /**
32
32
  * @license React
@@ -38,7 +38,7 @@ function Ki() {
38
38
  * LICENSE file in the root directory of this source tree.
39
39
  */
40
40
  return t.NODE_ENV !== "production" && function() {
41
- var e = Sr, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, g = "@@iterator";
41
+ var e = Or, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, g = "@@iterator";
42
42
  function m(h) {
43
43
  if (h === null || typeof h != "object")
44
44
  return null;
@@ -127,18 +127,18 @@ function Ki() {
127
127
  }
128
128
  return null;
129
129
  }
130
- var le = Object.assign, Me = 0, pn, yn, bn, _n, gn, Tn, mn;
131
- function wn() {
130
+ var le = Object.assign, Me = 0, yn, bn, _n, gn, Tn, mn, wn;
131
+ function vn() {
132
132
  }
133
- wn.__reactDisabledLog = !0;
134
- function hi() {
133
+ vn.__reactDisabledLog = !0;
134
+ function pi() {
135
135
  {
136
136
  if (Me === 0) {
137
- pn = console.log, yn = console.info, bn = console.warn, _n = console.error, gn = console.group, Tn = console.groupCollapsed, mn = console.groupEnd;
137
+ yn = console.log, bn = console.info, _n = console.warn, gn = console.error, Tn = console.group, mn = console.groupCollapsed, wn = console.groupEnd;
138
138
  var h = {
139
139
  configurable: !0,
140
140
  enumerable: !0,
141
- value: wn,
141
+ value: vn,
142
142
  writable: !0
143
143
  };
144
144
  Object.defineProperties(console, {
@@ -154,7 +154,7 @@ function Ki() {
154
154
  Me++;
155
155
  }
156
156
  }
157
- function pi() {
157
+ function yi() {
158
158
  {
159
159
  if (Me--, Me === 0) {
160
160
  var h = {
@@ -164,25 +164,25 @@ function Ki() {
164
164
  };
165
165
  Object.defineProperties(console, {
166
166
  log: le({}, h, {
167
- value: pn
167
+ value: yn
168
168
  }),
169
169
  info: le({}, h, {
170
- value: yn
170
+ value: bn
171
171
  }),
172
172
  warn: le({}, h, {
173
- value: bn
173
+ value: _n
174
174
  }),
175
175
  error: le({}, h, {
176
- value: _n
176
+ value: gn
177
177
  }),
178
178
  group: le({}, h, {
179
- value: gn
179
+ value: Tn
180
180
  }),
181
181
  groupCollapsed: le({}, h, {
182
- value: Tn
182
+ value: mn
183
183
  }),
184
184
  groupEnd: le({}, h, {
185
- value: mn
185
+ value: wn
186
186
  })
187
187
  });
188
188
  }
@@ -205,10 +205,10 @@ function Ki() {
205
205
  }
206
206
  var wt = !1, Je;
207
207
  {
208
- var yi = typeof WeakMap == "function" ? WeakMap : Map;
209
- Je = new yi();
208
+ var bi = typeof WeakMap == "function" ? WeakMap : Map;
209
+ Je = new bi();
210
210
  }
211
- function vn(h, _) {
211
+ function Sn(h, _) {
212
212
  if (!h || wt)
213
213
  return "";
214
214
  {
@@ -221,7 +221,7 @@ function Ki() {
221
221
  var C = Error.prepareStackTrace;
222
222
  Error.prepareStackTrace = void 0;
223
223
  var P;
224
- P = Tt.current, Tt.current = null, hi();
224
+ P = Tt.current, Tt.current = null, pi();
225
225
  try {
226
226
  if (_) {
227
227
  var j = function() {
@@ -274,15 +274,15 @@ function Ki() {
274
274
  }
275
275
  }
276
276
  } finally {
277
- wt = !1, Tt.current = P, pi(), Error.prepareStackTrace = C;
277
+ wt = !1, Tt.current = P, yi(), Error.prepareStackTrace = C;
278
278
  }
279
279
  var ve = h ? h.displayName || h.name : "", he = ve ? Ye(ve) : "";
280
280
  return typeof h == "function" && Je.set(h, he), he;
281
281
  }
282
- function bi(h, _, w) {
283
- return vn(h, !1);
282
+ function _i(h, _, w) {
283
+ return Sn(h, !1);
284
284
  }
285
- function _i(h) {
285
+ function gi(h) {
286
286
  var _ = h.prototype;
287
287
  return !!(_ && _.isReactComponent);
288
288
  }
@@ -290,7 +290,7 @@ function Ki() {
290
290
  if (h == null)
291
291
  return "";
292
292
  if (typeof h == "function")
293
- return vn(h, _i(h));
293
+ return Sn(h, gi(h));
294
294
  if (typeof h == "string")
295
295
  return Ye(h);
296
296
  switch (h) {
@@ -302,7 +302,7 @@ function Ki() {
302
302
  if (typeof h == "object")
303
303
  switch (h.$$typeof) {
304
304
  case d:
305
- return bi(h.render);
305
+ return _i(h.render);
306
306
  case l:
307
307
  return Ze(h.type, _, w);
308
308
  case p: {
@@ -315,15 +315,15 @@ function Ki() {
315
315
  }
316
316
  return "";
317
317
  }
318
- var Re = Object.prototype.hasOwnProperty, Sn = {}, On = T.ReactDebugCurrentFrame;
318
+ var Re = Object.prototype.hasOwnProperty, On = {}, En = T.ReactDebugCurrentFrame;
319
319
  function Xe(h) {
320
320
  if (h) {
321
321
  var _ = h._owner, w = Ze(h.type, h._source, _ ? _.type : null);
322
- On.setExtraStackFrame(w);
322
+ En.setExtraStackFrame(w);
323
323
  } else
324
- On.setExtraStackFrame(null);
324
+ En.setExtraStackFrame(null);
325
325
  }
326
- function gi(h, _, w, O, C) {
326
+ function Ti(h, _, w, O, C) {
327
327
  {
328
328
  var P = Function.call.bind(Re);
329
329
  for (var j in h)
@@ -338,41 +338,41 @@ function Ki() {
338
338
  } catch ($) {
339
339
  E = $;
340
340
  }
341
- E && !(E instanceof Error) && (Xe(C), v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", O || "React class", w, j, typeof E), Xe(null)), E instanceof Error && !(E.message in Sn) && (Sn[E.message] = !0, Xe(C), v("Failed %s type: %s", w, E.message), Xe(null));
341
+ E && !(E instanceof Error) && (Xe(C), v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", O || "React class", w, j, typeof E), Xe(null)), E instanceof Error && !(E.message in On) && (On[E.message] = !0, Xe(C), v("Failed %s type: %s", w, E.message), Xe(null));
342
342
  }
343
343
  }
344
344
  }
345
- var Ti = Array.isArray;
345
+ var mi = Array.isArray;
346
346
  function vt(h) {
347
- return Ti(h);
347
+ return mi(h);
348
348
  }
349
- function mi(h) {
349
+ function wi(h) {
350
350
  {
351
351
  var _ = typeof Symbol == "function" && Symbol.toStringTag, w = _ && h[Symbol.toStringTag] || h.constructor.name || "Object";
352
352
  return w;
353
353
  }
354
354
  }
355
- function wi(h) {
355
+ function vi(h) {
356
356
  try {
357
- return En(h), !1;
357
+ return An(h), !1;
358
358
  } catch {
359
359
  return !0;
360
360
  }
361
361
  }
362
- function En(h) {
362
+ function An(h) {
363
363
  return "" + h;
364
364
  }
365
- function An(h) {
366
- if (wi(h))
367
- return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", mi(h)), En(h);
365
+ function jn(h) {
366
+ if (vi(h))
367
+ return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", wi(h)), An(h);
368
368
  }
369
- var jn = T.ReactCurrentOwner, vi = {
369
+ var kn = T.ReactCurrentOwner, Si = {
370
370
  key: !0,
371
371
  ref: !0,
372
372
  __self: !0,
373
373
  __source: !0
374
- }, kn, Cn;
375
- function Si(h) {
374
+ }, Cn, Pn;
375
+ function Oi(h) {
376
376
  if (Re.call(h, "ref")) {
377
377
  var _ = Object.getOwnPropertyDescriptor(h, "ref").get;
378
378
  if (_ && _.isReactWarning)
@@ -380,7 +380,7 @@ function Ki() {
380
380
  }
381
381
  return h.ref !== void 0;
382
382
  }
383
- function Oi(h) {
383
+ function Ei(h) {
384
384
  if (Re.call(h, "key")) {
385
385
  var _ = Object.getOwnPropertyDescriptor(h, "key").get;
386
386
  if (_ && _.isReactWarning)
@@ -388,13 +388,13 @@ function Ki() {
388
388
  }
389
389
  return h.key !== void 0;
390
390
  }
391
- function Ei(h, _) {
392
- typeof h.ref == "string" && jn.current;
393
- }
394
391
  function Ai(h, _) {
392
+ typeof h.ref == "string" && kn.current;
393
+ }
394
+ function ji(h, _) {
395
395
  {
396
396
  var w = function() {
397
- kn || (kn = !0, v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", _));
397
+ Cn || (Cn = !0, v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", _));
398
398
  };
399
399
  w.isReactWarning = !0, Object.defineProperty(h, "key", {
400
400
  get: w,
@@ -402,10 +402,10 @@ function Ki() {
402
402
  });
403
403
  }
404
404
  }
405
- function ji(h, _) {
405
+ function ki(h, _) {
406
406
  {
407
407
  var w = function() {
408
- Cn || (Cn = !0, v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", _));
408
+ Pn || (Pn = !0, v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", _));
409
409
  };
410
410
  w.isReactWarning = !0, Object.defineProperty(h, "ref", {
411
411
  get: w,
@@ -413,7 +413,7 @@ function Ki() {
413
413
  });
414
414
  }
415
415
  }
416
- var ki = function(h, _, w, O, C, P, j) {
416
+ var Ci = function(h, _, w, O, C, P, j) {
417
417
  var E = {
418
418
  // This tag allows us to uniquely identify this as a React Element
419
419
  $$typeof: n,
@@ -442,12 +442,12 @@ function Ki() {
442
442
  value: C
443
443
  }), Object.freeze && (Object.freeze(E.props), Object.freeze(E)), E;
444
444
  };
445
- function Ci(h, _, w, O, C) {
445
+ function Pi(h, _, w, O, C) {
446
446
  {
447
447
  var P, j = {}, E = null, z = null;
448
- w !== void 0 && (An(w), E = "" + w), Oi(_) && (An(_.key), E = "" + _.key), Si(_) && (z = _.ref, Ei(_, C));
448
+ w !== void 0 && (jn(w), E = "" + w), Ei(_) && (jn(_.key), E = "" + _.key), Oi(_) && (z = _.ref, Ai(_, C));
449
449
  for (P in _)
450
- Re.call(_, P) && !vi.hasOwnProperty(P) && (j[P] = _[P]);
450
+ Re.call(_, P) && !Si.hasOwnProperty(P) && (j[P] = _[P]);
451
451
  if (h && h.defaultProps) {
452
452
  var $ = h.defaultProps;
453
453
  for (P in $)
@@ -455,25 +455,25 @@ function Ki() {
455
455
  }
456
456
  if (E || z) {
457
457
  var D = typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
458
- E && Ai(j, D), z && ji(j, D);
458
+ E && ji(j, D), z && ki(j, D);
459
459
  }
460
- return ki(h, E, z, C, O, jn.current, j);
460
+ return Ci(h, E, z, C, O, kn.current, j);
461
461
  }
462
462
  }
463
- var St = T.ReactCurrentOwner, Pn = T.ReactDebugCurrentFrame;
463
+ var St = T.ReactCurrentOwner, In = T.ReactDebugCurrentFrame;
464
464
  function we(h) {
465
465
  if (h) {
466
466
  var _ = h._owner, w = Ze(h.type, h._source, _ ? _.type : null);
467
- Pn.setExtraStackFrame(w);
467
+ In.setExtraStackFrame(w);
468
468
  } else
469
- Pn.setExtraStackFrame(null);
469
+ In.setExtraStackFrame(null);
470
470
  }
471
471
  var Ot;
472
472
  Ot = !1;
473
473
  function Et(h) {
474
474
  return typeof h == "object" && h !== null && h.$$typeof === n;
475
475
  }
476
- function In() {
476
+ function Mn() {
477
477
  {
478
478
  if (St.current) {
479
479
  var h = ne(St.current.type);
@@ -485,13 +485,13 @@ Check the render method of \`` + h + "`.";
485
485
  return "";
486
486
  }
487
487
  }
488
- function Pi(h) {
488
+ function Ii(h) {
489
489
  return "";
490
490
  }
491
- var Mn = {};
492
- function Ii(h) {
491
+ var Rn = {};
492
+ function Mi(h) {
493
493
  {
494
- var _ = In();
494
+ var _ = Mn();
495
495
  if (!_) {
496
496
  var w = typeof h == "string" ? h : h.displayName || h.name;
497
497
  w && (_ = `
@@ -501,27 +501,27 @@ Check the top-level render call using <` + w + ">.");
501
501
  return _;
502
502
  }
503
503
  }
504
- function Rn(h, _) {
504
+ function $n(h, _) {
505
505
  {
506
506
  if (!h._store || h._store.validated || h.key != null)
507
507
  return;
508
508
  h._store.validated = !0;
509
- var w = Ii(_);
510
- if (Mn[w])
509
+ var w = Mi(_);
510
+ if (Rn[w])
511
511
  return;
512
- Mn[w] = !0;
512
+ Rn[w] = !0;
513
513
  var O = "";
514
514
  h && h._owner && h._owner !== St.current && (O = " It was passed a child from " + ne(h._owner.type) + "."), we(h), v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', w, O), we(null);
515
515
  }
516
516
  }
517
- function $n(h, _) {
517
+ function xn(h, _) {
518
518
  {
519
519
  if (typeof h != "object")
520
520
  return;
521
521
  if (vt(h))
522
522
  for (var w = 0; w < h.length; w++) {
523
523
  var O = h[w];
524
- Et(O) && Rn(O, _);
524
+ Et(O) && $n(O, _);
525
525
  }
526
526
  else if (Et(h))
527
527
  h._store && (h._store.validated = !0);
@@ -529,11 +529,11 @@ Check the top-level render call using <` + w + ">.");
529
529
  var C = m(h);
530
530
  if (typeof C == "function" && C !== h.entries)
531
531
  for (var P = C.call(h), j; !(j = P.next()).done; )
532
- Et(j.value) && Rn(j.value, _);
532
+ Et(j.value) && $n(j.value, _);
533
533
  }
534
534
  }
535
535
  }
536
- function Mi(h) {
536
+ function Ri(h) {
537
537
  {
538
538
  var _ = h.type;
539
539
  if (_ == null || typeof _ == "string")
@@ -549,7 +549,7 @@ Check the top-level render call using <` + w + ">.");
549
549
  return;
550
550
  if (w) {
551
551
  var O = ne(_);
552
- gi(w, h.props, "prop", O, h);
552
+ Ti(w, h.props, "prop", O, h);
553
553
  } else if (_.PropTypes !== void 0 && !Ot) {
554
554
  Ot = !0;
555
555
  var C = ne(_);
@@ -558,7 +558,7 @@ Check the top-level render call using <` + w + ">.");
558
558
  typeof _.getDefaultProps == "function" && !_.getDefaultProps.isReactClassApproved && v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
559
559
  }
560
560
  }
561
- function Ri(h) {
561
+ function $i(h) {
562
562
  {
563
563
  for (var _ = Object.keys(h.props), w = 0; w < _.length; w++) {
564
564
  var O = _[w];
@@ -570,19 +570,19 @@ Check the top-level render call using <` + w + ">.");
570
570
  h.ref !== null && (we(h), v("Invalid attribute `ref` supplied to `React.Fragment`."), we(null));
571
571
  }
572
572
  }
573
- var xn = {};
574
- function Dn(h, _, w, O, C, P) {
573
+ var Dn = {};
574
+ function Un(h, _, w, O, C, P) {
575
575
  {
576
576
  var j = _t(h);
577
577
  if (!j) {
578
578
  var E = "";
579
579
  (h === void 0 || typeof h == "object" && h !== null && Object.keys(h).length === 0) && (E += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
580
- var z = Pi();
581
- z ? E += z : E += In();
580
+ var z = Ii();
581
+ z ? E += z : E += Mn();
582
582
  var $;
583
583
  h === null ? $ = "null" : vt(h) ? $ = "array" : h !== void 0 && h.$$typeof === n ? ($ = "<" + (ne(h.type) || "Unknown") + " />", E = " Did you accidentally export a JSX literal instead of a component?") : $ = typeof h, v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", $, E);
584
584
  }
585
- var D = Ci(h, _, w, C, P);
585
+ var D = Pi(h, _, w, C, P);
586
586
  if (D == null)
587
587
  return D;
588
588
  if (j) {
@@ -591,43 +591,43 @@ Check the top-level render call using <` + w + ">.");
591
591
  if (O)
592
592
  if (vt(J)) {
593
593
  for (var ve = 0; ve < J.length; ve++)
594
- $n(J[ve], h);
594
+ xn(J[ve], h);
595
595
  Object.freeze && Object.freeze(J);
596
596
  } else
597
597
  v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
598
598
  else
599
- $n(J, h);
599
+ xn(J, h);
600
600
  }
601
601
  if (Re.call(_, "key")) {
602
- var he = ne(h), W = Object.keys(_).filter(function(Fi) {
603
- return Fi !== "key";
602
+ var he = ne(h), W = Object.keys(_).filter(function(Ni) {
603
+ return Ni !== "key";
604
604
  }), At = W.length > 0 ? "{key: someKey, " + W.join(": ..., ") + ": ...}" : "{key: someKey}";
605
- if (!xn[he + At]) {
606
- var Li = W.length > 0 ? "{" + W.join(": ..., ") + ": ...}" : "{}";
605
+ if (!Dn[he + At]) {
606
+ var Fi = W.length > 0 ? "{" + W.join(": ..., ") + ": ...}" : "{}";
607
607
  v(`A props object containing a "key" prop is being spread into JSX:
608
608
  let props = %s;
609
609
  <%s {...props} />
610
610
  React keys must be passed directly to JSX without using spread:
611
611
  let props = %s;
612
- <%s key={someKey} {...props} />`, At, he, Li, he), xn[he + At] = !0;
612
+ <%s key={someKey} {...props} />`, At, he, Fi, he), Dn[he + At] = !0;
613
613
  }
614
614
  }
615
- return h === i ? Ri(D) : Mi(D), D;
615
+ return h === i ? $i(D) : Ri(D), D;
616
616
  }
617
617
  }
618
- function $i(h, _, w) {
619
- return Dn(h, _, w, !0);
620
- }
621
618
  function xi(h, _, w) {
622
- return Dn(h, _, w, !1);
619
+ return Un(h, _, w, !0);
620
+ }
621
+ function Di(h, _, w) {
622
+ return Un(h, _, w, !1);
623
623
  }
624
- var Di = xi, Ui = $i;
625
- xe.Fragment = i, xe.jsx = Di, xe.jsxs = Ui;
624
+ var Ui = Di, Li = xi;
625
+ xe.Fragment = i, xe.jsx = Ui, xe.jsxs = Li;
626
626
  }(), xe;
627
627
  }
628
- var qi = {};
629
- qi.NODE_ENV === "production" ? $t.exports = Ni() : $t.exports = Ki();
630
- var et = $t.exports;
628
+ var zi = {};
629
+ zi.NODE_ENV === "production" ? xt.exports = Ki() : xt.exports = qi();
630
+ var et = xt.exports;
631
631
  function N(t) {
632
632
  if (typeof t == "number")
633
633
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
@@ -670,14 +670,14 @@ const x = {
670
670
  Remove: "remove",
671
671
  Replace: "replace",
672
672
  Add: "add"
673
- }, Er = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), zi = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), st = Symbol.iterator, Y = {
673
+ }, Ar = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Vi = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), st = Symbol.iterator, Y = {
674
674
  mutable: "mutable",
675
675
  immutable: "immutable"
676
- }, Xt = {};
676
+ }, en = {};
677
677
  function Ne(t, e) {
678
678
  return t instanceof Map ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
679
679
  }
680
- function Fn(t, e) {
680
+ function Nn(t, e) {
681
681
  if (e in t) {
682
682
  let n = Reflect.getPrototypeOf(t);
683
683
  for (; n; ) {
@@ -688,10 +688,10 @@ function Fn(t, e) {
688
688
  }
689
689
  }
690
690
  }
691
- function en(t) {
691
+ function tn(t) {
692
692
  return Object.getPrototypeOf(t) === Set.prototype;
693
693
  }
694
- function tn(t) {
694
+ function nn(t) {
695
695
  return Object.getPrototypeOf(t) === Map.prototype;
696
696
  }
697
697
  function H(t) {
@@ -702,9 +702,9 @@ function Te(t) {
702
702
  return !!A(t);
703
703
  }
704
704
  function A(t) {
705
- return typeof t != "object" ? null : t == null ? void 0 : t[Er];
705
+ return typeof t != "object" ? null : t == null ? void 0 : t[Ar];
706
706
  }
707
- function nn(t) {
707
+ function rn(t) {
708
708
  var e;
709
709
  const n = A(t);
710
710
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
@@ -715,7 +715,7 @@ function ee(t, e) {
715
715
  let n;
716
716
  return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, Y)) === Y.immutable || typeof n == "function");
717
717
  }
718
- function Ar(t, e = []) {
718
+ function jr(t, e = []) {
719
719
  if (Object.hasOwnProperty.call(t, "key")) {
720
720
  const n = t.parent.copy, r = A(ce(n, t.key));
721
721
  if (r !== null && (r == null ? void 0 : r.original) !== t.original)
@@ -726,10 +726,10 @@ function Ar(t, e = []) {
726
726
  e.push(s);
727
727
  }
728
728
  if (t.parent)
729
- return Ar(t.parent, e);
729
+ return jr(t.parent, e);
730
730
  e.reverse();
731
731
  try {
732
- Vi(t.copy, e);
732
+ Wi(t.copy, e);
733
733
  } catch {
734
734
  return null;
735
735
  }
@@ -751,7 +751,7 @@ function jt(t, e) {
751
751
  function ae(t, e) {
752
752
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
753
753
  }
754
- function xt(t) {
754
+ function Dt(t) {
755
755
  if (t)
756
756
  for (; t.finalities.revoke.length > 0; )
757
757
  t.finalities.revoke.pop()();
@@ -762,7 +762,7 @@ function be(t, e) {
762
762
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
763
763
  }).join("/");
764
764
  }
765
- function Vi(t, e) {
765
+ function Wi(t, e) {
766
766
  for (let n = 0; n < e.length - 1; n += 1) {
767
767
  const r = e[n];
768
768
  if (t = ce(me(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
@@ -770,7 +770,7 @@ function Vi(t, e) {
770
770
  }
771
771
  return t;
772
772
  }
773
- function Wi(t) {
773
+ function Bi(t) {
774
774
  const e = Object.create(Object.getPrototypeOf(t));
775
775
  return Reflect.ownKeys(t).forEach((n) => {
776
776
  let r = Reflect.getOwnPropertyDescriptor(t, n);
@@ -786,26 +786,26 @@ function Wi(t) {
786
786
  }), Reflect.defineProperty(e, n, r);
787
787
  }), e;
788
788
  }
789
- const Bi = Object.prototype.propertyIsEnumerable;
790
- function jr(t, e) {
789
+ const Gi = Object.prototype.propertyIsEnumerable;
790
+ function kr(t, e) {
791
791
  let n;
792
792
  if (Array.isArray(t))
793
793
  return Array.prototype.concat.call(t);
794
794
  if (t instanceof Set) {
795
- if (!en(t)) {
795
+ if (!tn(t)) {
796
796
  const r = Object.getPrototypeOf(t).constructor;
797
797
  return new r(t.values());
798
798
  }
799
799
  return Set.prototype.difference ? Set.prototype.difference.call(t, /* @__PURE__ */ new Set()) : new Set(t.values());
800
800
  } else if (t instanceof Map) {
801
- if (!tn(t)) {
801
+ if (!nn(t)) {
802
802
  const r = Object.getPrototypeOf(t).constructor;
803
803
  return new r(t);
804
804
  }
805
805
  return new Map(t);
806
806
  } else if (e != null && e.mark && (n = e.mark(t, Y), n !== void 0) && n !== Y.mutable) {
807
807
  if (n === Y.immutable)
808
- return Wi(t);
808
+ return Bi(t);
809
809
  if (typeof n == "function") {
810
810
  if (e.enablePatches || e.enableAutoFreeze)
811
811
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -817,17 +817,17 @@ function jr(t, e) {
817
817
  return Object.keys(t).forEach((i) => {
818
818
  r[i] = t[i];
819
819
  }), Object.getOwnPropertySymbols(t).forEach((i) => {
820
- Bi.call(t, i) && (r[i] = t[i]);
820
+ Gi.call(t, i) && (r[i] = t[i]);
821
821
  }), r;
822
822
  } else
823
823
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
824
824
  }
825
825
  function V(t) {
826
- t.copy || (t.copy = jr(t.original, t.options));
826
+ t.copy || (t.copy = kr(t.original, t.options));
827
827
  }
828
828
  function Ue(t) {
829
829
  if (!ee(t))
830
- return nn(t);
830
+ return rn(t);
831
831
  if (Array.isArray(t))
832
832
  return t.map(Ue);
833
833
  if (t instanceof Map) {
@@ -835,7 +835,7 @@ function Ue(t) {
835
835
  r,
836
836
  Ue(i)
837
837
  ]);
838
- if (!tn(t)) {
838
+ if (!nn(t)) {
839
839
  const r = Object.getPrototypeOf(t).constructor;
840
840
  return new r(n);
841
841
  }
@@ -843,7 +843,7 @@ function Ue(t) {
843
843
  }
844
844
  if (t instanceof Set) {
845
845
  const n = Array.from(t).map(Ue);
846
- if (!en(t)) {
846
+ if (!tn(t)) {
847
847
  const r = Object.getPrototypeOf(t).constructor;
848
848
  return new r(n);
849
849
  }
@@ -861,7 +861,7 @@ function ie(t) {
861
861
  var e;
862
862
  t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent && ie(t.parent));
863
863
  }
864
- function Nn() {
864
+ function Kn() {
865
865
  throw new Error("Cannot modify frozen object");
866
866
  }
867
867
  function Se(t, e, n, r, i) {
@@ -889,12 +889,12 @@ function Se(t, e, n, r, i) {
889
889
  case 2:
890
890
  for (const [u, a] of t)
891
891
  Se(u, u, n, r, i), Se(a, u, n, r, i);
892
- t.set = t.clear = t.delete = Nn;
892
+ t.set = t.clear = t.delete = Kn;
893
893
  break;
894
894
  case 3:
895
895
  for (const u of t)
896
896
  Se(u, u, n, r, i);
897
- t.add = t.clear = t.delete = Nn;
897
+ t.add = t.clear = t.delete = Kn;
898
898
  break;
899
899
  case 1:
900
900
  Object.freeze(t);
@@ -910,7 +910,7 @@ function Se(t, e, n, r, i) {
910
910
  }
911
911
  r.pop(), i.pop();
912
912
  }
913
- function rn(t, e) {
913
+ function sn(t, e) {
914
914
  const n = me(t);
915
915
  if (n === 0)
916
916
  Reflect.ownKeys(t).forEach((r) => {
@@ -923,11 +923,11 @@ function rn(t, e) {
923
923
  } else
924
924
  t.forEach((r, i) => e(i, r, t));
925
925
  }
926
- function kr(t, e, n) {
926
+ function Cr(t, e, n) {
927
927
  if (Te(t) || !ee(t, n) || e.has(t) || Object.isFrozen(t))
928
928
  return;
929
929
  const r = t instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
930
- if (e.add(t), rn(t, (s, o) => {
930
+ if (e.add(t), sn(t, (s, o) => {
931
931
  var u;
932
932
  if (Te(o)) {
933
933
  const a = A(o);
@@ -935,7 +935,7 @@ function kr(t, e, n) {
935
935
  const d = !((u = a.assignedMap) === null || u === void 0) && u.size || a.operated ? a.copy : a.original;
936
936
  We(r ? i : t, s, d);
937
937
  } else
938
- kr(o, e, n);
938
+ Cr(o, e, n);
939
939
  }), i) {
940
940
  const s = t, o = Array.from(s);
941
941
  s.clear(), o.forEach((u) => {
@@ -943,39 +943,39 @@ function kr(t, e, n) {
943
943
  });
944
944
  }
945
945
  }
946
- function Gi(t, e) {
946
+ function Qi(t, e) {
947
947
  const n = t.type === 3 ? t.setMap : t.copy;
948
- t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && kr(ce(n, e), t.finalities.handledSet, t.options);
948
+ t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && Cr(ce(n, e), t.finalities.handledSet, t.options);
949
949
  }
950
- function Dt(t) {
950
+ function Ut(t) {
951
951
  t.type === 3 && t.copy && (t.copy.clear(), t.setMap.forEach((e) => {
952
- t.copy.add(nn(e));
952
+ t.copy.add(rn(e));
953
953
  }));
954
954
  }
955
- function Ut(t, e, n, r) {
955
+ function Lt(t, e, n, r) {
956
956
  if (t.operated && t.assignedMap && t.assignedMap.size > 0 && !t.finalized) {
957
957
  if (n && r) {
958
- const s = Ar(t);
958
+ const s = jr(t);
959
959
  s && e(t, s, n, r);
960
960
  }
961
961
  t.finalized = !0;
962
962
  }
963
963
  }
964
- function sn(t, e, n, r) {
964
+ function on(t, e, n, r) {
965
965
  const i = A(n);
966
966
  i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
967
967
  var u;
968
968
  const a = t.type === 3 ? t.setMap : t.copy;
969
969
  if (ae(ce(a, e), n)) {
970
970
  let d = i.original;
971
- i.copy && (d = i.copy), Dt(t), Ut(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (u = t.options.updatedValues) !== null && u !== void 0 ? u : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), We(a, e, d);
971
+ i.copy && (d = i.copy), Ut(t), Lt(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (u = t.options.updatedValues) !== null && u !== void 0 ? u : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), We(a, e, d);
972
972
  }
973
973
  }), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ee(n, t.options) && t.finalities.draft.push(() => {
974
974
  const s = t.type === 3 ? t.setMap : t.copy;
975
- ae(ce(s, e), n) && Gi(t, e);
975
+ ae(ce(s, e), n) && Qi(t, e);
976
976
  });
977
977
  }
978
- function Qi(t, e, n, r, i) {
978
+ function Hi(t, e, n, r, i) {
979
979
  let { original: s, assignedMap: o, options: u } = t, a = t.copy;
980
980
  a.length < s.length && ([s, a] = [a, s], [n, r] = [r, n]);
981
981
  for (let d = 0; d < s.length; d += 1)
@@ -1021,7 +1021,7 @@ function Qi(t, e, n, r, i) {
1021
1021
  }
1022
1022
  }
1023
1023
  }
1024
- function Hi({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
1024
+ function Yi({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
1025
1025
  n.forEach((u, a) => {
1026
1026
  const d = ce(t, a), c = ot(ce(e, a)), f = u ? Ne(t, a) ? x.Replace : x.Add : x.Remove;
1027
1027
  if (ae(d, c) && f === x.Replace)
@@ -1030,7 +1030,7 @@ function Hi({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
1030
1030
  i.push(f === x.Remove ? { op: f, path: p } : { op: f, path: p, value: c }), s.push(f === x.Add ? { op: x.Remove, path: p } : f === x.Remove ? { op: x.Add, path: p, value: d } : { op: x.Replace, path: p, value: d });
1031
1031
  });
1032
1032
  }
1033
- function Yi({ original: t, copy: e }, n, r, i, s) {
1033
+ function Ji({ original: t, copy: e }, n, r, i, s) {
1034
1034
  let o = 0;
1035
1035
  t.forEach((u) => {
1036
1036
  if (!e.has(u)) {
@@ -1067,17 +1067,17 @@ function Ve(t, e, n, r) {
1067
1067
  switch (t.type) {
1068
1068
  case 0:
1069
1069
  case 2:
1070
- return Hi(t, e, n, r, i);
1070
+ return Yi(t, e, n, r, i);
1071
1071
  case 1:
1072
- return Qi(t, e, n, r, i);
1072
+ return Hi(t, e, n, r, i);
1073
1073
  case 3:
1074
- return Yi(t, e, n, r, i);
1074
+ return Ji(t, e, n, r, i);
1075
1075
  }
1076
1076
  }
1077
1077
  const ct = (t, e, n = !1) => {
1078
1078
  if (typeof t == "object" && t !== null && (!ee(t, e) || n))
1079
1079
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
1080
- }, Lt = {
1080
+ }, Ft = {
1081
1081
  get size() {
1082
1082
  return H(A(this)).size;
1083
1083
  },
@@ -1086,7 +1086,7 @@ const ct = (t, e, n = !1) => {
1086
1086
  },
1087
1087
  set(t, e) {
1088
1088
  const n = A(this), r = H(n);
1089
- return (!r.has(t) || !ae(r.get(t), e)) && (V(n), ie(n), n.assignedMap.set(t, !0), n.copy.set(t, e), sn(n, t, e, Ve)), this;
1089
+ return (!r.has(t) || !ae(r.get(t), e)) && (V(n), ie(n), n.assignedMap.set(t, !0), n.copy.set(t, e), on(n, t, e, Ve)), this;
1090
1090
  },
1091
1091
  delete(t) {
1092
1092
  if (!this.has(t))
@@ -1114,7 +1114,7 @@ const ct = (t, e, n = !1) => {
1114
1114
  const r = A(this), i = H(r).get(t), s = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, i, Y)) === Y.mutable;
1115
1115
  if (r.options.strict && ct(i, r.options, s), s || r.finalized || !ee(i, r.options) || i !== r.original.get(t))
1116
1116
  return i;
1117
- const o = Xt.createDraft({
1117
+ const o = en.createDraft({
1118
1118
  original: i,
1119
1119
  parentDraft: r,
1120
1120
  key: t,
@@ -1158,7 +1158,7 @@ const ct = (t, e, n = !1) => {
1158
1158
  [st]() {
1159
1159
  return this.entries();
1160
1160
  }
1161
- }, Ji = Reflect.ownKeys(Lt), Kn = (t, e, { isValuesIterator: n }) => () => {
1161
+ }, Zi = Reflect.ownKeys(Ft), qn = (t, e, { isValuesIterator: n }) => () => {
1162
1162
  var r, i;
1163
1163
  const s = e.next();
1164
1164
  if (s.done)
@@ -1167,7 +1167,7 @@ const ct = (t, e, n = !1) => {
1167
1167
  let u = t.setMap.get(o);
1168
1168
  const a = A(u), d = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, u, Y)) === Y.mutable;
1169
1169
  if (t.options.strict && ct(o, t.options, d), !d && !a && ee(o, t.options) && !t.finalized && t.original.has(o)) {
1170
- const c = Xt.createDraft({
1170
+ const c = en.createDraft({
1171
1171
  original: o,
1172
1172
  parentDraft: t,
1173
1173
  key: o,
@@ -1194,7 +1194,7 @@ const ct = (t, e, n = !1) => {
1194
1194
  },
1195
1195
  add(t) {
1196
1196
  const e = A(this);
1197
- return this.has(t) || (V(e), ie(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), sn(e, t, t, Ve)), this;
1197
+ return this.has(t) || (V(e), ie(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), on(e, t, t, Ve)), this;
1198
1198
  },
1199
1199
  delete(t) {
1200
1200
  if (!this.has(t))
@@ -1219,7 +1219,7 @@ const ct = (t, e, n = !1) => {
1219
1219
  const e = t.setMap.keys();
1220
1220
  return {
1221
1221
  [Symbol.iterator]: () => this.values(),
1222
- next: Kn(t, e, { isValuesIterator: !0 })
1222
+ next: qn(t, e, { isValuesIterator: !0 })
1223
1223
  };
1224
1224
  },
1225
1225
  entries() {
@@ -1228,7 +1228,7 @@ const ct = (t, e, n = !1) => {
1228
1228
  const e = t.setMap.keys();
1229
1229
  return {
1230
1230
  [Symbol.iterator]: () => this.entries(),
1231
- next: Kn(t, e, {
1231
+ next: qn(t, e, {
1232
1232
  isValuesIterator: !1
1233
1233
  })
1234
1234
  };
@@ -1269,13 +1269,13 @@ Set.prototype.difference && Object.assign(dt, {
1269
1269
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
1270
1270
  }
1271
1271
  });
1272
- const Zi = Reflect.ownKeys(dt), Cr = /* @__PURE__ */ new WeakSet(), Pr = {
1272
+ const Xi = Reflect.ownKeys(dt), Pr = /* @__PURE__ */ new WeakSet(), Ir = {
1273
1273
  get(t, e, n) {
1274
1274
  var r, i;
1275
1275
  const s = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
1276
- if (s && Cr.has(s))
1276
+ if (s && Pr.has(s))
1277
1277
  return s;
1278
- if (e === Er)
1278
+ if (e === Ar)
1279
1279
  return t;
1280
1280
  let o;
1281
1281
  if (t.options.mark) {
@@ -1284,14 +1284,14 @@ const Zi = Reflect.ownKeys(dt), Cr = /* @__PURE__ */ new WeakSet(), Pr = {
1284
1284
  return t.options.strict && ct(d, t.options, !0), d;
1285
1285
  }
1286
1286
  const u = H(t);
1287
- if (u instanceof Map && Ji.includes(e)) {
1287
+ if (u instanceof Map && Zi.includes(e)) {
1288
1288
  if (e === "size")
1289
- return Object.getOwnPropertyDescriptor(Lt, "size").get.call(t.proxy);
1290
- const d = Lt[e];
1289
+ return Object.getOwnPropertyDescriptor(Ft, "size").get.call(t.proxy);
1290
+ const d = Ft[e];
1291
1291
  if (d)
1292
1292
  return d.bind(t.proxy);
1293
1293
  }
1294
- if (u instanceof Set && Zi.includes(e)) {
1294
+ if (u instanceof Set && Xi.includes(e)) {
1295
1295
  if (e === "size")
1296
1296
  return Object.getOwnPropertyDescriptor(dt, "size").get.call(t.proxy);
1297
1297
  const d = dt[e];
@@ -1299,7 +1299,7 @@ const Zi = Reflect.ownKeys(dt), Cr = /* @__PURE__ */ new WeakSet(), Pr = {
1299
1299
  return d.bind(t.proxy);
1300
1300
  }
1301
1301
  if (!Ne(u, e)) {
1302
- const d = Fn(u, e);
1302
+ const d = Nn(u, e);
1303
1303
  return d ? "value" in d ? d.value : (
1304
1304
  // !case: support for getter
1305
1305
  (i = d.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
@@ -1309,7 +1309,7 @@ const Zi = Reflect.ownKeys(dt), Cr = /* @__PURE__ */ new WeakSet(), Pr = {
1309
1309
  if (t.options.strict && ct(a, t.options), t.finalized || !ee(a, t.options))
1310
1310
  return a;
1311
1311
  if (a === jt(t.original, e)) {
1312
- if (V(t), t.copy[e] = on({
1312
+ if (V(t), t.copy[e] = un({
1313
1313
  original: t.original[e],
1314
1314
  parentDraft: t,
1315
1315
  key: t.type === 1 ? Number(e) : e,
@@ -1330,11 +1330,11 @@ const Zi = Reflect.ownKeys(dt), Cr = /* @__PURE__ */ new WeakSet(), Pr = {
1330
1330
  let i;
1331
1331
  if (t.type === 1 && e !== "length" && !(Number.isInteger(i = Number(e)) && i >= 0 && (e === 0 || i === 0 || String(i) === String(e))))
1332
1332
  throw new Error("Only supports setting array indices and the 'length' property.");
1333
- const s = Fn(H(t), e);
1333
+ const s = Nn(H(t), e);
1334
1334
  if (s != null && s.set)
1335
1335
  return s.set.call(t.proxy, n), !0;
1336
1336
  const o = jt(H(t), e), u = A(o);
1337
- return u && ae(u.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (ae(n, o) && (n !== void 0 || Ne(t.original, e)) || (V(t), ie(t), Ne(t.original, e) && ae(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, sn(t, e, n, Ve)), !0);
1337
+ return u && ae(u.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (ae(n, o) && (n !== void 0 || Ne(t.original, e)) || (V(t), ie(t), Ne(t.original, e) && ae(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, on(t, e, n, Ve)), !0);
1338
1338
  },
1339
1339
  has(t, e) {
1340
1340
  return e in H(t);
@@ -1362,10 +1362,10 @@ const Zi = Reflect.ownKeys(dt), Cr = /* @__PURE__ */ new WeakSet(), Pr = {
1362
1362
  },
1363
1363
  deleteProperty(t, e) {
1364
1364
  var n;
1365
- return t.type === 1 ? Pr.set.call(this, t, e, void 0, t.proxy) : (jt(t.original, e) !== void 0 || e in t.original ? (V(t), ie(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
1365
+ return t.type === 1 ? Ir.set.call(this, t, e, void 0, t.proxy) : (jt(t.original, e) !== void 0 || e in t.original ? (V(t), ie(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
1366
1366
  }
1367
1367
  };
1368
- function on(t) {
1368
+ function un(t) {
1369
1369
  const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = me(e), u = {
1370
1370
  type: o,
1371
1371
  finalized: !1,
@@ -1379,8 +1379,8 @@ function on(t) {
1379
1379
  setMap: o === 3 ? new Map(e.entries()) : void 0
1380
1380
  };
1381
1381
  (r || "key" in t) && (u.key = r);
1382
- const { proxy: a, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, Pr);
1383
- if (i.revoke.push(d), Cr.add(a), u.proxy = a, n) {
1382
+ const { proxy: a, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, Ir);
1383
+ if (i.revoke.push(d), Pr.add(a), u.proxy = a, n) {
1384
1384
  const c = n;
1385
1385
  c.finalities.draft.push((f, l) => {
1386
1386
  var p, y;
@@ -1389,7 +1389,7 @@ function on(t) {
1389
1389
  const m = ce(g, r), T = A(m);
1390
1390
  if (T) {
1391
1391
  let v = T.original;
1392
- T.operated && (v = nn(m)), Dt(T), Ut(T, Ve, f, l), c.options.enableAutoFreeze && (c.options.updatedValues = (p = c.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(v, T.original)), We(g, r, v);
1392
+ T.operated && (v = rn(m)), Ut(T), Lt(T, Ve, f, l), c.options.enableAutoFreeze && (c.options.updatedValues = (p = c.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(v, T.original)), We(g, r, v);
1393
1393
  }
1394
1394
  (y = b.callbacks) === null || y === void 0 || y.forEach((v) => {
1395
1395
  v(f, l);
@@ -1398,26 +1398,26 @@ function on(t) {
1398
1398
  } else {
1399
1399
  const c = A(a);
1400
1400
  c.finalities.draft.push((f, l) => {
1401
- Dt(c), Ut(c, Ve, f, l);
1401
+ Ut(c), Lt(c, Ve, f, l);
1402
1402
  });
1403
1403
  }
1404
1404
  return a;
1405
1405
  }
1406
- Xt.createDraft = on;
1407
- function Xi(t, e, n, r, i) {
1406
+ en.createDraft = un;
1407
+ function es(t, e, n, r, i) {
1408
1408
  var s;
1409
1409
  const o = A(t), u = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, a = !!e.length;
1410
1410
  if (o != null && o.operated)
1411
1411
  for (; o.finalities.draft.length > 0; )
1412
1412
  o.finalities.draft.pop()(n, r);
1413
1413
  const d = a ? e[0] : o ? o.operated ? o.copy : o.original : t;
1414
- return o && xt(o), i && Se(d, d, o == null ? void 0 : o.options.updatedValues), [
1414
+ return o && Dt(o), i && Se(d, d, o == null ? void 0 : o.options.updatedValues), [
1415
1415
  d,
1416
1416
  n && a ? [{ op: x.Replace, path: [], value: e[0] }] : n,
1417
1417
  r && a ? [{ op: x.Replace, path: [], value: u }] : r
1418
1418
  ];
1419
1419
  }
1420
- function es(t, e) {
1420
+ function ts(t, e) {
1421
1421
  var n;
1422
1422
  const r = {
1423
1423
  draft: [],
@@ -1426,7 +1426,7 @@ function es(t, e) {
1426
1426
  };
1427
1427
  let i, s;
1428
1428
  e.enablePatches && (i = [], s = []);
1429
- const u = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, Y)) === Y.mutable || !ee(t, e) ? t : on({
1429
+ const u = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, Y)) === Y.mutable || !ee(t, e) ? t : un({
1430
1430
  original: t,
1431
1431
  parentDraft: null,
1432
1432
  finalities: r,
@@ -1435,14 +1435,14 @@ function es(t, e) {
1435
1435
  return [
1436
1436
  u,
1437
1437
  (a = []) => {
1438
- const [d, c, f] = Xi(u, a, i, s, e.enableAutoFreeze);
1438
+ const [d, c, f] = es(u, a, i, s, e.enableAutoFreeze);
1439
1439
  return e.enablePatches ? [d, c, f] : d;
1440
1440
  }
1441
1441
  ];
1442
1442
  }
1443
- function Ft(t) {
1443
+ function Nt(t) {
1444
1444
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: i = !0 } = t;
1445
- rn(n, (s, o, u) => {
1445
+ sn(n, (s, o, u) => {
1446
1446
  const a = A(o);
1447
1447
  if (a && e && a.finalities === e.finalities) {
1448
1448
  t.isContainDraft = !0;
@@ -1452,10 +1452,10 @@ function Ft(t) {
1452
1452
  u.clear(), c.forEach((f) => u.add(s === f ? d : f));
1453
1453
  } else
1454
1454
  We(u, s, d);
1455
- } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, Ft(t));
1455
+ } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, Nt(t));
1456
1456
  }), i && (t.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."));
1457
1457
  }
1458
- function Ir(t) {
1458
+ function Mr(t) {
1459
1459
  var e;
1460
1460
  const n = A(t);
1461
1461
  if (!ee(t, n == null ? void 0 : n.options))
@@ -1465,7 +1465,7 @@ function Ir(t) {
1465
1465
  return n.original;
1466
1466
  let i;
1467
1467
  function s() {
1468
- i = r === 2 ? tn(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : jr(t, n == null ? void 0 : n.options);
1468
+ i = r === 2 ? nn(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : kr(t, n == null ? void 0 : n.options);
1469
1469
  }
1470
1470
  if (n) {
1471
1471
  n.finalized = !0;
@@ -1476,23 +1476,23 @@ function Ir(t) {
1476
1476
  }
1477
1477
  } else
1478
1478
  i = t;
1479
- if (rn(i, (o, u) => {
1479
+ if (sn(i, (o, u) => {
1480
1480
  if (n && ae(ce(n.original, o), u))
1481
1481
  return;
1482
- const a = Ir(u);
1482
+ const a = Mr(u);
1483
1483
  a !== u && (i === t && s(), We(i, o, a));
1484
1484
  }), r === 3) {
1485
1485
  const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : i;
1486
- return en(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
1486
+ return tn(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
1487
1487
  }
1488
1488
  return i;
1489
1489
  }
1490
- function qn(t) {
1490
+ function zn(t) {
1491
1491
  if (!Te(t))
1492
1492
  throw new Error(`current() is only used for Draft, parameter: ${t}`);
1493
- return Ir(t);
1493
+ return Mr(t);
1494
1494
  }
1495
- const ts = (t) => function e(n, r, i) {
1495
+ const ns = (t) => function e(n, r, i) {
1496
1496
  var s, o, u;
1497
1497
  if (typeof n == "function" && typeof r != "function")
1498
1498
  return function(S, ...I) {
@@ -1503,7 +1503,7 @@ const ts = (t) => function e(n, r, i) {
1503
1503
  if (typeof r != "function" && (c = r), c !== void 0 && Object.prototype.toString.call(c) !== "[object Object]")
1504
1504
  throw new Error(`Invalid options: ${c}, 'options' should be an object.`);
1505
1505
  c = Object.assign(Object.assign({}, t), c);
1506
- const f = Te(a) ? qn(a) : a, l = Array.isArray(c.mark) ? (S, I) => {
1506
+ const f = Te(a) ? zn(a) : a, l = Array.isArray(c.mark) ? (S, I) => {
1507
1507
  for (const R of c.mark) {
1508
1508
  if (typeof R != "function")
1509
1509
  throw new Error(`Invalid mark: ${R}, 'mark' should be a function.`);
@@ -1519,7 +1519,7 @@ const ts = (t) => function e(n, r, i) {
1519
1519
  };
1520
1520
  if (!ee(f, g) && typeof f == "object" && f !== null)
1521
1521
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
1522
- const [m, T] = es(f, g);
1522
+ const [m, T] = ts(f, g);
1523
1523
  if (typeof r != "function") {
1524
1524
  if (!ee(f, g))
1525
1525
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
@@ -1529,24 +1529,24 @@ const ts = (t) => function e(n, r, i) {
1529
1529
  try {
1530
1530
  v = d(m);
1531
1531
  } catch (S) {
1532
- throw xt(A(m)), S;
1532
+ throw Dt(A(m)), S;
1533
1533
  }
1534
1534
  const k = (S) => {
1535
1535
  const I = A(m);
1536
1536
  if (!Te(S)) {
1537
1537
  if (S !== void 0 && !ae(S, m) && (I != null && I.operated))
1538
1538
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
1539
- const q = S == null ? void 0 : S[zi];
1539
+ const q = S == null ? void 0 : S[Vi];
1540
1540
  if (q) {
1541
1541
  const Ie = q[0];
1542
- return g.strict && typeof S == "object" && S !== null && Ft({
1542
+ return g.strict && typeof S == "object" && S !== null && Nt({
1543
1543
  rootDraft: I,
1544
1544
  value: S,
1545
1545
  useRawReturn: !0
1546
1546
  }), T([Ie]);
1547
1547
  }
1548
1548
  if (S !== void 0)
1549
- return typeof S == "object" && S !== null && Ft({ rootDraft: I, value: S }), T([S]);
1549
+ return typeof S == "object" && S !== null && Nt({ rootDraft: I, value: S }), T([S]);
1550
1550
  }
1551
1551
  if (S === m || S === void 0)
1552
1552
  return T([]);
@@ -1554,26 +1554,26 @@ const ts = (t) => function e(n, r, i) {
1554
1554
  if (g === R.options) {
1555
1555
  if (R.operated)
1556
1556
  throw new Error("Cannot return a modified child draft.");
1557
- return T([qn(S)]);
1557
+ return T([zn(S)]);
1558
1558
  }
1559
1559
  return T([S]);
1560
1560
  };
1561
1561
  return v instanceof Promise ? v.then(k, (S) => {
1562
- throw xt(A(m)), S;
1562
+ throw Dt(A(m)), S;
1563
1563
  }) : k(v);
1564
- }, ft = ts();
1564
+ }, ft = ns();
1565
1565
  Object.prototype.constructor.toString();
1566
- function Mr(t, e) {
1566
+ function Rr(t, e) {
1567
1567
  const n = Object.keys(t), r = Object.keys(e);
1568
1568
  return n.length === r.length && Object.keys(t).every((i) => e.hasOwnProperty(i));
1569
1569
  }
1570
- function zn(t, e) {
1570
+ function Vn(t, e) {
1571
1571
  return Object.keys(t).length === Object.keys(e).length && Object.keys(t).every((n) => e.hasOwnProperty(n) && t[n] === e[n]);
1572
1572
  }
1573
1573
  function ut(t, e) {
1574
- return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : Mr(t, e) ? Object.keys(t).every((n) => ut(t[n], e[n])) : !1;
1574
+ return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : Rr(t, e) ? Object.keys(t).every((n) => ut(t[n], e[n])) : !1;
1575
1575
  }
1576
- function un(t) {
1576
+ function an(t) {
1577
1577
  if (!Le(t))
1578
1578
  return t;
1579
1579
  const e = {};
@@ -1581,7 +1581,7 @@ function un(t) {
1581
1581
  r !== void 0 && (e[n] = r);
1582
1582
  return e;
1583
1583
  }
1584
- function Rr(t, e) {
1584
+ function $r(t, e) {
1585
1585
  if (!Le(t) || !Le(e))
1586
1586
  return e;
1587
1587
  const n = Object.assign({}, t);
@@ -1593,14 +1593,14 @@ function Rr(t, e) {
1593
1593
  continue;
1594
1594
  }
1595
1595
  const i = Le(t[r]) && Le(e[r]);
1596
- n[r] = i ? Rr(t[r], e[r]) : e[r];
1596
+ n[r] = i ? $r(t[r], e[r]) : e[r];
1597
1597
  }
1598
1598
  return n;
1599
1599
  }
1600
1600
  function Le(t) {
1601
1601
  return typeof t == "object" && t !== null && !Array.isArray(t);
1602
1602
  }
1603
- function ns(t, e, n) {
1603
+ function rs(t, e, n) {
1604
1604
  if (!t || e.length === 0)
1605
1605
  return;
1606
1606
  let r = t || {};
@@ -1611,7 +1611,7 @@ function ns(t, e, n) {
1611
1611
  const i = e[e.length - 1];
1612
1612
  Array.isArray(r) && typeof i == "number" ? r.splice(i, 0, n) : r[i] = n;
1613
1613
  }
1614
- function Vn(t, e, n) {
1614
+ function Wn(t, e, n) {
1615
1615
  if (!t || e.length === 0)
1616
1616
  return;
1617
1617
  let r = t || {};
@@ -1621,7 +1621,7 @@ function Vn(t, e, n) {
1621
1621
  }
1622
1622
  r[e[e.length - 1]] = n;
1623
1623
  }
1624
- function $r(t, e) {
1624
+ function xr(t, e) {
1625
1625
  if (!t || e.length === 0)
1626
1626
  return;
1627
1627
  const [n, ...r] = e;
@@ -1630,13 +1630,13 @@ function $r(t, e) {
1630
1630
  Array.isArray(t) ? t.splice(n, 1) : delete t[n];
1631
1631
  return;
1632
1632
  }
1633
- $r(t[n], r), rs(t[n]) && delete t[n];
1633
+ xr(t[n], r), is(t[n]) && delete t[n];
1634
1634
  }
1635
1635
  }
1636
- function rs(t) {
1636
+ function is(t) {
1637
1637
  return t && Object.keys(t).length === 0;
1638
1638
  }
1639
- const Wn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, is = {
1639
+ const Bn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, ss = {
1640
1640
  ZULU: 0,
1641
1641
  YEKT: 18e3,
1642
1642
  YEKST: 21600,
@@ -1832,39 +1832,39 @@ const Wn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
1832
1832
  ACSST: 37800,
1833
1833
  ACDT: 37800
1834
1834
  };
1835
- function ss(t) {
1835
+ function os(t) {
1836
1836
  return new Date(t);
1837
1837
  }
1838
- function os(t) {
1838
+ function us(t) {
1839
1839
  return /* @__PURE__ */ new Date(t + "Z");
1840
1840
  }
1841
- const us = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1842
- function as(t) {
1843
- const e = t.match(us);
1841
+ const as = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1842
+ function cs(t) {
1843
+ const e = t.match(as);
1844
1844
  if (!e)
1845
1845
  return null;
1846
1846
  const [n, r, i, s] = e;
1847
1847
  return r <= 0 || i <= 0 || s <= 0 ? null : r > 999 ? new Date(Date.UTC(r, i - 1, s, 0, 0, 0, 0)) : new Date(Date.UTC(s, r - 1, i, 0, 0, 0, 0));
1848
1848
  }
1849
- function cs(t) {
1849
+ function ds(t) {
1850
1850
  const [e, n] = t.split(" ");
1851
1851
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1852
1852
  }
1853
- function ds(t) {
1853
+ function fs(t) {
1854
1854
  const [e, n] = t.split(" ");
1855
1855
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1856
1856
  }
1857
- function fs(t) {
1857
+ function ls(t) {
1858
1858
  return new Date(t);
1859
1859
  }
1860
- function ls(t) {
1860
+ function hs(t) {
1861
1861
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1862
1862
  if (!t.match(e))
1863
1863
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1864
1864
  const r = /* @__PURE__ */ new Date(t + " UTC");
1865
1865
  return new Date(Date.UTC(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate(), 0, 0, 0, 0));
1866
1866
  }
1867
- function hs(t) {
1867
+ function ps(t) {
1868
1868
  const e = /^(.+T.+)([+-])(\d{2})$/, n = t.match(e);
1869
1869
  if (n) {
1870
1870
  const [, r, i, s] = n, o = `${r}${i}${s}:00`;
@@ -1872,7 +1872,7 @@ function hs(t) {
1872
1872
  }
1873
1873
  return null;
1874
1874
  }
1875
- function ps(t) {
1875
+ function ys(t) {
1876
1876
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
1877
1877
  if (n) {
1878
1878
  const [, r, i, s, o, u] = n, a = i.padStart(2, "0"), d = s.padStart(2, "0"), c = `${r}-${a}-${d}T${u}`;
@@ -1880,14 +1880,14 @@ function ps(t) {
1880
1880
  }
1881
1881
  return null;
1882
1882
  }
1883
- function ys(t) {
1883
+ function bs(t) {
1884
1884
  const [e, n] = t.split(", "), [r, i, s] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1885
1885
  if (!o)
1886
1886
  throw new Error(`Unable to parse time from: ${t}`);
1887
1887
  let [, u, a, d, c] = o;
1888
1888
  return u = Number(u), a = Number(a), d = Number(d), c === "PM" && u !== 12 ? u += 12 : c === "AM" && u === 12 && (u = 0), new Date(Date.UTC(s, r - 1, i, u, a, d));
1889
1889
  }
1890
- function bs(t) {
1890
+ function _s(t) {
1891
1891
  switch (t) {
1892
1892
  case "epoch":
1893
1893
  return /* @__PURE__ */ new Date(0);
@@ -1899,28 +1899,28 @@ function bs(t) {
1899
1899
  return null;
1900
1900
  }
1901
1901
  }
1902
- function _s(t) {
1903
- const e = t.match(Wn);
1902
+ function gs(t) {
1903
+ const e = t.match(Bn);
1904
1904
  if (!e)
1905
1905
  return null;
1906
- const [n] = e, r = is[n], i = new Date(t.replace(Wn, "Z"));
1906
+ const [n] = e, r = ss[n], i = new Date(t.replace(Bn, "Z"));
1907
1907
  return new Date(i.getTime() - r * 1e3);
1908
1908
  }
1909
- const gs = [
1910
- as,
1911
- ds,
1912
- ls,
1913
- ys,
1909
+ const Ts = [
1910
+ cs,
1914
1911
  fs,
1915
- os,
1916
1912
  hs,
1917
- cs,
1918
- ss,
1919
1913
  bs,
1914
+ ls,
1915
+ us,
1916
+ ps,
1917
+ ds,
1918
+ os,
1920
1919
  _s,
1921
- ps
1920
+ gs,
1921
+ ys
1922
1922
  ];
1923
- function Ts(t, e) {
1923
+ function ms(t, e) {
1924
1924
  try {
1925
1925
  const n = t(e);
1926
1926
  return n instanceof Date && !isNaN(n.getTime()) ? n : null;
@@ -1928,18 +1928,18 @@ function Ts(t, e) {
1928
1928
  return null;
1929
1929
  }
1930
1930
  }
1931
- function Nt(t) {
1932
- for (const e of gs) {
1933
- const n = Ts(e, t);
1931
+ function Kt(t) {
1932
+ for (const e of Ts) {
1933
+ const n = ms(e, t);
1934
1934
  if (n)
1935
1935
  return n;
1936
1936
  }
1937
1937
  return null;
1938
1938
  }
1939
- function ms(t) {
1939
+ function ws(t) {
1940
1940
  try {
1941
1941
  const e = JSON.parse(t);
1942
- return typeof e == "string" ? Nt(e) : null;
1942
+ return typeof e == "string" ? Kt(e) : null;
1943
1943
  } catch {
1944
1944
  return null;
1945
1945
  }
@@ -1951,7 +1951,7 @@ function pt(t) {
1951
1951
  if (t instanceof Date)
1952
1952
  return t;
1953
1953
  if (typeof t == "string") {
1954
- const e = Nt(t) || ms(t) || Nt(t.trim());
1954
+ const e = Kt(t) || ws(t) || Kt(t.trim());
1955
1955
  if (!e)
1956
1956
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1957
1957
  return e;
@@ -1960,13 +1960,13 @@ function pt(t) {
1960
1960
  throw new Error(`Invalid date value \`${t}\`. Expected a date, number, or string, got type ${typeof t}.`);
1961
1961
  }
1962
1962
  }
1963
- function ws(t) {
1963
+ function vs(t) {
1964
1964
  return t.cardinality === "one";
1965
1965
  }
1966
- function an(t) {
1966
+ function cn(t) {
1967
1967
  return t["value-type"] === "ref";
1968
1968
  }
1969
- function cn(t) {
1969
+ function dn(t) {
1970
1970
  return t["value-type"] === "blob";
1971
1971
  }
1972
1972
  function ke(t, e) {
@@ -1996,7 +1996,7 @@ function B(t, e, n) {
1996
1996
  let s = t.get(r);
1997
1997
  s || (s = /* @__PURE__ */ new Map(), t.set(r, s)), B(s, i, n);
1998
1998
  }
1999
- function xr(t, e, n) {
1999
+ function Dr(t, e, n) {
2000
2000
  const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
2001
2001
  for (const o of e) {
2002
2002
  let [u, a, d, c] = o;
@@ -2005,22 +2005,22 @@ function xr(t, e, n) {
2005
2005
  console.warn("no such attr", u, t);
2006
2006
  continue;
2007
2007
  }
2008
- f["checked-data-type"] === "date" && n && (d = pt(d), o[2] = d), an(f) && B(s, [d, a, u], o), B(r, [u, a, d], o), B(i, [a, u, d], o);
2008
+ f["checked-data-type"] === "date" && n && (d = pt(d), o[2] = d), cn(f) && B(s, [d, a, u], o), B(r, [u, a, d], o), B(i, [a, u, d], o);
2009
2009
  }
2010
2010
  return { eav: r, aev: i, vae: s };
2011
2011
  }
2012
- function Dr(t) {
2012
+ function Ur(t) {
2013
2013
  const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
2014
2014
  for (const s of Object.values(t)) {
2015
2015
  const o = s["forward-identity"], [u, a, d] = o, c = s["reverse-identity"];
2016
- if (B(r, [a, d], s), cn(s) && B(e, [a, d], s), s["primary?"] && B(n, [a], s), c) {
2016
+ if (B(r, [a, d], s), dn(s) && B(e, [a, d], s), s["primary?"] && B(n, [a], s), c) {
2017
2017
  const [f, l, p] = c;
2018
2018
  B(i, [l, p], s);
2019
2019
  }
2020
2020
  }
2021
2021
  return { blobAttrs: e, primaryKeys: n, forwardIdents: r, revIdents: i };
2022
2022
  }
2023
- function Ur(t) {
2023
+ function Lr(t) {
2024
2024
  return {
2025
2025
  __type: t.__type,
2026
2026
  attrs: t.attrs,
@@ -2030,18 +2030,18 @@ function Ur(t) {
2030
2030
  useDateObjects: t.useDateObjects
2031
2031
  };
2032
2032
  }
2033
- function Lr(t) {
2033
+ function Fr(t) {
2034
2034
  return at(t.attrs, t.triples, t.cardinalityInference, t.linkIndex, t.useDateObjects);
2035
2035
  }
2036
- function vs(t, e) {
2036
+ function Ss(t, e) {
2037
2037
  return Ce(t.eav, [e]) !== void 0;
2038
2038
  }
2039
- function dn(t) {
2040
- t.attrIndexes = Dr(t.attrs);
2039
+ function fn(t) {
2040
+ t.attrIndexes = Ur(t.attrs);
2041
2041
  }
2042
2042
  function at(t, e, n, r, i) {
2043
- const s = xr(t, e, i);
2044
- return s.useDateObjects = i, s.attrs = t, s.attrIndexes = Dr(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
2043
+ const s = Dr(t, e, i);
2044
+ return s.useDateObjects = i, s.attrs = t, s.attrIndexes = Ur(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
2045
2045
  }
2046
2046
  function Be(t, e) {
2047
2047
  var n, r;
@@ -2070,21 +2070,21 @@ function Be(t, e) {
2070
2070
  return [i, ...u];
2071
2071
  }
2072
2072
  }
2073
- function Fr(t, e) {
2073
+ function Nr(t, e) {
2074
2074
  const n = Be(t, e);
2075
2075
  if (!n)
2076
2076
  return;
2077
2077
  const [r, i, s] = n, o = ke(t.attrs, i);
2078
- o && (X(t.eav, [r, i, s]), X(t.aev, [i, r, s]), an(o) && X(t.vae, [s, i, r]));
2078
+ o && (X(t.eav, [r, i, s]), X(t.aev, [i, r, s]), cn(o) && X(t.vae, [s, i, r]));
2079
2079
  }
2080
- let Ss = 0;
2081
- function Nr(t, e, n) {
2080
+ let Os = 0;
2081
+ function Kr(t, e, n) {
2082
2082
  const [r, i, s] = n;
2083
2083
  let o;
2084
- const u = Ce(t.ea, [r, i, s]);
2085
- return u && (o = u[3]), o || Date.now() * 10 + Ss++;
2084
+ const u = Ce(t.eav, [r, i, s]);
2085
+ return u && (o = u[3]), o || Date.now() * 10 + Os++;
2086
2086
  }
2087
- function Kr(t, e) {
2087
+ function qr(t, e) {
2088
2088
  var n;
2089
2089
  const r = Be(t, e);
2090
2090
  if (!r)
@@ -2094,10 +2094,10 @@ function Kr(t, e) {
2094
2094
  if (!u)
2095
2095
  return;
2096
2096
  u["checked-data-type"] === "date" && t.useDateObjects && (o = pt(o));
2097
- const a = Ce(t.eav, [i, s, o]), d = (n = a == null ? void 0 : a[3]) !== null && n !== void 0 ? n : Nr(t, u, r), c = [i, s, o, d];
2098
- ws(u) ? (B(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), B(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (B(t.eav, [i, s, o], c), B(t.aev, [s, i, o], c)), an(u) && B(t.vae, [o, s, i], c);
2097
+ const a = Ce(t.eav, [i, s, o]), d = (n = a == null ? void 0 : a[3]) !== null && n !== void 0 ? n : Kr(t, u, r), c = [i, s, o, d];
2098
+ vs(u) ? (B(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), B(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (B(t.eav, [i, s, o], c), B(t.aev, [s, i, o], c)), cn(u) && B(t.vae, [o, s, i], c);
2099
2099
  }
2100
- function Os(t, e) {
2100
+ function Es(t, e) {
2101
2101
  var n;
2102
2102
  const r = Be(t, e);
2103
2103
  if (!r)
@@ -2105,7 +2105,7 @@ function Os(t, e) {
2105
2105
  const [i, s, o] = r, u = ke(t.attrs, s);
2106
2106
  if (!u)
2107
2107
  return;
2108
- if (!cn(u))
2108
+ if (!dn(u))
2109
2109
  throw new Error("merge operation is not supported for links");
2110
2110
  const a = Ce(t.eav, [i, s]);
2111
2111
  if (!a)
@@ -2113,15 +2113,15 @@ function Os(t, e) {
2113
2113
  const d = (n = a.values().next()) === null || n === void 0 ? void 0 : n.value;
2114
2114
  if (!d)
2115
2115
  return;
2116
- const c = d[2], f = Rr(c, o), l = [
2116
+ const c = d[2], f = $r(c, o), l = [
2117
2117
  i,
2118
2118
  s,
2119
2119
  f,
2120
- Nr(t, u, d)
2120
+ Kr(t, u, d)
2121
2121
  ];
2122
2122
  B(t.eav, [i, s], /* @__PURE__ */ new Map([[f, l]]));
2123
2123
  }
2124
- function Kt(t, e) {
2124
+ function qt(t, e) {
2125
2125
  var n, r;
2126
2126
  const [i, s] = e, o = Be(t, [i]);
2127
2127
  if (!o)
@@ -2132,7 +2132,7 @@ function Kt(t, e) {
2132
2132
  const f = t.attrs[c];
2133
2133
  f && f["on-delete-reverse"] === "cascade" && G(a.get(c), 1).forEach(([l, p, y]) => {
2134
2134
  var b;
2135
- return Kt(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
2135
+ return qt(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
2136
2136
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
2137
2137
  // the store that didn't set `etype` in deleteEntity
2138
2138
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -2145,54 +2145,54 @@ function Kt(t, e) {
2145
2145
  d && d.forEach((c) => {
2146
2146
  var f, l, p;
2147
2147
  const [y, b, g] = c, m = t.attrs[b];
2148
- (!s || !m || ((f = m["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (X(t.eav, [y, b, g]), X(t.aev, [b, y, g]), X(t.vae, [g, b, y])), m && m["on-delete"] === "cascade" && ((l = m["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === s && Kt(t, [y, (p = m["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
2148
+ (!s || !m || ((f = m["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (X(t.eav, [y, b, g]), X(t.aev, [b, y, g]), X(t.vae, [g, b, y])), m && m["on-delete"] === "cascade" && ((l = m["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === s && qt(t, [y, (p = m["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
2149
2149
  }), ((r = t.vae.get(u)) === null || r === void 0 ? void 0 : r.size) === 0 && X(t.vae, [u]);
2150
2150
  }
2151
- function qr(t, e) {
2152
- const n = xr(t.attrs, e, t.useDateObjects);
2151
+ function zr(t, e) {
2152
+ const n = Dr(t.attrs, e, t.useDateObjects);
2153
2153
  Object.keys(n).forEach((r) => {
2154
2154
  t[r] = n[r];
2155
2155
  });
2156
2156
  }
2157
- function Es(t, [e]) {
2158
- t.attrs[e.id] = e, dn(t);
2157
+ function As(t, [e]) {
2158
+ t.attrs[e.id] = e, fn(t);
2159
2159
  }
2160
- function zr(t) {
2160
+ function Vr(t) {
2161
2161
  return G(t.eav, 3);
2162
2162
  }
2163
- function As(t, [e]) {
2163
+ function js(t, [e]) {
2164
2164
  if (!t.attrs[e])
2165
2165
  return;
2166
- const n = zr(t).filter(([r, i]) => i !== e);
2167
- delete t.attrs[e], dn(t), qr(t, n);
2166
+ const n = Vr(t).filter(([r, i]) => i !== e);
2167
+ delete t.attrs[e], fn(t), zr(t, n);
2168
2168
  }
2169
- function js(t, [e]) {
2169
+ function ks(t, [e]) {
2170
2170
  const n = t.attrs[e.id];
2171
- n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), dn(t), qr(t, zr(t)));
2171
+ n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), fn(t), zr(t, Vr(t)));
2172
2172
  }
2173
- function ks(t, e) {
2173
+ function Cs(t, e) {
2174
2174
  const [n, ...r] = e;
2175
2175
  switch (n) {
2176
2176
  case "add-triple":
2177
- Kr(t, r);
2177
+ qr(t, r);
2178
2178
  break;
2179
2179
  case "deep-merge-triple":
2180
- Os(t, r);
2180
+ Es(t, r);
2181
2181
  break;
2182
2182
  case "retract-triple":
2183
- Fr(t, r);
2183
+ Nr(t, r);
2184
2184
  break;
2185
2185
  case "delete-entity":
2186
- Kt(t, r);
2186
+ qt(t, r);
2187
2187
  break;
2188
2188
  case "add-attr":
2189
- Es(t, r);
2189
+ As(t, r);
2190
2190
  break;
2191
2191
  case "delete-attr":
2192
- As(t, r);
2192
+ js(t, r);
2193
2193
  break;
2194
2194
  case "update-attr":
2195
- js(t, r);
2195
+ ks(t, r);
2196
2196
  break;
2197
2197
  case "restore-attr":
2198
2198
  break;
@@ -2215,45 +2215,45 @@ function G(t, e, n = []) {
2215
2215
  return n;
2216
2216
  }
2217
2217
  function tt(t, e, n) {
2218
- var r, i;
2219
- const s = [];
2218
+ var r;
2219
+ const i = [];
2220
2220
  if (n != null && n.hasOwnProperty("$not")) {
2221
- for (const u of e.keys())
2222
- n.$not !== u && s.push(e.get(u));
2223
- return s;
2221
+ for (const o of e.keys())
2222
+ n.$not !== o && i.push(e.get(o));
2223
+ return i;
2224
2224
  }
2225
2225
  if (n != null && n.hasOwnProperty("$isNull")) {
2226
- const { attrId: u, isNull: a, reverse: d } = n.$isNull;
2227
- if (d)
2228
- for (const c of e.keys()) {
2229
- const f = t.vae.get(c), l = !f || ((r = f.get(u)) === null || r === void 0 ? void 0 : r.get(null)) || !f.get(u);
2230
- (a ? l : !l) && s.push(e.get(c));
2226
+ const { attrId: o, isNull: u, reverse: a } = n.$isNull;
2227
+ if (a)
2228
+ for (const d of e.keys()) {
2229
+ const c = t.vae.get(d), f = !c || !c.get(o);
2230
+ (u ? f : !f) && i.push(e.get(d));
2231
2231
  }
2232
2232
  else {
2233
- const c = t.aev.get(u);
2234
- for (const f of e.keys()) {
2235
- const l = !c || ((i = c.get(f)) === null || i === void 0 ? void 0 : i.get(null)) || !c.get(f);
2236
- (a ? l : !l) && s.push(e.get(f));
2233
+ const d = t.aev.get(o);
2234
+ for (const c of e.keys()) {
2235
+ const f = !d || ((r = d.get(c)) === null || r === void 0 ? void 0 : r.get(null)) || !d.get(c);
2236
+ (u ? f : !f) && i.push(e.get(c));
2237
2237
  }
2238
2238
  }
2239
- return s;
2239
+ return i;
2240
2240
  }
2241
2241
  if (n != null && n.$comparator)
2242
2242
  return G(e, 1).filter(n.$op);
2243
- const o = n.in || n.$in || [n];
2244
- for (const u of o) {
2245
- const a = e.get(u);
2246
- a && s.push(a);
2243
+ const s = n.in || n.$in || [n];
2244
+ for (const o of s) {
2245
+ const u = e.get(o);
2246
+ u && i.push(u);
2247
2247
  }
2248
- return s;
2248
+ return i;
2249
2249
  }
2250
- function Cs(t, e, n) {
2250
+ function Ps(t, e, n) {
2251
2251
  let r = "";
2252
2252
  return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
2253
2253
  }
2254
- function Ps(t, [e, n, r]) {
2254
+ function Is(t, [e, n, r]) {
2255
2255
  var i, s;
2256
- switch (Cs(e, n, r)) {
2256
+ switch (Ps(e, n, r)) {
2257
2257
  case "e": {
2258
2258
  const u = t.eav.get(e);
2259
2259
  return G(u, 2);
@@ -2299,33 +2299,36 @@ function Ps(t, [e, n, r]) {
2299
2299
  return G(t.eav, 3);
2300
2300
  }
2301
2301
  }
2302
- function Is(t, e, n) {
2302
+ const kt = {};
2303
+ function Ms(t, e, n) {
2303
2304
  var r;
2305
+ if (kt[n])
2306
+ return kt[n];
2304
2307
  const i = {};
2305
2308
  for (const [s, o] of e.entries()) {
2306
2309
  const u = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), a = G(u, 1);
2307
2310
  for (const d of a)
2308
2311
  i[s] = d[2];
2309
2312
  }
2310
- return i;
2313
+ return kt[n] = i, i;
2311
2314
  }
2312
2315
  function fe(t, e, n) {
2313
2316
  var r;
2314
2317
  return (r = t.attrIndexes.forwardIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
2315
2318
  }
2316
- function Vr(t, e, n) {
2319
+ function Wr(t, e, n) {
2317
2320
  var r;
2318
2321
  return (r = t.attrIndexes.revIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
2319
2322
  }
2320
- function Ms(t, e) {
2323
+ function Rs(t, e) {
2321
2324
  return t.attrIndexes.blobAttrs.get(e);
2322
2325
  }
2323
- function Wr(t, e) {
2326
+ function Br(t, e) {
2324
2327
  var n;
2325
2328
  const r = t.attrIndexes.primaryKeys.get(e);
2326
2329
  return r || ((n = t.attrIndexes.forwardIdents.get(e)) === null || n === void 0 ? void 0 : n.get("id"));
2327
2330
  }
2328
- function Rs(t, e) {
2331
+ function $s(t, e) {
2329
2332
  const n = Be(t, e);
2330
2333
  if (!n)
2331
2334
  return;
@@ -2333,7 +2336,7 @@ function Rs(t, e) {
2333
2336
  if (ke(t.attrs, i))
2334
2337
  return Ce(t.eav, [r, i]);
2335
2338
  }
2336
- function $s(t, e) {
2339
+ function xs(t, e) {
2337
2340
  const n = e.filter(([r, i, s, o, u]) => {
2338
2341
  if (r !== "add-triple" && r !== "deep-merge-triple")
2339
2342
  return !0;
@@ -2343,39 +2346,43 @@ function $s(t, e) {
2343
2346
  let d = !1;
2344
2347
  const c = ke(t.attrs, s);
2345
2348
  if (c) {
2346
- const f = Wr(t, c["forward-identity"][1]);
2347
- d = !!Rs(t, [i, f.id, i]);
2349
+ const f = Br(t, c["forward-identity"][1]);
2350
+ d = !!$s(t, [
2351
+ i,
2352
+ f == null ? void 0 : f.id,
2353
+ i
2354
+ ]);
2348
2355
  }
2349
2356
  return !(a === "create" && d || a === "update" && !d);
2350
2357
  });
2351
2358
  return ft(t, (r) => {
2352
2359
  n.forEach((i) => {
2353
- ks(r, i);
2360
+ Cs(r, i);
2354
2361
  });
2355
2362
  });
2356
2363
  }
2357
- function xs(t) {
2364
+ function Ds(t) {
2358
2365
  return typeof t == "string" && t.startsWith("?");
2359
2366
  }
2360
- function Ds(t, e, n) {
2367
+ function Us(t, e, n) {
2361
2368
  if (n.hasOwnProperty(t)) {
2362
2369
  const r = n[t];
2363
- return Br(r, e, n);
2370
+ return Gr(r, e, n);
2364
2371
  }
2365
2372
  return Object.assign(Object.assign({}, n), { [t]: e });
2366
2373
  }
2367
- function Bn(t, e, n) {
2374
+ function Gn(t, e, n) {
2368
2375
  return t === e ? n : null;
2369
2376
  }
2370
- function Us(t) {
2377
+ function Ls(t) {
2371
2378
  switch (typeof t) {
2372
2379
  case "string":
2373
- return t.startsWith("?") ? Ds : Bn;
2380
+ return t.startsWith("?") ? Us : Gn;
2374
2381
  default:
2375
- return Bn;
2382
+ return Gn;
2376
2383
  }
2377
2384
  }
2378
- const Ls = [
2385
+ const Fs = [
2379
2386
  "in",
2380
2387
  "$in",
2381
2388
  "$not",
@@ -2383,77 +2390,77 @@ const Ls = [
2383
2390
  "$comparator"
2384
2391
  // covers all of $gt, $lt, etc.
2385
2392
  ];
2386
- function Fs(t) {
2387
- for (const e of Ls)
2393
+ function Ns(t) {
2394
+ for (const e of Fs)
2388
2395
  if (t.hasOwnProperty(e))
2389
2396
  return !0;
2390
2397
  return !1;
2391
2398
  }
2392
- function Br(t, e, n) {
2393
- return n ? typeof t == "object" ? Fs(t) ? n : null : Us(t)(t, e, n) : null;
2399
+ function Gr(t, e, n) {
2400
+ return n ? typeof t == "object" ? Ns(t) ? n : null : Ls(t)(t, e, n) : null;
2394
2401
  }
2395
- function Ns(t, e, n) {
2402
+ function Ks(t, e, n) {
2396
2403
  return t.reduce((r, i, s) => {
2397
2404
  const o = e[s];
2398
- return Br(i, o, r);
2405
+ return Gr(i, o, r);
2399
2406
  }, n);
2400
2407
  }
2401
- function Ks(t, e, n) {
2402
- return Vs(t, e, n).map((r) => Ns(e, r, n)).filter((r) => r);
2403
- }
2404
2408
  function qs(t, e, n) {
2405
- return e.or ? e.or.patterns.flatMap((r) => qt(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => qt(t, i, r), n) : n.flatMap((r) => Ks(t, e, r));
2409
+ return Ws(t, e, n).map((r) => Ks(e, r, n)).filter((r) => r);
2410
+ }
2411
+ function zs(t, e, n) {
2412
+ return e.or ? e.or.patterns.flatMap((r) => zt(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => zt(t, i, r), n) : n.flatMap((r) => qs(t, e, r));
2406
2413
  }
2407
- function qt(t, e, n = [{}]) {
2408
- return e.reduce((r, i) => qs(t, i, r), n);
2414
+ function zt(t, e, n = [{}]) {
2415
+ return e.reduce((r, i) => zs(t, i, r), n);
2409
2416
  }
2410
- function fn(t, e) {
2411
- return Array.isArray(e) ? e.map((n) => fn(t, n)) : xs(e) ? t[e] : e;
2417
+ function ln(t, e) {
2418
+ return Array.isArray(e) ? e.map((n) => ln(t, n)) : Ds(e) ? t[e] : e;
2412
2419
  }
2413
- function zs(t, { find: e, where: n }) {
2414
- return qt(t, n).map((i) => fn(i, e));
2420
+ function Vs(t, { find: e, where: n }) {
2421
+ return zt(t, n).map((i) => ln(i, e));
2415
2422
  }
2416
- function Vs(t, e, n) {
2417
- return Ps(t, fn(n, e));
2423
+ function Ws(t, e, n) {
2424
+ return Is(t, ln(n, e));
2418
2425
  }
2419
- const Ws = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
2426
+ const Bs = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
2420
2427
  function Ee(t) {
2421
- return typeof t == "string" && Ws.test(t);
2428
+ return typeof t == "string" && Bs.test(t);
2422
2429
  }
2423
2430
  const F = [];
2424
2431
  for (let t = 0; t < 256; ++t)
2425
2432
  F.push((t + 256).toString(16).slice(1));
2426
- function Bs(t, e = 0) {
2433
+ function Gs(t, e = 0) {
2427
2434
  return (F[t[e + 0]] + F[t[e + 1]] + F[t[e + 2]] + F[t[e + 3]] + "-" + F[t[e + 4]] + F[t[e + 5]] + "-" + F[t[e + 6]] + F[t[e + 7]] + "-" + F[t[e + 8]] + F[t[e + 9]] + "-" + F[t[e + 10]] + F[t[e + 11]] + F[t[e + 12]] + F[t[e + 13]] + F[t[e + 14]] + F[t[e + 15]]).toLowerCase();
2428
2435
  }
2429
- let kt;
2430
- const Gs = new Uint8Array(16);
2431
- function Qs() {
2432
- if (!kt) {
2436
+ let Ct;
2437
+ const Qs = new Uint8Array(16);
2438
+ function Hs() {
2439
+ if (!Ct) {
2433
2440
  if (typeof crypto > "u" || !crypto.getRandomValues)
2434
2441
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2435
- kt = crypto.getRandomValues.bind(crypto);
2442
+ Ct = crypto.getRandomValues.bind(crypto);
2436
2443
  }
2437
- return kt(Gs);
2444
+ return Ct(Qs);
2438
2445
  }
2439
- const Hs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Gn = { randomUUID: Hs };
2440
- function Ys(t, e, n) {
2446
+ const Ys = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qn = { randomUUID: Ys };
2447
+ function Js(t, e, n) {
2441
2448
  var i;
2442
- if (Gn.randomUUID && !t)
2443
- return Gn.randomUUID();
2449
+ if (Qn.randomUUID && !t)
2450
+ return Qn.randomUUID();
2444
2451
  t = t || {};
2445
- const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Qs();
2452
+ const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Hs();
2446
2453
  if (r.length < 16)
2447
2454
  throw new Error("Random bytes length must be >= 16");
2448
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Bs(r);
2455
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Gs(r);
2449
2456
  }
2450
- function Qn(t) {
2457
+ function Hn(t) {
2451
2458
  const e = t.replace(/-/g, ""), n = [];
2452
2459
  for (let r = 0; r < e.length; r += 2)
2453
2460
  n.push(parseInt(e.substring(r, r + 2), 16));
2454
2461
  return n;
2455
2462
  }
2456
- function Js(t, e) {
2463
+ function Zs(t, e) {
2457
2464
  for (let n = 0; n < t.length; n++) {
2458
2465
  if (t[n] < e[n])
2459
2466
  return -1;
@@ -2462,17 +2469,17 @@ function Js(t, e) {
2462
2469
  }
2463
2470
  return 0;
2464
2471
  }
2465
- function Zs(t, e) {
2466
- return Js(Qn(t), Qn(e));
2472
+ function Xs(t, e) {
2473
+ return Zs(Hn(t), Hn(e));
2467
2474
  }
2468
2475
  function L() {
2469
- return Ys();
2476
+ return Js();
2470
2477
  }
2471
- function Xs(t, e) {
2478
+ function eo(t, e) {
2472
2479
  return t.localeCompare(e);
2473
2480
  }
2474
- function eo() {
2475
- let t = Xs;
2481
+ function to() {
2482
+ let t = eo;
2476
2483
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
2477
2484
  try {
2478
2485
  t = Intl.Collator("en-US").compare;
@@ -2480,10 +2487,10 @@ function eo() {
2480
2487
  }
2481
2488
  return t;
2482
2489
  }
2483
- const to = eo();
2484
- let no = 0;
2490
+ const no = to();
2491
+ let ro = 0;
2485
2492
  function Ke(t) {
2486
- return yt(`_${t}`, no++);
2493
+ return yt(`_${t}`, ro++);
2487
2494
  }
2488
2495
  function yt(t, e) {
2489
2496
  return `?${t}-${e}`;
@@ -2493,28 +2500,28 @@ class Ae extends Error {
2493
2500
  super(e), this.name = "AttrNotFoundError";
2494
2501
  }
2495
2502
  }
2496
- function ro(t, e) {
2497
- const n = Wr(t, e);
2503
+ function io(t, e) {
2504
+ const n = Br(t, e);
2498
2505
  if (!n)
2499
2506
  throw new Ae(`Could not find id attr for ${e}`);
2500
2507
  return n;
2501
2508
  }
2502
- function Hn(t, e, n, r) {
2503
- return [io(t, e, n, r)];
2509
+ function Yn(t, e, n, r) {
2510
+ return [so(t, e, n, r)];
2504
2511
  }
2505
- function io(t, e, n, r) {
2512
+ function so(t, e, n, r) {
2506
2513
  return [
2507
2514
  t(n, r),
2508
- ro(e, n).id,
2515
+ io(e, n).id,
2509
2516
  t(n, r),
2510
2517
  t("time", r)
2511
2518
  ];
2512
2519
  }
2513
- function so(t, e, n) {
2520
+ function oo(t, e, n) {
2514
2521
  return t.map((r) => r === e ? n : r);
2515
2522
  }
2516
- function Gr(t, e, n, r, i) {
2517
- const s = fe(e, n, i), o = Vr(e, n, i), u = s || o;
2523
+ function Qr(t, e, n, r, i) {
2524
+ const s = fe(e, n, i), o = Wr(e, n, i), u = s || o;
2518
2525
  if (!u)
2519
2526
  throw new Ae(`Could not find attr for ${[n, i]}`);
2520
2527
  if (u["value-type"] !== "ref")
@@ -2532,7 +2539,7 @@ function Gr(t, e, n, r, i) {
2532
2539
  ];
2533
2540
  return [s ? f : d, l, p, u, !!s];
2534
2541
  }
2535
- function Yn(t, e) {
2542
+ function Jn(t, e) {
2536
2543
  if (typeof e != "string")
2537
2544
  return function(o) {
2538
2545
  return !1;
@@ -2542,7 +2549,7 @@ function Yn(t, e) {
2542
2549
  return typeof o != "string" ? !1 : i.test(o);
2543
2550
  };
2544
2551
  }
2545
- function oo(t, e) {
2552
+ function uo(t, e) {
2546
2553
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2547
2554
  return e;
2548
2555
  const n = t["checked-data-type"] === "date";
@@ -2583,7 +2590,7 @@ function oo(t, e) {
2583
2590
  }
2584
2591
  };
2585
2592
  if (e.hasOwnProperty("$like")) {
2586
- const r = Yn(!0, e.$like);
2593
+ const r = Jn(!0, e.$like);
2587
2594
  return {
2588
2595
  $comparator: !0,
2589
2596
  $op: function(s) {
@@ -2592,7 +2599,7 @@ function oo(t, e) {
2592
2599
  };
2593
2600
  }
2594
2601
  if (e.hasOwnProperty("$ilike")) {
2595
- const r = Yn(!1, e.$ilike);
2602
+ const r = Jn(!1, e.$ilike);
2596
2603
  return {
2597
2604
  $comparator: !0,
2598
2605
  $op: function(s) {
@@ -2602,8 +2609,8 @@ function oo(t, e) {
2602
2609
  }
2603
2610
  return e;
2604
2611
  }
2605
- function uo(t, e, n, r, i, s) {
2606
- const o = fe(e, n, i), u = Vr(e, n, i), a = o || u;
2612
+ function ao(t, e, n, r, i, s) {
2613
+ const o = fe(e, n, i), u = Wr(e, n, i), a = o || u;
2607
2614
  if (!a)
2608
2615
  throw new Ae(`No attr for etype = ${n} label = ${i}`);
2609
2616
  if (s != null && s.hasOwnProperty("$isNull")) {
@@ -2620,63 +2627,63 @@ function uo(t, e, n, r, i, s) {
2620
2627
  return o ? [
2621
2628
  t(n, r),
2622
2629
  a.id,
2623
- oo(a, s),
2630
+ uo(a, s),
2624
2631
  Ke("time")
2625
2632
  ] : [s, a.id, t(n, r), Ke("time")];
2626
2633
  }
2627
- function ao(t, e, n, r, i) {
2634
+ function co(t, e, n, r, i) {
2628
2635
  const [s, o, u] = i.reduce((a, d) => {
2629
- const [c, f, l] = a, [p, y, b] = Gr(t, e, c, f, d);
2636
+ const [c, f, l] = a, [p, y, b] = Qr(t, e, c, f, d);
2630
2637
  return [p, y, [...l, b]];
2631
2638
  }, [n, r, []]);
2632
2639
  return [s, o, u];
2633
2640
  }
2634
- function zt(t, e, n, r, i, s) {
2635
- const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] = ao(t, e, n, r, o), f = uo(t, e, a, d, u, s);
2641
+ function Vt(t, e, n, r, i, s) {
2642
+ const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] = co(t, e, n, r, o), f = ao(t, e, a, d, u, s);
2636
2643
  return c.concat([f]);
2637
2644
  }
2638
- function co(t, e) {
2645
+ function fo(t, e) {
2639
2646
  return e ? [e].concat(t) : t;
2640
2647
  }
2641
- function fo([t, e]) {
2648
+ function lo([t, e]) {
2642
2649
  return t === "or" && Array.isArray(e);
2643
2650
  }
2644
- function lo([t, e]) {
2651
+ function ho([t, e]) {
2645
2652
  return t === "and" && Array.isArray(e);
2646
2653
  }
2647
- function ho(t, e, n) {
2654
+ function po(t, e, n) {
2648
2655
  return (r, i) => {
2649
2656
  const s = t(r, i);
2650
2657
  return e == s ? s : `${s}-${n}`;
2651
2658
  };
2652
2659
  }
2653
- function Jn(t, e, n, r, i, s) {
2660
+ function Zn(t, e, n, r, i, s) {
2654
2661
  const o = t(r, i), u = s.map((a, d) => {
2655
- const c = ho(t, o, d);
2656
- return Qr(c, n, r, i, a);
2662
+ const c = po(t, o, d);
2663
+ return Hr(c, n, r, i, a);
2657
2664
  });
2658
2665
  return { [e]: { patterns: u, joinSym: o } };
2659
2666
  }
2660
- function po(t) {
2667
+ function yo(t) {
2661
2668
  const e = [];
2662
2669
  for (let n = 1; n <= t.length; n++)
2663
2670
  e.push(t.slice(0, n));
2664
2671
  return e;
2665
2672
  }
2666
- function Zn(t, e, n, r, i) {
2667
- return po(i).map((s) => zt(t, e, n, r, s, { $isNull: !0 }));
2673
+ function Xn(t, e, n, r, i) {
2674
+ return yo(i).map((s) => Vt(t, e, n, r, s, { $isNull: !0 }));
2668
2675
  }
2669
- function Qr(t, e, n, r, i) {
2676
+ function Hr(t, e, n, r, i) {
2670
2677
  return Object.entries(i).flatMap(([s, o]) => {
2671
- if (fo([s, o]))
2672
- return Jn(t, "or", e, n, r, o);
2673
2678
  if (lo([s, o]))
2674
- return Jn(t, "and", e, n, r, o);
2679
+ return Zn(t, "or", e, n, r, o);
2680
+ if (ho([s, o]))
2681
+ return Zn(t, "and", e, n, r, o);
2675
2682
  if (s === "$entityIdStartsWith")
2676
2683
  return [];
2677
2684
  const u = s.split(".");
2678
2685
  if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2679
- const a = zt(t, e, n, r, u, o), d = Zn(t, e, n, r, u);
2686
+ const a = Vt(t, e, n, r, u, o), d = Xn(t, e, n, r, u);
2680
2687
  return [
2681
2688
  {
2682
2689
  or: {
@@ -2689,32 +2696,32 @@ function Qr(t, e, n, r, i) {
2689
2696
  return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && u.length > 1 ? [
2690
2697
  {
2691
2698
  or: {
2692
- patterns: Zn(t, e, n, r, u),
2699
+ patterns: Xn(t, e, n, r, u),
2693
2700
  joinSym: t(n, r)
2694
2701
  }
2695
2702
  }
2696
- ] : zt(t, e, n, r, u, o);
2703
+ ] : Vt(t, e, n, r, u, o);
2697
2704
  });
2698
2705
  }
2699
- function yo(t, e, n, r) {
2706
+ function bo(t, e, n, r) {
2700
2707
  const i = yt;
2701
- return r ? Qr(i, t, e, n, r).concat(Hn(i, t, e, n)) : Hn(i, t, e, n);
2708
+ return r ? Hr(i, t, e, n, r).concat(Yn(i, t, e, n)) : Yn(i, t, e, n);
2702
2709
  }
2703
- function bo(t, e, n) {
2710
+ function _o(t, e, n) {
2704
2711
  return [t(e, n), t("time", n)];
2705
2712
  }
2706
- function _o(t, e, n, r, i, s) {
2707
- const [o, u, a, d, c] = Gr(t, e, n, r, i), f = so(a, t(n, r), s);
2713
+ function go(t, e, n, r, i, s) {
2714
+ const [o, u, a, d, c] = Qr(t, e, n, r, i), f = oo(a, t(n, r), s);
2708
2715
  return [o, u, f, d, c];
2709
2716
  }
2710
- function go(t, e, { etype: n, level: r, form: i }, s) {
2717
+ function To(t, e, { etype: n, level: r, form: i }, s) {
2711
2718
  const o = Object.keys(i).filter((u) => u !== "$");
2712
2719
  return o.length ? Object.entries(s).map(function([a, d]) {
2713
2720
  return o.map(function(l) {
2714
2721
  var p, y, b;
2715
2722
  const g = !!(e.cardinalityInference && (!((b = (y = (p = e.linkIndex) === null || p === void 0 ? void 0 : p[n]) === null || y === void 0 ? void 0 : y[l]) === null || b === void 0) && b.isSingular));
2716
2723
  try {
2717
- const [m, T, v] = _o(t, e, n, r, l, a), k = Yr(e, {
2724
+ const [m, T, v] = go(t, e, n, r, l, a), k = Jr(e, {
2718
2725
  etype: m,
2719
2726
  level: T,
2720
2727
  form: i[l],
@@ -2731,48 +2738,48 @@ function go(t, e, { etype: n, level: r, form: i }, s) {
2731
2738
  }, d);
2732
2739
  }) : Object.values(s);
2733
2740
  }
2734
- function To(t, e, n) {
2735
- return n === "string" ? to(t, e) : t > e ? 1 : -1;
2741
+ function mo(t, e, n) {
2742
+ return n === "string" ? no(t, e) : t > e ? 1 : -1;
2736
2743
  }
2737
2744
  function Fe(t, e, n, r, i) {
2738
- return e === r || e == null && r == null ? Zs(t, n) : r == null ? 1 : e == null ? -1 : To(e, r, i);
2745
+ return e === r || e == null && r == null ? Xs(t, n) : r == null ? 1 : e == null ? -1 : mo(e, r, i);
2739
2746
  }
2740
2747
  function lt([t, e], [n, r], i) {
2741
2748
  return Fe(t, e, n, r, i);
2742
2749
  }
2743
- function Vt(t) {
2750
+ function Wt(t) {
2744
2751
  return t == null ? t : new Date(t).getTime();
2745
2752
  }
2746
- function mo(t, e, n, r) {
2753
+ function wo(t, e, n, r) {
2747
2754
  var i;
2748
2755
  const [s, o, u, a] = t, d = n === "desc" ? 1 : -1;
2749
2756
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
2750
2757
  return lt(r, [s, a], null) === d;
2751
- const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? Vt(f) : f, y = l === "date" ? Vt(u) : u;
2758
+ const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? Wt(f) : f, y = l === "date" ? Wt(u) : u;
2752
2759
  return lt([c, p], [s, y], l) === d;
2753
2760
  }
2754
- function wo(t, e) {
2761
+ function vo(t, e) {
2755
2762
  const n = e[1];
2756
2763
  return t.attrs[n];
2757
2764
  }
2758
- function vo(t, e, n) {
2765
+ function So(t, e, n) {
2759
2766
  const r = Object.keys(n)[0];
2760
2767
  return fe(t, e, r);
2761
2768
  }
2762
- function So(t, e, n, r) {
2769
+ function Oo(t, e, n, r) {
2763
2770
  if (n)
2764
- return wo(t, n);
2771
+ return vo(t, n);
2765
2772
  if (r)
2766
- return vo(t, e, r);
2773
+ return So(t, e, r);
2767
2774
  }
2768
- function Oo(t, e, n) {
2775
+ function Eo(t, e, n) {
2769
2776
  var r, i;
2770
2777
  if (!Array.isArray(n.fields))
2771
- return Ms(t, e);
2778
+ return Rs(t, e);
2772
2779
  const s = /* @__PURE__ */ new Map();
2773
2780
  for (const o of n.fields) {
2774
2781
  const u = fe(t, e, o), a = (r = u == null ? void 0 : u["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2775
- a && cn(u) && s.set(a, u);
2782
+ a && dn(u) && s.set(a, u);
2776
2783
  }
2777
2784
  if (!s.has("id")) {
2778
2785
  const o = fe(t, e, "id"), u = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
@@ -2780,17 +2787,17 @@ function Oo(t, e, n) {
2780
2787
  }
2781
2788
  return s;
2782
2789
  }
2783
- function Eo(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2790
+ function Ao(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2784
2791
  var s, o;
2785
- const u = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, a = Hr(i), d = Ao(i);
2786
- let c = zs(t, r);
2787
- const f = n == null ? void 0 : n["start-cursor"], l = So(t, e, f, u);
2792
+ const u = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, a = Yr(i), d = jo(i);
2793
+ let c = Vs(t, r);
2794
+ const f = n == null ? void 0 : n["start-cursor"], l = Oo(t, e, f, u);
2788
2795
  if (l && ((o = l == null ? void 0 : l["forward-identity"]) === null || o === void 0 ? void 0 : o[2]) !== "id") {
2789
2796
  const b = l["checked-data-type"] === "date", g = l.id;
2790
2797
  c = c.map(([m]) => {
2791
2798
  var T, v, k, S, I;
2792
2799
  let R = (I = (S = (k = (v = (T = t.eav.get(m)) === null || T === void 0 ? void 0 : T.get(g)) === null || v === void 0 ? void 0 : v.values()) === null || k === void 0 ? void 0 : k.next()) === null || S === void 0 ? void 0 : S.value) === null || I === void 0 ? void 0 : I[2];
2793
- return b && (R = Vt(R)), [m, R];
2800
+ return b && (R = Wt(R)), [m, R];
2794
2801
  });
2795
2802
  }
2796
2803
  c.sort(d === "asc" ? function(g, m) {
@@ -2799,31 +2806,31 @@ function Eo(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2799
2806
  return lt(m, g, l == null ? void 0 : l["checked-data-type"]);
2800
2807
  });
2801
2808
  let p = {};
2802
- const y = Oo(t, e, r);
2809
+ const y = Eo(t, e, r);
2803
2810
  for (const b of c) {
2804
2811
  const [g] = b;
2805
- if (p[g] || !a && f && l && mo(f, l, d, b))
2812
+ if (p[g] || !a && f && l && wo(f, l, d, b))
2806
2813
  continue;
2807
- const m = Is(t, y, g);
2814
+ const m = Ms(t, y, g);
2808
2815
  m && (p[g] = m);
2809
2816
  }
2810
2817
  return p;
2811
2818
  }
2812
- function Ao(t) {
2819
+ function jo(t) {
2813
2820
  var e;
2814
2821
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2815
2822
  return n && n[Object.keys(n)[0]] || "asc";
2816
2823
  }
2817
- function Hr(t) {
2824
+ function Yr(t) {
2818
2825
  var e, n, r;
2819
2826
  const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
2820
2827
  return !i && !s && !o;
2821
2828
  }
2822
- function jo(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2829
+ function ko(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2823
2830
  var o, u, a, d, c;
2824
- if (!Hr(r) && (!s || !s["start-cursor"]))
2831
+ if (!Yr(r) && (!s || !s["start-cursor"]))
2825
2832
  return [];
2826
- const f = co(yo(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = bo(yt, e, n), p = (u = r.$) === null || u === void 0 ? void 0 : u.fields, y = Eo(t, {
2833
+ const f = fo(bo(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = _o(yt, e, n), p = (u = r.$) === null || u === void 0 ? void 0 : u.fields, y = Ao(t, {
2827
2834
  etype: e,
2828
2835
  pageInfo: s,
2829
2836
  form: r,
@@ -2836,20 +2843,20 @@ function jo(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2836
2843
  }
2837
2844
  return y;
2838
2845
  }
2839
- function ko(t, e) {
2846
+ function Co(t, e) {
2840
2847
  try {
2841
- return jo(t, e);
2848
+ return ko(t, e);
2842
2849
  } catch (n) {
2843
2850
  if (n instanceof Ae)
2844
2851
  return {};
2845
2852
  throw n;
2846
2853
  }
2847
2854
  }
2848
- function Yr(t, e) {
2849
- const n = ko(t, e);
2850
- return go(yt, t, e, n);
2855
+ function Jr(t, e) {
2856
+ const n = Co(t, e);
2857
+ return To(yt, t, e, n);
2851
2858
  }
2852
- function Co(t) {
2859
+ function Po(t) {
2853
2860
  const e = {};
2854
2861
  for (const [n, r] of Object.entries(t))
2855
2862
  e[n] = {
@@ -2860,18 +2867,18 @@ function Co(t) {
2860
2867
  };
2861
2868
  return e;
2862
2869
  }
2863
- function Jr({ store: t, pageInfo: e, aggregate: n }, r) {
2870
+ function Zr({ store: t, pageInfo: e, aggregate: n }, r) {
2864
2871
  const s = { data: Object.keys(r).reduce(function(u, a) {
2865
- return n != null && n[a] || a === "$$ruleParams" || (u[a] = Yr(t, {
2872
+ return n != null && n[a] || a === "$$ruleParams" || (u[a] = Jr(t, {
2866
2873
  etype: a,
2867
2874
  form: r[a],
2868
2875
  level: 0,
2869
2876
  pageInfo: e == null ? void 0 : e[a]
2870
2877
  })), u;
2871
2878
  }, {}) };
2872
- return e && (s.pageInfo = Co(e)), n && (s.aggregate = n), s;
2879
+ return e && (s.pageInfo = Po(e)), n && (s.aggregate = n), s;
2873
2880
  }
2874
- function Po() {
2881
+ function Io() {
2875
2882
  const e = {
2876
2883
  __etype: 1,
2877
2884
  __ops: 1,
@@ -2885,8 +2892,8 @@ function Po() {
2885
2892
  };
2886
2893
  return new Set(Object.keys(e));
2887
2894
  }
2888
- const Io = Po();
2889
- function Wt(t, e, n) {
2895
+ const Mo = Io();
2896
+ function Bt(t, e, n) {
2890
2897
  const r = {
2891
2898
  __etype: t,
2892
2899
  __ops: n
@@ -2897,8 +2904,8 @@ function Wt(t, e, n) {
2897
2904
  return n;
2898
2905
  if (s === "__etype")
2899
2906
  return t;
2900
- if (Io.has(s))
2901
- return (o, u) => Wt(t, e, [
2907
+ if (Mo.has(s))
2908
+ return (o, u) => Bt(t, e, [
2902
2909
  ...n,
2903
2910
  u ? [s, t, e, o, u] : [s, t, e, o]
2904
2911
  ]);
@@ -2908,11 +2915,11 @@ function Wt(t, e, n) {
2908
2915
  function ht(t) {
2909
2916
  return t.startsWith("lookup__");
2910
2917
  }
2911
- function Zr(t) {
2918
+ function Xr(t) {
2912
2919
  const [e, n, ...r] = t.split("__");
2913
2920
  return [n, JSON.parse(r.join("__"))];
2914
2921
  }
2915
- function Mo(t) {
2922
+ function Ro(t) {
2916
2923
  return new Proxy({
2917
2924
  __etype: t
2918
2925
  }, {
@@ -2920,22 +2927,22 @@ function Mo(t) {
2920
2927
  if (n === "__etype")
2921
2928
  return t;
2922
2929
  const r = n;
2923
- return ht(r) ? Wt(t, Zr(r), []) : Wt(t, r, []);
2930
+ return ht(r) ? Bt(t, Xr(r), []) : Bt(t, r, []);
2924
2931
  }
2925
2932
  });
2926
2933
  }
2927
- function ln() {
2934
+ function hn() {
2928
2935
  return new Proxy({}, {
2929
2936
  get(t, e) {
2930
- return Mo(e);
2937
+ return Ro(e);
2931
2938
  }
2932
2939
  });
2933
2940
  }
2934
- ln();
2935
- function Ro(t) {
2941
+ hn();
2942
+ function $o(t) {
2936
2943
  return t.__ops;
2937
2944
  }
2938
- function $o(t, e) {
2945
+ function xo(t, e) {
2939
2946
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2940
2947
  for (const o of e) {
2941
2948
  const u = n[o];
@@ -2969,7 +2976,7 @@ function _e(t, e, n) {
2969
2976
  return o === e && u === n;
2970
2977
  });
2971
2978
  }
2972
- function xo(t) {
2979
+ function Do(t) {
2973
2980
  if (Array.isArray(t))
2974
2981
  return t;
2975
2982
  const e = Object.entries(t);
@@ -2977,38 +2984,38 @@ function xo(t) {
2977
2984
  throw new Error("lookup must be an object with a single unique attr and value.");
2978
2985
  return e[0];
2979
2986
  }
2980
- function Bt(t, e, n) {
2987
+ function Gt(t, e, n) {
2981
2988
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2982
2989
  // before assuming it's a ref lookup.
2983
2990
  !K(t, e, n);
2984
2991
  }
2985
- function Gt(t) {
2992
+ function Qt(t) {
2986
2993
  const [e, n, ...r] = t.split(".");
2987
2994
  if (r.length > 0 || n !== "id")
2988
2995
  throw new Error(`${t} is not a valid lookup attribute.`);
2989
2996
  return e;
2990
2997
  }
2991
- function Do(t, e, n) {
2992
- if (!Bt(t, e, n))
2998
+ function Uo(t, e, n) {
2999
+ if (!Gt(t, e, n))
2993
3000
  return K(t, e, n);
2994
- const r = Gt(n), i = K(t, e, r) || _e(t, e, r);
3001
+ const r = Qt(n), i = K(t, e, r) || _e(t, e, r);
2995
3002
  if (i && i["value-type"] !== "ref")
2996
3003
  throw new Error(`${n} does not reference a valid link attribute.`);
2997
3004
  return i;
2998
3005
  }
2999
- function Qt(t) {
3000
- return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Zr(t) : xo(t);
3006
+ function Ht(t) {
3007
+ return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Xr(t) : Do(t);
3001
3008
  }
3002
3009
  function Q(t, e, n) {
3003
- const r = Qt(n);
3010
+ const r = Ht(n);
3004
3011
  if (r === null)
3005
3012
  return n;
3006
- const [i, s] = r, o = Do(t, e, i);
3013
+ const [i, s] = r, o = Uo(t, e, i);
3007
3014
  if (!o || !o["unique?"])
3008
3015
  throw new Error(`${i} is not a unique attribute.`);
3009
3016
  return [o.id, s];
3010
3017
  }
3011
- function Xr(t, e, n, r) {
3018
+ function ei(t, e, n, r) {
3012
3019
  const i = Q(t, e, n);
3013
3020
  return Array.isArray(i) ? [[
3014
3021
  "add-triple",
@@ -3017,7 +3024,7 @@ function Xr(t, e, n, r) {
3017
3024
  i
3018
3025
  ]].concat(r) : r;
3019
3026
  }
3020
- function Uo({ attrs: t }, [e, n, r]) {
3027
+ function Lo({ attrs: t }, [e, n, r]) {
3021
3028
  const i = Object.entries(r).flatMap(([s, o]) => {
3022
3029
  const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = _e(t, e, s);
3023
3030
  return u.map((c) => a ? [
@@ -3032,9 +3039,9 @@ function Uo({ attrs: t }, [e, n, r]) {
3032
3039
  Q(t, e, n)
3033
3040
  ]);
3034
3041
  });
3035
- return Xr(t, e, n, i);
3042
+ return ei(t, e, n, i);
3036
3043
  }
3037
- function Lo({ attrs: t }, [e, n, r]) {
3044
+ function Fo({ attrs: t }, [e, n, r]) {
3038
3045
  const i = Object.entries(r).flatMap(([s, o]) => {
3039
3046
  const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = _e(t, e, s);
3040
3047
  return u.map((c) => a ? [
@@ -3049,9 +3056,9 @@ function Lo({ attrs: t }, [e, n, r]) {
3049
3056
  Q(t, e, n)
3050
3057
  ]);
3051
3058
  });
3052
- return Xr(t, e, n, i);
3059
+ return ei(t, e, n, i);
3053
3060
  }
3054
- function Fo(t, e, n) {
3061
+ function No(t, e, n) {
3055
3062
  if (Array.isArray(n)) {
3056
3063
  const [r, i] = n;
3057
3064
  for (const s of t || []) {
@@ -3073,18 +3080,18 @@ function Fo(t, e, n) {
3073
3080
  }
3074
3081
  return !1;
3075
3082
  }
3076
- function ei({ stores: t, attrs: e }, [n, r, i, s]) {
3077
- return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Fo(t, n, r) ? { mode: "update" } : null;
3083
+ function ti({ stores: t, attrs: e }, [n, r, i, s]) {
3084
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : No(t, n, r) ? { mode: "update" } : null;
3078
3085
  }
3079
- function No(t, e) {
3080
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = un(o), d = Q(r, i, s);
3086
+ function Ko(t, e) {
3087
+ const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = an(o), d = Q(r, i, s);
3081
3088
  return [["id", d]].concat(Object.entries(a)).map(([f, l]) => {
3082
3089
  const p = K(r, i, f);
3083
3090
  return p["checked-data-type"] === "date" && t.useDateObjects && (l = pt(l)), ["add-triple", d, p.id, l, { mode: "create" }];
3084
3091
  });
3085
3092
  }
3086
- function Ko(t, e) {
3087
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = un(o), d = Q(r, i, s), c = ei(t, [i, d, o, u]);
3093
+ function qo(t, e) {
3094
+ const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = an(o), d = Q(r, i, s), c = ti(t, [i, d, o, u]);
3088
3095
  return [["id", d]].concat(Object.entries(a)).map(([l, p]) => {
3089
3096
  const y = K(r, i, l);
3090
3097
  return y["checked-data-type"] === "date" && t.useDateObjects && (p = pt(p)), [
@@ -3096,11 +3103,11 @@ function Ko(t, e) {
3096
3103
  ];
3097
3104
  });
3098
3105
  }
3099
- function qo({ attrs: t }, [e, n]) {
3106
+ function zo({ attrs: t }, [e, n]) {
3100
3107
  return [["delete-entity", Q(t, e, n), e]];
3101
3108
  }
3102
- function zo(t, e) {
3103
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = un(o), d = Q(r, i, s), c = ei(t, [i, d, o, u]), f = Object.entries(a).map(([p, y]) => {
3109
+ function Vo(t, e) {
3110
+ const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = an(o), d = Q(r, i, s), c = ti(t, [i, d, o, u]), f = Object.entries(a).map(([p, y]) => {
3104
3111
  const b = K(r, i, p);
3105
3112
  return [
3106
3113
  "deep-merge-triple",
@@ -3118,38 +3125,38 @@ function zo(t, e) {
3118
3125
  ...c ? [c] : []
3119
3126
  ]].concat(f);
3120
3127
  }
3121
- function Vo({ attrs: t }, [e, n, r]) {
3128
+ function Wo({ attrs: t }, [e, n, r]) {
3122
3129
  return [["rule-params", Q(t, e, n), e, r]];
3123
3130
  }
3124
- function Wo(t) {
3131
+ function Bo(t) {
3125
3132
  const [e, n, r, i, s] = t;
3126
3133
  if (!i)
3127
3134
  return t;
3128
3135
  const o = Object.assign({}, i);
3129
3136
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
3130
3137
  }
3131
- function Bo(t, e) {
3132
- const [n, ...r] = Wo(e);
3138
+ function Go(t, e) {
3139
+ const [n, ...r] = Bo(e);
3133
3140
  switch (n) {
3134
3141
  case "merge":
3135
- return zo(t, r);
3142
+ return Vo(t, r);
3136
3143
  case "create":
3137
- return No(t, r);
3138
- case "update":
3139
3144
  return Ko(t, r);
3145
+ case "update":
3146
+ return qo(t, r);
3140
3147
  case "link":
3141
- return Uo(t, r);
3142
- case "unlink":
3143
3148
  return Lo(t, r);
3149
+ case "unlink":
3150
+ return Fo(t, r);
3144
3151
  case "delete":
3145
- return qo(t, r);
3152
+ return zo(t, r);
3146
3153
  case "ruleParams":
3147
- return Vo(t, r);
3154
+ return Wo(t, r);
3148
3155
  default:
3149
3156
  throw new Error(`unsupported action ${n}`);
3150
3157
  }
3151
3158
  }
3152
- function Go(t) {
3159
+ function Qo(t) {
3153
3160
  switch (t) {
3154
3161
  case "string":
3155
3162
  case "date":
@@ -3160,14 +3167,14 @@ function Go(t) {
3160
3167
  return;
3161
3168
  }
3162
3169
  }
3163
- function Qo(t, e, n) {
3170
+ function Ho(t, e, n) {
3164
3171
  var r, i;
3165
3172
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
3166
3173
  if (n === "id")
3167
3174
  return null;
3168
3175
  if (!s)
3169
3176
  throw new Error(`${e}.${n} does not exist in your schema`);
3170
- const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Go(s == null ? void 0 : s.valueType);
3177
+ const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Qo(s == null ? void 0 : s.valueType);
3171
3178
  return {
3172
3179
  "index?": u,
3173
3180
  "unique?": o,
@@ -3175,14 +3182,14 @@ function Qo(t, e, n) {
3175
3182
  };
3176
3183
  }
3177
3184
  function nt(t, e, n, r) {
3178
- const i = t ? Qo(t, e, n) : null, s = L(), u = [L(), e, n];
3185
+ const i = t ? Ho(t, e, n) : null, s = L(), u = [L(), e, n];
3179
3186
  return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
3180
3187
  }
3181
- function Ho(t, e, n) {
3188
+ function Yo(t, e, n) {
3182
3189
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
3183
3190
  }
3184
- function Yo(t, e, n) {
3185
- const r = Ho(t, e, n);
3191
+ function Jo(t, e, n) {
3192
+ const r = Yo(t, e, n);
3186
3193
  if (!r)
3187
3194
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
3188
3195
  const { forward: i, reverse: s } = r;
@@ -3195,11 +3202,11 @@ function Yo(t, e, n) {
3195
3202
  "on-delete-reverse": s.onDelete
3196
3203
  };
3197
3204
  }
3198
- function Xn(t, e, n, r) {
3199
- const i = t ? Yo(t, e, n) : null, s = L(), o = [L(), e, n], u = [L(), n, e];
3205
+ function er(t, e, n, r) {
3206
+ const i = t ? Jo(t, e, n) : null, s = L(), o = [L(), e, n], u = [L(), n, e];
3200
3207
  return Object.assign(Object.assign({ id: s, "forward-identity": o, "reverse-identity": u, "value-type": "ref", cardinality: "many", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
3201
3208
  }
3202
- const Jo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Zo = /* @__PURE__ */ new Set(["link", "unlink"]), Xo = /* @__PURE__ */ new Set(["create", "update", "merge"]), eu = /* @__PURE__ */ new Set([
3209
+ const Zo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Xo = /* @__PURE__ */ new Set(["link", "unlink"]), eu = /* @__PURE__ */ new Set(["create", "update", "merge"]), tu = /* @__PURE__ */ new Set([
3203
3210
  "link",
3204
3211
  "unlink",
3205
3212
  "create",
@@ -3207,17 +3214,17 @@ const Jo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
3207
3214
  "merge",
3208
3215
  "delete",
3209
3216
  "ruleParams"
3210
- ]), Ht = { "unique?": !0, "index?": !0 }, tu = Object.assign(Object.assign({}, Ht), { cardinality: "one" });
3211
- function nu(t) {
3217
+ ]), Yt = { "unique?": !0, "index?": !0 }, nu = Object.assign(Object.assign({}, Yt), { cardinality: "one" });
3218
+ function ru(t) {
3212
3219
  const e = [], [n, r, i, s] = t;
3213
- if (!eu.has(n))
3220
+ if (!tu.has(n))
3214
3221
  return e;
3215
- const o = Qt(i);
3222
+ const o = Ht(i);
3216
3223
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
3217
3224
  for (const [u, a] of Object.entries(s)) {
3218
3225
  const d = Array.isArray(a) ? a : [a];
3219
3226
  for (const c of d) {
3220
- const f = Qt(c);
3227
+ const f = Ht(c);
3221
3228
  f && e.push({
3222
3229
  etype: r,
3223
3230
  lookupPair: f,
@@ -3227,7 +3234,7 @@ function nu(t) {
3227
3234
  }
3228
3235
  return e;
3229
3236
  }
3230
- function ru({ attrs: t, schema: e }, n) {
3237
+ function iu({ attrs: t, schema: e }, n) {
3231
3238
  var r, i;
3232
3239
  const [s, o, u] = [/* @__PURE__ */ new Set(), Object.assign({}, t), []];
3233
3240
  function a(f) {
@@ -3238,47 +3245,47 @@ function ru({ attrs: t, schema: e }, n) {
3238
3245
  }
3239
3246
  function c(f, l) {
3240
3247
  const p = K(o, f, l), y = _e(o, f, l);
3241
- d(p), d(y), !p && !y && a(Xn(e, f, l, tu));
3248
+ d(p), d(y), !p && !y && a(er(e, f, l, nu));
3242
3249
  }
3243
3250
  for (const f of n)
3244
- for (const { etype: l, lookupPair: p, linkLabel: y } of nu(f)) {
3251
+ for (const { etype: l, lookupPair: p, linkLabel: y } of ru(f)) {
3245
3252
  const b = p[0];
3246
3253
  if (y) {
3247
3254
  c(l, y);
3248
3255
  const g = K(o, l, y), m = _e(o, l, y);
3249
3256
  d(g), d(m);
3250
3257
  const T = ((r = g == null ? void 0 : g["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = m == null ? void 0 : m["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || y;
3251
- if (Bt(o, T, b))
3252
- c(T, Gt(b));
3258
+ if (Gt(o, T, b))
3259
+ c(T, Qt(b));
3253
3260
  else {
3254
3261
  const v = K(o, T, b);
3255
- v || a(nt(e, T, b, Ht)), d(v);
3262
+ v || a(nt(e, T, b, Yt)), d(v);
3256
3263
  }
3257
- } else if (Bt(o, l, b))
3258
- c(l, Gt(b));
3264
+ } else if (Gt(o, l, b))
3265
+ c(l, Qt(b));
3259
3266
  else {
3260
3267
  const g = K(o, l, b);
3261
- g || a(nt(e, l, b, Ht)), d(g);
3268
+ g || a(nt(e, l, b, Yt)), d(g);
3262
3269
  }
3263
3270
  }
3264
3271
  for (const f of n) {
3265
3272
  const [l, p, y, b] = f;
3266
- if (Jo.has(l)) {
3273
+ if (Zo.has(l)) {
3267
3274
  const g = K(o, p, "id");
3268
3275
  d(g), g || a(nt(e, p, "id", { "unique?": !0 }));
3269
3276
  for (const m of Object.keys(b)) {
3270
3277
  const T = K(o, p, m);
3271
- if (d(T), Xo.has(l) && (T || a(nt(e, p, m, m === "id" ? { "unique?": !0 } : null))), Zo.has(l)) {
3278
+ if (d(T), eu.has(l) && (T || a(nt(e, p, m, m === "id" ? { "unique?": !0 } : null))), Xo.has(l)) {
3272
3279
  const v = _e(o, p, m);
3273
- !T && !v && a(Xn(e, p, m)), d(v);
3280
+ !T && !v && a(er(e, p, m)), d(v);
3274
3281
  }
3275
3282
  }
3276
3283
  }
3277
3284
  }
3278
3285
  return [o, u];
3279
3286
  }
3280
- function iu(t, e) {
3281
- const r = (Array.isArray(e) ? e : [e]).flatMap((a) => Ro(a)), [i, s] = ru(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), u = r.flatMap((a) => Bo(o, a));
3287
+ function su(t, e) {
3288
+ const r = (Array.isArray(e) ? e : [e]).flatMap((a) => $o(a)), [i, s] = iu(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), u = r.flatMap((a) => Go(o, a));
3282
3289
  return [...s, ...u];
3283
3290
  }
3284
3291
  var re = function(t, e, n, r) {
@@ -3308,15 +3315,15 @@ var re = function(t, e, n, r) {
3308
3315
  d((r = r.apply(t, e || [])).next());
3309
3316
  });
3310
3317
  };
3311
- function er(t, e) {
3318
+ function tr(t, e) {
3312
3319
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
3313
3320
  }
3314
3321
  const qe = "__meta";
3315
- class su {
3322
+ class ou {
3316
3323
  constructor(e, n) {
3317
3324
  }
3318
3325
  }
3319
- class Yt {
3326
+ class Jt {
3320
3327
  constructor(e) {
3321
3328
  var n, r;
3322
3329
  this._subs = [], this._nextSave = null, this._nextGc = null, this._pendingSaveKeys = /* @__PURE__ */ new Set(), this._loadedKeys = /* @__PURE__ */ new Set(), this._version = 0, this._meta = {
@@ -3510,7 +3517,7 @@ class Yt {
3510
3517
  gc() {
3511
3518
  this._nextGc || (this._nextGc = setTimeout(
3512
3519
  () => {
3513
- er(() => {
3520
+ tr(() => {
3514
3521
  this._nextGc = null, this._gc();
3515
3522
  }, 30 * 1e3);
3516
3523
  },
@@ -3525,7 +3532,7 @@ class Yt {
3525
3532
  return;
3526
3533
  }
3527
3534
  this._nextSave = setTimeout(() => {
3528
- er(() => {
3535
+ tr(() => {
3529
3536
  this._nextSave = null, this._writeToStorage(e).then(n).catch(r);
3530
3537
  }, this._idleCallbackMaxWaitMs);
3531
3538
  }, this._saveThrottleMs);
@@ -3584,13 +3591,13 @@ var oe = function(t, e, n, r) {
3584
3591
  d((r = r.apply(t, e || [])).next());
3585
3592
  });
3586
3593
  };
3587
- const ou = 6, uu = ["kv", "querySubs", "syncSubs"];
3588
- function au(t) {
3594
+ const uu = 6, au = ["kv", "querySubs", "syncSubs"];
3595
+ function cu(t) {
3589
3596
  return function(n) {
3590
3597
  console.error("Error in IndexedDB event", { source: t, event: n });
3591
3598
  };
3592
3599
  }
3593
- function cu(t) {
3600
+ function du(t) {
3594
3601
  return oe(this, void 0, void 0, function* () {
3595
3602
  return new Promise((e) => {
3596
3603
  const n = indexedDB.open(t);
@@ -3606,7 +3613,7 @@ function cu(t) {
3606
3613
  });
3607
3614
  });
3608
3615
  }
3609
- function du(t, e, n) {
3616
+ function fu(t, e, n) {
3610
3617
  return oe(this, void 0, void 0, function* () {
3611
3618
  const r = (
3612
3619
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3642,7 +3649,7 @@ function du(t, e, n) {
3642
3649
  });
3643
3650
  });
3644
3651
  }
3645
- function tr(t, e, n) {
3652
+ function nr(t, e, n) {
3646
3653
  return oe(this, void 0, void 0, function* () {
3647
3654
  const r = n.put(e, t);
3648
3655
  return new Promise((i, s) => {
@@ -3650,9 +3657,9 @@ function tr(t, e, n) {
3650
3657
  });
3651
3658
  });
3652
3659
  }
3653
- function fu(t, e) {
3660
+ function lu(t, e) {
3654
3661
  return oe(this, void 0, void 0, function* () {
3655
- const n = yield cu(`instant_${t}_5`);
3662
+ const n = yield du(`instant_${t}_5`);
3656
3663
  if (!n)
3657
3664
  return;
3658
3665
  const r = yield new Promise((c, f) => {
@@ -3675,12 +3682,12 @@ function fu(t, e) {
3675
3682
  for (const [c, f] of r)
3676
3683
  switch (c) {
3677
3684
  case "querySubs": {
3678
- const l = du(c, f, o);
3685
+ const l = fu(c, f, o);
3679
3686
  u.push(l);
3680
3687
  break;
3681
3688
  }
3682
3689
  default: {
3683
- const l = tr(c, f, s);
3690
+ const l = nr(c, f, s);
3684
3691
  u.push(l);
3685
3692
  const p = {
3686
3693
  createdAt: Date.now(),
@@ -3691,16 +3698,16 @@ function fu(t, e) {
3691
3698
  break;
3692
3699
  }
3693
3700
  }
3694
- const d = tr(qe, a, s);
3701
+ const d = nr(qe, a, s);
3695
3702
  u.push(d), yield Promise.all(u), yield new Promise((c, f) => {
3696
3703
  i.oncomplete = (l) => c(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
3697
3704
  });
3698
3705
  });
3699
3706
  }
3700
- const nr = /* @__PURE__ */ new Map();
3701
- class ti extends su {
3707
+ const rr = /* @__PURE__ */ new Map();
3708
+ class ni extends ou {
3702
3709
  constructor(e, n) {
3703
- super(e, n), this.dbName = `instant_${e}_${ou}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3710
+ super(e, n), this.dbName = `instant_${e}_${uu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3704
3711
  }
3705
3712
  _init() {
3706
3713
  return new Promise((e, n) => {
@@ -3711,12 +3718,12 @@ class ti extends su {
3711
3718
  }, i.onsuccess = (s) => {
3712
3719
  const u = s.target.result;
3713
3720
  if (r) {
3714
- const a = fu(this._appId, u).catch((d) => {
3715
- au("Error upgrading store from version 5 to 6.")(d);
3721
+ const a = lu(this._appId, u).catch((d) => {
3722
+ cu("Error upgrading store from version 5 to 6.")(d);
3716
3723
  });
3717
- nr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3724
+ rr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3718
3725
  } else {
3719
- const a = nr.get(this.dbName);
3726
+ const a = rr.get(this.dbName);
3720
3727
  a ? a.then(() => e(u)).catch(() => e(u)) : e(u);
3721
3728
  }
3722
3729
  }, i.onupgradeneeded = (s) => {
@@ -3726,7 +3733,7 @@ class ti extends su {
3726
3733
  }
3727
3734
  _upgradeStore(e) {
3728
3735
  const r = e.target.result;
3729
- for (const i of uu)
3736
+ for (const i of au)
3730
3737
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3731
3738
  }
3732
3739
  getItem(e) {
@@ -3801,7 +3808,7 @@ class ti extends su {
3801
3808
  });
3802
3809
  }
3803
3810
  }
3804
- var lu = function(t, e, n, r) {
3811
+ var hu = function(t, e, n, r) {
3805
3812
  function i(s) {
3806
3813
  return s instanceof n ? s : new n(function(o) {
3807
3814
  o(s);
@@ -3828,9 +3835,9 @@ var lu = function(t, e, n, r) {
3828
3835
  d((r = r.apply(t, e || [])).next());
3829
3836
  });
3830
3837
  };
3831
- class ni {
3838
+ class ri {
3832
3839
  static getIsOnline() {
3833
- return lu(this, void 0, void 0, function* () {
3840
+ return hu(this, void 0, void 0, function* () {
3834
3841
  return navigator.onLine;
3835
3842
  });
3836
3843
  }
@@ -3855,7 +3862,7 @@ class je extends Error {
3855
3862
  return "InstantError";
3856
3863
  }
3857
3864
  }
3858
- var hu = function(t, e, n, r) {
3865
+ var pu = function(t, e, n, r) {
3859
3866
  function i(s) {
3860
3867
  return s instanceof n ? s : new n(function(o) {
3861
3868
  o(s);
@@ -3895,7 +3902,7 @@ class bt extends je {
3895
3902
  }
3896
3903
  }
3897
3904
  function te(t, e) {
3898
- return hu(this, void 0, void 0, function* () {
3905
+ return pu(this, void 0, void 0, function* () {
3899
3906
  const n = yield fetch(t, e), r = yield n.json();
3900
3907
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new bt({ status: n.status, body: r }));
3901
3908
  });
@@ -3927,14 +3934,14 @@ var Pe = function(t, e, n, r) {
3927
3934
  d((r = r.apply(t, e || [])).next());
3928
3935
  });
3929
3936
  };
3930
- function pu({ apiURI: t, appId: e, email: n }) {
3937
+ function yu({ apiURI: t, appId: e, email: n }) {
3931
3938
  return te(`${t}/runtime/auth/send_magic_code`, {
3932
3939
  method: "POST",
3933
3940
  headers: { "content-type": "application/json" },
3934
3941
  body: JSON.stringify({ "app-id": e, email: n })
3935
3942
  });
3936
3943
  }
3937
- function yu(t) {
3944
+ function bu(t) {
3938
3945
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
3939
3946
  return yield te(`${e}/runtime/auth/verify_magic_code`, {
3940
3947
  method: "POST",
@@ -3947,7 +3954,7 @@ function yu(t) {
3947
3954
  });
3948
3955
  });
3949
3956
  }
3950
- function bu(t) {
3957
+ function _u(t) {
3951
3958
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3952
3959
  return yield te(`${e}/runtime/auth/verify_refresh_token`, {
3953
3960
  method: "POST",
@@ -3959,7 +3966,7 @@ function bu(t) {
3959
3966
  });
3960
3967
  });
3961
3968
  }
3962
- function _u(t) {
3969
+ function gu(t) {
3963
3970
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
3964
3971
  return yield te(`${e}/runtime/auth/sign_in_guest`, {
3965
3972
  method: "POST",
@@ -3970,7 +3977,7 @@ function _u(t) {
3970
3977
  });
3971
3978
  });
3972
3979
  }
3973
- function rr(t) {
3980
+ function ir(t) {
3974
3981
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, code: r, codeVerifier: i, refreshToken: s }) {
3975
3982
  return yield te(`${e}/runtime/oauth/token`, {
3976
3983
  method: "POST",
@@ -3984,7 +3991,7 @@ function rr(t) {
3984
3991
  });
3985
3992
  });
3986
3993
  }
3987
- function gu(t) {
3994
+ function Tu(t) {
3988
3995
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
3989
3996
  return yield te(`${e}/runtime/oauth/id_token`, {
3990
3997
  method: "POST",
@@ -3999,7 +4006,7 @@ function gu(t) {
3999
4006
  });
4000
4007
  });
4001
4008
  }
4002
- function Tu(t) {
4009
+ function mu(t) {
4003
4010
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
4004
4011
  return yield te(`${e}/runtime/signout`, {
4005
4012
  method: "POST",
@@ -4040,7 +4047,7 @@ var Ge = function(t, e, n, r) {
4040
4047
  d((r = r.apply(t, e || [])).next());
4041
4048
  });
4042
4049
  };
4043
- function mu(t) {
4050
+ function wu(t) {
4044
4051
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
4045
4052
  const a = {
4046
4053
  app_id: n,
@@ -4055,7 +4062,7 @@ function mu(t) {
4055
4062
  });
4056
4063
  });
4057
4064
  }
4058
- function wu(t) {
4065
+ function vu(t) {
4059
4066
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
4060
4067
  const { data: s } = yield te(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
4061
4068
  method: "DELETE",
@@ -4067,7 +4074,7 @@ function wu(t) {
4067
4074
  return s;
4068
4075
  });
4069
4076
  }
4070
- function vu(t) {
4077
+ function Su(t) {
4071
4078
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
4072
4079
  const { data: o } = yield te(`${e}/storage/signed-upload-url`, {
4073
4080
  method: "POST",
@@ -4083,7 +4090,7 @@ function vu(t) {
4083
4090
  return o;
4084
4091
  });
4085
4092
  }
4086
- function Su(t, e) {
4093
+ function Ou(t, e) {
4087
4094
  return Ge(this, void 0, void 0, function* () {
4088
4095
  return (yield fetch(t, {
4089
4096
  method: "PUT",
@@ -4094,7 +4101,7 @@ function Su(t, e) {
4094
4101
  })).ok;
4095
4102
  });
4096
4103
  }
4097
- function Ou(t) {
4104
+ function Eu(t) {
4098
4105
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
4099
4106
  const { data: s } = yield te(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
4100
4107
  method: "GET",
@@ -4106,9 +4113,9 @@ function Ou(t) {
4106
4113
  return s;
4107
4114
  });
4108
4115
  }
4109
- let hn = !1, ri = !1, ii = !1;
4110
- typeof window < "u" && typeof window.localStorage < "u" && (hn = !!window.localStorage.getItem("devBackend"), ri = !!window.localStorage.getItem("__instantLogging"), ii = !!window.localStorage.getItem("__devtoolLocalDash"));
4111
- function ir(t, e) {
4116
+ let pn = !1, ii = !1, si = !1;
4117
+ typeof window < "u" && typeof window.localStorage < "u" && (pn = !!window.localStorage.getItem("devBackend"), ii = !!window.localStorage.getItem("__instantLogging"), si = !!window.localStorage.getItem("__devtoolLocalDash"));
4118
+ function sr(t, e) {
4112
4119
  if (!e)
4113
4120
  return t;
4114
4121
  const n = {};
@@ -4116,33 +4123,33 @@ function ir(t, e) {
4116
4123
  n[r] = t[r];
4117
4124
  }), n;
4118
4125
  }
4119
- function Eu(t, e, n) {
4126
+ function Au(t, e, n) {
4120
4127
  var r, i;
4121
4128
  const s = {
4122
4129
  peers: {}
4123
4130
  };
4124
4131
  if (e && "user" in e ? e.user : !0) {
4125
- const u = ir((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
4132
+ const u = sr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
4126
4133
  s.user = Object.assign(Object.assign({}, u), { peerId: n });
4127
4134
  }
4128
4135
  for (const u of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
4129
4136
  const a = (e == null ? void 0 : e.peers) === void 0, d = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(u));
4130
4137
  if (a || d) {
4131
- const c = ir(t.peers[u], e == null ? void 0 : e.keys);
4138
+ const c = sr(t.peers[u], e == null ? void 0 : e.keys);
4132
4139
  s.peers[u] = Object.assign(Object.assign({}, c), { peerId: u });
4133
4140
  }
4134
4141
  }
4135
4142
  return s;
4136
4143
  }
4137
- function Au(t, e) {
4138
- if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !zn(t.user, e.user)) || !Mr(t.peers, e.peers))
4144
+ function ju(t, e) {
4145
+ if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Vn(t.user, e.user)) || !Rr(t.peers, e.peers))
4139
4146
  return !0;
4140
4147
  for (const r of Object.keys(t.peers))
4141
- if (!zn(t.peers[r], e.peers[r]))
4148
+ if (!Vn(t.peers[r], e.peers[r]))
4142
4149
  return !0;
4143
4150
  return !1;
4144
4151
  }
4145
- class sr {
4152
+ class or {
4146
4153
  constructor() {
4147
4154
  this.promise = new Promise((e, n) => {
4148
4155
  this._resolve = e, this._reject = n;
@@ -4155,20 +4162,20 @@ class sr {
4155
4162
  this._reject(e);
4156
4163
  }
4157
4164
  }
4158
- function si(t, e = []) {
4165
+ function oi(t, e = []) {
4159
4166
  t.forEach((n) => {
4160
4167
  const { data: r } = n, { "datalog-result": i } = r, { "join-rows": s } = i;
4161
4168
  for (const o of s)
4162
4169
  for (const u of o)
4163
4170
  e.push(u);
4164
- si(n["child-nodes"], e);
4171
+ oi(n["child-nodes"], e);
4165
4172
  });
4166
4173
  }
4167
- function or(t) {
4174
+ function ur(t) {
4168
4175
  const e = [];
4169
- return si(t, e), e;
4176
+ return oi(t, e), e;
4170
4177
  }
4171
- function ur(t) {
4178
+ function ar(t) {
4172
4179
  return Object.values(t.links).reduce((e, n) => {
4173
4180
  var r, i, s, o;
4174
4181
  return (r = e[s = n.forward.on]) !== null && r !== void 0 || (e[s] = {}), e[n.forward.on][n.forward.label] = {
@@ -4182,8 +4189,8 @@ function ur(t) {
4182
4189
  }, e;
4183
4190
  }, {});
4184
4191
  }
4185
- const oi = "v0.22.83";
4186
- function ju(t, e) {
4192
+ const ui = "v0.22.84-experimental.drewh-entity-caching.20106835282.1";
4193
+ function ku(t, e) {
4187
4194
  return {
4188
4195
  info: t ? (...n) => console.info(...n, e()) : () => {
4189
4196
  },
@@ -4221,7 +4228,7 @@ class M extends Error {
4221
4228
  super(r), this.name = "QueryValidationError";
4222
4229
  }
4223
4230
  }
4224
- const ar = [
4231
+ const cr = [
4225
4232
  "where",
4226
4233
  "order",
4227
4234
  "limit",
@@ -4232,7 +4239,7 @@ const ar = [
4232
4239
  "before",
4233
4240
  "fields",
4234
4241
  "aggregate"
4235
- ], ku = (t) => t.valueType || "unknown", ui = (t, e, n = !1) => {
4242
+ ], Cu = (t) => t.valueType || "unknown", ai = (t, e, n = !1) => {
4236
4243
  if (n || t == null)
4237
4244
  return !0;
4238
4245
  switch (e) {
@@ -4247,9 +4254,9 @@ const ar = [
4247
4254
  default:
4248
4255
  return !0;
4249
4256
  }
4250
- }, Cu = (t, e, n, r, i, s, o) => {
4257
+ }, Pu = (t, e, n, r, i, s, o) => {
4251
4258
  const u = s.valueType === "json", a = (d, c, f) => {
4252
- if (!ui(f, c, u))
4259
+ if (!ai(f, c, u))
4253
4260
  throw new M(`Invalid value for operator '${d}' on attribute '${r}' in entity '${i}'. Expected ${c}, but received: ${typeof f}`, o);
4254
4261
  };
4255
4262
  switch (t) {
@@ -4280,16 +4287,16 @@ const ar = [
4280
4287
  throw new M(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
4281
4288
  }
4282
4289
  }, Oe = (t, e, n, r, i) => {
4283
- const s = ku(n), o = n.valueType === "json";
4290
+ const s = Cu(n), o = n.valueType === "json";
4284
4291
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
4285
4292
  if (o)
4286
4293
  return;
4287
4294
  const a = t;
4288
4295
  for (const [d, c] of Object.entries(a))
4289
- Cu(d, c, s, e, r, n, `${i}.${d}`);
4290
- } else if (!ui(t, s, o))
4296
+ Pu(d, c, s, e, r, n, `${i}.${d}`);
4297
+ } else if (!ai(t, s, o))
4291
4298
  throw new M(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
4292
- }, Pu = (t, e, n, r, i) => {
4299
+ }, Iu = (t, e, n, r, i) => {
4293
4300
  const s = t.split(".");
4294
4301
  if (s.length < 2)
4295
4302
  throw new M(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -4326,12 +4333,12 @@ const ar = [
4326
4333
  throw new M(`Attribute '${u}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${c.length > 0 ? c.join(", ") + ", id" : "id"}`, i);
4327
4334
  }
4328
4335
  Oe(e, t, d, n, i);
4329
- }, ai = (t, e, n, r) => {
4336
+ }, ci = (t, e, n, r) => {
4330
4337
  for (const [i, s] of Object.entries(t)) {
4331
4338
  if (i === "or" || i === "and") {
4332
4339
  if (Array.isArray(s))
4333
4340
  for (const d of s)
4334
- typeof d == "object" && d !== null && ai(d, e, n, `${r}.${i}[${d}]`);
4341
+ typeof d == "object" && d !== null && ci(d, e, n, `${r}.${i}[${d}]`);
4335
4342
  continue;
4336
4343
  }
4337
4344
  if (i === "id") {
@@ -4339,7 +4346,7 @@ const ar = [
4339
4346
  continue;
4340
4347
  }
4341
4348
  if (i.includes(".")) {
4342
- Pu(i, s, e, n, `${r}.${i}`);
4349
+ Iu(i, s, e, n, `${r}.${i}`);
4343
4350
  continue;
4344
4351
  }
4345
4352
  const o = n.entities[e];
@@ -4359,10 +4366,10 @@ const ar = [
4359
4366
  Oe(s, i, d, e, `${r}.${i}`);
4360
4367
  }
4361
4368
  }
4362
- }, Iu = (t, e, n, r, i = 0) => {
4369
+ }, Mu = (t, e, n, r, i = 0) => {
4363
4370
  for (const o of Object.keys(t))
4364
- if (!ar.includes(o))
4365
- throw new M(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${ar.join(", ")}. Found: ${o}`, r);
4371
+ if (!cr.includes(o))
4372
+ throw new M(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${cr.join(", ")}. Found: ${o}`, r);
4366
4373
  const s = [
4367
4374
  // 'limit', // only supported client side
4368
4375
  "offset",
@@ -4377,9 +4384,9 @@ const ar = [
4377
4384
  if (t.where && n) {
4378
4385
  if (typeof t.where != "object" || t.where === null)
4379
4386
  throw new M(`'where' clause must be an object in entity '${e}', but received: ${typeof t.where}`, r ? `${r}.where` : void 0);
4380
- ai(t.where, e, n, r ? `${r}.where` : "where");
4387
+ ci(t.where, e, n, r ? `${r}.where` : "where");
4381
4388
  }
4382
- }, ci = (t, e, n, r, i = 0) => {
4389
+ }, di = (t, e, n, r, i = 0) => {
4383
4390
  var s;
4384
4391
  if (!t || typeof t != "object")
4385
4392
  throw new M(`Query part for entity '${e}' must be an object, but received: ${typeof t}`, r);
@@ -4392,15 +4399,15 @@ const ar = [
4392
4399
  const u = t[o];
4393
4400
  if (typeof u == "object" && u !== null) {
4394
4401
  const a = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
4395
- a && ci(u, a, n, `${r}.${o}`, i + 1);
4402
+ a && di(u, a, n, `${r}.${o}`, i + 1);
4396
4403
  }
4397
4404
  } else {
4398
4405
  const u = t[o];
4399
4406
  if (typeof u != "object" || u === null)
4400
4407
  throw new M(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
4401
- Iu(u, e, n, `${r}.$`, i);
4408
+ Mu(u, e, n, `${r}.$`, i);
4402
4409
  }
4403
- }, cr = (t, e) => {
4410
+ }, dr = (t, e) => {
4404
4411
  if (typeof t != "object" || t === null)
4405
4412
  throw new M(`Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`);
4406
4413
  if (Array.isArray(t))
@@ -4416,67 +4423,67 @@ const ar = [
4416
4423
  const i = Object.keys(e.entities);
4417
4424
  throw new M(`Entity '${r}' does not exist in schema. Available entities: ${i.length > 0 ? i.join(", ") : "none"}`, r);
4418
4425
  }
4419
- ci(n[r], r, e, r, 0);
4426
+ di(n[r], r, e, r, 0);
4420
4427
  }
4421
4428
  }
4422
- }, dr = (t) => typeof t != "string" ? !1 : ht(t) ? !0 : Ee(t);
4429
+ }, fr = (t) => typeof t != "string" ? !1 : ht(t) ? !0 : Ee(t);
4423
4430
  class Z extends Error {
4424
4431
  constructor(e) {
4425
4432
  super(e), this.name = "TransactionValidationError";
4426
4433
  }
4427
4434
  }
4428
- const di = (t) => t.length > 0 ? t.join(", ") : "none", Mu = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${di(e)}`), fr = {
4435
+ const fi = (t) => t.length > 0 ? t.join(", ") : "none", Ru = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${fi(e)}`), lr = {
4429
4436
  string: (t) => typeof t == "string",
4430
4437
  number: (t) => typeof t == "number" && !isNaN(t),
4431
4438
  boolean: (t) => typeof t == "boolean",
4432
4439
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
4433
4440
  json: () => !0
4434
- }, Ru = (t, e) => {
4441
+ }, $u = (t, e) => {
4435
4442
  var n, r;
4436
- return t == null ? !0 : (r = (n = fr[e.valueType]) === null || n === void 0 ? void 0 : n.call(fr, t)) !== null && r !== void 0 ? r : !1;
4437
- }, fi = (t, e) => {
4443
+ return t == null ? !0 : (r = (n = lr[e.valueType]) === null || n === void 0 ? void 0 : n.call(lr, t)) !== null && r !== void 0 ? r : !1;
4444
+ }, li = (t, e) => {
4438
4445
  const n = e.entities[t];
4439
4446
  if (!n)
4440
- throw Mu(t, Object.keys(e.entities));
4447
+ throw Ru(t, Object.keys(e.entities));
4441
4448
  return n;
4442
- }, Ct = (t, e, n) => {
4443
- const r = fi(t, n);
4449
+ }, Pt = (t, e, n) => {
4450
+ const r = li(t, n);
4444
4451
  if (typeof e != "object" || e === null)
4445
4452
  throw new Z(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);
4446
4453
  for (const [i, s] of Object.entries(e)) {
4447
4454
  if (i === "id")
4448
4455
  continue;
4449
4456
  const o = r.attrs[i];
4450
- if (o && !Ru(s, o))
4457
+ if (o && !$u(s, o))
4451
4458
  throw new Z(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
4452
4459
  }
4453
- }, lr = (t, e, n) => {
4454
- const r = fi(t, n);
4460
+ }, hr = (t, e, n) => {
4461
+ const r = li(t, n);
4455
4462
  if (typeof e != "object" || e === null)
4456
4463
  throw new Z(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
4457
4464
  for (const [i, s] of Object.entries(e)) {
4458
4465
  if (!r.links[i]) {
4459
4466
  const u = Object.keys(r.links);
4460
- throw new Z(`Link '${i}' does not exist on entity '${t}'. Available links: ${di(u)}`);
4467
+ throw new Z(`Link '${i}' does not exist on entity '${t}'. Available links: ${fi(u)}`);
4461
4468
  }
4462
4469
  if (s != null) {
4463
4470
  if (Array.isArray(s)) {
4464
4471
  for (const u of s)
4465
- if (!dr(u))
4472
+ if (!fr(u))
4466
4473
  throw new Z(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${u}`);
4467
- } else if (!dr(s))
4474
+ } else if (!fr(s))
4468
4475
  throw new Z(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
4469
4476
  }
4470
4477
  }
4471
- }, $u = {
4472
- create: Ct,
4473
- update: Ct,
4474
- merge: Ct,
4475
- link: lr,
4476
- unlink: lr,
4478
+ }, xu = {
4479
+ create: Pt,
4480
+ update: Pt,
4481
+ merge: Pt,
4482
+ link: hr,
4483
+ unlink: hr,
4477
4484
  delete: () => {
4478
4485
  }
4479
- }, xu = (t, e) => {
4486
+ }, Du = (t, e) => {
4480
4487
  if (!e)
4481
4488
  return;
4482
4489
  const [n, r, i, s] = t;
@@ -4484,9 +4491,9 @@ const di = (t) => t.length > 0 ? t.join(", ") : "none", Mu = (t, e) => new Z(`En
4484
4491
  throw new Z(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
4485
4492
  if (typeof r != "string")
4486
4493
  throw new Z(`Entity name must be a string, but received: ${typeof r}`);
4487
- const o = $u[n];
4494
+ const o = xu[n];
4488
4495
  o && s !== void 0 && o(r, s, e);
4489
- }, Du = (t, e) => {
4496
+ }, Uu = (t, e) => {
4490
4497
  const n = Array.isArray(t) ? t : [t];
4491
4498
  for (const r of n) {
4492
4499
  if (!r || typeof r != "object")
@@ -4496,11 +4503,11 @@ const di = (t) => t.length > 0 ? t.join(", ") : "none", Mu = (t, e) => new Z(`En
4496
4503
  for (const i of r.__ops) {
4497
4504
  if (!Array.isArray(i))
4498
4505
  throw new Z(`Transaction operation must be an array, but received: ${typeof i}`);
4499
- xu(i, e);
4506
+ Du(i, e);
4500
4507
  }
4501
4508
  }
4502
4509
  };
4503
- var hr = function(t, e, n, r) {
4510
+ var pr = function(t, e, n, r) {
4504
4511
  function i(s) {
4505
4512
  return s instanceof n ? s : new n(function(o) {
4506
4513
  o(s);
@@ -4527,10 +4534,10 @@ var hr = function(t, e, n, r) {
4527
4534
  d((r = r.apply(t, e || [])).next());
4528
4535
  });
4529
4536
  };
4530
- let li = 0;
4531
- class pr {
4537
+ let hi = 0;
4538
+ class yr {
4532
4539
  constructor(e) {
4533
- this.type = "ws", this.id = `${this.type}_${li++}`, this.conn = new WebSocket(e), this.conn.onopen = (n) => {
4540
+ this.type = "ws", this.id = `${this.type}_${hi++}`, this.conn = new WebSocket(e), this.conn.onopen = (n) => {
4534
4541
  this.onopen && this.onopen({ target: this });
4535
4542
  }, this.conn.onmessage = (n) => {
4536
4543
  this.onmessage && this.onmessage({
@@ -4558,9 +4565,9 @@ class pr {
4558
4565
  return this.conn.send(JSON.stringify(e));
4559
4566
  }
4560
4567
  }
4561
- class Uu {
4568
+ class Lu {
4562
4569
  constructor(e, n) {
4563
- this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${li++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4570
+ this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${hi++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4564
4571
  this.initParams || this.handleError();
4565
4572
  }, 1e4), this.conn.onmessage = (r) => {
4566
4573
  const i = JSON.parse(r.data);
@@ -4599,7 +4606,7 @@ class Uu {
4599
4606
  this.conn.close(), this.onclose && !this.closeFired && (this.closeFired = !0, this.onclose({ target: this }));
4600
4607
  }
4601
4608
  postMessages(e) {
4602
- return hr(this, void 0, void 0, function* () {
4609
+ return pr(this, void 0, void 0, function* () {
4603
4610
  var n, r, i;
4604
4611
  try {
4605
4612
  (yield fetch(this.url, {
@@ -4618,7 +4625,7 @@ class Uu {
4618
4625
  });
4619
4626
  }
4620
4627
  flushQueue() {
4621
- return hr(this, void 0, void 0, function* () {
4628
+ return pr(this, void 0, void 0, function* () {
4622
4629
  if (this.sendPromise || !this.sendQueue.length)
4623
4630
  return;
4624
4631
  const e = this.sendQueue;
@@ -4644,7 +4651,7 @@ class Uu {
4644
4651
  this.handleClose();
4645
4652
  }
4646
4653
  }
4647
- var yr = function(t, e, n, r) {
4654
+ var br = function(t, e, n, r) {
4648
4655
  function i(s) {
4649
4656
  return s instanceof n ? s : new n(function(o) {
4650
4657
  o(s);
@@ -4671,34 +4678,34 @@ var yr = function(t, e, n, r) {
4671
4678
  d((r = r.apply(t, e || [])).next());
4672
4679
  });
4673
4680
  };
4674
- function Lu(t, e) {
4681
+ function Fu(t, e) {
4675
4682
  const n = t.values;
4676
4683
  if (n)
4677
4684
  for (const r of n.entities || [])
4678
- r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Lr(r.store);
4685
+ r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Fr(r.store);
4679
4686
  return t;
4680
4687
  }
4681
- function Fu(t, e) {
4688
+ function Nu(t, e) {
4682
4689
  var n, r;
4683
4690
  if (!((n = e.values) === null || n === void 0) && n.entities) {
4684
4691
  const i = [];
4685
4692
  for (const s of (r = e.values) === null || r === void 0 ? void 0 : r.entities) {
4686
- const o = Ur(s.store);
4693
+ const o = Lr(s.store);
4687
4694
  delete o.attrs, i.push(Object.assign(Object.assign({}, s), { store: o }));
4688
4695
  }
4689
4696
  return Object.assign(Object.assign({}, e), { values: Object.assign(Object.assign({}, e.values), { entities: i }) });
4690
4697
  } else
4691
4698
  return e;
4692
4699
  }
4693
- function Nu(t, e, n) {
4700
+ function Ku(t, e, n) {
4694
4701
  var r, i;
4695
4702
  const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
4696
4703
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
4697
4704
  }
4698
- function Pt(t, e) {
4699
- return Jr({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4705
+ function It(t, e) {
4706
+ return Zr({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4700
4707
  }
4701
- function br(t, e, n) {
4708
+ function _r(t, e, n) {
4702
4709
  var r;
4703
4710
  const i = (r = fe(e, t.table, "id")) === null || r === void 0 ? void 0 : r.id;
4704
4711
  if (!i)
@@ -4706,18 +4713,18 @@ function br(t, e, n) {
4706
4713
  const s = Ce(e.eav, [n, i, n]);
4707
4714
  return s ? s[3] : -1;
4708
4715
  }
4709
- function _r(t, e) {
4716
+ function gr(t, e) {
4710
4717
  for (const { action: n, triple: r } of e)
4711
4718
  switch (n) {
4712
4719
  case "added":
4713
- Kr(t, r);
4720
+ qr(t, r);
4714
4721
  break;
4715
4722
  case "removed":
4716
- Fr(t, r);
4723
+ Nr(t, r);
4717
4724
  break;
4718
4725
  }
4719
4726
  }
4720
- function Ku(t, e) {
4727
+ function qu(t, e) {
4721
4728
  var n, r, i, s;
4722
4729
  const o = {};
4723
4730
  for (const { action: u, triple: a } of e) {
@@ -4745,14 +4752,14 @@ function Ku(t, e) {
4745
4752
  function rt(t, e) {
4746
4753
  return { [t.table]: e.map((n) => n.entity) };
4747
4754
  }
4748
- function qu(t, e) {
4755
+ function zu(t, e) {
4749
4756
  var n;
4750
4757
  if (t.orderFieldType)
4751
4758
  return t.orderFieldType;
4752
4759
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = fe(e([]), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4753
4760
  return t.orderFieldType = r, r;
4754
4761
  }
4755
- function zu(t, e, n) {
4762
+ function Vu(t, e, n) {
4756
4763
  const r = e;
4757
4764
  if (t.orderField === "serverCreatedAt") {
4758
4765
  n.sort(t.orderDirection === "asc" ? function(o, u) {
@@ -4773,13 +4780,13 @@ var pe;
4773
4780
  (function(t) {
4774
4781
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4775
4782
  })(pe || (pe = {}));
4776
- class Vu {
4783
+ class Wu {
4777
4784
  constructor(e, n, r, i, s) {
4778
- this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new Yt({
4785
+ this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new Jt({
4779
4786
  persister: n,
4780
- merge: Nu,
4781
- serialize: Fu,
4782
- parse: (o, u) => Lu(u, this.config.useDateObjects),
4787
+ merge: Ku,
4788
+ serialize: Nu,
4789
+ parse: (o, u) => Fu(u, this.config.useDateObjects),
4783
4790
  objectSize: (o) => {
4784
4791
  var u;
4785
4792
  return ((u = o.values) === null || u === void 0 ? void 0 : u.entities.length) || 0;
@@ -4836,7 +4843,7 @@ class Vu {
4836
4843
  });
4837
4844
  }
4838
4845
  initSubscription(e, n, r) {
4839
- return yr(this, void 0, void 0, function* () {
4846
+ return br(this, void 0, void 0, function* () {
4840
4847
  var i, s, o, u;
4841
4848
  yield this.subs.waitForKeyToLoad(n);
4842
4849
  const a = this.subs.currentValue[n];
@@ -4862,7 +4869,7 @@ class Vu {
4862
4869
  });
4863
4870
  }
4864
4871
  flushPending() {
4865
- return yr(this, void 0, void 0, function* () {
4872
+ return br(this, void 0, void 0, function* () {
4866
4873
  for (const e of Object.keys(this.callbacks)) {
4867
4874
  yield this.subs.waitForKeyToLoad(e);
4868
4875
  const n = this.subs.currentValue[e];
@@ -4907,11 +4914,11 @@ class Vu {
4907
4914
  for (const c of i) {
4908
4915
  const f = this.createStore(c);
4909
4916
  a.attrs = f.attrs;
4910
- const l = Pt(u, f);
4917
+ const l = It(u, f);
4911
4918
  d.push({
4912
4919
  store: f,
4913
4920
  entity: l,
4914
- serverCreatedAt: br(u, f, l.id)
4921
+ serverCreatedAt: _r(u, f, l.id)
4915
4922
  }), o.push(l);
4916
4923
  }
4917
4924
  this.subs.updateInPlace((c) => {
@@ -4981,9 +4988,9 @@ class Vu {
4981
4988
  e: for (const [T, v] of Object.entries(f))
4982
4989
  for (let k = 0; k < p.length; k++) {
4983
4990
  const S = p[k];
4984
- if (vs(S.store, T)) {
4985
- _r(S.store, v);
4986
- const I = Pt(u, S.store), R = Ku(S.store, v)[T];
4991
+ if (Ss(S.store, T)) {
4992
+ gr(S.store, v);
4993
+ const I = It(u, S.store), R = qu(S.store, v)[T];
4987
4994
  I ? (y.push({
4988
4995
  oldEntity: S.entity,
4989
4996
  newEntity: I,
@@ -4995,8 +5002,8 @@ class Vu {
4995
5002
  const b = [];
4996
5003
  for (const [T, v] of Object.entries(f)) {
4997
5004
  const k = this.createStore([]);
4998
- l.attrs = k.attrs, _r(k, v);
4999
- const S = Pt(u, k);
5005
+ l.attrs = k.attrs, gr(k, v);
5006
+ const S = It(u, k);
5000
5007
  if (!S) {
5001
5008
  this.log.error("No entity found after applying change", {
5002
5009
  sub: u,
@@ -5008,14 +5015,14 @@ class Vu {
5008
5015
  p.push({
5009
5016
  store: k,
5010
5017
  entity: S,
5011
- serverCreatedAt: br(u, k, S.id)
5018
+ serverCreatedAt: _r(u, k, S.id)
5012
5019
  }), b.push(S);
5013
5020
  }
5014
5021
  const g = [];
5015
5022
  for (const T of c.sort().reverse())
5016
5023
  g.push(p[T].entity), p.splice(T, 1);
5017
- const m = qu(u, this.createStore);
5018
- zu(u, m, p), this.notifyCbs(o, {
5024
+ const m = zu(u, this.createStore);
5025
+ Vu(u, m, p), this.notifyCbs(o, {
5019
5026
  type: pe.SyncTransaction,
5020
5027
  data: rt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
5021
5028
  added: b,
@@ -5082,7 +5089,7 @@ var U = function(t, e, n, r) {
5082
5089
  }
5083
5090
  d((r = r.apply(t, e || [])).next());
5084
5091
  });
5085
- }, Wu = function(t, e) {
5092
+ }, Bu = function(t, e) {
5086
5093
  var n = {};
5087
5094
  for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
5088
5095
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
@@ -5096,46 +5103,46 @@ const se = {
5096
5103
  AUTHENTICATED: "authenticated",
5097
5104
  CLOSED: "closed",
5098
5105
  ERRORED: "errored"
5099
- }, Bu = 3e4, Gu = 3e4, Qu = 200, Hu = {
5106
+ }, Gu = 3e4, Qu = 3e4, Hu = 200, Yu = {
5100
5107
  apiURI: "https://api.instantdb.com",
5101
5108
  websocketURI: "wss://api.instantdb.com/runtime/session"
5102
- }, It = "_instant_oauth_redirect", De = "currentUser";
5103
- function Yu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
5109
+ }, Mt = "_instant_oauth_redirect", De = "currentUser";
5110
+ function Ju({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
5104
5111
  if (!i)
5105
- return new pr(`${r}?app_id=${e}`);
5112
+ return new yr(`${r}?app_id=${e}`);
5106
5113
  switch (t) {
5107
5114
  case "ws":
5108
- return new pr(`${r}?app_id=${e}`);
5115
+ return new yr(`${r}?app_id=${e}`);
5109
5116
  case "sse":
5110
- return new Uu(i, `${n}/runtime/sse?app_id=${e}`);
5117
+ return new Lu(i, `${n}/runtime/sse?app_id=${e}`);
5111
5118
  default:
5112
5119
  throw new Error("Unknown transport type " + t);
5113
5120
  }
5114
5121
  }
5115
- function Ju() {
5122
+ function Zu() {
5116
5123
  return typeof window < "u" || typeof chrome < "u";
5117
5124
  }
5118
- const gr = {
5125
+ const Tr = {
5119
5126
  "set-presence": !0,
5120
5127
  "set-presence-ok": !0,
5121
5128
  "refresh-presence": !0,
5122
5129
  "patch-presence": !0
5123
5130
  };
5124
- function Zu(t, e) {
5131
+ function Xu(t, e) {
5125
5132
  var n;
5126
5133
  const r = typeof t == "string" ? JSON.parse(t) : t;
5127
5134
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
5128
5135
  const i = r.result.store;
5129
- r.result.store = Lr(Object.assign(Object.assign({}, i), { useDateObjects: e }));
5136
+ r.result.store = Fr(Object.assign(Object.assign({}, i), { useDateObjects: e }));
5130
5137
  }
5131
5138
  return r;
5132
5139
  }
5133
- function Xu(t, e) {
5140
+ function ea(t, e) {
5134
5141
  var n;
5135
5142
  const r = Object.assign({}, e);
5136
- return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Ur(e.result.store) })), r;
5143
+ return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Lr(e.result.store) })), r;
5137
5144
  }
5138
- function ea(t, e) {
5145
+ function ta(t, e) {
5139
5146
  switch (t) {
5140
5147
  case "pendingMutations":
5141
5148
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -5143,7 +5150,7 @@ function ea(t, e) {
5143
5150
  return e;
5144
5151
  }
5145
5152
  }
5146
- function ta(t, e) {
5153
+ function na(t, e) {
5147
5154
  switch (t) {
5148
5155
  case "pendingMutations":
5149
5156
  return [...e.entries()];
@@ -5151,18 +5158,18 @@ function ta(t, e) {
5151
5158
  return e;
5152
5159
  }
5153
5160
  }
5154
- function na(t, e, n) {
5161
+ function ra(t, e, n) {
5155
5162
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
5156
5163
  return r && !i && n && (n.result = r), n || e;
5157
5164
  }
5158
- function Tr(t) {
5165
+ function mr(t) {
5159
5166
  return [...t].sort((e, n) => {
5160
5167
  const [r, i] = e, [s, o] = n, u = i.order || 0, a = o.order || 0;
5161
5168
  return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
5162
5169
  });
5163
5170
  }
5164
- class ra {
5165
- constructor(e, n = ti, r = ni, i, s) {
5171
+ class ia {
5172
+ constructor(e, n = ni, r = ri, i, s) {
5166
5173
  var o, u, a;
5167
5174
  if (this._isOnline = !0, this._isShutdown = !1, this.status = se.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (d, c, f) => {
5168
5175
  var l, p;
@@ -5194,9 +5201,9 @@ class ra {
5194
5201
  }, this.notifyQueryError = (d, c) => {
5195
5202
  (this.queryCbs[d] || []).forEach((l) => l.cb({ error: c }));
5196
5203
  }, this.pushTx = (d) => {
5197
- this.config.disableValidation || Du(d, this.config.schema);
5204
+ this.config.disableValidation || Uu(d, this.config.schema);
5198
5205
  try {
5199
- const c = iu({
5206
+ const c = su({
5200
5207
  attrs: this.optimisticAttrs(),
5201
5208
  schema: this.config.schema,
5202
5209
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -5220,7 +5227,7 @@ class ra {
5220
5227
  this._updatePendingMutations((g) => {
5221
5228
  g.set(f, y);
5222
5229
  });
5223
- const b = new sr();
5230
+ const b = new or();
5224
5231
  return this.mutationDeferredStore.set(f, b), this._sendMutation(f, y), this.notifyAll(), b.promise;
5225
5232
  }, this._transportOnOpen = (d) => {
5226
5233
  const c = d.target;
@@ -5285,7 +5292,7 @@ class ra {
5285
5292
  return;
5286
5293
  }
5287
5294
  this._log.info("[socket][close]", c.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
5288
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Hu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Gu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Qu, this._log = ju(e.verbose || hn || ri, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": oi }), this.config.schema && (this._linkIndex = ur(this.config.schema)), !!Ju()) {
5295
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Yu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Qu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Hu, this._log = ku(e.verbose || pn || ii, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": ui }), this.config.schema && (this._linkIndex = ar(this.config.schema)), !!Zu()) {
5289
5296
  if (!e.appId)
5290
5297
  throw new Error("Instant must be initialized with an appId.");
5291
5298
  if (!Ee(e.appId))
@@ -5300,7 +5307,7 @@ class ra {
5300
5307
  } catch (f) {
5301
5308
  this._log.error("[error] handle broadcast channel", f);
5302
5309
  }
5303
- }))), this._initStorage(n), this._syncTable = new Vu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5310
+ }))), this._initStorage(n), this._syncTable = new Wu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5304
5311
  useDateObjects: this.config.useDateObjects
5305
5312
  }, this._log, (d) => at(this.attrs, d, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
5306
5313
  this._isOnline = d, this._startSocket(), r.listen((c) => {
@@ -5310,7 +5317,7 @@ class ra {
5310
5317
  }
5311
5318
  }
5312
5319
  updateSchema(e) {
5313
- this.config = Object.assign(Object.assign({}, this.config), { schema: e, cardinalityInference: !!e }), this._linkIndex = e ? ur(this.config.schema) : null;
5320
+ this.config = Object.assign(Object.assign({}, this.config), { schema: e, cardinalityInference: !!e }), this._linkIndex = e ? ar(this.config.schema) : null;
5314
5321
  }
5315
5322
  _reactorStats() {
5316
5323
  return {
@@ -5323,11 +5330,11 @@ class ra {
5323
5330
  this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
5324
5331
  }
5325
5332
  _initStorage(e) {
5326
- this.querySubs = new Yt({
5333
+ this.querySubs = new Jt({
5327
5334
  persister: new e(this.config.appId, "querySubs"),
5328
- merge: na,
5329
- serialize: Xu,
5330
- parse: (n, r) => Zu(r, this.config.useDateObjects),
5335
+ merge: ra,
5336
+ serialize: ea,
5337
+ parse: (n, r) => Xu(r, this.config.useDateObjects),
5331
5338
  // objectSize
5332
5339
  objectSize: (n) => {
5333
5340
  var r, i, s, o;
@@ -5343,11 +5350,11 @@ class ra {
5343
5350
  maxSize: 1e6
5344
5351
  // 1 million triples
5345
5352
  }
5346
- }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Yt({
5353
+ }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Jt({
5347
5354
  persister: new e(this.config.appId, "kv"),
5348
5355
  merge: this._onMergeKv,
5349
- serialize: ta,
5350
- parse: ea,
5356
+ serialize: na,
5357
+ parse: ta,
5351
5358
  objectSize: () => 0,
5352
5359
  logger: this._log,
5353
5360
  saveThrottleMs: 100,
@@ -5378,7 +5385,7 @@ class ra {
5378
5385
  if (s)
5379
5386
  i.resolve({ status: e, eventId: n });
5380
5387
  else if (r != null && r.type) {
5381
- const { status: o } = r, u = Wu(r, ["status"]);
5388
+ const { status: o } = r, u = Bu(r, ["status"]);
5382
5389
  i.reject(new bt({
5383
5390
  // @ts-expect-error body.type is not constant typed
5384
5391
  body: u,
@@ -5402,7 +5409,7 @@ class ra {
5402
5409
  _handleReceive(e, n) {
5403
5410
  var r, i, s, o, u, a;
5404
5411
  const d = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
5405
- switch (gr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5412
+ switch (Tr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5406
5413
  case "init-ok": {
5407
5414
  this._setStatus(se.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
5408
5415
  for (const l of Object.keys(this._rooms)) {
@@ -5419,7 +5426,7 @@ class ra {
5419
5426
  const { q: l, result: p } = n, y = N(l);
5420
5427
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
5421
5428
  break;
5422
- const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], g = (a = (u = p == null ? void 0 : p[0]) === null || u === void 0 ? void 0 : u.data) === null || a === void 0 ? void 0 : a.aggregate, m = or(p), T = at(this.attrs, m, d, this._linkIndex, this.config.useDateObjects);
5429
+ const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], g = (a = (u = p == null ? void 0 : p[0]) === null || u === void 0 ? void 0 : u.data) === null || a === void 0 ? void 0 : a.aggregate, m = ur(p), T = at(this.attrs, m, d, this._linkIndex, this.config.useDateObjects);
5423
5430
  this.querySubs.updateInPlace((v) => {
5424
5431
  if (!v[y]) {
5425
5432
  this._log.info("Missing value in querySubs", { hash: y, q: l });
@@ -5457,9 +5464,9 @@ class ra {
5457
5464
  b !== this._pendingMutations() && this.kv.updateInPlace((T) => {
5458
5465
  T.pendingMutations = b;
5459
5466
  });
5460
- const g = Tr(b.entries()), m = l.map((T) => {
5467
+ const g = mr(b.entries()), m = l.map((T) => {
5461
5468
  var v, k, S, I;
5462
- const R = T["instaql-query"], q = T["instaql-result"], Ie = N(R), Qe = or(q), _t = at(this.attrs, Qe, d, this._linkIndex, this.config.useDateObjects), gt = this._applyOptimisticUpdates(_t, g, y), He = (k = (v = q == null ? void 0 : q[0]) === null || v === void 0 ? void 0 : v.data) === null || k === void 0 ? void 0 : k["page-info"], ne = (I = (S = q == null ? void 0 : q[0]) === null || S === void 0 ? void 0 : S.data) === null || I === void 0 ? void 0 : I.aggregate;
5469
+ const R = T["instaql-query"], q = T["instaql-result"], Ie = N(R), Qe = ur(q), _t = at(this.attrs, Qe, d, this._linkIndex, this.config.useDateObjects), gt = this._applyOptimisticUpdates(_t, g, y), He = (k = (v = q == null ? void 0 : q[0]) === null || v === void 0 ? void 0 : v.data) === null || k === void 0 ? void 0 : k["page-info"], ne = (I = (S = q == null ? void 0 : q[0]) === null || S === void 0 ? void 0 : S.data) === null || I === void 0 ? void 0 : I.aggregate;
5463
5470
  return { q: R, hash: Ie, store: gt, pageInfo: He, aggregate: ne };
5464
5471
  });
5465
5472
  m.forEach(({ hash: T, q: v, store: k, pageInfo: S, aggregate: I }) => {
@@ -5622,7 +5629,7 @@ class ra {
5622
5629
  */
5623
5630
  subscribeQuery(e, n, r) {
5624
5631
  var i;
5625
- this.config.disableValidation || cr(e, this.config.schema), r && "ruleParams" in r && (e = Object.assign({ $$ruleParams: r.ruleParams }, e));
5632
+ this.config.disableValidation || dr(e, this.config.schema), r && "ruleParams" in r && (e = Object.assign({ $$ruleParams: r.ruleParams }, e));
5626
5633
  const s = N(e), o = this.getPreviousResult(e);
5627
5634
  return o && n(o), this.queryCbs[s] = (i = this.queryCbs[s]) !== null && i !== void 0 ? i : [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
5628
5635
  this._unsubQuery(e, s, n);
@@ -5630,14 +5637,14 @@ class ra {
5630
5637
  }
5631
5638
  queryOnce(e, n) {
5632
5639
  var r;
5633
- this.config.disableValidation || cr(e, this.config.schema), n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
5634
- const i = new sr();
5640
+ this.config.disableValidation || dr(e, this.config.schema), n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
5641
+ const i = new or();
5635
5642
  if (!this._isOnline)
5636
5643
  return i.reject(new Error("We can't run `queryOnce`, because the device is offline.")), i.promise;
5637
5644
  if (!this.querySubs)
5638
5645
  return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
5639
5646
  const s = N(e), o = this._startQuerySub(e, s);
5640
- return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Bu), i.promise;
5647
+ return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Gu), i.promise;
5641
5648
  }
5642
5649
  _completeQueryOnce(e, n, r) {
5643
5650
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5698,7 +5705,7 @@ class ra {
5698
5705
  u = !0;
5699
5706
  continue;
5700
5707
  }
5701
- const b = u ? $o(o, p) : p;
5708
+ const b = u ? xo(o, p) : p;
5702
5709
  l.push(b);
5703
5710
  }
5704
5711
  return u ? l : c;
@@ -5708,7 +5715,7 @@ class ra {
5708
5715
  return u ? d : n;
5709
5716
  }
5710
5717
  _rewriteMutationsSorted(e, n) {
5711
- return Tr(this._rewriteMutations(e, n).entries());
5718
+ return mr(this._rewriteMutations(e, n).entries());
5712
5719
  }
5713
5720
  // ---------------------------
5714
5721
  // Transact
@@ -5742,11 +5749,11 @@ class ra {
5742
5749
  if (d && r === d.querySubVersion && s === d.pendingMutationsVersion)
5743
5750
  return d;
5744
5751
  const { store: c, pageInfo: f, aggregate: l, processedTxId: p } = a, y = this._rewriteMutationsSorted(c.attrs, o), b = this._applyOptimisticUpdates(c, y, p);
5745
- return { data: Jr({ store: b, pageInfo: f, aggregate: l }, u), querySubVersion: r, pendingMutationsVersion: s };
5752
+ return { data: Zr({ store: b, pageInfo: f, aggregate: l }, u), querySubVersion: r, pendingMutationsVersion: s };
5746
5753
  }
5747
5754
  _applyOptimisticUpdates(e, n, r) {
5748
5755
  for (const [i, s] of n)
5749
- (!s["tx-id"] || r && s["tx-id"] > r) && (e = $s(e, s["tx-steps"]));
5756
+ (!s["tx-id"] || r && s["tx-id"] > r) && (e = xs(e, s["tx-steps"]));
5750
5757
  return e;
5751
5758
  }
5752
5759
  /** Re-compute all subscriptions */
@@ -5834,7 +5841,7 @@ class ra {
5834
5841
  }
5835
5842
  _trySend(e, n, r) {
5836
5843
  if (this._transport.isOpen()) {
5837
- switch (gr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5844
+ switch (Tr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5838
5845
  case "transact": {
5839
5846
  this._inFlightMutationEventIds.add(e);
5840
5847
  break;
@@ -5855,7 +5862,7 @@ class ra {
5855
5862
  return;
5856
5863
  }
5857
5864
  const e = this._transport;
5858
- this._transport = Yu({
5865
+ this._transport = Ju({
5859
5866
  transportType: this._transportType,
5860
5867
  appId: this.config.appId,
5861
5868
  apiURI: this.config.apiURI,
@@ -5891,9 +5898,9 @@ class ra {
5891
5898
  if (typeof URL > "u")
5892
5899
  return;
5893
5900
  const e = new URL(window.location.href);
5894
- if (e.searchParams.get(It)) {
5901
+ if (e.searchParams.get(Mt)) {
5895
5902
  const n = e.toString();
5896
- e.searchParams.delete(It), e.searchParams.delete("code"), e.searchParams.delete("error");
5903
+ e.searchParams.delete(Mt), e.searchParams.delete("code"), e.searchParams.delete("error");
5897
5904
  const r = e.pathname + (e.searchParams.size ? "?" + e.searchParams : "") + e.hash;
5898
5905
  if (history.replaceState(history.state, "", r), // @ts-ignore (waiting for ts support)
5899
5906
  typeof navigation == "object" && // @ts-ignore (waiting for ts support)
@@ -5918,7 +5925,7 @@ class ra {
5918
5925
  if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
5919
5926
  return null;
5920
5927
  const s = new URLSearchParams(window.location.search);
5921
- if (!s.get(It))
5928
+ if (!s.get(Mt))
5922
5929
  return null;
5923
5930
  const o = s.get("error");
5924
5931
  if (o)
@@ -5928,7 +5935,7 @@ class ra {
5928
5935
  return null;
5929
5936
  this._replaceUrlAfterOAuth();
5930
5937
  try {
5931
- const a = yield this._getCurrentUser(), d = (a == null ? void 0 : a.type) === "guest", { user: c } = yield rr({
5938
+ const a = yield this._getCurrentUser(), d = (a == null ? void 0 : a.type) === "guest", { user: c } = yield ir({
5932
5939
  apiURI: this.config.apiURI,
5933
5940
  appId: this.config.appId,
5934
5941
  code: u,
@@ -6058,7 +6065,7 @@ class ra {
6058
6065
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
6059
6066
  }
6060
6067
  sendMagicCode({ email: e }) {
6061
- return pu({
6068
+ return yu({
6062
6069
  apiURI: this.config.apiURI,
6063
6070
  appId: this.config.appId,
6064
6071
  email: e
@@ -6067,7 +6074,7 @@ class ra {
6067
6074
  signInWithMagicCode(e) {
6068
6075
  return U(this, arguments, void 0, function* ({ email: n, code: r }) {
6069
6076
  var i;
6070
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield yu({
6077
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield bu({
6071
6078
  apiURI: this.config.apiURI,
6072
6079
  appId: this.config.appId,
6073
6080
  email: n,
@@ -6079,7 +6086,7 @@ class ra {
6079
6086
  }
6080
6087
  signInWithCustomToken(e) {
6081
6088
  return U(this, void 0, void 0, function* () {
6082
- const n = yield bu({
6089
+ const n = yield _u({
6083
6090
  apiURI: this.config.apiURI,
6084
6091
  appId: this.config.appId,
6085
6092
  refreshToken: e
@@ -6089,7 +6096,7 @@ class ra {
6089
6096
  }
6090
6097
  signInAsGuest() {
6091
6098
  return U(this, void 0, void 0, function* () {
6092
- const e = yield _u({
6099
+ const e = yield gu({
6093
6100
  apiURI: this.config.apiURI,
6094
6101
  appId: this.config.appId
6095
6102
  });
@@ -6105,7 +6112,7 @@ class ra {
6105
6112
  this._log.info("[auth-invalidate] skipped invalidateToken");
6106
6113
  return;
6107
6114
  }
6108
- Tu({
6115
+ mu({
6109
6116
  apiURI: this.config.apiURI,
6110
6117
  appId: this.config.appId,
6111
6118
  refreshToken: i
@@ -6140,7 +6147,7 @@ class ra {
6140
6147
  exchangeCodeForToken(e) {
6141
6148
  return U(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
6142
6149
  var i;
6143
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield rr({
6150
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield ir({
6144
6151
  apiURI: this.config.apiURI,
6145
6152
  appId: this.config.appId,
6146
6153
  code: n,
@@ -6163,7 +6170,7 @@ class ra {
6163
6170
  signInWithIdToken(e) {
6164
6171
  return U(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
6165
6172
  var s;
6166
- const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield gu({
6173
+ const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield Tu({
6167
6174
  apiURI: this.config.apiURI,
6168
6175
  appId: this.config.appId,
6169
6176
  idToken: n,
@@ -6204,7 +6211,7 @@ class ra {
6204
6211
  // TODO: look into typing again
6205
6212
  getPresence(e, n, r = {}) {
6206
6213
  const i = this._rooms[n], s = this._presence[n];
6207
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Eu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
6214
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Au(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
6208
6215
  }
6209
6216
  // TODO: look into typing again
6210
6217
  publishPresence(e, n, r) {
@@ -6254,7 +6261,7 @@ class ra {
6254
6261
  }
6255
6262
  _notifyPresenceSub(e, n) {
6256
6263
  const r = this.getPresence("", e, n);
6257
- r && (n.prev && !Au(r, n.prev) || (n.prev = r, n.cb(r)));
6264
+ r && (n.prev && !ju(r, n.prev) || (n.prev = r, n.cb(r)));
6258
6265
  }
6259
6266
  _patchPresencePeers(e, n) {
6260
6267
  var r, i, s;
@@ -6265,13 +6272,13 @@ class ra {
6265
6272
  for (let [c, f, l] of n)
6266
6273
  switch (f) {
6267
6274
  case "+":
6268
- ns(d, c, l);
6275
+ rs(d, c, l);
6269
6276
  break;
6270
6277
  case "r":
6271
- Vn(d, c, l);
6278
+ Wn(d, c, l);
6272
6279
  break;
6273
6280
  case "-":
6274
- $r(d, c);
6281
+ xr(d, c);
6275
6282
  break;
6276
6283
  }
6277
6284
  delete d[this._sessionId];
@@ -6283,7 +6290,7 @@ class ra {
6283
6290
  delete r[this._sessionId];
6284
6291
  const i = Object.fromEntries(Object.entries(r).map(([s, o]) => [s, o.data]));
6285
6292
  this._presence = ft(this._presence, (s) => {
6286
- Vn(s, [e, "result", "peers"], i);
6293
+ Wn(s, [e, "result", "peers"], i);
6287
6294
  });
6288
6295
  }
6289
6296
  // --------
@@ -6328,14 +6335,14 @@ class ra {
6328
6335
  return U(this, void 0, void 0, function* () {
6329
6336
  var i;
6330
6337
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
6331
- return mu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
6338
+ return wu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
6332
6339
  });
6333
6340
  }
6334
6341
  deleteFile(e) {
6335
6342
  return U(this, void 0, void 0, function* () {
6336
6343
  var n;
6337
6344
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
6338
- return yield wu({
6345
+ return yield vu({
6339
6346
  apiURI: this.config.apiURI,
6340
6347
  appId: this.config.appId,
6341
6348
  path: e,
@@ -6348,20 +6355,20 @@ class ra {
6348
6355
  upload(e, n) {
6349
6356
  return U(this, void 0, void 0, function* () {
6350
6357
  var r;
6351
- const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield vu({
6358
+ const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield Su({
6352
6359
  apiURI: this.config.apiURI,
6353
6360
  appId: this.config.appId,
6354
6361
  fileName: o,
6355
6362
  refreshToken: s
6356
6363
  });
6357
- return yield Su(u, n);
6364
+ return yield Ou(u, n);
6358
6365
  });
6359
6366
  }
6360
6367
  getDownloadUrl(e) {
6361
6368
  return U(this, void 0, void 0, function* () {
6362
6369
  var n;
6363
6370
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
6364
- return yield Ou({
6371
+ return yield Eu({
6365
6372
  apiURI: this.config.apiURI,
6366
6373
  appId: this.config.appId,
6367
6374
  path: e,
@@ -6371,9 +6378,9 @@ class ra {
6371
6378
  }
6372
6379
  }
6373
6380
  let it;
6374
- function ia(t, e) {
6381
+ function sa(t, e) {
6375
6382
  it == null || it.dispose();
6376
- const n = da(e), r = ua(e, u), i = oa(sa(t));
6383
+ const n = fa(e), r = aa(e, u), i = ua(oa(t));
6377
6384
  function s(c) {
6378
6385
  var f;
6379
6386
  c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
@@ -6395,10 +6402,10 @@ function ia(t, e) {
6395
6402
  }
6396
6403
  return d();
6397
6404
  }
6398
- function sa(t) {
6399
- return `${hn || ii ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6400
- }
6401
6405
  function oa(t) {
6406
+ return `${pn || si ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6407
+ }
6408
+ function ua(t) {
6402
6409
  const e = document.createElement("iframe");
6403
6410
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6404
6411
  width: "100%",
@@ -6407,7 +6414,7 @@ function oa(t) {
6407
6414
  border: "none"
6408
6415
  }), { element: e };
6409
6416
  }
6410
- function ua(t, e) {
6417
+ function aa(t, e) {
6411
6418
  const n = `
6412
6419
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6413
6420
  <rect width="512" height="512" fill="black"/>
@@ -6417,7 +6424,7 @@ function ua(t, e) {
6417
6424
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
6418
6425
  // pos
6419
6426
  position: "fixed"
6420
- }, aa(t.position)), {
6427
+ }, ca(t.position)), {
6421
6428
  height: "32px",
6422
6429
  width: "32px",
6423
6430
  // layout
@@ -6432,7 +6439,7 @@ function ua(t, e) {
6432
6439
  cursor: "pointer"
6433
6440
  })), r.addEventListener("click", e), { element: r };
6434
6441
  }
6435
- function aa(t) {
6442
+ function ca(t) {
6436
6443
  switch (t) {
6437
6444
  case "bottom-left":
6438
6445
  return { bottom: "24px", left: "24px" };
@@ -6444,7 +6451,7 @@ function aa(t) {
6444
6451
  return { top: "24px", left: "24px" };
6445
6452
  }
6446
6453
  }
6447
- function ca(t) {
6454
+ function da(t) {
6448
6455
  switch (t) {
6449
6456
  case "bottom-left":
6450
6457
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6456,47 +6463,47 @@ function ca(t) {
6456
6463
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6457
6464
  }
6458
6465
  }
6459
- function da(t) {
6466
+ function fa(t) {
6460
6467
  const e = document.createElement("div");
6461
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, ca(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6468
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, da(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6462
6469
  function n() {
6463
6470
  return e.style.display !== "none";
6464
6471
  }
6465
6472
  return { element: e, isVisible: n };
6466
6473
  }
6467
- const fa = {
6474
+ const la = {
6468
6475
  apiURI: "https://api.instantdb.com",
6469
6476
  websocketURI: "wss://api.instantdb.com/runtime/session"
6470
6477
  };
6471
- function la() {
6478
+ function ha() {
6472
6479
  var t;
6473
6480
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6474
6481
  }
6475
- function ha() {
6482
+ function pa() {
6476
6483
  var t;
6477
6484
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
6478
6485
  }
6479
- function Jt(t) {
6486
+ function Zt(t) {
6480
6487
  const e = t.__adminToken;
6481
6488
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6482
6489
  }
6483
- const Zt = ha(), mr = la();
6484
- class pa {
6490
+ const Xt = pa(), wr = ha();
6491
+ class ya {
6485
6492
  constructor(e) {
6486
6493
  this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
6487
6494
  }
6488
6495
  }
6489
- class ya {
6496
+ class ba {
6490
6497
  constructor(e) {
6491
6498
  this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
6492
6499
  }
6493
6500
  }
6494
- function ba(t) {
6501
+ function _a(t) {
6495
6502
  return JSON.parse(JSON.stringify(t));
6496
6503
  }
6497
- class _a {
6504
+ class ga {
6498
6505
  constructor(e) {
6499
- this.tx = ln(), this._reactor = e, this.auth = new pa(this._reactor), this.storage = new ya(this._reactor);
6506
+ this.tx = hn(), this._reactor = e, this.auth = new ya(this._reactor), this.storage = new ba(this._reactor);
6500
6507
  }
6501
6508
  /**
6502
6509
  * Use this to write data! You can create, update, delete, and link objects
@@ -6637,7 +6644,7 @@ class _a {
6637
6644
  };
6638
6645
  }
6639
6646
  shutdown() {
6640
- delete Zt[Jt(this._reactor.config)], this._reactor.shutdown();
6647
+ delete Xt[Zt(this._reactor.config)], this._reactor.shutdown();
6641
6648
  }
6642
6649
  /**
6643
6650
  * Use this for one-off queries.
@@ -6670,39 +6677,39 @@ class _a {
6670
6677
  return this._reactor.subscribeTable(e, n);
6671
6678
  }
6672
6679
  }
6673
- function wr(t) {
6680
+ function vr(t) {
6674
6681
  if (!t)
6675
6682
  return "0";
6676
- const e = mr.get(t);
6683
+ const e = wr.get(t);
6677
6684
  if (e)
6678
6685
  return e;
6679
6686
  const n = N(t);
6680
- return mr.set(t, n), n;
6687
+ return wr.set(t, n), n;
6681
6688
  }
6682
- function ga(t, e) {
6683
- return wr(t._reactor.config.schema) !== wr(e);
6689
+ function Ta(t, e) {
6690
+ return vr(t._reactor.config.schema) !== vr(e);
6684
6691
  }
6685
- function Ta(t, e, n, r, i) {
6692
+ function ma(t, e, n, r, i) {
6686
6693
  var s;
6687
- const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = Zt[Jt(o)];
6694
+ const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = Xt[Zt(o)];
6688
6695
  if (u)
6689
- return ga(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6690
- const a = new ra(Object.assign(Object.assign(Object.assign({}, fa), o), { cardinalityInference: !!o.schema }), e || ti, n || ni, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": oi }), i), d = new _a(a);
6691
- return Zt[Jt(o)] = d, ma(o.appId, o.devtool), d;
6696
+ return Ta(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6697
+ const a = new ia(Object.assign(Object.assign(Object.assign({}, la), o), { cardinalityInference: !!o.schema }), e || ni, n || ri, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": ui }), i), d = new ga(a);
6698
+ return Xt[Zt(o)] = d, wa(o.appId, o.devtool), d;
6692
6699
  }
6693
- function ma(t, e) {
6700
+ function wa(t, e) {
6694
6701
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6695
6702
  return;
6696
6703
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6697
- n.allowedHosts.includes(window.location.hostname) && ia(t, n);
6704
+ n.allowedHosts.includes(window.location.hostname) && sa(t, n);
6698
6705
  }
6699
- const wa = {
6706
+ const va = {
6700
6707
  isLoading: !0,
6701
6708
  data: void 0,
6702
6709
  pageInfo: void 0,
6703
6710
  error: void 0
6704
6711
  };
6705
- function vr(t) {
6712
+ function Sr(t) {
6706
6713
  return {
6707
6714
  isLoading: !t,
6708
6715
  data: void 0,
@@ -6711,12 +6718,12 @@ function vr(t) {
6711
6718
  ...t || {}
6712
6719
  };
6713
6720
  }
6714
- function va(t, e, n) {
6721
+ function Sa(t, e, n) {
6715
6722
  e && n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
6716
- const r = e ? ba(e) : null, i = N(r), s = ze(
6717
- vr(t._reactor.getPreviousResult(r))
6723
+ const r = e ? _a(e) : null, i = N(r), s = ze(
6724
+ Sr(t._reactor.getPreviousResult(r))
6718
6725
  ), o = de(
6719
- (a) => (s.current = vr(
6726
+ (a) => (s.current = Sr(
6720
6727
  t._reactor.getPreviousResult(r)
6721
6728
  ), r ? t.subscribeQuery(r, (c) => {
6722
6729
  s.current = {
@@ -6734,13 +6741,13 @@ function va(t, e, n) {
6734
6741
  // Build a new subscribe function if the query changes
6735
6742
  [i]
6736
6743
  );
6737
- return { state: Mt(
6744
+ return { state: Rt(
6738
6745
  o,
6739
6746
  () => s.current,
6740
- () => wa
6747
+ () => va
6741
6748
  ), query: r };
6742
6749
  }
6743
- function Sa() {
6750
+ function Oa() {
6744
6751
  const t = ze(null);
6745
6752
  ge(() => {
6746
6753
  n();
@@ -6753,8 +6760,8 @@ function Sa() {
6753
6760
  }
6754
6761
  return { set: e, clear: n };
6755
6762
  }
6756
- const Oa = 1e3;
6757
- function Ea(t, e, n) {
6763
+ const Ea = 1e3;
6764
+ function Aa(t, e, n) {
6758
6765
  const r = ze(n);
6759
6766
  r.current = n, ge(() => t.core._reactor.subscribeTopic(
6760
6767
  t.id,
@@ -6764,7 +6771,7 @@ function Ea(t, e, n) {
6764
6771
  }
6765
6772
  ), [t.id, e]);
6766
6773
  }
6767
- function Aa(t, e) {
6774
+ function ja(t, e) {
6768
6775
  return ge(() => t.core._reactor.joinRoom(t.id), [t.id]), de(
6769
6776
  (r) => {
6770
6777
  t.core._reactor.publishTopic({
@@ -6777,9 +6784,9 @@ function Aa(t, e) {
6777
6784
  [t.id, e]
6778
6785
  );
6779
6786
  }
6780
- function ja(t, e = {}) {
6787
+ function ka(t, e = {}) {
6781
6788
  var o, u;
6782
- const [n, r] = Or(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
6789
+ const [n, r] = Er(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
6783
6790
  peers: {},
6784
6791
  isLoading: !0
6785
6792
  });
@@ -6797,18 +6804,18 @@ function ja(t, e = {}) {
6797
6804
  },
6798
6805
  [t.type, t.id]
6799
6806
  );
6800
- return Rt(() => ({
6807
+ return $t(() => ({
6801
6808
  ...n,
6802
6809
  publishPresence: i
6803
6810
  }), [n, i]);
6804
6811
  }
6805
- function ka(t, e, n) {
6812
+ function Ca(t, e, n) {
6806
6813
  ge(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ge(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
6807
6814
  }
6808
- function Ca(t, e, n = {}) {
6809
- const r = Sa(), i = ye.usePresence(t, {
6815
+ function Pa(t, e, n = {}) {
6816
+ const r = Oa(), i = ye.usePresence(t, {
6810
6817
  keys: [e]
6811
- }), s = Rt(() => {
6818
+ }), s = $t(() => {
6812
6819
  const c = t._core._reactor.getPresence(
6813
6820
  t.type,
6814
6821
  t.id
@@ -6820,7 +6827,7 @@ function Ca(t, e, n = {}) {
6820
6827
  (c) => {
6821
6828
  t.core._reactor.publishPresence(t.type, t.id, {
6822
6829
  [e]: c
6823
- }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? Oa, () => {
6830
+ }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? Ea, () => {
6824
6831
  t.core._reactor.publishPresence(t.type, t.id, {
6825
6832
  [e]: null
6826
6833
  });
@@ -6835,7 +6842,7 @@ function Ca(t, e, n = {}) {
6835
6842
  [n.stopOnEnter, o]
6836
6843
  ), a = de(() => {
6837
6844
  o(!1);
6838
- }, [o]), d = Rt(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
6845
+ }, [o]), d = $t(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
6839
6846
  return {
6840
6847
  active: s,
6841
6848
  setActive: o,
@@ -6843,44 +6850,44 @@ function Ca(t, e, n = {}) {
6843
6850
  };
6844
6851
  }
6845
6852
  const ye = {
6846
- useTopicEffect: Ea,
6847
- usePublishTopic: Aa,
6848
- usePresence: ja,
6849
- useSyncPresence: ka,
6850
- useTypingIndicator: Ca
6853
+ useTopicEffect: Aa,
6854
+ usePublishTopic: ja,
6855
+ usePresence: ka,
6856
+ useSyncPresence: Ca,
6857
+ useTypingIndicator: Pa
6851
6858
  };
6852
- class Pa {
6859
+ class Ia {
6853
6860
  constructor(e, n, r) {
6854
6861
  this.useTopicEffect = (i, s) => {
6855
6862
  ye.useTopicEffect(this, i, s);
6856
6863
  }, this.usePublishTopic = (i) => ye.usePublishTopic(this, i), this.usePresence = (i = {}) => ye.usePresence(this, i), this.useSyncPresence = (i, s) => ye.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => ye.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
6857
6864
  }
6858
6865
  }
6859
- const Ia = {
6866
+ const Ma = {
6860
6867
  isLoading: !0,
6861
6868
  user: void 0,
6862
6869
  error: void 0
6863
6870
  };
6864
- class Ra {
6871
+ class $a {
6865
6872
  constructor(e, n) {
6866
- this.tx = ln(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6867
- const [i, s] = Or(null);
6873
+ this.tx = hn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6874
+ const [i, s] = Er(null);
6868
6875
  return ge(() => {
6869
6876
  (async () => {
6870
6877
  const u = await this.getLocalId(r);
6871
6878
  s(u);
6872
6879
  })();
6873
6880
  }, [r]), i;
6874
- }, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => va(this.core, r, i).state, this.useAuth = () => {
6881
+ }, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => Sa(this.core, r, i).state, this.useAuth = () => {
6875
6882
  const r = ze(
6876
6883
  this.core._reactor._currentUserCached
6877
6884
  ), i = de((o) => this.core.subscribeAuth((a) => {
6878
6885
  r.current = { isLoading: !1, ...a }, o();
6879
6886
  }), []);
6880
- return Mt(
6887
+ return Rt(
6881
6888
  i,
6882
6889
  () => r.current,
6883
- () => Ia
6890
+ () => Ma
6884
6891
  );
6885
6892
  }, this.useUser = () => {
6886
6893
  const { user: r } = this.useAuth();
@@ -6895,7 +6902,7 @@ class Ra {
6895
6902
  ), i = de((o) => this.core.subscribeConnectionStatus((a) => {
6896
6903
  a !== r.current && (r.current = a, o());
6897
6904
  }), []);
6898
- return Mt(
6905
+ return Rt(
6899
6906
  i,
6900
6907
  () => r.current,
6901
6908
  // For SSR, always return 'connecting' as the initial state
@@ -6907,7 +6914,7 @@ class Ra {
6907
6914
  }, this.SignedOut = ({ children: r }) => {
6908
6915
  const i = this.useAuth();
6909
6916
  return i.isLoading || i.error || i.user ? null : /* @__PURE__ */ et.jsx(et.Fragment, { children: r });
6910
- }, this.core = Ta(
6917
+ }, this.core = ma(
6911
6918
  e,
6912
6919
  // @ts-expect-error because TS can't resolve subclass statics
6913
6920
  this.constructor.Storage,
@@ -6931,7 +6938,7 @@ class Ra {
6931
6938
  * const { peers } = db.rooms.usePresence(room);
6932
6939
  */
6933
6940
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
6934
- return new Pa(this.core, e, n);
6941
+ return new Ia(this.core, e, n);
6935
6942
  }
6936
6943
  /**
6937
6944
  * One time query for the logged in state. This is useful
@@ -6948,5 +6955,5 @@ class Ra {
6948
6955
  }
6949
6956
  }
6950
6957
  export {
6951
- Ra as InstantReactAbstractDatabase
6958
+ $a as InstantReactAbstractDatabase
6952
6959
  };