cogsbox-state 0.5.307 → 0.5.308

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