@instantdb/react-common 0.22.167 → 0.22.168

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,8 +1,8 @@
1
- var Ks = Object.defineProperty;
2
- var qs = (n, e, t) => e in n ? Ks(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var p = (n, e, t) => qs(n, typeof e != "symbol" ? e + "" : e, t);
4
- import Or, { useRef as ke, useCallback as Ae, useSyncExternalStore as Tt, useEffect as je, useMemo as Vt, useState as Er } from "react";
5
- var Qt = { exports: {} }, He = {};
1
+ var Ws = Object.defineProperty;
2
+ var zs = (n, e, t) => e in n ? Ws(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var p = (n, e, t) => zs(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import kr, { useRef as ke, useCallback as Ae, useSyncExternalStore as St, useEffect as je, useMemo as Bt, useState as Cr } from "react";
5
+ var Gt = { exports: {} }, He = {};
6
6
  /**
7
7
  * @license React
8
8
  * react-jsx-runtime.production.min.js
@@ -12,11 +12,11 @@ var Qt = { exports: {} }, He = {};
12
12
  * This source code is licensed under the MIT license found in the
13
13
  * LICENSE file in the root directory of this source tree.
14
14
  */
15
- var Fn;
16
- function Ws() {
17
- if (Fn) return He;
18
- Fn = 1;
19
- var n = Or, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
15
+ var Kn;
16
+ function Vs() {
17
+ if (Kn) return He;
18
+ Kn = 1;
19
+ var n = kr, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
20
20
  function o(a, c, u) {
21
21
  var l, f = {}, h = null, y = null;
22
22
  u !== void 0 && (h = "" + u), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (y = c.ref);
@@ -26,10 +26,10 @@ function Ws() {
26
26
  }
27
27
  return He.Fragment = t, He.jsx = o, He.jsxs = o, He;
28
28
  }
29
- var Je = {}, Nn;
30
- function zs() {
31
- if (Nn) return Je;
32
- Nn = 1;
29
+ var Je = {}, qn;
30
+ function Qs() {
31
+ if (qn) return Je;
32
+ qn = 1;
33
33
  var n = {};
34
34
  /**
35
35
  * @license React
@@ -41,7 +41,7 @@ function zs() {
41
41
  * LICENSE file in the root directory of this source tree.
42
42
  */
43
43
  return n.NODE_ENV !== "production" && function() {
44
- var e = Or, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), _ = Symbol.iterator, T = "@@iterator";
44
+ var e = kr, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), _ = Symbol.iterator, T = "@@iterator";
45
45
  function S(d) {
46
46
  if (d === null || typeof d != "object")
47
47
  return null;
@@ -192,27 +192,27 @@ function zs() {
192
192
  P < 0 && m("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
193
193
  }
194
194
  }
195
- var be = g.ReactCurrentDispatcher, Pt;
195
+ var be = g.ReactCurrentDispatcher, Mt;
196
196
  function ct(d, w, A) {
197
197
  {
198
- if (Pt === void 0)
198
+ if (Mt === void 0)
199
199
  try {
200
200
  throw Error();
201
201
  } catch (F) {
202
202
  var C = F.stack.trim().match(/\n( *(at )?)/);
203
- Pt = C && C[1] || "";
203
+ Mt = C && C[1] || "";
204
204
  }
205
205
  return `
206
- ` + Pt + d;
206
+ ` + Mt + d;
207
207
  }
208
208
  }
209
- var Mt = !1, ut;
209
+ var Rt = !1, ut;
210
210
  {
211
- var bs = typeof WeakMap == "function" ? WeakMap : Map;
212
- ut = new bs();
211
+ var _s = typeof WeakMap == "function" ? WeakMap : Map;
212
+ ut = new _s();
213
213
  }
214
- function An(d, w) {
215
- if (!d || Mt)
214
+ function En(d, w) {
215
+ if (!d || Rt)
216
216
  return "";
217
217
  {
218
218
  var A = ut.get(d);
@@ -220,7 +220,7 @@ function zs() {
220
220
  return A;
221
221
  }
222
222
  var C;
223
- Mt = !0;
223
+ Rt = !0;
224
224
  var F = Error.prepareStackTrace;
225
225
  Error.prepareStackTrace = void 0;
226
226
  var K;
@@ -277,15 +277,15 @@ function zs() {
277
277
  }
278
278
  }
279
279
  } finally {
280
- Mt = !1, be.current = K, Be(), Error.prepareStackTrace = F;
280
+ Rt = !1, be.current = K, Be(), Error.prepareStackTrace = F;
281
281
  }
282
282
  var Le = d ? d.displayName || d.name : "", Ce = Le ? ct(Le) : "";
283
283
  return typeof d == "function" && ut.set(d, Ce), Ce;
284
284
  }
285
- function gs(d, w, A) {
286
- return An(d, !1);
285
+ function ms(d, w, A) {
286
+ return En(d, !1);
287
287
  }
288
- function _s(d) {
288
+ function ws(d) {
289
289
  var w = d.prototype;
290
290
  return !!(w && w.isReactComponent);
291
291
  }
@@ -293,7 +293,7 @@ function zs() {
293
293
  if (d == null)
294
294
  return "";
295
295
  if (typeof d == "function")
296
- return An(d, _s(d));
296
+ return En(d, ws(d));
297
297
  if (typeof d == "string")
298
298
  return ct(d);
299
299
  switch (d) {
@@ -305,7 +305,7 @@ function zs() {
305
305
  if (typeof d == "object")
306
306
  switch (d.$$typeof) {
307
307
  case u:
308
- return gs(d.render);
308
+ return ms(d.render);
309
309
  case h:
310
310
  return lt(d.type, w, A);
311
311
  case y: {
@@ -318,15 +318,15 @@ function zs() {
318
318
  }
319
319
  return "";
320
320
  }
321
- var Ge = Object.prototype.hasOwnProperty, On = {}, En = g.ReactDebugCurrentFrame;
321
+ var Ge = Object.prototype.hasOwnProperty, kn = {}, Cn = g.ReactDebugCurrentFrame;
322
322
  function ft(d) {
323
323
  if (d) {
324
324
  var w = d._owner, A = lt(d.type, d._source, w ? w.type : null);
325
- En.setExtraStackFrame(A);
325
+ Cn.setExtraStackFrame(A);
326
326
  } else
327
- En.setExtraStackFrame(null);
327
+ Cn.setExtraStackFrame(null);
328
328
  }
329
- function ms(d, w, A, C, F) {
329
+ function Ts(d, w, A, C, F) {
330
330
  {
331
331
  var K = Function.call.bind(Ge);
332
332
  for (var D in d)
@@ -341,41 +341,41 @@ function zs() {
341
341
  } catch (B) {
342
342
  j = B;
343
343
  }
344
- j && !(j instanceof Error) && (ft(F), m("%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).", C || "React class", A, D, typeof j), ft(null)), j instanceof Error && !(j.message in On) && (On[j.message] = !0, ft(F), m("Failed %s type: %s", A, j.message), ft(null));
344
+ j && !(j instanceof Error) && (ft(F), m("%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).", C || "React class", A, D, typeof j), ft(null)), j instanceof Error && !(j.message in kn) && (kn[j.message] = !0, ft(F), m("Failed %s type: %s", A, j.message), ft(null));
345
345
  }
346
346
  }
347
347
  }
348
- var ws = Array.isArray;
349
- function Rt(d) {
350
- return ws(d);
348
+ var Ss = Array.isArray;
349
+ function jt(d) {
350
+ return Ss(d);
351
351
  }
352
- function Ts(d) {
352
+ function vs(d) {
353
353
  {
354
354
  var w = typeof Symbol == "function" && Symbol.toStringTag, A = w && d[Symbol.toStringTag] || d.constructor.name || "Object";
355
355
  return A;
356
356
  }
357
357
  }
358
- function Ss(d) {
358
+ function As(d) {
359
359
  try {
360
- return kn(d), !1;
360
+ return In(d), !1;
361
361
  } catch {
362
362
  return !0;
363
363
  }
364
364
  }
365
- function kn(d) {
365
+ function In(d) {
366
366
  return "" + d;
367
367
  }
368
- function Cn(d) {
369
- if (Ss(d))
370
- return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ts(d)), kn(d);
368
+ function Pn(d) {
369
+ if (As(d))
370
+ return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", vs(d)), In(d);
371
371
  }
372
- var In = g.ReactCurrentOwner, vs = {
372
+ var Mn = g.ReactCurrentOwner, Os = {
373
373
  key: !0,
374
374
  ref: !0,
375
375
  __self: !0,
376
376
  __source: !0
377
- }, Pn, Mn;
378
- function As(d) {
377
+ }, Rn, jn;
378
+ function Es(d) {
379
379
  if (Ge.call(d, "ref")) {
380
380
  var w = Object.getOwnPropertyDescriptor(d, "ref").get;
381
381
  if (w && w.isReactWarning)
@@ -383,7 +383,7 @@ function zs() {
383
383
  }
384
384
  return d.ref !== void 0;
385
385
  }
386
- function Os(d) {
386
+ function ks(d) {
387
387
  if (Ge.call(d, "key")) {
388
388
  var w = Object.getOwnPropertyDescriptor(d, "key").get;
389
389
  if (w && w.isReactWarning)
@@ -391,13 +391,13 @@ function zs() {
391
391
  }
392
392
  return d.key !== void 0;
393
393
  }
394
- function Es(d, w) {
395
- typeof d.ref == "string" && In.current;
394
+ function Cs(d, w) {
395
+ typeof d.ref == "string" && Mn.current;
396
396
  }
397
- function ks(d, w) {
397
+ function Is(d, w) {
398
398
  {
399
399
  var A = function() {
400
- Pn || (Pn = !0, m("%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)", w));
400
+ Rn || (Rn = !0, m("%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)", w));
401
401
  };
402
402
  A.isReactWarning = !0, Object.defineProperty(d, "key", {
403
403
  get: A,
@@ -405,10 +405,10 @@ function zs() {
405
405
  });
406
406
  }
407
407
  }
408
- function Cs(d, w) {
408
+ function Ps(d, w) {
409
409
  {
410
410
  var A = function() {
411
- Mn || (Mn = !0, m("%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)", w));
411
+ jn || (jn = !0, m("%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)", w));
412
412
  };
413
413
  A.isReactWarning = !0, Object.defineProperty(d, "ref", {
414
414
  get: A,
@@ -416,7 +416,7 @@ function zs() {
416
416
  });
417
417
  }
418
418
  }
419
- var Is = function(d, w, A, C, F, K, D) {
419
+ var Ms = function(d, w, A, C, F, K, D) {
420
420
  var j = {
421
421
  // This tag allows us to uniquely identify this as a React Element
422
422
  $$typeof: t,
@@ -445,12 +445,12 @@ function zs() {
445
445
  value: F
446
446
  }), Object.freeze && (Object.freeze(j.props), Object.freeze(j)), j;
447
447
  };
448
- function Ps(d, w, A, C, F) {
448
+ function Rs(d, w, A, C, F) {
449
449
  {
450
450
  var K, D = {}, j = null, se = null;
451
- A !== void 0 && (Cn(A), j = "" + A), Os(w) && (Cn(w.key), j = "" + w.key), As(w) && (se = w.ref, Es(w, F));
451
+ A !== void 0 && (Pn(A), j = "" + A), ks(w) && (Pn(w.key), j = "" + w.key), Es(w) && (se = w.ref, Cs(w, F));
452
452
  for (K in w)
453
- Ge.call(w, K) && !vs.hasOwnProperty(K) && (D[K] = w[K]);
453
+ Ge.call(w, K) && !Os.hasOwnProperty(K) && (D[K] = w[K]);
454
454
  if (d && d.defaultProps) {
455
455
  var B = d.defaultProps;
456
456
  for (K in B)
@@ -458,28 +458,28 @@ function zs() {
458
458
  }
459
459
  if (j || se) {
460
460
  var H = typeof d == "function" ? d.displayName || d.name || "Unknown" : d;
461
- j && ks(D, H), se && Cs(D, H);
461
+ j && Is(D, H), se && Ps(D, H);
462
462
  }
463
- return Is(d, j, se, F, C, In.current, D);
463
+ return Ms(d, j, se, F, C, Mn.current, D);
464
464
  }
465
465
  }
466
- var jt = g.ReactCurrentOwner, Rn = g.ReactDebugCurrentFrame;
466
+ var $t = g.ReactCurrentOwner, $n = g.ReactDebugCurrentFrame;
467
467
  function Ue(d) {
468
468
  if (d) {
469
469
  var w = d._owner, A = lt(d.type, d._source, w ? w.type : null);
470
- Rn.setExtraStackFrame(A);
470
+ $n.setExtraStackFrame(A);
471
471
  } else
472
- Rn.setExtraStackFrame(null);
472
+ $n.setExtraStackFrame(null);
473
473
  }
474
- var $t;
475
- $t = !1;
476
- function xt(d) {
474
+ var xt;
475
+ xt = !1;
476
+ function Dt(d) {
477
477
  return typeof d == "object" && d !== null && d.$$typeof === t;
478
478
  }
479
- function jn() {
479
+ function xn() {
480
480
  {
481
- if (jt.current) {
482
- var d = O(jt.current.type);
481
+ if ($t.current) {
482
+ var d = O($t.current.type);
483
483
  if (d)
484
484
  return `
485
485
 
@@ -488,13 +488,13 @@ Check the render method of \`` + d + "`.";
488
488
  return "";
489
489
  }
490
490
  }
491
- function Ms(d) {
491
+ function js(d) {
492
492
  return "";
493
493
  }
494
- var $n = {};
495
- function Rs(d) {
494
+ var Dn = {};
495
+ function $s(d) {
496
496
  {
497
- var w = jn();
497
+ var w = xn();
498
498
  if (!w) {
499
499
  var A = typeof d == "string" ? d : d.displayName || d.name;
500
500
  A && (w = `
@@ -504,39 +504,39 @@ Check the top-level render call using <` + A + ">.");
504
504
  return w;
505
505
  }
506
506
  }
507
- function xn(d, w) {
507
+ function Un(d, w) {
508
508
  {
509
509
  if (!d._store || d._store.validated || d.key != null)
510
510
  return;
511
511
  d._store.validated = !0;
512
- var A = Rs(w);
513
- if ($n[A])
512
+ var A = $s(w);
513
+ if (Dn[A])
514
514
  return;
515
- $n[A] = !0;
515
+ Dn[A] = !0;
516
516
  var C = "";
517
- d && d._owner && d._owner !== jt.current && (C = " It was passed a child from " + O(d._owner.type) + "."), Ue(d), m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', A, C), Ue(null);
517
+ d && d._owner && d._owner !== $t.current && (C = " It was passed a child from " + O(d._owner.type) + "."), Ue(d), m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', A, C), Ue(null);
518
518
  }
519
519
  }
520
- function Dn(d, w) {
520
+ function Ln(d, w) {
521
521
  {
522
522
  if (typeof d != "object")
523
523
  return;
524
- if (Rt(d))
524
+ if (jt(d))
525
525
  for (var A = 0; A < d.length; A++) {
526
526
  var C = d[A];
527
- xt(C) && xn(C, w);
527
+ Dt(C) && Un(C, w);
528
528
  }
529
- else if (xt(d))
529
+ else if (Dt(d))
530
530
  d._store && (d._store.validated = !0);
531
531
  else if (d) {
532
532
  var F = S(d);
533
533
  if (typeof F == "function" && F !== d.entries)
534
534
  for (var K = F.call(d), D; !(D = K.next()).done; )
535
- xt(D.value) && xn(D.value, w);
535
+ Dt(D.value) && Un(D.value, w);
536
536
  }
537
537
  }
538
538
  }
539
- function js(d) {
539
+ function xs(d) {
540
540
  {
541
541
  var w = d.type;
542
542
  if (w == null || typeof w == "string")
@@ -552,16 +552,16 @@ Check the top-level render call using <` + A + ">.");
552
552
  return;
553
553
  if (A) {
554
554
  var C = O(w);
555
- ms(A, d.props, "prop", C, d);
556
- } else if (w.PropTypes !== void 0 && !$t) {
557
- $t = !0;
555
+ Ts(A, d.props, "prop", C, d);
556
+ } else if (w.PropTypes !== void 0 && !xt) {
557
+ xt = !0;
558
558
  var F = O(w);
559
559
  m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", F || "Unknown");
560
560
  }
561
561
  typeof w.getDefaultProps == "function" && !w.getDefaultProps.isReactClassApproved && m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
562
562
  }
563
563
  }
564
- function $s(d) {
564
+ function Ds(d) {
565
565
  {
566
566
  for (var w = Object.keys(d.props), A = 0; A < w.length; A++) {
567
567
  var C = w[A];
@@ -573,64 +573,64 @@ Check the top-level render call using <` + A + ">.");
573
573
  d.ref !== null && (Ue(d), m("Invalid attribute `ref` supplied to `React.Fragment`."), Ue(null));
574
574
  }
575
575
  }
576
- var Un = {};
577
- function Ln(d, w, A, C, F, K) {
576
+ var Fn = {};
577
+ function Nn(d, w, A, C, F, K) {
578
578
  {
579
579
  var D = we(d);
580
580
  if (!D) {
581
581
  var j = "";
582
582
  (d === void 0 || typeof d == "object" && d !== null && Object.keys(d).length === 0) && (j += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
583
- var se = Ms();
584
- se ? j += se : j += jn();
583
+ var se = js();
584
+ se ? j += se : j += xn();
585
585
  var B;
586
- d === null ? B = "null" : Rt(d) ? B = "array" : d !== void 0 && d.$$typeof === t ? (B = "<" + (O(d.type) || "Unknown") + " />", j = " Did you accidentally export a JSX literal instead of a component?") : B = typeof d, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", B, j);
586
+ d === null ? B = "null" : jt(d) ? B = "array" : d !== void 0 && d.$$typeof === t ? (B = "<" + (O(d.type) || "Unknown") + " />", j = " Did you accidentally export a JSX literal instead of a component?") : B = typeof d, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", B, j);
587
587
  }
588
- var H = Ps(d, w, A, F, K);
588
+ var H = Rs(d, w, A, F, K);
589
589
  if (H == null)
590
590
  return H;
591
591
  if (D) {
592
592
  var he = w.children;
593
593
  if (he !== void 0)
594
594
  if (C)
595
- if (Rt(he)) {
595
+ if (jt(he)) {
596
596
  for (var Le = 0; Le < he.length; Le++)
597
- Dn(he[Le], d);
597
+ Ln(he[Le], d);
598
598
  Object.freeze && Object.freeze(he);
599
599
  } else
600
600
  m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
601
601
  else
602
- Dn(he, d);
602
+ Ln(he, d);
603
603
  }
604
604
  if (Ge.call(w, "key")) {
605
- var Ce = O(d), ae = Object.keys(w).filter(function(Ns) {
606
- return Ns !== "key";
607
- }), Dt = ae.length > 0 ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}";
608
- if (!Un[Ce + Dt]) {
609
- var Fs = ae.length > 0 ? "{" + ae.join(": ..., ") + ": ...}" : "{}";
605
+ var Ce = O(d), ae = Object.keys(w).filter(function(qs) {
606
+ return qs !== "key";
607
+ }), Ut = ae.length > 0 ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}";
608
+ if (!Fn[Ce + Ut]) {
609
+ var Ks = ae.length > 0 ? "{" + ae.join(": ..., ") + ": ...}" : "{}";
610
610
  m(`A props object containing a "key" prop is being spread into JSX:
611
611
  let props = %s;
612
612
  <%s {...props} />
613
613
  React keys must be passed directly to JSX without using spread:
614
614
  let props = %s;
615
- <%s key={someKey} {...props} />`, Dt, Ce, Fs, Ce), Un[Ce + Dt] = !0;
615
+ <%s key={someKey} {...props} />`, Ut, Ce, Ks, Ce), Fn[Ce + Ut] = !0;
616
616
  }
617
617
  }
618
- return d === s ? $s(H) : js(H), H;
618
+ return d === s ? Ds(H) : xs(H), H;
619
619
  }
620
620
  }
621
- function xs(d, w, A) {
622
- return Ln(d, w, A, !0);
621
+ function Us(d, w, A) {
622
+ return Nn(d, w, A, !0);
623
623
  }
624
- function Ds(d, w, A) {
625
- return Ln(d, w, A, !1);
624
+ function Ls(d, w, A) {
625
+ return Nn(d, w, A, !1);
626
626
  }
627
- var Us = Ds, Ls = xs;
628
- Je.Fragment = s, Je.jsx = Us, Je.jsxs = Ls;
627
+ var Fs = Ls, Ns = Us;
628
+ Je.Fragment = s, Je.jsx = Fs, Je.jsxs = Ns;
629
629
  }(), Je;
630
630
  }
631
- var Vs = {};
632
- Vs.NODE_ENV === "production" ? Qt.exports = Ws() : Qt.exports = zs();
633
- var dt = Qt.exports;
631
+ var Bs = {};
632
+ Bs.NODE_ENV === "production" ? Gt.exports = Vs() : Gt.exports = Qs();
633
+ var dt = Gt.exports;
634
634
  function J(n) {
635
635
  if (typeof n == "number")
636
636
  return (Math.abs(n * 2654435761) >>> 0).toString(16);
@@ -676,14 +676,14 @@ const G = {
676
676
  Remove: "remove",
677
677
  Replace: "replace",
678
678
  Add: "add"
679
- }, kr = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Qs = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), gt = Symbol.iterator, de = {
679
+ }, Ir = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Gs = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), _t = Symbol.iterator, de = {
680
680
  mutable: "mutable",
681
681
  immutable: "immutable"
682
- }, fn = {};
682
+ }, hn = {};
683
683
  function rt(n, e) {
684
684
  return n instanceof Map ? n.has(e) : Object.prototype.hasOwnProperty.call(n, e);
685
685
  }
686
- function Kn(n, e) {
686
+ function Wn(n, e) {
687
687
  if (e in n) {
688
688
  let t = Reflect.getPrototypeOf(n);
689
689
  for (; t; ) {
@@ -694,10 +694,10 @@ function Kn(n, e) {
694
694
  }
695
695
  }
696
696
  }
697
- function dn(n) {
697
+ function pn(n) {
698
698
  return Object.getPrototypeOf(n) === Set.prototype;
699
699
  }
700
- function hn(n) {
700
+ function yn(n) {
701
701
  return Object.getPrototypeOf(n) === Map.prototype;
702
702
  }
703
703
  function fe(n) {
@@ -708,9 +708,9 @@ function $e(n) {
708
708
  return !!$(n);
709
709
  }
710
710
  function $(n) {
711
- return typeof n != "object" ? null : n == null ? void 0 : n[kr];
711
+ return typeof n != "object" ? null : n == null ? void 0 : n[Ir];
712
712
  }
713
- function pn(n) {
713
+ function bn(n) {
714
714
  var e;
715
715
  const t = $(n);
716
716
  return t ? (e = t.copy) !== null && e !== void 0 ? e : t.original : n;
@@ -721,7 +721,7 @@ function _e(n, e) {
721
721
  let t;
722
722
  return Object.getPrototypeOf(n) === Object.prototype || Array.isArray(n) || n instanceof Map || n instanceof Set || !!(e != null && e.mark) && ((t = e.mark(n, de)) === de.immutable || typeof t == "function");
723
723
  }
724
- function Cr(n, e = []) {
724
+ function Pr(n, e = []) {
725
725
  if (Object.hasOwnProperty.call(n, "key")) {
726
726
  const t = n.parent.copy, r = $(Ee(t, n.key));
727
727
  if (r !== null && (r == null ? void 0 : r.original) !== n.original)
@@ -732,10 +732,10 @@ function Cr(n, e = []) {
732
732
  e.push(i);
733
733
  }
734
734
  if (n.parent)
735
- return Cr(n.parent, e);
735
+ return Pr(n.parent, e);
736
736
  e.reverse();
737
737
  try {
738
- Bs(n.copy, e);
738
+ Hs(n.copy, e);
739
739
  } catch {
740
740
  return null;
741
741
  }
@@ -750,14 +750,14 @@ function Ee(n, e) {
750
750
  function ot(n, e, t) {
751
751
  xe(n) === 2 ? n.set(e, t) : n[e] = t;
752
752
  }
753
- function Ut(n, e) {
753
+ function Lt(n, e) {
754
754
  const t = $(n);
755
755
  return (t ? fe(t) : n)[e];
756
756
  }
757
757
  function Oe(n, e) {
758
758
  return n === e ? n !== 0 || 1 / n === 1 / e : n !== n && e !== e;
759
759
  }
760
- function Bt(n) {
760
+ function Ht(n) {
761
761
  if (n)
762
762
  for (; n.finalities.revoke.length > 0; )
763
763
  n.finalities.revoke.pop()();
@@ -768,7 +768,7 @@ function Me(n, e) {
768
768
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
769
769
  }).join("/");
770
770
  }
771
- function Bs(n, e) {
771
+ function Hs(n, e) {
772
772
  for (let t = 0; t < e.length - 1; t += 1) {
773
773
  const r = e[t];
774
774
  if (n = Ee(xe(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
@@ -776,7 +776,7 @@ function Bs(n, e) {
776
776
  }
777
777
  return n;
778
778
  }
779
- function Gs(n) {
779
+ function Js(n) {
780
780
  const e = Object.create(Object.getPrototypeOf(n));
781
781
  return Reflect.ownKeys(n).forEach((t) => {
782
782
  let r = Reflect.getOwnPropertyDescriptor(n, t);
@@ -792,26 +792,26 @@ function Gs(n) {
792
792
  }), Reflect.defineProperty(e, t, r);
793
793
  }), e;
794
794
  }
795
- const Hs = Object.prototype.propertyIsEnumerable;
796
- function Ir(n, e) {
795
+ const Ys = Object.prototype.propertyIsEnumerable;
796
+ function Mr(n, e) {
797
797
  let t;
798
798
  if (Array.isArray(n))
799
799
  return Array.prototype.concat.call(n);
800
800
  if (n instanceof Set) {
801
- if (!dn(n)) {
801
+ if (!pn(n)) {
802
802
  const r = Object.getPrototypeOf(n).constructor;
803
803
  return new r(n.values());
804
804
  }
805
805
  return Set.prototype.difference ? Set.prototype.difference.call(n, /* @__PURE__ */ new Set()) : new Set(n.values());
806
806
  } else if (n instanceof Map) {
807
- if (!hn(n)) {
807
+ if (!yn(n)) {
808
808
  const r = Object.getPrototypeOf(n).constructor;
809
809
  return new r(n);
810
810
  }
811
811
  return new Map(n);
812
812
  } else if (e != null && e.mark && (t = e.mark(n, de), t !== void 0) && t !== de.mutable) {
813
813
  if (t === de.immutable)
814
- return Gs(n);
814
+ return Js(n);
815
815
  if (typeof t == "function") {
816
816
  if (e.enablePatches || e.enableAutoFreeze)
817
817
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -823,17 +823,17 @@ function Ir(n, e) {
823
823
  return Object.keys(n).forEach((s) => {
824
824
  r[s] = n[s];
825
825
  }), Object.getOwnPropertySymbols(n).forEach((s) => {
826
- Hs.call(n, s) && (r[s] = n[s]);
826
+ Ys.call(n, s) && (r[s] = n[s]);
827
827
  }), r;
828
828
  } else
829
829
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
830
830
  }
831
831
  function ie(n) {
832
- n.copy || (n.copy = Ir(n.original, n.options));
832
+ n.copy || (n.copy = Mr(n.original, n.options));
833
833
  }
834
834
  function Xe(n) {
835
835
  if (!_e(n))
836
- return pn(n);
836
+ return bn(n);
837
837
  if (Array.isArray(n))
838
838
  return n.map(Xe);
839
839
  if (n instanceof Map) {
@@ -841,7 +841,7 @@ function Xe(n) {
841
841
  r,
842
842
  Xe(s)
843
843
  ]);
844
- if (!hn(n)) {
844
+ if (!yn(n)) {
845
845
  const r = Object.getPrototypeOf(n).constructor;
846
846
  return new r(t);
847
847
  }
@@ -849,7 +849,7 @@ function Xe(n) {
849
849
  }
850
850
  if (n instanceof Set) {
851
851
  const t = Array.from(n).map(Xe);
852
- if (!dn(n)) {
852
+ if (!pn(n)) {
853
853
  const r = Object.getPrototypeOf(n).constructor;
854
854
  return new r(t);
855
855
  }
@@ -860,14 +860,14 @@ function Xe(n) {
860
860
  e[t] = Xe(n[t]);
861
861
  return e;
862
862
  }
863
- function _t(n) {
863
+ function mt(n) {
864
864
  return $e(n) ? Xe(n) : n;
865
865
  }
866
866
  function Se(n) {
867
867
  var e;
868
868
  n.assignedMap = (e = n.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), n.operated || (n.operated = !0, n.parent && Se(n.parent));
869
869
  }
870
- function qn() {
870
+ function zn() {
871
871
  throw new Error("Cannot modify frozen object");
872
872
  }
873
873
  function Ke(n, e, t, r, s) {
@@ -895,12 +895,12 @@ function Ke(n, e, t, r, s) {
895
895
  case 2:
896
896
  for (const [a, c] of n)
897
897
  Ke(a, a, t, r, s), Ke(c, a, t, r, s);
898
- n.set = n.clear = n.delete = qn;
898
+ n.set = n.clear = n.delete = zn;
899
899
  break;
900
900
  case 3:
901
901
  for (const a of n)
902
902
  Ke(a, a, t, r, s);
903
- n.add = n.clear = n.delete = qn;
903
+ n.add = n.clear = n.delete = zn;
904
904
  break;
905
905
  case 1:
906
906
  Object.freeze(n);
@@ -916,7 +916,7 @@ function Ke(n, e, t, r, s) {
916
916
  }
917
917
  r.pop(), s.pop();
918
918
  }
919
- function yn(n, e) {
919
+ function gn(n, e) {
920
920
  const t = xe(n);
921
921
  if (t === 0)
922
922
  Reflect.ownKeys(n).forEach((r) => {
@@ -929,11 +929,11 @@ function yn(n, e) {
929
929
  } else
930
930
  n.forEach((r, s) => e(s, r, n));
931
931
  }
932
- function Pr(n, e, t) {
932
+ function Rr(n, e, t) {
933
933
  if ($e(n) || !_e(n, t) || e.has(n) || Object.isFrozen(n))
934
934
  return;
935
935
  const r = n instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
936
- if (e.add(n), yn(n, (i, o) => {
936
+ if (e.add(n), gn(n, (i, o) => {
937
937
  var a;
938
938
  if ($e(o)) {
939
939
  const c = $(o);
@@ -941,7 +941,7 @@ function Pr(n, e, t) {
941
941
  const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
942
942
  ot(r ? s : n, i, u);
943
943
  } else
944
- Pr(o, e, t);
944
+ Rr(o, e, t);
945
945
  }), s) {
946
946
  const i = n, o = Array.from(i);
947
947
  i.clear(), o.forEach((a) => {
@@ -949,39 +949,39 @@ function Pr(n, e, t) {
949
949
  });
950
950
  }
951
951
  }
952
- function Js(n, e) {
952
+ function Zs(n, e) {
953
953
  const t = n.type === 3 ? n.setMap : n.copy;
954
- n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && Pr(Ee(t, e), n.finalities.handledSet, n.options);
954
+ n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && Rr(Ee(t, e), n.finalities.handledSet, n.options);
955
955
  }
956
- function Gt(n) {
956
+ function Jt(n) {
957
957
  n.type === 3 && n.copy && (n.copy.clear(), n.setMap.forEach((e) => {
958
- n.copy.add(pn(e));
958
+ n.copy.add(bn(e));
959
959
  }));
960
960
  }
961
- function Ht(n, e, t, r) {
961
+ function Yt(n, e, t, r) {
962
962
  if (n.operated && n.assignedMap && n.assignedMap.size > 0 && !n.finalized) {
963
963
  if (t && r) {
964
- const i = Cr(n);
964
+ const i = Pr(n);
965
965
  i && e(n, i, t, r);
966
966
  }
967
967
  n.finalized = !0;
968
968
  }
969
969
  }
970
- function bn(n, e, t, r) {
970
+ function _n(n, e, t, r) {
971
971
  const s = $(t);
972
972
  s && (s.callbacks || (s.callbacks = []), s.callbacks.push((i, o) => {
973
973
  var a;
974
974
  const c = n.type === 3 ? n.setMap : n.copy;
975
975
  if (Oe(Ee(c, e), t)) {
976
976
  let u = s.original;
977
- s.copy && (u = s.copy), Gt(n), Ht(n, r, i, o), n.options.enableAutoFreeze && (n.options.updatedValues = (a = n.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), n.options.updatedValues.set(u, s.original)), ot(c, e, u);
977
+ s.copy && (u = s.copy), Jt(n), Yt(n, r, i, o), n.options.enableAutoFreeze && (n.options.updatedValues = (a = n.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), n.options.updatedValues.set(u, s.original)), ot(c, e, u);
978
978
  }
979
979
  }), n.options.enableAutoFreeze && s.finalities !== n.finalities && (n.options.enableAutoFreeze = !1)), _e(t, n.options) && n.finalities.draft.push(() => {
980
980
  const i = n.type === 3 ? n.setMap : n.copy;
981
- Oe(Ee(i, e), t) && Js(n, e);
981
+ Oe(Ee(i, e), t) && Zs(n, e);
982
982
  });
983
983
  }
984
- function Ys(n, e, t, r, s) {
984
+ function Xs(n, e, t, r, s) {
985
985
  let { original: i, assignedMap: o, options: a } = n, c = n.copy;
986
986
  c.length < i.length && ([i, c] = [c, i], [t, r] = [r, t]);
987
987
  for (let u = 0; u < i.length; u += 1)
@@ -991,12 +991,12 @@ function Ys(n, e, t, r, s) {
991
991
  op: G.Replace,
992
992
  path: f,
993
993
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
994
- value: _t(c[u])
994
+ value: mt(c[u])
995
995
  }), r.push({
996
996
  op: G.Replace,
997
997
  path: f,
998
998
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
999
- value: _t(i[u])
999
+ value: mt(i[u])
1000
1000
  });
1001
1001
  }
1002
1002
  for (let u = i.length; u < c.length; u += 1) {
@@ -1005,7 +1005,7 @@ function Ys(n, e, t, r, s) {
1005
1005
  op: G.Add,
1006
1006
  path: f,
1007
1007
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
1008
- value: _t(c[u])
1008
+ value: mt(c[u])
1009
1009
  });
1010
1010
  }
1011
1011
  if (i.length < c.length) {
@@ -1027,16 +1027,16 @@ function Ys(n, e, t, r, s) {
1027
1027
  }
1028
1028
  }
1029
1029
  }
1030
- function Zs({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
1030
+ function ei({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
1031
1031
  t.forEach((a, c) => {
1032
- const u = Ee(n, c), l = _t(Ee(e, c)), f = a ? rt(n, c) ? G.Replace : G.Add : G.Remove;
1032
+ const u = Ee(n, c), l = mt(Ee(e, c)), f = a ? rt(n, c) ? G.Replace : G.Add : G.Remove;
1033
1033
  if (Oe(u, l) && f === G.Replace)
1034
1034
  return;
1035
1035
  const h = r.concat(c), y = Me(h, o);
1036
1036
  s.push(f === G.Remove ? { op: f, path: y } : { op: f, path: y, value: l }), i.push(f === G.Add ? { op: G.Remove, path: y } : f === G.Remove ? { op: G.Add, path: y, value: u } : { op: G.Replace, path: y, value: u });
1037
1037
  });
1038
1038
  }
1039
- function Xs({ original: n, copy: e }, t, r, s, i) {
1039
+ function ti({ original: n, copy: e }, t, r, s, i) {
1040
1040
  let o = 0;
1041
1041
  n.forEach((a) => {
1042
1042
  if (!e.has(a)) {
@@ -1073,17 +1073,17 @@ function it(n, e, t, r) {
1073
1073
  switch (n.type) {
1074
1074
  case 0:
1075
1075
  case 2:
1076
- return Zs(n, e, t, r, s);
1076
+ return ei(n, e, t, r, s);
1077
1077
  case 1:
1078
- return Ys(n, e, t, r, s);
1079
- case 3:
1080
1078
  return Xs(n, e, t, r, s);
1079
+ case 3:
1080
+ return ti(n, e, t, r, s);
1081
1081
  }
1082
1082
  }
1083
- const St = (n, e, t = !1) => {
1083
+ const vt = (n, e, t = !1) => {
1084
1084
  if (typeof n == "object" && n !== null && (!_e(n, e) || t))
1085
1085
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
1086
- }, Jt = {
1086
+ }, Zt = {
1087
1087
  get size() {
1088
1088
  return fe($(this)).size;
1089
1089
  },
@@ -1092,7 +1092,7 @@ const St = (n, e, t = !1) => {
1092
1092
  },
1093
1093
  set(n, e) {
1094
1094
  const t = $(this), r = fe(t);
1095
- return (!r.has(n) || !Oe(r.get(n), e)) && (ie(t), Se(t), t.assignedMap.set(n, !0), t.copy.set(n, e), bn(t, n, e, it)), this;
1095
+ return (!r.has(n) || !Oe(r.get(n), e)) && (ie(t), Se(t), t.assignedMap.set(n, !0), t.copy.set(n, e), _n(t, n, e, it)), this;
1096
1096
  },
1097
1097
  delete(n) {
1098
1098
  if (!this.has(n))
@@ -1118,9 +1118,9 @@ const St = (n, e, t = !1) => {
1118
1118
  get(n) {
1119
1119
  var e, t;
1120
1120
  const r = $(this), s = fe(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, de)) === de.mutable;
1121
- if (r.options.strict && St(s, r.options, i), i || r.finalized || !_e(s, r.options) || s !== r.original.get(n))
1121
+ if (r.options.strict && vt(s, r.options, i), i || r.finalized || !_e(s, r.options) || s !== r.original.get(n))
1122
1122
  return s;
1123
- const o = fn.createDraft({
1123
+ const o = hn.createDraft({
1124
1124
  original: s,
1125
1125
  parentDraft: r,
1126
1126
  key: n,
@@ -1135,7 +1135,7 @@ const St = (n, e, t = !1) => {
1135
1135
  values() {
1136
1136
  const n = this.keys();
1137
1137
  return {
1138
- [gt]: () => this.values(),
1138
+ [_t]: () => this.values(),
1139
1139
  next: () => {
1140
1140
  const e = n.next();
1141
1141
  return e.done ? e : {
@@ -1148,7 +1148,7 @@ const St = (n, e, t = !1) => {
1148
1148
  entries() {
1149
1149
  const n = this.keys();
1150
1150
  return {
1151
- [gt]: () => this.entries(),
1151
+ [_t]: () => this.entries(),
1152
1152
  next: () => {
1153
1153
  const e = n.next();
1154
1154
  if (e.done)
@@ -1161,10 +1161,10 @@ const St = (n, e, t = !1) => {
1161
1161
  }
1162
1162
  };
1163
1163
  },
1164
- [gt]() {
1164
+ [_t]() {
1165
1165
  return this.entries();
1166
1166
  }
1167
- }, ei = Reflect.ownKeys(Jt), Wn = (n, e, { isValuesIterator: t }) => () => {
1167
+ }, ni = Reflect.ownKeys(Zt), Vn = (n, e, { isValuesIterator: t }) => () => {
1168
1168
  var r, s;
1169
1169
  const i = e.next();
1170
1170
  if (i.done)
@@ -1172,8 +1172,8 @@ const St = (n, e, t = !1) => {
1172
1172
  const o = i.value;
1173
1173
  let a = n.setMap.get(o);
1174
1174
  const c = $(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, de)) === de.mutable;
1175
- if (n.options.strict && St(o, n.options, u), !u && !c && _e(o, n.options) && !n.finalized && n.original.has(o)) {
1176
- const l = fn.createDraft({
1175
+ if (n.options.strict && vt(o, n.options, u), !u && !c && _e(o, n.options) && !n.finalized && n.original.has(o)) {
1176
+ const l = hn.createDraft({
1177
1177
  original: o,
1178
1178
  parentDraft: n,
1179
1179
  key: o,
@@ -1186,7 +1186,7 @@ const St = (n, e, t = !1) => {
1186
1186
  done: !1,
1187
1187
  value: t ? a : [a, a]
1188
1188
  };
1189
- }, vt = {
1189
+ }, At = {
1190
1190
  get size() {
1191
1191
  return $(this).setMap.size;
1192
1192
  },
@@ -1200,7 +1200,7 @@ const St = (n, e, t = !1) => {
1200
1200
  },
1201
1201
  add(n) {
1202
1202
  const e = $(this);
1203
- return this.has(n) || (ie(e), Se(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), bn(e, n, n, it)), this;
1203
+ return this.has(n) || (ie(e), Se(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), _n(e, n, n, it)), this;
1204
1204
  },
1205
1205
  delete(n) {
1206
1206
  if (!this.has(n))
@@ -1225,7 +1225,7 @@ const St = (n, e, t = !1) => {
1225
1225
  const e = n.setMap.keys();
1226
1226
  return {
1227
1227
  [Symbol.iterator]: () => this.values(),
1228
- next: Wn(n, e, { isValuesIterator: !0 })
1228
+ next: Vn(n, e, { isValuesIterator: !0 })
1229
1229
  };
1230
1230
  },
1231
1231
  entries() {
@@ -1234,7 +1234,7 @@ const St = (n, e, t = !1) => {
1234
1234
  const e = n.setMap.keys();
1235
1235
  return {
1236
1236
  [Symbol.iterator]: () => this.entries(),
1237
- next: Wn(n, e, {
1237
+ next: Vn(n, e, {
1238
1238
  isValuesIterator: !1
1239
1239
  })
1240
1240
  };
@@ -1242,7 +1242,7 @@ const St = (n, e, t = !1) => {
1242
1242
  keys() {
1243
1243
  return this.values();
1244
1244
  },
1245
- [gt]() {
1245
+ [_t]() {
1246
1246
  return this.values();
1247
1247
  },
1248
1248
  forEach(n, e) {
@@ -1252,7 +1252,7 @@ const St = (n, e, t = !1) => {
1252
1252
  n.call(e, r.value, r.value, this), r = t.next();
1253
1253
  }
1254
1254
  };
1255
- Set.prototype.difference && Object.assign(vt, {
1255
+ Set.prototype.difference && Object.assign(At, {
1256
1256
  intersection(n) {
1257
1257
  return Set.prototype.intersection.call(new Set(this.values()), n);
1258
1258
  },
@@ -1275,47 +1275,47 @@ Set.prototype.difference && Object.assign(vt, {
1275
1275
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), n);
1276
1276
  }
1277
1277
  });
1278
- const ti = Reflect.ownKeys(vt), Mr = /* @__PURE__ */ new WeakSet(), Rr = {
1278
+ const ri = Reflect.ownKeys(At), jr = /* @__PURE__ */ new WeakSet(), $r = {
1279
1279
  get(n, e, t) {
1280
1280
  var r, s;
1281
1281
  const i = (r = n.copy) === null || r === void 0 ? void 0 : r[e];
1282
- if (i && Mr.has(i))
1282
+ if (i && jr.has(i))
1283
1283
  return i;
1284
- if (e === kr)
1284
+ if (e === Ir)
1285
1285
  return n;
1286
1286
  let o;
1287
1287
  if (n.options.mark) {
1288
1288
  const u = e === "size" && (n.original instanceof Map || n.original instanceof Set) ? Reflect.get(n.original, e) : Reflect.get(n.original, e, t);
1289
1289
  if (o = n.options.mark(u, de), o === de.mutable)
1290
- return n.options.strict && St(u, n.options, !0), u;
1290
+ return n.options.strict && vt(u, n.options, !0), u;
1291
1291
  }
1292
1292
  const a = fe(n);
1293
- if (a instanceof Map && ei.includes(e)) {
1293
+ if (a instanceof Map && ni.includes(e)) {
1294
1294
  if (e === "size")
1295
- return Object.getOwnPropertyDescriptor(Jt, "size").get.call(n.proxy);
1296
- const u = Jt[e];
1295
+ return Object.getOwnPropertyDescriptor(Zt, "size").get.call(n.proxy);
1296
+ const u = Zt[e];
1297
1297
  if (u)
1298
1298
  return u.bind(n.proxy);
1299
1299
  }
1300
- if (a instanceof Set && ti.includes(e)) {
1300
+ if (a instanceof Set && ri.includes(e)) {
1301
1301
  if (e === "size")
1302
- return Object.getOwnPropertyDescriptor(vt, "size").get.call(n.proxy);
1303
- const u = vt[e];
1302
+ return Object.getOwnPropertyDescriptor(At, "size").get.call(n.proxy);
1303
+ const u = At[e];
1304
1304
  if (u)
1305
1305
  return u.bind(n.proxy);
1306
1306
  }
1307
1307
  if (!rt(a, e)) {
1308
- const u = Kn(a, e);
1308
+ const u = Wn(a, e);
1309
1309
  return u ? "value" in u ? u.value : (
1310
1310
  // !case: support for getter
1311
1311
  (s = u.get) === null || s === void 0 ? void 0 : s.call(n.proxy)
1312
1312
  ) : void 0;
1313
1313
  }
1314
1314
  const c = a[e];
1315
- if (n.options.strict && St(c, n.options), n.finalized || !_e(c, n.options))
1315
+ if (n.options.strict && vt(c, n.options), n.finalized || !_e(c, n.options))
1316
1316
  return c;
1317
- if (c === Ut(n.original, e)) {
1318
- if (ie(n), n.copy[e] = gn({
1317
+ if (c === Lt(n.original, e)) {
1318
+ if (ie(n), n.copy[e] = mn({
1319
1319
  original: n.original[e],
1320
1320
  parentDraft: n,
1321
1321
  key: n.type === 1 ? Number(e) : e,
@@ -1336,11 +1336,11 @@ const ti = Reflect.ownKeys(vt), Mr = /* @__PURE__ */ new WeakSet(), Rr = {
1336
1336
  let s;
1337
1337
  if (n.type === 1 && e !== "length" && !(Number.isInteger(s = Number(e)) && s >= 0 && (e === 0 || s === 0 || String(s) === String(e))))
1338
1338
  throw new Error("Only supports setting array indices and the 'length' property.");
1339
- const i = Kn(fe(n), e);
1339
+ const i = Wn(fe(n), e);
1340
1340
  if (i != null && i.set)
1341
1341
  return i.set.call(n.proxy, t), !0;
1342
- const o = Ut(fe(n), e), a = $(o);
1343
- return a && Oe(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (Oe(t, o) && (t !== void 0 || rt(n.original, e)) || (ie(n), Se(n), rt(n.original, e) && Oe(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, bn(n, e, t, it)), !0);
1342
+ const o = Lt(fe(n), e), a = $(o);
1343
+ return a && Oe(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (Oe(t, o) && (t !== void 0 || rt(n.original, e)) || (ie(n), Se(n), rt(n.original, e) && Oe(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, _n(n, e, t, it)), !0);
1344
1344
  },
1345
1345
  has(n, e) {
1346
1346
  return e in fe(n);
@@ -1368,10 +1368,10 @@ const ti = Reflect.ownKeys(vt), Mr = /* @__PURE__ */ new WeakSet(), Rr = {
1368
1368
  },
1369
1369
  deleteProperty(n, e) {
1370
1370
  var t;
1371
- return n.type === 1 ? Rr.set.call(this, n, e, void 0, n.proxy) : (Ut(n.original, e) !== void 0 || e in n.original ? (ie(n), Se(n), n.assignedMap.set(e, !1)) : (n.assignedMap = (t = n.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), n.assignedMap.delete(e)), n.copy && delete n.copy[e], !0);
1371
+ return n.type === 1 ? $r.set.call(this, n, e, void 0, n.proxy) : (Lt(n.original, e) !== void 0 || e in n.original ? (ie(n), Se(n), n.assignedMap.set(e, !1)) : (n.assignedMap = (t = n.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), n.assignedMap.delete(e)), n.copy && delete n.copy[e], !0);
1372
1372
  }
1373
1373
  };
1374
- function gn(n) {
1374
+ function mn(n) {
1375
1375
  const { original: e, parentDraft: t, key: r, finalities: s, options: i } = n, o = xe(e), a = {
1376
1376
  type: o,
1377
1377
  finalized: !1,
@@ -1385,8 +1385,8 @@ function gn(n) {
1385
1385
  setMap: o === 3 ? new Map(e.entries()) : void 0
1386
1386
  };
1387
1387
  (r || "key" in n) && (a.key = r);
1388
- const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, Rr);
1389
- if (s.revoke.push(u), Mr.add(c), a.proxy = c, t) {
1388
+ const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, $r);
1389
+ if (s.revoke.push(u), jr.add(c), a.proxy = c, t) {
1390
1390
  const l = t;
1391
1391
  l.finalities.draft.push((f, h) => {
1392
1392
  var y, b;
@@ -1395,7 +1395,7 @@ function gn(n) {
1395
1395
  const S = Ee(T, r), g = $(S);
1396
1396
  if (g) {
1397
1397
  let m = g.original;
1398
- g.operated && (m = pn(S)), Gt(g), Ht(g, it, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (y = l.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(m, g.original)), ot(T, r, m);
1398
+ g.operated && (m = bn(S)), Jt(g), Yt(g, it, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (y = l.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(m, g.original)), ot(T, r, m);
1399
1399
  }
1400
1400
  (b = _.callbacks) === null || b === void 0 || b.forEach((m) => {
1401
1401
  m(f, h);
@@ -1404,26 +1404,26 @@ function gn(n) {
1404
1404
  } else {
1405
1405
  const l = $(c);
1406
1406
  l.finalities.draft.push((f, h) => {
1407
- Gt(l), Ht(l, it, f, h);
1407
+ Jt(l), Yt(l, it, f, h);
1408
1408
  });
1409
1409
  }
1410
1410
  return c;
1411
1411
  }
1412
- fn.createDraft = gn;
1413
- function ni(n, e, t, r, s) {
1412
+ hn.createDraft = mn;
1413
+ function si(n, e, t, r, s) {
1414
1414
  var i;
1415
1415
  const o = $(n), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : n, c = !!e.length;
1416
1416
  if (o != null && o.operated)
1417
1417
  for (; o.finalities.draft.length > 0; )
1418
1418
  o.finalities.draft.pop()(t, r);
1419
1419
  const u = c ? e[0] : o ? o.operated ? o.copy : o.original : n;
1420
- return o && Bt(o), s && Ke(u, u, o == null ? void 0 : o.options.updatedValues), [
1420
+ return o && Ht(o), s && Ke(u, u, o == null ? void 0 : o.options.updatedValues), [
1421
1421
  u,
1422
1422
  t && c ? [{ op: G.Replace, path: [], value: e[0] }] : t,
1423
1423
  r && c ? [{ op: G.Replace, path: [], value: a }] : r
1424
1424
  ];
1425
1425
  }
1426
- function ri(n, e) {
1426
+ function ii(n, e) {
1427
1427
  var t;
1428
1428
  const r = {
1429
1429
  draft: [],
@@ -1432,7 +1432,7 @@ function ri(n, e) {
1432
1432
  };
1433
1433
  let s, i;
1434
1434
  e.enablePatches && (s = [], i = []);
1435
- const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, de)) === de.mutable || !_e(n, e) ? n : gn({
1435
+ const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, de)) === de.mutable || !_e(n, e) ? n : mn({
1436
1436
  original: n,
1437
1437
  parentDraft: null,
1438
1438
  finalities: r,
@@ -1441,14 +1441,14 @@ function ri(n, e) {
1441
1441
  return [
1442
1442
  a,
1443
1443
  (c = []) => {
1444
- const [u, l, f] = ni(a, c, s, i, e.enableAutoFreeze);
1444
+ const [u, l, f] = si(a, c, s, i, e.enableAutoFreeze);
1445
1445
  return e.enablePatches ? [u, l, f] : u;
1446
1446
  }
1447
1447
  ];
1448
1448
  }
1449
- function Yt(n) {
1449
+ function Xt(n) {
1450
1450
  const { rootDraft: e, value: t, useRawReturn: r = !1, isRoot: s = !0 } = n;
1451
- yn(t, (i, o, a) => {
1451
+ gn(t, (i, o, a) => {
1452
1452
  const c = $(o);
1453
1453
  if (c && e && c.finalities === e.finalities) {
1454
1454
  n.isContainDraft = !0;
@@ -1458,10 +1458,10 @@ function Yt(n) {
1458
1458
  a.clear(), l.forEach((f) => a.add(i === f ? u : f));
1459
1459
  } else
1460
1460
  ot(a, i, u);
1461
- } else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, Yt(n));
1461
+ } else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, Xt(n));
1462
1462
  }), s && (n.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."));
1463
1463
  }
1464
- function jr(n) {
1464
+ function xr(n) {
1465
1465
  var e;
1466
1466
  const t = $(n);
1467
1467
  if (!_e(n, t == null ? void 0 : t.options))
@@ -1471,7 +1471,7 @@ function jr(n) {
1471
1471
  return t.original;
1472
1472
  let s;
1473
1473
  function i() {
1474
- s = r === 2 ? hn(n) ? new Map(n) : new (Object.getPrototypeOf(n)).constructor(n) : r === 3 ? Array.from(t.setMap.values()) : Ir(n, t == null ? void 0 : t.options);
1474
+ s = r === 2 ? yn(n) ? new Map(n) : new (Object.getPrototypeOf(n)).constructor(n) : r === 3 ? Array.from(t.setMap.values()) : Mr(n, t == null ? void 0 : t.options);
1475
1475
  }
1476
1476
  if (t) {
1477
1477
  t.finalized = !0;
@@ -1482,23 +1482,23 @@ function jr(n) {
1482
1482
  }
1483
1483
  } else
1484
1484
  s = n;
1485
- if (yn(s, (o, a) => {
1485
+ if (gn(s, (o, a) => {
1486
1486
  if (t && Oe(Ee(t.original, o), a))
1487
1487
  return;
1488
- const c = jr(a);
1488
+ const c = xr(a);
1489
1489
  c !== a && (s === n && i(), ot(s, o, c));
1490
1490
  }), r === 3) {
1491
1491
  const o = (e = t == null ? void 0 : t.original) !== null && e !== void 0 ? e : s;
1492
- return dn(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
1492
+ return pn(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
1493
1493
  }
1494
1494
  return s;
1495
1495
  }
1496
- function zn(n) {
1496
+ function Qn(n) {
1497
1497
  if (!$e(n))
1498
1498
  throw new Error(`current() is only used for Draft, parameter: ${n}`);
1499
- return jr(n);
1499
+ return xr(n);
1500
1500
  }
1501
- const si = (n) => function e(t, r, s) {
1501
+ const oi = (n) => function e(t, r, s) {
1502
1502
  var i, o, a;
1503
1503
  if (typeof t == "function" && typeof r != "function")
1504
1504
  return function(v, ...M) {
@@ -1509,7 +1509,7 @@ const si = (n) => function e(t, r, s) {
1509
1509
  if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
1510
1510
  throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
1511
1511
  l = Object.assign(Object.assign({}, n), l);
1512
- const f = $e(c) ? zn(c) : c, h = Array.isArray(l.mark) ? (v, M) => {
1512
+ const f = $e(c) ? Qn(c) : c, h = Array.isArray(l.mark) ? (v, M) => {
1513
1513
  for (const x of l.mark) {
1514
1514
  if (typeof x != "function")
1515
1515
  throw new Error(`Invalid mark: ${x}, 'mark' should be a function.`);
@@ -1525,7 +1525,7 @@ const si = (n) => function e(t, r, s) {
1525
1525
  };
1526
1526
  if (!_e(f, T) && typeof f == "object" && f !== null)
1527
1527
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
1528
- const [S, g] = ri(f, T);
1528
+ const [S, g] = ii(f, T);
1529
1529
  if (typeof r != "function") {
1530
1530
  if (!_e(f, T))
1531
1531
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
@@ -1535,24 +1535,24 @@ const si = (n) => function e(t, r, s) {
1535
1535
  try {
1536
1536
  m = u(S);
1537
1537
  } catch (v) {
1538
- throw Bt($(S)), v;
1538
+ throw Ht($(S)), v;
1539
1539
  }
1540
1540
  const I = (v) => {
1541
1541
  const M = $(S);
1542
1542
  if (!$e(v)) {
1543
1543
  if (v !== void 0 && !Oe(v, S) && (M != null && M.operated))
1544
1544
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
1545
- const N = v == null ? void 0 : v[Qs];
1545
+ const N = v == null ? void 0 : v[Gs];
1546
1546
  if (N) {
1547
1547
  const W = N[0];
1548
- return T.strict && typeof v == "object" && v !== null && Yt({
1548
+ return T.strict && typeof v == "object" && v !== null && Xt({
1549
1549
  rootDraft: M,
1550
1550
  value: v,
1551
1551
  useRawReturn: !0
1552
1552
  }), g([W]);
1553
1553
  }
1554
1554
  if (v !== void 0)
1555
- return typeof v == "object" && v !== null && Yt({ rootDraft: M, value: v }), g([v]);
1555
+ return typeof v == "object" && v !== null && Xt({ rootDraft: M, value: v }), g([v]);
1556
1556
  }
1557
1557
  if (v === S || v === void 0)
1558
1558
  return g([]);
@@ -1560,26 +1560,26 @@ const si = (n) => function e(t, r, s) {
1560
1560
  if (T === x.options) {
1561
1561
  if (x.operated)
1562
1562
  throw new Error("Cannot return a modified child draft.");
1563
- return g([zn(v)]);
1563
+ return g([Qn(v)]);
1564
1564
  }
1565
1565
  return g([v]);
1566
1566
  };
1567
1567
  return m instanceof Promise ? m.then(I, (v) => {
1568
- throw Bt($(S)), v;
1568
+ throw Ht($(S)), v;
1569
1569
  }) : I(m);
1570
- }, At = si();
1570
+ }, Ot = oi();
1571
1571
  Object.prototype.constructor.toString();
1572
- function $r(n, e) {
1572
+ function Dr(n, e) {
1573
1573
  const t = Object.keys(n), r = Object.keys(e);
1574
1574
  return t.length === r.length && Object.keys(n).every((s) => e.hasOwnProperty(s));
1575
1575
  }
1576
- function Vn(n, e) {
1576
+ function Bn(n, e) {
1577
1577
  return Object.keys(n).length === Object.keys(e).length && Object.keys(n).every((t) => e.hasOwnProperty(t) && n[t] === e[t]);
1578
1578
  }
1579
- function mt(n, e) {
1580
- return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : $r(n, e) ? Object.keys(n).every((t) => mt(n[t], e[t])) : !1;
1579
+ function wt(n, e) {
1580
+ return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Dr(n, e) ? Object.keys(n).every((t) => wt(n[t], e[t])) : !1;
1581
1581
  }
1582
- function _n(n) {
1582
+ function wn(n) {
1583
1583
  if (!et(n))
1584
1584
  return n;
1585
1585
  const e = {};
@@ -1587,7 +1587,7 @@ function _n(n) {
1587
1587
  r !== void 0 && (e[t] = r);
1588
1588
  return e;
1589
1589
  }
1590
- function xr(n, e) {
1590
+ function Ur(n, e) {
1591
1591
  if (!et(n) || !et(e))
1592
1592
  return e;
1593
1593
  const t = { ...n };
@@ -1599,14 +1599,14 @@ function xr(n, e) {
1599
1599
  continue;
1600
1600
  }
1601
1601
  const s = et(n[r]) && et(e[r]);
1602
- t[r] = s ? xr(n[r], e[r]) : e[r];
1602
+ t[r] = s ? Ur(n[r], e[r]) : e[r];
1603
1603
  }
1604
1604
  return t;
1605
1605
  }
1606
1606
  function et(n) {
1607
1607
  return typeof n == "object" && n !== null && !Array.isArray(n);
1608
1608
  }
1609
- function ii(n, e, t) {
1609
+ function ai(n, e, t) {
1610
1610
  if (!n || e.length === 0)
1611
1611
  return;
1612
1612
  let r = n || {};
@@ -1617,7 +1617,7 @@ function ii(n, e, t) {
1617
1617
  const s = e[e.length - 1];
1618
1618
  Array.isArray(r) && typeof s == "number" ? r.splice(s, 0, t) : r[s] = t;
1619
1619
  }
1620
- function Qn(n, e, t) {
1620
+ function Gn(n, e, t) {
1621
1621
  if (!n || e.length === 0)
1622
1622
  return;
1623
1623
  let r = n || {};
@@ -1627,7 +1627,7 @@ function Qn(n, e, t) {
1627
1627
  }
1628
1628
  r[e[e.length - 1]] = t;
1629
1629
  }
1630
- function Dr(n, e) {
1630
+ function Lr(n, e) {
1631
1631
  if (!n || e.length === 0)
1632
1632
  return;
1633
1633
  const [t, ...r] = e;
@@ -1636,13 +1636,13 @@ function Dr(n, e) {
1636
1636
  Array.isArray(n) ? n.splice(t, 1) : delete n[t];
1637
1637
  return;
1638
1638
  }
1639
- Dr(n[t], r), oi(n[t]) && delete n[t];
1639
+ Lr(n[t], r), ci(n[t]) && delete n[t];
1640
1640
  }
1641
1641
  }
1642
- function oi(n) {
1642
+ function ci(n) {
1643
1643
  return n && Object.keys(n).length === 0;
1644
1644
  }
1645
- 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$/, ai = {
1645
+ const Hn = /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$/, ui = {
1646
1646
  ZULU: 0,
1647
1647
  YEKT: 18e3,
1648
1648
  YEKST: 21600,
@@ -1838,39 +1838,39 @@ const Bn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
1838
1838
  ACSST: 37800,
1839
1839
  ACDT: 37800
1840
1840
  };
1841
- function ci(n) {
1841
+ function li(n) {
1842
1842
  return new Date(n);
1843
1843
  }
1844
- function ui(n) {
1844
+ function fi(n) {
1845
1845
  return /* @__PURE__ */ new Date(n + "Z");
1846
1846
  }
1847
- const li = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1848
- function fi(n) {
1849
- const e = n.match(li);
1847
+ const di = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1848
+ function hi(n) {
1849
+ const e = n.match(di);
1850
1850
  if (!e)
1851
1851
  return null;
1852
1852
  const [t, r, s, i] = e;
1853
1853
  return r <= 0 || s <= 0 || i <= 0 ? null : r > 999 ? new Date(Date.UTC(r, s - 1, i, 0, 0, 0, 0)) : new Date(Date.UTC(i, r - 1, s, 0, 0, 0, 0));
1854
1854
  }
1855
- function di(n) {
1855
+ function pi(n) {
1856
1856
  const [e, t] = n.split(" ");
1857
1857
  return /* @__PURE__ */ new Date(e + "T" + t + "Z");
1858
1858
  }
1859
- function hi(n) {
1859
+ function yi(n) {
1860
1860
  const [e, t] = n.split(" ");
1861
1861
  return /* @__PURE__ */ new Date(e + "T" + t + "Z");
1862
1862
  }
1863
- function pi(n) {
1863
+ function bi(n) {
1864
1864
  return new Date(n);
1865
1865
  }
1866
- function yi(n) {
1866
+ function gi(n) {
1867
1867
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1868
1868
  if (!n.match(e))
1869
1869
  throw new Error(`Unable to parse \`${n}\` as a date.`);
1870
1870
  const r = /* @__PURE__ */ new Date(n + " UTC");
1871
1871
  return new Date(Date.UTC(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate(), 0, 0, 0, 0));
1872
1872
  }
1873
- function bi(n) {
1873
+ function _i(n) {
1874
1874
  const e = /^(.+T.+)([+-])(\d{2})$/, t = n.match(e);
1875
1875
  if (t) {
1876
1876
  const [, r, s, i] = t, o = `${r}${s}${i}:00`;
@@ -1878,7 +1878,7 @@ function bi(n) {
1878
1878
  }
1879
1879
  return null;
1880
1880
  }
1881
- function gi(n) {
1881
+ function mi(n) {
1882
1882
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, t = n.match(e);
1883
1883
  if (t) {
1884
1884
  const [, r, s, i, o, a] = t, c = s.padStart(2, "0"), u = i.padStart(2, "0"), l = `${r}-${c}-${u}T${a}`;
@@ -1886,14 +1886,14 @@ function gi(n) {
1886
1886
  }
1887
1887
  return null;
1888
1888
  }
1889
- function _i(n) {
1889
+ function wi(n) {
1890
1890
  const [e, t] = n.split(", "), [r, s, i] = e.split("/").map(Number), o = t.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1891
1891
  if (!o)
1892
1892
  throw new Error(`Unable to parse time from: ${n}`);
1893
1893
  let [, a, c, u, l] = o;
1894
1894
  return a = Number(a), c = Number(c), u = Number(u), l === "PM" && a !== 12 ? a += 12 : l === "AM" && a === 12 && (a = 0), new Date(Date.UTC(i, r - 1, s, a, c, u));
1895
1895
  }
1896
- function mi(n) {
1896
+ function Ti(n) {
1897
1897
  switch (n) {
1898
1898
  case "epoch":
1899
1899
  return /* @__PURE__ */ new Date(0);
@@ -1905,28 +1905,28 @@ function mi(n) {
1905
1905
  return null;
1906
1906
  }
1907
1907
  }
1908
- function wi(n) {
1909
- const e = n.match(Bn);
1908
+ function Si(n) {
1909
+ const e = n.match(Hn);
1910
1910
  if (!e)
1911
1911
  return null;
1912
- const [t] = e, r = ai[t], s = new Date(n.replace(Bn, "Z"));
1912
+ const [t] = e, r = ui[t], s = new Date(n.replace(Hn, "Z"));
1913
1913
  return new Date(s.getTime() - r * 1e3);
1914
1914
  }
1915
- const Ti = [
1916
- fi,
1915
+ const vi = [
1917
1916
  hi,
1918
1917
  yi,
1918
+ gi,
1919
+ wi,
1920
+ bi,
1921
+ fi,
1919
1922
  _i,
1920
1923
  pi,
1921
- ui,
1922
- bi,
1923
- di,
1924
- ci,
1925
- mi,
1926
- wi,
1927
- gi
1924
+ li,
1925
+ Ti,
1926
+ Si,
1927
+ mi
1928
1928
  ];
1929
- function Si(n, e) {
1929
+ function Ai(n, e) {
1930
1930
  try {
1931
1931
  const t = n(e);
1932
1932
  return t instanceof Date && !isNaN(t.getTime()) ? t : null;
@@ -1934,30 +1934,30 @@ function Si(n, e) {
1934
1934
  return null;
1935
1935
  }
1936
1936
  }
1937
- function Zt(n) {
1938
- for (const e of Ti) {
1939
- const t = Si(e, n);
1937
+ function en(n) {
1938
+ for (const e of vi) {
1939
+ const t = Ai(e, n);
1940
1940
  if (t)
1941
1941
  return t;
1942
1942
  }
1943
1943
  return null;
1944
1944
  }
1945
- function vi(n) {
1945
+ function Oi(n) {
1946
1946
  try {
1947
1947
  const e = JSON.parse(n);
1948
- return typeof e == "string" ? Zt(e) : null;
1948
+ return typeof e == "string" ? en(e) : null;
1949
1949
  } catch {
1950
1950
  return null;
1951
1951
  }
1952
1952
  }
1953
- function kt(n) {
1953
+ function Ct(n) {
1954
1954
  if (n !== void 0) {
1955
1955
  if (n === null)
1956
1956
  return null;
1957
1957
  if (n instanceof Date)
1958
1958
  return n;
1959
1959
  if (typeof n == "string") {
1960
- const e = Zt(n) || vi(n) || Zt(n.trim());
1960
+ const e = en(n) || Oi(n) || en(n.trim());
1961
1961
  if (!e)
1962
1962
  throw new Error(`Unable to parse \`${n}\` as a date.`);
1963
1963
  return e;
@@ -1997,7 +1997,7 @@ class Re {
1997
1997
  return this._blobAttrs;
1998
1998
  this._blobAttrs = /* @__PURE__ */ new Map();
1999
1999
  for (const e of Object.values(this.attrs))
2000
- if (wn(e)) {
2000
+ if (Sn(e)) {
2001
2001
  const [t, r, s] = e["forward-identity"];
2002
2002
  ce(this.blobAttrs, [r, s], e);
2003
2003
  }
@@ -2041,13 +2041,13 @@ class Re {
2041
2041
  return { attrs: this.attrs, linkIndex: this.linkIndex };
2042
2042
  }
2043
2043
  }
2044
- function Ai(n) {
2044
+ function Ei(n) {
2045
2045
  return n.cardinality === "one";
2046
2046
  }
2047
- function mn(n) {
2047
+ function Tn(n) {
2048
2048
  return n["value-type"] === "ref";
2049
2049
  }
2050
- function wn(n) {
2050
+ function Sn(n) {
2051
2051
  return n["value-type"] === "blob";
2052
2052
  }
2053
2053
  function Qe(n, e) {
@@ -2073,7 +2073,7 @@ function ce(n, e, t) {
2073
2073
  }
2074
2074
  s > -1 && r.set(e[s], t);
2075
2075
  }
2076
- function Ur(n, e, t) {
2076
+ function Fr(n, e, t) {
2077
2077
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
2078
2078
  for (const o of e) {
2079
2079
  let [a, c, u] = o;
@@ -2082,11 +2082,11 @@ function Ur(n, e, t) {
2082
2082
  console.warn("no such attr", c, a);
2083
2083
  continue;
2084
2084
  }
2085
- l["checked-data-type"] === "date" && t && (u = kt(u), o[2] = u), mn(l) && ce(i, [u, c, a], o), ce(r, [a, c, u], o), ce(s, [c, a, u], o);
2085
+ l["checked-data-type"] === "date" && t && (u = Ct(u), o[2] = u), Tn(l) && ce(i, [u, c, a], o), ce(r, [a, c, u], o), ce(s, [c, a, u], o);
2086
2086
  }
2087
2087
  return { eav: r, aev: s, vae: i };
2088
2088
  }
2089
- function Lr(n) {
2089
+ function Nr(n) {
2090
2090
  return {
2091
2091
  triples: ue(n.eav, 3),
2092
2092
  cardinalityInference: n.cardinalityInference,
@@ -2094,20 +2094,20 @@ function Lr(n) {
2094
2094
  version: 1
2095
2095
  };
2096
2096
  }
2097
- function Fr(n, e) {
2097
+ function Kr(n, e) {
2098
2098
  return tt(n, e.triples, e.cardinalityInference, e.useDateObjects);
2099
2099
  }
2100
- function Nr(n, e) {
2100
+ function qr(n, e) {
2101
2101
  if (n)
2102
2102
  return new Re(n.attrs, n.linkIndex);
2103
2103
  if (e && "__type" in e)
2104
2104
  return new Re(e.attrs, e.linkIndex);
2105
2105
  }
2106
- function Oi(n, e) {
2106
+ function ki(n, e) {
2107
2107
  return Qe(n.eav, [e]) !== void 0;
2108
2108
  }
2109
2109
  function tt(n, e, t, r) {
2110
- const s = Ur(n, e, r);
2110
+ const s = Fr(n, e, r);
2111
2111
  return s.cardinalityInference = t, s.useDateObjects = r, s;
2112
2112
  }
2113
2113
  function at(n, e) {
@@ -2137,21 +2137,21 @@ function at(n, e) {
2137
2137
  return [t, ...a];
2138
2138
  }
2139
2139
  }
2140
- function Kr(n, e, t) {
2140
+ function Wr(n, e, t) {
2141
2141
  const r = at(n, t);
2142
2142
  if (!r)
2143
2143
  return;
2144
2144
  const [s, i, o] = r, a = e.getAttr(i);
2145
- a && (ge(n.eav, [s, i, o]), ge(n.aev, [i, s, o]), mn(a) && ge(n.vae, [o, i, s]));
2145
+ a && (ge(n.eav, [s, i, o]), ge(n.aev, [i, s, o]), Tn(a) && ge(n.vae, [o, i, s]));
2146
2146
  }
2147
- let Ei = 0;
2148
- function qr(n, e, t) {
2147
+ let Ci = 0;
2148
+ function zr(n, e, t) {
2149
2149
  const [r, s, i] = t;
2150
2150
  let o;
2151
2151
  const a = Qe(n.eav, [r, s, i]);
2152
- return a && (o = a[3]), o || Date.now() * 10 + Ei++;
2152
+ return a && (o = a[3]), o || Date.now() * 10 + Ci++;
2153
2153
  }
2154
- function Wr(n, e, t) {
2154
+ function Vr(n, e, t) {
2155
2155
  const r = at(n, t);
2156
2156
  if (!r)
2157
2157
  return;
@@ -2159,11 +2159,11 @@ function Wr(n, e, t) {
2159
2159
  const a = e.getAttr(i);
2160
2160
  if (!a)
2161
2161
  return;
2162
- a["checked-data-type"] === "date" && n.useDateObjects && (o = kt(o));
2163
- const c = Qe(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? qr(n, a, r), l = [s, i, o, u];
2164
- Ai(a) ? (ce(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), ce(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (ce(n.eav, [s, i, o], l), ce(n.aev, [i, s, o], l)), mn(a) && ce(n.vae, [o, i, s], l);
2162
+ a["checked-data-type"] === "date" && n.useDateObjects && (o = Ct(o));
2163
+ const c = Qe(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? zr(n, a, r), l = [s, i, o, u];
2164
+ Ei(a) ? (ce(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), ce(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (ce(n.eav, [s, i, o], l), ce(n.aev, [i, s, o], l)), Tn(a) && ce(n.vae, [o, i, s], l);
2165
2165
  }
2166
- function ki(n, e, t) {
2166
+ function Ii(n, e, t) {
2167
2167
  var y;
2168
2168
  const r = at(n, t);
2169
2169
  if (!r)
@@ -2171,7 +2171,7 @@ function ki(n, e, t) {
2171
2171
  const [s, i, o] = r, a = e.getAttr(i);
2172
2172
  if (!a)
2173
2173
  return;
2174
- if (!wn(a))
2174
+ if (!Sn(a))
2175
2175
  throw new Error("merge operation is not supported for links");
2176
2176
  const c = Qe(n.eav, [s, i]);
2177
2177
  if (!c)
@@ -2179,15 +2179,15 @@ function ki(n, e, t) {
2179
2179
  const u = (y = c.values().next()) == null ? void 0 : y.value;
2180
2180
  if (!u)
2181
2181
  return;
2182
- const l = u[2], f = xr(l, o), h = [
2182
+ const l = u[2], f = Ur(l, o), h = [
2183
2183
  s,
2184
2184
  i,
2185
2185
  f,
2186
- qr(n, a, u)
2186
+ zr(n, a, u)
2187
2187
  ];
2188
2188
  ce(n.eav, [s, i], /* @__PURE__ */ new Map([[f, h]])), ce(n.aev, [i, s], /* @__PURE__ */ new Map([[f, h]]));
2189
2189
  }
2190
- function Xt(n, e, t) {
2190
+ function tn(n, e, t) {
2191
2191
  var u, l;
2192
2192
  const [r, s] = t, i = at(n, [r]);
2193
2193
  if (!i)
@@ -2198,7 +2198,7 @@ function Xt(n, e, t) {
2198
2198
  const h = e.getAttr(f);
2199
2199
  h && h["on-delete-reverse"] === "cascade" && ue(a.get(f), 1).forEach(([y, b, _]) => {
2200
2200
  var T;
2201
- return Xt(n, e, [_, (T = h["reverse-identity"]) == null ? void 0 : T[1]]);
2201
+ return tn(n, e, [_, (T = h["reverse-identity"]) == null ? void 0 : T[1]]);
2202
2202
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
2203
2203
  // the store that didn't set `etype` in deleteEntity
2204
2204
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -2211,53 +2211,53 @@ function Xt(n, e, t) {
2211
2211
  c && c.forEach((f) => {
2212
2212
  var T, S, g;
2213
2213
  const [h, y, b] = f, _ = e.getAttr(y);
2214
- (!s || !_ || ((T = _["reverse-identity"]) == null ? void 0 : T[1]) === s) && (ge(n.eav, [h, y, b]), ge(n.aev, [y, h, b]), ge(n.vae, [b, y, h])), _ && _["on-delete"] === "cascade" && ((S = _["reverse-identity"]) == null ? void 0 : S[1]) === s && Xt(n, e, [h, (g = _["forward-identity"]) == null ? void 0 : g[1]]);
2214
+ (!s || !_ || ((T = _["reverse-identity"]) == null ? void 0 : T[1]) === s) && (ge(n.eav, [h, y, b]), ge(n.aev, [y, h, b]), ge(n.vae, [b, y, h])), _ && _["on-delete"] === "cascade" && ((S = _["reverse-identity"]) == null ? void 0 : S[1]) === s && tn(n, e, [h, (g = _["forward-identity"]) == null ? void 0 : g[1]]);
2215
2215
  }), ((l = n.vae.get(o)) == null ? void 0 : l.size) === 0 && ge(n.vae, [o]);
2216
2216
  }
2217
- function zr(n, e, t) {
2218
- const r = Ur(e, t, n.useDateObjects);
2217
+ function Qr(n, e, t) {
2218
+ const r = Fr(e, t, n.useDateObjects);
2219
2219
  Object.keys(r).forEach((s) => {
2220
2220
  n[s] = r[s];
2221
2221
  });
2222
2222
  }
2223
- function Ci(n, [e]) {
2223
+ function Pi(n, [e]) {
2224
2224
  n.addAttr(e);
2225
2225
  }
2226
- function Vr(n) {
2226
+ function Br(n) {
2227
2227
  return ue(n.eav, 3);
2228
2228
  }
2229
- function Ii(n, e, [t]) {
2229
+ function Mi(n, e, [t]) {
2230
2230
  if (!e.getAttr(t))
2231
2231
  return;
2232
- const r = Vr(n).filter(([s, i]) => i !== t);
2233
- e.deleteAttr(t), zr(n, e, r);
2232
+ const r = Br(n).filter(([s, i]) => i !== t);
2233
+ e.deleteAttr(t), Qr(n, e, r);
2234
2234
  }
2235
- function Pi(n, e, [t]) {
2236
- e.getAttr(t.id) && (e.updateAttr(t), zr(n, e, Vr(n)));
2235
+ function Ri(n, e, [t]) {
2236
+ e.getAttr(t.id) && (e.updateAttr(t), Qr(n, e, Br(n)));
2237
2237
  }
2238
- function Mi(n, e, t) {
2238
+ function ji(n, e, t) {
2239
2239
  const [r, ...s] = t;
2240
2240
  switch (r) {
2241
2241
  case "add-triple":
2242
- Wr(n, e, s);
2242
+ Vr(n, e, s);
2243
2243
  break;
2244
2244
  case "deep-merge-triple":
2245
- ki(n, e, s);
2245
+ Ii(n, e, s);
2246
2246
  break;
2247
2247
  case "retract-triple":
2248
- Kr(n, e, s);
2248
+ Wr(n, e, s);
2249
2249
  break;
2250
2250
  case "delete-entity":
2251
- Xt(n, e, s);
2251
+ tn(n, e, s);
2252
2252
  break;
2253
2253
  case "add-attr":
2254
- Ci(e, s);
2254
+ Pi(e, s);
2255
2255
  break;
2256
2256
  case "delete-attr":
2257
- Ii(n, e, s);
2257
+ Mi(n, e, s);
2258
2258
  break;
2259
2259
  case "update-attr":
2260
- Pi(n, e, s);
2260
+ Ri(n, e, s);
2261
2261
  break;
2262
2262
  case "restore-attr":
2263
2263
  break;
@@ -2312,13 +2312,13 @@ function ht(n, e, t) {
2312
2312
  }
2313
2313
  return r;
2314
2314
  }
2315
- function Ri(n, e, t) {
2315
+ function $i(n, e, t) {
2316
2316
  let r = "";
2317
2317
  return n !== void 0 && (r += "e"), e !== void 0 && (r += "a"), t !== void 0 && (r += "v"), r;
2318
2318
  }
2319
- function ji(n, [e, t, r]) {
2319
+ function xi(n, [e, t, r]) {
2320
2320
  var i, o;
2321
- switch (Ri(e, t, r)) {
2321
+ switch ($i(e, t, r)) {
2322
2322
  case "e": {
2323
2323
  const a = n.eav.get(e);
2324
2324
  return ue(a, 2);
@@ -2364,7 +2364,7 @@ function ji(n, [e, t, r]) {
2364
2364
  return ue(n.eav, 3);
2365
2365
  }
2366
2366
  }
2367
- function $i(n, e, t) {
2367
+ function Di(n, e, t) {
2368
2368
  var s;
2369
2369
  const r = {};
2370
2370
  if (!e)
@@ -2384,15 +2384,15 @@ function De(n, e, t) {
2384
2384
  var r;
2385
2385
  return (r = n.revIdents.get(e)) == null ? void 0 : r.get(t);
2386
2386
  }
2387
- function xi(n, e) {
2387
+ function Ui(n, e) {
2388
2388
  return n.blobAttrs.get(e);
2389
2389
  }
2390
- function Qr(n, e) {
2390
+ function Gr(n, e) {
2391
2391
  var r;
2392
2392
  const t = n.primaryKeys.get(e);
2393
2393
  return t || ((r = n.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
2394
2394
  }
2395
- function Di(n, e, t) {
2395
+ function Li(n, e, t) {
2396
2396
  const r = at(n, t);
2397
2397
  if (!r)
2398
2398
  return;
@@ -2400,7 +2400,7 @@ function Di(n, e, t) {
2400
2400
  if (e.getAttr(i))
2401
2401
  return Qe(n.eav, [s, i]);
2402
2402
  }
2403
- function Ui(n, e, t) {
2403
+ function Fi(n, e, t) {
2404
2404
  const r = t.filter(([s, i, o, a, c]) => {
2405
2405
  if (s !== "add-triple" && s !== "deep-merge-triple")
2406
2406
  return !0;
@@ -2410,8 +2410,8 @@ function Ui(n, e, t) {
2410
2410
  let l = !1;
2411
2411
  const f = e.getAttr(o);
2412
2412
  if (f) {
2413
- const h = Qr(e, f["forward-identity"][1]);
2414
- l = !!Di(n, e, [
2413
+ const h = Gr(e, f["forward-identity"][1]);
2414
+ l = !!Li(n, e, [
2415
2415
  i,
2416
2416
  h == null ? void 0 : h.id,
2417
2417
  i
@@ -2419,9 +2419,9 @@ function Ui(n, e, t) {
2419
2419
  }
2420
2420
  return !(u === "create" && l || u === "update" && !l);
2421
2421
  });
2422
- return At({ store: n, attrsStore: e }, (s) => {
2422
+ return Ot({ store: n, attrsStore: e }, (s) => {
2423
2423
  r.forEach((i) => {
2424
- Mi(s.store, s.attrsStore, i);
2424
+ ji(s.store, s.attrsStore, i);
2425
2425
  });
2426
2426
  }, {
2427
2427
  mark: (s) => {
@@ -2430,28 +2430,28 @@ function Ui(n, e, t) {
2430
2430
  }
2431
2431
  });
2432
2432
  }
2433
- function Li(n) {
2433
+ function Ni(n) {
2434
2434
  return typeof n == "string" && n.startsWith("?");
2435
2435
  }
2436
- function Fi(n, e, t) {
2436
+ function Ki(n, e, t) {
2437
2437
  if (t.hasOwnProperty(n)) {
2438
2438
  const r = t[n];
2439
- return Br(r, e, t);
2439
+ return Hr(r, e, t);
2440
2440
  }
2441
2441
  return { ...t, [n]: e };
2442
2442
  }
2443
- function Gn(n, e, t) {
2443
+ function Jn(n, e, t) {
2444
2444
  return n === e ? t : null;
2445
2445
  }
2446
- function Ni(n) {
2446
+ function qi(n) {
2447
2447
  switch (typeof n) {
2448
2448
  case "string":
2449
- return n.startsWith("?") ? Fi : Gn;
2449
+ return n.startsWith("?") ? Ki : Jn;
2450
2450
  default:
2451
- return Gn;
2451
+ return Jn;
2452
2452
  }
2453
2453
  }
2454
- const Ki = [
2454
+ const Wi = [
2455
2455
  "in",
2456
2456
  "$in",
2457
2457
  "$not",
@@ -2459,77 +2459,77 @@ const Ki = [
2459
2459
  "$comparator"
2460
2460
  // covers all of $gt, $lt, etc.
2461
2461
  ];
2462
- function qi(n) {
2463
- for (const e of Ki)
2462
+ function zi(n) {
2463
+ for (const e of Wi)
2464
2464
  if (n.hasOwnProperty(e))
2465
2465
  return !0;
2466
2466
  return !1;
2467
2467
  }
2468
- function Br(n, e, t) {
2469
- return t ? typeof n == "object" ? qi(n) ? t : null : Ni(n)(n, e, t) : null;
2468
+ function Hr(n, e, t) {
2469
+ return t ? typeof n == "object" ? zi(n) ? t : null : qi(n)(n, e, t) : null;
2470
2470
  }
2471
- function Wi(n, e, t) {
2471
+ function Vi(n, e, t) {
2472
2472
  return n.reduce((r, s, i) => {
2473
2473
  const o = e[i];
2474
- return Br(s, o, r);
2474
+ return Hr(s, o, r);
2475
2475
  }, t);
2476
2476
  }
2477
- function zi(n, e, t) {
2478
- return Bi(n, e, t).map((r) => Wi(e, r, t)).filter((r) => r);
2477
+ function Qi(n, e, t) {
2478
+ return Hi(n, e, t).map((r) => Vi(e, r, t)).filter((r) => r);
2479
2479
  }
2480
- function Vi(n, e, t) {
2481
- return e.or ? e.or.patterns.flatMap((r) => en(n, r, t)) : e.and ? e.and.patterns.reduce((r, s) => en(n, s, r), t) : t.flatMap((r) => zi(n, e, r));
2480
+ function Bi(n, e, t) {
2481
+ return e.or ? e.or.patterns.flatMap((r) => nn(n, r, t)) : e.and ? e.and.patterns.reduce((r, s) => nn(n, s, r), t) : t.flatMap((r) => Qi(n, e, r));
2482
2482
  }
2483
- function en(n, e, t = [{}]) {
2484
- return e.reduce((r, s) => Vi(n, s, r), t);
2483
+ function nn(n, e, t = [{}]) {
2484
+ return e.reduce((r, s) => Bi(n, s, r), t);
2485
2485
  }
2486
- function Tn(n, e) {
2487
- return Array.isArray(e) ? e.map((t) => Tn(n, t)) : Li(e) ? n[e] : e;
2486
+ function vn(n, e) {
2487
+ return Array.isArray(e) ? e.map((t) => vn(n, t)) : Ni(e) ? n[e] : e;
2488
2488
  }
2489
- function Qi(n, { find: e, where: t }) {
2490
- return en(n, t).map((s) => Tn(s, e));
2489
+ function Gi(n, { find: e, where: t }) {
2490
+ return nn(n, t).map((s) => vn(s, e));
2491
2491
  }
2492
- function Bi(n, e, t) {
2493
- return ji(n, Tn(t, e));
2492
+ function Hi(n, e, t) {
2493
+ return xi(n, vn(t, e));
2494
2494
  }
2495
- const Gi = /^(?:[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;
2495
+ const Ji = /^(?:[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;
2496
2496
  function ze(n) {
2497
- return typeof n == "string" && Gi.test(n);
2497
+ return typeof n == "string" && Ji.test(n);
2498
2498
  }
2499
2499
  const ne = [];
2500
2500
  for (let n = 0; n < 256; ++n)
2501
2501
  ne.push((n + 256).toString(16).slice(1));
2502
- function Hi(n, e = 0) {
2502
+ function Yi(n, e = 0) {
2503
2503
  return (ne[n[e + 0]] + ne[n[e + 1]] + ne[n[e + 2]] + ne[n[e + 3]] + "-" + ne[n[e + 4]] + ne[n[e + 5]] + "-" + ne[n[e + 6]] + ne[n[e + 7]] + "-" + ne[n[e + 8]] + ne[n[e + 9]] + "-" + ne[n[e + 10]] + ne[n[e + 11]] + ne[n[e + 12]] + ne[n[e + 13]] + ne[n[e + 14]] + ne[n[e + 15]]).toLowerCase();
2504
2504
  }
2505
- let Lt;
2506
- const Ji = new Uint8Array(16);
2507
- function Yi() {
2508
- if (!Lt) {
2505
+ let Ft;
2506
+ const Zi = new Uint8Array(16);
2507
+ function Xi() {
2508
+ if (!Ft) {
2509
2509
  if (typeof crypto > "u" || !crypto.getRandomValues)
2510
2510
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2511
- Lt = crypto.getRandomValues.bind(crypto);
2511
+ Ft = crypto.getRandomValues.bind(crypto);
2512
2512
  }
2513
- return Lt(Ji);
2513
+ return Ft(Zi);
2514
2514
  }
2515
- const Zi = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Hn = { randomUUID: Zi };
2516
- function Xi(n, e, t) {
2515
+ const eo = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Yn = { randomUUID: eo };
2516
+ function to(n, e, t) {
2517
2517
  var s;
2518
- if (Hn.randomUUID && !n)
2519
- return Hn.randomUUID();
2518
+ if (Yn.randomUUID && !n)
2519
+ return Yn.randomUUID();
2520
2520
  n = n || {};
2521
- const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? Yi();
2521
+ const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? Xi();
2522
2522
  if (r.length < 16)
2523
2523
  throw new Error("Random bytes length must be >= 16");
2524
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Hi(r);
2524
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Yi(r);
2525
2525
  }
2526
- function Jn(n) {
2526
+ function Zn(n) {
2527
2527
  const e = n.replace(/-/g, ""), t = [];
2528
2528
  for (let r = 0; r < e.length; r += 2)
2529
2529
  t.push(parseInt(e.substring(r, r + 2), 16));
2530
2530
  return t;
2531
2531
  }
2532
- function eo(n, e) {
2532
+ function no(n, e) {
2533
2533
  for (let t = 0; t < n.length; t++) {
2534
2534
  if (n[t] < e[t])
2535
2535
  return -1;
@@ -2538,17 +2538,17 @@ function eo(n, e) {
2538
2538
  }
2539
2539
  return 0;
2540
2540
  }
2541
- function to(n, e) {
2542
- return eo(Jn(n), Jn(e));
2541
+ function ro(n, e) {
2542
+ return no(Zn(n), Zn(e));
2543
2543
  }
2544
2544
  function V() {
2545
- return Xi();
2545
+ return to();
2546
2546
  }
2547
- function no(n, e) {
2547
+ function so(n, e) {
2548
2548
  return n.localeCompare(e);
2549
2549
  }
2550
- function ro() {
2551
- let n = no;
2550
+ function io() {
2551
+ let n = so;
2552
2552
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
2553
2553
  try {
2554
2554
  n = Intl.Collator("en-US").compare;
@@ -2556,12 +2556,12 @@ function ro() {
2556
2556
  }
2557
2557
  return n;
2558
2558
  }
2559
- const so = ro();
2560
- let io = !0, oo = 0;
2559
+ const oo = io();
2560
+ let ao = !0, co = 0;
2561
2561
  function st(n) {
2562
- return Ct(`_${n}`, oo++);
2562
+ return It(`_${n}`, co++);
2563
2563
  }
2564
- function Ct(n, e) {
2564
+ function It(n, e) {
2565
2565
  return `?${n}-${e}`;
2566
2566
  }
2567
2567
  class Ve extends Error {
@@ -2569,27 +2569,27 @@ class Ve extends Error {
2569
2569
  super(e), this.name = "AttrNotFoundError";
2570
2570
  }
2571
2571
  }
2572
- function ao(n, e) {
2573
- const t = Qr(n, e);
2572
+ function uo(n, e) {
2573
+ const t = Gr(n, e);
2574
2574
  if (!t)
2575
2575
  throw new Ve(`Could not find id attr for ${e}`);
2576
2576
  return t;
2577
2577
  }
2578
- function Yn(n, e, t, r) {
2579
- return [co(n, e, t, r)];
2578
+ function Xn(n, e, t, r) {
2579
+ return [lo(n, e, t, r)];
2580
2580
  }
2581
- function co(n, e, t, r) {
2581
+ function lo(n, e, t, r) {
2582
2582
  return [
2583
2583
  n(t, r),
2584
- ao(e, t).id,
2584
+ uo(e, t).id,
2585
2585
  n(t, r),
2586
2586
  n("time", r)
2587
2587
  ];
2588
2588
  }
2589
- function uo(n, e, t) {
2589
+ function fo(n, e, t) {
2590
2590
  return n.map((r) => r === e ? t : r);
2591
2591
  }
2592
- function Gr(n, e, t, r, s) {
2592
+ function Jr(n, e, t, r, s) {
2593
2593
  const i = Y(e, t, s), o = De(e, t, s), a = i || o;
2594
2594
  if (!a)
2595
2595
  throw new Ve(`Could not find attr for ${[t, s]}`);
@@ -2608,7 +2608,7 @@ function Gr(n, e, t, r, s) {
2608
2608
  ];
2609
2609
  return [i ? f : u, h, y, a, !!i];
2610
2610
  }
2611
- function Zn(n, e) {
2611
+ function er(n, e) {
2612
2612
  if (typeof e != "string")
2613
2613
  return function(o) {
2614
2614
  return !1;
@@ -2618,7 +2618,7 @@ function Zn(n, e) {
2618
2618
  return typeof o != "string" ? !1 : s.test(o);
2619
2619
  };
2620
2620
  }
2621
- function lo(n, e) {
2621
+ function ho(n, e) {
2622
2622
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2623
2623
  return e;
2624
2624
  const t = n["checked-data-type"] === "date";
@@ -2659,7 +2659,7 @@ function lo(n, e) {
2659
2659
  }
2660
2660
  };
2661
2661
  if (e.hasOwnProperty("$like")) {
2662
- const r = Zn(!0, e.$like);
2662
+ const r = er(!0, e.$like);
2663
2663
  return {
2664
2664
  $comparator: !0,
2665
2665
  $op: function(i) {
@@ -2668,7 +2668,7 @@ function lo(n, e) {
2668
2668
  };
2669
2669
  }
2670
2670
  if (e.hasOwnProperty("$ilike")) {
2671
- const r = Zn(!1, e.$ilike);
2671
+ const r = er(!1, e.$ilike);
2672
2672
  return {
2673
2673
  $comparator: !0,
2674
2674
  $op: function(i) {
@@ -2678,7 +2678,7 @@ function lo(n, e) {
2678
2678
  }
2679
2679
  return e;
2680
2680
  }
2681
- function fo(n, e, t, r, s, i) {
2681
+ function po(n, e, t, r, s, i) {
2682
2682
  const o = Y(e, t, s), a = De(e, t, s), c = o || a;
2683
2683
  if (!c)
2684
2684
  throw new Ve(`No attr for etype = ${t} label = ${s}`);
@@ -2696,65 +2696,65 @@ function fo(n, e, t, r, s, i) {
2696
2696
  return o ? [
2697
2697
  n(t, r),
2698
2698
  c.id,
2699
- lo(c, i),
2699
+ ho(c, i),
2700
2700
  st("time")
2701
2701
  ] : [i, c.id, n(t, r), st("time")];
2702
2702
  }
2703
- function ho(n, e, t, r, s) {
2703
+ function yo(n, e, t, r, s) {
2704
2704
  const [i, o, a] = s.reduce((c, u) => {
2705
- const [l, f, h] = c, [y, b, _] = Gr(n, e, l, f, u);
2705
+ const [l, f, h] = c, [y, b, _] = Jr(n, e, l, f, u);
2706
2706
  return [y, b, [...h, _]];
2707
2707
  }, [t, r, []]);
2708
2708
  return [i, o, a];
2709
2709
  }
2710
- function tn(n, e, t, r, s, i) {
2711
- const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = ho(n, e, t, r, o), f = fo(n, e, c, u, a, i);
2710
+ function rn(n, e, t, r, s, i) {
2711
+ const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = yo(n, e, t, r, o), f = po(n, e, c, u, a, i);
2712
2712
  return l.concat([f]);
2713
2713
  }
2714
- function po(n, e) {
2714
+ function bo(n, e) {
2715
2715
  return e ? [e].concat(n) : n;
2716
2716
  }
2717
- function yo([n, e]) {
2717
+ function go([n, e]) {
2718
2718
  return n === "or" && Array.isArray(e);
2719
2719
  }
2720
- function bo([n, e]) {
2720
+ function _o([n, e]) {
2721
2721
  return n === "and" && Array.isArray(e);
2722
2722
  }
2723
- function go(n, e, t) {
2723
+ function mo(n, e, t) {
2724
2724
  return (r, s) => {
2725
2725
  const i = n(r, s);
2726
2726
  return e == i ? i : `${i}-${t}`;
2727
2727
  };
2728
2728
  }
2729
- function Xn(n, e, t, r, s, i) {
2729
+ function tr(n, e, t, r, s, i) {
2730
2730
  const o = n(r, s), a = i.map((c, u) => {
2731
- const l = go(n, o, u);
2732
- return Hr(l, t, r, s, c);
2731
+ const l = mo(n, o, u);
2732
+ return Yr(l, t, r, s, c);
2733
2733
  });
2734
2734
  return { [e]: { patterns: a, joinSym: o } };
2735
2735
  }
2736
- function _o(n) {
2736
+ function wo(n) {
2737
2737
  const e = [];
2738
2738
  for (let t = 1; t <= n.length; t++)
2739
2739
  e.push(n.slice(0, t));
2740
2740
  return e;
2741
2741
  }
2742
- function er(n, e, t, r, s) {
2743
- return _o(s).map((i) => tn(n, e, t, r, i, {
2742
+ function nr(n, e, t, r, s) {
2743
+ return wo(s).map((i) => rn(n, e, t, r, i, {
2744
2744
  $isNull: !0
2745
2745
  }));
2746
2746
  }
2747
- function Hr(n, e, t, r, s) {
2747
+ function Yr(n, e, t, r, s) {
2748
2748
  return Object.entries(s).flatMap(([i, o]) => {
2749
- if (yo([i, o]))
2750
- return Xn(n, "or", e, t, r, o);
2751
- if (bo([i, o]))
2752
- return Xn(n, "and", e, t, r, o);
2749
+ if (go([i, o]))
2750
+ return tr(n, "or", e, t, r, o);
2751
+ if (_o([i, o]))
2752
+ return tr(n, "and", e, t, r, o);
2753
2753
  if (i === "$entityIdStartsWith")
2754
2754
  return [];
2755
2755
  const a = i.split(".");
2756
2756
  if (o != null && o.hasOwnProperty("$ne") && (o = { ...o, $not: o.$ne }, delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2757
- const c = tn(n, e, t, r, a, o), u = er(n, e, t, r, a);
2757
+ const c = rn(n, e, t, r, a, o), u = nr(n, e, t, r, a);
2758
2758
  return [
2759
2759
  {
2760
2760
  or: {
@@ -2767,32 +2767,32 @@ function Hr(n, e, t, r, s) {
2767
2767
  return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2768
2768
  {
2769
2769
  or: {
2770
- patterns: er(n, e, t, r, a),
2770
+ patterns: nr(n, e, t, r, a),
2771
2771
  joinSym: n(t, r)
2772
2772
  }
2773
2773
  }
2774
- ] : tn(n, e, t, r, a, o);
2774
+ ] : rn(n, e, t, r, a, o);
2775
2775
  });
2776
2776
  }
2777
- function mo(n, e, t, r) {
2778
- const s = Ct;
2779
- return r ? Hr(s, n, e, t, r).concat(Yn(s, n, e, t)) : Yn(s, n, e, t);
2777
+ function To(n, e, t, r) {
2778
+ const s = It;
2779
+ return r ? Yr(s, n, e, t, r).concat(Xn(s, n, e, t)) : Xn(s, n, e, t);
2780
2780
  }
2781
- function wo(n, e, t) {
2781
+ function So(n, e, t) {
2782
2782
  return [n(e, t), n("time", t)];
2783
2783
  }
2784
- function To(n, e, t, r, s, i) {
2785
- const [o, a, c, u, l] = Gr(n, e, t, r, s), f = uo(c, n(t, r), i);
2784
+ function vo(n, e, t, r, s, i) {
2785
+ const [o, a, c, u, l] = Jr(n, e, t, r, s), f = fo(c, n(t, r), i);
2786
2786
  return [o, a, f, u, l];
2787
2787
  }
2788
- function So(n, e, t, { etype: r, level: s, form: i }, o) {
2788
+ function Ao(n, e, t, { etype: r, level: s, form: i }, o) {
2789
2789
  const a = Object.keys(i).filter((c) => c !== "$");
2790
2790
  return a.length ? Object.entries(o).map(function([u, l]) {
2791
2791
  return a.map(function(y) {
2792
2792
  var _, T, S;
2793
2793
  const b = !!(e.cardinalityInference && ((S = (T = (_ = t.linkIndex) == null ? void 0 : _[r]) == null ? void 0 : T[y]) != null && S.isSingular));
2794
2794
  try {
2795
- const [g, m, I] = To(n, t, r, s, y, u), v = Zr(e, t, {
2795
+ const [g, m, I] = vo(n, t, r, s, y, u), v = es(e, t, {
2796
2796
  etype: g,
2797
2797
  level: m,
2798
2798
  form: i[y],
@@ -2809,56 +2809,56 @@ function So(n, e, t, { etype: r, level: s, form: i }, o) {
2809
2809
  }, l);
2810
2810
  }) : Object.values(o);
2811
2811
  }
2812
- function vo(n, e, t) {
2813
- return t === "string" ? so(n, e) : n > e ? 1 : -1;
2812
+ function Oo(n, e, t) {
2813
+ return t === "string" ? oo(n, e) : n > e ? 1 : -1;
2814
2814
  }
2815
2815
  function nt(n, e, t, r, s) {
2816
- return e === r || e == null && r == null ? to(n, t) : r == null ? 1 : e == null ? -1 : vo(e, r, s);
2816
+ return e === r || e == null && r == null ? ro(n, t) : r == null ? 1 : e == null ? -1 : Oo(e, r, s);
2817
2817
  }
2818
- function Ot([n, e], [t, r], s) {
2818
+ function Et([n, e], [t, r], s) {
2819
2819
  return nt(n, e, t, r, s);
2820
2820
  }
2821
- function nn(n) {
2821
+ function sn(n) {
2822
2822
  return n == null ? n : new Date(n).getTime();
2823
2823
  }
2824
- function Jr(n, e, t) {
2824
+ function Zr(n, e, t) {
2825
2825
  var h;
2826
2826
  const [r, s, i, o] = n;
2827
2827
  if (((h = e["forward-identity"]) == null ? void 0 : h[2]) === "id")
2828
- return Ot(t, [r, o], null);
2829
- const [a, c] = t, u = e["checked-data-type"], l = u === "date" ? nn(c) : c, f = u === "date" ? nn(i) : i;
2830
- return Ot([a, l], [r, f], u);
2828
+ return Et(t, [r, o], null);
2829
+ const [a, c] = t, u = e["checked-data-type"], l = u === "date" ? sn(c) : c, f = u === "date" ? sn(i) : i;
2830
+ return Et([a, l], [r, f], u);
2831
2831
  }
2832
- function Ao(n, e, t, r) {
2833
- const s = Jr(n, e, r);
2832
+ function Eo(n, e, t, r) {
2833
+ const s = Zr(n, e, r);
2834
2834
  return t === "desc" ? s > 0 : s < 0;
2835
2835
  }
2836
- function Oo(n, e, t, r) {
2837
- const s = Jr(n, e, r);
2836
+ function ko(n, e, t, r) {
2837
+ const s = Zr(n, e, r);
2838
2838
  return t === "desc" ? s < 0 : s > 0;
2839
2839
  }
2840
- function Eo(n, e) {
2840
+ function Co(n, e) {
2841
2841
  const t = e[1];
2842
2842
  return n.getAttr(t);
2843
2843
  }
2844
- function ko(n, e, t) {
2844
+ function Io(n, e, t) {
2845
2845
  const r = Object.keys(t)[0];
2846
2846
  return Y(n, e, r);
2847
2847
  }
2848
- function Co(n, e, t, r) {
2848
+ function Po(n, e, t, r) {
2849
2849
  if (t)
2850
- return Eo(n, t);
2850
+ return Co(n, t);
2851
2851
  if (r)
2852
- return ko(n, e, r);
2852
+ return Io(n, e, r);
2853
2853
  }
2854
- function Io(n, e, t) {
2854
+ function Mo(n, e, t) {
2855
2855
  var s, i;
2856
2856
  if (!Array.isArray(t.fields))
2857
- return xi(n, e);
2857
+ return Ui(n, e);
2858
2858
  const r = /* @__PURE__ */ new Map();
2859
2859
  for (const o of t.fields) {
2860
2860
  const a = Y(n, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
2861
- c && wn(a) && r.set(c, a);
2861
+ c && Sn(a) && r.set(c, a);
2862
2862
  }
2863
2863
  if (!r.has("id")) {
2864
2864
  const o = Y(n, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) == null ? void 0 : i[2];
@@ -2866,76 +2866,76 @@ function Io(n, e, t) {
2866
2866
  }
2867
2867
  return r;
2868
2868
  }
2869
- function Po(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2869
+ function Ro(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2870
2870
  var _, T;
2871
- const o = (_ = i == null ? void 0 : i.$) == null ? void 0 : _.order, a = Yr(i), c = Mo(i);
2872
- let u = Qi(n, s);
2873
- const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], h = Co(e, t, l, o);
2871
+ const o = (_ = i == null ? void 0 : i.$) == null ? void 0 : _.order, a = Xr(i), c = jo(i);
2872
+ let u = Gi(n, s);
2873
+ const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], h = Po(e, t, l, o);
2874
2874
  if (h && ((T = h == null ? void 0 : h["forward-identity"]) == null ? void 0 : T[2]) !== "id") {
2875
2875
  const S = h["checked-data-type"] === "date", g = h.id;
2876
2876
  u = u.map(([m]) => {
2877
2877
  var v, M, x, N, W;
2878
2878
  let I = (W = (N = (x = (M = (v = n.eav.get(m)) == null ? void 0 : v.get(g)) == null ? void 0 : M.values()) == null ? void 0 : x.next()) == null ? void 0 : N.value) == null ? void 0 : W[2];
2879
- return S && (I = nn(I)), [m, I];
2879
+ return S && (I = sn(I)), [m, I];
2880
2880
  });
2881
2881
  }
2882
2882
  u.sort(c === "asc" ? function(g, m) {
2883
- return Ot(g, m, h == null ? void 0 : h["checked-data-type"]);
2883
+ return Et(g, m, h == null ? void 0 : h["checked-data-type"]);
2884
2884
  } : function(g, m) {
2885
- return Ot(m, g, h == null ? void 0 : h["checked-data-type"]);
2885
+ return Et(m, g, h == null ? void 0 : h["checked-data-type"]);
2886
2886
  });
2887
2887
  let y = {};
2888
- const b = Io(e, t, s);
2888
+ const b = Mo(e, t, s);
2889
2889
  for (const S of u) {
2890
2890
  const [g] = S;
2891
- if (y[g] || !a && l && h && Ao(l, h, c, S) || f && h && Oo(f, h, c, S))
2891
+ if (y[g] || !a && l && h && Eo(l, h, c, S) || f && h && ko(f, h, c, S))
2892
2892
  continue;
2893
- const m = $i(n, b, g);
2893
+ const m = Di(n, b, g);
2894
2894
  m && (y[g] = m);
2895
2895
  }
2896
2896
  return y;
2897
2897
  }
2898
- function Mo(n) {
2898
+ function jo(n) {
2899
2899
  var t;
2900
2900
  const e = (t = n.$) == null ? void 0 : t.order;
2901
2901
  return e && e[Object.keys(e)[0]] || "asc";
2902
2902
  }
2903
- function Yr(n) {
2903
+ function Xr(n) {
2904
2904
  var s, i, o;
2905
2905
  const e = (s = n.$) == null ? void 0 : s.offset, t = (i = n.$) == null ? void 0 : i.before, r = (o = n.$) == null ? void 0 : o.after;
2906
2906
  return !e && !t && !r;
2907
2907
  }
2908
- function Ro(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2908
+ function $o(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2909
2909
  var h, y, b, _, T;
2910
- if (!Yr(s) && (!o || !o["start-cursor"]))
2910
+ if (!Xr(s) && (!o || !o["start-cursor"]))
2911
2911
  return [];
2912
- const a = po(mo(e, t, r, (h = s.$) == null ? void 0 : h.where), i), c = wo(Ct, t, r), u = (y = s.$) == null ? void 0 : y.fields, l = Po(n, e, {
2912
+ const a = bo(To(e, t, r, (h = s.$) == null ? void 0 : h.where), i), c = So(It, t, r), u = (y = s.$) == null ? void 0 : y.fields, l = Ro(n, e, {
2913
2913
  etype: t,
2914
2914
  pageInfo: o,
2915
2915
  form: s,
2916
2916
  dq: { where: a, find: c, fields: u }
2917
2917
  }), f = ((b = s.$) == null ? void 0 : b.limit) || ((_ = s.$) == null ? void 0 : _.first) || ((T = s.$) == null ? void 0 : T.last);
2918
2918
  if (f != null) {
2919
- r > 0 && io && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2919
+ r > 0 && ao && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2920
2920
  const S = Object.entries(l);
2921
2921
  return S.length <= f ? l : Object.fromEntries(S.slice(0, f));
2922
2922
  }
2923
2923
  return l;
2924
2924
  }
2925
- function jo(n, e, t) {
2925
+ function xo(n, e, t) {
2926
2926
  try {
2927
- return Ro(n, e, t);
2927
+ return $o(n, e, t);
2928
2928
  } catch (r) {
2929
2929
  if (r instanceof Ve)
2930
2930
  return {};
2931
2931
  throw r;
2932
2932
  }
2933
2933
  }
2934
- function Zr(n, e, t) {
2935
- const r = jo(n, e, t);
2936
- return So(Ct, n, e, t, r);
2934
+ function es(n, e, t) {
2935
+ const r = xo(n, e, t);
2936
+ return Ao(It, n, e, t, r);
2937
2937
  }
2938
- function $o(n) {
2938
+ function Do(n) {
2939
2939
  const e = {};
2940
2940
  for (const [t, r] of Object.entries(n))
2941
2941
  e[t] = {
@@ -2946,18 +2946,18 @@ function $o(n) {
2946
2946
  };
2947
2947
  return e;
2948
2948
  }
2949
- function Xr({ store: n, attrsStore: e, pageInfo: t, aggregate: r }, s) {
2949
+ function ts({ store: n, attrsStore: e, pageInfo: t, aggregate: r }, s) {
2950
2950
  const o = { data: Object.keys(s).reduce(function(c, u) {
2951
- return r != null && r[u] || u === "$$ruleParams" || (c[u] = Zr(n, e, {
2951
+ return r != null && r[u] || u === "$$ruleParams" || (c[u] = es(n, e, {
2952
2952
  etype: u,
2953
2953
  form: s[u],
2954
2954
  level: 0,
2955
2955
  pageInfo: t == null ? void 0 : t[u]
2956
2956
  })), c;
2957
2957
  }, {}) };
2958
- return t && (o.pageInfo = $o(t)), r && (o.aggregate = r), o;
2958
+ return t && (o.pageInfo = Do(t)), r && (o.aggregate = r), o;
2959
2959
  }
2960
- function xo() {
2960
+ function Uo() {
2961
2961
  const e = {
2962
2962
  __etype: 1,
2963
2963
  __ops: 1,
@@ -2971,8 +2971,8 @@ function xo() {
2971
2971
  };
2972
2972
  return new Set(Object.keys(e));
2973
2973
  }
2974
- const Do = xo();
2975
- function wt(n, e, t) {
2974
+ const Lo = Uo();
2975
+ function Tt(n, e, t) {
2976
2976
  const r = {
2977
2977
  __etype: n,
2978
2978
  __ops: t
@@ -2983,50 +2983,50 @@ function wt(n, e, t) {
2983
2983
  return t;
2984
2984
  if (i === "__etype")
2985
2985
  return n;
2986
- if (Do.has(i))
2987
- return (o, a) => wt(n, e, [
2986
+ if (Lo.has(i))
2987
+ return (o, a) => Tt(n, e, [
2988
2988
  ...t,
2989
2989
  a ? [i, n, e, o, a] : [i, n, e, o]
2990
2990
  ]);
2991
2991
  }
2992
2992
  });
2993
2993
  }
2994
- function Uo(n, e) {
2994
+ function Fo(n, e) {
2995
2995
  return `lookup__${n}__${JSON.stringify(e)}`;
2996
2996
  }
2997
- function Et(n) {
2997
+ function kt(n) {
2998
2998
  return n.startsWith("lookup__");
2999
2999
  }
3000
- function rn(n) {
3000
+ function on(n) {
3001
3001
  const [e, t, ...r] = n.split("__");
3002
3002
  return [t, JSON.parse(r.join("__"))];
3003
3003
  }
3004
- function Lo(n) {
3004
+ function No(n) {
3005
3005
  return new Proxy({
3006
3006
  __etype: n
3007
3007
  }, {
3008
3008
  get(e, t) {
3009
3009
  if (t === "lookup")
3010
- return (s, i) => wt(n, rn(Uo(s, i)), []);
3010
+ return (s, i) => Tt(n, on(Fo(s, i)), []);
3011
3011
  if (t === "__etype")
3012
3012
  return n;
3013
3013
  const r = t;
3014
- return Et(r) ? wt(n, rn(r), []) : wt(n, r, []);
3014
+ return kt(r) ? Tt(n, on(r), []) : Tt(n, r, []);
3015
3015
  }
3016
3016
  });
3017
3017
  }
3018
- function Sn() {
3018
+ function An() {
3019
3019
  return new Proxy({}, {
3020
3020
  get(n, e) {
3021
- return Lo(e);
3021
+ return No(e);
3022
3022
  }
3023
3023
  });
3024
3024
  }
3025
- Sn();
3026
- function Fo(n) {
3025
+ An();
3026
+ function Ko(n) {
3027
3027
  return n.__ops;
3028
3028
  }
3029
- function No(n, e) {
3029
+ function qo(n, e) {
3030
3030
  const { attrIdMap: t, refSwapAttrIds: r } = n, s = [];
3031
3031
  for (const o of e) {
3032
3032
  const a = t[o];
@@ -3045,7 +3045,7 @@ function No(n, e) {
3045
3045
  }
3046
3046
  return s;
3047
3047
  }
3048
- function Ko(n) {
3048
+ function Wo(n) {
3049
3049
  if (Array.isArray(n))
3050
3050
  return n;
3051
3051
  const e = Object.entries(n);
@@ -3053,38 +3053,38 @@ function Ko(n) {
3053
3053
  throw new Error("lookup must be an object with a single unique attr and value.");
3054
3054
  return e[0];
3055
3055
  }
3056
- function qo(n, e, t) {
3056
+ function zo(n, e, t) {
3057
3057
  return t.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
3058
3058
  // before assuming it's a ref lookup.
3059
3059
  !Y(n, e, t);
3060
3060
  }
3061
- function sn(n) {
3061
+ function an(n) {
3062
3062
  const [e, t, ...r] = n.split(".");
3063
3063
  if (r.length > 0 || t !== "id")
3064
3064
  throw new Error(`${n} is not a valid lookup attribute.`);
3065
3065
  return e;
3066
3066
  }
3067
- function Wo(n, e, t) {
3068
- if (!qo(n, e, t))
3067
+ function Vo(n, e, t) {
3068
+ if (!zo(n, e, t))
3069
3069
  return Y(n, e, t);
3070
- const r = sn(t), s = Y(n, e, r) || De(n, e, r);
3070
+ const r = an(t), s = Y(n, e, r) || De(n, e, r);
3071
3071
  if (s && s["value-type"] !== "ref")
3072
3072
  throw new Error(`${t} does not reference a valid link attribute.`);
3073
3073
  return s;
3074
3074
  }
3075
- function on(n) {
3076
- return typeof n == "string" && !Et(n) ? null : typeof n == "string" && Et(n) ? rn(n) : Ko(n);
3075
+ function cn(n) {
3076
+ return typeof n == "string" && !kt(n) ? null : typeof n == "string" && kt(n) ? on(n) : Wo(n);
3077
3077
  }
3078
3078
  function le(n, e, t) {
3079
- const r = on(t);
3079
+ const r = cn(t);
3080
3080
  if (r === null)
3081
3081
  return t;
3082
- const [s, i] = r, o = Wo(n, e, s);
3082
+ const [s, i] = r, o = Vo(n, e, s);
3083
3083
  if (!o || !o["unique?"])
3084
3084
  throw new Error(`${s} is not a unique attribute.`);
3085
3085
  return [o.id, i];
3086
3086
  }
3087
- function es(n, e, t, r) {
3087
+ function ns(n, e, t, r) {
3088
3088
  var o;
3089
3089
  const s = le(n, e, t);
3090
3090
  return Array.isArray(s) ? [[
@@ -3094,7 +3094,7 @@ function es(n, e, t, r) {
3094
3094
  s
3095
3095
  ]].concat(r) : r;
3096
3096
  }
3097
- function zo({ attrsStore: n }, [e, t, r]) {
3097
+ function Qo({ attrsStore: n }, [e, t, r]) {
3098
3098
  const s = Object.entries(r).flatMap(([i, o]) => {
3099
3099
  const a = Array.isArray(o) ? o : [o], c = Y(n, e, i), u = De(n, e, i);
3100
3100
  return a.map((l) => c ? [
@@ -3113,9 +3113,9 @@ function zo({ attrsStore: n }, [e, t, r]) {
3113
3113
  le(n, e, t)
3114
3114
  ]);
3115
3115
  });
3116
- return es(n, e, t, s);
3116
+ return ns(n, e, t, s);
3117
3117
  }
3118
- function Vo({ attrsStore: n }, [e, t, r]) {
3118
+ function Bo({ attrsStore: n }, [e, t, r]) {
3119
3119
  const s = Object.entries(r).flatMap(([i, o]) => {
3120
3120
  const a = Array.isArray(o) ? o : [o], c = Y(n, e, i), u = De(n, e, i);
3121
3121
  return a.map((l) => c ? [
@@ -3134,9 +3134,9 @@ function Vo({ attrsStore: n }, [e, t, r]) {
3134
3134
  le(n, e, t)
3135
3135
  ]);
3136
3136
  });
3137
- return es(n, e, t, s);
3137
+ return ns(n, e, t, s);
3138
3138
  }
3139
- function Qo(n, e, t, r) {
3139
+ function Go(n, e, t, r) {
3140
3140
  var s;
3141
3141
  if (Array.isArray(r)) {
3142
3142
  const [i, o] = r;
@@ -3159,21 +3159,21 @@ function Qo(n, e, t, r) {
3159
3159
  }
3160
3160
  return !1;
3161
3161
  }
3162
- function ts({ stores: n, attrsStore: e }, [t, r, s, i]) {
3163
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Qo(n, e, t, r) ? { mode: "update" } : null;
3162
+ function rs({ stores: n, attrsStore: e }, [t, r, s, i]) {
3163
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Go(n, e, t, r) ? { mode: "update" } : null;
3164
3164
  }
3165
- function Bo(n, e) {
3166
- const { attrsStore: t } = n, [r, s, i, o] = e, a = _n(i), c = le(t, r, s);
3165
+ function Ho(n, e) {
3166
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = wn(i), c = le(t, r, s);
3167
3167
  return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
3168
3168
  const h = Y(t, r, l);
3169
- return h["checked-data-type"] === "date" && n.useDateObjects && (f = kt(f)), ["add-triple", c, h.id, f, { mode: "create" }];
3169
+ return h["checked-data-type"] === "date" && n.useDateObjects && (f = Ct(f)), ["add-triple", c, h.id, f, { mode: "create" }];
3170
3170
  });
3171
3171
  }
3172
- function Go(n, e) {
3173
- const { attrsStore: t } = n, [r, s, i, o] = e, a = _n(i), c = le(t, r, s), u = ts(n, [r, c, i, o]);
3172
+ function Jo(n, e) {
3173
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = wn(i), c = le(t, r, s), u = rs(n, [r, c, i, o]);
3174
3174
  return [["id", c]].concat(Object.entries(a)).map(([f, h]) => {
3175
3175
  const y = Y(t, r, f);
3176
- return y["checked-data-type"] === "date" && n.useDateObjects && (h = kt(h)), [
3176
+ return y["checked-data-type"] === "date" && n.useDateObjects && (h = Ct(h)), [
3177
3177
  "add-triple",
3178
3178
  c,
3179
3179
  y.id,
@@ -3182,11 +3182,11 @@ function Go(n, e) {
3182
3182
  ];
3183
3183
  });
3184
3184
  }
3185
- function Ho({ attrsStore: n }, [e, t]) {
3185
+ function Yo({ attrsStore: n }, [e, t]) {
3186
3186
  return [["delete-entity", le(n, e, t), e]];
3187
3187
  }
3188
- function Jo(n, e) {
3189
- const { attrsStore: t } = n, [r, s, i, o] = e, a = _n(i), c = le(t, r, s), u = ts(n, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
3188
+ function Zo(n, e) {
3189
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = wn(i), c = le(t, r, s), u = rs(n, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
3190
3190
  const b = Y(t, r, h);
3191
3191
  return [
3192
3192
  "deep-merge-triple",
@@ -3204,38 +3204,38 @@ function Jo(n, e) {
3204
3204
  ...u ? [u] : []
3205
3205
  ]].concat(l);
3206
3206
  }
3207
- function Yo({ attrsStore: n }, [e, t, r]) {
3207
+ function Xo({ attrsStore: n }, [e, t, r]) {
3208
3208
  return [["rule-params", le(n, e, t), e, r]];
3209
3209
  }
3210
- function Zo(n) {
3210
+ function ea(n) {
3211
3211
  const [e, t, r, s, i] = n;
3212
3212
  if (!s)
3213
3213
  return n;
3214
3214
  const o = { ...s };
3215
3215
  return delete o.id, [e, t, r, o, ...i ? [i] : []];
3216
3216
  }
3217
- function Xo(n, e) {
3218
- const [t, ...r] = Zo(e);
3217
+ function ta(n, e) {
3218
+ const [t, ...r] = ea(e);
3219
3219
  switch (t) {
3220
3220
  case "merge":
3221
- return Jo(n, r);
3221
+ return Zo(n, r);
3222
3222
  case "create":
3223
- return Bo(n, r);
3223
+ return Ho(n, r);
3224
3224
  case "update":
3225
- return Go(n, r);
3225
+ return Jo(n, r);
3226
3226
  case "link":
3227
- return zo(n, r);
3227
+ return Qo(n, r);
3228
3228
  case "unlink":
3229
- return Vo(n, r);
3229
+ return Bo(n, r);
3230
3230
  case "delete":
3231
- return Ho(n, r);
3232
- case "ruleParams":
3233
3231
  return Yo(n, r);
3232
+ case "ruleParams":
3233
+ return Xo(n, r);
3234
3234
  default:
3235
3235
  throw new Error(`unsupported action ${t}`);
3236
3236
  }
3237
3237
  }
3238
- function ea(n) {
3238
+ function na(n) {
3239
3239
  switch (n) {
3240
3240
  case "string":
3241
3241
  case "date":
@@ -3246,14 +3246,14 @@ function ea(n) {
3246
3246
  return;
3247
3247
  }
3248
3248
  }
3249
- function ta(n, e, t) {
3249
+ function ra(n, e, t) {
3250
3250
  var a, c;
3251
3251
  const r = (c = (a = n.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[t];
3252
3252
  if (t === "id")
3253
3253
  return null;
3254
3254
  if (!r)
3255
3255
  throw new Error(`${e}.${t} does not exist in your schema`);
3256
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = ea(r == null ? void 0 : r.valueType);
3256
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = na(r == null ? void 0 : r.valueType);
3257
3257
  return {
3258
3258
  "index?": i,
3259
3259
  "unique?": s,
@@ -3261,7 +3261,7 @@ function ta(n, e, t) {
3261
3261
  };
3262
3262
  }
3263
3263
  function pt(n, e, t, r) {
3264
- const s = n ? ta(n, e, t) : null, i = V(), a = [V(), e, t];
3264
+ const s = n ? ra(n, e, t) : null, i = V(), a = [V(), e, t];
3265
3265
  return {
3266
3266
  id: i,
3267
3267
  "forward-identity": a,
@@ -3274,11 +3274,11 @@ function pt(n, e, t, r) {
3274
3274
  ...r || {}
3275
3275
  };
3276
3276
  }
3277
- function na(n, e, t) {
3277
+ function sa(n, e, t) {
3278
3278
  return Object.values(n.links).find((i) => i.forward.on === e && i.forward.label === t || i.reverse.on === e && i.reverse.label === t);
3279
3279
  }
3280
- function ra(n, e, t) {
3281
- const r = na(n, e, t);
3280
+ function ia(n, e, t) {
3281
+ const r = sa(n, e, t);
3282
3282
  if (!r)
3283
3283
  throw new Error(`Couldn't find the link ${e}.${t} in your schema`);
3284
3284
  const { forward: s, reverse: i } = r;
@@ -3291,8 +3291,8 @@ function ra(n, e, t) {
3291
3291
  "on-delete-reverse": i.onDelete
3292
3292
  };
3293
3293
  }
3294
- function tr(n, e, t, r) {
3295
- const s = n ? ra(n, e, t) : null, i = V(), o = [V(), e, t], a = [V(), t, e];
3294
+ function rr(n, e, t, r) {
3295
+ const s = n ? ia(n, e, t) : null, i = V(), o = [V(), e, t], a = [V(), t, e];
3296
3296
  return {
3297
3297
  id: i,
3298
3298
  // @ts-ignore: ts thinks it's any[]
@@ -3309,7 +3309,7 @@ function tr(n, e, t, r) {
3309
3309
  ...r || {}
3310
3310
  };
3311
3311
  }
3312
- const sa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), ia = /* @__PURE__ */ new Set(["link", "unlink"]), oa = /* @__PURE__ */ new Set(["create", "update", "merge"]), aa = /* @__PURE__ */ new Set([
3312
+ const oa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), aa = /* @__PURE__ */ new Set(["link", "unlink"]), ca = /* @__PURE__ */ new Set(["create", "update", "merge"]), ua = /* @__PURE__ */ new Set([
3313
3313
  "link",
3314
3314
  "unlink",
3315
3315
  "create",
@@ -3317,20 +3317,20 @@ const sa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
3317
3317
  "merge",
3318
3318
  "delete",
3319
3319
  "ruleParams"
3320
- ]), an = { "unique?": !0, "index?": !0 }, ca = {
3321
- ...an,
3320
+ ]), un = { "unique?": !0, "index?": !0 }, la = {
3321
+ ...un,
3322
3322
  cardinality: "one"
3323
3323
  };
3324
- function ua(n) {
3324
+ function fa(n) {
3325
3325
  const e = [], [t, r, s, i] = n;
3326
- if (!aa.has(t))
3326
+ if (!ua.has(t))
3327
3327
  return e;
3328
- const o = on(s);
3328
+ const o = cn(s);
3329
3329
  if (o && e.push({ etype: r, lookupPair: o }), t === "link")
3330
3330
  for (const [a, c] of Object.entries(i)) {
3331
3331
  const u = Array.isArray(c) ? c : [c];
3332
3332
  for (const l of u) {
3333
- const f = on(l);
3333
+ const f = cn(l);
3334
3334
  f && e.push({
3335
3335
  etype: r,
3336
3336
  lookupPair: f,
@@ -3340,7 +3340,7 @@ function ua(n) {
3340
3340
  }
3341
3341
  return e;
3342
3342
  }
3343
- function la({ attrsStore: n, schema: e }, t) {
3343
+ function da({ attrsStore: n, schema: e }, t) {
3344
3344
  var h, y;
3345
3345
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
3346
3346
  function o(b, _) {
@@ -3365,10 +3365,10 @@ function la({ attrsStore: n, schema: e }, t) {
3365
3365
  }
3366
3366
  function f(b, _) {
3367
3367
  const T = o(b, _), S = a(b, _);
3368
- u(T), u(S), !T && !S && c(tr(e, b, _, ca));
3368
+ u(T), u(S), !T && !S && c(rr(e, b, _, la));
3369
3369
  }
3370
3370
  for (const b of t)
3371
- for (const { etype: _, lookupPair: T, linkLabel: S } of ua(b)) {
3371
+ for (const { etype: _, lookupPair: T, linkLabel: S } of fa(b)) {
3372
3372
  const g = T[0];
3373
3373
  if (S) {
3374
3374
  f(_, S);
@@ -3376,28 +3376,28 @@ function la({ attrsStore: n, schema: e }, t) {
3376
3376
  u(m), u(I);
3377
3377
  const v = ((h = m == null ? void 0 : m["reverse-identity"]) == null ? void 0 : h[1]) || ((y = I == null ? void 0 : I["forward-identity"]) == null ? void 0 : y[1]) || S;
3378
3378
  if (l(v, g))
3379
- f(v, sn(g));
3379
+ f(v, an(g));
3380
3380
  else {
3381
3381
  const M = o(v, g);
3382
- M || c(pt(e, v, g, an)), u(M);
3382
+ M || c(pt(e, v, g, un)), u(M);
3383
3383
  }
3384
3384
  } else if (l(_, g))
3385
- f(_, sn(g));
3385
+ f(_, an(g));
3386
3386
  else {
3387
3387
  const m = o(_, g);
3388
- m || c(pt(e, _, g, an)), u(m);
3388
+ m || c(pt(e, _, g, un)), u(m);
3389
3389
  }
3390
3390
  }
3391
3391
  for (const b of t) {
3392
3392
  const [_, T, S, g] = b;
3393
- if (sa.has(_)) {
3393
+ if (oa.has(_)) {
3394
3394
  const m = o(T, "id");
3395
3395
  u(m), m || c(pt(e, T, "id", { "unique?": !0 }));
3396
3396
  for (const I of Object.keys(g)) {
3397
3397
  const v = o(T, I);
3398
- if (u(v), oa.has(_) && (v || c(pt(e, T, I, I === "id" ? { "unique?": !0 } : null))), ia.has(_)) {
3398
+ if (u(v), ca.has(_) && (v || c(pt(e, T, I, I === "id" ? { "unique?": !0 } : null))), aa.has(_)) {
3399
3399
  const M = a(T, I);
3400
- !v && !M && c(tr(e, T, I)), u(M);
3400
+ !v && !M && c(rr(e, T, I)), u(M);
3401
3401
  }
3402
3402
  }
3403
3403
  }
@@ -3410,19 +3410,19 @@ function la({ attrsStore: n, schema: e }, t) {
3410
3410
  }
3411
3411
  return [n, i];
3412
3412
  }
3413
- function fa(n, e) {
3414
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Fo(c)), [s, i] = la(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => Xo(o, c));
3413
+ function ha(n, e) {
3414
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Ko(c)), [s, i] = da(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => ta(o, c));
3415
3415
  return [...i, ...a];
3416
3416
  }
3417
- function nr(n, e) {
3417
+ function sr(n, e) {
3418
3418
  typeof requestIdleCallback > "u" ? n() : requestIdleCallback(n, { timeout: e });
3419
3419
  }
3420
3420
  const qe = "__meta";
3421
- class da {
3421
+ class pa {
3422
3422
  constructor(e, t) {
3423
3423
  }
3424
3424
  }
3425
- class cn {
3425
+ class ln {
3426
3426
  constructor(e) {
3427
3427
  p(this, "currentValue");
3428
3428
  p(this, "_subs", []);
@@ -3615,7 +3615,7 @@ class cn {
3615
3615
  gc() {
3616
3616
  this._nextGc || (this._nextGc = setTimeout(
3617
3617
  () => {
3618
- nr(() => {
3618
+ sr(() => {
3619
3619
  this._nextGc = null, this._gc();
3620
3620
  }, 30 * 1e3);
3621
3621
  },
@@ -3630,7 +3630,7 @@ class cn {
3630
3630
  return;
3631
3631
  }
3632
3632
  this._nextSave = setTimeout(() => {
3633
- nr(() => {
3633
+ sr(() => {
3634
3634
  this._nextSave = null, this._writeToStorage(e).then(t).catch(r);
3635
3635
  }, this._idleCallbackMaxWaitMs);
3636
3636
  }, this._saveThrottleMs);
@@ -3644,7 +3644,7 @@ class cn {
3644
3644
  // so that we know which entries we need to persist to the store.
3645
3645
  updateInPlace(e) {
3646
3646
  this._version++;
3647
- const [t, r] = At(this.currentValue, e, {
3647
+ const [t, r] = Ot(this.currentValue, e, {
3648
3648
  enablePatches: !0
3649
3649
  });
3650
3650
  for (const s of r) {
@@ -3670,13 +3670,13 @@ class cn {
3670
3670
  e && await this._enqueuePersist();
3671
3671
  }
3672
3672
  }
3673
- const ha = 6, pa = ["kv", "querySubs", "syncSubs"];
3674
- function ya(n) {
3673
+ const ya = 6, ba = ["kv", "querySubs", "syncSubs"];
3674
+ function ga(n) {
3675
3675
  return function(t) {
3676
3676
  console.error("Error in IndexedDB event", { source: n, event: t });
3677
3677
  };
3678
3678
  }
3679
- async function ba(n) {
3679
+ async function _a(n) {
3680
3680
  return new Promise((e) => {
3681
3681
  const t = indexedDB.open(n);
3682
3682
  t.onerror = (r) => {
@@ -3690,7 +3690,7 @@ async function ba(n) {
3690
3690
  };
3691
3691
  });
3692
3692
  }
3693
- async function ga(n, e, t) {
3693
+ async function ma(n, e, t) {
3694
3694
  const r = (
3695
3695
  // Backwards compatibility for older versions where we JSON.stringified before storing
3696
3696
  typeof e == "string" ? JSON.parse(e) : e
@@ -3724,14 +3724,14 @@ async function ga(n, e, t) {
3724
3724
  };
3725
3725
  });
3726
3726
  }
3727
- async function rr(n, e, t) {
3727
+ async function ir(n, e, t) {
3728
3728
  const r = t.put(e, n);
3729
3729
  return new Promise((s, i) => {
3730
3730
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3731
3731
  });
3732
3732
  }
3733
- async function _a(n, e) {
3734
- const t = await ba(`instant_${n}_5`);
3733
+ async function wa(n, e) {
3734
+ const t = await _a(`instant_${n}_5`);
3735
3735
  if (!t)
3736
3736
  return;
3737
3737
  const r = await new Promise((l, f) => {
@@ -3754,12 +3754,12 @@ async function _a(n, e) {
3754
3754
  for (const [l, f] of r)
3755
3755
  switch (l) {
3756
3756
  case "querySubs": {
3757
- const h = ga(l, f, o);
3757
+ const h = ma(l, f, o);
3758
3758
  a.push(h);
3759
3759
  break;
3760
3760
  }
3761
3761
  default: {
3762
- const h = rr(l, f, i);
3762
+ const h = ir(l, f, i);
3763
3763
  a.push(h);
3764
3764
  const y = {
3765
3765
  createdAt: Date.now(),
@@ -3770,13 +3770,13 @@ async function _a(n, e) {
3770
3770
  break;
3771
3771
  }
3772
3772
  }
3773
- const u = rr(qe, c, i);
3773
+ const u = ir(qe, c, i);
3774
3774
  a.push(u), await Promise.all(a), await new Promise((l, f) => {
3775
3775
  s.oncomplete = (h) => l(h), s.onerror = (h) => f(h), s.onabort = (h) => f(h);
3776
3776
  });
3777
3777
  }
3778
- const sr = /* @__PURE__ */ new Map();
3779
- class ns extends da {
3778
+ const or = /* @__PURE__ */ new Map();
3779
+ class ss extends pa {
3780
3780
  constructor(t, r) {
3781
3781
  super(t, r);
3782
3782
  p(this, "dbName");
@@ -3784,7 +3784,7 @@ class ns extends da {
3784
3784
  p(this, "_appId");
3785
3785
  p(this, "_prefix");
3786
3786
  p(this, "_dbPromise");
3787
- this.dbName = `instant_${t}_${ha}`, this._storeName = r, this._appId = t, this._dbPromise = this._init();
3787
+ this.dbName = `instant_${t}_${ya}`, this._storeName = r, this._appId = t, this._dbPromise = this._init();
3788
3788
  }
3789
3789
  _init() {
3790
3790
  return new Promise((t, r) => {
@@ -3795,12 +3795,12 @@ class ns extends da {
3795
3795
  }, i.onsuccess = (o) => {
3796
3796
  const c = o.target.result;
3797
3797
  if (s) {
3798
- const u = _a(this._appId, c).catch((l) => {
3799
- ya("Error upgrading store from version 5 to 6.")(l);
3798
+ const u = wa(this._appId, c).catch((l) => {
3799
+ ga("Error upgrading store from version 5 to 6.")(l);
3800
3800
  });
3801
- sr.set(this.dbName, u), u.then(() => t(c)).catch(() => t(c));
3801
+ or.set(this.dbName, u), u.then(() => t(c)).catch(() => t(c));
3802
3802
  } else {
3803
- const u = sr.get(this.dbName);
3803
+ const u = or.get(this.dbName);
3804
3804
  u ? u.then(() => t(c)).catch(() => t(c)) : t(c);
3805
3805
  }
3806
3806
  }, i.onupgradeneeded = (o) => {
@@ -3810,7 +3810,7 @@ class ns extends da {
3810
3810
  }
3811
3811
  _upgradeStore(t) {
3812
3812
  const s = t.target.result;
3813
- for (const i of pa)
3813
+ for (const i of ba)
3814
3814
  s.objectStoreNames.contains(i) || s.createObjectStore(i);
3815
3815
  }
3816
3816
  async getItem(t) {
@@ -3875,7 +3875,7 @@ class ns extends da {
3875
3875
  });
3876
3876
  }
3877
3877
  }
3878
- class rs {
3878
+ class is {
3879
3879
  static async getIsOnline() {
3880
3880
  return navigator.onLine;
3881
3881
  }
@@ -3903,7 +3903,7 @@ class oe extends Error {
3903
3903
  return "InstantError";
3904
3904
  }
3905
3905
  }
3906
- class It extends oe {
3906
+ class Pt extends oe {
3907
3907
  constructor(t) {
3908
3908
  var i;
3909
3909
  const r = ((i = t.body) == null ? void 0 : i.message) || `API Error (${t.status})`;
@@ -3911,7 +3911,7 @@ class It extends oe {
3911
3911
  p(this, "body");
3912
3912
  p(this, "status");
3913
3913
  const s = new.target.prototype;
3914
- Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, It), this.name = "InstantAPIError", this.status = t.status, this.body = t.body;
3914
+ Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Pt), this.name = "InstantAPIError", this.status = t.status, this.body = t.body;
3915
3915
  }
3916
3916
  get [Symbol.toStringTag]() {
3917
3917
  return "InstantAPIError";
@@ -3919,16 +3919,16 @@ class It extends oe {
3919
3919
  }
3920
3920
  async function me(n, e) {
3921
3921
  const t = await fetch(n, e), r = await t.json();
3922
- return t.status === 200 ? Promise.resolve(r) : Promise.reject(new It({ status: t.status, body: r }));
3922
+ return t.status === 200 ? Promise.resolve(r) : Promise.reject(new Pt({ status: t.status, body: r }));
3923
3923
  }
3924
- function ma({ apiURI: n, appId: e, email: t }) {
3924
+ function Ta({ apiURI: n, appId: e, email: t }) {
3925
3925
  return me(`${n}/runtime/auth/send_magic_code`, {
3926
3926
  method: "POST",
3927
3927
  headers: { "content-type": "application/json" },
3928
3928
  body: JSON.stringify({ "app-id": e, email: t })
3929
3929
  });
3930
3930
  }
3931
- async function wa({ apiURI: n, appId: e, email: t, code: r, refreshToken: s }) {
3931
+ async function Sa({ apiURI: n, appId: e, email: t, code: r, refreshToken: s, extraFields: i }) {
3932
3932
  return await me(`${n}/runtime/auth/verify_magic_code`, {
3933
3933
  method: "POST",
3934
3934
  headers: { "content-type": "application/json" },
@@ -3936,11 +3936,12 @@ async function wa({ apiURI: n, appId: e, email: t, code: r, refreshToken: s }) {
3936
3936
  "app-id": e,
3937
3937
  email: t,
3938
3938
  code: r,
3939
- ...s ? { "refresh-token": s } : {}
3939
+ ...s ? { "refresh-token": s } : {},
3940
+ ...i ? { "extra-fields": i } : {}
3940
3941
  })
3941
3942
  });
3942
3943
  }
3943
- async function Ta({ apiURI: n, appId: e, refreshToken: t }) {
3944
+ async function va({ apiURI: n, appId: e, refreshToken: t }) {
3944
3945
  return await me(`${n}/runtime/auth/verify_refresh_token`, {
3945
3946
  method: "POST",
3946
3947
  headers: { "content-type": "application/json" },
@@ -3950,7 +3951,7 @@ async function Ta({ apiURI: n, appId: e, refreshToken: t }) {
3950
3951
  })
3951
3952
  });
3952
3953
  }
3953
- async function Sa({ apiURI: n, appId: e }) {
3954
+ async function Aa({ apiURI: n, appId: e }) {
3954
3955
  return await me(`${n}/runtime/auth/sign_in_guest`, {
3955
3956
  method: "POST",
3956
3957
  headers: { "content-type": "application/json" },
@@ -3959,7 +3960,7 @@ async function Sa({ apiURI: n, appId: e }) {
3959
3960
  })
3960
3961
  });
3961
3962
  }
3962
- async function ir({ apiURI: n, appId: e, code: t, codeVerifier: r, refreshToken: s }) {
3963
+ async function ar({ apiURI: n, appId: e, code: t, codeVerifier: r, refreshToken: s, extraFields: i }) {
3963
3964
  return await me(`${n}/runtime/oauth/token`, {
3964
3965
  method: "POST",
3965
3966
  headers: { "content-type": "application/json" },
@@ -3967,11 +3968,12 @@ async function ir({ apiURI: n, appId: e, code: t, codeVerifier: r, refreshToken:
3967
3968
  app_id: e,
3968
3969
  code: t,
3969
3970
  code_verifier: r,
3970
- refresh_token: s
3971
+ refresh_token: s,
3972
+ ...i ? { extra_fields: i } : {}
3971
3973
  })
3972
3974
  });
3973
3975
  }
3974
- async function va({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, refreshToken: i }) {
3976
+ async function Oa({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, refreshToken: i, extraFields: o }) {
3975
3977
  return await me(`${n}/runtime/oauth/id_token`, {
3976
3978
  method: "POST",
3977
3979
  headers: { "content-type": "application/json" },
@@ -3980,11 +3982,12 @@ async function va({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, re
3980
3982
  nonce: t,
3981
3983
  id_token: r,
3982
3984
  client_name: s,
3983
- refresh_token: i
3985
+ refresh_token: i,
3986
+ ...o ? { extra_fields: o } : {}
3984
3987
  })
3985
3988
  });
3986
3989
  }
3987
- async function Aa({ apiURI: n, appId: e, refreshToken: t }) {
3990
+ async function Ea({ apiURI: n, appId: e, refreshToken: t }) {
3988
3991
  return await me(`${n}/runtime/signout`, {
3989
3992
  method: "POST",
3990
3993
  headers: {
@@ -3996,7 +3999,7 @@ async function Aa({ apiURI: n, appId: e, refreshToken: t }) {
3996
3999
  })
3997
4000
  });
3998
4001
  }
3999
- async function Oa({ apiURI: n, appId: e, path: t, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
4002
+ async function ka({ apiURI: n, appId: e, path: t, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
4000
4003
  const a = {
4001
4004
  app_id: e,
4002
4005
  path: t,
@@ -4009,7 +4012,7 @@ async function Oa({ apiURI: n, appId: e, path: t, file: r, refreshToken: s, cont
4009
4012
  body: r
4010
4013
  });
4011
4014
  }
4012
- async function Ea({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4015
+ async function Ca({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4013
4016
  const { data: s } = await me(`${n}/storage/files?app_id=${e}&filename=${encodeURIComponent(t)}`, {
4014
4017
  method: "DELETE",
4015
4018
  headers: {
@@ -4019,7 +4022,7 @@ async function Ea({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4019
4022
  });
4020
4023
  return s;
4021
4024
  }
4022
- async function ka({ apiURI: n, appId: e, fileName: t, refreshToken: r, metadata: s = {} }) {
4025
+ async function Ia({ apiURI: n, appId: e, fileName: t, refreshToken: r, metadata: s = {} }) {
4023
4026
  const { data: i } = await me(`${n}/storage/signed-upload-url`, {
4024
4027
  method: "POST",
4025
4028
  headers: {
@@ -4033,7 +4036,7 @@ async function ka({ apiURI: n, appId: e, fileName: t, refreshToken: r, metadata:
4033
4036
  });
4034
4037
  return i;
4035
4038
  }
4036
- async function Ca(n, e) {
4039
+ async function Pa(n, e) {
4037
4040
  return (await fetch(n, {
4038
4041
  method: "PUT",
4039
4042
  body: e,
@@ -4042,7 +4045,7 @@ async function Ca(n, e) {
4042
4045
  }
4043
4046
  })).ok;
4044
4047
  }
4045
- async function Ia({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4048
+ async function Ma({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4046
4049
  const { data: s } = await me(`${n}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(t)}`, {
4047
4050
  method: "GET",
4048
4051
  headers: {
@@ -4052,9 +4055,9 @@ async function Ia({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4052
4055
  });
4053
4056
  return s;
4054
4057
  }
4055
- let vn = !1, ss = !1, is = !1;
4056
- typeof window < "u" && typeof window.localStorage < "u" && (vn = !!window.localStorage.getItem("devBackend"), ss = !!window.localStorage.getItem("__instantLogging"), is = !!window.localStorage.getItem("__devtoolLocalDash"));
4057
- function or(n, e) {
4058
+ let On = !1, os = !1, as = !1;
4059
+ typeof window < "u" && typeof window.localStorage < "u" && (On = !!window.localStorage.getItem("devBackend"), os = !!window.localStorage.getItem("__instantLogging"), as = !!window.localStorage.getItem("__devtoolLocalDash"));
4060
+ function cr(n, e) {
4058
4061
  if (!e)
4059
4062
  return n;
4060
4063
  const t = {};
@@ -4062,32 +4065,32 @@ function or(n, e) {
4062
4065
  t[r] = n[r];
4063
4066
  }), t;
4064
4067
  }
4065
- function Pa(n, e, t) {
4068
+ function Ra(n, e, t) {
4066
4069
  const r = {
4067
4070
  peers: {}
4068
4071
  };
4069
4072
  if (e && "user" in e ? e.user : !0) {
4070
- const i = or(n.user ?? {}, e == null ? void 0 : e.keys);
4073
+ const i = cr(n.user ?? {}, e == null ? void 0 : e.keys);
4071
4074
  r.user = { ...i, peerId: t };
4072
4075
  }
4073
4076
  for (const i of Object.keys(n.peers ?? {})) {
4074
4077
  const o = (e == null ? void 0 : e.peers) === void 0, a = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(i));
4075
4078
  if (o || a) {
4076
- const c = or(n.peers[i], e == null ? void 0 : e.keys);
4079
+ const c = cr(n.peers[i], e == null ? void 0 : e.keys);
4077
4080
  r.peers[i] = { ...c, peerId: i };
4078
4081
  }
4079
4082
  }
4080
4083
  return r;
4081
4084
  }
4082
- function Ma(n, e) {
4083
- if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !Vn(n.user, e.user)) || !$r(n.peers, e.peers))
4085
+ function ja(n, e) {
4086
+ if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !Bn(n.user, e.user)) || !Dr(n.peers, e.peers))
4084
4087
  return !0;
4085
4088
  for (const r of Object.keys(n.peers))
4086
- if (!Vn(n.peers[r], e.peers[r]))
4089
+ if (!Bn(n.peers[r], e.peers[r]))
4087
4090
  return !0;
4088
4091
  return !1;
4089
4092
  }
4090
- class ar {
4093
+ class ur {
4091
4094
  constructor() {
4092
4095
  p(this, "promise");
4093
4096
  p(this, "_resolve");
@@ -4103,20 +4106,20 @@ class ar {
4103
4106
  this._reject(e);
4104
4107
  }
4105
4108
  }
4106
- function os(n, e = []) {
4109
+ function cs(n, e = []) {
4107
4110
  n.forEach((t) => {
4108
4111
  const { data: r } = t, { "datalog-result": s } = r, { "join-rows": i } = s;
4109
4112
  for (const o of i)
4110
4113
  for (const a of o)
4111
4114
  e.push(a);
4112
- os(t["child-nodes"], e);
4115
+ cs(t["child-nodes"], e);
4113
4116
  });
4114
4117
  }
4115
- function cr(n) {
4118
+ function lr(n) {
4116
4119
  const e = [];
4117
- return os(n, e), e;
4120
+ return cs(n, e), e;
4118
4121
  }
4119
- function ur(n) {
4122
+ function fr(n) {
4120
4123
  return Object.values(n.links).reduce((e, t) => {
4121
4124
  var r, s;
4122
4125
  return e[r = t.forward.on] ?? (e[r] = {}), e[t.forward.on][t.forward.label] = {
@@ -4130,8 +4133,8 @@ function ur(n) {
4130
4133
  }, e;
4131
4134
  }, {});
4132
4135
  }
4133
- const as = "v0.22.167";
4134
- function Ra(n, e) {
4136
+ const us = "v0.22.168";
4137
+ function $a(n, e) {
4135
4138
  return {
4136
4139
  info: n ? (...t) => console.info(...t, e()) : () => {
4137
4140
  },
@@ -4180,7 +4183,7 @@ class q extends Error {
4180
4183
  super(r), this.name = "QueryValidationError";
4181
4184
  }
4182
4185
  }
4183
- const lr = [
4186
+ const dr = [
4184
4187
  "where",
4185
4188
  "order",
4186
4189
  "limit",
@@ -4193,7 +4196,7 @@ const lr = [
4193
4196
  "beforeInclusive",
4194
4197
  "fields",
4195
4198
  "aggregate"
4196
- ], ja = (n) => n.valueType || "unknown", cs = (n, e, t = !1) => {
4199
+ ], xa = (n) => n.valueType || "unknown", ls = (n, e, t = !1) => {
4197
4200
  if (t || n == null)
4198
4201
  return !0;
4199
4202
  switch (e) {
@@ -4208,9 +4211,9 @@ const lr = [
4208
4211
  default:
4209
4212
  return !0;
4210
4213
  }
4211
- }, $a = (n, e, t, r, s, i, o) => {
4214
+ }, Da = (n, e, t, r, s, i, o) => {
4212
4215
  const a = i.valueType === "json", c = (u, l, f) => {
4213
- if (!cs(f, l, a))
4216
+ if (!ls(f, l, a))
4214
4217
  throw new q(`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`, o);
4215
4218
  };
4216
4219
  switch (n) {
@@ -4241,16 +4244,16 @@ const lr = [
4241
4244
  throw new q(`Unknown operator '${n}' for attribute '${r}' in entity '${s}'`, o);
4242
4245
  }
4243
4246
  }, We = (n, e, t, r, s) => {
4244
- const i = ja(t), o = t.valueType === "json";
4247
+ const i = xa(t), o = t.valueType === "json";
4245
4248
  if (typeof n == "object" && n !== null && !Array.isArray(n)) {
4246
4249
  if (o)
4247
4250
  return;
4248
4251
  const c = n;
4249
4252
  for (const [u, l] of Object.entries(c))
4250
- $a(u, l, i, e, r, t, `${s}.${u}`);
4251
- } else if (!cs(n, i, o))
4253
+ Da(u, l, i, e, r, t, `${s}.${u}`);
4254
+ } else if (!ls(n, i, o))
4252
4255
  throw new q(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof n}`, s);
4253
- }, xa = (n, e, t, r, s) => {
4256
+ }, Ua = (n, e, t, r, s) => {
4254
4257
  const i = n.split(".");
4255
4258
  if (i.length < 2)
4256
4259
  throw new q(`Invalid dot notation path '${n}'. Must contain at least one dot.`, s);
@@ -4287,12 +4290,12 @@ const lr = [
4287
4290
  throw new q(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${n}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
4288
4291
  }
4289
4292
  We(e, n, u, t, s);
4290
- }, us = (n, e, t, r) => {
4293
+ }, fs = (n, e, t, r) => {
4291
4294
  for (const [s, i] of Object.entries(n)) {
4292
4295
  if (s === "or" || s === "and") {
4293
4296
  if (Array.isArray(i))
4294
4297
  for (const u of i)
4295
- typeof u == "object" && u !== null && us(u, e, t, `${r}.${s}[${u}]`);
4298
+ typeof u == "object" && u !== null && fs(u, e, t, `${r}.${s}[${u}]`);
4296
4299
  continue;
4297
4300
  }
4298
4301
  if (s === "id") {
@@ -4300,7 +4303,7 @@ const lr = [
4300
4303
  continue;
4301
4304
  }
4302
4305
  if (s.includes(".")) {
4303
- xa(s, i, e, t, `${r}.${s}`);
4306
+ Ua(s, i, e, t, `${r}.${s}`);
4304
4307
  continue;
4305
4308
  }
4306
4309
  const o = t.entities[e];
@@ -4320,10 +4323,10 @@ const lr = [
4320
4323
  We(i, s, u, e, `${r}.${s}`);
4321
4324
  }
4322
4325
  }
4323
- }, Da = (n, e, t, r, s = 0) => {
4326
+ }, La = (n, e, t, r, s = 0) => {
4324
4327
  for (const o of Object.keys(n))
4325
- if (!lr.includes(o))
4326
- throw new q(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${lr.join(", ")}. Found: ${o}`, r);
4328
+ if (!dr.includes(o))
4329
+ throw new q(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${dr.join(", ")}. Found: ${o}`, r);
4327
4330
  const i = [
4328
4331
  // 'limit', // only supported client side
4329
4332
  "offset",
@@ -4340,9 +4343,9 @@ const lr = [
4340
4343
  if (n.where && t) {
4341
4344
  if (typeof n.where != "object" || n.where === null)
4342
4345
  throw new q(`'where' clause must be an object in entity '${e}', but received: ${typeof n.where}`, r ? `${r}.where` : void 0);
4343
- us(n.where, e, t, r ? `${r}.where` : "where");
4346
+ fs(n.where, e, t, r ? `${r}.where` : "where");
4344
4347
  }
4345
- }, ls = (n, e, t, r, s = 0) => {
4348
+ }, ds = (n, e, t, r, s = 0) => {
4346
4349
  var i;
4347
4350
  if (!n || typeof n != "object")
4348
4351
  throw new q(`Query part for entity '${e}' must be an object, but received: ${typeof n}`, r);
@@ -4355,15 +4358,15 @@ const lr = [
4355
4358
  const a = n[o];
4356
4359
  if (typeof a == "object" && a !== null) {
4357
4360
  const c = (i = t == null ? void 0 : t.entities[e].links[o]) == null ? void 0 : i.entityName;
4358
- c && ls(a, c, t, `${r}.${o}`, s + 1);
4361
+ c && ds(a, c, t, `${r}.${o}`, s + 1);
4359
4362
  }
4360
4363
  } else {
4361
4364
  const a = n[o];
4362
4365
  if (typeof a != "object" || a === null)
4363
4366
  throw new q(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
4364
- Da(a, e, t, `${r}.$`, s);
4367
+ La(a, e, t, `${r}.$`, s);
4365
4368
  }
4366
- }, fr = (n, e) => {
4369
+ }, hr = (n, e) => {
4367
4370
  if (typeof n != "object" || n === null)
4368
4371
  throw new q(`Query must be an object, but received: ${typeof n}${n === null ? " (null)" : ""}`);
4369
4372
  if (Array.isArray(n))
@@ -4379,67 +4382,67 @@ const lr = [
4379
4382
  const s = Object.keys(e.entities);
4380
4383
  throw new q(`Entity '${r}' does not exist in schema. Available entities: ${s.length > 0 ? s.join(", ") : "none"}`, r);
4381
4384
  }
4382
- ls(t[r], r, e, r, 0);
4385
+ ds(t[r], r, e, r, 0);
4383
4386
  }
4384
4387
  }
4385
- }, dr = (n) => typeof n != "string" ? !1 : Et(n) ? !0 : ze(n);
4388
+ }, pr = (n) => typeof n != "string" ? !1 : kt(n) ? !0 : ze(n);
4386
4389
  class pe extends Error {
4387
4390
  constructor(e) {
4388
4391
  super(e), this.name = "TransactionValidationError";
4389
4392
  }
4390
4393
  }
4391
- const fs = (n) => n.length > 0 ? n.join(", ") : "none", Ua = (n, e) => new pe(`Entity '${n}' does not exist in schema. Available entities: ${fs(e)}`), Ft = {
4394
+ const hs = (n) => n.length > 0 ? n.join(", ") : "none", Fa = (n, e) => new pe(`Entity '${n}' does not exist in schema. Available entities: ${hs(e)}`), Nt = {
4392
4395
  string: (n) => typeof n == "string",
4393
4396
  number: (n) => typeof n == "number" && !isNaN(n),
4394
4397
  boolean: (n) => typeof n == "boolean",
4395
4398
  date: (n) => n instanceof Date || typeof n == "string" || typeof n == "number",
4396
4399
  json: () => !0
4397
- }, La = (n, e) => {
4400
+ }, Na = (n, e) => {
4398
4401
  var t;
4399
- return n == null ? !0 : ((t = Ft[e.valueType]) == null ? void 0 : t.call(Ft, n)) ?? !1;
4400
- }, ds = (n, e) => {
4402
+ return n == null ? !0 : ((t = Nt[e.valueType]) == null ? void 0 : t.call(Nt, n)) ?? !1;
4403
+ }, ps = (n, e) => {
4401
4404
  const t = e.entities[n];
4402
4405
  if (!t)
4403
- throw Ua(n, Object.keys(e.entities));
4406
+ throw Fa(n, Object.keys(e.entities));
4404
4407
  return t;
4405
- }, Nt = (n, e, t) => {
4406
- const r = ds(n, t);
4408
+ }, Kt = (n, e, t) => {
4409
+ const r = ps(n, t);
4407
4410
  if (typeof e != "object" || e === null)
4408
4411
  throw new pe(`Arguments for data operation on entity '${n}' must be an object, but received: ${typeof e}`);
4409
4412
  for (const [s, i] of Object.entries(e)) {
4410
4413
  if (s === "id")
4411
4414
  continue;
4412
4415
  const o = r.attrs[s];
4413
- if (o && !La(i, o))
4416
+ if (o && !Na(i, o))
4414
4417
  throw new pe(`Invalid value for attribute '${s}' in entity '${n}'. Expected ${o.valueType}, but received: ${typeof i}`);
4415
4418
  }
4416
- }, hr = (n, e, t) => {
4417
- const r = ds(n, t);
4419
+ }, yr = (n, e, t) => {
4420
+ const r = ps(n, t);
4418
4421
  if (typeof e != "object" || e === null)
4419
4422
  throw new pe(`Arguments for link operation on entity '${n}' must be an object, but received: ${typeof e}`);
4420
4423
  for (const [s, i] of Object.entries(e)) {
4421
4424
  if (!r.links[s]) {
4422
4425
  const a = Object.keys(r.links);
4423
- throw new pe(`Link '${s}' does not exist on entity '${n}'. Available links: ${fs(a)}`);
4426
+ throw new pe(`Link '${s}' does not exist on entity '${n}'. Available links: ${hs(a)}`);
4424
4427
  }
4425
4428
  if (i != null) {
4426
4429
  if (Array.isArray(i)) {
4427
4430
  for (const a of i)
4428
- if (!dr(a))
4431
+ if (!pr(a))
4429
4432
  throw new pe(`Invalid entity ID in link '${s}' for entity '${n}'. Expected a UUID or a lookup, but received: ${a}`);
4430
- } else if (!dr(i))
4433
+ } else if (!pr(i))
4431
4434
  throw new pe(`Invalid UUID in link '${s}' for entity '${n}'. Expected a UUID, but received: ${i}`);
4432
4435
  }
4433
4436
  }
4434
- }, Fa = {
4435
- create: Nt,
4436
- update: Nt,
4437
- merge: Nt,
4438
- link: hr,
4439
- unlink: hr,
4437
+ }, Ka = {
4438
+ create: Kt,
4439
+ update: Kt,
4440
+ merge: Kt,
4441
+ link: yr,
4442
+ unlink: yr,
4440
4443
  delete: () => {
4441
4444
  }
4442
- }, Na = (n, e) => {
4445
+ }, qa = (n, e) => {
4443
4446
  if (!e)
4444
4447
  return;
4445
4448
  const [t, r, s, i] = n;
@@ -4447,9 +4450,9 @@ const fs = (n) => n.length > 0 ? n.join(", ") : "none", Ua = (n, e) => new pe(`E
4447
4450
  throw new pe(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
4448
4451
  if (typeof r != "string")
4449
4452
  throw new pe(`Entity name must be a string, but received: ${typeof r}`);
4450
- const o = Fa[t];
4453
+ const o = Ka[t];
4451
4454
  o && i !== void 0 && o(r, i, e);
4452
- }, Ka = (n, e) => {
4455
+ }, Wa = (n, e) => {
4453
4456
  const t = Array.isArray(n) ? n : [n];
4454
4457
  for (const r of t) {
4455
4458
  if (!r || typeof r != "object")
@@ -4459,12 +4462,12 @@ const fs = (n) => n.length > 0 ? n.join(", ") : "none", Ua = (n, e) => new pe(`E
4459
4462
  for (const s of r.__ops) {
4460
4463
  if (!Array.isArray(s))
4461
4464
  throw new pe(`Transaction operation must be an array, but received: ${typeof s}`);
4462
- Na(s, e);
4465
+ qa(s, e);
4463
4466
  }
4464
4467
  }
4465
4468
  };
4466
- let hs = 0;
4467
- class pr {
4469
+ let ys = 0;
4470
+ class br {
4468
4471
  constructor(e) {
4469
4472
  p(this, "type", "ws");
4470
4473
  p(this, "conn");
@@ -4473,7 +4476,7 @@ class pr {
4473
4476
  p(this, "onmessage");
4474
4477
  p(this, "onclose");
4475
4478
  p(this, "onerror");
4476
- this.id = `${this.type}_${hs++}`, this.conn = new WebSocket(e), this.conn.onopen = (t) => {
4479
+ this.id = `${this.type}_${ys++}`, this.conn = new WebSocket(e), this.conn.onopen = (t) => {
4477
4480
  this.onopen && this.onopen({ target: this });
4478
4481
  }, this.conn.onmessage = (t) => {
4479
4482
  this.onmessage && this.onmessage({
@@ -4499,7 +4502,7 @@ class pr {
4499
4502
  return this.conn.send(JSON.stringify(e));
4500
4503
  }
4501
4504
  }
4502
- class qa {
4505
+ class za {
4503
4506
  constructor(e, t, r) {
4504
4507
  p(this, "type", "sse");
4505
4508
  p(this, "initParams", null);
@@ -4516,7 +4519,7 @@ class qa {
4516
4519
  p(this, "onmessage");
4517
4520
  p(this, "onclose");
4518
4521
  p(this, "onerror");
4519
- this.id = `${this.type}_${hs++}`, this.url = t, this.messageUrl = r || this.url, this.ES = e, this.conn = new e(t), this.sseInitTimeout = setTimeout(() => {
4522
+ this.id = `${this.type}_${ys++}`, this.url = t, this.messageUrl = r || this.url, this.ES = e, this.conn = new e(t), this.sseInitTimeout = setTimeout(() => {
4520
4523
  this.initParams || this.handleError();
4521
4524
  }, 1e4), this.conn.onmessage = (s) => {
4522
4525
  const i = JSON.parse(s.data);
@@ -4596,24 +4599,24 @@ class qa {
4596
4599
  this.handleClose();
4597
4600
  }
4598
4601
  }
4599
- function Wa(n, e) {
4602
+ function Va(n, e) {
4600
4603
  const t = n.values;
4601
4604
  if (t) {
4602
- const r = Nr(t.attrsStore, null);
4605
+ const r = qr(t.attrsStore, null);
4603
4606
  if (r) {
4604
4607
  for (const s of t.entities || [])
4605
- s.store.useDateObjects = e, s.store = Fr(r, s.store);
4608
+ s.store.useDateObjects = e, s.store = Kr(r, s.store);
4606
4609
  t.attrsStore = r;
4607
4610
  }
4608
4611
  }
4609
4612
  return n;
4610
4613
  }
4611
- function za(n, e) {
4614
+ function Qa(n, e) {
4612
4615
  var t;
4613
4616
  if (e.values) {
4614
4617
  const r = [];
4615
4618
  for (const s of (t = e.values) == null ? void 0 : t.entities) {
4616
- const i = Lr(s.store);
4619
+ const i = Nr(s.store);
4617
4620
  r.push({ ...s, store: i });
4618
4621
  }
4619
4622
  return {
@@ -4623,15 +4626,15 @@ function za(n, e) {
4623
4626
  } else
4624
4627
  return e;
4625
4628
  }
4626
- function Va(n, e, t) {
4629
+ function Ba(n, e, t) {
4627
4630
  var i, o;
4628
4631
  const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = t == null ? void 0 : t.state) == null ? void 0 : o.txId;
4629
4632
  return r && (!s || r > s) ? e : s && (!r || s > r) ? t : e || t;
4630
4633
  }
4631
- function Kt(n, e, t) {
4632
- return Xr({ store: e, attrsStore: t, pageInfo: null, aggregate: null }, n.query).data[n.table][0];
4634
+ function qt(n, e, t) {
4635
+ return ts({ store: e, attrsStore: t, pageInfo: null, aggregate: null }, n.query).data[n.table][0];
4633
4636
  }
4634
- function yr(n, e, t, r) {
4637
+ function gr(n, e, t, r) {
4635
4638
  var o;
4636
4639
  const s = (o = Y(t, n.table, "id")) == null ? void 0 : o.id;
4637
4640
  if (!s)
@@ -4639,18 +4642,18 @@ function yr(n, e, t, r) {
4639
4642
  const i = Qe(e.eav, [r, s, r]);
4640
4643
  return i ? i[3] : -1;
4641
4644
  }
4642
- function br(n, e, t) {
4645
+ function _r(n, e, t) {
4643
4646
  for (const { action: r, triple: s } of t)
4644
4647
  switch (r) {
4645
4648
  case "added":
4646
- Wr(n, e, s);
4649
+ Vr(n, e, s);
4647
4650
  break;
4648
4651
  case "removed":
4649
- Kr(n, e, s);
4652
+ Wr(n, e, s);
4650
4653
  break;
4651
4654
  }
4652
4655
  }
4653
- function Qa(n, e, t) {
4656
+ function Ga(n, e, t) {
4654
4657
  var s, i;
4655
4658
  const r = {};
4656
4659
  for (const { action: o, triple: a } of t) {
@@ -4678,14 +4681,14 @@ function Qa(n, e, t) {
4678
4681
  function yt(n, e) {
4679
4682
  return { [n.table]: e.map((t) => t.entity) };
4680
4683
  }
4681
- function Ba(n, e) {
4684
+ function Ha(n, e) {
4682
4685
  var r;
4683
4686
  if (n.orderFieldType)
4684
4687
  return n.orderFieldType;
4685
4688
  const t = n.orderField === "serverCreatedAt" ? "number" : (r = Y(e(), n.table, n.orderField)) == null ? void 0 : r["checked-data-type"];
4686
4689
  return n.orderFieldType = t, t;
4687
4690
  }
4688
- function Ga(n, e, t) {
4691
+ function Ja(n, e, t) {
4689
4692
  const r = e;
4690
4693
  if (n.orderField === "serverCreatedAt") {
4691
4694
  t.sort(n.orderDirection === "asc" ? function(o, a) {
@@ -4706,7 +4709,7 @@ var Ie;
4706
4709
  (function(n) {
4707
4710
  n.InitialSyncBatch = "InitialSyncBatch", n.InitialSyncComplete = "InitialSyncComplete", n.LoadFromStorage = "LoadFromStorage", n.SyncTransaction = "SyncTransaction", n.Error = "Error";
4708
4711
  })(Ie || (Ie = {}));
4709
- class Ha {
4712
+ class Ya {
4710
4713
  constructor(e, t, r, s, i, o) {
4711
4714
  p(this, "trySend");
4712
4715
  p(this, "subs");
@@ -4717,11 +4720,11 @@ class Ha {
4717
4720
  p(this, "log");
4718
4721
  p(this, "createStore");
4719
4722
  p(this, "getAttrs");
4720
- this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new cn({
4723
+ this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new ln({
4721
4724
  persister: t,
4722
- merge: Va,
4723
- serialize: za,
4724
- parse: (a, c) => Wa(c, this.config.useDateObjects),
4725
+ merge: Ba,
4726
+ serialize: Qa,
4727
+ parse: (a, c) => Va(c, this.config.useDateObjects),
4725
4728
  objectSize: (a) => {
4726
4729
  var c;
4727
4730
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4842,11 +4845,11 @@ class Ha {
4842
4845
  o.values = a;
4843
4846
  const c = a.entities;
4844
4847
  for (const u of r) {
4845
- const l = this.createStore(u), f = Kt(o, l, a.attrsStore);
4848
+ const l = this.createStore(u), f = qt(o, l, a.attrsStore);
4846
4849
  c.push({
4847
4850
  store: l,
4848
4851
  entity: f,
4849
- serverCreatedAt: yr(o, l, a.attrsStore, f.id)
4852
+ serverCreatedAt: gr(o, l, a.attrsStore, f.id)
4850
4853
  }), i.push(f);
4851
4854
  }
4852
4855
  this.subs.updateInPlace((u) => {
@@ -4916,9 +4919,9 @@ class Ha {
4916
4919
  e: for (const [T, S] of Object.entries(u))
4917
4920
  for (let g = 0; g < f.length; g++) {
4918
4921
  const m = f[g];
4919
- if (Oi(m.store, T)) {
4920
- br(m.store, l.attrsStore, S);
4921
- const I = Kt(s, m.store, l.attrsStore), v = Qa(m.store, l.attrsStore, S)[T];
4922
+ if (ki(m.store, T)) {
4923
+ _r(m.store, l.attrsStore, S);
4924
+ const I = qt(s, m.store, l.attrsStore), v = Ga(m.store, l.attrsStore, S)[T];
4922
4925
  I ? (h.push({
4923
4926
  oldEntity: m.entity,
4924
4927
  newEntity: I,
@@ -4930,8 +4933,8 @@ class Ha {
4930
4933
  const y = [];
4931
4934
  for (const [T, S] of Object.entries(u)) {
4932
4935
  const g = this.createStore([]);
4933
- br(g, l.attrsStore, S);
4934
- const m = Kt(s, g, l.attrsStore);
4936
+ _r(g, l.attrsStore, S);
4937
+ const m = qt(s, g, l.attrsStore);
4935
4938
  if (!m) {
4936
4939
  this.log.error("No entity found after applying change", {
4937
4940
  sub: s,
@@ -4943,14 +4946,14 @@ class Ha {
4943
4946
  f.push({
4944
4947
  store: g,
4945
4948
  entity: m,
4946
- serverCreatedAt: yr(s, g, l.attrsStore, m.id)
4949
+ serverCreatedAt: gr(s, g, l.attrsStore, m.id)
4947
4950
  }), y.push(m);
4948
4951
  }
4949
4952
  const b = [];
4950
4953
  for (const T of c.sort().reverse())
4951
4954
  b.push(f[T].entity), f.splice(T, 1);
4952
- const _ = Ba(s, this.getAttrs);
4953
- Ga(s, _, f), this.notifyCbs(r, {
4955
+ const _ = Ha(s, this.getAttrs);
4956
+ Ja(s, _, f), this.notifyCbs(r, {
4954
4957
  type: Ie.SyncTransaction,
4955
4958
  data: yt(s, (o = s.values) == null ? void 0 : o.entities),
4956
4959
  added: y,
@@ -4991,7 +4994,7 @@ class Ha {
4991
4994
  r && this.initSubscription(r.query, r.hash);
4992
4995
  }
4993
4996
  }
4994
- function Ja({ WStream: n, opts: e, startStream: t, appendStream: r, registerStream: s }) {
4997
+ function Za({ WStream: n, opts: e, startStream: t, appendStream: r, registerStream: s }) {
4995
4998
  const i = e.clientId;
4996
4999
  let o = null, a = null, c = null;
4997
5000
  const u = V();
@@ -5190,7 +5193,7 @@ function Ja({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5190
5193
  }
5191
5194
  };
5192
5195
  }
5193
- class Ya {
5196
+ class Xa {
5194
5197
  constructor() {
5195
5198
  p(this, "items", []);
5196
5199
  p(this, "resolvers", []);
@@ -5224,7 +5227,7 @@ class Ya {
5224
5227
  }
5225
5228
  }
5226
5229
  }
5227
- function Za({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5230
+ function ec({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5228
5231
  let s = e.byteOffset || 0, i = !1;
5229
5232
  const o = new TextDecoder("utf-8"), a = new TextEncoder();
5230
5233
  let c, u = !1;
@@ -5350,7 +5353,7 @@ function Za({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5350
5353
  }
5351
5354
  };
5352
5355
  }
5353
- class Xa {
5356
+ class tc {
5354
5357
  constructor({ WStream: e, RStream: t, trySend: r, log: s }) {
5355
5358
  p(this, "trySend");
5356
5359
  p(this, "WStream");
@@ -5363,7 +5366,7 @@ class Xa {
5363
5366
  this.WStream = e, this.RStream = t, this.trySend = r, this.log = s;
5364
5367
  }
5365
5368
  createWriteStream(e) {
5366
- const { stream: t, addCompleteCb: r } = Ja({
5369
+ const { stream: t, addCompleteCb: r } = Za({
5367
5370
  WStream: this.WStream,
5368
5371
  startStream: this.startWriteStream.bind(this),
5369
5372
  appendStream: this.appendStream.bind(this),
@@ -5375,7 +5378,7 @@ class Xa {
5375
5378
  }), t;
5376
5379
  }
5377
5380
  createReadStream(e) {
5378
- const { stream: t, addCloseCb: r } = Za({
5381
+ const { stream: t, addCloseCb: r } = ec({
5379
5382
  RStream: this.RStream,
5380
5383
  opts: e,
5381
5384
  startStream: this.startReadStream.bind(this),
@@ -5437,7 +5440,7 @@ class Xa {
5437
5440
  if (!r && !t)
5438
5441
  throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");
5439
5442
  r && (o["stream-id"] = r), t && (o["client-id"] = t), s && (o.offset = s), i && (o["rule-params"] = i);
5440
- const a = new Ya();
5443
+ const a = new Xa();
5441
5444
  return this.readStreamIterators[e] = a, this.trySend(e, o), a;
5442
5445
  }
5443
5446
  cancelReadStream({ eventId: e }) {
@@ -5518,39 +5521,39 @@ const Te = {
5518
5521
  AUTHENTICATED: "authenticated",
5519
5522
  CLOSED: "closed",
5520
5523
  ERRORED: "errored"
5521
- }, ec = 3e4, tc = 3e4, nc = 200, rc = 1e3 * 60, sc = {
5524
+ }, nc = 3e4, rc = 3e4, sc = 200, ic = 1e3 * 60, oc = {
5522
5525
  apiURI: "https://api.instantdb.com",
5523
5526
  websocketURI: "wss://api.instantdb.com/runtime/session"
5524
- }, qt = "_instant_oauth_redirect", Fe = "currentUser";
5525
- function ic({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
5527
+ }, Wt = "_instant_oauth_redirect", zt = "_instant_extra_fields_id", bt = "oauthExtraFields", Fe = "currentUser";
5528
+ function ac({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
5526
5529
  if (!s)
5527
- return new pr(`${r}?app_id=${e}`);
5530
+ return new br(`${r}?app_id=${e}`);
5528
5531
  switch (n) {
5529
5532
  case "ws":
5530
- return new pr(`${r}?app_id=${e}`);
5533
+ return new br(`${r}?app_id=${e}`);
5531
5534
  case "sse":
5532
- return new qa(s, `${t}/runtime/sse?app_id=${e}`);
5535
+ return new za(s, `${t}/runtime/sse?app_id=${e}`);
5533
5536
  default:
5534
5537
  throw new Error("Unknown transport type " + n);
5535
5538
  }
5536
5539
  }
5537
- function oc() {
5540
+ function cc() {
5538
5541
  return typeof window < "u" || typeof chrome < "u";
5539
5542
  }
5540
- const gr = {
5543
+ const mr = {
5541
5544
  "set-presence": !0,
5542
5545
  "set-presence-ok": !0,
5543
5546
  "refresh-presence": !0,
5544
5547
  "patch-presence": !0
5545
5548
  };
5546
- function ac(n, e) {
5549
+ function uc(n, e) {
5547
5550
  var r;
5548
5551
  const t = typeof n == "string" ? JSON.parse(n) : n;
5549
5552
  if ((r = t == null ? void 0 : t.result) != null && r.store) {
5550
- const s = Nr(t.result.attrsStore, t.result.store);
5553
+ const s = qr(t.result.attrsStore, t.result.store);
5551
5554
  if (s) {
5552
5555
  const i = t.result.store;
5553
- t.result.store = Fr(s, {
5556
+ t.result.store = Kr(s, {
5554
5557
  ...i,
5555
5558
  useDateObjects: e
5556
5559
  }), t.result.attrsStore = s;
@@ -5558,7 +5561,7 @@ function ac(n, e) {
5558
5561
  }
5559
5562
  return t;
5560
5563
  }
5561
- function cc(n, e) {
5564
+ function lc(n, e) {
5562
5565
  const { result: t, ...r } = e, s = (
5563
5566
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
5564
5567
  r
@@ -5566,14 +5569,14 @@ function cc(n, e) {
5566
5569
  if (t) {
5567
5570
  const i = {
5568
5571
  ...t,
5569
- store: Lr(t.store),
5572
+ store: Nr(t.store),
5570
5573
  attrsStore: t.attrsStore.toJSON()
5571
5574
  };
5572
5575
  s.result = i;
5573
5576
  }
5574
5577
  return s;
5575
5578
  }
5576
- function uc(n, e) {
5579
+ function fc(n, e) {
5577
5580
  switch (n) {
5578
5581
  case "pendingMutations":
5579
5582
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -5581,7 +5584,7 @@ function uc(n, e) {
5581
5584
  return e;
5582
5585
  }
5583
5586
  }
5584
- function lc(n, e) {
5587
+ function dc(n, e) {
5585
5588
  switch (n) {
5586
5589
  case "pendingMutations":
5587
5590
  return [...e.entries()];
@@ -5589,18 +5592,18 @@ function lc(n, e) {
5589
5592
  return e;
5590
5593
  }
5591
5594
  }
5592
- function fc(n, e, t) {
5595
+ function hc(n, e, t) {
5593
5596
  const r = e == null ? void 0 : e.result, s = t == null ? void 0 : t.result;
5594
5597
  return r && !s && t && (t.result = r), t || e;
5595
5598
  }
5596
- function Wt(n) {
5599
+ function Vt(n) {
5597
5600
  return [...n].sort((e, t) => {
5598
5601
  const [r, s] = e, [i, o] = t, a = s.order || 0, c = o.order || 0;
5599
5602
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
5600
5603
  });
5601
5604
  }
5602
- class dc {
5603
- constructor(e, t = ns, r = rs, s, i) {
5605
+ class pc {
5606
+ constructor(e, t = ss, r = is, s, i) {
5604
5607
  /** @type {s.AttrsStore | undefined} */
5605
5608
  p(this, "attrs");
5606
5609
  p(this, "_isOnline", !0);
@@ -5684,7 +5687,7 @@ class dc {
5684
5687
  p(this, "notifyOne", (e) => {
5685
5688
  var i;
5686
5689
  const t = this.queryCbs[e] ?? [], r = (i = this._dataForQueryCache[e]) == null ? void 0 : i.data, s = this.dataForQuery(e);
5687
- s != null && s.data && (this._dataForQueryCache[e] = s, !mt(s.data, r) && t.forEach((o) => o.cb(s.data)));
5690
+ s != null && s.data && (this._dataForQueryCache[e] = s, !wt(s.data, r) && t.forEach((o) => o.cb(s.data)));
5688
5691
  });
5689
5692
  p(this, "notifyOneQueryOnce", (e) => {
5690
5693
  var s;
@@ -5698,9 +5701,9 @@ class dc {
5698
5701
  });
5699
5702
  /** Applies transactions locally and sends transact message to server */
5700
5703
  p(this, "pushTx", (e) => {
5701
- this.config.disableValidation || Ka(e, this.config.schema);
5704
+ this.config.disableValidation || Wa(e, this.config.schema);
5702
5705
  try {
5703
- const t = fa({
5706
+ const t = ha({
5704
5707
  attrsStore: this.optimisticAttrs(),
5705
5708
  schema: this.config.schema,
5706
5709
  stores: Object.values(this.querySubs.currentValue).map((r) => {
@@ -5730,7 +5733,7 @@ class dc {
5730
5733
  this._updatePendingMutations((c) => {
5731
5734
  c.set(r, o);
5732
5735
  });
5733
- const a = new ar();
5736
+ const a = new ur();
5734
5737
  return this.mutationDeferredStore.set(r, a), this._sendMutation(r, o), this.notifyAll(), a.promise;
5735
5738
  });
5736
5739
  p(this, "_transportOnOpen", (e) => {
@@ -5801,7 +5804,7 @@ class dc {
5801
5804
  }
5802
5805
  this._log.info("[socket][close]", t.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
5803
5806
  });
5804
- if (this._EventSource = i, this.config = { ...sc, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? tc, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? nc, this._log = Ra(e.verbose || vn || ss, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": as }, this.config.schema && (this._linkIndex = ur(this.config.schema)), !!oc()) {
5807
+ if (this._EventSource = i, this.config = { ...oc, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? rc, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? sc, this._log = $a(e.verbose || On || os, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": us }, this.config.schema && (this._linkIndex = fr(this.config.schema)), !!cc()) {
5805
5808
  if (!e.appId)
5806
5809
  throw new Error("Instant must be initialized with an appId.");
5807
5810
  if (!ze(e.appId))
@@ -5820,9 +5823,9 @@ class dc {
5820
5823
  } catch (c) {
5821
5824
  this._log.error("[error] handle broadcast channel", c);
5822
5825
  }
5823
- })), this._initStorage(t), this._syncTable = new Ha(this._trySendAuthed.bind(this), new t(this.config.appId, "syncSubs"), {
5826
+ })), this._initStorage(t), this._syncTable = new Ya(this._trySendAuthed.bind(this), new t(this.config.appId, "syncSubs"), {
5824
5827
  useDateObjects: this.config.useDateObjects
5825
- }, this._log, (o) => tt(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._instantStream = new Xa({
5828
+ }, this._log, (o) => tt(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._instantStream = new tc({
5826
5829
  WStream: this.config.WritableStream || WritableStream,
5827
5830
  RStream: this.config.ReadableStream || ReadableStream,
5828
5831
  trySend: this._trySendAuthed.bind(this),
@@ -5832,7 +5835,7 @@ class dc {
5832
5835
  }), setInterval(async () => {
5833
5836
  const o = await this.getCurrentUser();
5834
5837
  this.syncUserToEndpoint(o.user);
5835
- }, rc), r.getIsOnline().then((o) => {
5838
+ }, ic), r.getIsOnline().then((o) => {
5836
5839
  this._isOnline = o, this._startSocket(), r.listen((a) => {
5837
5840
  a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", Te.CLOSED), this._setStatus(Te.CLOSED)));
5838
5841
  });
@@ -5856,7 +5859,7 @@ class dc {
5856
5859
  ...this.config,
5857
5860
  schema: e,
5858
5861
  cardinalityInference: !!e
5859
- }, this._linkIndex = e ? ur(this.config.schema) : null;
5862
+ }, this._linkIndex = e ? fr(this.config.schema) : null;
5860
5863
  }
5861
5864
  _reactorStats() {
5862
5865
  return {
@@ -5869,11 +5872,11 @@ class dc {
5869
5872
  this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
5870
5873
  }
5871
5874
  _initStorage(e) {
5872
- this.querySubs = new cn({
5875
+ this.querySubs = new ln({
5873
5876
  persister: new e(this.config.appId, "querySubs"),
5874
- merge: fc,
5875
- serialize: cc,
5876
- parse: (t, r) => ac(r, this.config.useDateObjects),
5877
+ merge: hc,
5878
+ serialize: lc,
5879
+ parse: (t, r) => uc(r, this.config.useDateObjects),
5877
5880
  // objectSize
5878
5881
  objectSize: (t) => {
5879
5882
  var r, s, i;
@@ -5889,11 +5892,11 @@ class dc {
5889
5892
  maxSize: 1e6
5890
5893
  // 1 million triples
5891
5894
  }
5892
- }), this.querySubs.onKeyLoaded = (t) => this._onQuerySubLoaded(t), this.kv = new cn({
5895
+ }), this.querySubs.onKeyLoaded = (t) => this._onQuerySubLoaded(t), this.kv = new ln({
5893
5896
  persister: new e(this.config.appId, "kv"),
5894
5897
  merge: this._onMergeKv,
5895
- serialize: lc,
5896
- parse: uc,
5898
+ serialize: dc,
5899
+ parse: fc,
5897
5900
  objectSize: () => 0,
5898
5901
  logger: this._log,
5899
5902
  saveThrottleMs: 100,
@@ -5925,7 +5928,7 @@ class dc {
5925
5928
  s.resolve({ status: e, eventId: t });
5926
5929
  else if (r != null && r.type) {
5927
5930
  const { status: o, ...a } = r;
5928
- s.reject(new It({
5931
+ s.reject(new Pt({
5929
5932
  // @ts-expect-error body.type is not constant typed
5930
5933
  body: a,
5931
5934
  status: o ?? 0
@@ -5972,7 +5975,7 @@ class dc {
5972
5975
  _handleReceive(e, t) {
5973
5976
  var s, i, o, a, c, u, l;
5974
5977
  const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
5975
- switch (gr[t.op] || this._log.info("[receive]", e, t.op, t), t.op) {
5978
+ switch (mr[t.op] || this._log.info("[receive]", e, t.op, t), t.op) {
5976
5979
  case "init-ok": {
5977
5980
  this._setStatus(Te.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(t.attrs), this._flushPendingMessages(), this._sessionId = t["session-id"];
5978
5981
  for (const y of Object.keys(this._rooms)) {
@@ -5989,7 +5992,7 @@ class dc {
5989
5992
  const { q: y, result: b } = t, _ = J(y);
5990
5993
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[_])
5991
5994
  break;
5992
- const T = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], S = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, g = cr(b), m = this.ensureAttrs(), I = tt(m, g, r, this.config.useDateObjects);
5995
+ const T = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], S = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, g = lr(b), m = this.ensureAttrs(), I = tt(m, g, r, this.config.useDateObjects);
5993
5996
  this.querySubs.updateInPlace((v) => {
5994
5997
  if (!v[_]) {
5995
5998
  this._log.info("Missing value in querySubs", { hash: _, q: y });
@@ -6044,9 +6047,9 @@ class dc {
6044
6047
  T !== this._pendingMutations() && this.kv.updateInPlace((m) => {
6045
6048
  m.pendingMutations = T;
6046
6049
  });
6047
- const S = Wt(T.entries()), g = y.map((m) => {
6050
+ const S = Vt(T.entries()), g = y.map((m) => {
6048
6051
  var O, R, P, U;
6049
- const I = m["instaql-query"], v = m["instaql-result"], M = J(I), x = cr(v), N = this.ensureAttrs(), W = tt(N, x, r, this.config.useDateObjects), { store: re, attrsStore: we } = this._applyOptimisticUpdates(W, N, S, _), Z = (R = (O = v == null ? void 0 : v[0]) == null ? void 0 : O.data) == null ? void 0 : R["page-info"], X = (U = (P = v == null ? void 0 : v[0]) == null ? void 0 : P.data) == null ? void 0 : U.aggregate;
6052
+ const I = m["instaql-query"], v = m["instaql-result"], M = J(I), x = lr(v), N = this.ensureAttrs(), W = tt(N, x, r, this.config.useDateObjects), { store: re, attrsStore: we } = this._applyOptimisticUpdates(W, N, S, _), Z = (R = (O = v == null ? void 0 : v[0]) == null ? void 0 : O.data) == null ? void 0 : R["page-info"], X = (U = (P = v == null ? void 0 : v[0]) == null ? void 0 : P.data) == null ? void 0 : U.aggregate;
6050
6053
  return {
6051
6054
  q: I,
6052
6055
  hash: M,
@@ -6247,21 +6250,21 @@ class dc {
6247
6250
  * Returns an unsubscribe function
6248
6251
  */
6249
6252
  subscribeQuery(e, t, r) {
6250
- this.config.disableValidation || fr(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
6253
+ this.config.disableValidation || hr(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
6251
6254
  const s = J(e), i = this.getPreviousResult(e);
6252
6255
  return i && t(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: t }), this._startQuerySub(e, s), () => {
6253
6256
  this._unsubQuery(e, s, t);
6254
6257
  };
6255
6258
  }
6256
6259
  queryOnce(e, t) {
6257
- this.config.disableValidation || fr(e, this.config.schema), t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
6258
- const r = new ar();
6260
+ this.config.disableValidation || hr(e, this.config.schema), t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
6261
+ const r = new ur();
6259
6262
  if (!this._isOnline)
6260
6263
  return r.reject(new Error("We can't run `queryOnce`, because the device is offline.")), r.promise;
6261
6264
  if (!this.querySubs)
6262
6265
  return r.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), r.promise;
6263
6266
  const s = J(e), i = this._startQuerySub(e, s);
6264
- return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), ec), r.promise;
6267
+ return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), nc), r.promise;
6265
6268
  }
6266
6269
  _completeQueryOnce(e, t, r) {
6267
6270
  this.queryOnceDfds[t] && (this.queryOnceDfds[t] = this.queryOnceDfds[t].filter((s) => s.dfd !== r), this._cleanupQuery(e, t));
@@ -6328,7 +6331,7 @@ class dc {
6328
6331
  a = !0;
6329
6332
  continue;
6330
6333
  }
6331
- const _ = a ? No(o, y) : y;
6334
+ const _ = a ? qo(o, y) : y;
6332
6335
  h.push(_);
6333
6336
  }
6334
6337
  return a ? h : l;
@@ -6341,7 +6344,7 @@ class dc {
6341
6344
  return a ? u : t;
6342
6345
  }
6343
6346
  _rewriteMutationsSorted(e, t) {
6344
- return Wt(this._rewriteMutations(e, t).entries());
6347
+ return Vt(this._rewriteMutations(e, t).entries());
6345
6348
  }
6346
6349
  // ---------------------------
6347
6350
  // Transact
@@ -6386,12 +6389,12 @@ class dc {
6386
6389
  const g = this._applyOptimisticUpdates(f, h, T, _);
6387
6390
  f = g.store, h = g.attrsStore;
6388
6391
  }
6389
- return { data: Xr({ store: f, attrsStore: h, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
6392
+ return { data: ts({ store: f, attrsStore: h, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
6390
6393
  }
6391
6394
  _applyOptimisticUpdates(e, t, r, s) {
6392
6395
  for (const [i, o] of r)
6393
6396
  if (!o["tx-id"] || s && o["tx-id"] > s) {
6394
- const a = Ui(e, t, o["tx-steps"]);
6397
+ const a = Fi(e, t, o["tx-steps"]);
6395
6398
  e = a.store, t = a.attrsStore;
6396
6399
  }
6397
6400
  return { store: e, attrsStore: t };
@@ -6450,7 +6453,7 @@ class dc {
6450
6453
  const r = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations());
6451
6454
  r !== this._pendingMutations() && this.kv.updateInPlace((i) => {
6452
6455
  i.pendingMutations = r;
6453
- }), Wt(r.entries()).forEach(([i, o]) => {
6456
+ }), Vt(r.entries()).forEach(([i, o]) => {
6454
6457
  o["tx-id"] || this._sendMutation(i, o);
6455
6458
  }), this._syncTable.flushPending();
6456
6459
  }
@@ -6485,7 +6488,7 @@ class dc {
6485
6488
  }
6486
6489
  _trySend(e, t, r) {
6487
6490
  if (this._transport.isOpen()) {
6488
- switch (gr[t.op] || this._log.info("[send]", this._transport.id, t.op, {
6491
+ switch (mr[t.op] || this._log.info("[send]", this._transport.id, t.op, {
6489
6492
  "client-event-id": e,
6490
6493
  ...t
6491
6494
  }), t.op) {
@@ -6509,7 +6512,7 @@ class dc {
6509
6512
  return;
6510
6513
  }
6511
6514
  const e = this._transport;
6512
- this._transport = ic({
6515
+ this._transport = ac({
6513
6516
  transportType: this._transportType,
6514
6517
  appId: this.config.appId,
6515
6518
  apiURI: this.config.apiURI,
@@ -6543,9 +6546,9 @@ class dc {
6543
6546
  if (typeof URL > "u")
6544
6547
  return;
6545
6548
  const e = new URL(window.location.href);
6546
- if (e.searchParams.get(qt)) {
6549
+ if (e.searchParams.get(Wt)) {
6547
6550
  const t = e.toString();
6548
- e.searchParams.delete(qt), e.searchParams.delete("code"), e.searchParams.delete("error");
6551
+ e.searchParams.delete(Wt), e.searchParams.delete(zt), e.searchParams.delete("code"), e.searchParams.delete("error");
6549
6552
  const r = e.pathname + (e.searchParams.size ? "?" + e.searchParams : "") + e.hash;
6550
6553
  if (history.replaceState(history.state, "", r), // @ts-ignore (waiting for ts support)
6551
6554
  typeof navigation == "object" && // @ts-ignore (waiting for ts support)
@@ -6565,11 +6568,11 @@ class dc {
6565
6568
  * @returns Promise<null | {error: {message: string}}>
6566
6569
  */
6567
6570
  async _oauthLoginInit() {
6568
- var s, i, o, a;
6571
+ var i, o, a, c;
6569
6572
  if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
6570
6573
  return null;
6571
6574
  const e = new URLSearchParams(window.location.search);
6572
- if (!e.get(qt))
6575
+ if (!e.get(Wt))
6573
6576
  return null;
6574
6577
  const t = e.get("error");
6575
6578
  if (t)
@@ -6577,17 +6580,24 @@ class dc {
6577
6580
  const r = e.get("code");
6578
6581
  if (!r)
6579
6582
  return null;
6583
+ const s = e.get(zt);
6580
6584
  this._replaceUrlAfterOAuth();
6581
6585
  try {
6582
- const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await ir({
6586
+ let u;
6587
+ const l = await this.kv.waitForKeyToLoad(bt);
6588
+ s && l && (u = l[s]), l && this.kv.updateInPlace((b) => {
6589
+ delete b[bt];
6590
+ });
6591
+ const f = await this._getCurrentUser(), h = (f == null ? void 0 : f.type) === "guest", { user: y } = await ar({
6583
6592
  apiURI: this.config.apiURI,
6584
6593
  appId: this.config.appId,
6585
6594
  code: r,
6586
- refreshToken: u ? c.refresh_token : void 0
6595
+ refreshToken: h ? f.refresh_token : void 0,
6596
+ extraFields: u
6587
6597
  });
6588
- return this.setCurrentUser(l), null;
6589
- } catch (c) {
6590
- return ((s = c == null ? void 0 : c.body) == null ? void 0 : s.type) === "record-not-found" && ((o = (i = c == null ? void 0 : c.body) == null ? void 0 : i.hint) == null ? void 0 : o["record-type"]) === "app-oauth-code" && await this._hasCurrentUser() ? null : { error: { message: ((a = c == null ? void 0 : c.body) == null ? void 0 : a.message) || "Error logging in." } };
6598
+ return this.setCurrentUser(y), null;
6599
+ } catch (u) {
6600
+ return ((i = u == null ? void 0 : u.body) == null ? void 0 : i.type) === "record-not-found" && ((a = (o = u == null ? void 0 : u.body) == null ? void 0 : o.hint) == null ? void 0 : a["record-type"]) === "app-oauth-code" && await this._hasCurrentUser() ? null : { error: { message: ((c = u == null ? void 0 : u.body) == null ? void 0 : c.message) || "Error logging in." } };
6591
6601
  }
6592
6602
  }
6593
6603
  async _waitForOAuthCallbackResponse() {
@@ -6604,7 +6614,7 @@ class dc {
6604
6614
  t.isLoading || e(this._currentUserCached);
6605
6615
  let r = !1;
6606
6616
  return this.getCurrentUser().then((s) => {
6607
- r || mt(s, t) || e(s);
6617
+ r || wt(s, t) || e(s);
6608
6618
  }), () => {
6609
6619
  r = !0, this.authCbs = this.authCbs.filter((s) => s !== e);
6610
6620
  };
@@ -6688,7 +6698,7 @@ class dc {
6688
6698
  async changeCurrentUser(e) {
6689
6699
  var r;
6690
6700
  const { user: t } = await this.getCurrentUser();
6691
- if (!mt(t, e)) {
6701
+ if (!wt(t, e)) {
6692
6702
  this._frameworkClient = null, await this.setCurrentUser(e), await this.updateUser(e);
6693
6703
  try {
6694
6704
  await this.kv.flush(), (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
@@ -6736,25 +6746,26 @@ class dc {
6736
6746
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(t);
6737
6747
  }
6738
6748
  sendMagicCode({ email: e }) {
6739
- return ma({
6749
+ return Ta({
6740
6750
  apiURI: this.config.apiURI,
6741
6751
  appId: this.config.appId,
6742
6752
  email: e
6743
6753
  });
6744
6754
  }
6745
- async signInWithMagicCode({ email: e, code: t }) {
6746
- var o, a;
6747
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await wa({
6755
+ async signInWithMagicCode(e) {
6756
+ var i, o;
6757
+ const t = await this.getCurrentUser(), r = ((i = t == null ? void 0 : t.user) == null ? void 0 : i.type) === "guest", s = await Sa({
6748
6758
  apiURI: this.config.apiURI,
6749
6759
  appId: this.config.appId,
6750
- email: e,
6751
- code: t,
6752
- refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
6760
+ email: e.email,
6761
+ code: e.code,
6762
+ refreshToken: r ? (o = t == null ? void 0 : t.user) == null ? void 0 : o.refresh_token : void 0,
6763
+ extraFields: e.extraFields
6753
6764
  });
6754
- return await this.changeCurrentUser(i.user), i;
6765
+ return await this.changeCurrentUser(s.user), s;
6755
6766
  }
6756
6767
  async signInWithCustomToken(e) {
6757
- const t = await Ta({
6768
+ const t = await va({
6758
6769
  apiURI: this.config.apiURI,
6759
6770
  appId: this.config.appId,
6760
6771
  refreshToken: e
@@ -6762,7 +6773,7 @@ class dc {
6762
6773
  return await this.changeCurrentUser(t.user), t;
6763
6774
  }
6764
6775
  async signInAsGuest() {
6765
- const e = await Sa({
6776
+ const e = await Aa({
6766
6777
  apiURI: this.config.apiURI,
6767
6778
  appId: this.config.appId
6768
6779
  });
@@ -6777,7 +6788,7 @@ class dc {
6777
6788
  this._log.info("[auth-invalidate] skipped invalidateToken");
6778
6789
  return;
6779
6790
  }
6780
- Aa({
6791
+ Ea({
6781
6792
  apiURI: this.config.apiURI,
6782
6793
  appId: this.config.appId,
6783
6794
  refreshToken: r
@@ -6796,27 +6807,38 @@ class dc {
6796
6807
  * @param {Object} params - The parameters to create the authorization URL.
6797
6808
  * @param {string} params.clientName - The name of the client requesting authorization.
6798
6809
  * @param {string} params.redirectURL - The URL to redirect users to after authorization.
6810
+ * @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
6799
6811
  * @returns {string} The created authorization URL.
6800
6812
  */
6801
- createAuthorizationURL({ clientName: e, redirectURL: t }) {
6802
- const { apiURI: r, appId: s } = this.config;
6803
- return `${r}/runtime/oauth/start?app_id=${s}&client_name=${e}&redirect_uri=${t}`;
6813
+ createAuthorizationURL({ clientName: e, redirectURL: t, extraFields: r }) {
6814
+ const { apiURI: s, appId: i } = this.config;
6815
+ let o = t;
6816
+ if (r) {
6817
+ const a = `${Math.random().toString(36).slice(2)}`;
6818
+ this.kv.updateInPlace((c) => {
6819
+ const u = c[bt] || {};
6820
+ u[a] = r, c[bt] = u;
6821
+ }), o = `${t}${t.includes("?") ? "&" : "?"}${zt}=${a}`;
6822
+ }
6823
+ return `${s}/runtime/oauth/start?app_id=${i}&client_name=${e}&redirect_uri=${encodeURIComponent(o)}`;
6804
6824
  }
6805
6825
  /**
6806
6826
  * @param {Object} params
6807
6827
  * @param {string} params.code - The code received from the OAuth service.
6808
6828
  * @param {string} [params.codeVerifier] - The code verifier used to generate the code challenge.
6829
+ * @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
6809
6830
  */
6810
- async exchangeCodeForToken({ code: e, codeVerifier: t }) {
6811
- var o, a;
6812
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await ir({
6831
+ async exchangeCodeForToken({ code: e, codeVerifier: t, extraFields: r }) {
6832
+ var a, c;
6833
+ const s = await this.getCurrentUser(), i = ((a = s == null ? void 0 : s.user) == null ? void 0 : a.type) === "guest", o = await ar({
6813
6834
  apiURI: this.config.apiURI,
6814
6835
  appId: this.config.appId,
6815
6836
  code: e,
6816
6837
  codeVerifier: t,
6817
- refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
6838
+ refreshToken: i ? (c = s == null ? void 0 : s.user) == null ? void 0 : c.refresh_token : void 0,
6839
+ extraFields: r
6818
6840
  });
6819
- return await this.changeCurrentUser(i.user), i;
6841
+ return await this.changeCurrentUser(o.user), o;
6820
6842
  }
6821
6843
  issuerURI() {
6822
6844
  const { apiURI: e, appId: t } = this.config;
@@ -6827,18 +6849,20 @@ class dc {
6827
6849
  * @param {string} params.clientName - The name of the client requesting authorization.
6828
6850
  * @param {string} params.idToken - The id_token from the external service
6829
6851
  * @param {string | null | undefined} [params.nonce] - The nonce used when requesting the id_token from the external service
6852
+ * @param {Record<string, any>} [params.extraFields] - Extra fields to write to $users on creation
6830
6853
  */
6831
- async signInWithIdToken({ idToken: e, clientName: t, nonce: r }) {
6832
- var a;
6833
- const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await va({
6854
+ async signInWithIdToken(e) {
6855
+ var i;
6856
+ const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token, s = await Oa({
6834
6857
  apiURI: this.config.apiURI,
6835
6858
  appId: this.config.appId,
6836
- idToken: e,
6837
- clientName: t,
6838
- nonce: r,
6839
- refreshToken: i
6859
+ idToken: e.idToken,
6860
+ clientName: e.clientName,
6861
+ nonce: e.nonce,
6862
+ refreshToken: r,
6863
+ extraFields: e.extraFields
6840
6864
  });
6841
- return await this.changeCurrentUser(o.user), o;
6865
+ return await this.changeCurrentUser(s.user), s;
6842
6866
  }
6843
6867
  // --------
6844
6868
  // Rooms
@@ -6873,7 +6897,7 @@ class dc {
6873
6897
  getPresence(e, t, r = {}) {
6874
6898
  const s = this._rooms[t], i = this._presence[t];
6875
6899
  return !s || !i || !i.result ? null : {
6876
- ...Pa(i.result, r, this._sessionId),
6900
+ ...Ra(i.result, r, this._sessionId),
6877
6901
  isLoading: !s.isConnected,
6878
6902
  error: s.error
6879
6903
  };
@@ -6935,24 +6959,24 @@ class dc {
6935
6959
  }
6936
6960
  _notifyPresenceSub(e, t) {
6937
6961
  const r = this.getPresence("", e, t);
6938
- r && (t.prev && !Ma(r, t.prev) || (t.prev = r, t.cb(r)));
6962
+ r && (t.prev && !ja(r, t.prev) || (t.prev = r, t.cb(r)));
6939
6963
  }
6940
6964
  _patchPresencePeers(e, t) {
6941
6965
  var o, a, c;
6942
6966
  const r = ((a = (o = this._presence[e]) == null ? void 0 : o.result) == null ? void 0 : a.peers) || {};
6943
6967
  let s = Object.fromEntries(Object.entries(r).map(([u, l]) => [u, { data: l }]));
6944
6968
  (c = this._presence[e]) == null || c.result;
6945
- const i = At(s, (u) => {
6969
+ const i = Ot(s, (u) => {
6946
6970
  for (let [l, f, h] of t)
6947
6971
  switch (f) {
6948
6972
  case "+":
6949
- ii(u, l, h);
6973
+ ai(u, l, h);
6950
6974
  break;
6951
6975
  case "r":
6952
- Qn(u, l, h);
6976
+ Gn(u, l, h);
6953
6977
  break;
6954
6978
  case "-":
6955
- Dr(u, l);
6979
+ Lr(u, l);
6956
6980
  break;
6957
6981
  }
6958
6982
  delete u[this._sessionId];
@@ -6963,8 +6987,8 @@ class dc {
6963
6987
  const r = { ...t };
6964
6988
  delete r[this._sessionId];
6965
6989
  const s = Object.fromEntries(Object.entries(r).map(([i, o]) => [i, o.data]));
6966
- this._presence = At(this._presence, (i) => {
6967
- Qn(i, [e, "result", "peers"], s);
6990
+ this._presence = Ot(this._presence, (i) => {
6991
+ Gn(i, [e, "result", "peers"], s);
6968
6992
  });
6969
6993
  }
6970
6994
  // --------
@@ -7007,7 +7031,7 @@ class dc {
7007
7031
  async uploadFile(e, t, r) {
7008
7032
  var o;
7009
7033
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
7010
- return Oa({
7034
+ return ka({
7011
7035
  ...r,
7012
7036
  apiURI: this.config.apiURI,
7013
7037
  appId: this.config.appId,
@@ -7019,7 +7043,7 @@ class dc {
7019
7043
  async deleteFile(e) {
7020
7044
  var i;
7021
7045
  const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token;
7022
- return await Ea({
7046
+ return await Ca({
7023
7047
  apiURI: this.config.apiURI,
7024
7048
  appId: this.config.appId,
7025
7049
  path: e,
@@ -7030,18 +7054,18 @@ class dc {
7030
7054
  // ---------------------------------
7031
7055
  async upload(e, t) {
7032
7056
  var c;
7033
- const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || t.name, o = await ka({
7057
+ const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || t.name, o = await Ia({
7034
7058
  apiURI: this.config.apiURI,
7035
7059
  appId: this.config.appId,
7036
7060
  fileName: i,
7037
7061
  refreshToken: s
7038
7062
  });
7039
- return await Ca(o, t);
7063
+ return await Pa(o, t);
7040
7064
  }
7041
7065
  async getDownloadUrl(e) {
7042
7066
  var i;
7043
7067
  const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token;
7044
- return await Ia({
7068
+ return await Ma({
7045
7069
  apiURI: this.config.apiURI,
7046
7070
  appId: this.config.appId,
7047
7071
  path: e,
@@ -7049,10 +7073,10 @@ class dc {
7049
7073
  });
7050
7074
  }
7051
7075
  }
7052
- let bt;
7053
- function hc(n, e) {
7054
- bt == null || bt.dispose();
7055
- const t = mc(e), r = bc(e, a), s = yc(pc(n));
7076
+ let gt;
7077
+ function yc(n, e) {
7078
+ gt == null || gt.dispose();
7079
+ const t = Tc(e), r = _c(e, a), s = gc(bc(n));
7056
7080
  function i(l) {
7057
7081
  var f;
7058
7082
  l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && t.isVisible() && a();
@@ -7068,16 +7092,16 @@ function hc(n, e) {
7068
7092
  t.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", i);
7069
7093
  }
7070
7094
  function u() {
7071
- document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i), bt = {
7095
+ document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i), gt = {
7072
7096
  dispose: c
7073
7097
  };
7074
7098
  }
7075
7099
  return u();
7076
7100
  }
7077
- function pc(n) {
7078
- return `${vn || is ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
7101
+ function bc(n) {
7102
+ return `${On || as ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
7079
7103
  }
7080
- function yc(n) {
7104
+ function gc(n) {
7081
7105
  const e = document.createElement("iframe");
7082
7106
  return e.src = n, e.className = "instant-devtool-iframe", Object.assign(e.style, {
7083
7107
  width: "100%",
@@ -7086,7 +7110,7 @@ function yc(n) {
7086
7110
  border: "none"
7087
7111
  }), { element: e };
7088
7112
  }
7089
- function bc(n, e) {
7113
+ function _c(n, e) {
7090
7114
  const t = `
7091
7115
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
7092
7116
  <rect width="512" height="512" fill="black"/>
@@ -7096,7 +7120,7 @@ function bc(n, e) {
7096
7120
  return r.innerHTML = t, r.className = "instant-devtool-toggler", Object.assign(r.style, {
7097
7121
  // pos
7098
7122
  position: "fixed",
7099
- ...gc(n.position),
7123
+ ...mc(n.position),
7100
7124
  height: "32px",
7101
7125
  width: "32px",
7102
7126
  // layout
@@ -7111,7 +7135,7 @@ function bc(n, e) {
7111
7135
  cursor: "pointer"
7112
7136
  }), r.addEventListener("click", e), { element: r };
7113
7137
  }
7114
- function gc(n) {
7138
+ function mc(n) {
7115
7139
  switch (n) {
7116
7140
  case "bottom-left":
7117
7141
  return { bottom: "24px", left: "24px" };
@@ -7123,7 +7147,7 @@ function gc(n) {
7123
7147
  return { top: "24px", left: "24px" };
7124
7148
  }
7125
7149
  }
7126
- function _c(n) {
7150
+ function wc(n) {
7127
7151
  switch (n) {
7128
7152
  case "bottom-left":
7129
7153
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -7135,11 +7159,11 @@ function _c(n) {
7135
7159
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
7136
7160
  }
7137
7161
  }
7138
- function mc(n) {
7162
+ function Tc(n) {
7139
7163
  const e = document.createElement("div");
7140
7164
  Object.assign(e.style, {
7141
7165
  position: "fixed",
7142
- ..._c(n.position),
7166
+ ...wc(n.position),
7143
7167
  display: "block",
7144
7168
  borderRadius: "4px",
7145
7169
  border: "1px #ccc solid",
@@ -7156,11 +7180,11 @@ function Ye(n, e) {
7156
7180
  if (!n)
7157
7181
  throw new Error("[assertion error] " + e);
7158
7182
  }
7159
- const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.endCursor, Tc = (n) => {
7183
+ const Ze = (n) => JSON.stringify(n), wr = (n) => JSON.parse(n), Sc = (n) => !!n.endCursor, vc = (n) => {
7160
7184
  var t;
7161
7185
  const e = Array.from(n.values());
7162
7186
  return e.length === 0 ? !1 : ((t = e[e.length - 1]) == null ? void 0 : t.hasMore) || !1;
7163
- }, Ne = (n, e) => `${n}:${JSON.stringify(e)}`, mr = (n) => {
7187
+ }, Ne = (n, e) => `${n}:${JSON.stringify(e)}`, Tr = (n) => {
7164
7188
  if (!n)
7165
7189
  return {
7166
7190
  serverCreatedAt: "asc"
@@ -7171,7 +7195,7 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7171
7195
  } : {
7172
7196
  serverCreatedAt: "asc"
7173
7197
  };
7174
- }, Sc = (n, e) => {
7198
+ }, Ac = (n, e) => {
7175
7199
  const t = [
7176
7200
  ...Array.from(e.values()).slice().reverse(),
7177
7201
  ...Array.from(n.values())
@@ -7180,21 +7204,21 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7180
7204
  ...Array.from(n.values()).flatMap((s) => s.data)
7181
7205
  ];
7182
7206
  return { chunks: t, data: r };
7183
- }, wr = ["bootstrap", "bootstrap", "bootstrap", 1], vc = (n, e, t, r) => {
7207
+ }, Sr = ["bootstrap", "bootstrap", "bootstrap", 1], Oc = (n, e, t, r) => {
7184
7208
  var re, we, Z, X;
7185
- const { entityName: s, entityQuery: i } = ps(e), o = ((re = i.$) == null ? void 0 : re.limit) || 10, a = s, c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
7209
+ const { entityName: s, entityQuery: i } = bs(e), o = ((re = i.$) == null ? void 0 : re.limit) || 10, a = s, c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
7186
7210
  let f = !1, h = !0, y = null, b = null;
7187
7211
  const _ = (O) => {
7188
7212
  t({ error: O, data: void 0, canLoadNextPage: !1 });
7189
7213
  }, T = () => {
7190
7214
  if (!h)
7191
7215
  return;
7192
- const { chunks: O, data: R } = Sc(c, u);
7216
+ const { chunks: O, data: R } = Ac(c, u);
7193
7217
  t({
7194
7218
  data: { [a]: R },
7195
7219
  // @ts-expect-error hidden debug variable
7196
7220
  chunks: O,
7197
- canLoadNextPage: Tc(c)
7221
+ canLoadNextPage: vc(c)
7198
7222
  });
7199
7223
  }, S = (O, R) => {
7200
7224
  c.set(Ze(O), R), T();
@@ -7202,7 +7226,7 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7202
7226
  u.set(Ze(O), R), x(), T();
7203
7227
  }, m = (O, R) => {
7204
7228
  var te, E, k;
7205
- const P = _r(O), U = l.get(Ne("reverse", P));
7229
+ const P = wr(O), U = l.get(Ne("reverse", P));
7206
7230
  U == null || U();
7207
7231
  const ee = n.subscribeQuery({
7208
7232
  [a]: {
@@ -7213,7 +7237,7 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7213
7237
  beforeInclusive: !0,
7214
7238
  where: (te = i.$) == null ? void 0 : te.where,
7215
7239
  fields: (E = i.$) == null ? void 0 : E.fields,
7216
- order: mr((k = i.$) == null ? void 0 : k.order)
7240
+ order: Tr((k = i.$) == null ? void 0 : k.order)
7217
7241
  }
7218
7242
  }
7219
7243
  }, (L) => {
@@ -7238,7 +7262,7 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7238
7262
  after: O,
7239
7263
  where: (P = i.$) == null ? void 0 : P.where,
7240
7264
  fields: (U = i.$) == null ? void 0 : U.fields,
7241
- order: mr((ee = i.$) == null ? void 0 : ee.order)
7265
+ order: Tr((ee = i.$) == null ? void 0 : ee.order)
7242
7266
  }
7243
7267
  }
7244
7268
  }, (te) => {
@@ -7318,7 +7342,7 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7318
7342
  if (!O)
7319
7343
  return;
7320
7344
  const [R, P] = O;
7321
- if (!(P != null && P.hasMore) || !wc(P))
7345
+ if (!(P != null && P.hasMore) || !Sc(P))
7322
7346
  return;
7323
7347
  const U = `${R}:${Ze(P.endCursor)}`;
7324
7348
  U != y && (y = U, m(R, P), I(P.endCursor));
@@ -7327,7 +7351,7 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7327
7351
  if (!O)
7328
7352
  return;
7329
7353
  const [R, P] = O;
7330
- P.endCursor && (M(_r(R)), v(P.endCursor));
7354
+ P.endCursor && (M(wr(R)), v(P.endCursor));
7331
7355
  };
7332
7356
  return b = n.subscribeQuery({
7333
7357
  [a]: {
@@ -7347,14 +7371,14 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7347
7371
  return _(O.error);
7348
7372
  const R = O.pageInfo[a], P = (ee = O == null ? void 0 : O.data) == null ? void 0 : ee[a];
7349
7373
  if (Ye(P && R, "Expected rows and pageInfo"), P.length < o) {
7350
- S(wr, {
7374
+ S(Sr, {
7351
7375
  data: P,
7352
7376
  status: "pre-bootstrap"
7353
7377
  });
7354
7378
  return;
7355
7379
  }
7356
7380
  const U = R.startCursor;
7357
- U && (c.delete(Ze(wr)), v(U, !0), I(R.startCursor), f = !0, await n._reactor.querySubs.flush(), b == null || b(), b = null);
7381
+ U && (c.delete(Ze(Sr)), v(U, !0), I(R.startCursor), f = !0, await n._reactor.querySubs.flush(), b == null || b(), b = null);
7358
7382
  }, r), {
7359
7383
  unsubscribe: () => {
7360
7384
  if (h) {
@@ -7366,7 +7390,7 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7366
7390
  },
7367
7391
  loadNextPage: N
7368
7392
  };
7369
- }, Ac = (n, e, t) => {
7393
+ }, Ec = (n, e, t) => {
7370
7394
  var c, u, l, f;
7371
7395
  if (!e)
7372
7396
  return {
@@ -7374,8 +7398,8 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7374
7398
  data: void 0,
7375
7399
  error: void 0
7376
7400
  };
7377
- const { entityName: r, entityQuery: s } = ps(e), i = ((c = s.$) == null ? void 0 : c.limit) || 10;
7378
- let o = e ? ys({
7401
+ const { entityName: r, entityQuery: s } = bs(e), i = ((c = s.$) == null ? void 0 : c.limit) || 10;
7402
+ let o = e ? gs({
7379
7403
  [r]: {
7380
7404
  ...s,
7381
7405
  $: {
@@ -7396,29 +7420,29 @@ const Ze = (n) => JSON.stringify(n), _r = (n) => JSON.parse(n), wc = (n) => !!n.
7396
7420
  data: (a == null ? void 0 : a.data) || void 0,
7397
7421
  error: void 0
7398
7422
  };
7399
- }, ps = (n) => {
7423
+ }, bs = (n) => {
7400
7424
  if (Object.keys(n).length !== 1)
7401
7425
  throw new q("subscribeInfiniteQuery expects exactly one entity");
7402
7426
  const [t, r] = Object.entries(n)[0];
7403
7427
  if (!t || !r)
7404
7428
  throw new q("No query provided for infinite query");
7405
7429
  return { entityName: t, entityQuery: r };
7406
- }, Oc = {
7430
+ }, kc = {
7407
7431
  apiURI: "https://api.instantdb.com",
7408
7432
  websocketURI: "wss://api.instantdb.com/runtime/session"
7409
7433
  };
7410
- function Ec() {
7434
+ function Cc() {
7411
7435
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
7412
7436
  }
7413
- function kc() {
7437
+ function Ic() {
7414
7438
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
7415
7439
  }
7416
- function un(n) {
7440
+ function fn(n) {
7417
7441
  const e = n.__adminToken;
7418
7442
  return n.appId + "_" + (n.websocketURI || "default_ws_uri") + "_" + (n.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + n.useDateObjects;
7419
7443
  }
7420
- const ln = kc(), Tr = Ec();
7421
- class Cc {
7444
+ const dn = Ic(), vr = Cc();
7445
+ class Pc {
7422
7446
  constructor(e) {
7423
7447
  p(this, "db");
7424
7448
  /**
@@ -7535,7 +7559,7 @@ class Cc {
7535
7559
  this.db = e;
7536
7560
  }
7537
7561
  }
7538
- class Ic {
7562
+ class Mc {
7539
7563
  constructor(e) {
7540
7564
  p(this, "db");
7541
7565
  /**
@@ -7593,7 +7617,7 @@ class Ic {
7593
7617
  this.db = e;
7594
7618
  }
7595
7619
  }
7596
- class Pc {
7620
+ class Rc {
7597
7621
  constructor(e) {
7598
7622
  p(this, "db");
7599
7623
  /**
@@ -7619,17 +7643,17 @@ class Pc {
7619
7643
  this.db = e;
7620
7644
  }
7621
7645
  }
7622
- function ys(n) {
7646
+ function gs(n) {
7623
7647
  return JSON.parse(JSON.stringify(n));
7624
7648
  }
7625
- class Mc {
7649
+ class jc {
7626
7650
  constructor(e) {
7627
7651
  p(this, "_reactor");
7628
7652
  p(this, "auth");
7629
7653
  p(this, "storage");
7630
7654
  p(this, "streams");
7631
- p(this, "tx", Sn());
7632
- this._reactor = e, this.auth = new Cc(this._reactor), this.storage = new Ic(this._reactor), this.streams = new Pc(this._reactor);
7655
+ p(this, "tx", An());
7656
+ this._reactor = e, this.auth = new Pc(this._reactor), this.storage = new Mc(this._reactor), this.streams = new Rc(this._reactor);
7633
7657
  }
7634
7658
  /**
7635
7659
  * Use this to write data! You can create, update, delete, and link objects
@@ -7707,7 +7731,7 @@ class Mc {
7707
7731
  * });
7708
7732
  */
7709
7733
  subscribeInfiniteQuery(e, t, r) {
7710
- return vc(this, e, t, r);
7734
+ return Oc(this, e, t, r);
7711
7735
  }
7712
7736
  /**
7713
7737
  * Listen for the logged in state. This is useful
@@ -7792,7 +7816,7 @@ class Mc {
7792
7816
  };
7793
7817
  }
7794
7818
  shutdown() {
7795
- delete ln[un(this._reactor.config)], this._reactor.shutdown();
7819
+ delete dn[fn(this._reactor.config)], this._reactor.shutdown();
7796
7820
  }
7797
7821
  /**
7798
7822
  * Use this for one-off queries.
@@ -7825,35 +7849,35 @@ class Mc {
7825
7849
  return this._reactor.subscribeTable(e, t);
7826
7850
  }
7827
7851
  }
7828
- function Sr(n) {
7852
+ function Ar(n) {
7829
7853
  if (!n)
7830
7854
  return "0";
7831
- const e = Tr.get(n);
7855
+ const e = vr.get(n);
7832
7856
  if (e)
7833
7857
  return e;
7834
7858
  const t = J(n);
7835
- return Tr.set(n, t), t;
7859
+ return vr.set(n, t), t;
7836
7860
  }
7837
- function Rc(n, e) {
7838
- return Sr(n._reactor.config.schema) !== Sr(e);
7861
+ function $c(n, e) {
7862
+ return Ar(n._reactor.config.schema) !== Ar(e);
7839
7863
  }
7840
- function jc(n, e, t, r, s) {
7864
+ function xc(n, e, t, r, s) {
7841
7865
  var u;
7842
7866
  const i = {
7843
7867
  ...n,
7844
7868
  appId: (u = n.appId) == null ? void 0 : u.trim(),
7845
7869
  useDateObjects: n.useDateObjects ?? !1
7846
- }, o = ln[un(i)];
7870
+ }, o = dn[fn(i)];
7847
7871
  if (o)
7848
- return Rc(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7849
- const a = new dc({
7850
- ...Oc,
7872
+ return $c(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7873
+ const a = new pc({
7874
+ ...kc,
7851
7875
  ...i,
7852
7876
  cardinalityInference: !!i.schema
7853
- }, e || ns, t || rs, { ...r || {}, "@instantdb/core": as }, s), c = new Mc(a);
7854
- return ln[un(i)] = c, $c(i.appId, i.devtool), c;
7877
+ }, e || ss, t || is, { ...r || {}, "@instantdb/core": us }, s), c = new jc(a);
7878
+ return dn[fn(i)] = c, Dc(i.appId, i.devtool), c;
7855
7879
  }
7856
- function $c(n, e) {
7880
+ function Dc(n, e) {
7857
7881
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
7858
7882
  return;
7859
7883
  const t = {
@@ -7861,15 +7885,15 @@ function $c(n, e) {
7861
7885
  allowedHosts: ["localhost"],
7862
7886
  ...typeof e == "object" ? e : {}
7863
7887
  };
7864
- t.allowedHosts.includes(window.location.hostname) && hc(n, t);
7888
+ t.allowedHosts.includes(window.location.hostname) && yc(n, t);
7865
7889
  }
7866
- const vr = {
7890
+ const Or = {
7867
7891
  isLoading: !0,
7868
7892
  data: void 0,
7869
7893
  pageInfo: void 0,
7870
7894
  error: void 0
7871
7895
  };
7872
- function Ar(n) {
7896
+ function Er(n) {
7873
7897
  return {
7874
7898
  isLoading: !n,
7875
7899
  data: void 0,
@@ -7878,12 +7902,12 @@ function Ar(n) {
7878
7902
  ...n || {}
7879
7903
  };
7880
7904
  }
7881
- function xc(n, e, t, r) {
7905
+ function Uc(n, e, t, r) {
7882
7906
  e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
7883
- const s = e ? ys(e) : null, i = J(s), o = ke(
7884
- Ar(n._reactor.getPreviousResult(s))
7885
- ), a = ke(vr), c = Ae(
7886
- (l) => (o.current = Ar(
7907
+ const s = e ? gs(e) : null, i = J(s), o = ke(
7908
+ Er(n._reactor.getPreviousResult(s))
7909
+ ), a = ke(Or), c = Ae(
7910
+ (l) => (o.current = Er(
7887
7911
  n._reactor.getPreviousResult(s)
7888
7912
  ), l(), s ? n.subscribeQuery(s, (h) => {
7889
7913
  o.current = {
@@ -7901,11 +7925,11 @@ function xc(n, e, t, r) {
7901
7925
  // Build a new subscribe function if the query changes
7902
7926
  [i]
7903
7927
  );
7904
- return { state: Tt(
7928
+ return { state: St(
7905
7929
  c,
7906
7930
  () => o.current,
7907
7931
  () => {
7908
- if (r && a.current === vr) {
7932
+ if (r && a.current === Or) {
7909
7933
  const l = r();
7910
7934
  l && (a.current = l);
7911
7935
  }
@@ -7913,18 +7937,18 @@ function xc(n, e, t, r) {
7913
7937
  }
7914
7938
  ), query: s, queryHash: i };
7915
7939
  }
7916
- const Dc = {
7940
+ const Lc = {
7917
7941
  error: void 0,
7918
7942
  data: void 0,
7919
7943
  isLoading: !0,
7920
7944
  canLoadNextPage: !1
7921
7945
  };
7922
- function Uc({
7946
+ function Fc({
7923
7947
  core: n,
7924
7948
  query: e,
7925
7949
  opts: t
7926
7950
  }) {
7927
- const r = ke(null), s = J(e), i = J(t), o = Ac(n, e, t), a = ke({
7951
+ const r = ke(null), s = J(e), i = J(t), o = Ec(n, e, t), a = ke({
7928
7952
  ...o,
7929
7953
  isLoading: !o.data && !o.error
7930
7954
  }), c = Ae(
@@ -7954,10 +7978,10 @@ function Uc({
7954
7978
  [s, i]
7955
7979
  );
7956
7980
  return {
7957
- ...Tt(
7981
+ ...St(
7958
7982
  c,
7959
7983
  () => a.current,
7960
- () => Dc
7984
+ () => Lc
7961
7985
  ),
7962
7986
  loadNextPage: () => {
7963
7987
  var f;
@@ -7965,7 +7989,7 @@ function Uc({
7965
7989
  }
7966
7990
  };
7967
7991
  }
7968
- function Lc() {
7992
+ function Nc() {
7969
7993
  const n = ke(null);
7970
7994
  je(() => {
7971
7995
  t();
@@ -7978,8 +8002,8 @@ function Lc() {
7978
8002
  }
7979
8003
  return { set: e, clear: t };
7980
8004
  }
7981
- const Fc = 1e3;
7982
- function Nc(n, e, t) {
8005
+ const Kc = 1e3;
8006
+ function qc(n, e, t) {
7983
8007
  const r = ke(t);
7984
8008
  r.current = t, je(() => n.core._reactor.subscribeTopic(
7985
8009
  n.type,
@@ -7990,7 +8014,7 @@ function Nc(n, e, t) {
7990
8014
  }
7991
8015
  ), [n.id, e]);
7992
8016
  }
7993
- function Kc(n, e) {
8017
+ function Wc(n, e) {
7994
8018
  return je(() => n.core._reactor.joinRoom(n.type, n.id), [n.id]), Ae(
7995
8019
  (r) => {
7996
8020
  n.core._reactor.publishTopic({
@@ -8003,9 +8027,9 @@ function Kc(n, e) {
8003
8027
  [n.id, e]
8004
8028
  );
8005
8029
  }
8006
- function qc(n, e = {}) {
8030
+ function zc(n, e = {}) {
8007
8031
  var o, a;
8008
- const [t, r] = Er(() => n.core._reactor.getPresence(n.type, n.id, e) ?? {
8032
+ const [t, r] = Cr(() => n.core._reactor.getPresence(n.type, n.id, e) ?? {
8009
8033
  peers: {},
8010
8034
  isLoading: !0
8011
8035
  });
@@ -8023,21 +8047,21 @@ function qc(n, e = {}) {
8023
8047
  },
8024
8048
  [n.type, n.id]
8025
8049
  );
8026
- return Vt(() => ({
8050
+ return Bt(() => ({
8027
8051
  ...t,
8028
8052
  publishPresence: s
8029
8053
  }), [t, s]);
8030
8054
  }
8031
- function Wc(n, e, t) {
8055
+ function Vc(n, e, t) {
8032
8056
  je(
8033
8057
  () => n.core._reactor.joinRoom(n.type, n.id, e),
8034
8058
  [n.id]
8035
8059
  ), je(() => n.core._reactor.publishPresence(n.type, n.id, e), [n.type, n.id, t ?? JSON.stringify(e)]);
8036
8060
  }
8037
- function zc(n, e, t = {}) {
8038
- const r = Lc(), s = Pe.usePresence(n, {
8061
+ function Qc(n, e, t = {}) {
8062
+ const r = Nc(), s = Pe.usePresence(n, {
8039
8063
  keys: [e]
8040
- }), i = Vt(() => {
8064
+ }), i = Bt(() => {
8041
8065
  const l = n._core._reactor.getPresence(
8042
8066
  n.type,
8043
8067
  n.id
@@ -8049,7 +8073,7 @@ function zc(n, e, t = {}) {
8049
8073
  (l) => {
8050
8074
  n.core._reactor.publishPresence(n.type, n.id, {
8051
8075
  [e]: l
8052
- }), l && ((t == null ? void 0 : t.timeout) === null || (t == null ? void 0 : t.timeout) === 0 || r.set((t == null ? void 0 : t.timeout) ?? Fc, () => {
8076
+ }), l && ((t == null ? void 0 : t.timeout) === null || (t == null ? void 0 : t.timeout) === 0 || r.set((t == null ? void 0 : t.timeout) ?? Kc, () => {
8053
8077
  n.core._reactor.publishPresence(n.type, n.id, {
8054
8078
  [e]: null
8055
8079
  });
@@ -8064,7 +8088,7 @@ function zc(n, e, t = {}) {
8064
8088
  [t.stopOnEnter, o]
8065
8089
  ), c = Ae(() => {
8066
8090
  o(!1);
8067
- }, [o]), u = Vt(() => ({ onKeyDown: a, onBlur: c }), [a, c]);
8091
+ }, [o]), u = Bt(() => ({ onKeyDown: a, onBlur: c }), [a, c]);
8068
8092
  return {
8069
8093
  active: i,
8070
8094
  setActive: o,
@@ -8072,13 +8096,13 @@ function zc(n, e, t = {}) {
8072
8096
  };
8073
8097
  }
8074
8098
  const Pe = {
8075
- useTopicEffect: Nc,
8076
- usePublishTopic: Kc,
8077
- usePresence: qc,
8078
- useSyncPresence: Wc,
8079
- useTypingIndicator: zc
8099
+ useTopicEffect: qc,
8100
+ usePublishTopic: Wc,
8101
+ usePresence: zc,
8102
+ useSyncPresence: Vc,
8103
+ useTypingIndicator: Qc
8080
8104
  };
8081
- class Vc {
8105
+ class Bc {
8082
8106
  constructor(e, t, r) {
8083
8107
  p(this, "core");
8084
8108
  /** @deprecated use `core` instead */
@@ -8165,14 +8189,14 @@ class Vc {
8165
8189
  this.core = e, this._core = this.core, this.type = t, this.id = r;
8166
8190
  }
8167
8191
  }
8168
- const Qc = {
8192
+ const Gc = {
8169
8193
  isLoading: !0,
8170
8194
  user: void 0,
8171
8195
  error: void 0
8172
8196
  };
8173
- class zt {
8197
+ class Qt {
8174
8198
  constructor(e, t) {
8175
- p(this, "tx", Sn());
8199
+ p(this, "tx", An());
8176
8200
  p(this, "auth");
8177
8201
  p(this, "storage");
8178
8202
  p(this, "streams");
@@ -8201,7 +8225,7 @@ class zt {
8201
8225
  * console.log('Device ID:', deviceId)
8202
8226
  */
8203
8227
  p(this, "useLocalId", (e) => {
8204
- const [t, r] = Er(null);
8228
+ const [t, r] = Cr(null);
8205
8229
  return je(() => {
8206
8230
  (async () => {
8207
8231
  const i = await this.getLocalId(e);
@@ -8269,7 +8293,7 @@ class zt {
8269
8293
  * auth.user ? { goals: {} } : null,
8270
8294
  * );
8271
8295
  */
8272
- p(this, "useQuery", (e, t) => xc(this.core, e, t).state);
8296
+ p(this, "useQuery", (e, t) => Uc(this.core, e, t).state);
8273
8297
  /**
8274
8298
  * Listen for the logged in state. This is useful
8275
8299
  * for deciding when to show a login screen.
@@ -8349,7 +8373,7 @@ class zt {
8349
8373
  ), t = Ae((s) => this.core.subscribeConnectionStatus((o) => {
8350
8374
  o !== e.current && (e.current = o, s());
8351
8375
  }), []);
8352
- return Tt(
8376
+ return St(
8353
8377
  t,
8354
8378
  () => e.current,
8355
8379
  // For SSR, always return 'connecting' as the initial state
@@ -8393,7 +8417,7 @@ class zt {
8393
8417
  * },
8394
8418
  * });
8395
8419
  */
8396
- p(this, "useInfiniteQuery", (e, t) => Uc({
8420
+ p(this, "useInfiniteQuery", (e, t) => Fc({
8397
8421
  core: this.core,
8398
8422
  query: e,
8399
8423
  opts: t
@@ -8426,7 +8450,7 @@ class zt {
8426
8450
  const t = this.useAuth();
8427
8451
  return t.isLoading || t.error || t.user ? null : /* @__PURE__ */ dt.jsx(dt.Fragment, { children: e });
8428
8452
  });
8429
- this.core = jc(
8453
+ this.core = xc(
8430
8454
  e,
8431
8455
  // @ts-expect-error because TS can't resolve subclass statics
8432
8456
  e.Store || this.constructor.Store,
@@ -8450,7 +8474,7 @@ class zt {
8450
8474
  * const { peers } = db.rooms.usePresence(room);
8451
8475
  */
8452
8476
  room(e = "_defaultRoomType", t = "_defaultRoomId") {
8453
- return new Vc(this.core, e, t);
8477
+ return new Bc(this.core, e, t);
8454
8478
  }
8455
8479
  _useAuth() {
8456
8480
  const e = ke(
@@ -8458,10 +8482,10 @@ class zt {
8458
8482
  ), t = Ae((s) => this.core.subscribeAuth((o) => {
8459
8483
  e.current = { isLoading: !1, ...o }, s();
8460
8484
  }), []);
8461
- return Tt(
8485
+ return St(
8462
8486
  t,
8463
8487
  () => e.current,
8464
- () => Qc
8488
+ () => Gc
8465
8489
  );
8466
8490
  }
8467
8491
  /**
@@ -8478,8 +8502,8 @@ class zt {
8478
8502
  return this.core.getAuth();
8479
8503
  }
8480
8504
  }
8481
- p(zt, "Store"), p(zt, "NetworkListener"), p(zt, "EventSourceImpl");
8505
+ p(Qt, "Store"), p(Qt, "NetworkListener"), p(Qt, "EventSourceImpl");
8482
8506
  export {
8483
- zt as InstantReactAbstractDatabase,
8484
- xc as useQueryInternal
8507
+ Qt as InstantReactAbstractDatabase,
8508
+ Uc as useQueryInternal
8485
8509
  };