cogsbox-state 0.5.308 → 0.5.310

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