@reformer/core 9.0.0 → 9.1.0

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.
Files changed (105) hide show
  1. package/README.md +52 -57
  2. package/dist/behaviors-node-BMOI2JJF.js +26 -0
  3. package/dist/behaviors-value-lCpqicfa.js +148 -0
  4. package/dist/behaviors.d.ts +2 -133
  5. package/dist/behaviors.js +148 -147
  6. package/dist/{core/utils → form}/aggregate-signals.d.ts +2 -2
  7. package/dist/form/behaviors-node.d.ts +55 -0
  8. package/dist/form/behaviors.d.ts +133 -0
  9. package/dist/{core/utils → form}/create-form.d.ts +5 -4
  10. package/dist/{core/utils → form}/error-handler.d.ts +1 -1
  11. package/dist/{core → form}/factories/node-factory.d.ts +1 -1
  12. package/dist/{core/utils → form}/form-proxy-builder.d.ts +2 -2
  13. package/dist/{core/utils → form}/form-submitter.d.ts +6 -1
  14. package/dist/{hooks → form/hooks}/types.d.ts +31 -1
  15. package/dist/{hooks → form/hooks}/useArrayLength.d.ts +1 -1
  16. package/dist/{hooks → form/hooks}/useFormControl.d.ts +3 -3
  17. package/dist/{hooks → form/hooks}/useFormControlValue.d.ts +2 -2
  18. package/dist/{hooks → form/hooks}/useSignalSubscription.d.ts +8 -1
  19. package/dist/form/index.d.ts +36 -0
  20. package/dist/{core → form}/nodes/array-node.d.ts +1 -1
  21. package/dist/{core → form}/nodes/field-node.d.ts +1 -1
  22. package/dist/{core → form}/nodes/form-node.d.ts +1 -1
  23. package/dist/{core → form}/nodes/group-node.d.ts +34 -4
  24. package/dist/{core → form}/nodes/model-array-node.d.ts +10 -3
  25. package/dist/{core/utils → form}/signal-node-registry.d.ts +1 -1
  26. package/dist/{core/utils → form}/status-machine.d.ts +1 -1
  27. package/dist/{core/utils → form}/type-guards.d.ts +5 -5
  28. package/dist/{core/types/index.d.ts → form/types/contracts.d.ts} +11 -90
  29. package/dist/{core → form}/types/deep-schema.d.ts +23 -1
  30. package/dist/{core → form}/types/form-proxy.d.ts +26 -1
  31. package/dist/form/types/index.d.ts +91 -0
  32. package/dist/{core → form}/types/schema-node.d.ts +1 -1
  33. package/dist/{core → form}/types/validation-schema.d.ts +19 -9
  34. package/dist/{core/model/validate-model.d.ts → form/validate-model-core.d.ts} +25 -25
  35. package/dist/form/validate-model.d.ts +27 -0
  36. package/dist/{core → form}/validation/validators/required.d.ts +2 -1
  37. package/dist/form/validators.d.ts +6 -0
  38. package/dist/form-model-C8Fi83k4.js +439 -0
  39. package/dist/index.d.ts +11 -16
  40. package/dist/index.js +666 -1011
  41. package/dist/{core/model/behaviors.d.ts → state/behaviors-value.d.ts} +0 -38
  42. package/dist/{core/utils → state}/derived-registry.d.ts +29 -0
  43. package/dist/state/form-model.d.ts +26 -0
  44. package/dist/state/index.d.ts +31 -0
  45. package/dist/state/safe-effect.d.ts +93 -0
  46. package/dist/{core/model → state}/types.d.ts +14 -11
  47. package/dist/state.d.ts +2 -0
  48. package/dist/state.js +19 -0
  49. package/dist/validators/email.d.ts +1 -1
  50. package/dist/validators/future-date.d.ts +1 -1
  51. package/dist/validators/integer.d.ts +1 -1
  52. package/dist/validators/is-date.d.ts +1 -1
  53. package/dist/validators/is-number.d.ts +1 -1
  54. package/dist/validators/max-age.d.ts +1 -1
  55. package/dist/validators/max-date.d.ts +1 -1
  56. package/dist/validators/max-length.d.ts +1 -1
  57. package/dist/validators/max.d.ts +1 -1
  58. package/dist/validators/min-age.d.ts +1 -1
  59. package/dist/validators/min-date.d.ts +1 -1
  60. package/dist/validators/min-length.d.ts +1 -1
  61. package/dist/validators/min.d.ts +1 -1
  62. package/dist/validators/multiple-of.d.ts +1 -1
  63. package/dist/validators/non-negative.d.ts +1 -1
  64. package/dist/validators/non-zero.d.ts +1 -1
  65. package/dist/validators/past-date.d.ts +1 -1
  66. package/dist/validators/pattern.d.ts +1 -1
  67. package/dist/validators/pattern.js +7 -6
  68. package/dist/validators/phone.d.ts +1 -1
  69. package/dist/validators/required.d.ts +1 -1
  70. package/dist/validators/required.js +5 -9
  71. package/dist/validators/url.d.ts +1 -1
  72. package/dist/validators.d.ts +6 -6
  73. package/llms.txt +307 -166
  74. package/package.json +5 -1
  75. package/dist/behaviors-O9a1Djj9.js +0 -147
  76. package/dist/core/model/form-model.d.ts +0 -18
  77. package/dist/core/model/index.d.ts +0 -12
  78. package/dist/core/utils/index.d.ts +0 -18
  79. package/dist/core/utils/safe-effect.d.ts +0 -73
  80. /package/dist/{core → form}/factories/index.d.ts +0 -0
  81. /package/dist/{core/utils → form}/unique-id.d.ts +0 -0
  82. /package/dist/{core → form}/validation/index.d.ts +0 -0
  83. /package/dist/{core → form}/validation/validators/date-utils.d.ts +0 -0
  84. /package/dist/{core → form}/validation/validators/email.d.ts +0 -0
  85. /package/dist/{core → form}/validation/validators/future-date.d.ts +0 -0
  86. /package/dist/{core → form}/validation/validators/index.d.ts +0 -0
  87. /package/dist/{core → form}/validation/validators/integer.d.ts +0 -0
  88. /package/dist/{core → form}/validation/validators/is-date.d.ts +0 -0
  89. /package/dist/{core → form}/validation/validators/is-number.d.ts +0 -0
  90. /package/dist/{core → form}/validation/validators/max-age.d.ts +0 -0
  91. /package/dist/{core → form}/validation/validators/max-date.d.ts +0 -0
  92. /package/dist/{core → form}/validation/validators/max-length.d.ts +0 -0
  93. /package/dist/{core → form}/validation/validators/max.d.ts +0 -0
  94. /package/dist/{core → form}/validation/validators/min-age.d.ts +0 -0
  95. /package/dist/{core → form}/validation/validators/min-date.d.ts +0 -0
  96. /package/dist/{core → form}/validation/validators/min-length.d.ts +0 -0
  97. /package/dist/{core → form}/validation/validators/min.d.ts +0 -0
  98. /package/dist/{core → form}/validation/validators/multiple-of.d.ts +0 -0
  99. /package/dist/{core → form}/validation/validators/non-negative.d.ts +0 -0
  100. /package/dist/{core → form}/validation/validators/non-zero.d.ts +0 -0
  101. /package/dist/{core → form}/validation/validators/past-date.d.ts +0 -0
  102. /package/dist/{core → form}/validation/validators/pattern.d.ts +0 -0
  103. /package/dist/{core → form}/validation/validators/phone.d.ts +0 -0
  104. /package/dist/{core → form}/validation/validators/url.d.ts +0 -0
  105. /package/dist/{core/utils → state}/subscription-manager.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,9 +1,13 @@
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 { S as I } from "./form-model-C8Fi83k4.js";
2
+ import { c as Ge } from "./form-model-C8Fi83k4.js";
3
+ import { i as G } from "./behaviors-value-lCpqicfa.js";
4
+ import { c as We, a as qe, m as He, r as Ke, b as Je, d as Ye, e as ze, f as Qe, s as Xe, t as Ze, u as et, w as tt } from "./behaviors-value-lCpqicfa.js";
5
+ import { default as rt } from "./validators.js";
6
+ import { signal as g, computed as f, effect as b, batch as ie, Signal as z } from "@preact/signals-core";
7
+ import { g as U, r as ne } from "./behaviors-node-BMOI2JJF.js";
8
+ import { d as nt, e as at } from "./behaviors-node-BMOI2JJF.js";
9
+ import Q, { useRef as N, useCallback as E } from "react";
10
+ class C {
7
11
  // ============================================================================
8
12
  // Protected состояние (для Template Method паттерна)
9
13
  // ============================================================================
@@ -11,17 +15,17 @@ class D {
11
15
  * Пользователь взаимодействовал с узлом (touched)
12
16
  * Protected: наследники могут читать/изменять через методы
13
17
  */
14
- _touched = y(!1);
18
+ _touched = g(!1);
15
19
  /**
16
20
  * Значение узла было изменено (dirty)
17
21
  * Protected: наследники могут читать/изменять через методы
18
22
  */
19
- _dirty = y(!1);
23
+ _dirty = g(!1);
20
24
  /**
21
25
  * Текущий статус узла
22
26
  * Protected: наследники могут читать/изменять через методы
23
27
  */
24
- _status = y("valid");
28
+ _status = g("valid");
25
29
  // ============================================================================
26
30
  // Публичные computed signals (readonly для внешнего мира)
27
31
  // ============================================================================
@@ -29,33 +33,33 @@ class D {
29
33
  * Пользователь взаимодействовал с узлом (touched)
30
34
  * Computed из _touched для предоставления readonly интерфейса
31
35
  */
32
- touched = h(() => this._touched.value);
36
+ touched = f(() => this._touched.value);
33
37
  /**
34
38
  * Пользователь не взаимодействовал с узлом (untouched)
35
39
  */
36
- untouched = h(() => !this._touched.value);
40
+ untouched = f(() => !this._touched.value);
37
41
  /**
38
42
  * Значение узла было изменено (dirty)
39
43
  * Computed из _dirty для предоставления readonly интерфейса
40
44
  */
41
- dirty = h(() => this._dirty.value);
45
+ dirty = f(() => this._dirty.value);
42
46
  /**
43
47
  * Значение узла не было изменено (pristine)
44
48
  */
45
- pristine = h(() => !this._dirty.value);
49
+ pristine = f(() => !this._dirty.value);
46
50
  /**
47
51
  * Текущий статус узла
48
52
  * Computed из _status для предоставления readonly интерфейса
49
53
  */
50
- status = h(() => this._status.value);
54
+ status = f(() => this._status.value);
51
55
  /**
52
56
  * Узел отключен (disabled)
53
57
  */
54
- disabled = h(() => this._status.value === "disabled");
58
+ disabled = f(() => this._status.value === "disabled");
55
59
  /**
56
60
  * Узел включен (enabled)
57
61
  */
58
- enabled = h(() => this._status.value !== "disabled");
62
+ enabled = f(() => this._status.value !== "disabled");
59
63
  /**
60
64
  * Получить ошибки валидации с фильтрацией
61
65
  *
@@ -103,8 +107,8 @@ class D {
103
107
  if (e.params !== void 0) {
104
108
  if (!s.params)
105
109
  return !1;
106
- for (const [r, n] of Object.entries(e.params))
107
- if (s.params[r] !== n)
110
+ for (const [i, n] of Object.entries(e.params))
111
+ if (s.params[i] !== n)
108
112
  return !1;
109
113
  }
110
114
  return !(e.predicate !== void 0 && !e.predicate(s));
@@ -280,175 +284,7 @@ class D {
280
284
  onEnable() {
281
285
  }
282
286
  }
283
- class K {
284
- /**
285
- * Хранилище подписок
286
- * Ключ: уникальный идентификатор подписки
287
- * Значение: функция отписки (dispose)
288
- */
289
- subscriptions = /* @__PURE__ */ new Map();
290
- /**
291
- * Добавляет подписку
292
- *
293
- * Если подписка с таким ключом уже существует, отписывается от неё
294
- * и заменяет новой. Это предотвращает утечки памяти при повторной
295
- * регистрации подписки с тем же ключом.
296
- *
297
- * @param key Уникальный ключ подписки
298
- * @param dispose Функция отписки (обычно возвращаемая из effect())
299
- * @returns Функция для отписки от этой конкретной подписки
300
- *
301
- * @example
302
- * ```typescript
303
- * const manager = new SubscriptionManager();
304
- *
305
- * // Добавление подписки
306
- * const unsubscribe = manager.add('mySubscription', () => {
307
- * console.log('Disposing subscription');
308
- * });
309
- *
310
- * // Отписка через возвращаемую функцию
311
- * unsubscribe();
312
- *
313
- * // Или через manager.remove()
314
- * manager.add('anotherSub', disposeFn);
315
- * manager.remove('anotherSub');
316
- * ```
317
- */
318
- add(e, t) {
319
- return this.subscriptions.has(e) && (process.env.NODE_ENV !== "production" && console.warn(`[SubscriptionManager] Subscription "${e}" already exists, replacing`), this.subscriptions.get(e)?.()), this.subscriptions.set(e, t), () => this.remove(e);
320
- }
321
- /**
322
- * Удаляет подписку по ключу
323
- *
324
- * Вызывает функцию отписки и удаляет подписку из хранилища.
325
- * Если подписка с таким ключом не найдена, ничего не делает.
326
- *
327
- * @param key Ключ подписки
328
- * @returns true, если подписка была удалена, false если не найдена
329
- *
330
- * @example
331
- * ```typescript
332
- * const manager = new SubscriptionManager();
333
- * manager.add('mySub', disposeFn);
334
- *
335
- * // Удаление подписки
336
- * const removed = manager.remove('mySub'); // true
337
- *
338
- * // Попытка удалить несуществующую подписку
339
- * const removed2 = manager.remove('nonExistent'); // false
340
- * ```
341
- */
342
- remove(e) {
343
- const t = this.subscriptions.get(e);
344
- return t ? (t(), this.subscriptions.delete(e), !0) : !1;
345
- }
346
- /**
347
- * Очищает все подписки
348
- *
349
- * Вызывает функции отписки для всех активных подписок
350
- * и очищает хранилище. Обычно используется при dispose узла формы.
351
- *
352
- * @example
353
- * ```typescript
354
- * class FieldNode {
355
- * private subscriptions = new SubscriptionManager();
356
- *
357
- * dispose() {
358
- * // Отписываемся от всех effect
359
- * this.subscriptions.clear();
360
- * }
361
- * }
362
- * ```
363
- */
364
- clear() {
365
- this.subscriptions.forEach((e) => {
366
- e();
367
- }), this.subscriptions.clear();
368
- }
369
- /**
370
- * Возвращает количество активных подписок
371
- *
372
- * Полезно для отладки утечек памяти. Если количество подписок
373
- * растет без ограничений, это может указывать на то, что
374
- * компоненты не отписываются должным образом.
375
- *
376
- * @returns Количество активных подписок
377
- *
378
- * @example
379
- * ```typescript
380
- * const manager = new SubscriptionManager();
381
- * console.log(manager.size()); // 0
382
- *
383
- * manager.add('sub1', disposeFn1);
384
- * manager.add('sub2', disposeFn2);
385
- * console.log(manager.size()); // 2
386
- *
387
- * manager.clear();
388
- * console.log(manager.size()); // 0
389
- * ```
390
- */
391
- size() {
392
- return this.subscriptions.size;
393
- }
394
- /**
395
- * Проверяет, есть ли подписка с данным ключом
396
- *
397
- * @param key Ключ подписки
398
- * @returns true, если подписка существует
399
- *
400
- * @example
401
- * ```typescript
402
- * const manager = new SubscriptionManager();
403
- * manager.add('mySub', disposeFn);
404
- *
405
- * console.log(manager.has('mySub')); // true
406
- * console.log(manager.has('nonExistent')); // false
407
- * ```
408
- */
409
- has(e) {
410
- return this.subscriptions.has(e);
411
- }
412
- /**
413
- * Возвращает список всех ключей активных подписок
414
- *
415
- * Полезно для отладки: можно увидеть, какие подписки активны.
416
- *
417
- * @returns Массив ключей всех активных подписок
418
- *
419
- * @example
420
- * ```typescript
421
- * const manager = new SubscriptionManager();
422
- * manager.add('watch-value', disposeFn1);
423
- * manager.add('watch-errors', disposeFn2);
424
- *
425
- * console.log(manager.getKeys()); // ['watch-value', 'watch-errors']
426
- * ```
427
- */
428
- getKeys() {
429
- return Array.from(this.subscriptions.keys());
430
- }
431
- /**
432
- * Отписывается от всех подписок (алиас для clear())
433
- *
434
- * Используется при dispose() узла формы для совместимости с ожидаемым API.
435
- *
436
- * @example
437
- * ```typescript
438
- * class FieldNode {
439
- * private subscriptions = new SubscriptionManager();
440
- *
441
- * dispose() {
442
- * this.subscriptions.dispose();
443
- * }
444
- * }
445
- * ```
446
- */
447
- dispose() {
448
- this.clear();
449
- }
450
- }
451
- const k = {
287
+ const w = {
452
288
  /** FieldNode.watch() */
453
289
  Watch: "watch",
454
290
  /** FieldNode.computeFrom() */
@@ -462,15 +298,15 @@ const k = {
462
298
  /** ArrayNode.watchLength() */
463
299
  WatchLength: "watchLength"
464
300
  };
465
- let ge = 0;
466
- function V(i) {
467
- return `${i}-${++ge}`;
301
+ let ae = 0;
302
+ function V(r) {
303
+ return `${r}-${++ae}`;
468
304
  }
469
- var S = /* @__PURE__ */ ((i) => (i.THROW = "throw", i.LOG = "log", i.CONVERT = "convert", i))(S || {});
305
+ var A = /* @__PURE__ */ ((r) => (r.THROW = "throw", r.LOG = "log", r.CONVERT = "convert", r))(A || {});
470
306
  class O {
471
307
  static handle(e, t, s = "throw") {
472
- const r = this.extractMessage(e);
473
- switch (s) {
308
+ const i = this.extractMessage(e);
309
+ switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), s) {
474
310
  case "throw":
475
311
  throw e;
476
312
  case "log":
@@ -478,7 +314,7 @@ class O {
478
314
  case "convert":
479
315
  return {
480
316
  code: "validator_error",
481
- message: r,
317
+ message: i,
482
318
  params: { field: t }
483
319
  };
484
320
  }
@@ -560,7 +396,7 @@ class O {
560
396
  return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
561
397
  }
562
398
  }
563
- class be {
399
+ class oe {
564
400
  /** Внутренний сигнал статуса */
565
401
  _status;
566
402
  /** Публичный read-only сигнал статуса */
@@ -577,7 +413,7 @@ class be {
577
413
  * @param initial - Начальный статус (по умолчанию 'valid')
578
414
  */
579
415
  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");
416
+ this._status = g(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
417
  }
582
418
  /**
583
419
  * Начать валидацию
@@ -705,7 +541,7 @@ class be {
705
541
  return this._status.value !== "disabled";
706
542
  }
707
543
  }
708
- class _e extends D {
544
+ class le extends C {
709
545
  // ============================================================================
710
546
  // Приватные сигналы
711
547
  // ============================================================================
@@ -757,13 +593,13 @@ class _e extends D {
757
593
  * Менеджер подписок для централизованного cleanup
758
594
  * Использует SubscriptionManager вместо массива для управления подписками
759
595
  */
760
- disposers = new K();
596
+ disposers = new I();
761
597
  component;
762
598
  // ============================================================================
763
599
  // Конструктор
764
600
  // ============================================================================
765
601
  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(
602
+ 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 ?? g(e.value), this.initialValue = this._value.peek(), this._errors = g([]), this._componentProps = g(e.componentProps || {}), this.statusMachine = new oe(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
603
  () => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
768
604
  );
769
605
  }
@@ -776,12 +612,12 @@ class _e extends D {
776
612
  setValue(e, t) {
777
613
  if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
778
614
  return;
779
- const s = this.validators.length > 0 || this.asyncValidators.length > 0, r = this._errors.value.length > 0;
615
+ const s = this.validators.length > 0 || this.asyncValidators.length > 0, i = this._errors.value.length > 0;
780
616
  if (this.updateOn === "change") {
781
617
  this.validate();
782
618
  return;
783
619
  }
784
- r && s && this.validate();
620
+ i && s && this.validate();
785
621
  }
786
622
  patchValue(e) {
787
623
  this.setValue(e);
@@ -875,19 +711,19 @@ class _e extends D {
875
711
  if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
876
712
  return this.validateImmediate();
877
713
  const s = new AbortController();
878
- return new Promise((r) => {
879
- this.pendingValidation = { resolve: r, abortController: s }, this.validateDebounceTimer = setTimeout(async () => {
714
+ return new Promise((i) => {
715
+ this.pendingValidation = { resolve: i, abortController: s }, this.validateDebounceTimer = setTimeout(async () => {
880
716
  if (this.validateDebounceTimer = void 0, s.signal.aborted) {
881
- r(!1);
717
+ i(!1);
882
718
  return;
883
719
  }
884
720
  this.pendingValidation = void 0;
885
721
  const n = await this.validateImmediate(s);
886
- r(n);
722
+ i(n);
887
723
  }, t), s.signal.addEventListener(
888
724
  "abort",
889
725
  () => {
890
- this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), r(!1);
726
+ this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), i(!1);
891
727
  },
892
728
  { once: !0 }
893
729
  );
@@ -906,16 +742,16 @@ class _e extends D {
906
742
  async validateImmediate(e) {
907
743
  const t = e ?? new AbortController();
908
744
  e || this.currentAbortController?.abort(), this.currentAbortController = t;
909
- const { signal: s } = t, r = [];
745
+ const { signal: s } = t, i = [];
910
746
  for (const a of this.validators) {
911
- const o = a(this._value.value);
912
- o && r.push(o);
747
+ const l = a(this._value.value);
748
+ l && i.push(l);
913
749
  }
914
750
  if (s.aborted)
915
751
  return !1;
916
- if (r.length > 0) {
917
- this._errors.value = r;
918
- const a = r.some((o) => o.severity !== "warning");
752
+ if (i.length > 0) {
753
+ this._errors.value = i;
754
+ const a = i.some((l) => l.severity !== "warning");
919
755
  if (this.statusMachine.setErrors(a), a)
920
756
  return !1;
921
757
  }
@@ -925,11 +761,11 @@ class _e extends D {
925
761
  this.statusMachine.startValidation();
926
762
  try {
927
763
  const a = await Promise.all(
928
- this.asyncValidators.map(async (l) => {
764
+ this.asyncValidators.map(async (d) => {
929
765
  if (s.aborted)
930
766
  throw new DOMException("Validation aborted", "AbortError");
931
767
  try {
932
- const u = await l(this._value.value, { signal: s });
768
+ const u = await d(this._value.value, { signal: s });
933
769
  if (s.aborted)
934
770
  throw new DOMException("Validation aborted", "AbortError");
935
771
  return u;
@@ -939,18 +775,18 @@ class _e extends D {
939
775
  return O.handle(
940
776
  u,
941
777
  "FieldNode AsyncValidator",
942
- S.CONVERT
778
+ A.CONVERT
943
779
  );
944
780
  }
945
781
  })
946
782
  );
947
783
  if (s.aborted)
948
784
  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)
785
+ const l = a.filter((d) => d !== null);
786
+ if (l.length > 0) {
787
+ this._errors.value = l;
788
+ const d = l.some((u) => u.severity !== "warning");
789
+ if (this.statusMachine.completeValidation(d), d)
954
790
  return !1;
955
791
  }
956
792
  } catch (a) {
@@ -1080,11 +916,11 @@ class _e extends D {
1080
916
  * ```
1081
917
  */
1082
918
  watch(e) {
1083
- const t = new AbortController(), s = _(() => {
919
+ const t = new AbortController(), s = b(() => {
1084
920
  const n = this.value.value;
1085
921
  e(n, t.signal);
1086
- }), r = V(k.Watch);
1087
- return this.disposers.add(r, () => {
922
+ }), i = V(w.Watch);
923
+ return this.disposers.add(i, () => {
1088
924
  t.abort(), s();
1089
925
  });
1090
926
  }
@@ -1111,11 +947,11 @@ class _e extends D {
1111
947
  * ```
1112
948
  */
1113
949
  computeFrom(e, t) {
1114
- const s = _(() => {
1115
- const n = e.map((o) => o.value), a = t(...n);
950
+ const s = b(() => {
951
+ const n = e.map((l) => l.value), a = t(...n);
1116
952
  this.setValue(a, { emitEvent: !1 });
1117
- }), r = V(k.ComputeFrom);
1118
- return this.disposers.add(r, s);
953
+ }), i = V(w.ComputeFrom);
954
+ return this.disposers.add(i, s);
1119
955
  }
1120
956
  /**
1121
957
  * Очистить все ресурсы и таймеры
@@ -1145,46 +981,59 @@ class _e extends D {
1145
981
  }
1146
982
  }
1147
983
  }
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");
984
+ function L(r) {
985
+ const { getChildren: e, ownErrors: t, disabled: s } = r, i = f(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = f(() => !i.value), a = f(() => e().some((o) => o.pending.value)), l = f(() => e().some((o) => o.touched.value)), d = f(() => e().some((o) => o.dirty.value)), u = f(() => {
986
+ const o = [...t.value];
987
+ for (const p of e())
988
+ o.push(...p.errors.value);
989
+ return o;
990
+ }), h = f(() => s?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
1155
991
  return {
1156
- valid: r,
992
+ valid: i,
1157
993
  invalid: n,
1158
994
  pending: a,
1159
- touched: o,
1160
- dirty: l,
995
+ touched: l,
996
+ dirty: d,
1161
997
  errors: u,
1162
- status: m
998
+ status: h
1163
999
  };
1164
1000
  }
1165
- function Ee(i) {
1166
- return typeof i == "object" && i !== null && "getProxy" in i && typeof i.getProxy == "function";
1001
+ function W(r) {
1002
+ return typeof r == "object" && r !== null && "getProxy" in r && typeof r.getProxy == "function";
1167
1003
  }
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;
1004
+ const q = "$";
1005
+ function ue(r, e) {
1006
+ let t;
1007
+ const s = () => {
1008
+ if (!t) {
1009
+ const i = {};
1010
+ e.forEach((n, a) => {
1011
+ i[a] = n && W(n) ? n.getProxy() : n;
1012
+ }), t = i;
1013
+ }
1014
+ return t;
1015
+ };
1016
+ return new Proxy(r, {
1017
+ get: (i, n) => {
1018
+ if (n === q)
1019
+ return s();
1020
+ if (n in i)
1021
+ return i[n];
1022
+ if (typeof n == "string" && e.has(n)) {
1023
+ const a = e.get(n);
1024
+ return a && W(a) ? a.getProxy() : a;
1176
1025
  }
1177
1026
  },
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])];
1027
+ set: (i, n, a) => typeof n == "string" && e.has(n) ? !1 : (i[n] = a, !0),
1028
+ has: (i, n) => n === q || typeof n == "string" && e.has(n) ? !0 : n in i,
1029
+ ownKeys: (i) => {
1030
+ const n = Reflect.ownKeys(i), a = Array.from(e.keys());
1031
+ return [.../* @__PURE__ */ new Set([...n, ...a])];
1183
1032
  },
1184
- getOwnPropertyDescriptor: (t, s) => typeof s == "string" && e.has(s) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(t, s)
1033
+ getOwnPropertyDescriptor: (i, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(i, n)
1185
1034
  });
1186
1035
  }
1187
- class we {
1036
+ class de {
1188
1037
  /**
1189
1038
  * @param form - Форма для отправки
1190
1039
  */
@@ -1192,9 +1041,9 @@ class we {
1192
1041
  this.form = e;
1193
1042
  }
1194
1043
  /** Внутренний сигнал состояния отправки */
1195
- _submitting = y(!1);
1044
+ _submitting = g(!1);
1196
1045
  /** Публичный read-only сигнал состояния отправки */
1197
- submitting = h(() => this._submitting.value);
1046
+ submitting = f(() => this._submitting.value);
1198
1047
  /**
1199
1048
  * Отправить форму
1200
1049
  *
@@ -1206,7 +1055,12 @@ class we {
1206
1055
  *
1207
1056
  * @param onSubmit - Callback для отправки данных
1208
1057
  * @param options - Опции submit
1209
- * @returns Результат от onSubmit или null если валидация не пройдена
1058
+ * @returns Результат от onSubmit или `null` если валидация не пройдена
1059
+ *
1060
+ * @remarks
1061
+ * Возвращаемый `null` неоднозначен: он сигналит и провал валидации, и легитимный `null`,
1062
+ * который вернул `onSubmit` (или void-обработчик). Чтобы различать эти случаи, используйте
1063
+ * {@link submitWithResult} — он отдаёт явный флаг `success`.
1210
1064
  *
1211
1065
  * @example
1212
1066
  * ```typescript
@@ -1224,8 +1078,8 @@ class we {
1224
1078
  * ```
1225
1079
  */
1226
1080
  async submit(e, t) {
1227
- const { skipValidation: s = !1, skipTouch: r = !1 } = t || {};
1228
- if (r || this.form.markAsTouched(), !s && !await this.form.validate())
1081
+ const { skipValidation: s = !1, skipTouch: i = !1 } = t || {};
1082
+ if (i || this.form.markAsTouched(), !s && !await this.form.validate())
1229
1083
  return null;
1230
1084
  this._submitting.value = !0;
1231
1085
  try {
@@ -1259,8 +1113,8 @@ class we {
1259
1113
  * ```
1260
1114
  */
1261
1115
  async submitWithResult(e, t) {
1262
- const { skipValidation: s = !1, skipTouch: r = !1 } = t || {};
1263
- if (r || this.form.markAsTouched(), !s && !await this.form.validate())
1116
+ const { skipValidation: s = !1, skipTouch: i = !1 } = t || {};
1117
+ if (i || this.form.markAsTouched(), !s && !await this.form.validate())
1264
1118
  return { success: !1, data: null };
1265
1119
  this._submitting.value = !0;
1266
1120
  try {
@@ -1282,16 +1136,16 @@ class we {
1282
1136
  return this._submitting.value;
1283
1137
  }
1284
1138
  }
1285
- function Se(i) {
1139
+ function ce(r) {
1286
1140
  const e = [];
1287
- for (const t of i.split(".")) {
1141
+ for (const t of r.split(".")) {
1288
1142
  const s = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
1289
1143
  if (!s) return [];
1290
1144
  e.push(s[2] !== void 0 ? { key: s[1], index: Number(s[2]) } : { key: s[1] });
1291
1145
  }
1292
1146
  return e;
1293
1147
  }
1294
- let x = class ae extends D {
1148
+ class S extends C {
1295
1149
  // ============================================================================
1296
1150
  // Приватные поля
1297
1151
  // ============================================================================
@@ -1304,7 +1158,7 @@ let x = class ae extends D {
1304
1158
  /**
1305
1159
  * Менеджер подписок для централизованного cleanup
1306
1160
  */
1307
- disposers = new K();
1161
+ disposers = new I();
1308
1162
  /**
1309
1163
  * Ссылка на Proxy-инстанс
1310
1164
  */
@@ -1316,7 +1170,7 @@ let x = class ae extends D {
1316
1170
  /**
1317
1171
  * Фабрика для создания узлов формы
1318
1172
  */
1319
- nodeFactory = new ke();
1173
+ nodeFactory = new he();
1320
1174
  // ============================================================================
1321
1175
  // Приватные сигналы состояния (inline из StateManager)
1322
1176
  // ============================================================================
@@ -1324,9 +1178,22 @@ let x = class ae extends D {
1324
1178
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1325
1179
  formSubmitter;
1326
1180
  /** Флаг disabled состояния */
1327
- _disabled = y(!1);
1181
+ _disabled = g(!1);
1328
1182
  /** Form-level validation errors */
1329
- _formErrors = y([]);
1183
+ _formErrors = g([]);
1184
+ /**
1185
+ * M1: валидация уровня модели/схемы (`validateFormModel(model, schema)`). Привязывается
1186
+ * `createForm({ model, schema })`, т.к. под M1 валидаторы срезаны с FieldNode и живут на слое
1187
+ * модели. Без неё `validate()`/`submit()` пропускали бы все schema-валидаторы. @internal
1188
+ */
1189
+ _modelValidate;
1190
+ /**
1191
+ * M1: связь листовой ноды-ребёнка → её сигнал модели (тот, что помечает `markDerived`).
1192
+ * Нужна bulk-сеттерам (`setValue`/`patchValue`), чтобы корректно определять derived-поля:
1193
+ * `field.value` — computed-обёртка, отличная от записываемого сигнала модели. @internal
1194
+ */
1195
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1196
+ _fieldSignals = /* @__PURE__ */ new WeakMap();
1330
1197
  // ============================================================================
1331
1198
  // Публичные computed signals
1332
1199
  // ============================================================================
@@ -1340,24 +1207,24 @@ let x = class ae extends D {
1340
1207
  status;
1341
1208
  submitting;
1342
1209
  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);
1210
+ super(), this.formSubmitter = new de(this);
1211
+ const t = e.form, s = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !s ? e.form : e;
1212
+ for (const [l, d] of Object.entries(n)) {
1213
+ const u = this.createNode(d);
1214
+ this._fields.set(l, u);
1348
1215
  }
1349
- this.value = h(() => {
1350
- const n = {};
1351
- return this._fields.forEach((a, o) => {
1352
- n[o] = a.value.value;
1353
- }), n;
1216
+ this.value = f(() => {
1217
+ const l = {};
1218
+ return this._fields.forEach((d, u) => {
1219
+ l[u] = d.value.value;
1220
+ }), l;
1354
1221
  });
1355
- const r = H({
1222
+ const a = L({
1356
1223
  getChildren: () => Array.from(this._fields.values()),
1357
1224
  ownErrors: this._formErrors,
1358
1225
  disabled: this._disabled
1359
1226
  });
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;
1227
+ 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
1228
  }
1362
1229
  // ============================================================================
1363
1230
  // Приватный метод для создания Proxy
@@ -1367,7 +1234,7 @@ let x = class ae extends D {
1367
1234
  * @see buildFormProxy
1368
1235
  */
1369
1236
  buildProxy() {
1370
- return Ae(this, this._fields);
1237
+ return ue(this, this._fields);
1371
1238
  }
1372
1239
  // ============================================================================
1373
1240
  // Реализация абстрактных методов FormNode
@@ -1379,21 +1246,23 @@ let x = class ae extends D {
1379
1246
  }), e;
1380
1247
  }
1381
1248
  setValue(e, t) {
1382
- for (const [s, r] of Object.entries(e)) {
1249
+ for (const [s, i] of Object.entries(e)) {
1383
1250
  const n = this._fields.get(s);
1384
1251
  if (n) {
1385
- if (B(n.value)) continue;
1386
- n.setValue(r, t);
1252
+ const a = this._fieldSignals.get(n) ?? n.value;
1253
+ if (G(a)) continue;
1254
+ n.setValue(i, t);
1387
1255
  }
1388
1256
  }
1389
1257
  }
1390
1258
  patchValue(e) {
1391
- me(() => {
1259
+ ie(() => {
1392
1260
  for (const [t, s] of Object.entries(e)) {
1393
- const r = this._fields.get(t);
1394
- if (r && s !== void 0) {
1395
- if (B(r.value)) continue;
1396
- r.setValue(s, { emitEvent: !1 });
1261
+ const i = this._fields.get(t);
1262
+ if (i && s !== void 0) {
1263
+ const n = this._fieldSignals.get(i) ?? i.value;
1264
+ if (G(n)) continue;
1265
+ i.setValue(s, { emitEvent: !1 });
1397
1266
  }
1398
1267
  }
1399
1268
  });
@@ -1416,23 +1285,25 @@ let x = class ae extends D {
1416
1285
  * ```
1417
1286
  */
1418
1287
  reset(e) {
1419
- this._fields.forEach((t, s) => {
1420
- const r = e?.[s];
1421
- t.reset(r);
1288
+ this._formErrors.value = [], this._fields.forEach((t, s) => {
1289
+ const i = e?.[s];
1290
+ t.reset(i);
1422
1291
  });
1423
1292
  }
1424
1293
  /**
1425
1294
  * Сбросить форму к исходным значениям (initialValues)
1426
1295
  */
1427
1296
  resetToInitial() {
1428
- this._fields.forEach((e) => {
1297
+ this._formErrors.value = [], this._fields.forEach((e) => {
1429
1298
  "resetToInitial" in e && typeof e.resetToInitial == "function" ? e.resetToInitial() : e.reset();
1430
1299
  });
1431
1300
  }
1432
1301
  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
1302
+ this.clearErrors(), await Promise.all(Array.from(this._fields.values()).map((s) => s.validate()));
1303
+ const e = this._modelValidate ? await this._modelValidate() : !0, t = Array.from(this._fields.values()).every(
1304
+ (s) => s.valid.value || s.disabled.value
1435
1305
  );
1306
+ return e && t;
1436
1307
  }
1437
1308
  /**
1438
1309
  * Установить form-level validation errors
@@ -1514,7 +1385,12 @@ let x = class ae extends D {
1514
1385
  *
1515
1386
  * @param onSubmit - Callback для отправки данных
1516
1387
  * @param options - Опции submit (skipValidation, skipTouch)
1517
- * @returns Результат от onSubmit или null если валидация не пройдена
1388
+ * @returns Результат от onSubmit или `null` если валидация не пройдена
1389
+ *
1390
+ * @remarks
1391
+ * `null` перегружен: он означает и «валидация не пройдена», и легитимный `null`-результат
1392
+ * `onSubmit` (или void-обработчик). Если вызывающей стороне нужно различать эти случаи —
1393
+ * используйте {@link submitWithResult}, который возвращает явный флаг `success`.
1518
1394
  */
1519
1395
  async submit(e, t) {
1520
1396
  return this.formSubmitter.submit(e, t);
@@ -1561,15 +1437,15 @@ let x = class ae extends D {
1561
1437
  getFieldByPath(e) {
1562
1438
  if (e.startsWith(".") || e.endsWith("."))
1563
1439
  return;
1564
- const t = Se(e);
1440
+ const t = ce(e);
1565
1441
  if (t.length === 0)
1566
1442
  return;
1567
1443
  let s = this;
1568
- for (const r of t) {
1569
- if (!(s instanceof ae) || (s = s.getField(r.key), !s)) return;
1570
- if (r.index !== void 0)
1444
+ for (const i of t) {
1445
+ if (!(s instanceof S) || (s = s.getField(i.key), !s)) return;
1446
+ if (i.index !== void 0)
1571
1447
  if ("at" in s && "length" in s && typeof s.at == "function") {
1572
- const n = s.at(r.index);
1448
+ const n = s.at(i.index);
1573
1449
  if (!n) return;
1574
1450
  s = n;
1575
1451
  } else
@@ -1605,16 +1481,16 @@ let x = class ae extends D {
1605
1481
  * Связывает два поля: при изменении source автоматически обновляется target
1606
1482
  */
1607
1483
  linkFields(e, t, s) {
1608
- const r = this._fields.get(e), n = this._fields.get(t);
1609
- if (!r || !n) {
1610
- const l = r ? t : e;
1611
- throw new Error(`GroupNode.linkFields: field "${String(l)}" not found`);
1484
+ const i = this._fields.get(e), n = this._fields.get(t);
1485
+ if (!i || !n) {
1486
+ const d = i ? t : e;
1487
+ throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
1612
1488
  }
1613
- const a = _(() => {
1614
- const l = r.value.value, u = s ? s(l) : l;
1489
+ const a = b(() => {
1490
+ const d = i.value.value, u = s ? s(d) : d;
1615
1491
  n.setValue(u, { emitEvent: !1 });
1616
- }), o = V(k.LinkFields);
1617
- return this.disposers.add(o, a);
1492
+ }), l = V(w.LinkFields);
1493
+ return this.disposers.add(l, a);
1618
1494
  }
1619
1495
  /**
1620
1496
  * Подписка на изменения вложенного поля по строковому пути
@@ -1648,10 +1524,10 @@ let x = class ae extends D {
1648
1524
  const s = this.getFieldByPath(e);
1649
1525
  if (!s)
1650
1526
  throw new Error(`GroupNode.watchField: field "${e}" not found`);
1651
- const r = _(() => {
1527
+ const i = b(() => {
1652
1528
  t(s.value.value);
1653
- }), n = V(k.WatchField);
1654
- return this.disposers.add(n, r);
1529
+ }), n = V(w.WatchField);
1530
+ return this.disposers.add(n, i);
1655
1531
  }
1656
1532
  /**
1657
1533
  * Подписка на вложенное поле по строковому пути ("address.city").
@@ -1661,10 +1537,10 @@ let x = class ae extends D {
1661
1537
  const s = this.getFieldByPath(e);
1662
1538
  if (!s)
1663
1539
  throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
1664
- const r = _(() => {
1540
+ const i = b(() => {
1665
1541
  t(s.value.value);
1666
- }), n = V(k.WatchField);
1667
- return this.disposers.add(n, r);
1542
+ }), n = V(w.WatchField);
1543
+ return this.disposers.add(n, i);
1668
1544
  }
1669
1545
  /**
1670
1546
  * Hook: вызывается после disable()
@@ -1685,6 +1561,24 @@ let x = class ae extends D {
1685
1561
  attachBehaviorCleanup(e) {
1686
1562
  this._behaviorCleanup = e;
1687
1563
  }
1564
+ /**
1565
+ * Прикрепить валидацию уровня модели/схемы (M1). Вызывается `createForm({ model, schema })`,
1566
+ * чтобы `validate()`/`submit()` прогоняли schema-валидаторы (`validateFormModel`), а не только
1567
+ * пустые FieldNode. Возвращаемый флаг — валидна ли модель по схеме.
1568
+ * @internal
1569
+ */
1570
+ attachModelValidator(e) {
1571
+ this._modelValidate = e;
1572
+ }
1573
+ /**
1574
+ * Связать листовую ноду-ребёнка с её сигналом модели (M1). Вызывается `createForm` для каждого
1575
+ * листового поля на его владеющей группе — используется bulk-сеттерами для derived-guard (F9).
1576
+ * @internal
1577
+ */
1578
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1579
+ registerFieldSignal(e, t) {
1580
+ this._fieldSignals.set(e, t);
1581
+ }
1688
1582
  /**
1689
1583
  * Очистить все ресурсы узла
1690
1584
  */
@@ -1693,7 +1587,8 @@ let x = class ae extends D {
1693
1587
  "dispose" in e && typeof e.dispose == "function" && e.dispose();
1694
1588
  });
1695
1589
  }
1696
- }, X = class extends D {
1590
+ }
1591
+ class H extends C {
1697
1592
  // ============================================================================
1698
1593
  // Приватные поля
1699
1594
  // ============================================================================
@@ -1704,9 +1599,9 @@ let x = class ae extends D {
1704
1599
  * Менеджер подписок для централизованного cleanup
1705
1600
  * Использует SubscriptionManager вместо массива для управления подписками
1706
1601
  */
1707
- disposers = new K();
1602
+ disposers = new I();
1708
1603
  /** Array-level validation errors (e.g., "минимум 1 элемент") */
1709
- _arrayErrors = y([]);
1604
+ _arrayErrors = g([]);
1710
1605
  // ============================================================================
1711
1606
  // Приватные поля для сохранения схем
1712
1607
  // ============================================================================
@@ -1728,11 +1623,11 @@ let x = class ae extends D {
1728
1623
  // Конструктор
1729
1624
  // ============================================================================
1730
1625
  constructor(e, t = []) {
1731
- super(), this.itemSchema = e, this.initialItems = t, this.items = y([]);
1732
- for (const r of t)
1733
- 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({
1626
+ super(), this.itemSchema = e, this.initialItems = t, this.items = g([]);
1627
+ for (const i of t)
1628
+ this.push(i);
1629
+ this.length = f(() => this.items.value.length), this.value = f(() => this.items.value.map((i) => i.value.value));
1630
+ const s = L({
1736
1631
  getChildren: () => this.items.value,
1737
1632
  ownErrors: this._arrayErrors
1738
1633
  });
@@ -1763,12 +1658,12 @@ let x = class ae extends D {
1763
1658
  `ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
1764
1659
  ),
1765
1660
  "ArrayNode.removeAt",
1766
- S.LOG
1661
+ A.LOG
1767
1662
  );
1768
1663
  return;
1769
1664
  }
1770
1665
  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();
1666
+ this.items.value = this.items.value.filter((s, i) => i !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
1772
1667
  }
1773
1668
  /**
1774
1669
  * Вставить элемент в массив
@@ -1782,12 +1677,12 @@ let x = class ae extends D {
1782
1677
  `ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
1783
1678
  ),
1784
1679
  "ArrayNode.insert",
1785
- S.LOG
1680
+ A.LOG
1786
1681
  );
1787
1682
  return;
1788
1683
  }
1789
- const s = this.createItem(t), r = [...this.items.value];
1790
- r.splice(e, 0, s), this.items.value = r;
1684
+ const s = this.createItem(t), i = [...this.items.value];
1685
+ i.splice(e, 0, s), this.items.value = i;
1791
1686
  }
1792
1687
  /**
1793
1688
  * Переместить элемент массива с позиции `from` на позицию `to`
@@ -1811,13 +1706,13 @@ let x = class ae extends D {
1811
1706
  O.handle(
1812
1707
  new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${s})`),
1813
1708
  "ArrayNode.move",
1814
- S.LOG
1709
+ A.LOG
1815
1710
  );
1816
1711
  return;
1817
1712
  }
1818
1713
  if (e === t) return;
1819
- const r = [...this.items.value], [n] = r.splice(e, 1);
1820
- r.splice(t, 0, n), this.items.value = r;
1714
+ const i = [...this.items.value], [n] = i.splice(e, 1);
1715
+ i.splice(t, 0, n), this.items.value = i;
1821
1716
  }
1822
1717
  /**
1823
1718
  * Поменять местами два элемента массива
@@ -1839,13 +1734,13 @@ let x = class ae extends D {
1839
1734
  O.handle(
1840
1735
  new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${s})`),
1841
1736
  "ArrayNode.swap",
1842
- S.LOG
1737
+ A.LOG
1843
1738
  );
1844
1739
  return;
1845
1740
  }
1846
1741
  if (e === t) return;
1847
- const r = [...this.items.value];
1848
- [r[e], r[t]] = [r[t], r[e]], this.items.value = r;
1742
+ const i = [...this.items.value];
1743
+ [i[e], i[t]] = [i[t], i[e]], this.items.value = i;
1849
1744
  }
1850
1745
  /**
1851
1746
  * Удалить все элементы массива
@@ -1877,7 +1772,7 @@ let x = class ae extends D {
1877
1772
  }
1878
1773
  setValue(e, t) {
1879
1774
  this.clear(), e.forEach((s) => this.push(s)), t?.emitEvent !== !1 && this.validate().catch((s) => {
1880
- O.handle(s, "ArrayNode.setValue", S.LOG);
1775
+ O.handle(s, "ArrayNode.setValue", A.LOG);
1881
1776
  });
1882
1777
  }
1883
1778
  patchValue(e) {
@@ -1937,7 +1832,7 @@ let x = class ae extends D {
1937
1832
  this._arrayErrors.value = [], this.clear(), this.initialItems.forEach((e) => this.push(e));
1938
1833
  }
1939
1834
  async validate() {
1940
- return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean);
1835
+ return (await Promise.all(this.items.value.map((t) => t.validate()))).every(Boolean) && this._arrayErrors.value.length === 0;
1941
1836
  }
1942
1837
  /**
1943
1838
  * Установить array-level validation errors
@@ -2011,8 +1906,8 @@ let x = class ae extends D {
2011
1906
  */
2012
1907
  forEach(e) {
2013
1908
  this.items.value.forEach((t, s) => {
2014
- const r = t.getProxy();
2015
- e(r, s);
1909
+ const i = t.getProxy();
1910
+ e(i, s);
2016
1911
  });
2017
1912
  }
2018
1913
  /**
@@ -2022,8 +1917,8 @@ let x = class ae extends D {
2022
1917
  */
2023
1918
  map(e) {
2024
1919
  return this.items.value.map((t, s) => {
2025
- const r = t.getProxy();
2026
- return e(r, s);
1920
+ const i = t.getProxy();
1921
+ return e(i, s);
2027
1922
  });
2028
1923
  }
2029
1924
  // ============================================================================
@@ -2035,7 +1930,7 @@ let x = class ae extends D {
2035
1930
  */
2036
1931
  createItem(e) {
2037
1932
  if (this.isGroupSchema(this.itemSchema)) {
2038
- const t = new x(this.itemSchema);
1933
+ const t = new S(this.itemSchema);
2039
1934
  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
1935
  }
2041
1936
  throw new Error(
@@ -2122,14 +2017,14 @@ let x = class ae extends D {
2122
2017
  * ```
2123
2018
  */
2124
2019
  watchItems(e, t) {
2125
- const s = _(() => {
2020
+ const s = b(() => {
2126
2021
  const n = this.items.value.map((a) => {
2127
- if (a instanceof x)
2022
+ if (a instanceof S)
2128
2023
  return a.getFieldByPath(e)?.value.value;
2129
2024
  });
2130
2025
  t(n);
2131
- }), r = V(k.WatchItems);
2132
- return this.disposers.add(r, s);
2026
+ }), i = V(w.WatchItems);
2027
+ return this.disposers.add(i, s);
2133
2028
  }
2134
2029
  /**
2135
2030
  * Подписка на изменение длины массива
@@ -2154,10 +2049,10 @@ let x = class ae extends D {
2154
2049
  * ```
2155
2050
  */
2156
2051
  watchLength(e) {
2157
- const t = _(() => {
2158
- const r = this.length.value;
2159
- e(r);
2160
- }), s = V(k.WatchLength);
2052
+ const t = b(() => {
2053
+ const i = this.length.value;
2054
+ e(i);
2055
+ }), s = V(w.WatchLength);
2161
2056
  return this.disposers.add(s, t);
2162
2057
  }
2163
2058
  /**
@@ -2220,8 +2115,8 @@ let x = class ae extends D {
2220
2115
  e.enable();
2221
2116
  });
2222
2117
  }
2223
- };
2224
- class ke {
2118
+ }
2119
+ class he {
2225
2120
  /**
2226
2121
  * Создает узел формы на основе конфигурации
2227
2122
  *
@@ -2271,14 +2166,14 @@ class ke {
2271
2166
  if (Array.isArray(e) && e.length >= 1)
2272
2167
  return this.createArrayNodeFromArray(e);
2273
2168
  if (this.isFieldConfig(e))
2274
- return new _e(e);
2169
+ return new le(e);
2275
2170
  if (this.isArrayConfig(e))
2276
- return new X(
2171
+ return new H(
2277
2172
  e.schema,
2278
2173
  e.initialItems
2279
2174
  );
2280
2175
  if (this.isGroupConfig(e))
2281
- return new x(e);
2176
+ return new S(e);
2282
2177
  throw new Error(
2283
2178
  `NodeFactory: Unknown node config. Expected FieldConfig, GroupConfig, or ArrayConfig, but got: ${JSON.stringify(
2284
2179
  e
@@ -2312,11 +2207,11 @@ class ke {
2312
2207
  */
2313
2208
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2314
2209
  createArrayNodeFromArray(e) {
2315
- const [t, ...s] = e, r = [];
2316
- this.isGroupConfig(t) && r.push(this.extractValues(t));
2210
+ const [t, ...s] = e, i = [];
2211
+ this.isGroupConfig(t) && i.push(this.extractValues(t));
2317
2212
  for (const n of s)
2318
- this.isGroupConfig(n) ? r.push(this.extractValues(n)) : r.push(n);
2319
- return new X(t, r);
2213
+ this.isGroupConfig(n) ? i.push(this.extractValues(n)) : i.push(n);
2214
+ return new H(t, i);
2320
2215
  }
2321
2216
  /**
2322
2217
  * Извлечь значения из схемы (рекурсивно)
@@ -2354,8 +2249,8 @@ class ke {
2354
2249
  return e.map((t) => this.extractValues(t));
2355
2250
  if (this.isGroupConfig(e)) {
2356
2251
  const t = {};
2357
- for (const [s, r] of Object.entries(e))
2358
- t[s] = this.extractValues(r);
2252
+ for (const [s, i] of Object.entries(e))
2253
+ t[s] = this.extractValues(i);
2359
2254
  return t;
2360
2255
  }
2361
2256
  return e;
@@ -2380,7 +2275,7 @@ class ke {
2380
2275
  * ```
2381
2276
  */
2382
2277
  isFieldConfig(e) {
2383
- return e == null || typeof e != "object" ? !1 : "valueSignal" in e ? !0 : "value" in e && "component" in e;
2278
+ 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
2279
  }
2385
2280
  /**
2386
2281
  * Проверяет, является ли конфиг конфигурацией массива (ArrayConfig)
@@ -2435,55 +2330,43 @@ class ke {
2435
2330
  return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
2436
2331
  }
2437
2332
  }
2438
- function I(i) {
2439
- return i == null ? !1 : typeof i == "object" && "value" in i && "setValue" in i && "getValue" in i && "validate" in i;
2440
- }
2441
- function Ve(i) {
2442
- return i == null ? !1 : I(i) && "validators" in i && "asyncValidators" in i && // FieldNode имеет markAsTouched метод
2443
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2444
- typeof i.markAsTouched == "function" && // У FieldNode нет fields или items
2445
- !("fields" in i) && !("items" in i);
2446
- }
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);
2450
- }
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";
2455
- }
2456
- function ze(i) {
2457
- return Ve(i) ? "FieldNode" : Oe(i) ? "GroupNode" : Ne(i) ? "ArrayNode" : I(i) ? "FormNode" : "Unknown";
2458
- }
2459
- class Fe extends D {
2333
+ class fe extends C {
2460
2334
  /**
2461
2335
  * @param control Реактивный массив модели (`model.<path>`).
2462
2336
  * @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
2463
2337
  * импорта с `create-form`). Обычно `(item) => createForm({ model: item, schema: itemSchema(item) })`.
2464
2338
  */
2465
2339
  constructor(e, t) {
2466
- 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);
2340
+ super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = b(() => {
2341
+ const i = e.length, n = [], a = [];
2342
+ for (let u = 0; u < i; u++) {
2343
+ const h = e.at(u);
2344
+ if (!h) continue;
2345
+ let o = this.cache.get(h);
2346
+ o || (o = t(h), this.cache.set(h, o)), n.push(h), a.push(o);
2473
2347
  }
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({
2348
+ const l = new Set(n), d = [];
2349
+ for (const u of this.mountedModels) {
2350
+ if (l.has(u)) continue;
2351
+ const h = this.cache.get(u);
2352
+ this.cache.delete(u), h && d.push(h);
2353
+ }
2354
+ this.mountedModels = n, this.itemNodes.value = a, d.forEach((u) => this.disposeItemNode(u));
2355
+ }), this.length = f(() => this.itemNodes.value.length), this.value = f(() => this.itemNodes.value.map((i) => i.value.value));
2356
+ const s = L({
2477
2357
  getChildren: () => this.itemNodes.value,
2478
2358
  ownErrors: this._arrayErrors
2479
2359
  });
2480
2360
  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;
2481
2361
  }
2482
- itemNodes = y([]);
2362
+ itemNodes = g([]);
2483
2363
  // Кэш per-item формы по идентичности фасада под-модели (фасады кэшируются в core).
2484
2364
  cache = /* @__PURE__ */ new WeakMap();
2365
+ // Фасады под-моделей, для которых сейчас смонтированы формы — «предыдущий» набор для
2366
+ // реконсиляции в disposeSync. Выпавшие из массива элементы диспозятся и вытесняются из кэша.
2367
+ mountedModels = [];
2485
2368
  initial;
2486
- _arrayErrors = y([]);
2369
+ _arrayErrors = g([]);
2487
2370
  disposeSync;
2488
2371
  /**
2489
2372
  * Сигнал per-item форм. Публичен в т.ч. чтобы `isArrayNode` распознавал узел как массив
@@ -2596,24 +2479,111 @@ class Fe extends D {
2596
2479
  onEnable() {
2597
2480
  this.itemNodes.value.forEach((e) => e.enable?.());
2598
2481
  }
2599
- /** Очистка подписки синхронизации. */
2482
+ /** Диспозит форму элемента (эффекты/поведения/вложенные подписки); терпима к не-GroupNode. */
2483
+ disposeItemNode(e) {
2484
+ e.dispose?.();
2485
+ }
2486
+ /**
2487
+ * Очистка подписки синхронизации И детерминированный teardown всех форм элементов.
2488
+ * Без пробрасывания dispose в itemNodes эффекты/поведения каждой формы элемента (в т.ч. disposeSync
2489
+ * вложенных ModelArrayNode) остались бы жить после teardown формы — утечка подписок.
2490
+ */
2600
2491
  dispose() {
2601
- this.disposeSync();
2492
+ this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
2602
2493
  }
2603
2494
  }
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);
2495
+ const ve = (r) => {
2496
+ const e = r.componentProps;
2497
+ return e != null && typeof e == "object" && typeof e.itemComponent == "function" && e.control != null && typeof e.control.at == "function" && typeof e.control.length == "number";
2498
+ }, pe = (r) => typeof r.when == "function" && Array.isArray(r.children);
2499
+ function F(r, e, t, s, i) {
2500
+ if (r == null || typeof r != "object") return;
2501
+ if (Array.isArray(r)) {
2502
+ for (const a of r) F(a, e, t, s, i);
2503
+ return;
2504
+ }
2505
+ const n = r;
2506
+ if (pe(n)) {
2507
+ const a = s && !!n.when(e, t);
2508
+ for (const l of n.children) F(l, e, t, a, i);
2609
2509
  return;
2610
2510
  }
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);
2511
+ if (ve(n)) {
2512
+ const a = n.componentProps.control, l = n.componentProps.itemComponent, d = a.length;
2513
+ for (let u = 0; u < d; u++) {
2514
+ const h = a.at(u);
2515
+ F(l(h), h, t, s, i);
2516
+ }
2517
+ return;
2518
+ }
2519
+ if (n.value instanceof z) {
2520
+ const a = n.validators ?? [], l = n.asyncValidators ?? [], d = l.length ? [...a, ...l] : a;
2521
+ d.length > 0 && (s ? i.tasks.push({ signal: n.value, validators: d, scope: e }) : i.clearSignals.push(n.value));
2522
+ for (const [u, h] of Object.entries(n))
2523
+ u === "value" || u === "validators" || u === "asyncValidators" || F(h, e, t, s, i);
2614
2524
  return;
2615
2525
  }
2616
- s.value instanceof re && e.set(s.value, {
2526
+ for (const a of Object.values(n)) F(a, e, t, s, i);
2527
+ }
2528
+ function R(r, e) {
2529
+ const t = { tasks: [], clearSignals: [] };
2530
+ return F(e, r, r, !0, t), t;
2531
+ }
2532
+ const X = (r, e, t) => {
2533
+ (r[e] ??= []).push(t);
2534
+ }, B = (r) => {
2535
+ for (const e of Object.values(r))
2536
+ for (const t of e) if (t.severity !== "warning") return !0;
2537
+ return !1;
2538
+ };
2539
+ function Pe(r, e) {
2540
+ const { tasks: t } = R(r, e), s = {};
2541
+ for (const { signal: i, validators: n, scope: a } of t) {
2542
+ const l = i.peek();
2543
+ for (const d of n) {
2544
+ const u = d(l, a, r);
2545
+ u && typeof u.then == "function" || u && X(s, i.__path, u);
2546
+ }
2547
+ }
2548
+ return { valid: !B(s), errors: s };
2549
+ }
2550
+ async function Te(r, e) {
2551
+ const { tasks: t } = R(r, e), s = await Z(t, r);
2552
+ return { valid: !B(s), errors: s };
2553
+ }
2554
+ async function Z(r, e) {
2555
+ const t = {};
2556
+ return await Promise.all(
2557
+ r.map(async ({ signal: s, validators: i, scope: n }) => {
2558
+ const a = s.peek();
2559
+ for (const l of i) {
2560
+ const d = await l(a, n, e);
2561
+ d && X(t, s.__path, d);
2562
+ }
2563
+ })
2564
+ ), t;
2565
+ }
2566
+ async function me(r, e) {
2567
+ const { tasks: t, clearSignals: s } = R(r, e), i = await Z(t, r);
2568
+ for (const { signal: n } of t)
2569
+ U(n)?.setErrors(i[n.__path] ?? []);
2570
+ for (const n of s)
2571
+ U(n)?.setErrors([]);
2572
+ return { valid: !B(i), errors: i };
2573
+ }
2574
+ const ee = (r) => r !== null && typeof r == "object" && !Array.isArray(r) && !(r instanceof Date) && !(typeof Blob < "u" && r instanceof Blob) && !(typeof File < "u" && r instanceof File);
2575
+ function D(r, e, t) {
2576
+ if (r == null || typeof r != "object") return;
2577
+ if (Array.isArray(r)) {
2578
+ for (const n of r) D(n, e, t);
2579
+ return;
2580
+ }
2581
+ const s = r, i = s.array;
2582
+ if (i && typeof i.__path == "string" && typeof s.item == "function") {
2583
+ t.set(i.__path, s.item);
2584
+ return;
2585
+ }
2586
+ s.value instanceof z ? e.set(s.value, {
2617
2587
  component: s.component,
2618
2588
  componentProps: s.componentProps,
2619
2589
  validators: s.validators,
@@ -2621,581 +2591,259 @@ function G(i, e, t) {
2621
2591
  updateOn: s.updateOn,
2622
2592
  disabled: s.disabled,
2623
2593
  debounce: s.debounce
2624
- });
2594
+ }) : process.env.NODE_ENV !== "production" && s.component !== void 0 && ("valueSignal" in s || s.value != null) && console.warn(
2595
+ "[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
2596
+ );
2625
2597
  for (const [n, a] of Object.entries(s))
2626
- n !== "value" && G(a, e, t);
2598
+ n !== "value" && D(a, e, t);
2627
2599
  }
2628
- function le(i, e, t, s) {
2629
- const r = {};
2600
+ function te(r, e, t, s) {
2601
+ const i = {};
2630
2602
  for (const [n, a] of Object.entries(e)) {
2631
- const o = t === "" ? n : `${t}.${n}`;
2603
+ const l = t === "" ? n : `${t}.${n}`;
2632
2604
  if (Array.isArray(a))
2633
2605
  continue;
2634
- if (oe(a)) {
2635
- r[n] = le(i, a, o, s);
2606
+ if (ee(a)) {
2607
+ i[n] = te(r, a, l, s);
2636
2608
  continue;
2637
2609
  }
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 };
2642
- }
2643
- return r;
2644
- }
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));
2649
- }
2650
- }
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;
2669
- }
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();
2673
- }
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)) {
2677
- const e = {};
2678
- for (const t of Object.keys(i)) e[t] = w(i[t]);
2679
- return e;
2610
+ const d = r.signalAt(l);
2611
+ if (!d) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
2612
+ const u = s.get(d) ?? {}, { validators: h, asyncValidators: o, ...p } = u;
2613
+ i[n] = { ...p, valueSignal: d };
2680
2614
  }
2681
2615
  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]));
2689
- }
2690
- return !1;
2691
- };
2692
- class Pe {
2693
- constructor(e, t) {
2694
- this.path = t;
2695
- const s = y(e);
2696
- s.__path = t, this.signal = s, this.initial = w(e);
2697
- }
2698
- kind = "leaf";
2699
- signal;
2700
- initial;
2701
- rebase(e) {
2702
- this.path = e, this.signal.__path = e;
2703
- }
2704
- /** Реактивное чтение (внутри effect/computed создаёт зависимость). */
2705
- read() {
2706
- return this.signal.value;
2707
- }
2708
- /** Нереактивный снимок. */
2709
- peek() {
2710
- return this.signal.peek();
2711
- }
2712
- set(e) {
2713
- this.signal.value = e;
2714
- }
2715
- resetToInitial() {
2716
- this.signal.value = w(this.initial);
2717
- }
2718
- captureInitial() {
2719
- this.initial = w(this.signal.peek());
2720
- }
2721
- dirty() {
2722
- return !C(this.signal.peek(), this.initial);
2723
- }
2724
- }
2725
- class he {
2726
- constructor(e, t) {
2727
- this.path = t;
2728
- for (const s of Object.keys(e))
2729
- this.children.set(s, F(e[s], A(t, s)));
2730
- }
2731
- kind = "group";
2732
- children = /* @__PURE__ */ new Map();
2733
- rebase(e) {
2734
- this.path = e;
2735
- for (const [t, s] of this.children) s.rebase(A(e, t));
2736
- }
2737
- peek() {
2738
- const e = {};
2739
- for (const [t, s] of this.children) e[t] = s.peek();
2740
- return e;
2741
- }
2742
- set(e) {
2743
- if (e == null || typeof e != "object") return;
2744
- 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]));
2747
- }
2748
- resetToInitial() {
2749
- for (const e of this.children.values()) e.resetToInitial();
2750
- }
2751
- captureInitial() {
2752
- for (const e of this.children.values()) e.captureInitial();
2753
- }
2754
- dirty() {
2755
- for (const e of this.children.values()) if (e.dirty()) return !0;
2756
- return !1;
2757
- }
2758
2616
  }
2759
- class Me {
2760
- constructor(e, t) {
2761
- this.path = t, this.items = y(e.map((s, r) => F(s, A(t, r)))), this.initial = w(e);
2762
- }
2763
- kind = "array";
2764
- items;
2765
- initial;
2766
- rebase(e) {
2767
- this.path = e, this.items.peek().forEach((t, s) => t.rebase(A(e, s)));
2768
- }
2769
- reindex() {
2770
- this.items.peek().forEach((e, t) => e.rebase(A(this.path, t)));
2771
- }
2772
- push(e) {
2773
- const t = this.items.peek();
2774
- this.items.value = [...t, F(e, A(this.path, t.length))];
2775
- }
2776
- 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();
2779
- }
2780
- removeAt(e) {
2781
- const t = [...this.items.peek()];
2782
- t.splice(e, 1), this.items.value = t, this.reindex();
2783
- }
2784
- 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();
2787
- }
2788
- 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());
2791
- }
2792
- clear() {
2793
- this.items.value = [];
2794
- }
2795
- peek() {
2796
- return this.items.peek().map((e) => e.peek());
2797
- }
2798
- set(e) {
2799
- const t = Array.isArray(e) ? e : [];
2800
- this.items.value = t.map((s, r) => F(s, A(this.path, r)));
2801
- }
2802
- resetToInitial() {
2803
- this.set(w(this.initial));
2804
- }
2805
- captureInitial() {
2806
- this.initial = w(this.peek());
2807
- }
2808
- dirty() {
2809
- return !C(this.peek(), this.initial);
2617
+ function se(r, e, t) {
2618
+ for (const [s, i] of Object.entries(r)) {
2619
+ const n = e === "" ? s : `${e}.${s}`;
2620
+ Array.isArray(i) || (ee(i) ? se(i, n, t) : t.push(n));
2810
2621
  }
2811
2622
  }
2812
- function F(i, e) {
2813
- return Array.isArray(i) ? new Me(i, e) : M(i) ? new he(i, e) : new Pe(i, e);
2814
- }
2815
- function T(i) {
2816
- if (i)
2817
- return i.kind === "leaf" ? i.read() : i.kind === "group" ? Ce(i) : de(i);
2818
- }
2819
- function Ce(i) {
2820
- return new Proxy(
2821
- {},
2822
- {
2823
- get: (e, t) => t === "__path" ? i.path : typeof t == "string" ? T(i.children.get(t)) : void 0,
2824
- set: (e, t, s) => {
2825
- if (typeof t != "string") return !1;
2826
- const r = i.children.get(t);
2827
- return r && r.set(s), !0;
2828
- },
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
2623
+ function re(r) {
2624
+ const { model: e, schema: t, behavior: s } = r, i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
2625
+ t !== void 0 && D(t, i, n);
2626
+ const a = te(e, e.get(), "", i), l = new S(a), d = e.get();
2627
+ for (const [o, p] of Object.entries(d)) {
2628
+ if (!Array.isArray(p)) continue;
2629
+ const c = n.get(o);
2630
+ if (!c) continue;
2631
+ const v = e[o], m = (y) => re({ model: y, schema: c(y) }), _ = new fe(v, m);
2632
+ l.fields.set(o, _);
2633
+ }
2634
+ const u = l.getProxy(), h = [];
2635
+ se(e.get(), "", h);
2636
+ for (const o of h) {
2637
+ const p = e.signalAt(o), c = l.getFieldByPath(o);
2638
+ if (p && c) {
2639
+ ne(p, c);
2640
+ const v = o.lastIndexOf("."), m = v === -1 ? l : l.getFieldByPath(o.slice(0, v));
2641
+ m instanceof S && m.registerFieldSignal(c, p);
2832
2642
  }
2833
- );
2834
- }
2835
- function j(i) {
2836
- if (i)
2837
- return i.kind === "group" ? fe(i) : i.kind === "array" ? de(i) : i.read();
2838
- }
2839
- function de(i) {
2840
- const e = {
2841
- get length() {
2842
- return i.items.value.length;
2843
- },
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(),
2854
- [Symbol.iterator]: function* () {
2855
- const t = i.items.value;
2856
- for (let s = 0; s < t.length; s++) yield T(t[s]);
2857
- }
2858
- };
2859
- 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)
2862
- });
2863
- }
2864
- function W(i) {
2865
- if (i.kind === "leaf") return i.signal;
2866
- if (i.kind === "group")
2867
- return new Proxy(
2868
- {},
2869
- {
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;
2875
- },
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
2879
- }
2880
- );
2881
- const e = i;
2882
- return new Proxy(
2883
- {
2884
- get length() {
2885
- return e.items.value.length;
2886
- }
2887
- },
2888
- {
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;
2894
- }
2895
- return Reflect.get(t, s, r);
2896
- }
2897
- }
2898
- );
2899
- }
2900
- function Te(i, e) {
2901
- if (!e) return;
2902
- let t = i;
2903
- for (const s of e.split(".")) {
2904
- 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)];
2907
- else return;
2908
- }
2909
- return t && t.kind === "leaf" ? t.signal : void 0;
2910
- }
2911
- const Z = /* @__PURE__ */ new Set([
2912
- "$",
2913
- "get",
2914
- "set",
2915
- "patch",
2916
- "isDirty",
2917
- "reset",
2918
- "captureInitial",
2919
- "signalAt"
2920
- ]), ee = /* @__PURE__ */ new WeakMap();
2921
- function fe(i) {
2922
- const e = ee.get(i);
2923
- if (e) return e;
2924
- 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(
2934
- {},
2935
- {
2936
- get: (r, n) => {
2937
- 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];
2941
- },
2942
- set: (r, n, a) => {
2943
- if (typeof n != "string") return !1;
2944
- const o = i.children.get(n);
2945
- return o ? (o.set(a), !0) : !1;
2946
- },
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
2950
- }
2951
- );
2952
- return ee.set(i, s), s;
2953
- }
2954
- function Ye(i) {
2955
- const e = new he(i, "");
2956
- return fe(e);
2957
- }
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
2643
  }
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;
2644
+ if (t !== void 0) {
2645
+ const o = t;
2646
+ l.attachModelValidator(async () => (await me(e, o)).valid);
2988
2647
  }
2989
- for (const a of Object.values(n)) N(a, e, t, s, r);
2648
+ return s && l.attachBehaviorCleanup(s.__run(e, u)), u;
2990
2649
  }
2991
- function z(i, e) {
2992
- const t = { tasks: [], clearSignals: [] };
2993
- return N(e, i, i, !0, t), t;
2650
+ const ye = (r) => r != null && typeof r == "object" && "model" in r && typeof r.model?.signalAt == "function";
2651
+ function De(r) {
2652
+ return ye(r) ? re(r) : new S(r).getProxy();
2994
2653
  }
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 };
2654
+ function x(r) {
2655
+ return r == null ? !1 : typeof r == "object" && "value" in r && "setValue" in r && "getValue" in r && "validate" in r;
3008
2656
  }
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 };
2657
+ function ge(r) {
2658
+ return r == null ? !1 : x(r) && "validators" in r && "asyncValidators" in r && // FieldNode имеет markAsTouched метод
2659
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2660
+ typeof r.markAsTouched == "function" && // У FieldNode нет fields или items
2661
+ !("fields" in r) && !("items" in r);
3012
2662
  }
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;
2663
+ function _e(r) {
2664
+ return r == null ? !1 : x(r) && "getFieldByPath" in r && "fields" in r && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
2665
+ !("items" in r) && !("push" in r) && !("removeAt" in r);
3024
2666
  }
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 };
2667
+ function be(r) {
2668
+ return r == null ? !1 : x(r) && "items" in r && "length" in r && "push" in r && "removeAt" in r && "at" in r && // eslint-disable-next-line @typescript-eslint/no-explicit-any
2669
+ typeof r.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
2670
+ typeof r.removeAt == "function";
3032
2671
  }
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];
2672
+ function Ie(r) {
2673
+ return ge(r) ? "FieldNode" : _e(r) ? "GroupNode" : be(r) ? "ArrayNode" : x(r) ? "FormNode" : "Unknown";
2674
+ }
2675
+ var M = { exports: {} }, P = {};
2676
+ var K;
2677
+ function Ee() {
2678
+ if (K) return P;
2679
+ K = 1;
2680
+ var r = Q;
2681
+ function e(o, p) {
2682
+ return o === p && (o !== 0 || 1 / o === 1 / p) || o !== o && p !== p;
2683
+ }
2684
+ var t = typeof Object.is == "function" ? Object.is : e, s = r.useState, i = r.useEffect, n = r.useLayoutEffect, a = r.useDebugValue;
2685
+ function l(o, p) {
2686
+ var c = p(), v = s({ inst: { value: c, getSnapshot: p } }), m = v[0].inst, _ = v[1];
3045
2687
  return n(
3046
2688
  function() {
3047
- v.value = d, v.getSnapshot = f, l(v) && g({ inst: v });
2689
+ m.value = c, m.getSnapshot = p, d(m) && _({ inst: m });
3048
2690
  },
3049
- [c, d, f]
3050
- ), r(
2691
+ [o, c, p]
2692
+ ), i(
3051
2693
  function() {
3052
- return l(v) && g({ inst: v }), c(function() {
3053
- l(v) && g({ inst: v });
2694
+ return d(m) && _({ inst: m }), o(function() {
2695
+ d(m) && _({ inst: m });
3054
2696
  });
3055
2697
  },
3056
- [c]
3057
- ), a(d), d;
2698
+ [o]
2699
+ ), a(c), c;
3058
2700
  }
3059
- function l(c) {
3060
- var f = c.getSnapshot;
3061
- c = c.value;
2701
+ function d(o) {
2702
+ var p = o.getSnapshot;
2703
+ o = o.value;
3062
2704
  try {
3063
- var d = f();
3064
- return !t(c, d);
2705
+ var c = p();
2706
+ return !t(o, c);
3065
2707
  } catch {
3066
2708
  return !0;
3067
2709
  }
3068
2710
  }
3069
- function u(c, f) {
3070
- return f();
2711
+ function u(o, p) {
2712
+ return p();
3071
2713
  }
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;
2714
+ var h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
2715
+ return P.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : h, P;
3074
2716
  }
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;
2717
+ var T = {};
2718
+ var J;
2719
+ function Se() {
2720
+ return J || (J = 1, process.env.NODE_ENV !== "production" && (function() {
2721
+ function r(c, v) {
2722
+ return c === v && (c !== 0 || 1 / c === 1 / v) || c !== c && v !== v;
3081
2723
  }
3082
- function e(d, p) {
3083
- m || r.startTransition === void 0 || (m = !0, console.error(
2724
+ function e(c, v) {
2725
+ h || i.startTransition === void 0 || (h = !0, console.error(
3084
2726
  "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
2727
  ));
3086
- var v = p();
3087
- if (!c) {
3088
- var g = p();
3089
- n(v, g) || (console.error(
2728
+ var m = v();
2729
+ if (!o) {
2730
+ var _ = v();
2731
+ n(m, _) || (console.error(
3090
2732
  "The result of getSnapshot should be cached to avoid an infinite loop"
3091
- ), c = !0);
2733
+ ), o = !0);
3092
2734
  }
3093
- g = a({
3094
- inst: { value: v, getSnapshot: p }
2735
+ _ = a({
2736
+ inst: { value: m, getSnapshot: v }
3095
2737
  });
3096
- var b = g[0].inst, L = g[1];
3097
- return l(
2738
+ var y = _[0].inst, k = _[1];
2739
+ return d(
3098
2740
  function() {
3099
- b.value = v, b.getSnapshot = p, t(b) && L({ inst: b });
2741
+ y.value = m, y.getSnapshot = v, t(y) && k({ inst: y });
3100
2742
  },
3101
- [d, v, p]
3102
- ), o(
2743
+ [c, m, v]
2744
+ ), l(
3103
2745
  function() {
3104
- return t(b) && L({ inst: b }), d(function() {
3105
- t(b) && L({ inst: b });
2746
+ return t(y) && k({ inst: y }), c(function() {
2747
+ t(y) && k({ inst: y });
3106
2748
  });
3107
2749
  },
3108
- [d]
3109
- ), u(v), v;
2750
+ [c]
2751
+ ), u(m), m;
3110
2752
  }
3111
- function t(d) {
3112
- var p = d.getSnapshot;
3113
- d = d.value;
2753
+ function t(c) {
2754
+ var v = c.getSnapshot;
2755
+ c = c.value;
3114
2756
  try {
3115
- var v = p();
3116
- return !n(d, v);
2757
+ var m = v();
2758
+ return !n(c, m);
3117
2759
  } catch {
3118
2760
  return !0;
3119
2761
  }
3120
2762
  }
3121
- function s(d, p) {
3122
- return p();
2763
+ function s(c, v) {
2764
+ return v();
3123
2765
  }
3124
2766
  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
- })()), $;
2767
+ var i = Q, n = typeof Object.is == "function" ? Object.is : r, a = i.useState, l = i.useEffect, d = i.useLayoutEffect, u = i.useDebugValue, h = !1, o = !1, p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : e;
2768
+ T.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : p, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
2769
+ })()), T;
3128
2770
  }
3129
- var ie;
3130
- function Re() {
3131
- return ie || (ie = 1, process.env.NODE_ENV === "production" ? P.exports = Le() : P.exports = je()), P.exports;
2771
+ var Y;
2772
+ function Ae() {
2773
+ return Y || (Y = 1, process.env.NODE_ENV === "production" ? M.exports = Ee() : M.exports = Se()), M.exports;
3132
2774
  }
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;
2775
+ var $ = Ae();
2776
+ function we(r, e) {
2777
+ if (r === e) return !0;
2778
+ if (r.length !== e.length) return !1;
2779
+ for (let t = 0; t < r.length; t++)
2780
+ if (r[t] !== e[t]) return !1;
3139
2781
  return !0;
3140
2782
  }
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) => {
2783
+ function j(r, e, t, s) {
2784
+ const i = N(null), n = N(r);
2785
+ n.current = r;
2786
+ const a = N(e);
2787
+ a.current = e;
2788
+ const l = N(t);
2789
+ if (l.current = t, i.current === null) {
2790
+ const h = {};
2791
+ for (const o in r)
2792
+ h[o] = r[o].value;
2793
+ i.current = { ...h, __snapshot: null };
2794
+ }
2795
+ const d = E(
2796
+ (h) => {
3151
2797
  let o = !0;
3152
- return _(() => {
3153
- for (const u in i)
3154
- i[u].value;
2798
+ return b(() => {
2799
+ const c = n.current;
2800
+ for (const v in c)
2801
+ c[v].value;
3155
2802
  if (o) {
3156
2803
  o = !1;
3157
2804
  return;
3158
2805
  }
3159
- a();
2806
+ h();
3160
2807
  });
3161
2808
  },
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;
2809
+ [s]
2810
+ ), u = E(() => {
2811
+ const h = i.current, o = n.current, p = {};
2812
+ for (const v in o)
2813
+ p[v] = o[v].value;
2814
+ let c = !1;
2815
+ for (const v of a.current) {
2816
+ const { key: m, useShallowArrayEqual: _ } = v, y = p[m], k = h[m];
2817
+ if (_) {
2818
+ if (!we(k, y)) {
2819
+ c = !0;
3173
2820
  break;
3174
2821
  }
3175
- } else if (d !== f) {
3176
- l = !0;
2822
+ } else if (k !== y) {
2823
+ c = !0;
3177
2824
  break;
3178
2825
  }
3179
2826
  }
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);
2827
+ if (!c && h.__snapshot)
2828
+ return h.__snapshot;
2829
+ for (const v in o)
2830
+ h[v] = p[v];
2831
+ return h.__snapshot = l.current(p), h.__snapshot;
2832
+ }, [s]);
2833
+ return $.useSyncExternalStore(d, u, u);
3187
2834
  }
3188
- function Be(i) {
2835
+ function Ve(r) {
3189
2836
  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
2837
+ value: r.value,
2838
+ disabled: r.disabled,
2839
+ errors: r.errors,
2840
+ pending: r.pending,
2841
+ valid: r.valid,
2842
+ invalid: r.invalid,
2843
+ touched: r.touched,
2844
+ dirty: r.dirty,
2845
+ shouldShowError: r.shouldShowError,
2846
+ componentProps: r.componentProps
3199
2847
  }, t = [
3200
2848
  { key: "value" },
3201
2849
  { key: "disabled" },
@@ -3204,34 +2852,37 @@ function Be(i) {
3204
2852
  { key: "valid" },
3205
2853
  { key: "invalid" },
3206
2854
  { key: "touched" },
2855
+ { key: "dirty" },
3207
2856
  { key: "shouldShowError" },
3208
2857
  { key: "componentProps" }
3209
2858
  ], s = E(
3210
- (r) => ({
3211
- value: r.value,
3212
- pending: r.pending,
3213
- disabled: r.disabled,
3214
- errors: r.errors,
3215
- valid: r.valid,
3216
- invalid: r.invalid,
3217
- touched: r.touched,
3218
- shouldShowError: r.shouldShowError,
3219
- componentProps: r.componentProps
2859
+ (i) => ({
2860
+ value: i.value,
2861
+ pending: i.pending,
2862
+ disabled: i.disabled,
2863
+ errors: i.errors,
2864
+ valid: i.valid,
2865
+ invalid: i.invalid,
2866
+ touched: i.touched,
2867
+ dirty: i.dirty,
2868
+ shouldShowError: i.shouldShowError,
2869
+ componentProps: i.componentProps
3220
2870
  }),
3221
2871
  []
3222
2872
  );
3223
- return Y(e, t, s);
2873
+ return j(e, t, s, r);
3224
2874
  }
3225
- function Ge(i) {
2875
+ function ke(r) {
3226
2876
  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
2877
+ value: r.value,
2878
+ length: r.length,
2879
+ errors: r.errors,
2880
+ pending: r.pending,
2881
+ valid: r.valid,
2882
+ invalid: r.invalid,
2883
+ touched: r.touched,
2884
+ dirty: r.dirty,
2885
+ disabled: r.disabled
3235
2886
  }, t = [
3236
2887
  { key: "value" },
3237
2888
  { key: "length" },
@@ -3240,24 +2891,26 @@ function Ge(i) {
3240
2891
  { key: "valid" },
3241
2892
  { key: "invalid" },
3242
2893
  { key: "touched" },
3243
- { key: "dirty" }
2894
+ { key: "dirty" },
2895
+ { key: "disabled" }
3244
2896
  ], s = E(
3245
- (r) => ({
3246
- value: r.value,
3247
- length: r.length,
3248
- pending: r.pending,
3249
- errors: r.errors,
3250
- valid: r.valid,
3251
- invalid: r.invalid,
3252
- touched: r.touched,
3253
- dirty: r.dirty
2897
+ (i) => ({
2898
+ value: i.value,
2899
+ length: i.length,
2900
+ pending: i.pending,
2901
+ errors: i.errors,
2902
+ valid: i.valid,
2903
+ invalid: i.invalid,
2904
+ touched: i.touched,
2905
+ dirty: i.dirty,
2906
+ disabled: i.disabled
3254
2907
  }),
3255
2908
  []
3256
2909
  );
3257
- return Y(e, t, s);
2910
+ return j(e, t, s, r);
3258
2911
  }
3259
- function Ue() {
3260
- const i = E(
2912
+ function Oe() {
2913
+ const r = E(
3261
2914
  () => ({
3262
2915
  value: [],
3263
2916
  length: 0,
@@ -3266,96 +2919,98 @@ function Ue() {
3266
2919
  valid: !0,
3267
2920
  invalid: !1,
3268
2921
  touched: !1,
3269
- dirty: !1
2922
+ dirty: !1,
2923
+ disabled: !1
3270
2924
  }),
3271
2925
  []
3272
2926
  );
3273
- return Y({}, [], i);
2927
+ return j({}, [], r);
3274
2928
  }
3275
- function et(i) {
3276
- const e = i && "length" in i && "map" in i;
3277
- return i ? e ? Ge(i) : Be(i) : Ue();
2929
+ function Le(r) {
2930
+ const e = r && "length" in r && "map" in r;
2931
+ return r ? e ? ke(r) : Ve(r) : Oe();
3278
2932
  }
3279
- function tt(i) {
3280
- const e = q({ value: i.value.value }), t = E(
3281
- (r) => {
2933
+ function Re(r) {
2934
+ const e = N({ value: r.value.value }), t = E(
2935
+ (i) => {
3282
2936
  let n = !0;
3283
- return _(() => {
3284
- if (i.value.value, n) {
2937
+ return b(() => {
2938
+ if (r.value.value, n) {
3285
2939
  n = !1;
3286
2940
  return;
3287
2941
  }
3288
- r();
2942
+ i();
3289
2943
  });
3290
2944
  },
3291
- [i]
2945
+ [r]
3292
2946
  ), s = E(() => {
3293
- const r = i.value.value;
3294
- return e.current.value === r ? e.current.value : (e.current.value = r, r);
3295
- }, [i]);
3296
- return J.useSyncExternalStore(t, s, s);
2947
+ const i = r.value.value;
2948
+ return e.current.value === i ? e.current.value : (e.current.value = i, i);
2949
+ }, [r]);
2950
+ return $.useSyncExternalStore(t, s, s);
3297
2951
  }
3298
- function st(i) {
3299
- const e = q({ length: i.length.value }), t = E(
3300
- (r) => {
2952
+ function Be(r) {
2953
+ const e = N({ length: r.length.value }), t = E(
2954
+ (i) => {
3301
2955
  let n = !0;
3302
- return _(() => {
3303
- if (i.length.value, n) {
2956
+ return b(() => {
2957
+ if (r.length.value, n) {
3304
2958
  n = !1;
3305
2959
  return;
3306
2960
  }
3307
- r();
2961
+ i();
3308
2962
  });
3309
2963
  },
3310
- [i]
2964
+ [r]
3311
2965
  ), s = E(() => {
3312
- const r = i.length.value;
3313
- return e.current.length === r ? e.current.length : (e.current.length = r, r);
3314
- }, [i]);
3315
- return J.useSyncExternalStore(t, s, s);
2966
+ const i = r.length.value;
2967
+ return e.current.length === i ? e.current.length : (e.current.length = i, i);
2968
+ }, [r]);
2969
+ return $.useSyncExternalStore(t, s, s);
3316
2970
  }
3317
2971
  export {
3318
- X as ArrayNode,
3319
- S as ErrorStrategy,
3320
- _e as FieldNode,
2972
+ H as ArrayNode,
2973
+ A as ErrorStrategy,
2974
+ le as FieldNode,
3321
2975
  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,
3328
- 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,
2976
+ C as FormNode,
2977
+ oe as FormStatusMachine,
2978
+ de as FormSubmitter,
2979
+ S as GroupNode,
2980
+ fe as ModelArrayNode,
2981
+ he as NodeFactory,
2982
+ I as SubscriptionManager,
2983
+ We as computeFrom,
2984
+ qe as copyFrom,
2985
+ De as createForm,
2986
+ re as createFormFromModel,
2987
+ Ge as createModel,
2988
+ nt as disableWhen,
2989
+ at as enableWhen,
2990
+ U as getNodeForSignal,
2991
+ Ie as getNodeType,
2992
+ be as isArrayNode,
2993
+ G as isDerived,
2994
+ ge as isFieldNode,
2995
+ x as isFormNode,
2996
+ _e as isGroupNode,
2997
+ He as markDerived,
2998
+ ne as registerSignalNode,
2999
+ Ke as resetWhen,
3000
+ Je as revalidateWhen,
3001
+ Ye as runOutsideEffect,
3002
+ ze as safeCallback,
3003
+ Qe as safeDebouncedCallback,
3004
+ Xe as syncFields,
3005
+ Ze as transformValue,
3352
3006
  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
3007
+ et as unmarkDerived,
3008
+ Be as useArrayLength,
3009
+ Le as useFormControl,
3010
+ Re as useFormControlValue,
3011
+ me as validateFormModel,
3012
+ Te as validateModel,
3013
+ Pe as validateModelSync,
3014
+ rt as validators,
3015
+ tt as watchField
3361
3016
  };