@reformer/core 9.0.0-beta.1 → 9.0.0-beta.2

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.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { signal as y, computed as h, effect as _, batch as me, Signal as re } from "@preact/signals-core";
2
- import { i as B, d as ye, g as Q } from "./behaviors-O9a1Djj9.js";
3
- import { j as nt, c as at, k as ot, e as lt, m as ut, a as ct, b as ht, r as dt, f as ft, h as pt, s as vt, t as mt, w as yt } from "./behaviors-O9a1Djj9.js";
4
- import ne, { useRef as q, useCallback as E } from "react";
5
- import { default as bt } from "./validators.js";
6
- class D {
1
+ import { signal as y, computed as f, effect as _, batch as be, Signal as oe } from "@preact/signals-core";
2
+ import { F as N, E as O, i as G, g as X, d as _e } from "./behaviors-Br4Im38V.js";
3
+ import { j as ot, c as lt, k as ut, e as ct, m as ht, a as dt, b as ft, r as pt, f as vt, h as mt, s as yt, t as gt, u as bt, w as _t } from "./behaviors-Br4Im38V.js";
4
+ import le, { useRef as M, useCallback as E } from "react";
5
+ import { default as At } from "./validators.js";
6
+ class L {
7
7
  // ============================================================================
8
8
  // Protected состояние (для Template Method паттерна)
9
9
  // ============================================================================
@@ -29,33 +29,33 @@ class D {
29
29
  * Пользователь взаимодействовал с узлом (touched)
30
30
  * Computed из _touched для предоставления readonly интерфейса
31
31
  */
32
- touched = h(() => this._touched.value);
32
+ touched = f(() => this._touched.value);
33
33
  /**
34
34
  * Пользователь не взаимодействовал с узлом (untouched)
35
35
  */
36
- untouched = h(() => !this._touched.value);
36
+ untouched = f(() => !this._touched.value);
37
37
  /**
38
38
  * Значение узла было изменено (dirty)
39
39
  * Computed из _dirty для предоставления readonly интерфейса
40
40
  */
41
- dirty = h(() => this._dirty.value);
41
+ dirty = f(() => this._dirty.value);
42
42
  /**
43
43
  * Значение узла не было изменено (pristine)
44
44
  */
45
- pristine = h(() => !this._dirty.value);
45
+ pristine = f(() => !this._dirty.value);
46
46
  /**
47
47
  * Текущий статус узла
48
48
  * Computed из _status для предоставления readonly интерфейса
49
49
  */
50
- status = h(() => this._status.value);
50
+ status = f(() => this._status.value);
51
51
  /**
52
52
  * Узел отключен (disabled)
53
53
  */
54
- disabled = h(() => this._status.value === "disabled");
54
+ disabled = f(() => this._status.value === "disabled");
55
55
  /**
56
56
  * Узел включен (enabled)
57
57
  */
58
- enabled = h(() => this._status.value !== "disabled");
58
+ enabled = f(() => this._status.value !== "disabled");
59
59
  /**
60
60
  * Получить ошибки валидации с фильтрацией
61
61
  *
@@ -97,17 +97,17 @@ class D {
97
97
  */
98
98
  getErrors(e) {
99
99
  const t = this.errors.value;
100
- return e ? t.filter((s) => {
101
- if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(s.code) || e.message !== void 0 && !s.message.toLowerCase().includes(e.message.toLowerCase()))
100
+ return e ? t.filter((i) => {
101
+ if (e.code !== void 0 && !(Array.isArray(e.code) ? e.code : [e.code]).includes(i.code) || e.message !== void 0 && !i.message.toLowerCase().includes(e.message.toLowerCase()))
102
102
  return !1;
103
103
  if (e.params !== void 0) {
104
- if (!s.params)
104
+ if (!i.params)
105
105
  return !1;
106
106
  for (const [r, n] of Object.entries(e.params))
107
- if (s.params[r] !== n)
107
+ if (i.params[r] !== n)
108
108
  return !1;
109
109
  }
110
- return !(e.predicate !== void 0 && !e.predicate(s));
110
+ return !(e.predicate !== void 0 && !e.predicate(i));
111
111
  }) : t;
112
112
  }
113
113
  // ============================================================================
@@ -448,7 +448,7 @@ class K {
448
448
  this.clear();
449
449
  }
450
450
  }
451
- const k = {
451
+ const w = {
452
452
  /** FieldNode.watch() */
453
453
  Watch: "watch",
454
454
  /** FieldNode.computeFrom() */
@@ -462,105 +462,11 @@ const k = {
462
462
  /** ArrayNode.watchLength() */
463
463
  WatchLength: "watchLength"
464
464
  };
465
- let ge = 0;
466
- function V(i) {
467
- return `${i}-${++ge}`;
465
+ let Ee = 0;
466
+ function k(s) {
467
+ return `${s}-${++Ee}`;
468
468
  }
469
- var S = /* @__PURE__ */ ((i) => (i.THROW = "throw", i.LOG = "log", i.CONVERT = "convert", i))(S || {});
470
- class O {
471
- static handle(e, t, s = "throw") {
472
- const r = this.extractMessage(e);
473
- switch (s) {
474
- case "throw":
475
- throw e;
476
- case "log":
477
- return;
478
- case "convert":
479
- return {
480
- code: "validator_error",
481
- message: r,
482
- params: { field: t }
483
- };
484
- }
485
- }
486
- /**
487
- * Извлечь сообщение из ошибки
488
- *
489
- * Обрабатывает различные типы ошибок:
490
- * - Error объекты → error.message
491
- * - Строки → возвращает как есть
492
- * - Объекты с message → извлекает message
493
- * - Другое → String(error)
494
- *
495
- * @param error Ошибка для извлечения сообщения
496
- * @returns Сообщение ошибки
497
- * @private
498
- *
499
- * @example
500
- * ```typescript
501
- * FormErrorHandler.extractMessage(new Error('Test'));
502
- * // 'Test'
503
- *
504
- * FormErrorHandler.extractMessage('String error');
505
- * // 'String error'
506
- *
507
- * FormErrorHandler.extractMessage({ message: 'Object error' });
508
- * // 'Object error'
509
- *
510
- * FormErrorHandler.extractMessage(null);
511
- * // 'null'
512
- * ```
513
- */
514
- static extractMessage(e) {
515
- return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e !== null && "message" in e ? String(e.message) : String(e);
516
- }
517
- /**
518
- * Создать ValidationError с заданными параметрами
519
- *
520
- * Утилитная функция для создания ValidationError объектов
521
- *
522
- * @param code Код ошибки
523
- * @param message Сообщение ошибки
524
- * @param field Поле (опционально)
525
- * @returns ValidationError объект
526
- *
527
- * @example
528
- * ```typescript
529
- * const error = FormErrorHandler.createValidationError(
530
- * 'required',
531
- * 'This field is required',
532
- * 'email'
533
- * );
534
- * // { code: 'required', message: 'This field is required', field: 'email' }
535
- * ```
536
- */
537
- static createValidationError(e, t, s) {
538
- return {
539
- code: e,
540
- message: t,
541
- params: s ? { field: s } : void 0
542
- };
543
- }
544
- /**
545
- * Проверить, является ли объект ValidationError
546
- *
547
- * Type guard для ValidationError
548
- *
549
- * @param value Значение для проверки
550
- * @returns true если value является ValidationError
551
- *
552
- * @example
553
- * ```typescript
554
- * if (FormErrorHandler.isValidationError(result)) {
555
- * console.log(result.code); // OK, типобезопасно
556
- * }
557
- * ```
558
- */
559
- static isValidationError(e) {
560
- return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
561
- }
562
- }
563
- class be {
469
+ class Ae {
564
470
  /** Внутренний сигнал статуса */
565
471
  _status;
566
472
  /** Публичный read-only сигнал статуса */
@@ -577,7 +483,7 @@ class be {
577
483
  * @param initial - Начальный статус (по умолчанию 'valid')
578
484
  */
579
485
  constructor(e = "valid") {
580
- this._status = y(e), this.status = h(() => this._status.value), this.valid = h(() => this._status.value === "valid"), this.invalid = h(() => this._status.value === "invalid"), this.pending = h(() => this._status.value === "pending"), this.disabled = h(() => this._status.value === "disabled");
486
+ this._status = y(e), this.status = f(() => this._status.value), this.valid = f(() => this._status.value === "valid"), this.invalid = f(() => this._status.value === "invalid"), this.pending = f(() => this._status.value === "pending"), this.disabled = f(() => this._status.value === "disabled");
581
487
  }
582
488
  /**
583
489
  * Начать валидацию
@@ -705,7 +611,7 @@ class be {
705
611
  return this._status.value !== "disabled";
706
612
  }
707
613
  }
708
- class _e extends D {
614
+ class Se extends L {
709
615
  // ============================================================================
710
616
  // Приватные сигналы
711
617
  // ============================================================================
@@ -763,7 +669,7 @@ class _e extends D {
763
669
  // Конструктор
764
670
  // ============================================================================
765
671
  constructor(e) {
766
- super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? y(e.value), this.initialValue = this._value.peek(), this._errors = y([]), this._componentProps = y(e.componentProps || {}), this.statusMachine = new be(e.disabled ? "disabled" : "valid"), this.value = h(() => this._value.value), this.valid = h(() => this.statusMachine.valid.value), this.invalid = h(() => this.statusMachine.invalid.value), this.pending = h(() => this.statusMachine.pending.value), this.status = h(() => this.statusMachine.status.value), this.disabled = h(() => this.statusMachine.disabled.value), this.errors = h(() => this._errors.value), this.componentProps = h(() => this._componentProps.value), this.shouldShowError = h(
672
+ super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? y(e.value), this.initialValue = this._value.peek(), this._errors = y([]), this._componentProps = y(e.componentProps || {}), this.statusMachine = new Ae(e.disabled ? "disabled" : "valid"), this.value = f(() => this._value.value), this.valid = f(() => this.statusMachine.valid.value), this.invalid = f(() => this.statusMachine.invalid.value), this.pending = f(() => this.statusMachine.pending.value), this.status = f(() => this.statusMachine.status.value), this.disabled = f(() => this.statusMachine.disabled.value), this.errors = f(() => this._errors.value), this.componentProps = f(() => this._componentProps.value), this.shouldShowError = f(
767
673
  () => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
768
674
  );
769
675
  }
@@ -776,12 +682,12 @@ class _e extends D {
776
682
  setValue(e, t) {
777
683
  if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
778
684
  return;
779
- const s = this.validators.length > 0 || this.asyncValidators.length > 0, r = this._errors.value.length > 0;
685
+ const i = this.validators.length > 0 || this.asyncValidators.length > 0, r = this._errors.value.length > 0;
780
686
  if (this.updateOn === "change") {
781
687
  this.validate();
782
688
  return;
783
689
  }
784
- r && s && this.validate();
690
+ r && i && this.validate();
785
691
  }
786
692
  patchValue(e) {
787
693
  this.setValue(e);
@@ -874,17 +780,17 @@ class _e extends D {
874
780
  const t = e?.debounce ?? this.debounceMs;
875
781
  if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
876
782
  return this.validateImmediate();
877
- const s = new AbortController();
783
+ const i = new AbortController();
878
784
  return new Promise((r) => {
879
- this.pendingValidation = { resolve: r, abortController: s }, this.validateDebounceTimer = setTimeout(async () => {
880
- if (this.validateDebounceTimer = void 0, s.signal.aborted) {
785
+ this.pendingValidation = { resolve: r, abortController: i }, this.validateDebounceTimer = setTimeout(async () => {
786
+ if (this.validateDebounceTimer = void 0, i.signal.aborted) {
881
787
  r(!1);
882
788
  return;
883
789
  }
884
790
  this.pendingValidation = void 0;
885
- const n = await this.validateImmediate(s);
791
+ const n = await this.validateImmediate(i);
886
792
  r(n);
887
- }, t), s.signal.addEventListener(
793
+ }, t), i.signal.addEventListener(
888
794
  "abort",
889
795
  () => {
890
796
  this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), r(!1);
@@ -906,51 +812,51 @@ class _e extends D {
906
812
  async validateImmediate(e) {
907
813
  const t = e ?? new AbortController();
908
814
  e || this.currentAbortController?.abort(), this.currentAbortController = t;
909
- const { signal: s } = t, r = [];
815
+ const { signal: i } = t, r = [];
910
816
  for (const a of this.validators) {
911
- const o = a(this._value.value);
912
- o && r.push(o);
817
+ const l = a(this._value.value);
818
+ l && r.push(l);
913
819
  }
914
- if (s.aborted)
820
+ if (i.aborted)
915
821
  return !1;
916
822
  if (r.length > 0) {
917
823
  this._errors.value = r;
918
- const a = r.some((o) => o.severity !== "warning");
824
+ const a = r.some((l) => l.severity !== "warning");
919
825
  if (this.statusMachine.setErrors(a), a)
920
826
  return !1;
921
827
  }
922
828
  if (this.asyncValidators.length > 0) {
923
- if (s.aborted)
829
+ if (i.aborted)
924
830
  return !1;
925
831
  this.statusMachine.startValidation();
926
832
  try {
927
833
  const a = await Promise.all(
928
- this.asyncValidators.map(async (l) => {
929
- if (s.aborted)
834
+ this.asyncValidators.map(async (c) => {
835
+ if (i.aborted)
930
836
  throw new DOMException("Validation aborted", "AbortError");
931
837
  try {
932
- const u = await l(this._value.value, { signal: s });
933
- if (s.aborted)
838
+ const u = await c(this._value.value, { signal: i });
839
+ if (i.aborted)
934
840
  throw new DOMException("Validation aborted", "AbortError");
935
841
  return u;
936
842
  } catch (u) {
937
843
  if (u instanceof DOMException && u.name === "AbortError")
938
844
  throw u;
939
- return O.handle(
845
+ return N.handle(
940
846
  u,
941
847
  "FieldNode AsyncValidator",
942
- S.CONVERT
848
+ O.CONVERT
943
849
  );
944
850
  }
945
851
  })
946
852
  );
947
- if (s.aborted)
853
+ if (i.aborted)
948
854
  return !1;
949
- const o = a.filter((l) => l !== null);
950
- if (o.length > 0) {
951
- this._errors.value = o;
952
- const l = o.some((u) => u.severity !== "warning");
953
- if (this.statusMachine.completeValidation(l), l)
855
+ const l = a.filter((c) => c !== null);
856
+ if (l.length > 0) {
857
+ this._errors.value = l;
858
+ const c = l.some((u) => u.severity !== "warning");
859
+ if (this.statusMachine.completeValidation(c), c)
954
860
  return !1;
955
861
  }
956
862
  } catch (a) {
@@ -959,11 +865,11 @@ class _e extends D {
959
865
  throw a;
960
866
  }
961
867
  }
962
- return s.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((a) => a.severity !== "warning"));
868
+ return i.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((a) => a.severity !== "warning"));
963
869
  }
964
870
  setErrors(e) {
965
871
  this._errors.value = e;
966
- const t = e.some((s) => s.severity !== "warning");
872
+ const t = e.some((i) => i.severity !== "warning");
967
873
  this.statusMachine.setErrors(t);
968
874
  }
969
875
  clearErrors() {
@@ -1080,12 +986,12 @@ class _e extends D {
1080
986
  * ```
1081
987
  */
1082
988
  watch(e) {
1083
- const t = new AbortController(), s = _(() => {
989
+ const t = new AbortController(), i = _(() => {
1084
990
  const n = this.value.value;
1085
991
  e(n, t.signal);
1086
- }), r = V(k.Watch);
992
+ }), r = k(w.Watch);
1087
993
  return this.disposers.add(r, () => {
1088
- t.abort(), s();
994
+ t.abort(), i();
1089
995
  });
1090
996
  }
1091
997
  /**
@@ -1111,11 +1017,11 @@ class _e extends D {
1111
1017
  * ```
1112
1018
  */
1113
1019
  computeFrom(e, t) {
1114
- const s = _(() => {
1115
- const n = e.map((o) => o.value), a = t(...n);
1020
+ const i = _(() => {
1021
+ const n = e.map((l) => l.value), a = t(...n);
1116
1022
  this.setValue(a, { emitEvent: !1 });
1117
- }), r = V(k.ComputeFrom);
1118
- return this.disposers.add(r, s);
1023
+ }), r = k(w.ComputeFrom);
1024
+ return this.disposers.add(r, i);
1119
1025
  }
1120
1026
  /**
1121
1027
  * Очистить все ресурсы и таймеры
@@ -1145,46 +1051,59 @@ class _e extends D {
1145
1051
  }
1146
1052
  }
1147
1053
  }
1148
- function H(i) {
1149
- const { getChildren: e, ownErrors: t, disabled: s } = i, r = h(() => t.value.length > 0 ? !1 : e().every((c) => c.disabled.value || c.valid.value)), n = h(() => !r.value), a = h(() => e().some((c) => c.pending.value)), o = h(() => e().some((c) => c.touched.value)), l = h(() => e().some((c) => c.dirty.value)), u = h(() => {
1150
- const c = [...t.value];
1151
- for (const f of e())
1152
- c.push(...f.errors.value);
1153
- return c;
1154
- }), m = h(() => s?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
1054
+ function H(s) {
1055
+ const { getChildren: e, ownErrors: t, disabled: i } = s, r = f(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = f(() => !r.value), a = f(() => e().some((o) => o.pending.value)), l = f(() => e().some((o) => o.touched.value)), c = f(() => e().some((o) => o.dirty.value)), u = f(() => {
1056
+ const o = [...t.value];
1057
+ for (const v of e())
1058
+ o.push(...v.errors.value);
1059
+ return o;
1060
+ }), d = f(() => i?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
1155
1061
  return {
1156
1062
  valid: r,
1157
1063
  invalid: n,
1158
1064
  pending: a,
1159
- touched: o,
1160
- dirty: l,
1065
+ touched: l,
1066
+ dirty: c,
1161
1067
  errors: u,
1162
- status: m
1068
+ status: d
1163
1069
  };
1164
1070
  }
1165
- function Ee(i) {
1166
- return typeof i == "object" && i !== null && "getProxy" in i && typeof i.getProxy == "function";
1071
+ function Z(s) {
1072
+ return typeof s == "object" && s !== null && "getProxy" in s && typeof s.getProxy == "function";
1167
1073
  }
1168
- function Ae(i, e) {
1169
- return new Proxy(i, {
1170
- get: (t, s) => {
1171
- if (s in t)
1172
- return t[s];
1173
- if (typeof s == "string" && e.has(s)) {
1174
- const r = e.get(s);
1175
- return r && Ee(r) ? r.getProxy() : r;
1074
+ const ee = "$";
1075
+ function we(s, e) {
1076
+ let t;
1077
+ const i = () => {
1078
+ if (!t) {
1079
+ const r = {};
1080
+ e.forEach((n, a) => {
1081
+ r[a] = n && Z(n) ? n.getProxy() : n;
1082
+ }), t = r;
1083
+ }
1084
+ return t;
1085
+ };
1086
+ return new Proxy(s, {
1087
+ get: (r, n) => {
1088
+ if (n === ee)
1089
+ return i();
1090
+ if (n in r)
1091
+ return r[n];
1092
+ if (typeof n == "string" && e.has(n)) {
1093
+ const a = e.get(n);
1094
+ return a && Z(a) ? a.getProxy() : a;
1176
1095
  }
1177
1096
  },
1178
- set: (t, s, r) => typeof s == "string" && e.has(s) ? !1 : (t[s] = r, !0),
1179
- has: (t, s) => typeof s == "string" && e.has(s) ? !0 : s in t,
1180
- ownKeys: (t) => {
1181
- const s = Reflect.ownKeys(t), r = Array.from(e.keys());
1182
- return [.../* @__PURE__ */ new Set([...s, ...r])];
1097
+ set: (r, n, a) => typeof n == "string" && e.has(n) ? !1 : (r[n] = a, !0),
1098
+ has: (r, n) => n === ee || typeof n == "string" && e.has(n) ? !0 : n in r,
1099
+ ownKeys: (r) => {
1100
+ const n = Reflect.ownKeys(r), a = Array.from(e.keys());
1101
+ return [.../* @__PURE__ */ new Set([...n, ...a])];
1183
1102
  },
1184
- getOwnPropertyDescriptor: (t, s) => typeof s == "string" && e.has(s) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(t, s)
1103
+ getOwnPropertyDescriptor: (r, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(r, n)
1185
1104
  });
1186
1105
  }
1187
- class we {
1106
+ class ke {
1188
1107
  /**
1189
1108
  * @param form - Форма для отправки
1190
1109
  */
@@ -1194,7 +1113,7 @@ class we {
1194
1113
  /** Внутренний сигнал состояния отправки */
1195
1114
  _submitting = y(!1);
1196
1115
  /** Публичный read-only сигнал состояния отправки */
1197
- submitting = h(() => this._submitting.value);
1116
+ submitting = f(() => this._submitting.value);
1198
1117
  /**
1199
1118
  * Отправить форму
1200
1119
  *
@@ -1206,7 +1125,12 @@ class we {
1206
1125
  *
1207
1126
  * @param onSubmit - Callback для отправки данных
1208
1127
  * @param options - Опции submit
1209
- * @returns Результат от onSubmit или null если валидация не пройдена
1128
+ * @returns Результат от onSubmit или `null` если валидация не пройдена
1129
+ *
1130
+ * @remarks
1131
+ * Возвращаемый `null` неоднозначен: он сигналит и провал валидации, и легитимный `null`,
1132
+ * который вернул `onSubmit` (или void-обработчик). Чтобы различать эти случаи, используйте
1133
+ * {@link submitWithResult} — он отдаёт явный флаг `success`.
1210
1134
  *
1211
1135
  * @example
1212
1136
  * ```typescript
@@ -1224,8 +1148,8 @@ class we {
1224
1148
  * ```
1225
1149
  */
1226
1150
  async submit(e, t) {
1227
- const { skipValidation: s = !1, skipTouch: r = !1 } = t || {};
1228
- if (r || this.form.markAsTouched(), !s && !await this.form.validate())
1151
+ const { skipValidation: i = !1, skipTouch: r = !1 } = t || {};
1152
+ if (r || this.form.markAsTouched(), !i && !await this.form.validate())
1229
1153
  return null;
1230
1154
  this._submitting.value = !0;
1231
1155
  try {
@@ -1259,8 +1183,8 @@ class we {
1259
1183
  * ```
1260
1184
  */
1261
1185
  async submitWithResult(e, t) {
1262
- const { skipValidation: s = !1, skipTouch: r = !1 } = t || {};
1263
- if (r || this.form.markAsTouched(), !s && !await this.form.validate())
1186
+ const { skipValidation: i = !1, skipTouch: r = !1 } = t || {};
1187
+ if (r || this.form.markAsTouched(), !i && !await this.form.validate())
1264
1188
  return { success: !1, data: null };
1265
1189
  this._submitting.value = !0;
1266
1190
  try {
@@ -1282,16 +1206,16 @@ class we {
1282
1206
  return this._submitting.value;
1283
1207
  }
1284
1208
  }
1285
- function Se(i) {
1209
+ function Ve(s) {
1286
1210
  const e = [];
1287
- for (const t of i.split(".")) {
1288
- const s = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
1289
- if (!s) return [];
1290
- e.push(s[2] !== void 0 ? { key: s[1], index: Number(s[2]) } : { key: s[1] });
1211
+ for (const t of s.split(".")) {
1212
+ const i = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
1213
+ if (!i) return [];
1214
+ e.push(i[2] !== void 0 ? { key: i[1], index: Number(i[2]) } : { key: i[1] });
1291
1215
  }
1292
1216
  return e;
1293
1217
  }
1294
- let x = class ae extends D {
1218
+ let P = class ue extends L {
1295
1219
  // ============================================================================
1296
1220
  // Приватные поля
1297
1221
  // ============================================================================
@@ -1316,7 +1240,7 @@ let x = class ae extends D {
1316
1240
  /**
1317
1241
  * Фабрика для создания узлов формы
1318
1242
  */
1319
- nodeFactory = new ke();
1243
+ nodeFactory = new Ne();
1320
1244
  // ============================================================================
1321
1245
  // Приватные сигналы состояния (inline из StateManager)
1322
1246
  // ============================================================================
@@ -1327,6 +1251,19 @@ let x = class ae extends D {
1327
1251
  _disabled = y(!1);
1328
1252
  /** Form-level validation errors */
1329
1253
  _formErrors = y([]);
1254
+ /**
1255
+ * M1: валидация уровня модели/схемы (`validateFormModel(model, schema)`). Привязывается
1256
+ * `createForm({ model, schema })`, т.к. под M1 валидаторы срезаны с FieldNode и живут на слое
1257
+ * модели. Без неё `validate()`/`submit()` пропускали бы все schema-валидаторы. @internal
1258
+ */
1259
+ _modelValidate;
1260
+ /**
1261
+ * M1: связь листовой ноды-ребёнка → её сигнал модели (тот, что помечает `markDerived`).
1262
+ * Нужна bulk-сеттерам (`setValue`/`patchValue`), чтобы корректно определять derived-поля:
1263
+ * `field.value` — computed-обёртка, отличная от записываемого сигнала модели. @internal
1264
+ */
1265
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1266
+ _fieldSignals = /* @__PURE__ */ new WeakMap();
1330
1267
  // ============================================================================
1331
1268
  // Публичные computed signals
1332
1269
  // ============================================================================
@@ -1340,24 +1277,24 @@ let x = class ae extends D {
1340
1277
  status;
1341
1278
  submitting;
1342
1279
  constructor(e) {
1343
- super(), this.formSubmitter = new we(this);
1344
- const s = "form" in e ? e.form : e;
1345
- for (const [n, a] of Object.entries(s)) {
1346
- const o = this.createNode(a);
1347
- this._fields.set(n, o);
1280
+ super(), this.formSubmitter = new ke(this);
1281
+ const t = e.form, i = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !i ? e.form : e;
1282
+ for (const [l, c] of Object.entries(n)) {
1283
+ const u = this.createNode(c);
1284
+ this._fields.set(l, u);
1348
1285
  }
1349
- this.value = h(() => {
1350
- const n = {};
1351
- return this._fields.forEach((a, o) => {
1352
- n[o] = a.value.value;
1353
- }), n;
1286
+ this.value = f(() => {
1287
+ const l = {};
1288
+ return this._fields.forEach((c, u) => {
1289
+ l[u] = c.value.value;
1290
+ }), l;
1354
1291
  });
1355
- const r = H({
1292
+ const a = H({
1356
1293
  getChildren: () => Array.from(this._fields.values()),
1357
1294
  ownErrors: this._formErrors,
1358
1295
  disabled: this._disabled
1359
1296
  });
1360
- this.valid = r.valid, this.invalid = r.invalid, this.pending = r.pending, this.touched = r.touched, this.dirty = r.dirty, this.errors = r.errors, this.status = r.status, this.submitting = this.formSubmitter.submitting;
1297
+ this.valid = a.valid, this.invalid = a.invalid, this.pending = a.pending, this.touched = a.touched, this.dirty = a.dirty, this.errors = a.errors, this.status = a.status, this.submitting = this.formSubmitter.submitting;
1361
1298
  }
1362
1299
  // ============================================================================
1363
1300
  // Приватный метод для создания Proxy
@@ -1367,33 +1304,35 @@ let x = class ae extends D {
1367
1304
  * @see buildFormProxy
1368
1305
  */
1369
1306
  buildProxy() {
1370
- return Ae(this, this._fields);
1307
+ return we(this, this._fields);
1371
1308
  }
1372
1309
  // ============================================================================
1373
1310
  // Реализация абстрактных методов FormNode
1374
1311
  // ============================================================================
1375
1312
  getValue() {
1376
1313
  const e = {};
1377
- return this._fields.forEach((t, s) => {
1378
- e[s] = t.getValue();
1314
+ return this._fields.forEach((t, i) => {
1315
+ e[i] = t.getValue();
1379
1316
  }), e;
1380
1317
  }
1381
1318
  setValue(e, t) {
1382
- for (const [s, r] of Object.entries(e)) {
1383
- const n = this._fields.get(s);
1319
+ for (const [i, r] of Object.entries(e)) {
1320
+ const n = this._fields.get(i);
1384
1321
  if (n) {
1385
- if (B(n.value)) continue;
1322
+ const a = this._fieldSignals.get(n) ?? n.value;
1323
+ if (G(a)) continue;
1386
1324
  n.setValue(r, t);
1387
1325
  }
1388
1326
  }
1389
1327
  }
1390
1328
  patchValue(e) {
1391
- me(() => {
1392
- for (const [t, s] of Object.entries(e)) {
1329
+ be(() => {
1330
+ for (const [t, i] of Object.entries(e)) {
1393
1331
  const r = this._fields.get(t);
1394
- if (r && s !== void 0) {
1395
- if (B(r.value)) continue;
1396
- r.setValue(s, { emitEvent: !1 });
1332
+ if (r && i !== void 0) {
1333
+ const n = this._fieldSignals.get(r) ?? r.value;
1334
+ if (G(n)) continue;
1335
+ r.setValue(i, { emitEvent: !1 });
1397
1336
  }
1398
1337
  }
1399
1338
  });
@@ -1416,8 +1355,8 @@ let x = class ae extends D {
1416
1355
  * ```
1417
1356
  */
1418
1357
  reset(e) {
1419
- this._fields.forEach((t, s) => {
1420
- const r = e?.[s];
1358
+ this._formErrors.value = [], this._fields.forEach((t, i) => {
1359
+ const r = e?.[i];
1421
1360
  t.reset(r);
1422
1361
  });
1423
1362
  }
@@ -1425,14 +1364,16 @@ let x = class ae extends D {
1425
1364
  * Сбросить форму к исходным значениям (initialValues)
1426
1365
  */
1427
1366
  resetToInitial() {
1428
- this._fields.forEach((e) => {
1367
+ this._formErrors.value = [], this._fields.forEach((e) => {
1429
1368
  "resetToInitial" in e && typeof e.resetToInitial == "function" ? e.resetToInitial() : e.reset();
1430
1369
  });
1431
1370
  }
1432
1371
  async validate() {
1433
- return this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((e) => e.validate())), Array.from(this._fields.values()).every(
1434
- (e) => e.valid.value || e.disabled.value
1372
+ this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((i) => i.validate()));
1373
+ const e = this._modelValidate ? await this._modelValidate() : !0, t = Array.from(this._fields.values()).every(
1374
+ (i) => i.valid.value || i.disabled.value
1435
1375
  );
1376
+ return e && t;
1436
1377
  }
1437
1378
  /**
1438
1379
  * Установить form-level validation errors
@@ -1514,7 +1455,12 @@ let x = class ae extends D {
1514
1455
  *
1515
1456
  * @param onSubmit - Callback для отправки данных
1516
1457
  * @param options - Опции submit (skipValidation, skipTouch)
1517
- * @returns Результат от onSubmit или null если валидация не пройдена
1458
+ * @returns Результат от onSubmit или `null` если валидация не пройдена
1459
+ *
1460
+ * @remarks
1461
+ * `null` перегружен: он означает и «валидация не пройдена», и легитимный `null`-результат
1462
+ * `onSubmit` (или void-обработчик). Если вызывающей стороне нужно различать эти случаи —
1463
+ * используйте {@link submitWithResult}, который возвращает явный флаг `success`.
1518
1464
  */
1519
1465
  async submit(e, t) {
1520
1466
  return this.formSubmitter.submit(e, t);
@@ -1561,21 +1507,21 @@ let x = class ae extends D {
1561
1507
  getFieldByPath(e) {
1562
1508
  if (e.startsWith(".") || e.endsWith("."))
1563
1509
  return;
1564
- const t = Se(e);
1510
+ const t = Ve(e);
1565
1511
  if (t.length === 0)
1566
1512
  return;
1567
- let s = this;
1513
+ let i = this;
1568
1514
  for (const r of t) {
1569
- if (!(s instanceof ae) || (s = s.getField(r.key), !s)) return;
1515
+ if (!(i instanceof ue) || (i = i.getField(r.key), !i)) return;
1570
1516
  if (r.index !== void 0)
1571
- if ("at" in s && "length" in s && typeof s.at == "function") {
1572
- const n = s.at(r.index);
1517
+ if ("at" in i && "length" in i && typeof i.at == "function") {
1518
+ const n = i.at(r.index);
1573
1519
  if (!n) return;
1574
- s = n;
1520
+ i = n;
1575
1521
  } else
1576
1522
  return;
1577
1523
  }
1578
- return s;
1524
+ return i;
1579
1525
  }
1580
1526
  // ============================================================================
1581
1527
  // Private методы для создания узлов
@@ -1604,17 +1550,17 @@ let x = class ae extends D {
1604
1550
  /**
1605
1551
  * Связывает два поля: при изменении source автоматически обновляется target
1606
1552
  */
1607
- linkFields(e, t, s) {
1553
+ linkFields(e, t, i) {
1608
1554
  const r = this._fields.get(e), n = this._fields.get(t);
1609
1555
  if (!r || !n) {
1610
- const l = r ? t : e;
1611
- throw new Error(`GroupNode.linkFields: field "${String(l)}" not found`);
1556
+ const c = r ? t : e;
1557
+ throw new Error(`GroupNode.linkFields: field "${String(c)}" not found`);
1612
1558
  }
1613
1559
  const a = _(() => {
1614
- const l = r.value.value, u = s ? s(l) : l;
1560
+ const c = r.value.value, u = i ? i(c) : c;
1615
1561
  n.setValue(u, { emitEvent: !1 });
1616
- }), o = V(k.LinkFields);
1617
- return this.disposers.add(o, a);
1562
+ }), l = k(w.LinkFields);
1563
+ return this.disposers.add(l, a);
1618
1564
  }
1619
1565
  /**
1620
1566
  * Подписка на изменения вложенного поля по строковому пути
@@ -1645,12 +1591,12 @@ let x = class ae extends D {
1645
1591
  */
1646
1592
  /** Подписка на top-level поле — value типизирован как `T[K]`. */
1647
1593
  watchField(e, t) {
1648
- const s = this.getFieldByPath(e);
1649
- if (!s)
1594
+ const i = this.getFieldByPath(e);
1595
+ if (!i)
1650
1596
  throw new Error(`GroupNode.watchField: field "${e}" not found`);
1651
1597
  const r = _(() => {
1652
- t(s.value.value);
1653
- }), n = V(k.WatchField);
1598
+ t(i.value.value);
1599
+ }), n = k(w.WatchField);
1654
1600
  return this.disposers.add(n, r);
1655
1601
  }
1656
1602
  /**
@@ -1658,12 +1604,12 @@ let x = class ae extends D {
1658
1604
  * Путь нельзя выразить в типах узла → value честно `unknown`, потребитель сужает.
1659
1605
  */
1660
1606
  watchFieldByPath(e, t) {
1661
- const s = this.getFieldByPath(e);
1662
- if (!s)
1607
+ const i = this.getFieldByPath(e);
1608
+ if (!i)
1663
1609
  throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
1664
1610
  const r = _(() => {
1665
- t(s.value.value);
1666
- }), n = V(k.WatchField);
1611
+ t(i.value.value);
1612
+ }), n = k(w.WatchField);
1667
1613
  return this.disposers.add(n, r);
1668
1614
  }
1669
1615
  /**
@@ -1685,6 +1631,24 @@ let x = class ae extends D {
1685
1631
  attachBehaviorCleanup(e) {
1686
1632
  this._behaviorCleanup = e;
1687
1633
  }
1634
+ /**
1635
+ * Прикрепить валидацию уровня модели/схемы (M1). Вызывается `createForm({ model, schema })`,
1636
+ * чтобы `validate()`/`submit()` прогоняли schema-валидаторы (`validateFormModel`), а не только
1637
+ * пустые FieldNode. Возвращаемый флаг — валидна ли модель по схеме.
1638
+ * @internal
1639
+ */
1640
+ attachModelValidator(e) {
1641
+ this._modelValidate = e;
1642
+ }
1643
+ /**
1644
+ * Связать листовую ноду-ребёнка с её сигналом модели (M1). Вызывается `createForm` для каждого
1645
+ * листового поля на его владеющей группе — используется bulk-сеттерами для derived-guard (F9).
1646
+ * @internal
1647
+ */
1648
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1649
+ registerFieldSignal(e, t) {
1650
+ this._fieldSignals.set(e, t);
1651
+ }
1688
1652
  /**
1689
1653
  * Очистить все ресурсы узла
1690
1654
  */
@@ -1693,7 +1657,7 @@ let x = class ae extends D {
1693
1657
  "dispose" in e && typeof e.dispose == "function" && e.dispose();
1694
1658
  });
1695
1659
  }
1696
- }, X = class extends D {
1660
+ }, te = class extends L {
1697
1661
  // ============================================================================
1698
1662
  // Приватные поля
1699
1663
  // ============================================================================
@@ -1731,12 +1695,12 @@ let x = class ae extends D {
1731
1695
  super(), this.itemSchema = e, this.initialItems = t, this.items = y([]);
1732
1696
  for (const r of t)
1733
1697
  this.push(r);
1734
- this.length = h(() => this.items.value.length), this.value = h(() => this.items.value.map((r) => r.value.value));
1735
- const s = H({
1698
+ this.length = f(() => this.items.value.length), this.value = f(() => this.items.value.map((r) => r.value.value));
1699
+ const i = H({
1736
1700
  getChildren: () => this.items.value,
1737
1701
  ownErrors: this._arrayErrors
1738
1702
  });
1739
- this.valid = s.valid, this.invalid = s.invalid, this.pending = s.pending, this.touched = s.touched, this.dirty = s.dirty, this.errors = s.errors, this.status = s.status;
1703
+ this.valid = i.valid, this.invalid = i.invalid, this.pending = i.pending, this.touched = i.touched, this.dirty = i.dirty, this.errors = i.errors, this.status = i.status;
1740
1704
  }
1741
1705
  // ============================================================================
1742
1706
  // CRUD операции
@@ -1758,17 +1722,17 @@ let x = class ae extends D {
1758
1722
  */
1759
1723
  removeAt(e) {
1760
1724
  if (e < 0 || e >= this.items.value.length) {
1761
- O.handle(
1725
+ N.handle(
1762
1726
  new Error(
1763
1727
  `ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
1764
1728
  ),
1765
1729
  "ArrayNode.removeAt",
1766
- S.LOG
1730
+ O.LOG
1767
1731
  );
1768
1732
  return;
1769
1733
  }
1770
1734
  const t = this.items.value[e];
1771
- this.items.value = this.items.value.filter((s, r) => r !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
1735
+ this.items.value = this.items.value.filter((i, r) => r !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
1772
1736
  }
1773
1737
  /**
1774
1738
  * Вставить элемент в массив
@@ -1777,17 +1741,17 @@ let x = class ae extends D {
1777
1741
  */
1778
1742
  insert(e, t) {
1779
1743
  if (e < 0 || e > this.items.value.length) {
1780
- O.handle(
1744
+ N.handle(
1781
1745
  new Error(
1782
1746
  `ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
1783
1747
  ),
1784
1748
  "ArrayNode.insert",
1785
- S.LOG
1749
+ O.LOG
1786
1750
  );
1787
1751
  return;
1788
1752
  }
1789
- const s = this.createItem(t), r = [...this.items.value];
1790
- r.splice(e, 0, s), this.items.value = r;
1753
+ const i = this.createItem(t), r = [...this.items.value];
1754
+ r.splice(e, 0, i), this.items.value = r;
1791
1755
  }
1792
1756
  /**
1793
1757
  * Переместить элемент массива с позиции `from` на позицию `to`
@@ -1806,12 +1770,12 @@ let x = class ae extends D {
1806
1770
  * ```
1807
1771
  */
1808
1772
  move(e, t) {
1809
- const s = this.items.value.length;
1810
- if (e < 0 || e >= s || t < 0 || t >= s) {
1811
- O.handle(
1812
- new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${s})`),
1773
+ const i = this.items.value.length;
1774
+ if (e < 0 || e >= i || t < 0 || t >= i) {
1775
+ N.handle(
1776
+ new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${i})`),
1813
1777
  "ArrayNode.move",
1814
- S.LOG
1778
+ O.LOG
1815
1779
  );
1816
1780
  return;
1817
1781
  }
@@ -1834,12 +1798,12 @@ let x = class ae extends D {
1834
1798
  * ```
1835
1799
  */
1836
1800
  swap(e, t) {
1837
- const s = this.items.value.length;
1838
- if (e < 0 || e >= s || t < 0 || t >= s) {
1839
- O.handle(
1840
- new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${s})`),
1801
+ const i = this.items.value.length;
1802
+ if (e < 0 || e >= i || t < 0 || t >= i) {
1803
+ N.handle(
1804
+ new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${i})`),
1841
1805
  "ArrayNode.swap",
1842
- S.LOG
1806
+ O.LOG
1843
1807
  );
1844
1808
  return;
1845
1809
  }
@@ -1876,13 +1840,13 @@ let x = class ae extends D {
1876
1840
  return this.items.value.map((e) => e.getValue());
1877
1841
  }
1878
1842
  setValue(e, t) {
1879
- this.clear(), e.forEach((s) => this.push(s)), t?.emitEvent !== !1 && this.validate().catch((s) => {
1880
- O.handle(s, "ArrayNode.setValue", S.LOG);
1843
+ this.clear(), e.forEach((i) => this.push(i)), t?.emitEvent !== !1 && this.validate().catch((i) => {
1844
+ N.handle(i, "ArrayNode.setValue", O.LOG);
1881
1845
  });
1882
1846
  }
1883
1847
  patchValue(e) {
1884
- e.forEach((t, s) => {
1885
- this.items.value[s] && t !== void 0 && this.items.value[s].patchValue(t);
1848
+ e.forEach((t, i) => {
1849
+ this.items.value[i] && t !== void 0 && this.items.value[i].patchValue(t);
1886
1850
  });
1887
1851
  }
1888
1852
  /**
@@ -1937,7 +1901,7 @@ let x = class ae extends D {
1937
1901
  this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
1938
1902
  }
1939
1903
  async validate() {
1940
- return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean);
1904
+ return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean) && this._arrayErrors.value.length === 0;
1941
1905
  }
1942
1906
  /**
1943
1907
  * Установить array-level validation errors
@@ -2010,9 +1974,9 @@ let x = class ae extends D {
2010
1974
  * @param callback - Функция, вызываемая для каждого элемента с типизированным GroupNode proxy
2011
1975
  */
2012
1976
  forEach(e) {
2013
- this.items.value.forEach((t, s) => {
1977
+ this.items.value.forEach((t, i) => {
2014
1978
  const r = t.getProxy();
2015
- e(r, s);
1979
+ e(r, i);
2016
1980
  });
2017
1981
  }
2018
1982
  /**
@@ -2021,9 +1985,9 @@ let x = class ae extends D {
2021
1985
  * @returns Новый массив результатов
2022
1986
  */
2023
1987
  map(e) {
2024
- return this.items.value.map((t, s) => {
1988
+ return this.items.value.map((t, i) => {
2025
1989
  const r = t.getProxy();
2026
- return e(r, s);
1990
+ return e(r, i);
2027
1991
  });
2028
1992
  }
2029
1993
  // ============================================================================
@@ -2035,7 +1999,7 @@ let x = class ae extends D {
2035
1999
  */
2036
2000
  createItem(e) {
2037
2001
  if (this.isGroupSchema(this.itemSchema)) {
2038
- const t = new x(this.itemSchema);
2002
+ const t = new P(this.itemSchema);
2039
2003
  return e && t.patchValue(e), this.validationSchemaFn && "applyValidationSchema" in t && t.applyValidationSchema(this.validationSchemaFn), this.behaviorSchemaFn && "applyBehaviorSchema" in t && t.applyBehaviorSchema(this.behaviorSchemaFn), t;
2040
2004
  }
2041
2005
  throw new Error(
@@ -2122,14 +2086,14 @@ let x = class ae extends D {
2122
2086
  * ```
2123
2087
  */
2124
2088
  watchItems(e, t) {
2125
- const s = _(() => {
2089
+ const i = _(() => {
2126
2090
  const n = this.items.value.map((a) => {
2127
- if (a instanceof x)
2091
+ if (a instanceof P)
2128
2092
  return a.getFieldByPath(e)?.value.value;
2129
2093
  });
2130
2094
  t(n);
2131
- }), r = V(k.WatchItems);
2132
- return this.disposers.add(r, s);
2095
+ }), r = k(w.WatchItems);
2096
+ return this.disposers.add(r, i);
2133
2097
  }
2134
2098
  /**
2135
2099
  * Подписка на изменение длины массива
@@ -2157,8 +2121,8 @@ let x = class ae extends D {
2157
2121
  const t = _(() => {
2158
2122
  const r = this.length.value;
2159
2123
  e(r);
2160
- }), s = V(k.WatchLength);
2161
- return this.disposers.add(s, t);
2124
+ }), i = k(w.WatchLength);
2125
+ return this.disposers.add(i, t);
2162
2126
  }
2163
2127
  /**
2164
2128
  * Очистить все ресурсы узла
@@ -2221,7 +2185,7 @@ let x = class ae extends D {
2221
2185
  });
2222
2186
  }
2223
2187
  };
2224
- class ke {
2188
+ class Ne {
2225
2189
  /**
2226
2190
  * Создает узел формы на основе конфигурации
2227
2191
  *
@@ -2271,14 +2235,14 @@ class ke {
2271
2235
  if (Array.isArray(e) && e.length >= 1)
2272
2236
  return this.createArrayNodeFromArray(e);
2273
2237
  if (this.isFieldConfig(e))
2274
- return new _e(e);
2238
+ return new Se(e);
2275
2239
  if (this.isArrayConfig(e))
2276
- return new X(
2240
+ return new te(
2277
2241
  e.schema,
2278
2242
  e.initialItems
2279
2243
  );
2280
2244
  if (this.isGroupConfig(e))
2281
- return new x(e);
2245
+ return new P(e);
2282
2246
  throw new Error(
2283
2247
  `NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
2284
2248
  e
@@ -2312,11 +2276,11 @@ class ke {
2312
2276
  */
2313
2277
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2314
2278
  createArrayNodeFromArray(e) {
2315
- const [t, ...s] = e, r = [];
2279
+ const [t, ...i] = e, r = [];
2316
2280
  this.isGroupConfig(t) && r.push(this.extractValues(t));
2317
- for (const n of s)
2281
+ for (const n of i)
2318
2282
  this.isGroupConfig(n) ? r.push(this.extractValues(n)) : r.push(n);
2319
- return new X(t, r);
2283
+ return new te(t, r);
2320
2284
  }
2321
2285
  /**
2322
2286
  * Извлечь значения из схемы (рекурсивно)
@@ -2354,8 +2318,8 @@ class ke {
2354
2318
  return e.map((t) => this.extractValues(t));
2355
2319
  if (this.isGroupConfig(e)) {
2356
2320
  const t = {};
2357
- for (const [s, r] of Object.entries(e))
2358
- t[s] = this.extractValues(r);
2321
+ for (const [i, r] of Object.entries(e))
2322
+ t[i] = this.extractValues(r);
2359
2323
  return t;
2360
2324
  }
2361
2325
  return e;
@@ -2380,7 +2344,7 @@ class ke {
2380
2344
  * ```
2381
2345
  */
2382
2346
  isFieldConfig(e) {
2383
- return e == null || typeof e != "object" ? !1 : "valueSignal" in e ? !0 : "value" in e && "component" in e;
2347
+ return e == null || typeof e != "object" ? !1 : "valueSignal" in e ? !0 : "value" in e ? "component" in e || "componentProps" in e || "validators" in e || "asyncValidators" in e || "updateOn" in e || "debounce" in e : !1;
2384
2348
  }
2385
2349
  /**
2386
2350
  * Проверяет, является ли конфиг конфигурацией массива (ArrayConfig)
@@ -2435,28 +2399,28 @@ class ke {
2435
2399
  return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
2436
2400
  }
2437
2401
  }
2438
- function I(i) {
2439
- return i == null ? !1 : typeof i == "object" && "value" in i && "setValue" in i && "getValue" in i && "validate" in i;
2402
+ function R(s) {
2403
+ return s == null ? !1 : typeof s == "object" && "value" in s && "setValue" in s && "getValue" in s && "validate" in s;
2440
2404
  }
2441
- function Ve(i) {
2442
- return i == null ? !1 : I(i) && "validators" in i && "asyncValidators" in i && // FieldNode имеет markAsTouched метод
2405
+ function Oe(s) {
2406
+ return s == null ? !1 : R(s) && "validators" in s && "asyncValidators" in s && // FieldNode имеет markAsTouched метод
2443
2407
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2444
- typeof i.markAsTouched == "function" && // У FieldNode нет fields или items
2445
- !("fields" in i) && !("items" in i);
2408
+ typeof s.markAsTouched == "function" && // У FieldNode нет fields или items
2409
+ !("fields" in s) && !("items" in s);
2446
2410
  }
2447
- function Oe(i) {
2448
- return i == null ? !1 : I(i) && "getFieldByPath" in i && "fields" in i && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
2449
- !("items" in i) && !("push" in i) && !("removeAt" in i);
2411
+ function Fe(s) {
2412
+ return s == null ? !1 : R(s) && "getFieldByPath" in s && "fields" in s && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
2413
+ !("items" in s) && !("push" in s) && !("removeAt" in s);
2450
2414
  }
2451
- function Ne(i) {
2452
- return i == null ? !1 : I(i) && "items" in i && "length" in i && "push" in i && "removeAt" in i && "at" in i && // eslint-disable-next-line @typescript-eslint/no-explicit-any
2453
- typeof i.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
2454
- typeof i.removeAt == "function";
2415
+ function Me(s) {
2416
+ return s == null ? !1 : R(s) && "items" in s && "length" in s && "push" in s && "removeAt" in s && "at" in s && // eslint-disable-next-line @typescript-eslint/no-explicit-any
2417
+ typeof s.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
2418
+ typeof s.removeAt == "function";
2455
2419
  }
2456
- function ze(i) {
2457
- return Ve(i) ? "FieldNode" : Oe(i) ? "GroupNode" : Ne(i) ? "ArrayNode" : I(i) ? "FormNode" : "Unknown";
2420
+ function Qe(s) {
2421
+ return Oe(s) ? "FieldNode" : Fe(s) ? "GroupNode" : Me(s) ? "ArrayNode" : R(s) ? "FormNode" : "Unknown";
2458
2422
  }
2459
- class Fe extends D {
2423
+ class Pe extends L {
2460
2424
  /**
2461
2425
  * @param control Реактивный массив модели (`model.<path>`).
2462
2426
  * @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
@@ -2464,24 +2428,33 @@ class Fe extends D {
2464
2428
  */
2465
2429
  constructor(e, t) {
2466
2430
  super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = _(() => {
2467
- const r = e.length, n = [];
2468
- for (let a = 0; a < r; a++) {
2469
- const o = e.at(a);
2470
- if (!o) continue;
2471
- let l = this.cache.get(o);
2472
- l || (l = t(o), this.cache.set(o, l)), n.push(l);
2431
+ const r = e.length, n = [], a = [];
2432
+ for (let u = 0; u < r; u++) {
2433
+ const d = e.at(u);
2434
+ if (!d) continue;
2435
+ let o = this.cache.get(d);
2436
+ o || (o = t(d), this.cache.set(d, o)), n.push(d), a.push(o);
2473
2437
  }
2474
- this.itemNodes.value = n;
2475
- }), this.length = h(() => this.itemNodes.value.length), this.value = h(() => this.itemNodes.value.map((r) => r.value.value));
2476
- const s = H({
2438
+ const l = new Set(n), c = [];
2439
+ for (const u of this.mountedModels) {
2440
+ if (l.has(u)) continue;
2441
+ const d = this.cache.get(u);
2442
+ this.cache.delete(u), d && c.push(d);
2443
+ }
2444
+ this.mountedModels = n, this.itemNodes.value = a, c.forEach((u) => this.disposeItemNode(u));
2445
+ }), this.length = f(() => this.itemNodes.value.length), this.value = f(() => this.itemNodes.value.map((r) => r.value.value));
2446
+ const i = H({
2477
2447
  getChildren: () => this.itemNodes.value,
2478
2448
  ownErrors: this._arrayErrors
2479
2449
  });
2480
- this.valid = s.valid, this.invalid = s.invalid, this.pending = s.pending, this.touched = s.touched, this.dirty = s.dirty, this.errors = s.errors, this.status = s.status;
2450
+ this.valid = i.valid, this.invalid = i.invalid, this.pending = i.pending, this.touched = i.touched, this.dirty = i.dirty, this.errors = i.errors, this.status = i.status;
2481
2451
  }
2482
2452
  itemNodes = y([]);
2483
2453
  // Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
2484
2454
  cache = /* @__PURE__ */ new WeakMap();
2455
+ // Фасады под-моделей, для которых сейчас смонтированы формы — «предыдущий» набор для
2456
+ // реконсиляции в disposeSync. Выпавшие из массива элементы диспозятся и вытесняются из кэша.
2457
+ mountedModels = [];
2485
2458
  initial;
2486
2459
  _arrayErrors = y([]);
2487
2460
  disposeSync;
@@ -2506,10 +2479,10 @@ class Fe extends D {
2506
2479
  return this.itemNodes.value[e];
2507
2480
  }
2508
2481
  map(e) {
2509
- return this.itemNodes.value.map((t, s) => e(t, s));
2482
+ return this.itemNodes.value.map((t, i) => e(t, i));
2510
2483
  }
2511
2484
  forEach(e) {
2512
- this.itemNodes.value.forEach((t, s) => e(t, s));
2485
+ this.itemNodes.value.forEach((t, i) => e(t, i));
2513
2486
  }
2514
2487
  // ── Мутации (делегируют массиву модели; effect пересоберёт itemNodes) ──────
2515
2488
  push(e) {
@@ -2596,104 +2569,201 @@ class Fe extends D {
2596
2569
  onEnable() {
2597
2570
  this.itemNodes.value.forEach((e) => e.enable?.());
2598
2571
  }
2599
- /** Очистка подписки синхронизации. */
2572
+ /** Диспозит форму элемента (эффекты/поведения/вложенные подписки); терпима к не-GroupNode. */
2573
+ disposeItemNode(e) {
2574
+ e.dispose?.();
2575
+ }
2576
+ /**
2577
+ * Очистка подписки синхронизации И детерминированный teardown всех форм элементов.
2578
+ * Без пробрасывания dispose в itemNodes эффекты/поведения каждой формы элемента (в т.ч. disposeSync
2579
+ * вложенных ModelArrayNode) остались бы жить после teardown формы — утечка подписок.
2580
+ */
2600
2581
  dispose() {
2601
- this.disposeSync();
2582
+ this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
2602
2583
  }
2603
2584
  }
2604
- const oe = (i) => i !== null && typeof i == "object" && !Array.isArray(i) && !(i instanceof Date) && !(typeof Blob < "u" && i instanceof Blob) && !(typeof File < "u" && i instanceof File);
2605
- function G(i, e, t) {
2606
- if (i == null || typeof i != "object") return;
2607
- if (Array.isArray(i)) {
2608
- for (const n of i) G(n, e, t);
2585
+ const xe = (s) => {
2586
+ const e = s.componentProps;
2587
+ return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
2588
+ }, Ce = (s) => typeof s.when == "function" && Array.isArray(s.children);
2589
+ function F(s, e, t, i, r) {
2590
+ if (s == null || typeof s != "object") return;
2591
+ if (Array.isArray(s)) {
2592
+ for (const a of s) F(a, e, t, i, r);
2609
2593
  return;
2610
2594
  }
2611
- const s = i, r = s.array;
2612
- if (r && typeof r.__path == "string" && typeof s.item == "function") {
2613
- t.set(r.__path, s.item);
2595
+ const n = s;
2596
+ if (Ce(n)) {
2597
+ const a = i && !!n.when(e, t);
2598
+ for (const l of n.children) F(l, e, t, a, r);
2614
2599
  return;
2615
2600
  }
2616
- s.value instanceof re && e.set(s.value, {
2617
- component: s.component,
2618
- componentProps: s.componentProps,
2619
- validators: s.validators,
2620
- asyncValidators: s.asyncValidators,
2621
- updateOn: s.updateOn,
2622
- disabled: s.disabled,
2623
- debounce: s.debounce
2624
- });
2625
- for (const [n, a] of Object.entries(s))
2626
- n !== "value" && G(a, e, t);
2601
+ if (xe(n)) {
2602
+ const a = n.componentProps.control, l = n.componentProps.itemComponent, c = a.length;
2603
+ for (let u = 0; u < c; u++) {
2604
+ const d = a.at(u);
2605
+ F(l(d), d, t, i, r);
2606
+ }
2607
+ return;
2608
+ }
2609
+ if (n.value instanceof oe) {
2610
+ const a = n.validators ?? [], l = n.asyncValidators ?? [], c = l.length ? [...a, ...l] : a;
2611
+ c.length > 0 && (i ? r.tasks.push({ signal: n.value, validators: c, scope: e }) : r.clearSignals.push(n.value));
2612
+ for (const [u, d] of Object.entries(n))
2613
+ u === "value" || u === "validators" || u === "asyncValidators" || F(d, e, t, i, r);
2614
+ return;
2615
+ }
2616
+ for (const a of Object.values(n)) F(a, e, t, i, r);
2617
+ }
2618
+ function z(s, e) {
2619
+ const t = { tasks: [], clearSignals: [] };
2620
+ return F(e, s, s, !0, t), t;
2621
+ }
2622
+ const ce = (s, e, t) => {
2623
+ (s[e] ??= []).push(t);
2624
+ }, J = (s) => {
2625
+ for (const e of Object.values(s))
2626
+ for (const t of e) if (t.severity !== "warning") return !0;
2627
+ return !1;
2628
+ };
2629
+ function Xe(s, e) {
2630
+ const { tasks: t } = z(s, e), i = {};
2631
+ for (const { signal: r, validators: n, scope: a } of t) {
2632
+ const l = r.peek();
2633
+ for (const c of n) {
2634
+ const u = c(l, a, s);
2635
+ u && typeof u.then == "function" || u && ce(i, r.__path, u);
2636
+ }
2637
+ }
2638
+ return { valid: !J(i), errors: i };
2639
+ }
2640
+ async function Ze(s, e) {
2641
+ const { tasks: t } = z(s, e), i = await he(t, s);
2642
+ return { valid: !J(i), errors: i };
2643
+ }
2644
+ async function he(s, e) {
2645
+ const t = {};
2646
+ return await Promise.all(
2647
+ s.map(async ({ signal: i, validators: r, scope: n }) => {
2648
+ const a = i.peek();
2649
+ for (const l of r) {
2650
+ const c = await l(a, n, e);
2651
+ c && ce(t, i.__path, c);
2652
+ }
2653
+ })
2654
+ ), t;
2627
2655
  }
2628
- function le(i, e, t, s) {
2656
+ async function Te(s, e) {
2657
+ const { tasks: t, clearSignals: i } = z(s, e), r = await he(t, s);
2658
+ for (const { signal: n } of t)
2659
+ X(n)?.setErrors(r[n.__path] ?? []);
2660
+ for (const n of i)
2661
+ X(n)?.setErrors([]);
2662
+ return { valid: !J(r), errors: r };
2663
+ }
2664
+ const de = (s) => s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(typeof Blob < "u" && s instanceof Blob) && !(typeof File < "u" && s instanceof File);
2665
+ function U(s, e, t) {
2666
+ if (s == null || typeof s != "object") return;
2667
+ if (Array.isArray(s)) {
2668
+ for (const n of s) U(n, e, t);
2669
+ return;
2670
+ }
2671
+ const i = s, r = i.array;
2672
+ if (r && typeof r.__path == "string" && typeof i.item == "function") {
2673
+ t.set(r.__path, i.item);
2674
+ return;
2675
+ }
2676
+ i.value instanceof oe ? e.set(i.value, {
2677
+ component: i.component,
2678
+ componentProps: i.componentProps,
2679
+ validators: i.validators,
2680
+ asyncValidators: i.asyncValidators,
2681
+ updateOn: i.updateOn,
2682
+ disabled: i.disabled,
2683
+ debounce: i.debounce
2684
+ }) : process.env.NODE_ENV !== "production" && i.component !== void 0 && ("valueSignal" in i || i.value != null) && console.warn(
2685
+ "[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
2686
+ );
2687
+ for (const [n, a] of Object.entries(i))
2688
+ n !== "value" && U(a, e, t);
2689
+ }
2690
+ function fe(s, e, t, i) {
2629
2691
  const r = {};
2630
2692
  for (const [n, a] of Object.entries(e)) {
2631
- const o = t === "" ? n : `${t}.${n}`;
2693
+ const l = t === "" ? n : `${t}.${n}`;
2632
2694
  if (Array.isArray(a))
2633
2695
  continue;
2634
- if (oe(a)) {
2635
- r[n] = le(i, a, o, s);
2696
+ if (de(a)) {
2697
+ r[n] = fe(s, a, l, i);
2636
2698
  continue;
2637
2699
  }
2638
- const l = i.signalAt(o);
2639
- if (!l) throw new Error(`createForm({ model }): не найден сигнал для пути "${o}"`);
2640
- const u = s.get(l) ?? {}, { validators: m, asyncValidators: c, ...f } = u;
2641
- r[n] = { ...f, valueSignal: l };
2700
+ const c = s.signalAt(l);
2701
+ if (!c) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
2702
+ const u = i.get(c) ?? {}, { validators: d, asyncValidators: o, ...v } = u;
2703
+ r[n] = { ...v, valueSignal: c };
2642
2704
  }
2643
2705
  return r;
2644
2706
  }
2645
- function ue(i, e, t) {
2646
- for (const [s, r] of Object.entries(i)) {
2647
- const n = e === "" ? s : `${e}.${s}`;
2648
- Array.isArray(r) || (oe(r) ? ue(r, n, t) : t.push(n));
2707
+ function pe(s, e, t) {
2708
+ for (const [i, r] of Object.entries(s)) {
2709
+ const n = e === "" ? i : `${e}.${i}`;
2710
+ Array.isArray(r) || (de(r) ? pe(r, n, t) : t.push(n));
2649
2711
  }
2650
2712
  }
2651
- function ce(i) {
2652
- const { model: e, schema: t, behavior: s } = i, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
2653
- t !== void 0 && G(t, r, n);
2654
- const a = le(e, e.get(), "", r), o = new x(a), l = e.get();
2655
- for (const [c, f] of Object.entries(l)) {
2656
- if (!Array.isArray(f)) continue;
2657
- const d = n.get(c);
2658
- if (!d) continue;
2659
- const p = e[c], v = (b) => ce({ model: b, schema: d(b) }), g = new Fe(p, v);
2660
- o.fields.set(c, g);
2661
- }
2662
- const u = o.getProxy(), m = [];
2663
- ue(e.get(), "", m);
2664
- for (const c of m) {
2665
- const f = e.signalAt(c), d = o.getFieldByPath(c);
2666
- f && d && ye(f, d);
2667
- }
2668
- return s && o.attachBehaviorCleanup(s.__run(e, u)), u;
2713
+ function ve(s) {
2714
+ const { model: e, schema: t, behavior: i } = s, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
2715
+ t !== void 0 && U(t, r, n);
2716
+ const a = fe(e, e.get(), "", r), l = new P(a), c = e.get();
2717
+ for (const [o, v] of Object.entries(c)) {
2718
+ if (!Array.isArray(v)) continue;
2719
+ const h = n.get(o);
2720
+ if (!h) continue;
2721
+ const p = e[o], m = (g) => ve({ model: g, schema: h(g) }), b = new Pe(p, m);
2722
+ l.fields.set(o, b);
2723
+ }
2724
+ const u = l.getProxy(), d = [];
2725
+ pe(e.get(), "", d);
2726
+ for (const o of d) {
2727
+ const v = e.signalAt(o), h = l.getFieldByPath(o);
2728
+ if (v && h) {
2729
+ _e(v, h);
2730
+ const p = o.lastIndexOf("."), m = p === -1 ? l : l.getFieldByPath(o.slice(0, p));
2731
+ m instanceof P && m.registerFieldSignal(h, v);
2732
+ }
2733
+ }
2734
+ if (t !== void 0) {
2735
+ const o = t;
2736
+ l.attachModelValidator(async () => (await Te(e, o)).valid);
2737
+ }
2738
+ return i && l.attachBehaviorCleanup(i.__run(e, u)), u;
2669
2739
  }
2670
- const xe = (i) => i != null && typeof i == "object" && "model" in i && typeof i.model?.signalAt == "function";
2671
- function Je(i) {
2672
- return xe(i) ? ce(i) : new x(i).getProxy();
2740
+ const Ie = (s) => s != null && typeof s == "object" && "model" in s && typeof s.model?.signalAt == "function";
2741
+ function et(s) {
2742
+ return Ie(s) ? ve(s) : new P(s).getProxy();
2673
2743
  }
2674
- const M = (i) => !(i === null || typeof i != "object" || Array.isArray(i) || i instanceof Date || typeof Blob < "u" && i instanceof Blob || typeof File < "u" && i instanceof File), A = (i, e) => i === "" ? String(e) : `${i}.${e}`, U = (i) => /^\d+$/.test(i), w = (i) => {
2675
- if (Array.isArray(i)) return i.map(w);
2676
- if (M(i)) {
2744
+ const T = (s) => !(s === null || typeof s != "object" || Array.isArray(s) || s instanceof Date || typeof Blob < "u" && s instanceof Blob || typeof File < "u" && s instanceof File), A = (s, e) => s === "" ? String(e) : `${s}.${e}`, W = (s) => /^\d+$/.test(s), S = (s) => {
2745
+ if (Array.isArray(s)) return s.map(S);
2746
+ if (T(s)) {
2677
2747
  const e = {};
2678
- for (const t of Object.keys(i)) e[t] = w(i[t]);
2748
+ for (const t of Object.keys(s)) e[t] = S(s[t]);
2679
2749
  return e;
2680
2750
  }
2681
- return i;
2682
- }, C = (i, e) => {
2683
- if (i === e) return !0;
2684
- if (Array.isArray(i) && Array.isArray(e))
2685
- return i.length !== e.length ? !1 : i.every((t, s) => C(t, e[s]));
2686
- if (M(i) && M(e)) {
2687
- const t = Object.keys(i), s = Object.keys(e);
2688
- return t.length !== s.length ? !1 : t.every((r) => C(i[r], e[r]));
2751
+ return s;
2752
+ }, I = (s, e) => {
2753
+ if (s === e) return !0;
2754
+ if (Array.isArray(s) && Array.isArray(e))
2755
+ return s.length !== e.length ? !1 : s.every((t, i) => I(t, e[i]));
2756
+ if (T(s) && T(e)) {
2757
+ const t = Object.keys(s), i = Object.keys(e);
2758
+ return t.length !== i.length ? !1 : t.every((r) => I(s[r], e[r]));
2689
2759
  }
2690
2760
  return !1;
2691
2761
  };
2692
- class Pe {
2762
+ class De {
2693
2763
  constructor(e, t) {
2694
2764
  this.path = t;
2695
- const s = y(e);
2696
- s.__path = t, this.signal = s, this.initial = w(e);
2765
+ const i = y(e);
2766
+ i.__path = t, this.signal = i, this.initial = S(e);
2697
2767
  }
2698
2768
  kind = "leaf";
2699
2769
  signal;
@@ -2713,37 +2783,37 @@ class Pe {
2713
2783
  this.signal.value = e;
2714
2784
  }
2715
2785
  resetToInitial() {
2716
- this.signal.value = w(this.initial);
2786
+ this.signal.value = S(this.initial);
2717
2787
  }
2718
2788
  captureInitial() {
2719
- this.initial = w(this.signal.peek());
2789
+ this.initial = S(this.signal.peek());
2720
2790
  }
2721
2791
  dirty() {
2722
- return !C(this.signal.peek(), this.initial);
2792
+ return !I(this.signal.peek(), this.initial);
2723
2793
  }
2724
2794
  }
2725
- class he {
2795
+ class me {
2726
2796
  constructor(e, t) {
2727
2797
  this.path = t;
2728
- for (const s of Object.keys(e))
2729
- this.children.set(s, F(e[s], A(t, s)));
2798
+ for (const i of Object.keys(e))
2799
+ this.children.set(i, x(e[i], A(t, i)));
2730
2800
  }
2731
2801
  kind = "group";
2732
2802
  children = /* @__PURE__ */ new Map();
2733
2803
  rebase(e) {
2734
2804
  this.path = e;
2735
- for (const [t, s] of this.children) s.rebase(A(e, t));
2805
+ for (const [t, i] of this.children) i.rebase(A(e, t));
2736
2806
  }
2737
2807
  peek() {
2738
2808
  const e = {};
2739
- for (const [t, s] of this.children) e[t] = s.peek();
2809
+ for (const [t, i] of this.children) e[t] = i.peek();
2740
2810
  return e;
2741
2811
  }
2742
2812
  set(e) {
2743
2813
  if (e == null || typeof e != "object") return;
2744
2814
  const t = e;
2745
- for (const [s, r] of this.children)
2746
- s in t && (r.kind === "leaf" && B(r.signal) || r.set(t[s]));
2815
+ for (const [i, r] of this.children)
2816
+ i in t && (r.kind === "leaf" && G(r.signal) || r.set(t[i]));
2747
2817
  }
2748
2818
  resetToInitial() {
2749
2819
  for (const e of this.children.values()) e.resetToInitial();
@@ -2756,38 +2826,38 @@ class he {
2756
2826
  return !1;
2757
2827
  }
2758
2828
  }
2759
- class Me {
2829
+ class Le {
2760
2830
  constructor(e, t) {
2761
- this.path = t, this.items = y(e.map((s, r) => F(s, A(t, r)))), this.initial = w(e);
2831
+ this.path = t, this.items = y(e.map((i, r) => x(i, A(t, r)))), this.initial = S(e);
2762
2832
  }
2763
2833
  kind = "array";
2764
2834
  items;
2765
2835
  initial;
2766
2836
  rebase(e) {
2767
- this.path = e, this.items.peek().forEach((t, s) => t.rebase(A(e, s)));
2837
+ this.path = e, this.items.peek().forEach((t, i) => t.rebase(A(e, i)));
2768
2838
  }
2769
2839
  reindex() {
2770
2840
  this.items.peek().forEach((e, t) => e.rebase(A(this.path, t)));
2771
2841
  }
2772
2842
  push(e) {
2773
2843
  const t = this.items.peek();
2774
- this.items.value = [...t, F(e, A(this.path, t.length))];
2844
+ this.items.value = [...t, x(e, A(this.path, t.length))];
2775
2845
  }
2776
2846
  insertAt(e, t) {
2777
- const s = [...this.items.peek()];
2778
- s.splice(e, 0, F(t, A(this.path, e))), this.items.value = s, this.reindex();
2847
+ const i = [...this.items.peek()];
2848
+ i.splice(e, 0, x(t, A(this.path, e))), this.items.value = i, this.reindex();
2779
2849
  }
2780
2850
  removeAt(e) {
2781
2851
  const t = [...this.items.peek()];
2782
2852
  t.splice(e, 1), this.items.value = t, this.reindex();
2783
2853
  }
2784
2854
  move(e, t) {
2785
- const s = [...this.items.peek()], [r] = s.splice(e, 1);
2786
- r && s.splice(t, 0, r), this.items.value = s, this.reindex();
2855
+ const i = [...this.items.peek()], [r] = i.splice(e, 1);
2856
+ r && i.splice(t, 0, r), this.items.value = i, this.reindex();
2787
2857
  }
2788
2858
  swap(e, t) {
2789
- const s = [...this.items.peek()];
2790
- e < 0 || t < 0 || e >= s.length || t >= s.length || e === t || ([s[e], s[t]] = [s[t], s[e]], this.items.value = s, this.reindex());
2859
+ const i = [...this.items.peek()];
2860
+ e < 0 || t < 0 || e >= i.length || t >= i.length || e === t || ([i[e], i[t]] = [i[t], i[e]], this.items.value = i, this.reindex());
2791
2861
  }
2792
2862
  clear() {
2793
2863
  this.items.value = [];
@@ -2797,88 +2867,88 @@ class Me {
2797
2867
  }
2798
2868
  set(e) {
2799
2869
  const t = Array.isArray(e) ? e : [];
2800
- this.items.value = t.map((s, r) => F(s, A(this.path, r)));
2870
+ this.items.value = t.map((i, r) => x(i, A(this.path, r)));
2801
2871
  }
2802
2872
  resetToInitial() {
2803
- this.set(w(this.initial));
2873
+ this.set(S(this.initial));
2804
2874
  }
2805
2875
  captureInitial() {
2806
- this.initial = w(this.peek());
2876
+ this.initial = S(this.peek());
2807
2877
  }
2808
2878
  dirty() {
2809
- return !C(this.peek(), this.initial);
2879
+ return !I(this.peek(), this.initial);
2810
2880
  }
2811
2881
  }
2812
- function F(i, e) {
2813
- return Array.isArray(i) ? new Me(i, e) : M(i) ? new he(i, e) : new Pe(i, e);
2882
+ function x(s, e) {
2883
+ return Array.isArray(s) ? new Le(s, e) : T(s) ? new me(s, e) : new De(s, e);
2814
2884
  }
2815
- function T(i) {
2816
- if (i)
2817
- return i.kind === "leaf" ? i.read() : i.kind === "group" ? Ce(i) : de(i);
2885
+ function D(s) {
2886
+ if (s)
2887
+ return s.kind === "leaf" ? s.read() : s.kind === "group" ? Re(s) : ye(s);
2818
2888
  }
2819
- function Ce(i) {
2889
+ function Re(s) {
2820
2890
  return new Proxy(
2821
2891
  {},
2822
2892
  {
2823
- get: (e, t) => t === "__path" ? i.path : typeof t == "string" ? T(i.children.get(t)) : void 0,
2824
- set: (e, t, s) => {
2893
+ get: (e, t) => t === "__path" ? s.path : typeof t == "string" ? D(s.children.get(t)) : void 0,
2894
+ set: (e, t, i) => {
2825
2895
  if (typeof t != "string") return !1;
2826
- const r = i.children.get(t);
2827
- return r && r.set(s), !0;
2896
+ const r = s.children.get(t);
2897
+ return r && r.set(i), !0;
2828
2898
  },
2829
- has: (e, t) => typeof t == "string" && i.children.has(t),
2830
- ownKeys: () => [...i.children.keys()],
2831
- getOwnPropertyDescriptor: (e, t) => typeof t == "string" && i.children.has(t) ? { enumerable: !0, configurable: !0 } : void 0
2899
+ has: (e, t) => typeof t == "string" && s.children.has(t),
2900
+ ownKeys: () => [...s.children.keys()],
2901
+ getOwnPropertyDescriptor: (e, t) => typeof t == "string" && s.children.has(t) ? { enumerable: !0, configurable: !0 } : void 0
2832
2902
  }
2833
2903
  );
2834
2904
  }
2835
- function j(i) {
2836
- if (i)
2837
- return i.kind === "group" ? fe(i) : i.kind === "array" ? de(i) : i.read();
2905
+ function $(s) {
2906
+ if (s)
2907
+ return s.kind === "group" ? ge(s) : s.kind === "array" ? ye(s) : s.read();
2838
2908
  }
2839
- function de(i) {
2909
+ function ye(s) {
2840
2910
  const e = {
2841
2911
  get length() {
2842
- return i.items.value.length;
2912
+ return s.items.value.length;
2843
2913
  },
2844
- push: (t) => i.push(t),
2845
- insertAt: (t, s) => i.insertAt(t, s),
2846
- removeAt: (t) => i.removeAt(t),
2847
- move: (t, s) => i.move(t, s),
2848
- swap: (t, s) => i.swap(t, s),
2849
- clear: () => i.clear(),
2850
- at: (t) => j(i.items.value[t]),
2851
- map: (t) => i.items.value.map((s, r) => t(j(s), r)),
2852
- forEach: (t) => i.items.value.forEach((s, r) => t(j(s), r)),
2853
- toArray: () => i.peek(),
2914
+ push: (t) => s.push(t),
2915
+ insertAt: (t, i) => s.insertAt(t, i),
2916
+ removeAt: (t) => s.removeAt(t),
2917
+ move: (t, i) => s.move(t, i),
2918
+ swap: (t, i) => s.swap(t, i),
2919
+ clear: () => s.clear(),
2920
+ at: (t) => $(s.items.value[t]),
2921
+ map: (t) => s.items.value.map((i, r) => t($(i), r)),
2922
+ forEach: (t) => s.items.value.forEach((i, r) => t($(i), r)),
2923
+ toArray: () => s.peek(),
2854
2924
  [Symbol.iterator]: function* () {
2855
- const t = i.items.value;
2856
- for (let s = 0; s < t.length; s++) yield T(t[s]);
2925
+ const t = s.items.value;
2926
+ for (let i = 0; i < t.length; i++) yield D(t[i]);
2857
2927
  }
2858
2928
  };
2859
2929
  return new Proxy(e, {
2860
- get: (t, s, r) => s === "__path" ? i.path : typeof s == "string" && U(s) ? T(i.items.value[Number(s)]) : Reflect.get(t, s, r),
2861
- has: (t, s) => typeof s == "string" && U(s) ? Number(s) < i.items.value.length : Reflect.has(t, s)
2930
+ get: (t, i, r) => i === "__path" ? s.path : typeof i == "string" && W(i) ? D(s.items.value[Number(i)]) : Reflect.get(t, i, r),
2931
+ has: (t, i) => typeof i == "string" && W(i) ? Number(i) < s.items.value.length : Reflect.has(t, i)
2862
2932
  });
2863
2933
  }
2864
- function W(i) {
2865
- if (i.kind === "leaf") return i.signal;
2866
- if (i.kind === "group")
2934
+ function q(s) {
2935
+ if (s.kind === "leaf") return s.signal;
2936
+ if (s.kind === "group")
2867
2937
  return new Proxy(
2868
2938
  {},
2869
2939
  {
2870
- get: (t, s) => {
2871
- if (s === "__path") return i.path;
2872
- if (typeof s != "string") return;
2873
- const r = i.children.get(s);
2874
- return r ? W(r) : void 0;
2940
+ get: (t, i) => {
2941
+ if (i === "__path") return s.path;
2942
+ if (typeof i != "string") return;
2943
+ const r = s.children.get(i);
2944
+ return r ? q(r) : void 0;
2875
2945
  },
2876
- has: (t, s) => typeof s == "string" && i.children.has(s),
2877
- ownKeys: () => [...i.children.keys()],
2878
- getOwnPropertyDescriptor: (t, s) => typeof s == "string" && i.children.has(s) ? { enumerable: !0, configurable: !0 } : void 0
2946
+ has: (t, i) => typeof i == "string" && s.children.has(i),
2947
+ ownKeys: () => [...s.children.keys()],
2948
+ getOwnPropertyDescriptor: (t, i) => typeof i == "string" && s.children.has(i) ? { enumerable: !0, configurable: !0 } : void 0
2879
2949
  }
2880
2950
  );
2881
- const e = i;
2951
+ const e = s;
2882
2952
  return new Proxy(
2883
2953
  {
2884
2954
  get length() {
@@ -2886,29 +2956,29 @@ function W(i) {
2886
2956
  }
2887
2957
  },
2888
2958
  {
2889
- get: (t, s, r) => {
2890
- if (s === "__path") return e.path;
2891
- if (typeof s == "string" && U(s)) {
2892
- const n = e.items.value[Number(s)];
2893
- return n ? W(n) : void 0;
2959
+ get: (t, i, r) => {
2960
+ if (i === "__path") return e.path;
2961
+ if (typeof i == "string" && W(i)) {
2962
+ const n = e.items.value[Number(i)];
2963
+ return n ? q(n) : void 0;
2894
2964
  }
2895
- return Reflect.get(t, s, r);
2965
+ return Reflect.get(t, i, r);
2896
2966
  }
2897
2967
  }
2898
2968
  );
2899
2969
  }
2900
- function Te(i, e) {
2970
+ function $e(s, e) {
2901
2971
  if (!e) return;
2902
- let t = i;
2903
- for (const s of e.split(".")) {
2972
+ let t = s;
2973
+ for (const i of e.split(".")) {
2904
2974
  if (!t) return;
2905
- if (t.kind === "group") t = t.children.get(s);
2906
- else if (t.kind === "array") t = t.items.peek()[Number(s)];
2975
+ if (t.kind === "group") t = t.children.get(i);
2976
+ else if (t.kind === "array") t = t.items.peek()[Number(i)];
2907
2977
  else return;
2908
2978
  }
2909
2979
  return t && t.kind === "leaf" ? t.signal : void 0;
2910
2980
  }
2911
- const Z = /* @__PURE__ */ new Set([
2981
+ const se = /* @__PURE__ */ new Set([
2912
2982
  "$",
2913
2983
  "get",
2914
2984
  "set",
@@ -2917,285 +2987,216 @@ const Z = /* @__PURE__ */ new Set([
2917
2987
  "reset",
2918
2988
  "captureInitial",
2919
2989
  "signalAt"
2920
- ]), ee = /* @__PURE__ */ new WeakMap();
2921
- function fe(i) {
2922
- const e = ee.get(i);
2990
+ ]), ie = /* @__PURE__ */ new WeakMap();
2991
+ function ge(s) {
2992
+ const e = ie.get(s);
2923
2993
  if (e) return e;
2924
2994
  const t = {
2925
- $: W(i),
2926
- get: () => i.peek(),
2927
- set: (r) => i.set(r),
2928
- patch: (r) => i.set(r),
2929
- isDirty: () => i.dirty(),
2930
- reset: () => i.resetToInitial(),
2931
- captureInitial: () => i.captureInitial(),
2932
- signalAt: (r) => Te(i, r)
2933
- }, s = new Proxy(
2995
+ $: q(s),
2996
+ get: () => s.peek(),
2997
+ set: (r) => s.set(r),
2998
+ patch: (r) => s.set(r),
2999
+ isDirty: () => s.dirty(),
3000
+ reset: () => s.resetToInitial(),
3001
+ captureInitial: () => s.captureInitial(),
3002
+ signalAt: (r) => $e(s, r)
3003
+ }, i = new Proxy(
2934
3004
  {},
2935
3005
  {
2936
3006
  get: (r, n) => {
2937
3007
  if (typeof n != "string") return;
2938
- const a = i.children.get(n);
2939
- if (a) return T(a);
2940
- if (Z.has(n)) return t[n];
3008
+ const a = s.children.get(n);
3009
+ if (a) return D(a);
3010
+ if (se.has(n)) return t[n];
2941
3011
  },
2942
3012
  set: (r, n, a) => {
2943
3013
  if (typeof n != "string") return !1;
2944
- const o = i.children.get(n);
2945
- return o ? (o.set(a), !0) : !1;
3014
+ const l = s.children.get(n);
3015
+ return l ? (l.set(a), !0) : !1;
2946
3016
  },
2947
- has: (r, n) => typeof n == "string" && (i.children.has(n) || Z.has(n)),
2948
- ownKeys: () => [...i.children.keys()],
2949
- getOwnPropertyDescriptor: (r, n) => typeof n == "string" && i.children.has(n) ? { enumerable: !0, configurable: !0 } : void 0
3017
+ has: (r, n) => typeof n == "string" && (s.children.has(n) || se.has(n)),
3018
+ ownKeys: () => [...s.children.keys()],
3019
+ getOwnPropertyDescriptor: (r, n) => typeof n == "string" && s.children.has(n) ? { enumerable: !0, configurable: !0 } : void 0
2950
3020
  }
2951
3021
  );
2952
- return ee.set(i, s), s;
3022
+ return ie.set(s, i), i;
2953
3023
  }
2954
- function Ye(i) {
2955
- const e = new he(i, "");
2956
- return fe(e);
3024
+ function tt(s) {
3025
+ const e = new me(s, "");
3026
+ return ge(e);
2957
3027
  }
2958
- const De = (i) => {
2959
- const e = i.componentProps;
2960
- return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
2961
- }, Ie = (i) => typeof i.when == "function" && Array.isArray(i.children);
2962
- function N(i, e, t, s, r) {
2963
- if (i == null || typeof i != "object") return;
2964
- if (Array.isArray(i)) {
2965
- for (const a of i) N(a, e, t, s, r);
2966
- return;
2967
- }
2968
- const n = i;
2969
- if (Ie(n)) {
2970
- const a = s && !!n.when(e, t);
2971
- for (const o of n.children) N(o, e, t, a, r);
2972
- return;
2973
- }
2974
- if (De(n)) {
2975
- const a = n.componentProps.control, o = n.componentProps.itemComponent, l = a.length;
2976
- for (let u = 0; u < l; u++) {
2977
- const m = a.at(u);
2978
- N(o(m), m, t, s, r);
2979
- }
2980
- return;
2981
- }
2982
- if (n.value instanceof re) {
2983
- const a = n.validators ?? [];
2984
- a.length > 0 && (s ? r.tasks.push({ signal: n.value, validators: a, scope: e }) : r.clearSignals.push(n.value));
2985
- for (const [o, l] of Object.entries(n))
2986
- o === "value" || o === "validators" || N(l, e, t, s, r);
2987
- return;
2988
- }
2989
- for (const a of Object.values(n)) N(a, e, t, s, r);
2990
- }
2991
- function z(i, e) {
2992
- const t = { tasks: [], clearSignals: [] };
2993
- return N(e, i, i, !0, t), t;
2994
- }
2995
- const pe = (i, e, t) => {
2996
- (i[e] ??= []).push(t);
2997
- };
2998
- function Qe(i, e) {
2999
- const { tasks: t } = z(i, e), s = {};
3000
- for (const { signal: r, validators: n, scope: a } of t) {
3001
- const o = r.peek();
3002
- for (const l of n) {
3003
- const u = l(o, a, i);
3004
- u && typeof u.then == "function" || u && pe(s, r.__path, u);
3005
- }
3006
- }
3007
- return { valid: Object.keys(s).length === 0, errors: s };
3008
- }
3009
- async function Xe(i, e) {
3010
- const { tasks: t } = z(i, e), s = await ve(t, i);
3011
- return { valid: Object.keys(s).length === 0, errors: s };
3012
- }
3013
- async function ve(i, e) {
3014
- const t = {};
3015
- return await Promise.all(
3016
- i.map(async ({ signal: s, validators: r, scope: n }) => {
3017
- const a = s.peek();
3018
- for (const o of r) {
3019
- const l = await o(a, n, e);
3020
- l && pe(t, s.__path, l);
3021
- }
3022
- })
3023
- ), t;
3024
- }
3025
- async function Ze(i, e) {
3026
- const { tasks: t, clearSignals: s } = z(i, e), r = await ve(t, i);
3027
- for (const { signal: n } of t)
3028
- Q(n)?.setErrors(r[n.__path] ?? []);
3029
- for (const n of s)
3030
- Q(n)?.setErrors([]);
3031
- return { valid: Object.keys(r).length === 0, errors: r };
3032
- }
3033
- var P = { exports: {} }, R = {};
3034
- var te;
3035
- function Le() {
3036
- if (te) return R;
3037
- te = 1;
3038
- var i = ne;
3039
- function e(c, f) {
3040
- return c === f && (c !== 0 || 1 / c === 1 / f) || c !== c && f !== f;
3041
- }
3042
- var t = typeof Object.is == "function" ? Object.is : e, s = i.useState, r = i.useEffect, n = i.useLayoutEffect, a = i.useDebugValue;
3043
- function o(c, f) {
3044
- var d = f(), p = s({ inst: { value: d, getSnapshot: f } }), v = p[0].inst, g = p[1];
3028
+ var C = { exports: {} }, j = {};
3029
+ var re;
3030
+ function je() {
3031
+ if (re) return j;
3032
+ re = 1;
3033
+ var s = le;
3034
+ function e(o, v) {
3035
+ return o === v && (o !== 0 || 1 / o === 1 / v) || o !== o && v !== v;
3036
+ }
3037
+ var t = typeof Object.is == "function" ? Object.is : e, i = s.useState, r = s.useEffect, n = s.useLayoutEffect, a = s.useDebugValue;
3038
+ function l(o, v) {
3039
+ var h = v(), p = i({ inst: { value: h, getSnapshot: v } }), m = p[0].inst, b = p[1];
3045
3040
  return n(
3046
3041
  function() {
3047
- v.value = d, v.getSnapshot = f, l(v) && g({ inst: v });
3042
+ m.value = h, m.getSnapshot = v, c(m) && b({ inst: m });
3048
3043
  },
3049
- [c, d, f]
3044
+ [o, h, v]
3050
3045
  ), r(
3051
3046
  function() {
3052
- return l(v) && g({ inst: v }), c(function() {
3053
- l(v) && g({ inst: v });
3047
+ return c(m) && b({ inst: m }), o(function() {
3048
+ c(m) && b({ inst: m });
3054
3049
  });
3055
3050
  },
3056
- [c]
3057
- ), a(d), d;
3051
+ [o]
3052
+ ), a(h), h;
3058
3053
  }
3059
- function l(c) {
3060
- var f = c.getSnapshot;
3061
- c = c.value;
3054
+ function c(o) {
3055
+ var v = o.getSnapshot;
3056
+ o = o.value;
3062
3057
  try {
3063
- var d = f();
3064
- return !t(c, d);
3058
+ var h = v();
3059
+ return !t(o, h);
3065
3060
  } catch {
3066
3061
  return !0;
3067
3062
  }
3068
3063
  }
3069
- function u(c, f) {
3070
- return f();
3064
+ function u(o, v) {
3065
+ return v();
3071
3066
  }
3072
- var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : o;
3073
- return R.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : m, R;
3067
+ var d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
3068
+ return j.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : d, j;
3074
3069
  }
3075
- var $ = {};
3076
- var se;
3077
- function je() {
3078
- return se || (se = 1, process.env.NODE_ENV !== "production" && (function() {
3079
- function i(d, p) {
3080
- return d === p && (d !== 0 || 1 / d === 1 / p) || d !== d && p !== p;
3070
+ var B = {};
3071
+ var ne;
3072
+ function Be() {
3073
+ return ne || (ne = 1, process.env.NODE_ENV !== "production" && (function() {
3074
+ function s(h, p) {
3075
+ return h === p && (h !== 0 || 1 / h === 1 / p) || h !== h && p !== p;
3081
3076
  }
3082
- function e(d, p) {
3083
- m || r.startTransition === void 0 || (m = !0, console.error(
3077
+ function e(h, p) {
3078
+ d || r.startTransition === void 0 || (d = !0, console.error(
3084
3079
  "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
3085
3080
  ));
3086
- var v = p();
3087
- if (!c) {
3088
- var g = p();
3089
- n(v, g) || (console.error(
3081
+ var m = p();
3082
+ if (!o) {
3083
+ var b = p();
3084
+ n(m, b) || (console.error(
3090
3085
  "The result of getSnapshot should be cached to avoid an infinite loop"
3091
- ), c = !0);
3086
+ ), o = !0);
3092
3087
  }
3093
- g = a({
3094
- inst: { value: v, getSnapshot: p }
3088
+ b = a({
3089
+ inst: { value: m, getSnapshot: p }
3095
3090
  });
3096
- var b = g[0].inst, L = g[1];
3097
- return l(
3091
+ var g = b[0].inst, V = b[1];
3092
+ return c(
3098
3093
  function() {
3099
- b.value = v, b.getSnapshot = p, t(b) && L({ inst: b });
3094
+ g.value = m, g.getSnapshot = p, t(g) && V({ inst: g });
3100
3095
  },
3101
- [d, v, p]
3102
- ), o(
3096
+ [h, m, p]
3097
+ ), l(
3103
3098
  function() {
3104
- return t(b) && L({ inst: b }), d(function() {
3105
- t(b) && L({ inst: b });
3099
+ return t(g) && V({ inst: g }), h(function() {
3100
+ t(g) && V({ inst: g });
3106
3101
  });
3107
3102
  },
3108
- [d]
3109
- ), u(v), v;
3103
+ [h]
3104
+ ), u(m), m;
3110
3105
  }
3111
- function t(d) {
3112
- var p = d.getSnapshot;
3113
- d = d.value;
3106
+ function t(h) {
3107
+ var p = h.getSnapshot;
3108
+ h = h.value;
3114
3109
  try {
3115
- var v = p();
3116
- return !n(d, v);
3110
+ var m = p();
3111
+ return !n(h, m);
3117
3112
  } catch {
3118
3113
  return !0;
3119
3114
  }
3120
3115
  }
3121
- function s(d, p) {
3116
+ function i(h, p) {
3122
3117
  return p();
3123
3118
  }
3124
3119
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
3125
- var r = ne, n = typeof Object.is == "function" ? Object.is : i, a = r.useState, o = r.useEffect, l = r.useLayoutEffect, u = r.useDebugValue, m = !1, c = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : e;
3126
- $.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
3127
- })()), $;
3120
+ var r = le, n = typeof Object.is == "function" ? Object.is : s, a = r.useState, l = r.useEffect, c = r.useLayoutEffect, u = r.useDebugValue, d = !1, o = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? i : e;
3121
+ B.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : v, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
3122
+ })()), B;
3128
3123
  }
3129
- var ie;
3130
- function Re() {
3131
- return ie || (ie = 1, process.env.NODE_ENV === "production" ? P.exports = Le() : P.exports = je()), P.exports;
3124
+ var ae;
3125
+ function Ge() {
3126
+ return ae || (ae = 1, process.env.NODE_ENV === "production" ? C.exports = je() : C.exports = Be()), C.exports;
3132
3127
  }
3133
- var J = Re();
3134
- function $e(i, e) {
3135
- if (i === e) return !0;
3136
- if (i.length !== e.length) return !1;
3137
- for (let t = 0; t < i.length; t++)
3138
- if (i[t] !== e[t]) return !1;
3128
+ var Y = Ge();
3129
+ function Ue(s, e) {
3130
+ if (s === e) return !0;
3131
+ if (s.length !== e.length) return !1;
3132
+ for (let t = 0; t < s.length; t++)
3133
+ if (s[t] !== e[t]) return !1;
3139
3134
  return !0;
3140
3135
  }
3141
- function Y(i, e, t) {
3142
- const s = q(null);
3143
- if (s.current === null) {
3144
- const a = {};
3145
- for (const o in i)
3146
- a[o] = i[o].value;
3147
- s.current = { ...a, __snapshot: null };
3148
- }
3149
- const r = E(
3150
- (a) => {
3136
+ function Q(s, e, t, i) {
3137
+ const r = M(null), n = M(s);
3138
+ n.current = s;
3139
+ const a = M(e);
3140
+ a.current = e;
3141
+ const l = M(t);
3142
+ if (l.current = t, r.current === null) {
3143
+ const d = {};
3144
+ for (const o in s)
3145
+ d[o] = s[o].value;
3146
+ r.current = { ...d, __snapshot: null };
3147
+ }
3148
+ const c = E(
3149
+ (d) => {
3151
3150
  let o = !0;
3152
3151
  return _(() => {
3153
- for (const u in i)
3154
- i[u].value;
3152
+ const h = n.current;
3153
+ for (const p in h)
3154
+ h[p].value;
3155
3155
  if (o) {
3156
3156
  o = !1;
3157
3157
  return;
3158
3158
  }
3159
- a();
3159
+ d();
3160
3160
  });
3161
3161
  },
3162
3162
  [i]
3163
- ), n = E(() => {
3164
- const a = s.current, o = {};
3165
- for (const u in i)
3166
- o[u] = i[u].value;
3167
- let l = !1;
3168
- for (const u of e) {
3169
- const { key: m, useShallowArrayEqual: c } = u, f = o[m], d = a[m];
3170
- if (c) {
3171
- if (!$e(d, f)) {
3172
- l = !0;
3163
+ ), u = E(() => {
3164
+ const d = r.current, o = n.current, v = {};
3165
+ for (const p in o)
3166
+ v[p] = o[p].value;
3167
+ let h = !1;
3168
+ for (const p of a.current) {
3169
+ const { key: m, useShallowArrayEqual: b } = p, g = v[m], V = d[m];
3170
+ if (b) {
3171
+ if (!Ue(V, g)) {
3172
+ h = !0;
3173
3173
  break;
3174
3174
  }
3175
- } else if (d !== f) {
3176
- l = !0;
3175
+ } else if (V !== g) {
3176
+ h = !0;
3177
3177
  break;
3178
3178
  }
3179
3179
  }
3180
- if (!l && a.__snapshot)
3181
- return a.__snapshot;
3182
- for (const u in i)
3183
- a[u] = o[u];
3184
- return a.__snapshot = t(o), a.__snapshot;
3185
- }, [i, t]);
3186
- return J.useSyncExternalStore(r, n, n);
3180
+ if (!h && d.__snapshot)
3181
+ return d.__snapshot;
3182
+ for (const p in o)
3183
+ d[p] = v[p];
3184
+ return d.__snapshot = l.current(v), d.__snapshot;
3185
+ }, [i]);
3186
+ return Y.useSyncExternalStore(c, u, u);
3187
3187
  }
3188
- function Be(i) {
3188
+ function We(s) {
3189
3189
  const e = {
3190
- value: i.value,
3191
- disabled: i.disabled,
3192
- errors: i.errors,
3193
- pending: i.pending,
3194
- valid: i.valid,
3195
- invalid: i.invalid,
3196
- touched: i.touched,
3197
- shouldShowError: i.shouldShowError,
3198
- componentProps: i.componentProps
3190
+ value: s.value,
3191
+ disabled: s.disabled,
3192
+ errors: s.errors,
3193
+ pending: s.pending,
3194
+ valid: s.valid,
3195
+ invalid: s.invalid,
3196
+ touched: s.touched,
3197
+ dirty: s.dirty,
3198
+ shouldShowError: s.shouldShowError,
3199
+ componentProps: s.componentProps
3199
3200
  }, t = [
3200
3201
  { key: "value" },
3201
3202
  { key: "disabled" },
@@ -3204,9 +3205,10 @@ function Be(i) {
3204
3205
  { key: "valid" },
3205
3206
  { key: "invalid" },
3206
3207
  { key: "touched" },
3208
+ { key: "dirty" },
3207
3209
  { key: "shouldShowError" },
3208
3210
  { key: "componentProps" }
3209
- ], s = E(
3211
+ ], i = E(
3210
3212
  (r) => ({
3211
3213
  value: r.value,
3212
3214
  pending: r.pending,
@@ -3215,23 +3217,25 @@ function Be(i) {
3215
3217
  valid: r.valid,
3216
3218
  invalid: r.invalid,
3217
3219
  touched: r.touched,
3220
+ dirty: r.dirty,
3218
3221
  shouldShowError: r.shouldShowError,
3219
3222
  componentProps: r.componentProps
3220
3223
  }),
3221
3224
  []
3222
3225
  );
3223
- return Y(e, t, s);
3226
+ return Q(e, t, i, s);
3224
3227
  }
3225
- function Ge(i) {
3228
+ function qe(s) {
3226
3229
  const e = {
3227
- value: i.value,
3228
- length: i.length,
3229
- errors: i.errors,
3230
- pending: i.pending,
3231
- valid: i.valid,
3232
- invalid: i.invalid,
3233
- touched: i.touched,
3234
- dirty: i.dirty
3230
+ value: s.value,
3231
+ length: s.length,
3232
+ errors: s.errors,
3233
+ pending: s.pending,
3234
+ valid: s.valid,
3235
+ invalid: s.invalid,
3236
+ touched: s.touched,
3237
+ dirty: s.dirty,
3238
+ disabled: s.disabled
3235
3239
  }, t = [
3236
3240
  { key: "value" },
3237
3241
  { key: "length" },
@@ -3240,8 +3244,9 @@ function Ge(i) {
3240
3244
  { key: "valid" },
3241
3245
  { key: "invalid" },
3242
3246
  { key: "touched" },
3243
- { key: "dirty" }
3244
- ], s = E(
3247
+ { key: "dirty" },
3248
+ { key: "disabled" }
3249
+ ], i = E(
3245
3250
  (r) => ({
3246
3251
  value: r.value,
3247
3252
  length: r.length,
@@ -3250,14 +3255,15 @@ function Ge(i) {
3250
3255
  valid: r.valid,
3251
3256
  invalid: r.invalid,
3252
3257
  touched: r.touched,
3253
- dirty: r.dirty
3258
+ dirty: r.dirty,
3259
+ disabled: r.disabled
3254
3260
  }),
3255
3261
  []
3256
3262
  );
3257
- return Y(e, t, s);
3263
+ return Q(e, t, i, s);
3258
3264
  }
3259
- function Ue() {
3260
- const i = E(
3265
+ function Ke() {
3266
+ const s = E(
3261
3267
  () => ({
3262
3268
  value: [],
3263
3269
  length: 0,
@@ -3266,96 +3272,98 @@ function Ue() {
3266
3272
  valid: !0,
3267
3273
  invalid: !1,
3268
3274
  touched: !1,
3269
- dirty: !1
3275
+ dirty: !1,
3276
+ disabled: !1
3270
3277
  }),
3271
3278
  []
3272
3279
  );
3273
- return Y({}, [], i);
3280
+ return Q({}, [], s);
3274
3281
  }
3275
- function et(i) {
3276
- const e = i && "length" in i && "map" in i;
3277
- return i ? e ? Ge(i) : Be(i) : Ue();
3282
+ function st(s) {
3283
+ const e = s && "length" in s && "map" in s;
3284
+ return s ? e ? qe(s) : We(s) : Ke();
3278
3285
  }
3279
- function tt(i) {
3280
- const e = q({ value: i.value.value }), t = E(
3286
+ function it(s) {
3287
+ const e = M({ value: s.value.value }), t = E(
3281
3288
  (r) => {
3282
3289
  let n = !0;
3283
3290
  return _(() => {
3284
- if (i.value.value, n) {
3291
+ if (s.value.value, n) {
3285
3292
  n = !1;
3286
3293
  return;
3287
3294
  }
3288
3295
  r();
3289
3296
  });
3290
3297
  },
3291
- [i]
3292
- ), s = E(() => {
3293
- const r = i.value.value;
3298
+ [s]
3299
+ ), i = E(() => {
3300
+ const r = s.value.value;
3294
3301
  return e.current.value === r ? e.current.value : (e.current.value = r, r);
3295
- }, [i]);
3296
- return J.useSyncExternalStore(t, s, s);
3302
+ }, [s]);
3303
+ return Y.useSyncExternalStore(t, i, i);
3297
3304
  }
3298
- function st(i) {
3299
- const e = q({ length: i.length.value }), t = E(
3305
+ function rt(s) {
3306
+ const e = M({ length: s.length.value }), t = E(
3300
3307
  (r) => {
3301
3308
  let n = !0;
3302
3309
  return _(() => {
3303
- if (i.length.value, n) {
3310
+ if (s.length.value, n) {
3304
3311
  n = !1;
3305
3312
  return;
3306
3313
  }
3307
3314
  r();
3308
3315
  });
3309
3316
  },
3310
- [i]
3311
- ), s = E(() => {
3312
- const r = i.length.value;
3317
+ [s]
3318
+ ), i = E(() => {
3319
+ const r = s.length.value;
3313
3320
  return e.current.length === r ? e.current.length : (e.current.length = r, r);
3314
- }, [i]);
3315
- return J.useSyncExternalStore(t, s, s);
3321
+ }, [s]);
3322
+ return Y.useSyncExternalStore(t, i, i);
3316
3323
  }
3317
3324
  export {
3318
- X as ArrayNode,
3319
- S as ErrorStrategy,
3320
- _e as FieldNode,
3321
- O as FormErrorHandler,
3322
- D as FormNode,
3323
- be as FormStatusMachine,
3324
- we as FormSubmitter,
3325
- x as GroupNode,
3326
- Fe as ModelArrayNode,
3327
- ke as NodeFactory,
3325
+ te as ArrayNode,
3326
+ O as ErrorStrategy,
3327
+ Se as FieldNode,
3328
+ N as FormErrorHandler,
3329
+ L as FormNode,
3330
+ Ae as FormStatusMachine,
3331
+ ke as FormSubmitter,
3332
+ P as GroupNode,
3333
+ Pe as ModelArrayNode,
3334
+ Ne as NodeFactory,
3328
3335
  K as SubscriptionManager,
3329
- nt as computeFrom,
3330
- at as copyFrom,
3331
- Je as createForm,
3332
- ce as createFormFromModel,
3333
- Ye as createModel,
3334
- ot as disableWhen,
3335
- lt as enableWhen,
3336
- Q as getNodeForSignal,
3337
- ze as getNodeType,
3338
- Ne as isArrayNode,
3339
- B as isDerived,
3340
- Ve as isFieldNode,
3341
- I as isFormNode,
3342
- Oe as isGroupNode,
3343
- ut as markDerived,
3344
- ye as registerSignalNode,
3345
- ct as resetWhen,
3346
- ht as revalidateWhen,
3347
- dt as runOutsideEffect,
3348
- ft as safeCallback,
3349
- pt as safeDebouncedCallback,
3350
- vt as syncFields,
3351
- mt as transformValue,
3352
- V as uniqueId,
3353
- st as useArrayLength,
3354
- et as useFormControl,
3355
- tt as useFormControlValue,
3356
- Ze as validateFormModel,
3357
- Xe as validateModel,
3358
- Qe as validateModelSync,
3359
- bt as validators,
3360
- yt as watchField
3336
+ ot as computeFrom,
3337
+ lt as copyFrom,
3338
+ et as createForm,
3339
+ ve as createFormFromModel,
3340
+ tt as createModel,
3341
+ ut as disableWhen,
3342
+ ct as enableWhen,
3343
+ X as getNodeForSignal,
3344
+ Qe as getNodeType,
3345
+ Me as isArrayNode,
3346
+ G as isDerived,
3347
+ Oe as isFieldNode,
3348
+ R as isFormNode,
3349
+ Fe as isGroupNode,
3350
+ ht as markDerived,
3351
+ _e as registerSignalNode,
3352
+ dt as resetWhen,
3353
+ ft as revalidateWhen,
3354
+ pt as runOutsideEffect,
3355
+ vt as safeCallback,
3356
+ mt as safeDebouncedCallback,
3357
+ yt as syncFields,
3358
+ gt as transformValue,
3359
+ k as uniqueId,
3360
+ bt as unmarkDerived,
3361
+ rt as useArrayLength,
3362
+ st as useFormControl,
3363
+ it as useFormControlValue,
3364
+ Te as validateFormModel,
3365
+ Ze as validateModel,
3366
+ Xe as validateModelSync,
3367
+ At as validators,
3368
+ _t as watchField
3361
3369
  };