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,965 @@
1
+ // ../util/out/arrays.js
2
+ var getDuplicatesOf = (arr, opts) => {
3
+ const isEqual = opts?.isEqual ?? ((l, r) => l === r);
4
+ const elementFirstSeenIndx = /* @__PURE__ */ new Map();
5
+ const duplicates = [];
6
+ for (const [indx, element] of arr.entries()) {
7
+ const duplicatesIndx = duplicates.findIndex((duplicate) => isEqual(duplicate.element, element));
8
+ if (duplicatesIndx !== -1) {
9
+ duplicates[duplicatesIndx].indices.push(indx);
10
+ continue;
11
+ }
12
+ let found = false;
13
+ for (const [existingElement, firstSeenIndx] of elementFirstSeenIndx) {
14
+ if (isEqual(element, existingElement)) {
15
+ found = true;
16
+ duplicates.push({
17
+ element: existingElement,
18
+ indices: [firstSeenIndx, indx]
19
+ });
20
+ }
21
+ }
22
+ if (!found) {
23
+ elementFirstSeenIndx.set(element, indx);
24
+ }
25
+ }
26
+ return duplicates;
27
+ };
28
+ var join = (segments, delimiter) => segments.join(delimiter);
29
+ var getPath = (root, path) => {
30
+ let result = root;
31
+ for (const segment of path) {
32
+ if (typeof result !== "object" || result === null)
33
+ return void 0;
34
+ result = result[segment];
35
+ }
36
+ return result;
37
+ };
38
+ var intersectUniqueLists = (l, r) => {
39
+ const intersection = [...l];
40
+ for (const item of r)
41
+ if (!l.includes(item))
42
+ intersection.push(item);
43
+ return intersection;
44
+ };
45
+ var liftArray = (data) => Array.isArray(data) ? data : [data];
46
+ var spliterate = (arr, predicate) => {
47
+ const result = [[], []];
48
+ for (const item of arr) {
49
+ if (predicate(item))
50
+ result[0].push(item);
51
+ else
52
+ result[1].push(item);
53
+ }
54
+ return result;
55
+ };
56
+ var includes = (array, element) => array.includes(element);
57
+ var range = (length, offset = 0) => [...new Array(length)].map((_, i) => i + offset);
58
+ var append = (to, value, opts) => {
59
+ if (to === void 0) {
60
+ return value === void 0 ? [] : Array.isArray(value) ? value : [value];
61
+ }
62
+ if (opts?.prepend) {
63
+ if (Array.isArray(value))
64
+ to.unshift(...value);
65
+ else
66
+ to.unshift(value);
67
+ } else {
68
+ if (Array.isArray(value))
69
+ to.push(...value);
70
+ else
71
+ to.push(value);
72
+ }
73
+ return to;
74
+ };
75
+ var conflatenate = (to, elementOrList) => {
76
+ if (elementOrList === void 0 || elementOrList === null)
77
+ return to ?? [];
78
+ if (to === void 0 || to === null)
79
+ return liftArray(elementOrList);
80
+ return to.concat(elementOrList);
81
+ };
82
+ var conflatenateAll = (...elementsOrLists) => elementsOrLists.reduce(conflatenate, []);
83
+ var appendUnique = (to, value, opts) => {
84
+ if (to === void 0)
85
+ return Array.isArray(value) ? value : [value];
86
+ const isEqual = opts?.isEqual ?? ((l, r) => l === r);
87
+ for (const v of liftArray(value))
88
+ if (!to.some((existing) => isEqual(existing, v)))
89
+ to.push(v);
90
+ return to;
91
+ };
92
+ var groupBy = (array, discriminant) => array.reduce((result, item) => {
93
+ const key = item[discriminant];
94
+ result[key] = append(result[key], item);
95
+ return result;
96
+ }, {});
97
+ var arrayEquals = (l, r, opts) => l.length === r.length && l.every(opts?.isEqual ? (lItem, i) => opts.isEqual(lItem, r[i]) : (lItem, i) => lItem === r[i]);
98
+
99
+ // ../util/out/domain.js
100
+ var hasDomain = (data, kind) => domainOf(data) === kind;
101
+ var domainOf = (data) => {
102
+ const builtinType = typeof data;
103
+ return builtinType === "object" ? data === null ? "null" : "object" : builtinType === "function" ? "object" : builtinType;
104
+ };
105
+ var domainDescriptions = {
106
+ boolean: "boolean",
107
+ null: "null",
108
+ undefined: "undefined",
109
+ bigint: "a bigint",
110
+ number: "a number",
111
+ object: "an object",
112
+ string: "a string",
113
+ symbol: "a symbol"
114
+ };
115
+ var jsTypeOfDescriptions = /* @__PURE__ */ Object.assign({}, domainDescriptions, { function: "a function" });
116
+
117
+ // ../util/out/errors.js
118
+ var InternalArktypeError = class extends Error {
119
+ };
120
+ var throwInternalError = (message) => throwError(message, InternalArktypeError);
121
+ var throwError = (message, ctor = Error) => {
122
+ throw new ctor(message);
123
+ };
124
+ var ParseError = class extends Error {
125
+ name = "ParseError";
126
+ };
127
+ var throwParseError = (message) => throwError(message, ParseError);
128
+ var noSuggest = ((s) => ` ${s}`);
129
+ var ZeroWidthSpace = "​";
130
+
131
+ // ../util/out/facts.js
132
+ var arkKind = " arkKind";
133
+ var arkKindOf = (value) => value?.[arkKind];
134
+ var isStandardSchema = (o) => "~standard" in o;
135
+ var isDate = (value) => value instanceof Date;
136
+ var isInstanceOf = (o, ctor) => o instanceof ctor;
137
+ var prototypeOf = (o) => Object.getPrototypeOf(o);
138
+ var arityOf = (fn) => {
139
+ const proto = Object.getPrototypeOf(fn);
140
+ return proto && Object.prototype.hasOwnProperty.call(proto, "traverse") ? 2 : fn.length;
141
+ };
142
+ var readsOnlyData = /* @__PURE__ */ new WeakSet();
143
+ var returnsReports = /* @__PURE__ */ new WeakSet();
144
+ var testsOrRejects = /* @__PURE__ */ new WeakSet();
145
+ var functionNameOf = (fn) => fn.name;
146
+ var constructorNameOf = (o) => o.constructor?.name;
147
+ var expressionOf = (o) => "expression" in o && typeof o.expression === "string" ? o.expression : void 0;
148
+ var toJsonMethodOf = (o) => {
149
+ const toJson = o.toJSON;
150
+ return typeof toJson === "function" ? toJson : void 0;
151
+ };
152
+ var constructorExtends = (ctor, base) => {
153
+ let current = ctor.prototype;
154
+ while (current !== null) {
155
+ if (current === base.prototype)
156
+ return true;
157
+ current = Object.getPrototypeOf(current);
158
+ }
159
+ return false;
160
+ };
161
+ var ownEntriesOf = (o, opts) => {
162
+ const result = [];
163
+ for (const k of Reflect.ownKeys(o)) {
164
+ const descriptor = Object.getOwnPropertyDescriptor(o, k);
165
+ if (!descriptor.enumerable)
166
+ continue;
167
+ result.push([
168
+ k,
169
+ "value" in descriptor ? descriptor.value : opts.onAccessor ? opts.onAccessor(descriptor) : o[k]
170
+ ]);
171
+ }
172
+ return result;
173
+ };
174
+
175
+ // ../util/out/numbers.js
176
+ var nonFiniteNumbers = {
177
+ NaN: NaN,
178
+ Infinity: Infinity,
179
+ "-Infinity": -Infinity
180
+ };
181
+ var wellFormedNumberMatcher = (
182
+ // sources are public (keywords, JSON Schema), so keep their groups
183
+ // eslint-disable-next-line unicorn/better-regex
184
+ /^(?:(?!^-0\.?0*$)(?:-?(?:(?:0|[1-9]\d*)(?:\.\d*[1-9])?)))$/
185
+ );
186
+ var isWellFormedNumber = (s) => wellFormedNumberMatcher.test(s);
187
+ var numericStringMatcher = (
188
+ // "-0" is excluded by requiring a nonzero digit after "-", not a lookahead,
189
+ // since it's a JSON Schema pattern, which RE2 (e.g. LLM structured outputs)
190
+ // can't read with one
191
+ /^(?:(?:0|[1-9]\d*)(?:\.\d+)?|\.\d+|-(?:[1-9]\d*(?:\.\d+)?|0?\.\d*[1-9]\d*))(?:[Ee][+-]?\d+)?$/
192
+ );
193
+ var isDigitCode = (code) => code >= 48 && code <= 57;
194
+ var isNumericString = (s) => {
195
+ let i = 0;
196
+ let code = s.charCodeAt(0);
197
+ const isNegative = code === 45;
198
+ if (isNegative)
199
+ code = s.charCodeAt(++i);
200
+ let isZero = true;
201
+ if (code === 48)
202
+ code = s.charCodeAt(++i);
203
+ else if (code > 48 && code <= 57) {
204
+ isZero = false;
205
+ do
206
+ code = s.charCodeAt(++i);
207
+ while (isDigitCode(code));
208
+ } else if (code !== 46)
209
+ return false;
210
+ if (code === 46) {
211
+ code = s.charCodeAt(++i);
212
+ if (!isDigitCode(code))
213
+ return false;
214
+ do {
215
+ if (code !== 48)
216
+ isZero = false;
217
+ code = s.charCodeAt(++i);
218
+ } while (isDigitCode(code));
219
+ }
220
+ if (code === 69 || code === 101) {
221
+ code = s.charCodeAt(++i);
222
+ if (code === 43 || code === 45)
223
+ code = s.charCodeAt(++i);
224
+ if (!isDigitCode(code))
225
+ return false;
226
+ do
227
+ code = s.charCodeAt(++i);
228
+ while (isDigitCode(code));
229
+ }
230
+ return i === s.length && !(isNegative && isZero);
231
+ };
232
+ var numberLikeMatcher = /^-?\d*\.?\d*$/;
233
+ var isNumberLike = (s) => s.length !== 0 && numberLikeMatcher.test(s);
234
+ var wellFormedIntegerMatcher = (
235
+ // "-0" is excluded without a lookahead, as numericStringMatcher's is
236
+ /^(?:0|-?[1-9]\d*)$/
237
+ );
238
+ var isWellFormedInteger = (s) => {
239
+ const length = s.length;
240
+ let i = s.charCodeAt(0) === 45 ? 1 : 0;
241
+ const code = s.charCodeAt(i);
242
+ if (code === 48)
243
+ return length === 1;
244
+ if (!(code > 48 && code <= 57))
245
+ return false;
246
+ while (++i < length)
247
+ if (!isDigitCode(s.charCodeAt(i)))
248
+ return false;
249
+ return true;
250
+ };
251
+ var integerLikeMatcher = /^-?\d+$/;
252
+ var isIntegerLike = (s) => integerLikeMatcher.test(s);
253
+ var numericLiteralDescriptions = {
254
+ number: "a number",
255
+ bigint: "a bigint",
256
+ integer: "an integer"
257
+ };
258
+ var writeMalformedNumericLiteralMessage = (def, kind) => `'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`;
259
+ var isWellFormed = (def, kind) => kind === "number" ? isWellFormedNumber(def) : isWellFormedInteger(def);
260
+ var parseKind = (def, kind) => kind === "number" ? Number(def) : Number.parseInt(def);
261
+ var isKindLike = (def, kind) => kind === "number" ? isNumberLike(def) : isIntegerLike(def);
262
+ var tryParseNumber = (token, options) => parseNumeric(token, "number", options);
263
+ var tryParseWellFormedNumber = (token, options) => parseNumeric(token, "number", { ...options, strict: true });
264
+ var tryParseInteger = (token, options) => parseNumeric(token, "integer", options);
265
+ var parseNumeric = (token, kind, options) => {
266
+ const value = parseKind(token, kind);
267
+ if (!Number.isNaN(value)) {
268
+ if (isKindLike(token, kind)) {
269
+ if (options?.strict) {
270
+ return isWellFormed(token, kind) ? value : throwParseError(writeMalformedNumericLiteralMessage(token, kind));
271
+ }
272
+ return value;
273
+ }
274
+ }
275
+ return options?.errorOnFail ? throwParseError(options?.errorOnFail === true ? `Failed to parse ${numericLiteralDescriptions[kind]} from '${token}'` : options?.errorOnFail) : void 0;
276
+ };
277
+ var tryParseWellFormedBigint = (def) => {
278
+ if (def[def.length - 1] !== "n")
279
+ return;
280
+ const maybeIntegerLiteral = def.slice(0, -1);
281
+ let value;
282
+ try {
283
+ value = BigInt(maybeIntegerLiteral);
284
+ } catch {
285
+ return;
286
+ }
287
+ if (wellFormedIntegerMatcher.test(maybeIntegerLiteral))
288
+ return value;
289
+ if (integerLikeMatcher.test(maybeIntegerLiteral)) {
290
+ return throwParseError(writeMalformedNumericLiteralMessage(def, "bigint"));
291
+ }
292
+ };
293
+ var nearestFloat = (n, direction = "+") => {
294
+ const buffer = new ArrayBuffer(8);
295
+ const f64 = new Float64Array(buffer);
296
+ const u32 = new Uint32Array(buffer);
297
+ f64[0] = n;
298
+ if (n === 0) {
299
+ u32[0] = 1;
300
+ u32[1] = direction === "-" ? 1 << 31 : 0;
301
+ } else if (n > 0 && direction === "+" || n < 0 && direction === "-") {
302
+ if (u32[0]++ === 4294967295)
303
+ u32[1]++;
304
+ } else if (u32[0]-- === 0)
305
+ u32[1]--;
306
+ return f64[0];
307
+ };
308
+ var printDecimal = (n) => {
309
+ const [mantissa, exponent] = `${n}`.split("e");
310
+ if (exponent === void 0)
311
+ return mantissa;
312
+ const sign = mantissa[0] === "-" ? "-" : "";
313
+ const [whole, fraction = ""] = mantissa.slice(sign.length).split(".");
314
+ const digits = whole + fraction;
315
+ const point = whole.length + Number(exponent);
316
+ return sign + (point <= 0 ? `0.${"0".repeat(-point)}${digits}` : point >= digits.length ? digits + "0".repeat(point - digits.length) : `${digits.slice(0, point)}.${digits.slice(point)}`);
317
+ };
318
+
319
+ // ../util/out/flatMorph.js
320
+ var flatMorph = (o, flatMapEntry) => {
321
+ const result = {};
322
+ const inputIsArray = Array.isArray(o);
323
+ let outputShouldBeArray = false;
324
+ const entries = Object.entries(o);
325
+ for (let i = 0; i < entries.length; i++) {
326
+ const entry = entries[i];
327
+ const mapped = inputIsArray ? flatMapEntry(i, entry[1]) : flatMapEntry(entry[0], entry[1], i);
328
+ outputShouldBeArray ||= typeof mapped[0] === "number";
329
+ const flattenedEntries = Array.isArray(mapped[0]) || mapped.length === 0 ? (
330
+ // if we have an empty array (for filtering) or an array with
331
+ // another array as its first element, treat it as a list
332
+ mapped
333
+ ) : [mapped];
334
+ for (let j = 0; j < flattenedEntries.length; j++) {
335
+ const k = flattenedEntries[j][0];
336
+ const v = flattenedEntries[j][1];
337
+ if (typeof k === "object")
338
+ result[k.group] = append(result[k.group], v);
339
+ else
340
+ result[k] = v;
341
+ }
342
+ }
343
+ return outputShouldBeArray ? Object.values(result) : result;
344
+ };
345
+
346
+ // ../util/out/records.js
347
+ var entriesOf = /* @__PURE__ */ (() => Object.entries)();
348
+ var fromEntries = (entries) => Object.fromEntries(entries);
349
+ var keysOf = (o) => Object.keys(o);
350
+ var isKeyOf = (k, o) => k in o;
351
+ var hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
352
+ var hasKey = (o, k) => k in o;
353
+ var hasDefinedKey = (o, k) => o[k] !== void 0;
354
+ var InnerDynamicBase = class {
355
+ };
356
+ var DynamicBase = class {
357
+ constructor(properties) {
358
+ Object.assign(this, properties);
359
+ }
360
+ };
361
+ var NoopBase = class {
362
+ };
363
+ var CastableBase = class extends NoopBase {
364
+ };
365
+ var splitByKeys = (o, leftKeys) => {
366
+ const l = {};
367
+ const r = {};
368
+ let k;
369
+ for (k in o)
370
+ if (hasOwn(o, k))
371
+ defineValue(hasOwn(leftKeys, k) ? l : r, k, o[k]);
372
+ return [l, r];
373
+ };
374
+ var pick = (o, keys) => splitByKeys(o, keys)[0];
375
+ var omit = (o, keys) => splitByKeys(o, keys)[1];
376
+ var isEmptyObject = (o) => {
377
+ for (const k in o)
378
+ if (hasOwn(o, k))
379
+ return false;
380
+ return true;
381
+ };
382
+ var stringAndSymbolicEntriesOf = (o) => [
383
+ ...Object.entries(o),
384
+ ...Object.getOwnPropertySymbols(o).map((k) => [k, o[k]])
385
+ ];
386
+ var defineProperties = ((base, merged) => (
387
+ // declared like this to avoid https://github.com/microsoft/TypeScript/issues/55049
388
+ Object.defineProperties(base, Object.getOwnPropertyDescriptors(merged))
389
+ ));
390
+ var defineValue = (o, k, value) => Object.defineProperty(o, k, {
391
+ value,
392
+ writable: true,
393
+ enumerable: true,
394
+ configurable: true
395
+ });
396
+ var withAlphabetizedKeys = (o) => {
397
+ const keys = Object.keys(o).sort();
398
+ const result = {};
399
+ for (let i = 0; i < keys.length; i++)
400
+ defineValue(result, keys[i], o[keys[i]]);
401
+ return result;
402
+ };
403
+ var invert = (t) => flatMorph(t, (k, v) => [v, k]);
404
+ var unset = /* @__PURE__ */ noSuggest("unset​");
405
+ var enumValues = (tsEnum) => Object.values(tsEnum).filter((v) => {
406
+ if (typeof v === "number")
407
+ return true;
408
+ return typeof tsEnum[v] !== "number";
409
+ });
410
+
411
+ // ../util/out/objectKinds.js
412
+ var ecmascriptConstructorsOf = () => ({
413
+ Array,
414
+ Boolean,
415
+ Date,
416
+ Error,
417
+ Function,
418
+ Map,
419
+ Number,
420
+ Promise,
421
+ RegExp,
422
+ Set,
423
+ String,
424
+ WeakMap,
425
+ WeakSet
426
+ });
427
+ var ecmascriptConstructors = /* @__PURE__ */ ecmascriptConstructorsOf();
428
+ var FileConstructor = /* @__PURE__ */ (() => globalThis.File ?? globalThis.Blob)();
429
+ var platformConstructorsOf = () => ({
430
+ ArrayBuffer,
431
+ Blob: globalThis.Blob,
432
+ // Node loads a module for File, and undici for the rest, on first read
433
+ get File() {
434
+ return globalThis.File ?? globalThis.Blob;
435
+ },
436
+ get FormData() {
437
+ return globalThis.FormData;
438
+ },
439
+ get Headers() {
440
+ return globalThis.Headers;
441
+ },
442
+ get Request() {
443
+ return globalThis.Request;
444
+ },
445
+ get Response() {
446
+ return globalThis.Response;
447
+ },
448
+ URL: globalThis.URL
449
+ });
450
+ var platformConstructors = /* @__PURE__ */ platformConstructorsOf();
451
+ var typedArrayConstructorsOf = () => ({
452
+ Int8Array,
453
+ Uint8Array,
454
+ Uint8ClampedArray,
455
+ Int16Array,
456
+ Uint16Array,
457
+ Int32Array,
458
+ Uint32Array,
459
+ Float32Array,
460
+ Float64Array,
461
+ BigInt64Array,
462
+ BigUint64Array
463
+ });
464
+ var typedArrayConstructors = /* @__PURE__ */ typedArrayConstructorsOf();
465
+ var builtins;
466
+ var builtinsOf = () => builtins ??= defineProperties(defineProperties(Object.assign({}, ecmascriptConstructorsOf()), platformConstructorsOf()), typedArrayConstructorsOf());
467
+ var builtinConstructors = /* @__PURE__ */ builtinsOf();
468
+ var objectKindOf = (data) => {
469
+ if (Array.isArray(data))
470
+ return "Array";
471
+ let prototype = prototypeOf(data);
472
+ if (prototype === Object.prototype)
473
+ return void 0;
474
+ const constructors = builtinsOf();
475
+ while (prototype?.constructor && (!hasOwn(constructors, prototype.constructor.name) || constructors[prototype.constructor.name]?.prototype !== prototype))
476
+ prototype = Object.getPrototypeOf(prototype);
477
+ const name = prototype?.constructor?.name;
478
+ if (name === void 0 || name === "Object")
479
+ return void 0;
480
+ return name;
481
+ };
482
+ var objectKindOrDomainOf = (data) => typeof data === "object" && data !== null ? objectKindOf(data) ?? "object" : domainOf(data);
483
+ var hasObjectKind = (data, kind) => objectKindOf(data) === kind;
484
+ var isArray = /* @__PURE__ */ (() => Array.isArray)();
485
+ var dateGetTime = /* @__PURE__ */ (() => Date.prototype.getTime)();
486
+ var timeOf = (date) => {
487
+ try {
488
+ return date.getTime === dateGetTime ? date.getTime() : dateGetTime.call(date);
489
+ } catch {
490
+ return void 0;
491
+ }
492
+ };
493
+ var isValidDate = (date) => {
494
+ try {
495
+ return !Number.isNaN(date.getTime === dateGetTime ? date.getTime() : dateGetTime.call(date));
496
+ } catch {
497
+ return false;
498
+ }
499
+ };
500
+ var isDateObject = (value) => prototypeOf(value) === Date.prototype;
501
+ var isRegExpObject = (value) => prototypeOf(value) === RegExp.prototype;
502
+ var writeInvalidDateMessage = (source) => `Date literal '${source}' must be an ISO date like 2025-01-01, an ISO date-time with Z or an offset like 2025-01-01T12:00Z, or epoch milliseconds`;
503
+ var tryParseDate = (source, errorOnFail) => {
504
+ const isoParts = isoInstantMatcher.exec(source);
505
+ if (isoParts) {
506
+ const [, year, month = "01", day = "01"] = isoParts;
507
+ const stringParsedDate = new Date(source);
508
+ if (isValidDate(stringParsedDate) && isDayOfMonth(+year, +month, +day))
509
+ return stringParsedDate;
510
+ } else {
511
+ const epochMillis = tryParseNumber(source);
512
+ if (epochMillis !== void 0) {
513
+ const numberParsedDate = new Date(epochMillis);
514
+ if (isValidDate(numberParsedDate))
515
+ return numberParsedDate;
516
+ }
517
+ }
518
+ return errorOnFail ? throwParseError(errorOnFail === true ? writeInvalidDateMessage(source) : errorOnFail) : void 0;
519
+ };
520
+ var isoInstantMatcher = /^((?!-0{6})[+-]\d{6}|\d{4})(?:-(0[1-9]|1[0-2])(?:-(0[1-9]|[12]\d|3[01]))?)?(?:T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{3})?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d))?$/;
521
+ var isDayOfMonth = (year, month, day) => {
522
+ const date = /* @__PURE__ */ new Date(0);
523
+ date.setUTCFullYear(year, month - 1, day);
524
+ return date.getUTCDate() === day;
525
+ };
526
+ var ecmascriptDescriptions = {
527
+ Array: "an array",
528
+ Function: "a function",
529
+ Date: "a Date",
530
+ RegExp: "a RegExp",
531
+ Error: "an Error",
532
+ Map: "a Map",
533
+ Set: "a Set",
534
+ String: "a String object",
535
+ Number: "a Number object",
536
+ Boolean: "a Boolean object",
537
+ Promise: "a Promise",
538
+ WeakMap: "a WeakMap",
539
+ WeakSet: "a WeakSet"
540
+ };
541
+ var platformDescriptions = {
542
+ ArrayBuffer: "an ArrayBuffer instance",
543
+ Blob: "a Blob instance",
544
+ File: "a File instance",
545
+ FormData: "a FormData instance",
546
+ Headers: "a Headers instance",
547
+ Request: "a Request instance",
548
+ Response: "a Response instance",
549
+ URL: "a URL instance"
550
+ };
551
+ var typedArrayDescriptions = {
552
+ Int8Array: "an Int8Array",
553
+ Uint8Array: "a Uint8Array",
554
+ Uint8ClampedArray: "a Uint8ClampedArray",
555
+ Int16Array: "an Int16Array",
556
+ Uint16Array: "a Uint16Array",
557
+ Int32Array: "an Int32Array",
558
+ Uint32Array: "a Uint32Array",
559
+ Float32Array: "a Float32Array",
560
+ Float64Array: "a Float64Array",
561
+ BigInt64Array: "a BigInt64Array",
562
+ BigUint64Array: "a BigUint64Array"
563
+ };
564
+ var objectKindDescriptions = /* @__PURE__ */ Object.assign({}, ecmascriptDescriptions, platformDescriptions, typedArrayDescriptions);
565
+ var getBuiltinNameOfConstructor = (ctor) => {
566
+ const constructorName = functionNameOf(Object(ctor)) ?? null;
567
+ return constructorName && hasOwn(builtinConstructors, constructorName) && builtinConstructors[constructorName] === ctor ? constructorName : null;
568
+ };
569
+ var ancestorsOf = (o) => {
570
+ let proto = Object.getPrototypeOf(o);
571
+ const result = [];
572
+ while (proto !== null) {
573
+ result.push(proto.constructor);
574
+ proto = Object.getPrototypeOf(proto);
575
+ }
576
+ return result;
577
+ };
578
+ var isPlainObjectOrArray = (o) => {
579
+ const proto = Object.getPrototypeOf(o);
580
+ return proto === Object.prototype || proto === null || Array.isArray(o);
581
+ };
582
+
583
+ // ../util/out/functions.js
584
+ var cached = (thunk) => {
585
+ let result = unset;
586
+ return () => result === unset ? result = thunk() : result;
587
+ };
588
+ var isThunk = (value) => typeof value === "function" && arityOf(value) === 0;
589
+ var tryCatch = (fn, onError) => {
590
+ try {
591
+ return fn();
592
+ } catch (e) {
593
+ return onError?.(e);
594
+ }
595
+ };
596
+ var DynamicFunction = class extends Function {
597
+ constructor(...args) {
598
+ const params = args.slice(0, -1);
599
+ const body = args[args.length - 1];
600
+ try {
601
+ super(...params, body);
602
+ } catch (e) {
603
+ if (e instanceof EvalError)
604
+ throw e;
605
+ return throwInternalError(`Encountered an unexpected error while compiling your definition:
606
+ Message: ${e}
607
+ Source: (${args.slice(0, -1)}) => {
608
+ ${args[args.length - 1]}
609
+ }`);
610
+ }
611
+ }
612
+ };
613
+ var Callable = class {
614
+ constructor(fn, ...args) {
615
+ const opts = args[0];
616
+ const callable = Object.setPrototypeOf(opts?.bind === null ? fn : fn.bind(opts?.bind ?? this), new.target.prototype);
617
+ return opts?.attach ? Object.assign(callable, opts.attach) : callable;
618
+ }
619
+ };
620
+ var envHasCsp = /* @__PURE__ */ cached(() => {
621
+ try {
622
+ return new Function("return false")();
623
+ } catch {
624
+ return true;
625
+ }
626
+ });
627
+
628
+ // ../util/out/primitive.js
629
+ var lastString;
630
+ var lastSerialized;
631
+ var serializePrimitive = (value) => typeof value === "string" ? value === lastString ? lastSerialized : lastSerialized = JSON.stringify(lastString = value) : typeof value === "bigint" ? `${value}n` : `${value}`;
632
+
633
+ // ../util/out/serialize.js
634
+ var snapshot = (data, opts = {}) => _serialize(data, {
635
+ onUndefined: `$ark.undefined`,
636
+ onBigInt: (n) => `$ark.bigint-${n}`,
637
+ ...opts
638
+ }, []);
639
+ var print = (data, opts) => console.log(printable(data, opts));
640
+ var printable = (data, opts) => {
641
+ switch (domainOf(data)) {
642
+ case "object":
643
+ const o = data;
644
+ const ctorName = constructorNameOf(o) ?? "Object";
645
+ const serializationOpts = opts?.ownDataOnly ? ownDataPrintableOpts : printableOpts;
646
+ return ctorName === "Object" || ctorName === "Array" ? opts?.quoteKeys === false ? stringifyUnquoted(o, opts?.indent ?? 0, "", serializationOpts) : JSON.stringify(_serialize(o, serializationOpts, []), null, opts?.indent).replace(quotedMarkedValue, "$1") : stringifyUnquoted(o, opts?.indent ?? 0, "", serializationOpts);
647
+ case "symbol":
648
+ return printableOpts.onSymbol(data);
649
+ default:
650
+ return serializePrimitive(data);
651
+ }
652
+ };
653
+ var printKind = (data) => typeof data === "function" ? "a function" : typeof data === "symbol" ? printSymbol(data) : typeof data !== "object" || data === null ? serializePrimitive(data) : isArray(data) ? "an array" : "an object";
654
+ var stringifyUnquoted = (value, indent, currentIndent, opts) => {
655
+ if (typeof value === "function")
656
+ return printableOpts.onFunction(value);
657
+ if (typeof value === "symbol")
658
+ return printableOpts.onSymbol(value);
659
+ if (typeof value !== "object" || value === null)
660
+ return serializePrimitive(value);
661
+ const nextIndent = currentIndent + " ".repeat(indent);
662
+ if (isArray(value)) {
663
+ if (value.length === 0)
664
+ return "[]";
665
+ const items = value.map((item) => stringifyUnquoted(item, indent, nextIndent, opts)).join(",\n" + nextIndent);
666
+ return indent ? `[
667
+ ${nextIndent}${items}
668
+ ${currentIndent}]` : `[${items}]`;
669
+ }
670
+ const ctorName = constructorNameOf(value) ?? "Object";
671
+ if (ctorName === "Object") {
672
+ const keyValues = ownEntriesOf(value, opts).map(([key, val]) => {
673
+ const stringifiedKey = typeof key === "symbol" ? printableOpts.onSymbol(key) : isDotAccessible(key) ? key : JSON.stringify(key);
674
+ const stringifiedValue = stringifyUnquoted(val, indent, nextIndent, opts);
675
+ return `${nextIndent}${stringifiedKey}: ${stringifiedValue}`;
676
+ });
677
+ if (keyValues.length === 0)
678
+ return "{}";
679
+ return indent ? `{
680
+ ${keyValues.join(",\n")}
681
+ ${currentIndent}}` : `{${keyValues.join(", ")}}`;
682
+ }
683
+ if (isDate(value))
684
+ return describeCollapsibleDate(value);
685
+ return expressionOf(value) ?? ctorName;
686
+ };
687
+ var printSymbol = (symbol) => `Symbol(${baseNameOfSymbol(symbol)})`;
688
+ var printableOpts = {
689
+ onCycle: () => "(cycle)",
690
+ onSymbol: printSymbol,
691
+ onFunction: (v) => `Function(${baseNameOf(v)})`,
692
+ onBigInt: (n) => `${n}n`,
693
+ onUndefined: "undefined"
694
+ };
695
+ var ownDataPrintableOpts = /* @__PURE__ */ Object.assign({}, printableOpts, {
696
+ onAccessor: (descriptor) => descriptor.get ? "(getter)" : "(setter)"
697
+ });
698
+ var quotedMarkedValue = /"\uE000(-?\d+n|undefined)"/g;
699
+ var _serialize = (data, opts, seen) => {
700
+ switch (domainOf(data)) {
701
+ case "object": {
702
+ const o = data;
703
+ const toJson = !opts.onAccessor || isDate(o) ? toJsonMethodOf(o) : void 0;
704
+ if (toJson)
705
+ return Reflect.apply(toJson, o, []);
706
+ if (typeof o === "function")
707
+ return opts.onFunction?.(o) ?? printableOpts.onFunction(o);
708
+ if (seen.includes(o))
709
+ return opts.onCycle?.(o) ?? "(cycle)";
710
+ const nextSeen = [...seen, o];
711
+ if (isArray(o))
712
+ return o.map((item) => _serialize(item, opts, nextSeen));
713
+ if (isDate(o))
714
+ return o.toDateString();
715
+ const result = {};
716
+ for (const [k, v] of ownEntriesOf(o, opts)) {
717
+ const key = typeof k === "symbol" ? opts.onSymbol?.(k) ?? k.toString() : k;
718
+ defineValue(result, key, _serialize(v, opts, nextSeen));
719
+ }
720
+ return result;
721
+ }
722
+ case "symbol":
723
+ return opts.onSymbol?.(data) ?? printableOpts.onSymbol(data);
724
+ case "bigint":
725
+ return opts.onBigInt?.(data) ?? `${data}n`;
726
+ case "undefined":
727
+ return opts.onUndefined ?? "undefined";
728
+ case "string":
729
+ return data.replace(/\\/g, "\\\\");
730
+ default:
731
+ return data;
732
+ }
733
+ };
734
+ var describeCollapsibleDate = (date) => {
735
+ if (!isValidDate(date))
736
+ return "Invalid Date";
737
+ const year = date.getUTCFullYear();
738
+ const month = date.getUTCMonth();
739
+ const dayOfMonth = date.getUTCDate();
740
+ const hours = date.getUTCHours();
741
+ const minutes = date.getUTCMinutes();
742
+ const seconds = date.getUTCSeconds();
743
+ const milliseconds = date.getUTCMilliseconds();
744
+ if (hours === 0 && minutes === 0 && seconds === 0 && milliseconds === 0)
745
+ return `${months[month]} ${dayOfMonth}, ${year}`;
746
+ const h = hours % 12 || 12;
747
+ const suffix = hours < 12 ? " AM" : " PM";
748
+ let timePortion = seconds || milliseconds ? `${h}:${pad(minutes, 2)}:${pad(seconds, 2)}` : `${h}:${pad(minutes, 2)}`;
749
+ if (milliseconds)
750
+ timePortion += `.${pad(milliseconds, 3)}`;
751
+ return `${months[month]} ${dayOfMonth}, ${year}, ${timePortion + suffix} UTC`;
752
+ };
753
+ var months = [
754
+ "January",
755
+ "February",
756
+ "March",
757
+ "April",
758
+ "May",
759
+ "June",
760
+ "July",
761
+ "August",
762
+ "September",
763
+ "October",
764
+ "November",
765
+ "December"
766
+ ];
767
+ var pad = (value, length) => String(value).padStart(length, "0");
768
+ var dotAccessibleKeys = /* @__PURE__ */ new Map();
769
+ var isDotAccessible = (keyName) => {
770
+ let accessible = dotAccessibleKeys.get(keyName);
771
+ if (accessible === void 0) {
772
+ accessible = /^[$A-Z_a-z][\w$]*$/.test(keyName);
773
+ if (keyName.length <= 64) {
774
+ if (dotAccessibleKeys.size === 1024)
775
+ dotAccessibleKeys.clear();
776
+ dotAccessibleKeys.set(keyName, accessible);
777
+ }
778
+ }
779
+ return accessible;
780
+ };
781
+ var baseNameOf = (value) => {
782
+ switch (typeof value) {
783
+ case "object": {
784
+ if (value === null)
785
+ break;
786
+ const prefix = objectKindOf(value) ?? "object";
787
+ return prefix[0].toLowerCase() + prefix.slice(1);
788
+ }
789
+ case "function":
790
+ const name = functionNameOf(value);
791
+ return isDotAccessible(name) ? name : "fn";
792
+ case "symbol":
793
+ return baseNameOfSymbol(value);
794
+ }
795
+ return throwInternalError(`Unexpected attempt to register serializable value of type ${domainOf(value)}`);
796
+ };
797
+ var baseNameOfSymbol = (symbol) => symbol.description && isDotAccessible(symbol.description) ? symbol.description : "symbol";
798
+
799
+ // ../util/out/path.js
800
+ var keySuffixes = /* @__PURE__ */ new Map();
801
+ var keySuffixOf = (key) => {
802
+ let suffix = keySuffixes.get(key);
803
+ if (suffix === void 0) {
804
+ suffix = isDotAccessible(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
805
+ if (key.length <= 64) {
806
+ if (keySuffixes.size === 1024)
807
+ keySuffixes.clear();
808
+ keySuffixes.set(key, suffix);
809
+ }
810
+ }
811
+ return suffix;
812
+ };
813
+ var indexSuffixes = [];
814
+ var appendStringifiedKey = ((path, prop, opts) => {
815
+ switch (typeof prop) {
816
+ case "string": {
817
+ const suffix = keySuffixOf(prop);
818
+ return path === "" && suffix[0] === "." ? prop : path + suffix;
819
+ }
820
+ case "number":
821
+ return path + (prop >>> 0 === prop && prop < 256 ? indexSuffixes[prop] ??= `[${prop}]` : `[${prop}]`);
822
+ case "symbol":
823
+ return `${path}[${(opts?.stringifySymbol ?? String)(prop)}]`;
824
+ }
825
+ return opts?.stringifyNonKey ? `${path}[${opts.stringifyNonKey(prop)}]` : throwParseError(`${typeof prop} must be a PropertyKey or stringifyNonKey must be passed to options`);
826
+ });
827
+ var stringifyPath = ((path, opts) => {
828
+ let s = "";
829
+ for (const k of path)
830
+ s = appendStringifiedKey(s, k, opts);
831
+ return s;
832
+ });
833
+ var pathAt = (path, key) => {
834
+ if (key !== void 0)
835
+ path.push(key);
836
+ const copy = path.length === 1 ? [path[0]] : path.length === 2 ? [path[0], path[1]] : path.slice();
837
+ if (key !== void 0)
838
+ path.pop();
839
+ return copy;
840
+ };
841
+
842
+ export {
843
+ getDuplicatesOf,
844
+ join,
845
+ getPath,
846
+ intersectUniqueLists,
847
+ liftArray,
848
+ spliterate,
849
+ includes,
850
+ range,
851
+ append,
852
+ conflatenate,
853
+ conflatenateAll,
854
+ appendUnique,
855
+ groupBy,
856
+ arrayEquals,
857
+ hasDomain,
858
+ domainOf,
859
+ domainDescriptions,
860
+ jsTypeOfDescriptions,
861
+ InternalArktypeError,
862
+ throwInternalError,
863
+ throwError,
864
+ ParseError,
865
+ throwParseError,
866
+ noSuggest,
867
+ ZeroWidthSpace,
868
+ arkKind,
869
+ arkKindOf,
870
+ isStandardSchema,
871
+ isDate,
872
+ isInstanceOf,
873
+ prototypeOf,
874
+ arityOf,
875
+ readsOnlyData,
876
+ returnsReports,
877
+ testsOrRejects,
878
+ functionNameOf,
879
+ constructorNameOf,
880
+ expressionOf,
881
+ toJsonMethodOf,
882
+ constructorExtends,
883
+ ownEntriesOf,
884
+ nonFiniteNumbers,
885
+ wellFormedNumberMatcher,
886
+ isWellFormedNumber,
887
+ numericStringMatcher,
888
+ isDigitCode,
889
+ isNumericString,
890
+ numberLikeMatcher,
891
+ wellFormedIntegerMatcher,
892
+ isWellFormedInteger,
893
+ integerLikeMatcher,
894
+ writeMalformedNumericLiteralMessage,
895
+ tryParseNumber,
896
+ tryParseWellFormedNumber,
897
+ tryParseInteger,
898
+ tryParseWellFormedBigint,
899
+ nearestFloat,
900
+ printDecimal,
901
+ flatMorph,
902
+ entriesOf,
903
+ fromEntries,
904
+ keysOf,
905
+ isKeyOf,
906
+ hasOwn,
907
+ hasKey,
908
+ hasDefinedKey,
909
+ InnerDynamicBase,
910
+ DynamicBase,
911
+ NoopBase,
912
+ CastableBase,
913
+ splitByKeys,
914
+ pick,
915
+ omit,
916
+ isEmptyObject,
917
+ stringAndSymbolicEntriesOf,
918
+ defineProperties,
919
+ defineValue,
920
+ withAlphabetizedKeys,
921
+ invert,
922
+ unset,
923
+ enumValues,
924
+ ecmascriptConstructors,
925
+ FileConstructor,
926
+ platformConstructors,
927
+ typedArrayConstructors,
928
+ builtinConstructors,
929
+ objectKindOf,
930
+ objectKindOrDomainOf,
931
+ hasObjectKind,
932
+ isArray,
933
+ dateGetTime,
934
+ timeOf,
935
+ isValidDate,
936
+ isDateObject,
937
+ isRegExpObject,
938
+ writeInvalidDateMessage,
939
+ tryParseDate,
940
+ ecmascriptDescriptions,
941
+ platformDescriptions,
942
+ typedArrayDescriptions,
943
+ objectKindDescriptions,
944
+ getBuiltinNameOfConstructor,
945
+ ancestorsOf,
946
+ isPlainObjectOrArray,
947
+ cached,
948
+ isThunk,
949
+ tryCatch,
950
+ DynamicFunction,
951
+ Callable,
952
+ envHasCsp,
953
+ serializePrimitive,
954
+ snapshot,
955
+ print,
956
+ printable,
957
+ printKind,
958
+ printSymbol,
959
+ describeCollapsibleDate,
960
+ isDotAccessible,
961
+ baseNameOf,
962
+ appendStringifiedKey,
963
+ stringifyPath,
964
+ pathAt
965
+ };