cogsbox-state 0.5.340 → 0.5.342

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