cogsbox-state 0.5.320 → 0.5.321

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