cogsbox-state 0.5.305 → 0.5.306

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as yt } from "react/jsx-runtime";
3
- import { useState as nt, useRef as q, useEffect as at, useLayoutEffect as dt, useMemo as It, createElement as st, useSyncExternalStore as Mt, startTransition as jt, useCallback as Et } from "react";
4
- import { transformStateFunc as Ot, isDeepEqual as z, isFunction as Z, getNestedValue as B, getDifferences as pt, debounce as Rt } from "./utility.js";
5
- import { pushFunc as vt, updateFn as ot, cutFunc as lt, ValidationWrapper as Ft, FormControlComponent as Ut } from "./Functions.jsx";
3
+ import { useState as tt, useRef as B, useEffect as at, useLayoutEffect as dt, useMemo as It, createElement as st, useSyncExternalStore as Mt, startTransition as jt, useCallback as Et } from "react";
4
+ import { transformStateFunc as Ot, isDeepEqual as H, isFunction as Y, getNestedValue as z, getDifferences as pt, debounce as Ft } from "./utility.js";
5
+ import { pushFunc as vt, updateFn as ot, cutFunc as lt, ValidationWrapper as Rt, FormControlComponent as Ut } from "./Functions.jsx";
6
6
  import Dt from "superjson";
7
7
  import { v4 as wt } from "uuid";
8
8
  import "zod";
@@ -17,18 +17,18 @@ function $t(t, c) {
17
17
  ...c
18
18
  });
19
19
  }
20
- function kt({
20
+ function bt({
21
21
  stateKey: t,
22
22
  options: c,
23
23
  initialOptionsPart: m
24
24
  }) {
25
- const f = et(t) || {}, y = m[t] || {}, k = o.getState().setInitialStateOptions, p = { ...y, ...f };
25
+ const f = nt(t) || {}, y = m[t] || {}, b = o.getState().setInitialStateOptions, p = { ...y, ...f };
26
26
  let I = !1;
27
27
  if (c)
28
28
  for (const a in c)
29
29
  p.hasOwnProperty(a) ? (a == "localStorage" && c[a] && p[a].key !== c[a]?.key && (I = !0, p[a] = c[a]), a == "initialState" && c[a] && p[a] !== c[a] && // Different references
30
- !z(p[a], c[a]) && (I = !0, p[a] = c[a])) : (I = !0, p[a] = c[a]);
31
- I && k(t, p);
30
+ !H(p[a], c[a]) && (I = !0, p[a] = c[a])) : (I = !0, p[a] = c[a]);
31
+ I && b(t, p);
32
32
  }
33
33
  function de(t, { formElements: c, validation: m }) {
34
34
  return { initialState: t, formElements: c, validation: m };
@@ -43,16 +43,16 @@ const ue = (t, c) => {
43
43
  ...c?.validation,
44
44
  ...y[I].formElements || {}
45
45
  // State-specific overrides
46
- }, et(I) || o.getState().setInitialStateOptions(I, y[I]);
46
+ }, nt(I) || o.getState().setInitialStateOptions(I, y[I]);
47
47
  }), o.getState().setInitialStates(f), o.getState().setCreatedState(f);
48
- const k = (I, a) => {
49
- const [v] = nt(a?.componentId ?? wt());
50
- kt({
48
+ const b = (I, a) => {
49
+ const [v] = tt(a?.componentId ?? wt());
50
+ bt({
51
51
  stateKey: I,
52
52
  options: a,
53
53
  initialOptionsPart: y
54
54
  });
55
- const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [G, F] = Yt(
55
+ const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [W, R] = Yt(
56
56
  S,
57
57
  {
58
58
  stateKey: I,
@@ -68,33 +68,33 @@ const ue = (t, c) => {
68
68
  serverState: a?.serverState
69
69
  }
70
70
  );
71
- return F;
71
+ return R;
72
72
  };
73
73
  function p(I, a) {
74
- kt({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage && Bt(I, a), St(I);
74
+ bt({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage && Bt(I, a), St(I);
75
75
  }
76
- return { useCogsState: k, setCogsOptions: p };
76
+ return { useCogsState: b, setCogsOptions: p };
77
77
  }, {
78
78
  setUpdaterState: ut,
79
- setState: tt,
80
- getInitialOptions: et,
79
+ setState: et,
80
+ getInitialOptions: nt,
81
81
  getKeyState: Vt,
82
82
  getValidationErrors: Lt,
83
83
  setStateLog: Ht,
84
84
  updateInitialStateGlobal: At,
85
85
  addValidationError: zt,
86
- removeValidationError: Y,
86
+ removeValidationError: J,
87
87
  setServerSyncActions: qt
88
- } = o.getState(), Nt = (t, c, m, f, y) => {
88
+ } = o.getState(), kt = (t, c, m, f, y) => {
89
89
  m?.log && console.log(
90
90
  "saving to localstorage",
91
91
  c,
92
92
  m.localStorage?.key,
93
93
  f
94
94
  );
95
- const k = Z(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
96
- if (k && f) {
97
- const p = `${f}-${c}-${k}`;
95
+ const b = Y(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
96
+ if (b && f) {
97
+ const p = `${f}-${c}-${b}`;
98
98
  let I;
99
99
  try {
100
100
  I = ft(p)?.lastSyncedWithServer;
@@ -119,27 +119,27 @@ const ue = (t, c) => {
119
119
  return console.error("Error loading from localStorage:", c), null;
120
120
  }
121
121
  }, Bt = (t, c) => {
122
- const m = o.getState().cogsStateStore[t], { sessionId: f } = Ct(), y = Z(c?.localStorage?.key) ? c.localStorage.key(m) : c?.localStorage?.key;
122
+ const m = o.getState().cogsStateStore[t], { sessionId: f } = Ct(), y = Y(c?.localStorage?.key) ? c.localStorage.key(m) : c?.localStorage?.key;
123
123
  if (y && f) {
124
- const k = ft(
124
+ const b = ft(
125
125
  `${f}-${t}-${y}`
126
126
  );
127
- if (k && k.lastUpdated > (k.lastSyncedWithServer || 0))
128
- return tt(t, k.state), St(t), !0;
127
+ if (b && b.lastUpdated > (b.lastSyncedWithServer || 0))
128
+ return et(t, b.state), St(t), !0;
129
129
  }
130
130
  return !1;
131
- }, xt = (t, c, m, f, y, k) => {
131
+ }, xt = (t, c, m, f, y, b) => {
132
132
  const p = {
133
133
  initialState: c,
134
134
  updaterState: gt(
135
135
  t,
136
136
  f,
137
137
  y,
138
- k
138
+ b
139
139
  ),
140
140
  state: m
141
141
  };
142
- At(t, p.initialState), ut(t, p.updaterState), tt(t, p.state);
142
+ At(t, p.initialState), ut(t, p.updaterState), et(t, p.state);
143
143
  }, St = (t) => {
144
144
  const c = o.getState().stateComponents.get(t);
145
145
  if (!c) return;
@@ -161,18 +161,18 @@ const ue = (t, c) => {
161
161
  switch (t) {
162
162
  case "update":
163
163
  return {
164
- oldValue: B(c, f),
165
- newValue: B(m, f)
164
+ oldValue: z(c, f),
165
+ newValue: z(m, f)
166
166
  };
167
167
  case "insert":
168
168
  return {
169
169
  oldValue: null,
170
170
  // or undefined
171
- newValue: B(m, f)
171
+ newValue: z(m, f)
172
172
  };
173
173
  case "cut":
174
174
  return {
175
- oldValue: B(c, f),
175
+ oldValue: z(c, f),
176
176
  newValue: null
177
177
  // or undefined
178
178
  };
@@ -185,7 +185,7 @@ function Yt(t, {
185
185
  serverSync: m,
186
186
  localStorage: f,
187
187
  formElements: y,
188
- reactiveDeps: k,
188
+ reactiveDeps: b,
189
189
  reactiveType: p,
190
190
  componentId: I,
191
191
  initialState: a,
@@ -193,14 +193,14 @@ function Yt(t, {
193
193
  dependencies: n,
194
194
  serverState: S
195
195
  } = {}) {
196
- const [G, F] = nt({}), { sessionId: U } = Ct();
197
- let L = !c;
198
- const [h] = nt(c ?? wt()), l = o.getState().stateLog[h], it = q(/* @__PURE__ */ new Set()), X = q(I ?? wt()), j = q(
196
+ const [W, R] = tt({}), { sessionId: U } = Ct();
197
+ let G = !c;
198
+ const [h] = tt(c ?? wt()), l = o.getState().stateLog[h], it = B(/* @__PURE__ */ new Set()), Z = B(I ?? wt()), j = B(
199
199
  null
200
200
  );
201
- j.current = et(h) ?? null, at(() => {
201
+ j.current = nt(h) ?? null, at(() => {
202
202
  if (v && v.stateKey === h && v.path?.[0]) {
203
- tt(h, (r) => ({
203
+ et(h, (r) => ({
204
204
  ...r,
205
205
  [v.path[0]]: v.newValue
206
206
  }));
@@ -216,21 +216,21 @@ function Yt(t, {
216
216
  initialState: a
217
217
  });
218
218
  const e = j.current, s = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, i = o.getState().initialStateGlobal[h];
219
- if (!(i && !z(i, a) || !i) && !s)
219
+ if (!(i && !H(i, a) || !i) && !s)
220
220
  return;
221
- let u = null;
222
- const A = Z(e?.localStorage?.key) ? e?.localStorage?.key(a) : e?.localStorage?.key;
223
- A && U && (u = ft(`${U}-${h}-${A}`));
221
+ let g = null;
222
+ const A = Y(e?.localStorage?.key) ? e?.localStorage?.key(a) : e?.localStorage?.key;
223
+ A && U && (g = ft(`${U}-${h}-${A}`));
224
224
  let w = a, T = !1;
225
- const P = s ? Date.now() : 0, x = u?.lastUpdated || 0, M = u?.lastSyncedWithServer || 0;
226
- s && P > x ? (w = e.serverState.data, T = !0) : u && x > M && (w = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(w)), o.getState().initializeShadowState(h, a), xt(
225
+ const _ = s ? Date.now() : 0, C = g?.lastUpdated || 0, M = g?.lastSyncedWithServer || 0;
226
+ s && _ > C ? (w = e.serverState.data, T = !0) : g && C > M && (w = g.state, e?.localStorage?.onChange && e?.localStorage?.onChange(w)), o.getState().initializeShadowState(h, a), xt(
227
227
  h,
228
228
  a,
229
229
  w,
230
230
  rt,
231
- X.current,
231
+ Z.current,
232
232
  U
233
- ), T && A && U && Nt(w, h, e, U, Date.now()), St(h), (Array.isArray(p) ? p : [p || "component"]).includes("none") || F({});
233
+ ), T && A && U && kt(w, h, e, U, Date.now()), St(h), (Array.isArray(p) ? p : [p || "component"]).includes("none") || R({});
234
234
  }
235
235
  }, [
236
236
  a,
@@ -238,178 +238,178 @@ function Yt(t, {
238
238
  S?.data,
239
239
  ...n || []
240
240
  ]), dt(() => {
241
- L && $t(h, {
241
+ G && $t(h, {
242
242
  serverSync: m,
243
243
  formElements: y,
244
244
  initialState: a,
245
245
  localStorage: f,
246
246
  middleware: j.current?.middleware
247
247
  });
248
- const e = `${h}////${X.current}`, r = o.getState().stateComponents.get(h) || {
248
+ const e = `${h}////${Z.current}`, r = o.getState().stateComponents.get(h) || {
249
249
  components: /* @__PURE__ */ new Map()
250
250
  };
251
251
  return r.components.set(e, {
252
- forceUpdate: () => F({}),
252
+ forceUpdate: () => R({}),
253
253
  paths: /* @__PURE__ */ new Set(),
254
254
  deps: [],
255
- depsFunction: k || void 0,
255
+ depsFunction: b || void 0,
256
256
  reactiveType: p ?? ["component", "deps"]
257
- }), o.getState().stateComponents.set(h, r), F({}), () => {
257
+ }), o.getState().stateComponents.set(h, r), R({}), () => {
258
258
  r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(h));
259
259
  };
260
260
  }, []);
261
261
  const rt = (e, r, s, i) => {
262
262
  if (Array.isArray(r)) {
263
- const u = `${h}-${r.join(".")}`;
264
- it.current.add(u);
263
+ const g = `${h}-${r.join(".")}`;
264
+ it.current.add(g);
265
265
  }
266
- const g = o.getState();
267
- tt(h, (u) => {
268
- const A = Z(e) ? e(u) : e, w = `${h}-${r.join(".")}`;
266
+ const u = o.getState();
267
+ et(h, (g) => {
268
+ const A = Y(e) ? e(g) : e, w = `${h}-${r.join(".")}`;
269
269
  if (w) {
270
- let b = !1, N = g.signalDomElements.get(w);
271
- if ((!N || N.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
272
- const O = r.slice(0, -1), W = B(A, O);
273
- if (Array.isArray(W)) {
274
- b = !0;
270
+ let V = !1, k = u.signalDomElements.get(w);
271
+ if ((!k || k.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
272
+ const O = r.slice(0, -1), D = z(A, O);
273
+ if (Array.isArray(D)) {
274
+ V = !0;
275
275
  const $ = `${h}-${O.join(".")}`;
276
- N = g.signalDomElements.get($);
276
+ k = u.signalDomElements.get($);
277
277
  }
278
278
  }
279
- if (N) {
280
- const O = b ? B(A, r.slice(0, -1)) : B(A, r);
281
- N.forEach(({ parentId: W, position: $, effect: E }) => {
282
- const C = document.querySelector(
283
- `[data-parent-id="${W}"]`
279
+ if (k) {
280
+ const O = V ? z(A, r.slice(0, -1)) : z(A, r);
281
+ k.forEach(({ parentId: D, position: $, effect: E }) => {
282
+ const N = document.querySelector(
283
+ `[data-parent-id="${D}"]`
284
284
  );
285
- if (C) {
286
- const R = Array.from(C.childNodes);
287
- if (R[$]) {
288
- const _ = E ? new Function("state", `return (${E})(state)`)(O) : O;
289
- R[$].textContent = String(_);
285
+ if (N) {
286
+ const F = Array.from(N.childNodes);
287
+ if (F[$]) {
288
+ const x = E ? new Function("state", `return (${E})(state)`)(O) : O;
289
+ F[$].textContent = String(x);
290
290
  }
291
291
  }
292
292
  });
293
293
  }
294
294
  }
295
- console.log("shadowState", g.shadowStateStore), s.updateType === "update" && (i || j.current?.validation?.key) && r && Y(
295
+ console.log("shadowState", u.shadowStateStore), s.updateType === "update" && (i || j.current?.validation?.key) && r && J(
296
296
  (i || j.current?.validation?.key) + "." + r.join(".")
297
297
  );
298
298
  const T = r.slice(0, r.length - 1);
299
- s.updateType === "cut" && j.current?.validation?.key && Y(
299
+ s.updateType === "cut" && j.current?.validation?.key && J(
300
300
  j.current?.validation?.key + "." + T.join(".")
301
301
  ), s.updateType === "insert" && j.current?.validation?.key && Lt(
302
302
  j.current?.validation?.key + "." + T.join(".")
303
- ).filter(([N, O]) => {
304
- let W = N?.split(".").length;
305
- if (N == T.join(".") && W == T.length - 1) {
306
- let $ = N + "." + T;
307
- Y(N), zt($, O);
303
+ ).filter(([k, O]) => {
304
+ let D = k?.split(".").length;
305
+ if (k == T.join(".") && D == T.length - 1) {
306
+ let $ = k + "." + T;
307
+ J(k), zt($, O);
308
308
  }
309
309
  });
310
- const P = g.stateComponents.get(h);
311
- if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", P), P) {
312
- const b = pt(u, A), N = new Set(b), O = s.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
310
+ const _ = u.stateComponents.get(h);
311
+ if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", _), _) {
312
+ const V = pt(g, A), k = new Set(V), O = s.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
313
313
  for (const [
314
- W,
314
+ D,
315
315
  $
316
- ] of P.components.entries()) {
316
+ ] of _.components.entries()) {
317
317
  let E = !1;
318
- const C = Array.isArray($.reactiveType) ? $.reactiveType : [$.reactiveType || "component"];
319
- if (console.log("component", $), !C.includes("none")) {
320
- if (C.includes("all")) {
318
+ const N = Array.isArray($.reactiveType) ? $.reactiveType : [$.reactiveType || "component"];
319
+ if (console.log("component", $), !N.includes("none")) {
320
+ if (N.includes("all")) {
321
321
  $.forceUpdate();
322
322
  continue;
323
323
  }
324
- if (C.includes("component") && (($.paths.has(O) || $.paths.has("")) && (E = !0), !E))
325
- for (const R of N) {
326
- let _ = R;
324
+ if (N.includes("component") && (($.paths.has(O) || $.paths.has("")) && (E = !0), !E))
325
+ for (const F of k) {
326
+ let x = F;
327
327
  for (; ; ) {
328
- if ($.paths.has(_)) {
328
+ if ($.paths.has(x)) {
329
329
  E = !0;
330
330
  break;
331
331
  }
332
- const D = _.lastIndexOf(".");
333
- if (D !== -1) {
334
- const H = _.substring(
332
+ const L = x.lastIndexOf(".");
333
+ if (L !== -1) {
334
+ const X = x.substring(
335
335
  0,
336
- D
336
+ L
337
337
  );
338
338
  if (!isNaN(
339
- Number(_.substring(D + 1))
340
- ) && $.paths.has(H)) {
339
+ Number(x.substring(L + 1))
340
+ ) && $.paths.has(X)) {
341
341
  E = !0;
342
342
  break;
343
343
  }
344
- _ = H;
344
+ x = X;
345
345
  } else
346
- _ = "";
347
- if (_ === "")
346
+ x = "";
347
+ if (x === "")
348
348
  break;
349
349
  }
350
350
  if (E) break;
351
351
  }
352
- if (!E && C.includes("deps") && $.depsFunction) {
353
- const R = $.depsFunction(A);
354
- let _ = !1;
355
- typeof R == "boolean" ? R && (_ = !0) : z($.deps, R) || ($.deps = R, _ = !0), _ && (E = !0);
352
+ if (!E && N.includes("deps") && $.depsFunction) {
353
+ const F = $.depsFunction(A);
354
+ let x = !1;
355
+ typeof F == "boolean" ? F && (x = !0) : H($.deps, F) || ($.deps = F, x = !0), x && (E = !0);
356
356
  }
357
357
  E && $.forceUpdate();
358
358
  }
359
359
  }
360
360
  }
361
- const x = Date.now();
362
- r = r.map((b, N) => {
363
- const O = r.slice(0, -1), W = B(A, O);
364
- return N === r.length - 1 && ["insert", "cut"].includes(s.updateType) ? (W.length - 1).toString() : b;
361
+ const C = Date.now();
362
+ r = r.map((V, k) => {
363
+ const O = r.slice(0, -1), D = z(A, O);
364
+ return k === r.length - 1 && ["insert", "cut"].includes(s.updateType) ? (D.length - 1).toString() : V;
365
365
  });
366
- const { oldValue: M, newValue: V } = Jt(
366
+ const { oldValue: M, newValue: P } = Jt(
367
367
  s.updateType,
368
- u,
368
+ g,
369
369
  A,
370
370
  r
371
- ), J = {
372
- timeStamp: x,
371
+ ), q = {
372
+ timeStamp: C,
373
373
  stateKey: h,
374
374
  path: r,
375
375
  updateType: s.updateType,
376
376
  status: "new",
377
377
  oldValue: M,
378
- newValue: V
378
+ newValue: P
379
379
  };
380
380
  switch (s.updateType) {
381
381
  case "update":
382
- g.updateShadowAtPath(h, r, A);
382
+ u.updateShadowAtPath(h, r, A);
383
383
  break;
384
384
  case "insert":
385
- const b = r.slice(0, -1);
386
- g.insertShadowArrayElement(h, b, V);
385
+ const V = r.slice(0, -1);
386
+ u.insertShadowArrayElement(h, V, P);
387
387
  break;
388
388
  case "cut":
389
- const N = r.slice(0, -1), O = parseInt(r[r.length - 1]);
390
- g.removeShadowArrayElement(h, N, O);
389
+ const k = r.slice(0, -1), O = parseInt(r[r.length - 1]);
390
+ u.removeShadowArrayElement(h, k, O);
391
391
  break;
392
392
  }
393
- if (Ht(h, (b) => {
394
- const O = [...b ?? [], J].reduce((W, $) => {
395
- const E = `${$.stateKey}:${JSON.stringify($.path)}`, C = W.get(E);
396
- return C ? (C.timeStamp = Math.max(C.timeStamp, $.timeStamp), C.newValue = $.newValue, C.oldValue = C.oldValue ?? $.oldValue, C.updateType = $.updateType) : W.set(E, { ...$ }), W;
393
+ if (Ht(h, (V) => {
394
+ const O = [...V ?? [], q].reduce((D, $) => {
395
+ const E = `${$.stateKey}:${JSON.stringify($.path)}`, N = D.get(E);
396
+ return N ? (N.timeStamp = Math.max(N.timeStamp, $.timeStamp), N.newValue = $.newValue, N.oldValue = N.oldValue ?? $.oldValue, N.updateType = $.updateType) : D.set(E, { ...$ }), D;
397
397
  }, /* @__PURE__ */ new Map());
398
398
  return Array.from(O.values());
399
- }), Nt(
399
+ }), kt(
400
400
  A,
401
401
  h,
402
402
  j.current,
403
403
  U
404
404
  ), j.current?.middleware && j.current.middleware({
405
405
  updateLog: l,
406
- update: J
406
+ update: q
407
407
  }), j.current?.serverSync) {
408
- const b = g.serverState[h], N = j.current?.serverSync;
408
+ const V = u.serverState[h], k = j.current?.serverSync;
409
409
  qt(h, {
410
- syncKey: typeof N.syncKey == "string" ? N.syncKey : N.syncKey({ state: A }),
411
- rollBackState: b,
412
- actionTimeStamp: Date.now() + (N.debounce ?? 3e3),
410
+ syncKey: typeof k.syncKey == "string" ? k.syncKey : k.syncKey({ state: A }),
411
+ rollBackState: V,
412
+ actionTimeStamp: Date.now() + (k.debounce ?? 3e3),
413
413
  status: "waiting"
414
414
  });
415
415
  }
@@ -421,58 +421,58 @@ function Yt(t, {
421
421
  gt(
422
422
  h,
423
423
  rt,
424
- X.current,
424
+ Z.current,
425
425
  U
426
426
  )
427
- ), o.getState().cogsStateStore[h] || tt(h, t), o.getState().initialStateGlobal[h] || At(h, t));
427
+ ), o.getState().cogsStateStore[h] || et(h, t), o.getState().initialStateGlobal[h] || At(h, t));
428
428
  const d = It(() => gt(
429
429
  h,
430
430
  rt,
431
- X.current,
431
+ Z.current,
432
432
  U
433
433
  ), [h, U]);
434
434
  return [Vt(h), d];
435
435
  }
436
436
  function gt(t, c, m, f) {
437
437
  const y = /* @__PURE__ */ new Map();
438
- let k = 0;
438
+ let b = 0;
439
439
  const p = (v) => {
440
440
  const n = v.join(".");
441
441
  for (const [S] of y)
442
442
  (S === n || S.startsWith(n + ".")) && y.delete(S);
443
- k++;
443
+ b++;
444
444
  }, I = {
445
445
  removeValidation: (v) => {
446
- v?.validationKey && Y(v.validationKey);
446
+ v?.validationKey && J(v.validationKey);
447
447
  },
448
448
  revertToInitialState: (v) => {
449
449
  const n = o.getState().getInitialOptions(t)?.validation;
450
- n?.key && Y(n?.key), v?.validationKey && Y(v.validationKey);
450
+ n?.key && J(n?.key), v?.validationKey && J(v.validationKey);
451
451
  const S = o.getState().initialStateGlobal[t];
452
- o.getState().clearSelectedIndexesForState(t), y.clear(), k++;
453
- const G = a(S, []), F = et(t), U = Z(F?.localStorage?.key) ? F?.localStorage?.key(S) : F?.localStorage?.key, L = `${f}-${t}-${U}`;
454
- L && localStorage.removeItem(L), ut(t, G), tt(t, S);
452
+ o.getState().clearSelectedIndexesForState(t), y.clear(), b++;
453
+ const W = a(S, []), R = nt(t), U = Y(R?.localStorage?.key) ? R?.localStorage?.key(S) : R?.localStorage?.key, G = `${f}-${t}-${U}`;
454
+ G && localStorage.removeItem(G), ut(t, W), et(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: (v) => {
461
- y.clear(), k++;
461
+ y.clear(), b++;
462
462
  const n = gt(
463
463
  t,
464
464
  c,
465
465
  m,
466
466
  f
467
- ), S = o.getState().initialStateGlobal[t], G = et(t), F = Z(G?.localStorage?.key) ? G?.localStorage?.key(S) : G?.localStorage?.key, U = `${f}-${t}-${F}`;
467
+ ), S = o.getState().initialStateGlobal[t], W = nt(t), R = Y(W?.localStorage?.key) ? W?.localStorage?.key(S) : W?.localStorage?.key, U = `${f}-${t}-${R}`;
468
468
  return localStorage.getItem(U) && localStorage.removeItem(U), jt(() => {
469
- At(t, v), o.getState().initializeShadowState(t, v), ut(t, n), tt(t, v);
470
- const L = o.getState().stateComponents.get(t);
471
- L && L.components.forEach((h) => {
469
+ At(t, v), o.getState().initializeShadowState(t, v), ut(t, n), et(t, v);
470
+ const G = o.getState().stateComponents.get(t);
471
+ G && G.components.forEach((h) => {
472
472
  h.forceUpdate();
473
473
  });
474
474
  }), {
475
- fetchId: (L) => n.get()[L]
475
+ fetchId: (G) => n.get()[G]
476
476
  };
477
477
  },
478
478
  _initialState: o.getState().initialStateGlobal[t],
@@ -480,17 +480,17 @@ function gt(t, c, m, f) {
480
480
  _isLoading: o.getState().isLoadingGlobal[t],
481
481
  _isServerSynced: () => {
482
482
  const v = o.getState().serverState[t];
483
- return !!(v && z(v, Vt(t)));
483
+ return !!(v && H(v, Vt(t)));
484
484
  }
485
485
  };
486
486
  function a(v, n = [], S) {
487
- const G = n.map(String).join(".");
488
- y.get(G);
489
- const F = function() {
487
+ const W = n.map(String).join(".");
488
+ y.get(W);
489
+ const R = function() {
490
490
  return o().getNestedState(t, n);
491
491
  };
492
492
  Object.keys(I).forEach((h) => {
493
- F[h] = I[h];
493
+ R[h] = I[h];
494
494
  });
495
495
  const U = {
496
496
  apply(h, l, it) {
@@ -530,8 +530,8 @@ function gt(t, c, m, f) {
530
530
  if (r && !r.paths.has("")) {
531
531
  const s = n.join(".");
532
532
  let i = !0;
533
- for (const g of r.paths)
534
- if (s.startsWith(g) && (s === g || s[g.length] === ".")) {
533
+ for (const u of r.paths)
534
+ if (s.startsWith(u) && (s === u || s[u.length] === ".")) {
535
535
  i = !1;
536
536
  break;
537
537
  }
@@ -553,13 +553,13 @@ function gt(t, c, m, f) {
553
553
  try {
554
554
  const i = await e.action(r);
555
555
  if (i && !i.success && i.errors && s) {
556
- o.getState().removeValidationError(s), i.errors.forEach((u) => {
557
- const A = [s, ...u.path].join(".");
558
- o.getState().addValidationError(A, u.message);
556
+ o.getState().removeValidationError(s), i.errors.forEach((g) => {
557
+ const A = [s, ...g.path].join(".");
558
+ o.getState().addValidationError(A, g.message);
559
559
  });
560
- const g = o.getState().stateComponents.get(t);
561
- g && g.components.forEach((u) => {
562
- u.forceUpdate();
560
+ const u = o.getState().stateComponents.get(t);
561
+ u && u.components.forEach((g) => {
562
+ g.forceUpdate();
563
563
  });
564
564
  }
565
565
  return i?.success && e.onSuccess ? e.onSuccess(i.data) : !i?.success && e.onError && e.onError(i.error), i;
@@ -568,20 +568,20 @@ function gt(t, c, m, f) {
568
568
  }
569
569
  };
570
570
  if (l === "_status") {
571
- const d = o.getState().getNestedState(t, n), e = o.getState().initialStateGlobal[t], r = B(e, n);
572
- return z(d, r) ? "fresh" : "stale";
571
+ const d = o.getState().getNestedState(t, n), e = o.getState().initialStateGlobal[t], r = z(e, n);
572
+ return H(d, r) ? "fresh" : "stale";
573
573
  }
574
574
  if (l === "getStatus")
575
575
  return function() {
576
576
  const d = o().getNestedState(
577
577
  t,
578
578
  n
579
- ), e = o.getState().initialStateGlobal[t], r = B(e, n);
580
- return z(d, r) ? "fresh" : "stale";
579
+ ), e = o.getState().initialStateGlobal[t], r = z(e, n);
580
+ return H(d, r) ? "fresh" : "stale";
581
581
  };
582
582
  if (l === "removeStorage")
583
583
  return () => {
584
- const d = o.getState().initialStateGlobal[t], e = et(t), r = Z(e?.localStorage?.key) ? e?.localStorage?.key(d) : e?.localStorage?.key, s = `${f}-${t}-${r}`;
584
+ const d = o.getState().initialStateGlobal[t], e = nt(t), r = Y(e?.localStorage?.key) ? e?.localStorage?.key(d) : e?.localStorage?.key, s = `${f}-${t}-${r}`;
585
585
  s && localStorage.removeItem(s);
586
586
  };
587
587
  if (l === "showValidationErrors")
@@ -621,160 +621,156 @@ function gt(t, c, m, f) {
621
621
  itemHeight: r = 50,
622
622
  overscan: s = 5,
623
623
  stickToBottom: i = !1
624
- } = e, g = q(null), [u, A] = nt({
624
+ } = e, u = B(null), [g, A] = tt({
625
625
  startIndex: 0,
626
626
  endIndex: 10
627
- }), w = q(i), T = q(0), P = q(!0), x = q(!1), M = o().getNestedState(
627
+ }), [, w] = tt({}), T = B(i), _ = B(0), C = B(!0);
628
+ at(() => o.getState().subscribeToShadowState(t, () => w({})), [t]);
629
+ const M = o().getNestedState(
628
630
  t,
629
631
  n
630
- ), V = M.length, { totalHeight: J, positions: b } = It(() => {
632
+ ), P = M.length, { totalHeight: q, positions: V } = It(() => {
631
633
  const E = o.getState().getShadowMetadata(t, n) || [];
632
- let C = 0;
633
- const R = [];
634
- let _ = !1;
635
- for (let D = 0; D < V; D++) {
636
- R[D] = C;
637
- const H = E[D]?.virtualizer?.itemHeight;
638
- H && (_ = !0), C += H || r;
634
+ let N = 0;
635
+ const F = [];
636
+ for (let x = 0; x < P; x++) {
637
+ F[x] = N;
638
+ const L = E[x]?.virtualizer?.itemHeight;
639
+ N += L || r;
639
640
  }
640
- return x.current = _, { totalHeight: C, positions: R };
641
- }, [V, t, n.join("."), r]), N = It(() => {
642
- const E = Math.max(0, u.startIndex), C = Math.min(V, u.endIndex), R = Array.from(
643
- { length: C - E },
644
- (D, H) => E + H
645
- ), _ = R.map((D) => M[D]);
646
- return a(_, n, {
641
+ return { totalHeight: N, positions: F };
642
+ }, [P, t, n.join("."), r]), k = It(() => {
643
+ const E = Math.max(0, g.startIndex), N = Math.min(P, g.endIndex), F = Array.from(
644
+ { length: N - E },
645
+ (L, X) => E + X
646
+ ), x = F.map((L) => M[L]);
647
+ return a(x, n, {
647
648
  ...S,
648
- validIndices: R
649
+ validIndices: F
649
650
  });
650
- }, [u.startIndex, u.endIndex, M, V]);
651
+ }, [g.startIndex, g.endIndex, M, P]);
651
652
  dt(() => {
652
- const E = g.current;
653
+ const E = u.current;
653
654
  if (!E) return;
654
- const C = w.current, R = V > T.current;
655
- T.current = V;
656
- const _ = () => {
657
- const { scrollTop: D, clientHeight: H, scrollHeight: Pt } = E;
658
- w.current = Pt - D - H < 10;
659
- let mt = 0, ct = V - 1;
655
+ const N = T.current, F = P > _.current;
656
+ _.current = P;
657
+ const x = () => {
658
+ const { scrollTop: L, clientHeight: X, scrollHeight: Pt } = E;
659
+ T.current = Pt - L - X < 10;
660
+ let mt = 0, ct = P - 1;
660
661
  for (; mt <= ct; ) {
661
662
  const K = Math.floor((mt + ct) / 2);
662
- b[K] < D ? mt = K + 1 : ct = K - 1;
663
+ V[K] < L ? mt = K + 1 : ct = K - 1;
663
664
  }
664
665
  const ht = Math.max(0, ct - s);
665
666
  let Q = ht;
666
- const _t = D + H;
667
- for (; Q < V && b[Q] < _t; )
667
+ const _t = L + X;
668
+ for (; Q < P && V[Q] < _t; )
668
669
  Q++;
669
- Q = Math.min(V, Q + s), A((K) => K.startIndex !== ht || K.endIndex !== Q ? { startIndex: ht, endIndex: Q } : K);
670
+ Q = Math.min(P, Q + s), A((K) => K.startIndex !== ht || K.endIndex !== Q ? { startIndex: ht, endIndex: Q } : K);
670
671
  };
671
- return E.addEventListener("scroll", _, {
672
+ return E.addEventListener("scroll", x, {
672
673
  passive: !0
673
- }), i && !P.current && C && R && requestAnimationFrame(() => {
674
+ }), i && (C.current && P > 0 ? requestAnimationFrame(() => {
675
+ requestAnimationFrame(() => {
676
+ u.current && (u.current.scrollTo({
677
+ top: u.current.scrollHeight,
678
+ behavior: "auto"
679
+ }), C.current = !1);
680
+ });
681
+ }) : !C.current && N && F && requestAnimationFrame(() => {
674
682
  E.scrollTo({
675
683
  top: E.scrollHeight,
676
684
  behavior: "smooth"
677
685
  });
678
- }), _(), () => E.removeEventListener("scroll", _);
679
- }, [V, b, s, i]), at(() => {
680
- if (i && P.current && V > 0 && x.current) {
681
- const E = g.current;
682
- E && requestAnimationFrame(() => {
683
- requestAnimationFrame(() => {
684
- E.scrollTo({
685
- top: E.scrollHeight,
686
- behavior: "auto"
687
- }), P.current = !1;
688
- });
689
- });
690
- }
691
- }, [i, V, b]);
686
+ })), x(), () => E.removeEventListener("scroll", x);
687
+ }, [P, V, s, i]);
692
688
  const O = Et(
693
689
  (E = "smooth") => {
694
- g.current && g.current.scrollTo({
695
- top: g.current.scrollHeight,
690
+ u.current && u.current.scrollTo({
691
+ top: u.current.scrollHeight,
696
692
  behavior: E
697
693
  });
698
694
  },
699
695
  []
700
- ), W = Et(
701
- (E, C = "smooth") => {
702
- g.current && b[E] !== void 0 && g.current.scrollTo({
703
- top: b[E],
704
- behavior: C
696
+ ), D = Et(
697
+ (E, N = "smooth") => {
698
+ u.current && V[E] !== void 0 && u.current.scrollTo({
699
+ top: V[E],
700
+ behavior: N
705
701
  });
706
702
  },
707
- [b]
703
+ [V]
708
704
  ), $ = {
709
705
  outer: {
710
- ref: g,
706
+ ref: u,
711
707
  style: { overflowY: "auto", height: "100%" }
712
708
  },
713
709
  inner: {
714
710
  style: {
715
- height: `${J}px`,
711
+ height: `${q}px`,
716
712
  position: "relative"
717
713
  }
718
714
  },
719
715
  list: {
720
716
  style: {
721
- transform: `translateY(${b[u.startIndex] || 0}px)`
717
+ transform: `translateY(${V[g.startIndex] || 0}px)`
722
718
  }
723
719
  }
724
720
  };
725
721
  return {
726
- virtualState: N,
722
+ virtualState: k,
727
723
  virtualizerProps: $,
728
724
  scrollToBottom: O,
729
- scrollToIndex: W
725
+ scrollToIndex: D
730
726
  };
731
727
  };
732
728
  if (l === "stateSort")
733
729
  return (e) => {
734
730
  const s = [...d()].sort(
735
- (u, A) => e(u.item, A.item)
736
- ), i = s.map(({ item: u }) => u), g = {
731
+ (g, A) => e(g.item, A.item)
732
+ ), i = s.map(({ item: g }) => g), u = {
737
733
  ...S,
738
734
  validIndices: s.map(
739
- ({ originalIndex: u }) => u
735
+ ({ originalIndex: g }) => g
740
736
  )
741
737
  };
742
- return a(i, n, g);
738
+ return a(i, n, u);
743
739
  };
744
740
  if (l === "stateFilter")
745
741
  return (e) => {
746
742
  const s = d().filter(
747
- ({ item: u }, A) => e(u, A)
748
- ), i = s.map(({ item: u }) => u), g = {
743
+ ({ item: g }, A) => e(g, A)
744
+ ), i = s.map(({ item: g }) => g), u = {
749
745
  ...S,
750
746
  validIndices: s.map(
751
- ({ originalIndex: u }) => u
747
+ ({ originalIndex: g }) => g
752
748
  )
753
749
  };
754
- return a(i, n, g);
750
+ return a(i, n, u);
755
751
  };
756
752
  if (l === "stateMap")
757
753
  return (e) => {
758
754
  const r = o.getState().getNestedState(t, n);
759
- return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, g) => g)).map((i, g) => {
760
- const u = r[i], A = [...n, i.toString()], w = a(u, A, S);
761
- return e(u, w, {
755
+ return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, u) => u)).map((i, u) => {
756
+ const g = r[i], A = [...n, i.toString()], w = a(g, A, S);
757
+ return e(g, w, {
762
758
  register: () => {
763
- const [, P] = nt({}), x = `${m}-${n.join(".")}-${i}`;
759
+ const [, _] = tt({}), C = `${m}-${n.join(".")}-${i}`;
764
760
  dt(() => {
765
- const M = `${t}////${x}`, V = o.getState().stateComponents.get(t) || {
761
+ const M = `${t}////${C}`, P = o.getState().stateComponents.get(t) || {
766
762
  components: /* @__PURE__ */ new Map()
767
763
  };
768
- return V.components.set(M, {
769
- forceUpdate: () => P({}),
764
+ return P.components.set(M, {
765
+ forceUpdate: () => _({}),
770
766
  paths: /* @__PURE__ */ new Set([A.join(".")])
771
- }), o.getState().stateComponents.set(t, V), () => {
772
- const J = o.getState().stateComponents.get(t);
773
- J && J.components.delete(M);
767
+ }), o.getState().stateComponents.set(t, P), () => {
768
+ const q = o.getState().stateComponents.get(t);
769
+ q && q.components.delete(M);
774
770
  };
775
- }, [t, x]);
771
+ }, [t, C]);
776
772
  },
777
- index: g,
773
+ index: u,
778
774
  originalIndex: i
779
775
  });
780
776
  }) : (console.warn(
@@ -784,9 +780,9 @@ function gt(t, c, m, f) {
784
780
  };
785
781
  if (l === "stateMapNoRender")
786
782
  return (e) => v.map((s, i) => {
787
- let g;
788
- S?.validIndices && S.validIndices[i] !== void 0 ? g = S.validIndices[i] : g = i;
789
- const u = [...n, g.toString()], A = a(s, u, S);
783
+ let u;
784
+ S?.validIndices && S.validIndices[i] !== void 0 ? u = S.validIndices[i] : u = i;
785
+ const g = [...n, u.toString()], A = a(s, g, S);
790
786
  return e(
791
787
  s,
792
788
  A,
@@ -808,17 +804,17 @@ function gt(t, c, m, f) {
808
804
  if (l === "stateList")
809
805
  return (e) => {
810
806
  const r = o.getState().getNestedState(t, n);
811
- return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, g) => g)).map((i, g) => {
812
- const u = r[i], A = [...n, i.toString()], w = a(u, A, S), T = `${m}-${n.join(".")}-${i}`;
807
+ return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, u) => u)).map((i, u) => {
808
+ const g = r[i], A = [...n, i.toString()], w = a(g, A, S), T = `${m}-${n.join(".")}-${i}`;
813
809
  return st(Qt, {
814
810
  key: i,
815
811
  stateKey: t,
816
812
  itemComponentId: T,
817
813
  itemPath: A,
818
814
  children: e(
819
- u,
820
- w,
821
815
  g,
816
+ w,
817
+ u,
822
818
  r,
823
819
  a(r, n, S)
824
820
  )
@@ -830,7 +826,7 @@ function gt(t, c, m, f) {
830
826
  if (l === "stateFlattenOn")
831
827
  return (e) => {
832
828
  const r = v;
833
- y.clear(), k++;
829
+ y.clear(), b++;
834
830
  const s = r.flatMap(
835
831
  (i) => i[e] ?? []
836
832
  );
@@ -859,22 +855,22 @@ function gt(t, c, m, f) {
859
855
  ));
860
856
  if (l === "uniqueInsert")
861
857
  return (e, r, s) => {
862
- const i = o.getState().getNestedState(t, n), g = Z(e) ? e(i) : e;
863
- let u = null;
858
+ const i = o.getState().getNestedState(t, n), u = Y(e) ? e(i) : e;
859
+ let g = null;
864
860
  if (!i.some((w) => {
865
861
  if (r) {
866
- const P = r.every(
867
- (x) => z(w[x], g[x])
862
+ const _ = r.every(
863
+ (C) => H(w[C], u[C])
868
864
  );
869
- return P && (u = w), P;
865
+ return _ && (g = w), _;
870
866
  }
871
- const T = z(w, g);
872
- return T && (u = w), T;
867
+ const T = H(w, u);
868
+ return T && (g = w), T;
873
869
  }))
874
- p(n), vt(c, g, n, t);
875
- else if (s && u) {
876
- const w = s(u), T = i.map(
877
- (P) => z(P, u) ? w : P
870
+ p(n), vt(c, u, n, t);
871
+ else if (s && g) {
872
+ const w = s(g), T = i.map(
873
+ (_) => H(_, g) ? w : _
878
874
  );
879
875
  p(n), ot(c, T, n);
880
876
  }
@@ -900,7 +896,7 @@ function gt(t, c, m, f) {
900
896
  if (l === "stateFind")
901
897
  return (e) => {
902
898
  const s = d().find(
903
- ({ item: g }, u) => e(g, u)
899
+ ({ item: u }, g) => e(u, g)
904
900
  );
905
901
  if (!s) return;
906
902
  const i = [...n, s.originalIndex.toString()];
@@ -909,22 +905,22 @@ function gt(t, c, m, f) {
909
905
  if (l === "findWith")
910
906
  return (e, r) => {
911
907
  const i = d().find(
912
- ({ item: u }) => u[e] === r
908
+ ({ item: g }) => g[e] === r
913
909
  );
914
910
  if (!i) return;
915
- const g = [...n, i.originalIndex.toString()];
916
- return a(i.item, g, S);
911
+ const u = [...n, i.originalIndex.toString()];
912
+ return a(i.item, u, S);
917
913
  };
918
914
  }
919
- const X = n[n.length - 1];
920
- if (!isNaN(Number(X))) {
915
+ const Z = n[n.length - 1];
916
+ if (!isNaN(Number(Z))) {
921
917
  const d = n.slice(0, -1), e = o.getState().getNestedState(t, d);
922
918
  if (Array.isArray(e) && l === "cut")
923
919
  return () => lt(
924
920
  c,
925
921
  d,
926
922
  t,
927
- Number(X)
923
+ Number(Z)
928
924
  );
929
925
  }
930
926
  if (l === "get")
@@ -936,13 +932,13 @@ function gt(t, c, m, f) {
936
932
  return o.getState().getNestedState(t, n);
937
933
  };
938
934
  if (l === "$derive")
939
- return (d) => bt({
935
+ return (d) => Nt({
940
936
  _stateKey: t,
941
937
  _path: n,
942
938
  _effect: d.toString()
943
939
  });
944
940
  if (l === "$get")
945
- return () => bt({
941
+ return () => Nt({
946
942
  _stateKey: t,
947
943
  _path: n
948
944
  });
@@ -988,55 +984,55 @@ function gt(t, c, m, f) {
988
984
  );
989
985
  const i = o.getState().stateComponents.get(t);
990
986
  if (i) {
991
- const g = pt(e, s), u = new Set(g);
987
+ const u = pt(e, s), g = new Set(u);
992
988
  for (const [
993
989
  A,
994
990
  w
995
991
  ] of i.components.entries()) {
996
992
  let T = !1;
997
- const P = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
998
- if (!P.includes("none")) {
999
- if (P.includes("all")) {
993
+ const _ = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
994
+ if (!_.includes("none")) {
995
+ if (_.includes("all")) {
1000
996
  w.forceUpdate();
1001
997
  continue;
1002
998
  }
1003
- if (P.includes("component") && (w.paths.has("") && (T = !0), !T))
1004
- for (const x of u) {
1005
- if (w.paths.has(x)) {
999
+ if (_.includes("component") && (w.paths.has("") && (T = !0), !T))
1000
+ for (const C of g) {
1001
+ if (w.paths.has(C)) {
1006
1002
  T = !0;
1007
1003
  break;
1008
1004
  }
1009
- let M = x.lastIndexOf(".");
1005
+ let M = C.lastIndexOf(".");
1010
1006
  for (; M !== -1; ) {
1011
- const V = x.substring(0, M);
1012
- if (w.paths.has(V)) {
1007
+ const P = C.substring(0, M);
1008
+ if (w.paths.has(P)) {
1013
1009
  T = !0;
1014
1010
  break;
1015
1011
  }
1016
- const J = x.substring(
1012
+ const q = C.substring(
1017
1013
  M + 1
1018
1014
  );
1019
- if (!isNaN(Number(J))) {
1020
- const b = V.lastIndexOf(".");
1021
- if (b !== -1) {
1022
- const N = V.substring(
1015
+ if (!isNaN(Number(q))) {
1016
+ const V = P.lastIndexOf(".");
1017
+ if (V !== -1) {
1018
+ const k = P.substring(
1023
1019
  0,
1024
- b
1020
+ V
1025
1021
  );
1026
- if (w.paths.has(N)) {
1022
+ if (w.paths.has(k)) {
1027
1023
  T = !0;
1028
1024
  break;
1029
1025
  }
1030
1026
  }
1031
1027
  }
1032
- M = V.lastIndexOf(".");
1028
+ M = P.lastIndexOf(".");
1033
1029
  }
1034
1030
  if (T) break;
1035
1031
  }
1036
- if (!T && P.includes("deps") && w.depsFunction) {
1037
- const x = w.depsFunction(s);
1032
+ if (!T && _.includes("deps") && w.depsFunction) {
1033
+ const C = w.depsFunction(s);
1038
1034
  let M = !1;
1039
- typeof x == "boolean" ? x && (M = !0) : z(w.deps, x) || (w.deps = x, M = !0), M && (T = !0);
1035
+ typeof C == "boolean" ? C && (M = !0) : H(w.deps, C) || (w.deps = C, M = !0), M && (T = !0);
1040
1036
  }
1041
1037
  T && w.forceUpdate();
1042
1038
  }
@@ -1050,16 +1046,16 @@ function gt(t, c, m, f) {
1050
1046
  throw new Error("Zod schema not found");
1051
1047
  if (!d?.key)
1052
1048
  throw new Error("Validation key not found");
1053
- Y(d.key);
1049
+ J(d.key);
1054
1050
  const r = o.getState().cogsStateStore[t];
1055
1051
  try {
1056
1052
  const s = o.getState().getValidationErrors(d.key);
1057
- s && s.length > 0 && s.forEach(([g]) => {
1058
- g && g.startsWith(d.key) && Y(g);
1053
+ s && s.length > 0 && s.forEach(([u]) => {
1054
+ u && u.startsWith(d.key) && J(u);
1059
1055
  });
1060
1056
  const i = d.zodSchema.safeParse(r);
1061
- return i.success ? !0 : (i.error.errors.forEach((u) => {
1062
- const A = u.path, w = u.message, T = [d.key, ...A].join(".");
1057
+ return i.success ? !0 : (i.error.errors.forEach((g) => {
1058
+ const A = g.path, w = g.message, T = [d.key, ...A].join(".");
1063
1059
  e(T, w);
1064
1060
  }), St(t), !1);
1065
1061
  } catch (s) {
@@ -1089,7 +1085,7 @@ function gt(t, c, m, f) {
1089
1085
  children: d,
1090
1086
  hideMessage: e
1091
1087
  }) => /* @__PURE__ */ yt(
1092
- Ft,
1088
+ Rt,
1093
1089
  {
1094
1090
  formOpts: e ? { validation: { message: "" } } : void 0,
1095
1091
  path: n,
@@ -1105,7 +1101,7 @@ function gt(t, c, m, f) {
1105
1101
  if (l === "update")
1106
1102
  return (d, e) => {
1107
1103
  if (e?.debounce)
1108
- Rt(() => {
1104
+ Ft(() => {
1109
1105
  ot(c, d, n, "");
1110
1106
  const r = o.getState().getNestedState(t, n);
1111
1107
  e?.afterUpdate && e.afterUpdate(r);
@@ -1131,17 +1127,17 @@ function gt(t, c, m, f) {
1131
1127
  const j = [...n, l], rt = o.getState().getNestedState(t, j);
1132
1128
  return a(rt, j, S);
1133
1129
  }
1134
- }, L = new Proxy(F, U);
1135
- return y.set(G, {
1136
- proxy: L,
1137
- stateVersion: k
1138
- }), L;
1130
+ }, G = new Proxy(R, U);
1131
+ return y.set(W, {
1132
+ proxy: G,
1133
+ stateVersion: b
1134
+ }), G;
1139
1135
  }
1140
1136
  return a(
1141
1137
  o.getState().getNestedState(t, [])
1142
1138
  );
1143
1139
  }
1144
- function bt(t) {
1140
+ function Nt(t) {
1145
1141
  return st(Xt, { proxy: t });
1146
1142
  }
1147
1143
  function Zt({
@@ -1153,13 +1149,13 @@ function Zt({
1153
1149
  m,
1154
1150
  t._path
1155
1151
  ).stateMapNoRender(
1156
- (y, k, p, I, a) => t._mapFn(y, k, p, I, a)
1152
+ (y, b, p, I, a) => t._mapFn(y, b, p, I, a)
1157
1153
  ) : null;
1158
1154
  }
1159
1155
  function Xt({
1160
1156
  proxy: t
1161
1157
  }) {
1162
- const c = q(null), m = `${t._stateKey}-${t._path.join(".")}`;
1158
+ const c = B(null), m = `${t._stateKey}-${t._path.join(".")}`;
1163
1159
  return at(() => {
1164
1160
  const f = c.current;
1165
1161
  if (!f || !f.parentElement) return;
@@ -1181,14 +1177,14 @@ function Xt({
1181
1177
  "state",
1182
1178
  `return (${t._effect})(state)`
1183
1179
  )(n);
1184
- } catch (F) {
1185
- console.error("Error evaluating effect function during mount:", F), S = n;
1180
+ } catch (R) {
1181
+ console.error("Error evaluating effect function during mount:", R), S = n;
1186
1182
  }
1187
1183
  else
1188
1184
  S = n;
1189
1185
  S !== null && typeof S == "object" && (S = JSON.stringify(S));
1190
- const G = document.createTextNode(String(S));
1191
- f.replaceWith(G);
1186
+ const W = document.createTextNode(String(S));
1187
+ f.replaceWith(W);
1192
1188
  }, [t._stateKey, t._path.join("."), t._effect]), st("span", {
1193
1189
  ref: c,
1194
1190
  style: { display: "none" },
@@ -1216,7 +1212,7 @@ function Qt({
1216
1212
  itemPath: m,
1217
1213
  children: f
1218
1214
  }) {
1219
- const [, y] = nt({}), [k, p] = Gt(), I = q(null);
1215
+ const [, y] = tt({}), [b, p] = Gt(), I = B(null);
1220
1216
  return at(() => {
1221
1217
  p.height > 0 && p.height !== I.current && (I.current = p.height, o.getState().setShadowMetadata(t, m, {
1222
1218
  virtualizer: {
@@ -1234,10 +1230,10 @@ function Qt({
1234
1230
  const n = o.getState().stateComponents.get(t);
1235
1231
  n && n.components.delete(a);
1236
1232
  };
1237
- }, [t, c, m.join(".")]), /* @__PURE__ */ yt("div", { ref: k, children: f });
1233
+ }, [t, c, m.join(".")]), /* @__PURE__ */ yt("div", { ref: b, children: f });
1238
1234
  }
1239
1235
  export {
1240
- bt as $cogsSignal,
1236
+ Nt as $cogsSignal,
1241
1237
  fe as $cogsSignalStore,
1242
1238
  de as addStateOptions,
1243
1239
  ue as createCogsState,