attaform 0.16.3 → 0.17.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 (86) hide show
  1. package/README.md +4 -2
  2. package/dist/chunks/devtools.cjs +19 -12
  3. package/dist/chunks/devtools.cjs.map +1 -1
  4. package/dist/chunks/devtools.mjs +19 -12
  5. package/dist/chunks/devtools.mjs.map +1 -1
  6. package/dist/chunks/indexeddb.cjs +1 -1
  7. package/dist/chunks/indexeddb.mjs +1 -1
  8. package/dist/chunks/local-storage.cjs +1 -1
  9. package/dist/chunks/local-storage.mjs +1 -1
  10. package/dist/chunks/session-storage.cjs +1 -1
  11. package/dist/chunks/session-storage.mjs +1 -1
  12. package/dist/index.cjs +27 -7
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +80 -8
  15. package/dist/index.d.mts +80 -8
  16. package/dist/index.d.ts +80 -8
  17. package/dist/index.mjs +28 -9
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/nuxt.d.cts +1 -1
  20. package/dist/nuxt.d.mts +1 -1
  21. package/dist/nuxt.d.ts +1 -1
  22. package/dist/runtime/plugins/attaform.cjs +3 -3
  23. package/dist/runtime/plugins/attaform.cjs.map +1 -1
  24. package/dist/runtime/plugins/attaform.mjs +3 -3
  25. package/dist/runtime/plugins/attaform.mjs.map +1 -1
  26. package/dist/shared/{attaform.KrNw10aW.cjs → attaform.0Wg7UEeX.cjs} +60 -20
  27. package/dist/shared/attaform.0Wg7UEeX.cjs.map +1 -0
  28. package/dist/shared/attaform.AOgGyRoI.d.cts +65 -0
  29. package/dist/shared/{attaform.lFNwBcA3.d.ts → attaform.B0zue7zt.d.ts} +1 -1
  30. package/dist/shared/{attaform.c_NzdRyc.cjs → attaform.BBM2muQ9.cjs} +7 -3
  31. package/dist/shared/attaform.BBM2muQ9.cjs.map +1 -0
  32. package/dist/shared/{attaform.C9Ph2SMx.cjs → attaform.BFumZXY2.cjs} +1514 -391
  33. package/dist/shared/attaform.BFumZXY2.cjs.map +1 -0
  34. package/dist/shared/attaform.BQ-iGGWd.d.mts +65 -0
  35. package/dist/shared/{attaform.DILbdvfo.mjs → attaform.BT55rDNN.mjs} +1514 -393
  36. package/dist/shared/attaform.BT55rDNN.mjs.map +1 -0
  37. package/dist/shared/{attaform._EqYNPYF.d.mts → attaform.BYbsV2Wv.d.cts} +738 -138
  38. package/dist/shared/{attaform._EqYNPYF.d.ts → attaform.BYbsV2Wv.d.mts} +738 -138
  39. package/dist/shared/{attaform._EqYNPYF.d.cts → attaform.BYbsV2Wv.d.ts} +738 -138
  40. package/dist/shared/{attaform.DGuGGNg9.cjs → attaform.C6_zOf8x.cjs} +232 -113
  41. package/dist/shared/attaform.C6_zOf8x.cjs.map +1 -0
  42. package/dist/shared/{attaform.CJttVxRj.cjs → attaform.C8LVFVVe.cjs} +2 -2
  43. package/dist/shared/{attaform.CJttVxRj.cjs.map → attaform.C8LVFVVe.cjs.map} +1 -1
  44. package/dist/shared/{attaform.BfMxsfmE.mjs → attaform.CIEQgJnM.mjs} +143 -78
  45. package/dist/shared/attaform.CIEQgJnM.mjs.map +1 -0
  46. package/dist/shared/attaform.CX9v2M8k.d.ts +65 -0
  47. package/dist/shared/{attaform.XYOMTvuO.mjs → attaform.Cj0pCNVn.mjs} +232 -113
  48. package/dist/shared/attaform.Cj0pCNVn.mjs.map +1 -0
  49. package/dist/shared/{attaform.DLnKT7wk.d.cts → attaform.ClfCi1i2.d.mts} +1 -1
  50. package/dist/shared/{attaform.CFA6y0KF.mjs → attaform.D6Q5ZP8L.mjs} +60 -20
  51. package/dist/shared/attaform.D6Q5ZP8L.mjs.map +1 -0
  52. package/dist/shared/{attaform.Bls_kFR6.d.mts → attaform.D7lomopc.d.cts} +1 -1
  53. package/dist/shared/{attaform.rIRYSUI1.cjs → attaform.Dee2rU1P.cjs} +145 -77
  54. package/dist/shared/attaform.Dee2rU1P.cjs.map +1 -0
  55. package/dist/shared/{attaform.CINUMjPq.mjs → attaform.Vo-Kft0t.mjs} +2 -2
  56. package/dist/shared/{attaform.CINUMjPq.mjs.map → attaform.Vo-Kft0t.mjs.map} +1 -1
  57. package/dist/shared/{attaform.jrxE_xZw.mjs → attaform.h1sq3BFu.mjs} +6 -4
  58. package/dist/shared/attaform.h1sq3BFu.mjs.map +1 -0
  59. package/dist/zod-v3.cjs +3 -3
  60. package/dist/zod-v3.d.cts +5 -5
  61. package/dist/zod-v3.d.mts +5 -5
  62. package/dist/zod-v3.d.ts +5 -5
  63. package/dist/zod-v3.mjs +3 -3
  64. package/dist/zod-v4.cjs +3 -3
  65. package/dist/zod-v4.d.cts +16 -42
  66. package/dist/zod-v4.d.mts +16 -42
  67. package/dist/zod-v4.d.ts +16 -42
  68. package/dist/zod-v4.mjs +3 -3
  69. package/dist/zod.cjs +4 -4
  70. package/dist/zod.cjs.map +1 -1
  71. package/dist/zod.d.cts +6 -5
  72. package/dist/zod.d.mts +6 -5
  73. package/dist/zod.d.ts +6 -5
  74. package/dist/zod.mjs +5 -5
  75. package/dist/zod.mjs.map +1 -1
  76. package/package.json +3 -8
  77. package/dist/shared/attaform.BfMxsfmE.mjs.map +0 -1
  78. package/dist/shared/attaform.C9Ph2SMx.cjs.map +0 -1
  79. package/dist/shared/attaform.CFA6y0KF.mjs.map +0 -1
  80. package/dist/shared/attaform.DGuGGNg9.cjs.map +0 -1
  81. package/dist/shared/attaform.DILbdvfo.mjs.map +0 -1
  82. package/dist/shared/attaform.KrNw10aW.cjs.map +0 -1
  83. package/dist/shared/attaform.XYOMTvuO.mjs.map +0 -1
  84. package/dist/shared/attaform.c_NzdRyc.cjs.map +0 -1
  85. package/dist/shared/attaform.jrxE_xZw.mjs.map +0 -1
  86. package/dist/shared/attaform.rIRYSUI1.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
- import { g as getAtPath, s as slimKindOf, e as setAtPath, f as isPlainRecord, A as AttaformErrorCode, h as humanize, c as useAbstractForm } from './attaform.DILbdvfo.mjs';
2
- import { a as AttaformError, _ as __DEV__, b as InvalidUseFormConfigError } from './attaform.BfMxsfmE.mjs';
1
+ import { g as getAtPath, s as slimKindOf, f as setAtPath, j as isPlainRecord, A as AttaformErrorCode, h as humanize, e as useAbstractForm } from './attaform.BT55rDNN.mjs';
2
+ import { a as AttaformError, _ as __DEV__, b as InvalidUseFormConfigError } from './attaform.CIEQgJnM.mjs';
3
3
  import { f as fieldMetaStore, g as getFieldMetaForSchema, a as getFieldMetaListForSchema } from './attaform.D13GMFgK.mjs';
4
- import { c as canonicalizePath } from './attaform.jrxE_xZw.mjs';
4
+ import { c as canonicalizePath } from './attaform.h1sq3BFu.mjs';
5
5
  import { z } from 'zod';
6
6
 
7
7
  const fieldMeta = fieldMetaStore;
@@ -35,6 +35,10 @@ function zodIssuesToValidationErrors(issues, formKey) {
35
35
  }
36
36
  return {
37
37
  message: issue.message,
38
+ // Adapter-side paths stay schema-relative — the validation
39
+ // pipeline in `create-form-store.ts` prepends the parent path
40
+ // to absolutise, then routes form-level (absolute path length 0)
41
+ // entries to the empty-string bucket at storage time.
38
42
  path: issue.path.map((seg) => typeof seg === "number" ? seg : String(seg)),
39
43
  formKey,
40
44
  code
@@ -111,6 +115,8 @@ function kindOf(schema) {
111
115
  return "intersection";
112
116
  case "catch":
113
117
  return "catch";
118
+ case "transform":
119
+ return "transform";
114
120
  case "promise":
115
121
  return "promise";
116
122
  case "custom":
@@ -168,6 +174,18 @@ function unwrapPipe(schema) {
168
174
  const def = readDef(schema);
169
175
  return def?.in ?? def?.out;
170
176
  }
177
+ function unwrapPipeIn(schema) {
178
+ const def = readDef(schema);
179
+ return def?.in;
180
+ }
181
+ function unwrapPipeOut(schema) {
182
+ const def = readDef(schema);
183
+ return def?.out;
184
+ }
185
+ function readTransformFn(schema) {
186
+ const def = readDef(schema);
187
+ return typeof def?.transform === "function" ? def.transform : void 0;
188
+ }
171
189
  function unwrapLazy(schema) {
172
190
  const def = readDef(schema);
173
191
  const getter = def?.getter;
@@ -359,11 +377,7 @@ function assertSupportedKinds(schema, path = [], lazyGetters = []) {
359
377
  }
360
378
  case "lazy": {
361
379
  const getter = getLazyGetter(schema);
362
- if (getter !== void 0 && lazyGetters.includes(getter)) {
363
- throw new UnsupportedSchemaError(
364
- `[attaform/zod] Recursive z.lazy() at '${labelPath(path)}'`
365
- );
366
- }
380
+ if (getter !== void 0 && lazyGetters.includes(getter)) return;
367
381
  const inner = unwrapLazy(schema);
368
382
  if (inner !== void 0) {
369
383
  assertSupportedKinds(
@@ -399,6 +413,7 @@ function assertSupportedKinds(schema, path = [], lazyGetters = []) {
399
413
  case "promise":
400
414
  case "custom":
401
415
  case "template-literal":
416
+ case "transform":
402
417
  return;
403
418
  default: {
404
419
  const _exhaustive = kind;
@@ -417,6 +432,15 @@ function unwrapToDiscriminatedUnion(schema) {
417
432
  next = unwrapInner(current);
418
433
  } else if (kind === "pipe") {
419
434
  next = unwrapPipe(current);
435
+ } else if (kind === "intersection") {
436
+ const left = getIntersectionLeft(current);
437
+ const right = getIntersectionRight(current);
438
+ const leftDU = left !== void 0 ? unwrapToDiscriminatedUnion(left) : void 0;
439
+ const rightDU = right !== void 0 ? unwrapToDiscriminatedUnion(right) : void 0;
440
+ if (leftDU !== void 0 && rightDU !== void 0) {
441
+ return void 0;
442
+ }
443
+ return leftDU ?? rightDU;
420
444
  }
421
445
  if (next === void 0) return void 0;
422
446
  current = next;
@@ -544,6 +568,7 @@ function computeFingerprint(schema, cache, inProgress) {
544
568
  case "promise":
545
569
  case "custom":
546
570
  case "template-literal":
571
+ case "transform":
547
572
  return `${kind}:*`;
548
573
  default: {
549
574
  const _ = kind;
@@ -625,12 +650,10 @@ const PERMISSIVE = /* @__PURE__ */ new Set([
625
650
  "map",
626
651
  "set"
627
652
  ]);
628
- const MAX_LAZY_DEPTH = 64;
629
- function slimPrimitivesOf(schema) {
630
- return walk(schema, 0);
653
+ function slimPrimitivesOf(schema, maxRecursionDepth) {
654
+ return walk(schema, 0, maxRecursionDepth);
631
655
  }
632
- function walk(schema, depth) {
633
- if (depth > MAX_LAZY_DEPTH) return new Set(PERMISSIVE);
656
+ function walk(schema, lazyDepth, maxDepth) {
634
657
  const kind = kindOf(schema);
635
658
  switch (kind) {
636
659
  case "string":
@@ -674,13 +697,13 @@ function walk(schema, depth) {
674
697
  return /* @__PURE__ */ new Set(["set"]);
675
698
  case "optional": {
676
699
  const inner = unwrapInner(schema);
677
- const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, depth + 1);
700
+ const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, lazyDepth, maxDepth);
678
701
  innerSet.add("undefined");
679
702
  return innerSet;
680
703
  }
681
704
  case "nullable": {
682
705
  const inner = unwrapInner(schema);
683
- const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, depth + 1);
706
+ const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, lazyDepth, maxDepth);
684
707
  innerSet.add("null");
685
708
  return innerSet;
686
709
  }
@@ -688,30 +711,31 @@ function walk(schema, depth) {
688
711
  case "readonly":
689
712
  case "catch": {
690
713
  const inner = unwrapInner(schema);
691
- return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, depth + 1);
714
+ return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, lazyDepth, maxDepth);
692
715
  }
693
716
  case "pipe": {
694
717
  const inner = unwrapPipe(schema);
695
- return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, depth + 1);
718
+ return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, lazyDepth, maxDepth);
696
719
  }
697
720
  case "lazy": {
721
+ if (lazyDepth >= maxDepth) return new Set(PERMISSIVE);
698
722
  const inner = unwrapLazy(schema);
699
- return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, depth + 1);
723
+ return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, lazyDepth + 1, maxDepth);
700
724
  }
701
725
  case "union":
702
726
  case "discriminated-union": {
703
727
  const options = getUnionOptions(schema);
704
728
  const out = /* @__PURE__ */ new Set();
705
729
  for (const opt of options) {
706
- for (const k of walk(opt, depth + 1)) out.add(k);
730
+ for (const k of walk(opt, lazyDepth, maxDepth)) out.add(k);
707
731
  }
708
732
  return out.size === 0 ? new Set(PERMISSIVE) : out;
709
733
  }
710
734
  case "intersection": {
711
735
  const left = getIntersectionLeft(schema);
712
736
  const right = getIntersectionRight(schema);
713
- const leftSet = left === void 0 ? new Set(PERMISSIVE) : walk(left, depth + 1);
714
- const rightSet = right === void 0 ? new Set(PERMISSIVE) : walk(right, depth + 1);
737
+ const leftSet = left === void 0 ? new Set(PERMISSIVE) : walk(left, lazyDepth, maxDepth);
738
+ const rightSet = right === void 0 ? new Set(PERMISSIVE) : walk(right, lazyDepth, maxDepth);
715
739
  const out = /* @__PURE__ */ new Set();
716
740
  for (const k of leftSet) if (rightSet.has(k)) out.add(k);
717
741
  return out;
@@ -727,6 +751,8 @@ function walk(schema, depth) {
727
751
  case "promise":
728
752
  case "custom":
729
753
  case "template-literal":
754
+ case "transform":
755
+ return new Set(PERMISSIVE);
730
756
  default:
731
757
  return new Set(PERMISSIVE);
732
758
  }
@@ -760,13 +786,13 @@ function slimKindOfRaw(value) {
760
786
  }
761
787
 
762
788
  const PATH_SEPARATOR$1 = ".";
763
- function getNestedZodSchemasAtPath(schema, path) {
764
- if (Array.isArray(path)) return walkSegments(schema, path.map(String));
789
+ function getNestedZodSchemasAtPath(schema, path, maxRecursionDepth) {
790
+ if (Array.isArray(path)) return walkSegments(schema, path.map(String), maxRecursionDepth, 0);
765
791
  const pathString = path;
766
792
  if (pathString.length === 0) return [schema];
767
- return walkSegments(schema, pathString.split(PATH_SEPARATOR$1));
793
+ return walkSegments(schema, pathString.split(PATH_SEPARATOR$1), maxRecursionDepth, 0);
768
794
  }
769
- function walkSegments(schema, segments) {
795
+ function walkSegments(schema, segments, maxDepth, lazyDepth) {
770
796
  if (segments.length === 0) return [schema];
771
797
  const [head, ...rest] = segments;
772
798
  if (head === void 0) return [schema];
@@ -776,23 +802,25 @@ function walkSegments(schema, segments) {
776
802
  const shape = getObjectShape(schema);
777
803
  if (!Object.hasOwn(shape, head)) return [];
778
804
  const next = shape[head];
779
- return next === void 0 ? [] : walkSegments(next, rest);
805
+ return next === void 0 ? [] : walkSegments(next, rest, maxDepth, lazyDepth);
780
806
  }
781
807
  case "array":
782
- return walkSegments(getArrayElement(schema), rest);
808
+ return walkSegments(getArrayElement(schema), rest, maxDepth, lazyDepth);
783
809
  case "set":
784
- return walkSegments(getSetValueType(schema), rest);
810
+ return walkSegments(getSetValueType(schema), rest, maxDepth, lazyDepth);
785
811
  case "record":
786
- return walkSegments(getRecordValueType(schema), rest);
812
+ return walkSegments(getRecordValueType(schema), rest, maxDepth, lazyDepth);
787
813
  case "tuple": {
788
814
  const index = Number(head);
789
815
  if (!Number.isInteger(index)) return [];
790
816
  const items = getTupleItems(schema);
791
817
  const item = items[index];
792
- return item === void 0 ? [] : walkSegments(item, rest);
818
+ return item === void 0 ? [] : walkSegments(item, rest, maxDepth, lazyDepth);
793
819
  }
794
820
  case "union":
795
- return getUnionOptions(schema).flatMap((opt) => walkSegments(opt, segments));
821
+ return getUnionOptions(schema).flatMap(
822
+ (opt) => walkSegments(opt, segments, maxDepth, lazyDepth)
823
+ );
796
824
  case "discriminated-union": {
797
825
  const options = getDiscriminatedOptions(schema);
798
826
  const matching = options.filter((opt) => {
@@ -800,7 +828,7 @@ function walkSegments(schema, segments) {
800
828
  return Object.hasOwn(shape, head);
801
829
  });
802
830
  const candidates = matching.length > 0 ? matching : options;
803
- return candidates.flatMap((opt) => walkSegments(opt, segments));
831
+ return candidates.flatMap((opt) => walkSegments(opt, segments, maxDepth, lazyDepth));
804
832
  }
805
833
  case "optional":
806
834
  case "nullable":
@@ -808,21 +836,22 @@ function walkSegments(schema, segments) {
808
836
  case "readonly":
809
837
  case "catch": {
810
838
  const inner = unwrapInner(schema);
811
- return inner === void 0 ? [] : walkSegments(inner, segments);
839
+ return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth);
812
840
  }
813
841
  case "pipe": {
814
842
  const inner = unwrapPipe(schema);
815
- return inner === void 0 ? [] : walkSegments(inner, segments);
843
+ return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth);
816
844
  }
817
845
  case "lazy": {
846
+ if (lazyDepth >= maxDepth) return [];
818
847
  const inner = unwrapLazy(schema);
819
- return inner === void 0 ? [] : walkSegments(inner, segments);
848
+ return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth + 1);
820
849
  }
821
850
  case "intersection": {
822
851
  const left = getIntersectionLeft(schema);
823
852
  const right = getIntersectionRight(schema);
824
- const leftResults = left === void 0 ? [] : walkSegments(left, segments);
825
- const rightResults = right === void 0 ? [] : walkSegments(right, segments);
853
+ const leftResults = left === void 0 ? [] : walkSegments(left, segments, maxDepth, lazyDepth);
854
+ const rightResults = right === void 0 ? [] : walkSegments(right, segments, maxDepth, lazyDepth);
826
855
  return [...leftResults, ...rightResults];
827
856
  }
828
857
  // Leaf types — can't descend further.
@@ -843,6 +872,7 @@ function walkSegments(schema, segments) {
843
872
  case "promise":
844
873
  case "custom":
845
874
  case "template-literal":
875
+ case "transform":
846
876
  return [];
847
877
  default: {
848
878
  const _exhaustive = kind;
@@ -954,6 +984,7 @@ function stripRefinements(schema) {
954
984
  case "promise":
955
985
  case "custom":
956
986
  case "template-literal":
987
+ case "transform":
957
988
  return schema;
958
989
  default: {
959
990
  const _exhaustive = kind;
@@ -1077,6 +1108,7 @@ function stripAsyncChecks(schema) {
1077
1108
  case "promise":
1078
1109
  case "custom":
1079
1110
  case "template-literal":
1111
+ case "transform":
1080
1112
  return s;
1081
1113
  default: {
1082
1114
  const _exhaustive = kind;
@@ -1086,34 +1118,37 @@ function stripAsyncChecks(schema) {
1086
1118
  }
1087
1119
  return recurse(schema);
1088
1120
  }
1089
- function getSlimSchema(schema, stripConfig) {
1121
+ function getSlimSchema(schema, stripConfig, maxRecursionDepth) {
1122
+ return walkSlim(schema, stripConfig, maxRecursionDepth, 0);
1123
+ }
1124
+ function walkSlim(schema, stripConfig, maxDepth, lazyDepth) {
1090
1125
  const kind = kindOf(schema);
1091
1126
  switch (kind) {
1092
1127
  case "optional": {
1093
1128
  const inner = unwrapInner(schema) ?? schema;
1094
- const slimmedInner = getSlimSchema(inner, stripConfig);
1129
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1095
1130
  return stripConfig.stripOptional === true ? slimmedInner : slimmedInner.optional();
1096
1131
  }
1097
1132
  case "nullable": {
1098
1133
  const inner = unwrapInner(schema) ?? schema;
1099
- const slimmedInner = getSlimSchema(inner, stripConfig);
1134
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1100
1135
  return stripConfig.stripNullable === true ? slimmedInner : slimmedInner.nullable();
1101
1136
  }
1102
1137
  case "default": {
1103
1138
  const inner = unwrapInner(schema) ?? schema;
1104
- const slimmedInner = getSlimSchema(inner, stripConfig);
1139
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1105
1140
  if (stripConfig.stripDefaultValues === true) return slimmedInner;
1106
1141
  const defaultValue = getDefaultValue(schema);
1107
1142
  return slimmedInner.default(defaultValue);
1108
1143
  }
1109
1144
  case "readonly": {
1110
1145
  const inner = unwrapInner(schema);
1111
- return inner === void 0 ? schema : getSlimSchema(inner, stripConfig).readonly();
1146
+ return inner === void 0 ? schema : walkSlim(inner, stripConfig, maxDepth, lazyDepth).readonly();
1112
1147
  }
1113
1148
  case "pipe": {
1114
1149
  if (stripConfig.stripPipe === true) {
1115
1150
  const inner = unwrapPipe(schema) ?? schema;
1116
- return getSlimSchema(inner, stripConfig);
1151
+ return walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1117
1152
  }
1118
1153
  return schema;
1119
1154
  }
@@ -1121,20 +1156,30 @@ function getSlimSchema(schema, stripConfig) {
1121
1156
  const shape = getObjectShape(schema);
1122
1157
  const next = {};
1123
1158
  for (const [k, v] of Object.entries(shape)) {
1124
- next[k] = getSlimSchema(v, stripConfig);
1159
+ next[k] = walkSlim(v, stripConfig, maxDepth, lazyDepth);
1125
1160
  }
1126
1161
  return carryChecks(z.object(next), schema, stripConfig);
1127
1162
  }
1128
1163
  case "array": {
1129
1164
  const element = getArrayElement(schema);
1130
- return carryChecks(z.array(getSlimSchema(element, stripConfig)), schema, stripConfig);
1165
+ return carryChecks(
1166
+ z.array(walkSlim(element, stripConfig, maxDepth, lazyDepth)),
1167
+ schema,
1168
+ stripConfig
1169
+ );
1131
1170
  }
1132
1171
  case "set": {
1133
1172
  const valueType = getSetValueType(schema);
1134
- return carryChecks(z.set(getSlimSchema(valueType, stripConfig)), schema, stripConfig);
1173
+ return carryChecks(
1174
+ z.set(walkSlim(valueType, stripConfig, maxDepth, lazyDepth)),
1175
+ schema,
1176
+ stripConfig
1177
+ );
1135
1178
  }
1136
1179
  case "tuple": {
1137
- const items = getTupleItems(schema).map((it) => getSlimSchema(it, stripConfig));
1180
+ const items = getTupleItems(schema).map(
1181
+ (it) => walkSlim(it, stripConfig, maxDepth, lazyDepth)
1182
+ );
1138
1183
  const rebuilt = z.tuple(
1139
1184
  items
1140
1185
  );
@@ -1142,18 +1187,20 @@ function getSlimSchema(schema, stripConfig) {
1142
1187
  }
1143
1188
  case "record": {
1144
1189
  const keyType = getRecordKeyType(schema);
1145
- const valueType = getSlimSchema(getRecordValueType(schema), stripConfig);
1190
+ const valueType = walkSlim(getRecordValueType(schema), stripConfig, maxDepth, lazyDepth);
1146
1191
  const rebuilt = z.record(keyType, valueType);
1147
1192
  return carryChecks(rebuilt, schema, stripConfig);
1148
1193
  }
1149
1194
  case "union": {
1150
- const options = getUnionOptions(schema).map((opt) => getSlimSchema(opt, stripConfig));
1195
+ const options = getUnionOptions(schema).map(
1196
+ (opt) => walkSlim(opt, stripConfig, maxDepth, lazyDepth)
1197
+ );
1151
1198
  const rebuilt = z.union(options);
1152
1199
  return carryChecks(rebuilt, schema, stripConfig);
1153
1200
  }
1154
1201
  case "discriminated-union": {
1155
1202
  const options = getDiscriminatedOptions(schema).map(
1156
- (opt) => getSlimSchema(opt, stripConfig)
1203
+ (opt) => walkSlim(opt, stripConfig, maxDepth, lazyDepth)
1157
1204
  );
1158
1205
  const discriminator = getDiscriminator(schema);
1159
1206
  if (discriminator === void 0) return schema;
@@ -1183,23 +1230,29 @@ function getSlimSchema(schema, stripConfig) {
1183
1230
  case "template-literal":
1184
1231
  return schema;
1185
1232
  case "lazy": {
1233
+ if (lazyDepth >= maxDepth) return schema;
1186
1234
  const inner = unwrapLazy(schema);
1187
1235
  if (inner === void 0) return schema;
1188
- const slimmedInner = getSlimSchema(inner, stripConfig);
1236
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth + 1);
1189
1237
  return z.lazy(() => slimmedInner);
1190
1238
  }
1191
1239
  case "intersection": {
1192
1240
  const left = getIntersectionLeft(schema);
1193
1241
  const right = getIntersectionRight(schema);
1194
1242
  if (left === void 0 || right === void 0) return schema;
1195
- return z.intersection(getSlimSchema(left, stripConfig), getSlimSchema(right, stripConfig));
1243
+ return z.intersection(
1244
+ walkSlim(left, stripConfig, maxDepth, lazyDepth),
1245
+ walkSlim(right, stripConfig, maxDepth, lazyDepth)
1246
+ );
1196
1247
  }
1197
1248
  case "catch": {
1198
1249
  const inner = unwrapInner(schema);
1199
1250
  if (inner === void 0) return schema;
1200
- const slimmedInner = getSlimSchema(inner, stripConfig);
1251
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1201
1252
  return slimmedInner.catch(getCatchDefault(schema));
1202
1253
  }
1254
+ case "transform":
1255
+ return schema;
1203
1256
  default: {
1204
1257
  const _exhaustive = kind;
1205
1258
  throw new Error(`getSlimSchema: unhandled ZodKind '${_exhaustive}'`);
@@ -1207,23 +1260,23 @@ function getSlimSchema(schema, stripConfig) {
1207
1260
  }
1208
1261
  }
1209
1262
 
1210
- function deriveDefault(schema, useDefault) {
1211
- return defaultForKind(kindOf(schema), schema, useDefault);
1263
+ function deriveDefault(schema, useDefault, maxRecursionDepth) {
1264
+ return defaultForKind(kindOf(schema), schema, useDefault, maxRecursionDepth, 0);
1212
1265
  }
1213
- function defaultForKind(kind, schema, useDefault) {
1266
+ function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
1214
1267
  switch (kind) {
1215
1268
  case "object": {
1216
1269
  const shape = getObjectShape(schema);
1217
1270
  const out = {};
1218
1271
  for (const [key, subSchema] of Object.entries(shape)) {
1219
- out[key] = deriveDefault(subSchema, useDefault);
1272
+ out[key] = defaultForKind(kindOf(subSchema), subSchema, useDefault, maxDepth, lazyDepth);
1220
1273
  }
1221
1274
  return out;
1222
1275
  }
1223
1276
  case "default": {
1224
1277
  if (useDefault) return getDefaultValue(schema);
1225
1278
  const inner = unwrapInner(schema);
1226
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1279
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1227
1280
  }
1228
1281
  case "optional":
1229
1282
  return void 0;
@@ -1231,11 +1284,11 @@ function defaultForKind(kind, schema, useDefault) {
1231
1284
  return null;
1232
1285
  case "readonly": {
1233
1286
  const inner = unwrapInner(schema);
1234
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1287
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1235
1288
  }
1236
1289
  case "pipe": {
1237
1290
  const inner = unwrapPipe(schema);
1238
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1291
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1239
1292
  }
1240
1293
  case "array":
1241
1294
  return [];
@@ -1245,16 +1298,18 @@ function defaultForKind(kind, schema, useDefault) {
1245
1298
  return {};
1246
1299
  case "tuple": {
1247
1300
  const items = getTupleItems(schema);
1248
- return items.map((item) => deriveDefault(item, useDefault));
1301
+ return items.map(
1302
+ (item) => defaultForKind(kindOf(item), item, useDefault, maxDepth, lazyDepth)
1303
+ );
1249
1304
  }
1250
1305
  case "union": {
1251
1306
  const options = getUnionOptions(schema);
1252
1307
  const first = options[0];
1253
- return first === void 0 ? void 0 : deriveDefault(first, useDefault);
1308
+ return first === void 0 ? void 0 : defaultForKind(kindOf(first), first, useDefault, maxDepth, lazyDepth);
1254
1309
  }
1255
1310
  case "discriminated-union": {
1256
1311
  const first = getDiscriminatedUnionFirstOption(schema);
1257
- return first === void 0 ? void 0 : deriveDefault(first, useDefault);
1312
+ return first === void 0 ? void 0 : defaultForKind(kindOf(first), first, useDefault, maxDepth, lazyDepth);
1258
1313
  }
1259
1314
  case "string":
1260
1315
  return "";
@@ -1281,20 +1336,21 @@ function defaultForKind(kind, schema, useDefault) {
1281
1336
  case "nan":
1282
1337
  return NaN;
1283
1338
  case "lazy": {
1339
+ if (lazyDepth >= maxDepth) return void 0;
1284
1340
  const inner = unwrapLazy(schema);
1285
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1341
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth + 1);
1286
1342
  }
1287
1343
  case "intersection": {
1288
1344
  const left = getIntersectionLeft(schema);
1289
1345
  const right = getIntersectionRight(schema);
1290
- const l = left === void 0 ? void 0 : deriveDefault(left, useDefault);
1291
- const r = right === void 0 ? void 0 : deriveDefault(right, useDefault);
1346
+ const l = left === void 0 ? void 0 : defaultForKind(kindOf(left), left, useDefault, maxDepth, lazyDepth);
1347
+ const r = right === void 0 ? void 0 : defaultForKind(kindOf(right), right, useDefault, maxDepth, lazyDepth);
1292
1348
  return mergeDeep(l, r);
1293
1349
  }
1294
1350
  case "catch": {
1295
1351
  if (useDefault) return getCatchDefault(schema);
1296
1352
  const inner = unwrapInner(schema);
1297
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1353
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1298
1354
  }
1299
1355
  case "any":
1300
1356
  case "unknown":
@@ -1303,6 +1359,7 @@ function defaultForKind(kind, schema, useDefault) {
1303
1359
  case "promise":
1304
1360
  case "custom":
1305
1361
  case "template-literal":
1362
+ case "transform":
1306
1363
  return void 0;
1307
1364
  default: {
1308
1365
  const _exhaustive = kind;
@@ -1327,14 +1384,18 @@ function mergeDeep(base, override) {
1327
1384
  return result;
1328
1385
  }
1329
1386
  function getDefaultValuesFromZodSchema(opts) {
1330
- const { schema, useDefaultSchemaValues, constraints } = opts;
1331
- const initial = deriveDefault(schema, useDefaultSchemaValues);
1387
+ const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts;
1388
+ const initial = deriveDefault(schema, useDefaultSchemaValues, maxRecursionDepth);
1332
1389
  const merged = mergeDeep(initial, constraints);
1333
- const slimSchema = getSlimSchema(schema, {
1334
- stripDefaultValues: true,
1335
- stripPipe: true,
1336
- stripRefinements: true
1337
- });
1390
+ const slimSchema = getSlimSchema(
1391
+ schema,
1392
+ {
1393
+ stripDefaultValues: true,
1394
+ stripPipe: true,
1395
+ stripRefinements: true
1396
+ },
1397
+ maxRecursionDepth
1398
+ );
1338
1399
  const firstParse = slimSchema.safeParse(merged);
1339
1400
  if (firstParse.success) {
1340
1401
  return { data: firstParse.data, success: true, slimSchema };
@@ -1342,16 +1403,16 @@ function getDefaultValuesFromZodSchema(opts) {
1342
1403
  let fixedData = merged;
1343
1404
  for (const issue of firstParse.error.issues) {
1344
1405
  const pathSegments = issue.path.map((seg) => typeof seg === "number" ? seg : String(seg));
1345
- const candidates = getNestedZodSchemasAtPath(slimSchema, pathSegments);
1406
+ const candidates = getNestedZodSchemasAtPath(slimSchema, pathSegments, maxRecursionDepth);
1346
1407
  if (candidates.length === 0) continue;
1347
1408
  const candidate = candidates[0];
1348
1409
  if (candidate === void 0) continue;
1349
1410
  const valueAtPath = getAtPath(merged, pathSegments);
1350
- const slimKinds = slimPrimitivesOf(candidate);
1411
+ const slimKinds = slimPrimitivesOf(candidate, maxRecursionDepth);
1351
1412
  if (slimKinds.size > 0 && slimKinds.has(slimKindOf(valueAtPath))) {
1352
1413
  continue;
1353
1414
  }
1354
- const fixValue = defaultFromIssue(issue, candidate, useDefaultSchemaValues);
1415
+ const fixValue = defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursionDepth);
1355
1416
  if (fixValue === SKIP) continue;
1356
1417
  fixedData = pathSegments.length === 0 ? fixValue : setAtPath(fixedData, pathSegments, fixValue);
1357
1418
  }
@@ -1362,21 +1423,22 @@ function getDefaultValuesFromZodSchema(opts) {
1362
1423
  return { data: fixedData, success: false, slimSchema };
1363
1424
  }
1364
1425
  const SKIP = Symbol("atta:skip-fix");
1365
- function defaultFromIssue(issue, candidate, useDefaultSchemaValues) {
1426
+ function defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursionDepth) {
1366
1427
  if (issue.code === "invalid_type") {
1367
1428
  const du = unwrapToDiscriminatedUnion(candidate);
1368
1429
  if (du !== void 0) {
1369
1430
  const first = getDiscriminatedUnionFirstOption(du);
1370
- if (first !== void 0) return deriveDefault(first, useDefaultSchemaValues);
1431
+ if (first !== void 0)
1432
+ return deriveDefault(first, useDefaultSchemaValues, maxRecursionDepth);
1371
1433
  }
1372
- return deriveDefault(candidate, useDefaultSchemaValues);
1434
+ return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth);
1373
1435
  }
1374
1436
  if (issue.code === "invalid_value") {
1375
1437
  const values = issue.values;
1376
1438
  if (values !== void 0 && values.length > 0) return values[0];
1377
- return deriveDefault(candidate, useDefaultSchemaValues);
1439
+ return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth);
1378
1440
  }
1379
- return deriveDefault(candidate, useDefaultSchemaValues);
1441
+ return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth);
1380
1442
  }
1381
1443
 
1382
1444
  const PATH_SEPARATOR = ".";
@@ -1466,7 +1528,8 @@ function isLeafRequired(schema, depth = 0) {
1466
1528
  function zodV4Adapter(rootSchema) {
1467
1529
  assertZodVersion(rootSchema);
1468
1530
  assertSupportedKinds(rootSchema);
1469
- return (formKey) => {
1531
+ return (formKey, options) => {
1532
+ const maxRecursionDepth = options.maxRecursionDepth;
1470
1533
  const leafCache = /* @__PURE__ */ new Map();
1471
1534
  let asyncValidationFlag = null;
1472
1535
  return {
@@ -1479,13 +1542,16 @@ function zodV4Adapter(rootSchema) {
1479
1542
  const { data } = getDefaultValuesFromZodSchema({
1480
1543
  schema: rootSchema,
1481
1544
  useDefaultSchemaValues: config.useDefaultSchemaValues,
1482
- constraints: config.constraints
1545
+ constraints: config.constraints,
1546
+ maxRecursionDepth
1483
1547
  });
1484
1548
  if (config.strict !== false) {
1485
1549
  try {
1486
- const strictResult = rootSchema.safeParse(data);
1550
+ const strictResult = rootSchema.safeParse(
1551
+ data
1552
+ );
1487
1553
  if (strictResult.success) {
1488
- return { data: strictResult.data, errors: void 0, success: true, formKey };
1554
+ return { data, errors: void 0, success: true, formKey };
1489
1555
  }
1490
1556
  return {
1491
1557
  data,
@@ -1513,15 +1579,46 @@ function zodV4Adapter(rootSchema) {
1513
1579
  }
1514
1580
  return { data, errors: void 0, success: true, formKey };
1515
1581
  },
1582
+ normalizeWriteValueAtPath(value, path) {
1583
+ const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1584
+ const [first] = candidates;
1585
+ if (first === void 0) return value;
1586
+ let current = first;
1587
+ let result = value;
1588
+ for (let i = 0; i < 64; i++) {
1589
+ if (kindOf(current) !== "pipe") break;
1590
+ const pipeIn = unwrapPipeIn(current);
1591
+ if (pipeIn === void 0 || kindOf(pipeIn) !== "transform") break;
1592
+ const fn = readTransformFn(pipeIn);
1593
+ if (typeof fn !== "function") break;
1594
+ let next;
1595
+ try {
1596
+ next = fn(result);
1597
+ } catch (cause) {
1598
+ throw new Error(
1599
+ `[attaform] input normalization at path "${path.join(".")}" threw \u2014 write rejected.`,
1600
+ { cause }
1601
+ );
1602
+ }
1603
+ if (next instanceof Promise) {
1604
+ return value;
1605
+ }
1606
+ result = next;
1607
+ const out = unwrapPipeOut(current);
1608
+ if (out === void 0) break;
1609
+ current = out;
1610
+ }
1611
+ return result;
1612
+ },
1516
1613
  getDefaultAtPath(path) {
1517
- if (path.length === 0) return deriveDefault(rootSchema, true);
1518
- const [first] = getNestedZodSchemasAtPath(rootSchema, path);
1614
+ if (path.length === 0) return deriveDefault(rootSchema, true, maxRecursionDepth);
1615
+ const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1519
1616
  if (first === void 0) return void 0;
1520
- return deriveDefault(unwrapStructuralWrappers(first), true);
1617
+ return deriveDefault(unwrapStructuralWrappers(first), true, maxRecursionDepth);
1521
1618
  },
1522
1619
  arrayShapeAtPath(path) {
1523
1620
  if (path.length === 0) return void 0;
1524
- const [first] = getNestedZodSchemasAtPath(rootSchema, path);
1621
+ const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1525
1622
  if (first === void 0) return void 0;
1526
1623
  const peeled = peelAllWrappers(first);
1527
1624
  const kind = kindOf(peeled);
@@ -1530,13 +1627,13 @@ function zodV4Adapter(rootSchema) {
1530
1627
  return void 0;
1531
1628
  },
1532
1629
  getSchemasAtPath(path) {
1533
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1630
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1534
1631
  return resolved.map(
1535
1632
  (schema) => ({
1536
1633
  fingerprint: () => fingerprintZodSchema(schema),
1537
1634
  needsAsyncValidation: () => containsAsyncRefine(schema),
1538
1635
  getDefaultValues: () => ({
1539
- data: deriveDefault(schema, true),
1636
+ data: deriveDefault(schema, true, maxRecursionDepth),
1540
1637
  errors: void 0,
1541
1638
  success: true,
1542
1639
  formKey
@@ -1559,11 +1656,11 @@ function zodV4Adapter(rootSchema) {
1559
1656
  },
1560
1657
  getSlimPrimitiveTypesAtPath(path) {
1561
1658
  if (path.length === 0) return /* @__PURE__ */ new Set(["object"]);
1562
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1659
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1563
1660
  if (resolved.length === 0) return /* @__PURE__ */ new Set();
1564
1661
  const out = /* @__PURE__ */ new Set();
1565
1662
  for (const candidate of resolved) {
1566
- for (const k of slimPrimitivesOf(candidate)) out.add(k);
1663
+ for (const k of slimPrimitivesOf(candidate, maxRecursionDepth)) out.add(k);
1567
1664
  }
1568
1665
  return out;
1569
1666
  },
@@ -1578,15 +1675,15 @@ function zodV4Adapter(rootSchema) {
1578
1675
  },
1579
1676
  isRequiredAtPath(path) {
1580
1677
  if (path.length === 0) return true;
1581
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1678
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1582
1679
  if (resolved.length === 0) return false;
1583
1680
  return resolved.every((candidate) => isLeafRequired(candidate));
1584
1681
  },
1585
1682
  getFieldMetaAtPath(path) {
1586
- return resolveFieldMetaAtPath(rootSchema, path);
1683
+ return resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth);
1587
1684
  },
1588
1685
  getUnionDiscriminatorAtPath(path) {
1589
- const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path);
1686
+ const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1590
1687
  let matchedUnion;
1591
1688
  for (const candidate of candidates) {
1592
1689
  const du = unwrapToDiscriminatedUnion(candidate);
@@ -1597,24 +1694,35 @@ function zodV4Adapter(rootSchema) {
1597
1694
  if (matchedUnion === void 0) return void 0;
1598
1695
  const discKey = getDiscriminator(matchedUnion);
1599
1696
  if (discKey === void 0) return void 0;
1600
- const options = getDiscriminatedOptions(matchedUnion);
1697
+ const options2 = getDiscriminatedOptions(matchedUnion);
1698
+ const literalSet = /* @__PURE__ */ new Set();
1699
+ for (const opt of options2) {
1700
+ const shape = getObjectShape(opt);
1701
+ const litSchema = shape[discKey];
1702
+ if (litSchema === void 0) continue;
1703
+ if (kindOf(litSchema) !== "literal") continue;
1704
+ for (const v of getLiteralValues(litSchema)) literalSet.add(v);
1705
+ }
1601
1706
  return {
1602
1707
  discriminatorKey: discKey,
1603
1708
  getVariantDefault(value) {
1604
- for (const opt of options) {
1709
+ for (const opt of options2) {
1605
1710
  const shape = getObjectShape(opt);
1606
1711
  const litSchema = shape[discKey];
1607
1712
  if (litSchema === void 0) continue;
1608
1713
  if (kindOf(litSchema) !== "literal") continue;
1609
1714
  const literalValues = getLiteralValues(litSchema);
1610
- if (literalValues.includes(value)) return deriveDefault(opt, true);
1715
+ if (literalValues.includes(value)) return deriveDefault(opt, true, maxRecursionDepth);
1611
1716
  }
1612
1717
  return void 0;
1718
+ },
1719
+ isVariantSelected(value) {
1720
+ return literalSet.has(value);
1613
1721
  }
1614
1722
  };
1615
1723
  },
1616
- validateAtPath(data, path, options) {
1617
- const trySync = options?.sync === true;
1724
+ validateAtPath(data, path, options2) {
1725
+ const trySync = options2?.sync === true;
1618
1726
  if (trySync) {
1619
1727
  try {
1620
1728
  return runSync();
@@ -1632,13 +1740,18 @@ function zodV4Adapter(rootSchema) {
1632
1740
  formKey
1633
1741
  };
1634
1742
  }
1635
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1743
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1636
1744
  if (resolved.length === 0) return pathNotFound(path);
1637
1745
  const aggregated = [];
1638
1746
  for (const candidate of resolved) {
1639
1747
  const result = candidate.safeParse(data);
1640
1748
  if (result.success) {
1641
- return { data: result.data, errors: void 0, success: true, formKey };
1749
+ return {
1750
+ data: result.data,
1751
+ errors: void 0,
1752
+ success: true,
1753
+ formKey
1754
+ };
1642
1755
  }
1643
1756
  aggregated.push(...zodIssuesToValidationErrors(result.error.issues, formKey));
1644
1757
  }
@@ -1646,7 +1759,9 @@ function zodV4Adapter(rootSchema) {
1646
1759
  }
1647
1760
  async function runAsync() {
1648
1761
  if (path === void 0) {
1649
- const result = await rootSchema.safeParseAsync(data);
1762
+ const result = await rootSchema.safeParseAsync(
1763
+ data
1764
+ );
1650
1765
  return result.success ? { data: result.data, errors: void 0, success: true, formKey } : {
1651
1766
  data: void 0,
1652
1767
  errors: zodIssuesToValidationErrors(result.error.issues, formKey),
@@ -1654,13 +1769,18 @@ function zodV4Adapter(rootSchema) {
1654
1769
  formKey
1655
1770
  };
1656
1771
  }
1657
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1772
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1658
1773
  if (resolved.length === 0) return pathNotFound(path);
1659
1774
  const aggregated = [];
1660
1775
  for (const candidate of resolved) {
1661
1776
  const result = await candidate.safeParseAsync(data);
1662
1777
  if (result.success) {
1663
- return { data: result.data, errors: void 0, success: true, formKey };
1778
+ return {
1779
+ data: result.data,
1780
+ errors: void 0,
1781
+ success: true,
1782
+ formKey
1783
+ };
1664
1784
  }
1665
1785
  aggregated.push(...zodIssuesToValidationErrors(result.error.issues, formKey));
1666
1786
  }
@@ -1838,6 +1958,7 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress)
1838
1958
  case "promise":
1839
1959
  case "custom":
1840
1960
  case "template-literal":
1961
+ case "transform":
1841
1962
  return;
1842
1963
  }
1843
1964
  } finally {
@@ -1852,9 +1973,9 @@ function consumePayload(schema, counters) {
1852
1973
  counters.set(schema, idx + 1);
1853
1974
  return payload;
1854
1975
  }
1855
- function resolveFieldMetaAtPath(rootSchema, path) {
1976
+ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
1856
1977
  const lastSegment = path.length === 0 ? "" : path[path.length - 1];
1857
- const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path);
1978
+ const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1858
1979
  const target = candidates[0];
1859
1980
  if (target === void 0) {
1860
1981
  return {
@@ -1888,9 +2009,7 @@ function useForm(configuration) {
1888
2009
  if (candidate === void 0 || candidate === null || candidate.schema === void 0) {
1889
2010
  throw new InvalidUseFormConfigError();
1890
2011
  }
1891
- const adapter = zodV4Adapter(
1892
- configuration.schema
1893
- );
2012
+ const adapter = zodV4Adapter(configuration.schema);
1894
2013
  return useAbstractForm({
1895
2014
  ...configuration,
1896
2015
  schema: adapter
@@ -1898,4 +2017,4 @@ function useForm(configuration) {
1898
2017
  }
1899
2018
 
1900
2019
  export { UnsupportedSchemaError as U, assertZodVersion as a, fieldMeta as f, kindOf as k, useForm as u, withMeta as w, zodV4Adapter as z };
1901
- //# sourceMappingURL=attaform.XYOMTvuO.mjs.map
2020
+ //# sourceMappingURL=attaform.Cj0pCNVn.mjs.map