@statezero/core 0.2.53 → 0.2.54

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,61 +1,61 @@
1
- import { ref as J, computed as R, onMounted as fs, onBeforeUnmount as ps, watch as it, createElementBlock as $, openBlock as A, createElementVNode as h, createVNode as Mt, toDisplayString as S, createCommentVNode as V, Fragment as W, renderList as ce, normalizeClass as $t, normalizeStyle as at, withDirectives as Qe, createTextVNode as Ve, vModelCheckbox as At, vModelSelect as Ot, Transition as Pt, withCtx as Ft } from "vue";
2
- import { v7 as G } from "uuid";
3
- import { isNil as E, isEmpty as ve, trim as ut, isEqual as qe } from "lodash-es";
4
- import Ae from "mitt";
5
- import It from "handlebars";
6
- import Dt from "superjson";
7
- import ms from "p-queue";
8
- import ys from "axios";
9
- import { z as P } from "zod";
10
- import gs from "pusher-js";
11
- import Yt, { createEqualsOperation as ee } from "sift";
1
+ import { ref as J, computed as I, onMounted as hs, onBeforeUnmount as fs, watch as ot, createElementBlock as M, openBlock as A, createElementVNode as f, createVNode as St, toDisplayString as S, createCommentVNode as L, Fragment as W, renderList as ce, normalizeClass as Tt, normalizeStyle as it, withDirectives as Ue, createTextVNode as Qe, vModelCheckbox as Mt, vModelSelect as At, Transition as Ot, withCtx as $t } from "vue";
2
+ import { v7 as B } from "uuid";
3
+ import { isNil as b, isEmpty as ve, trim as dt, isEqual as He } from "lodash-es";
4
+ import Oe from "mitt";
5
+ import Ft from "handlebars";
6
+ import Pt from "superjson";
7
+ import ps from "p-queue";
8
+ import ms from "axios";
9
+ import { z as $ } from "zod";
10
+ import ys from "pusher-js";
11
+ import Wt, { createEqualsOperation as ee } from "sift";
12
12
  import { DateTime as _e } from "luxon";
13
- import { parse as _s, format as ws } from "date-fns";
14
- import { Graph as zt } from "graphlib";
13
+ import { parse as gs, format as _s } from "date-fns";
14
+ import { Graph as Dt } from "graphlib";
15
15
  import Le from "object-hash";
16
- import * as Xt from "mathjs";
17
- import Cs from "rfdc";
18
- const se = /* @__PURE__ */ new Map(), ht = /* @__PURE__ */ new Set();
19
- function vs(n) {
20
- return ht.add(n), () => ht.delete(n);
16
+ import * as Zt from "mathjs";
17
+ import ws from "rfdc";
18
+ const se = /* @__PURE__ */ new Map(), ut = /* @__PURE__ */ new Set();
19
+ function Cs(n) {
20
+ return ut.add(n), () => ut.delete(n);
21
21
  }
22
- function Je(n) {
22
+ function qe(n) {
23
23
  return typeof n == "string" && /\{\{\s*TempPK_[^}\s]+\s*\}\}/.test(n);
24
24
  }
25
- function Kt(n) {
25
+ function zt(n) {
26
26
  return `{{TempPK_${n}}}`;
27
27
  }
28
28
  function Rt(n, e) {
29
29
  const t = `{{TempPK_${n}}}`, s = `"TempPK_${n}"`, r = typeof e == "string" ? `"${e}"` : String(e);
30
30
  se.set(s, r);
31
- for (const o of ht)
31
+ for (const o of ut)
32
32
  try {
33
33
  o(t, e);
34
34
  } catch (i) {
35
35
  console.warn("[tempPk] onResolve callback error:", i);
36
36
  }
37
37
  }
38
- function Es(n) {
39
- if (!Je(String(n))) return n;
38
+ function vs(n) {
39
+ if (!qe(String(n))) return n;
40
40
  const e = String(n).match(/\{\{\s*TempPK_([^}\s]+)\s*\}\}/);
41
41
  if (!e) return n;
42
42
  const t = `"TempPK_${e[1]}"`, s = se.get(t);
43
43
  return s ? s.startsWith('"') && s.endsWith('"') ? s.slice(1, -1) : parseInt(s, 10) : n;
44
44
  }
45
- function We(n) {
45
+ function Je(n) {
46
46
  if (se.size === 0) return n;
47
47
  const e = Object.fromEntries(se);
48
48
  try {
49
49
  if (typeof n == "string")
50
- return It.compile(n, { noEscape: !0 })(e);
51
- const t = Dt.stringify(n), r = It.compile(t, { noEscape: !0 })(e);
52
- return Dt.parse(r);
50
+ return Ft.compile(n, { noEscape: !0 })(e);
51
+ const t = Pt.stringify(n), r = Ft.compile(t, { noEscape: !0 })(e);
52
+ return Pt.parse(r);
53
53
  } catch {
54
54
  return n;
55
55
  }
56
56
  }
57
- const bs = Ae(), ks = Ae(), Nt = Ae(), lt = /* @__PURE__ */ new Map();
58
- class Ss {
57
+ const ks = Oe(), bs = Oe(), Kt = Oe(), at = /* @__PURE__ */ new Map();
58
+ class Es {
59
59
  constructor(e, t = {}) {
60
60
  this.dbName = e, this.storeName = t.storeName || "keyval-store", this.batchDelay = t.batchDelay || 50, this.version = t.version || 5, this.resetOnErrors = t.resetOnErrors || [
61
61
  "VersionError",
@@ -236,9 +236,9 @@ class Ss {
236
236
  }
237
237
  }
238
238
  }
239
- class Et {
239
+ class Ct {
240
240
  constructor(e, t = {}, s = null) {
241
- lt.has(e) ? this.store = lt.get(e) : (this.store = new Ss(e, t), lt.set(e, this.store)), this.localMap = /* @__PURE__ */ new Map(), this.hydrate().then((r) => {
241
+ at.has(e) ? this.store = at.get(e) : (this.store = new Es(e, t), at.set(e, this.store)), this.localMap = /* @__PURE__ */ new Map(), this.hydrate().then((r) => {
242
242
  typeof s == "function" && s(r);
243
243
  }).catch((r) => {
244
244
  console.error(`Cache hydration failed for "${e}":`, r);
@@ -288,13 +288,13 @@ class Et {
288
288
  const ge = (n, e) => {
289
289
  if (!e || !e.pks || e.pks.length === 0) return;
290
290
  const t = e.pks.map((r) => n._lastRenderedData.get(r) ?? null), s = n.render(e.pks, !0, !1);
291
- if (!qe(s, t)) {
291
+ if (!He(s, t)) {
292
292
  const r = n.pkField;
293
293
  for (const o of s)
294
294
  o && o[r] != null && n._lastRenderedData.set(o[r], o);
295
295
  for (const o of e.pks)
296
296
  s.some((i) => i && i[r] === o) || n._lastRenderedData.set(o, null);
297
- bs.emit(
297
+ ks.emit(
298
298
  `${n.modelClass.configKey}::${n.modelClass.modelName}::render`,
299
299
  e
300
300
  ), n.renderCallbacks.forEach((o) => {
@@ -340,14 +340,14 @@ class Y {
340
340
  return r.size > 0 ? new Y(t, Array.from(r)) : null;
341
341
  }
342
342
  }
343
- class Ts {
343
+ class Ss {
344
344
  modelClass;
345
345
  fetchFn;
346
346
  groundTruthArray;
347
347
  operationsMap;
348
348
  isSyncing;
349
349
  constructor(e, t, s = null, r = null, o = {}) {
350
- this.modelClass = e, this.fetchFn = t, this.isSyncing = !1, this.pruneThreshold = o.pruneThreshold || 10, this.groundTruthArray = s || [], this.operationsMap = /* @__PURE__ */ new Map(), r && r.length > 0 && this._loadOperations(r), this.modelCache = new Et("model-cache", {}, this.onHydrated.bind(this)), this._lastRenderedData = /* @__PURE__ */ new Map(), this.renderCallbacks = /* @__PURE__ */ new Set(), this._unsubscribeTempPk = vs((i, l) => {
350
+ this.modelClass = e, this.fetchFn = t, this.isSyncing = !1, this.pruneThreshold = o.pruneThreshold || 10, this.groundTruthArray = s || [], this.operationsMap = /* @__PURE__ */ new Map(), r && r.length > 0 && this._loadOperations(r), this.modelCache = new Ct("model-cache", {}, this.onHydrated.bind(this)), this._lastRenderedData = /* @__PURE__ */ new Map(), this.renderCallbacks = /* @__PURE__ */ new Set(), this._unsubscribeTempPk = Cs((i, l) => {
351
351
  if (this._lastRenderedData.has(i)) {
352
352
  const a = this._lastRenderedData.get(i);
353
353
  a && typeof a == "object" && (a[this.pkField] = l), this._lastRenderedData.set(l, a), this._lastRenderedData.delete(i);
@@ -363,7 +363,7 @@ class Ts {
363
363
  */
364
364
  _loadOperations(e) {
365
365
  e.forEach((t) => {
366
- const s = Pe.get(t.operationId);
366
+ const s = Fe.get(t.operationId);
367
367
  s ? this.operationsMap.set(s.operationId, s) : this.operationsMap.set(t.operationId, new q(t, !0));
368
368
  });
369
369
  }
@@ -374,7 +374,7 @@ class Ts {
374
374
  onHydrated() {
375
375
  if (this.groundTruthArray.length === 0 && this.operationsMap.size === 0) {
376
376
  let e = this.modelCache.get(this.cacheKey);
377
- !E(e) && !ve(e) && this.setGroundTruth(e);
377
+ !b(e) && !ve(e) && this.setGroundTruth(e);
378
378
  }
379
379
  }
380
380
  setCache(e) {
@@ -382,7 +382,7 @@ class Ts {
382
382
  let s = [];
383
383
  e.forEach((r) => {
384
384
  let o = r[t];
385
- if (!(typeof o == "string" && Je(o) && (o = We(r[t]), E(o) || ve(ut(o)))))
385
+ if (!(typeof o == "string" && qe(o) && (o = Je(r[t]), b(o) || ve(dt(o)))))
386
386
  if (r && typeof r.serialize == "function") {
387
387
  const i = r.serialize(!0);
388
388
  i[t] = o, s.push(i);
@@ -397,14 +397,14 @@ class Ts {
397
397
  const s = this.pkField;
398
398
  let r = [];
399
399
  if (e.forEach((c) => {
400
- let f = c[s];
401
- typeof f == "string" && Je(f) && (f = We(c[s]), E(f) || ve(ut(f))) || (c[s] = f, r.push(c));
400
+ let h = c[s];
401
+ typeof h == "string" && qe(h) && (h = Je(c[s]), b(h) || ve(dt(h))) || (c[s] = h, r.push(c));
402
402
  }), t === null) {
403
403
  this.setCache(r);
404
404
  return;
405
405
  }
406
406
  const i = (this.modelCache.get(this.cacheKey) || []).filter(
407
- (c) => c && typeof c == "object" && s in c && (!t.has(c[s]) || r.some((f) => f[s] === c[s]))
407
+ (c) => c && typeof c == "object" && s in c && (!t.has(c[s]) || r.some((h) => h[s] === c[s]))
408
408
  ), l = new Map(
409
409
  i.map((c) => [c[s], c])
410
410
  );
@@ -478,18 +478,28 @@ class Ts {
478
478
  r.push(l);
479
479
  }
480
480
  if (r.push(...Array.from(s.values())), this.groundTruthArray = r, i.length > 0) {
481
- const l = new q({
482
- operationId: `checkpoint_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
483
- type: M.CHECKPOINT,
484
- instances: i,
485
- status: C.CONFIRMED,
486
- timestamp: Date.now(),
487
- queryset: this.modelClass.objects.all()
488
- });
489
- this.operationsMap.set(
490
- l.operationId,
491
- l
481
+ const l = /* @__PURE__ */ new Set();
482
+ for (const c of this.operations)
483
+ if ((c.type === P.UPDATE || c.type === P.UPDATE_INSTANCE) && c.status !== C.CONFIRMED && c.status !== C.REJECTED)
484
+ for (const h of c.instances)
485
+ h && h[t] != null && l.add(h[t]);
486
+ const a = i.filter(
487
+ (c) => !l.has(c[t])
492
488
  );
489
+ if (a.length > 0) {
490
+ const c = new q({
491
+ operationId: `checkpoint_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
492
+ type: P.CHECKPOINT,
493
+ instances: a,
494
+ status: C.CONFIRMED,
495
+ timestamp: Date.now(),
496
+ queryset: this.modelClass.objects.all()
497
+ });
498
+ this.operationsMap.set(
499
+ c.operationId,
500
+ c
501
+ );
502
+ }
493
503
  }
494
504
  ge(
495
505
  this,
@@ -543,21 +553,21 @@ class Ts {
543
553
  }
544
554
  let o = r[s];
545
555
  switch (e.type) {
546
- case M.CREATE:
547
- case M.BULK_CREATE:
556
+ case P.CREATE:
557
+ case P.BULK_CREATE:
548
558
  t.has(o) || t.set(o, r);
549
559
  break;
550
- case M.CHECKPOINT:
551
- case M.UPDATE_INSTANCE:
552
- case M.UPDATE: {
560
+ case P.CHECKPOINT:
561
+ case P.UPDATE_INSTANCE:
562
+ case P.UPDATE: {
553
563
  const i = t.get(o);
554
564
  i ? t.set(o, { ...i, ...r }) : this.operations.some(
555
- (a) => a.type === M.DELETE && a.status !== C.REJECTED && a.instances.some((c) => c && c[s] === o)
565
+ (a) => a.type === P.DELETE && a.status !== C.REJECTED && a.instances.some((c) => c && c[s] === o)
556
566
  ) || t.set(o, r);
557
567
  break;
558
568
  }
559
- case M.DELETE_INSTANCE:
560
- case M.DELETE:
569
+ case P.DELETE_INSTANCE:
570
+ case P.DELETE:
561
571
  t.delete(o);
562
572
  break;
563
573
  default:
@@ -593,24 +603,24 @@ class Ts {
593
603
  pruneUnreferencedInstances(e) {
594
604
  const t = this.pkField, s = this.modelClass.modelName, r = /* @__PURE__ */ new Set();
595
605
  for (const [l, a] of e._stores.entries())
596
- a.modelClass.modelName === s && a.groundTruthPks.forEach((c) => r.add(c)), a.includedPks.has(s) && a.includedPks.get(s).forEach((f) => r.add(f));
606
+ a.modelClass.modelName === s && a.groundTruthPks.forEach((c) => r.add(c)), a.includedPks.has(s) && a.includedPks.get(s).forEach((h) => r.add(h));
597
607
  const o = this.groundTruthArray.filter((l) => !l || typeof l != "object" || !(t in l) ? !1 : r.has(l[t]));
598
608
  this.groundTruthArray.length - o.length > 0 && (this.groundTruthArray = o, this.setCache(o));
599
609
  }
600
610
  // Render methods
601
611
  render(e = null, t = !0, s = !0) {
602
612
  if (s && e !== null) {
603
- const o = (Array.isArray(e) ? e : [e]).map((a) => Es(a)), i = [];
613
+ const o = (Array.isArray(e) ? e : [e]).map((a) => vs(a)), i = [];
604
614
  for (const a of o)
605
615
  this._lastRenderedData.has(a) || i.push(a);
606
616
  if (i.length === 0)
607
617
  return this._renderFromCache(o);
608
618
  const l = this.pkField;
609
619
  if (i.length < o.length) {
610
- const a = o.filter((p) => this._lastRenderedData.has(p)), c = this._renderFromCache(a), f = this._renderFresh(i, t);
611
- for (const p of f)
620
+ const a = o.filter((p) => this._lastRenderedData.has(p)), c = this._renderFromCache(a), h = this._renderFresh(i, t);
621
+ for (const p of h)
612
622
  p && p[l] != null && this._lastRenderedData.set(p[l], p);
613
- return [...c, ...f];
623
+ return [...c, ...h];
614
624
  } else {
615
625
  const a = this._renderFresh(o, t);
616
626
  for (const c of a)
@@ -634,7 +644,7 @@ class Ts {
634
644
  for (const l of o)
635
645
  l.status !== C.REJECTED && (t || l.status === C.CONFIRMED) && this.applyOperation(l, r);
636
646
  let i = Array.from(r.values());
637
- return e && this.updateCache(i, s), E(e) && this.setCache(i), i;
647
+ return e && this.updateCache(i, s), b(e) && this.setCache(i), i;
638
648
  }
639
649
  async sync(e = null) {
640
650
  const t = this.modelClass.modelName;
@@ -669,7 +679,7 @@ class Ts {
669
679
  }
670
680
  }
671
681
  }
672
- class Ge {
682
+ class Ve {
673
683
  constructor() {
674
684
  this._stores = /* @__PURE__ */ new Map(), this.syncManager = () => {
675
685
  console.warn("SyncManager not set for ModelStoreRegistry");
@@ -688,41 +698,43 @@ class Ge {
688
698
  const t = async ({ pks: s, modelClass: r }) => await r.objects.filter({
689
699
  [`${r.primaryKeyField}__in`]: s
690
700
  }).fetch().serialize();
691
- this._stores.set(e, new Ts(e, t, null, null)), this.syncManager.followModel(this, e);
701
+ this._stores.set(e, new Ss(e, t, null, null)), this.syncManager.followModel(this, e);
692
702
  }
693
703
  return this._stores.get(e);
694
704
  }
695
705
  // Get a single entity from the store
696
706
  getEntity(e, t) {
697
- if (E(e) || E(t)) return;
707
+ if (b(e) || b(t)) return;
698
708
  if (t[e.primaryKeyField]) throw new Error("getEntity should be called with a pk not an object");
699
709
  return this.getStore(e).render([t])[0] || null;
700
710
  }
701
711
  // Add or update an entity ground truth in the store, not for operations!
702
712
  setEntity(e, t, s) {
703
- if (E(e) || E(t)) return;
713
+ if (b(e) || b(t)) return;
704
714
  if (t[e.primaryKeyField]) throw new Error("getEntity should be called with a pk not an object");
705
715
  return this.getStore(e).addToGroundTruth([s]), s;
706
716
  }
707
717
  // Batch add or update entities in the store ground truth
708
718
  setEntities(e, t) {
709
- if (E(e) || !t?.length) return;
719
+ if (b(e) || !t?.length) return;
710
720
  this.getStore(e).addToGroundTruth(t);
711
721
  }
712
722
  }
713
- const Q = new Ge(), ie = Ae(), C = {
723
+ const j = new Ve(), ie = Oe(), C = {
714
724
  CREATED: "operation:created",
715
725
  CONFIRMED: "operation:confirmed",
716
726
  REJECTED: "operation:rejected",
717
727
  CLEAR: "clear:all",
718
728
  MUTATED: "operation:mutated"
719
- }, M = {
729
+ }, P = {
720
730
  CREATE: "create",
721
731
  BULK_CREATE: "bulk_create",
722
732
  UPDATE: "update",
723
733
  DELETE: "delete",
724
734
  UPDATE_INSTANCE: "update_instance",
725
735
  DELETE_INSTANCE: "delete_instance",
736
+ GET_OR_CREATE: "get_or_create",
737
+ UPDATE_OR_CREATE: "update_or_create",
726
738
  CHECKPOINT: "checkpoint"
727
739
  };
728
740
  class q {
@@ -743,15 +755,15 @@ class q {
743
755
  throw new Error("Operation data must include a 'type'.");
744
756
  if (!e.instances)
745
757
  throw new Error("Operation data must include 'instances'.");
746
- this.operationId = e.operationId || `op_${G()}`, this.type = e.type, this.status = e.status || C.CREATED, this.queryset = e.queryset, this.args = e.args, this.doNotPropagate = e.doNotPropagate || !1, this.localOnly = e.localOnly || !1;
758
+ this.operationId = e.operationId || `op_${B()}`, this.type = e.type, this.status = e.status || C.CREATED, this.queryset = e.queryset, this.args = e.args, this.doNotPropagate = e.doNotPropagate || !1, this.localOnly = e.localOnly || !1;
747
759
  let s = this.queryset.ModelClass, r = e.instances;
748
- E(r) || (r = Array.isArray(e.instances) ? e.instances : [e.instances]);
760
+ b(r) || (r = Array.isArray(e.instances) ? e.instances : [e.instances]);
749
761
  let o = s.primaryKeyField;
750
- if (r.some((a) => E(a) || typeof a != "object" || !(o in a)))
762
+ if (r.some((a) => b(a) || typeof a != "object" || !(o in a)))
751
763
  throw new Error(`All operation instances must be objects with the '${o}' field`);
752
764
  this.#e = r;
753
765
  const i = r.map((a) => a[o]);
754
- Q.getStore(s).render(i, !0, !1), this.#t = r.map((a) => s.fromPk(a[o]).serialize()), this.timestamp = e.timestamp || Date.now(), !t && (Pe.register(this), ie.emit(C.CREATED, this));
766
+ j.getStore(s).render(i, !0, !1), this.#t = r.map((a) => s.fromPk(a[o]).serialize()), this.timestamp = e.timestamp || Date.now(), !t && (Fe.register(this), ie.emit(C.CREATED, this));
755
767
  }
756
768
  /**
757
769
  * Getter for instances that replaces any temporary PKs with real PKs
@@ -818,7 +830,7 @@ class q {
818
830
  return e.instances && !Array.isArray(e.instances) && (e.instances = [e.instances]), Object.assign(this, e), this.timestamp = Date.now(), ie.emit(C.MUTATED, this), this;
819
831
  }
820
832
  }
821
- class Ms {
833
+ class Ts {
822
834
  constructor() {
823
835
  this._operations = /* @__PURE__ */ new Map(), this._querysetStates = /* @__PURE__ */ new Map();
824
836
  }
@@ -903,9 +915,9 @@ class Ms {
903
915
  return t.length > 0 ? t[t.length - 1] : void 0;
904
916
  }
905
917
  }
906
- const Pe = new Ms(), $s = Ae();
918
+ const Fe = new Ts(), Ms = Oe();
907
919
  function As(n) {
908
- $s.emit("error", n);
920
+ Ms.emit("error", n);
909
921
  }
910
922
  class fe extends Error {
911
923
  /**
@@ -939,7 +951,7 @@ class fe extends Error {
939
951
  return this.message;
940
952
  }
941
953
  }
942
- class Oe extends fe {
954
+ class $e extends fe {
943
955
  /**
944
956
  * Creates a new ValidationError.
945
957
  *
@@ -950,7 +962,7 @@ class Oe extends fe {
950
962
  super("Validation error", "validation_error", e, t), this.name = "ValidationError";
951
963
  }
952
964
  }
953
- class xt extends fe {
965
+ class It extends fe {
954
966
  /**
955
967
  * Creates a new DoesNotExist error.
956
968
  *
@@ -961,7 +973,7 @@ class xt extends fe {
961
973
  super("DoesNotExist", "does_not_exist", e, t), this.name = "DoesNotExist";
962
974
  }
963
975
  }
964
- class ct extends fe {
976
+ class lt extends fe {
965
977
  /**
966
978
  * Creates a new PermissionDenied error.
967
979
  *
@@ -983,7 +995,7 @@ class Os extends fe {
983
995
  super("Multiple objects returned", "multiple_objects_returned", e, t), this.name = "MultipleObjectsReturned";
984
996
  }
985
997
  }
986
- class jt extends fe {
998
+ class Nt extends fe {
987
999
  /**
988
1000
  * Creates a new ConflictError.
989
1001
  *
@@ -994,7 +1006,7 @@ class jt extends fe {
994
1006
  super("Conflict", "conflict", e, t), this.name = "ConflictError";
995
1007
  }
996
1008
  }
997
- class Ps extends fe {
1009
+ class $s extends fe {
998
1010
  /**
999
1011
  * Creates a new ASTValidationError.
1000
1012
  *
@@ -1005,7 +1017,7 @@ class Ps extends fe {
1005
1017
  super("Query syntax error", "ast_validation_error", e, t), this.name = "ASTValidationError";
1006
1018
  }
1007
1019
  }
1008
- class x extends fe {
1020
+ class U extends fe {
1009
1021
  /**
1010
1022
  * Creates a new ConfigError.
1011
1023
  *
@@ -1019,33 +1031,33 @@ class x extends fe {
1019
1031
  function Fs(n) {
1020
1032
  const { status: e, type: t, detail: s } = n;
1021
1033
  if (t === void 0 && s === "Invalid token.")
1022
- return new ct(s, 403);
1034
+ return new lt(s, 403);
1023
1035
  switch (t) {
1024
1036
  // Direct mappings
1025
1037
  case "ValidationError":
1026
- return new Oe(s, e);
1038
+ return new $e(s, e);
1027
1039
  case "NotFound":
1028
- return new xt(s, e);
1040
+ return new It(s, e);
1029
1041
  case "MultipleObjectsReturned":
1030
1042
  return new Os(s, e);
1031
1043
  case "PermissionDenied":
1032
- return new ct(s, e);
1044
+ return new lt(s, e);
1033
1045
  case "ConflictError":
1034
- return new jt(s, e);
1046
+ return new Nt(s, e);
1035
1047
  case "ASTValidationError":
1036
- return new Ps(s, e);
1048
+ return new $s(s, e);
1037
1049
  case "ConfigError":
1038
- return new x(s, e);
1050
+ return new U(s, e);
1039
1051
  // Django error types that map to our error classes
1040
1052
  case "FieldError":
1041
- return new Oe(s, e);
1053
+ return new $e(s, e);
1042
1054
  case "ValueError":
1043
- return new Oe(s, e);
1055
+ return new $e(s, e);
1044
1056
  default:
1045
- return e === 400 ? new Oe(s, e) : e === 403 ? new ct(s, e) : e === 404 ? new xt(s, e) : e === 409 ? new jt(s, e) : new fe("Unknown error", "unknown", s, e);
1057
+ return e === 400 ? new $e(s, e) : e === 403 ? new lt(s, e) : e === 404 ? new It(s, e) : e === 409 ? new Nt(s, e) : new fe("Unknown error", "unknown", s, e);
1046
1058
  }
1047
1059
  }
1048
- const Ut = {
1060
+ const xt = {
1049
1061
  CREATE: "create",
1050
1062
  UPDATE: "update",
1051
1063
  DELETE: "delete",
@@ -1053,7 +1065,7 @@ const Ut = {
1053
1065
  BULK_UPDATE: "bulk_update",
1054
1066
  BULK_DELETE: "bulk_delete"
1055
1067
  };
1056
- class Is {
1068
+ class Ps {
1057
1069
  /**
1058
1070
  * @param {PusherReceiverOptions} options
1059
1071
  * @param {string} configKey - The backend configuration key
@@ -1063,7 +1075,7 @@ class Is {
1063
1075
  this.configKey = t, this.connectionTimeoutId = null, s.appKey && /^\d+$/.test(s.appKey) && s.appKey.length < 15 && console.warn(
1064
1076
  `%c[Pusher Warning] The provided appKey ("${s.appKey}") looks like a numeric app_id. Pusher requires the alphanumeric key, not the ID. Please verify your configuration for backend: "${this.configKey}".`,
1065
1077
  "color: orange; font-weight: bold; font-size: 14px;"
1066
- ), this.pusherClient = new gs(s.appKey, {
1078
+ ), this.pusherClient = new ys(s.appKey, {
1067
1079
  cluster: s.cluster,
1068
1080
  forceTLS: s.forceTLS ?? !0,
1069
1081
  authEndpoint: s.authEndpoint,
@@ -1143,7 +1155,7 @@ Common causes:
1143
1155
  `%cAuthentication failed for channel ${t}. Check your authEndpoint and server-side permissions.`,
1144
1156
  "color: orange; font-weight: bold;"
1145
1157
  );
1146
- }), Object.values(Ut).forEach((r) => {
1158
+ }), Object.values(xt).forEach((r) => {
1147
1159
  s.bind(r, (o) => {
1148
1160
  const i = {
1149
1161
  ...o,
@@ -1158,7 +1170,7 @@ Common causes:
1158
1170
  unsubscribe(e) {
1159
1171
  const t = this.channels.get(e);
1160
1172
  if (!t) return;
1161
- Object.values(Ut).forEach((r) => {
1173
+ Object.values(xt).forEach((r) => {
1162
1174
  t.unbind(r);
1163
1175
  });
1164
1176
  const s = e.startsWith("private-") ? e : this.formatChannelName(e);
@@ -1200,67 +1212,67 @@ Common causes:
1200
1212
  return this.namespaceResolver(e);
1201
1213
  }
1202
1214
  }
1203
- const Ze = /* @__PURE__ */ new Map();
1215
+ const We = /* @__PURE__ */ new Map();
1204
1216
  function Ds(n, e) {
1205
- const t = Ze.get(n);
1206
- t && t.disconnect(), Ze.set(n, e), e.connect();
1217
+ const t = We.get(n);
1218
+ t && t.disconnect(), We.set(n, e), e.connect();
1207
1219
  }
1208
- function Qt(n = "default") {
1209
- return Ze.get(n);
1220
+ function jt(n = "default") {
1221
+ return We.get(n);
1210
1222
  }
1211
1223
  function zs() {
1212
- return Ze;
1224
+ return We;
1213
1225
  }
1214
- let Vt = {
1226
+ let Ut = {
1215
1227
  backendConfigs: {}
1216
1228
  };
1217
- const Ks = P.object({
1218
- clientOptions: P.object({
1219
- appKey: P.string({ required_error: "Pusher appKey is required" }),
1220
- cluster: P.string({ required_error: "Pusher cluster is required" }),
1221
- forceTLS: P.boolean().optional(),
1222
- authEndpoint: P.string().url("Pusher authentication endpoint URL is required"),
1223
- getAuthHeaders: P.function().optional().refine(
1229
+ const Rs = $.object({
1230
+ clientOptions: $.object({
1231
+ appKey: $.string({ required_error: "Pusher appKey is required" }),
1232
+ cluster: $.string({ required_error: "Pusher cluster is required" }),
1233
+ forceTLS: $.boolean().optional(),
1234
+ authEndpoint: $.string().url("Pusher authentication endpoint URL is required"),
1235
+ getAuthHeaders: $.function().optional().refine(
1224
1236
  (n) => n === void 0 || typeof n == "function",
1225
1237
  "getAuthHeaders must be a function if provided"
1226
1238
  )
1227
1239
  })
1228
- }), Rs = P.object({
1229
- type: P.enum(["websocket", "pusher", "none"]),
1230
- websocketUrl: P.string().url().optional(),
1231
- pusher: Ks.optional(),
1232
- hotpaths: P.array(P.string()).default(["default"])
1240
+ }), Ks = $.object({
1241
+ type: $.enum(["websocket", "pusher", "none"]),
1242
+ websocketUrl: $.string().url().optional(),
1243
+ pusher: Rs.optional(),
1244
+ hotpaths: $.array($.string()).default(["default"])
1233
1245
  }).superRefine((n, e) => {
1234
1246
  n.type === "websocket" && (n.websocketUrl || e.addIssue({
1235
- code: P.ZodIssueCode.custom,
1247
+ code: $.ZodIssueCode.custom,
1236
1248
  path: ["websocketUrl"],
1237
1249
  message: "WebSocket URL is required for WebSocket event receiver"
1238
1250
  })), n.type === "pusher" && (n.pusher || e.addIssue({
1239
- code: P.ZodIssueCode.custom,
1251
+ code: $.ZodIssueCode.custom,
1240
1252
  path: ["pusher"],
1241
1253
  message: "Pusher configuration is required for Pusher event receiver"
1242
1254
  }));
1243
- }), Be = P.object({
1244
- API_URL: P.string().url("API_URL must be a valid URL"),
1245
- GENERATED_TYPES_DIR: P.string({
1255
+ }), Be = $.object({
1256
+ API_URL: $.string().url("API_URL must be a valid URL"),
1257
+ GENERATED_TYPES_DIR: $.string({
1246
1258
  required_error: "GENERATED_TYPES_DIR is required"
1247
1259
  }),
1248
- GENERATED_ACTIONS_DIR: P.string().optional(),
1249
- BACKEND_TZ: P.string().optional(),
1250
- SYNC_TOKEN: P.string().optional(),
1251
- fileRootURL: P.string().url("fileRootURL must be a valid URL").optional(),
1252
- fileUploadMode: P.enum(["server", "s3"]).default("server"),
1253
- getAuthHeaders: P.function().optional().refine(
1260
+ GENERATED_ACTIONS_DIR: $.string().optional(),
1261
+ BACKEND_TZ: $.string().optional(),
1262
+ SYNC_TOKEN: $.string().optional(),
1263
+ fileRootURL: $.string().url("fileRootURL must be a valid URL").optional(),
1264
+ fileUploadMode: $.enum(["server", "s3"]).default("server"),
1265
+ getAuthHeaders: $.function().optional().refine(
1254
1266
  (n) => n === void 0 || typeof n == "function",
1255
1267
  "getAuthHeaders must be a function if provided"
1256
1268
  ),
1257
- eventInterceptor: P.function().optional().refine(
1269
+ eventInterceptor: $.function().optional().refine(
1258
1270
  (n) => n === void 0 || typeof n == "function",
1259
1271
  "eventInterceptor must be a function if provided"
1260
1272
  ),
1261
- events: P.lazy(() => Rs.optional())
1262
- }), Ns = P.object({
1263
- backendConfigs: P.record(P.string(), Be).refine(
1273
+ events: $.lazy(() => Ks.optional())
1274
+ }), Is = $.object({
1275
+ backendConfigs: $.record($.string(), Be).refine(
1264
1276
  (n) => {
1265
1277
  for (const [e, t] of Object.entries(n))
1266
1278
  if (!Be.safeParse(t).success)
@@ -1279,43 +1291,43 @@ const Ks = P.object({
1279
1291
  return { message: e.join("; ") };
1280
1292
  }
1281
1293
  ),
1282
- periodicSyncIntervalSeconds: P.number().min(5).nullable().optional().default(null)
1294
+ periodicSyncIntervalSeconds: $.number().min(5).nullable().optional().default(null)
1283
1295
  });
1284
- let ft = null;
1285
- function xs(n) {
1286
- Vt = n;
1287
- const e = Ns.safeParse(Vt);
1296
+ let ht = null;
1297
+ function Ns(n) {
1298
+ Ut = n;
1299
+ const e = Is.safeParse(Ut);
1288
1300
  if (!e.success) {
1289
1301
  const t = e.error.errors.map((s) => s.message);
1290
- throw new x(`Error setting configuration: ${t.join(", ")}`);
1302
+ throw new U(`Error setting configuration: ${t.join(", ")}`);
1291
1303
  }
1292
- ft = e.data;
1304
+ ht = e.data;
1293
1305
  }
1294
1306
  function he() {
1295
- if (!ft)
1296
- throw new x("Configuration not set. Please call setConfig() with a valid configuration.");
1297
- return ft;
1307
+ if (!ht)
1308
+ throw new U("Configuration not set. Please call setConfig() with a valid configuration.");
1309
+ return ht;
1298
1310
  }
1299
- function js(n, e) {
1311
+ function xs(n, e) {
1300
1312
  try {
1301
1313
  const t = he();
1302
1314
  if (!t.backendConfigs[n])
1303
- throw new x(`Backend "${n}" not found in configuration.`);
1315
+ throw new U(`Backend "${n}" not found in configuration.`);
1304
1316
  const s = { ...t.backendConfigs[n], ...e }, r = Be.safeParse(s);
1305
1317
  if (!r.success) {
1306
1318
  const o = r.error.errors.map((i) => i.message);
1307
- throw new x(`Invalid backend configuration: ${o.join(", ")}`);
1319
+ throw new U(`Invalid backend configuration: ${o.join(", ")}`);
1308
1320
  }
1309
1321
  t.backendConfigs[n] = r.data;
1310
1322
  } catch (t) {
1311
- throw t instanceof x ? t : new x(t.message || "Invalid backend configuration");
1323
+ throw t instanceof U ? t : new U(t.message || "Invalid backend configuration");
1312
1324
  }
1313
1325
  }
1314
- function es(n = "default") {
1326
+ function Yt(n = "default") {
1315
1327
  try {
1316
1328
  const e = he();
1317
1329
  if (!e.backendConfigs[n])
1318
- throw new x(`Backend "${n}" not found in configuration.`);
1330
+ throw new U(`Backend "${n}" not found in configuration.`);
1319
1331
  const t = e.backendConfigs[n];
1320
1332
  if (!t.events)
1321
1333
  return null;
@@ -1323,9 +1335,9 @@ function es(n = "default") {
1323
1335
  switch (t.events.type) {
1324
1336
  case "pusher":
1325
1337
  if (!t.events.pusher || !t.events.pusher.clientOptions)
1326
- throw new x("Pusher client options are required for Pusher event receiver.");
1338
+ throw new U("Pusher client options are required for Pusher event receiver.");
1327
1339
  if (!t.events.pusher.clientOptions.authEndpoint)
1328
- throw new x("Pusher auth endpoint is required for Pusher event receiver.");
1340
+ throw new U("Pusher auth endpoint is required for Pusher event receiver.");
1329
1341
  const r = t.events.pusher.clientOptions.getAuthHeaders || t.getAuthHeaders, o = t.SYNC_TOKEN, i = () => {
1330
1342
  const a = r ? r() : {};
1331
1343
  return o ? { ...a, "X-StateZero-Sync-Token": o } : a;
@@ -1333,68 +1345,68 @@ function es(n = "default") {
1333
1345
  ...t.events.pusher.clientOptions,
1334
1346
  getAuthHeaders: i
1335
1347
  };
1336
- s = new Is({ clientOptions: l }, n);
1348
+ s = new Ps({ clientOptions: l }, n);
1337
1349
  break;
1338
1350
  case "none":
1339
1351
  return null;
1340
1352
  default:
1341
- throw new x(`Unknown event receiver type: ${t.events.type}`);
1353
+ throw new U(`Unknown event receiver type: ${t.events.type}`);
1342
1354
  }
1343
1355
  return s && Ds(n, s), s;
1344
1356
  } catch (e) {
1345
- throw e instanceof x ? e : new x(`Failed to initialize event receiver: ${e.message}`);
1357
+ throw e instanceof U ? e : new U(`Failed to initialize event receiver: ${e.message}`);
1346
1358
  }
1347
1359
  }
1348
- function Us() {
1360
+ function js() {
1349
1361
  try {
1350
1362
  const n = he(), e = {};
1351
1363
  return Object.keys(n.backendConfigs).forEach((t) => {
1352
1364
  try {
1353
- e[t] = es(t);
1365
+ e[t] = Yt(t);
1354
1366
  } catch (s) {
1355
1367
  console.warn(`Failed to initialize event receiver for backend "${t}": ${s.message}`);
1356
1368
  }
1357
1369
  }), e;
1358
1370
  } catch (n) {
1359
- throw new x(`Failed to initialize event receivers: ${n.message}`);
1371
+ throw new U(`Failed to initialize event receivers: ${n.message}`);
1360
1372
  }
1361
1373
  }
1362
- let pt = null;
1363
- function Qs(n) {
1374
+ let ft = null;
1375
+ function Us(n) {
1364
1376
  if (typeof n != "function")
1365
- throw new x("Provided model getter must be a function.");
1366
- pt = n;
1377
+ throw new U("Provided model getter must be a function.");
1378
+ ft = n;
1367
1379
  }
1368
- function Vs(n, e = "default") {
1380
+ function Qs(n, e = "default") {
1369
1381
  if (n && n.startsWith("http"))
1370
1382
  return n;
1371
1383
  const s = he().backendConfigs[e];
1372
1384
  if (!s)
1373
- throw new x(`Backend "${e}" not found in configuration.`);
1385
+ throw new U(`Backend "${e}" not found in configuration.`);
1374
1386
  return s.fileRootURL ? s.fileRootURL.replace(/\/$/, "") + n : n;
1375
1387
  }
1376
- function ts(n, e) {
1377
- if (!pt)
1378
- throw new x("Model registry not registered. Please call registerModelGetter() with the function from model-registry.js during app initialization.");
1379
- return pt(n, e);
1388
+ function Xt(n, e) {
1389
+ if (!ft)
1390
+ throw new U("Model registry not registered. Please call registerModelGetter() with the function from model-registry.js during app initialization.");
1391
+ return ft(n, e);
1380
1392
  }
1381
- const Ie = {
1382
- setConfig: xs,
1393
+ const De = {
1394
+ setConfig: Ns,
1383
1395
  getConfig: he,
1384
- setBackendConfig: js,
1385
- initializeEventReceiver: es,
1386
- registerModelGetter: Qs,
1387
- getModelClass: ts,
1388
- buildFileUrl: Vs
1389
- }, ss = "__STATEZERO_DEBUG__", X = globalThis[ss] || {
1390
- emitter: Ae(),
1396
+ setBackendConfig: xs,
1397
+ initializeEventReceiver: Yt,
1398
+ registerModelGetter: Us,
1399
+ getModelClass: Xt,
1400
+ buildFileUrl: Qs
1401
+ }, es = "__STATEZERO_DEBUG__", X = globalThis[es] || {
1402
+ emitter: Oe(),
1391
1403
  buffer: [],
1392
1404
  enabled: !0,
1393
1405
  started: !1,
1394
1406
  maxEntries: 500,
1395
1407
  nextId: 1
1396
1408
  };
1397
- globalThis[ss] = X;
1409
+ globalThis[es] = X;
1398
1410
  const Me = X.emitter, ue = X.buffer;
1399
1411
  function Te(n) {
1400
1412
  if (!X.enabled) return;
@@ -1405,26 +1417,26 @@ function Te(n) {
1405
1417
  };
1406
1418
  ue.push(e), ue.length > X.maxEntries && ue.shift(), Me.emit("record", e);
1407
1419
  }
1408
- function B(n) {
1420
+ function G(n) {
1409
1421
  Te(n);
1410
1422
  }
1411
1423
  function Ls(n) {
1412
1424
  return Me.on("record", n), () => Me.off("record", n);
1413
1425
  }
1414
- function Gs(n) {
1426
+ function Vs(n) {
1415
1427
  return Me.on("clear", n), () => Me.off("clear", n);
1416
1428
  }
1417
- function Lt() {
1429
+ function Qt() {
1418
1430
  return ue.slice();
1419
1431
  }
1420
1432
  function Bs() {
1421
1433
  ue.length = 0, Me.emit("clear");
1422
1434
  }
1423
- function Gt(n) {
1435
+ function Lt(n) {
1424
1436
  const e = Number(n);
1425
1437
  !Number.isFinite(e) || e <= 0 || (X.maxEntries = Math.floor(e), ue.length > X.maxEntries && ue.splice(0, ue.length - X.maxEntries));
1426
1438
  }
1427
- function Hs() {
1439
+ function Gs() {
1428
1440
  X.started || (X.started = !0, ie.on(C.CREATED, (n) => {
1429
1441
  Te({
1430
1442
  type: "operation",
@@ -1477,11 +1489,11 @@ function Hs() {
1477
1489
  Te({ type: "operation", subtype: C.CLEAR });
1478
1490
  }));
1479
1491
  }
1480
- const dt = /* @__PURE__ */ new Map();
1481
- function qs(n = "default") {
1482
- return dt.has(n) || dt.set(n, new ms({ concurrency: 1 })), dt.get(n);
1492
+ const ct = /* @__PURE__ */ new Map();
1493
+ function Hs(n = "default") {
1494
+ return ct.has(n) || ct.set(n, new ps({ concurrency: 1 })), ct.get(n);
1483
1495
  }
1484
- function Js(n, e = 3e4) {
1496
+ function qs(n, e = 3e4) {
1485
1497
  return Promise.race([
1486
1498
  n,
1487
1499
  new Promise(
@@ -1493,19 +1505,19 @@ function we(n, e, t, s = null) {
1493
1505
  if (!e) return;
1494
1506
  const r = t.configKey;
1495
1507
  let o = null;
1496
- s && (o = j.getStore(s));
1508
+ s && (o = x.getStore(s));
1497
1509
  try {
1498
1510
  for (const [i, l] of Object.entries(e)) {
1499
- const a = Ie.getModelClass(i, r);
1511
+ const a = De.getModelClass(i, r);
1500
1512
  if (!a)
1501
1513
  throw console.error(
1502
1514
  `Model class not found for ${i} in config ${r}`
1503
1515
  ), new Error(`Model class not found for ${i}`);
1504
1516
  if (o) {
1505
1517
  o.includedPks.has(i) || o.includedPks.set(i, /* @__PURE__ */ new Set());
1506
- const f = o.includedPks.get(i);
1518
+ const h = o.includedPks.get(i);
1507
1519
  for (const p of Object.keys(l))
1508
- f.add(Number(p));
1520
+ h.add(Number(p));
1509
1521
  }
1510
1522
  const c = Object.values(l);
1511
1523
  n.setEntities(a, c);
@@ -1517,8 +1529,8 @@ function we(n, e, t, s = null) {
1517
1529
  ), new Error(`Failed to process included entities: ${i.message}`);
1518
1530
  }
1519
1531
  }
1520
- async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1521
- const { namespace: l = "default", timeout: a } = i, c = n.ModelClass, p = Ie.getConfig().backendConfigs[c.configKey];
1532
+ async function V(n, e, t = {}, s, r = null, o = null, i = {}) {
1533
+ const { namespace: l = "default", timeout: a } = i, c = n.ModelClass, p = De.getConfig().backendConfigs[c.configKey];
1522
1534
  if (!p)
1523
1535
  throw new Error(
1524
1536
  `No backend configuration found for key: ${c.configKey}`
@@ -1539,7 +1551,7 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1539
1551
  }
1540
1552
  }, v = w?.ast?.serializerOptions?.limit, O = w?.ast?.serializerOptions?.overfetch || 10;
1541
1553
  v && O && (w.ast.serializerOptions.limit = v + O);
1542
- const b = [
1554
+ const k = [
1543
1555
  "create",
1544
1556
  "bulk_create",
1545
1557
  "update",
@@ -1548,11 +1560,11 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1548
1560
  "delete_instance",
1549
1561
  "get_or_create",
1550
1562
  "update_or_create"
1551
- ].includes(e), U = `${p.API_URL.replace(/\/+$/, "")}/${c.modelName}/`, N = p.getAuthHeaders ? p.getAuthHeaders() : {}, F = n.semanticKey;
1563
+ ].includes(e), Q = `${p.API_URL.replace(/\/+$/, "")}/${c.modelName}/`, N = p.getAuthHeaders ? p.getAuthHeaders() : {}, F = n.semanticKey;
1552
1564
  s && (N["X-Operation-ID"] = s), o && (N["X-Canonical-ID"] = o);
1553
1565
  const re = async () => {
1554
1566
  try {
1555
- B({
1567
+ G({
1556
1568
  type: "request",
1557
1569
  modelName: c.modelName,
1558
1570
  configKey: c.configKey,
@@ -1560,25 +1572,25 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1560
1572
  operationType: e,
1561
1573
  operationId: s,
1562
1574
  canonicalId: o,
1563
- url: U,
1575
+ url: Q,
1564
1576
  payload: w,
1565
1577
  namespace: l
1566
1578
  });
1567
- let D = await ys.post(U, We(w), { headers: N });
1568
- typeof r == "function" && D?.data && await r(D.data);
1569
- const I = D?.data?.data, K = D?.data?.included, me = Array.isArray(I) ? I.length : I != null ? 1 : 0, Ye = K ? Object.keys(K).length : 0, ye = 100, Ke = Array.isArray(I) && I.length > ye ? I.slice(0, ye) : I, Xe = Array.isArray(I) && I.length > ye;
1570
- let Re = K, Ee = !1;
1579
+ let z = await ms.post(Q, Je(w), { headers: N });
1580
+ typeof r == "function" && z?.data && await r(z.data);
1581
+ const D = z?.data?.data, K = z?.data?.included, me = Array.isArray(D) ? D.length : D != null ? 1 : 0, Ze = K ? Object.keys(K).length : 0, ye = 100, Re = Array.isArray(D) && D.length > ye ? D.slice(0, ye) : D, Ye = Array.isArray(D) && D.length > ye;
1582
+ let Ke = K, ke = !1;
1571
1583
  if (K && typeof K == "object") {
1572
- const Ne = {};
1584
+ const Ie = {};
1573
1585
  let ne = 0;
1574
- for (const [xe, je] of Object.entries(K))
1575
- if (Ne[xe] = je, ne += 1, ne >= ye) {
1576
- Ee = !0;
1586
+ for (const [Ne, xe] of Object.entries(K))
1587
+ if (Ie[Ne] = xe, ne += 1, ne >= ye) {
1588
+ ke = !0;
1577
1589
  break;
1578
1590
  }
1579
- Re = Ee ? Ne : K;
1591
+ Ke = ke ? Ie : K;
1580
1592
  }
1581
- return B({
1593
+ return G({
1582
1594
  type: "response",
1583
1595
  modelName: c.modelName,
1584
1596
  configKey: c.configKey,
@@ -1586,17 +1598,17 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1586
1598
  operationType: e,
1587
1599
  operationId: s,
1588
1600
  canonicalId: o,
1589
- url: U,
1590
- status: D.status,
1601
+ url: Q,
1602
+ status: z.status,
1591
1603
  dataCount: me,
1592
- includedCount: Ye,
1593
- data: Ke,
1594
- included: Re,
1595
- dataTruncated: Xe,
1596
- includedTruncated: Ee
1597
- }), D.data;
1598
- } catch (D) {
1599
- if (B({
1604
+ includedCount: Ze,
1605
+ data: Re,
1606
+ included: Ke,
1607
+ dataTruncated: Ye,
1608
+ includedTruncated: ke
1609
+ }), z.data;
1610
+ } catch (z) {
1611
+ if (G({
1600
1612
  type: "error",
1601
1613
  modelName: c.modelName,
1602
1614
  configKey: c.configKey,
@@ -1604,23 +1616,23 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1604
1616
  operationType: e,
1605
1617
  operationId: s,
1606
1618
  canonicalId: o,
1607
- url: U,
1608
- status: D?.response?.status,
1609
- message: D?.message
1610
- }), D?.code === "ECONNREFUSED") {
1611
- const I = "Connection refused. If you're running tests, start the test server with `python manage.py statezero_testserver`.";
1612
- throw new Error(`${I} (${U})`);
1619
+ url: Q,
1620
+ status: z?.response?.status,
1621
+ message: z?.message
1622
+ }), z?.code === "ECONNREFUSED") {
1623
+ const D = "Connection refused. If you're running tests, start the test server with `python manage.py statezero_testserver`.";
1624
+ throw new Error(`${D} (${Q})`);
1613
1625
  }
1614
- if (D.response && D.response.data) {
1615
- const I = Fs(D.response.data);
1616
- throw Error.captureStackTrace && Error.captureStackTrace(I, L), I;
1626
+ if (z.response && z.response.data) {
1627
+ const D = Fs(z.response.data);
1628
+ throw Error.captureStackTrace && Error.captureStackTrace(D, V), D;
1617
1629
  }
1618
- throw new Error(`API call failed: ${D.message}`);
1630
+ throw new Error(`API call failed: ${z.message}`);
1619
1631
  }
1620
- }, pe = qs(l), ae = b ? pe.add(re) : re();
1621
- return a ? Js(ae, a) : ae;
1632
+ }, pe = Hs(l), ae = k ? pe.add(re) : re();
1633
+ return a ? qs(ae, a) : ae;
1622
1634
  }
1623
- class Bt {
1635
+ class Vt {
1624
1636
  // Supported Django strftime formats and their date-fns equivalents
1625
1637
  static SUPPORTED_FORMATS = {
1626
1638
  "iso-8601": null,
@@ -1674,7 +1686,7 @@ class Bt {
1674
1686
  return c.isValid ? c.toJSDate() : (console.error(`Failed to parse ISO date "${e}":`, c.invalidReason), null);
1675
1687
  }
1676
1688
  const a = this.SUPPORTED_FORMATS[l];
1677
- return _s(e, a, /* @__PURE__ */ new Date());
1689
+ return gs(e, a, /* @__PURE__ */ new Date());
1678
1690
  } catch (a) {
1679
1691
  return console.error(`Failed to parse date "${e}" with format "${l}"`, a), null;
1680
1692
  }
@@ -1706,24 +1718,24 @@ class Bt {
1706
1718
  if (!i || i === "iso-8601")
1707
1719
  return r === "date" ? e.toISOString().slice(0, 10) : e.toISOString();
1708
1720
  const l = this.SUPPORTED_FORMATS[i];
1709
- return ws(e, l);
1721
+ return _s(e, l);
1710
1722
  } catch (l) {
1711
1723
  return console.error(`Failed to format date with format "${i}"`, l), e.toISOString();
1712
1724
  }
1713
1725
  }
1714
1726
  }
1715
- function Ws(n) {
1727
+ function Js(n) {
1716
1728
  if (!n || !n.configKey)
1717
1729
  return "UTC";
1718
- const e = Ie.getConfig();
1730
+ const e = De.getConfig();
1719
1731
  return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
1720
1732
  }
1721
- const Ht = {
1733
+ const Bt = {
1722
1734
  // Store backend snake_case format internally for consistency with API
1723
1735
  toInternal: (n, e = {}) => {
1724
1736
  if (typeof n == "string")
1725
1737
  throw new Error("File field expects a file object, not a string path");
1726
- if (E(n))
1738
+ if (b(n))
1727
1739
  return null;
1728
1740
  if (typeof n != "object" || Array.isArray(n))
1729
1741
  throw new Error(`expected file object, got ${Array.isArray(n) ? "array" : typeof n}`);
@@ -1738,7 +1750,7 @@ const Ht = {
1738
1750
  // Return object with both formats for maximum compatibility
1739
1751
  toLive: (n, e = {}) => {
1740
1752
  if (!n || typeof n != "object") return n;
1741
- const t = e.model?.constructor?.configKey || "default", s = n.file_url ? Ie.buildFileUrl(n.file_url, t) : null;
1753
+ const t = e.model?.constructor?.configKey || "default", s = n.file_url ? De.buildFileUrl(n.file_url, t) : null;
1742
1754
  return {
1743
1755
  // snake_case (backend format)
1744
1756
  file_path: n.file_path,
@@ -1755,23 +1767,23 @@ const Ht = {
1755
1767
  mimeType: n.mime_type
1756
1768
  };
1757
1769
  }
1758
- }, qt = {
1770
+ }, Gt = {
1759
1771
  toInternal: (n, e = {}) => {
1760
- if (E(n) || typeof n == "string") return n;
1772
+ if (b(n) || typeof n == "string") return n;
1761
1773
  if (n instanceof Date) {
1762
1774
  const { model: t, field: s, fieldSchema: r } = e, o = t?.schema || r?.format && {
1763
1775
  properties: { [s]: { format: r.format } }
1764
1776
  };
1765
- return o ? Bt.serializeDate(n, s, o) : n.toISOString();
1777
+ return o ? Vt.serializeDate(n, s, o) : n.toISOString();
1766
1778
  }
1767
1779
  throw new Error(`expected string or Date, got ${typeof n}`);
1768
1780
  },
1769
1781
  toLive: (n, e = {}) => {
1770
- if (E(n) || typeof n != "string") return n;
1782
+ if (b(n) || typeof n != "string") return n;
1771
1783
  const { model: t, field: s } = e;
1772
1784
  if (t?.schema) {
1773
- const r = Ws(t);
1774
- return Bt.parseDate(n, s, t.schema, r);
1785
+ const r = Js(t);
1786
+ return Vt.parseDate(n, s, t.schema, r);
1775
1787
  }
1776
1788
  try {
1777
1789
  return new Date(n);
@@ -1779,9 +1791,9 @@ const Ht = {
1779
1791
  return console.warn(`Failed to parse date: ${n}`), n;
1780
1792
  }
1781
1793
  }
1782
- }, ke = {
1794
+ }, Ee = {
1783
1795
  toInternal: (n, e = {}) => {
1784
- if (E(n)) return n;
1796
+ if (b(n)) return n;
1785
1797
  const t = n.pk || n;
1786
1798
  if (typeof t != "string" && typeof t != "number")
1787
1799
  throw new Error(
@@ -1790,13 +1802,13 @@ const Ht = {
1790
1802
  return t;
1791
1803
  },
1792
1804
  toLive: (n, e = {}) => {
1793
- if (E(n)) return n;
1805
+ if (b(n)) return n;
1794
1806
  const { model: t, field: s } = e;
1795
1807
  return t.relationshipFields.has(s) && n ? t.relationshipFields.get(s).ModelClass().fromPk(n) : n;
1796
1808
  }
1797
- }, Zs = {
1809
+ }, Ws = {
1798
1810
  toInternal: (n, e = {}) => {
1799
- if (E(n)) return n;
1811
+ if (b(n)) return n;
1800
1812
  if (!Array.isArray(n)) throw new Error(`expected array, got ${typeof n}`);
1801
1813
  return n.map((t) => {
1802
1814
  const s = t.pk || t;
@@ -1808,7 +1820,7 @@ const Ht = {
1808
1820
  });
1809
1821
  },
1810
1822
  toLive: (n, e = {}) => {
1811
- if (E(n)) return n;
1823
+ if (b(n)) return n;
1812
1824
  const { model: t, field: s } = e;
1813
1825
  if (t.relationshipFields.has(s) && n) {
1814
1826
  const r = t.relationshipFields.get(s);
@@ -1822,27 +1834,27 @@ const Ht = {
1822
1834
  }
1823
1835
  }, Se = {
1824
1836
  string: {
1825
- "file-path": Ht,
1826
- "image-path": Ht,
1827
- date: qt,
1828
- "date-time": qt,
1829
- "foreign-key": ke,
1830
- "one-to-one": ke
1837
+ "file-path": Bt,
1838
+ "image-path": Bt,
1839
+ date: Gt,
1840
+ "date-time": Gt,
1841
+ "foreign-key": Ee,
1842
+ "one-to-one": Ee
1831
1843
  },
1832
1844
  integer: {
1833
- "foreign-key": ke,
1834
- "one-to-one": ke
1845
+ "foreign-key": Ee,
1846
+ "one-to-one": Ee
1835
1847
  },
1836
1848
  // Add other PK types as needed
1837
1849
  uuid: {
1838
- "foreign-key": ke,
1839
- "one-to-one": ke
1850
+ "foreign-key": Ee,
1851
+ "one-to-one": Ee
1840
1852
  },
1841
1853
  array: {
1842
- "many-to-many": Zs
1854
+ "many-to-many": Ws
1843
1855
  }
1844
1856
  };
1845
- class rs {
1857
+ class ts {
1846
1858
  constructor(e) {
1847
1859
  this.modelClass = e;
1848
1860
  }
@@ -1897,18 +1909,18 @@ class rs {
1897
1909
  return t;
1898
1910
  }
1899
1911
  }
1900
- function Ys(n) {
1912
+ function Zs(n) {
1901
1913
  if (!n || !n.configKey)
1902
1914
  return "UTC";
1903
- const e = Ie.getConfig();
1915
+ const e = De.getConfig();
1904
1916
  return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
1905
1917
  }
1906
- function Xs(n, e, t) {
1918
+ function Ys(n, e, t) {
1907
1919
  if (!t?.schema || !n) return e;
1908
- const s = new rs(t);
1920
+ const s = new ts(t);
1909
1921
  return Array.isArray(e) ? e.map((r) => s.toLiveField(n, r)) : s.toLiveField(n, e);
1910
1922
  }
1911
- function De(n, e, t, s = {}) {
1923
+ function ze(n, e, t, s = {}) {
1912
1924
  const r = n.split("__"), o = [
1913
1925
  "exact",
1914
1926
  "iexact",
@@ -1936,74 +1948,74 @@ function De(n, e, t, s = {}) {
1936
1948
  ], i = ["year", "month", "day", "week_day", "hour", "minute", "second", "date", "time"], l = ["gt", "gte", "lt", "lte", "exact"];
1937
1949
  let a = [], c = [...r];
1938
1950
  if (r.length >= 3) {
1939
- const b = r[r.length - 2], k = r[r.length - 1];
1940
- i.includes(b) && l.includes(k) && (a = [b, k], c = r.slice(0, -2));
1951
+ const k = r[r.length - 2], E = r[r.length - 1];
1952
+ i.includes(k) && l.includes(E) && (a = [k, E], c = r.slice(0, -2));
1941
1953
  }
1942
- let f = null;
1943
- a.length === 0 && r.length > 1 && o.includes(r[r.length - 1]) && (f = r[r.length - 1], c = r.slice(0, -1));
1954
+ let h = null;
1955
+ a.length === 0 && r.length > 1 && o.includes(r[r.length - 1]) && (h = r[r.length - 1], c = r.slice(0, -1));
1944
1956
  let p = t, m = [], y = !1, _ = !1, w = null;
1945
- for (let b = 0; b < c.length; b++) {
1946
- let k = c[b];
1947
- k === "pk" && p && (k = p.primaryKeyField);
1948
- const U = b === c.length - 1;
1949
- if (p && p.relationshipFields && p.relationshipFields instanceof Map && p.relationshipFields.has(k)) {
1950
- const N = p.relationshipFields.get(k), F = N.ModelClass(), re = N.relationshipType;
1951
- if (!U && re === "many-to-many") {
1952
- let ae = c.slice(b + 1).join("__");
1953
- a.length > 0 ? ae += "__" + a.join("__") : f && (ae += "__" + f);
1954
- const D = De(ae, e, F, s), I = m.length > 0 ? m.join(".") + "." + k : k, K = D.requiredPath || D.field, me = `${I}.${K}`;
1957
+ for (let k = 0; k < c.length; k++) {
1958
+ let E = c[k];
1959
+ E === "pk" && p && (E = p.primaryKeyField);
1960
+ const Q = k === c.length - 1;
1961
+ if (p && p.relationshipFields && p.relationshipFields instanceof Map && p.relationshipFields.has(E)) {
1962
+ const N = p.relationshipFields.get(E), F = N.ModelClass(), re = N.relationshipType;
1963
+ if (!Q && re === "many-to-many") {
1964
+ let ae = c.slice(k + 1).join("__");
1965
+ a.length > 0 ? ae += "__" + a.join("__") : h && (ae += "__" + h);
1966
+ const z = ze(ae, e, F, s), D = m.length > 0 ? m.join(".") + "." + E : E, K = z.requiredPath || z.field, me = `${D}.${K}`;
1955
1967
  return {
1956
- field: I,
1957
- operator: { $elemMatch: { [D.field]: D.operator } },
1968
+ field: D,
1969
+ operator: { $elemMatch: { [z.field]: z.operator } },
1958
1970
  isM2M: !0,
1959
1971
  requiredPath: me
1960
1972
  // Full path for data picking
1961
1973
  };
1962
1974
  }
1963
- if (m.push(k), !U)
1975
+ if (m.push(E), !Q)
1964
1976
  p = F;
1965
1977
  else {
1966
1978
  if (y = !0, re === "many-to-many")
1967
- _ = !0, w = k;
1979
+ _ = !0, w = E;
1968
1980
  else {
1969
1981
  const pe = F.primaryKeyField || "id";
1970
1982
  m.push(pe), w = pe;
1971
1983
  }
1972
1984
  p = F;
1973
1985
  }
1974
- } else if (p && p.fields && p.fields.includes(k)) {
1975
- if (m.push(k), w = k, U)
1986
+ } else if (p && p.fields && p.fields.includes(E)) {
1987
+ if (m.push(E), w = E, Q)
1976
1988
  break;
1977
- const N = p.schema?.properties?.[k];
1989
+ const N = p.schema?.properties?.[E];
1978
1990
  if (N && N.format === "json") {
1979
- const F = c.slice(b + 1);
1991
+ const F = c.slice(k + 1);
1980
1992
  m.push(...F);
1981
1993
  break;
1982
1994
  }
1983
- throw new Error(`Field '${k}' in '${n}' is not a relationship field and cannot be traversed.`);
1995
+ throw new Error(`Field '${E}' in '${n}' is not a relationship field and cannot be traversed.`);
1984
1996
  } else
1985
- throw new Error(`Field '${k}' in '${n}' not found in model ${p.modelName}.`);
1997
+ throw new Error(`Field '${E}' in '${n}' not found in model ${p.modelName}.`);
1986
1998
  }
1987
- const v = m.join("."), T = i.includes(f) || a.length === 2 && i.includes(a[0]) ? e : Xs(w, e, p);
1999
+ const v = m.join("."), T = i.includes(h) || a.length === 2 && i.includes(a[0]) ? e : Ys(w, e, p);
1988
2000
  if (a.length === 2) {
1989
- const [b, k] = a;
1990
- return er(v, b, k, T, y);
2001
+ const [k, E] = a;
2002
+ return Xs(v, k, E, T, y);
1991
2003
  }
1992
- if (f)
1993
- return tr(v, f, T, y, p, w, _);
2004
+ if (h)
2005
+ return er(v, h, T, y, p, w, _);
1994
2006
  if (y) {
1995
- let b = T;
1996
- return T && typeof T == "object" && "pk" in T && (b = T.pk), _ ? { field: v, operator: { $elemMatch: { pk: { $eq: b } } }, isM2M: !0 } : { field: v, operator: { $eq: b } };
2007
+ let k = T;
2008
+ return T && typeof T == "object" && "pk" in T && (k = T.pk), _ ? { field: v, operator: { $elemMatch: { pk: { $eq: k } } }, isM2M: !0 } : { field: v, operator: { $eq: k } };
1997
2009
  }
1998
2010
  return { field: v, operator: { $eq: T } };
1999
2011
  }
2000
- function er(n, e, t, s, r) {
2012
+ function Xs(n, e, t, s, r) {
2001
2013
  return r ? (console.warn(`Date part comparison on relationship fields may not work as expected: ${n}`), { field: n, operator: { $eq: s } }) : {
2002
2014
  field: n,
2003
2015
  operator: { [`$${e}_${t}`]: s }
2004
2016
  };
2005
2017
  }
2006
- function tr(n, e, t, s, r, o, i = !1) {
2018
+ function er(n, e, t, s, r, o, i = !1) {
2007
2019
  function l(a) {
2008
2020
  return a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2009
2021
  }
@@ -2016,8 +2028,8 @@ function tr(n, e, t, s, r, o, i = !1) {
2016
2028
  // document-level operator
2017
2029
  requiredPath: n,
2018
2030
  // need the M2M field itself for data picking
2019
- operator: function(f) {
2020
- const p = f[a], m = p === null || Array.isArray(p) && p.length === 0;
2031
+ operator: function(h) {
2032
+ const p = h[a], m = p === null || Array.isArray(p) && p.length === 0;
2021
2033
  return c ? m : !m;
2022
2034
  }
2023
2035
  };
@@ -2058,16 +2070,16 @@ function tr(n, e, t, s, r, o, i = !1) {
2058
2070
  operator: { $regex: new RegExp(`${l(t)}$`, "i") }
2059
2071
  } : e === "in" ? { field: n, operator: { $in: t } } : e === "gt" ? { field: n, operator: { $nin: [null, void 0], $gt: t } } : e === "gte" ? { field: n, operator: { $nin: [null, void 0], $gte: t } } : e === "lt" ? { field: n, operator: { $nin: [null, void 0], $lt: t } } : e === "lte" ? { field: n, operator: { $nin: [null, void 0], $lte: t } } : { field: n, operator: { $eq: t } };
2060
2072
  }
2061
- function sr(n = "UTC", e = null) {
2062
- const t = e ? new rs(e) : null, s = (a, c = null) => a ? a instanceof Date ? a : t && c && typeof a == "string" ? t.toLiveField(c, a) : (console.warn("Date conversion without serializer context:", a), null) : null, r = (a, c, f = null) => {
2063
- const p = s(a, f);
2073
+ function tr(n = "UTC", e = null) {
2074
+ const t = e ? new ts(e) : null, s = (a, c = null) => a ? a instanceof Date ? a : t && c && typeof a == "string" ? t.toLiveField(c, a) : (console.warn("Date conversion without serializer context:", a), null) : null, r = (a, c, h = null) => {
2075
+ const p = s(a, h);
2064
2076
  if (!p || !(p instanceof Date) || isNaN(p.getTime()))
2065
2077
  return null;
2066
2078
  const m = _e.fromJSDate(p).setZone(n);
2067
2079
  return c(m);
2068
2080
  }, o = {
2069
2081
  // Year - same in both
2070
- $year(a, c, f) {
2082
+ $year(a, c, h) {
2071
2083
  const p = typeof a == "string" ? Number(a) : a;
2072
2084
  return ee(
2073
2085
  (m) => {
@@ -2075,11 +2087,11 @@ function sr(n = "UTC", e = null) {
2075
2087
  return y !== null && y === p;
2076
2088
  },
2077
2089
  c,
2078
- f
2090
+ h
2079
2091
  );
2080
2092
  },
2081
2093
  // Month - Luxon is 1-indexed like Django
2082
- $month(a, c, f) {
2094
+ $month(a, c, h) {
2083
2095
  const p = typeof a == "string" ? Number(a) : a;
2084
2096
  return ee(
2085
2097
  (m) => {
@@ -2087,11 +2099,11 @@ function sr(n = "UTC", e = null) {
2087
2099
  return y !== null && y === p;
2088
2100
  },
2089
2101
  c,
2090
- f
2102
+ h
2091
2103
  );
2092
2104
  },
2093
2105
  // Day of month - same in both
2094
- $day(a, c, f) {
2106
+ $day(a, c, h) {
2095
2107
  const p = typeof a == "string" ? Number(a) : a;
2096
2108
  return ee(
2097
2109
  (m) => {
@@ -2099,11 +2111,11 @@ function sr(n = "UTC", e = null) {
2099
2111
  return y !== null && y === p;
2100
2112
  },
2101
2113
  c,
2102
- f
2114
+ h
2103
2115
  );
2104
2116
  },
2105
2117
  // Day of week - convert to Django's 1=Sunday format
2106
- $week_day(a, c, f) {
2118
+ $week_day(a, c, h) {
2107
2119
  const p = typeof a == "string" ? Number(a) : a;
2108
2120
  return ee(
2109
2121
  (m) => {
@@ -2111,11 +2123,11 @@ function sr(n = "UTC", e = null) {
2111
2123
  return y !== null && y === p;
2112
2124
  },
2113
2125
  c,
2114
- f
2126
+ h
2115
2127
  );
2116
2128
  },
2117
2129
  // Hour - same in both
2118
- $hour(a, c, f) {
2130
+ $hour(a, c, h) {
2119
2131
  const p = typeof a == "string" ? Number(a) : a;
2120
2132
  return ee(
2121
2133
  (m) => {
@@ -2123,11 +2135,11 @@ function sr(n = "UTC", e = null) {
2123
2135
  return y !== null && y === p;
2124
2136
  },
2125
2137
  c,
2126
- f
2138
+ h
2127
2139
  );
2128
2140
  },
2129
2141
  // Minute - same in both
2130
- $minute(a, c, f) {
2142
+ $minute(a, c, h) {
2131
2143
  const p = typeof a == "string" ? Number(a) : a;
2132
2144
  return ee(
2133
2145
  (m) => {
@@ -2135,11 +2147,11 @@ function sr(n = "UTC", e = null) {
2135
2147
  return y !== null && y === p;
2136
2148
  },
2137
2149
  c,
2138
- f
2150
+ h
2139
2151
  );
2140
2152
  },
2141
2153
  // Second - same in both
2142
- $second(a, c, f) {
2154
+ $second(a, c, h) {
2143
2155
  const p = typeof a == "string" ? Number(a) : a;
2144
2156
  return ee(
2145
2157
  (m) => {
@@ -2147,11 +2159,11 @@ function sr(n = "UTC", e = null) {
2147
2159
  return y !== null && y === p;
2148
2160
  },
2149
2161
  c,
2150
- f
2162
+ h
2151
2163
  );
2152
2164
  },
2153
2165
  // Date - extract date portion (ignore time)
2154
- $date(a, c, f) {
2166
+ $date(a, c, h) {
2155
2167
  return ee(
2156
2168
  (p, m) => {
2157
2169
  const y = s(p, m);
@@ -2163,11 +2175,11 @@ function sr(n = "UTC", e = null) {
2163
2175
  return w.year === v.year && w.month === v.month && w.day === v.day;
2164
2176
  },
2165
2177
  c,
2166
- f
2178
+ h
2167
2179
  );
2168
2180
  },
2169
2181
  // Time - extract time portion (ignore date)
2170
- $time(a, c, f) {
2182
+ $time(a, c, h) {
2171
2183
  return ee(
2172
2184
  (p, m) => {
2173
2185
  const y = s(p, m);
@@ -2181,13 +2193,13 @@ function sr(n = "UTC", e = null) {
2181
2193
  } else {
2182
2194
  const T = s(a, m);
2183
2195
  if (!T) return !1;
2184
- const b = _e.fromJSDate(T).setZone(n);
2185
- w = b.hour, v = b.minute, O = b.second;
2196
+ const k = _e.fromJSDate(T).setZone(n);
2197
+ w = k.hour, v = k.minute, O = k.second;
2186
2198
  }
2187
2199
  return _.hour === w && _.minute === v && _.second === O;
2188
2200
  },
2189
2201
  c,
2190
- f
2202
+ h
2191
2203
  );
2192
2204
  }
2193
2205
  }, i = {
@@ -2205,24 +2217,24 @@ function sr(n = "UTC", e = null) {
2205
2217
  }, l = ["gt", "gte", "lt", "lte", "exact"];
2206
2218
  return Object.keys(i).forEach((a) => {
2207
2219
  const c = i[a];
2208
- l.forEach((f) => {
2209
- o[`$${a}_${f}`] = (p, m, y) => ee(
2220
+ l.forEach((h) => {
2221
+ o[`$${a}_${h}`] = (p, m, y) => ee(
2210
2222
  (_, w) => {
2211
2223
  const v = s(_, w);
2212
2224
  if (!v || !(v instanceof Date) || isNaN(v.getTime()))
2213
2225
  return !1;
2214
- const O = _e.fromJSDate(v).setZone(n), T = c(O), b = a === "date" ? p : typeof p == "string" ? Number(p) : p;
2215
- switch (f) {
2226
+ const O = _e.fromJSDate(v).setZone(n), T = c(O), k = a === "date" ? p : typeof p == "string" ? Number(p) : p;
2227
+ switch (h) {
2216
2228
  case "gt":
2217
- return T > b;
2229
+ return T > k;
2218
2230
  case "gte":
2219
- return T >= b;
2231
+ return T >= k;
2220
2232
  case "lt":
2221
- return T < b;
2233
+ return T < k;
2222
2234
  case "lte":
2223
- return T <= b;
2235
+ return T <= k;
2224
2236
  case "exact":
2225
- return T === b;
2237
+ return T === k;
2226
2238
  default:
2227
2239
  return !1;
2228
2240
  }
@@ -2233,20 +2245,20 @@ function sr(n = "UTC", e = null) {
2233
2245
  });
2234
2246
  }), o;
2235
2247
  }
2236
- function rr(n, e) {
2237
- const t = Ys(e);
2238
- return Yt(n, {
2239
- operations: sr(t, e)
2248
+ function sr(n, e) {
2249
+ const t = Zs(e);
2250
+ return Wt(n, {
2251
+ operations: tr(t, e)
2240
2252
  });
2241
2253
  }
2242
- function mt(n, e) {
2254
+ function pt(n, e) {
2243
2255
  const t = {}, s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
2244
2256
  for (const [o, i] of Object.entries(n))
2245
2257
  try {
2246
- const l = De(o, i, e), { field: a, operator: c, isDatePart: f, isM2M: p } = l;
2247
- f ? (s.has(a) || s.set(a, []), s.get(a).push({ [a]: c })) : p && c.$elemMatch ? (r.has(a) || r.set(a, []), r.get(a).push(c.$elemMatch)) : t[a] ? t[a] = { ...t[a], ...c } : t[a] = c;
2258
+ const l = ze(o, i, e), { field: a, operator: c, isDatePart: h, isM2M: p } = l;
2259
+ h ? (s.has(a) || s.set(a, []), s.get(a).push({ [a]: c })) : p && c.$elemMatch ? (r.has(a) || r.set(a, []), r.get(a).push(c.$elemMatch)) : t[a] ? t[a] = { ...t[a], ...c } : t[a] = c;
2248
2260
  } catch (l) {
2249
- throw new Oe(`Failed to process field '${o}': ${l.message}`);
2261
+ throw new $e(`Failed to process field '${o}': ${l.message}`);
2250
2262
  }
2251
2263
  for (const [o, i] of r.entries())
2252
2264
  i.length === 1 ? t[o] = { $elemMatch: i[0] } : t[o] = { $elemMatch: { $and: i } };
@@ -2267,38 +2279,38 @@ function mt(n, e) {
2267
2279
  }
2268
2280
  return t;
2269
2281
  }
2270
- function nr(n, e) {
2282
+ function rr(n, e) {
2271
2283
  return !n || !n.length ? null : {
2272
- $or: n.map((t) => "operator" in t && "conditions" in t ? { [t.operator === "AND" ? "$and" : "$or"]: t.conditions.map((r) => mt(r, e)) } : mt(t, e))
2284
+ $or: n.map((t) => "operator" in t && "conditions" in t ? { [t.operator === "AND" ? "$and" : "$or"]: t.conditions.map((r) => pt(r, e)) } : pt(t, e))
2273
2285
  };
2274
2286
  }
2275
- function He(n, e) {
2287
+ function Ge(n, e) {
2276
2288
  if (!n) return null;
2277
2289
  if (n.type === "filter") {
2278
2290
  const { conditions: t, Q: s } = n;
2279
2291
  let r = {};
2280
- if (t && Object.keys(t).length > 0 && (r = mt(t, e)), s && s.length > 0) {
2281
- const o = nr(s, e);
2292
+ if (t && Object.keys(t).length > 0 && (r = pt(t, e)), s && s.length > 0) {
2293
+ const o = rr(s, e);
2282
2294
  if (o)
2283
2295
  return Object.keys(r).length > 0 ? { $and: [r, o] } : o;
2284
2296
  }
2285
2297
  return r;
2286
2298
  }
2287
2299
  if (n.type === "and" && n.children) {
2288
- const t = n.children.map((s) => He(s, e)).filter((s) => s != null);
2300
+ const t = n.children.map((s) => Ge(s, e)).filter((s) => s != null);
2289
2301
  return t.length === 0 ? null : t.length === 1 ? t[0] : { $and: t };
2290
2302
  }
2291
2303
  if (n.type === "or" && n.children) {
2292
- const t = n.children.map((s) => He(s, e)).filter((s) => s != null);
2304
+ const t = n.children.map((s) => Ge(s, e)).filter((s) => s != null);
2293
2305
  return t.length === 0 ? null : t.length === 1 ? t[0] : { $or: t };
2294
2306
  }
2295
2307
  if (n.type === "exclude" && n.child) {
2296
- const t = He(n.child, e);
2308
+ const t = Ge(n.child, e);
2297
2309
  return t ? { $not: t } : null;
2298
2310
  }
2299
2311
  return null;
2300
2312
  }
2301
- function or(n, e, t) {
2313
+ function nr(n, e, t) {
2302
2314
  if (!e || !e.searchQuery) return n;
2303
2315
  const s = e.searchFields || (n[0] ? Object.keys(n[0]).filter((i) => typeof n[0][i] == "string") : []);
2304
2316
  if (!s.length) return n;
@@ -2307,7 +2319,7 @@ function or(n, e, t) {
2307
2319
  }
2308
2320
  const o = s.map((i) => {
2309
2321
  try {
2310
- const { field: l } = De(i, "", t);
2322
+ const { field: l } = ze(i, "", t);
2311
2323
  return {
2312
2324
  [l]: {
2313
2325
  $regex: new RegExp(r(e.searchQuery), "i")
@@ -2321,9 +2333,9 @@ function or(n, e, t) {
2321
2333
  };
2322
2334
  }
2323
2335
  });
2324
- return n.filter(Yt({ $or: o }));
2336
+ return n.filter(Wt({ $or: o }));
2325
2337
  }
2326
- function Jt(n, e) {
2338
+ function Ht(n, e) {
2327
2339
  const t = e.split(".");
2328
2340
  let s = n;
2329
2341
  for (const r of t) {
@@ -2333,11 +2345,11 @@ function Jt(n, e) {
2333
2345
  }
2334
2346
  return s;
2335
2347
  }
2336
- function ir(n, e) {
2348
+ function or(n, e) {
2337
2349
  return n.map((t) => {
2338
2350
  const s = t.startsWith("-"), r = s ? t.substring(1) : t;
2339
2351
  try {
2340
- const { field: o } = De(r, "", e);
2352
+ const { field: o } = ze(r, "", e);
2341
2353
  return {
2342
2354
  field: o,
2343
2355
  desc: s
@@ -2350,12 +2362,12 @@ function ir(n, e) {
2350
2362
  }
2351
2363
  });
2352
2364
  }
2353
- function ar(n, e, t) {
2365
+ function ir(n, e, t) {
2354
2366
  if (!e || !e.length) return [...n];
2355
- const s = ir(e, t);
2367
+ const s = or(e, t);
2356
2368
  return [...n].sort((r, o) => {
2357
2369
  for (const { field: i, desc: l } of s) {
2358
- const a = Jt(r, i), c = Jt(o, i);
2370
+ const a = Ht(r, i), c = Ht(o, i);
2359
2371
  if (a !== c) {
2360
2372
  if (a === null && c !== null) return l ? -1 : 1;
2361
2373
  if (a !== null && c === null) return l ? 1 : -1;
@@ -2368,7 +2380,7 @@ function ar(n, e, t) {
2368
2380
  return 0;
2369
2381
  });
2370
2382
  }
2371
- function yt(n, e, t) {
2383
+ function mt(n, e, t) {
2372
2384
  if (!Array.isArray(n) || n.length === 0)
2373
2385
  return [];
2374
2386
  if (!t)
@@ -2376,19 +2388,19 @@ function yt(n, e, t) {
2376
2388
  const s = t.primaryKeyField;
2377
2389
  let r = [...n];
2378
2390
  if (e.filter) {
2379
- const o = He(e.filter, t);
2380
- o && Object.keys(o).length && (r = r.filter(rr(o, t)));
2391
+ const o = Ge(e.filter, t);
2392
+ o && Object.keys(o).length && (r = r.filter(sr(o, t)));
2381
2393
  }
2382
- return e.search && e.search.searchQuery && (r = or(r, e.search, t)), Array.isArray(e.orderBy) && e.orderBy.length && (r = ar(r, e.orderBy, t)), r.map((o) => o[s]);
2394
+ return e.search && e.search.searchQuery && (r = nr(r, e.search, t)), Array.isArray(e.orderBy) && e.orderBy.length && (r = ir(r, e.orderBy, t)), r.map((o) => o[s]);
2383
2395
  }
2384
- function gt(n, e) {
2396
+ function yt(n, e) {
2385
2397
  const t = /* @__PURE__ */ new Set(), s = e.primaryKeyField;
2386
2398
  t.add(s);
2387
2399
  function r(i) {
2388
2400
  try {
2389
- const { field: l, isM2M: a, requiredPath: c } = De(i, null, e);
2390
- let f;
2391
- c ? f = c : a ? f = `${l}.pk` : f = l, t.add(f);
2401
+ const { field: l, isM2M: a, requiredPath: c } = ze(i, null, e);
2402
+ let h;
2403
+ c ? h = c : a ? h = `${l}.pk` : h = l, t.add(h);
2392
2404
  } catch (l) {
2393
2405
  console.warn(`getRequiredFields: couldn't process "${i}": ${l.message}`);
2394
2406
  }
@@ -2414,36 +2426,36 @@ function gt(n, e) {
2414
2426
  r(i.replace(/^-/, ""));
2415
2427
  }), Array.from(t);
2416
2428
  }
2417
- function _t(n, e, t) {
2429
+ function gt(n, e, t) {
2418
2430
  if (e == null || t.length === 0)
2419
2431
  return;
2420
2432
  const [s, ...r] = t, o = e[s];
2421
2433
  o !== void 0 && (r.length === 0 ? n[s] = o : Array.isArray(o) ? (s in n || (n[s] = []), o.forEach((i, l) => {
2422
- n[s][l] === void 0 && (n[s][l] = {}), _t(n[s][l], i, r);
2423
- })) : typeof o == "object" && (s in n || (n[s] = {}), _t(n[s], o, r)));
2434
+ n[s][l] === void 0 && (n[s][l] = {}), gt(n[s][l], i, r);
2435
+ })) : typeof o == "object" && (s in n || (n[s] = {}), gt(n[s], o, r)));
2424
2436
  }
2425
- function wt(n, e) {
2437
+ function _t(n, e) {
2426
2438
  const t = {};
2427
2439
  return n.forEach((s) => {
2428
2440
  const r = s.split(".");
2429
- _t(t, e, r);
2441
+ gt(t, e, r);
2430
2442
  }), t;
2431
2443
  }
2432
- function Ct(n, e, t, s = !1) {
2444
+ function ss(n, e, t, s = !1) {
2433
2445
  if (!Array.isArray(n) || n.length === 0)
2434
2446
  return [];
2435
2447
  if (!t)
2436
2448
  throw new Error("ModelClass is required for proper relationship traversal");
2437
2449
  const r = t.primaryKeyField || "id";
2438
- let o = gt(e, t), i = n.map((a) => wt(o, a));
2439
- const l = yt(i, e, t);
2450
+ let o = yt(e, t), i = n.map((a) => _t(o, a));
2451
+ const l = mt(i, e, t);
2440
2452
  if (s) {
2441
2453
  const a = new Map(n.map((c) => [c[r], c]));
2442
2454
  return l.map((c) => a.get(c));
2443
2455
  }
2444
2456
  return l;
2445
2457
  }
2446
- class lr {
2458
+ class ar {
2447
2459
  modelClass;
2448
2460
  fetchFn;
2449
2461
  queryset;
@@ -2452,13 +2464,13 @@ class lr {
2452
2464
  groundTruthPks;
2453
2465
  isSyncing;
2454
2466
  constructor(e, t, s, r = null, o = null, i = {}) {
2455
- if (this.modelClass = e, this.fetchFn = t, this.queryset = s, this.isSyncing = !1, this.lastSync = null, this.isTemp = i.isTemp || !1, this.pruneThreshold = i.pruneThreshold || 10, this.groundTruthPks = r || [], this.operationsMap = /* @__PURE__ */ new Map(), this.includedPks = /* @__PURE__ */ new Map(), Array.isArray(o))
2467
+ if (this.modelClass = e, this.fetchFn = t, this.queryset = s, this.isSyncing = !1, this.lastSync = null, this._createdAt = Date.now(), this.isTemp = i.isTemp || !1, this.pruneThreshold = i.pruneThreshold || 10, this.groundTruthPks = r || [], this.operationsMap = /* @__PURE__ */ new Map(), this.includedPks = /* @__PURE__ */ new Map(), Array.isArray(o))
2456
2468
  for (const l of o) {
2457
- const c = Pe.get(l.operationId) || new q(l, !0);
2469
+ const c = Fe.get(l.operationId) || new q(l, !0);
2458
2470
  this.operationsMap.set(c.operationId, c);
2459
2471
  }
2460
- if (this.qsCache = new Et("queryset-cache", {}, this.onHydrated.bind(this)), this._lastRenderedPks = null, this.renderCallbacks = /* @__PURE__ */ new Set(), !this.isTemp) {
2461
- const l = Q.getStore(this.modelClass);
2472
+ if (this.qsCache = new Ct("queryset-cache", {}, this.onHydrated.bind(this)), this._lastRenderedPks = null, this.renderCallbacks = /* @__PURE__ */ new Set(), !this.isTemp) {
2473
+ const l = j.getStore(this.modelClass);
2462
2474
  this._modelStoreUnregister = l.registerRenderCallback(() => {
2463
2475
  this._emitRenderEvent();
2464
2476
  });
@@ -2471,12 +2483,12 @@ class lr {
2471
2483
  onHydrated(e) {
2472
2484
  if (this.lastSync !== null || this.groundTruthPks.length > 0 || this.operationsMap.size > 0) return;
2473
2485
  const t = this.qsCache.get(this.cacheKey);
2474
- !E(t) && !ve(t) && (this.groundTruthPks = Array.isArray(t) ? t : [], this._emitRenderEvent());
2486
+ !b(t) && !ve(t) && (this.groundTruthPks = Array.isArray(t) ? t : [], this._emitRenderEvent());
2475
2487
  }
2476
2488
  setCache(e) {
2477
2489
  let t = [];
2478
2490
  e.forEach((s) => {
2479
- typeof s == "string" && Je(s) && (s = We(s), E(s) || ve(ut(s))) || t.push(s);
2491
+ typeof s == "string" && qe(s) && (s = Je(s), b(s) || ve(dt(s))) || t.push(s);
2480
2492
  }), this.qsCache.set(this.cacheKey, t);
2481
2493
  }
2482
2494
  clearCache() {
@@ -2500,7 +2512,7 @@ class lr {
2500
2512
  } catch (s) {
2501
2513
  console.warn("Error in render callback:", s);
2502
2514
  }
2503
- }), qe(e, this._lastRenderedPks) || (this._lastRenderedPks = e, ks.emit(
2515
+ }), He(e, this._lastRenderedPks) || (this._lastRenderedPks = e, bs.emit(
2504
2516
  `${this.modelClass.configKey}::${this.modelClass.modelName}::queryset::render`,
2505
2517
  { ast: this.queryset.build(), ModelClass: this.modelClass }
2506
2518
  ));
@@ -2555,7 +2567,7 @@ class lr {
2555
2567
  */
2556
2568
  registerWithModelStore() {
2557
2569
  if (this._modelStoreUnregister) return;
2558
- const e = Q.getStore(this.modelClass);
2570
+ const e = j.getStore(this.modelClass);
2559
2571
  this._modelStoreUnregister = e.registerRenderCallback(() => {
2560
2572
  this._emitRenderEvent();
2561
2573
  });
@@ -2567,15 +2579,39 @@ class lr {
2567
2579
  */
2568
2580
  _getValidatedAndFilteredPks(e) {
2569
2581
  const t = Array.from(e).map((o) => this.modelClass.fromPk(o, this.queryset)).filter(
2570
- (o) => Q.getEntity(this.modelClass, o.pk) !== null
2582
+ (o) => j.getEntity(this.modelClass, o.pk) !== null
2571
2583
  ), s = this.queryset.build();
2572
- return Ct(t, s, this.modelClass, !1);
2584
+ return ss(t, s, this.modelClass, !1);
2585
+ }
2586
+ /**
2587
+ * For offset pages that aren't full, expand with creates from the model store
2588
+ * that sort after the first item on the page (direction-adjusted).
2589
+ */
2590
+ _fillOffsetPage(e, t) {
2591
+ const s = j.getStore(this.modelClass);
2592
+ if (!s) return null;
2593
+ const r = this.queryset._orderBy;
2594
+ if (!r || r.length === 0) return null;
2595
+ const o = r[0].replace(/^-/, ""), i = r[0].startsWith("-"), l = this.modelClass.fromPk(e[0], this.queryset);
2596
+ if (!l) return null;
2597
+ const a = l[o];
2598
+ if (a == null) return null;
2599
+ const c = this.pkField, h = new Set(e), p = new Set(e);
2600
+ for (const m of s.operations)
2601
+ if (m.status !== C.REJECTED && !(!t && m.status !== C.CONFIRMED) && !(m.type !== P.CREATE && m.type !== P.BULK_CREATE && m.type !== P.GET_OR_CREATE && m.type !== P.UPDATE_OR_CREATE))
2602
+ for (const y of m.instances) {
2603
+ if (!y || y[c] == null || h.has(y[c])) continue;
2604
+ const _ = y[o];
2605
+ if (_ == null) continue;
2606
+ (i ? _ <= a : _ >= a) && p.add(y[c]);
2607
+ }
2608
+ return p.size === h.size ? null : this._getValidatedAndFilteredPks(Array.from(p));
2573
2609
  }
2574
2610
  render(e = !0, t = !1) {
2575
2611
  if (t) {
2576
- const c = this.qsCache.get(this.cacheKey);
2577
- if (Array.isArray(c))
2578
- return B({
2612
+ const a = this.qsCache.get(this.cacheKey);
2613
+ if (Array.isArray(a))
2614
+ return G({
2579
2615
  type: "render",
2580
2616
  source: "cache",
2581
2617
  semanticKey: this.queryset.semanticKey,
@@ -2584,40 +2620,70 @@ class lr {
2584
2620
  optimistic: e,
2585
2621
  groundTruthCount: this.groundTruthPks.length,
2586
2622
  operationsCount: this.operationsMap.size,
2587
- resultCount: c.length
2588
- }), c;
2623
+ resultCount: a.length
2624
+ }), a;
2589
2625
  }
2590
- const s = this.queryset.build().serializerOptions?.offset, o = this.groundTruthPks.length === 0 && this.lastSync === null && !(s != null && s > 0) ? this.renderFromModelStore() : this.renderFromData(e);
2591
- let i = this._getValidatedAndFilteredPks(o);
2592
- const l = i.length, a = this.queryset.build().serializerOptions?.limit;
2593
- return a && (i = i.slice(0, a)), this.setCache(i), B({
2626
+ const s = this.renderFromData(e);
2627
+ let r = this._getValidatedAndFilteredPks(s);
2628
+ const o = r.length, i = this.queryset.build().serializerOptions?.limit;
2629
+ if ((this.queryset._serializerOptions?.offset ?? 0) > 0 && i && r.length > 0 && r.length < i) {
2630
+ const a = this._fillOffsetPage(r, e);
2631
+ a && (r = a);
2632
+ }
2633
+ return i && (r = r.slice(0, i)), this.setCache(r), G({
2594
2634
  type: "render",
2595
- source: this.groundTruthPks.length === 0 && this.lastSync === null ? "modelStore" : "groundTruth",
2635
+ source: "groundTruth",
2596
2636
  semanticKey: this.queryset.semanticKey,
2597
2637
  modelName: this.modelClass.modelName,
2598
2638
  configKey: this.modelClass.configKey,
2599
2639
  optimistic: e,
2600
2640
  groundTruthCount: this.groundTruthPks.length,
2601
2641
  operationsCount: this.operationsMap.size,
2602
- rawCount: Array.isArray(o) ? o.length : 0,
2603
- filteredCount: l,
2604
- resultCount: i.length,
2605
- limit: a
2606
- }), i;
2642
+ rawCount: Array.isArray(s) ? s.length : 0,
2643
+ filteredCount: o,
2644
+ resultCount: r.length,
2645
+ limit: i
2646
+ }), r;
2607
2647
  }
2608
2648
  renderFromData(e = !0) {
2609
- const t = this.groundTruthSet;
2610
- for (const r of this.operations)
2611
- r.status !== C.REJECTED && (e || r.status === C.CONFIRMED) && this.applyOperation(r, t);
2612
- return Array.from(t);
2649
+ const t = j.getStore(this.modelClass);
2650
+ if (this.isTemp && this.lastSync === null && t) {
2651
+ const i = this.pkField;
2652
+ return t.render().map((l) => l[i]).filter((l) => l != null);
2653
+ }
2654
+ if (!this.isTemp && this.lastSync === null && t) {
2655
+ if (!((this.queryset._serializerOptions?.offset ?? 0) > 0)) {
2656
+ const c = this.pkField;
2657
+ return t.render().map((h) => h[c]).filter((h) => h != null);
2658
+ }
2659
+ const { root: l } = x.querysetStoreGraph.findRoot(this.queryset), a = l ? x._stores.get(l) : null;
2660
+ if (a && a !== this && a.lastSync !== null)
2661
+ return a.render();
2662
+ }
2663
+ if ((this.queryset._serializerOptions?.offset ?? 0) > 0)
2664
+ return Array.from(this.groundTruthSet);
2665
+ if (!t || !this._hasRecentOps(t))
2666
+ return Array.from(this.groundTruthSet);
2667
+ const r = this._buildFreshPks(t, e), o = this.groundTruthSet;
2668
+ for (const i of r) o.add(i);
2669
+ return Array.from(o);
2670
+ }
2671
+ /** Are there any inflight or recent confirmed ops in the model store? */
2672
+ _hasRecentOps(e) {
2673
+ const t = e.operations, s = this.lastSync ?? this._createdAt;
2674
+ for (let r = t.length - 1; r >= 0; r--)
2675
+ if (t[r].status !== C.REJECTED)
2676
+ return t[r].status !== C.CONFIRMED ? !0 : t[r].timestamp >= s;
2677
+ return !1;
2613
2678
  }
2614
- /**
2615
- * Render by getting all instances from the model store and filtering locally.
2616
- * Used when a queryset has no ground truth (temp stores, newly created stores, etc.)
2617
- */
2618
- renderFromModelStore() {
2619
- const s = Q.getStore(this.modelClass).groundTruthPks.map((o) => this.modelClass.fromPk(o, this.queryset)), r = this.queryset.build();
2620
- return Ct(s, r, this.modelClass, !1);
2679
+ /** Build set of PKs from ops newer than lastSync. Only used for no-offset querysets. */
2680
+ _buildFreshPks(e, t) {
2681
+ const s = /* @__PURE__ */ new Set(), r = this.pkField, o = this.lastSync ?? this._createdAt;
2682
+ for (const i of e.operations)
2683
+ if (i.status !== C.REJECTED && !(!t && i.status !== C.CONFIRMED) && !(i.status === C.CONFIRMED && i.timestamp < o))
2684
+ for (const l of i.instances)
2685
+ l && l[r] != null && s.add(l[r]);
2686
+ return s;
2621
2687
  }
2622
2688
  applyOperation(e, t) {
2623
2689
  const s = this.pkField;
@@ -2629,26 +2695,7 @@ class lr {
2629
2695
  continue;
2630
2696
  }
2631
2697
  let o = r[s];
2632
- switch (e.type) {
2633
- case M.CREATE:
2634
- case M.BULK_CREATE:
2635
- t.add(o);
2636
- break;
2637
- case M.CHECKPOINT:
2638
- break;
2639
- case M.UPDATE:
2640
- case M.UPDATE_INSTANCE:
2641
- t.add(o);
2642
- break;
2643
- case M.DELETE:
2644
- case M.DELETE_INSTANCE:
2645
- t.delete(o);
2646
- break;
2647
- default:
2648
- console.error(
2649
- `[QuerysetStore ${this.modelClass.modelName}] Unknown operation type: ${e.type}`
2650
- );
2651
- }
2698
+ CREATE_TYPES.has(e.type) && t.add(o);
2652
2699
  }
2653
2700
  return t;
2654
2701
  }
@@ -2662,7 +2709,7 @@ class lr {
2662
2709
  console.warn(`[QuerysetStore ${t}] Already syncing, request ignored.`);
2663
2710
  return;
2664
2711
  }
2665
- this.isSyncing = !0, B({
2712
+ this.isSyncing = !0, G({
2666
2713
  type: "sync",
2667
2714
  phase: "start",
2668
2715
  semanticKey: this.queryset.semanticKey,
@@ -2676,7 +2723,7 @@ class lr {
2676
2723
  modelClass: this.modelClass,
2677
2724
  canonical_id: e
2678
2725
  }), { data: r, included: o } = s;
2679
- E(r) || (this.includedPks.clear(), we(Q, o, this.modelClass, this.queryset), this.setGroundTruth(r)), this.setOperations(this.getInflightOperations()), this.lastSync = Date.now(), B({
2726
+ b(r) || (this.includedPks.clear(), we(j, o, this.modelClass, this.queryset), this.setGroundTruth(r)), this.setOperations(this.getInflightOperations()), this.lastSync = Date.now(), G({
2680
2727
  type: "sync",
2681
2728
  phase: "success",
2682
2729
  semanticKey: this.queryset.semanticKey,
@@ -2687,7 +2734,7 @@ class lr {
2687
2734
  includedCount: o ? Object.keys(o).length : 0
2688
2735
  });
2689
2736
  } catch (s) {
2690
- console.error(`[${t}] Failed to sync ground truth:`, s), B({
2737
+ console.error(`[${t}] Failed to sync ground truth:`, s), G({
2691
2738
  type: "sync",
2692
2739
  phase: "error",
2693
2740
  semanticKey: this.queryset.semanticKey,
@@ -2701,9 +2748,9 @@ class lr {
2701
2748
  }
2702
2749
  }
2703
2750
  }
2704
- class cr {
2751
+ class lr {
2705
2752
  constructor() {
2706
- this.graph = new zt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2753
+ this.graph = new Dt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2707
2754
  }
2708
2755
  /**
2709
2756
  * Add a queryset and its parent relationship to the graph
@@ -2789,16 +2836,16 @@ class cr {
2789
2836
  return !e && !t ? !0 : !e || !t || e.length !== t.length ? !1 : e.every((s, r) => s === t[r]);
2790
2837
  }
2791
2838
  clear() {
2792
- this.graph = new zt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2839
+ this.graph = new Dt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2793
2840
  }
2794
2841
  }
2795
- class dr {
2842
+ class cr {
2796
2843
  #e;
2797
2844
  #t;
2798
- #s;
2799
- #r = [];
2845
+ #r;
2846
+ #s = [];
2800
2847
  constructor(e) {
2801
- return this.#e = e, this.#t = e.ModelClass, this.#r.queryset = e, this.#r.ModelClass = e.ModelClass, this.#s = new Proxy(this.#r, {
2848
+ return this.#e = e, this.#t = e.ModelClass, this.#s.queryset = e, this.#s.ModelClass = e.ModelClass, this.#r = new Proxy(this.#s, {
2802
2849
  get: (t, s, r) => s === "touch" ? () => this.touch() : s === "serialize" ? () => this.serialize() : s === Symbol.iterator ? () => this.getCurrentItems()[Symbol.iterator]() : typeof s == "string" && [
2803
2850
  "forEach",
2804
2851
  "map",
@@ -2808,20 +2855,20 @@ class dr {
2808
2855
  "every",
2809
2856
  "find"
2810
2857
  ].includes(s) ? (...o) => this.getCurrentItems()[s](...o) : s === "length" ? this.getCurrentItems().length : typeof s == "string" && !isNaN(parseInt(s)) ? this.getCurrentItems()[s] : t[s]
2811
- }), this.#s;
2858
+ }), this.#r;
2812
2859
  }
2813
2860
  /**
2814
2861
  * Serializes the lqs as a simple array of objects, for freezing e.g in the metric stores
2815
2862
  */
2816
2863
  serialize() {
2817
- return j.getStore(this.#e).render().map((s) => (this.#t.primaryKeyField, this.#t.fromPk(s, this.#e).serialize()));
2864
+ return x.getStore(this.#e).render().map((s) => (this.#t.primaryKeyField, this.#t.fromPk(s, this.#e).serialize()));
2818
2865
  }
2819
2866
  /**
2820
2867
  * Refresh the queryset data from the database
2821
2868
  * Delegates to the underlying store's sync method
2822
2869
  */
2823
2870
  refreshFromDb() {
2824
- return j.getStore(this.#e).sync(!0);
2871
+ return x.getStore(this.#e).sync(!0);
2825
2872
  }
2826
2873
  /**
2827
2874
  * Get the current items from the store
@@ -2829,14 +2876,14 @@ class dr {
2829
2876
  * @returns {Array} The current items in the queryset
2830
2877
  */
2831
2878
  getCurrentItems() {
2832
- return j.getStore(this.#e).render().map((r) => (this.#t.primaryKeyField, this.#t.fromPk(r, this.#e)));
2879
+ return x.getStore(this.#e).render().map((r) => (this.#t.primaryKeyField, this.#t.fromPk(r, this.#e)));
2833
2880
  }
2834
2881
  }
2835
2882
  class Ce {
2836
2883
  constructor() {
2837
2884
  this._stores = /* @__PURE__ */ new Map(), this._tempStores = /* @__PURE__ */ new WeakMap(), this.followingQuerysets = /* @__PURE__ */ new Map(), this.syncManager = () => {
2838
2885
  console.warn("SyncManager not set for QuerysetStoreRegistry");
2839
- }, this.querysetStoreGraph = new cr(), this._groupSyncCache = /* @__PURE__ */ new Map();
2886
+ }, this.querysetStoreGraph = new lr(), this._groupSyncCache = /* @__PURE__ */ new Map();
2840
2887
  }
2841
2888
  clear() {
2842
2889
  this._stores.forEach((e) => {
@@ -2853,7 +2900,7 @@ class Ce {
2853
2900
  this.followingQuerysets.has(e) || this.followingQuerysets.set(e, /* @__PURE__ */ new Set()), this.followingQuerysets.get(e).add(t);
2854
2901
  }
2855
2902
  getStore(e) {
2856
- if (E(e) || E(e.ModelClass))
2903
+ if (b(e) || b(e.ModelClass))
2857
2904
  throw new Error("QuerysetStoreRegistry.getStore requires a valid queryset");
2858
2905
  if (this.querysetStoreGraph.addQueryset(e), this._tempStores.has(e))
2859
2906
  return this._tempStores.get(e);
@@ -2871,7 +2918,7 @@ class Ce {
2871
2918
  ...i,
2872
2919
  type: "list"
2873
2920
  };
2874
- return (await L(
2921
+ return (await V(
2875
2922
  e,
2876
2923
  "list",
2877
2924
  c,
@@ -2884,7 +2931,7 @@ class Ce {
2884
2931
  { namespace: "sync", timeout: 3e4 }
2885
2932
  // Sync ops on separate queue
2886
2933
  )).data;
2887
- }, o = new lr(
2934
+ }, o = new ar(
2888
2935
  e.ModelClass,
2889
2936
  r,
2890
2937
  e,
@@ -2903,12 +2950,12 @@ class Ce {
2903
2950
  * @returns {LiveQueryset} - A live view of the queryset
2904
2951
  */
2905
2952
  getEntity(e, t = !1) {
2906
- if (E(e)) throw new Error("qsStoreRegistry: getEntity cannot be called without a queryset");
2953
+ if (b(e)) throw new Error("qsStoreRegistry: getEntity cannot be called without a queryset");
2907
2954
  const s = e.semanticKey;
2908
2955
  this.addFollowingQueryset(s, e);
2909
2956
  let r;
2910
2957
  this._tempStores.has(e) ? (r = this._tempStores.get(e), r.isTemp = !1, r.registerWithModelStore(), this._stores.set(s, r), this.syncManager.followModel(this, e.ModelClass)) : this._stores.has(s) ? r = this._stores.get(s) : (r = this.getStore(e), r.isTemp = !1, r.registerWithModelStore(), this._stores.set(s, r), this.syncManager.followModel(this, e.ModelClass));
2911
- const o = new dr(e);
2958
+ const o = new cr(e);
2912
2959
  return t && r.sync(), o;
2913
2960
  }
2914
2961
  /**
@@ -2918,7 +2965,7 @@ class Ce {
2918
2965
  * @returns {Array} - The set instances
2919
2966
  */
2920
2967
  setEntity(e, t) {
2921
- if (E(e) || E(t)) return [];
2968
+ if (b(e) || b(t)) return [];
2922
2969
  const s = e.semanticKey;
2923
2970
  this.addFollowingQueryset(s, e);
2924
2971
  let r;
@@ -2945,20 +2992,20 @@ class Ce {
2945
2992
  * @param {Set} dbSyncedKeys - Set of semanticKeys that are dbSynced (followedQuerysets)
2946
2993
  */
2947
2994
  async groupSync(e, t, s, r = null) {
2948
- if (E(e)) return;
2995
+ if (b(e)) return;
2949
2996
  const o = e.semanticKey, i = e.ModelClass, l = /* @__PURE__ */ new Set();
2950
2997
  for (const y of s) {
2951
2998
  const _ = typeof y == "string" ? y : y?.semanticKey;
2952
2999
  _ && this._stores.has(_) && l.add(_);
2953
3000
  }
2954
- const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l), f = a || c === o;
2955
- if (B({
3001
+ const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l), h = a || c === o;
3002
+ if (G({
2956
3003
  type: "groupSync",
2957
3004
  phase: "start",
2958
3005
  operationId: t,
2959
3006
  semanticKey: o,
2960
3007
  rootKey: c,
2961
- iAmRoot: f,
3008
+ iAmRoot: h,
2962
3009
  modelName: i?.modelName,
2963
3010
  configKey: i?.configKey
2964
3011
  }), !this._groupSyncCache.has(t)) {
@@ -2973,8 +3020,8 @@ class Ce {
2973
3020
  console.warn(`[groupSync] No store found for queryset: ${o}`);
2974
3021
  return;
2975
3022
  }
2976
- if (f)
2977
- await m.sync(r), p.pks = m.groundTruthPks, p.resolve(), B({
3023
+ if (h)
3024
+ await m.sync(r), p.pks = m.groundTruthPks, p.resolve(), G({
2978
3025
  type: "groupSync",
2979
3026
  phase: "rootSynced",
2980
3027
  operationId: t,
@@ -2987,12 +3034,12 @@ class Ce {
2987
3034
  else {
2988
3035
  let y = 3e4;
2989
3036
  try {
2990
- const b = he();
2991
- b.periodicSyncIntervalSeconds && (y = b.periodicSyncIntervalSeconds * 2e3);
3037
+ const k = he();
3038
+ k.periodicSyncIntervalSeconds && (y = k.periodicSyncIntervalSeconds * 2e3);
2992
3039
  } catch {
2993
3040
  }
2994
- const _ = new Promise((b, k) => {
2995
- setTimeout(() => k(new Error("timeout")), y);
3041
+ const _ = new Promise((k, E) => {
3042
+ setTimeout(() => E(new Error("timeout")), y);
2996
3043
  });
2997
3044
  let w = !1;
2998
3045
  try {
@@ -3001,7 +3048,7 @@ class Ce {
3001
3048
  w = !0;
3002
3049
  }
3003
3050
  if (w || !p.pks) {
3004
- console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r), B({
3051
+ console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r), G({
3005
3052
  type: "groupSync",
3006
3053
  phase: "fallbackSync",
3007
3054
  operationId: t,
@@ -3012,8 +3059,8 @@ class Ce {
3012
3059
  });
3013
3060
  return;
3014
3061
  }
3015
- const v = p.pks.map((b) => i.fromPk(b, e)), O = e.build(), T = Ct(v, O, i, !1);
3016
- m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(), B({
3062
+ const v = p.pks.map((k) => i.fromPk(k, e)), O = e.build(), T = ss(v, O, i, !1);
3063
+ m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(), G({
3017
3064
  type: "groupSync",
3018
3065
  phase: "filteredFromRoot",
3019
3066
  operationId: t,
@@ -3026,248 +3073,63 @@ class Ce {
3026
3073
  }
3027
3074
  }
3028
3075
  }
3029
- const j = new Ce();
3030
- class ze {
3031
- /**
3032
- * Calculate metric based on ground truth and operations
3033
- */
3034
- calculateWithOperations(e, t, s, r) {
3035
- let o = e === null ? this.getInitialValue() : e;
3036
- for (const i of t)
3037
- i.status !== C.REJECTED && i.frozenInstances.forEach((l, a) => {
3038
- l[r.primaryKeyField];
3039
- const c = i.instances[a] || null, f = {
3040
- originalData: l,
3041
- // Pre-operation state
3042
- updatedData: c,
3043
- // Post-operation state (for updates)
3044
- type: i.type,
3045
- status: i.status
3046
- };
3047
- o = this.reduceOperation(o, f, s);
3048
- });
3049
- return o;
3050
- }
3051
- /**
3052
- * Get initial value for the metric type
3053
- * Override in subclasses if needed
3054
- */
3055
- getInitialValue() {
3056
- return 0;
3057
- }
3058
- /**
3059
- * Process a single operation - implement in subclasses
3060
- */
3061
- reduceOperation(e, t, s) {
3062
- throw new Error("reduceOperation must be implemented by subclass");
3063
- }
3064
- /**
3065
- * Safely get a numeric value from an object
3066
- */
3067
- safeGetValue(e, t) {
3068
- if (!e || !t) return 0;
3069
- const s = e[t];
3070
- if (E(s)) return 0;
3071
- const r = parseFloat(s);
3072
- return isNaN(r) ? 0 : r;
3073
- }
3074
- }
3075
- class ur extends ze {
3076
- reduceOperation(e, t, s) {
3077
- if (t.status === C.REJECTED)
3078
- return e;
3079
- const { type: r } = t;
3080
- return r === M.CREATE ? e + 1 : [M.DELETE, M.DELETE_INSTANCE].includes(r) ? Math.max(0, e - 1) : e;
3081
- }
3082
- }
3083
- class hr extends ze {
3084
- reduceOperation(e, t, s) {
3085
- if (t.status === C.REJECTED)
3086
- return e;
3087
- if (!s)
3088
- throw new Error("SumStrategy requires a field parameter");
3089
- const { type: r, originalData: o, updatedData: i } = t;
3090
- switch (r) {
3091
- case M.CREATE:
3092
- return e + this.safeGetValue(o, s);
3093
- case M.CHECKPOINT:
3094
- case M.UPDATE:
3095
- if (i) {
3096
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3097
- return e - l + a;
3098
- }
3099
- return e;
3100
- case M.DELETE:
3101
- case M.DELETE_INSTANCE:
3102
- return e - this.safeGetValue(o, s);
3103
- default:
3104
- return e;
3105
- }
3106
- }
3107
- }
3108
- class fr extends ze {
3109
- getInitialValue() {
3110
- return 1 / 0;
3111
- }
3112
- reduceOperation(e, t, s) {
3113
- if (t.status === C.REJECTED)
3114
- return e;
3115
- if (!s)
3116
- throw new Error("MinStrategy requires a field parameter");
3117
- const { type: r, originalData: o, updatedData: i } = t;
3118
- if (r === M.CREATE) {
3119
- const l = this.safeGetValue(o, s);
3120
- return Math.min(e, l);
3121
- } else if ((r === M.UPDATE || r.CHECKPOINT) && i) {
3122
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3123
- if (l === e)
3124
- return a <= l, a;
3125
- if (a < e)
3126
- return a;
3127
- }
3128
- return e;
3129
- }
3130
- }
3131
- class pr extends ze {
3132
- getInitialValue() {
3133
- return -1 / 0;
3134
- }
3135
- reduceOperation(e, t, s) {
3136
- if (t.status === C.REJECTED)
3137
- return e;
3138
- if (!s)
3139
- throw new Error("MaxStrategy requires a field parameter");
3140
- const { type: r, originalData: o, updatedData: i } = t;
3141
- if (r === M.CREATE) {
3142
- const l = this.safeGetValue(o, s);
3143
- return Math.max(e, l);
3144
- } else if ((r === M.UPDATE || r === M.CHECKPOINT) && i) {
3145
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3146
- if (l === e)
3147
- return a >= l, a;
3148
- if (a > e)
3149
- return a;
3150
- }
3151
- return e;
3152
- }
3153
- }
3154
- class mr {
3155
- // Collection of custom strategy overrides
3156
- static #e = /* @__PURE__ */ new Map();
3157
- // Default strategy map
3158
- static #t = /* @__PURE__ */ new Map([
3159
- ["count", () => new ur()],
3160
- ["sum", () => new hr()],
3161
- ["min", () => new fr()],
3162
- ["max", () => new pr()]
3163
- ]);
3164
- /**
3165
- * Clear all custom strategy overrides
3166
- */
3167
- static clearCustomStrategies() {
3168
- this.#e.clear();
3169
- }
3170
- /**
3171
- * Generate a unique key for the strategy map
3172
- * @private
3173
- * @param {string} metricType - The type of metric (count, sum, min, max)
3174
- * @param {Function} ModelClass - The model class
3175
- * @returns {string} A unique key
3176
- */
3177
- static #s(e, t) {
3178
- return `${e}::${t.configKey}::${t.modelName}`;
3179
- }
3180
- /**
3181
- * Override a strategy for a specific metric type and model class
3182
- * @param {string} metricType - The type of metric (count, sum, min, max)
3183
- * @param {Function|null} ModelClass - The model class or null for a generic override
3184
- * @param {MetricCalculationStrategy} strategy - The strategy to use
3185
- */
3186
- static overrideStrategy(e, t, s) {
3187
- if (!e || !s)
3188
- throw new Error("overrideStrategy requires metricType and strategy");
3189
- if (!(s instanceof ze))
3190
- throw new Error("strategy must be an instance of MetricCalculationStrategy");
3191
- let r;
3192
- t ? r = this.#s(e, t) : r = `${e}::*::*`, this.#e.set(r, s);
3193
- }
3194
- /**
3195
- * Get the appropriate strategy for a model class and metric type
3196
- * @param {string} metricType - The type of metric (count, sum, min, max)
3197
- * @param {Function} ModelClass - The model class
3198
- * @returns {MetricCalculationStrategy} The appropriate strategy
3199
- */
3200
- static getStrategy(e, t) {
3201
- const s = e.toLowerCase(), r = this.#s(s, t);
3202
- if (this.#e.has(r))
3203
- return this.#e.get(r);
3204
- const o = `${s}::*::*`;
3205
- return this.#e.has(o) ? this.#e.get(o) : (this.#t.get(s) || this.#t.get("count"))();
3206
- }
3207
- }
3208
- class yr {
3076
+ const x = new Ce();
3077
+ class dr {
3209
3078
  constructor(e, t, s, r = null, o = null, i) {
3210
- this.metricType = e, this.modelClass = t, this.queryset = s, this.field = r, this.ast = o, this.fetchFn = i, this.groundTruthValue = null, this.isSyncing = !1, this.strategy = mr.getStrategy(e, t), this.operations = [], this.confirmedOps = /* @__PURE__ */ new Set(), this.metricCache = new Et(
3079
+ this.metricType = e, this.modelClass = t, this.queryset = s, this.field = r, this.ast = o, this.fetchFn = i, this.groundTruthValue = null, this.isSyncing = !1, this.deltas = /* @__PURE__ */ new Map(), this.metricCache = new Ct(
3211
3080
  "metric-store-cache",
3212
3081
  {},
3213
3082
  this.onHydrated.bind(this)
3214
3083
  ), this._lastCalculatedValue = null;
3215
3084
  }
3216
3085
  reset() {
3217
- this.groundTruthValue = null, this._lastCalculatedValue = null, this.operations = [], this.confirmedOps = /* @__PURE__ */ new Set(), this.isSyncing = !1, this.clearCache();
3086
+ this.groundTruthValue = null, this._lastCalculatedValue = null, this.deltas = /* @__PURE__ */ new Map(), this.isSyncing = !1, this.clearCache();
3218
3087
  }
3219
3088
  get cacheKey() {
3220
3089
  return `${this.modelClass.configKey}::${this.modelClass.modelName}::metric::${this.metricType}::${this.field || "null"}::${this.ast ? Le(this.ast) : "global"}`;
3221
3090
  }
3222
3091
  /**
3223
- * Add an operation to this metric store
3224
- * @param {Operation} operation - The operation to add
3092
+ * Add a delta for an operation
3225
3093
  */
3226
- addOperation(e) {
3227
- if (e.queryset.ModelClass !== this.modelClass)
3228
- return;
3229
- const t = this.operations.findIndex(
3230
- (s) => s.operationId === e.operationId
3231
- );
3232
- t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
3094
+ addDelta(e, t) {
3095
+ this.deltas.set(e, { delta: t, confirmed: !1 }), this.render();
3233
3096
  }
3234
3097
  /**
3235
- * Update an operation in this metric store
3236
- * @param {Operation} operation - The operation to update
3098
+ * Mark a delta as confirmed
3237
3099
  */
3238
- updateOperation(e) {
3239
- if (e.queryset.ModelClass !== this.modelClass)
3240
- return;
3241
- const t = this.operations.findIndex(
3242
- (s) => s.operationId === e.operationId
3243
- );
3244
- t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
3100
+ confirmDelta(e) {
3101
+ const t = this.deltas.get(e);
3102
+ t && (t.confirmed = !0, this.render());
3245
3103
  }
3246
3104
  /**
3247
- * Confirm an operation in this metric store
3248
- * @param {Operation} operation - The operation to confirm
3105
+ * Remove a rejected delta
3249
3106
  */
3250
- confirm(e) {
3251
- if (e.queryset.ModelClass !== this.modelClass)
3252
- return;
3253
- const t = this.operations.findIndex(
3254
- (s) => s.operationId === e.operationId
3255
- );
3256
- t !== -1 && (this.operations[t] = e, this.confirmedOps.add(e.operationId)), this.render();
3107
+ rejectDelta(e) {
3108
+ this.deltas.delete(e) && this.render();
3257
3109
  }
3258
3110
  /**
3259
- * Reject an operation in this metric store
3260
- * @param {Operation} operation - The operation to reject
3111
+ * Update a delta (e.g., when operation is mutated)
3261
3112
  */
3113
+ updateDelta(e, t) {
3114
+ const s = this.deltas.get(e);
3115
+ s ? (s.delta = t, this.render()) : this.addDelta(e, t);
3116
+ }
3117
+ // Legacy API — kept for backward compatibility with existing callers.
3118
+ // processMetricStores in operationEventHandlers still calls these.
3119
+ addOperation(e) {
3120
+ }
3121
+ updateOperation(e) {
3122
+ }
3123
+ confirm(e) {
3124
+ this.confirmDelta(e.operationId);
3125
+ }
3262
3126
  reject(e) {
3263
- e.queryset.ModelClass === this.modelClass && (this.operations = this.operations.filter(
3264
- (t) => t.operationId !== e.operationId
3265
- ), this.confirmedOps.delete(e.operationId), E(this.groundTruthValue) || this.render());
3127
+ this.rejectDelta(e.operationId);
3266
3128
  }
3267
3129
  onHydrated() {
3268
3130
  if (this.groundTruthValue === null) {
3269
3131
  const e = this.metricCache.get(this.cacheKey);
3270
- !E(e) && !ve(e) && this.setGroundTruth(e?.value);
3132
+ !b(e) && !ve(e) && this.setGroundTruth(e?.value);
3271
3133
  }
3272
3134
  }
3273
3135
  setCache() {
@@ -3280,8 +3142,8 @@ class yr {
3280
3142
  this.metricCache.delete(this.cacheKey);
3281
3143
  }
3282
3144
  setGroundTruth(e) {
3283
- const t = !qe(this.groundTruthValue, e);
3284
- this.groundTruthValue = e, this.setCache(), t && Nt.emit("metric::render", {
3145
+ const t = !He(this.groundTruthValue, e);
3146
+ this.groundTruthValue = e, this.setCache(), t && Kt.emit("metric::render", {
3285
3147
  metricType: this.metricType,
3286
3148
  ModelClass: this.modelClass,
3287
3149
  field: this.field,
@@ -3290,19 +3152,15 @@ class yr {
3290
3152
  });
3291
3153
  }
3292
3154
  /**
3293
- * Render the metric with current operations
3294
- * @returns {any} Calculated metric value
3155
+ * Render: groundTruthValue + sum of all deltas
3295
3156
  */
3296
3157
  render() {
3297
- if (E(this.groundTruthValue))
3158
+ if (b(this.groundTruthValue))
3298
3159
  return null;
3299
- const e = this.strategy.calculateWithOperations(
3300
- this.groundTruthValue,
3301
- this.operations,
3302
- this.field,
3303
- this.modelClass
3304
- );
3305
- return qe(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Nt.emit("metric::render", {
3160
+ let e = this.groundTruthValue;
3161
+ for (const { delta: t } of this.deltas.values())
3162
+ e += t;
3163
+ return He(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Kt.emit("metric::render", {
3306
3164
  metricType: this.metricType,
3307
3165
  ModelClass: this.modelClass,
3308
3166
  field: this.field,
@@ -3328,9 +3186,9 @@ class yr {
3328
3186
  field: this.field,
3329
3187
  ast: this.ast
3330
3188
  });
3331
- return this.confirmedOps.size > 0 && (this.operations = this.operations.filter(
3332
- (t) => !this.confirmedOps.has(t.operationId)
3333
- ), this.confirmedOps.clear()), this.setGroundTruth(e), e;
3189
+ for (const [t, s] of this.deltas)
3190
+ s.confirmed && this.deltas.delete(t);
3191
+ return this.setGroundTruth(e), e;
3334
3192
  } catch (e) {
3335
3193
  return console.error(
3336
3194
  `[MetricStore] Failed to sync ${this.metricType} metric:`,
@@ -3347,13 +3205,13 @@ function te(n, e) {
3347
3205
  function Z(n) {
3348
3206
  return delete n.isOptimistic, delete n.then, delete n.catch, n;
3349
3207
  }
3350
- Cs();
3351
- Xt.create();
3352
- function gr(n, e) {
3208
+ ws();
3209
+ Zt.create();
3210
+ function ur(n, e) {
3353
3211
  if (!n || !n.__f_expr)
3354
3212
  return n;
3355
3213
  try {
3356
- return Xt.evaluate(n.original_expr, e);
3214
+ return Zt.evaluate(n.original_expr, e);
3357
3215
  } catch (t) {
3358
3216
  return console.warn(`Error evaluating F expression: ${t.message}`), null;
3359
3217
  }
@@ -3367,10 +3225,10 @@ class de {
3367
3225
  * @returns {Operation} The created operation
3368
3226
  */
3369
3227
  static createCreateOperation(e, t = {}, s = null) {
3370
- const o = e.ModelClass.primaryKeyField, i = s || `${G()}`, l = Kt(i);
3228
+ const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = zt(i);
3371
3229
  return new q({
3372
3230
  operationId: i,
3373
- type: M.CREATE,
3231
+ type: P.CREATE,
3374
3232
  instances: [{ ...t, [o]: l }],
3375
3233
  queryset: e,
3376
3234
  args: { data: t },
@@ -3385,13 +3243,13 @@ class de {
3385
3243
  * @returns {Operation} The created operation
3386
3244
  */
3387
3245
  static createBulkCreateOperation(e, t = [], s = null) {
3388
- const o = e.ModelClass.primaryKeyField, i = s || `${G()}`, l = t.map((a, c) => {
3389
- const f = Kt(`${i}_${c}`);
3390
- return { ...a, [o]: f };
3246
+ const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = t.map((a, c) => {
3247
+ const h = zt(`${i}_${c}`);
3248
+ return { ...a, [o]: h };
3391
3249
  });
3392
3250
  return new q({
3393
3251
  operationId: i,
3394
- type: M.BULK_CREATE,
3252
+ type: P.BULK_CREATE,
3395
3253
  instances: l,
3396
3254
  queryset: e,
3397
3255
  args: { data: t },
@@ -3407,12 +3265,12 @@ class de {
3407
3265
  * @returns {Operation} The created operation
3408
3266
  */
3409
3267
  static createUpdateOperation(e, t = {}, s = null, r = null) {
3410
- const o = e.ModelClass, i = o.primaryKeyField, a = j.getStore(e).render(), c = r || `${G()}`, f = a.map((p) => {
3411
- const m = Q.getEntity(o, p), y = { ...m };
3268
+ const o = e.ModelClass, i = o.primaryKeyField, a = x.getStore(e).render(), c = r || `${B()}`, h = a.map((p) => {
3269
+ const m = j.getEntity(o, p), y = { ...m };
3412
3270
  y[i] = p;
3413
3271
  for (const [_, w] of Object.entries(t))
3414
3272
  if (w && typeof w == "object" && w.__f_expr) {
3415
- const v = gr(w, m);
3273
+ const v = ur(w, m);
3416
3274
  v !== null ? y[_] = v : y[_] = m[_];
3417
3275
  } else
3418
3276
  y[_] = w;
@@ -3420,8 +3278,8 @@ class de {
3420
3278
  });
3421
3279
  return new q({
3422
3280
  operationId: c,
3423
- type: M.UPDATE,
3424
- instances: f,
3281
+ type: P.UPDATE,
3282
+ instances: h,
3425
3283
  queryset: e,
3426
3284
  args: { filter: s, data: t },
3427
3285
  localOnly: e._optimisticOnly || !1
@@ -3434,10 +3292,10 @@ class de {
3434
3292
  * @returns {Operation} The created operation
3435
3293
  */
3436
3294
  static createDeleteOperation(e, t = null) {
3437
- const r = e.ModelClass.primaryKeyField, i = j.getStore(e).render(), l = t || `${G()}`, a = i.map((c) => ({ [r]: c }));
3295
+ const r = e.ModelClass.primaryKeyField, i = x.getStore(e).render(), l = t || `${B()}`, a = i.map((c) => ({ [r]: c }));
3438
3296
  return new q({
3439
3297
  operationId: l,
3440
- type: M.DELETE,
3298
+ type: P.DELETE,
3441
3299
  instances: a,
3442
3300
  queryset: e,
3443
3301
  args: {},
@@ -3452,10 +3310,10 @@ class de {
3452
3310
  * @returns {Operation} The created operation
3453
3311
  */
3454
3312
  static createUpdateInstanceOperation(e, t = {}, s = null) {
3455
- const o = e.ModelClass.primaryKeyField, l = j.getStore(e).render(), a = s || `${G()}`, c = l.map((f) => ({ ...t, [o]: f }));
3313
+ const o = e.ModelClass.primaryKeyField, l = x.getStore(e).render(), a = s || `${B()}`, c = l.map((h) => ({ ...t, [o]: h }));
3456
3314
  return new q({
3457
3315
  operationId: a,
3458
- type: M.UPDATE_INSTANCE,
3316
+ type: P.UPDATE_INSTANCE,
3459
3317
  instances: c,
3460
3318
  queryset: e,
3461
3319
  args: { data: t },
@@ -3470,10 +3328,10 @@ class de {
3470
3328
  * @returns {Operation} The created operation
3471
3329
  */
3472
3330
  static createDeleteInstanceOperation(e, t, s = null) {
3473
- const r = s || `${G()}`;
3331
+ const r = s || `${B()}`;
3474
3332
  return new q({
3475
3333
  operationId: r,
3476
- type: M.DELETE_INSTANCE,
3334
+ type: P.DELETE_INSTANCE,
3477
3335
  instances: [t],
3478
3336
  queryset: e,
3479
3337
  args: t,
@@ -3489,15 +3347,15 @@ class de {
3489
3347
  * @returns {Operation} The created operation
3490
3348
  */
3491
3349
  static createGetOrCreateOperation(e, t = {}, s = {}, r = null) {
3492
- const o = e.ModelClass, i = o.primaryKeyField, l = r || `${G()}`, c = Q.getStore(o).render(), f = { ...t }, m = new e.constructor(o).filter(f).build(), y = gt(m, o), _ = c.map(
3493
- (k) => wt(y, o.fromPk(k[i], e))
3494
- ), w = yt(_, m, o), v = c.filter(
3495
- (k) => w.includes(k[i])
3496
- ), O = v.length === 0, T = O ? M.CREATE : M.UPDATE, b = O ? { ...t, ...s, [i]: l } : v[0];
3350
+ const o = e.ModelClass, i = o.primaryKeyField, l = r || `${B()}`, c = j.getStore(o).render(), h = { ...t }, m = new e.constructor(o).filter(h).build(), y = yt(m, o), _ = c.map(
3351
+ (E) => _t(y, o.fromPk(E[i], e))
3352
+ ), w = mt(_, m, o), v = c.filter(
3353
+ (E) => w.includes(E[i])
3354
+ ), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : v[0];
3497
3355
  return new q({
3498
3356
  operationId: l,
3499
3357
  type: T,
3500
- instances: [b],
3358
+ instances: [k],
3501
3359
  queryset: e,
3502
3360
  args: { lookup: t, defaults: s },
3503
3361
  localOnly: e._optimisticOnly || !1
@@ -3512,22 +3370,22 @@ class de {
3512
3370
  * @returns {Operation} The created operation
3513
3371
  */
3514
3372
  static createUpdateOrCreateOperation(e, t = {}, s = {}, r = null) {
3515
- const o = e.ModelClass, i = o.primaryKeyField, l = r || `${G()}`, c = Q.getStore(o).render(), f = { ...t }, m = new e.constructor(o).filter(f).build(), y = gt(m, o), _ = c.map(
3516
- (k) => wt(y, o.fromPk(k[i], e))
3517
- ), w = yt(_, m, o), v = c.filter(
3518
- (k) => w.includes(k[i])
3519
- ), O = v.length === 0, T = O ? M.CREATE : M.UPDATE, b = O ? { ...t, ...s, [i]: l } : { ...v[0], ...s };
3373
+ const o = e.ModelClass, i = o.primaryKeyField, l = r || `${B()}`, c = j.getStore(o).render(), h = { ...t }, m = new e.constructor(o).filter(h).build(), y = yt(m, o), _ = c.map(
3374
+ (E) => _t(y, o.fromPk(E[i], e))
3375
+ ), w = mt(_, m, o), v = c.filter(
3376
+ (E) => w.includes(E[i])
3377
+ ), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : { ...v[0], ...s };
3520
3378
  return new q({
3521
3379
  operationId: l,
3522
3380
  type: T,
3523
- instances: [b],
3381
+ instances: [k],
3524
3382
  queryset: e,
3525
3383
  args: { lookup: t, defaults: s },
3526
3384
  localOnly: e._optimisticOnly || !1
3527
3385
  });
3528
3386
  }
3529
3387
  }
3530
- class Wt extends Array {
3388
+ class qt extends Array {
3531
3389
  /**
3532
3390
  * Creates a new ResultTuple.
3533
3391
  *
@@ -3538,7 +3396,7 @@ class Wt extends Array {
3538
3396
  super(2), this[0] = e, this[1] = t, this.instance = e, this.created = t;
3539
3397
  }
3540
3398
  }
3541
- class _r {
3399
+ class hr {
3542
3400
  /**
3543
3401
  * Executes a get operation (get, first, last) with the QuerySet.
3544
3402
  *
@@ -3548,12 +3406,12 @@ class _r {
3548
3406
  * @returns {Promise<Object>} The model instance.
3549
3407
  */
3550
3408
  static executeGet(e, t, s = {}) {
3551
- const r = e.ModelClass, i = j.getStore(e).render(), l = Array.isArray(i) && i.length === 1 ? i[0] : null, a = r.fromPk(l, e), c = L(e, t, s).then(
3552
- (f) => {
3553
- const { data: p, included: m, model_name: y } = f.data;
3554
- if (E(p) || Array.isArray(p) && p.length === 0)
3409
+ const r = e.ModelClass, i = x.getStore(e).render(), l = Array.isArray(i) && i.length === 1 ? i[0] : null, a = r.fromPk(l, e), c = V(e, t, s).then(
3410
+ (h) => {
3411
+ const { data: p, included: m, model_name: y } = h.data;
3412
+ if (b(p) || Array.isArray(p) && p.length === 0)
3555
3413
  return null;
3556
- we(Q, m, r, e);
3414
+ we(j, m, r, e);
3557
3415
  const _ = Array.isArray(p) ? p[0] : p;
3558
3416
  return a.pk = _, Z(a), a;
3559
3417
  }
@@ -3576,11 +3434,11 @@ class _r {
3576
3434
  * synchronized with the in‑memory store.
3577
3435
  */
3578
3436
  static executeList(e, t = "list", s = {}) {
3579
- const r = j.getEntity(e), o = L(e, t, s).then((i) => {
3437
+ const r = x.getEntity(e), o = V(e, t, s).then((i) => {
3580
3438
  const { data: l, included: a } = i.data;
3581
- we(Q, a, e.ModelClass, e);
3439
+ we(j, a, e.ModelClass, e);
3582
3440
  const c = Array.isArray(l) ? l : [];
3583
- return j.setEntity(e, c), Z(r), r;
3441
+ return x.setEntity(e, c), Z(r), r;
3584
3442
  });
3585
3443
  return te(r, o);
3586
3444
  }
@@ -3597,28 +3455,28 @@ class _r {
3597
3455
  lookup: s.lookup || {},
3598
3456
  defaults: s.defaults || {}
3599
3457
  }, l = t === "get_or_create" ? de.createGetOrCreateOperation(e, i.lookup, i.defaults) : de.createUpdateOrCreateOperation(e, i.lookup, i.defaults), a = l.type === "create", c = r.fromPk(l.instances[0][o], e);
3600
- let f = new Wt(c, a);
3458
+ let h = new qt(c, a);
3601
3459
  if (l.localOnly)
3602
- return l.updateStatus(C.CONFIRMED, l.instances), f;
3603
- const p = L(
3460
+ return l.updateStatus(C.CONFIRMED, l.instances), h;
3461
+ const p = V(
3604
3462
  e,
3605
3463
  t,
3606
3464
  i,
3607
3465
  l.operationId
3608
3466
  ).then((m) => {
3609
3467
  const { data: y, included: _, model_name: w } = m.data, v = m.metadata.created;
3610
- we(Q, _, r, e);
3468
+ we(j, _, r, e);
3611
3469
  const O = Array.isArray(y) ? y[0] : y;
3612
3470
  a && (c.pk = O);
3613
- const b = (_[w] || {})[O];
3614
- return b && l.mutate({
3615
- instances: [b],
3471
+ const k = (_[w] || {})[O];
3472
+ return k && l.mutate({
3473
+ instances: [k],
3616
3474
  status: C.CONFIRMED
3617
- }), f = new Wt(c, v), Z(f), f;
3475
+ }), h = new qt(c, v), Z(h), h;
3618
3476
  }).catch((m) => {
3619
3477
  throw l.updateStatus(C.REJECTED), m;
3620
3478
  });
3621
- return te(f, p);
3479
+ return te(h, p);
3622
3480
  }
3623
3481
  /**
3624
3482
  * Executes an aggregation operation with the QuerySet.
@@ -3634,15 +3492,15 @@ class _r {
3634
3492
  throw new Error(
3635
3493
  `Field parameter is required for ${t} operation`
3636
3494
  );
3637
- const i = Fe.getEntity(t, e, o), l = {};
3495
+ const i = Pe.getEntity(t, e, o), l = {};
3638
3496
  t !== "exists" && (l.field = o);
3639
- const a = L(
3497
+ const a = V(
3640
3498
  e,
3641
3499
  t,
3642
3500
  l
3643
3501
  ).then((c) => {
3644
- const f = c.data, p = j.getEntity(e);
3645
- return Fe.setEntity(t, e, o, f, p), Z(i), f;
3502
+ const h = c.data, p = x.getEntity(e);
3503
+ return Pe.setEntity(t, e, o, h, p), Z(i), h;
3646
3504
  });
3647
3505
  return te(i, a);
3648
3506
  }
@@ -3655,7 +3513,7 @@ class _r {
3655
3513
  * @returns {Promise<boolean>} Whether records exist.
3656
3514
  */
3657
3515
  static async executeExists(e, t = "exists", s = {}) {
3658
- return (await L(
3516
+ return (await V(
3659
3517
  e,
3660
3518
  t,
3661
3519
  {}
@@ -3680,7 +3538,7 @@ class _r {
3680
3538
  let c = [a, { [o]: a }, l.instances];
3681
3539
  if (l.localOnly)
3682
3540
  return l.updateStatus(C.CONFIRMED, l.instances), c;
3683
- const f = L(
3541
+ const h = V(
3684
3542
  e,
3685
3543
  t,
3686
3544
  i,
@@ -3693,7 +3551,7 @@ class _r {
3693
3551
  }).catch((p) => {
3694
3552
  throw l.updateStatus(C.REJECTED), p;
3695
3553
  });
3696
- return te(c, f);
3554
+ return te(c, h);
3697
3555
  }
3698
3556
  /**
3699
3557
  * Executes a delete operation with the QuerySet.
@@ -3708,16 +3566,16 @@ class _r {
3708
3566
  let a = [l, { [o]: l }, i.instances];
3709
3567
  if (i.localOnly)
3710
3568
  return i.updateStatus(C.CONFIRMED, i.instances), a;
3711
- const c = L(
3569
+ const c = V(
3712
3570
  e,
3713
3571
  t,
3714
3572
  {},
3715
3573
  i.operationId
3716
- ).then((f) => {
3717
- const p = f.metadata.deleted_count, m = f.metadata.rows_deleted;
3574
+ ).then((h) => {
3575
+ const p = h.metadata.deleted_count, m = h.metadata.rows_deleted;
3718
3576
  return i.updateStatus(C.CONFIRMED, m), a = [p, { [o]: p }, m || []], Z(a), a;
3719
- }).catch((f) => {
3720
- throw i.updateStatus(C.REJECTED), f;
3577
+ }).catch((h) => {
3578
+ throw i.updateStatus(C.REJECTED), h;
3721
3579
  });
3722
3580
  return te(a, c);
3723
3581
  }
@@ -3730,14 +3588,14 @@ class _r {
3730
3588
  * @returns {LiveThenable<Object>} The live Model instance which resolves to the created model.
3731
3589
  */
3732
3590
  static executeCreate(e, t = "create", s = {}) {
3733
- const r = e.ModelClass, o = `${G()}`, i = {
3591
+ const r = e.ModelClass, o = `${B()}`, i = {
3734
3592
  data: s.data || {}
3735
3593
  };
3736
- E(s.data) && (console.warn("executeCreate was called with null data"), s.data = {});
3594
+ b(s.data) && (console.warn("executeCreate was called with null data"), s.data = {});
3737
3595
  const l = de.createCreateOperation(e, i.data, o), a = l.instances[0][r.primaryKeyField], c = r.fromPk(a, e);
3738
3596
  if (l.localOnly)
3739
3597
  return l.updateStatus(C.CONFIRMED, l.instances), c;
3740
- const f = L(
3598
+ const h = V(
3741
3599
  e,
3742
3600
  t,
3743
3601
  i,
@@ -3748,7 +3606,7 @@ class _r {
3748
3606
  }
3749
3607
  ).then((p) => {
3750
3608
  const { data: m, included: y, model_name: _ } = p.data;
3751
- we(Q, y, r, e);
3609
+ we(j, y, r, e);
3752
3610
  const w = Array.isArray(m) ? m[0] : m;
3753
3611
  c.pk = w;
3754
3612
  const O = (y[_] || {})[w];
@@ -3763,7 +3621,7 @@ class _r {
3763
3621
  }).catch((p) => {
3764
3622
  throw l.updateStatus(C.REJECTED), p;
3765
3623
  });
3766
- return te(c, f);
3624
+ return te(c, h);
3767
3625
  }
3768
3626
  /**
3769
3627
  * Executes a bulk_create operation with the QuerySet.
@@ -3774,10 +3632,10 @@ class _r {
3774
3632
  * @returns {LiveThenable<Array>} Array of live Model instances.
3775
3633
  */
3776
3634
  static executeBulkCreate(e, t = "bulk_create", s = {}) {
3777
- const r = e.ModelClass, o = `${G()}`, i = r.primaryKeyField, l = {
3635
+ const r = e.ModelClass, o = `${B()}`, i = r.primaryKeyField, l = {
3778
3636
  data: s.data || []
3779
3637
  };
3780
- if (E(s.data) || !Array.isArray(s.data))
3638
+ if (b(s.data) || !Array.isArray(s.data))
3781
3639
  return console.warn("executeBulkCreate was called with invalid data"), Promise.resolve([]);
3782
3640
  const a = de.createBulkCreateOperation(e, l.data, o), c = a.instances.map((p) => {
3783
3641
  const m = p[i];
@@ -3785,7 +3643,7 @@ class _r {
3785
3643
  });
3786
3644
  if (a.localOnly)
3787
3645
  return a.updateStatus(C.CONFIRMED, a.instances), c;
3788
- const f = L(
3646
+ const h = V(
3789
3647
  e,
3790
3648
  t,
3791
3649
  l,
@@ -3799,10 +3657,10 @@ class _r {
3799
3657
  }
3800
3658
  ).then((p) => {
3801
3659
  const { data: m, included: y, model_name: _ } = p.data;
3802
- we(Q, y, r, e);
3660
+ we(j, y, r, e);
3803
3661
  const w = Array.isArray(m) ? m : [];
3804
- w.forEach((T, b) => {
3805
- c[b] && (c[b].pk = T);
3662
+ w.forEach((T, k) => {
3663
+ c[k] && (c[k].pk = T);
3806
3664
  });
3807
3665
  const v = y[_] || {}, O = w.map((T) => v[T]).filter(Boolean);
3808
3666
  return a.mutate({
@@ -3812,7 +3670,7 @@ class _r {
3812
3670
  }).catch((p) => {
3813
3671
  throw a.updateStatus(C.REJECTED), p;
3814
3672
  });
3815
- return te(c, f);
3673
+ return te(c, h);
3816
3674
  }
3817
3675
  /**
3818
3676
  * Executes an update_instance operation with the QuerySet.
@@ -3825,29 +3683,29 @@ class _r {
3825
3683
  static executeUpdateInstance(e, t = "update_instance", s = {}) {
3826
3684
  const r = e.ModelClass;
3827
3685
  r.primaryKeyField;
3828
- const i = j.getStore(e).render(), l = s.data || {}, a = de.createUpdateInstanceOperation(e, l), c = Array.isArray(i) ? i[0] : null, f = r.fromPk(c, e);
3686
+ const i = x.getStore(e).render(), l = s.data || {}, a = de.createUpdateInstanceOperation(e, l), c = Array.isArray(i) ? i[0] : null, h = r.fromPk(c, e);
3829
3687
  if (a.localOnly)
3830
- return a.updateStatus(C.CONFIRMED, a.instances), f;
3831
- const p = L(
3688
+ return a.updateStatus(C.CONFIRMED, a.instances), h;
3689
+ const p = V(
3832
3690
  e,
3833
3691
  t,
3834
3692
  { data: l },
3835
3693
  a.operationId
3836
3694
  ).then((m) => {
3837
3695
  const { data: y, included: _, model_name: w } = m.data;
3838
- we(Q, _, r, e);
3696
+ we(j, _, r, e);
3839
3697
  const v = Array.isArray(y) ? y[0] : y;
3840
- f.pk = v;
3698
+ h.pk = v;
3841
3699
  const T = (_[w] || {})[v];
3842
3700
  if (!T)
3843
3701
  throw new Error(
3844
3702
  `Entity data not found for ${w} with pk ${v}`
3845
3703
  );
3846
- return a.updateStatus(C.CONFIRMED, [T]), Z(f), f;
3704
+ return a.updateStatus(C.CONFIRMED, [T]), Z(h), h;
3847
3705
  }).catch((m) => {
3848
3706
  throw a.updateStatus(C.REJECTED), m;
3849
3707
  });
3850
- return te(f, p);
3708
+ return te(h, p);
3851
3709
  }
3852
3710
  /**
3853
3711
  * Executes a delete_instance operation with the QuerySet.
@@ -3865,18 +3723,18 @@ class _r {
3865
3723
  let a = [1, { [o]: 1 }, l.instances];
3866
3724
  if (l.localOnly)
3867
3725
  return l.updateStatus(C.CONFIRMED, l.instances), a;
3868
- const c = L(
3726
+ const c = V(
3869
3727
  e,
3870
3728
  t,
3871
3729
  s,
3872
3730
  l.operationId
3873
- ).then((f) => {
3731
+ ).then((h) => {
3874
3732
  let p = 1;
3875
- typeof f.data == "number" && (p = f.data);
3876
- const m = f.metadata?.rows_deleted || [s];
3733
+ typeof h.data == "number" && (p = h.data);
3734
+ const m = h.metadata?.rows_deleted || [s];
3877
3735
  return l.updateStatus(C.CONFIRMED, [s]), a = [p, { [o]: p }, m], Z(a), a;
3878
- }).catch((f) => {
3879
- throw l.updateStatus(C.REJECTED), f;
3736
+ }).catch((h) => {
3737
+ throw l.updateStatus(C.REJECTED), h;
3880
3738
  });
3881
3739
  return te(a, c);
3882
3740
  }
@@ -3933,22 +3791,22 @@ class _r {
3933
3791
  * @returns {Promise<any>} The raw API response data.
3934
3792
  */
3935
3793
  static executeRemote(e, t = "list", s = {}) {
3936
- return L(e, t, s);
3794
+ return V(e, t, s);
3937
3795
  }
3938
3796
  }
3939
- class wr {
3797
+ class fr {
3940
3798
  constructor(e, t, s = null) {
3941
3799
  this.queryset = e, this.metricType = t, this.field = s;
3942
3800
  }
3943
3801
  get lqs() {
3944
- return j.getEntity(this.queryset);
3802
+ return x.getEntity(this.queryset);
3945
3803
  }
3946
3804
  /**
3947
3805
  * Refresh the metric data from the database
3948
3806
  * Delegates to the underlying store's sync method
3949
3807
  */
3950
3808
  refreshFromDb() {
3951
- return Fe.getStore(
3809
+ return Pe.getStore(
3952
3810
  this.metricType,
3953
3811
  this.queryset,
3954
3812
  this.field
@@ -3959,7 +3817,7 @@ class wr {
3959
3817
  * Called implicitly by JS when coercing to a primitive (arithmetic, template literals, etc.)
3960
3818
  */
3961
3819
  valueOf() {
3962
- const e = Fe.getStore(
3820
+ const e = Pe.getStore(
3963
3821
  this.metricType,
3964
3822
  this.queryset,
3965
3823
  this.field
@@ -3975,14 +3833,22 @@ class wr {
3975
3833
  return this.valueOf();
3976
3834
  }
3977
3835
  }
3978
- class vt {
3836
+ class wt {
3979
3837
  constructor() {
3980
- this._stores = /* @__PURE__ */ new Map(), this.syncManager = null;
3838
+ this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set(), this.syncManager = null;
3981
3839
  }
3982
3840
  clear() {
3983
3841
  for (const e of this._stores.values())
3984
3842
  this.syncManager.unfollowModel(this, e.store.modelClass);
3985
- this._stores = /* @__PURE__ */ new Map();
3843
+ this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set();
3844
+ }
3845
+ followMetric(e, t, s = null) {
3846
+ const r = this._makeKey(e, t, s);
3847
+ this.followedMetrics.add(r);
3848
+ }
3849
+ unfollowMetric(e, t, s = null) {
3850
+ const r = this._makeKey(e, t, s);
3851
+ this.followedMetrics.delete(r);
3986
3852
  }
3987
3853
  setSyncManager(e) {
3988
3854
  this.syncManager = e;
@@ -3993,7 +3859,7 @@ class vt {
3993
3859
  * @returns {Array} Array of metric stores
3994
3860
  */
3995
3861
  getAllStoresForQueryset(e) {
3996
- if (E(e) || E(e.ModelClass))
3862
+ if (b(e) || b(e.ModelClass))
3997
3863
  return [];
3998
3864
  const t = [], s = e.ModelClass;
3999
3865
  for (const [r, o] of this._stores.entries()) {
@@ -4010,14 +3876,14 @@ class vt {
4010
3876
  * Get a metric store for a specific queryset and metric type
4011
3877
  */
4012
3878
  getStore(e, t, s = null) {
4013
- if (E(e) || E(t) || E(t.ModelClass))
3879
+ if (b(e) || b(t) || b(t.ModelClass))
4014
3880
  return null;
4015
3881
  const r = t.ModelClass, o = t.build(), i = this._makeKey(e, t, s);
4016
3882
  if (!this._stores.has(i)) {
4017
- const l = async ({ metricType: c, modelClass: f, field: p, ast: m }) => {
3883
+ const l = async ({ metricType: c, modelClass: h, field: p, ast: m }) => {
4018
3884
  const y = t.clone();
4019
- return await _r.executeAgg(y, c, { field: p });
4020
- }, a = new yr(
3885
+ return await hr.executeAgg(y, c, { field: p });
3886
+ }, a = new dr(
4021
3887
  e,
4022
3888
  r,
4023
3889
  t,
@@ -4037,20 +3903,20 @@ class vt {
4037
3903
  * Get a metric value for a specific queryset
4038
3904
  */
4039
3905
  getEntity(e, t, s = null) {
4040
- if (E(e) || E(t) || E(t.ModelClass))
3906
+ if (b(e) || b(t) || b(t.ModelClass))
4041
3907
  return null;
4042
3908
  this.getStore(e, t, s);
4043
- const r = new wr(t, e, s);
3909
+ const r = new fr(t, e, s);
4044
3910
  return r;
4045
3911
  }
4046
3912
  /**
4047
3913
  * Set metric ground truth value
4048
3914
  */
4049
3915
  setEntity(e, t, s, r) {
4050
- if (E(e) || E(t) || E(t.ModelClass))
3916
+ if (b(e) || b(t) || b(t.ModelClass))
4051
3917
  return null;
4052
3918
  const o = this.getStore(e, t, s);
4053
- return o ? ((!E(o.groundTruthValue) || !ve(o.operations)) && o.reset(), o.setGroundTruth(r), r) : null;
3919
+ return o ? ((!b(o.groundTruthValue) || !ve(o.operations)) && o.reset(), o.setGroundTruth(r), r) : null;
4054
3920
  }
4055
3921
  /**
4056
3922
  * Sync a specific metric with the server
@@ -4067,8 +3933,8 @@ class vt {
4067
3933
  return this._stores.has(e) ? this._stores.get(e).queryset : null;
4068
3934
  }
4069
3935
  }
4070
- const Fe = new vt();
4071
- class Cr {
3936
+ const Pe = new wt();
3937
+ class pr {
4072
3938
  constructor(e) {
4073
3939
  this.event = e.event, this.model = e.model, this.operation_id = e.operation_id, this.pk_field_name = e.pk_field_name, this.configKey = e.configKey, this.canonical_id = e.canonical_id || null, this.server_ts_ms = e.server_ts_ms || null, this.instances = e.instances?.map((t) => t && this.pk_field_name && t[this.pk_field_name] != null ? {
4074
3940
  ...t,
@@ -4076,21 +3942,21 @@ class Cr {
4076
3942
  } : t) || e.instances, this._cachedInstances = null;
4077
3943
  }
4078
3944
  get modelClass() {
4079
- return ts(this.model, this.configKey);
3945
+ return Xt(this.model, this.configKey);
4080
3946
  }
4081
3947
  async getFullInstances() {
4082
3948
  if (this.event === "delete")
4083
3949
  throw new Error(
4084
3950
  "Cannot fetch full instances for delete operation bozo..."
4085
3951
  );
4086
- return E(this._cachedInstances) && (this._cachedInstances = await this.modelClass.objects.filter({
3952
+ return b(this._cachedInstances) && (this._cachedInstances = await this.modelClass.objects.filter({
4087
3953
  [`${this.modelClass.primaryKeyField}__in`]: this.instances.map(
4088
3954
  (e) => e[this.modelClass.primaryKeyField]
4089
3955
  )
4090
3956
  }).fetch()), this._cachedInstances;
4091
3957
  }
4092
3958
  }
4093
- class vr {
3959
+ class mr {
4094
3960
  constructor() {
4095
3961
  this.registries = /* @__PURE__ */ new Map(), this.followedModels = /* @__PURE__ */ new Map(), this.followAllQuerysets = !0, this.followedQuerysets = /* @__PURE__ */ new Map(), this.periodicSyncTimer = null, this.eventBatch = /* @__PURE__ */ new Map(), this.debounceTimer = null, this.maxWaitTimer = null, this.debounceMs = 100, this.maxWaitMs = 2e3, this.batchStartTime = null;
4096
3962
  }
@@ -4113,7 +3979,7 @@ class vr {
4113
3979
  * Initialize event handlers for all event receivers
4114
3980
  */
4115
3981
  initialize() {
4116
- Us(), zs().forEach((t, s) => {
3982
+ js(), zs().forEach((t, s) => {
4117
3983
  t && t.addModelEventHandler(this.handleEvent.bind(this));
4118
3984
  }), this.startPeriodicSync();
4119
3985
  }
@@ -4133,7 +3999,7 @@ class vr {
4133
3999
  async syncStaleQuerysets() {
4134
4000
  const e = this.registries.get(Ce);
4135
4001
  if (!e) return;
4136
- const t = `periodic-sync-${G()}`, s = new Set(
4002
+ const t = `periodic-sync-${B()}`, s = new Set(
4137
4003
  [...this.followedQuerysets].map((o) => o.semanticKey).filter((o) => e._stores.has(o))
4138
4004
  ), r = [];
4139
4005
  for (const [o, i] of e._stores.entries()) {
@@ -4147,7 +4013,7 @@ class vr {
4147
4013
  ), this.pruneUnreferencedModels();
4148
4014
  }
4149
4015
  pruneUnreferencedModels() {
4150
- const e = this.registries.get(Ge), t = this.registries.get(Ce);
4016
+ const e = this.registries.get(Ve), t = this.registries.get(Ce);
4151
4017
  if (!(!e || !t))
4152
4018
  for (const [s, r] of e._stores.entries())
4153
4019
  r.pruneUnreferencedInstances(t);
@@ -4165,7 +4031,7 @@ class vr {
4165
4031
  const r = [...this.followedModels.values()].some(
4166
4032
  (o) => o.has(t)
4167
4033
  );
4168
- s.add(t), r || Qt(t.configKey)?.subscribe(
4034
+ s.add(t), r || jt(t.configKey)?.subscribe(
4169
4035
  t.modelName,
4170
4036
  this.handleEvent
4171
4037
  );
@@ -4175,7 +4041,7 @@ class vr {
4175
4041
  if (!s) return;
4176
4042
  s.delete(t), [...this.followedModels.values()].some(
4177
4043
  (o) => o.has(t)
4178
- ) || Qt(t.configKey)?.unsubscribe(
4044
+ ) || jt(t.configKey)?.unsubscribe(
4179
4045
  t.modelName,
4180
4046
  this.handleEvent
4181
4047
  );
@@ -4192,7 +4058,7 @@ class vr {
4192
4058
  * Checks the `verify` flag on membership state to determine which querysets need syncing.
4193
4059
  */
4194
4060
  syncQuerysetsNeedingVerification(e) {
4195
- const t = Pe.getQuerysetStates(e);
4061
+ const t = Fe.getQuerysetStates(e);
4196
4062
  if (!t) return;
4197
4063
  const s = this.registries.get(Ce);
4198
4064
  if (!s) return;
@@ -4203,7 +4069,7 @@ class vr {
4203
4069
  c && r.push(c);
4204
4070
  }
4205
4071
  if (r.length === 0) return;
4206
- const o = `maybe-sync-${G()}`, i = new Set(
4072
+ const o = `maybe-sync-${B()}`, i = new Set(
4207
4073
  [...this.followedQuerysets].map((l) => l.semanticKey).filter((l) => s._stores.has(l))
4208
4074
  );
4209
4075
  Promise.all(
@@ -4213,7 +4079,7 @@ class vr {
4213
4079
  );
4214
4080
  }
4215
4081
  handleEvent = (e) => {
4216
- B({
4082
+ G({
4217
4083
  type: "event",
4218
4084
  modelName: e.model,
4219
4085
  configKey: e.configKey,
@@ -4223,8 +4089,8 @@ class vr {
4223
4089
  operationId: e.operation_id,
4224
4090
  socketId: e.socket_id
4225
4091
  });
4226
- let t = new Cr(e), s = Pe.has(t.operation_id);
4227
- if (this.registries.has(vt) && this.processMetrics(t), s) {
4092
+ let t = new pr(e), s = Fe.has(t.operation_id);
4093
+ if (this.registries.has(wt) && this.processMetrics(t), s) {
4228
4094
  this.syncQuerysetsNeedingVerification(t.operation_id);
4229
4095
  return;
4230
4096
  }
@@ -4251,7 +4117,7 @@ class vr {
4251
4117
  s.has(o) || s.set(o, []), s.get(o).push(r);
4252
4118
  }), s.forEach((r, o) => {
4253
4119
  const i = r[0];
4254
- this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(Ge) && this.processModels(i);
4120
+ this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(Ve) && this.processModels(i);
4255
4121
  });
4256
4122
  }
4257
4123
  isQuerysetFollowed(e) {
@@ -4268,20 +4134,20 @@ class vr {
4268
4134
  }
4269
4135
  processQuerysetsBatch(e, t) {
4270
4136
  const s = this.registries.get(Ce), r = [];
4271
- for (const [c, f] of s._stores.entries())
4272
- if (f.modelClass.modelName === e.model && f.modelClass.configKey === e.configKey) {
4137
+ for (const [c, h] of s._stores.entries())
4138
+ if (h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey) {
4273
4139
  if (this.followAllQuerysets) {
4274
- r.push(f);
4140
+ r.push(h);
4275
4141
  continue;
4276
4142
  }
4277
4143
  const p = s.followingQuerysets.get(c);
4278
- p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(f);
4144
+ p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(h);
4279
4145
  }
4280
4146
  if (r.length === 0) return;
4281
4147
  const i = t.reduce(
4282
- (c, f) => (f.server_ts_ms || 0) > (c.server_ts_ms || 0) ? f : c,
4148
+ (c, h) => (h.server_ts_ms || 0) > (c.server_ts_ms || 0) ? h : c,
4283
4149
  t[0]
4284
- ).canonical_id, l = `remote-event-${G()}`, a = new Set(
4150
+ ).canonical_id, l = `remote-event-${B()}`, a = new Set(
4285
4151
  [...this.followedQuerysets].map((c) => c.semanticKey).filter((c) => s._stores.has(c))
4286
4152
  );
4287
4153
  Promise.all(
@@ -4291,18 +4157,18 @@ class vr {
4291
4157
  );
4292
4158
  }
4293
4159
  processMetrics(e) {
4294
- const t = this.registries.get(vt);
4160
+ const t = this.registries.get(wt);
4295
4161
  for (const [s, r] of t._stores.entries())
4296
4162
  if (r.queryset && r.queryset.modelClass.modelName === e.model && r.queryset.modelClass.configKey === e.configKey) {
4297
4163
  if (this.followAllQuerysets) {
4298
4164
  r.store.sync();
4299
4165
  continue;
4300
4166
  }
4301
- this.isQuerysetFollowed(r.queryset) && r.store.sync();
4167
+ (t.followedMetrics.has(s) || this.isQuerysetFollowed(r.queryset)) && r.store.sync();
4302
4168
  }
4303
4169
  }
4304
4170
  processModels(e) {
4305
- const t = this.registries.get(Ge);
4171
+ const t = this.registries.get(Ve);
4306
4172
  if (!t) return;
4307
4173
  const s = t.getStore(e.modelClass);
4308
4174
  if (!s) return;
@@ -4312,105 +4178,105 @@ class vr {
4312
4178
  if (r.size === 0) return;
4313
4179
  const o = new Set(s.groundTruthPks), i = this.registries.get(Ce), l = /* @__PURE__ */ new Set();
4314
4180
  if (i)
4315
- for (const [c, f] of i._stores.entries())
4316
- f.modelClass.modelName === e.model && f.modelClass.configKey === e.configKey && f.groundTruthPks.forEach((p) => l.add(p));
4181
+ for (const [c, h] of i._stores.entries())
4182
+ h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey && h.groundTruthPks.forEach((p) => l.add(p));
4317
4183
  const a = [];
4318
4184
  r.forEach((c) => {
4319
4185
  o.has(c) && !l.has(c) && a.push(c);
4320
4186
  }), a.length > 0 && s.sync(a);
4321
4187
  }
4322
4188
  }
4323
- const $e = new vr();
4324
- $e.manageRegistry(j);
4325
- $e.manageRegistry(Q);
4326
- $e.manageRegistry(Fe);
4327
- const Er = /* @__PURE__ */ new Set();
4328
- function br(n) {
4329
- typeof n == "function" && Er.add(n);
4189
+ const Ae = new mr();
4190
+ Ae.manageRegistry(x);
4191
+ Ae.manageRegistry(j);
4192
+ Ae.manageRegistry(Pe);
4193
+ const yr = /* @__PURE__ */ new Set();
4194
+ function gr(n) {
4195
+ typeof n == "function" && yr.add(n);
4330
4196
  }
4331
- $e.followAllQuerysets = !1;
4332
- const ns = /* @__PURE__ */ new Map();
4333
- br(() => {
4334
- ns.clear(), $e.followAllQuerysets = !0, $e.followedQuerysets.clear();
4197
+ Ae.followAllQuerysets = !1;
4198
+ const rs = /* @__PURE__ */ new Map();
4199
+ gr(() => {
4200
+ rs.clear(), Ae.followAllQuerysets = !0, Ae.followedQuerysets.clear();
4335
4201
  });
4336
- const kr = (n, e) => {
4202
+ const _r = (n, e) => {
4337
4203
  const t = n.__vccOpts || n;
4338
4204
  for (const [s, r] of e)
4339
4205
  t[s] = r;
4340
4206
  return t;
4341
- }, Sr = { class: "szd" }, Tr = { class: "szd-header" }, Mr = { class: "szd-header__top" }, $r = { class: "szd-header__left" }, Ar = {
4207
+ }, wr = { class: "szd" }, Cr = { class: "szd-header" }, vr = { class: "szd-header__top" }, kr = { class: "szd-header__left" }, br = {
4342
4208
  key: 0,
4343
4209
  class: "szd-header__model"
4344
- }, Or = {
4210
+ }, Er = {
4345
4211
  key: 1,
4346
4212
  class: "szd-header__model szd-header__model--empty"
4347
- }, Pr = { class: "szd-header__right" }, Fr = {
4213
+ }, Sr = { class: "szd-header__right" }, Tr = {
4348
4214
  key: 0,
4349
4215
  class: "szd-header__badge szd-header__badge--syncing"
4350
- }, Ir = {
4216
+ }, Mr = {
4351
4217
  key: 1,
4352
4218
  class: "szd-header__badge"
4353
- }, Dr = { class: "szd-header__badge" }, zr = { class: "szd-tabs" }, Kr = ["onClick"], Rr = { class: "szd-content" }, Nr = {
4219
+ }, Ar = { class: "szd-header__badge" }, Or = { class: "szd-tabs" }, $r = ["onClick"], Fr = { class: "szd-content" }, Pr = {
4354
4220
  key: 0,
4355
4221
  class: "szd-panel"
4356
- }, xr = { class: "szd-panel__section" }, jr = { class: "szd-kv" }, Ur = { class: "szd-kv__row" }, Qr = { class: "szd-kv__value" }, Vr = { class: "szd-kv__row" }, Lr = { class: "szd-kv__value" }, Gr = { class: "szd-kv__row" }, Br = { class: "szd-kv__value" }, Hr = { class: "szd-kv__row" }, qr = { class: "szd-kv__value" }, Jr = { class: "szd-panel__section" }, Wr = { class: "szd-stats" }, Zr = { class: "szd-stat" }, Yr = { class: "szd-stat__value" }, Xr = { class: "szd-stat" }, en = { class: "szd-stat__value" }, tn = { class: "szd-stat" }, sn = { class: "szd-stat__value" }, rn = { class: "szd-stat" }, nn = { class: "szd-stat__value" }, on = {
4222
+ }, Dr = { class: "szd-panel__section" }, zr = { class: "szd-kv" }, Rr = { class: "szd-kv__row" }, Kr = { class: "szd-kv__value" }, Ir = { class: "szd-kv__row" }, Nr = { class: "szd-kv__value" }, xr = { class: "szd-kv__row" }, jr = { class: "szd-kv__value" }, Ur = { class: "szd-kv__row" }, Qr = { class: "szd-kv__value" }, Lr = { class: "szd-panel__section" }, Vr = { class: "szd-stats" }, Br = { class: "szd-stat" }, Gr = { class: "szd-stat__value" }, Hr = { class: "szd-stat" }, qr = { class: "szd-stat__value" }, Jr = { class: "szd-stat" }, Wr = { class: "szd-stat__value" }, Zr = { class: "szd-stat" }, Yr = { class: "szd-stat__value" }, Xr = {
4357
4223
  class: "szd-kv",
4358
4224
  style: { "margin-top": "12px" }
4359
- }, an = { class: "szd-kv__row" }, ln = { class: "szd-kv__value" }, cn = {
4225
+ }, en = { class: "szd-kv__row" }, tn = { class: "szd-kv__value" }, sn = {
4360
4226
  key: 0,
4361
4227
  class: "szd-panel__section"
4362
- }, dn = { class: "szd-event-preview__text" }, un = { class: "szd-event-preview__time" }, hn = {
4228
+ }, rn = { class: "szd-event-preview__text" }, nn = { class: "szd-event-preview__time" }, on = {
4363
4229
  key: 1,
4364
4230
  class: "szd-panel"
4365
- }, fn = { class: "szd-timeline-filters" }, pn = ["onUpdate:modelValue"], mn = { class: "szd-timeline" }, yn = ["onClick"], gn = { class: "szd-timeline__time" }, _n = { class: "szd-timeline__text" }, wn = {
4231
+ }, an = { class: "szd-timeline-filters" }, ln = ["onUpdate:modelValue"], cn = { class: "szd-timeline" }, dn = ["onClick"], un = { class: "szd-timeline__time" }, hn = { class: "szd-timeline__text" }, fn = {
4366
4232
  key: 0,
4367
4233
  class: "szd-empty"
4368
- }, Cn = {
4234
+ }, pn = {
4369
4235
  key: 2,
4370
4236
  class: "szd-panel"
4371
- }, vn = { class: "szd-pipeline" }, En = ["onClick"], bn = { class: "szd-pipeline__label" }, kn = { class: "szd-pipeline__count" }, Sn = {
4237
+ }, mn = { class: "szd-pipeline" }, yn = ["onClick"], gn = { class: "szd-pipeline__label" }, _n = { class: "szd-pipeline__count" }, wn = {
4372
4238
  key: 0,
4373
4239
  class: "szd-pipeline__arrow"
4374
- }, Tn = {
4240
+ }, Cn = {
4375
4241
  class: "szd-panel__section",
4376
4242
  style: { "margin-top": "20px" }
4377
- }, Mn = { class: "szd-preview-header" }, $n = ["value"], An = {
4243
+ }, vn = { class: "szd-preview-header" }, kn = ["value"], bn = {
4378
4244
  key: 0,
4379
4245
  class: "szd-data-grid"
4380
- }, On = { class: "szd-data-card__header" }, Pn = {
4246
+ }, En = { class: "szd-data-card__header" }, Sn = {
4381
4247
  key: 0,
4382
4248
  class: "szd-data-card__badge"
4383
- }, Fn = {
4249
+ }, Tn = {
4384
4250
  key: 1,
4385
4251
  class: "szd-data-card__badge szd-data-card__badge--absent"
4386
- }, In = { class: "szd-data-card__content" }, Dn = {
4252
+ }, Mn = { class: "szd-data-card__content" }, An = {
4387
4253
  key: 1,
4388
4254
  class: "szd-empty"
4389
- }, zn = {
4255
+ }, On = {
4390
4256
  key: 3,
4391
4257
  class: "szd-panel"
4392
- }, Kn = {
4258
+ }, $n = {
4393
4259
  class: "szd-kv",
4394
4260
  style: { "margin-bottom": "16px" }
4395
- }, Rn = { class: "szd-kv__row" }, Nn = { class: "szd-kv__value szd-kv__value--mono" }, xn = { class: "szd-ast" }, jn = {
4261
+ }, Fn = { class: "szd-kv__row" }, Pn = { class: "szd-kv__value szd-kv__value--mono" }, Dn = { class: "szd-ast" }, zn = {
4396
4262
  key: 0,
4397
4263
  class: "szd-detail"
4398
- }, Un = { class: "szd-detail__panel szd-detail__panel--sm" }, Qn = { class: "szd-detail__header" }, Vn = { class: "szd-detail__body" }, Ln = { class: "szd-settings-section" }, Gn = ["value"], Bn = {
4264
+ }, Rn = { class: "szd-detail__panel szd-detail__panel--sm" }, Kn = { class: "szd-detail__header" }, In = { class: "szd-detail__body" }, Nn = { class: "szd-settings-section" }, xn = ["value"], jn = {
4399
4265
  key: 0,
4400
4266
  class: "szd-settings-section"
4401
- }, Hn = { class: "szd-settings-row" }, qn = { class: "szd-settings-code" }, Jn = { class: "szd-settings-section" }, Wn = { class: "szd-settings-actions" }, Zn = ["disabled"], Yn = { class: "szd-settings-section" }, Xn = { class: "szd-toggle" }, eo = {
4267
+ }, Un = { class: "szd-settings-row" }, Qn = { class: "szd-settings-code" }, Ln = { class: "szd-settings-section" }, Vn = { class: "szd-settings-actions" }, Bn = ["disabled"], Gn = { class: "szd-settings-section" }, Hn = { class: "szd-toggle" }, qn = {
4402
4268
  key: 1,
4403
4269
  class: "szd-settings-section"
4404
- }, to = { class: "szd-kv" }, so = { class: "szd-kv__row" }, ro = { class: "szd-kv__value" }, no = { class: "szd-kv__row" }, oo = { class: "szd-kv__value" }, io = { class: "szd-kv__row" }, ao = { class: "szd-kv__value" }, lo = { class: "szd-kv__row" }, co = { class: "szd-kv__value" }, uo = { class: "szd-kv__row" }, ho = { class: "szd-kv__value" }, fo = {
4270
+ }, Jn = { class: "szd-kv" }, Wn = { class: "szd-kv__row" }, Zn = { class: "szd-kv__value" }, Yn = { class: "szd-kv__row" }, Xn = { class: "szd-kv__value" }, eo = { class: "szd-kv__row" }, to = { class: "szd-kv__value" }, so = { class: "szd-kv__row" }, ro = { class: "szd-kv__value" }, no = { class: "szd-kv__row" }, oo = { class: "szd-kv__value" }, io = {
4405
4271
  key: 0,
4406
4272
  class: "szd-detail"
4407
- }, po = { class: "szd-detail__panel" }, mo = { class: "szd-detail__header" }, yo = { class: "szd-detail__title" }, go = { class: "szd-detail__body" }, _o = { class: "szd-kv" }, wo = { class: "szd-kv__key" }, Co = { class: "szd-kv__value" }, vo = { class: "szd-ast" }, Eo = {
4273
+ }, ao = { class: "szd-detail__panel" }, lo = { class: "szd-detail__header" }, co = { class: "szd-detail__title" }, uo = { class: "szd-detail__body" }, ho = { class: "szd-kv" }, fo = { class: "szd-kv__key" }, po = { class: "szd-kv__value" }, mo = { class: "szd-ast" }, yo = {
4408
4274
  class: "szd-kv",
4409
4275
  style: { "margin-bottom": "16px" }
4410
- }, bo = { class: "szd-kv__row" }, ko = { class: "szd-kv__value" }, So = { class: "szd-kv__row" }, To = { class: "szd-kv__value" }, Mo = {
4276
+ }, go = { class: "szd-kv__row" }, _o = { class: "szd-kv__value" }, wo = { class: "szd-kv__row" }, Co = { class: "szd-kv__value" }, vo = {
4411
4277
  key: 0,
4412
4278
  class: "szd-kv__note"
4413
- }, $o = { class: "szd-ast" }, Zt = 100, Ao = {
4279
+ }, ko = { class: "szd-ast" }, Jt = 100, bo = {
4414
4280
  __name: "StateZeroDebugPanel",
4415
4281
  props: {
4416
4282
  queryset: { type: [Object, String], default: null },
@@ -4424,7 +4290,7 @@ const kr = (n, e) => {
4424
4290
  { id: "timeline", label: "Timeline" },
4425
4291
  { id: "data", label: "Data" },
4426
4292
  { id: "ast", label: "AST" }
4427
- ], r = J(""), o = J(e.useQueryset), i = J(!0), l = J(Lt()), a = J(0), c = J(!1), f = J(null), p = J(!1), m = J(null), y = J({
4293
+ ], r = J(""), o = J(e.useQueryset), i = J(!0), l = J(Qt()), a = J(0), c = J(!1), h = J(null), p = J(!1), m = J(null), y = J({
4428
4294
  request: !0,
4429
4295
  response: !0,
4430
4296
  render: !0,
@@ -4440,12 +4306,12 @@ const kr = (n, e) => {
4440
4306
  let g = u;
4441
4307
  return d && g && typeof g == "object" && "value" in g && (g = g.value), g?.original?.queryset ? g.original.queryset : g?.queryset ? g.queryset : g?.semanticKey ? g : null;
4442
4308
  }
4443
- const w = R(
4309
+ const w = I(
4444
4310
  () => _(e.queryset, o.value)
4445
- ), v = R(() => {
4311
+ ), v = I(() => {
4446
4312
  a.value;
4447
4313
  const u = [];
4448
- return ns.forEach((d) => {
4314
+ return rs.forEach((d) => {
4449
4315
  d?.semanticKey && u.push({
4450
4316
  semanticKey: d.semanticKey,
4451
4317
  modelName: d.ModelClass?.modelName,
@@ -4453,50 +4319,50 @@ const kr = (n, e) => {
4453
4319
  queryset: d
4454
4320
  });
4455
4321
  }), u;
4456
- }), O = R(() => (a.value, Array.from(j._stores.entries()).map(
4322
+ }), O = I(() => (a.value, Array.from(x._stores.entries()).map(
4457
4323
  ([u, d]) => ({
4458
4324
  semanticKey: u,
4459
4325
  modelName: d?.modelClass?.modelName,
4460
4326
  configKey: d?.modelClass?.configKey,
4461
4327
  store: d
4462
4328
  })
4463
- ))), T = R(() => {
4329
+ ))), T = I(() => {
4464
4330
  const u = /* @__PURE__ */ new Map();
4465
4331
  return v.value.forEach((d) => {
4466
4332
  u.set(d.semanticKey, d.queryset);
4467
4333
  }), u;
4468
- }), b = R(() => {
4334
+ }), k = I(() => {
4469
4335
  const u = /* @__PURE__ */ new Map();
4470
4336
  return v.value.forEach((d) => {
4471
4337
  u.set(d.semanticKey, d);
4472
4338
  }), O.value.forEach((d) => {
4473
4339
  u.has(d.semanticKey) || u.set(d.semanticKey, d);
4474
4340
  }), Array.from(u.values());
4475
- }), k = R(() => w.value?.semanticKey ? w.value.semanticKey : r.value ? r.value : ""), U = R(() => w.value ? w.value : r.value && T.value.get(r.value) || null), N = R(() => {
4476
- if (U.value)
4341
+ }), E = I(() => w.value?.semanticKey ? w.value.semanticKey : r.value ? r.value : ""), Q = I(() => w.value ? w.value : r.value && T.value.get(r.value) || null), N = I(() => {
4342
+ if (Q.value)
4477
4343
  try {
4478
- return j.getStore(U.value);
4344
+ return x.getStore(Q.value);
4479
4345
  } catch {
4480
4346
  return null;
4481
4347
  }
4482
- return k.value && j._stores.get(k.value) || null;
4483
- }), F = R(() => {
4348
+ return E.value && x._stores.get(E.value) || null;
4349
+ }), F = I(() => {
4484
4350
  a.value;
4485
- const u = N.value, d = U.value, g = u?.modelClass?.modelName || d?.ModelClass?.modelName, z = u?.modelClass?.configKey || d?.ModelClass?.configKey, H = u?.groundTruthPks?.length ?? 0, oe = u?.operationsMap?.size ?? 0, le = u?.getInflightOperations?.() || [], be = u?.isSyncing ?? !1, Ue = u?.lastSync ? new Date(u.lastSync).toLocaleString() : "—", ot = u && Array.isArray(u._lastRenderedPks) ? u._lastRenderedPks.length : null, ds = u?.groundTruthPks?.length ?? 0, us = u ? u.lastSync === null ? "model store" : "ground truth" : "—", hs = be ? "Sync in progress — results may change." : oe > 0 ? "Optimistic operations are applied to results." : u?.lastSync === null ? "No ground truth yet — rendering from model store." : "Using ground truth + local filters.";
4351
+ const u = N.value, d = Q.value, g = u?.modelClass?.modelName || d?.ModelClass?.modelName, R = u?.modelClass?.configKey || d?.ModelClass?.configKey, H = u?.groundTruthPks?.length ?? 0, oe = u?.operationsMap?.size ?? 0, le = u?.getInflightOperations?.() || [], be = u?.isSyncing ?? !1, je = u?.lastSync ? new Date(u.lastSync).toLocaleString() : "—", nt = u && Array.isArray(u._lastRenderedPks) ? u._lastRenderedPks.length : null, cs = u?.groundTruthPks?.length ?? 0, ds = u ? u.lastSync === null ? "model store" : "ground truth" : "—", us = be ? "Sync in progress — results may change." : oe > 0 ? "Optimistic operations are applied to results." : u?.lastSync === null ? "No ground truth yet — rendering from model store." : "Using ground truth + local filters.";
4486
4352
  return {
4487
4353
  modelName: g,
4488
- configKey: z,
4354
+ configKey: R,
4489
4355
  groundTruthCount: H,
4490
4356
  opsCount: oe,
4491
4357
  inFlightCount: le.length,
4492
4358
  isSyncing: be,
4493
- lastSync: Ue,
4494
- optimisticCount: ot,
4495
- confirmedCount: ds,
4496
- source: us,
4497
- reason: hs
4359
+ lastSync: je,
4360
+ optimisticCount: nt,
4361
+ confirmedCount: cs,
4362
+ source: ds,
4363
+ reason: us
4498
4364
  };
4499
- }), re = R(() => {
4365
+ }), re = I(() => {
4500
4366
  a.value;
4501
4367
  try {
4502
4368
  return N.value?.queryset?.build?.() || null;
@@ -4507,13 +4373,13 @@ const kr = (n, e) => {
4507
4373
  function pe(u) {
4508
4374
  if (!u?.filter?.conditions) return "—";
4509
4375
  const d = u.filter.conditions;
4510
- return typeof d != "object" ? String(d) : Object.entries(d).map(([z, H]) => H === null ? `${z}: null` : typeof H == "object" ? `${z}: ${JSON.stringify(H)}` : `${z}: ${H}`).join(", ");
4376
+ return typeof d != "object" ? String(d) : Object.entries(d).map(([R, H]) => H === null ? `${R}: null` : typeof H == "object" ? `${R}: ${JSON.stringify(H)}` : `${R}: ${H}`).join(", ");
4511
4377
  }
4512
4378
  function ae(u) {
4513
4379
  const d = u?.orderBy;
4514
4380
  return !d || Array.isArray(d) && d.length === 0 ? "—" : Array.isArray(d) ? d.join(", ") : String(d);
4515
4381
  }
4516
- const D = R(() => {
4382
+ const z = I(() => {
4517
4383
  const u = re.value;
4518
4384
  return {
4519
4385
  filter: pe(u),
@@ -4521,10 +4387,10 @@ const kr = (n, e) => {
4521
4387
  limit: u?.serializerOptions?.limit ?? "—"
4522
4388
  };
4523
4389
  });
4524
- function I(u, d, g, z) {
4390
+ function D(u, d, g, R) {
4525
4391
  if (!u || !Array.isArray(g)) return [];
4526
4392
  const H = [];
4527
- for (const oe of g.slice(0, z))
4393
+ for (const oe of g.slice(0, R))
4528
4394
  try {
4529
4395
  const le = u.fromPk(oe, d);
4530
4396
  le && H.push(le.serialize());
@@ -4532,9 +4398,9 @@ const kr = (n, e) => {
4532
4398
  }
4533
4399
  return H;
4534
4400
  }
4535
- const K = R(() => {
4401
+ const K = I(() => {
4536
4402
  a.value;
4537
- const u = N.value, d = U.value;
4403
+ const u = N.value, d = Q.value;
4538
4404
  if (!u || !d)
4539
4405
  return {
4540
4406
  modelStoreFiltered: [],
@@ -4549,7 +4415,7 @@ const kr = (n, e) => {
4549
4415
  finalSample: [],
4550
4416
  limit: null
4551
4417
  };
4552
- const g = Array.isArray(u.groundTruthPks) ? [...u.groundTruthPks] : [], z = u.renderFromData(!0), H = u.renderFromData(!1), oe = u._getValidatedAndFilteredPks(z), le = u.lastSync === null ? u.renderFromModelStore() : [], be = d.build()?.serializerOptions?.limit ?? null, Ue = be ? oe.slice(0, be) : oe, ot = le.length > 0 ? I(
4418
+ const g = Array.isArray(u.groundTruthPks) ? [...u.groundTruthPks] : [], R = u.renderFromData(!0), H = u.renderFromData(!1), oe = u._getValidatedAndFilteredPks(R), le = [], be = d.build()?.serializerOptions?.limit ?? null, je = be ? oe.slice(0, be) : oe, nt = le.length > 0 ? D(
4553
4419
  u.modelClass,
4554
4420
  d,
4555
4421
  le,
@@ -4558,66 +4424,66 @@ const kr = (n, e) => {
4558
4424
  return {
4559
4425
  modelStoreFiltered: le,
4560
4426
  groundTruth: g,
4561
- optimistic: z,
4427
+ optimistic: R,
4562
4428
  filtered: oe,
4563
- final: Ue,
4564
- modelStoreSample: ot,
4565
- groundTruthSample: I(
4429
+ final: je,
4430
+ modelStoreSample: nt,
4431
+ groundTruthSample: D(
4566
4432
  u.modelClass,
4567
4433
  d,
4568
4434
  g,
4569
4435
  e.sampleSize
4570
4436
  ),
4571
- optimisticSample: I(
4437
+ optimisticSample: D(
4572
4438
  u.modelClass,
4573
4439
  d,
4574
- z,
4440
+ R,
4575
4441
  e.sampleSize
4576
4442
  ),
4577
- filteredSample: I(
4443
+ filteredSample: D(
4578
4444
  u.modelClass,
4579
4445
  d,
4580
4446
  oe,
4581
4447
  e.sampleSize
4582
4448
  ),
4583
- finalSample: I(
4449
+ finalSample: D(
4584
4450
  u.modelClass,
4585
4451
  d,
4586
- Ue,
4452
+ je,
4587
4453
  e.sampleSize
4588
4454
  ),
4589
4455
  limit: be,
4590
4456
  confirmed: H
4591
4457
  };
4592
- }), me = R(() => [
4458
+ }), me = I(() => [
4593
4459
  { id: "model-store", label: "Model Store", count: K.value.modelStoreFiltered.length, pks: K.value.modelStoreFiltered },
4594
4460
  { id: "ground-truth", label: "Ground Truth", count: K.value.groundTruth.length, pks: K.value.groundTruth },
4595
4461
  { id: "optimistic", label: "Optimistic", count: K.value.optimistic.length, pks: K.value.optimistic },
4596
4462
  { id: "filtered", label: "Filtered", count: K.value.filtered.length, pks: K.value.filtered },
4597
4463
  { id: "final", label: "Final", count: K.value.final.length, pks: K.value.final }
4598
- ]), Ye = R(() => K.value.final || []);
4464
+ ]), Ze = I(() => K.value.final || []);
4599
4465
  function ye(u) {
4600
- const d = N.value, g = U.value;
4466
+ const d = N.value, g = Q.value;
4601
4467
  if (!d || !g || u == null) return null;
4602
4468
  try {
4603
- const z = d.modelClass.fromPk(u, g);
4604
- return z ? z.serialize() : null;
4469
+ const R = d.modelClass.fromPk(u, g);
4470
+ return R ? R.serialize() : null;
4605
4471
  } catch {
4606
4472
  return null;
4607
4473
  }
4608
4474
  }
4609
- R(() => m.value == null ? null : ye(m.value));
4610
- const Ke = R(() => {
4611
- if (!f.value || f.value.type !== "snapshot") return [];
4612
- const u = f.value.data, d = N.value, g = U.value;
4613
- return !d || !g || !u.pks ? [] : I(d.modelClass, g, u.pks, Zt);
4614
- }), Xe = R(() => !f.value || f.value.type !== "snapshot" ? !1 : f.value.data.count > Zt), Re = R(() => {
4615
- if (!k.value) return l.value;
4475
+ I(() => m.value == null ? null : ye(m.value));
4476
+ const Re = I(() => {
4477
+ if (!h.value || h.value.type !== "snapshot") return [];
4478
+ const u = h.value.data, d = N.value, g = Q.value;
4479
+ return !d || !g || !u.pks ? [] : D(d.modelClass, g, u.pks, Jt);
4480
+ }), Ye = I(() => !h.value || h.value.type !== "snapshot" ? !1 : h.value.data.count > Jt), Ke = I(() => {
4481
+ if (!E.value) return l.value;
4616
4482
  const u = N.value;
4617
- return l.value.filter((d) => d.semanticKey === k.value ? !0 : u ? d.modelName === u.modelClass?.modelName && d.configKey === u.modelClass?.configKey : !1);
4618
- }), Ee = R(() => Re.value.filter((u) => y.value[u.type])), Ne = R(() => l.value.length), ne = R(
4483
+ return l.value.filter((d) => d.semanticKey === E.value ? !0 : u ? d.modelName === u.modelClass?.modelName && d.configKey === u.modelClass?.configKey : !1);
4484
+ }), ke = I(() => Ke.value.filter((u) => y.value[u.type])), Ie = I(() => l.value.length), ne = I(
4619
4485
  () => l.value.length ? l.value[l.value.length - 1] : null
4620
- ), xe = [
4486
+ ), Ne = [
4621
4487
  { id: "request", label: "Requests", color: "#3b82f6" },
4622
4488
  { id: "response", label: "Responses", color: "#22c55e" },
4623
4489
  { id: "render", label: "Renders", color: "#a855f7" },
@@ -4628,10 +4494,10 @@ const kr = (n, e) => {
4628
4494
  { id: "groupSync", label: "Group Sync", color: "#8b5cf6" },
4629
4495
  { id: "error", label: "Errors", color: "#ef4444" }
4630
4496
  ];
4631
- function je(u) {
4632
- return xe.find((d) => d.id === u)?.color || "#6b7280";
4497
+ function xe(u) {
4498
+ return Ne.find((d) => d.id === u)?.color || "#6b7280";
4633
4499
  }
4634
- function et(u) {
4500
+ function Xe(u) {
4635
4501
  if (!u) return "";
4636
4502
  try {
4637
4503
  return new Date(u).toLocaleTimeString();
@@ -4639,7 +4505,7 @@ const kr = (n, e) => {
4639
4505
  return "";
4640
4506
  }
4641
4507
  }
4642
- function bt(u) {
4508
+ function vt(u) {
4643
4509
  if (!u) return "";
4644
4510
  switch (u.type) {
4645
4511
  case "request":
@@ -4664,11 +4530,11 @@ const kr = (n, e) => {
4664
4530
  return u.type;
4665
4531
  }
4666
4532
  }
4667
- function os(u) {
4533
+ function ns(u) {
4668
4534
  if (!u) return null;
4669
4535
  const d = {
4670
4536
  type: u.type,
4671
- time: et(u.ts),
4537
+ time: Xe(u.ts),
4672
4538
  model: u.modelName,
4673
4539
  config: u.configKey,
4674
4540
  semanticKey: u.semanticKey
@@ -4696,13 +4562,13 @@ const kr = (n, e) => {
4696
4562
  return d;
4697
4563
  }
4698
4564
  }
4699
- function is() {
4565
+ function os() {
4700
4566
  Bs(), l.value = [];
4701
4567
  }
4702
- function as() {
4703
- !k.value || !navigator?.clipboard || navigator.clipboard.writeText(k.value);
4568
+ function is() {
4569
+ !E.value || !navigator?.clipboard || navigator.clipboard.writeText(E.value);
4704
4570
  }
4705
- async function ls() {
4571
+ async function as() {
4706
4572
  if (!(!N.value || c.value)) {
4707
4573
  c.value = !0;
4708
4574
  try {
@@ -4714,59 +4580,59 @@ const kr = (n, e) => {
4714
4580
  }
4715
4581
  }
4716
4582
  function kt(u) {
4717
- f.value = { type: "entry", data: u };
4583
+ h.value = { type: "entry", data: u };
4718
4584
  }
4719
- function cs(u) {
4720
- f.value = { type: "snapshot", data: u };
4585
+ function ls(u) {
4586
+ h.value = { type: "snapshot", data: u };
4721
4587
  }
4722
- function St() {
4723
- f.value = null;
4588
+ function bt() {
4589
+ h.value = null;
4724
4590
  }
4725
- function Tt(u) {
4591
+ function Et(u) {
4726
4592
  Object.keys(y.value).forEach((d) => {
4727
4593
  y.value[d] = u;
4728
4594
  });
4729
4595
  }
4730
- let tt = null, st = null, rt = null, nt = null;
4731
- return fs(() => {
4732
- Hs(), Gt(e.maxEntries), tt = Ls((u) => {
4596
+ let et = null, tt = null, st = null, rt = null;
4597
+ return hs(() => {
4598
+ Gs(), Lt(e.maxEntries), et = Ls((u) => {
4733
4599
  i.value && (l.value = [...l.value, u], l.value.length > e.maxEntries && (l.value = l.value.slice(-e.maxEntries)));
4734
- }), st = Gs(() => {
4600
+ }), tt = Vs(() => {
4735
4601
  l.value = [];
4736
- }), rt = setInterval(() => {
4602
+ }), st = setInterval(() => {
4737
4603
  a.value += 1;
4738
- }, 2e3), nt = setInterval(() => {
4739
- l.value = Lt();
4604
+ }, 2e3), rt = setInterval(() => {
4605
+ l.value = Qt();
4740
4606
  }, 1e3);
4741
- }), ps(() => {
4742
- tt && tt(), st && st(), rt && clearInterval(rt), nt && clearInterval(nt);
4743
- }), it(
4607
+ }), fs(() => {
4608
+ et && et(), tt && tt(), st && clearInterval(st), rt && clearInterval(rt);
4609
+ }), ot(
4744
4610
  () => e.maxEntries,
4745
- (u) => Gt(u)
4746
- ), it(
4611
+ (u) => Lt(u)
4612
+ ), ot(
4747
4613
  () => e.useQueryset,
4748
4614
  (u) => {
4749
4615
  o.value = u;
4750
4616
  }
4751
- ), it(k, () => {
4617
+ ), ot(E, () => {
4752
4618
  m.value = null;
4753
- }), (u, d) => (A(), $("section", Sr, [
4754
- h("header", Tr, [
4755
- h("div", Mr, [
4756
- h("div", $r, [
4757
- d[9] || (d[9] = h("div", { class: "szd-header__title" }, "StateZero", -1)),
4758
- k.value ? (A(), $("span", Ar, S(F.value.modelName || "?"), 1)) : (A(), $("span", Or, "No queryset"))
4619
+ }), (u, d) => (A(), M("section", wr, [
4620
+ f("header", Cr, [
4621
+ f("div", vr, [
4622
+ f("div", kr, [
4623
+ d[9] || (d[9] = f("div", { class: "szd-header__title" }, "StateZero", -1)),
4624
+ E.value ? (A(), M("span", br, S(F.value.modelName || "?"), 1)) : (A(), M("span", Er, "No queryset"))
4759
4625
  ]),
4760
- h("div", Pr, [
4761
- F.value.isSyncing ? (A(), $("span", Fr, "Syncing")) : V("", !0),
4762
- F.value.opsCount > 0 ? (A(), $("span", Ir, S(F.value.opsCount) + " ops", 1)) : V("", !0),
4763
- h("span", Dr, S(Ne.value) + " events", 1),
4764
- h("button", {
4626
+ f("div", Sr, [
4627
+ F.value.isSyncing ? (A(), M("span", Tr, "Syncing")) : L("", !0),
4628
+ F.value.opsCount > 0 ? (A(), M("span", Mr, S(F.value.opsCount) + " ops", 1)) : L("", !0),
4629
+ f("span", Ar, S(Ie.value) + " events", 1),
4630
+ f("button", {
4765
4631
  class: "szd-btn szd-btn--icon",
4766
4632
  onClick: d[0] || (d[0] = (g) => p.value = !0),
4767
4633
  title: "Settings"
4768
4634
  }, [...d[10] || (d[10] = [
4769
- h("svg", {
4635
+ f("svg", {
4770
4636
  width: "16",
4771
4637
  height: "16",
4772
4638
  viewBox: "0 0 24 24",
@@ -4774,339 +4640,339 @@ const kr = (n, e) => {
4774
4640
  stroke: "currentColor",
4775
4641
  "stroke-width": "2"
4776
4642
  }, [
4777
- h("circle", {
4643
+ f("circle", {
4778
4644
  cx: "12",
4779
4645
  cy: "12",
4780
4646
  r: "3"
4781
4647
  }),
4782
- h("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" })
4648
+ f("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" })
4783
4649
  ], -1)
4784
4650
  ])])
4785
4651
  ])
4786
4652
  ]),
4787
- h("nav", zr, [
4788
- (A(), $(W, null, ce(s, (g) => h("button", {
4653
+ f("nav", Or, [
4654
+ (A(), M(W, null, ce(s, (g) => f("button", {
4789
4655
  key: g.id,
4790
- class: $t(["szd-tabs__tab", { "szd-tabs__tab--active": t.value === g.id }]),
4791
- onClick: (z) => t.value = g.id
4792
- }, S(g.label), 11, Kr)), 64))
4656
+ class: Tt(["szd-tabs__tab", { "szd-tabs__tab--active": t.value === g.id }]),
4657
+ onClick: (R) => t.value = g.id
4658
+ }, S(g.label), 11, $r)), 64))
4793
4659
  ])
4794
4660
  ]),
4795
- h("main", Rr, [
4796
- t.value === "overview" ? (A(), $("div", Nr, [
4797
- h("div", xr, [
4798
- d[15] || (d[15] = h("h3", { class: "szd-panel__heading" }, "Why This View?", -1)),
4799
- h("div", jr, [
4800
- h("div", Ur, [
4801
- d[11] || (d[11] = h("span", { class: "szd-kv__key" }, "Filter:", -1)),
4802
- h("span", Qr, S(D.value.filter), 1)
4661
+ f("main", Fr, [
4662
+ t.value === "overview" ? (A(), M("div", Pr, [
4663
+ f("div", Dr, [
4664
+ d[15] || (d[15] = f("h3", { class: "szd-panel__heading" }, "Why This View?", -1)),
4665
+ f("div", zr, [
4666
+ f("div", Rr, [
4667
+ d[11] || (d[11] = f("span", { class: "szd-kv__key" }, "Filter:", -1)),
4668
+ f("span", Kr, S(z.value.filter), 1)
4803
4669
  ]),
4804
- h("div", Vr, [
4805
- d[12] || (d[12] = h("span", { class: "szd-kv__key" }, "Order:", -1)),
4806
- h("span", Lr, S(D.value.orderBy), 1)
4670
+ f("div", Ir, [
4671
+ d[12] || (d[12] = f("span", { class: "szd-kv__key" }, "Order:", -1)),
4672
+ f("span", Nr, S(z.value.orderBy), 1)
4807
4673
  ]),
4808
- h("div", Gr, [
4809
- d[13] || (d[13] = h("span", { class: "szd-kv__key" }, "Limit:", -1)),
4810
- h("span", Br, S(D.value.limit), 1)
4674
+ f("div", xr, [
4675
+ d[13] || (d[13] = f("span", { class: "szd-kv__key" }, "Limit:", -1)),
4676
+ f("span", jr, S(z.value.limit), 1)
4811
4677
  ]),
4812
- h("div", Hr, [
4813
- d[14] || (d[14] = h("span", { class: "szd-kv__key" }, "Reason:", -1)),
4814
- h("span", qr, S(F.value.reason), 1)
4678
+ f("div", Ur, [
4679
+ d[14] || (d[14] = f("span", { class: "szd-kv__key" }, "Reason:", -1)),
4680
+ f("span", Qr, S(F.value.reason), 1)
4815
4681
  ])
4816
4682
  ])
4817
4683
  ]),
4818
- h("div", Jr, [
4819
- d[21] || (d[21] = h("h3", { class: "szd-panel__heading" }, "Current State", -1)),
4820
- h("div", Wr, [
4821
- h("div", Zr, [
4822
- h("div", Yr, S(F.value.optimisticCount ?? "—"), 1),
4823
- d[16] || (d[16] = h("div", { class: "szd-stat__label" }, "Optimistic", -1))
4684
+ f("div", Lr, [
4685
+ d[21] || (d[21] = f("h3", { class: "szd-panel__heading" }, "Current State", -1)),
4686
+ f("div", Vr, [
4687
+ f("div", Br, [
4688
+ f("div", Gr, S(F.value.optimisticCount ?? "—"), 1),
4689
+ d[16] || (d[16] = f("div", { class: "szd-stat__label" }, "Optimistic", -1))
4824
4690
  ]),
4825
- h("div", Xr, [
4826
- h("div", en, S(F.value.confirmedCount), 1),
4827
- d[17] || (d[17] = h("div", { class: "szd-stat__label" }, "Confirmed", -1))
4691
+ f("div", Hr, [
4692
+ f("div", qr, S(F.value.confirmedCount), 1),
4693
+ d[17] || (d[17] = f("div", { class: "szd-stat__label" }, "Confirmed", -1))
4828
4694
  ]),
4829
- h("div", tn, [
4830
- h("div", sn, S(F.value.groundTruthCount), 1),
4831
- d[18] || (d[18] = h("div", { class: "szd-stat__label" }, "Ground Truth", -1))
4695
+ f("div", Jr, [
4696
+ f("div", Wr, S(F.value.groundTruthCount), 1),
4697
+ d[18] || (d[18] = f("div", { class: "szd-stat__label" }, "Ground Truth", -1))
4832
4698
  ]),
4833
- h("div", rn, [
4834
- h("div", nn, S(F.value.inFlightCount), 1),
4835
- d[19] || (d[19] = h("div", { class: "szd-stat__label" }, "In-Flight", -1))
4699
+ f("div", Zr, [
4700
+ f("div", Yr, S(F.value.inFlightCount), 1),
4701
+ d[19] || (d[19] = f("div", { class: "szd-stat__label" }, "In-Flight", -1))
4836
4702
  ])
4837
4703
  ]),
4838
- h("div", on, [
4839
- h("div", an, [
4840
- d[20] || (d[20] = h("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4841
- h("span", ln, S(F.value.lastSync), 1)
4704
+ f("div", Xr, [
4705
+ f("div", en, [
4706
+ d[20] || (d[20] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4707
+ f("span", tn, S(F.value.lastSync), 1)
4842
4708
  ])
4843
4709
  ])
4844
4710
  ]),
4845
- ne.value ? (A(), $("div", cn, [
4846
- d[22] || (d[22] = h("h3", { class: "szd-panel__heading" }, "Last Event", -1)),
4847
- h("button", {
4711
+ ne.value ? (A(), M("div", sn, [
4712
+ d[22] || (d[22] = f("h3", { class: "szd-panel__heading" }, "Last Event", -1)),
4713
+ f("button", {
4848
4714
  class: "szd-event-preview",
4849
4715
  onClick: d[1] || (d[1] = (g) => kt(ne.value))
4850
4716
  }, [
4851
- h("span", {
4717
+ f("span", {
4852
4718
  class: "szd-event-preview__badge",
4853
- style: at({ background: je(ne.value.type) })
4719
+ style: it({ background: xe(ne.value.type) })
4854
4720
  }, S(ne.value.type), 5),
4855
- h("span", dn, S(bt(ne.value)), 1),
4856
- h("span", un, S(et(ne.value.ts)), 1)
4721
+ f("span", rn, S(vt(ne.value)), 1),
4722
+ f("span", nn, S(Xe(ne.value.ts)), 1)
4857
4723
  ])
4858
- ])) : V("", !0)
4859
- ])) : V("", !0),
4860
- t.value === "timeline" ? (A(), $("div", hn, [
4861
- h("div", fn, [
4862
- h("button", {
4724
+ ])) : L("", !0)
4725
+ ])) : L("", !0),
4726
+ t.value === "timeline" ? (A(), M("div", on, [
4727
+ f("div", an, [
4728
+ f("button", {
4863
4729
  class: "szd-btn szd-btn--sm",
4864
- onClick: d[2] || (d[2] = (g) => Tt(!0))
4730
+ onClick: d[2] || (d[2] = (g) => Et(!0))
4865
4731
  }, "All"),
4866
- h("button", {
4732
+ f("button", {
4867
4733
  class: "szd-btn szd-btn--sm",
4868
- onClick: d[3] || (d[3] = (g) => Tt(!1))
4734
+ onClick: d[3] || (d[3] = (g) => Et(!1))
4869
4735
  }, "None"),
4870
- (A(), $(W, null, ce(xe, (g) => h("label", {
4736
+ (A(), M(W, null, ce(Ne, (g) => f("label", {
4871
4737
  key: g.id,
4872
- class: $t(["szd-filter-chip", { "szd-filter-chip--active": y.value[g.id] }]),
4873
- style: at(y.value[g.id] ? { background: g.color, borderColor: g.color } : {})
4738
+ class: Tt(["szd-filter-chip", { "szd-filter-chip--active": y.value[g.id] }]),
4739
+ style: it(y.value[g.id] ? { background: g.color, borderColor: g.color } : {})
4874
4740
  }, [
4875
- Qe(h("input", {
4741
+ Ue(f("input", {
4876
4742
  type: "checkbox",
4877
- "onUpdate:modelValue": (z) => y.value[g.id] = z,
4743
+ "onUpdate:modelValue": (R) => y.value[g.id] = R,
4878
4744
  class: "szd-filter-chip__input"
4879
- }, null, 8, pn), [
4880
- [At, y.value[g.id]]
4745
+ }, null, 8, ln), [
4746
+ [Mt, y.value[g.id]]
4881
4747
  ]),
4882
- Ve(" " + S(g.label), 1)
4748
+ Qe(" " + S(g.label), 1)
4883
4749
  ], 6)), 64))
4884
4750
  ]),
4885
- h("div", mn, [
4886
- (A(!0), $(W, null, ce(Ee.value, (g) => (A(), $("div", {
4751
+ f("div", cn, [
4752
+ (A(!0), M(W, null, ce(ke.value, (g) => (A(), M("div", {
4887
4753
  key: g.id,
4888
4754
  class: "szd-timeline__item",
4889
- onClick: (z) => kt(g)
4755
+ onClick: (R) => kt(g)
4890
4756
  }, [
4891
- h("span", gn, S(et(g.ts)), 1),
4892
- h("span", {
4757
+ f("span", un, S(Xe(g.ts)), 1),
4758
+ f("span", {
4893
4759
  class: "szd-timeline__badge",
4894
- style: at({ background: je(g.type) })
4760
+ style: it({ background: xe(g.type) })
4895
4761
  }, S(g.type), 5),
4896
- h("span", _n, S(bt(g)), 1)
4897
- ], 8, yn))), 128)),
4898
- Ee.value.length ? V("", !0) : (A(), $("div", wn, " No events match current filters "))
4762
+ f("span", hn, S(vt(g)), 1)
4763
+ ], 8, dn))), 128)),
4764
+ ke.value.length ? L("", !0) : (A(), M("div", fn, " No events match current filters "))
4899
4765
  ])
4900
- ])) : V("", !0),
4901
- t.value === "data" ? (A(), $("div", Cn, [
4902
- d[25] || (d[25] = h("h3", { class: "szd-panel__heading" }, "Data Pipeline", -1)),
4903
- h("div", vn, [
4904
- (A(!0), $(W, null, ce(me.value, (g, z) => (A(), $(W, {
4766
+ ])) : L("", !0),
4767
+ t.value === "data" ? (A(), M("div", pn, [
4768
+ d[25] || (d[25] = f("h3", { class: "szd-panel__heading" }, "Data Pipeline", -1)),
4769
+ f("div", mn, [
4770
+ (A(!0), M(W, null, ce(me.value, (g, R) => (A(), M(W, {
4905
4771
  key: g.id
4906
4772
  }, [
4907
- h("div", {
4773
+ f("div", {
4908
4774
  class: "szd-pipeline__stage",
4909
- onClick: (H) => cs(g)
4775
+ onClick: (H) => ls(g)
4910
4776
  }, [
4911
- h("div", bn, S(g.label), 1),
4912
- h("div", kn, S(g.count), 1)
4913
- ], 8, En),
4914
- z < me.value.length - 1 ? (A(), $("div", Sn, "→")) : V("", !0)
4777
+ f("div", gn, S(g.label), 1),
4778
+ f("div", _n, S(g.count), 1)
4779
+ ], 8, yn),
4780
+ R < me.value.length - 1 ? (A(), M("div", wn, "→")) : L("", !0)
4915
4781
  ], 64))), 128))
4916
4782
  ]),
4917
- h("div", Tn, [
4918
- h("div", Mn, [
4919
- d[24] || (d[24] = h("h3", { class: "szd-panel__heading" }, "Instance Preview", -1)),
4920
- Qe(h("select", {
4783
+ f("div", Cn, [
4784
+ f("div", vn, [
4785
+ d[24] || (d[24] = f("h3", { class: "szd-panel__heading" }, "Instance Preview", -1)),
4786
+ Ue(f("select", {
4921
4787
  "onUpdate:modelValue": d[4] || (d[4] = (g) => m.value = g),
4922
4788
  class: "szd-select"
4923
4789
  }, [
4924
- d[23] || (d[23] = h("option", { value: null }, "Select instance...", -1)),
4925
- (A(!0), $(W, null, ce(Ye.value, (g) => (A(), $("option", {
4790
+ d[23] || (d[23] = f("option", { value: null }, "Select instance...", -1)),
4791
+ (A(!0), M(W, null, ce(Ze.value, (g) => (A(), M("option", {
4926
4792
  key: g,
4927
4793
  value: g
4928
- }, S(g), 9, $n))), 128))
4794
+ }, S(g), 9, kn))), 128))
4929
4795
  ], 512), [
4930
- [Ot, m.value]
4796
+ [At, m.value]
4931
4797
  ])
4932
4798
  ]),
4933
- m.value != null ? (A(), $("div", An, [
4934
- (A(!0), $(W, null, ce(me.value, (g) => (A(), $("div", {
4799
+ m.value != null ? (A(), M("div", bn, [
4800
+ (A(!0), M(W, null, ce(me.value, (g) => (A(), M("div", {
4935
4801
  key: g.id,
4936
4802
  class: "szd-data-card"
4937
4803
  }, [
4938
- h("div", On, [
4939
- Ve(S(g.label) + " ", 1),
4940
- g.pks.includes(m.value) ? (A(), $("span", Pn, "Present")) : (A(), $("span", Fn, "Absent"))
4804
+ f("div", En, [
4805
+ Qe(S(g.label) + " ", 1),
4806
+ g.pks.includes(m.value) ? (A(), M("span", Sn, "Present")) : (A(), M("span", Tn, "Absent"))
4941
4807
  ]),
4942
- h("pre", In, S(g.pks.includes(m.value) ? JSON.stringify(ye(m.value), null, 2) : "—"), 1)
4808
+ f("pre", Mn, S(g.pks.includes(m.value) ? JSON.stringify(ye(m.value), null, 2) : "—"), 1)
4943
4809
  ]))), 128))
4944
- ])) : (A(), $("div", Dn, "Select an instance to preview"))
4810
+ ])) : (A(), M("div", An, "Select an instance to preview"))
4945
4811
  ])
4946
- ])) : V("", !0),
4947
- t.value === "ast" ? (A(), $("div", zn, [
4948
- d[27] || (d[27] = h("h3", { class: "szd-panel__heading" }, "Query AST", -1)),
4949
- h("div", Kn, [
4950
- h("div", Rn, [
4951
- d[26] || (d[26] = h("span", { class: "szd-kv__key" }, "Semantic Key:", -1)),
4952
- h("code", Nn, S(k.value || "—"), 1)
4812
+ ])) : L("", !0),
4813
+ t.value === "ast" ? (A(), M("div", On, [
4814
+ d[27] || (d[27] = f("h3", { class: "szd-panel__heading" }, "Query AST", -1)),
4815
+ f("div", $n, [
4816
+ f("div", Fn, [
4817
+ d[26] || (d[26] = f("span", { class: "szd-kv__key" }, "Semantic Key:", -1)),
4818
+ f("code", Pn, S(E.value || "—"), 1)
4953
4819
  ])
4954
4820
  ]),
4955
- h("pre", xn, S(re.value ? JSON.stringify(re.value, null, 2) : "Select a queryset to view AST"), 1)
4956
- ])) : V("", !0)
4821
+ f("pre", Dn, S(re.value ? JSON.stringify(re.value, null, 2) : "Select a queryset to view AST"), 1)
4822
+ ])) : L("", !0)
4957
4823
  ]),
4958
- Mt(Pt, { name: "szd-slide" }, {
4959
- default: Ft(() => [
4960
- p.value ? (A(), $("div", jn, [
4961
- h("div", {
4824
+ St(Ot, { name: "szd-slide" }, {
4825
+ default: $t(() => [
4826
+ p.value ? (A(), M("div", zn, [
4827
+ f("div", {
4962
4828
  class: "szd-detail__backdrop",
4963
4829
  onClick: d[5] || (d[5] = (g) => p.value = !1)
4964
4830
  }),
4965
- h("div", Un, [
4966
- h("div", Qn, [
4967
- d[28] || (d[28] = h("h3", { class: "szd-detail__title" }, "Debug Settings", -1)),
4968
- h("button", {
4831
+ f("div", Rn, [
4832
+ f("div", Kn, [
4833
+ d[28] || (d[28] = f("h3", { class: "szd-detail__title" }, "Debug Settings", -1)),
4834
+ f("button", {
4969
4835
  class: "szd-btn",
4970
4836
  onClick: d[6] || (d[6] = (g) => p.value = !1)
4971
4837
  }, "Close")
4972
4838
  ]),
4973
- h("div", Vn, [
4974
- h("div", Ln, [
4975
- d[30] || (d[30] = h("label", { class: "szd-settings-label" }, "Queryset", -1)),
4976
- Qe(h("select", {
4839
+ f("div", In, [
4840
+ f("div", Nn, [
4841
+ d[30] || (d[30] = f("label", { class: "szd-settings-label" }, "Queryset", -1)),
4842
+ Ue(f("select", {
4977
4843
  "onUpdate:modelValue": d[7] || (d[7] = (g) => r.value = g),
4978
4844
  class: "szd-select szd-select--full"
4979
4845
  }, [
4980
- d[29] || (d[29] = h("option", { value: "" }, "Select queryset...", -1)),
4981
- (A(!0), $(W, null, ce(b.value, (g) => (A(), $("option", {
4846
+ d[29] || (d[29] = f("option", { value: "" }, "Select queryset...", -1)),
4847
+ (A(!0), M(W, null, ce(k.value, (g) => (A(), M("option", {
4982
4848
  key: g.semanticKey,
4983
4849
  value: g.semanticKey
4984
- }, S(g.modelName || "?") + " · " + S(g.semanticKey), 9, Gn))), 128))
4850
+ }, S(g.modelName || "?") + " · " + S(g.semanticKey), 9, xn))), 128))
4985
4851
  ], 512), [
4986
- [Ot, r.value]
4852
+ [At, r.value]
4987
4853
  ])
4988
4854
  ]),
4989
- k.value ? (A(), $("div", Bn, [
4990
- d[31] || (d[31] = h("label", { class: "szd-settings-label" }, "Semantic Key", -1)),
4991
- h("div", Hn, [
4992
- h("code", qn, S(k.value), 1),
4993
- h("button", {
4855
+ E.value ? (A(), M("div", jn, [
4856
+ d[31] || (d[31] = f("label", { class: "szd-settings-label" }, "Semantic Key", -1)),
4857
+ f("div", Un, [
4858
+ f("code", Qn, S(E.value), 1),
4859
+ f("button", {
4994
4860
  class: "szd-btn szd-btn--sm",
4995
- onClick: as
4861
+ onClick: is
4996
4862
  }, "Copy")
4997
4863
  ])
4998
- ])) : V("", !0),
4999
- h("div", Jn, [
5000
- d[32] || (d[32] = h("label", { class: "szd-settings-label" }, "Actions", -1)),
5001
- h("div", Wn, [
5002
- h("button", {
4864
+ ])) : L("", !0),
4865
+ f("div", Ln, [
4866
+ d[32] || (d[32] = f("label", { class: "szd-settings-label" }, "Actions", -1)),
4867
+ f("div", Vn, [
4868
+ f("button", {
5003
4869
  class: "szd-btn",
5004
- onClick: ls,
4870
+ onClick: as,
5005
4871
  disabled: !N.value || c.value
5006
- }, S(c.value ? "Syncing..." : "Sync Now"), 9, Zn),
5007
- h("button", {
4872
+ }, S(c.value ? "Syncing..." : "Sync Now"), 9, Bn),
4873
+ f("button", {
5008
4874
  class: "szd-btn",
5009
- onClick: is
4875
+ onClick: os
5010
4876
  }, "Clear Events")
5011
4877
  ])
5012
4878
  ]),
5013
- h("div", Yn, [
5014
- d[34] || (d[34] = h("label", { class: "szd-settings-label" }, "Options", -1)),
5015
- h("label", Xn, [
5016
- Qe(h("input", {
4879
+ f("div", Gn, [
4880
+ d[34] || (d[34] = f("label", { class: "szd-settings-label" }, "Options", -1)),
4881
+ f("label", Hn, [
4882
+ Ue(f("input", {
5017
4883
  type: "checkbox",
5018
4884
  "onUpdate:modelValue": d[8] || (d[8] = (g) => i.value = g)
5019
4885
  }, null, 512), [
5020
- [At, i.value]
4886
+ [Mt, i.value]
5021
4887
  ]),
5022
- d[33] || (d[33] = Ve(" Live updates ", -1))
4888
+ d[33] || (d[33] = Qe(" Live updates ", -1))
5023
4889
  ])
5024
4890
  ]),
5025
- k.value ? (A(), $("div", eo, [
5026
- d[40] || (d[40] = h("label", { class: "szd-settings-label" }, "Current State", -1)),
5027
- h("div", to, [
5028
- h("div", so, [
5029
- d[35] || (d[35] = h("span", { class: "szd-kv__key" }, "Model:", -1)),
5030
- h("span", ro, S(F.value.modelName || "—"), 1)
4891
+ E.value ? (A(), M("div", qn, [
4892
+ d[40] || (d[40] = f("label", { class: "szd-settings-label" }, "Current State", -1)),
4893
+ f("div", Jn, [
4894
+ f("div", Wn, [
4895
+ d[35] || (d[35] = f("span", { class: "szd-kv__key" }, "Model:", -1)),
4896
+ f("span", Zn, S(F.value.modelName || "—"), 1)
5031
4897
  ]),
5032
- h("div", no, [
5033
- d[36] || (d[36] = h("span", { class: "szd-kv__key" }, "Source:", -1)),
5034
- h("span", oo, S(F.value.source), 1)
4898
+ f("div", Yn, [
4899
+ d[36] || (d[36] = f("span", { class: "szd-kv__key" }, "Source:", -1)),
4900
+ f("span", Xn, S(F.value.source), 1)
5035
4901
  ]),
5036
- h("div", io, [
5037
- d[37] || (d[37] = h("span", { class: "szd-kv__key" }, "Syncing:", -1)),
5038
- h("span", ao, S(F.value.isSyncing ? "Yes" : "No"), 1)
4902
+ f("div", eo, [
4903
+ d[37] || (d[37] = f("span", { class: "szd-kv__key" }, "Syncing:", -1)),
4904
+ f("span", to, S(F.value.isSyncing ? "Yes" : "No"), 1)
5039
4905
  ]),
5040
- h("div", lo, [
5041
- d[38] || (d[38] = h("span", { class: "szd-kv__key" }, "Operations:", -1)),
5042
- h("span", co, S(F.value.opsCount), 1)
4906
+ f("div", so, [
4907
+ d[38] || (d[38] = f("span", { class: "szd-kv__key" }, "Operations:", -1)),
4908
+ f("span", ro, S(F.value.opsCount), 1)
5043
4909
  ]),
5044
- h("div", uo, [
5045
- d[39] || (d[39] = h("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
5046
- h("span", ho, S(F.value.lastSync), 1)
4910
+ f("div", no, [
4911
+ d[39] || (d[39] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4912
+ f("span", oo, S(F.value.lastSync), 1)
5047
4913
  ])
5048
4914
  ])
5049
- ])) : V("", !0)
4915
+ ])) : L("", !0)
5050
4916
  ])
5051
4917
  ])
5052
- ])) : V("", !0)
4918
+ ])) : L("", !0)
5053
4919
  ]),
5054
4920
  _: 1
5055
4921
  }),
5056
- Mt(Pt, { name: "szd-slide" }, {
5057
- default: Ft(() => [
5058
- f.value ? (A(), $("div", fo, [
5059
- h("div", {
4922
+ St(Ot, { name: "szd-slide" }, {
4923
+ default: $t(() => [
4924
+ h.value ? (A(), M("div", io, [
4925
+ f("div", {
5060
4926
  class: "szd-detail__backdrop",
5061
- onClick: St
4927
+ onClick: bt
5062
4928
  }),
5063
- h("div", po, [
5064
- h("div", mo, [
5065
- h("h3", yo, S(f.value.type === "entry" ? "Event Detail" : "Snapshot: " + f.value.data.label), 1),
5066
- h("button", {
4929
+ f("div", ao, [
4930
+ f("div", lo, [
4931
+ f("h3", co, S(h.value.type === "entry" ? "Event Detail" : "Snapshot: " + h.value.data.label), 1),
4932
+ f("button", {
5067
4933
  class: "szd-btn",
5068
- onClick: St
4934
+ onClick: bt
5069
4935
  }, "Close")
5070
4936
  ]),
5071
- h("div", go, [
5072
- f.value.type === "entry" ? (A(), $(W, { key: 0 }, [
5073
- h("div", _o, [
5074
- (A(!0), $(W, null, ce(os(f.value.data), (g, z) => (A(), $("div", {
5075
- key: z,
4937
+ f("div", uo, [
4938
+ h.value.type === "entry" ? (A(), M(W, { key: 0 }, [
4939
+ f("div", ho, [
4940
+ (A(!0), M(W, null, ce(ns(h.value.data), (g, R) => (A(), M("div", {
4941
+ key: R,
5076
4942
  class: "szd-kv__row"
5077
4943
  }, [
5078
- h("span", wo, S(z) + ":", 1),
5079
- h("span", Co, S(g ?? "—"), 1)
4944
+ f("span", fo, S(R) + ":", 1),
4945
+ f("span", po, S(g ?? "—"), 1)
5080
4946
  ]))), 128))
5081
4947
  ]),
5082
- d[41] || (d[41] = h("h4", { style: { margin: "16px 0 8px" } }, "Raw JSON", -1)),
5083
- h("pre", vo, S(JSON.stringify(f.value.data, null, 2)), 1)
5084
- ], 64)) : (A(), $(W, { key: 1 }, [
5085
- h("div", Eo, [
5086
- h("div", bo, [
5087
- d[42] || (d[42] = h("span", { class: "szd-kv__key" }, "Total Count:", -1)),
5088
- h("span", ko, S(f.value.data.count), 1)
4948
+ d[41] || (d[41] = f("h4", { style: { margin: "16px 0 8px" } }, "Raw JSON", -1)),
4949
+ f("pre", mo, S(JSON.stringify(h.value.data, null, 2)), 1)
4950
+ ], 64)) : (A(), M(W, { key: 1 }, [
4951
+ f("div", yo, [
4952
+ f("div", go, [
4953
+ d[42] || (d[42] = f("span", { class: "szd-kv__key" }, "Total Count:", -1)),
4954
+ f("span", _o, S(h.value.data.count), 1)
5089
4955
  ]),
5090
- h("div", So, [
5091
- d[43] || (d[43] = h("span", { class: "szd-kv__key" }, "Showing:", -1)),
5092
- h("span", To, [
5093
- Ve(S(Ke.value.length) + " items ", 1),
5094
- Xe.value ? (A(), $("span", Mo, "(limited to first 100)")) : V("", !0)
4956
+ f("div", wo, [
4957
+ d[43] || (d[43] = f("span", { class: "szd-kv__key" }, "Showing:", -1)),
4958
+ f("span", Co, [
4959
+ Qe(S(Re.value.length) + " items ", 1),
4960
+ Ye.value ? (A(), M("span", vo, "(limited to first 100)")) : L("", !0)
5095
4961
  ])
5096
4962
  ])
5097
4963
  ]),
5098
- d[44] || (d[44] = h("h4", { style: { margin: "0 0 8px" } }, "Data", -1)),
5099
- h("pre", $o, S(JSON.stringify(Ke.value, null, 2)), 1)
4964
+ d[44] || (d[44] = f("h4", { style: { margin: "0 0 8px" } }, "Data", -1)),
4965
+ f("pre", ko, S(JSON.stringify(Re.value, null, 2)), 1)
5100
4966
  ], 64))
5101
4967
  ])
5102
4968
  ])
5103
- ])) : V("", !0)
4969
+ ])) : L("", !0)
5104
4970
  ]),
5105
4971
  _: 1
5106
4972
  })
5107
4973
  ]));
5108
4974
  }
5109
- }, Bo = /* @__PURE__ */ kr(Ao, [["__scopeId", "data-v-6d80920c"]]);
4975
+ }, jo = /* @__PURE__ */ _r(bo, [["__scopeId", "data-v-cf94aafd"]]);
5110
4976
  export {
5111
- Bo as default
4977
+ jo as default
5112
4978
  };