cogsbox-state 0.5.378 → 0.5.379

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,34 +1,34 @@
1
1
  "use client";
2
2
  import { jsx as Ot } from "react/jsx-runtime";
3
- import { useState as K, useRef as J, useEffect as st, useLayoutEffect as dt, useMemo as _t, createElement as ut, useSyncExternalStore as Dt, startTransition as Ut, useCallback as $t } from "react";
4
- import { transformStateFunc as jt, isDeepEqual as q, isFunction as tt, getNestedValue as Z, getDifferences as At, debounce as Ht } from "./utility.js";
5
- import { pushFunc as wt, updateFn as lt, cutFunc as It, ValidationWrapper as Ft, FormControlComponent as Bt } from "./Functions.jsx";
3
+ import { useState as K, useRef as J, useEffect as st, useLayoutEffect as ut, useMemo as _t, createElement as gt, useSyncExternalStore as Dt, startTransition as Ut, useCallback as bt } from "react";
4
+ import { transformStateFunc as jt, isDeepEqual as q, isFunction as tt, getNestedValue as Z, getDifferences as Nt, debounce as Ht } from "./utility.js";
5
+ import { pushFunc as At, updateFn as dt, cutFunc as Tt, ValidationWrapper as Ft, FormControlComponent as Bt } from "./Functions.jsx";
6
6
  import Wt from "superjson";
7
- import { v4 as Nt } from "uuid";
7
+ import { v4 as Ct } from "uuid";
8
8
  import "zod";
9
- import { getGlobalStore as o, formRefStore as bt } from "./store.js";
10
- import { useCogsConfig as Vt } from "./CogsStateClient.jsx";
9
+ import { getGlobalStore as o, formRefStore as kt } from "./store.js";
10
+ import { useCogsConfig as Gt } from "./CogsStateClient.jsx";
11
11
  import { applyPatch as zt } from "fast-json-patch";
12
12
  import qt from "react-use-measure";
13
- function kt(t, i) {
13
+ function xt(t, i) {
14
14
  const m = o.getState().getInitialOptions, g = o.getState().setInitialStateOptions, v = m(t) || {};
15
15
  g(t, {
16
16
  ...v,
17
17
  ...i
18
18
  });
19
19
  }
20
- function xt({
20
+ function Mt({
21
21
  stateKey: t,
22
22
  options: i,
23
23
  initialOptionsPart: m
24
24
  }) {
25
- const g = at(t) || {}, v = m[t] || {}, A = o.getState().setInitialStateOptions, E = { ...v, ...g };
25
+ const g = at(t) || {}, v = m[t] || {}, _ = o.getState().setInitialStateOptions, w = { ...v, ...g };
26
26
  let y = !1;
27
27
  if (i)
28
28
  for (const s in i)
29
- E.hasOwnProperty(s) ? (s == "localStorage" && i[s] && E[s].key !== i[s]?.key && (y = !0, E[s] = i[s]), s == "initialState" && i[s] && E[s] !== i[s] && // Different references
30
- !q(E[s], i[s]) && (y = !0, E[s] = i[s])) : (y = !0, E[s] = i[s]);
31
- y && A(t, E);
29
+ w.hasOwnProperty(s) ? (s == "localStorage" && i[s] && w[s].key !== i[s]?.key && (y = !0, w[s] = i[s]), s == "initialState" && i[s] && w[s] !== i[s] && // Different references
30
+ !q(w[s], i[s]) && (y = !0, w[s] = i[s])) : (y = !0, w[s] = i[s]);
31
+ y && _(t, w);
32
32
  }
33
33
  function me(t, { formElements: i, validation: m }) {
34
34
  return { initialState: t, formElements: i, validation: m };
@@ -45,9 +45,9 @@ const he = (t, i) => {
45
45
  // State-specific overrides
46
46
  }, at(y) || o.getState().setInitialStateOptions(y, v[y]);
47
47
  }), o.getState().setInitialStates(g), o.getState().setCreatedState(g);
48
- const A = (y, s) => {
49
- const [I] = K(s?.componentId ?? Nt());
50
- xt({
48
+ const _ = (y, s) => {
49
+ const [I] = K(s?.componentId ?? Ct());
50
+ Mt({
51
51
  stateKey: y,
52
52
  options: s,
53
53
  initialOptionsPart: v
@@ -70,34 +70,34 @@ const he = (t, i) => {
70
70
  );
71
71
  return G;
72
72
  };
73
- function E(y, s) {
74
- xt({ stateKey: y, options: s, initialOptionsPart: v }), s.localStorage && Qt(y, s), pt(y);
73
+ function w(y, s) {
74
+ Mt({ stateKey: y, options: s, initialOptionsPart: v }), s.localStorage && Qt(y, s), wt(y);
75
75
  }
76
- return { useCogsState: A, setCogsOptions: E };
76
+ return { useCogsState: _, setCogsOptions: w };
77
77
  }, {
78
- setUpdaterState: Tt,
78
+ setUpdaterState: vt,
79
79
  setState: rt,
80
80
  getInitialOptions: at,
81
- getKeyState: Gt,
81
+ getKeyState: Lt,
82
82
  getValidationErrors: Jt,
83
83
  setStateLog: Yt,
84
- updateInitialStateGlobal: Ct,
84
+ updateInitialStateGlobal: $t,
85
85
  addValidationError: Zt,
86
86
  removeValidationError: Q,
87
87
  setServerSyncActions: Xt
88
- } = o.getState(), Mt = (t, i, m, g, v) => {
88
+ } = o.getState(), Pt = (t, i, m, g, v) => {
89
89
  m?.log && console.log(
90
90
  "saving to localstorage",
91
91
  i,
92
92
  m.localStorage?.key,
93
93
  g
94
94
  );
95
- const A = tt(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
96
- if (A && g) {
97
- const E = `${g}-${i}-${A}`;
95
+ const _ = tt(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
96
+ if (_ && g) {
97
+ const w = `${g}-${i}-${_}`;
98
98
  let y;
99
99
  try {
100
- y = yt(E)?.lastSyncedWithServer;
100
+ y = pt(w)?.lastSyncedWithServer;
101
101
  } catch {
102
102
  }
103
103
  const s = {
@@ -106,11 +106,11 @@ const he = (t, i) => {
106
106
  lastSyncedWithServer: v ?? y
107
107
  }, I = Wt.serialize(s);
108
108
  window.localStorage.setItem(
109
- E,
109
+ w,
110
110
  JSON.stringify(I.json)
111
111
  );
112
112
  }
113
- }, yt = (t) => {
113
+ }, pt = (t) => {
114
114
  if (!t) return null;
115
115
  try {
116
116
  const i = window.localStorage.getItem(t);
@@ -119,28 +119,28 @@ const he = (t, i) => {
119
119
  return console.error("Error loading from localStorage:", i), null;
120
120
  }
121
121
  }, Qt = (t, i) => {
122
- const m = o.getState().cogsStateStore[t], { sessionId: g } = Vt(), v = tt(i?.localStorage?.key) ? i.localStorage.key(m) : i?.localStorage?.key;
122
+ const m = o.getState().cogsStateStore[t], { sessionId: g } = Gt(), v = tt(i?.localStorage?.key) ? i.localStorage.key(m) : i?.localStorage?.key;
123
123
  if (v && g) {
124
- const A = yt(
124
+ const _ = pt(
125
125
  `${g}-${t}-${v}`
126
126
  );
127
- if (A && A.lastUpdated > (A.lastSyncedWithServer || 0))
128
- return rt(t, A.state), pt(t), !0;
127
+ if (_ && _.lastUpdated > (_.lastSyncedWithServer || 0))
128
+ return rt(t, _.state), wt(t), !0;
129
129
  }
130
130
  return !1;
131
- }, Lt = (t, i, m, g, v, A) => {
132
- const E = {
131
+ }, Rt = (t, i, m, g, v, _) => {
132
+ const w = {
133
133
  initialState: i,
134
- updaterState: vt(
134
+ updaterState: yt(
135
135
  t,
136
136
  g,
137
137
  v,
138
- A
138
+ _
139
139
  ),
140
140
  state: m
141
141
  };
142
- Ct(t, E.initialState), Tt(t, E.updaterState), rt(t, E.state);
143
- }, pt = (t) => {
142
+ $t(t, w.initialState), vt(t, w.updaterState), rt(t, w.state);
143
+ }, wt = (t) => {
144
144
  const i = o.getState().stateComponents.get(t);
145
145
  if (!i) return;
146
146
  const m = /* @__PURE__ */ new Set();
@@ -185,17 +185,17 @@ function te(t, {
185
185
  serverSync: m,
186
186
  localStorage: g,
187
187
  formElements: v,
188
- reactiveDeps: A,
189
- reactiveType: E,
188
+ reactiveDeps: _,
189
+ reactiveType: w,
190
190
  componentId: y,
191
191
  initialState: s,
192
192
  syncUpdate: I,
193
193
  dependencies: n,
194
194
  serverState: S
195
195
  } = {}) {
196
- const [F, G] = K({}), { sessionId: L } = Vt();
196
+ const [F, G] = K({}), { sessionId: L } = Gt();
197
197
  let B = !i;
198
- const [h] = K(i ?? Nt()), l = o.getState().stateLog[h], gt = J(/* @__PURE__ */ new Set()), et = J(y ?? Nt()), P = J(
198
+ const [h] = K(i ?? Ct()), l = o.getState().stateLog[h], ft = J(/* @__PURE__ */ new Set()), et = J(y ?? Ct()), P = J(
199
199
  null
200
200
  );
201
201
  P.current = at(h) ?? null, st(() => {
@@ -212,33 +212,33 @@ function te(t, {
212
212
  }
213
213
  }, [I]), st(() => {
214
214
  if (s) {
215
- kt(h, {
215
+ xt(h, {
216
216
  initialState: s
217
217
  });
218
218
  const e = P.current, a = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, c = o.getState().initialStateGlobal[h];
219
219
  if (!(c && !q(c, s) || !c) && !a)
220
220
  return;
221
221
  let u = null;
222
- const w = tt(e?.localStorage?.key) ? e?.localStorage?.key(s) : e?.localStorage?.key;
223
- w && L && (u = yt(`${L}-${h}-${w}`));
224
- let p = s, O = !1;
225
- const $ = a ? Date.now() : 0, _ = u?.lastUpdated || 0, x = u?.lastSyncedWithServer || 0;
226
- a && $ > _ ? (p = e.serverState.data, O = !0) : u && _ > x && (p = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), o.getState().initializeShadowState(h, s), Lt(
222
+ const E = tt(e?.localStorage?.key) ? e?.localStorage?.key(s) : e?.localStorage?.key;
223
+ E && L && (u = pt(`${L}-${h}-${E}`));
224
+ let p = s, A = !1;
225
+ const C = a ? Date.now() : 0, O = u?.lastUpdated || 0, x = u?.lastSyncedWithServer || 0;
226
+ a && C > O ? (p = e.serverState.data, A = !0) : u && O > x && (p = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), o.getState().initializeShadowState(h, s), Rt(
227
227
  h,
228
228
  s,
229
229
  p,
230
230
  it,
231
231
  et.current,
232
232
  L
233
- ), O && w && L && Mt(p, h, e, L, Date.now()), pt(h), (Array.isArray(E) ? E : [E || "component"]).includes("none") || G({});
233
+ ), A && E && L && Pt(p, h, e, L, Date.now()), wt(h), (Array.isArray(w) ? w : [w || "component"]).includes("none") || G({});
234
234
  }
235
235
  }, [
236
236
  s,
237
237
  S?.status,
238
238
  S?.data,
239
239
  ...n || []
240
- ]), dt(() => {
241
- B && kt(h, {
240
+ ]), ut(() => {
241
+ B && xt(h, {
242
242
  serverSync: m,
243
243
  formElements: v,
244
244
  initialState: s,
@@ -252,8 +252,8 @@ function te(t, {
252
252
  forceUpdate: () => G({}),
253
253
  paths: /* @__PURE__ */ new Set(),
254
254
  deps: [],
255
- depsFunction: A || void 0,
256
- reactiveType: E ?? ["component", "deps"]
255
+ depsFunction: _ || void 0,
256
+ reactiveType: w ?? ["component", "deps"]
257
257
  }), o.getState().stateComponents.set(h, r), G({}), () => {
258
258
  r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(h));
259
259
  };
@@ -261,15 +261,15 @@ function te(t, {
261
261
  const it = (e, r, a, c) => {
262
262
  if (Array.isArray(r)) {
263
263
  const u = `${h}-${r.join(".")}`;
264
- gt.current.add(u);
264
+ ft.current.add(u);
265
265
  }
266
266
  const f = o.getState();
267
267
  rt(h, (u) => {
268
- const w = tt(e) ? e(u) : e, p = `${h}-${r.join(".")}`;
268
+ const E = tt(e) ? e(u) : e, p = `${h}-${r.join(".")}`;
269
269
  if (p) {
270
270
  let M = !1, N = f.signalDomElements.get(p);
271
271
  if ((!N || N.size === 0) && (a.updateType === "insert" || a.updateType === "cut")) {
272
- const V = r.slice(0, -1), D = Z(w, V);
272
+ const V = r.slice(0, -1), D = Z(E, V);
273
273
  if (Array.isArray(D)) {
274
274
  M = !0;
275
275
  const T = `${h}-${V.join(".")}`;
@@ -277,13 +277,13 @@ function te(t, {
277
277
  }
278
278
  }
279
279
  if (N) {
280
- const V = M ? Z(w, r.slice(0, -1)) : Z(w, r);
280
+ const V = M ? Z(E, r.slice(0, -1)) : Z(E, r);
281
281
  N.forEach(({ parentId: D, position: T, effect: U }) => {
282
- const C = document.querySelector(
282
+ const $ = document.querySelector(
283
283
  `[data-parent-id="${D}"]`
284
284
  );
285
- if (C) {
286
- const z = Array.from(C.childNodes);
285
+ if ($) {
286
+ const z = Array.from($.childNodes);
287
287
  if (z[T]) {
288
288
  const j = U ? new Function("state", `return (${U})(state)`)(V) : V;
289
289
  z[T].textContent = String(j);
@@ -295,33 +295,33 @@ function te(t, {
295
295
  console.log("shadowState", f.shadowStateStore), a.updateType === "update" && (c || P.current?.validation?.key) && r && Q(
296
296
  (c || P.current?.validation?.key) + "." + r.join(".")
297
297
  );
298
- const O = r.slice(0, r.length - 1);
298
+ const A = r.slice(0, r.length - 1);
299
299
  a.updateType === "cut" && P.current?.validation?.key && Q(
300
- P.current?.validation?.key + "." + O.join(".")
300
+ P.current?.validation?.key + "." + A.join(".")
301
301
  ), a.updateType === "insert" && P.current?.validation?.key && Jt(
302
- P.current?.validation?.key + "." + O.join(".")
302
+ P.current?.validation?.key + "." + A.join(".")
303
303
  ).filter(([N, V]) => {
304
304
  let D = N?.split(".").length;
305
- if (N == O.join(".") && D == O.length - 1) {
306
- let T = N + "." + O;
305
+ if (N == A.join(".") && D == A.length - 1) {
306
+ let T = N + "." + A;
307
307
  Q(N), Zt(T, V);
308
308
  }
309
309
  });
310
- const $ = f.stateComponents.get(h);
311
- if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", $), $) {
312
- const M = At(u, w), N = new Set(M), V = a.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
310
+ const C = f.stateComponents.get(h);
311
+ if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", C), C) {
312
+ const M = Nt(u, E), N = new Set(M), V = a.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
313
313
  for (const [
314
314
  D,
315
315
  T
316
- ] of $.components.entries()) {
316
+ ] of C.components.entries()) {
317
317
  let U = !1;
318
- const C = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
319
- if (console.log("component", T), !C.includes("none")) {
320
- if (C.includes("all")) {
318
+ const $ = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
319
+ if (console.log("component", T), !$.includes("none")) {
320
+ if ($.includes("all")) {
321
321
  T.forceUpdate();
322
322
  continue;
323
323
  }
324
- if (C.includes("component") && ((T.paths.has(V) || T.paths.has("")) && (U = !0), !U))
324
+ if ($.includes("component") && ((T.paths.has(V) || T.paths.has("")) && (U = !0), !U))
325
325
  for (const z of N) {
326
326
  let j = z;
327
327
  for (; ; ) {
@@ -331,17 +331,17 @@ function te(t, {
331
331
  }
332
332
  const ct = j.lastIndexOf(".");
333
333
  if (ct !== -1) {
334
- const ft = j.substring(
334
+ const St = j.substring(
335
335
  0,
336
336
  ct
337
337
  );
338
338
  if (!isNaN(
339
339
  Number(j.substring(ct + 1))
340
- ) && T.paths.has(ft)) {
340
+ ) && T.paths.has(St)) {
341
341
  U = !0;
342
342
  break;
343
343
  }
344
- j = ft;
344
+ j = St;
345
345
  } else
346
346
  j = "";
347
347
  if (j === "")
@@ -349,8 +349,8 @@ function te(t, {
349
349
  }
350
350
  if (U) break;
351
351
  }
352
- if (!U && C.includes("deps") && T.depsFunction) {
353
- const z = T.depsFunction(w);
352
+ if (!U && $.includes("deps") && T.depsFunction) {
353
+ const z = T.depsFunction(E);
354
354
  let j = !1;
355
355
  typeof z == "boolean" ? z && (j = !0) : q(T.deps, z) || (T.deps = z, j = !0), j && (U = !0);
356
356
  }
@@ -358,18 +358,18 @@ function te(t, {
358
358
  }
359
359
  }
360
360
  }
361
- const _ = Date.now();
361
+ const O = Date.now();
362
362
  r = r.map((M, N) => {
363
- const V = r.slice(0, -1), D = Z(w, V);
363
+ const V = r.slice(0, -1), D = Z(E, V);
364
364
  return N === r.length - 1 && ["insert", "cut"].includes(a.updateType) ? (D.length - 1).toString() : M;
365
365
  });
366
366
  const { oldValue: x, newValue: R } = Kt(
367
367
  a.updateType,
368
368
  u,
369
- w,
369
+ E,
370
370
  r
371
371
  ), Y = {
372
- timeStamp: _,
372
+ timeStamp: O,
373
373
  stateKey: h,
374
374
  path: r,
375
375
  updateType: a.updateType,
@@ -379,7 +379,7 @@ function te(t, {
379
379
  };
380
380
  switch (a.updateType) {
381
381
  case "update":
382
- f.updateShadowAtPath(h, r, w);
382
+ f.updateShadowAtPath(h, r, E);
383
383
  break;
384
384
  case "insert":
385
385
  const M = r.slice(0, -1);
@@ -392,12 +392,12 @@ function te(t, {
392
392
  }
393
393
  if (Yt(h, (M) => {
394
394
  const V = [...M ?? [], Y].reduce((D, T) => {
395
- const U = `${T.stateKey}:${JSON.stringify(T.path)}`, C = D.get(U);
396
- return C ? (C.timeStamp = Math.max(C.timeStamp, T.timeStamp), C.newValue = T.newValue, C.oldValue = C.oldValue ?? T.oldValue, C.updateType = T.updateType) : D.set(U, { ...T }), D;
395
+ const U = `${T.stateKey}:${JSON.stringify(T.path)}`, $ = D.get(U);
396
+ return $ ? ($.timeStamp = Math.max($.timeStamp, T.timeStamp), $.newValue = T.newValue, $.oldValue = $.oldValue ?? T.oldValue, $.updateType = T.updateType) : D.set(U, { ...T }), D;
397
397
  }, /* @__PURE__ */ new Map());
398
398
  return Array.from(V.values());
399
- }), Mt(
400
- w,
399
+ }), Pt(
400
+ E,
401
401
  h,
402
402
  P.current,
403
403
  L
@@ -407,40 +407,40 @@ function te(t, {
407
407
  }), P.current?.serverSync) {
408
408
  const M = f.serverState[h], N = P.current?.serverSync;
409
409
  Xt(h, {
410
- syncKey: typeof N.syncKey == "string" ? N.syncKey : N.syncKey({ state: w }),
410
+ syncKey: typeof N.syncKey == "string" ? N.syncKey : N.syncKey({ state: E }),
411
411
  rollBackState: M,
412
412
  actionTimeStamp: Date.now() + (N.debounce ?? 3e3),
413
413
  status: "waiting"
414
414
  });
415
415
  }
416
- return w;
416
+ return E;
417
417
  });
418
418
  };
419
- o.getState().updaterState[h] || (Tt(
419
+ o.getState().updaterState[h] || (vt(
420
420
  h,
421
- vt(
421
+ yt(
422
422
  h,
423
423
  it,
424
424
  et.current,
425
425
  L
426
426
  )
427
- ), o.getState().cogsStateStore[h] || rt(h, t), o.getState().initialStateGlobal[h] || Ct(h, t));
428
- const d = _t(() => vt(
427
+ ), o.getState().cogsStateStore[h] || rt(h, t), o.getState().initialStateGlobal[h] || $t(h, t));
428
+ const d = _t(() => yt(
429
429
  h,
430
430
  it,
431
431
  et.current,
432
432
  L
433
433
  ), [h, L]);
434
- return [Gt(h), d];
434
+ return [Lt(h), d];
435
435
  }
436
- function vt(t, i, m, g) {
436
+ function yt(t, i, m, g) {
437
437
  const v = /* @__PURE__ */ new Map();
438
- let A = 0;
439
- const E = (I) => {
438
+ let _ = 0;
439
+ const w = (I) => {
440
440
  const n = I.join(".");
441
441
  for (const [S] of v)
442
442
  (S === n || S.startsWith(n + ".")) && v.delete(S);
443
- A++;
443
+ _++;
444
444
  }, y = {
445
445
  removeValidation: (I) => {
446
446
  I?.validationKey && Q(I.validationKey);
@@ -449,24 +449,24 @@ function vt(t, i, m, g) {
449
449
  const n = o.getState().getInitialOptions(t)?.validation;
450
450
  n?.key && Q(n?.key), I?.validationKey && Q(I.validationKey);
451
451
  const S = o.getState().initialStateGlobal[t];
452
- o.getState().clearSelectedIndexesForState(t), v.clear(), A++;
452
+ o.getState().clearSelectedIndexesForState(t), v.clear(), _++;
453
453
  const F = s(S, []), G = at(t), L = tt(G?.localStorage?.key) ? G?.localStorage?.key(S) : G?.localStorage?.key, B = `${g}-${t}-${L}`;
454
- B && localStorage.removeItem(B), Tt(t, F), rt(t, S);
454
+ B && localStorage.removeItem(B), vt(t, F), rt(t, S);
455
455
  const h = o.getState().stateComponents.get(t);
456
456
  return h && h.components.forEach((l) => {
457
457
  l.forceUpdate();
458
458
  }), S;
459
459
  },
460
460
  updateInitialState: (I) => {
461
- v.clear(), A++;
462
- const n = vt(
461
+ v.clear(), _++;
462
+ const n = yt(
463
463
  t,
464
464
  i,
465
465
  m,
466
466
  g
467
467
  ), S = o.getState().initialStateGlobal[t], F = at(t), G = tt(F?.localStorage?.key) ? F?.localStorage?.key(S) : F?.localStorage?.key, L = `${g}-${t}-${G}`;
468
468
  return localStorage.getItem(L) && localStorage.removeItem(L), Ut(() => {
469
- Ct(t, I), o.getState().initializeShadowState(t, I), Tt(t, n), rt(t, I);
469
+ $t(t, I), o.getState().initializeShadowState(t, I), vt(t, n), rt(t, I);
470
470
  const B = o.getState().stateComponents.get(t);
471
471
  B && B.components.forEach((h) => {
472
472
  h.forceUpdate();
@@ -480,7 +480,7 @@ function vt(t, i, m, g) {
480
480
  _isLoading: o.getState().isLoadingGlobal[t],
481
481
  _isServerSynced: () => {
482
482
  const I = o.getState().serverState[t];
483
- return !!(I && q(I, Gt(t)));
483
+ return !!(I && q(I, Lt(t)));
484
484
  }
485
485
  };
486
486
  function s(I, n = [], S) {
@@ -493,14 +493,14 @@ function vt(t, i, m, g) {
493
493
  G[h] = y[h];
494
494
  });
495
495
  const L = {
496
- apply(h, l, gt) {
496
+ apply(h, l, ft) {
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(h, l) {
502
502
  S?.validIndices && !Array.isArray(I) && (S = { ...S, validIndices: void 0 });
503
- const gt = /* @__PURE__ */ new Set([
503
+ const ft = /* @__PURE__ */ new Set([
504
504
  "insert",
505
505
  "cut",
506
506
  "cutByValue",
@@ -523,7 +523,7 @@ function vt(t, i, m, g) {
523
523
  "_stateKey",
524
524
  "getComponents"
525
525
  ]);
526
- if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !gt.has(l)) {
526
+ if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !ft.has(l)) {
527
527
  const d = `${t}////${m}`, e = o.getState().stateComponents.get(t);
528
528
  if (e) {
529
529
  const r = e.components.get(d);
@@ -540,7 +540,7 @@ function vt(t, i, m, g) {
540
540
  }
541
541
  }
542
542
  if (l === "getDifferences")
543
- return () => At(
543
+ return () => Nt(
544
544
  o.getState().cogsStateStore[t],
545
545
  o.getState().initialStateGlobal[t]
546
546
  );
@@ -554,8 +554,8 @@ function vt(t, i, m, g) {
554
554
  const c = await e.action(r);
555
555
  if (c && !c.success && c.errors && a) {
556
556
  o.getState().removeValidationError(a), c.errors.forEach((u) => {
557
- const w = [a, ...u.path].join(".");
558
- o.getState().addValidationError(w, u.message);
557
+ const E = [a, ...u.path].join(".");
558
+ o.getState().addValidationError(E, u.message);
559
559
  });
560
560
  const f = o.getState().stateComponents.get(t);
561
561
  f && f.components.forEach((u) => {
@@ -622,17 +622,17 @@ function vt(t, i, m, g) {
622
622
  overscan: a = 6,
623
623
  stickToBottom: c = !1,
624
624
  dependencies: f = []
625
- } = e, u = J(!1), w = J(null), [p, O] = K({
625
+ } = e, u = J(!1), E = J(null), [p, A] = K({
626
626
  startIndex: 0,
627
627
  endIndex: 10
628
- }), [$, _] = K("IDLE_AT_TOP"), x = J(!1), R = J(0), Y = J(f), M = J(0), [N, V] = K(0);
628
+ }), [C, O] = K("IDLE_AT_TOP"), x = J(!1), R = J(0), Y = J(f), M = J(0), [N, V] = K(0);
629
629
  st(() => o.getState().subscribeToShadowState(t, () => {
630
630
  V((k) => k + 1);
631
631
  }), [t]);
632
632
  const D = o().getNestedState(
633
633
  t,
634
634
  n
635
- ), T = D.length, { totalHeight: U, positions: C } = _t(() => {
635
+ ), T = D.length, { totalHeight: U, positions: $ } = _t(() => {
636
636
  const b = o.getState().getShadowMetadata(t, n) || [];
637
637
  let k = 0;
638
638
  const W = [];
@@ -658,29 +658,29 @@ function vt(t, i, m, g) {
658
658
  validIndices: W
659
659
  });
660
660
  }, [p.startIndex, p.endIndex, D, T]);
661
- dt(() => {
661
+ ut(() => {
662
662
  const b = !q(
663
663
  f,
664
664
  Y.current
665
665
  ), k = T > R.current;
666
666
  if (b) {
667
- console.log("TRANSITION: Deps changed -> IDLE_AT_TOP"), _("IDLE_AT_TOP");
667
+ console.log("TRANSITION: Deps changed -> IDLE_AT_TOP"), O("IDLE_AT_TOP");
668
668
  return;
669
669
  }
670
- k && $ === "LOCKED_AT_BOTTOM" && c && (console.log(
670
+ k && C === "LOCKED_AT_BOTTOM" && c && (console.log(
671
671
  "TRANSITION: New items arrived while locked -> GETTING_HEIGHTS"
672
- ), _("GETTING_HEIGHTS")), R.current = T, Y.current = f;
673
- }, [T, ...f]), dt(() => {
674
- const b = w.current;
672
+ ), O("GETTING_HEIGHTS")), R.current = T, Y.current = f;
673
+ }, [T, ...f]), ut(() => {
674
+ const b = E.current;
675
675
  if (b) {
676
- if ($ === "IDLE_AT_TOP" && c && T > 0)
676
+ if (C === "IDLE_AT_TOP" && c && T > 0)
677
677
  console.log(
678
678
  "ACTION (IDLE_AT_TOP): Data has arrived -> GETTING_HEIGHTS"
679
- ), _("GETTING_HEIGHTS");
680
- else if ($ === "GETTING_HEIGHTS") {
679
+ ), O("GETTING_HEIGHTS");
680
+ else if (C === "GETTING_HEIGHTS") {
681
681
  console.log(
682
682
  "ACTION (GETTING_HEIGHTS): Setting range to end and starting loop."
683
- ), O({
683
+ ), A({
684
684
  startIndex: Math.max(0, T - 10 - a),
685
685
  endIndex: T
686
686
  });
@@ -689,21 +689,20 @@ function vt(t, i, m, g) {
689
689
  const W = T - 1;
690
690
  if (((o.getState().getShadowMetadata(t, n) || [])[W]?.virtualizer?.itemHeight || 0) > 0 && (clearInterval(k), !u.current)) {
691
691
  const X = R.current, ot = T - X;
692
- if (ot > 0 && ot <= 3) {
693
- const St = C[T - 1] - (C[X] ?? 0);
694
- b.scrollBy({
695
- top: St,
692
+ ot > 0 && ot <= 3 ? requestAnimationFrame(() => {
693
+ const mt = $[X] ?? b.scrollHeight, ht = b.scrollHeight - mt;
694
+ ht > 0 && b.scrollBy({
695
+ top: ht,
696
696
  behavior: "smooth"
697
697
  }), console.log(
698
698
  "ACTION (GETTING_HEIGHTS): Small addition -> LOCKED_AT_BOTTOM"
699
- ), _("LOCKED_AT_BOTTOM");
700
- } else
701
- console.log(
702
- "ACTION (GETTING_HEIGHTS): Large change -> SCROLLING_TO_BOTTOM"
703
- ), _("SCROLLING_TO_BOTTOM");
699
+ ), O("LOCKED_AT_BOTTOM");
700
+ }) : (console.log(
701
+ "ACTION (GETTING_HEIGHTS): Large change -> SCROLLING_TO_BOTTOM"
702
+ ), O("SCROLLING_TO_BOTTOM"));
704
703
  }
705
- }, 100), () => clearInterval(k);
706
- } else if ($ === "SCROLLING_TO_BOTTOM") {
704
+ }, 50), () => clearInterval(k);
705
+ } else if (C === "SCROLLING_TO_BOTTOM") {
707
706
  console.log(
708
707
  "ACTION (SCROLLING_TO_BOTTOM): Executing scroll."
709
708
  ), x.current = !0;
@@ -716,7 +715,7 @@ function vt(t, i, m, g) {
716
715
  () => {
717
716
  console.log(
718
717
  "ACTION (SCROLLING_TO_BOTTOM): Scroll finished -> LOCKED_AT_BOTTOM"
719
- ), x.current = !1, u.current = !1, _("LOCKED_AT_BOTTOM");
718
+ ), x.current = !1, u.current = !1, O("LOCKED_AT_BOTTOM");
720
719
  },
721
720
  k === "smooth" ? 500 : 50
722
721
  );
@@ -725,8 +724,8 @@ function vt(t, i, m, g) {
725
724
  return () => {
726
725
  };
727
726
  }
728
- }, [$, T, C]), st(() => {
729
- const b = w.current;
727
+ }, [C, T, $]), st(() => {
728
+ const b = E.current;
730
729
  if (!b) return;
731
730
  const k = r, W = () => {
732
731
  if (x.current)
@@ -740,38 +739,38 @@ function vt(t, i, m, g) {
740
739
  const { clientHeight: nt } = b;
741
740
  let X = T - 1, ot = 0, Et = 0;
742
741
  for (; ot <= X; ) {
743
- const ht = Math.floor((ot + X) / 2);
744
- C[ht] < H ? (Et = ht, ot = ht + 1) : X = ht - 1;
742
+ const It = Math.floor((ot + X) / 2);
743
+ $[It] < H ? (Et = It, ot = It + 1) : X = It - 1;
745
744
  }
746
- const St = Math.max(0, Et - a);
747
- let mt = St;
748
- const Rt = H + nt;
749
- for (; mt < T && C[mt] < Rt; )
750
- mt++;
751
- O({
752
- startIndex: St,
753
- endIndex: Math.min(T, mt + a)
745
+ const mt = Math.max(0, Et - a);
746
+ let lt = mt;
747
+ const ht = H + nt;
748
+ for (; lt < T && $[lt] < ht; )
749
+ lt++;
750
+ A({
751
+ startIndex: mt,
752
+ endIndex: Math.min(T, lt + a)
754
753
  }), M.current = H;
755
754
  };
756
755
  return b.addEventListener("scroll", W, {
757
756
  passive: !0
758
757
  }), () => b.removeEventListener("scroll", W);
759
- }, [T, C, r, a, $]);
760
- const j = $t(() => {
758
+ }, [T, $, r, a, C]);
759
+ const j = bt(() => {
761
760
  console.log(
762
761
  "USER ACTION: Clicked scroll button -> SCROLLING_TO_BOTTOM"
763
- ), _("SCROLLING_TO_BOTTOM");
764
- }, []), ct = $t(
762
+ ), O("SCROLLING_TO_BOTTOM");
763
+ }, []), ct = bt(
765
764
  (b, k = "smooth") => {
766
- w.current && C[b] !== void 0 && (_("IDLE_NOT_AT_BOTTOM"), w.current.scrollTo({
767
- top: C[b],
765
+ E.current && $[b] !== void 0 && (O("IDLE_NOT_AT_BOTTOM"), E.current.scrollTo({
766
+ top: $[b],
768
767
  behavior: k
769
768
  }));
770
769
  },
771
- [C]
772
- ), ft = {
770
+ [$]
771
+ ), St = {
773
772
  outer: {
774
- ref: w,
773
+ ref: E,
775
774
  style: { overflowY: "auto", height: "100%" }
776
775
  },
777
776
  inner: {
@@ -782,13 +781,13 @@ function vt(t, i, m, g) {
782
781
  },
783
782
  list: {
784
783
  style: {
785
- transform: `translateY(${C[p.startIndex] || 0}px)`
784
+ transform: `translateY(${$[p.startIndex] || 0}px)`
786
785
  }
787
786
  }
788
787
  };
789
788
  return {
790
789
  virtualState: z,
791
- virtualizerProps: ft,
790
+ virtualizerProps: St,
792
791
  scrollToBottom: j,
793
792
  scrollToIndex: ct
794
793
  };
@@ -796,7 +795,7 @@ function vt(t, i, m, g) {
796
795
  if (l === "stateSort")
797
796
  return (e) => {
798
797
  const a = [...d()].sort(
799
- (u, w) => e(u.item, w.item)
798
+ (u, E) => e(u.item, E.item)
800
799
  ), c = a.map(({ item: u }) => u), f = {
801
800
  ...S,
802
801
  validIndices: a.map(
@@ -808,7 +807,7 @@ function vt(t, i, m, g) {
808
807
  if (l === "stateFilter")
809
808
  return (e) => {
810
809
  const a = d().filter(
811
- ({ item: u }, w) => e(u, w)
810
+ ({ item: u }, E) => e(u, E)
812
811
  ), c = a.map(({ item: u }) => u), f = {
813
812
  ...S,
814
813
  validIndices: a.map(
@@ -821,22 +820,22 @@ function vt(t, i, m, g) {
821
820
  return (e) => {
822
821
  const r = o.getState().getNestedState(t, n);
823
822
  return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (c, f) => f)).map((c, f) => {
824
- const u = r[c], w = [...n, c.toString()], p = s(u, w, S);
823
+ const u = r[c], E = [...n, c.toString()], p = s(u, E, S);
825
824
  return e(u, p, {
826
825
  register: () => {
827
- const [, $] = K({}), _ = `${m}-${n.join(".")}-${c}`;
828
- dt(() => {
829
- const x = `${t}////${_}`, R = o.getState().stateComponents.get(t) || {
826
+ const [, C] = K({}), O = `${m}-${n.join(".")}-${c}`;
827
+ ut(() => {
828
+ const x = `${t}////${O}`, R = o.getState().stateComponents.get(t) || {
830
829
  components: /* @__PURE__ */ new Map()
831
830
  };
832
831
  return R.components.set(x, {
833
- forceUpdate: () => $({}),
834
- paths: /* @__PURE__ */ new Set([w.join(".")])
832
+ forceUpdate: () => C({}),
833
+ paths: /* @__PURE__ */ new Set([E.join(".")])
835
834
  }), o.getState().stateComponents.set(t, R), () => {
836
835
  const Y = o.getState().stateComponents.get(t);
837
836
  Y && Y.components.delete(x);
838
837
  };
839
- }, [t, _]);
838
+ }, [t, O]);
840
839
  },
841
840
  index: f,
842
841
  originalIndex: c
@@ -850,17 +849,17 @@ function vt(t, i, m, g) {
850
849
  return (e) => I.map((a, c) => {
851
850
  let f;
852
851
  S?.validIndices && S.validIndices[c] !== void 0 ? f = S.validIndices[c] : f = c;
853
- const u = [...n, f.toString()], w = s(a, u, S);
852
+ const u = [...n, f.toString()], E = s(a, u, S);
854
853
  return e(
855
854
  a,
856
- w,
855
+ E,
857
856
  c,
858
857
  I,
859
858
  s(I, n, S)
860
859
  );
861
860
  });
862
861
  if (l === "$stateMap")
863
- return (e) => ut(ee, {
862
+ return (e) => gt(ee, {
864
863
  proxy: {
865
864
  _stateKey: t,
866
865
  _path: n,
@@ -873,12 +872,12 @@ function vt(t, i, m, g) {
873
872
  return (e) => {
874
873
  const r = o.getState().getNestedState(t, n);
875
874
  return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (c, f) => f)).map((c, f) => {
876
- const u = r[c], w = [...n, c.toString()], p = s(u, w, S), O = `${m}-${n.join(".")}-${c}`;
877
- return ut(re, {
875
+ const u = r[c], E = [...n, c.toString()], p = s(u, E, S), A = `${m}-${n.join(".")}-${c}`;
876
+ return gt(re, {
878
877
  key: c,
879
878
  stateKey: t,
880
- itemComponentId: O,
881
- itemPath: w,
879
+ itemComponentId: A,
880
+ itemPath: E,
882
881
  children: e(
883
882
  u,
884
883
  p,
@@ -894,7 +893,7 @@ function vt(t, i, m, g) {
894
893
  if (l === "stateFlattenOn")
895
894
  return (e) => {
896
895
  const r = I;
897
- v.clear(), A++;
896
+ v.clear(), _++;
898
897
  const a = r.flatMap(
899
898
  (c) => c[e] ?? []
900
899
  );
@@ -917,7 +916,7 @@ function vt(t, i, m, g) {
917
916
  return s(a, c);
918
917
  };
919
918
  if (l === "insert")
920
- return (e) => (E(n), wt(i, e, n, t), s(
919
+ return (e) => (w(n), At(i, e, n, t), s(
921
920
  o.getState().getNestedState(t, n),
922
921
  n
923
922
  ));
@@ -927,26 +926,26 @@ function vt(t, i, m, g) {
927
926
  let u = null;
928
927
  if (!c.some((p) => {
929
928
  if (r) {
930
- const $ = r.every(
931
- (_) => q(p[_], f[_])
929
+ const C = r.every(
930
+ (O) => q(p[O], f[O])
932
931
  );
933
- return $ && (u = p), $;
932
+ return C && (u = p), C;
934
933
  }
935
- const O = q(p, f);
936
- return O && (u = p), O;
934
+ const A = q(p, f);
935
+ return A && (u = p), A;
937
936
  }))
938
- E(n), wt(i, f, n, t);
937
+ w(n), At(i, f, n, t);
939
938
  else if (a && u) {
940
- const p = a(u), O = c.map(
941
- ($) => q($, u) ? p : $
939
+ const p = a(u), A = c.map(
940
+ (C) => q(C, u) ? p : C
942
941
  );
943
- E(n), lt(i, O, n);
942
+ w(n), dt(i, A, n);
944
943
  }
945
944
  };
946
945
  if (l === "cut")
947
946
  return (e, r) => {
948
947
  if (!r?.waitForSync)
949
- return E(n), It(i, n, t, e), s(
948
+ return w(n), Tt(i, n, t, e), s(
950
949
  o.getState().getNestedState(t, n),
951
950
  n
952
951
  );
@@ -954,12 +953,12 @@ function vt(t, i, m, g) {
954
953
  if (l === "cutByValue")
955
954
  return (e) => {
956
955
  for (let r = 0; r < I.length; r++)
957
- I[r] === e && It(i, n, t, r);
956
+ I[r] === e && Tt(i, n, t, r);
958
957
  };
959
958
  if (l === "toggleByValue")
960
959
  return (e) => {
961
960
  const r = I.findIndex((a) => a === e);
962
- r > -1 ? It(i, n, t, r) : wt(i, e, n, t);
961
+ r > -1 ? Tt(i, n, t, r) : At(i, e, n, t);
963
962
  };
964
963
  if (l === "stateFind")
965
964
  return (e) => {
@@ -984,7 +983,7 @@ function vt(t, i, m, g) {
984
983
  if (!isNaN(Number(et))) {
985
984
  const d = n.slice(0, -1), e = o.getState().getNestedState(t, d);
986
985
  if (Array.isArray(e) && l === "cut")
987
- return () => It(
986
+ return () => Tt(
988
987
  i,
989
988
  d,
990
989
  t,
@@ -1000,13 +999,13 @@ function vt(t, i, m, g) {
1000
999
  return o.getState().getNestedState(t, n);
1001
1000
  };
1002
1001
  if (l === "$derive")
1003
- return (d) => Pt({
1002
+ return (d) => Vt({
1004
1003
  _stateKey: t,
1005
1004
  _path: n,
1006
1005
  _effect: d.toString()
1007
1006
  });
1008
1007
  if (l === "$get")
1009
- return () => Pt({
1008
+ return () => Vt({
1010
1009
  _stateKey: t,
1011
1010
  _path: n
1012
1011
  });
@@ -1015,7 +1014,7 @@ function vt(t, i, m, g) {
1015
1014
  return o.getState().getSyncInfo(d);
1016
1015
  }
1017
1016
  if (l == "getLocalStorage")
1018
- return (d) => yt(g + "-" + t + "-" + d);
1017
+ return (d) => pt(g + "-" + t + "-" + d);
1019
1018
  if (l === "_selected") {
1020
1019
  const d = n.slice(0, -1), e = d.join("."), r = o.getState().getNestedState(t, d);
1021
1020
  return Array.isArray(r) ? Number(n[n.length - 1]) === o.getState().getSelectedIndex(t, e) : void 0;
@@ -1025,7 +1024,7 @@ function vt(t, i, m, g) {
1025
1024
  const e = n.slice(0, -1), r = Number(n[n.length - 1]), a = e.join(".");
1026
1025
  d ? o.getState().setSelectedIndex(t, a, r) : o.getState().setSelectedIndex(t, a, void 0);
1027
1026
  const c = o.getState().getNestedState(t, [...e]);
1028
- lt(i, c, e), E(e);
1027
+ dt(i, c, e), w(e);
1029
1028
  };
1030
1029
  if (l === "toggleSelected")
1031
1030
  return () => {
@@ -1036,13 +1035,13 @@ function vt(t, i, m, g) {
1036
1035
  a === e ? void 0 : e
1037
1036
  );
1038
1037
  const c = o.getState().getNestedState(t, [...d]);
1039
- lt(i, c, d), E(d);
1038
+ dt(i, c, d), w(d);
1040
1039
  };
1041
1040
  if (n.length == 0) {
1042
1041
  if (l === "applyJsonPatch")
1043
1042
  return (d) => {
1044
1043
  const e = o.getState().cogsStateStore[t], a = zt(e, d).newDocument;
1045
- Lt(
1044
+ Rt(
1046
1045
  t,
1047
1046
  o.getState().initialStateGlobal[t],
1048
1047
  a,
@@ -1052,32 +1051,32 @@ function vt(t, i, m, g) {
1052
1051
  );
1053
1052
  const c = o.getState().stateComponents.get(t);
1054
1053
  if (c) {
1055
- const f = At(e, a), u = new Set(f);
1054
+ const f = Nt(e, a), u = new Set(f);
1056
1055
  for (const [
1057
- w,
1056
+ E,
1058
1057
  p
1059
1058
  ] of c.components.entries()) {
1060
- let O = !1;
1061
- const $ = Array.isArray(p.reactiveType) ? p.reactiveType : [p.reactiveType || "component"];
1062
- if (!$.includes("none")) {
1063
- if ($.includes("all")) {
1059
+ let A = !1;
1060
+ const C = Array.isArray(p.reactiveType) ? p.reactiveType : [p.reactiveType || "component"];
1061
+ if (!C.includes("none")) {
1062
+ if (C.includes("all")) {
1064
1063
  p.forceUpdate();
1065
1064
  continue;
1066
1065
  }
1067
- if ($.includes("component") && (p.paths.has("") && (O = !0), !O))
1068
- for (const _ of u) {
1069
- if (p.paths.has(_)) {
1070
- O = !0;
1066
+ if (C.includes("component") && (p.paths.has("") && (A = !0), !A))
1067
+ for (const O of u) {
1068
+ if (p.paths.has(O)) {
1069
+ A = !0;
1071
1070
  break;
1072
1071
  }
1073
- let x = _.lastIndexOf(".");
1072
+ let x = O.lastIndexOf(".");
1074
1073
  for (; x !== -1; ) {
1075
- const R = _.substring(0, x);
1074
+ const R = O.substring(0, x);
1076
1075
  if (p.paths.has(R)) {
1077
- O = !0;
1076
+ A = !0;
1078
1077
  break;
1079
1078
  }
1080
- const Y = _.substring(
1079
+ const Y = O.substring(
1081
1080
  x + 1
1082
1081
  );
1083
1082
  if (!isNaN(Number(Y))) {
@@ -1088,21 +1087,21 @@ function vt(t, i, m, g) {
1088
1087
  M
1089
1088
  );
1090
1089
  if (p.paths.has(N)) {
1091
- O = !0;
1090
+ A = !0;
1092
1091
  break;
1093
1092
  }
1094
1093
  }
1095
1094
  }
1096
1095
  x = R.lastIndexOf(".");
1097
1096
  }
1098
- if (O) break;
1097
+ if (A) break;
1099
1098
  }
1100
- if (!O && $.includes("deps") && p.depsFunction) {
1101
- const _ = p.depsFunction(a);
1099
+ if (!A && C.includes("deps") && p.depsFunction) {
1100
+ const O = p.depsFunction(a);
1102
1101
  let x = !1;
1103
- typeof _ == "boolean" ? _ && (x = !0) : q(p.deps, _) || (p.deps = _, x = !0), x && (O = !0);
1102
+ typeof O == "boolean" ? O && (x = !0) : q(p.deps, O) || (p.deps = O, x = !0), x && (A = !0);
1104
1103
  }
1105
- O && p.forceUpdate();
1104
+ A && p.forceUpdate();
1106
1105
  }
1107
1106
  }
1108
1107
  }
@@ -1123,9 +1122,9 @@ function vt(t, i, m, g) {
1123
1122
  });
1124
1123
  const c = d.zodSchema.safeParse(r);
1125
1124
  return c.success ? !0 : (c.error.errors.forEach((u) => {
1126
- const w = u.path, p = u.message, O = [d.key, ...w].join(".");
1127
- e(O, p);
1128
- }), pt(t), !1);
1125
+ const E = u.path, p = u.message, A = [d.key, ...E].join(".");
1126
+ e(A, p);
1127
+ }), wt(t), !1);
1129
1128
  } catch (a) {
1130
1129
  return console.error("Zod schema validation failed", a), !1;
1131
1130
  }
@@ -1134,7 +1133,7 @@ function vt(t, i, m, g) {
1134
1133
  if (l === "getComponents")
1135
1134
  return () => o().stateComponents.get(t);
1136
1135
  if (l === "getAllFormRefs")
1137
- return () => bt.getState().getFormRefsByStateKey(t);
1136
+ return () => kt.getState().getFormRefsByStateKey(t);
1138
1137
  if (l === "_initialState")
1139
1138
  return o.getState().initialStateGlobal[t];
1140
1139
  if (l === "_serverState")
@@ -1147,7 +1146,7 @@ function vt(t, i, m, g) {
1147
1146
  if (l === "removeValidation") return y.removeValidation;
1148
1147
  }
1149
1148
  if (l === "getFormRef")
1150
- return () => bt.getState().getFormRef(t + "." + n.join("."));
1149
+ return () => kt.getState().getFormRef(t + "." + n.join("."));
1151
1150
  if (l === "validationWrapper")
1152
1151
  return ({
1153
1152
  children: d,
@@ -1170,16 +1169,16 @@ function vt(t, i, m, g) {
1170
1169
  return (d, e) => {
1171
1170
  if (e?.debounce)
1172
1171
  Ht(() => {
1173
- lt(i, d, n, "");
1172
+ dt(i, d, n, "");
1174
1173
  const r = o.getState().getNestedState(t, n);
1175
1174
  e?.afterUpdate && e.afterUpdate(r);
1176
1175
  }, e.debounce);
1177
1176
  else {
1178
- lt(i, d, n, "");
1177
+ dt(i, d, n, "");
1179
1178
  const r = o.getState().getNestedState(t, n);
1180
1179
  e?.afterUpdate && e.afterUpdate(r);
1181
1180
  }
1182
- E(n);
1181
+ w(n);
1183
1182
  };
1184
1183
  if (l === "formElement")
1185
1184
  return (d, e) => /* @__PURE__ */ Ot(
@@ -1198,15 +1197,15 @@ function vt(t, i, m, g) {
1198
1197
  }, B = new Proxy(G, L);
1199
1198
  return v.set(F, {
1200
1199
  proxy: B,
1201
- stateVersion: A
1200
+ stateVersion: _
1202
1201
  }), B;
1203
1202
  }
1204
1203
  return s(
1205
1204
  o.getState().getNestedState(t, [])
1206
1205
  );
1207
1206
  }
1208
- function Pt(t) {
1209
- return ut(ne, { proxy: t });
1207
+ function Vt(t) {
1208
+ return gt(ne, { proxy: t });
1210
1209
  }
1211
1210
  function ee({
1212
1211
  proxy: t,
@@ -1217,7 +1216,7 @@ function ee({
1217
1216
  m,
1218
1217
  t._path
1219
1218
  ).stateMapNoRender(
1220
- (v, A, E, y, s) => t._mapFn(v, A, E, y, s)
1219
+ (v, _, w, y, s) => t._mapFn(v, _, w, y, s)
1221
1220
  ) : null;
1222
1221
  }
1223
1222
  function ne({
@@ -1227,13 +1226,13 @@ function ne({
1227
1226
  return st(() => {
1228
1227
  const g = i.current;
1229
1228
  if (!g || !g.parentElement) return;
1230
- const v = g.parentElement, E = Array.from(v.childNodes).indexOf(g);
1229
+ const v = g.parentElement, w = Array.from(v.childNodes).indexOf(g);
1231
1230
  let y = v.getAttribute("data-parent-id");
1232
1231
  y || (y = `parent-${crypto.randomUUID()}`, v.setAttribute("data-parent-id", y));
1233
1232
  const I = {
1234
1233
  instanceId: `instance-${crypto.randomUUID()}`,
1235
1234
  parentId: y,
1236
- position: E,
1235
+ position: w,
1237
1236
  effect: t._effect
1238
1237
  };
1239
1238
  o.getState().addSignalElement(m, I);
@@ -1253,7 +1252,7 @@ function ne({
1253
1252
  S !== null && typeof S == "object" && (S = JSON.stringify(S));
1254
1253
  const F = document.createTextNode(String(S));
1255
1254
  g.replaceWith(F);
1256
- }, [t._stateKey, t._path.join("."), t._effect]), ut("span", {
1255
+ }, [t._stateKey, t._path.join("."), t._effect]), gt("span", {
1257
1256
  ref: i,
1258
1257
  style: { display: "none" },
1259
1258
  "data-signal-id": m
@@ -1272,7 +1271,7 @@ function Te(t) {
1272
1271
  },
1273
1272
  () => o.getState().getNestedState(t._stateKey, t._path)
1274
1273
  );
1275
- return ut("text", {}, String(i));
1274
+ return gt("text", {}, String(i));
1276
1275
  }
1277
1276
  function re({
1278
1277
  stateKey: t,
@@ -1280,14 +1279,14 @@ function re({
1280
1279
  itemPath: m,
1281
1280
  children: g
1282
1281
  }) {
1283
- const [, v] = K({}), [A, E] = qt(), y = J(null);
1282
+ const [, v] = K({}), [_, w] = qt(), y = J(null);
1284
1283
  return st(() => {
1285
- E.height > 0 && E.height !== y.current && (y.current = E.height, o.getState().setShadowMetadata(t, m, {
1284
+ w.height > 0 && w.height !== y.current && (y.current = w.height, o.getState().setShadowMetadata(t, m, {
1286
1285
  virtualizer: {
1287
- itemHeight: E.height
1286
+ itemHeight: w.height
1288
1287
  }
1289
1288
  }));
1290
- }, [E.height, t, m]), dt(() => {
1289
+ }, [w.height, t, m]), ut(() => {
1291
1290
  const s = `${t}////${i}`, I = o.getState().stateComponents.get(t) || {
1292
1291
  components: /* @__PURE__ */ new Map()
1293
1292
  };
@@ -1298,10 +1297,10 @@ function re({
1298
1297
  const n = o.getState().stateComponents.get(t);
1299
1298
  n && n.components.delete(s);
1300
1299
  };
1301
- }, [t, i, m.join(".")]), /* @__PURE__ */ Ot("div", { ref: A, children: g });
1300
+ }, [t, i, m.join(".")]), /* @__PURE__ */ Ot("div", { ref: _, children: g });
1302
1301
  }
1303
1302
  export {
1304
- Pt as $cogsSignal,
1303
+ Vt as $cogsSignal,
1305
1304
  Te as $cogsSignalStore,
1306
1305
  me as addStateOptions,
1307
1306
  he as createCogsState,