cogsbox-state 0.5.418 → 0.5.419

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,12 +1,12 @@
1
1
  "use client";
2
2
  import { jsx as It } from "react/jsx-runtime";
3
- import { useState as ot, useRef as J, useEffect as et, useLayoutEffect as Nt, useMemo as wt, createElement as ct, useSyncExternalStore as Ot, startTransition as jt, useCallback as ft } from "react";
3
+ import { useState as ot, useRef as J, useEffect as et, useLayoutEffect as Nt, useMemo as wt, createElement as st, useSyncExternalStore as Ot, startTransition as jt, useCallback as ft } from "react";
4
4
  import { transformStateFunc as Ut, isDeepEqual as q, isFunction as K, getNestedValue as Y, getDifferences as pt, debounce as Ft } from "./utility.js";
5
- import { pushFunc as yt, updateFn as st, cutFunc as gt, ValidationWrapper as Dt, FormControlComponent as Lt } from "./Functions.jsx";
5
+ import { pushFunc as yt, updateFn as it, cutFunc as gt, ValidationWrapper as Dt, FormControlComponent as Lt } from "./Functions.jsx";
6
6
  import Gt from "superjson";
7
7
  import { v4 as Et } from "uuid";
8
8
  import "zod";
9
- import { getGlobalStore as o, formRefStore as kt } from "./store.js";
9
+ import { getGlobalStore as o, formRefStore as Tt } from "./store.js";
10
10
  import { useCogsConfig as Pt } from "./CogsStateClient.jsx";
11
11
  import { applyPatch as Wt } from "fast-json-patch";
12
12
  import zt from "react-use-measure";
@@ -52,7 +52,7 @@ const ge = (t, s) => {
52
52
  options: i,
53
53
  initialOptionsPart: v
54
54
  });
55
- const n = o.getState().cogsStateStore[y] || u[y], g = i?.modifyState ? i.modifyState(n) : n, [L, U] = Zt(
55
+ const n = o.getState().cogsStateStore[y] || u[y], g = i?.modifyState ? i.modifyState(n) : n, [L, j] = Zt(
56
56
  g,
57
57
  {
58
58
  stateKey: y,
@@ -68,10 +68,10 @@ const ge = (t, s) => {
68
68
  serverState: i?.serverState
69
69
  }
70
70
  );
71
- return U;
71
+ return j;
72
72
  };
73
73
  function I(y, i) {
74
- Vt({ stateKey: y, options: i, initialOptionsPart: v }), i.localStorage && Jt(y, i), lt(y);
74
+ Vt({ stateKey: y, options: i, initialOptionsPart: v }), i.localStorage && Jt(y, i), ct(y);
75
75
  }
76
76
  return { useCogsState: V, setCogsOptions: I };
77
77
  }, {
@@ -125,7 +125,7 @@ const ge = (t, s) => {
125
125
  `${u}-${t}-${v}`
126
126
  );
127
127
  if (V && V.lastUpdated > (V.lastSyncedWithServer || 0))
128
- return nt(t, V.state), lt(t), !0;
128
+ return nt(t, V.state), ct(t), !0;
129
129
  }
130
130
  return !1;
131
131
  }, Rt = (t, s, S, u, v, V) => {
@@ -140,7 +140,7 @@ const ge = (t, s) => {
140
140
  state: S
141
141
  };
142
142
  At(t, I.initialState), St(t, I.updaterState), nt(t, I.state);
143
- }, lt = (t) => {
143
+ }, ct = (t) => {
144
144
  const s = o.getState().stateComponents.get(t);
145
145
  if (!s) return;
146
146
  const S = /* @__PURE__ */ new Set();
@@ -193,9 +193,9 @@ function Zt(t, {
193
193
  dependencies: n,
194
194
  serverState: g
195
195
  } = {}) {
196
- const [L, U] = ot({}), { sessionId: F } = Pt();
197
- let z = !s;
198
- const [f] = ot(s ?? Et()), l = o.getState().stateLog[f], dt = J(/* @__PURE__ */ new Set()), tt = J(y ?? Et()), R = J(
196
+ const [L, j] = ot({}), { sessionId: U } = Pt();
197
+ let W = !s;
198
+ const [f] = ot(s ?? Et()), l = o.getState().stateLog[f], lt = J(/* @__PURE__ */ new Set()), tt = J(y ?? Et()), R = J(
199
199
  null
200
200
  );
201
201
  R.current = rt(f) ?? null, et(() => {
@@ -220,17 +220,17 @@ function Zt(t, {
220
220
  return;
221
221
  let m = null;
222
222
  const k = K(e?.localStorage?.key) ? e?.localStorage?.key(i) : e?.localStorage?.key;
223
- k && F && (m = ht(`${F}-${f}-${k}`));
223
+ k && U && (m = ht(`${U}-${f}-${k}`));
224
224
  let p = i, b = !1;
225
- const C = a ? Date.now() : 0, P = m?.lastUpdated || 0, M = m?.lastSyncedWithServer || 0;
226
- a && C > P ? (p = e.serverState.data, b = !0) : m && P > M && (p = m.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), o.getState().initializeShadowState(f, i), Rt(
225
+ const C = a ? Date.now() : 0, P = m?.lastUpdated || 0, F = m?.lastSyncedWithServer || 0;
226
+ a && C > P ? (p = e.serverState.data, b = !0) : m && P > F && (p = m.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), o.getState().initializeShadowState(f, i), Rt(
227
227
  f,
228
228
  i,
229
229
  p,
230
230
  at,
231
231
  tt.current,
232
- F
233
- ), b && k && F && $t(p, f, e, F, Date.now()), lt(f), (Array.isArray(I) ? I : [I || "component"]).includes("none") || U({});
232
+ U
233
+ ), b && k && U && $t(p, f, e, U, Date.now()), ct(f), (Array.isArray(I) ? I : [I || "component"]).includes("none") || j({});
234
234
  }
235
235
  }, [
236
236
  i,
@@ -238,7 +238,7 @@ function Zt(t, {
238
238
  g?.data,
239
239
  ...n || []
240
240
  ]), Nt(() => {
241
- z && bt(f, {
241
+ W && bt(f, {
242
242
  serverSync: S,
243
243
  formElements: v,
244
244
  initialState: i,
@@ -249,19 +249,19 @@ function Zt(t, {
249
249
  components: /* @__PURE__ */ new Map()
250
250
  };
251
251
  return r.components.set(e, {
252
- forceUpdate: () => U({}),
252
+ forceUpdate: () => j({}),
253
253
  paths: /* @__PURE__ */ new Set(),
254
254
  deps: [],
255
255
  depsFunction: V || void 0,
256
256
  reactiveType: I ?? ["component", "deps"]
257
- }), o.getState().stateComponents.set(f, r), U({}), () => {
257
+ }), o.getState().stateComponents.set(f, r), j({}), () => {
258
258
  r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(f));
259
259
  };
260
260
  }, []);
261
261
  const at = (e, r, a, c) => {
262
262
  if (Array.isArray(r)) {
263
263
  const m = `${f}-${r.join(".")}`;
264
- dt.current.add(m);
264
+ lt.current.add(m);
265
265
  }
266
266
  const w = o.getState();
267
267
  nt(f, (m) => {
@@ -279,14 +279,14 @@ function Zt(t, {
279
279
  if ($) {
280
280
  const x = A ? Y(k, r.slice(0, -1)) : Y(k, r);
281
281
  $.forEach(({ parentId: G, position: T, effect: D }) => {
282
- const O = document.querySelector(
282
+ const M = document.querySelector(
283
283
  `[data-parent-id="${G}"]`
284
284
  );
285
- if (O) {
286
- const B = Array.from(O.childNodes);
287
- if (B[T]) {
285
+ if (M) {
286
+ const H = Array.from(M.childNodes);
287
+ if (H[T]) {
288
288
  const E = D ? new Function("state", `return (${D})(state)`)(x) : x;
289
- B[T].textContent = String(E);
289
+ H[T].textContent = String(E);
290
290
  }
291
291
  }
292
292
  });
@@ -315,15 +315,15 @@ function Zt(t, {
315
315
  T
316
316
  ] of C.components.entries()) {
317
317
  let D = !1;
318
- const O = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
319
- if (console.log("component", T), !O.includes("none")) {
320
- if (O.includes("all")) {
318
+ const M = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
319
+ if (console.log("component", T), !M.includes("none")) {
320
+ if (M.includes("all")) {
321
321
  T.forceUpdate();
322
322
  continue;
323
323
  }
324
- if (O.includes("component") && ((T.paths.has(x) || T.paths.has("")) && (D = !0), !D))
325
- for (const B of $) {
326
- let E = B;
324
+ if (M.includes("component") && ((T.paths.has(x) || T.paths.has("")) && (D = !0), !D))
325
+ for (const H of $) {
326
+ let E = H;
327
327
  for (; ; ) {
328
328
  if (T.paths.has(E)) {
329
329
  D = !0;
@@ -349,10 +349,10 @@ function Zt(t, {
349
349
  }
350
350
  if (D) break;
351
351
  }
352
- if (!D && O.includes("deps") && T.depsFunction) {
353
- const B = T.depsFunction(k);
352
+ if (!D && M.includes("deps") && T.depsFunction) {
353
+ const H = T.depsFunction(k);
354
354
  let E = !1;
355
- typeof B == "boolean" ? B && (E = !0) : q(T.deps, B) || (T.deps = B, E = !0), E && (D = !0);
355
+ typeof H == "boolean" ? H && (E = !0) : q(T.deps, H) || (T.deps = H, E = !0), E && (D = !0);
356
356
  }
357
357
  D && T.forceUpdate();
358
358
  }
@@ -363,7 +363,7 @@ function Zt(t, {
363
363
  const x = r.slice(0, -1), G = Y(k, x);
364
364
  return $ === r.length - 1 && ["insert", "cut"].includes(a.updateType) ? (G.length - 1).toString() : A;
365
365
  });
366
- const { oldValue: M, newValue: H } = Yt(
366
+ const { oldValue: F, newValue: z } = Yt(
367
367
  a.updateType,
368
368
  m,
369
369
  k,
@@ -374,8 +374,8 @@ function Zt(t, {
374
374
  path: r,
375
375
  updateType: a.updateType,
376
376
  status: "new",
377
- oldValue: M,
378
- newValue: H
377
+ oldValue: F,
378
+ newValue: z
379
379
  };
380
380
  switch (a.updateType) {
381
381
  case "update":
@@ -383,7 +383,7 @@ function Zt(t, {
383
383
  break;
384
384
  case "insert":
385
385
  const A = r.slice(0, -1);
386
- w.insertShadowArrayElement(f, A, H);
386
+ w.insertShadowArrayElement(f, A, z);
387
387
  break;
388
388
  case "cut":
389
389
  const $ = r.slice(0, -1), x = parseInt(r[r.length - 1]);
@@ -392,15 +392,15 @@ function Zt(t, {
392
392
  }
393
393
  if (Bt(f, (A) => {
394
394
  const x = [...A ?? [], Q].reduce((G, T) => {
395
- const D = `${T.stateKey}:${JSON.stringify(T.path)}`, O = G.get(D);
396
- return O ? (O.timeStamp = Math.max(O.timeStamp, T.timeStamp), O.newValue = T.newValue, O.oldValue = O.oldValue ?? T.oldValue, O.updateType = T.updateType) : G.set(D, { ...T }), G;
395
+ const D = `${T.stateKey}:${JSON.stringify(T.path)}`, M = G.get(D);
396
+ return M ? (M.timeStamp = Math.max(M.timeStamp, T.timeStamp), M.newValue = T.newValue, M.oldValue = M.oldValue ?? T.oldValue, M.updateType = T.updateType) : G.set(D, { ...T }), G;
397
397
  }, /* @__PURE__ */ new Map());
398
398
  return Array.from(x.values());
399
399
  }), $t(
400
400
  k,
401
401
  f,
402
402
  R.current,
403
- F
403
+ U
404
404
  ), R.current?.middleware && R.current.middleware({
405
405
  updateLog: l,
406
406
  update: Q
@@ -422,15 +422,15 @@ function Zt(t, {
422
422
  f,
423
423
  at,
424
424
  tt.current,
425
- F
425
+ U
426
426
  )
427
427
  ), o.getState().cogsStateStore[f] || nt(f, t), o.getState().initialStateGlobal[f] || At(f, t));
428
428
  const d = wt(() => mt(
429
429
  f,
430
430
  at,
431
431
  tt.current,
432
- F
433
- ), [f, F]);
432
+ U
433
+ ), [f, U]);
434
434
  return [Ct(f), d];
435
435
  }
436
436
  function mt(t, s, S, u) {
@@ -450,8 +450,8 @@ function mt(t, s, S, u) {
450
450
  n?.key && X(n?.key), h?.validationKey && X(h.validationKey);
451
451
  const g = o.getState().initialStateGlobal[t];
452
452
  o.getState().clearSelectedIndexesForState(t), v.clear(), V++;
453
- const L = i(g, []), U = rt(t), F = K(U?.localStorage?.key) ? U?.localStorage?.key(g) : U?.localStorage?.key, z = `${u}-${t}-${F}`;
454
- z && localStorage.removeItem(z), St(t, L), nt(t, g);
453
+ const L = i(g, []), j = rt(t), U = K(j?.localStorage?.key) ? j?.localStorage?.key(g) : j?.localStorage?.key, W = `${u}-${t}-${U}`;
454
+ W && localStorage.removeItem(W), St(t, L), nt(t, g);
455
455
  const f = o.getState().stateComponents.get(t);
456
456
  return f && f.components.forEach((l) => {
457
457
  l.forceUpdate();
@@ -464,15 +464,15 @@ function mt(t, s, S, u) {
464
464
  s,
465
465
  S,
466
466
  u
467
- ), g = o.getState().initialStateGlobal[t], L = rt(t), U = K(L?.localStorage?.key) ? L?.localStorage?.key(g) : L?.localStorage?.key, F = `${u}-${t}-${U}`;
468
- return localStorage.getItem(F) && localStorage.removeItem(F), jt(() => {
467
+ ), g = o.getState().initialStateGlobal[t], L = rt(t), j = K(L?.localStorage?.key) ? L?.localStorage?.key(g) : L?.localStorage?.key, U = `${u}-${t}-${j}`;
468
+ return localStorage.getItem(U) && localStorage.removeItem(U), jt(() => {
469
469
  At(t, h), o.getState().initializeShadowState(t, h), St(t, n), nt(t, h);
470
- const z = o.getState().stateComponents.get(t);
471
- z && z.components.forEach((f) => {
470
+ const W = o.getState().stateComponents.get(t);
471
+ W && W.components.forEach((f) => {
472
472
  f.forceUpdate();
473
473
  });
474
474
  }), {
475
- fetchId: (z) => n.get()[z]
475
+ fetchId: (W) => n.get()[W]
476
476
  };
477
477
  },
478
478
  _initialState: o.getState().initialStateGlobal[t],
@@ -486,21 +486,21 @@ function mt(t, s, S, u) {
486
486
  function i(h, n = [], g) {
487
487
  const L = n.map(String).join(".");
488
488
  v.get(L);
489
- const U = function() {
489
+ const j = function() {
490
490
  return o().getNestedState(t, n);
491
491
  };
492
492
  Object.keys(y).forEach((f) => {
493
- U[f] = y[f];
493
+ j[f] = y[f];
494
494
  });
495
- const F = {
496
- apply(f, l, dt) {
495
+ const U = {
496
+ apply(f, l, lt) {
497
497
  return console.log(
498
498
  `PROXY APPLY TRAP HIT: stateKey=${t}, path=${n.join(".")}`
499
499
  ), console.trace("Apply trap stack trace"), o().getNestedState(t, n);
500
500
  },
501
501
  get(f, l) {
502
502
  g?.validIndices && !Array.isArray(h) && (g = { ...g, validIndices: void 0 });
503
- const dt = /* @__PURE__ */ new Set([
503
+ const lt = /* @__PURE__ */ new Set([
504
504
  "insert",
505
505
  "cut",
506
506
  "cutByValue",
@@ -523,7 +523,7 @@ function mt(t, s, S, u) {
523
523
  "_stateKey",
524
524
  "getComponents"
525
525
  ]);
526
- if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !dt.has(l)) {
526
+ if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !lt.has(l)) {
527
527
  const d = `${t}////${S}`, e = o.getState().stateComponents.get(t);
528
528
  if (e) {
529
529
  const r = e.components.get(d);
@@ -625,7 +625,7 @@ function mt(t, s, S, u) {
625
625
  } = e, m = J(null), [k, p] = ot({
626
626
  startIndex: 0,
627
627
  endIndex: 10
628
- }), [b, C] = ot(0), P = J(!0), M = J(0), H = J(!1);
628
+ }), [b, C] = ot(0), P = J(!0), F = J(0), z = J(!1);
629
629
  et(() => o.getState().subscribeToShadowState(t, () => {
630
630
  C((N) => N + 1);
631
631
  }), [t]);
@@ -636,10 +636,10 @@ function mt(t, s, S, u) {
636
636
  const E = o.getState().getShadowMetadata(t, n) || [];
637
637
  let N = 0;
638
638
  const _ = [];
639
- for (let j = 0; j < A; j++) {
640
- _[j] = N;
641
- const W = E[j]?.virtualizer?.itemHeight;
642
- N += W || r;
639
+ for (let O = 0; O < A; O++) {
640
+ _[O] = N;
641
+ const B = E[O]?.virtualizer?.itemHeight;
642
+ N += B || r;
643
643
  }
644
644
  return { totalHeight: N, positions: _ };
645
645
  }, [
@@ -651,9 +651,9 @@ function mt(t, s, S, u) {
651
651
  ]), G = wt(() => {
652
652
  const E = Math.max(0, k.startIndex), N = Math.min(A, k.endIndex), _ = Array.from(
653
653
  { length: N - E },
654
- (W, it) => E + it
655
- ), j = _.map((W) => Q[W]);
656
- return i(j, n, {
654
+ (B, dt) => E + dt
655
+ ), O = _.map((B) => Q[B]);
656
+ return i(O, n, {
657
657
  ...g,
658
658
  validIndices: _
659
659
  });
@@ -662,9 +662,9 @@ function mt(t, s, S, u) {
662
662
  if (N >= 0) {
663
663
  const _ = E[N];
664
664
  if (_?.virtualizer?.domRef) {
665
- const j = _.virtualizer.domRef;
666
- if (j && j.scrollIntoView)
667
- return j.scrollIntoView({
665
+ const O = _.virtualizer.domRef;
666
+ if (O && O.scrollIntoView)
667
+ return O.scrollIntoView({
668
668
  behavior: "auto",
669
669
  block: "end",
670
670
  inline: "nearest"
@@ -675,43 +675,41 @@ function mt(t, s, S, u) {
675
675
  }, [t, n, A]);
676
676
  et(() => {
677
677
  if (!c || A === 0) return;
678
- const E = A > M.current, N = M.current === 0 && A > 0;
679
- if ((E || N) && P.current && !H.current) {
678
+ const E = A > F.current, N = F.current === 0 && A > 0;
679
+ if ((E || N) && P.current) {
680
680
  const _ = Math.ceil(
681
681
  (m.current?.clientHeight || 0) / r
682
- ), j = {
682
+ ), O = {
683
683
  startIndex: Math.max(
684
684
  0,
685
685
  A - _ - a
686
686
  ),
687
687
  endIndex: A
688
688
  };
689
- p(j);
690
- const W = setTimeout(() => {
691
- !T() && m.current && (m.current.scrollTop = m.current.scrollHeight);
689
+ p(O), setTimeout(() => {
690
+ m.current && (m.current.scrollTop = m.current.scrollHeight);
692
691
  }, 50);
693
- return M.current = A, () => clearTimeout(W);
694
692
  }
695
- M.current = A;
693
+ F.current = A;
696
694
  }, [A]), et(() => {
697
695
  const E = m.current;
698
696
  if (!E) return;
699
697
  const N = () => {
700
- const { scrollTop: _, scrollHeight: j, clientHeight: W } = E, it = j - _ - W, vt = it < 5;
701
- P.current = vt, !vt && it > 50 && (H.current = !0), vt && (H.current = !1);
698
+ const { scrollTop: _, scrollHeight: O, clientHeight: B } = E, dt = O - _ - B, vt = dt < 5;
699
+ P.current = vt, !vt && dt > 50 && (z.current = !0), vt && (z.current = !1);
702
700
  let ut = 0;
703
701
  for (let Z = 0; Z < x.length; Z++)
704
702
  if (x[Z] > _ - r * a) {
705
703
  ut = Math.max(0, Z - 1);
706
704
  break;
707
705
  }
708
- let Tt = ut;
709
- const Mt = _ + W;
706
+ let kt = ut;
707
+ const Mt = _ + B;
710
708
  for (let Z = ut; Z < x.length && !(x[Z] > Mt + r * a); Z++)
711
- Tt = Z;
709
+ kt = Z;
712
710
  p({
713
711
  startIndex: Math.max(0, ut),
714
- endIndex: Math.min(A, Tt + 1 + a)
712
+ endIndex: Math.min(A, kt + 1 + a)
715
713
  });
716
714
  };
717
715
  return E.addEventListener("scroll", N, {
@@ -722,13 +720,13 @@ function mt(t, s, S, u) {
722
720
  }, [x, A, r, a, c]);
723
721
  const D = ft(() => {
724
722
  P.current = !0, !T() && m.current && (m.current.scrollTop = m.current.scrollHeight);
725
- }, [T]), O = ft(
723
+ }, [T]), M = ft(
726
724
  (E, N = "smooth") => {
727
- const j = (o.getState().getShadowMetadata(t, n) || [])[E];
728
- if (j?.virtualizer?.domRef) {
729
- const W = j.virtualizer.domRef;
730
- if (W && W.scrollIntoView) {
731
- W.scrollIntoView({ behavior: N, block: "center" });
725
+ const O = (o.getState().getShadowMetadata(t, n) || [])[E];
726
+ if (O?.virtualizer?.domRef) {
727
+ const B = O.virtualizer.domRef;
728
+ if (B && B.scrollIntoView) {
729
+ B.scrollIntoView({ behavior: N, block: "center" });
732
730
  return;
733
731
  }
734
732
  }
@@ -738,7 +736,7 @@ function mt(t, s, S, u) {
738
736
  });
739
737
  },
740
738
  [x, t, n]
741
- ), B = {
739
+ ), H = {
742
740
  outer: {
743
741
  ref: m,
744
742
  style: { overflowY: "auto", height: "100%" }
@@ -757,9 +755,9 @@ function mt(t, s, S, u) {
757
755
  };
758
756
  return {
759
757
  virtualState: G,
760
- virtualizerProps: B,
758
+ virtualizerProps: H,
761
759
  scrollToBottom: D,
762
- scrollToIndex: O
760
+ scrollToIndex: M
763
761
  };
764
762
  };
765
763
  if (l === "stateMapNoRender")
@@ -776,7 +774,7 @@ function mt(t, s, S, u) {
776
774
  );
777
775
  });
778
776
  if (l === "$stateMap")
779
- return (e) => ct(Xt, {
777
+ return (e) => st(Xt, {
780
778
  proxy: {
781
779
  _stateKey: t,
782
780
  _path: n,
@@ -790,7 +788,7 @@ function mt(t, s, S, u) {
790
788
  const r = o.getState().getNestedState(t, n);
791
789
  return Array.isArray(r) ? (g?.validIndices || Array.from({ length: r.length }, (c, w) => w)).map((c, w) => {
792
790
  const m = r[c], k = [...n, c.toString()], p = i(m, k, g), b = `${S}-${n.join(".")}-${c}`;
793
- return ct(Kt, {
791
+ return st(Kt, {
794
792
  key: c,
795
793
  stateKey: t,
796
794
  itemComponentId: b,
@@ -856,7 +854,7 @@ function mt(t, s, S, u) {
856
854
  const p = a(m), b = c.map(
857
855
  (C) => q(C, m) ? p : C
858
856
  );
859
- I(n), st(s, b, n);
857
+ I(n), it(s, b, n);
860
858
  }
861
859
  };
862
860
  if (l === "cut")
@@ -941,7 +939,7 @@ function mt(t, s, S, u) {
941
939
  const e = n.slice(0, -1), r = Number(n[n.length - 1]), a = e.join(".");
942
940
  d ? o.getState().setSelectedIndex(t, a, r) : o.getState().setSelectedIndex(t, a, void 0);
943
941
  const c = o.getState().getNestedState(t, [...e]);
944
- st(s, c, e), I(e);
942
+ it(s, c, e), I(e);
945
943
  };
946
944
  if (l === "toggleSelected")
947
945
  return () => {
@@ -952,7 +950,7 @@ function mt(t, s, S, u) {
952
950
  a === e ? void 0 : e
953
951
  );
954
952
  const c = o.getState().getNestedState(t, [...d]);
955
- st(s, c, d), I(d);
953
+ it(s, c, d), I(d);
956
954
  };
957
955
  if (n.length == 0) {
958
956
  if (l === "addValidation")
@@ -963,7 +961,7 @@ function mt(t, s, S, u) {
963
961
  X(e.key), console.log("addValidationError", d), d.forEach((r) => {
964
962
  const a = [e.key, ...r.path].join(".");
965
963
  console.log("fullErrorPath", a), _t(a, r.message);
966
- }), lt(t);
964
+ }), ct(t);
967
965
  };
968
966
  if (l === "applyJsonPatch")
969
967
  return (d) => {
@@ -996,20 +994,20 @@ function mt(t, s, S, u) {
996
994
  b = !0;
997
995
  break;
998
996
  }
999
- let M = P.lastIndexOf(".");
1000
- for (; M !== -1; ) {
1001
- const H = P.substring(0, M);
1002
- if (p.paths.has(H)) {
997
+ let F = P.lastIndexOf(".");
998
+ for (; F !== -1; ) {
999
+ const z = P.substring(0, F);
1000
+ if (p.paths.has(z)) {
1003
1001
  b = !0;
1004
1002
  break;
1005
1003
  }
1006
1004
  const Q = P.substring(
1007
- M + 1
1005
+ F + 1
1008
1006
  );
1009
1007
  if (!isNaN(Number(Q))) {
1010
- const A = H.lastIndexOf(".");
1008
+ const A = z.lastIndexOf(".");
1011
1009
  if (A !== -1) {
1012
- const $ = H.substring(
1010
+ const $ = z.substring(
1013
1011
  0,
1014
1012
  A
1015
1013
  );
@@ -1019,14 +1017,14 @@ function mt(t, s, S, u) {
1019
1017
  }
1020
1018
  }
1021
1019
  }
1022
- M = H.lastIndexOf(".");
1020
+ F = z.lastIndexOf(".");
1023
1021
  }
1024
1022
  if (b) break;
1025
1023
  }
1026
1024
  if (!b && C.includes("deps") && p.depsFunction) {
1027
1025
  const P = p.depsFunction(a);
1028
- let M = !1;
1029
- typeof P == "boolean" ? P && (M = !0) : q(p.deps, P) || (p.deps = P, M = !0), M && (b = !0);
1026
+ let F = !1;
1027
+ typeof P == "boolean" ? P && (F = !0) : q(p.deps, P) || (p.deps = P, F = !0), F && (b = !0);
1030
1028
  }
1031
1029
  b && p.forceUpdate();
1032
1030
  }
@@ -1051,7 +1049,7 @@ function mt(t, s, S, u) {
1051
1049
  return c.success ? !0 : (c.error.errors.forEach((m) => {
1052
1050
  const k = m.path, p = m.message, b = [d.key, ...k].join(".");
1053
1051
  e(b, p);
1054
- }), lt(t), !1);
1052
+ }), ct(t), !1);
1055
1053
  } catch (a) {
1056
1054
  return console.error("Zod schema validation failed", a), !1;
1057
1055
  }
@@ -1060,7 +1058,7 @@ function mt(t, s, S, u) {
1060
1058
  if (l === "getComponents")
1061
1059
  return () => o().stateComponents.get(t);
1062
1060
  if (l === "getAllFormRefs")
1063
- return () => kt.getState().getFormRefsByStateKey(t);
1061
+ return () => Tt.getState().getFormRefsByStateKey(t);
1064
1062
  if (l === "_initialState")
1065
1063
  return o.getState().initialStateGlobal[t];
1066
1064
  if (l === "_serverState")
@@ -1073,7 +1071,7 @@ function mt(t, s, S, u) {
1073
1071
  if (l === "removeValidation") return y.removeValidation;
1074
1072
  }
1075
1073
  if (l === "getFormRef")
1076
- return () => kt.getState().getFormRef(t + "." + n.join("."));
1074
+ return () => Tt.getState().getFormRef(t + "." + n.join("."));
1077
1075
  if (l === "validationWrapper")
1078
1076
  return ({
1079
1077
  children: d,
@@ -1096,12 +1094,12 @@ function mt(t, s, S, u) {
1096
1094
  return (d, e) => {
1097
1095
  if (e?.debounce)
1098
1096
  Ft(() => {
1099
- st(s, d, n, "");
1097
+ it(s, d, n, "");
1100
1098
  const r = o.getState().getNestedState(t, n);
1101
1099
  e?.afterUpdate && e.afterUpdate(r);
1102
1100
  }, e.debounce);
1103
1101
  else {
1104
- st(s, d, n, "");
1102
+ it(s, d, n, "");
1105
1103
  const r = o.getState().getNestedState(t, n);
1106
1104
  e?.afterUpdate && e.afterUpdate(r);
1107
1105
  }
@@ -1121,18 +1119,18 @@ function mt(t, s, S, u) {
1121
1119
  const R = [...n, l], at = o.getState().getNestedState(t, R);
1122
1120
  return i(at, R, g);
1123
1121
  }
1124
- }, z = new Proxy(U, F);
1122
+ }, W = new Proxy(j, U);
1125
1123
  return v.set(L, {
1126
- proxy: z,
1124
+ proxy: W,
1127
1125
  stateVersion: V
1128
- }), z;
1126
+ }), W;
1129
1127
  }
1130
1128
  return i(
1131
1129
  o.getState().getNestedState(t, [])
1132
1130
  );
1133
1131
  }
1134
1132
  function xt(t) {
1135
- return ct(Qt, { proxy: t });
1133
+ return st(Qt, { proxy: t });
1136
1134
  }
1137
1135
  function Xt({
1138
1136
  proxy: t,
@@ -1171,15 +1169,15 @@ function Qt({
1171
1169
  "state",
1172
1170
  `return (${t._effect})(state)`
1173
1171
  )(n);
1174
- } catch (U) {
1175
- console.error("Error evaluating effect function during mount:", U), g = n;
1172
+ } catch (j) {
1173
+ console.error("Error evaluating effect function during mount:", j), g = n;
1176
1174
  }
1177
1175
  else
1178
1176
  g = n;
1179
1177
  g !== null && typeof g == "object" && (g = JSON.stringify(g));
1180
1178
  const L = document.createTextNode(String(g));
1181
1179
  u.replaceWith(L);
1182
- }, [t._stateKey, t._path.join("."), t._effect]), ct("span", {
1180
+ }, [t._stateKey, t._path.join("."), t._effect]), st("span", {
1183
1181
  ref: s,
1184
1182
  style: { display: "none" },
1185
1183
  "data-signal-id": S
@@ -1198,7 +1196,7 @@ function Se(t) {
1198
1196
  },
1199
1197
  () => o.getState().getNestedState(t._stateKey, t._path)
1200
1198
  );
1201
- return ct("text", {}, String(s));
1199
+ return st("text", {}, String(s));
1202
1200
  }
1203
1201
  function Kt({
1204
1202
  stateKey: t,