@wirecat/notion-cli 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +204 -0
  3. package/README.md +36 -2
  4. package/contracts/wirecat.json +1315 -0
  5. package/dist/bin/notion.d.ts +3 -0
  6. package/dist/bin/notion.d.ts.map +1 -0
  7. package/dist/bin/notion.js +40 -0
  8. package/dist/bin/notion.js.map +1 -0
  9. package/dist/bundle/all-profiles-OETMCOLN.js +278 -0
  10. package/dist/bundle/anthropic-5Y3O2TYM.js +91 -0
  11. package/dist/bundle/app-server-IVWBIVHC.js +231 -0
  12. package/dist/bundle/bun-EO636SAD.js +169 -0
  13. package/dist/bundle/bun-sqlite-C2T7QJ2M.js +76 -0
  14. package/dist/bundle/chunk-24FAYAML.js +52 -0
  15. package/dist/bundle/chunk-2YR3RYT4.js +73 -0
  16. package/dist/bundle/chunk-35K5T6WV.js +24 -0
  17. package/dist/bundle/chunk-3D3PFXBP.js +2315 -0
  18. package/dist/bundle/chunk-47R43UVJ.js +1068 -0
  19. package/dist/bundle/chunk-4GC5DBHW.js +100 -0
  20. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  21. package/dist/bundle/chunk-64D5VUZ4.js +9564 -0
  22. package/dist/bundle/chunk-66PL7P4C.js +23 -0
  23. package/dist/bundle/chunk-7FII4DCE.js +362 -0
  24. package/dist/bundle/chunk-7N5QB6NL.js +156 -0
  25. package/dist/bundle/chunk-AE2KQ37N.js +95 -0
  26. package/dist/bundle/chunk-AQZO3ITW.js +58 -0
  27. package/dist/bundle/chunk-B2WFKFYL.js +1488 -0
  28. package/dist/bundle/chunk-B2XKEEFX.js +230 -0
  29. package/dist/bundle/chunk-B4B65XIO.js +73 -0
  30. package/dist/bundle/chunk-BWICUW7W.js +288 -0
  31. package/dist/bundle/chunk-CLG2ISQH.js +206 -0
  32. package/dist/bundle/chunk-CWVAYQXI.js +185 -0
  33. package/dist/bundle/chunk-D72URWJE.js +532 -0
  34. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  35. package/dist/bundle/chunk-DIM5YWBU.js +53 -0
  36. package/dist/bundle/chunk-EGTBL3MJ.js +6848 -0
  37. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  38. package/dist/bundle/chunk-EPAZ7DJB.js +783 -0
  39. package/dist/bundle/chunk-ESZT4WW3.js +142 -0
  40. package/dist/bundle/chunk-EU5WCOMQ.js +4001 -0
  41. package/dist/bundle/chunk-F6MLJ3V5.js +72 -0
  42. package/dist/bundle/chunk-FF4DDBCB.js +1028 -0
  43. package/dist/bundle/chunk-GA3URWIF.js +46 -0
  44. package/dist/bundle/chunk-HRTIRRXR.js +3112 -0
  45. package/dist/bundle/chunk-HWRKURQH.js +54 -0
  46. package/dist/bundle/chunk-IQWEJEB5.js +39724 -0
  47. package/dist/bundle/chunk-JK44XO2S.js +392 -0
  48. package/dist/bundle/chunk-JKIN5TOU.js +131 -0
  49. package/dist/bundle/chunk-K5TWMQSY.js +188 -0
  50. package/dist/bundle/chunk-KHOVVPLC.js +18 -0
  51. package/dist/bundle/chunk-NLDYZBTC.js +5862 -0
  52. package/dist/bundle/chunk-OWJDC4CB.js +217 -0
  53. package/dist/bundle/chunk-QBC23NHD.js +38 -0
  54. package/dist/bundle/chunk-QC3KOJT4.js +300 -0
  55. package/dist/bundle/chunk-R6ZM45NF.js +1239 -0
  56. package/dist/bundle/chunk-RAZKIHGH.js +76 -0
  57. package/dist/bundle/chunk-RDZ7SVBZ.js +731 -0
  58. package/dist/bundle/chunk-RLSFOR2D.js +161 -0
  59. package/dist/bundle/chunk-RSIS7BR7.js +2778 -0
  60. package/dist/bundle/chunk-ST2UC7FS.js +1324 -0
  61. package/dist/bundle/chunk-TR7R5DL4.js +370 -0
  62. package/dist/bundle/chunk-TSCIIXN3.js +106 -0
  63. package/dist/bundle/chunk-UWIA2G6Q.js +12737 -0
  64. package/dist/bundle/chunk-UWW24JQF.js +66 -0
  65. package/dist/bundle/chunk-WK3OSDNV.js +1197 -0
  66. package/dist/bundle/chunk-WM7663C2.js +1221 -0
  67. package/dist/bundle/chunk-WVZFXI36.js +274 -0
  68. package/dist/bundle/chunk-WWMB4UHF.js +78 -0
  69. package/dist/bundle/chunk-XC5CKHX2.js +63 -0
  70. package/dist/bundle/chunk-XL2HXHP3.js +82 -0
  71. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  72. package/dist/bundle/chunk-XYIT2XB3.js +1372 -0
  73. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  74. package/dist/bundle/chunk-YA4LSSDZ.js +64499 -0
  75. package/dist/bundle/chunk-ZI3YTXSF.js +2 -0
  76. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  77. package/dist/bundle/command-contract-6G5DC2FN.js +35 -0
  78. package/dist/bundle/command-server-entry-A66DJ3MH.js +164 -0
  79. package/dist/bundle/decode-7XOFRAAT.js +163 -0
  80. package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
  81. package/dist/bundle/dispatch-FEKU5UXC.js +411 -0
  82. package/dist/bundle/dist-YFKABFFF.js +7577 -0
  83. package/dist/bundle/echarts-XD2JSWU4.js +42501 -0
  84. package/dist/bundle/embed-F3HYGAF7.js +38 -0
  85. package/dist/bundle/embedder-GSEDDUH7.js +111 -0
  86. package/dist/bundle/failure-HDJLR2YJ.js +25 -0
  87. package/dist/bundle/first-run-TXNTIUSP.js +28 -0
  88. package/dist/bundle/first-screen-JZPJND7J.js +33 -0
  89. package/dist/bundle/instructions-NZGJ4FW5.js +11 -0
  90. package/dist/bundle/mcp-VFIOZDVY.js +167 -0
  91. package/dist/bundle/node-KM3CUABH.js +2340 -0
  92. package/dist/bundle/node-RPKPDYQS.js +176 -0
  93. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  94. package/dist/bundle/node-sqlite-KH2UUYVO.js +74 -0
  95. package/dist/bundle/notion.js +185 -0
  96. package/dist/bundle/oauth-NKAI7TQD.js +20 -0
  97. package/dist/bundle/open-WSAEAA2V.js +23 -0
  98. package/dist/bundle/openai-JPVDGHG5.js +238 -0
  99. package/dist/bundle/process-5ZFVKOQX.js +91 -0
  100. package/dist/bundle/program-M3D56D6T.js +28854 -0
  101. package/dist/bundle/prompt-FROYQ5LV.js +17 -0
  102. package/dist/bundle/recognize-NYCHQMCX.js +26 -0
  103. package/dist/bundle/remote-4OERF3Z4.js +32 -0
  104. package/dist/bundle/rerank-TEGXFUWY.js +52 -0
  105. package/dist/bundle/schemas-MZNNOEYN.js +12214 -0
  106. package/dist/bundle/serve-HLYYBAXY.js +199 -0
  107. package/dist/bundle/server-D5OYNEUW.js +193 -0
  108. package/dist/bundle/server-LWZGVMNW.js +62 -0
  109. package/dist/bundle/sqlite-runtime-H2S5RR2F.js +20 -0
  110. package/dist/bundle/state-OPOXCDZL.js +36 -0
  111. package/dist/bundle/store-NHMXEJPD.js +164 -0
  112. package/dist/bundle/store-Y3KRLCJ7.js +281 -0
  113. package/dist/bundle/store-maintenance-command-D4W7WSLQ.js +53 -0
  114. package/dist/commands/api.d.ts +4 -0
  115. package/dist/commands/api.d.ts.map +1 -0
  116. package/dist/commands/api.js +140 -0
  117. package/dist/commands/api.js.map +1 -0
  118. package/dist/commands/comments.d.ts +3 -0
  119. package/dist/commands/comments.d.ts.map +1 -0
  120. package/dist/commands/comments.js +114 -0
  121. package/dist/commands/comments.js.map +1 -0
  122. package/dist/commands/databases.d.ts +3 -0
  123. package/dist/commands/databases.d.ts.map +1 -0
  124. package/dist/commands/databases.js +65 -0
  125. package/dist/commands/databases.js.map +1 -0
  126. package/dist/commands/documents.d.ts +3 -0
  127. package/dist/commands/documents.d.ts.map +1 -0
  128. package/dist/commands/documents.js +41 -0
  129. package/dist/commands/documents.js.map +1 -0
  130. package/dist/commands/session.d.ts +3 -0
  131. package/dist/commands/session.d.ts.map +1 -0
  132. package/dist/commands/session.js +104 -0
  133. package/dist/commands/session.js.map +1 -0
  134. package/dist/config.d.ts +5 -0
  135. package/dist/config.d.ts.map +1 -0
  136. package/dist/config.js +13 -0
  137. package/dist/config.js.map +1 -0
  138. package/dist/context.d.ts +46 -0
  139. package/dist/context.d.ts.map +1 -0
  140. package/dist/context.js +58 -0
  141. package/dist/context.js.map +1 -0
  142. package/dist/generated/definitions.d.ts +3 -0
  143. package/dist/generated/definitions.d.ts.map +1 -0
  144. package/dist/generated/definitions.js +45603 -0
  145. package/dist/generated/definitions.js.map +1 -0
  146. package/dist/generated/manifest.d.ts +3 -0
  147. package/dist/generated/manifest.d.ts.map +1 -0
  148. package/dist/generated/manifest.js +2089 -0
  149. package/dist/generated/manifest.js.map +1 -0
  150. package/dist/generated/metadata.d.ts +6 -0
  151. package/dist/generated/metadata.d.ts.map +1 -0
  152. package/dist/generated/metadata.js +24 -0
  153. package/dist/generated/metadata.js.map +1 -0
  154. package/dist/generated/schemas.d.ts +1223 -0
  155. package/dist/generated/schemas.d.ts.map +1 -0
  156. package/dist/generated/schemas.js +11557 -0
  157. package/dist/generated/schemas.js.map +1 -0
  158. package/dist/generated/types.d.ts +11120 -0
  159. package/dist/generated/types.d.ts.map +1 -0
  160. package/dist/generated/types.js +5 -0
  161. package/dist/generated/types.js.map +1 -0
  162. package/dist/identity.d.ts +7 -0
  163. package/dist/identity.d.ts.map +1 -0
  164. package/dist/identity.js +29 -0
  165. package/dist/identity.js.map +1 -0
  166. package/dist/index.d.ts +3 -0
  167. package/dist/index.d.ts.map +1 -0
  168. package/dist/index.js +3 -0
  169. package/dist/index.js.map +1 -0
  170. package/dist/notion/client.d.ts +42 -0
  171. package/dist/notion/client.d.ts.map +1 -0
  172. package/dist/notion/client.js +118 -0
  173. package/dist/notion/client.js.map +1 -0
  174. package/dist/notion/errors.d.ts +24 -0
  175. package/dist/notion/errors.d.ts.map +1 -0
  176. package/dist/notion/errors.js +102 -0
  177. package/dist/notion/errors.js.map +1 -0
  178. package/dist/notion/ids.d.ts +7 -0
  179. package/dist/notion/ids.d.ts.map +1 -0
  180. package/dist/notion/ids.js +37 -0
  181. package/dist/notion/ids.js.map +1 -0
  182. package/dist/notion/links.d.ts +6 -0
  183. package/dist/notion/links.d.ts.map +1 -0
  184. package/dist/notion/links.js +22 -0
  185. package/dist/notion/links.js.map +1 -0
  186. package/dist/notion/notion.d.ts +95 -0
  187. package/dist/notion/notion.d.ts.map +1 -0
  188. package/dist/notion/notion.js +269 -0
  189. package/dist/notion/notion.js.map +1 -0
  190. package/dist/notion/port.d.ts +13 -0
  191. package/dist/notion/port.d.ts.map +1 -0
  192. package/dist/notion/port.js +60 -0
  193. package/dist/notion/port.js.map +1 -0
  194. package/dist/notion/read-posts.d.ts +36 -0
  195. package/dist/notion/read-posts.d.ts.map +1 -0
  196. package/dist/notion/read-posts.js +24 -0
  197. package/dist/notion/read-posts.js.map +1 -0
  198. package/dist/notion/reads.d.ts +327 -0
  199. package/dist/notion/reads.d.ts.map +1 -0
  200. package/dist/notion/reads.js +18 -0
  201. package/dist/notion/reads.js.map +1 -0
  202. package/dist/program.d.ts +6 -0
  203. package/dist/program.d.ts.map +1 -0
  204. package/dist/program.js +62 -0
  205. package/dist/program.js.map +1 -0
  206. package/dist/sample/comments.d.ts +61 -0
  207. package/dist/sample/comments.d.ts.map +1 -0
  208. package/dist/sample/comments.js +39 -0
  209. package/dist/sample/comments.js.map +1 -0
  210. package/dist/sample/records.d.ts +16 -0
  211. package/dist/sample/records.d.ts.map +1 -0
  212. package/dist/sample/records.js +22 -0
  213. package/dist/sample/records.js.map +1 -0
  214. package/dist/sample/transport.d.ts +42 -0
  215. package/dist/sample/transport.d.ts.map +1 -0
  216. package/dist/sample/transport.js +153 -0
  217. package/dist/sample/transport.js.map +1 -0
  218. package/dist/sync/cursor.d.ts +54 -0
  219. package/dist/sync/cursor.d.ts.map +1 -0
  220. package/dist/sync/cursor.js +52 -0
  221. package/dist/sync/cursor.js.map +1 -0
  222. package/dist/sync/front-matter.d.ts +10 -0
  223. package/dist/sync/front-matter.d.ts.map +1 -0
  224. package/dist/sync/front-matter.js +114 -0
  225. package/dist/sync/front-matter.js.map +1 -0
  226. package/dist/sync/markdown.d.ts +8 -0
  227. package/dist/sync/markdown.d.ts.map +1 -0
  228. package/dist/sync/markdown.js +40 -0
  229. package/dist/sync/markdown.js.map +1 -0
  230. package/dist/sync/source.d.ts +64 -0
  231. package/dist/sync/source.d.ts.map +1 -0
  232. package/dist/sync/source.js +634 -0
  233. package/dist/sync/source.js.map +1 -0
  234. package/dist/version.d.ts +2 -0
  235. package/dist/version.d.ts.map +1 -0
  236. package/dist/version.js +2 -0
  237. package/dist/version.js.map +1 -0
  238. package/dist/wcat.d.ts +3 -0
  239. package/dist/wcat.d.ts.map +1 -0
  240. package/dist/wcat.js +4 -0
  241. package/dist/wcat.js.map +1 -0
  242. package/package.json +85 -4
  243. package/skills/notion-cli/SKILL.md +34 -0
@@ -0,0 +1,1372 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ __name
5
+ } from "./chunk-ZVVMGPBJ.js";
6
+
7
+ // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
8
+ var store$4;
9
+ var DEFAULT_CONFIG = {
10
+ lang: void 0,
11
+ message: void 0,
12
+ abortEarly: void 0,
13
+ abortPipeEarly: void 0
14
+ };
15
+ // @__NO_SIDE_EFFECTS__
16
+ function getGlobalConfig(config$1) {
17
+ if (!config$1 && !store$4) return DEFAULT_CONFIG;
18
+ return {
19
+ lang: config$1?.lang ?? store$4?.lang,
20
+ message: config$1?.message,
21
+ abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
22
+ abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
23
+ };
24
+ }
25
+ __name(getGlobalConfig, "getGlobalConfig");
26
+ var store$3;
27
+ // @__NO_SIDE_EFFECTS__
28
+ function getGlobalMessage(lang) {
29
+ return store$3?.get(lang);
30
+ }
31
+ __name(getGlobalMessage, "getGlobalMessage");
32
+ var store$2;
33
+ // @__NO_SIDE_EFFECTS__
34
+ function getSchemaMessage(lang) {
35
+ return store$2?.get(lang);
36
+ }
37
+ __name(getSchemaMessage, "getSchemaMessage");
38
+ var store$1;
39
+ // @__NO_SIDE_EFFECTS__
40
+ function getSpecificMessage(reference, lang) {
41
+ return store$1?.get(reference)?.get(lang);
42
+ }
43
+ __name(getSpecificMessage, "getSpecificMessage");
44
+ // @__NO_SIDE_EFFECTS__
45
+ function _stringify(input) {
46
+ const type = typeof input;
47
+ if (type === "string") return `"${input}"`;
48
+ if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
49
+ if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
50
+ return type;
51
+ }
52
+ __name(_stringify, "_stringify");
53
+ function _addIssue(context, label, dataset, config$1, other) {
54
+ const input = other && "input" in other ? other.input : dataset.value;
55
+ const expected = other?.expected ?? context.expects ?? null;
56
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
57
+ const issue = {
58
+ kind: context.kind,
59
+ type: context.type,
60
+ input,
61
+ expected,
62
+ received,
63
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
64
+ requirement: context.requirement,
65
+ path: other?.path,
66
+ issues: other?.issues,
67
+ lang: config$1.lang,
68
+ abortEarly: config$1.abortEarly,
69
+ abortPipeEarly: config$1.abortPipeEarly
70
+ };
71
+ const isSchema = context.kind === "schema";
72
+ const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
73
+ if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
74
+ if (isSchema) dataset.typed = false;
75
+ if (dataset.issues) dataset.issues.push(issue);
76
+ else dataset.issues = [issue];
77
+ }
78
+ __name(_addIssue, "_addIssue");
79
+ // @__NO_SIDE_EFFECTS__
80
+ function _isSameValueZero(value1, value2) {
81
+ return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
82
+ }
83
+ __name(_isSameValueZero, "_isSameValueZero");
84
+ // @__NO_SIDE_EFFECTS__
85
+ function _isValidObjectKey(object$1, key) {
86
+ return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
87
+ }
88
+ __name(_isValidObjectKey, "_isValidObjectKey");
89
+ // @__NO_SIDE_EFFECTS__
90
+ function _joinExpects(values$1, separator) {
91
+ const list = [...new Set(values$1)];
92
+ if (list.length > 1) return `(${list.join(` ${separator} `)})`;
93
+ return list[0] ?? "never";
94
+ }
95
+ __name(_joinExpects, "_joinExpects");
96
+ function _standardSchema(schema) {
97
+ schema["~standard"] = {
98
+ version: 1,
99
+ vendor: "valibot",
100
+ validate: /* @__PURE__ */ __name((value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig()), "validate")
101
+ };
102
+ return schema;
103
+ }
104
+ __name(_standardSchema, "_standardSchema");
105
+ // @__NO_SIDE_EFFECTS__
106
+ function getDotPath(issue) {
107
+ if (issue.path) {
108
+ let key = "";
109
+ for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
110
+ else key += item.key;
111
+ else return null;
112
+ return key;
113
+ }
114
+ return null;
115
+ }
116
+ __name(getDotPath, "getDotPath");
117
+ var ValiError = class extends Error {
118
+ static {
119
+ __name(this, "ValiError");
120
+ }
121
+ /**
122
+ * Creates a Valibot error with useful information.
123
+ *
124
+ * @param issues The error issues.
125
+ */
126
+ constructor(issues) {
127
+ super(issues[0].message);
128
+ this.name = "ValiError";
129
+ this.issues = issues;
130
+ }
131
+ };
132
+ var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
133
+ var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])$/u;
134
+ var ISO_TIMESTAMP_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;
135
+ // @__NO_SIDE_EFFECTS__
136
+ function check(requirement, message$1) {
137
+ return {
138
+ kind: "validation",
139
+ type: "check",
140
+ reference: check,
141
+ async: false,
142
+ expects: null,
143
+ requirement,
144
+ message: message$1,
145
+ "~run"(dataset, config$1) {
146
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
147
+ return dataset;
148
+ }
149
+ };
150
+ }
151
+ __name(check, "check");
152
+ // @__NO_SIDE_EFFECTS__
153
+ function description(description_) {
154
+ return {
155
+ kind: "metadata",
156
+ type: "description",
157
+ reference: description,
158
+ description: description_
159
+ };
160
+ }
161
+ __name(description, "description");
162
+ // @__NO_SIDE_EFFECTS__
163
+ function endsWith(requirement, message$1) {
164
+ return {
165
+ kind: "validation",
166
+ type: "ends_with",
167
+ reference: endsWith,
168
+ async: false,
169
+ expects: `"${requirement}"`,
170
+ requirement,
171
+ message: message$1,
172
+ "~run"(dataset, config$1) {
173
+ if (dataset.typed && !dataset.value.endsWith(this.requirement)) _addIssue(this, "end", dataset, config$1, { received: `"${dataset.value.slice(-this.requirement.length)}"` });
174
+ return dataset;
175
+ }
176
+ };
177
+ }
178
+ __name(endsWith, "endsWith");
179
+ // @__NO_SIDE_EFFECTS__
180
+ function finite(message$1) {
181
+ return {
182
+ kind: "validation",
183
+ type: "finite",
184
+ reference: finite,
185
+ async: false,
186
+ expects: null,
187
+ requirement: Number.isFinite,
188
+ message: message$1,
189
+ "~run"(dataset, config$1) {
190
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "finite", dataset, config$1);
191
+ return dataset;
192
+ }
193
+ };
194
+ }
195
+ __name(finite, "finite");
196
+ // @__NO_SIDE_EFFECTS__
197
+ function integer(message$1) {
198
+ return {
199
+ kind: "validation",
200
+ type: "integer",
201
+ reference: integer,
202
+ async: false,
203
+ expects: null,
204
+ requirement: Number.isInteger,
205
+ message: message$1,
206
+ "~run"(dataset, config$1) {
207
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
208
+ return dataset;
209
+ }
210
+ };
211
+ }
212
+ __name(integer, "integer");
213
+ // @__NO_SIDE_EFFECTS__
214
+ function isoDate(message$1) {
215
+ return {
216
+ kind: "validation",
217
+ type: "iso_date",
218
+ reference: isoDate,
219
+ async: false,
220
+ expects: null,
221
+ requirement: ISO_DATE_REGEX,
222
+ message: message$1,
223
+ "~run"(dataset, config$1) {
224
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "date", dataset, config$1);
225
+ return dataset;
226
+ }
227
+ };
228
+ }
229
+ __name(isoDate, "isoDate");
230
+ // @__NO_SIDE_EFFECTS__
231
+ function isoTimestamp(message$1) {
232
+ return {
233
+ kind: "validation",
234
+ type: "iso_timestamp",
235
+ reference: isoTimestamp,
236
+ async: false,
237
+ expects: null,
238
+ requirement: ISO_TIMESTAMP_REGEX,
239
+ message: message$1,
240
+ "~run"(dataset, config$1) {
241
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "timestamp", dataset, config$1);
242
+ return dataset;
243
+ }
244
+ };
245
+ }
246
+ __name(isoTimestamp, "isoTimestamp");
247
+ // @__NO_SIDE_EFFECTS__
248
+ function maxLength(requirement, message$1) {
249
+ return {
250
+ kind: "validation",
251
+ type: "max_length",
252
+ reference: maxLength,
253
+ async: false,
254
+ expects: `<=${requirement}`,
255
+ requirement,
256
+ message: message$1,
257
+ "~run"(dataset, config$1) {
258
+ if (dataset.typed && dataset.value.length > this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
259
+ return dataset;
260
+ }
261
+ };
262
+ }
263
+ __name(maxLength, "maxLength");
264
+ // @__NO_SIDE_EFFECTS__
265
+ function maxValue(requirement, message$1) {
266
+ return {
267
+ kind: "validation",
268
+ type: "max_value",
269
+ reference: maxValue,
270
+ async: false,
271
+ expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
272
+ requirement,
273
+ message: message$1,
274
+ "~run"(dataset, config$1) {
275
+ if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
276
+ return dataset;
277
+ }
278
+ };
279
+ }
280
+ __name(maxValue, "maxValue");
281
+ // @__NO_SIDE_EFFECTS__
282
+ function minLength(requirement, message$1) {
283
+ return {
284
+ kind: "validation",
285
+ type: "min_length",
286
+ reference: minLength,
287
+ async: false,
288
+ expects: `>=${requirement}`,
289
+ requirement,
290
+ message: message$1,
291
+ "~run"(dataset, config$1) {
292
+ if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
293
+ return dataset;
294
+ }
295
+ };
296
+ }
297
+ __name(minLength, "minLength");
298
+ // @__NO_SIDE_EFFECTS__
299
+ function minValue(requirement, message$1) {
300
+ return {
301
+ kind: "validation",
302
+ type: "min_value",
303
+ reference: minValue,
304
+ async: false,
305
+ expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
306
+ requirement,
307
+ message: message$1,
308
+ "~run"(dataset, config$1) {
309
+ if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
310
+ return dataset;
311
+ }
312
+ };
313
+ }
314
+ __name(minValue, "minValue");
315
+ // @__NO_SIDE_EFFECTS__
316
+ function nonEmpty(message$1) {
317
+ return {
318
+ kind: "validation",
319
+ type: "non_empty",
320
+ reference: nonEmpty,
321
+ async: false,
322
+ expects: "!0",
323
+ message: message$1,
324
+ "~run"(dataset, config$1) {
325
+ if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
326
+ return dataset;
327
+ }
328
+ };
329
+ }
330
+ __name(nonEmpty, "nonEmpty");
331
+ // @__NO_SIDE_EFFECTS__
332
+ function regex(requirement, message$1) {
333
+ return {
334
+ kind: "validation",
335
+ type: "regex",
336
+ reference: regex,
337
+ async: false,
338
+ expects: `${requirement}`,
339
+ requirement,
340
+ message: message$1,
341
+ "~run"(dataset, config$1) {
342
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
343
+ return dataset;
344
+ }
345
+ };
346
+ }
347
+ __name(regex, "regex");
348
+ // @__NO_SIDE_EFFECTS__
349
+ function safeInteger(message$1) {
350
+ return {
351
+ kind: "validation",
352
+ type: "safe_integer",
353
+ reference: safeInteger,
354
+ async: false,
355
+ expects: null,
356
+ requirement: Number.isSafeInteger,
357
+ message: message$1,
358
+ "~run"(dataset, config$1) {
359
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
360
+ return dataset;
361
+ }
362
+ };
363
+ }
364
+ __name(safeInteger, "safeInteger");
365
+ // @__NO_SIDE_EFFECTS__
366
+ function startsWith(requirement, message$1) {
367
+ return {
368
+ kind: "validation",
369
+ type: "starts_with",
370
+ reference: startsWith,
371
+ async: false,
372
+ expects: `"${requirement}"`,
373
+ requirement,
374
+ message: message$1,
375
+ "~run"(dataset, config$1) {
376
+ if (dataset.typed && !dataset.value.startsWith(this.requirement)) _addIssue(this, "start", dataset, config$1, { received: `"${dataset.value.slice(0, this.requirement.length)}"` });
377
+ return dataset;
378
+ }
379
+ };
380
+ }
381
+ __name(startsWith, "startsWith");
382
+ // @__NO_SIDE_EFFECTS__
383
+ function transform(operation) {
384
+ return {
385
+ kind: "transformation",
386
+ type: "transform",
387
+ reference: transform,
388
+ async: false,
389
+ operation,
390
+ "~run"(dataset) {
391
+ dataset.value = this.operation(dataset.value);
392
+ return dataset;
393
+ }
394
+ };
395
+ }
396
+ __name(transform, "transform");
397
+ // @__NO_SIDE_EFFECTS__
398
+ function trim() {
399
+ return {
400
+ kind: "transformation",
401
+ type: "trim",
402
+ reference: trim,
403
+ async: false,
404
+ "~run"(dataset) {
405
+ dataset.value = dataset.value.trim();
406
+ return dataset;
407
+ }
408
+ };
409
+ }
410
+ __name(trim, "trim");
411
+ // @__NO_SIDE_EFFECTS__
412
+ function url(message$1) {
413
+ return {
414
+ kind: "validation",
415
+ type: "url",
416
+ reference: url,
417
+ async: false,
418
+ expects: null,
419
+ requirement(input) {
420
+ try {
421
+ if (URL.canParse) return URL.canParse(input);
422
+ new URL(input);
423
+ return true;
424
+ } catch {
425
+ return false;
426
+ }
427
+ },
428
+ message: message$1,
429
+ "~run"(dataset, config$1) {
430
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "URL", dataset, config$1);
431
+ return dataset;
432
+ }
433
+ };
434
+ }
435
+ __name(url, "url");
436
+ var ABORT_EARLY_CONFIG = { abortEarly: true };
437
+ // @__NO_SIDE_EFFECTS__
438
+ function getFallback(schema, dataset, config$1) {
439
+ return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
440
+ }
441
+ __name(getFallback, "getFallback");
442
+ // @__NO_SIDE_EFFECTS__
443
+ function forward(action, path) {
444
+ return {
445
+ ...action,
446
+ "~run"(dataset, config$1) {
447
+ const prevIssues = dataset.issues && [...dataset.issues];
448
+ dataset = action["~run"](dataset, config$1);
449
+ if (dataset.issues) {
450
+ for (const issue of dataset.issues) if (!prevIssues?.includes(issue)) {
451
+ let pathInput = dataset.value;
452
+ for (const key of path) {
453
+ const pathValue = pathInput[key];
454
+ const pathItem = {
455
+ type: "unknown",
456
+ origin: "value",
457
+ input: pathInput,
458
+ key,
459
+ value: pathValue
460
+ };
461
+ if (issue.path) issue.path.push(pathItem);
462
+ else issue.path = [pathItem];
463
+ if (!pathValue) break;
464
+ pathInput = pathValue;
465
+ }
466
+ }
467
+ }
468
+ return dataset;
469
+ }
470
+ };
471
+ }
472
+ __name(forward, "forward");
473
+ // @__NO_SIDE_EFFECTS__
474
+ function getDefault(schema, dataset, config$1) {
475
+ return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
476
+ }
477
+ __name(getDefault, "getDefault");
478
+ // @__NO_SIDE_EFFECTS__
479
+ function array(item, message$1) {
480
+ return _standardSchema({
481
+ kind: "schema",
482
+ type: "array",
483
+ reference: array,
484
+ expects: "Array",
485
+ async: false,
486
+ item,
487
+ message: message$1,
488
+ "~run"(dataset, config$1) {
489
+ const input = dataset.value;
490
+ if (Array.isArray(input)) {
491
+ dataset.typed = true;
492
+ dataset.value = [];
493
+ for (let key = 0; key < input.length; key++) {
494
+ const value$1 = input[key];
495
+ const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
496
+ if (itemDataset.issues) {
497
+ const pathItem = {
498
+ type: "array",
499
+ origin: "value",
500
+ input,
501
+ key,
502
+ value: value$1
503
+ };
504
+ for (const issue of itemDataset.issues) {
505
+ if (issue.path) issue.path.unshift(pathItem);
506
+ else issue.path = [pathItem];
507
+ dataset.issues?.push(issue);
508
+ }
509
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
510
+ if (config$1.abortEarly) {
511
+ dataset.typed = false;
512
+ break;
513
+ }
514
+ }
515
+ if (!itemDataset.typed) dataset.typed = false;
516
+ dataset.value.push(itemDataset.value);
517
+ }
518
+ } else _addIssue(this, "type", dataset, config$1);
519
+ return dataset;
520
+ }
521
+ });
522
+ }
523
+ __name(array, "array");
524
+ // @__NO_SIDE_EFFECTS__
525
+ function boolean(message$1) {
526
+ return _standardSchema({
527
+ kind: "schema",
528
+ type: "boolean",
529
+ reference: boolean,
530
+ expects: "boolean",
531
+ async: false,
532
+ message: message$1,
533
+ "~run"(dataset, config$1) {
534
+ if (typeof dataset.value === "boolean") dataset.typed = true;
535
+ else _addIssue(this, "type", dataset, config$1);
536
+ return dataset;
537
+ }
538
+ });
539
+ }
540
+ __name(boolean, "boolean");
541
+ // @__NO_SIDE_EFFECTS__
542
+ function custom(check$1, message$1) {
543
+ return _standardSchema({
544
+ kind: "schema",
545
+ type: "custom",
546
+ reference: custom,
547
+ expects: "unknown",
548
+ async: false,
549
+ check: check$1,
550
+ message: message$1,
551
+ "~run"(dataset, config$1) {
552
+ if (this.check(dataset.value)) dataset.typed = true;
553
+ else _addIssue(this, "type", dataset, config$1);
554
+ return dataset;
555
+ }
556
+ });
557
+ }
558
+ __name(custom, "custom");
559
+ // @__NO_SIDE_EFFECTS__
560
+ function exactOptional(wrapped, default_) {
561
+ return _standardSchema({
562
+ kind: "schema",
563
+ type: "exact_optional",
564
+ reference: exactOptional,
565
+ expects: wrapped.expects,
566
+ async: false,
567
+ wrapped,
568
+ default: default_,
569
+ "~run"(dataset, config$1) {
570
+ return this.wrapped["~run"](dataset, config$1);
571
+ }
572
+ });
573
+ }
574
+ __name(exactOptional, "exactOptional");
575
+ // @__NO_SIDE_EFFECTS__
576
+ function lazy(getter) {
577
+ return _standardSchema({
578
+ kind: "schema",
579
+ type: "lazy",
580
+ reference: lazy,
581
+ expects: "unknown",
582
+ async: false,
583
+ getter,
584
+ "~run"(dataset, config$1) {
585
+ return this.getter(dataset.value)["~run"](dataset, config$1);
586
+ }
587
+ });
588
+ }
589
+ __name(lazy, "lazy");
590
+ // @__NO_SIDE_EFFECTS__
591
+ function literal(literal_, message$1) {
592
+ return _standardSchema({
593
+ kind: "schema",
594
+ type: "literal",
595
+ reference: literal,
596
+ expects: /* @__PURE__ */ _stringify(literal_),
597
+ async: false,
598
+ literal: literal_,
599
+ message: message$1,
600
+ "~run"(dataset, config$1) {
601
+ if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
602
+ else _addIssue(this, "type", dataset, config$1);
603
+ return dataset;
604
+ }
605
+ });
606
+ }
607
+ __name(literal, "literal");
608
+ // @__NO_SIDE_EFFECTS__
609
+ function looseObject(entries$1, message$1) {
610
+ return _standardSchema({
611
+ kind: "schema",
612
+ type: "loose_object",
613
+ reference: looseObject,
614
+ expects: "Object",
615
+ async: false,
616
+ entries: entries$1,
617
+ message: message$1,
618
+ "~run"(dataset, config$1) {
619
+ const input = dataset.value;
620
+ if (input && typeof input === "object") {
621
+ dataset.typed = true;
622
+ dataset.value = {};
623
+ for (const key in this.entries) {
624
+ const valueSchema = this.entries[key];
625
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
626
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
627
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
628
+ if (valueDataset.issues) {
629
+ const pathItem = {
630
+ type: "object",
631
+ origin: "value",
632
+ input,
633
+ key,
634
+ value: value$1
635
+ };
636
+ for (const issue of valueDataset.issues) {
637
+ if (issue.path) issue.path.unshift(pathItem);
638
+ else issue.path = [pathItem];
639
+ dataset.issues?.push(issue);
640
+ }
641
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
642
+ if (config$1.abortEarly) {
643
+ dataset.typed = false;
644
+ break;
645
+ }
646
+ }
647
+ if (!valueDataset.typed) dataset.typed = false;
648
+ dataset.value[key] = valueDataset.value;
649
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
650
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
651
+ _addIssue(this, "key", dataset, config$1, {
652
+ input: void 0,
653
+ expected: `"${key}"`,
654
+ path: [{
655
+ type: "object",
656
+ origin: "key",
657
+ input,
658
+ key,
659
+ value: input[key]
660
+ }]
661
+ });
662
+ if (config$1.abortEarly) break;
663
+ }
664
+ }
665
+ if (!dataset.issues || !config$1.abortEarly) {
666
+ for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
667
+ }
668
+ } else _addIssue(this, "type", dataset, config$1);
669
+ return dataset;
670
+ }
671
+ });
672
+ }
673
+ __name(looseObject, "looseObject");
674
+ // @__NO_SIDE_EFFECTS__
675
+ function null_(message$1) {
676
+ return _standardSchema({
677
+ kind: "schema",
678
+ type: "null",
679
+ reference: null_,
680
+ expects: "null",
681
+ async: false,
682
+ message: message$1,
683
+ "~run"(dataset, config$1) {
684
+ if (dataset.value === null) dataset.typed = true;
685
+ else _addIssue(this, "type", dataset, config$1);
686
+ return dataset;
687
+ }
688
+ });
689
+ }
690
+ __name(null_, "null_");
691
+ // @__NO_SIDE_EFFECTS__
692
+ function nullable(wrapped, default_) {
693
+ return _standardSchema({
694
+ kind: "schema",
695
+ type: "nullable",
696
+ reference: nullable,
697
+ expects: `(${wrapped.expects} | null)`,
698
+ async: false,
699
+ wrapped,
700
+ default: default_,
701
+ "~run"(dataset, config$1) {
702
+ if (dataset.value === null) {
703
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
704
+ if (dataset.value === null) {
705
+ dataset.typed = true;
706
+ return dataset;
707
+ }
708
+ }
709
+ return this.wrapped["~run"](dataset, config$1);
710
+ }
711
+ });
712
+ }
713
+ __name(nullable, "nullable");
714
+ // @__NO_SIDE_EFFECTS__
715
+ function nullish(wrapped, default_) {
716
+ return _standardSchema({
717
+ kind: "schema",
718
+ type: "nullish",
719
+ reference: nullish,
720
+ expects: `(${wrapped.expects} | null | undefined)`,
721
+ async: false,
722
+ wrapped,
723
+ default: default_,
724
+ "~run"(dataset, config$1) {
725
+ if (dataset.value === null || dataset.value === void 0) {
726
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
727
+ if (dataset.value === null || dataset.value === void 0) {
728
+ dataset.typed = true;
729
+ return dataset;
730
+ }
731
+ }
732
+ return this.wrapped["~run"](dataset, config$1);
733
+ }
734
+ });
735
+ }
736
+ __name(nullish, "nullish");
737
+ // @__NO_SIDE_EFFECTS__
738
+ function number(message$1) {
739
+ return _standardSchema({
740
+ kind: "schema",
741
+ type: "number",
742
+ reference: number,
743
+ expects: "number",
744
+ async: false,
745
+ message: message$1,
746
+ "~run"(dataset, config$1) {
747
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
748
+ else _addIssue(this, "type", dataset, config$1);
749
+ return dataset;
750
+ }
751
+ });
752
+ }
753
+ __name(number, "number");
754
+ // @__NO_SIDE_EFFECTS__
755
+ function object(entries$1, message$1) {
756
+ return _standardSchema({
757
+ kind: "schema",
758
+ type: "object",
759
+ reference: object,
760
+ expects: "Object",
761
+ async: false,
762
+ entries: entries$1,
763
+ message: message$1,
764
+ "~run"(dataset, config$1) {
765
+ const input = dataset.value;
766
+ if (input && typeof input === "object") {
767
+ dataset.typed = true;
768
+ dataset.value = {};
769
+ for (const key in this.entries) {
770
+ const valueSchema = this.entries[key];
771
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
772
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
773
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
774
+ if (valueDataset.issues) {
775
+ const pathItem = {
776
+ type: "object",
777
+ origin: "value",
778
+ input,
779
+ key,
780
+ value: value$1
781
+ };
782
+ for (const issue of valueDataset.issues) {
783
+ if (issue.path) issue.path.unshift(pathItem);
784
+ else issue.path = [pathItem];
785
+ dataset.issues?.push(issue);
786
+ }
787
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
788
+ if (config$1.abortEarly) {
789
+ dataset.typed = false;
790
+ break;
791
+ }
792
+ }
793
+ if (!valueDataset.typed) dataset.typed = false;
794
+ dataset.value[key] = valueDataset.value;
795
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
796
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
797
+ _addIssue(this, "key", dataset, config$1, {
798
+ input: void 0,
799
+ expected: `"${key}"`,
800
+ path: [{
801
+ type: "object",
802
+ origin: "key",
803
+ input,
804
+ key,
805
+ value: input[key]
806
+ }]
807
+ });
808
+ if (config$1.abortEarly) break;
809
+ }
810
+ }
811
+ } else _addIssue(this, "type", dataset, config$1);
812
+ return dataset;
813
+ }
814
+ });
815
+ }
816
+ __name(object, "object");
817
+ // @__NO_SIDE_EFFECTS__
818
+ function objectWithRest(entries$1, rest, message$1) {
819
+ return _standardSchema({
820
+ kind: "schema",
821
+ type: "object_with_rest",
822
+ reference: objectWithRest,
823
+ expects: "Object",
824
+ async: false,
825
+ entries: entries$1,
826
+ rest,
827
+ message: message$1,
828
+ "~run"(dataset, config$1) {
829
+ const input = dataset.value;
830
+ if (input && typeof input === "object") {
831
+ dataset.typed = true;
832
+ dataset.value = {};
833
+ for (const key in this.entries) {
834
+ const valueSchema = this.entries[key];
835
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
836
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
837
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
838
+ if (valueDataset.issues) {
839
+ const pathItem = {
840
+ type: "object",
841
+ origin: "value",
842
+ input,
843
+ key,
844
+ value: value$1
845
+ };
846
+ for (const issue of valueDataset.issues) {
847
+ if (issue.path) issue.path.unshift(pathItem);
848
+ else issue.path = [pathItem];
849
+ dataset.issues?.push(issue);
850
+ }
851
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
852
+ if (config$1.abortEarly) {
853
+ dataset.typed = false;
854
+ break;
855
+ }
856
+ }
857
+ if (!valueDataset.typed) dataset.typed = false;
858
+ dataset.value[key] = valueDataset.value;
859
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
860
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
861
+ _addIssue(this, "key", dataset, config$1, {
862
+ input: void 0,
863
+ expected: `"${key}"`,
864
+ path: [{
865
+ type: "object",
866
+ origin: "key",
867
+ input,
868
+ key,
869
+ value: input[key]
870
+ }]
871
+ });
872
+ if (config$1.abortEarly) break;
873
+ }
874
+ }
875
+ if (!dataset.issues || !config$1.abortEarly) {
876
+ for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
877
+ const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
878
+ if (valueDataset.issues) {
879
+ const pathItem = {
880
+ type: "object",
881
+ origin: "value",
882
+ input,
883
+ key,
884
+ value: input[key]
885
+ };
886
+ for (const issue of valueDataset.issues) {
887
+ if (issue.path) issue.path.unshift(pathItem);
888
+ else issue.path = [pathItem];
889
+ dataset.issues?.push(issue);
890
+ }
891
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
892
+ if (config$1.abortEarly) {
893
+ dataset.typed = false;
894
+ break;
895
+ }
896
+ }
897
+ if (!valueDataset.typed) dataset.typed = false;
898
+ dataset.value[key] = valueDataset.value;
899
+ }
900
+ }
901
+ } else _addIssue(this, "type", dataset, config$1);
902
+ return dataset;
903
+ }
904
+ });
905
+ }
906
+ __name(objectWithRest, "objectWithRest");
907
+ // @__NO_SIDE_EFFECTS__
908
+ function optional(wrapped, default_) {
909
+ return _standardSchema({
910
+ kind: "schema",
911
+ type: "optional",
912
+ reference: optional,
913
+ expects: `(${wrapped.expects} | undefined)`,
914
+ async: false,
915
+ wrapped,
916
+ default: default_,
917
+ "~run"(dataset, config$1) {
918
+ if (dataset.value === void 0) {
919
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
920
+ if (dataset.value === void 0) {
921
+ dataset.typed = true;
922
+ return dataset;
923
+ }
924
+ }
925
+ return this.wrapped["~run"](dataset, config$1);
926
+ }
927
+ });
928
+ }
929
+ __name(optional, "optional");
930
+ // @__NO_SIDE_EFFECTS__
931
+ function picklist(options, message$1) {
932
+ return _standardSchema({
933
+ kind: "schema",
934
+ type: "picklist",
935
+ reference: picklist,
936
+ expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
937
+ async: false,
938
+ options,
939
+ message: message$1,
940
+ "~run"(dataset, config$1) {
941
+ if (this.options.includes(dataset.value)) dataset.typed = true;
942
+ else _addIssue(this, "type", dataset, config$1);
943
+ return dataset;
944
+ }
945
+ });
946
+ }
947
+ __name(picklist, "picklist");
948
+ // @__NO_SIDE_EFFECTS__
949
+ function record(key, value$1, message$1) {
950
+ return _standardSchema({
951
+ kind: "schema",
952
+ type: "record",
953
+ reference: record,
954
+ expects: "Object",
955
+ async: false,
956
+ key,
957
+ value: value$1,
958
+ message: message$1,
959
+ "~run"(dataset, config$1) {
960
+ const input = dataset.value;
961
+ if (input && typeof input === "object") {
962
+ dataset.typed = true;
963
+ dataset.value = {};
964
+ for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
965
+ const entryValue = input[entryKey];
966
+ const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
967
+ if (keyDataset.issues) {
968
+ const pathItem = {
969
+ type: "object",
970
+ origin: "key",
971
+ input,
972
+ key: entryKey,
973
+ value: entryValue
974
+ };
975
+ for (const issue of keyDataset.issues) {
976
+ issue.path = [pathItem];
977
+ dataset.issues?.push(issue);
978
+ }
979
+ if (!dataset.issues) dataset.issues = keyDataset.issues;
980
+ if (config$1.abortEarly) {
981
+ dataset.typed = false;
982
+ break;
983
+ }
984
+ }
985
+ const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
986
+ if (valueDataset.issues) {
987
+ const pathItem = {
988
+ type: "object",
989
+ origin: "value",
990
+ input,
991
+ key: entryKey,
992
+ value: entryValue
993
+ };
994
+ for (const issue of valueDataset.issues) {
995
+ if (issue.path) issue.path.unshift(pathItem);
996
+ else issue.path = [pathItem];
997
+ dataset.issues?.push(issue);
998
+ }
999
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
1000
+ if (config$1.abortEarly) {
1001
+ dataset.typed = false;
1002
+ break;
1003
+ }
1004
+ }
1005
+ if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
1006
+ if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
1007
+ }
1008
+ } else _addIssue(this, "type", dataset, config$1);
1009
+ return dataset;
1010
+ }
1011
+ });
1012
+ }
1013
+ __name(record, "record");
1014
+ // @__NO_SIDE_EFFECTS__
1015
+ function strictObject(entries$1, message$1) {
1016
+ return _standardSchema({
1017
+ kind: "schema",
1018
+ type: "strict_object",
1019
+ reference: strictObject,
1020
+ expects: "Object",
1021
+ async: false,
1022
+ entries: entries$1,
1023
+ message: message$1,
1024
+ "~run"(dataset, config$1) {
1025
+ const input = dataset.value;
1026
+ if (input && typeof input === "object") {
1027
+ dataset.typed = true;
1028
+ dataset.value = {};
1029
+ for (const key in this.entries) {
1030
+ const valueSchema = this.entries[key];
1031
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
1032
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
1033
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
1034
+ if (valueDataset.issues) {
1035
+ const pathItem = {
1036
+ type: "object",
1037
+ origin: "value",
1038
+ input,
1039
+ key,
1040
+ value: value$1
1041
+ };
1042
+ for (const issue of valueDataset.issues) {
1043
+ if (issue.path) issue.path.unshift(pathItem);
1044
+ else issue.path = [pathItem];
1045
+ dataset.issues?.push(issue);
1046
+ }
1047
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
1048
+ if (config$1.abortEarly) {
1049
+ dataset.typed = false;
1050
+ break;
1051
+ }
1052
+ }
1053
+ if (!valueDataset.typed) dataset.typed = false;
1054
+ dataset.value[key] = valueDataset.value;
1055
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
1056
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
1057
+ _addIssue(this, "key", dataset, config$1, {
1058
+ input: void 0,
1059
+ expected: `"${key}"`,
1060
+ path: [{
1061
+ type: "object",
1062
+ origin: "key",
1063
+ input,
1064
+ key,
1065
+ value: input[key]
1066
+ }]
1067
+ });
1068
+ if (config$1.abortEarly) break;
1069
+ }
1070
+ }
1071
+ if (!dataset.issues || !config$1.abortEarly) {
1072
+ for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
1073
+ _addIssue(this, "key", dataset, config$1, {
1074
+ input: key,
1075
+ expected: "never",
1076
+ path: [{
1077
+ type: "object",
1078
+ origin: "key",
1079
+ input,
1080
+ key,
1081
+ value: input[key]
1082
+ }]
1083
+ });
1084
+ break;
1085
+ }
1086
+ }
1087
+ } else _addIssue(this, "type", dataset, config$1);
1088
+ return dataset;
1089
+ }
1090
+ });
1091
+ }
1092
+ __name(strictObject, "strictObject");
1093
+ // @__NO_SIDE_EFFECTS__
1094
+ function string(message$1) {
1095
+ return _standardSchema({
1096
+ kind: "schema",
1097
+ type: "string",
1098
+ reference: string,
1099
+ expects: "string",
1100
+ async: false,
1101
+ message: message$1,
1102
+ "~run"(dataset, config$1) {
1103
+ if (typeof dataset.value === "string") dataset.typed = true;
1104
+ else _addIssue(this, "type", dataset, config$1);
1105
+ return dataset;
1106
+ }
1107
+ });
1108
+ }
1109
+ __name(string, "string");
1110
+ // @__NO_SIDE_EFFECTS__
1111
+ function _subIssues(datasets) {
1112
+ let issues;
1113
+ if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
1114
+ else issues = dataset.issues;
1115
+ return issues;
1116
+ }
1117
+ __name(_subIssues, "_subIssues");
1118
+ // @__NO_SIDE_EFFECTS__
1119
+ function union(options, message$1) {
1120
+ return _standardSchema({
1121
+ kind: "schema",
1122
+ type: "union",
1123
+ reference: union,
1124
+ expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1125
+ async: false,
1126
+ options,
1127
+ message: message$1,
1128
+ "~run"(dataset, config$1) {
1129
+ let validDataset;
1130
+ let typedDatasets;
1131
+ let untypedDatasets;
1132
+ for (const schema of this.options) {
1133
+ const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
1134
+ if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
1135
+ else typedDatasets = [optionDataset];
1136
+ else {
1137
+ validDataset = optionDataset;
1138
+ break;
1139
+ }
1140
+ else if (untypedDatasets) untypedDatasets.push(optionDataset);
1141
+ else untypedDatasets = [optionDataset];
1142
+ }
1143
+ if (validDataset) return validDataset;
1144
+ if (typedDatasets) {
1145
+ if (typedDatasets.length === 1) return typedDatasets[0];
1146
+ _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
1147
+ dataset.typed = true;
1148
+ } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
1149
+ else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
1150
+ return dataset;
1151
+ }
1152
+ });
1153
+ }
1154
+ __name(union, "union");
1155
+ // @__NO_SIDE_EFFECTS__
1156
+ function unknown() {
1157
+ return _standardSchema({
1158
+ kind: "schema",
1159
+ type: "unknown",
1160
+ reference: unknown,
1161
+ expects: "unknown",
1162
+ async: false,
1163
+ "~run"(dataset) {
1164
+ dataset.typed = true;
1165
+ return dataset;
1166
+ }
1167
+ });
1168
+ }
1169
+ __name(unknown, "unknown");
1170
+ // @__NO_SIDE_EFFECTS__
1171
+ function variant(key, options, message$1) {
1172
+ return _standardSchema({
1173
+ kind: "schema",
1174
+ type: "variant",
1175
+ reference: variant,
1176
+ expects: "Object",
1177
+ async: false,
1178
+ key,
1179
+ options,
1180
+ message: message$1,
1181
+ "~run"(dataset, config$1) {
1182
+ const input = dataset.value;
1183
+ if (input && typeof input === "object") {
1184
+ let outputDataset;
1185
+ let maxDiscriminatorPriority = 0;
1186
+ let invalidDiscriminatorKey = this.key;
1187
+ let expectedDiscriminators = [];
1188
+ const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
1189
+ for (const schema of variant$1.options) {
1190
+ if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
1191
+ else {
1192
+ let keysAreValid = true;
1193
+ let currentPriority = 0;
1194
+ for (const currentKey of allKeys) {
1195
+ const discriminatorSchema = schema.entries[currentKey];
1196
+ if (currentKey in input ? discriminatorSchema["~run"]({
1197
+ typed: false,
1198
+ value: input[currentKey]
1199
+ }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
1200
+ keysAreValid = false;
1201
+ if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
1202
+ maxDiscriminatorPriority = currentPriority;
1203
+ invalidDiscriminatorKey = currentKey;
1204
+ expectedDiscriminators = [];
1205
+ }
1206
+ if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
1207
+ break;
1208
+ }
1209
+ currentPriority++;
1210
+ }
1211
+ if (keysAreValid) {
1212
+ const optionDataset = schema["~run"]({ value: input }, config$1);
1213
+ if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
1214
+ }
1215
+ }
1216
+ if (outputDataset && !outputDataset.issues) break;
1217
+ }
1218
+ }, "parseOptions");
1219
+ parseOptions(this, /* @__PURE__ */ new Set([this.key]));
1220
+ if (outputDataset) return outputDataset;
1221
+ _addIssue(this, "type", dataset, config$1, {
1222
+ input: input[invalidDiscriminatorKey],
1223
+ expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
1224
+ path: [{
1225
+ type: "object",
1226
+ origin: "value",
1227
+ input,
1228
+ key: invalidDiscriminatorKey,
1229
+ value: input[invalidDiscriminatorKey]
1230
+ }]
1231
+ });
1232
+ } else _addIssue(this, "type", dataset, config$1);
1233
+ return dataset;
1234
+ }
1235
+ });
1236
+ }
1237
+ __name(variant, "variant");
1238
+ // @__NO_SIDE_EFFECTS__
1239
+ function omit(schema, keys) {
1240
+ const entries$1 = { ...schema.entries };
1241
+ for (const key of keys) delete entries$1[key];
1242
+ return _standardSchema({
1243
+ ...schema,
1244
+ entries: entries$1
1245
+ });
1246
+ }
1247
+ __name(omit, "omit");
1248
+ function parse(schema, input, config$1) {
1249
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1250
+ if (dataset.issues) throw new ValiError(dataset.issues);
1251
+ return dataset.value;
1252
+ }
1253
+ __name(parse, "parse");
1254
+ // @__NO_SIDE_EFFECTS__
1255
+ function partial(schema, keys) {
1256
+ const entries$1 = {};
1257
+ for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
1258
+ return _standardSchema({
1259
+ ...schema,
1260
+ entries: entries$1
1261
+ });
1262
+ }
1263
+ __name(partial, "partial");
1264
+ // @__NO_SIDE_EFFECTS__
1265
+ function pick(schema, keys) {
1266
+ const entries$1 = {};
1267
+ for (const key of keys) entries$1[key] = schema.entries[key];
1268
+ return _standardSchema({
1269
+ ...schema,
1270
+ entries: entries$1
1271
+ });
1272
+ }
1273
+ __name(pick, "pick");
1274
+ // @__NO_SIDE_EFFECTS__
1275
+ function pipe(...pipe$1) {
1276
+ return _standardSchema({
1277
+ ...pipe$1[0],
1278
+ pipe: pipe$1,
1279
+ "~run"(dataset, config$1) {
1280
+ for (const item of pipe$1) if (item.kind !== "metadata") {
1281
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
1282
+ dataset.typed = false;
1283
+ break;
1284
+ }
1285
+ if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
1286
+ }
1287
+ return dataset;
1288
+ }
1289
+ });
1290
+ }
1291
+ __name(pipe, "pipe");
1292
+ // @__NO_SIDE_EFFECTS__
1293
+ function safeParse(schema, input, config$1) {
1294
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1295
+ return {
1296
+ typed: dataset.typed,
1297
+ success: !dataset.issues,
1298
+ output: dataset.value,
1299
+ issues: dataset.issues
1300
+ };
1301
+ }
1302
+ __name(safeParse, "safeParse");
1303
+ // @__NO_SIDE_EFFECTS__
1304
+ function summarize(issues) {
1305
+ let summary = "";
1306
+ for (const issue of issues) {
1307
+ if (summary) summary += "\n";
1308
+ summary += `\xD7 ${issue.message}`;
1309
+ const dotPath = /* @__PURE__ */ getDotPath(issue);
1310
+ if (dotPath) summary += `
1311
+ \u2192 at ${dotPath}`;
1312
+ }
1313
+ return summary;
1314
+ }
1315
+ __name(summarize, "summarize");
1316
+ // @__NO_SIDE_EFFECTS__
1317
+ function unwrap(schema) {
1318
+ return schema.wrapped;
1319
+ }
1320
+ __name(unwrap, "unwrap");
1321
+
1322
+ export {
1323
+ getDotPath,
1324
+ check,
1325
+ description,
1326
+ endsWith,
1327
+ finite,
1328
+ integer,
1329
+ isoDate,
1330
+ isoTimestamp,
1331
+ maxLength,
1332
+ maxValue,
1333
+ minLength,
1334
+ minValue,
1335
+ nonEmpty,
1336
+ regex,
1337
+ safeInteger,
1338
+ startsWith,
1339
+ transform,
1340
+ trim,
1341
+ url,
1342
+ forward,
1343
+ array,
1344
+ boolean,
1345
+ custom,
1346
+ exactOptional,
1347
+ lazy,
1348
+ literal,
1349
+ looseObject,
1350
+ null_,
1351
+ nullable,
1352
+ nullish,
1353
+ number,
1354
+ object,
1355
+ objectWithRest,
1356
+ optional,
1357
+ picklist,
1358
+ record,
1359
+ strictObject,
1360
+ string,
1361
+ union,
1362
+ unknown,
1363
+ variant,
1364
+ omit,
1365
+ parse,
1366
+ partial,
1367
+ pick,
1368
+ pipe,
1369
+ safeParse,
1370
+ summarize,
1371
+ unwrap
1372
+ };