arktype 3.0.0-beta.1 → 3.0.0-rc.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 (312) hide show
  1. package/README.md +48 -144
  2. package/out/_internal/regex/charset.d.ts +24 -0
  3. package/out/_internal/regex/escape.d.ts +29 -0
  4. package/out/_internal/regex/execArray.d.ts +24 -0
  5. package/out/_internal/regex/group.d.ts +34 -0
  6. package/out/_internal/regex/index.d.ts +2 -0
  7. package/out/_internal/regex/internal.d.ts +9 -0
  8. package/out/_internal/regex/parse.d.ts +10 -0
  9. package/out/_internal/regex/quantify.d.ts +59 -0
  10. package/out/_internal/regex/regex.d.ts +38 -0
  11. package/out/_internal/regex/state.d.ts +383 -0
  12. package/out/_internal/schema/codecs.d.ts +2 -0
  13. package/out/_internal/schema/config.d.ts +103 -0
  14. package/out/_internal/schema/constraint.d.ts +78 -0
  15. package/out/_internal/schema/errors.d.ts +1 -0
  16. package/out/_internal/schema/generic.d.ts +85 -0
  17. package/out/_internal/schema/i18n.d.ts +3 -0
  18. package/out/_internal/schema/index.d.ts +54 -0
  19. package/out/_internal/schema/internal.d.ts +15 -0
  20. package/out/_internal/schema/intrinsic.d.ts +28 -0
  21. package/out/_internal/schema/kinds.d.ts +76 -0
  22. package/out/_internal/schema/module.d.ts +23 -0
  23. package/out/_internal/schema/mutatesInput.d.ts +2 -0
  24. package/out/_internal/schema/node.d.ts +349 -0
  25. package/out/_internal/schema/parse.d.ts +77 -0
  26. package/out/_internal/schema/parseSchema.d.ts +116 -0
  27. package/out/_internal/schema/predicate.d.ts +46 -0
  28. package/out/_internal/schema/refinements/after.d.ts +32 -0
  29. package/out/_internal/schema/refinements/before.d.ts +32 -0
  30. package/out/_internal/schema/refinements/divisor.d.ts +41 -0
  31. package/out/_internal/schema/refinements/exactLength.d.ts +43 -0
  32. package/out/_internal/schema/refinements/kinds.d.ts +40 -0
  33. package/out/_internal/schema/refinements/max.d.ts +33 -0
  34. package/out/_internal/schema/refinements/maxLength.d.ts +32 -0
  35. package/out/_internal/schema/refinements/min.d.ts +33 -0
  36. package/out/_internal/schema/refinements/minLength.d.ts +32 -0
  37. package/out/_internal/schema/refinements/notEqual.d.ts +38 -0
  38. package/out/_internal/schema/refinements/notEqualLength.d.ts +38 -0
  39. package/out/_internal/schema/refinements/pattern.d.ts +43 -0
  40. package/out/_internal/schema/refinements/range.d.ts +101 -0
  41. package/out/_internal/schema/roots/alias.d.ts +49 -0
  42. package/out/_internal/schema/roots/basis.d.ts +12 -0
  43. package/out/_internal/schema/roots/domain.d.ts +45 -0
  44. package/out/_internal/schema/roots/intersection.d.ts +72 -0
  45. package/out/_internal/schema/roots/morph.d.ts +59 -0
  46. package/out/_internal/schema/roots/proto.d.ts +42 -0
  47. package/out/_internal/schema/roots/root.d.ts +163 -0
  48. package/out/_internal/schema/roots/union.d.ts +146 -0
  49. package/out/_internal/schema/roots/unit.d.ts +36 -0
  50. package/out/_internal/schema/runtime.d.ts +29 -0
  51. package/out/_internal/schema/runtimeLean.d.ts +2 -0
  52. package/out/_internal/schema/runtimeNone.d.ts +2 -0
  53. package/out/_internal/schema/runtimeNoneLean.d.ts +2 -0
  54. package/out/_internal/schema/scope.d.ts +203 -0
  55. package/out/_internal/schema/shared/codecs.d.ts +5 -0
  56. package/out/_internal/schema/shared/compile.d.ts +144 -0
  57. package/out/_internal/schema/shared/configured.d.ts +14 -0
  58. package/out/_internal/schema/shared/declare.d.ts +100 -0
  59. package/out/_internal/schema/shared/disjoint.d.ts +45 -0
  60. package/out/_internal/schema/shared/enWriters.d.ts +30 -0
  61. package/out/_internal/schema/shared/errorModes.d.ts +25 -0
  62. package/out/_internal/schema/shared/errorWriters.d.ts +34 -0
  63. package/out/_internal/schema/shared/errors.d.ts +264 -0
  64. package/out/_internal/schema/shared/implement.d.ts +154 -0
  65. package/out/_internal/schema/shared/inPlace.d.ts +8 -0
  66. package/out/_internal/schema/shared/issueFeatures.d.ts +38 -0
  67. package/out/_internal/schema/shared/issues.d.ts +261 -0
  68. package/out/_internal/schema/shared/issuesLean.d.ts +80 -0
  69. package/out/_internal/schema/shared/issuesNone.d.ts +22 -0
  70. package/out/_internal/schema/shared/issuesNoneLean.d.ts +20 -0
  71. package/out/_internal/schema/shared/issuesUndetailed.d.ts +25 -0
  72. package/out/_internal/schema/shared/jsonSchema.d.ts +153 -0
  73. package/out/_internal/schema/shared/listed.d.ts +15 -0
  74. package/out/_internal/schema/shared/locale.d.ts +149 -0
  75. package/out/_internal/schema/shared/registry.d.ts +16 -0
  76. package/out/_internal/schema/shared/render.d.ts +3 -0
  77. package/out/_internal/schema/shared/rootApply.d.ts +19 -0
  78. package/out/_internal/schema/shared/sets.d.ts +26 -0
  79. package/out/_internal/schema/shared/standardFailure.d.ts +22 -0
  80. package/out/_internal/schema/shared/standardSchema.d.ts +124 -0
  81. package/out/_internal/schema/shared/toJsonSchema.d.ts +229 -0
  82. package/out/_internal/schema/shared/transform.d.ts +35 -0
  83. package/out/_internal/schema/shared/traversal.d.ts +288 -0
  84. package/out/_internal/schema/shared/utils.d.ts +59 -0
  85. package/out/_internal/schema/structure/index.d.ts +43 -0
  86. package/out/_internal/schema/structure/optional.d.ts +61 -0
  87. package/out/_internal/schema/structure/prop.d.ts +45 -0
  88. package/out/_internal/schema/structure/required.d.ts +49 -0
  89. package/out/_internal/schema/structure/sequence.d.ts +127 -0
  90. package/out/_internal/schema/structure/shared.d.ts +3 -0
  91. package/out/_internal/schema/structure/structure.d.ts +178 -0
  92. package/out/_internal/schema/units.d.ts +123 -0
  93. package/out/_internal/sets/algebra.d.ts +26 -0
  94. package/out/_internal/sets/constraint.d.ts +19 -0
  95. package/out/_internal/sets/engine.d.ts +2 -0
  96. package/out/_internal/sets/formats.d.ts +23 -0
  97. package/out/_internal/sets/fromJsonSchema.d.ts +15 -0
  98. package/out/_internal/sets/implement.d.ts +16 -0
  99. package/out/_internal/sets/index.d.ts +2 -0
  100. package/out/_internal/sets/internal.d.ts +20 -0
  101. package/out/_internal/sets/intersections.d.ts +5 -0
  102. package/out/_internal/sets/kinds.d.ts +3 -0
  103. package/out/_internal/sets/refinements.d.ts +14 -0
  104. package/out/_internal/sets/roots/alias.d.ts +3 -0
  105. package/out/_internal/sets/roots/domain.d.ts +3 -0
  106. package/out/_internal/sets/roots/intersection.d.ts +4 -0
  107. package/out/_internal/sets/roots/morph.d.ts +4 -0
  108. package/out/_internal/sets/roots/proto.d.ts +3 -0
  109. package/out/_internal/sets/roots/union.d.ts +16 -0
  110. package/out/_internal/sets/roots/unit.d.ts +3 -0
  111. package/out/_internal/sets/structure/index.d.ts +3 -0
  112. package/out/_internal/sets/structure/prop.d.ts +8 -0
  113. package/out/_internal/sets/structure/sequence.d.ts +3 -0
  114. package/out/_internal/sets/structure/structure.d.ts +3 -0
  115. package/out/_internal/sets/toJsonSchema.d.ts +25 -0
  116. package/out/_internal/util/arrays.d.ts +130 -0
  117. package/out/_internal/util/clone.d.ts +4 -0
  118. package/out/_internal/util/describe.d.ts +25 -0
  119. package/out/_internal/util/domain.d.ts +49 -0
  120. package/out/_internal/util/errors.d.ts +29 -0
  121. package/out/_internal/util/facts.d.ts +22 -0
  122. package/out/_internal/util/flatMorph.d.ts +41 -0
  123. package/out/_internal/util/formats.d.ts +8 -0
  124. package/out/_internal/util/functions.d.ts +33 -0
  125. package/out/_internal/util/generics.d.ts +65 -0
  126. package/out/_internal/util/get.d.ts +9 -0
  127. package/out/_internal/util/hkt.d.ts +27 -0
  128. package/out/_internal/util/i18n.d.ts +12 -0
  129. package/out/_internal/util/index.d.ts +28 -0
  130. package/out/_internal/util/internal.d.ts +2 -0
  131. package/out/_internal/util/intersections.d.ts +50 -0
  132. package/out/_internal/util/isomorphic.d.ts +8 -0
  133. package/out/_internal/util/keys.d.ts +18 -0
  134. package/out/_internal/util/lazily.d.ts +7 -0
  135. package/out/_internal/util/numbers.d.ts +82 -0
  136. package/out/_internal/util/objectKinds.d.ts +157 -0
  137. package/out/_internal/util/path.d.ts +16 -0
  138. package/out/_internal/util/primitive.d.ts +16 -0
  139. package/out/_internal/util/records.d.ts +173 -0
  140. package/out/_internal/util/registry.d.ts +13 -0
  141. package/out/_internal/util/scanner.d.ts +110 -0
  142. package/out/_internal/util/serialize.d.ts +40 -0
  143. package/out/_internal/util/strings.d.ts +35 -0
  144. package/out/_internal/util/traits.d.ts +89 -0
  145. package/out/_internal/util/unionToTuple.d.ts +14 -0
  146. package/out/_internal/util/weak.d.ts +8 -0
  147. package/out/attributes.d.ts +15 -11
  148. package/out/checkers.d.ts +1 -1
  149. package/out/chunk-22RQSVV3.js +0 -0
  150. package/out/chunk-3HZC67MT.js +965 -0
  151. package/out/chunk-3KBOPH3J.js +1564 -0
  152. package/out/chunk-3SH2BQ4T.js +15 -0
  153. package/out/chunk-46PLKNON.js +126 -0
  154. package/out/{chunk-G45P2CLE.js → chunk-4FTHWK63.js} +6 -1
  155. package/out/{chunk-UK5UGFOX.js → chunk-4HREHNIV.js} +23 -11
  156. package/out/chunk-4NZCLVBD.js +14 -0
  157. package/out/chunk-6FMBO47M.js +7 -0
  158. package/out/chunk-7TALAWYX.js +10 -0
  159. package/out/{chunk-DLWCO4RV.js → chunk-BCYKO54Z.js} +11 -2
  160. package/out/chunk-BDJVONP7.js +168 -0
  161. package/out/{chunk-E3DZXEZK.js → chunk-C2JOL5M2.js} +4 -2
  162. package/out/{chunk-2U2AWCI3.js → chunk-C2V6QPE3.js} +126 -97
  163. package/out/chunk-C3B4IFQL.js +6408 -0
  164. package/out/chunk-CWSF57VM.js +10 -0
  165. package/out/chunk-F5BACUJS.js +7 -0
  166. package/out/{chunk-EVCML554.js → chunk-FWRSDUJ2.js} +14 -5
  167. package/out/chunk-GID3FSQA.js +161 -0
  168. package/out/chunk-I2KLQ2HA.js +22 -0
  169. package/out/chunk-K7SLP5D2.js +84 -0
  170. package/out/chunk-KQPSKGUI.js +9 -0
  171. package/out/chunk-KXOC3JEX.js +8234 -0
  172. package/out/chunk-KXOSUYRA.js +405 -0
  173. package/out/chunk-LHNEY6QW.js +0 -0
  174. package/out/chunk-MTWKGAGO.js +323 -0
  175. package/out/chunk-NU73GNCX.js +170 -0
  176. package/out/{chunk-RAZ3TXOE.js → chunk-P5W67FQH.js} +34 -19
  177. package/out/chunk-PDLTEX6Z.js +1118 -0
  178. package/out/{chunk-VV6YDN2D.js → chunk-QUS4IAXJ.js} +304 -263
  179. package/out/chunk-R7WXIH5P.js +94 -0
  180. package/out/chunk-TACLEIDM.js +95 -0
  181. package/out/chunk-UJJGG4VQ.js +71 -0
  182. package/out/chunk-US6BWOGJ.js +109 -0
  183. package/out/chunk-VMMMOO4R.js +945 -0
  184. package/out/chunk-VYMXHSFR.js +439 -0
  185. package/out/chunk-W2XOI5DY.js +141 -0
  186. package/out/chunk-WC5L5YRP.js +25 -0
  187. package/out/{chunk-NRIGTMPM.js → chunk-WKOSL2G6.js} +4 -1
  188. package/out/chunk-XLG66ZDF.js +0 -0
  189. package/out/{chunk-5U2ZMDNI.js → chunk-XNUAQSJ4.js} +52 -30
  190. package/out/chunk-ZRYEHGSG.js +79 -0
  191. package/out/cli.d.ts +28 -0
  192. package/out/cli.js +636 -0
  193. package/out/codecs.d.ts +6 -5
  194. package/out/codecs.js +23 -7
  195. package/out/config.d.ts +5 -17
  196. package/out/config.js +11 -2
  197. package/out/declare.d.ts +40 -12
  198. package/out/deferred.d.ts +2 -2
  199. package/out/errors.d.ts +1 -1
  200. package/out/errors.js +10 -2
  201. package/out/fn.d.ts +20 -13
  202. package/out/fromJsonSchema.d.ts +18 -0
  203. package/out/generic.d.ts +9 -6
  204. package/out/i18n.d.ts +2 -2
  205. package/out/i18n.js +9 -2
  206. package/out/index.d.ts +16 -7
  207. package/out/index.js +25 -8
  208. package/out/internal.d.ts +4 -0
  209. package/out/internal.js +41 -17
  210. package/out/island.js +22 -6
  211. package/out/islandDependency.js +42 -18
  212. package/out/jsonSchema/infer.d.ts +805 -0
  213. package/out/jsonSchema/validate.d.ts +416 -0
  214. package/out/keywords/Array.d.ts +2 -2
  215. package/out/keywords/builtins.d.ts +3 -3
  216. package/out/keywords/constructors.d.ts +1 -1
  217. package/out/keywords/functions.d.ts +5 -192
  218. package/out/keywords/keywords.d.ts +3 -3
  219. package/out/keywords/number.d.ts +2 -2
  220. package/out/keywords/phrases.d.ts +4 -191
  221. package/out/keywords/string.d.ts +3 -3
  222. package/out/keywords/ts.d.ts +18 -18
  223. package/out/keywords/ts.js +19 -4
  224. package/out/locale.d.ts +6 -2
  225. package/out/locales/de.js +9 -2
  226. package/out/locales/en.js +21 -5
  227. package/out/match.d.ts +13 -10
  228. package/out/module.d.ts +2 -2
  229. package/out/mutatesInput.js +18 -3
  230. package/out/nary.d.ts +220 -194
  231. package/out/parser/ast/bounds.d.ts +2 -2
  232. package/out/parser/ast/default.d.ts +2 -2
  233. package/out/parser/ast/divisor.d.ts +2 -2
  234. package/out/parser/ast/generic.d.ts +2 -2
  235. package/out/parser/ast/infer.d.ts +1 -1
  236. package/out/parser/ast/keyof.d.ts +2 -2
  237. package/out/parser/ast/utils.d.ts +1 -1
  238. package/out/parser/ast/validate.d.ts +2 -2
  239. package/out/parser/definition.d.ts +4 -4
  240. package/out/parser/objectLiteral.d.ts +2 -2
  241. package/out/parser/property.d.ts +2 -2
  242. package/out/parser/reduce/dynamic.d.ts +2 -2
  243. package/out/parser/reduce/shared.d.ts +1 -1
  244. package/out/parser/reduce/static.d.ts +1 -1
  245. package/out/parser/shift/operand/enclosed.d.ts +2 -2
  246. package/out/parser/shift/operand/genericArgs.d.ts +2 -2
  247. package/out/parser/shift/operand/operand.d.ts +1 -1
  248. package/out/parser/shift/operand/unenclosed.d.ts +2 -2
  249. package/out/parser/shift/operand/unresolvable.d.ts +2 -2
  250. package/out/parser/shift/operator/bounds.d.ts +2 -2
  251. package/out/parser/shift/operator/brand.d.ts +2 -2
  252. package/out/parser/shift/operator/default.d.ts +4 -4
  253. package/out/parser/shift/operator/divisor.d.ts +1 -1
  254. package/out/parser/shift/operator/operator.d.ts +1 -1
  255. package/out/parser/shift/tokens.d.ts +1 -1
  256. package/out/parser/string.d.ts +2 -2
  257. package/out/parser/tupleExpressions.d.ts +6 -8
  258. package/out/parser/tupleLiteral.d.ts +2 -2
  259. package/out/precompiled.d.ts +1 -1
  260. package/out/precompiled.js +16 -2
  261. package/out/regex.d.ts +1 -0
  262. package/out/regex.js +2 -0
  263. package/out/runtime.d.ts +10 -8
  264. package/out/runtime.js +6 -4
  265. package/out/runtimeDevelopment.js +70 -52
  266. package/out/schema.d.ts +1 -0
  267. package/out/schema.js +15 -0
  268. package/out/schemaInternal.d.ts +1 -0
  269. package/out/schemaInternal.js +1401 -0
  270. package/out/schemaIssueFeatures.d.ts +1 -0
  271. package/out/schemaRuntime.d.ts +1 -0
  272. package/out/schemaRuntime.js +7 -0
  273. package/out/schemaRuntimeLean.d.ts +1 -0
  274. package/out/schemaRuntimeLean.js +1870 -0
  275. package/out/schemaRuntimeNone.d.ts +1 -0
  276. package/out/schemaRuntimeNone.js +1774 -0
  277. package/out/schemaRuntimeNoneLean.d.ts +1 -0
  278. package/out/schemaRuntimeNoneLean.js +1767 -0
  279. package/out/scope.d.ts +3 -4
  280. package/out/shared/issueFeatures.d.ts +38 -0
  281. package/out/shared/issueFeatures.js +40 -0
  282. package/out/standalone/artifact.d.ts +6 -6
  283. package/out/standalone/baking.d.ts +2 -2
  284. package/out/standalone/combinators.d.ts +1 -1
  285. package/out/standalone/compilers.d.ts +1 -1
  286. package/out/standalone/fallbacks.d.ts +1 -1
  287. package/out/standalone/keys.d.ts +1 -1
  288. package/out/standalone/sites.d.ts +3 -3
  289. package/out/standalone/units.d.ts +1 -1
  290. package/out/standalone/values.d.ts +1 -1
  291. package/out/type.d.ts +6 -6
  292. package/out/util.d.ts +1 -0
  293. package/out/util.js +137 -0
  294. package/out/variants/array.d.ts +6 -6
  295. package/out/variants/base.d.ts +61 -10
  296. package/out/variants/date.d.ts +5 -5
  297. package/out/variants/instantiate.d.ts +1 -1
  298. package/out/variants/number.d.ts +6 -6
  299. package/out/variants/object.d.ts +25 -12
  300. package/out/variants/string.d.ts +8 -8
  301. package/package.json +183 -8
  302. package/skills/arktype/SKILL.md +93 -93
  303. package/skills/arktype/references/migrating.md +144 -158
  304. package/skills/arktype/references/precompile.md +7 -7
  305. package/out/chunk-4CUA5XIP.js +0 -7
  306. package/out/chunk-GPNK5353.js +0 -2529
  307. package/out/chunk-MLKGABMK.js +0 -9
  308. package/out/chunk-PRTMQCHS.js +0 -3
  309. package/out/chunk-R5G57XC7.js +0 -7
  310. package/out/chunk-SWOOCAHN.js +0 -4
  311. package/out/chunk-TAHPKDNM.js +0 -3
  312. package/out/chunk-UETB6YE2.js +0 -14
@@ -0,0 +1,1564 @@
1
+ import {
2
+ listPattern
3
+ } from "./chunk-3SH2BQ4T.js";
4
+ import {
5
+ arkKindOf,
6
+ defineValue,
7
+ describeCollapsibleDate,
8
+ domainDescriptions,
9
+ domainOf,
10
+ flatMorph,
11
+ functionNameOf,
12
+ hasDomain,
13
+ hasOwn,
14
+ isArray,
15
+ isKeyOf,
16
+ isThunk,
17
+ isValidDate,
18
+ noSuggest,
19
+ objectKindDescriptions,
20
+ objectKindOf,
21
+ objectKindOrDomainOf,
22
+ pathAt,
23
+ printKind,
24
+ printable,
25
+ throwError,
26
+ timeOf
27
+ } from "./chunk-3HZC67MT.js";
28
+
29
+ // ../schema/out/shared/enWriters.js
30
+ var Stamp = class {
31
+ constructor(o) {
32
+ return o;
33
+ }
34
+ };
35
+ var DescribedActual = class extends Stamp {
36
+ #described = true;
37
+ static has(o) {
38
+ return #described in o;
39
+ }
40
+ };
41
+ var describeActual = (ctx) => {
42
+ if (!DescribedActual.has(ctx))
43
+ new DescribedActual(ctx);
44
+ };
45
+ var describeUnwrittenActual = (ctx) => {
46
+ try {
47
+ new DescribedActual(ctx);
48
+ } catch {
49
+ }
50
+ };
51
+ var printedActualOf = (ctx) => DescribedActual.has(ctx) ? "" : ctx.actual;
52
+ var writeMessage = (ctx) => {
53
+ const actual = printedActualOf(ctx);
54
+ return `must be ${ctx.expected}${actual ? ` (was ${actual})` : ""}`;
55
+ };
56
+ var writeLine = (ctx) => `${ctx.propString}${ctx.custom ? ":" : ""} ${ctx.message}`;
57
+ var writeUnitMessage = (ctx) => {
58
+ const actual = printedActualOf(ctx);
59
+ return !actual ? `must be ${ctx.expected}` : ctx.expected === actual ? `must be reference equal to ${ctx.expected} (serialized to the same value)` : `must be ${ctx.expected} (was ${actual})`;
60
+ };
61
+ var writeUnitActual = (data) => data instanceof Date && isValidDate(data) ? describeCollapsibleDate(data) : printKind(data);
62
+ var writeNotEqualActual = (data) => data instanceof Date ? describeCollapsibleDate(data) : printKind(data);
63
+ var writeDomainActual = (data) => typeof data === "number" && !Number.isFinite(data) ? String(data) : domainDescriptions[domainOf(data)];
64
+ var writeLengthActual = (data, e) => e.meta?.description === void 0 && e.meta?.expected === void 0 ? `${data.length}` : `length ${data.length}`;
65
+ var writeProtoActual = (data) => {
66
+ if (data instanceof Date && !isValidDate(data)) {
67
+ return timeOf(data) === void 0 ? domainDescriptions.object : "an invalid Date";
68
+ }
69
+ const kind = objectKindOrDomainOf(data);
70
+ return isKeyOf(kind, domainDescriptions) ? domainDescriptions[kind] : kind;
71
+ };
72
+ var enInfo = /* @__PURE__ */ Object.freeze({
73
+ tag: "en",
74
+ list: /* @__PURE__ */ listPattern({ two: " or ", middle: ", ", end: " or " }, { two: " and ", middle: ", ", end: " and " }),
75
+ plural: (n) => n === 1 ? "one" : "other",
76
+ number: String,
77
+ date: describeCollapsibleDate,
78
+ verbatim: (text) => text
79
+ });
80
+
81
+ // ../schema/out/shared/issues.js
82
+ import { bracketsKeys, callsSiteText, findsOnRead, listsUnions, namesTraversalError, readsErrors, readsSummary, reportsIndices, writesText } from "./shared/issueFeatures.js";
83
+ var refuseLocale = (locale) => {
84
+ if (locale === void 0)
85
+ return;
86
+ if (typeof locale !== "object" || locale === null || Array.isArray(locale))
87
+ throw Error("Expected a Locale object");
88
+ throw Error('import "arktype/i18n" to write errors in locales other than en');
89
+ };
90
+ var ReadIssues = class {
91
+ // assigned, as a target lowering class fields defines each with a helper
92
+ constructor() {
93
+ this._ = [];
94
+ this._p = [];
95
+ }
96
+ /**
97
+ * The number of issues.
98
+ */
99
+ get count() {
100
+ return this._.length;
101
+ }
102
+ /**
103
+ * Each issue, its message written when they are first read.
104
+ */
105
+ get issues() {
106
+ return serializableIssues(this._);
107
+ }
108
+ /**
109
+ * @internal fails data at the path it's at. Every bundle holds this, so it
110
+ * takes neither a key nor a site: a validator whose code fails nothing at
111
+ * a key would hold what enters one for nothing, which failsKey does
112
+ * through _k, and a site is a function building it in every bundle
113
+ */
114
+ _e(data, code, expected, message, text) {
115
+ this._.push({ code, path: this._p.slice(), data, expected, message });
116
+ if (callsSiteText)
117
+ text?.(this._[this._.length - 1]);
118
+ return void 0;
119
+ }
120
+ /** @internal */
121
+ _k(apply, data, key, ...missing) {
122
+ this._p.push(key);
123
+ const stops = missing.length && !(key in data) ? this._e(data, "required", ...missing) : !apply(data[key], this);
124
+ this._p.pop();
125
+ return stops;
126
+ }
127
+ };
128
+ var UnreadIssues = class {
129
+ constructor(data, config, apply) {
130
+ this._p = [];
131
+ this._a = apply;
132
+ this._d = data;
133
+ }
134
+ /** @internal each issue in the order it was added, found when first read */
135
+ get _() {
136
+ if (!this._f) {
137
+ this._f = [];
138
+ if (this._a && (this._a(this._d, this), !this._f.length))
139
+ this._e(this._d, "predicate", "valid", "is invalid");
140
+ }
141
+ return this._f;
142
+ }
143
+ get count() {
144
+ return this._.length;
145
+ }
146
+ get issues() {
147
+ return serializableIssues(this._);
148
+ }
149
+ _e(data, code, expected, message, text) {
150
+ this._.push({ code, path: this._p.slice(), data, expected, message });
151
+ if (callsSiteText)
152
+ text?.(this._[this._.length - 1]);
153
+ return void 0;
154
+ }
155
+ _k(apply, data, key, ...missing) {
156
+ this._p.push(key);
157
+ const stops = missing.length && !(key in data) ? this._e(data, "required", ...missing) : !apply(data[key], this);
158
+ this._p.pop();
159
+ return stops;
160
+ }
161
+ };
162
+ var failsKey = (ctx, data, key, code, expected, missing = expected) => ctx._k((value, ctx2) => !ctx2._e(value, code, expected), data, key, missing);
163
+ var failsSite = (ctx, context, data) => ctx._e(data, context.code, context.description, context.x, context.text);
164
+ var failsKeySite = (ctx, site, data, key) => ctx._k((value, ctx2) => !failsSite(ctx2, site.v ?? site, value), data, key, ...missingTextOf(site.m));
165
+ var missingTextOf = (missing) => missing ? [missing.description, missing.x, missing.text] : [];
166
+ var Issues = readsErrors ? findsOnRead ? (
167
+ // named apart, as one bundle may hold both and a name is one class's
168
+ class UnreadArkIssues {
169
+ constructor(data, config, apply) {
170
+ this._p = [];
171
+ this._a = apply;
172
+ this._d = data;
173
+ }
174
+ get _() {
175
+ if (!this._f) {
176
+ this._f = [];
177
+ if (this._a && (this._a(this._d, this), !this._f.length))
178
+ this._e(this._d, "predicate", "valid", "is invalid");
179
+ }
180
+ return this._f;
181
+ }
182
+ get count() {
183
+ return this._.length;
184
+ }
185
+ get issues() {
186
+ return serializableIssues(this._);
187
+ }
188
+ _e(data, code, expected, message, text) {
189
+ this._.push({ code, path: this._p.slice(), data, expected, message });
190
+ if (callsSiteText)
191
+ text?.(this._[this._.length - 1]);
192
+ return void 0;
193
+ }
194
+ _k(apply, data, key, ...missing) {
195
+ this._p.push(key);
196
+ const stops = missing.length && !(key in data) ? this._e(data, "required", ...missing) : !apply(data[key], this);
197
+ this._p.pop();
198
+ return stops;
199
+ }
200
+ get summary() {
201
+ let summary = "";
202
+ for (const issue of this._)
203
+ summary += (summary && "\n") + lineOf(issue);
204
+ return summary;
205
+ }
206
+ summaryIn(locale) {
207
+ refuseLocale(locale);
208
+ return this.summary;
209
+ }
210
+ throw() {
211
+ if (namesTraversalError)
212
+ throw new ThrownIssues(this);
213
+ if (definedThrown)
214
+ throw new definedThrown(this);
215
+ const thrown = Error(this.summary);
216
+ thrown.name = "TraversalError";
217
+ throw Object.defineProperty(thrown, "arkErrors", { value: this });
218
+ }
219
+ toJSON() {
220
+ return this.issues.map(jsonIssueOf);
221
+ }
222
+ [Symbol.iterator]() {
223
+ return this.issues[Symbol.iterator]();
224
+ }
225
+ toString() {
226
+ return this.summary;
227
+ }
228
+ }
229
+ ) : class ArkIssues {
230
+ constructor() {
231
+ this._ = [];
232
+ this._p = [];
233
+ }
234
+ get count() {
235
+ return this._.length;
236
+ }
237
+ get issues() {
238
+ return serializableIssues(this._);
239
+ }
240
+ _e(data, code, expected, message, text) {
241
+ this._.push({ code, path: this._p.slice(), data, expected, message });
242
+ if (callsSiteText)
243
+ text?.(this._[this._.length - 1]);
244
+ return void 0;
245
+ }
246
+ _k(apply, data, key, ...missing) {
247
+ this._p.push(key);
248
+ const stops = missing.length && !(key in data) ? this._e(data, "required", ...missing) : !apply(data[key], this);
249
+ this._p.pop();
250
+ return stops;
251
+ }
252
+ get summary() {
253
+ let summary = "";
254
+ for (const issue of this._)
255
+ summary += (summary && "\n") + lineOf(issue);
256
+ return summary;
257
+ }
258
+ summaryIn(locale) {
259
+ refuseLocale(locale);
260
+ return this.summary;
261
+ }
262
+ // constructed by TraversalError wherever its bundle keeps the
263
+ // class: otherwise an Error with the same name, message and
264
+ // errors, and no class in its bundle. Its name is assigned and
265
+ // its errors defined as the class's are, in statements, which
266
+ // gzip to less than one expression building it and which a build
267
+ // writing the flag as a literal folds as well
268
+ throw() {
269
+ if (namesTraversalError)
270
+ throw new ThrownIssues(this);
271
+ if (definedThrown)
272
+ throw new definedThrown(this);
273
+ const thrown = Error(this.summary);
274
+ thrown.name = "TraversalError";
275
+ throw Object.defineProperty(thrown, "arkErrors", { value: this });
276
+ }
277
+ toJSON() {
278
+ return this.issues.map(jsonIssueOf);
279
+ }
280
+ [Symbol.iterator]() {
281
+ return this.issues[Symbol.iterator]();
282
+ }
283
+ toString() {
284
+ return this.summary;
285
+ }
286
+ } : readsSummary ? class extends (findsOnRead ? UnreadIssues : ReadIssues) {
287
+ get summary() {
288
+ let summary = "";
289
+ for (const issue of this._)
290
+ summary += (summary && "\n") + lineOf(issue);
291
+ return summary;
292
+ }
293
+ } : findsOnRead ? UnreadIssues : ReadIssues;
294
+ var jsonIssueOf = (issue) => ({
295
+ code: issue.code,
296
+ path: issue.path.map((k) => typeof k === "symbol" ? String(k) : k),
297
+ ...issue.expected !== void 0 && { expected: issue.expected },
298
+ message: issue.message ?? messageOf(issue),
299
+ ...issue.errors?.length ? { errors: issue.errors.map(jsonIssueOf) } : {}
300
+ });
301
+ var issuesToJson = {
302
+ value() {
303
+ return this.map(jsonIssueOf);
304
+ },
305
+ writable: true,
306
+ configurable: true
307
+ };
308
+ var serializableIssues = (issues) => {
309
+ for (const issue of issues)
310
+ issue.message ??= messageOf(issue);
311
+ return issues.toJSON ? issues : Object.defineProperty(issues, "toJSON", issuesToJson);
312
+ };
313
+ var FirstIssues = class extends Issues {
314
+ // read from the prototype, so no errors object lists it among its own keys
315
+ get failFast() {
316
+ return true;
317
+ }
318
+ _e(...failure) {
319
+ super._e(...failure);
320
+ return true;
321
+ }
322
+ };
323
+ var applyIssues = (apply, data, onFail, Ctx = Issues) => {
324
+ const errors = new Ctx();
325
+ apply(data, errors);
326
+ return !errors.count ? data : onFail ? onFail(errors) : errors;
327
+ };
328
+ var issuesOf = (apply, data, errors) => {
329
+ apply(data, errors);
330
+ if (!errors._.length)
331
+ errors._e(data, "predicate", "valid", "is invalid");
332
+ return errors._;
333
+ };
334
+ var foundErrors = (apply, data, onFail, Ctx = Issues) => {
335
+ const errors = new Ctx();
336
+ apply(data, errors);
337
+ if (!errors._.length)
338
+ errors._e(data, "predicate", "valid", "is invalid");
339
+ return onFail ? onFail(errors) : errors;
340
+ };
341
+ var issueAt = (path, site, data, key) => {
342
+ let context = site.v ?? site;
343
+ if (key !== void 0) {
344
+ if (site.m && !(key in data))
345
+ context = site.m;
346
+ else
347
+ data = data[key];
348
+ }
349
+ const issue = {
350
+ code: context.code,
351
+ path: pathAt(path, key),
352
+ data,
353
+ expected: context.description,
354
+ message: context.x
355
+ };
356
+ if (callsSiteText)
357
+ context.text?.(issue);
358
+ return issue;
359
+ };
360
+ var throwOnDefault = (errors) => errors.throw();
361
+ var mergeIssues = (errors, merged, prefix) => {
362
+ for (const issue of merged.issues) {
363
+ errors._.push(listsUnions && issue._m ? issue._m(prefix) : movedIssue(issue, [...prefix, ...issue.path]));
364
+ }
365
+ };
366
+ var isCustomIssue = (issue) => listsUnions && issue._l !== void 0 ? false : writesText && issue.message !== void 0 && !issue.message.startsWith(messageOf(issue));
367
+ var codedIssue = (issue) => Object.defineProperty(issue, "_c", { value: 2 });
368
+ var notedAs = (issue, copy) => listsUnions && writesText && issue._c ? codedIssue(copy) : copy;
369
+ var movedIssue = (issue, path) => notedAs(issue, {
370
+ code: issue.code,
371
+ path,
372
+ data: issue.data,
373
+ expected: issue.expected,
374
+ message: issue.message
375
+ });
376
+ var pathOf = (issue) => {
377
+ let path = "";
378
+ for (const k of issue.path) {
379
+ path += reportsIndices && typeof k === "number" ? `[${k}]` : bracketsKeys && !/^[$_a-z][\w$]*$/i.test(String(k)) ? `[${JSON.stringify(k) ?? String(k)}]` : (path && ".") + String(k);
380
+ }
381
+ return path;
382
+ };
383
+ var lineOf = (issue) => {
384
+ const message = issue.message ??= messageOf(issue);
385
+ const path = reportsIndices || bracketsKeys ? pathOf(issue) : issue.path.join(".");
386
+ return listsUnions && issue._l !== void 0 ? issue._l : path ? path + (writesText && !(message === "is invalid" && issue.expected === "valid") && !message.startsWith(messageOf(issue)) ? ": " : " ") + message : message;
387
+ };
388
+ var messageOf = (issue) => issue.expected !== void 0 ? "must be " + issue.expected + (issue.code === "required" ? " (was missing)" : "") : issue.code === "required" ? "is missing" : "is invalid";
389
+ var definedThrown;
390
+ var ThrownIssues = /* @__PURE__ */ (() => definedThrown = class TraversalError extends Error {
391
+ constructor(errors) {
392
+ super(errors.summary);
393
+ this.name = "TraversalError";
394
+ Object.defineProperty(this, "arkErrors", { value: errors });
395
+ }
396
+ })();
397
+ var throwIssues = (apply, data) => {
398
+ const errors = new Issues();
399
+ apply(data, errors);
400
+ if (!errors._.length)
401
+ errors._e(data, "predicate", "valid", "is invalid");
402
+ return errors.throw();
403
+ };
404
+
405
+ // ../schema/out/shared/listed.js
406
+ import { rewritesUnions, writesText as writesText2 } from "./shared/issueFeatures.js";
407
+ var writeBranches = (alternatives) => {
408
+ const unique = [...new Set(alternatives)];
409
+ if ([...unique].sort().join() === "false,true")
410
+ return "boolean";
411
+ const last = unique.pop();
412
+ return unique.length ? `${unique.join(", ")} or ${last}` : last;
413
+ };
414
+ var alternativesOf = (issues) => issues.flatMap(({ code, expected = "valid" }) => issues.length > 1 && /^(req|disc|union)/.test(code) ? expected.split(/(?:, | or )(?=(?:[^"]*"[^"]*")*[^"]*$)/) : [expected]);
415
+ var writeListed = (errors) => {
416
+ const atSubject = {};
417
+ for (const error of errors) {
418
+ error.message ??= messageOf(error);
419
+ const path = pathOf(error);
420
+ (atSubject[(path && path + " ") + "must be "] ??= []).push(error);
421
+ }
422
+ return writeBranches(Object.entries(atSubject).map(([subject, same]) => subject + writeBranches(alternativesOf(same))));
423
+ };
424
+ var writeAlike = (errors) => {
425
+ for (const error of errors)
426
+ error.message ??= messageOf(error);
427
+ return lineOf(errors[0]);
428
+ };
429
+ var sharedMessageOf = (errors) => {
430
+ let shared;
431
+ for (const error of errors) {
432
+ if (!isCustomIssue(error) || error._c || shared !== void 0 && error.message !== shared)
433
+ return;
434
+ shared = error.message;
435
+ }
436
+ return shared;
437
+ };
438
+ var ListedIssue = class {
439
+ code = "union";
440
+ // private, so only what an issue's readers see is its own
441
+ #line;
442
+ constructor(path, data, errors, line, expected, message = expected) {
443
+ this.path = path;
444
+ this.data = data;
445
+ this.errors = errors;
446
+ this.expected = expected;
447
+ this.message = message;
448
+ this.#line = line;
449
+ }
450
+ get _l() {
451
+ return this.#line;
452
+ }
453
+ };
454
+ var movedBy = (errors, path) => errors.map((error) => ({ ...error, path: path(error) }));
455
+ var writeFromPath = (path, errors, write) => write(path.length ? movedBy(errors, (error) => error.path.slice(path.length)) : errors);
456
+ var basesIssueOf = (path, data, errors, describe) => {
457
+ for (const { code, path: at } of errors) {
458
+ if (code !== "domain" && code !== "proto" && code !== "unit" || at.length !== path.length || at.some((k, i) => k !== path[i]))
459
+ return;
460
+ }
461
+ const expected = describe(errors.map((error) => error.expected));
462
+ return new ListedIssue(path.slice(), data, [], void 0, expected, messageOf({ expected }));
463
+ };
464
+ var listed = (Issue, path, data, errors, write) => {
465
+ const line = write(errors);
466
+ const expected = writeFromPath(path, errors, write);
467
+ const shared = writesText2 ? sharedMessageOf(errors) : void 0;
468
+ return shared === void 0 ? new Issue(path.slice(), data, errors, line, expected) : new Issue(path.slice(), data, errors, void 0, expected, shared);
469
+ };
470
+ var issueWriterOf = (write, describeBases) => rewritesUnions ? /* @__PURE__ */ (() => {
471
+ class RewrittenIssue extends ListedIssue {
472
+ _m(prefix) {
473
+ const moved = movedBy(this.errors, (error) => [
474
+ ...prefix,
475
+ ...error.path
476
+ ]);
477
+ return new RewrittenIssue([...prefix, ...this.path], this.data, moved, this._l === void 0 ? void 0 : write(moved), this.expected, this.message);
478
+ }
479
+ }
480
+ return (path, data, errors) => basesIssueOf(path, data, errors, describeBases) ?? listed(RewrittenIssue, path, data, errors, write);
481
+ })() : (path, data, errors) => basesIssueOf(path, data, errors, describeBases) ?? listed(ListedIssue, path, data, errors, write);
482
+ var listedIssue = /* @__PURE__ */ issueWriterOf(writeListed, writeBranches);
483
+ var alikeIssue = /* @__PURE__ */ issueWriterOf(writeAlike, (expected) => expected[0]);
484
+
485
+ // ../schema/out/shared/transform.js
486
+ var TransformErrors = class TransformErrors {
487
+ // a function, so a check can rule out other values by typeof
488
+ constructor(result, data) {
489
+ const errors = Object.setPrototypeOf(() => {
490
+ }, TransformErrors.prototype);
491
+ errors.entries = [{ reversedPath: [], result, data }];
492
+ return errors;
493
+ }
494
+ addTo(gathered, key) {
495
+ if (key !== void 0)
496
+ for (const entry of this.entries)
497
+ entry.reversedPath.push(key);
498
+ if (!gathered)
499
+ return this;
500
+ gathered.entries.push(...this.entries);
501
+ return gathered;
502
+ }
503
+ };
504
+ var holdsOnlyIndices = (data) => {
505
+ const keys = Object.keys(data);
506
+ return keys.length === data.length && (!keys.length || keys[keys.length - 1] === `${keys.length - 1}`) && !Object.getOwnPropertySymbols(data).length;
507
+ };
508
+ var copyOf = (data) => {
509
+ if (isArray(data)) {
510
+ const copy = Array.prototype.slice.call(data);
511
+ const keys = Object.keys(data);
512
+ return keys.length !== copy.length || keys[copy.length - 1] !== `${copy.length - 1}` || Object.getOwnPropertySymbols(data).length ? Object.defineProperties(copy, Object.getOwnPropertyDescriptors({ ...data })) : copy;
513
+ }
514
+ const prototype = Object.getPrototypeOf(data);
515
+ if (prototype === Object.prototype)
516
+ return { ...data };
517
+ return Object.prototype.toString.call(data) === "[object Object]" ? Object.setPrototypeOf({ ...data }, prototype) : data;
518
+ };
519
+ var setOwnValue = (out, k, value) => {
520
+ if (k === "__proto__")
521
+ defineValue(out, k, value);
522
+ else
523
+ out[k] = value;
524
+ };
525
+ var keepOwn = (out, data, k) => {
526
+ if (!(k in out) && hasOwn(data, k))
527
+ setOwnValue(out, k, data[k]);
528
+ };
529
+ var copyDeclared = (data, declared, changes) => {
530
+ "use strict";
531
+ let out = data;
532
+ if (changes) {
533
+ for (let i = 0; i < changes.length; i += 3) {
534
+ if (Object.is(changes[i + 2], changes[i + 1]))
535
+ continue;
536
+ if (out === data)
537
+ out = copyOf(data);
538
+ setOwnValue(out, changes[i], changes[i + 2]);
539
+ }
540
+ if (out !== data)
541
+ for (const k of declared)
542
+ keepOwn(out, data, k);
543
+ }
544
+ for (const k of [
545
+ ...Object.keys(data),
546
+ ...Object.getOwnPropertySymbols(data)
547
+ ]) {
548
+ if (declared.includes(k))
549
+ continue;
550
+ if (out === data)
551
+ out = copyOf(data);
552
+ delete out[k];
553
+ }
554
+ return out;
555
+ };
556
+ var mergeTransformed = (input, l, r) => {
557
+ if (Object.is(r, input))
558
+ return l;
559
+ if (!hasDomain(input, "object") || !hasDomain(l, "object") || !hasDomain(r, "object") || r instanceof TransformErrors)
560
+ return r;
561
+ const merged = copyOf(l);
562
+ for (const k in input)
563
+ if (!hasOwn(r, k))
564
+ delete merged[k];
565
+ for (const k in r) {
566
+ if (!(k in input) || !Object.is(r[k], input[k]))
567
+ setOwnValue(merged, k, r[k]);
568
+ }
569
+ return merged;
570
+ };
571
+
572
+ // ../schema/out/shared/utils.js
573
+ var makeRootAndArrayPropertiesMutable = (o) => (
574
+ // this cast should not be required, but it seems TS is referencing
575
+ // the wrong parameters here?
576
+ flatMorph(o, (k, v) => [k, isArray(v) ? [...v] : v])
577
+ );
578
+ var hasArkKind = (value, kind) => arkKindOf(value) === kind;
579
+ var isNode = (value) => {
580
+ const kind = arkKindOf(value);
581
+ return kind === "root" || kind === "constraint";
582
+ };
583
+ var inProgress = {
584
+ definitions: 0,
585
+ resolutions: 0,
586
+ ioReads: 0,
587
+ compositions: 0
588
+ };
589
+ var isResolutionFinal = () => !inProgress.definitions && !inProgress.resolutions;
590
+ var isIoFinal = () => !inProgress.definitions && inProgress.resolutions === inProgress.ioReads;
591
+ var uncheckedAssertions = [];
592
+ var uncheckedKeys = {};
593
+ var queueUnchecked = (assert, key) => {
594
+ if (key !== void 0) {
595
+ if (uncheckedKeys[key])
596
+ return;
597
+ uncheckedKeys[key] = true;
598
+ }
599
+ uncheckedAssertions.push(assert);
600
+ };
601
+ var assertingUnchecked = false;
602
+ var assertUnchecked = () => {
603
+ if (!isResolutionFinal() || assertingUnchecked)
604
+ return;
605
+ assertingUnchecked = true;
606
+ try {
607
+ for (let i = 0; i < uncheckedAssertions.length; i++)
608
+ uncheckedAssertions[i]();
609
+ } finally {
610
+ assertingUnchecked = false;
611
+ discardUnchecked();
612
+ }
613
+ };
614
+ var discardUnchecked = () => {
615
+ uncheckedAssertions.length = 0;
616
+ uncheckedKeys = {};
617
+ };
618
+ var resolving = (resolve) => {
619
+ inProgress.resolutions++;
620
+ let result;
621
+ try {
622
+ result = resolve();
623
+ } finally {
624
+ inProgress.resolutions--;
625
+ }
626
+ assertUnchecked();
627
+ return result;
628
+ };
629
+ var defining = (define) => {
630
+ if (isResolutionFinal())
631
+ discardUnchecked();
632
+ inProgress.definitions++;
633
+ try {
634
+ return define();
635
+ } finally {
636
+ inProgress.definitions--;
637
+ }
638
+ };
639
+ var composing = (compose) => {
640
+ inProgress.compositions++;
641
+ try {
642
+ return compose();
643
+ } finally {
644
+ inProgress.compositions--;
645
+ }
646
+ };
647
+ var holeNameMarker = "$hole_";
648
+ var holeNameSuffix = /\$hole_[\da-z]+/g;
649
+ var withoutHoleNames = (s) => s.includes(holeNameMarker) ? s.replace(holeNameSuffix, "") : s;
650
+ var maxNestedLength = 1e3;
651
+ var elided = (nested) => nested.length > maxNestedLength && withoutHoleNames(nested).length > maxNestedLength ? "..." : nested;
652
+ var printSelfAsThis = (node, printedWithThis) => {
653
+ const { expression } = node;
654
+ return Object.defineProperties(node, {
655
+ expression: {
656
+ get: () => inProgress.compositions ? expression : printedWithThis.expression
657
+ },
658
+ description: {
659
+ get: () => inProgress.compositions ? Reflect.get(Object.getPrototypeOf(node), "description", node) : printedWithThis.description
660
+ }
661
+ });
662
+ };
663
+ var valueAtPath = (path, data, end = path.length) => {
664
+ let value = data;
665
+ for (let i = 0; i < end; i++)
666
+ value = value?.[path[i]];
667
+ return value;
668
+ };
669
+ var isAbsent = (path, data) => path.length !== 0 && !(path[path.length - 1] in valueAtPath(path, data, path.length - 1));
670
+ var removedProblemMessage = "problem was removed in 3.0; write message";
671
+ var describeBranches = (descriptions, opts) => {
672
+ const delimiter = opts?.delimiter ?? ", ";
673
+ const finalDelimiter = opts?.finalDelimiter ?? " or ";
674
+ if (descriptions.length === 0)
675
+ return "never";
676
+ if (descriptions.length === 1)
677
+ return descriptions[0];
678
+ if (descriptions.length === 2 && (descriptions[0] === "false" && descriptions[1] === "true" || descriptions[0] === "true" && descriptions[1] === "false"))
679
+ return "boolean";
680
+ const seen = /* @__PURE__ */ Object.create(null);
681
+ const unique = descriptions.filter((s) => seen[s] ? false : seen[s] = true);
682
+ const last = unique.pop();
683
+ return `${unique.join(delimiter)}${unique.length ? finalDelimiter : ""}${last}`;
684
+ };
685
+ var describeExpressionOptions = {
686
+ delimiter: " | ",
687
+ finalDelimiter: " | "
688
+ };
689
+ var expressBranches = (expressions) => describeBranches(expressions, describeExpressionOptions);
690
+ var describeCases = ({ discriminantKind, cases }) => describeBranches(discriminantKind === "domain" ? cases.map((domain) => domain === "Array" ? objectKindDescriptions.Array : domainDescriptions[domain]) : cases.map((unit) => printable(unit, { ownDataOnly: true })));
691
+
692
+ // ../schema/out/shared/traversal.js
693
+ import { callsSiteText as callsSiteText2, findsOnRead as findsOnRead2, listsUnions as listsUnions2 } from "./shared/issueFeatures.js";
694
+ var noBranches = [];
695
+ var InternalTraversal = class {
696
+ constructor(root, config) {
697
+ this.context = callContext;
698
+ if (onContextRead)
699
+ Object.defineProperty(this, "context", { get: onContextRead });
700
+ this.path = [];
701
+ this._errors = void 0;
702
+ this.root = root;
703
+ this.config = config;
704
+ this.branches = noBranches;
705
+ this.res = void 0;
706
+ this.isTree = true;
707
+ this.tfdById = void 0;
708
+ this.recv = root;
709
+ this.recvAt = 0;
710
+ this.chkOnly = false;
711
+ this.retFrom = void 0;
712
+ }
713
+ /**
714
+ * #### whether {@link currentBranch} (or the traversal root, outside a union) has one or more errors
715
+ */
716
+ hasError() {
717
+ return this.errN !== 0;
718
+ }
719
+ get currentBranch() {
720
+ return this.branches.length === 0 ? void 0 : this.branches[this.branches.length - 1];
721
+ }
722
+ /** its result: the data, or its errors passed to `onFail` if it has any */
723
+ fin(onFail) {
724
+ if (this.hasError())
725
+ return onFail ? onFail(this._errors) : this._errors;
726
+ return this.root;
727
+ }
728
+ /** how many errors the current union branch has, or the traversal has outside a union */
729
+ get errN() {
730
+ const branches = this.branches;
731
+ return branches.length === 0 ? this._errors?.count ?? 0 : branches[branches.length - 1].errN;
732
+ }
733
+ get failFast() {
734
+ return this.branches.length !== 0;
735
+ }
736
+ /** starts counting a union branch's errors */
737
+ pushBr() {
738
+ const branch = { error: void 0, errN: 0 };
739
+ if (this.branches === noBranches)
740
+ this.branches = [branch];
741
+ else
742
+ this.branches.push(branch);
743
+ }
744
+ /** stops counting the innermost union branch's errors, returning it */
745
+ popBr() {
746
+ return this.branches.pop();
747
+ }
748
+ /**
749
+ * @internal
750
+ * Convenience for casting from InternalTraversal to Traversal
751
+ * for cases where the extra methods on the external type are expected, e.g.
752
+ * a morph or predicate.
753
+ */
754
+ get external() {
755
+ return this;
756
+ }
757
+ nodeError(input, data) {
758
+ return this.addError({
759
+ code: input.code,
760
+ path: this.path.slice(),
761
+ data,
762
+ expected: input.description
763
+ });
764
+ }
765
+ /** @internal a validator's failure, as its errors take one */
766
+ _e(data, code, expected, message, text) {
767
+ const issue = {
768
+ code,
769
+ path: this.path.slice(),
770
+ data,
771
+ expected,
772
+ message
773
+ };
774
+ if (callsSiteText2)
775
+ text?.(issue);
776
+ this.addError(issue);
777
+ return this.failFast;
778
+ }
779
+ /** @internal a validator's key, as its errors enter one */
780
+ _k(apply, data, key, ...missing) {
781
+ this.path.push(key);
782
+ const value = data[key];
783
+ const stops = value === void 0 && missing.length && !(key in data) ? this._e(data, "required", ...missing) : !apply(value, this);
784
+ this.path.pop();
785
+ return stops;
786
+ }
787
+ /** @internal */
788
+ failsUnion(branches, site, data) {
789
+ this.addError(issueAt(this.path, site, data, void 0));
790
+ return this.failFast;
791
+ }
792
+ /** @internal */
793
+ addError(error) {
794
+ if (this.currentBranch)
795
+ this.failBranch(error);
796
+ else {
797
+ const errors = errorsOf(this);
798
+ if (findsOnRead2 || errors._.length)
799
+ errors._.push(error);
800
+ else
801
+ errors._ = [error];
802
+ }
803
+ return error;
804
+ }
805
+ /**
806
+ * @internal adds the errors of a validator called with this traversal,
807
+ * returning its own
808
+ */
809
+ piped(errors) {
810
+ const target = errorsOf(this);
811
+ if (target._merge)
812
+ target._merge(errors, this.path);
813
+ else {
814
+ for (const issue of errors._) {
815
+ target._.push(listsUnions2 && issue._m ? issue._m(this.path) : notedAs(issue, { ...issue, path: [...this.path, ...issue.path] }));
816
+ }
817
+ }
818
+ return target;
819
+ }
820
+ /** @internal */
821
+ createErrors() {
822
+ return new Issues();
823
+ }
824
+ failBranch(error) {
825
+ const branch = this.currentBranch;
826
+ branch.error = error;
827
+ branch.errN++;
828
+ }
829
+ };
830
+ var Traversal = class extends InternalTraversal {
831
+ /**
832
+ * #### {@link ArkErrors} that will be part of this traversal's finalized result
833
+ *
834
+ * ✅ will always be empty for a valid traversal
835
+ */
836
+ get errors() {
837
+ return errorsOf(this);
838
+ }
839
+ /**
840
+ * #### the data being validated or morphed
841
+ *
842
+ * ✅ the value at {@link path}, as transformed by any morphs that have already run
843
+ */
844
+ get data() {
845
+ let result = this.recv;
846
+ for (let i = this.recvAt; i < this.path.length; i++)
847
+ result = result?.[this.path[i]];
848
+ return result;
849
+ }
850
+ /**
851
+ * #### a string representing {@link path}
852
+ *
853
+ * @propString
854
+ */
855
+ get propString() {
856
+ return pathOf(this);
857
+ }
858
+ /**
859
+ * #### add an {@link ArkError} and return `false`
860
+ *
861
+ * ✅ useful for predicates like `.narrow`
862
+ * ✅ `{ message: "Enter a valid email" }` is the whole sentence an issue says
863
+ * 🔗 to say what the value must be, as `must be even`, pass `"even"` to {@link mustBe}
864
+ */
865
+ reject(input) {
866
+ this.raise(input);
867
+ return false;
868
+ }
869
+ /**
870
+ * #### add an {@link ArkError} from a description and return `false`
871
+ *
872
+ * ✅ useful for predicates like `.narrow`
873
+ * 🔗 equivalent to {@link reject}({ expected })
874
+ */
875
+ mustBe(expected) {
876
+ this.raise(expected);
877
+ return false;
878
+ }
879
+ error(input) {
880
+ this.retFrom ??= errorsOf(this).count;
881
+ return this.raise(input);
882
+ }
883
+ raise(input) {
884
+ throwOnProblem(input);
885
+ const supplied = typeof input === "object" ? input : { expected: input };
886
+ const code = supplied.code ?? "predicate";
887
+ const issue = {
888
+ code,
889
+ path: [
890
+ ...supplied.prefixPath ?? [],
891
+ ...supplied.path ?? this.path,
892
+ ...supplied.relativePath ?? []
893
+ ],
894
+ data: "data" in supplied ? supplied.data : this.data,
895
+ // a keyword raises its errors with the description of what it checks
896
+ // a code of its own is written without what its rule describes
897
+ expected: supplied.expected ?? supplied.description ?? (code === "predicate" || supplied.morph ? describePredicate(supplied) : "valid")
898
+ };
899
+ if (supplied.message !== void 0)
900
+ issue.message = supplied.message;
901
+ else if (supplied.cause !== void 0 && supplied.morph) {
902
+ try {
903
+ issue.message = `must be ${issue.expected} (${String(supplied.cause)})`;
904
+ } catch {
905
+ }
906
+ } else if (supplied.actual)
907
+ issue.message = `must be ${issue.expected} (was ${supplied.actual})`;
908
+ return this.addError(issue);
909
+ }
910
+ };
911
+ var FirstIssueTraversal = class extends Traversal {
912
+ get failFast() {
913
+ return true;
914
+ }
915
+ fin(onFail) {
916
+ this._errors?._.splice(1);
917
+ return super.fin(onFail);
918
+ }
919
+ };
920
+ var throwOnProblem = (input) => {
921
+ if (typeof input === "object" && "problem" in input)
922
+ throwError(removedProblemMessage);
923
+ };
924
+ var errorsOf = (ctx) => ctx._errors ??= ctx.createErrors();
925
+ var applyRejected = (node, data, config, onFail, ctor) => {
926
+ const ctx = new ctor(data, config);
927
+ node.tApply(data, ctx);
928
+ return ctx.fin(onFail);
929
+ };
930
+ var receive = (ctx, data) => {
931
+ ctx.recv = data;
932
+ ctx.recvAt = ctx.path.length;
933
+ };
934
+ var describePredicate = (ctx) => {
935
+ const fn = ctx.predicate ?? ctx.morph;
936
+ return `valid according to ${fn && functionNameOf(fn) || "an anonymous predicate"}`;
937
+ };
938
+ var tryMorph = (morph) => (In, ctx) => {
939
+ try {
940
+ return morph(In, ctx);
941
+ } catch (cause) {
942
+ return ctx.error({ code: "predicate", morph, cause });
943
+ }
944
+ };
945
+ var execMorph = (regex) => (s) => regex.exec(s);
946
+ var callMorph = (ctx, morph, data) => {
947
+ const { recv, recvAt } = ctx;
948
+ receive(ctx, data);
949
+ ctx.retFrom = void 0;
950
+ const result = morph(data, ctx);
951
+ ctx.recv = recv;
952
+ ctx.recvAt = recvAt;
953
+ return ctx.retFrom === void 0 ? result : returned(ctx, result);
954
+ };
955
+ var returned = (ctx, result) => typeof result === "object" && ctx._errors._.includes(result, ctx.retFrom) ? ctx._errors : result;
956
+ var transform = (ctx, node, data) => node.tfsById ? transformResolution(ctx, node.id, data, node.tTransform, node) : transformAcyclic(ctx, node, data);
957
+ var transformAcyclic = (ctx, node, data) => transformed(ctx, node.tTransform(data, ctx), data);
958
+ var transformed = (ctx, result, data) => {
959
+ if (!(result instanceof TransformErrors))
960
+ return result;
961
+ addMorphErrs(ctx, result);
962
+ return data;
963
+ };
964
+ var pipeOf = (node) => node.hasAlias ? pipe : pipeAcyclicOf(node);
965
+ var pipeAcyclicOf = (node) => node.tfs ? pipeTransformed : node.allowsCtx || node.reportsPred ? pipeChecked : pipeApplied;
966
+ var pipeChecked = (ctx, node, data) => allowsPiped(ctx, node, data) ? data : errorsOf(ctx);
967
+ var pipeApplied = (ctx, node, data) => {
968
+ if (node.allows(data))
969
+ return data;
970
+ node.tApply(data, ctx);
971
+ return errorsOf(ctx);
972
+ };
973
+ var pipeTransformed = (ctx, node, data) => allowsPiped(ctx, node, data) ? transformPiped(ctx, node, data, transformAcyclic) : errorsOf(ctx);
974
+ var pipe = (ctx, node, data) => {
975
+ if (!node.hasAlias)
976
+ return pipeAcyclicOf(node)(ctx, node, data);
977
+ if (!node.allows(data)) {
978
+ applyPipedResolution(ctx, node, data);
979
+ return errorsOf(ctx);
980
+ }
981
+ if (!node.tfs)
982
+ return data;
983
+ const { tfdById, isTree } = ctx;
984
+ ctx.tfdById = void 0;
985
+ ctx.isTree = true;
986
+ const result = transformPiped(ctx, node, data, transform);
987
+ ctx.tfdById = tfdById;
988
+ ctx.isTree = isTree;
989
+ return result;
990
+ };
991
+ var allowsPiped = (ctx, node, data) => {
992
+ if (node.allowsCtx || node.reportsPred)
993
+ return applyPiped(ctx, node, data);
994
+ if (node.allows(data))
995
+ return true;
996
+ applyPiped(ctx, node, data);
997
+ return false;
998
+ };
999
+ var transformPiped = (ctx, node, data, transformNode) => {
1000
+ const { recv, recvAt } = ctx;
1001
+ const errN = ctx.errN;
1002
+ const result = transformNode(ctx, node, data);
1003
+ ctx.recv = recv;
1004
+ ctx.recvAt = recvAt;
1005
+ return ctx.errN > errN ? errorsOf(ctx) : result;
1006
+ };
1007
+ var applyPiped = (ctx, node, data) => {
1008
+ const errN = ctx.errN;
1009
+ const { recv, recvAt, chkOnly } = ctx;
1010
+ receive(ctx, data);
1011
+ ctx.chkOnly = true;
1012
+ node.tApply(data, ctx);
1013
+ ctx.chkOnly = chkOnly;
1014
+ ctx.recv = recv;
1015
+ ctx.recvAt = recvAt;
1016
+ return ctx.errN === errN;
1017
+ };
1018
+ var applyPipedResolution = (ctx, node, data) => {
1019
+ const { recv, recvAt, chkOnly } = ctx;
1020
+ receive(ctx, data);
1021
+ ctx.chkOnly = true;
1022
+ const piped = traversalOf(ctx, data);
1023
+ piped.chkOnly = true;
1024
+ const { _errors } = applyCyclic(node, data, piped);
1025
+ if (_errors)
1026
+ addErrors(ctx, _errors);
1027
+ ctx.chkOnly = chkOnly;
1028
+ ctx.recv = recv;
1029
+ ctx.recvAt = recvAt;
1030
+ };
1031
+ var transformsValid = (ctx) => ctx.branches.length === 0 && !ctx.chkOnly;
1032
+ var transformedInApply = (ctx, result) => {
1033
+ if (result instanceof TransformErrors)
1034
+ addMorphErrs(ctx, result);
1035
+ };
1036
+ var transformIfAllowed = (ctx, node, data) => {
1037
+ if (!transformsValid(ctx))
1038
+ return false;
1039
+ if (node.hasAlias) {
1040
+ const untracked = allowsAcyclic(node, data);
1041
+ if (!(untracked ?? allowsInTraversal(node, data, traversalOf(ctx, data))))
1042
+ return false;
1043
+ ctx.isTree = untracked === void 0;
1044
+ ctx.tfdById = void 0;
1045
+ } else if (!allowsInBranch(ctx, node, data))
1046
+ return false;
1047
+ transformedInApply(ctx, transform(ctx, node, data));
1048
+ return true;
1049
+ };
1050
+ var allowsInBranch = (ctx, node, data) => node.checksCtx ? allowsInBranchBy(ctx, node.tAllows, data, node) : node.allows(data);
1051
+ var silentCtx = {
1052
+ mustBe: () => false,
1053
+ reject: () => false,
1054
+ get context() {
1055
+ return onContextRead ? onContextRead() : callContext;
1056
+ }
1057
+ };
1058
+ var callContext;
1059
+ var inContext = (context, run) => {
1060
+ const outer = callContext;
1061
+ callContext = context;
1062
+ try {
1063
+ return run();
1064
+ } finally {
1065
+ callContext = outer;
1066
+ }
1067
+ };
1068
+ var onContextRead;
1069
+ var readingContextWith = (onRead, run) => {
1070
+ const outer = onContextRead;
1071
+ onContextRead = onRead;
1072
+ try {
1073
+ return run();
1074
+ } finally {
1075
+ onContextRead = outer;
1076
+ }
1077
+ };
1078
+ var withContextOf = (t, context) => {
1079
+ const standard = t["~standard"];
1080
+ return Object.assign((data) => inContext(context, () => t(data)), {
1081
+ assert: (data) => inContext(context, () => t.assert(data)),
1082
+ allows: (data) => inContext(context, () => t.allows(data)),
1083
+ // as the Type's, with its vendor's own members like _c, but validating in context
1084
+ "~standard": Object.defineProperties({}, {
1085
+ ...Object.getOwnPropertyDescriptors(standard),
1086
+ validate: {
1087
+ value: (value, options) => inContext(context, () => standard.validate(value, options)),
1088
+ enumerable: true
1089
+ }
1090
+ })
1091
+ });
1092
+ };
1093
+ var allowsInBranchBy = (ctx, allows, data, node) => {
1094
+ const pathLength = ctx.path.length;
1095
+ ctx.pushBr();
1096
+ const allowed = allows.call(node, data, ctx);
1097
+ if (ctx.path.length !== pathLength)
1098
+ ctx.path.length = pathLength;
1099
+ return ctx.popBr().errN === 0 && allowed;
1100
+ };
1101
+ var disallowed = () => false;
1102
+ var rejectedBy;
1103
+ var rejectedValue;
1104
+ var rejected = (allows, value) => {
1105
+ if (typeof value === "string") {
1106
+ rejectedBy = allows;
1107
+ rejectedValue = value;
1108
+ }
1109
+ return false;
1110
+ };
1111
+ var rejects = (allows, value) => {
1112
+ if (value !== rejectedValue || allows !== rejectedBy)
1113
+ return !allows(value);
1114
+ rejectedBy = rejectedValue = void 0;
1115
+ return true;
1116
+ };
1117
+ var minStickyLength = 16;
1118
+ var stickyCopies = /* @__PURE__ */ new WeakMap();
1119
+ var matchesRepeated = (pattern, data) => {
1120
+ if (data.length < minStickyLength)
1121
+ return pattern.test(data);
1122
+ let sticky = stickyCopies.get(pattern);
1123
+ if (!sticky) {
1124
+ sticky = new RegExp(pattern.source.slice(1, -1), `${pattern.flags}y`);
1125
+ stickyCopies.set(pattern, sticky);
1126
+ }
1127
+ sticky.lastIndex = 0;
1128
+ return sticky.test(data) && sticky.lastIndex === data.length;
1129
+ };
1130
+ var addErrors = (ctx, errors) => {
1131
+ if (errors === ctx._errors)
1132
+ return;
1133
+ const target = errorsOf(ctx);
1134
+ if (target._merge)
1135
+ target._merge(errors, ctx.path);
1136
+ else
1137
+ mergeIssues(target, errors, ctx.path);
1138
+ };
1139
+ var addMorphErrs = (ctx, errors, key) => {
1140
+ const { path, recv, recvAt } = ctx;
1141
+ for (const { reversedPath, result, data } of errors.entries) {
1142
+ ctx.path = [...path];
1143
+ if (key !== void 0)
1144
+ ctx.path.push(key);
1145
+ for (let i = reversedPath.length - 1; i >= 0; i--)
1146
+ ctx.path.push(reversedPath[i]);
1147
+ receive(ctx, data);
1148
+ addErrors(ctx, result);
1149
+ }
1150
+ ctx.path = path;
1151
+ ctx.recv = recv;
1152
+ ctx.recvAt = recvAt;
1153
+ };
1154
+ var transformResolution = (ctx, id, data, transform2, node) => {
1155
+ if (!ctx.isTree || !hasDomain(data, "object"))
1156
+ return transformed(ctx, transform2.call(node, data, ctx), data);
1157
+ const transformedByData = (ctx.tfdById ??= {})[id] ??= /* @__PURE__ */ new Map();
1158
+ if (transformedByData.has(data)) {
1159
+ const result2 = transformedByData.get(data);
1160
+ if (result2 !== transforming)
1161
+ return result2;
1162
+ const placeholder2 = isArray(data) ? [] : {};
1163
+ transformedByData.set(data, placeholder2);
1164
+ return placeholder2;
1165
+ }
1166
+ transformedByData.set(data, transforming);
1167
+ const result = transformed(ctx, transform2.call(node, data, ctx), data);
1168
+ const placeholder = transformedByData.get(data);
1169
+ if (placeholder === transforming || !canFill(placeholder, result)) {
1170
+ transformedByData.set(data, result);
1171
+ if (hasDomain(result, "object"))
1172
+ transformedByData.set(result, result);
1173
+ return result;
1174
+ }
1175
+ Object.defineProperties(placeholder, Object.getOwnPropertyDescriptors(result));
1176
+ transformedByData.set(placeholder, placeholder);
1177
+ return Object.setPrototypeOf(placeholder, Object.getPrototypeOf(result));
1178
+ };
1179
+ var Resolutions = class {
1180
+ seen = {};
1181
+ // untracked until data is deep or broad enough to be cyclic
1182
+ tracked = true;
1183
+ // reused by depth, so entering doesn't allocate
1184
+ frames = void 0;
1185
+ depth = 0;
1186
+ /** how many nodes were entered while untracked, bounded so a cycle can't run forever */
1187
+ visits = 0;
1188
+ /** whether a failure was recorded, so untracked lookups still find it */
1189
+ hasFailed = false;
1190
+ /** how many resolutions were entered, numbering each */
1191
+ nEntered = 0;
1192
+ assumedFrom = Number.POSITIVE_INFINITY;
1193
+ assumed = void 0;
1194
+ /** the first reported invalid resolution reached */
1195
+ invalid = void 0;
1196
+ };
1197
+ var resolutionsOf = (ctx) => ctx.res ??= new Resolutions();
1198
+ var enterResolution = (ctx, id, data) => {
1199
+ const res = resolutionsOf(ctx);
1200
+ const states = res.tracked || res.hasFailed ? res.seen[id] : void 0;
1201
+ const state = states?.get(data);
1202
+ if (state !== void 0) {
1203
+ if (typeof state === "number") {
1204
+ if (state < res.assumedFrom)
1205
+ res.assumedFrom = state;
1206
+ return true;
1207
+ }
1208
+ if (typeof state === "boolean")
1209
+ return state;
1210
+ if (ctx.currentBranch) {
1211
+ ctx.failBranch(state.error);
1212
+ return false;
1213
+ }
1214
+ if (state.reported) {
1215
+ res.invalid ??= state;
1216
+ return false;
1217
+ }
1218
+ }
1219
+ if (!res.tracked && (res.depth >= maxAliasDepth || ++res.visits > maxAliasVisits))
1220
+ throw untrackedBound;
1221
+ const frame = (res.frames ??= [])[res.depth++] ??= {
1222
+ id,
1223
+ data,
1224
+ entered: 0,
1225
+ errN: 0,
1226
+ outerInvalid: void 0,
1227
+ assumedOuter: 0,
1228
+ assumedLength: 0
1229
+ };
1230
+ frame.id = id;
1231
+ frame.data = data;
1232
+ frame.errN = ctx.errN;
1233
+ if (!res.tracked)
1234
+ return;
1235
+ (states ?? (res.seen[id] = /* @__PURE__ */ new Map())).set(data, ++res.nEntered);
1236
+ frame.entered = res.nEntered;
1237
+ frame.outerInvalid = res.invalid;
1238
+ res.invalid = void 0;
1239
+ frame.assumedOuter = res.assumedFrom;
1240
+ frame.assumedLength = (res.assumed ??= []).length;
1241
+ res.assumedFrom = Number.POSITIVE_INFINITY;
1242
+ return;
1243
+ };
1244
+ var exitResolution = (ctx, allowed) => {
1245
+ const res = ctx.res;
1246
+ const frame = res.frames[--res.depth];
1247
+ if (!res.tracked)
1248
+ return allowed ?? exitUntracked(ctx, frame);
1249
+ const invalid = res.invalid;
1250
+ res.invalid = frame.outerInvalid;
1251
+ const valid = allowed ?? (invalid === void 0 && ctx.errN === frame.errN);
1252
+ const data = frame.data;
1253
+ const states = res.seen[frame.id];
1254
+ if (typeof data === "object" ? data === null : typeof data !== "function") {
1255
+ res.assumedFrom = frame.assumedOuter;
1256
+ states.delete(data);
1257
+ return valid;
1258
+ }
1259
+ const state = valid || allowed === false ? valid : invalidResolution(ctx, invalid?.error);
1260
+ const assumedFrom = res.assumedFrom;
1261
+ res.assumedFrom = frame.assumedOuter;
1262
+ const assumed = res.assumed;
1263
+ if (valid && assumedFrom < frame.entered) {
1264
+ assumed.push(states, data);
1265
+ if (assumedFrom < res.assumedFrom)
1266
+ res.assumedFrom = assumedFrom;
1267
+ return true;
1268
+ }
1269
+ if (assumed.length !== frame.assumedLength) {
1270
+ for (let i = frame.assumedLength; i < assumed.length; i += 2) {
1271
+ const assumedStates = assumed[i];
1272
+ if (valid)
1273
+ assumedStates.set(assumed[i + 1], true);
1274
+ else
1275
+ assumedStates.delete(assumed[i + 1]);
1276
+ }
1277
+ assumed.length = frame.assumedLength;
1278
+ }
1279
+ states.set(data, state);
1280
+ if (typeof state === "object" && state.reported)
1281
+ res.invalid ??= state;
1282
+ return valid;
1283
+ };
1284
+ var exitUntracked = (ctx, frame) => {
1285
+ if (ctx.errN === frame.errN)
1286
+ return true;
1287
+ if (!hasDomain(frame.data, "object"))
1288
+ return false;
1289
+ const res = ctx.res;
1290
+ (res.seen[frame.id] ??= /* @__PURE__ */ new Map()).set(frame.data, invalidResolution(ctx));
1291
+ res.hasFailed = true;
1292
+ return false;
1293
+ };
1294
+ var invalidResolution = (ctx, error = ctx.currentBranch?.error ?? lastOf(ctx._errors._i ?? ctx._errors._)) => ({
1295
+ error,
1296
+ reported: !ctx.currentBranch
1297
+ });
1298
+ var traversalOf = (ctx, data) => new ctx.constructor(data, ctx.config);
1299
+ var lastOf = (array) => array[array.length - 1];
1300
+ var transforming = /* @__PURE__ */ noSuggest("transforming");
1301
+ var maxAliasDepth = 64;
1302
+ var maxAliasVisits = 1e3;
1303
+ var continuation;
1304
+ var continuationConfig;
1305
+ var aliasVisits = {
1306
+ count: 0,
1307
+ tracked: false,
1308
+ // data past the depth bound may be cyclic, so every path past it continues one tracked traversal
1309
+ exceed: (data) => {
1310
+ aliasVisits.count += maxAliasDepth;
1311
+ if (aliasVisits.count > maxAliasVisits) {
1312
+ aliasVisits.count = Number.POSITIVE_INFINITY;
1313
+ return false;
1314
+ }
1315
+ aliasVisits.tracked = true;
1316
+ return continuation ??= new InternalTraversal(data, continuationConfig);
1317
+ }
1318
+ };
1319
+ var untrackedBound = /* @__PURE__ */ noSuggest("untrackedBound");
1320
+ var applyCyclic = (node, data, ctx) => {
1321
+ if (node.tfs) {
1322
+ applyResolution(node.trackedId, node, data, ctx);
1323
+ return ctx;
1324
+ }
1325
+ resolutionsOf(ctx).tracked = false;
1326
+ try {
1327
+ node.tApply(data, ctx);
1328
+ } catch (e) {
1329
+ if (e !== untrackedBound)
1330
+ throw e;
1331
+ ctx = traversalOf(ctx, data);
1332
+ applyResolution(node.trackedId, node, data, ctx);
1333
+ }
1334
+ return ctx;
1335
+ };
1336
+ var applyResolution = (id, node, data, ctx) => {
1337
+ if (enterResolution(ctx, id, data) !== void 0)
1338
+ return;
1339
+ node.tApply(data, ctx);
1340
+ exitResolution(ctx);
1341
+ };
1342
+ var enterApplied = (ctx, id, data) => {
1343
+ const entered = enterResolution(ctx, id, data);
1344
+ return entered === void 0 ? void 0 : entered || !ctx.failFast;
1345
+ };
1346
+ var exitApplied = (ctx, continues) => {
1347
+ exitResolution(ctx);
1348
+ return continues;
1349
+ };
1350
+ var applyMember = (node, data, ctx, member = node) => member.hasAlias ? applyResolution(member.id, node, data, ctx) : node.tApply(data, ctx);
1351
+ var applyValue = (node, data, ctx, tfs = true) => {
1352
+ if (node.tfs && (tfs && (node.hasMorph || node.hasAlias) ? transformIfAllowed(ctx, node, data) : allowsInBranch(ctx, node, data)))
1353
+ return;
1354
+ if (node.entersAlias)
1355
+ applyResolution(node.id, node, data, ctx);
1356
+ else
1357
+ node.tApply(data, ctx);
1358
+ };
1359
+ var allowsUntracked = (node, data) => {
1360
+ if (inProgress.definitions || inProgress.resolutions || node.checksCtx)
1361
+ return;
1362
+ const outerVisits = aliasVisits.count;
1363
+ const outerContinuation = continuation;
1364
+ const outerConfig = continuationConfig;
1365
+ aliasVisits.count = 0;
1366
+ continuation = void 0;
1367
+ continuationConfig = node.$.cfg;
1368
+ let allowed;
1369
+ try {
1370
+ allowed = node.tAllows(data, 0);
1371
+ } catch (e) {
1372
+ aliasVisits.count = outerVisits;
1373
+ continuation = outerContinuation;
1374
+ continuationConfig = outerConfig;
1375
+ throw e;
1376
+ }
1377
+ const exceeded = aliasVisits.count > maxAliasVisits;
1378
+ aliasVisits.count = outerVisits;
1379
+ continuation = outerContinuation;
1380
+ continuationConfig = outerConfig;
1381
+ return exceeded ? void 0 : allowed;
1382
+ };
1383
+ var allowsAcyclic = (node, data) => {
1384
+ if (inProgress.definitions || inProgress.resolutions || node.checksCtx)
1385
+ return;
1386
+ const outerTracked = aliasVisits.tracked;
1387
+ const outerVisits = aliasVisits.count;
1388
+ const outerContinuation = continuation;
1389
+ const outerConfig = continuationConfig;
1390
+ aliasVisits.tracked = false;
1391
+ aliasVisits.count = 0;
1392
+ continuation = void 0;
1393
+ continuationConfig = node.$.cfg;
1394
+ try {
1395
+ const allowed = node.tAllows(data, 0);
1396
+ return aliasVisits.count > maxAliasVisits || aliasVisits.tracked ? void 0 : allowed;
1397
+ } finally {
1398
+ aliasVisits.tracked ||= outerTracked;
1399
+ aliasVisits.count = outerVisits;
1400
+ continuation = outerContinuation;
1401
+ continuationConfig = outerConfig;
1402
+ }
1403
+ };
1404
+ var allowsInContext = (node, data, config, ctor = Traversal) => allowsInTraversal(node, data, new ctor(data, config));
1405
+ var allowsInTraversal = (node, data, ctx) => node.tAllows(data, ctx) && !ctx.hasError();
1406
+ var canFill = (placeholder, result) => typeof result === "object" && result !== null && (isArray(placeholder) ? isArray(result) : objectKindOf(result) === void 0);
1407
+ var travKey = (key, fn, ctx) => {
1408
+ if (!ctx || typeof ctx === "number")
1409
+ return fn();
1410
+ ctx.path.push(key);
1411
+ const result = fn();
1412
+ ctx.path.pop();
1413
+ return result;
1414
+ };
1415
+ var computeDefaultValueMorph = (key, value, defaultInput, node = value, isThunkInput = isThunk(defaultInput)) => {
1416
+ const thunk = isThunkInput ? defaultInput : void 0;
1417
+ const write = (data, v) => {
1418
+ setOwnValue(data, key, v);
1419
+ return data;
1420
+ };
1421
+ if (!thunk && !node.alters && !node.hasAlias)
1422
+ return (data) => write(data, defaultInput);
1423
+ if (!node.allowsCtx && !node.ctxMorph) {
1424
+ return (data) => {
1425
+ const input = thunk ? thunk() : defaultInput;
1426
+ const output = value.traverse(input);
1427
+ if (output instanceof Issues)
1428
+ return new TransformErrors(output, input).addTo(void 0, key);
1429
+ return write(data, output);
1430
+ };
1431
+ }
1432
+ let transformingDefault = false;
1433
+ return (data, ctx) => {
1434
+ if (transformingDefault)
1435
+ return data;
1436
+ if (!thunk && !node.tfs)
1437
+ return write(data, defaultInput);
1438
+ transformingDefault = true;
1439
+ try {
1440
+ write(data, travKey(key, () => value(thunk ? thunk() : defaultInput, ctx), ctx));
1441
+ } finally {
1442
+ transformingDefault = false;
1443
+ }
1444
+ return data;
1445
+ };
1446
+ };
1447
+
1448
+ export {
1449
+ describeActual,
1450
+ describeUnwrittenActual,
1451
+ printedActualOf,
1452
+ writeMessage,
1453
+ writeLine,
1454
+ writeUnitMessage,
1455
+ writeUnitActual,
1456
+ writeNotEqualActual,
1457
+ writeDomainActual,
1458
+ writeLengthActual,
1459
+ writeProtoActual,
1460
+ enInfo,
1461
+ failsKey,
1462
+ failsSite,
1463
+ failsKeySite,
1464
+ missingTextOf,
1465
+ Issues,
1466
+ FirstIssues,
1467
+ applyIssues,
1468
+ issuesOf,
1469
+ foundErrors,
1470
+ issueAt,
1471
+ throwOnDefault,
1472
+ mergeIssues,
1473
+ isCustomIssue,
1474
+ codedIssue,
1475
+ notedAs,
1476
+ movedIssue,
1477
+ pathOf,
1478
+ lineOf,
1479
+ messageOf,
1480
+ ThrownIssues,
1481
+ throwIssues,
1482
+ writeListed,
1483
+ sharedMessageOf,
1484
+ writeFromPath,
1485
+ listedIssue,
1486
+ alikeIssue,
1487
+ TransformErrors,
1488
+ holdsOnlyIndices,
1489
+ copyOf,
1490
+ setOwnValue,
1491
+ keepOwn,
1492
+ copyDeclared,
1493
+ mergeTransformed,
1494
+ makeRootAndArrayPropertiesMutable,
1495
+ hasArkKind,
1496
+ isNode,
1497
+ inProgress,
1498
+ isResolutionFinal,
1499
+ isIoFinal,
1500
+ queueUnchecked,
1501
+ assertUnchecked,
1502
+ resolving,
1503
+ defining,
1504
+ composing,
1505
+ holeNameMarker,
1506
+ withoutHoleNames,
1507
+ elided,
1508
+ printSelfAsThis,
1509
+ valueAtPath,
1510
+ isAbsent,
1511
+ removedProblemMessage,
1512
+ describeBranches,
1513
+ expressBranches,
1514
+ describeCases,
1515
+ InternalTraversal,
1516
+ Traversal,
1517
+ FirstIssueTraversal,
1518
+ throwOnProblem,
1519
+ errorsOf,
1520
+ applyRejected,
1521
+ describePredicate,
1522
+ tryMorph,
1523
+ execMorph,
1524
+ callMorph,
1525
+ transform,
1526
+ transformed,
1527
+ pipeOf,
1528
+ pipeChecked,
1529
+ pipeApplied,
1530
+ pipeTransformed,
1531
+ pipe,
1532
+ transformsValid,
1533
+ transformedInApply,
1534
+ transformIfAllowed,
1535
+ allowsInBranch,
1536
+ silentCtx,
1537
+ inContext,
1538
+ readingContextWith,
1539
+ withContextOf,
1540
+ allowsInBranchBy,
1541
+ disallowed,
1542
+ rejected,
1543
+ rejects,
1544
+ matchesRepeated,
1545
+ addErrors,
1546
+ addMorphErrs,
1547
+ transformResolution,
1548
+ enterResolution,
1549
+ exitResolution,
1550
+ maxAliasDepth,
1551
+ maxAliasVisits,
1552
+ aliasVisits,
1553
+ applyCyclic,
1554
+ applyResolution,
1555
+ enterApplied,
1556
+ exitApplied,
1557
+ applyMember,
1558
+ applyValue,
1559
+ allowsUntracked,
1560
+ allowsAcyclic,
1561
+ allowsInContext,
1562
+ travKey,
1563
+ computeDefaultValueMorph
1564
+ };