cogsbox-state 0.5.332 → 0.5.333

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,63 +1,63 @@
1
1
  "use client";
2
2
  import { jsx as mt } from "react/jsx-runtime";
3
- import { useState as X, useRef as Q, useEffect as nt, useLayoutEffect as ct, useMemo as ht, createElement as at, useSyncExternalStore as xt, startTransition as Pt, useCallback as wt } from "react";
4
- import { transformStateFunc as _t, isDeepEqual as H, isFunction as J, getNestedValue as z, getDifferences as vt, debounce as Mt } from "./utility.js";
5
- import { pushFunc as St, updateFn as ot, cutFunc as it, ValidationWrapper as jt, FormControlComponent as Ot } from "./Functions.jsx";
6
- import Rt from "superjson";
3
+ import { useState as Q, useRef as Z, useEffect as ot, useLayoutEffect as ct, useMemo as ht, createElement as at, useSyncExternalStore as xt, startTransition as Pt, useCallback as wt } from "react";
4
+ import { transformStateFunc as _t, isDeepEqual as H, isFunction as Y, getNestedValue as z, getDifferences as vt, debounce as Mt } from "./utility.js";
5
+ import { pushFunc as St, updateFn as rt, cutFunc as it, ValidationWrapper as jt, FormControlComponent as Rt } from "./Functions.jsx";
6
+ import Ot from "superjson";
7
7
  import { v4 as yt } from "uuid";
8
8
  import "zod";
9
9
  import { getGlobalStore as o, formRefStore as Tt } from "./store.js";
10
10
  import { useCogsConfig as bt } from "./CogsStateClient.jsx";
11
11
  import { applyPatch as Ut } from "fast-json-patch";
12
12
  import Ft from "react-use-measure";
13
- function Et(t, c) {
14
- const h = o.getState().getInitialOptions, S = o.getState().setInitialStateOptions, I = h(t) || {};
15
- S(t, {
16
- ...I,
17
- ...c
13
+ function Et(t, i) {
14
+ const m = o.getState().getInitialOptions, f = o.getState().setInitialStateOptions, y = m(t) || {};
15
+ f(t, {
16
+ ...y,
17
+ ...i
18
18
  });
19
19
  }
20
20
  function At({
21
21
  stateKey: t,
22
- options: c,
23
- initialOptionsPart: h
22
+ options: i,
23
+ initialOptionsPart: m
24
24
  }) {
25
- const S = et(t) || {}, I = h[t] || {}, b = o.getState().setInitialStateOptions, T = { ...I, ...S };
26
- let p = !1;
27
- if (c)
28
- for (const a in c)
29
- T.hasOwnProperty(a) ? (a == "localStorage" && c[a] && T[a].key !== c[a]?.key && (p = !0, T[a] = c[a]), a == "initialState" && c[a] && T[a] !== c[a] && // Different references
30
- !H(T[a], c[a]) && (p = !0, T[a] = c[a])) : (p = !0, T[a] = c[a]);
31
- p && b(t, T);
25
+ const f = et(t) || {}, y = m[t] || {}, b = o.getState().setInitialStateOptions, w = { ...y, ...f };
26
+ let I = !1;
27
+ if (i)
28
+ for (const a in i)
29
+ w.hasOwnProperty(a) ? (a == "localStorage" && i[a] && w[a].key !== i[a]?.key && (I = !0, w[a] = i[a]), a == "initialState" && i[a] && w[a] !== i[a] && // Different references
30
+ !H(w[a], i[a]) && (I = !0, w[a] = i[a])) : (I = !0, w[a] = i[a]);
31
+ I && b(t, w);
32
32
  }
33
- function ie(t, { formElements: c, validation: h }) {
34
- return { initialState: t, formElements: c, validation: h };
33
+ function ie(t, { formElements: i, validation: m }) {
34
+ return { initialState: t, formElements: i, validation: m };
35
35
  }
36
- const ce = (t, c) => {
37
- let h = t;
38
- const [S, I] = _t(h);
39
- (Object.keys(I).length > 0 || c && Object.keys(c).length > 0) && Object.keys(I).forEach((p) => {
40
- I[p] = I[p] || {}, I[p].formElements = {
41
- ...c?.formElements,
36
+ const ce = (t, i) => {
37
+ let m = t;
38
+ const [f, y] = _t(m);
39
+ (Object.keys(y).length > 0 || i && Object.keys(i).length > 0) && Object.keys(y).forEach((I) => {
40
+ y[I] = y[I] || {}, y[I].formElements = {
41
+ ...i?.formElements,
42
42
  // Global defaults first
43
- ...c?.validation,
44
- ...I[p].formElements || {}
43
+ ...i?.validation,
44
+ ...y[I].formElements || {}
45
45
  // State-specific overrides
46
- }, et(p) || o.getState().setInitialStateOptions(p, I[p]);
47
- }), o.getState().setInitialStates(S), o.getState().setCreatedState(S);
48
- const b = (p, a) => {
49
- const [y] = X(a?.componentId ?? yt());
46
+ }, et(I) || o.getState().setInitialStateOptions(I, y[I]);
47
+ }), o.getState().setInitialStates(f), o.getState().setCreatedState(f);
48
+ const b = (I, a) => {
49
+ const [v] = Q(a?.componentId ?? yt());
50
50
  At({
51
- stateKey: p,
51
+ stateKey: I,
52
52
  options: a,
53
- initialOptionsPart: I
53
+ initialOptionsPart: y
54
54
  });
55
- const n = o.getState().cogsStateStore[p] || S[p], m = a?.modifyState ? a.modifyState(n) : n, [L, R] = Bt(
56
- m,
55
+ const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [W, U] = Bt(
56
+ S,
57
57
  {
58
- stateKey: p,
58
+ stateKey: I,
59
59
  syncUpdate: a?.syncUpdate,
60
- componentId: y,
60
+ componentId: v,
61
61
  localStorage: a?.localStorage,
62
62
  middleware: a?.middleware,
63
63
  enabledSync: a?.enabledSync,
@@ -68,111 +68,111 @@ const ce = (t, c) => {
68
68
  serverState: a?.serverState
69
69
  }
70
70
  );
71
- return R;
71
+ return U;
72
72
  };
73
- function T(p, a) {
74
- At({ stateKey: p, options: a, initialOptionsPart: I }), a.localStorage && Ht(p, a), gt(p);
73
+ function w(I, a) {
74
+ At({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage && Ht(I, a), gt(I);
75
75
  }
76
- return { useCogsState: b, setCogsOptions: T };
76
+ return { useCogsState: b, setCogsOptions: w };
77
77
  }, {
78
78
  setUpdaterState: lt,
79
79
  setState: K,
80
80
  getInitialOptions: et,
81
81
  getKeyState: Nt,
82
82
  getValidationErrors: Dt,
83
- setStateLog: Wt,
83
+ setStateLog: Lt,
84
84
  updateInitialStateGlobal: It,
85
- addValidationError: Lt,
86
- removeValidationError: q,
85
+ addValidationError: Wt,
86
+ removeValidationError: J,
87
87
  setServerSyncActions: Gt
88
- } = o.getState(), $t = (t, c, h, S, I) => {
89
- h?.log && console.log(
88
+ } = o.getState(), $t = (t, i, m, f, y) => {
89
+ m?.log && console.log(
90
90
  "saving to localstorage",
91
- c,
92
- h.localStorage?.key,
93
- S
91
+ i,
92
+ m.localStorage?.key,
93
+ f
94
94
  );
95
- const b = J(h?.localStorage?.key) ? h.localStorage?.key(t) : h?.localStorage?.key;
96
- if (b && S) {
97
- const T = `${S}-${c}-${b}`;
98
- let p;
95
+ const b = Y(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
96
+ if (b && f) {
97
+ const w = `${f}-${i}-${b}`;
98
+ let I;
99
99
  try {
100
- p = ut(T)?.lastSyncedWithServer;
100
+ I = ut(w)?.lastSyncedWithServer;
101
101
  } catch {
102
102
  }
103
103
  const a = {
104
104
  state: t,
105
105
  lastUpdated: Date.now(),
106
- lastSyncedWithServer: I ?? p
107
- }, y = Rt.serialize(a);
106
+ lastSyncedWithServer: y ?? I
107
+ }, v = Ot.serialize(a);
108
108
  window.localStorage.setItem(
109
- T,
110
- JSON.stringify(y.json)
109
+ w,
110
+ JSON.stringify(v.json)
111
111
  );
112
112
  }
113
113
  }, ut = (t) => {
114
114
  if (!t) return null;
115
115
  try {
116
- const c = window.localStorage.getItem(t);
117
- return c ? JSON.parse(c) : null;
118
- } catch (c) {
119
- return console.error("Error loading from localStorage:", c), null;
116
+ const i = window.localStorage.getItem(t);
117
+ return i ? JSON.parse(i) : null;
118
+ } catch (i) {
119
+ return console.error("Error loading from localStorage:", i), null;
120
120
  }
121
- }, Ht = (t, c) => {
122
- const h = o.getState().cogsStateStore[t], { sessionId: S } = bt(), I = J(c?.localStorage?.key) ? c.localStorage.key(h) : c?.localStorage?.key;
123
- if (I && S) {
121
+ }, Ht = (t, i) => {
122
+ const m = o.getState().cogsStateStore[t], { sessionId: f } = bt(), y = Y(i?.localStorage?.key) ? i.localStorage.key(m) : i?.localStorage?.key;
123
+ if (y && f) {
124
124
  const b = ut(
125
- `${S}-${t}-${I}`
125
+ `${f}-${t}-${y}`
126
126
  );
127
127
  if (b && b.lastUpdated > (b.lastSyncedWithServer || 0))
128
128
  return K(t, b.state), gt(t), !0;
129
129
  }
130
130
  return !1;
131
- }, Vt = (t, c, h, S, I, b) => {
132
- const T = {
133
- initialState: c,
131
+ }, Vt = (t, i, m, f, y, b) => {
132
+ const w = {
133
+ initialState: i,
134
134
  updaterState: dt(
135
135
  t,
136
- S,
137
- I,
136
+ f,
137
+ y,
138
138
  b
139
139
  ),
140
- state: h
140
+ state: m
141
141
  };
142
- It(t, T.initialState), lt(t, T.updaterState), K(t, T.state);
142
+ It(t, w.initialState), lt(t, w.updaterState), K(t, w.state);
143
143
  }, gt = (t) => {
144
- const c = o.getState().stateComponents.get(t);
145
- if (!c) return;
146
- const h = /* @__PURE__ */ new Set();
147
- c.components.forEach((S) => {
148
- (S ? Array.isArray(S.reactiveType) ? S.reactiveType : [S.reactiveType || "component"] : null)?.includes("none") || h.add(() => S.forceUpdate());
144
+ const i = o.getState().stateComponents.get(t);
145
+ if (!i) return;
146
+ const m = /* @__PURE__ */ new Set();
147
+ i.components.forEach((f) => {
148
+ (f ? Array.isArray(f.reactiveType) ? f.reactiveType : [f.reactiveType || "component"] : null)?.includes("none") || m.add(() => f.forceUpdate());
149
149
  }), queueMicrotask(() => {
150
- h.forEach((S) => S());
150
+ m.forEach((f) => f());
151
151
  });
152
- }, le = (t, c) => {
153
- const h = o.getState().stateComponents.get(t);
154
- if (h) {
155
- const S = `${t}////${c}`, I = h.components.get(S);
156
- if ((I ? Array.isArray(I.reactiveType) ? I.reactiveType : [I.reactiveType || "component"] : null)?.includes("none"))
152
+ }, le = (t, i) => {
153
+ const m = o.getState().stateComponents.get(t);
154
+ if (m) {
155
+ const f = `${t}////${i}`, y = m.components.get(f);
156
+ if ((y ? Array.isArray(y.reactiveType) ? y.reactiveType : [y.reactiveType || "component"] : null)?.includes("none"))
157
157
  return;
158
- I && I.forceUpdate();
158
+ y && y.forceUpdate();
159
159
  }
160
- }, zt = (t, c, h, S) => {
160
+ }, zt = (t, i, m, f) => {
161
161
  switch (t) {
162
162
  case "update":
163
163
  return {
164
- oldValue: z(c, S),
165
- newValue: z(h, S)
164
+ oldValue: z(i, 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: z(h, S)
171
+ newValue: z(m, f)
172
172
  };
173
173
  case "cut":
174
174
  return {
175
- oldValue: z(c, S),
175
+ oldValue: z(i, f),
176
176
  newValue: null
177
177
  // or undefined
178
178
  };
@@ -181,234 +181,234 @@ const ce = (t, c) => {
181
181
  }
182
182
  };
183
183
  function Bt(t, {
184
- stateKey: c,
185
- serverSync: h,
186
- localStorage: S,
187
- formElements: I,
184
+ stateKey: i,
185
+ serverSync: m,
186
+ localStorage: f,
187
+ formElements: y,
188
188
  reactiveDeps: b,
189
- reactiveType: T,
190
- componentId: p,
189
+ reactiveType: w,
190
+ componentId: I,
191
191
  initialState: a,
192
- syncUpdate: y,
192
+ syncUpdate: v,
193
193
  dependencies: n,
194
- serverState: m
194
+ serverState: S
195
195
  } = {}) {
196
- const [L, R] = X({}), { sessionId: U } = bt();
197
- let G = !c;
198
- const [v] = X(c ?? yt()), l = o.getState().stateLog[v], st = Q(/* @__PURE__ */ new Set()), Y = Q(p ?? yt()), j = Q(
196
+ const [W, U] = Q({}), { sessionId: F } = bt();
197
+ let G = !i;
198
+ const [h] = Q(i ?? yt()), l = o.getState().stateLog[h], st = Z(/* @__PURE__ */ new Set()), X = Z(I ?? yt()), R = Z(
199
199
  null
200
200
  );
201
- j.current = et(v) ?? null, nt(() => {
202
- if (y && y.stateKey === v && y.path?.[0]) {
203
- K(v, (r) => ({
201
+ R.current = et(h) ?? null, ot(() => {
202
+ if (v && v.stateKey === h && v.path?.[0]) {
203
+ K(h, (r) => ({
204
204
  ...r,
205
- [y.path[0]]: y.newValue
205
+ [v.path[0]]: v.newValue
206
206
  }));
207
- const e = `${y.stateKey}:${y.path.join(".")}`;
207
+ const e = `${v.stateKey}:${v.path.join(".")}`;
208
208
  o.getState().setSyncInfo(e, {
209
- timeStamp: y.timeStamp,
210
- userId: y.userId
209
+ timeStamp: v.timeStamp,
210
+ userId: v.userId
211
211
  });
212
212
  }
213
- }, [y]), nt(() => {
213
+ }, [v]), ot(() => {
214
214
  if (a) {
215
- Et(v, {
215
+ Et(h, {
216
216
  initialState: a
217
217
  });
218
- const e = j.current, s = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, i = o.getState().initialStateGlobal[v];
219
- if (!(i && !H(i, a) || !i) && !s)
218
+ const e = R.current, s = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, c = o.getState().initialStateGlobal[h];
219
+ if (!(c && !H(c, a) || !c) && !s)
220
220
  return;
221
- let g = null;
222
- const E = J(e?.localStorage?.key) ? e?.localStorage?.key(a) : e?.localStorage?.key;
223
- E && U && (g = ut(`${U}-${v}-${E}`));
224
- let w = a, A = !1;
225
- const P = s ? Date.now() : 0, V = g?.lastUpdated || 0, k = g?.lastSyncedWithServer || 0;
226
- s && P > V ? (w = e.serverState.data, A = !0) : g && V > k && (w = g.state, e?.localStorage?.onChange && e?.localStorage?.onChange(w)), o.getState().initializeShadowState(v, a), Vt(
227
- v,
221
+ let u = null;
222
+ const E = Y(e?.localStorage?.key) ? e?.localStorage?.key(a) : e?.localStorage?.key;
223
+ E && F && (u = ut(`${F}-${h}-${E}`));
224
+ let p = a, $ = !1;
225
+ const _ = s ? Date.now() : 0, C = u?.lastUpdated || 0, M = u?.lastSyncedWithServer || 0;
226
+ s && _ > C ? (p = e.serverState.data, $ = !0) : u && C > M && (p = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(p)), o.getState().initializeShadowState(h, a), Vt(
227
+ h,
228
228
  a,
229
- w,
230
- rt,
231
- Y.current,
232
- U
233
- ), A && E && U && $t(w, v, e, U, Date.now()), gt(v), (Array.isArray(T) ? T : [T || "component"]).includes("none") || R({});
229
+ p,
230
+ nt,
231
+ X.current,
232
+ F
233
+ ), $ && E && F && $t(p, h, e, F, Date.now()), gt(h), (Array.isArray(w) ? w : [w || "component"]).includes("none") || U({});
234
234
  }
235
235
  }, [
236
236
  a,
237
- m?.status,
238
- m?.data,
237
+ S?.status,
238
+ S?.data,
239
239
  ...n || []
240
240
  ]), ct(() => {
241
- G && Et(v, {
242
- serverSync: h,
243
- formElements: I,
241
+ G && Et(h, {
242
+ serverSync: m,
243
+ formElements: y,
244
244
  initialState: a,
245
- localStorage: S,
246
- middleware: j.current?.middleware
245
+ localStorage: f,
246
+ middleware: R.current?.middleware
247
247
  });
248
- const e = `${v}////${Y.current}`, r = o.getState().stateComponents.get(v) || {
248
+ const e = `${h}////${X.current}`, r = o.getState().stateComponents.get(h) || {
249
249
  components: /* @__PURE__ */ new Map()
250
250
  };
251
251
  return r.components.set(e, {
252
- forceUpdate: () => R({}),
252
+ forceUpdate: () => U({}),
253
253
  paths: /* @__PURE__ */ new Set(),
254
254
  deps: [],
255
255
  depsFunction: b || void 0,
256
- reactiveType: T ?? ["component", "deps"]
257
- }), o.getState().stateComponents.set(v, r), R({}), () => {
258
- r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(v));
256
+ reactiveType: w ?? ["component", "deps"]
257
+ }), o.getState().stateComponents.set(h, r), U({}), () => {
258
+ r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(h));
259
259
  };
260
260
  }, []);
261
- const rt = (e, r, s, i) => {
261
+ const nt = (e, r, s, c) => {
262
262
  if (Array.isArray(r)) {
263
- const g = `${v}-${r.join(".")}`;
264
- st.current.add(g);
263
+ const u = `${h}-${r.join(".")}`;
264
+ st.current.add(u);
265
265
  }
266
- const u = o.getState();
267
- K(v, (g) => {
268
- const E = J(e) ? e(g) : e, w = `${v}-${r.join(".")}`;
269
- if (w) {
270
- let M = !1, N = u.signalDomElements.get(w);
266
+ const g = o.getState();
267
+ K(h, (u) => {
268
+ const E = Y(e) ? e(u) : e, p = `${h}-${r.join(".")}`;
269
+ if (p) {
270
+ let P = !1, N = g.signalDomElements.get(p);
271
271
  if ((!N || N.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
272
- const O = r.slice(0, -1), W = z(E, O);
273
- if (Array.isArray(W)) {
274
- M = !0;
275
- const f = `${v}-${O.join(".")}`;
276
- N = u.signalDomElements.get(f);
272
+ const O = r.slice(0, -1), D = z(E, O);
273
+ if (Array.isArray(D)) {
274
+ P = !0;
275
+ const A = `${h}-${O.join(".")}`;
276
+ N = g.signalDomElements.get(A);
277
277
  }
278
278
  }
279
279
  if (N) {
280
- const O = M ? z(E, r.slice(0, -1)) : z(E, r);
281
- N.forEach(({ parentId: W, position: f, effect: $ }) => {
282
- const C = document.querySelector(
283
- `[data-parent-id="${W}"]`
280
+ const O = P ? z(E, r.slice(0, -1)) : z(E, r);
281
+ N.forEach(({ parentId: D, position: A, effect: T }) => {
282
+ const k = document.querySelector(
283
+ `[data-parent-id="${D}"]`
284
284
  );
285
- if (C) {
286
- const _ = Array.from(C.childNodes);
287
- if (_[f]) {
288
- const x = $ ? new Function("state", `return (${$})(state)`)(O) : O;
289
- _[f].textContent = String(x);
285
+ if (k) {
286
+ const j = Array.from(k.childNodes);
287
+ if (j[A]) {
288
+ const V = T ? new Function("state", `return (${T})(state)`)(O) : O;
289
+ j[A].textContent = String(V);
290
290
  }
291
291
  }
292
292
  });
293
293
  }
294
294
  }
295
- console.log("shadowState", u.shadowStateStore), s.updateType === "update" && (i || j.current?.validation?.key) && r && q(
296
- (i || j.current?.validation?.key) + "." + r.join(".")
295
+ console.log("shadowState", g.shadowStateStore), s.updateType === "update" && (c || R.current?.validation?.key) && r && J(
296
+ (c || R.current?.validation?.key) + "." + r.join(".")
297
297
  );
298
- const A = r.slice(0, r.length - 1);
299
- s.updateType === "cut" && j.current?.validation?.key && q(
300
- j.current?.validation?.key + "." + A.join(".")
301
- ), s.updateType === "insert" && j.current?.validation?.key && Dt(
302
- j.current?.validation?.key + "." + A.join(".")
298
+ const $ = r.slice(0, r.length - 1);
299
+ s.updateType === "cut" && R.current?.validation?.key && J(
300
+ R.current?.validation?.key + "." + $.join(".")
301
+ ), s.updateType === "insert" && R.current?.validation?.key && Dt(
302
+ R.current?.validation?.key + "." + $.join(".")
303
303
  ).filter(([N, O]) => {
304
- let W = N?.split(".").length;
305
- if (N == A.join(".") && W == A.length - 1) {
306
- let f = N + "." + A;
307
- q(N), Lt(f, O);
304
+ let D = N?.split(".").length;
305
+ if (N == $.join(".") && D == $.length - 1) {
306
+ let A = N + "." + $;
307
+ J(N), Wt(A, O);
308
308
  }
309
309
  });
310
- const P = u.stateComponents.get(v);
311
- if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", P), P) {
312
- const M = vt(g, E), N = new Set(M), O = s.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
310
+ const _ = g.stateComponents.get(h);
311
+ if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", _), _) {
312
+ const P = vt(u, E), N = new Set(P), O = s.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
313
313
  for (const [
314
- W,
315
- f
316
- ] of P.components.entries()) {
317
- let $ = !1;
318
- const C = Array.isArray(f.reactiveType) ? f.reactiveType : [f.reactiveType || "component"];
319
- if (console.log("component", f), !C.includes("none")) {
320
- if (C.includes("all")) {
321
- f.forceUpdate();
314
+ D,
315
+ A
316
+ ] of _.components.entries()) {
317
+ let T = !1;
318
+ const k = Array.isArray(A.reactiveType) ? A.reactiveType : [A.reactiveType || "component"];
319
+ if (console.log("component", A), !k.includes("none")) {
320
+ if (k.includes("all")) {
321
+ A.forceUpdate();
322
322
  continue;
323
323
  }
324
- if (C.includes("component") && ((f.paths.has(O) || f.paths.has("")) && ($ = !0), !$))
325
- for (const _ of N) {
326
- let x = _;
324
+ if (k.includes("component") && ((A.paths.has(O) || A.paths.has("")) && (T = !0), !T))
325
+ for (const j of N) {
326
+ let V = j;
327
327
  for (; ; ) {
328
- if (f.paths.has(x)) {
329
- $ = !0;
328
+ if (A.paths.has(V)) {
329
+ T = !0;
330
330
  break;
331
331
  }
332
- const B = x.lastIndexOf(".");
333
- if (B !== -1) {
334
- const Z = x.substring(
332
+ const L = V.lastIndexOf(".");
333
+ if (L !== -1) {
334
+ const q = V.substring(
335
335
  0,
336
- B
336
+ L
337
337
  );
338
338
  if (!isNaN(
339
- Number(x.substring(B + 1))
340
- ) && f.paths.has(Z)) {
341
- $ = !0;
339
+ Number(V.substring(L + 1))
340
+ ) && A.paths.has(q)) {
341
+ T = !0;
342
342
  break;
343
343
  }
344
- x = Z;
344
+ V = q;
345
345
  } else
346
- x = "";
347
- if (x === "")
346
+ V = "";
347
+ if (V === "")
348
348
  break;
349
349
  }
350
- if ($) break;
350
+ if (T) break;
351
351
  }
352
- if (!$ && C.includes("deps") && f.depsFunction) {
353
- const _ = f.depsFunction(E);
354
- let x = !1;
355
- typeof _ == "boolean" ? _ && (x = !0) : H(f.deps, _) || (f.deps = _, x = !0), x && ($ = !0);
352
+ if (!T && k.includes("deps") && A.depsFunction) {
353
+ const j = A.depsFunction(E);
354
+ let V = !1;
355
+ typeof j == "boolean" ? j && (V = !0) : H(A.deps, j) || (A.deps = j, V = !0), V && (T = !0);
356
356
  }
357
- $ && f.forceUpdate();
357
+ T && A.forceUpdate();
358
358
  }
359
359
  }
360
360
  }
361
- const V = Date.now();
362
- r = r.map((M, N) => {
363
- const O = r.slice(0, -1), W = z(E, O);
364
- return N === r.length - 1 && ["insert", "cut"].includes(s.updateType) ? (W.length - 1).toString() : M;
361
+ const C = Date.now();
362
+ r = r.map((P, N) => {
363
+ const O = r.slice(0, -1), D = z(E, O);
364
+ return N === r.length - 1 && ["insert", "cut"].includes(s.updateType) ? (D.length - 1).toString() : P;
365
365
  });
366
- const { oldValue: k, newValue: F } = zt(
366
+ const { oldValue: M, newValue: x } = zt(
367
367
  s.updateType,
368
- g,
368
+ u,
369
369
  E,
370
370
  r
371
- ), D = {
372
- timeStamp: V,
373
- stateKey: v,
371
+ ), B = {
372
+ timeStamp: C,
373
+ stateKey: h,
374
374
  path: r,
375
375
  updateType: s.updateType,
376
376
  status: "new",
377
- oldValue: k,
378
- newValue: F
377
+ oldValue: M,
378
+ newValue: x
379
379
  };
380
380
  switch (s.updateType) {
381
381
  case "update":
382
- u.updateShadowAtPath(v, r, E);
382
+ g.updateShadowAtPath(h, r, E);
383
383
  break;
384
384
  case "insert":
385
- const M = r.slice(0, -1);
386
- u.insertShadowArrayElement(v, M, F);
385
+ const P = r.slice(0, -1);
386
+ g.insertShadowArrayElement(h, P, x);
387
387
  break;
388
388
  case "cut":
389
389
  const N = r.slice(0, -1), O = parseInt(r[r.length - 1]);
390
- u.removeShadowArrayElement(v, N, O);
390
+ g.removeShadowArrayElement(h, N, O);
391
391
  break;
392
392
  }
393
- if (Wt(v, (M) => {
394
- const O = [...M ?? [], D].reduce((W, f) => {
395
- const $ = `${f.stateKey}:${JSON.stringify(f.path)}`, C = W.get($);
396
- return C ? (C.timeStamp = Math.max(C.timeStamp, f.timeStamp), C.newValue = f.newValue, C.oldValue = C.oldValue ?? f.oldValue, C.updateType = f.updateType) : W.set($, { ...f }), W;
393
+ if (Lt(h, (P) => {
394
+ const O = [...P ?? [], B].reduce((D, A) => {
395
+ const T = `${A.stateKey}:${JSON.stringify(A.path)}`, k = D.get(T);
396
+ return k ? (k.timeStamp = Math.max(k.timeStamp, A.timeStamp), k.newValue = A.newValue, k.oldValue = k.oldValue ?? A.oldValue, k.updateType = A.updateType) : D.set(T, { ...A }), D;
397
397
  }, /* @__PURE__ */ new Map());
398
398
  return Array.from(O.values());
399
399
  }), $t(
400
400
  E,
401
- v,
402
- j.current,
403
- U
404
- ), j.current?.middleware && j.current.middleware({
401
+ h,
402
+ R.current,
403
+ F
404
+ ), R.current?.middleware && R.current.middleware({
405
405
  updateLog: l,
406
- update: D
407
- }), j.current?.serverSync) {
408
- const M = u.serverState[v], N = j.current?.serverSync;
409
- Gt(v, {
406
+ update: B
407
+ }), R.current?.serverSync) {
408
+ const P = g.serverState[h], N = R.current?.serverSync;
409
+ Gt(h, {
410
410
  syncKey: typeof N.syncKey == "string" ? N.syncKey : N.syncKey({ state: E }),
411
- rollBackState: M,
411
+ rollBackState: P,
412
412
  actionTimeStamp: Date.now() + (N.debounce ?? 3e3),
413
413
  status: "waiting"
414
414
  });
@@ -416,60 +416,60 @@ function Bt(t, {
416
416
  return E;
417
417
  });
418
418
  };
419
- o.getState().updaterState[v] || (lt(
420
- v,
419
+ o.getState().updaterState[h] || (lt(
420
+ h,
421
421
  dt(
422
- v,
423
- rt,
424
- Y.current,
425
- U
422
+ h,
423
+ nt,
424
+ X.current,
425
+ F
426
426
  )
427
- ), o.getState().cogsStateStore[v] || K(v, t), o.getState().initialStateGlobal[v] || It(v, t));
427
+ ), o.getState().cogsStateStore[h] || K(h, t), o.getState().initialStateGlobal[h] || It(h, t));
428
428
  const d = ht(() => dt(
429
- v,
430
- rt,
431
- Y.current,
432
- U
433
- ), [v, U]);
434
- return [Nt(v), d];
429
+ h,
430
+ nt,
431
+ X.current,
432
+ F
433
+ ), [h, F]);
434
+ return [Nt(h), d];
435
435
  }
436
- function dt(t, c, h, S) {
437
- const I = /* @__PURE__ */ new Map();
436
+ function dt(t, i, m, f) {
437
+ const y = /* @__PURE__ */ new Map();
438
438
  let b = 0;
439
- const T = (y) => {
440
- const n = y.join(".");
441
- for (const [m] of I)
442
- (m === n || m.startsWith(n + ".")) && I.delete(m);
439
+ const w = (v) => {
440
+ const n = v.join(".");
441
+ for (const [S] of y)
442
+ (S === n || S.startsWith(n + ".")) && y.delete(S);
443
443
  b++;
444
- }, p = {
445
- removeValidation: (y) => {
446
- y?.validationKey && q(y.validationKey);
444
+ }, I = {
445
+ removeValidation: (v) => {
446
+ v?.validationKey && J(v.validationKey);
447
447
  },
448
- revertToInitialState: (y) => {
448
+ revertToInitialState: (v) => {
449
449
  const n = o.getState().getInitialOptions(t)?.validation;
450
- n?.key && q(n?.key), y?.validationKey && q(y.validationKey);
451
- const m = o.getState().initialStateGlobal[t];
452
- o.getState().clearSelectedIndexesForState(t), I.clear(), b++;
453
- const L = a(m, []), R = et(t), U = J(R?.localStorage?.key) ? R?.localStorage?.key(m) : R?.localStorage?.key, G = `${S}-${t}-${U}`;
454
- G && localStorage.removeItem(G), lt(t, L), K(t, m);
455
- const v = o.getState().stateComponents.get(t);
456
- return v && v.components.forEach((l) => {
450
+ n?.key && J(n?.key), v?.validationKey && J(v.validationKey);
451
+ const S = o.getState().initialStateGlobal[t];
452
+ o.getState().clearSelectedIndexesForState(t), y.clear(), b++;
453
+ const W = a(S, []), U = et(t), F = Y(U?.localStorage?.key) ? U?.localStorage?.key(S) : U?.localStorage?.key, G = `${f}-${t}-${F}`;
454
+ G && localStorage.removeItem(G), lt(t, W), K(t, S);
455
+ const h = o.getState().stateComponents.get(t);
456
+ return h && h.components.forEach((l) => {
457
457
  l.forceUpdate();
458
- }), m;
458
+ }), S;
459
459
  },
460
- updateInitialState: (y) => {
461
- I.clear(), b++;
460
+ updateInitialState: (v) => {
461
+ y.clear(), b++;
462
462
  const n = dt(
463
463
  t,
464
- c,
465
- h,
466
- S
467
- ), m = o.getState().initialStateGlobal[t], L = et(t), R = J(L?.localStorage?.key) ? L?.localStorage?.key(m) : L?.localStorage?.key, U = `${S}-${t}-${R}`;
468
- return localStorage.getItem(U) && localStorage.removeItem(U), Pt(() => {
469
- It(t, y), o.getState().initializeShadowState(t, y), lt(t, n), K(t, y);
464
+ i,
465
+ m,
466
+ f
467
+ ), S = o.getState().initialStateGlobal[t], W = et(t), U = Y(W?.localStorage?.key) ? W?.localStorage?.key(S) : W?.localStorage?.key, F = `${f}-${t}-${U}`;
468
+ return localStorage.getItem(F) && localStorage.removeItem(F), Pt(() => {
469
+ It(t, v), o.getState().initializeShadowState(t, v), lt(t, n), K(t, v);
470
470
  const G = o.getState().stateComponents.get(t);
471
- G && G.components.forEach((v) => {
472
- v.forceUpdate();
471
+ G && G.components.forEach((h) => {
472
+ h.forceUpdate();
473
473
  });
474
474
  }), {
475
475
  fetchId: (G) => n.get()[G]
@@ -479,27 +479,27 @@ function dt(t, c, h, S) {
479
479
  _serverState: o.getState().serverState[t],
480
480
  _isLoading: o.getState().isLoadingGlobal[t],
481
481
  _isServerSynced: () => {
482
- const y = o.getState().serverState[t];
483
- return !!(y && H(y, Nt(t)));
482
+ const v = o.getState().serverState[t];
483
+ return !!(v && H(v, Nt(t)));
484
484
  }
485
485
  };
486
- function a(y, n = [], m) {
487
- const L = n.map(String).join(".");
488
- I.get(L);
489
- const R = function() {
486
+ function a(v, n = [], S) {
487
+ const W = n.map(String).join(".");
488
+ y.get(W);
489
+ const U = function() {
490
490
  return o().getNestedState(t, n);
491
491
  };
492
- Object.keys(p).forEach((v) => {
493
- R[v] = p[v];
492
+ Object.keys(I).forEach((h) => {
493
+ U[h] = I[h];
494
494
  });
495
- const U = {
496
- apply(v, l, st) {
495
+ const F = {
496
+ apply(h, l, st) {
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
- get(v, l) {
502
- m?.validIndices && !Array.isArray(y) && (m = { ...m, validIndices: void 0 });
501
+ get(h, l) {
502
+ S?.validIndices && !Array.isArray(v) && (S = { ...S, validIndices: void 0 });
503
503
  const st = /* @__PURE__ */ new Set([
504
504
  "insert",
505
505
  "cut",
@@ -524,18 +524,18 @@ function dt(t, c, h, S) {
524
524
  "getComponents"
525
525
  ]);
526
526
  if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !st.has(l)) {
527
- const d = `${t}////${h}`, e = o.getState().stateComponents.get(t);
527
+ const d = `${t}////${m}`, e = o.getState().stateComponents.get(t);
528
528
  if (e) {
529
529
  const r = e.components.get(d);
530
530
  if (r && !r.paths.has("")) {
531
531
  const s = n.join(".");
532
- let i = !0;
533
- for (const u of r.paths)
534
- if (s.startsWith(u) && (s === u || s[u.length] === ".")) {
535
- i = !1;
532
+ let c = !0;
533
+ for (const g of r.paths)
534
+ if (s.startsWith(g) && (s === g || s[g.length] === ".")) {
535
+ c = !1;
536
536
  break;
537
537
  }
538
- i && r.paths.add(s);
538
+ c && r.paths.add(s);
539
539
  }
540
540
  }
541
541
  }
@@ -551,20 +551,20 @@ function dt(t, c, h, S) {
551
551
  return console.error(`No mutation defined for state key "${t}"`), { success: !1, error: "No mutation defined" };
552
552
  const r = o.getState().getNestedState(t, []), s = d?.validation?.key;
553
553
  try {
554
- const i = await e.action(r);
555
- if (i && !i.success && i.errors && s) {
556
- o.getState().removeValidationError(s), i.errors.forEach((g) => {
557
- const E = [s, ...g.path].join(".");
558
- o.getState().addValidationError(E, g.message);
554
+ const c = await e.action(r);
555
+ if (c && !c.success && c.errors && s) {
556
+ o.getState().removeValidationError(s), c.errors.forEach((u) => {
557
+ const E = [s, ...u.path].join(".");
558
+ o.getState().addValidationError(E, u.message);
559
559
  });
560
- const u = o.getState().stateComponents.get(t);
561
- u && u.components.forEach((g) => {
562
- g.forceUpdate();
560
+ const g = o.getState().stateComponents.get(t);
561
+ g && g.components.forEach((u) => {
562
+ u.forceUpdate();
563
563
  });
564
564
  }
565
- return i?.success && e.onSuccess ? e.onSuccess(i.data) : !i?.success && e.onError && e.onError(i.error), i;
566
- } catch (i) {
567
- return e.onError && e.onError(i), { success: !1, error: i };
565
+ return c?.success && e.onSuccess ? e.onSuccess(c.data) : !c?.success && e.onError && e.onError(c.error), c;
566
+ } catch (c) {
567
+ return e.onError && e.onError(c), { success: !1, error: c };
568
568
  }
569
569
  };
570
570
  if (l === "_status") {
@@ -581,7 +581,7 @@ function dt(t, c, h, S) {
581
581
  };
582
582
  if (l === "removeStorage")
583
583
  return () => {
584
- const d = o.getState().initialStateGlobal[t], e = et(t), r = J(e?.localStorage?.key) ? e?.localStorage?.key(d) : e?.localStorage?.key, s = `${S}-${t}-${r}`;
584
+ const d = o.getState().initialStateGlobal[t], e = et(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")
@@ -591,10 +591,10 @@ function dt(t, c, h, S) {
591
591
  throw new Error("Validation key not found");
592
592
  return o.getState().getValidationErrors(d.key + "." + n.join("."));
593
593
  };
594
- if (Array.isArray(y)) {
595
- const d = () => m?.validIndices ? y.map((r, s) => ({
594
+ if (Array.isArray(v)) {
595
+ const d = () => S?.validIndices ? v.map((r, s) => ({
596
596
  item: r,
597
- originalIndex: m.validIndices[s]
597
+ originalIndex: S.validIndices[s]
598
598
  })) : o.getState().getNestedState(t, n).map((r, s) => ({
599
599
  item: r,
600
600
  originalIndex: s
@@ -604,9 +604,9 @@ function dt(t, c, h, S) {
604
604
  const e = o.getState().getSelectedIndex(t, n.join("."));
605
605
  if (e !== void 0)
606
606
  return a(
607
- y[e],
607
+ v[e],
608
608
  [...n, e.toString()],
609
- m
609
+ S
610
610
  );
611
611
  };
612
612
  if (l === "clearSelected")
@@ -620,178 +620,167 @@ function dt(t, c, h, S) {
620
620
  const {
621
621
  itemHeight: r = 50,
622
622
  overscan: s = 5,
623
- stickToBottom: i = !1
624
- } = e, u = Q(null), [g, E] = X({
623
+ stickToBottom: c = !1
624
+ } = e, g = Z(null), [u, E] = Q({
625
625
  startIndex: 0,
626
626
  endIndex: 10
627
- }), w = Q(i), [A, P] = X(0);
628
- nt(() => o.getState().subscribeToShadowState(t, () => {
629
- P(($) => $ + 1);
627
+ }), p = Z(!1), [$, _] = Q(0), C = Z(0);
628
+ ot(() => o.getState().subscribeToShadowState(t, () => {
629
+ _((k) => k + 1);
630
630
  }), [t]);
631
- const V = o().getNestedState(
631
+ const M = o().getNestedState(
632
632
  t,
633
633
  n
634
- ), k = V.length, { totalHeight: F, positions: D } = ht(() => {
635
- const f = o.getState().getShadowMetadata(t, n) || [];
636
- let $ = 0;
637
- const C = [];
638
- for (let _ = 0; _ < k; _++) {
639
- C[_] = $;
640
- const x = f[_]?.virtualizer?.itemHeight;
641
- $ += x || r;
634
+ ), x = M.length, { totalHeight: B, positions: P } = ht(() => {
635
+ const T = o.getState().getShadowMetadata(t, n) || [];
636
+ let k = 0;
637
+ const j = [];
638
+ for (let V = 0; V < x; V++) {
639
+ j[V] = k;
640
+ const L = T[V]?.virtualizer?.itemHeight;
641
+ k += L || r;
642
642
  }
643
- return { totalHeight: $, positions: C };
643
+ return { totalHeight: k, positions: j };
644
644
  }, [
645
- k,
645
+ x,
646
646
  t,
647
647
  n.join("."),
648
648
  r,
649
- A
650
- ]), M = ht(() => {
651
- const f = Math.max(0, g.startIndex), $ = Math.min(k, g.endIndex), C = Array.from(
652
- { length: $ - f },
653
- (x, B) => f + B
654
- ), _ = C.map((x) => V[x]);
655
- return a(_, n, {
656
- ...m,
657
- validIndices: C
649
+ $
650
+ ]), N = ht(() => {
651
+ const T = Math.max(0, u.startIndex), k = Math.min(x, u.endIndex), j = Array.from(
652
+ { length: k - T },
653
+ (L, q) => T + q
654
+ ), V = j.map((L) => M[L]);
655
+ return a(V, n, {
656
+ ...S,
657
+ validIndices: j
658
658
  });
659
- }, [g.startIndex, g.endIndex, V, k]);
660
- nt(() => {
661
- if (i && k > 0 && u.current) {
662
- const f = u.current, $ = Math.ceil(
663
- f.clientHeight / r
664
- );
665
- E({
666
- startIndex: Math.max(
667
- 0,
668
- k - $ - s
669
- ),
670
- endIndex: k
671
- }), setTimeout(() => {
672
- f.scrollTop = f.scrollHeight;
673
- }, 100);
674
- }
675
- }, [k]), ct(() => {
676
- const f = u.current;
677
- if (!f) return;
678
- let $;
679
- const C = () => {
680
- if (!f) return;
681
- const { scrollTop: x } = f;
682
- let B = 0, Z = k - 1;
683
- for (; B <= Z; ) {
684
- const ft = Math.floor((B + Z) / 2);
685
- D[ft] < x ? B = ft + 1 : Z = ft - 1;
659
+ }, [u.startIndex, u.endIndex, M, x]);
660
+ ct(() => {
661
+ const T = g.current;
662
+ if (!T) return;
663
+ const k = () => {
664
+ if (!T) return;
665
+ const { scrollTop: V } = T;
666
+ let L = 0, q = x - 1;
667
+ for (; L <= q; ) {
668
+ const ft = Math.floor((L + q) / 2);
669
+ P[ft] < V ? L = ft + 1 : q = ft - 1;
686
670
  }
687
- const pt = Math.max(0, Z - s);
671
+ const pt = Math.max(0, q - s);
688
672
  let tt = pt;
689
- const Ct = x + f.clientHeight;
690
- for (; tt < k && D[tt] < Ct; )
673
+ const Ct = V + T.clientHeight;
674
+ for (; tt < x && P[tt] < Ct; )
691
675
  tt++;
692
- tt = Math.min(k, tt + s), E({ startIndex: pt, endIndex: tt });
693
- }, _ = () => {
694
- w.current = f.scrollHeight - f.scrollTop - f.clientHeight < 1, C();
676
+ tt = Math.min(x, tt + s), E({ startIndex: pt, endIndex: tt });
677
+ }, j = () => {
678
+ p.current = T.scrollHeight - T.scrollTop - T.clientHeight < 1, k();
695
679
  };
696
- return f.addEventListener("scroll", _, {
680
+ if (T.addEventListener("scroll", j, {
697
681
  passive: !0
698
- }), i && w.current && ($ = setTimeout(() => {
699
- console.log("totalHeight", F), w.current && f.scrollTo({
700
- top: 999999999,
701
- behavior: "smooth"
702
- // ALWAYS 'auto' for an instant, correct jump.
703
- });
704
- }, 200)), C(), () => {
705
- clearTimeout($), f.removeEventListener("scroll", _);
682
+ }), c && x > 0) {
683
+ const V = C.current === 0 && x > 0, L = x > C.current;
684
+ V ? setTimeout(() => {
685
+ T.scrollTop = T.scrollHeight, p.current = !0;
686
+ }, 1e3) : L && p.current && setTimeout(() => {
687
+ T.scrollTo({
688
+ top: T.scrollHeight,
689
+ behavior: "smooth"
690
+ });
691
+ }, 100);
692
+ }
693
+ return k(), C.current = x, () => {
694
+ T.removeEventListener("scroll", j);
706
695
  };
707
- }, [k, D, F, i]);
708
- const N = wt(
709
- (f = "smooth") => {
710
- u.current && (w.current = !0, u.current.scrollTo({
711
- top: u.current.scrollHeight,
712
- behavior: f
696
+ }, [x, P, c]);
697
+ const O = wt(
698
+ (T = "smooth") => {
699
+ g.current && (p.current = !0, g.current.scrollTo({
700
+ top: g.current.scrollHeight,
701
+ behavior: T
713
702
  }));
714
703
  },
715
704
  []
716
- ), O = wt(
717
- (f, $ = "smooth") => {
718
- u.current && D[f] !== void 0 && (w.current = !1, u.current.scrollTo({
719
- top: D[f],
720
- behavior: $
705
+ ), D = wt(
706
+ (T, k = "smooth") => {
707
+ g.current && P[T] !== void 0 && (p.current = !1, g.current.scrollTo({
708
+ top: P[T],
709
+ behavior: k
721
710
  }));
722
711
  },
723
- [D]
724
- ), W = {
712
+ [P]
713
+ ), A = {
725
714
  outer: {
726
- ref: u,
715
+ ref: g,
727
716
  style: { overflowY: "auto", height: "100%" }
728
717
  },
729
718
  inner: {
730
719
  style: {
731
- height: `${F}px`,
720
+ height: `${B}px`,
732
721
  position: "relative"
733
722
  }
734
723
  },
735
724
  list: {
736
725
  style: {
737
- transform: `translateY(${D[g.startIndex] || 0}px)`
726
+ transform: `translateY(${P[u.startIndex] || 0}px)`
738
727
  }
739
728
  }
740
729
  };
741
730
  return {
742
- virtualState: M,
743
- virtualizerProps: W,
744
- scrollToBottom: N,
745
- scrollToIndex: O
731
+ virtualState: N,
732
+ virtualizerProps: A,
733
+ scrollToBottom: O,
734
+ scrollToIndex: D
746
735
  };
747
736
  };
748
737
  if (l === "stateSort")
749
738
  return (e) => {
750
739
  const s = [...d()].sort(
751
- (g, E) => e(g.item, E.item)
752
- ), i = s.map(({ item: g }) => g), u = {
753
- ...m,
740
+ (u, E) => e(u.item, E.item)
741
+ ), c = s.map(({ item: u }) => u), g = {
742
+ ...S,
754
743
  validIndices: s.map(
755
- ({ originalIndex: g }) => g
744
+ ({ originalIndex: u }) => u
756
745
  )
757
746
  };
758
- return a(i, n, u);
747
+ return a(c, n, g);
759
748
  };
760
749
  if (l === "stateFilter")
761
750
  return (e) => {
762
751
  const s = d().filter(
763
- ({ item: g }, E) => e(g, E)
764
- ), i = s.map(({ item: g }) => g), u = {
765
- ...m,
752
+ ({ item: u }, E) => e(u, E)
753
+ ), c = s.map(({ item: u }) => u), g = {
754
+ ...S,
766
755
  validIndices: s.map(
767
- ({ originalIndex: g }) => g
756
+ ({ originalIndex: u }) => u
768
757
  )
769
758
  };
770
- return a(i, n, u);
759
+ return a(c, n, g);
771
760
  };
772
761
  if (l === "stateMap")
773
762
  return (e) => {
774
763
  const r = o.getState().getNestedState(t, n);
775
- return Array.isArray(r) ? (m?.validIndices || Array.from({ length: r.length }, (i, u) => u)).map((i, u) => {
776
- const g = r[i], E = [...n, i.toString()], w = a(g, E, m);
777
- return e(g, w, {
764
+ return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (c, g) => g)).map((c, g) => {
765
+ const u = r[c], E = [...n, c.toString()], p = a(u, E, S);
766
+ return e(u, p, {
778
767
  register: () => {
779
- const [, P] = X({}), V = `${h}-${n.join(".")}-${i}`;
768
+ const [, _] = Q({}), C = `${m}-${n.join(".")}-${c}`;
780
769
  ct(() => {
781
- const k = `${t}////${V}`, F = o.getState().stateComponents.get(t) || {
770
+ const M = `${t}////${C}`, x = o.getState().stateComponents.get(t) || {
782
771
  components: /* @__PURE__ */ new Map()
783
772
  };
784
- return F.components.set(k, {
785
- forceUpdate: () => P({}),
773
+ return x.components.set(M, {
774
+ forceUpdate: () => _({}),
786
775
  paths: /* @__PURE__ */ new Set([E.join(".")])
787
- }), o.getState().stateComponents.set(t, F), () => {
788
- const D = o.getState().stateComponents.get(t);
789
- D && D.components.delete(k);
776
+ }), o.getState().stateComponents.set(t, x), () => {
777
+ const B = o.getState().stateComponents.get(t);
778
+ B && B.components.delete(M);
790
779
  };
791
- }, [t, V]);
780
+ }, [t, C]);
792
781
  },
793
- index: u,
794
- originalIndex: i
782
+ index: g,
783
+ originalIndex: c
795
784
  });
796
785
  }) : (console.warn(
797
786
  `stateMap called on a non-array value at path: ${n.join(".")}. The current value is:`,
@@ -799,16 +788,16 @@ function dt(t, c, h, S) {
799
788
  ), null);
800
789
  };
801
790
  if (l === "stateMapNoRender")
802
- return (e) => y.map((s, i) => {
803
- let u;
804
- m?.validIndices && m.validIndices[i] !== void 0 ? u = m.validIndices[i] : u = i;
805
- const g = [...n, u.toString()], E = a(s, g, m);
791
+ return (e) => v.map((s, c) => {
792
+ let g;
793
+ S?.validIndices && S.validIndices[c] !== void 0 ? g = S.validIndices[c] : g = c;
794
+ const u = [...n, g.toString()], E = a(s, u, S);
806
795
  return e(
807
796
  s,
808
797
  E,
809
- i,
810
- y,
811
- a(y, n, m)
798
+ c,
799
+ v,
800
+ a(v, n, S)
812
801
  );
813
802
  });
814
803
  if (l === "$stateMap")
@@ -824,19 +813,19 @@ function dt(t, c, h, S) {
824
813
  if (l === "stateList")
825
814
  return (e) => {
826
815
  const r = o.getState().getNestedState(t, n);
827
- return Array.isArray(r) ? (m?.validIndices || Array.from({ length: r.length }, (i, u) => u)).map((i, u) => {
828
- const g = r[i], E = [...n, i.toString()], w = a(g, E, m), A = `${h}-${n.join(".")}-${i}`;
816
+ return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (c, g) => g)).map((c, g) => {
817
+ const u = r[c], E = [...n, c.toString()], p = a(u, E, S), $ = `${m}-${n.join(".")}-${c}`;
829
818
  return at(Yt, {
830
- key: i,
819
+ key: c,
831
820
  stateKey: t,
832
- itemComponentId: A,
821
+ itemComponentId: $,
833
822
  itemPath: E,
834
823
  children: e(
835
- g,
836
- w,
837
824
  u,
825
+ p,
826
+ g,
838
827
  r,
839
- a(r, n, m)
828
+ a(r, n, S)
840
829
  )
841
830
  });
842
831
  }) : (console.warn(
@@ -845,109 +834,109 @@ function dt(t, c, h, S) {
845
834
  };
846
835
  if (l === "stateFlattenOn")
847
836
  return (e) => {
848
- const r = y;
849
- I.clear(), b++;
837
+ const r = v;
838
+ y.clear(), b++;
850
839
  const s = r.flatMap(
851
- (i) => i[e] ?? []
840
+ (c) => c[e] ?? []
852
841
  );
853
842
  return a(
854
843
  s,
855
844
  [...n, "[*]", e],
856
- m
845
+ S
857
846
  );
858
847
  };
859
848
  if (l === "index")
860
849
  return (e) => {
861
- const r = y[e];
850
+ const r = v[e];
862
851
  return a(r, [...n, e.toString()]);
863
852
  };
864
853
  if (l === "last")
865
854
  return () => {
866
855
  const e = o.getState().getNestedState(t, n);
867
856
  if (e.length === 0) return;
868
- const r = e.length - 1, s = e[r], i = [...n, r.toString()];
869
- return a(s, i);
857
+ const r = e.length - 1, s = e[r], c = [...n, r.toString()];
858
+ return a(s, c);
870
859
  };
871
860
  if (l === "insert")
872
- return (e) => (T(n), St(c, e, n, t), a(
861
+ return (e) => (w(n), St(i, e, n, t), a(
873
862
  o.getState().getNestedState(t, n),
874
863
  n
875
864
  ));
876
865
  if (l === "uniqueInsert")
877
866
  return (e, r, s) => {
878
- const i = o.getState().getNestedState(t, n), u = J(e) ? e(i) : e;
879
- let g = null;
880
- if (!i.some((w) => {
867
+ const c = o.getState().getNestedState(t, n), g = Y(e) ? e(c) : e;
868
+ let u = null;
869
+ if (!c.some((p) => {
881
870
  if (r) {
882
- const P = r.every(
883
- (V) => H(w[V], u[V])
871
+ const _ = r.every(
872
+ (C) => H(p[C], g[C])
884
873
  );
885
- return P && (g = w), P;
874
+ return _ && (u = p), _;
886
875
  }
887
- const A = H(w, u);
888
- return A && (g = w), A;
876
+ const $ = H(p, g);
877
+ return $ && (u = p), $;
889
878
  }))
890
- T(n), St(c, u, n, t);
891
- else if (s && g) {
892
- const w = s(g), A = i.map(
893
- (P) => H(P, g) ? w : P
879
+ w(n), St(i, g, n, t);
880
+ else if (s && u) {
881
+ const p = s(u), $ = c.map(
882
+ (_) => H(_, u) ? p : _
894
883
  );
895
- T(n), ot(c, A, n);
884
+ w(n), rt(i, $, n);
896
885
  }
897
886
  };
898
887
  if (l === "cut")
899
888
  return (e, r) => {
900
889
  if (!r?.waitForSync)
901
- return T(n), it(c, n, t, e), a(
890
+ return w(n), it(i, n, t, e), a(
902
891
  o.getState().getNestedState(t, n),
903
892
  n
904
893
  );
905
894
  };
906
895
  if (l === "cutByValue")
907
896
  return (e) => {
908
- for (let r = 0; r < y.length; r++)
909
- y[r] === e && it(c, n, t, r);
897
+ for (let r = 0; r < v.length; r++)
898
+ v[r] === e && it(i, n, t, r);
910
899
  };
911
900
  if (l === "toggleByValue")
912
901
  return (e) => {
913
- const r = y.findIndex((s) => s === e);
914
- r > -1 ? it(c, n, t, r) : St(c, e, n, t);
902
+ const r = v.findIndex((s) => s === e);
903
+ r > -1 ? it(i, n, t, r) : St(i, e, n, t);
915
904
  };
916
905
  if (l === "stateFind")
917
906
  return (e) => {
918
907
  const s = d().find(
919
- ({ item: u }, g) => e(u, g)
908
+ ({ item: g }, u) => e(g, u)
920
909
  );
921
910
  if (!s) return;
922
- const i = [...n, s.originalIndex.toString()];
923
- return a(s.item, i, m);
911
+ const c = [...n, s.originalIndex.toString()];
912
+ return a(s.item, c, S);
924
913
  };
925
914
  if (l === "findWith")
926
915
  return (e, r) => {
927
- const i = d().find(
928
- ({ item: g }) => g[e] === r
916
+ const c = d().find(
917
+ ({ item: u }) => u[e] === r
929
918
  );
930
- if (!i) return;
931
- const u = [...n, i.originalIndex.toString()];
932
- return a(i.item, u, m);
919
+ if (!c) return;
920
+ const g = [...n, c.originalIndex.toString()];
921
+ return a(c.item, g, S);
933
922
  };
934
923
  }
935
- const Y = n[n.length - 1];
936
- if (!isNaN(Number(Y))) {
924
+ const X = n[n.length - 1];
925
+ if (!isNaN(Number(X))) {
937
926
  const d = n.slice(0, -1), e = o.getState().getNestedState(t, d);
938
927
  if (Array.isArray(e) && l === "cut")
939
928
  return () => it(
940
- c,
929
+ i,
941
930
  d,
942
931
  t,
943
- Number(Y)
932
+ Number(X)
944
933
  );
945
934
  }
946
935
  if (l === "get")
947
936
  return () => {
948
- if (m?.validIndices && Array.isArray(y)) {
937
+ if (S?.validIndices && Array.isArray(v)) {
949
938
  const d = o.getState().getNestedState(t, n);
950
- return m.validIndices.map((e) => d[e]);
939
+ return S.validIndices.map((e) => d[e]);
951
940
  }
952
941
  return o.getState().getNestedState(t, n);
953
942
  };
@@ -967,7 +956,7 @@ function dt(t, c, h, S) {
967
956
  return o.getState().getSyncInfo(d);
968
957
  }
969
958
  if (l == "getLocalStorage")
970
- return (d) => ut(S + "-" + t + "-" + d);
959
+ return (d) => ut(f + "-" + t + "-" + d);
971
960
  if (l === "_selected") {
972
961
  const d = n.slice(0, -1), e = d.join("."), r = o.getState().getNestedState(t, d);
973
962
  return Array.isArray(r) ? Number(n[n.length - 1]) === o.getState().getSelectedIndex(t, e) : void 0;
@@ -976,8 +965,8 @@ function dt(t, c, h, S) {
976
965
  return (d) => {
977
966
  const e = n.slice(0, -1), r = Number(n[n.length - 1]), s = e.join(".");
978
967
  d ? o.getState().setSelectedIndex(t, s, r) : o.getState().setSelectedIndex(t, s, void 0);
979
- const i = o.getState().getNestedState(t, [...e]);
980
- ot(c, i, e), T(e);
968
+ const c = o.getState().getNestedState(t, [...e]);
969
+ rt(i, c, e), w(e);
981
970
  };
982
971
  if (l === "toggleSelected")
983
972
  return () => {
@@ -987,8 +976,8 @@ function dt(t, c, h, S) {
987
976
  r,
988
977
  s === e ? void 0 : e
989
978
  );
990
- const i = o.getState().getNestedState(t, [...d]);
991
- ot(c, i, d), T(d);
979
+ const c = o.getState().getNestedState(t, [...d]);
980
+ rt(i, c, d), w(d);
992
981
  };
993
982
  if (n.length == 0) {
994
983
  if (l === "applyJsonPatch")
@@ -998,63 +987,63 @@ function dt(t, c, h, S) {
998
987
  t,
999
988
  o.getState().initialStateGlobal[t],
1000
989
  s,
1001
- c,
1002
- h,
1003
- S
990
+ i,
991
+ m,
992
+ f
1004
993
  );
1005
- const i = o.getState().stateComponents.get(t);
1006
- if (i) {
1007
- const u = vt(e, s), g = new Set(u);
994
+ const c = o.getState().stateComponents.get(t);
995
+ if (c) {
996
+ const g = vt(e, s), u = new Set(g);
1008
997
  for (const [
1009
998
  E,
1010
- w
1011
- ] of i.components.entries()) {
1012
- let A = !1;
1013
- const P = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
1014
- if (!P.includes("none")) {
1015
- if (P.includes("all")) {
1016
- w.forceUpdate();
999
+ p
1000
+ ] of c.components.entries()) {
1001
+ let $ = !1;
1002
+ const _ = Array.isArray(p.reactiveType) ? p.reactiveType : [p.reactiveType || "component"];
1003
+ if (!_.includes("none")) {
1004
+ if (_.includes("all")) {
1005
+ p.forceUpdate();
1017
1006
  continue;
1018
1007
  }
1019
- if (P.includes("component") && (w.paths.has("") && (A = !0), !A))
1020
- for (const V of g) {
1021
- if (w.paths.has(V)) {
1022
- A = !0;
1008
+ if (_.includes("component") && (p.paths.has("") && ($ = !0), !$))
1009
+ for (const C of u) {
1010
+ if (p.paths.has(C)) {
1011
+ $ = !0;
1023
1012
  break;
1024
1013
  }
1025
- let k = V.lastIndexOf(".");
1026
- for (; k !== -1; ) {
1027
- const F = V.substring(0, k);
1028
- if (w.paths.has(F)) {
1029
- A = !0;
1014
+ let M = C.lastIndexOf(".");
1015
+ for (; M !== -1; ) {
1016
+ const x = C.substring(0, M);
1017
+ if (p.paths.has(x)) {
1018
+ $ = !0;
1030
1019
  break;
1031
1020
  }
1032
- const D = V.substring(
1033
- k + 1
1021
+ const B = C.substring(
1022
+ M + 1
1034
1023
  );
1035
- if (!isNaN(Number(D))) {
1036
- const M = F.lastIndexOf(".");
1037
- if (M !== -1) {
1038
- const N = F.substring(
1024
+ if (!isNaN(Number(B))) {
1025
+ const P = x.lastIndexOf(".");
1026
+ if (P !== -1) {
1027
+ const N = x.substring(
1039
1028
  0,
1040
- M
1029
+ P
1041
1030
  );
1042
- if (w.paths.has(N)) {
1043
- A = !0;
1031
+ if (p.paths.has(N)) {
1032
+ $ = !0;
1044
1033
  break;
1045
1034
  }
1046
1035
  }
1047
1036
  }
1048
- k = F.lastIndexOf(".");
1037
+ M = x.lastIndexOf(".");
1049
1038
  }
1050
- if (A) break;
1039
+ if ($) break;
1051
1040
  }
1052
- if (!A && P.includes("deps") && w.depsFunction) {
1053
- const V = w.depsFunction(s);
1054
- let k = !1;
1055
- typeof V == "boolean" ? V && (k = !0) : H(w.deps, V) || (w.deps = V, k = !0), k && (A = !0);
1041
+ if (!$ && _.includes("deps") && p.depsFunction) {
1042
+ const C = p.depsFunction(s);
1043
+ let M = !1;
1044
+ typeof C == "boolean" ? C && (M = !0) : H(p.deps, C) || (p.deps = C, M = !0), M && ($ = !0);
1056
1045
  }
1057
- A && w.forceUpdate();
1046
+ $ && p.forceUpdate();
1058
1047
  }
1059
1048
  }
1060
1049
  }
@@ -1066,23 +1055,23 @@ function dt(t, c, h, S) {
1066
1055
  throw new Error("Zod schema not found");
1067
1056
  if (!d?.key)
1068
1057
  throw new Error("Validation key not found");
1069
- q(d.key);
1058
+ J(d.key);
1070
1059
  const r = o.getState().cogsStateStore[t];
1071
1060
  try {
1072
1061
  const s = o.getState().getValidationErrors(d.key);
1073
- s && s.length > 0 && s.forEach(([u]) => {
1074
- u && u.startsWith(d.key) && q(u);
1062
+ s && s.length > 0 && s.forEach(([g]) => {
1063
+ g && g.startsWith(d.key) && J(g);
1075
1064
  });
1076
- const i = d.zodSchema.safeParse(r);
1077
- return i.success ? !0 : (i.error.errors.forEach((g) => {
1078
- const E = g.path, w = g.message, A = [d.key, ...E].join(".");
1079
- e(A, w);
1065
+ const c = d.zodSchema.safeParse(r);
1066
+ return c.success ? !0 : (c.error.errors.forEach((u) => {
1067
+ const E = u.path, p = u.message, $ = [d.key, ...E].join(".");
1068
+ e($, p);
1080
1069
  }), gt(t), !1);
1081
1070
  } catch (s) {
1082
1071
  return console.error("Zod schema validation failed", s), !1;
1083
1072
  }
1084
1073
  };
1085
- if (l === "_componentId") return h;
1074
+ if (l === "_componentId") return m;
1086
1075
  if (l === "getComponents")
1087
1076
  return () => o().stateComponents.get(t);
1088
1077
  if (l === "getAllFormRefs")
@@ -1094,9 +1083,9 @@ function dt(t, c, h, S) {
1094
1083
  if (l === "_isLoading")
1095
1084
  return o.getState().isLoadingGlobal[t];
1096
1085
  if (l === "revertToInitialState")
1097
- return p.revertToInitialState;
1098
- if (l === "updateInitialState") return p.updateInitialState;
1099
- if (l === "removeValidation") return p.removeValidation;
1086
+ return I.revertToInitialState;
1087
+ if (l === "updateInitialState") return I.updateInitialState;
1088
+ if (l === "removeValidation") return I.removeValidation;
1100
1089
  }
1101
1090
  if (l === "getFormRef")
1102
1091
  return () => Tt.getState().getFormRef(t + "." + n.join("."));
@@ -1111,44 +1100,44 @@ function dt(t, c, h, S) {
1111
1100
  path: n,
1112
1101
  validationKey: o.getState().getInitialOptions(t)?.validation?.key || "",
1113
1102
  stateKey: t,
1114
- validIndices: m?.validIndices,
1103
+ validIndices: S?.validIndices,
1115
1104
  children: d
1116
1105
  }
1117
1106
  );
1118
1107
  if (l === "_stateKey") return t;
1119
1108
  if (l === "_path") return n;
1120
- if (l === "_isServerSynced") return p._isServerSynced;
1109
+ if (l === "_isServerSynced") return I._isServerSynced;
1121
1110
  if (l === "update")
1122
1111
  return (d, e) => {
1123
1112
  if (e?.debounce)
1124
1113
  Mt(() => {
1125
- ot(c, d, n, "");
1114
+ rt(i, d, n, "");
1126
1115
  const r = o.getState().getNestedState(t, n);
1127
1116
  e?.afterUpdate && e.afterUpdate(r);
1128
1117
  }, e.debounce);
1129
1118
  else {
1130
- ot(c, d, n, "");
1119
+ rt(i, d, n, "");
1131
1120
  const r = o.getState().getNestedState(t, n);
1132
1121
  e?.afterUpdate && e.afterUpdate(r);
1133
1122
  }
1134
- T(n);
1123
+ w(n);
1135
1124
  };
1136
1125
  if (l === "formElement")
1137
1126
  return (d, e) => /* @__PURE__ */ mt(
1138
- Ot,
1127
+ Rt,
1139
1128
  {
1140
- setState: c,
1129
+ setState: i,
1141
1130
  stateKey: t,
1142
1131
  path: n,
1143
1132
  child: d,
1144
1133
  formOpts: e
1145
1134
  }
1146
1135
  );
1147
- const j = [...n, l], rt = o.getState().getNestedState(t, j);
1148
- return a(rt, j, m);
1136
+ const R = [...n, l], nt = o.getState().getNestedState(t, R);
1137
+ return a(nt, R, S);
1149
1138
  }
1150
- }, G = new Proxy(R, U);
1151
- return I.set(L, {
1139
+ }, G = new Proxy(U, F);
1140
+ return y.set(W, {
1152
1141
  proxy: G,
1153
1142
  stateVersion: b
1154
1143
  }), G;
@@ -1162,95 +1151,95 @@ function kt(t) {
1162
1151
  }
1163
1152
  function qt({
1164
1153
  proxy: t,
1165
- rebuildStateShape: c
1154
+ rebuildStateShape: i
1166
1155
  }) {
1167
- const h = o().getNestedState(t._stateKey, t._path);
1168
- return Array.isArray(h) ? c(
1169
- h,
1156
+ const m = o().getNestedState(t._stateKey, t._path);
1157
+ return Array.isArray(m) ? i(
1158
+ m,
1170
1159
  t._path
1171
1160
  ).stateMapNoRender(
1172
- (I, b, T, p, a) => t._mapFn(I, b, T, p, a)
1161
+ (y, b, w, I, a) => t._mapFn(y, b, w, I, a)
1173
1162
  ) : null;
1174
1163
  }
1175
1164
  function Jt({
1176
1165
  proxy: t
1177
1166
  }) {
1178
- const c = Q(null), h = `${t._stateKey}-${t._path.join(".")}`;
1179
- return nt(() => {
1180
- const S = c.current;
1181
- if (!S || !S.parentElement) return;
1182
- const I = S.parentElement, T = Array.from(I.childNodes).indexOf(S);
1183
- let p = I.getAttribute("data-parent-id");
1184
- p || (p = `parent-${crypto.randomUUID()}`, I.setAttribute("data-parent-id", p));
1185
- const y = {
1167
+ const i = Z(null), m = `${t._stateKey}-${t._path.join(".")}`;
1168
+ return ot(() => {
1169
+ const f = i.current;
1170
+ if (!f || !f.parentElement) return;
1171
+ const y = f.parentElement, w = Array.from(y.childNodes).indexOf(f);
1172
+ let I = y.getAttribute("data-parent-id");
1173
+ I || (I = `parent-${crypto.randomUUID()}`, y.setAttribute("data-parent-id", I));
1174
+ const v = {
1186
1175
  instanceId: `instance-${crypto.randomUUID()}`,
1187
- parentId: p,
1188
- position: T,
1176
+ parentId: I,
1177
+ position: w,
1189
1178
  effect: t._effect
1190
1179
  };
1191
- o.getState().addSignalElement(h, y);
1180
+ o.getState().addSignalElement(m, v);
1192
1181
  const n = o.getState().getNestedState(t._stateKey, t._path);
1193
- let m;
1182
+ let S;
1194
1183
  if (t._effect)
1195
1184
  try {
1196
- m = new Function(
1185
+ S = new Function(
1197
1186
  "state",
1198
1187
  `return (${t._effect})(state)`
1199
1188
  )(n);
1200
- } catch (R) {
1201
- console.error("Error evaluating effect function during mount:", R), m = n;
1189
+ } catch (U) {
1190
+ console.error("Error evaluating effect function during mount:", U), S = n;
1202
1191
  }
1203
1192
  else
1204
- m = n;
1205
- m !== null && typeof m == "object" && (m = JSON.stringify(m));
1206
- const L = document.createTextNode(String(m));
1207
- S.replaceWith(L);
1193
+ S = n;
1194
+ S !== null && typeof S == "object" && (S = JSON.stringify(S));
1195
+ const W = document.createTextNode(String(S));
1196
+ f.replaceWith(W);
1208
1197
  }, [t._stateKey, t._path.join("."), t._effect]), at("span", {
1209
- ref: c,
1198
+ ref: i,
1210
1199
  style: { display: "none" },
1211
- "data-signal-id": h
1200
+ "data-signal-id": m
1212
1201
  });
1213
1202
  }
1214
1203
  function de(t) {
1215
- const c = xt(
1216
- (h) => {
1217
- const S = o.getState().stateComponents.get(t._stateKey) || {
1204
+ const i = xt(
1205
+ (m) => {
1206
+ const f = o.getState().stateComponents.get(t._stateKey) || {
1218
1207
  components: /* @__PURE__ */ new Map()
1219
1208
  };
1220
- return S.components.set(t._stateKey, {
1221
- forceUpdate: h,
1209
+ return f.components.set(t._stateKey, {
1210
+ forceUpdate: m,
1222
1211
  paths: /* @__PURE__ */ new Set([t._path.join(".")])
1223
- }), () => S.components.delete(t._stateKey);
1212
+ }), () => f.components.delete(t._stateKey);
1224
1213
  },
1225
1214
  () => o.getState().getNestedState(t._stateKey, t._path)
1226
1215
  );
1227
- return at("text", {}, String(c));
1216
+ return at("text", {}, String(i));
1228
1217
  }
1229
1218
  function Yt({
1230
1219
  stateKey: t,
1231
- itemComponentId: c,
1232
- itemPath: h,
1233
- children: S
1220
+ itemComponentId: i,
1221
+ itemPath: m,
1222
+ children: f
1234
1223
  }) {
1235
- const [, I] = X({}), [b, T] = Ft(), p = Q(null);
1236
- return nt(() => {
1237
- T.height > 0 && T.height !== p.current && (p.current = T.height, o.getState().setShadowMetadata(t, h, {
1224
+ const [, y] = Q({}), [b, w] = Ft(), I = Z(null);
1225
+ return ot(() => {
1226
+ w.height > 0 && w.height !== I.current && (I.current = w.height, o.getState().setShadowMetadata(t, m, {
1238
1227
  virtualizer: {
1239
- itemHeight: T.height
1228
+ itemHeight: w.height
1240
1229
  }
1241
1230
  }));
1242
- }, [T.height, t, h]), ct(() => {
1243
- const a = `${t}////${c}`, y = o.getState().stateComponents.get(t) || {
1231
+ }, [w.height, t, m]), ct(() => {
1232
+ const a = `${t}////${i}`, v = o.getState().stateComponents.get(t) || {
1244
1233
  components: /* @__PURE__ */ new Map()
1245
1234
  };
1246
- return y.components.set(a, {
1247
- forceUpdate: () => I({}),
1248
- paths: /* @__PURE__ */ new Set([h.join(".")])
1249
- }), o.getState().stateComponents.set(t, y), () => {
1235
+ return v.components.set(a, {
1236
+ forceUpdate: () => y({}),
1237
+ paths: /* @__PURE__ */ new Set([m.join(".")])
1238
+ }), o.getState().stateComponents.set(t, v), () => {
1250
1239
  const n = o.getState().stateComponents.get(t);
1251
1240
  n && n.components.delete(a);
1252
1241
  };
1253
- }, [t, c, h.join(".")]), /* @__PURE__ */ mt("div", { ref: b, children: S });
1242
+ }, [t, i, m.join(".")]), /* @__PURE__ */ mt("div", { ref: b, children: f });
1254
1243
  }
1255
1244
  export {
1256
1245
  kt as $cogsSignal,