cogsbox-state 0.5.473 → 0.5.474

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.
@@ -36,16 +36,16 @@ const {
36
36
  removePluginMetaData: rt
37
37
  // Note: The old functions are no longer imported under their original names
38
38
  } = T.getState(), { notifyUpdate: nt } = Q.getState();
39
- function L(e, n, u) {
39
+ function L(e, n, l) {
40
40
  const s = b(e, n);
41
41
  if (!!!s?.arrayKeys)
42
42
  return { isArray: !1, value: T.getState().getShadowValue(e, n), keys: [] };
43
- const i = n.length > 0 ? n.join(".") : "root", h = u?.arrayViews?.[i] ?? s.arrayKeys;
43
+ const i = n.length > 0 ? n.join(".") : "root", h = l?.arrayViews?.[i] ?? s.arrayKeys;
44
44
  return Array.isArray(h) && h.length === 0 ? { isArray: !0, value: [], keys: [] } : { isArray: !0, value: T.getState().getShadowValue(e, n, h), keys: h ?? [] };
45
45
  }
46
- function ve(e, n, u) {
46
+ function ve(e, n, l) {
47
47
  for (let s = 0; s < e.length; s++)
48
- if (u(e[s], s)) {
48
+ if (l(e[s], s)) {
49
49
  const g = n[s];
50
50
  if (g)
51
51
  return { key: g, index: s, value: e[s] };
@@ -62,22 +62,22 @@ function we(e, n) {
62
62
  function Ae({
63
63
  stateKey: e,
64
64
  options: n,
65
- initialOptionsPart: u
65
+ initialOptionsPart: l
66
66
  }) {
67
- const s = W(e) || {}, g = u[e] || {};
67
+ const s = W(e) || {}, g = l[e] || {};
68
68
  let i = { ...g, ...s }, h = !1;
69
69
  if (n) {
70
- const l = (t, a) => {
70
+ const u = (t, a) => {
71
71
  for (const S in a)
72
- a.hasOwnProperty(S) && (a[S] instanceof Object && !Array.isArray(a[S]) && t[S] instanceof Object ? le(t[S], a[S]) || (l(t[S], a[S]), h = !0) : t[S] !== a[S] && (t[S] = a[S], h = !0));
72
+ a.hasOwnProperty(S) && (a[S] instanceof Object && !Array.isArray(a[S]) && t[S] instanceof Object ? le(t[S], a[S]) || (u(t[S], a[S]), h = !0) : t[S] !== a[S] && (t[S] = a[S], h = !0));
73
73
  return t;
74
74
  };
75
- i = l(i, n);
75
+ i = u(i, n);
76
76
  }
77
77
  if (i.validation && (n?.validation?.hasOwnProperty("onBlur") || s?.validation?.hasOwnProperty("onBlur") || g?.validation?.hasOwnProperty("onBlur") || (i.validation.onBlur = "error", h = !0)), h) {
78
78
  ue(e, i);
79
- const l = s?.validation?.zodSchemaV4 || s?.validation?.zodSchemaV3, t = i.validation?.zodSchemaV4 && !s?.validation?.zodSchemaV4, a = i.validation?.zodSchemaV3 && !s?.validation?.zodSchemaV3;
80
- !l && (t || a) && (t ? Ie(
79
+ const u = s?.validation?.zodSchemaV4 || s?.validation?.zodSchemaV3, t = i.validation?.zodSchemaV4 && !s?.validation?.zodSchemaV4, a = i.validation?.zodSchemaV3 && !s?.validation?.zodSchemaV3;
80
+ !u && (t || a) && (t ? Ie(
81
81
  e,
82
82
  i.validation.zodSchemaV4,
83
83
  "zod4"
@@ -98,9 +98,9 @@ function kt(e, n) {
98
98
  }
99
99
  const Ct = (e, n) => {
100
100
  n?.plugins && Q.getState().setRegisteredPlugins(n.plugins);
101
- const [u, s] = Oe(e);
102
- Object.keys(u).forEach((l) => {
103
- let t = s[l] || {};
101
+ const [l, s] = Oe(e);
102
+ Object.keys(l).forEach((u) => {
103
+ let t = s[u] || {};
104
104
  const a = {
105
105
  ...t
106
106
  };
@@ -111,8 +111,8 @@ const Ct = (e, n) => {
111
111
  onBlur: "error",
112
112
  ...n?.validation,
113
113
  ...t.validation || {}
114
- }, n?.validation?.key && !t.validation?.key && (a.validation.key = `${n.validation.key}.${l}`);
115
- const S = W(l), M = S ? {
114
+ }, n?.validation?.key && !t.validation?.key && (a.validation.key = `${n.validation.key}.${u}`);
115
+ const S = W(u), M = S ? {
116
116
  ...S,
117
117
  ...a,
118
118
  formElements: {
@@ -124,19 +124,19 @@ const Ct = (e, n) => {
124
124
  ...a.validation
125
125
  }
126
126
  } : a;
127
- ue(l, M);
128
- }), Object.keys(u).forEach((l) => {
129
- se(l, u[l]);
127
+ ue(u, M);
128
+ }), Object.keys(l).forEach((u) => {
129
+ se(u, l[u]);
130
130
  });
131
- const g = (l, t) => {
131
+ const g = (u, t) => {
132
132
  const [a] = ee(t?.componentId ?? ae()), S = Ae({
133
- stateKey: l,
133
+ stateKey: u,
134
134
  options: t,
135
135
  initialOptionsPart: s
136
136
  }), M = F(S);
137
137
  M.current = S;
138
- const E = x(l, []) || u[l], P = yt(E, {
139
- stateKey: l,
138
+ const E = x(u, []) || l[u], C = yt(E, {
139
+ stateKey: u,
140
140
  syncUpdate: t?.syncUpdate,
141
141
  componentId: a,
142
142
  localStorage: t?.localStorage,
@@ -148,28 +148,28 @@ const Ct = (e, n) => {
148
148
  serverState: t?.serverState
149
149
  });
150
150
  return z(() => {
151
- t && Q.getState().setPluginOptionsForState(l, t);
152
- }, [l, t]), z(() => (console.log("adding handler 1", l, P), Q.getState().stateHandlers.set(l, P), () => {
153
- Q.getState().stateHandlers.delete(l);
154
- }), [l, P]), P;
151
+ t && Q.getState().setPluginOptionsForState(u, t);
152
+ }, [u, t]), z(() => (Q.getState().stateHandlers.set(u, C), () => {
153
+ Q.getState().stateHandlers.delete(u);
154
+ }), [u, C]), C;
155
155
  };
156
- function i(l, t) {
157
- Ae({ stateKey: l, options: t, initialOptionsPart: s }), t.localStorage && at(l, t), K(l);
156
+ function i(u, t) {
157
+ Ae({ stateKey: u, options: t, initialOptionsPart: s }), t.localStorage && at(u, t), K(u);
158
158
  }
159
- function h(l) {
160
- const a = Q.getState().registeredPlugins.map((M) => l.hasOwnProperty(M.name) ? {
159
+ function h(u) {
160
+ const a = Q.getState().registeredPlugins.map((M) => u.hasOwnProperty(M.name) ? {
161
161
  ...M,
162
- formWrapper: l[M.name]
162
+ formWrapper: u[M.name]
163
163
  } : M);
164
- Q.getState().setRegisteredPlugins(a), Object.keys(u).forEach((M) => {
165
- const E = W(M) || {}, P = {
164
+ Q.getState().setRegisteredPlugins(a), Object.keys(l).forEach((M) => {
165
+ const E = W(M) || {}, C = {
166
166
  ...E,
167
167
  formElements: {
168
168
  ...E.formElements || {},
169
- ...l
169
+ ...u
170
170
  }
171
171
  };
172
- ue(M, P);
172
+ ue(M, C);
173
173
  });
174
174
  }
175
175
  return {
@@ -177,25 +177,25 @@ const Ct = (e, n) => {
177
177
  setCogsOptionsByKey: i,
178
178
  setCogsFormElements: h
179
179
  };
180
- }, ot = (e, n, u, s, g) => {
181
- u?.log && console.log(
180
+ }, ot = (e, n, l, s, g) => {
181
+ l?.log && console.log(
182
182
  "saving to localstorage",
183
183
  n,
184
- u.localStorage?.key,
184
+ l.localStorage?.key,
185
185
  s
186
186
  );
187
- const i = G(u?.localStorage?.key) ? u.localStorage?.key(e) : u?.localStorage?.key;
187
+ const i = G(l?.localStorage?.key) ? l.localStorage?.key(e) : l?.localStorage?.key;
188
188
  if (i && s) {
189
189
  const h = `${s}-${n}-${i}`;
190
- let l;
190
+ let u;
191
191
  try {
192
- l = Se(h)?.lastSyncedWithServer;
192
+ u = Se(h)?.lastSyncedWithServer;
193
193
  } catch {
194
194
  }
195
195
  const t = b(n, []), a = {
196
196
  state: e,
197
197
  lastUpdated: Date.now(),
198
- lastSyncedWithServer: l,
198
+ lastSyncedWithServer: u,
199
199
  stateSource: t?.stateSource,
200
200
  baseServerState: t?.baseServerState
201
201
  }, S = Le.serialize(a);
@@ -213,7 +213,7 @@ const Ct = (e, n) => {
213
213
  return console.error("Error loading from localStorage:", n), null;
214
214
  }
215
215
  }, at = (e, n) => {
216
- const u = x(e, []), { sessionId: s } = Pe(), g = G(n?.localStorage?.key) ? n.localStorage.key(u) : n?.localStorage?.key;
216
+ const l = x(e, []), { sessionId: s } = Pe(), g = G(n?.localStorage?.key) ? n.localStorage.key(l) : n?.localStorage?.key;
217
217
  if (g && s) {
218
218
  const i = Se(
219
219
  `${s}-${e}-${g}`
@@ -225,24 +225,24 @@ const Ct = (e, n) => {
225
225
  }, K = (e) => {
226
226
  const n = b(e, []);
227
227
  if (!n) return;
228
- const u = /* @__PURE__ */ new Set();
228
+ const l = /* @__PURE__ */ new Set();
229
229
  n?.components?.forEach((s) => {
230
- (s ? Array.isArray(s.reactiveType) ? s.reactiveType : [s.reactiveType || "component"] : null)?.includes("none") || u.add(() => s.forceUpdate());
230
+ (s ? Array.isArray(s.reactiveType) ? s.reactiveType : [s.reactiveType || "component"] : null)?.includes("none") || l.add(() => s.forceUpdate());
231
231
  }), queueMicrotask(() => {
232
- u.forEach((s) => s());
232
+ l.forEach((s) => s());
233
233
  });
234
234
  };
235
- function de(e, n, u, s) {
235
+ function de(e, n, l, s) {
236
236
  const g = b(e, n);
237
237
  if (J(e, n, {
238
238
  ...g,
239
239
  isDirty: !1,
240
240
  stateSource: "server",
241
241
  lastServerSync: s || Date.now()
242
- }), Array.isArray(u)) {
242
+ }), Array.isArray(l)) {
243
243
  const i = b(e, n);
244
- i?.arrayKeys && i.arrayKeys.forEach((h, l) => {
245
- const t = [...n, h], a = u[l];
244
+ i?.arrayKeys && i.arrayKeys.forEach((h, u) => {
245
+ const t = [...n, h], a = l[u];
246
246
  a !== void 0 && de(
247
247
  e,
248
248
  t,
@@ -250,9 +250,9 @@ function de(e, n, u, s) {
250
250
  s
251
251
  );
252
252
  });
253
- } else u && typeof u == "object" && u.constructor === Object && Object.keys(u).forEach((i) => {
254
- const h = [...n, i], l = u[i];
255
- de(e, h, l, s);
253
+ } else l && typeof l == "object" && l.constructor === Object && Object.keys(l).forEach((i) => {
254
+ const h = [...n, i], u = l[i];
255
+ de(e, h, u, s);
256
256
  });
257
257
  }
258
258
  let fe = [], be = !1;
@@ -262,50 +262,50 @@ function st() {
262
262
  }));
263
263
  }
264
264
  function it(e, n) {
265
- e?.signals?.length && e.signals.forEach(({ parentId: u, position: s, effect: g }) => {
266
- const i = document.querySelector(`[data-parent-id="${u}"]`);
265
+ e?.signals?.length && e.signals.forEach(({ parentId: l, position: s, effect: g }) => {
266
+ const i = document.querySelector(`[data-parent-id="${l}"]`);
267
267
  if (!i) return;
268
268
  const h = Array.from(i.childNodes);
269
269
  if (!h[s]) return;
270
- let l = n;
270
+ let u = n;
271
271
  if (g && n !== null)
272
272
  try {
273
- l = new Function("state", `return (${g})(state)`)(
273
+ u = new Function("state", `return (${g})(state)`)(
274
274
  n
275
275
  );
276
276
  } catch (t) {
277
277
  console.error("Error evaluating effect function:", t);
278
278
  }
279
- l !== null && typeof l == "object" && (l = JSON.stringify(l)), h[s].textContent = String(l ?? "");
279
+ u !== null && typeof u == "object" && (u = JSON.stringify(u)), h[s].textContent = String(u ?? "");
280
280
  });
281
281
  }
282
- function ct(e, n, u) {
282
+ function ct(e, n, l) {
283
283
  const s = b(e, []);
284
284
  if (!s?.components)
285
285
  return /* @__PURE__ */ new Set();
286
286
  const g = /* @__PURE__ */ new Set();
287
- if (u.type === "update") {
287
+ if (l.type === "update") {
288
288
  let i = [...n];
289
289
  for (; ; ) {
290
290
  const h = b(e, i);
291
- if (h?.pathComponents && h.pathComponents.forEach((l) => {
292
- const t = s.components?.get(l);
291
+ if (h?.pathComponents && h.pathComponents.forEach((u) => {
292
+ const t = s.components?.get(u);
293
293
  t && ((Array.isArray(t.reactiveType) ? t.reactiveType : [t.reactiveType || "component"]).includes("none") || g.add(t));
294
294
  }), i.length === 0) break;
295
295
  i.pop();
296
296
  }
297
- u.newValue && typeof u.newValue == "object" && !je(u.newValue) && Ne(u.newValue, u.oldValue).forEach((l) => {
298
- const t = l.split("."), a = [...n, ...t], S = b(e, a);
297
+ l.newValue && typeof l.newValue == "object" && !je(l.newValue) && Ne(l.newValue, l.oldValue).forEach((u) => {
298
+ const t = u.split("."), a = [...n, ...t], S = b(e, a);
299
299
  S?.pathComponents && S.pathComponents.forEach((M) => {
300
300
  const E = s.components?.get(M);
301
301
  E && ((Array.isArray(E.reactiveType) ? E.reactiveType : [E.reactiveType || "component"]).includes("none") || g.add(E));
302
302
  });
303
303
  });
304
- } else if (u.type === "insert" || u.type === "cut" || u.type === "insert_many") {
305
- let h = [...u.type === "insert" ? n : n.slice(0, -1)];
304
+ } else if (l.type === "insert" || l.type === "cut" || l.type === "insert_many") {
305
+ let h = [...l.type === "insert" ? n : n.slice(0, -1)];
306
306
  for (; ; ) {
307
- const l = b(e, h);
308
- if (l?.pathComponents && l.pathComponents.forEach((t) => {
307
+ const u = b(e, h);
308
+ if (u?.pathComponents && u.pathComponents.forEach((t) => {
309
309
  const a = s.components?.get(t);
310
310
  a && g.add(a);
311
311
  }), h.length === 0) break;
@@ -314,8 +314,8 @@ function ct(e, n, u) {
314
314
  }
315
315
  return g;
316
316
  }
317
- function lt(e, n, u) {
318
- const s = T.getState().getShadowValue(e, n), g = G(u) ? u(s) : u;
317
+ function lt(e, n, l) {
318
+ const s = T.getState().getShadowValue(e, n), g = G(l) ? l(s) : l;
319
319
  qe(e, n, g), ge(e, n, { bubble: !0 });
320
320
  const i = b(e, n);
321
321
  return {
@@ -325,23 +325,23 @@ function lt(e, n, u) {
325
325
  shadowMeta: i
326
326
  };
327
327
  }
328
- function ut(e, n, u) {
329
- Ce(e, n, u), ge(e, n, { bubble: !0 });
328
+ function ut(e, n, l) {
329
+ Ce(e, n, l), ge(e, n, { bubble: !0 });
330
330
  const s = b(e, n);
331
331
  return {
332
332
  type: "insert_many",
333
- count: u.length,
333
+ count: l.length,
334
334
  shadowMeta: s,
335
335
  path: n
336
336
  };
337
337
  }
338
- function dt(e, n, u, s, g) {
338
+ function dt(e, n, l, s, g) {
339
339
  let i;
340
- if (G(u)) {
340
+ if (G(l)) {
341
341
  const { value: a } = X(e, n);
342
- i = u({ state: a });
342
+ i = l({ state: a });
343
343
  } else
344
- i = u;
344
+ i = l;
345
345
  const h = He(
346
346
  e,
347
347
  n,
@@ -350,26 +350,26 @@ function dt(e, n, u, s, g) {
350
350
  g
351
351
  );
352
352
  ge(e, n, { bubble: !0 });
353
- const l = b(e, n);
353
+ const u = b(e, n);
354
354
  let t;
355
- return l?.arrayKeys && s !== void 0 && s > 0 && (t = l.arrayKeys[s - 1]), {
355
+ return u?.arrayKeys && s !== void 0 && s > 0 && (t = u.arrayKeys[s - 1]), {
356
356
  type: "insert",
357
357
  newValue: i,
358
- shadowMeta: l,
358
+ shadowMeta: u,
359
359
  path: n,
360
360
  itemId: h,
361
361
  insertAfterId: t
362
362
  };
363
363
  }
364
364
  function ft(e, n) {
365
- const u = n.slice(0, -1), s = x(e, n);
366
- return Ge(e, n), ge(e, u, { bubble: !0 }), { type: "cut", oldValue: s, parentPath: u };
365
+ const l = n.slice(0, -1), s = x(e, n);
366
+ return Ge(e, n), ge(e, l, { bubble: !0 }), { type: "cut", oldValue: s, parentPath: l };
367
367
  }
368
368
  function gt() {
369
- const e = /* @__PURE__ */ new Set(), n = [], u = [];
369
+ const e = /* @__PURE__ */ new Set(), n = [], l = [];
370
370
  for (const s of fe) {
371
371
  if (s.status && s.updateType) {
372
- u.push(s);
372
+ l.push(s);
373
373
  continue;
374
374
  }
375
375
  const g = s, i = g.type === "cut" ? null : g.newValue;
@@ -377,23 +377,23 @@ function gt() {
377
377
  g.stateKey,
378
378
  g.path,
379
379
  g
380
- ).forEach((l) => {
381
- e.add(l);
380
+ ).forEach((u) => {
381
+ e.add(u);
382
382
  });
383
383
  }
384
- u.length > 0 && Ze(u), n.forEach(({ shadowMeta: s, displayValue: g }) => {
384
+ l.length > 0 && Ze(l), n.forEach(({ shadowMeta: s, displayValue: g }) => {
385
385
  it(s, g);
386
386
  }), e.forEach((s) => {
387
387
  s.forceUpdate();
388
388
  }), fe = [], be = !1;
389
389
  }
390
- function St(e, n, u) {
390
+ function St(e, n, l) {
391
391
  return (g, i, h) => {
392
392
  s(e, i, g, h);
393
393
  };
394
- function s(g, i, h, l) {
394
+ function s(g, i, h, u) {
395
395
  let t;
396
- switch (l.updateType) {
396
+ switch (u.updateType) {
397
397
  case "update":
398
398
  t = lt(g, i, h);
399
399
  break;
@@ -402,8 +402,8 @@ function St(e, n, u) {
402
402
  g,
403
403
  i,
404
404
  h,
405
- l.index,
406
- l.itemId
405
+ u.index,
406
+ u.itemId
407
407
  );
408
408
  break;
409
409
  case "insert_many":
@@ -418,42 +418,42 @@ function St(e, n, u) {
418
418
  timeStamp: Date.now(),
419
419
  stateKey: g,
420
420
  path: i,
421
- updateType: l.updateType,
421
+ updateType: u.updateType,
422
422
  status: "new",
423
423
  oldValue: t.oldValue,
424
424
  newValue: t.newValue ?? null,
425
425
  itemId: t.itemId,
426
426
  insertAfterId: t.insertAfterId,
427
- metaData: l.metaData
427
+ metaData: u.metaData
428
428
  };
429
429
  fe.push(a), t.newValue !== void 0 && ot(
430
430
  t.newValue,
431
431
  g,
432
- u.current,
432
+ l.current,
433
433
  n
434
- ), u.current?.middleware && u.current.middleware({ update: a }), ze(a, l.validationTrigger || "programmatic"), nt(a);
434
+ ), l.current?.middleware && l.current.middleware({ update: a }), ze(a, u.validationTrigger || "programmatic"), nt(a);
435
435
  }
436
436
  }
437
437
  function yt(e, {
438
438
  stateKey: n,
439
- localStorage: u,
439
+ localStorage: l,
440
440
  formElements: s,
441
441
  reactiveDeps: g,
442
442
  reactiveType: i,
443
443
  componentId: h,
444
- defaultState: l,
444
+ defaultState: u,
445
445
  dependencies: t,
446
446
  serverState: a
447
447
  } = {}) {
448
448
  const [S, M] = ee({}), { sessionId: E } = Pe();
449
- let P = !n;
449
+ let C = !n;
450
450
  const [w] = ee(n ?? ae()), q = F(h ?? ae()), R = F(
451
451
  null
452
452
  );
453
453
  R.current = W(w) ?? null;
454
454
  const y = Te(
455
455
  (o) => {
456
- const d = o ? { ...W(w), ...o } : W(w), f = d?.defaultState || l || e;
456
+ const d = o ? { ...W(w), ...o } : W(w), f = d?.defaultState || u || e;
457
457
  if (d?.serverState?.status === "success" && d?.serverState?.data !== void 0)
458
458
  return {
459
459
  value: d.serverState.data,
@@ -477,7 +477,7 @@ function yt(e, {
477
477
  timestamp: Date.now()
478
478
  };
479
479
  },
480
- [w, l, e, E]
480
+ [w, u, e, E]
481
481
  );
482
482
  z(() => {
483
483
  a && a.status === "success" && a.data !== void 0 && $e(w, a);
@@ -528,8 +528,8 @@ function yt(e, {
528
528
  if (J(w, [], {
529
529
  ...o,
530
530
  features: d
531
- }), c?.defaultState !== void 0 || l !== void 0) {
532
- const p = c?.defaultState || l;
531
+ }), c?.defaultState !== void 0 || u !== void 0) {
532
+ const p = c?.defaultState || u;
533
533
  c?.defaultState || we(w, {
534
534
  defaultState: p
535
535
  });
@@ -542,10 +542,10 @@ function yt(e, {
542
542
  baseServerState: m === "server" ? f : void 0
543
543
  }), m === "server" && a && $e(w, a), K(w);
544
544
  }, [w, ...t || []]), ce(() => {
545
- P && we(w, {
545
+ C && we(w, {
546
546
  formElements: s,
547
- defaultState: l,
548
- localStorage: u,
547
+ defaultState: u,
548
+ localStorage: l,
549
549
  middleware: R.current?.middleware
550
550
  });
551
551
  const o = `${w}////${q.current}`, c = b(w, []), d = c?.components || /* @__PURE__ */ new Map();
@@ -579,30 +579,30 @@ function yt(e, {
579
579
  E
580
580
  ), [w, E]);
581
581
  }
582
- const mt = (e, n, u) => {
582
+ const mt = (e, n, l) => {
583
583
  let s = b(e, n)?.arrayKeys || [];
584
- const g = u?.transforms;
584
+ const g = l?.transforms;
585
585
  if (!g || g.length === 0)
586
586
  return s;
587
587
  for (const i of g)
588
588
  if (i.type === "filter") {
589
589
  const h = [];
590
- s.forEach((l, t) => {
591
- const a = x(e, [...n, l]);
592
- i.fn(a, t) && h.push(l);
590
+ s.forEach((u, t) => {
591
+ const a = x(e, [...n, u]);
592
+ i.fn(a, t) && h.push(u);
593
593
  }), s = h;
594
- } else i.type === "sort" && s.sort((h, l) => {
595
- const t = x(e, [...n, h]), a = x(e, [...n, l]);
594
+ } else i.type === "sort" && s.sort((h, u) => {
595
+ const t = x(e, [...n, h]), a = x(e, [...n, u]);
596
596
  return i.fn(t, a);
597
597
  });
598
598
  return s;
599
- }, pe = (e, n, u) => {
599
+ }, pe = (e, n, l) => {
600
600
  const s = `${e}////${n}`, i = b(e, [])?.components?.get(s);
601
- !i || i.reactiveType === "none" || !(Array.isArray(i.reactiveType) ? i.reactiveType : [i.reactiveType]).includes("component") || Je(e, u, s);
602
- }, oe = (e, n, u) => {
601
+ !i || i.reactiveType === "none" || !(Array.isArray(i.reactiveType) ? i.reactiveType : [i.reactiveType]).includes("component") || Je(e, l, s);
602
+ }, oe = (e, n, l) => {
603
603
  const s = b(e, []), g = /* @__PURE__ */ new Set();
604
- s?.components && s.components.forEach((h, l) => {
605
- (Array.isArray(h.reactiveType) ? h.reactiveType : [h.reactiveType || "component"]).includes("all") && (h.forceUpdate(), g.add(l));
604
+ s?.components && s.components.forEach((h, u) => {
605
+ (Array.isArray(h.reactiveType) ? h.reactiveType : [h.reactiveType || "component"]).includes("all") && (h.forceUpdate(), g.add(u));
606
606
  }), b(e, [
607
607
  ...n,
608
608
  "getSelected"
@@ -611,14 +611,14 @@ const mt = (e, n, u) => {
611
611
  });
612
612
  const i = b(e, n);
613
613
  for (let h of i?.arrayKeys || []) {
614
- const l = h + ".selected", t = b(e, l.split(".").slice(1));
615
- h == u && t?.pathComponents?.forEach((a) => {
614
+ const u = h + ".selected", t = b(e, u.split(".").slice(1));
615
+ h == l && t?.pathComponents?.forEach((a) => {
616
616
  s?.components?.get(a)?.forceUpdate();
617
617
  });
618
618
  }
619
619
  };
620
- function X(e, n, u) {
621
- const s = b(e, n), g = n.length > 0 ? n.join(".") : "root", i = u?.arrayViews?.[g];
620
+ function X(e, n, l) {
621
+ const s = b(e, n), g = n.length > 0 ? n.join(".") : "root", i = l?.arrayViews?.[g];
622
622
  if (Array.isArray(i) && i.length === 0)
623
623
  return {
624
624
  shadowMeta: s,
@@ -632,7 +632,7 @@ function X(e, n, u) {
632
632
  arrayKeys: s?.arrayKeys
633
633
  };
634
634
  }
635
- function De(e, n, u, s) {
635
+ function De(e, n, l, s) {
636
636
  const g = /* @__PURE__ */ new Map();
637
637
  function i({
638
638
  path: t = [],
@@ -642,7 +642,7 @@ function De(e, n, u, s) {
642
642
  const M = a ? JSON.stringify(a.arrayViews || a.transforms) : "", E = t.join(".") + ":" + S + ":" + M;
643
643
  if (g.has(E))
644
644
  return g.get(E);
645
- const P = [e, ...t].join("."), w = {
645
+ const C = [e, ...t].join("."), w = {
646
646
  get(R, y) {
647
647
  if (typeof y != "string")
648
648
  return Reflect.get(R, y);
@@ -751,10 +751,10 @@ function De(e, n, u, s) {
751
751
  endIndex: 10
752
752
  }), [A, $] = ee({}), D = F(!0);
753
753
  z(() => {
754
- const C = setInterval(() => {
754
+ const k = setInterval(() => {
755
755
  $({});
756
756
  }, 1e3);
757
- return () => clearInterval(C);
757
+ return () => clearInterval(k);
758
758
  }, []);
759
759
  const U = F({
760
760
  isUserScrolling: !1,
@@ -765,7 +765,7 @@ function De(e, n, u, s) {
765
765
  /* @__PURE__ */ new Map()
766
766
  ), { keys: I } = L(e, t, a);
767
767
  z(() => {
768
- const C = [e, ...t].join("."), V = T.getState().subscribeToPath(C, (j) => {
768
+ const k = [e, ...t].join("."), V = T.getState().subscribeToPath(k, (j) => {
769
769
  j.type !== "GET_SELECTED" && j.type;
770
770
  });
771
771
  return () => {
@@ -773,10 +773,10 @@ function De(e, n, u, s) {
773
773
  };
774
774
  }, [S, e, t.join(".")]), ce(() => {
775
775
  if (d && I.length > 0 && m.current && !U.current.isUserScrolling && D.current) {
776
- const C = m.current, V = () => {
777
- if (C.clientHeight > 0) {
776
+ const k = m.current, V = () => {
777
+ if (k.clientHeight > 0) {
778
778
  const j = Math.ceil(
779
- C.clientHeight / o
779
+ k.clientHeight / o
780
780
  ), B = I.length - 1, _ = Math.max(
781
781
  0,
782
782
  B - j - c
@@ -790,18 +790,18 @@ function De(e, n, u, s) {
790
790
  V();
791
791
  }
792
792
  }, [I.length, d, o, c]);
793
- const k = F(v);
793
+ const P = F(v);
794
794
  ce(() => {
795
- k.current = v;
795
+ P.current = v;
796
796
  }, [v]);
797
797
  const N = F(I);
798
798
  ce(() => {
799
799
  N.current = I;
800
800
  }, [I]);
801
801
  const ie = Te(() => {
802
- const C = m.current;
803
- if (!C) return;
804
- const V = C.scrollTop, { scrollHeight: j, clientHeight: B } = C, _ = U.current, re = j - (V + B), ye = _.isNearBottom;
802
+ const k = m.current;
803
+ if (!k) return;
804
+ const V = k.scrollTop, { scrollHeight: j, clientHeight: B } = k, _ = U.current, re = j - (V + B), ye = _.isNearBottom;
805
805
  _.isNearBottom = re <= f, V < _.lastScrollTop ? (_.scrollUpCount++, _.scrollUpCount > 3 && ye && (_.isUserScrolling = !0, console.log("User scrolled away from bottom"))) : _.isNearBottom && (_.isUserScrolling = !1, _.scrollUpCount = 0), _.lastScrollTop = V;
806
806
  let Y = 0;
807
807
  for (let H = 0; H < I.length; H++) {
@@ -834,16 +834,16 @@ function De(e, n, u, s) {
834
834
  f
835
835
  ]);
836
836
  z(() => {
837
- const C = m.current;
838
- if (C)
839
- return C.addEventListener("scroll", ie, {
837
+ const k = m.current;
838
+ if (k)
839
+ return k.addEventListener("scroll", ie, {
840
840
  passive: !0
841
841
  }), () => {
842
- C.removeEventListener("scroll", ie);
842
+ k.removeEventListener("scroll", ie);
843
843
  };
844
844
  }, [ie, d]);
845
845
  const Z = Te(
846
- (C = "smooth") => {
846
+ (k = "smooth") => {
847
847
  const V = m.current;
848
848
  if (!V) return;
849
849
  U.current.isUserScrolling = !1, U.current.isNearBottom = !0, U.current.scrollUpCount = 0;
@@ -853,7 +853,7 @@ function De(e, n, u, s) {
853
853
  const re = V.scrollHeight, ye = V.scrollTop, Y = V.clientHeight;
854
854
  ye + Y >= re - 1 || (V.scrollTo({
855
855
  top: re,
856
- behavior: C
856
+ behavior: k
857
857
  }), setTimeout(() => {
858
858
  const H = V.scrollHeight, me = V.scrollTop;
859
859
  (H !== re || me + Y < H - 1) && B(_ + 1);
@@ -869,7 +869,7 @@ function De(e, n, u, s) {
869
869
  );
870
870
  return z(() => {
871
871
  if (!d || !m.current) return;
872
- const C = m.current, V = U.current;
872
+ const k = m.current, V = U.current;
873
873
  let j;
874
874
  const B = () => {
875
875
  clearTimeout(j), j = setTimeout(() => {
@@ -880,7 +880,7 @@ function De(e, n, u, s) {
880
880
  }, _ = new MutationObserver(() => {
881
881
  V.isUserScrolling || B();
882
882
  });
883
- return _.observe(C, {
883
+ return _.observe(k, {
884
884
  childList: !0,
885
885
  subtree: !0,
886
886
  attributes: !0,
@@ -892,13 +892,13 @@ function De(e, n, u, s) {
892
892
  };
893
893
  }, [d, I.length, Z]), {
894
894
  virtualState: Me(() => {
895
- const C = Array.isArray(I) ? I.slice(v.startIndex, v.endIndex + 1) : [], V = t.length > 0 ? t.join(".") : "root";
895
+ const k = Array.isArray(I) ? I.slice(v.startIndex, v.endIndex + 1) : [], V = t.length > 0 ? t.join(".") : "root";
896
896
  return i({
897
897
  path: t,
898
898
  componentId: S,
899
899
  meta: {
900
900
  ...a,
901
- arrayViews: { [V]: C },
901
+ arrayViews: { [V]: k },
902
902
  serverStateIsUpStream: !0
903
903
  }
904
904
  });
@@ -924,9 +924,9 @@ function De(e, n, u, s) {
924
924
  }
925
925
  },
926
926
  scrollToBottom: Z,
927
- scrollToIndex: (C, V = "smooth") => {
928
- if (m.current && I[C]) {
929
- const j = O.current.get(I[C])?.offset || 0;
927
+ scrollToIndex: (k, V = "smooth") => {
928
+ if (m.current && I[k]) {
929
+ const j = O.current.get(I[k])?.offset || 0;
930
930
  m.current.scrollTo({ top: j, behavior: V });
931
931
  }
932
932
  }
@@ -1030,31 +1030,31 @@ function De(e, n, u, s) {
1030
1030
  onFlush: m
1031
1031
  } = r;
1032
1032
  let v = [], p = !1, A = null;
1033
- const $ = (k) => {
1033
+ const $ = (P) => {
1034
1034
  if (!p) {
1035
1035
  if (d === "sliding" && v.length >= o)
1036
1036
  v.shift();
1037
1037
  else if (d === "dropping" && v.length >= o)
1038
1038
  return;
1039
- v.push(k), v.length >= o && D();
1039
+ v.push(P), v.length >= o && D();
1040
1040
  }
1041
1041
  }, D = () => {
1042
1042
  if (v.length === 0) return;
1043
- const k = [...v];
1043
+ const P = [...v];
1044
1044
  if (v = [], f) {
1045
- const N = f(k);
1045
+ const N = f(P);
1046
1046
  N !== void 0 && (Array.isArray(N) ? N : [N]).forEach((Z) => {
1047
1047
  n(Z, t, {
1048
1048
  updateType: "insert"
1049
1049
  });
1050
1050
  });
1051
1051
  } else
1052
- k.forEach((N) => {
1052
+ P.forEach((N) => {
1053
1053
  n(N, t, {
1054
1054
  updateType: "insert"
1055
1055
  });
1056
1056
  });
1057
- m?.(k);
1057
+ m?.(P);
1058
1058
  };
1059
1059
  c > 0 && (A = setInterval(D, c));
1060
1060
  const U = ae(), O = b(e, t) || {}, I = O.streams || /* @__PURE__ */ new Map();
@@ -1062,8 +1062,8 @@ function De(e, n, u, s) {
1062
1062
  ...O,
1063
1063
  streams: I
1064
1064
  }), {
1065
- write: (k) => $(k),
1066
- writeMany: (k) => k.forEach($),
1065
+ write: (P) => $(P),
1066
+ writeMany: (P) => P.forEach($),
1067
1067
  flush: () => D(),
1068
1068
  pause: () => {
1069
1069
  p = !0;
@@ -1073,8 +1073,8 @@ function De(e, n, u, s) {
1073
1073
  },
1074
1074
  close: () => {
1075
1075
  D(), A && clearInterval(A);
1076
- const k = T.getState().getShadowMetadata(e, t);
1077
- k?.streams && k.streams.delete(U);
1076
+ const P = T.getState().getShadowMetadata(e, t);
1077
+ P?.streams && P.streams.delete(U);
1078
1078
  }
1079
1079
  };
1080
1080
  };
@@ -1092,19 +1092,19 @@ function De(e, n, u, s) {
1092
1092
  p
1093
1093
  );
1094
1094
  if (z(() => {
1095
- const U = T.getState().subscribeToPath(P, (O) => {
1095
+ const U = T.getState().subscribeToPath(C, (O) => {
1096
1096
  if (O.type === "GET_SELECTED")
1097
1097
  return;
1098
- const k = T.getState().getShadowMetadata(e, t)?.transformCaches;
1099
- if (k)
1100
- for (const N of k.keys())
1101
- N.startsWith(S) && k.delete(N);
1098
+ const P = T.getState().getShadowMetadata(e, t)?.transformCaches;
1099
+ if (P)
1100
+ for (const N of P.keys())
1101
+ N.startsWith(S) && P.delete(N);
1102
1102
  (O.type === "INSERT" || O.type === "INSERT_MANY" || O.type === "REMOVE" || O.type === "CLEAR_SELECTION" || O.type === "SERVER_STATE_UPDATE" && !a?.serverStateIsUpStream) && f({});
1103
1103
  });
1104
1104
  return () => {
1105
1105
  U();
1106
1106
  };
1107
- }, [S, P]), !Array.isArray(A))
1107
+ }, [S, C]), !Array.isArray(A))
1108
1108
  return null;
1109
1109
  const $ = i({
1110
1110
  path: t,
@@ -1115,13 +1115,13 @@ function De(e, n, u, s) {
1115
1115
  const I = v[O];
1116
1116
  if (!I)
1117
1117
  return null;
1118
- let k = c.current.get(I);
1119
- k || (k = ae(), c.current.set(I, k));
1118
+ let P = c.current.get(I);
1119
+ P || (P = ae(), c.current.set(I, P));
1120
1120
  const N = [...t, I];
1121
1121
  return Ee(Be, {
1122
1122
  key: I,
1123
1123
  stateKey: e,
1124
- itemComponentId: k,
1124
+ itemComponentId: P,
1125
1125
  itemPath: N,
1126
1126
  localIndex: O,
1127
1127
  arraySetter: $,
@@ -1550,10 +1550,10 @@ function De(e, n, u, s) {
1550
1550
  let S;
1551
1551
  a?.stateSource === "server" && a.baseServerState ? S = a.baseServerState : S = T.getState().initialStateGlobal[e], Ye(e), se(e, S), i({
1552
1552
  path: [],
1553
- componentId: u
1553
+ componentId: l
1554
1554
  });
1555
- const M = W(e), E = G(M?.localStorage?.key) ? M?.localStorage?.key(S) : M?.localStorage?.key, P = `${s}-${e}-${E}`;
1556
- return P && localStorage.removeItem(P), K(e), S;
1555
+ const M = W(e), E = G(M?.localStorage?.key) ? M?.localStorage?.key(S) : M?.localStorage?.key, C = `${s}-${e}-${E}`;
1556
+ return C && localStorage.removeItem(C), K(e), S;
1557
1557
  },
1558
1558
  $initializeAndMergeShadowState: (t) => {
1559
1559
  We(e, t), K(e);
@@ -1562,10 +1562,10 @@ function De(e, n, u, s) {
1562
1562
  const a = De(
1563
1563
  e,
1564
1564
  n,
1565
- u,
1565
+ l,
1566
1566
  s
1567
- ), S = T.getState().initialStateGlobal[e], M = W(e), E = G(M?.localStorage?.key) ? M?.localStorage?.key(S) : M?.localStorage?.key, P = `${s}-${e}-${E}`;
1568
- return localStorage.getItem(P) && localStorage.removeItem(P), _e(() => {
1567
+ ), S = T.getState().initialStateGlobal[e], M = W(e), E = G(M?.localStorage?.key) ? M?.localStorage?.key(S) : M?.localStorage?.key, C = `${s}-${e}-${E}`;
1568
+ return localStorage.getItem(C) && localStorage.removeItem(C), _e(() => {
1569
1569
  ke(e, t), se(e, t);
1570
1570
  const w = T.getState().getShadowMetadata(e, []);
1571
1571
  w && w?.components?.forEach((q) => {
@@ -1577,7 +1577,7 @@ function De(e, n, u, s) {
1577
1577
  }
1578
1578
  };
1579
1579
  return i({
1580
- componentId: u,
1580
+ componentId: l,
1581
1581
  path: []
1582
1582
  });
1583
1583
  }
@@ -1587,7 +1587,7 @@ function Ve(e) {
1587
1587
  function ht({
1588
1588
  proxy: e
1589
1589
  }) {
1590
- const n = F(null), u = F(null), s = F(!1), g = `${e._stateKey}-${e._path.join(".")}`, i = e._path.length > 0 ? e._path.join(".") : "root", h = e._meta?.arrayViews?.[i], l = x(e._stateKey, e._path, h);
1590
+ const n = F(null), l = F(null), s = F(!1), g = `${e._stateKey}-${e._path.join(".")}`, i = e._path.length > 0 ? e._path.join(".") : "root", h = e._meta?.arrayViews?.[i], u = x(e._stateKey, e._path, h);
1591
1591
  return z(() => {
1592
1592
  const t = n.current;
1593
1593
  if (!t || s.current) return;
@@ -1597,25 +1597,25 @@ function ht({
1597
1597
  return;
1598
1598
  }
1599
1599
  const S = t.parentElement, E = Array.from(S.childNodes).indexOf(t);
1600
- let P = S.getAttribute("data-parent-id");
1601
- P || (P = `parent-${crypto.randomUUID()}`, S.setAttribute("data-parent-id", P)), u.current = `instance-${crypto.randomUUID()}`;
1600
+ let C = S.getAttribute("data-parent-id");
1601
+ C || (C = `parent-${crypto.randomUUID()}`, S.setAttribute("data-parent-id", C)), l.current = `instance-${crypto.randomUUID()}`;
1602
1602
  const w = T.getState().getShadowMetadata(e._stateKey, e._path) || {}, q = w.signals || [];
1603
1603
  q.push({
1604
- instanceId: u.current,
1605
- parentId: P,
1604
+ instanceId: l.current,
1605
+ parentId: C,
1606
1606
  position: E,
1607
1607
  effect: e._effect
1608
1608
  }), T.getState().setShadowMetadata(e._stateKey, e._path, {
1609
1609
  ...w,
1610
1610
  signals: q
1611
1611
  });
1612
- let R = l;
1612
+ let R = u;
1613
1613
  if (e._effect)
1614
1614
  try {
1615
1615
  R = new Function(
1616
1616
  "state",
1617
1617
  `return (${e._effect})(state)`
1618
- )(l);
1618
+ )(u);
1619
1619
  } catch (te) {
1620
1620
  console.error("Error evaluating effect function:", te);
1621
1621
  }
@@ -1624,10 +1624,10 @@ function ht({
1624
1624
  t.replaceWith(y), s.current = !0;
1625
1625
  }, 0);
1626
1626
  return () => {
1627
- if (clearTimeout(a), u.current) {
1627
+ if (clearTimeout(a), l.current) {
1628
1628
  const S = T.getState().getShadowMetadata(e._stateKey, e._path) || {};
1629
1629
  S.signals && (S.signals = S.signals.filter(
1630
- (M) => M.instanceId !== u.current
1630
+ (M) => M.instanceId !== l.current
1631
1631
  ), T.getState().setShadowMetadata(e._stateKey, e._path, S));
1632
1632
  }
1633
1633
  };