@wise/dynamic-flow-types 2.11.0 → 2.12.0-experimental-b041af5

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.
package/build/main.mjs ADDED
@@ -0,0 +1,4490 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
22
+ var util;
23
+ (function(util2) {
24
+ util2.assertEqual = (val) => val;
25
+ function assertIs(_arg) {
26
+ }
27
+ util2.assertIs = assertIs;
28
+ function assertNever(_x) {
29
+ throw new Error();
30
+ }
31
+ util2.assertNever = assertNever;
32
+ util2.arrayToEnum = (items) => {
33
+ const obj = {};
34
+ for (const item of items) {
35
+ obj[item] = item;
36
+ }
37
+ return obj;
38
+ };
39
+ util2.getValidEnumValues = (obj) => {
40
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
41
+ const filtered = {};
42
+ for (const k of validKeys) {
43
+ filtered[k] = obj[k];
44
+ }
45
+ return util2.objectValues(filtered);
46
+ };
47
+ util2.objectValues = (obj) => {
48
+ return util2.objectKeys(obj).map(function(e) {
49
+ return obj[e];
50
+ });
51
+ };
52
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
53
+ const keys = [];
54
+ for (const key in object) {
55
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
56
+ keys.push(key);
57
+ }
58
+ }
59
+ return keys;
60
+ };
61
+ util2.find = (arr, checker) => {
62
+ for (const item of arr) {
63
+ if (checker(item))
64
+ return item;
65
+ }
66
+ return void 0;
67
+ };
68
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
69
+ function joinValues(array, separator = " | ") {
70
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
71
+ }
72
+ util2.joinValues = joinValues;
73
+ util2.jsonStringifyReplacer = (_, value) => {
74
+ if (typeof value === "bigint") {
75
+ return value.toString();
76
+ }
77
+ return value;
78
+ };
79
+ })(util || (util = {}));
80
+ var objectUtil;
81
+ (function(objectUtil2) {
82
+ objectUtil2.mergeShapes = (first, second) => {
83
+ return __spreadValues(__spreadValues({}, first), second);
84
+ };
85
+ })(objectUtil || (objectUtil = {}));
86
+ var ZodParsedType = util.arrayToEnum([
87
+ "string",
88
+ "nan",
89
+ "number",
90
+ "integer",
91
+ "float",
92
+ "boolean",
93
+ "date",
94
+ "bigint",
95
+ "symbol",
96
+ "function",
97
+ "undefined",
98
+ "null",
99
+ "array",
100
+ "object",
101
+ "unknown",
102
+ "promise",
103
+ "void",
104
+ "never",
105
+ "map",
106
+ "set"
107
+ ]);
108
+ var getParsedType = (data) => {
109
+ const t = typeof data;
110
+ switch (t) {
111
+ case "undefined":
112
+ return ZodParsedType.undefined;
113
+ case "string":
114
+ return ZodParsedType.string;
115
+ case "number":
116
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
117
+ case "boolean":
118
+ return ZodParsedType.boolean;
119
+ case "function":
120
+ return ZodParsedType.function;
121
+ case "bigint":
122
+ return ZodParsedType.bigint;
123
+ case "symbol":
124
+ return ZodParsedType.symbol;
125
+ case "object":
126
+ if (Array.isArray(data)) {
127
+ return ZodParsedType.array;
128
+ }
129
+ if (data === null) {
130
+ return ZodParsedType.null;
131
+ }
132
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
133
+ return ZodParsedType.promise;
134
+ }
135
+ if (typeof Map !== "undefined" && data instanceof Map) {
136
+ return ZodParsedType.map;
137
+ }
138
+ if (typeof Set !== "undefined" && data instanceof Set) {
139
+ return ZodParsedType.set;
140
+ }
141
+ if (typeof Date !== "undefined" && data instanceof Date) {
142
+ return ZodParsedType.date;
143
+ }
144
+ return ZodParsedType.object;
145
+ default:
146
+ return ZodParsedType.unknown;
147
+ }
148
+ };
149
+ var ZodIssueCode = util.arrayToEnum([
150
+ "invalid_type",
151
+ "invalid_literal",
152
+ "custom",
153
+ "invalid_union",
154
+ "invalid_union_discriminator",
155
+ "invalid_enum_value",
156
+ "unrecognized_keys",
157
+ "invalid_arguments",
158
+ "invalid_return_type",
159
+ "invalid_date",
160
+ "invalid_string",
161
+ "too_small",
162
+ "too_big",
163
+ "invalid_intersection_types",
164
+ "not_multiple_of",
165
+ "not_finite"
166
+ ]);
167
+ var quotelessJson = (obj) => {
168
+ const json = JSON.stringify(obj, null, 2);
169
+ return json.replace(/"([^"]+)":/g, "$1:");
170
+ };
171
+ var ZodError = class extends Error {
172
+ constructor(issues) {
173
+ super();
174
+ this.issues = [];
175
+ this.addIssue = (sub) => {
176
+ this.issues = [...this.issues, sub];
177
+ };
178
+ this.addIssues = (subs = []) => {
179
+ this.issues = [...this.issues, ...subs];
180
+ };
181
+ const actualProto = new.target.prototype;
182
+ if (Object.setPrototypeOf) {
183
+ Object.setPrototypeOf(this, actualProto);
184
+ } else {
185
+ this.__proto__ = actualProto;
186
+ }
187
+ this.name = "ZodError";
188
+ this.issues = issues;
189
+ }
190
+ get errors() {
191
+ return this.issues;
192
+ }
193
+ format(_mapper) {
194
+ const mapper = _mapper || function(issue) {
195
+ return issue.message;
196
+ };
197
+ const fieldErrors = { _errors: [] };
198
+ const processError = (error) => {
199
+ for (const issue of error.issues) {
200
+ if (issue.code === "invalid_union") {
201
+ issue.unionErrors.map(processError);
202
+ } else if (issue.code === "invalid_return_type") {
203
+ processError(issue.returnTypeError);
204
+ } else if (issue.code === "invalid_arguments") {
205
+ processError(issue.argumentsError);
206
+ } else if (issue.path.length === 0) {
207
+ fieldErrors._errors.push(mapper(issue));
208
+ } else {
209
+ let curr = fieldErrors;
210
+ let i = 0;
211
+ while (i < issue.path.length) {
212
+ const el = issue.path[i];
213
+ const terminal = i === issue.path.length - 1;
214
+ if (!terminal) {
215
+ curr[el] = curr[el] || { _errors: [] };
216
+ } else {
217
+ curr[el] = curr[el] || { _errors: [] };
218
+ curr[el]._errors.push(mapper(issue));
219
+ }
220
+ curr = curr[el];
221
+ i++;
222
+ }
223
+ }
224
+ }
225
+ };
226
+ processError(this);
227
+ return fieldErrors;
228
+ }
229
+ toString() {
230
+ return this.message;
231
+ }
232
+ get message() {
233
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
234
+ }
235
+ get isEmpty() {
236
+ return this.issues.length === 0;
237
+ }
238
+ flatten(mapper = (issue) => issue.message) {
239
+ const fieldErrors = {};
240
+ const formErrors = [];
241
+ for (const sub of this.issues) {
242
+ if (sub.path.length > 0) {
243
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
244
+ fieldErrors[sub.path[0]].push(mapper(sub));
245
+ } else {
246
+ formErrors.push(mapper(sub));
247
+ }
248
+ }
249
+ return { formErrors, fieldErrors };
250
+ }
251
+ get formErrors() {
252
+ return this.flatten();
253
+ }
254
+ };
255
+ ZodError.create = (issues) => {
256
+ const error = new ZodError(issues);
257
+ return error;
258
+ };
259
+ var errorMap = (issue, _ctx) => {
260
+ let message;
261
+ switch (issue.code) {
262
+ case ZodIssueCode.invalid_type:
263
+ if (issue.received === ZodParsedType.undefined) {
264
+ message = "Required";
265
+ } else {
266
+ message = `Expected ${issue.expected}, received ${issue.received}`;
267
+ }
268
+ break;
269
+ case ZodIssueCode.invalid_literal:
270
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
271
+ break;
272
+ case ZodIssueCode.unrecognized_keys:
273
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
274
+ break;
275
+ case ZodIssueCode.invalid_union:
276
+ message = `Invalid input`;
277
+ break;
278
+ case ZodIssueCode.invalid_union_discriminator:
279
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
280
+ break;
281
+ case ZodIssueCode.invalid_enum_value:
282
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
283
+ break;
284
+ case ZodIssueCode.invalid_arguments:
285
+ message = `Invalid function arguments`;
286
+ break;
287
+ case ZodIssueCode.invalid_return_type:
288
+ message = `Invalid function return type`;
289
+ break;
290
+ case ZodIssueCode.invalid_date:
291
+ message = `Invalid date`;
292
+ break;
293
+ case ZodIssueCode.invalid_string:
294
+ if (typeof issue.validation === "object") {
295
+ if ("includes" in issue.validation) {
296
+ message = `Invalid input: must include "${issue.validation.includes}"`;
297
+ if (typeof issue.validation.position === "number") {
298
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
299
+ }
300
+ } else if ("startsWith" in issue.validation) {
301
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
302
+ } else if ("endsWith" in issue.validation) {
303
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
304
+ } else {
305
+ util.assertNever(issue.validation);
306
+ }
307
+ } else if (issue.validation !== "regex") {
308
+ message = `Invalid ${issue.validation}`;
309
+ } else {
310
+ message = "Invalid";
311
+ }
312
+ break;
313
+ case ZodIssueCode.too_small:
314
+ if (issue.type === "array")
315
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
316
+ else if (issue.type === "string")
317
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
318
+ else if (issue.type === "number")
319
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
320
+ else if (issue.type === "date")
321
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
322
+ else
323
+ message = "Invalid input";
324
+ break;
325
+ case ZodIssueCode.too_big:
326
+ if (issue.type === "array")
327
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
328
+ else if (issue.type === "string")
329
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
330
+ else if (issue.type === "number")
331
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
332
+ else if (issue.type === "bigint")
333
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
334
+ else if (issue.type === "date")
335
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
336
+ else
337
+ message = "Invalid input";
338
+ break;
339
+ case ZodIssueCode.custom:
340
+ message = `Invalid input`;
341
+ break;
342
+ case ZodIssueCode.invalid_intersection_types:
343
+ message = `Intersection results could not be merged`;
344
+ break;
345
+ case ZodIssueCode.not_multiple_of:
346
+ message = `Number must be a multiple of ${issue.multipleOf}`;
347
+ break;
348
+ case ZodIssueCode.not_finite:
349
+ message = "Number must be finite";
350
+ break;
351
+ default:
352
+ message = _ctx.defaultError;
353
+ util.assertNever(issue);
354
+ }
355
+ return { message };
356
+ };
357
+ var overrideErrorMap = errorMap;
358
+ function setErrorMap(map) {
359
+ overrideErrorMap = map;
360
+ }
361
+ function getErrorMap() {
362
+ return overrideErrorMap;
363
+ }
364
+ var makeIssue = (params) => {
365
+ const { data, path, errorMaps, issueData } = params;
366
+ const fullPath = [...path, ...issueData.path || []];
367
+ const fullIssue = __spreadProps(__spreadValues({}, issueData), {
368
+ path: fullPath
369
+ });
370
+ let errorMessage = "";
371
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
372
+ for (const map of maps) {
373
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
374
+ }
375
+ return __spreadProps(__spreadValues({}, issueData), {
376
+ path: fullPath,
377
+ message: issueData.message || errorMessage
378
+ });
379
+ };
380
+ var EMPTY_PATH = [];
381
+ function addIssueToContext(ctx, issueData) {
382
+ const issue = makeIssue({
383
+ issueData,
384
+ data: ctx.data,
385
+ path: ctx.path,
386
+ errorMaps: [
387
+ ctx.common.contextualErrorMap,
388
+ ctx.schemaErrorMap,
389
+ getErrorMap(),
390
+ errorMap
391
+ // then global default map
392
+ ].filter((x) => !!x)
393
+ });
394
+ ctx.common.issues.push(issue);
395
+ }
396
+ var ParseStatus = class _ParseStatus {
397
+ constructor() {
398
+ this.value = "valid";
399
+ }
400
+ dirty() {
401
+ if (this.value === "valid")
402
+ this.value = "dirty";
403
+ }
404
+ abort() {
405
+ if (this.value !== "aborted")
406
+ this.value = "aborted";
407
+ }
408
+ static mergeArray(status, results) {
409
+ const arrayValue = [];
410
+ for (const s of results) {
411
+ if (s.status === "aborted")
412
+ return INVALID;
413
+ if (s.status === "dirty")
414
+ status.dirty();
415
+ arrayValue.push(s.value);
416
+ }
417
+ return { status: status.value, value: arrayValue };
418
+ }
419
+ static async mergeObjectAsync(status, pairs) {
420
+ const syncPairs = [];
421
+ for (const pair of pairs) {
422
+ syncPairs.push({
423
+ key: await pair.key,
424
+ value: await pair.value
425
+ });
426
+ }
427
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
428
+ }
429
+ static mergeObjectSync(status, pairs) {
430
+ const finalObject = {};
431
+ for (const pair of pairs) {
432
+ const { key, value } = pair;
433
+ if (key.status === "aborted")
434
+ return INVALID;
435
+ if (value.status === "aborted")
436
+ return INVALID;
437
+ if (key.status === "dirty")
438
+ status.dirty();
439
+ if (value.status === "dirty")
440
+ status.dirty();
441
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
442
+ finalObject[key.value] = value.value;
443
+ }
444
+ }
445
+ return { status: status.value, value: finalObject };
446
+ }
447
+ };
448
+ var INVALID = Object.freeze({
449
+ status: "aborted"
450
+ });
451
+ var DIRTY = (value) => ({ status: "dirty", value });
452
+ var OK = (value) => ({ status: "valid", value });
453
+ var isAborted = (x) => x.status === "aborted";
454
+ var isDirty = (x) => x.status === "dirty";
455
+ var isValid = (x) => x.status === "valid";
456
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
457
+ var errorUtil;
458
+ (function(errorUtil2) {
459
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
460
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
461
+ })(errorUtil || (errorUtil = {}));
462
+ var ParseInputLazyPath = class {
463
+ constructor(parent, value, path, key) {
464
+ this._cachedPath = [];
465
+ this.parent = parent;
466
+ this.data = value;
467
+ this._path = path;
468
+ this._key = key;
469
+ }
470
+ get path() {
471
+ if (!this._cachedPath.length) {
472
+ if (this._key instanceof Array) {
473
+ this._cachedPath.push(...this._path, ...this._key);
474
+ } else {
475
+ this._cachedPath.push(...this._path, this._key);
476
+ }
477
+ }
478
+ return this._cachedPath;
479
+ }
480
+ };
481
+ var handleResult = (ctx, result) => {
482
+ if (isValid(result)) {
483
+ return { success: true, data: result.value };
484
+ } else {
485
+ if (!ctx.common.issues.length) {
486
+ throw new Error("Validation failed but no issues detected.");
487
+ }
488
+ return {
489
+ success: false,
490
+ get error() {
491
+ if (this._error)
492
+ return this._error;
493
+ const error = new ZodError(ctx.common.issues);
494
+ this._error = error;
495
+ return this._error;
496
+ }
497
+ };
498
+ }
499
+ };
500
+ function processCreateParams(params) {
501
+ if (!params)
502
+ return {};
503
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
504
+ if (errorMap2 && (invalid_type_error || required_error)) {
505
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
506
+ }
507
+ if (errorMap2)
508
+ return { errorMap: errorMap2, description };
509
+ const customMap = (iss, ctx) => {
510
+ if (iss.code !== "invalid_type")
511
+ return { message: ctx.defaultError };
512
+ if (typeof ctx.data === "undefined") {
513
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
514
+ }
515
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
516
+ };
517
+ return { errorMap: customMap, description };
518
+ }
519
+ var ZodType = class {
520
+ constructor(def) {
521
+ this.spa = this.safeParseAsync;
522
+ this._def = def;
523
+ this.parse = this.parse.bind(this);
524
+ this.safeParse = this.safeParse.bind(this);
525
+ this.parseAsync = this.parseAsync.bind(this);
526
+ this.safeParseAsync = this.safeParseAsync.bind(this);
527
+ this.spa = this.spa.bind(this);
528
+ this.refine = this.refine.bind(this);
529
+ this.refinement = this.refinement.bind(this);
530
+ this.superRefine = this.superRefine.bind(this);
531
+ this.optional = this.optional.bind(this);
532
+ this.nullable = this.nullable.bind(this);
533
+ this.nullish = this.nullish.bind(this);
534
+ this.array = this.array.bind(this);
535
+ this.promise = this.promise.bind(this);
536
+ this.or = this.or.bind(this);
537
+ this.and = this.and.bind(this);
538
+ this.transform = this.transform.bind(this);
539
+ this.brand = this.brand.bind(this);
540
+ this.default = this.default.bind(this);
541
+ this.catch = this.catch.bind(this);
542
+ this.describe = this.describe.bind(this);
543
+ this.pipe = this.pipe.bind(this);
544
+ this.readonly = this.readonly.bind(this);
545
+ this.isNullable = this.isNullable.bind(this);
546
+ this.isOptional = this.isOptional.bind(this);
547
+ }
548
+ get description() {
549
+ return this._def.description;
550
+ }
551
+ _getType(input) {
552
+ return getParsedType(input.data);
553
+ }
554
+ _getOrReturnCtx(input, ctx) {
555
+ return ctx || {
556
+ common: input.parent.common,
557
+ data: input.data,
558
+ parsedType: getParsedType(input.data),
559
+ schemaErrorMap: this._def.errorMap,
560
+ path: input.path,
561
+ parent: input.parent
562
+ };
563
+ }
564
+ _processInputParams(input) {
565
+ return {
566
+ status: new ParseStatus(),
567
+ ctx: {
568
+ common: input.parent.common,
569
+ data: input.data,
570
+ parsedType: getParsedType(input.data),
571
+ schemaErrorMap: this._def.errorMap,
572
+ path: input.path,
573
+ parent: input.parent
574
+ }
575
+ };
576
+ }
577
+ _parseSync(input) {
578
+ const result = this._parse(input);
579
+ if (isAsync(result)) {
580
+ throw new Error("Synchronous parse encountered promise.");
581
+ }
582
+ return result;
583
+ }
584
+ _parseAsync(input) {
585
+ const result = this._parse(input);
586
+ return Promise.resolve(result);
587
+ }
588
+ parse(data, params) {
589
+ const result = this.safeParse(data, params);
590
+ if (result.success)
591
+ return result.data;
592
+ throw result.error;
593
+ }
594
+ safeParse(data, params) {
595
+ var _a;
596
+ const ctx = {
597
+ common: {
598
+ issues: [],
599
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
600
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
601
+ },
602
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
603
+ schemaErrorMap: this._def.errorMap,
604
+ parent: null,
605
+ data,
606
+ parsedType: getParsedType(data)
607
+ };
608
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
609
+ return handleResult(ctx, result);
610
+ }
611
+ async parseAsync(data, params) {
612
+ const result = await this.safeParseAsync(data, params);
613
+ if (result.success)
614
+ return result.data;
615
+ throw result.error;
616
+ }
617
+ async safeParseAsync(data, params) {
618
+ const ctx = {
619
+ common: {
620
+ issues: [],
621
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
622
+ async: true
623
+ },
624
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
625
+ schemaErrorMap: this._def.errorMap,
626
+ parent: null,
627
+ data,
628
+ parsedType: getParsedType(data)
629
+ };
630
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
631
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
632
+ return handleResult(ctx, result);
633
+ }
634
+ refine(check, message) {
635
+ const getIssueProperties = (val) => {
636
+ if (typeof message === "string" || typeof message === "undefined") {
637
+ return { message };
638
+ } else if (typeof message === "function") {
639
+ return message(val);
640
+ } else {
641
+ return message;
642
+ }
643
+ };
644
+ return this._refinement((val, ctx) => {
645
+ const result = check(val);
646
+ const setError = () => ctx.addIssue(__spreadValues({
647
+ code: ZodIssueCode.custom
648
+ }, getIssueProperties(val)));
649
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
650
+ return result.then((data) => {
651
+ if (!data) {
652
+ setError();
653
+ return false;
654
+ } else {
655
+ return true;
656
+ }
657
+ });
658
+ }
659
+ if (!result) {
660
+ setError();
661
+ return false;
662
+ } else {
663
+ return true;
664
+ }
665
+ });
666
+ }
667
+ refinement(check, refinementData) {
668
+ return this._refinement((val, ctx) => {
669
+ if (!check(val)) {
670
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
671
+ return false;
672
+ } else {
673
+ return true;
674
+ }
675
+ });
676
+ }
677
+ _refinement(refinement) {
678
+ return new ZodEffects({
679
+ schema: this,
680
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
681
+ effect: { type: "refinement", refinement }
682
+ });
683
+ }
684
+ superRefine(refinement) {
685
+ return this._refinement(refinement);
686
+ }
687
+ optional() {
688
+ return ZodOptional.create(this, this._def);
689
+ }
690
+ nullable() {
691
+ return ZodNullable.create(this, this._def);
692
+ }
693
+ nullish() {
694
+ return this.nullable().optional();
695
+ }
696
+ array() {
697
+ return ZodArray.create(this, this._def);
698
+ }
699
+ promise() {
700
+ return ZodPromise.create(this, this._def);
701
+ }
702
+ or(option) {
703
+ return ZodUnion.create([this, option], this._def);
704
+ }
705
+ and(incoming) {
706
+ return ZodIntersection.create(this, incoming, this._def);
707
+ }
708
+ transform(transform) {
709
+ return new ZodEffects(__spreadProps(__spreadValues({}, processCreateParams(this._def)), {
710
+ schema: this,
711
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
712
+ effect: { type: "transform", transform }
713
+ }));
714
+ }
715
+ default(def) {
716
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
717
+ return new ZodDefault(__spreadProps(__spreadValues({}, processCreateParams(this._def)), {
718
+ innerType: this,
719
+ defaultValue: defaultValueFunc,
720
+ typeName: ZodFirstPartyTypeKind.ZodDefault
721
+ }));
722
+ }
723
+ brand() {
724
+ return new ZodBranded(__spreadValues({
725
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
726
+ type: this
727
+ }, processCreateParams(this._def)));
728
+ }
729
+ catch(def) {
730
+ const catchValueFunc = typeof def === "function" ? def : () => def;
731
+ return new ZodCatch(__spreadProps(__spreadValues({}, processCreateParams(this._def)), {
732
+ innerType: this,
733
+ catchValue: catchValueFunc,
734
+ typeName: ZodFirstPartyTypeKind.ZodCatch
735
+ }));
736
+ }
737
+ describe(description) {
738
+ const This = this.constructor;
739
+ return new This(__spreadProps(__spreadValues({}, this._def), {
740
+ description
741
+ }));
742
+ }
743
+ pipe(target) {
744
+ return ZodPipeline.create(this, target);
745
+ }
746
+ readonly() {
747
+ return ZodReadonly.create(this);
748
+ }
749
+ isOptional() {
750
+ return this.safeParse(void 0).success;
751
+ }
752
+ isNullable() {
753
+ return this.safeParse(null).success;
754
+ }
755
+ };
756
+ var cuidRegex = /^c[^\s-]{8,}$/i;
757
+ var cuid2Regex = /^[a-z][a-z0-9]*$/;
758
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
759
+ var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
760
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
761
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
762
+ var emojiRegex;
763
+ var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
764
+ var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
765
+ var datetimeRegex = (args) => {
766
+ if (args.precision) {
767
+ if (args.offset) {
768
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
769
+ } else {
770
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
771
+ }
772
+ } else if (args.precision === 0) {
773
+ if (args.offset) {
774
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
775
+ } else {
776
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
777
+ }
778
+ } else {
779
+ if (args.offset) {
780
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
781
+ } else {
782
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
783
+ }
784
+ }
785
+ };
786
+ function isValidIP(ip, version) {
787
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
788
+ return true;
789
+ }
790
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
791
+ return true;
792
+ }
793
+ return false;
794
+ }
795
+ var ZodString = class _ZodString extends ZodType {
796
+ _parse(input) {
797
+ if (this._def.coerce) {
798
+ input.data = String(input.data);
799
+ }
800
+ const parsedType = this._getType(input);
801
+ if (parsedType !== ZodParsedType.string) {
802
+ const ctx2 = this._getOrReturnCtx(input);
803
+ addIssueToContext(
804
+ ctx2,
805
+ {
806
+ code: ZodIssueCode.invalid_type,
807
+ expected: ZodParsedType.string,
808
+ received: ctx2.parsedType
809
+ }
810
+ //
811
+ );
812
+ return INVALID;
813
+ }
814
+ const status = new ParseStatus();
815
+ let ctx = void 0;
816
+ for (const check of this._def.checks) {
817
+ if (check.kind === "min") {
818
+ if (input.data.length < check.value) {
819
+ ctx = this._getOrReturnCtx(input, ctx);
820
+ addIssueToContext(ctx, {
821
+ code: ZodIssueCode.too_small,
822
+ minimum: check.value,
823
+ type: "string",
824
+ inclusive: true,
825
+ exact: false,
826
+ message: check.message
827
+ });
828
+ status.dirty();
829
+ }
830
+ } else if (check.kind === "max") {
831
+ if (input.data.length > check.value) {
832
+ ctx = this._getOrReturnCtx(input, ctx);
833
+ addIssueToContext(ctx, {
834
+ code: ZodIssueCode.too_big,
835
+ maximum: check.value,
836
+ type: "string",
837
+ inclusive: true,
838
+ exact: false,
839
+ message: check.message
840
+ });
841
+ status.dirty();
842
+ }
843
+ } else if (check.kind === "length") {
844
+ const tooBig = input.data.length > check.value;
845
+ const tooSmall = input.data.length < check.value;
846
+ if (tooBig || tooSmall) {
847
+ ctx = this._getOrReturnCtx(input, ctx);
848
+ if (tooBig) {
849
+ addIssueToContext(ctx, {
850
+ code: ZodIssueCode.too_big,
851
+ maximum: check.value,
852
+ type: "string",
853
+ inclusive: true,
854
+ exact: true,
855
+ message: check.message
856
+ });
857
+ } else if (tooSmall) {
858
+ addIssueToContext(ctx, {
859
+ code: ZodIssueCode.too_small,
860
+ minimum: check.value,
861
+ type: "string",
862
+ inclusive: true,
863
+ exact: true,
864
+ message: check.message
865
+ });
866
+ }
867
+ status.dirty();
868
+ }
869
+ } else if (check.kind === "email") {
870
+ if (!emailRegex.test(input.data)) {
871
+ ctx = this._getOrReturnCtx(input, ctx);
872
+ addIssueToContext(ctx, {
873
+ validation: "email",
874
+ code: ZodIssueCode.invalid_string,
875
+ message: check.message
876
+ });
877
+ status.dirty();
878
+ }
879
+ } else if (check.kind === "emoji") {
880
+ if (!emojiRegex) {
881
+ emojiRegex = new RegExp(_emojiRegex, "u");
882
+ }
883
+ if (!emojiRegex.test(input.data)) {
884
+ ctx = this._getOrReturnCtx(input, ctx);
885
+ addIssueToContext(ctx, {
886
+ validation: "emoji",
887
+ code: ZodIssueCode.invalid_string,
888
+ message: check.message
889
+ });
890
+ status.dirty();
891
+ }
892
+ } else if (check.kind === "uuid") {
893
+ if (!uuidRegex.test(input.data)) {
894
+ ctx = this._getOrReturnCtx(input, ctx);
895
+ addIssueToContext(ctx, {
896
+ validation: "uuid",
897
+ code: ZodIssueCode.invalid_string,
898
+ message: check.message
899
+ });
900
+ status.dirty();
901
+ }
902
+ } else if (check.kind === "cuid") {
903
+ if (!cuidRegex.test(input.data)) {
904
+ ctx = this._getOrReturnCtx(input, ctx);
905
+ addIssueToContext(ctx, {
906
+ validation: "cuid",
907
+ code: ZodIssueCode.invalid_string,
908
+ message: check.message
909
+ });
910
+ status.dirty();
911
+ }
912
+ } else if (check.kind === "cuid2") {
913
+ if (!cuid2Regex.test(input.data)) {
914
+ ctx = this._getOrReturnCtx(input, ctx);
915
+ addIssueToContext(ctx, {
916
+ validation: "cuid2",
917
+ code: ZodIssueCode.invalid_string,
918
+ message: check.message
919
+ });
920
+ status.dirty();
921
+ }
922
+ } else if (check.kind === "ulid") {
923
+ if (!ulidRegex.test(input.data)) {
924
+ ctx = this._getOrReturnCtx(input, ctx);
925
+ addIssueToContext(ctx, {
926
+ validation: "ulid",
927
+ code: ZodIssueCode.invalid_string,
928
+ message: check.message
929
+ });
930
+ status.dirty();
931
+ }
932
+ } else if (check.kind === "url") {
933
+ try {
934
+ new URL(input.data);
935
+ } catch (_a) {
936
+ ctx = this._getOrReturnCtx(input, ctx);
937
+ addIssueToContext(ctx, {
938
+ validation: "url",
939
+ code: ZodIssueCode.invalid_string,
940
+ message: check.message
941
+ });
942
+ status.dirty();
943
+ }
944
+ } else if (check.kind === "regex") {
945
+ check.regex.lastIndex = 0;
946
+ const testResult = check.regex.test(input.data);
947
+ if (!testResult) {
948
+ ctx = this._getOrReturnCtx(input, ctx);
949
+ addIssueToContext(ctx, {
950
+ validation: "regex",
951
+ code: ZodIssueCode.invalid_string,
952
+ message: check.message
953
+ });
954
+ status.dirty();
955
+ }
956
+ } else if (check.kind === "trim") {
957
+ input.data = input.data.trim();
958
+ } else if (check.kind === "includes") {
959
+ if (!input.data.includes(check.value, check.position)) {
960
+ ctx = this._getOrReturnCtx(input, ctx);
961
+ addIssueToContext(ctx, {
962
+ code: ZodIssueCode.invalid_string,
963
+ validation: { includes: check.value, position: check.position },
964
+ message: check.message
965
+ });
966
+ status.dirty();
967
+ }
968
+ } else if (check.kind === "toLowerCase") {
969
+ input.data = input.data.toLowerCase();
970
+ } else if (check.kind === "toUpperCase") {
971
+ input.data = input.data.toUpperCase();
972
+ } else if (check.kind === "startsWith") {
973
+ if (!input.data.startsWith(check.value)) {
974
+ ctx = this._getOrReturnCtx(input, ctx);
975
+ addIssueToContext(ctx, {
976
+ code: ZodIssueCode.invalid_string,
977
+ validation: { startsWith: check.value },
978
+ message: check.message
979
+ });
980
+ status.dirty();
981
+ }
982
+ } else if (check.kind === "endsWith") {
983
+ if (!input.data.endsWith(check.value)) {
984
+ ctx = this._getOrReturnCtx(input, ctx);
985
+ addIssueToContext(ctx, {
986
+ code: ZodIssueCode.invalid_string,
987
+ validation: { endsWith: check.value },
988
+ message: check.message
989
+ });
990
+ status.dirty();
991
+ }
992
+ } else if (check.kind === "datetime") {
993
+ const regex = datetimeRegex(check);
994
+ if (!regex.test(input.data)) {
995
+ ctx = this._getOrReturnCtx(input, ctx);
996
+ addIssueToContext(ctx, {
997
+ code: ZodIssueCode.invalid_string,
998
+ validation: "datetime",
999
+ message: check.message
1000
+ });
1001
+ status.dirty();
1002
+ }
1003
+ } else if (check.kind === "ip") {
1004
+ if (!isValidIP(input.data, check.version)) {
1005
+ ctx = this._getOrReturnCtx(input, ctx);
1006
+ addIssueToContext(ctx, {
1007
+ validation: "ip",
1008
+ code: ZodIssueCode.invalid_string,
1009
+ message: check.message
1010
+ });
1011
+ status.dirty();
1012
+ }
1013
+ } else {
1014
+ util.assertNever(check);
1015
+ }
1016
+ }
1017
+ return { status: status.value, value: input.data };
1018
+ }
1019
+ _regex(regex, validation, message) {
1020
+ return this.refinement((data) => regex.test(data), __spreadValues({
1021
+ validation,
1022
+ code: ZodIssueCode.invalid_string
1023
+ }, errorUtil.errToObj(message)));
1024
+ }
1025
+ _addCheck(check) {
1026
+ return new _ZodString(__spreadProps(__spreadValues({}, this._def), {
1027
+ checks: [...this._def.checks, check]
1028
+ }));
1029
+ }
1030
+ email(message) {
1031
+ return this._addCheck(__spreadValues({ kind: "email" }, errorUtil.errToObj(message)));
1032
+ }
1033
+ url(message) {
1034
+ return this._addCheck(__spreadValues({ kind: "url" }, errorUtil.errToObj(message)));
1035
+ }
1036
+ emoji(message) {
1037
+ return this._addCheck(__spreadValues({ kind: "emoji" }, errorUtil.errToObj(message)));
1038
+ }
1039
+ uuid(message) {
1040
+ return this._addCheck(__spreadValues({ kind: "uuid" }, errorUtil.errToObj(message)));
1041
+ }
1042
+ cuid(message) {
1043
+ return this._addCheck(__spreadValues({ kind: "cuid" }, errorUtil.errToObj(message)));
1044
+ }
1045
+ cuid2(message) {
1046
+ return this._addCheck(__spreadValues({ kind: "cuid2" }, errorUtil.errToObj(message)));
1047
+ }
1048
+ ulid(message) {
1049
+ return this._addCheck(__spreadValues({ kind: "ulid" }, errorUtil.errToObj(message)));
1050
+ }
1051
+ ip(options) {
1052
+ return this._addCheck(__spreadValues({ kind: "ip" }, errorUtil.errToObj(options)));
1053
+ }
1054
+ datetime(options) {
1055
+ var _a;
1056
+ if (typeof options === "string") {
1057
+ return this._addCheck({
1058
+ kind: "datetime",
1059
+ precision: null,
1060
+ offset: false,
1061
+ message: options
1062
+ });
1063
+ }
1064
+ return this._addCheck(__spreadValues({
1065
+ kind: "datetime",
1066
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1067
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false
1068
+ }, errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)));
1069
+ }
1070
+ regex(regex, message) {
1071
+ return this._addCheck(__spreadValues({
1072
+ kind: "regex",
1073
+ regex
1074
+ }, errorUtil.errToObj(message)));
1075
+ }
1076
+ includes(value, options) {
1077
+ return this._addCheck(__spreadValues({
1078
+ kind: "includes",
1079
+ value,
1080
+ position: options === null || options === void 0 ? void 0 : options.position
1081
+ }, errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)));
1082
+ }
1083
+ startsWith(value, message) {
1084
+ return this._addCheck(__spreadValues({
1085
+ kind: "startsWith",
1086
+ value
1087
+ }, errorUtil.errToObj(message)));
1088
+ }
1089
+ endsWith(value, message) {
1090
+ return this._addCheck(__spreadValues({
1091
+ kind: "endsWith",
1092
+ value
1093
+ }, errorUtil.errToObj(message)));
1094
+ }
1095
+ min(minLength, message) {
1096
+ return this._addCheck(__spreadValues({
1097
+ kind: "min",
1098
+ value: minLength
1099
+ }, errorUtil.errToObj(message)));
1100
+ }
1101
+ max(maxLength, message) {
1102
+ return this._addCheck(__spreadValues({
1103
+ kind: "max",
1104
+ value: maxLength
1105
+ }, errorUtil.errToObj(message)));
1106
+ }
1107
+ length(len, message) {
1108
+ return this._addCheck(__spreadValues({
1109
+ kind: "length",
1110
+ value: len
1111
+ }, errorUtil.errToObj(message)));
1112
+ }
1113
+ /**
1114
+ * @deprecated Use z.string().min(1) instead.
1115
+ * @see {@link ZodString.min}
1116
+ */
1117
+ nonempty(message) {
1118
+ return this.min(1, errorUtil.errToObj(message));
1119
+ }
1120
+ trim() {
1121
+ return new _ZodString(__spreadProps(__spreadValues({}, this._def), {
1122
+ checks: [...this._def.checks, { kind: "trim" }]
1123
+ }));
1124
+ }
1125
+ toLowerCase() {
1126
+ return new _ZodString(__spreadProps(__spreadValues({}, this._def), {
1127
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1128
+ }));
1129
+ }
1130
+ toUpperCase() {
1131
+ return new _ZodString(__spreadProps(__spreadValues({}, this._def), {
1132
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1133
+ }));
1134
+ }
1135
+ get isDatetime() {
1136
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1137
+ }
1138
+ get isEmail() {
1139
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1140
+ }
1141
+ get isURL() {
1142
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1143
+ }
1144
+ get isEmoji() {
1145
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1146
+ }
1147
+ get isUUID() {
1148
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1149
+ }
1150
+ get isCUID() {
1151
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1152
+ }
1153
+ get isCUID2() {
1154
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1155
+ }
1156
+ get isULID() {
1157
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1158
+ }
1159
+ get isIP() {
1160
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1161
+ }
1162
+ get minLength() {
1163
+ let min = null;
1164
+ for (const ch of this._def.checks) {
1165
+ if (ch.kind === "min") {
1166
+ if (min === null || ch.value > min)
1167
+ min = ch.value;
1168
+ }
1169
+ }
1170
+ return min;
1171
+ }
1172
+ get maxLength() {
1173
+ let max = null;
1174
+ for (const ch of this._def.checks) {
1175
+ if (ch.kind === "max") {
1176
+ if (max === null || ch.value < max)
1177
+ max = ch.value;
1178
+ }
1179
+ }
1180
+ return max;
1181
+ }
1182
+ };
1183
+ ZodString.create = (params) => {
1184
+ var _a;
1185
+ return new ZodString(__spreadValues({
1186
+ checks: [],
1187
+ typeName: ZodFirstPartyTypeKind.ZodString,
1188
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false
1189
+ }, processCreateParams(params)));
1190
+ };
1191
+ function floatSafeRemainder(val, step) {
1192
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1193
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1194
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1195
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
1196
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1197
+ return valInt % stepInt / Math.pow(10, decCount);
1198
+ }
1199
+ var ZodNumber = class _ZodNumber extends ZodType {
1200
+ constructor() {
1201
+ super(...arguments);
1202
+ this.min = this.gte;
1203
+ this.max = this.lte;
1204
+ this.step = this.multipleOf;
1205
+ }
1206
+ _parse(input) {
1207
+ if (this._def.coerce) {
1208
+ input.data = Number(input.data);
1209
+ }
1210
+ const parsedType = this._getType(input);
1211
+ if (parsedType !== ZodParsedType.number) {
1212
+ const ctx2 = this._getOrReturnCtx(input);
1213
+ addIssueToContext(ctx2, {
1214
+ code: ZodIssueCode.invalid_type,
1215
+ expected: ZodParsedType.number,
1216
+ received: ctx2.parsedType
1217
+ });
1218
+ return INVALID;
1219
+ }
1220
+ let ctx = void 0;
1221
+ const status = new ParseStatus();
1222
+ for (const check of this._def.checks) {
1223
+ if (check.kind === "int") {
1224
+ if (!util.isInteger(input.data)) {
1225
+ ctx = this._getOrReturnCtx(input, ctx);
1226
+ addIssueToContext(ctx, {
1227
+ code: ZodIssueCode.invalid_type,
1228
+ expected: "integer",
1229
+ received: "float",
1230
+ message: check.message
1231
+ });
1232
+ status.dirty();
1233
+ }
1234
+ } else if (check.kind === "min") {
1235
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1236
+ if (tooSmall) {
1237
+ ctx = this._getOrReturnCtx(input, ctx);
1238
+ addIssueToContext(ctx, {
1239
+ code: ZodIssueCode.too_small,
1240
+ minimum: check.value,
1241
+ type: "number",
1242
+ inclusive: check.inclusive,
1243
+ exact: false,
1244
+ message: check.message
1245
+ });
1246
+ status.dirty();
1247
+ }
1248
+ } else if (check.kind === "max") {
1249
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1250
+ if (tooBig) {
1251
+ ctx = this._getOrReturnCtx(input, ctx);
1252
+ addIssueToContext(ctx, {
1253
+ code: ZodIssueCode.too_big,
1254
+ maximum: check.value,
1255
+ type: "number",
1256
+ inclusive: check.inclusive,
1257
+ exact: false,
1258
+ message: check.message
1259
+ });
1260
+ status.dirty();
1261
+ }
1262
+ } else if (check.kind === "multipleOf") {
1263
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1264
+ ctx = this._getOrReturnCtx(input, ctx);
1265
+ addIssueToContext(ctx, {
1266
+ code: ZodIssueCode.not_multiple_of,
1267
+ multipleOf: check.value,
1268
+ message: check.message
1269
+ });
1270
+ status.dirty();
1271
+ }
1272
+ } else if (check.kind === "finite") {
1273
+ if (!Number.isFinite(input.data)) {
1274
+ ctx = this._getOrReturnCtx(input, ctx);
1275
+ addIssueToContext(ctx, {
1276
+ code: ZodIssueCode.not_finite,
1277
+ message: check.message
1278
+ });
1279
+ status.dirty();
1280
+ }
1281
+ } else {
1282
+ util.assertNever(check);
1283
+ }
1284
+ }
1285
+ return { status: status.value, value: input.data };
1286
+ }
1287
+ gte(value, message) {
1288
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1289
+ }
1290
+ gt(value, message) {
1291
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1292
+ }
1293
+ lte(value, message) {
1294
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1295
+ }
1296
+ lt(value, message) {
1297
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1298
+ }
1299
+ setLimit(kind, value, inclusive, message) {
1300
+ return new _ZodNumber(__spreadProps(__spreadValues({}, this._def), {
1301
+ checks: [
1302
+ ...this._def.checks,
1303
+ {
1304
+ kind,
1305
+ value,
1306
+ inclusive,
1307
+ message: errorUtil.toString(message)
1308
+ }
1309
+ ]
1310
+ }));
1311
+ }
1312
+ _addCheck(check) {
1313
+ return new _ZodNumber(__spreadProps(__spreadValues({}, this._def), {
1314
+ checks: [...this._def.checks, check]
1315
+ }));
1316
+ }
1317
+ int(message) {
1318
+ return this._addCheck({
1319
+ kind: "int",
1320
+ message: errorUtil.toString(message)
1321
+ });
1322
+ }
1323
+ positive(message) {
1324
+ return this._addCheck({
1325
+ kind: "min",
1326
+ value: 0,
1327
+ inclusive: false,
1328
+ message: errorUtil.toString(message)
1329
+ });
1330
+ }
1331
+ negative(message) {
1332
+ return this._addCheck({
1333
+ kind: "max",
1334
+ value: 0,
1335
+ inclusive: false,
1336
+ message: errorUtil.toString(message)
1337
+ });
1338
+ }
1339
+ nonpositive(message) {
1340
+ return this._addCheck({
1341
+ kind: "max",
1342
+ value: 0,
1343
+ inclusive: true,
1344
+ message: errorUtil.toString(message)
1345
+ });
1346
+ }
1347
+ nonnegative(message) {
1348
+ return this._addCheck({
1349
+ kind: "min",
1350
+ value: 0,
1351
+ inclusive: true,
1352
+ message: errorUtil.toString(message)
1353
+ });
1354
+ }
1355
+ multipleOf(value, message) {
1356
+ return this._addCheck({
1357
+ kind: "multipleOf",
1358
+ value,
1359
+ message: errorUtil.toString(message)
1360
+ });
1361
+ }
1362
+ finite(message) {
1363
+ return this._addCheck({
1364
+ kind: "finite",
1365
+ message: errorUtil.toString(message)
1366
+ });
1367
+ }
1368
+ safe(message) {
1369
+ return this._addCheck({
1370
+ kind: "min",
1371
+ inclusive: true,
1372
+ value: Number.MIN_SAFE_INTEGER,
1373
+ message: errorUtil.toString(message)
1374
+ })._addCheck({
1375
+ kind: "max",
1376
+ inclusive: true,
1377
+ value: Number.MAX_SAFE_INTEGER,
1378
+ message: errorUtil.toString(message)
1379
+ });
1380
+ }
1381
+ get minValue() {
1382
+ let min = null;
1383
+ for (const ch of this._def.checks) {
1384
+ if (ch.kind === "min") {
1385
+ if (min === null || ch.value > min)
1386
+ min = ch.value;
1387
+ }
1388
+ }
1389
+ return min;
1390
+ }
1391
+ get maxValue() {
1392
+ let max = null;
1393
+ for (const ch of this._def.checks) {
1394
+ if (ch.kind === "max") {
1395
+ if (max === null || ch.value < max)
1396
+ max = ch.value;
1397
+ }
1398
+ }
1399
+ return max;
1400
+ }
1401
+ get isInt() {
1402
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1403
+ }
1404
+ get isFinite() {
1405
+ let max = null, min = null;
1406
+ for (const ch of this._def.checks) {
1407
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1408
+ return true;
1409
+ } else if (ch.kind === "min") {
1410
+ if (min === null || ch.value > min)
1411
+ min = ch.value;
1412
+ } else if (ch.kind === "max") {
1413
+ if (max === null || ch.value < max)
1414
+ max = ch.value;
1415
+ }
1416
+ }
1417
+ return Number.isFinite(min) && Number.isFinite(max);
1418
+ }
1419
+ };
1420
+ ZodNumber.create = (params) => {
1421
+ return new ZodNumber(__spreadValues({
1422
+ checks: [],
1423
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1424
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false
1425
+ }, processCreateParams(params)));
1426
+ };
1427
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1428
+ constructor() {
1429
+ super(...arguments);
1430
+ this.min = this.gte;
1431
+ this.max = this.lte;
1432
+ }
1433
+ _parse(input) {
1434
+ if (this._def.coerce) {
1435
+ input.data = BigInt(input.data);
1436
+ }
1437
+ const parsedType = this._getType(input);
1438
+ if (parsedType !== ZodParsedType.bigint) {
1439
+ const ctx2 = this._getOrReturnCtx(input);
1440
+ addIssueToContext(ctx2, {
1441
+ code: ZodIssueCode.invalid_type,
1442
+ expected: ZodParsedType.bigint,
1443
+ received: ctx2.parsedType
1444
+ });
1445
+ return INVALID;
1446
+ }
1447
+ let ctx = void 0;
1448
+ const status = new ParseStatus();
1449
+ for (const check of this._def.checks) {
1450
+ if (check.kind === "min") {
1451
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1452
+ if (tooSmall) {
1453
+ ctx = this._getOrReturnCtx(input, ctx);
1454
+ addIssueToContext(ctx, {
1455
+ code: ZodIssueCode.too_small,
1456
+ type: "bigint",
1457
+ minimum: check.value,
1458
+ inclusive: check.inclusive,
1459
+ message: check.message
1460
+ });
1461
+ status.dirty();
1462
+ }
1463
+ } else if (check.kind === "max") {
1464
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1465
+ if (tooBig) {
1466
+ ctx = this._getOrReturnCtx(input, ctx);
1467
+ addIssueToContext(ctx, {
1468
+ code: ZodIssueCode.too_big,
1469
+ type: "bigint",
1470
+ maximum: check.value,
1471
+ inclusive: check.inclusive,
1472
+ message: check.message
1473
+ });
1474
+ status.dirty();
1475
+ }
1476
+ } else if (check.kind === "multipleOf") {
1477
+ if (input.data % check.value !== BigInt(0)) {
1478
+ ctx = this._getOrReturnCtx(input, ctx);
1479
+ addIssueToContext(ctx, {
1480
+ code: ZodIssueCode.not_multiple_of,
1481
+ multipleOf: check.value,
1482
+ message: check.message
1483
+ });
1484
+ status.dirty();
1485
+ }
1486
+ } else {
1487
+ util.assertNever(check);
1488
+ }
1489
+ }
1490
+ return { status: status.value, value: input.data };
1491
+ }
1492
+ gte(value, message) {
1493
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1494
+ }
1495
+ gt(value, message) {
1496
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1497
+ }
1498
+ lte(value, message) {
1499
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1500
+ }
1501
+ lt(value, message) {
1502
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1503
+ }
1504
+ setLimit(kind, value, inclusive, message) {
1505
+ return new _ZodBigInt(__spreadProps(__spreadValues({}, this._def), {
1506
+ checks: [
1507
+ ...this._def.checks,
1508
+ {
1509
+ kind,
1510
+ value,
1511
+ inclusive,
1512
+ message: errorUtil.toString(message)
1513
+ }
1514
+ ]
1515
+ }));
1516
+ }
1517
+ _addCheck(check) {
1518
+ return new _ZodBigInt(__spreadProps(__spreadValues({}, this._def), {
1519
+ checks: [...this._def.checks, check]
1520
+ }));
1521
+ }
1522
+ positive(message) {
1523
+ return this._addCheck({
1524
+ kind: "min",
1525
+ value: BigInt(0),
1526
+ inclusive: false,
1527
+ message: errorUtil.toString(message)
1528
+ });
1529
+ }
1530
+ negative(message) {
1531
+ return this._addCheck({
1532
+ kind: "max",
1533
+ value: BigInt(0),
1534
+ inclusive: false,
1535
+ message: errorUtil.toString(message)
1536
+ });
1537
+ }
1538
+ nonpositive(message) {
1539
+ return this._addCheck({
1540
+ kind: "max",
1541
+ value: BigInt(0),
1542
+ inclusive: true,
1543
+ message: errorUtil.toString(message)
1544
+ });
1545
+ }
1546
+ nonnegative(message) {
1547
+ return this._addCheck({
1548
+ kind: "min",
1549
+ value: BigInt(0),
1550
+ inclusive: true,
1551
+ message: errorUtil.toString(message)
1552
+ });
1553
+ }
1554
+ multipleOf(value, message) {
1555
+ return this._addCheck({
1556
+ kind: "multipleOf",
1557
+ value,
1558
+ message: errorUtil.toString(message)
1559
+ });
1560
+ }
1561
+ get minValue() {
1562
+ let min = null;
1563
+ for (const ch of this._def.checks) {
1564
+ if (ch.kind === "min") {
1565
+ if (min === null || ch.value > min)
1566
+ min = ch.value;
1567
+ }
1568
+ }
1569
+ return min;
1570
+ }
1571
+ get maxValue() {
1572
+ let max = null;
1573
+ for (const ch of this._def.checks) {
1574
+ if (ch.kind === "max") {
1575
+ if (max === null || ch.value < max)
1576
+ max = ch.value;
1577
+ }
1578
+ }
1579
+ return max;
1580
+ }
1581
+ };
1582
+ ZodBigInt.create = (params) => {
1583
+ var _a;
1584
+ return new ZodBigInt(__spreadValues({
1585
+ checks: [],
1586
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1587
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false
1588
+ }, processCreateParams(params)));
1589
+ };
1590
+ var ZodBoolean = class extends ZodType {
1591
+ _parse(input) {
1592
+ if (this._def.coerce) {
1593
+ input.data = Boolean(input.data);
1594
+ }
1595
+ const parsedType = this._getType(input);
1596
+ if (parsedType !== ZodParsedType.boolean) {
1597
+ const ctx = this._getOrReturnCtx(input);
1598
+ addIssueToContext(ctx, {
1599
+ code: ZodIssueCode.invalid_type,
1600
+ expected: ZodParsedType.boolean,
1601
+ received: ctx.parsedType
1602
+ });
1603
+ return INVALID;
1604
+ }
1605
+ return OK(input.data);
1606
+ }
1607
+ };
1608
+ ZodBoolean.create = (params) => {
1609
+ return new ZodBoolean(__spreadValues({
1610
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1611
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false
1612
+ }, processCreateParams(params)));
1613
+ };
1614
+ var ZodDate = class _ZodDate extends ZodType {
1615
+ _parse(input) {
1616
+ if (this._def.coerce) {
1617
+ input.data = new Date(input.data);
1618
+ }
1619
+ const parsedType = this._getType(input);
1620
+ if (parsedType !== ZodParsedType.date) {
1621
+ const ctx2 = this._getOrReturnCtx(input);
1622
+ addIssueToContext(ctx2, {
1623
+ code: ZodIssueCode.invalid_type,
1624
+ expected: ZodParsedType.date,
1625
+ received: ctx2.parsedType
1626
+ });
1627
+ return INVALID;
1628
+ }
1629
+ if (isNaN(input.data.getTime())) {
1630
+ const ctx2 = this._getOrReturnCtx(input);
1631
+ addIssueToContext(ctx2, {
1632
+ code: ZodIssueCode.invalid_date
1633
+ });
1634
+ return INVALID;
1635
+ }
1636
+ const status = new ParseStatus();
1637
+ let ctx = void 0;
1638
+ for (const check of this._def.checks) {
1639
+ if (check.kind === "min") {
1640
+ if (input.data.getTime() < check.value) {
1641
+ ctx = this._getOrReturnCtx(input, ctx);
1642
+ addIssueToContext(ctx, {
1643
+ code: ZodIssueCode.too_small,
1644
+ message: check.message,
1645
+ inclusive: true,
1646
+ exact: false,
1647
+ minimum: check.value,
1648
+ type: "date"
1649
+ });
1650
+ status.dirty();
1651
+ }
1652
+ } else if (check.kind === "max") {
1653
+ if (input.data.getTime() > check.value) {
1654
+ ctx = this._getOrReturnCtx(input, ctx);
1655
+ addIssueToContext(ctx, {
1656
+ code: ZodIssueCode.too_big,
1657
+ message: check.message,
1658
+ inclusive: true,
1659
+ exact: false,
1660
+ maximum: check.value,
1661
+ type: "date"
1662
+ });
1663
+ status.dirty();
1664
+ }
1665
+ } else {
1666
+ util.assertNever(check);
1667
+ }
1668
+ }
1669
+ return {
1670
+ status: status.value,
1671
+ value: new Date(input.data.getTime())
1672
+ };
1673
+ }
1674
+ _addCheck(check) {
1675
+ return new _ZodDate(__spreadProps(__spreadValues({}, this._def), {
1676
+ checks: [...this._def.checks, check]
1677
+ }));
1678
+ }
1679
+ min(minDate, message) {
1680
+ return this._addCheck({
1681
+ kind: "min",
1682
+ value: minDate.getTime(),
1683
+ message: errorUtil.toString(message)
1684
+ });
1685
+ }
1686
+ max(maxDate, message) {
1687
+ return this._addCheck({
1688
+ kind: "max",
1689
+ value: maxDate.getTime(),
1690
+ message: errorUtil.toString(message)
1691
+ });
1692
+ }
1693
+ get minDate() {
1694
+ let min = null;
1695
+ for (const ch of this._def.checks) {
1696
+ if (ch.kind === "min") {
1697
+ if (min === null || ch.value > min)
1698
+ min = ch.value;
1699
+ }
1700
+ }
1701
+ return min != null ? new Date(min) : null;
1702
+ }
1703
+ get maxDate() {
1704
+ let max = null;
1705
+ for (const ch of this._def.checks) {
1706
+ if (ch.kind === "max") {
1707
+ if (max === null || ch.value < max)
1708
+ max = ch.value;
1709
+ }
1710
+ }
1711
+ return max != null ? new Date(max) : null;
1712
+ }
1713
+ };
1714
+ ZodDate.create = (params) => {
1715
+ return new ZodDate(__spreadValues({
1716
+ checks: [],
1717
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1718
+ typeName: ZodFirstPartyTypeKind.ZodDate
1719
+ }, processCreateParams(params)));
1720
+ };
1721
+ var ZodSymbol = class extends ZodType {
1722
+ _parse(input) {
1723
+ const parsedType = this._getType(input);
1724
+ if (parsedType !== ZodParsedType.symbol) {
1725
+ const ctx = this._getOrReturnCtx(input);
1726
+ addIssueToContext(ctx, {
1727
+ code: ZodIssueCode.invalid_type,
1728
+ expected: ZodParsedType.symbol,
1729
+ received: ctx.parsedType
1730
+ });
1731
+ return INVALID;
1732
+ }
1733
+ return OK(input.data);
1734
+ }
1735
+ };
1736
+ ZodSymbol.create = (params) => {
1737
+ return new ZodSymbol(__spreadValues({
1738
+ typeName: ZodFirstPartyTypeKind.ZodSymbol
1739
+ }, processCreateParams(params)));
1740
+ };
1741
+ var ZodUndefined = class extends ZodType {
1742
+ _parse(input) {
1743
+ const parsedType = this._getType(input);
1744
+ if (parsedType !== ZodParsedType.undefined) {
1745
+ const ctx = this._getOrReturnCtx(input);
1746
+ addIssueToContext(ctx, {
1747
+ code: ZodIssueCode.invalid_type,
1748
+ expected: ZodParsedType.undefined,
1749
+ received: ctx.parsedType
1750
+ });
1751
+ return INVALID;
1752
+ }
1753
+ return OK(input.data);
1754
+ }
1755
+ };
1756
+ ZodUndefined.create = (params) => {
1757
+ return new ZodUndefined(__spreadValues({
1758
+ typeName: ZodFirstPartyTypeKind.ZodUndefined
1759
+ }, processCreateParams(params)));
1760
+ };
1761
+ var ZodNull = class extends ZodType {
1762
+ _parse(input) {
1763
+ const parsedType = this._getType(input);
1764
+ if (parsedType !== ZodParsedType.null) {
1765
+ const ctx = this._getOrReturnCtx(input);
1766
+ addIssueToContext(ctx, {
1767
+ code: ZodIssueCode.invalid_type,
1768
+ expected: ZodParsedType.null,
1769
+ received: ctx.parsedType
1770
+ });
1771
+ return INVALID;
1772
+ }
1773
+ return OK(input.data);
1774
+ }
1775
+ };
1776
+ ZodNull.create = (params) => {
1777
+ return new ZodNull(__spreadValues({
1778
+ typeName: ZodFirstPartyTypeKind.ZodNull
1779
+ }, processCreateParams(params)));
1780
+ };
1781
+ var ZodAny = class extends ZodType {
1782
+ constructor() {
1783
+ super(...arguments);
1784
+ this._any = true;
1785
+ }
1786
+ _parse(input) {
1787
+ return OK(input.data);
1788
+ }
1789
+ };
1790
+ ZodAny.create = (params) => {
1791
+ return new ZodAny(__spreadValues({
1792
+ typeName: ZodFirstPartyTypeKind.ZodAny
1793
+ }, processCreateParams(params)));
1794
+ };
1795
+ var ZodUnknown = class extends ZodType {
1796
+ constructor() {
1797
+ super(...arguments);
1798
+ this._unknown = true;
1799
+ }
1800
+ _parse(input) {
1801
+ return OK(input.data);
1802
+ }
1803
+ };
1804
+ ZodUnknown.create = (params) => {
1805
+ return new ZodUnknown(__spreadValues({
1806
+ typeName: ZodFirstPartyTypeKind.ZodUnknown
1807
+ }, processCreateParams(params)));
1808
+ };
1809
+ var ZodNever = class extends ZodType {
1810
+ _parse(input) {
1811
+ const ctx = this._getOrReturnCtx(input);
1812
+ addIssueToContext(ctx, {
1813
+ code: ZodIssueCode.invalid_type,
1814
+ expected: ZodParsedType.never,
1815
+ received: ctx.parsedType
1816
+ });
1817
+ return INVALID;
1818
+ }
1819
+ };
1820
+ ZodNever.create = (params) => {
1821
+ return new ZodNever(__spreadValues({
1822
+ typeName: ZodFirstPartyTypeKind.ZodNever
1823
+ }, processCreateParams(params)));
1824
+ };
1825
+ var ZodVoid = class extends ZodType {
1826
+ _parse(input) {
1827
+ const parsedType = this._getType(input);
1828
+ if (parsedType !== ZodParsedType.undefined) {
1829
+ const ctx = this._getOrReturnCtx(input);
1830
+ addIssueToContext(ctx, {
1831
+ code: ZodIssueCode.invalid_type,
1832
+ expected: ZodParsedType.void,
1833
+ received: ctx.parsedType
1834
+ });
1835
+ return INVALID;
1836
+ }
1837
+ return OK(input.data);
1838
+ }
1839
+ };
1840
+ ZodVoid.create = (params) => {
1841
+ return new ZodVoid(__spreadValues({
1842
+ typeName: ZodFirstPartyTypeKind.ZodVoid
1843
+ }, processCreateParams(params)));
1844
+ };
1845
+ var ZodArray = class _ZodArray extends ZodType {
1846
+ _parse(input) {
1847
+ const { ctx, status } = this._processInputParams(input);
1848
+ const def = this._def;
1849
+ if (ctx.parsedType !== ZodParsedType.array) {
1850
+ addIssueToContext(ctx, {
1851
+ code: ZodIssueCode.invalid_type,
1852
+ expected: ZodParsedType.array,
1853
+ received: ctx.parsedType
1854
+ });
1855
+ return INVALID;
1856
+ }
1857
+ if (def.exactLength !== null) {
1858
+ const tooBig = ctx.data.length > def.exactLength.value;
1859
+ const tooSmall = ctx.data.length < def.exactLength.value;
1860
+ if (tooBig || tooSmall) {
1861
+ addIssueToContext(ctx, {
1862
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1863
+ minimum: tooSmall ? def.exactLength.value : void 0,
1864
+ maximum: tooBig ? def.exactLength.value : void 0,
1865
+ type: "array",
1866
+ inclusive: true,
1867
+ exact: true,
1868
+ message: def.exactLength.message
1869
+ });
1870
+ status.dirty();
1871
+ }
1872
+ }
1873
+ if (def.minLength !== null) {
1874
+ if (ctx.data.length < def.minLength.value) {
1875
+ addIssueToContext(ctx, {
1876
+ code: ZodIssueCode.too_small,
1877
+ minimum: def.minLength.value,
1878
+ type: "array",
1879
+ inclusive: true,
1880
+ exact: false,
1881
+ message: def.minLength.message
1882
+ });
1883
+ status.dirty();
1884
+ }
1885
+ }
1886
+ if (def.maxLength !== null) {
1887
+ if (ctx.data.length > def.maxLength.value) {
1888
+ addIssueToContext(ctx, {
1889
+ code: ZodIssueCode.too_big,
1890
+ maximum: def.maxLength.value,
1891
+ type: "array",
1892
+ inclusive: true,
1893
+ exact: false,
1894
+ message: def.maxLength.message
1895
+ });
1896
+ status.dirty();
1897
+ }
1898
+ }
1899
+ if (ctx.common.async) {
1900
+ return Promise.all([...ctx.data].map((item, i) => {
1901
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1902
+ })).then((result2) => {
1903
+ return ParseStatus.mergeArray(status, result2);
1904
+ });
1905
+ }
1906
+ const result = [...ctx.data].map((item, i) => {
1907
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1908
+ });
1909
+ return ParseStatus.mergeArray(status, result);
1910
+ }
1911
+ get element() {
1912
+ return this._def.type;
1913
+ }
1914
+ min(minLength, message) {
1915
+ return new _ZodArray(__spreadProps(__spreadValues({}, this._def), {
1916
+ minLength: { value: minLength, message: errorUtil.toString(message) }
1917
+ }));
1918
+ }
1919
+ max(maxLength, message) {
1920
+ return new _ZodArray(__spreadProps(__spreadValues({}, this._def), {
1921
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
1922
+ }));
1923
+ }
1924
+ length(len, message) {
1925
+ return new _ZodArray(__spreadProps(__spreadValues({}, this._def), {
1926
+ exactLength: { value: len, message: errorUtil.toString(message) }
1927
+ }));
1928
+ }
1929
+ nonempty(message) {
1930
+ return this.min(1, message);
1931
+ }
1932
+ };
1933
+ ZodArray.create = (schema, params) => {
1934
+ return new ZodArray(__spreadValues({
1935
+ type: schema,
1936
+ minLength: null,
1937
+ maxLength: null,
1938
+ exactLength: null,
1939
+ typeName: ZodFirstPartyTypeKind.ZodArray
1940
+ }, processCreateParams(params)));
1941
+ };
1942
+ function deepPartialify(schema) {
1943
+ if (schema instanceof ZodObject) {
1944
+ const newShape = {};
1945
+ for (const key in schema.shape) {
1946
+ const fieldSchema = schema.shape[key];
1947
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1948
+ }
1949
+ return new ZodObject(__spreadProps(__spreadValues({}, schema._def), {
1950
+ shape: () => newShape
1951
+ }));
1952
+ } else if (schema instanceof ZodArray) {
1953
+ return new ZodArray(__spreadProps(__spreadValues({}, schema._def), {
1954
+ type: deepPartialify(schema.element)
1955
+ }));
1956
+ } else if (schema instanceof ZodOptional) {
1957
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
1958
+ } else if (schema instanceof ZodNullable) {
1959
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
1960
+ } else if (schema instanceof ZodTuple) {
1961
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
1962
+ } else {
1963
+ return schema;
1964
+ }
1965
+ }
1966
+ var ZodObject = class _ZodObject extends ZodType {
1967
+ constructor() {
1968
+ super(...arguments);
1969
+ this._cached = null;
1970
+ this.nonstrict = this.passthrough;
1971
+ this.augment = this.extend;
1972
+ }
1973
+ _getCached() {
1974
+ if (this._cached !== null)
1975
+ return this._cached;
1976
+ const shape = this._def.shape();
1977
+ const keys = util.objectKeys(shape);
1978
+ return this._cached = { shape, keys };
1979
+ }
1980
+ _parse(input) {
1981
+ const parsedType = this._getType(input);
1982
+ if (parsedType !== ZodParsedType.object) {
1983
+ const ctx2 = this._getOrReturnCtx(input);
1984
+ addIssueToContext(ctx2, {
1985
+ code: ZodIssueCode.invalid_type,
1986
+ expected: ZodParsedType.object,
1987
+ received: ctx2.parsedType
1988
+ });
1989
+ return INVALID;
1990
+ }
1991
+ const { status, ctx } = this._processInputParams(input);
1992
+ const { shape, keys: shapeKeys } = this._getCached();
1993
+ const extraKeys = [];
1994
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
1995
+ for (const key in ctx.data) {
1996
+ if (!shapeKeys.includes(key)) {
1997
+ extraKeys.push(key);
1998
+ }
1999
+ }
2000
+ }
2001
+ const pairs = [];
2002
+ for (const key of shapeKeys) {
2003
+ const keyValidator = shape[key];
2004
+ const value = ctx.data[key];
2005
+ pairs.push({
2006
+ key: { status: "valid", value: key },
2007
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2008
+ alwaysSet: key in ctx.data
2009
+ });
2010
+ }
2011
+ if (this._def.catchall instanceof ZodNever) {
2012
+ const unknownKeys = this._def.unknownKeys;
2013
+ if (unknownKeys === "passthrough") {
2014
+ for (const key of extraKeys) {
2015
+ pairs.push({
2016
+ key: { status: "valid", value: key },
2017
+ value: { status: "valid", value: ctx.data[key] }
2018
+ });
2019
+ }
2020
+ } else if (unknownKeys === "strict") {
2021
+ if (extraKeys.length > 0) {
2022
+ addIssueToContext(ctx, {
2023
+ code: ZodIssueCode.unrecognized_keys,
2024
+ keys: extraKeys
2025
+ });
2026
+ status.dirty();
2027
+ }
2028
+ } else if (unknownKeys === "strip")
2029
+ ;
2030
+ else {
2031
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2032
+ }
2033
+ } else {
2034
+ const catchall = this._def.catchall;
2035
+ for (const key of extraKeys) {
2036
+ const value = ctx.data[key];
2037
+ pairs.push({
2038
+ key: { status: "valid", value: key },
2039
+ value: catchall._parse(
2040
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2041
+ //, ctx.child(key), value, getParsedType(value)
2042
+ ),
2043
+ alwaysSet: key in ctx.data
2044
+ });
2045
+ }
2046
+ }
2047
+ if (ctx.common.async) {
2048
+ return Promise.resolve().then(async () => {
2049
+ const syncPairs = [];
2050
+ for (const pair of pairs) {
2051
+ const key = await pair.key;
2052
+ syncPairs.push({
2053
+ key,
2054
+ value: await pair.value,
2055
+ alwaysSet: pair.alwaysSet
2056
+ });
2057
+ }
2058
+ return syncPairs;
2059
+ }).then((syncPairs) => {
2060
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2061
+ });
2062
+ } else {
2063
+ return ParseStatus.mergeObjectSync(status, pairs);
2064
+ }
2065
+ }
2066
+ get shape() {
2067
+ return this._def.shape();
2068
+ }
2069
+ strict(message) {
2070
+ errorUtil.errToObj;
2071
+ return new _ZodObject(__spreadValues(__spreadProps(__spreadValues({}, this._def), {
2072
+ unknownKeys: "strict"
2073
+ }), message !== void 0 ? {
2074
+ errorMap: (issue, ctx) => {
2075
+ var _a, _b, _c, _d;
2076
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2077
+ if (issue.code === "unrecognized_keys")
2078
+ return {
2079
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
2080
+ };
2081
+ return {
2082
+ message: defaultError
2083
+ };
2084
+ }
2085
+ } : {}));
2086
+ }
2087
+ strip() {
2088
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2089
+ unknownKeys: "strip"
2090
+ }));
2091
+ }
2092
+ passthrough() {
2093
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2094
+ unknownKeys: "passthrough"
2095
+ }));
2096
+ }
2097
+ // const AugmentFactory =
2098
+ // <Def extends ZodObjectDef>(def: Def) =>
2099
+ // <Augmentation extends ZodRawShape>(
2100
+ // augmentation: Augmentation
2101
+ // ): ZodObject<
2102
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2103
+ // Def["unknownKeys"],
2104
+ // Def["catchall"]
2105
+ // > => {
2106
+ // return new ZodObject({
2107
+ // ...def,
2108
+ // shape: () => ({
2109
+ // ...def.shape(),
2110
+ // ...augmentation,
2111
+ // }),
2112
+ // }) as any;
2113
+ // };
2114
+ extend(augmentation) {
2115
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2116
+ shape: () => __spreadValues(__spreadValues({}, this._def.shape()), augmentation)
2117
+ }));
2118
+ }
2119
+ /**
2120
+ * Prior to zod@1.0.12 there was a bug in the
2121
+ * inferred type of merged objects. Please
2122
+ * upgrade if you are experiencing issues.
2123
+ */
2124
+ merge(merging) {
2125
+ const merged = new _ZodObject({
2126
+ unknownKeys: merging._def.unknownKeys,
2127
+ catchall: merging._def.catchall,
2128
+ shape: () => __spreadValues(__spreadValues({}, this._def.shape()), merging._def.shape()),
2129
+ typeName: ZodFirstPartyTypeKind.ZodObject
2130
+ });
2131
+ return merged;
2132
+ }
2133
+ // merge<
2134
+ // Incoming extends AnyZodObject,
2135
+ // Augmentation extends Incoming["shape"],
2136
+ // NewOutput extends {
2137
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2138
+ // ? Augmentation[k]["_output"]
2139
+ // : k extends keyof Output
2140
+ // ? Output[k]
2141
+ // : never;
2142
+ // },
2143
+ // NewInput extends {
2144
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2145
+ // ? Augmentation[k]["_input"]
2146
+ // : k extends keyof Input
2147
+ // ? Input[k]
2148
+ // : never;
2149
+ // }
2150
+ // >(
2151
+ // merging: Incoming
2152
+ // ): ZodObject<
2153
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2154
+ // Incoming["_def"]["unknownKeys"],
2155
+ // Incoming["_def"]["catchall"],
2156
+ // NewOutput,
2157
+ // NewInput
2158
+ // > {
2159
+ // const merged: any = new ZodObject({
2160
+ // unknownKeys: merging._def.unknownKeys,
2161
+ // catchall: merging._def.catchall,
2162
+ // shape: () =>
2163
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2164
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2165
+ // }) as any;
2166
+ // return merged;
2167
+ // }
2168
+ setKey(key, schema) {
2169
+ return this.augment({ [key]: schema });
2170
+ }
2171
+ // merge<Incoming extends AnyZodObject>(
2172
+ // merging: Incoming
2173
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2174
+ // ZodObject<
2175
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2176
+ // Incoming["_def"]["unknownKeys"],
2177
+ // Incoming["_def"]["catchall"]
2178
+ // > {
2179
+ // // const mergedShape = objectUtil.mergeShapes(
2180
+ // // this._def.shape(),
2181
+ // // merging._def.shape()
2182
+ // // );
2183
+ // const merged: any = new ZodObject({
2184
+ // unknownKeys: merging._def.unknownKeys,
2185
+ // catchall: merging._def.catchall,
2186
+ // shape: () =>
2187
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2188
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2189
+ // }) as any;
2190
+ // return merged;
2191
+ // }
2192
+ catchall(index) {
2193
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2194
+ catchall: index
2195
+ }));
2196
+ }
2197
+ pick(mask) {
2198
+ const shape = {};
2199
+ util.objectKeys(mask).forEach((key) => {
2200
+ if (mask[key] && this.shape[key]) {
2201
+ shape[key] = this.shape[key];
2202
+ }
2203
+ });
2204
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2205
+ shape: () => shape
2206
+ }));
2207
+ }
2208
+ omit(mask) {
2209
+ const shape = {};
2210
+ util.objectKeys(this.shape).forEach((key) => {
2211
+ if (!mask[key]) {
2212
+ shape[key] = this.shape[key];
2213
+ }
2214
+ });
2215
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2216
+ shape: () => shape
2217
+ }));
2218
+ }
2219
+ /**
2220
+ * @deprecated
2221
+ */
2222
+ deepPartial() {
2223
+ return deepPartialify(this);
2224
+ }
2225
+ partial(mask) {
2226
+ const newShape = {};
2227
+ util.objectKeys(this.shape).forEach((key) => {
2228
+ const fieldSchema = this.shape[key];
2229
+ if (mask && !mask[key]) {
2230
+ newShape[key] = fieldSchema;
2231
+ } else {
2232
+ newShape[key] = fieldSchema.optional();
2233
+ }
2234
+ });
2235
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2236
+ shape: () => newShape
2237
+ }));
2238
+ }
2239
+ required(mask) {
2240
+ const newShape = {};
2241
+ util.objectKeys(this.shape).forEach((key) => {
2242
+ if (mask && !mask[key]) {
2243
+ newShape[key] = this.shape[key];
2244
+ } else {
2245
+ const fieldSchema = this.shape[key];
2246
+ let newField = fieldSchema;
2247
+ while (newField instanceof ZodOptional) {
2248
+ newField = newField._def.innerType;
2249
+ }
2250
+ newShape[key] = newField;
2251
+ }
2252
+ });
2253
+ return new _ZodObject(__spreadProps(__spreadValues({}, this._def), {
2254
+ shape: () => newShape
2255
+ }));
2256
+ }
2257
+ keyof() {
2258
+ return createZodEnum(util.objectKeys(this.shape));
2259
+ }
2260
+ };
2261
+ ZodObject.create = (shape, params) => {
2262
+ return new ZodObject(__spreadValues({
2263
+ shape: () => shape,
2264
+ unknownKeys: "strip",
2265
+ catchall: ZodNever.create(),
2266
+ typeName: ZodFirstPartyTypeKind.ZodObject
2267
+ }, processCreateParams(params)));
2268
+ };
2269
+ ZodObject.strictCreate = (shape, params) => {
2270
+ return new ZodObject(__spreadValues({
2271
+ shape: () => shape,
2272
+ unknownKeys: "strict",
2273
+ catchall: ZodNever.create(),
2274
+ typeName: ZodFirstPartyTypeKind.ZodObject
2275
+ }, processCreateParams(params)));
2276
+ };
2277
+ ZodObject.lazycreate = (shape, params) => {
2278
+ return new ZodObject(__spreadValues({
2279
+ shape,
2280
+ unknownKeys: "strip",
2281
+ catchall: ZodNever.create(),
2282
+ typeName: ZodFirstPartyTypeKind.ZodObject
2283
+ }, processCreateParams(params)));
2284
+ };
2285
+ var ZodUnion = class extends ZodType {
2286
+ _parse(input) {
2287
+ const { ctx } = this._processInputParams(input);
2288
+ const options = this._def.options;
2289
+ function handleResults(results) {
2290
+ for (const result of results) {
2291
+ if (result.result.status === "valid") {
2292
+ return result.result;
2293
+ }
2294
+ }
2295
+ for (const result of results) {
2296
+ if (result.result.status === "dirty") {
2297
+ ctx.common.issues.push(...result.ctx.common.issues);
2298
+ return result.result;
2299
+ }
2300
+ }
2301
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2302
+ addIssueToContext(ctx, {
2303
+ code: ZodIssueCode.invalid_union,
2304
+ unionErrors
2305
+ });
2306
+ return INVALID;
2307
+ }
2308
+ if (ctx.common.async) {
2309
+ return Promise.all(options.map(async (option) => {
2310
+ const childCtx = __spreadProps(__spreadValues({}, ctx), {
2311
+ common: __spreadProps(__spreadValues({}, ctx.common), {
2312
+ issues: []
2313
+ }),
2314
+ parent: null
2315
+ });
2316
+ return {
2317
+ result: await option._parseAsync({
2318
+ data: ctx.data,
2319
+ path: ctx.path,
2320
+ parent: childCtx
2321
+ }),
2322
+ ctx: childCtx
2323
+ };
2324
+ })).then(handleResults);
2325
+ } else {
2326
+ let dirty = void 0;
2327
+ const issues = [];
2328
+ for (const option of options) {
2329
+ const childCtx = __spreadProps(__spreadValues({}, ctx), {
2330
+ common: __spreadProps(__spreadValues({}, ctx.common), {
2331
+ issues: []
2332
+ }),
2333
+ parent: null
2334
+ });
2335
+ const result = option._parseSync({
2336
+ data: ctx.data,
2337
+ path: ctx.path,
2338
+ parent: childCtx
2339
+ });
2340
+ if (result.status === "valid") {
2341
+ return result;
2342
+ } else if (result.status === "dirty" && !dirty) {
2343
+ dirty = { result, ctx: childCtx };
2344
+ }
2345
+ if (childCtx.common.issues.length) {
2346
+ issues.push(childCtx.common.issues);
2347
+ }
2348
+ }
2349
+ if (dirty) {
2350
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2351
+ return dirty.result;
2352
+ }
2353
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
2354
+ addIssueToContext(ctx, {
2355
+ code: ZodIssueCode.invalid_union,
2356
+ unionErrors
2357
+ });
2358
+ return INVALID;
2359
+ }
2360
+ }
2361
+ get options() {
2362
+ return this._def.options;
2363
+ }
2364
+ };
2365
+ ZodUnion.create = (types, params) => {
2366
+ return new ZodUnion(__spreadValues({
2367
+ options: types,
2368
+ typeName: ZodFirstPartyTypeKind.ZodUnion
2369
+ }, processCreateParams(params)));
2370
+ };
2371
+ var getDiscriminator = (type) => {
2372
+ if (type instanceof ZodLazy) {
2373
+ return getDiscriminator(type.schema);
2374
+ } else if (type instanceof ZodEffects) {
2375
+ return getDiscriminator(type.innerType());
2376
+ } else if (type instanceof ZodLiteral) {
2377
+ return [type.value];
2378
+ } else if (type instanceof ZodEnum) {
2379
+ return type.options;
2380
+ } else if (type instanceof ZodNativeEnum) {
2381
+ return Object.keys(type.enum);
2382
+ } else if (type instanceof ZodDefault) {
2383
+ return getDiscriminator(type._def.innerType);
2384
+ } else if (type instanceof ZodUndefined) {
2385
+ return [void 0];
2386
+ } else if (type instanceof ZodNull) {
2387
+ return [null];
2388
+ } else {
2389
+ return null;
2390
+ }
2391
+ };
2392
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2393
+ _parse(input) {
2394
+ const { ctx } = this._processInputParams(input);
2395
+ if (ctx.parsedType !== ZodParsedType.object) {
2396
+ addIssueToContext(ctx, {
2397
+ code: ZodIssueCode.invalid_type,
2398
+ expected: ZodParsedType.object,
2399
+ received: ctx.parsedType
2400
+ });
2401
+ return INVALID;
2402
+ }
2403
+ const discriminator = this.discriminator;
2404
+ const discriminatorValue = ctx.data[discriminator];
2405
+ const option = this.optionsMap.get(discriminatorValue);
2406
+ if (!option) {
2407
+ addIssueToContext(ctx, {
2408
+ code: ZodIssueCode.invalid_union_discriminator,
2409
+ options: Array.from(this.optionsMap.keys()),
2410
+ path: [discriminator]
2411
+ });
2412
+ return INVALID;
2413
+ }
2414
+ if (ctx.common.async) {
2415
+ return option._parseAsync({
2416
+ data: ctx.data,
2417
+ path: ctx.path,
2418
+ parent: ctx
2419
+ });
2420
+ } else {
2421
+ return option._parseSync({
2422
+ data: ctx.data,
2423
+ path: ctx.path,
2424
+ parent: ctx
2425
+ });
2426
+ }
2427
+ }
2428
+ get discriminator() {
2429
+ return this._def.discriminator;
2430
+ }
2431
+ get options() {
2432
+ return this._def.options;
2433
+ }
2434
+ get optionsMap() {
2435
+ return this._def.optionsMap;
2436
+ }
2437
+ /**
2438
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2439
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2440
+ * have a different value for each object in the union.
2441
+ * @param discriminator the name of the discriminator property
2442
+ * @param types an array of object schemas
2443
+ * @param params
2444
+ */
2445
+ static create(discriminator, options, params) {
2446
+ const optionsMap = /* @__PURE__ */ new Map();
2447
+ for (const type of options) {
2448
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2449
+ if (!discriminatorValues) {
2450
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2451
+ }
2452
+ for (const value of discriminatorValues) {
2453
+ if (optionsMap.has(value)) {
2454
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2455
+ }
2456
+ optionsMap.set(value, type);
2457
+ }
2458
+ }
2459
+ return new _ZodDiscriminatedUnion(__spreadValues({
2460
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2461
+ discriminator,
2462
+ options,
2463
+ optionsMap
2464
+ }, processCreateParams(params)));
2465
+ }
2466
+ };
2467
+ function mergeValues(a, b) {
2468
+ const aType = getParsedType(a);
2469
+ const bType = getParsedType(b);
2470
+ if (a === b) {
2471
+ return { valid: true, data: a };
2472
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2473
+ const bKeys = util.objectKeys(b);
2474
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2475
+ const newObj = __spreadValues(__spreadValues({}, a), b);
2476
+ for (const key of sharedKeys) {
2477
+ const sharedValue = mergeValues(a[key], b[key]);
2478
+ if (!sharedValue.valid) {
2479
+ return { valid: false };
2480
+ }
2481
+ newObj[key] = sharedValue.data;
2482
+ }
2483
+ return { valid: true, data: newObj };
2484
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2485
+ if (a.length !== b.length) {
2486
+ return { valid: false };
2487
+ }
2488
+ const newArray = [];
2489
+ for (let index = 0; index < a.length; index++) {
2490
+ const itemA = a[index];
2491
+ const itemB = b[index];
2492
+ const sharedValue = mergeValues(itemA, itemB);
2493
+ if (!sharedValue.valid) {
2494
+ return { valid: false };
2495
+ }
2496
+ newArray.push(sharedValue.data);
2497
+ }
2498
+ return { valid: true, data: newArray };
2499
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2500
+ return { valid: true, data: a };
2501
+ } else {
2502
+ return { valid: false };
2503
+ }
2504
+ }
2505
+ var ZodIntersection = class extends ZodType {
2506
+ _parse(input) {
2507
+ const { status, ctx } = this._processInputParams(input);
2508
+ const handleParsed = (parsedLeft, parsedRight) => {
2509
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2510
+ return INVALID;
2511
+ }
2512
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2513
+ if (!merged.valid) {
2514
+ addIssueToContext(ctx, {
2515
+ code: ZodIssueCode.invalid_intersection_types
2516
+ });
2517
+ return INVALID;
2518
+ }
2519
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2520
+ status.dirty();
2521
+ }
2522
+ return { status: status.value, value: merged.data };
2523
+ };
2524
+ if (ctx.common.async) {
2525
+ return Promise.all([
2526
+ this._def.left._parseAsync({
2527
+ data: ctx.data,
2528
+ path: ctx.path,
2529
+ parent: ctx
2530
+ }),
2531
+ this._def.right._parseAsync({
2532
+ data: ctx.data,
2533
+ path: ctx.path,
2534
+ parent: ctx
2535
+ })
2536
+ ]).then(([left, right]) => handleParsed(left, right));
2537
+ } else {
2538
+ return handleParsed(this._def.left._parseSync({
2539
+ data: ctx.data,
2540
+ path: ctx.path,
2541
+ parent: ctx
2542
+ }), this._def.right._parseSync({
2543
+ data: ctx.data,
2544
+ path: ctx.path,
2545
+ parent: ctx
2546
+ }));
2547
+ }
2548
+ }
2549
+ };
2550
+ ZodIntersection.create = (left, right, params) => {
2551
+ return new ZodIntersection(__spreadValues({
2552
+ left,
2553
+ right,
2554
+ typeName: ZodFirstPartyTypeKind.ZodIntersection
2555
+ }, processCreateParams(params)));
2556
+ };
2557
+ var ZodTuple = class _ZodTuple extends ZodType {
2558
+ _parse(input) {
2559
+ const { status, ctx } = this._processInputParams(input);
2560
+ if (ctx.parsedType !== ZodParsedType.array) {
2561
+ addIssueToContext(ctx, {
2562
+ code: ZodIssueCode.invalid_type,
2563
+ expected: ZodParsedType.array,
2564
+ received: ctx.parsedType
2565
+ });
2566
+ return INVALID;
2567
+ }
2568
+ if (ctx.data.length < this._def.items.length) {
2569
+ addIssueToContext(ctx, {
2570
+ code: ZodIssueCode.too_small,
2571
+ minimum: this._def.items.length,
2572
+ inclusive: true,
2573
+ exact: false,
2574
+ type: "array"
2575
+ });
2576
+ return INVALID;
2577
+ }
2578
+ const rest = this._def.rest;
2579
+ if (!rest && ctx.data.length > this._def.items.length) {
2580
+ addIssueToContext(ctx, {
2581
+ code: ZodIssueCode.too_big,
2582
+ maximum: this._def.items.length,
2583
+ inclusive: true,
2584
+ exact: false,
2585
+ type: "array"
2586
+ });
2587
+ status.dirty();
2588
+ }
2589
+ const items = [...ctx.data].map((item, itemIndex) => {
2590
+ const schema = this._def.items[itemIndex] || this._def.rest;
2591
+ if (!schema)
2592
+ return null;
2593
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2594
+ }).filter((x) => !!x);
2595
+ if (ctx.common.async) {
2596
+ return Promise.all(items).then((results) => {
2597
+ return ParseStatus.mergeArray(status, results);
2598
+ });
2599
+ } else {
2600
+ return ParseStatus.mergeArray(status, items);
2601
+ }
2602
+ }
2603
+ get items() {
2604
+ return this._def.items;
2605
+ }
2606
+ rest(rest) {
2607
+ return new _ZodTuple(__spreadProps(__spreadValues({}, this._def), {
2608
+ rest
2609
+ }));
2610
+ }
2611
+ };
2612
+ ZodTuple.create = (schemas, params) => {
2613
+ if (!Array.isArray(schemas)) {
2614
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2615
+ }
2616
+ return new ZodTuple(__spreadValues({
2617
+ items: schemas,
2618
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2619
+ rest: null
2620
+ }, processCreateParams(params)));
2621
+ };
2622
+ var ZodRecord = class _ZodRecord extends ZodType {
2623
+ get keySchema() {
2624
+ return this._def.keyType;
2625
+ }
2626
+ get valueSchema() {
2627
+ return this._def.valueType;
2628
+ }
2629
+ _parse(input) {
2630
+ const { status, ctx } = this._processInputParams(input);
2631
+ if (ctx.parsedType !== ZodParsedType.object) {
2632
+ addIssueToContext(ctx, {
2633
+ code: ZodIssueCode.invalid_type,
2634
+ expected: ZodParsedType.object,
2635
+ received: ctx.parsedType
2636
+ });
2637
+ return INVALID;
2638
+ }
2639
+ const pairs = [];
2640
+ const keyType = this._def.keyType;
2641
+ const valueType = this._def.valueType;
2642
+ for (const key in ctx.data) {
2643
+ pairs.push({
2644
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2645
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
2646
+ });
2647
+ }
2648
+ if (ctx.common.async) {
2649
+ return ParseStatus.mergeObjectAsync(status, pairs);
2650
+ } else {
2651
+ return ParseStatus.mergeObjectSync(status, pairs);
2652
+ }
2653
+ }
2654
+ get element() {
2655
+ return this._def.valueType;
2656
+ }
2657
+ static create(first, second, third) {
2658
+ if (second instanceof ZodType) {
2659
+ return new _ZodRecord(__spreadValues({
2660
+ keyType: first,
2661
+ valueType: second,
2662
+ typeName: ZodFirstPartyTypeKind.ZodRecord
2663
+ }, processCreateParams(third)));
2664
+ }
2665
+ return new _ZodRecord(__spreadValues({
2666
+ keyType: ZodString.create(),
2667
+ valueType: first,
2668
+ typeName: ZodFirstPartyTypeKind.ZodRecord
2669
+ }, processCreateParams(second)));
2670
+ }
2671
+ };
2672
+ var ZodMap = class extends ZodType {
2673
+ get keySchema() {
2674
+ return this._def.keyType;
2675
+ }
2676
+ get valueSchema() {
2677
+ return this._def.valueType;
2678
+ }
2679
+ _parse(input) {
2680
+ const { status, ctx } = this._processInputParams(input);
2681
+ if (ctx.parsedType !== ZodParsedType.map) {
2682
+ addIssueToContext(ctx, {
2683
+ code: ZodIssueCode.invalid_type,
2684
+ expected: ZodParsedType.map,
2685
+ received: ctx.parsedType
2686
+ });
2687
+ return INVALID;
2688
+ }
2689
+ const keyType = this._def.keyType;
2690
+ const valueType = this._def.valueType;
2691
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
2692
+ return {
2693
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2694
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
2695
+ };
2696
+ });
2697
+ if (ctx.common.async) {
2698
+ const finalMap = /* @__PURE__ */ new Map();
2699
+ return Promise.resolve().then(async () => {
2700
+ for (const pair of pairs) {
2701
+ const key = await pair.key;
2702
+ const value = await pair.value;
2703
+ if (key.status === "aborted" || value.status === "aborted") {
2704
+ return INVALID;
2705
+ }
2706
+ if (key.status === "dirty" || value.status === "dirty") {
2707
+ status.dirty();
2708
+ }
2709
+ finalMap.set(key.value, value.value);
2710
+ }
2711
+ return { status: status.value, value: finalMap };
2712
+ });
2713
+ } else {
2714
+ const finalMap = /* @__PURE__ */ new Map();
2715
+ for (const pair of pairs) {
2716
+ const key = pair.key;
2717
+ const value = pair.value;
2718
+ if (key.status === "aborted" || value.status === "aborted") {
2719
+ return INVALID;
2720
+ }
2721
+ if (key.status === "dirty" || value.status === "dirty") {
2722
+ status.dirty();
2723
+ }
2724
+ finalMap.set(key.value, value.value);
2725
+ }
2726
+ return { status: status.value, value: finalMap };
2727
+ }
2728
+ }
2729
+ };
2730
+ ZodMap.create = (keyType, valueType, params) => {
2731
+ return new ZodMap(__spreadValues({
2732
+ valueType,
2733
+ keyType,
2734
+ typeName: ZodFirstPartyTypeKind.ZodMap
2735
+ }, processCreateParams(params)));
2736
+ };
2737
+ var ZodSet = class _ZodSet extends ZodType {
2738
+ _parse(input) {
2739
+ const { status, ctx } = this._processInputParams(input);
2740
+ if (ctx.parsedType !== ZodParsedType.set) {
2741
+ addIssueToContext(ctx, {
2742
+ code: ZodIssueCode.invalid_type,
2743
+ expected: ZodParsedType.set,
2744
+ received: ctx.parsedType
2745
+ });
2746
+ return INVALID;
2747
+ }
2748
+ const def = this._def;
2749
+ if (def.minSize !== null) {
2750
+ if (ctx.data.size < def.minSize.value) {
2751
+ addIssueToContext(ctx, {
2752
+ code: ZodIssueCode.too_small,
2753
+ minimum: def.minSize.value,
2754
+ type: "set",
2755
+ inclusive: true,
2756
+ exact: false,
2757
+ message: def.minSize.message
2758
+ });
2759
+ status.dirty();
2760
+ }
2761
+ }
2762
+ if (def.maxSize !== null) {
2763
+ if (ctx.data.size > def.maxSize.value) {
2764
+ addIssueToContext(ctx, {
2765
+ code: ZodIssueCode.too_big,
2766
+ maximum: def.maxSize.value,
2767
+ type: "set",
2768
+ inclusive: true,
2769
+ exact: false,
2770
+ message: def.maxSize.message
2771
+ });
2772
+ status.dirty();
2773
+ }
2774
+ }
2775
+ const valueType = this._def.valueType;
2776
+ function finalizeSet(elements2) {
2777
+ const parsedSet = /* @__PURE__ */ new Set();
2778
+ for (const element of elements2) {
2779
+ if (element.status === "aborted")
2780
+ return INVALID;
2781
+ if (element.status === "dirty")
2782
+ status.dirty();
2783
+ parsedSet.add(element.value);
2784
+ }
2785
+ return { status: status.value, value: parsedSet };
2786
+ }
2787
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2788
+ if (ctx.common.async) {
2789
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
2790
+ } else {
2791
+ return finalizeSet(elements);
2792
+ }
2793
+ }
2794
+ min(minSize, message) {
2795
+ return new _ZodSet(__spreadProps(__spreadValues({}, this._def), {
2796
+ minSize: { value: minSize, message: errorUtil.toString(message) }
2797
+ }));
2798
+ }
2799
+ max(maxSize, message) {
2800
+ return new _ZodSet(__spreadProps(__spreadValues({}, this._def), {
2801
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
2802
+ }));
2803
+ }
2804
+ size(size, message) {
2805
+ return this.min(size, message).max(size, message);
2806
+ }
2807
+ nonempty(message) {
2808
+ return this.min(1, message);
2809
+ }
2810
+ };
2811
+ ZodSet.create = (valueType, params) => {
2812
+ return new ZodSet(__spreadValues({
2813
+ valueType,
2814
+ minSize: null,
2815
+ maxSize: null,
2816
+ typeName: ZodFirstPartyTypeKind.ZodSet
2817
+ }, processCreateParams(params)));
2818
+ };
2819
+ var ZodFunction = class _ZodFunction extends ZodType {
2820
+ constructor() {
2821
+ super(...arguments);
2822
+ this.validate = this.implement;
2823
+ }
2824
+ _parse(input) {
2825
+ const { ctx } = this._processInputParams(input);
2826
+ if (ctx.parsedType !== ZodParsedType.function) {
2827
+ addIssueToContext(ctx, {
2828
+ code: ZodIssueCode.invalid_type,
2829
+ expected: ZodParsedType.function,
2830
+ received: ctx.parsedType
2831
+ });
2832
+ return INVALID;
2833
+ }
2834
+ function makeArgsIssue(args, error) {
2835
+ return makeIssue({
2836
+ data: args,
2837
+ path: ctx.path,
2838
+ errorMaps: [
2839
+ ctx.common.contextualErrorMap,
2840
+ ctx.schemaErrorMap,
2841
+ getErrorMap(),
2842
+ errorMap
2843
+ ].filter((x) => !!x),
2844
+ issueData: {
2845
+ code: ZodIssueCode.invalid_arguments,
2846
+ argumentsError: error
2847
+ }
2848
+ });
2849
+ }
2850
+ function makeReturnsIssue(returns, error) {
2851
+ return makeIssue({
2852
+ data: returns,
2853
+ path: ctx.path,
2854
+ errorMaps: [
2855
+ ctx.common.contextualErrorMap,
2856
+ ctx.schemaErrorMap,
2857
+ getErrorMap(),
2858
+ errorMap
2859
+ ].filter((x) => !!x),
2860
+ issueData: {
2861
+ code: ZodIssueCode.invalid_return_type,
2862
+ returnTypeError: error
2863
+ }
2864
+ });
2865
+ }
2866
+ const params = { errorMap: ctx.common.contextualErrorMap };
2867
+ const fn = ctx.data;
2868
+ if (this._def.returns instanceof ZodPromise) {
2869
+ const me = this;
2870
+ return OK(async function(...args) {
2871
+ const error = new ZodError([]);
2872
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2873
+ error.addIssue(makeArgsIssue(args, e));
2874
+ throw error;
2875
+ });
2876
+ const result = await Reflect.apply(fn, this, parsedArgs);
2877
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
2878
+ error.addIssue(makeReturnsIssue(result, e));
2879
+ throw error;
2880
+ });
2881
+ return parsedReturns;
2882
+ });
2883
+ } else {
2884
+ const me = this;
2885
+ return OK(function(...args) {
2886
+ const parsedArgs = me._def.args.safeParse(args, params);
2887
+ if (!parsedArgs.success) {
2888
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2889
+ }
2890
+ const result = Reflect.apply(fn, this, parsedArgs.data);
2891
+ const parsedReturns = me._def.returns.safeParse(result, params);
2892
+ if (!parsedReturns.success) {
2893
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2894
+ }
2895
+ return parsedReturns.data;
2896
+ });
2897
+ }
2898
+ }
2899
+ parameters() {
2900
+ return this._def.args;
2901
+ }
2902
+ returnType() {
2903
+ return this._def.returns;
2904
+ }
2905
+ args(...items) {
2906
+ return new _ZodFunction(__spreadProps(__spreadValues({}, this._def), {
2907
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
2908
+ }));
2909
+ }
2910
+ returns(returnType) {
2911
+ return new _ZodFunction(__spreadProps(__spreadValues({}, this._def), {
2912
+ returns: returnType
2913
+ }));
2914
+ }
2915
+ implement(func) {
2916
+ const validatedFunc = this.parse(func);
2917
+ return validatedFunc;
2918
+ }
2919
+ strictImplement(func) {
2920
+ const validatedFunc = this.parse(func);
2921
+ return validatedFunc;
2922
+ }
2923
+ static create(args, returns, params) {
2924
+ return new _ZodFunction(__spreadValues({
2925
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
2926
+ returns: returns || ZodUnknown.create(),
2927
+ typeName: ZodFirstPartyTypeKind.ZodFunction
2928
+ }, processCreateParams(params)));
2929
+ }
2930
+ };
2931
+ var ZodLazy = class extends ZodType {
2932
+ get schema() {
2933
+ return this._def.getter();
2934
+ }
2935
+ _parse(input) {
2936
+ const { ctx } = this._processInputParams(input);
2937
+ const lazySchema = this._def.getter();
2938
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
2939
+ }
2940
+ };
2941
+ ZodLazy.create = (getter, params) => {
2942
+ return new ZodLazy(__spreadValues({
2943
+ getter,
2944
+ typeName: ZodFirstPartyTypeKind.ZodLazy
2945
+ }, processCreateParams(params)));
2946
+ };
2947
+ var ZodLiteral = class extends ZodType {
2948
+ _parse(input) {
2949
+ if (input.data !== this._def.value) {
2950
+ const ctx = this._getOrReturnCtx(input);
2951
+ addIssueToContext(ctx, {
2952
+ received: ctx.data,
2953
+ code: ZodIssueCode.invalid_literal,
2954
+ expected: this._def.value
2955
+ });
2956
+ return INVALID;
2957
+ }
2958
+ return { status: "valid", value: input.data };
2959
+ }
2960
+ get value() {
2961
+ return this._def.value;
2962
+ }
2963
+ };
2964
+ ZodLiteral.create = (value, params) => {
2965
+ return new ZodLiteral(__spreadValues({
2966
+ value,
2967
+ typeName: ZodFirstPartyTypeKind.ZodLiteral
2968
+ }, processCreateParams(params)));
2969
+ };
2970
+ function createZodEnum(values, params) {
2971
+ return new ZodEnum(__spreadValues({
2972
+ values,
2973
+ typeName: ZodFirstPartyTypeKind.ZodEnum
2974
+ }, processCreateParams(params)));
2975
+ }
2976
+ var ZodEnum = class _ZodEnum extends ZodType {
2977
+ _parse(input) {
2978
+ if (typeof input.data !== "string") {
2979
+ const ctx = this._getOrReturnCtx(input);
2980
+ const expectedValues = this._def.values;
2981
+ addIssueToContext(ctx, {
2982
+ expected: util.joinValues(expectedValues),
2983
+ received: ctx.parsedType,
2984
+ code: ZodIssueCode.invalid_type
2985
+ });
2986
+ return INVALID;
2987
+ }
2988
+ if (this._def.values.indexOf(input.data) === -1) {
2989
+ const ctx = this._getOrReturnCtx(input);
2990
+ const expectedValues = this._def.values;
2991
+ addIssueToContext(ctx, {
2992
+ received: ctx.data,
2993
+ code: ZodIssueCode.invalid_enum_value,
2994
+ options: expectedValues
2995
+ });
2996
+ return INVALID;
2997
+ }
2998
+ return OK(input.data);
2999
+ }
3000
+ get options() {
3001
+ return this._def.values;
3002
+ }
3003
+ get enum() {
3004
+ const enumValues = {};
3005
+ for (const val of this._def.values) {
3006
+ enumValues[val] = val;
3007
+ }
3008
+ return enumValues;
3009
+ }
3010
+ get Values() {
3011
+ const enumValues = {};
3012
+ for (const val of this._def.values) {
3013
+ enumValues[val] = val;
3014
+ }
3015
+ return enumValues;
3016
+ }
3017
+ get Enum() {
3018
+ const enumValues = {};
3019
+ for (const val of this._def.values) {
3020
+ enumValues[val] = val;
3021
+ }
3022
+ return enumValues;
3023
+ }
3024
+ extract(values) {
3025
+ return _ZodEnum.create(values);
3026
+ }
3027
+ exclude(values) {
3028
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3029
+ }
3030
+ };
3031
+ ZodEnum.create = createZodEnum;
3032
+ var ZodNativeEnum = class extends ZodType {
3033
+ _parse(input) {
3034
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3035
+ const ctx = this._getOrReturnCtx(input);
3036
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3037
+ const expectedValues = util.objectValues(nativeEnumValues);
3038
+ addIssueToContext(ctx, {
3039
+ expected: util.joinValues(expectedValues),
3040
+ received: ctx.parsedType,
3041
+ code: ZodIssueCode.invalid_type
3042
+ });
3043
+ return INVALID;
3044
+ }
3045
+ if (nativeEnumValues.indexOf(input.data) === -1) {
3046
+ const expectedValues = util.objectValues(nativeEnumValues);
3047
+ addIssueToContext(ctx, {
3048
+ received: ctx.data,
3049
+ code: ZodIssueCode.invalid_enum_value,
3050
+ options: expectedValues
3051
+ });
3052
+ return INVALID;
3053
+ }
3054
+ return OK(input.data);
3055
+ }
3056
+ get enum() {
3057
+ return this._def.values;
3058
+ }
3059
+ };
3060
+ ZodNativeEnum.create = (values, params) => {
3061
+ return new ZodNativeEnum(__spreadValues({
3062
+ values,
3063
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum
3064
+ }, processCreateParams(params)));
3065
+ };
3066
+ var ZodPromise = class extends ZodType {
3067
+ unwrap() {
3068
+ return this._def.type;
3069
+ }
3070
+ _parse(input) {
3071
+ const { ctx } = this._processInputParams(input);
3072
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3073
+ addIssueToContext(ctx, {
3074
+ code: ZodIssueCode.invalid_type,
3075
+ expected: ZodParsedType.promise,
3076
+ received: ctx.parsedType
3077
+ });
3078
+ return INVALID;
3079
+ }
3080
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3081
+ return OK(promisified.then((data) => {
3082
+ return this._def.type.parseAsync(data, {
3083
+ path: ctx.path,
3084
+ errorMap: ctx.common.contextualErrorMap
3085
+ });
3086
+ }));
3087
+ }
3088
+ };
3089
+ ZodPromise.create = (schema, params) => {
3090
+ return new ZodPromise(__spreadValues({
3091
+ type: schema,
3092
+ typeName: ZodFirstPartyTypeKind.ZodPromise
3093
+ }, processCreateParams(params)));
3094
+ };
3095
+ var ZodEffects = class extends ZodType {
3096
+ innerType() {
3097
+ return this._def.schema;
3098
+ }
3099
+ sourceType() {
3100
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3101
+ }
3102
+ _parse(input) {
3103
+ const { status, ctx } = this._processInputParams(input);
3104
+ const effect = this._def.effect || null;
3105
+ const checkCtx = {
3106
+ addIssue: (arg) => {
3107
+ addIssueToContext(ctx, arg);
3108
+ if (arg.fatal) {
3109
+ status.abort();
3110
+ } else {
3111
+ status.dirty();
3112
+ }
3113
+ },
3114
+ get path() {
3115
+ return ctx.path;
3116
+ }
3117
+ };
3118
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3119
+ if (effect.type === "preprocess") {
3120
+ const processed = effect.transform(ctx.data, checkCtx);
3121
+ if (ctx.common.issues.length) {
3122
+ return {
3123
+ status: "dirty",
3124
+ value: ctx.data
3125
+ };
3126
+ }
3127
+ if (ctx.common.async) {
3128
+ return Promise.resolve(processed).then((processed2) => {
3129
+ return this._def.schema._parseAsync({
3130
+ data: processed2,
3131
+ path: ctx.path,
3132
+ parent: ctx
3133
+ });
3134
+ });
3135
+ } else {
3136
+ return this._def.schema._parseSync({
3137
+ data: processed,
3138
+ path: ctx.path,
3139
+ parent: ctx
3140
+ });
3141
+ }
3142
+ }
3143
+ if (effect.type === "refinement") {
3144
+ const executeRefinement = (acc) => {
3145
+ const result = effect.refinement(acc, checkCtx);
3146
+ if (ctx.common.async) {
3147
+ return Promise.resolve(result);
3148
+ }
3149
+ if (result instanceof Promise) {
3150
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3151
+ }
3152
+ return acc;
3153
+ };
3154
+ if (ctx.common.async === false) {
3155
+ const inner = this._def.schema._parseSync({
3156
+ data: ctx.data,
3157
+ path: ctx.path,
3158
+ parent: ctx
3159
+ });
3160
+ if (inner.status === "aborted")
3161
+ return INVALID;
3162
+ if (inner.status === "dirty")
3163
+ status.dirty();
3164
+ executeRefinement(inner.value);
3165
+ return { status: status.value, value: inner.value };
3166
+ } else {
3167
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3168
+ if (inner.status === "aborted")
3169
+ return INVALID;
3170
+ if (inner.status === "dirty")
3171
+ status.dirty();
3172
+ return executeRefinement(inner.value).then(() => {
3173
+ return { status: status.value, value: inner.value };
3174
+ });
3175
+ });
3176
+ }
3177
+ }
3178
+ if (effect.type === "transform") {
3179
+ if (ctx.common.async === false) {
3180
+ const base = this._def.schema._parseSync({
3181
+ data: ctx.data,
3182
+ path: ctx.path,
3183
+ parent: ctx
3184
+ });
3185
+ if (!isValid(base))
3186
+ return base;
3187
+ const result = effect.transform(base.value, checkCtx);
3188
+ if (result instanceof Promise) {
3189
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3190
+ }
3191
+ return { status: status.value, value: result };
3192
+ } else {
3193
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3194
+ if (!isValid(base))
3195
+ return base;
3196
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
3197
+ });
3198
+ }
3199
+ }
3200
+ util.assertNever(effect);
3201
+ }
3202
+ };
3203
+ ZodEffects.create = (schema, effect, params) => {
3204
+ return new ZodEffects(__spreadValues({
3205
+ schema,
3206
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3207
+ effect
3208
+ }, processCreateParams(params)));
3209
+ };
3210
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3211
+ return new ZodEffects(__spreadValues({
3212
+ schema,
3213
+ effect: { type: "preprocess", transform: preprocess },
3214
+ typeName: ZodFirstPartyTypeKind.ZodEffects
3215
+ }, processCreateParams(params)));
3216
+ };
3217
+ var ZodOptional = class extends ZodType {
3218
+ _parse(input) {
3219
+ const parsedType = this._getType(input);
3220
+ if (parsedType === ZodParsedType.undefined) {
3221
+ return OK(void 0);
3222
+ }
3223
+ return this._def.innerType._parse(input);
3224
+ }
3225
+ unwrap() {
3226
+ return this._def.innerType;
3227
+ }
3228
+ };
3229
+ ZodOptional.create = (type, params) => {
3230
+ return new ZodOptional(__spreadValues({
3231
+ innerType: type,
3232
+ typeName: ZodFirstPartyTypeKind.ZodOptional
3233
+ }, processCreateParams(params)));
3234
+ };
3235
+ var ZodNullable = class extends ZodType {
3236
+ _parse(input) {
3237
+ const parsedType = this._getType(input);
3238
+ if (parsedType === ZodParsedType.null) {
3239
+ return OK(null);
3240
+ }
3241
+ return this._def.innerType._parse(input);
3242
+ }
3243
+ unwrap() {
3244
+ return this._def.innerType;
3245
+ }
3246
+ };
3247
+ ZodNullable.create = (type, params) => {
3248
+ return new ZodNullable(__spreadValues({
3249
+ innerType: type,
3250
+ typeName: ZodFirstPartyTypeKind.ZodNullable
3251
+ }, processCreateParams(params)));
3252
+ };
3253
+ var ZodDefault = class extends ZodType {
3254
+ _parse(input) {
3255
+ const { ctx } = this._processInputParams(input);
3256
+ let data = ctx.data;
3257
+ if (ctx.parsedType === ZodParsedType.undefined) {
3258
+ data = this._def.defaultValue();
3259
+ }
3260
+ return this._def.innerType._parse({
3261
+ data,
3262
+ path: ctx.path,
3263
+ parent: ctx
3264
+ });
3265
+ }
3266
+ removeDefault() {
3267
+ return this._def.innerType;
3268
+ }
3269
+ };
3270
+ ZodDefault.create = (type, params) => {
3271
+ return new ZodDefault(__spreadValues({
3272
+ innerType: type,
3273
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3274
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default
3275
+ }, processCreateParams(params)));
3276
+ };
3277
+ var ZodCatch = class extends ZodType {
3278
+ _parse(input) {
3279
+ const { ctx } = this._processInputParams(input);
3280
+ const newCtx = __spreadProps(__spreadValues({}, ctx), {
3281
+ common: __spreadProps(__spreadValues({}, ctx.common), {
3282
+ issues: []
3283
+ })
3284
+ });
3285
+ const result = this._def.innerType._parse({
3286
+ data: newCtx.data,
3287
+ path: newCtx.path,
3288
+ parent: __spreadValues({}, newCtx)
3289
+ });
3290
+ if (isAsync(result)) {
3291
+ return result.then((result2) => {
3292
+ return {
3293
+ status: "valid",
3294
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
3295
+ get error() {
3296
+ return new ZodError(newCtx.common.issues);
3297
+ },
3298
+ input: newCtx.data
3299
+ })
3300
+ };
3301
+ });
3302
+ } else {
3303
+ return {
3304
+ status: "valid",
3305
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3306
+ get error() {
3307
+ return new ZodError(newCtx.common.issues);
3308
+ },
3309
+ input: newCtx.data
3310
+ })
3311
+ };
3312
+ }
3313
+ }
3314
+ removeCatch() {
3315
+ return this._def.innerType;
3316
+ }
3317
+ };
3318
+ ZodCatch.create = (type, params) => {
3319
+ return new ZodCatch(__spreadValues({
3320
+ innerType: type,
3321
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3322
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch
3323
+ }, processCreateParams(params)));
3324
+ };
3325
+ var ZodNaN = class extends ZodType {
3326
+ _parse(input) {
3327
+ const parsedType = this._getType(input);
3328
+ if (parsedType !== ZodParsedType.nan) {
3329
+ const ctx = this._getOrReturnCtx(input);
3330
+ addIssueToContext(ctx, {
3331
+ code: ZodIssueCode.invalid_type,
3332
+ expected: ZodParsedType.nan,
3333
+ received: ctx.parsedType
3334
+ });
3335
+ return INVALID;
3336
+ }
3337
+ return { status: "valid", value: input.data };
3338
+ }
3339
+ };
3340
+ ZodNaN.create = (params) => {
3341
+ return new ZodNaN(__spreadValues({
3342
+ typeName: ZodFirstPartyTypeKind.ZodNaN
3343
+ }, processCreateParams(params)));
3344
+ };
3345
+ var BRAND = Symbol("zod_brand");
3346
+ var ZodBranded = class extends ZodType {
3347
+ _parse(input) {
3348
+ const { ctx } = this._processInputParams(input);
3349
+ const data = ctx.data;
3350
+ return this._def.type._parse({
3351
+ data,
3352
+ path: ctx.path,
3353
+ parent: ctx
3354
+ });
3355
+ }
3356
+ unwrap() {
3357
+ return this._def.type;
3358
+ }
3359
+ };
3360
+ var ZodPipeline = class _ZodPipeline extends ZodType {
3361
+ _parse(input) {
3362
+ const { status, ctx } = this._processInputParams(input);
3363
+ if (ctx.common.async) {
3364
+ const handleAsync = async () => {
3365
+ const inResult = await this._def.in._parseAsync({
3366
+ data: ctx.data,
3367
+ path: ctx.path,
3368
+ parent: ctx
3369
+ });
3370
+ if (inResult.status === "aborted")
3371
+ return INVALID;
3372
+ if (inResult.status === "dirty") {
3373
+ status.dirty();
3374
+ return DIRTY(inResult.value);
3375
+ } else {
3376
+ return this._def.out._parseAsync({
3377
+ data: inResult.value,
3378
+ path: ctx.path,
3379
+ parent: ctx
3380
+ });
3381
+ }
3382
+ };
3383
+ return handleAsync();
3384
+ } else {
3385
+ const inResult = this._def.in._parseSync({
3386
+ data: ctx.data,
3387
+ path: ctx.path,
3388
+ parent: ctx
3389
+ });
3390
+ if (inResult.status === "aborted")
3391
+ return INVALID;
3392
+ if (inResult.status === "dirty") {
3393
+ status.dirty();
3394
+ return {
3395
+ status: "dirty",
3396
+ value: inResult.value
3397
+ };
3398
+ } else {
3399
+ return this._def.out._parseSync({
3400
+ data: inResult.value,
3401
+ path: ctx.path,
3402
+ parent: ctx
3403
+ });
3404
+ }
3405
+ }
3406
+ }
3407
+ static create(a, b) {
3408
+ return new _ZodPipeline({
3409
+ in: a,
3410
+ out: b,
3411
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
3412
+ });
3413
+ }
3414
+ };
3415
+ var ZodReadonly = class extends ZodType {
3416
+ _parse(input) {
3417
+ const result = this._def.innerType._parse(input);
3418
+ if (isValid(result)) {
3419
+ result.value = Object.freeze(result.value);
3420
+ }
3421
+ return result;
3422
+ }
3423
+ };
3424
+ ZodReadonly.create = (type, params) => {
3425
+ return new ZodReadonly(__spreadValues({
3426
+ innerType: type,
3427
+ typeName: ZodFirstPartyTypeKind.ZodReadonly
3428
+ }, processCreateParams(params)));
3429
+ };
3430
+ var custom = (check, params = {}, fatal) => {
3431
+ if (check)
3432
+ return ZodAny.create().superRefine((data, ctx) => {
3433
+ var _a, _b;
3434
+ if (!check(data)) {
3435
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3436
+ const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3437
+ const p2 = typeof p === "string" ? { message: p } : p;
3438
+ ctx.addIssue(__spreadProps(__spreadValues({ code: "custom" }, p2), { fatal: _fatal }));
3439
+ }
3440
+ });
3441
+ return ZodAny.create();
3442
+ };
3443
+ var late = {
3444
+ object: ZodObject.lazycreate
3445
+ };
3446
+ var ZodFirstPartyTypeKind;
3447
+ (function(ZodFirstPartyTypeKind2) {
3448
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3449
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
3450
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
3451
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
3452
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
3453
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
3454
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
3455
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
3456
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
3457
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
3458
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
3459
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
3460
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
3461
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
3462
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
3463
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
3464
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3465
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
3466
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
3467
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
3468
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
3469
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
3470
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
3471
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
3472
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
3473
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
3474
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
3475
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
3476
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
3477
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
3478
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
3479
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
3480
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3481
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3482
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3483
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3484
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3485
+ var instanceOfType = (cls, params = {
3486
+ message: `Input not instance of ${cls.name}`
3487
+ }) => custom((data) => data instanceof cls, params);
3488
+ var stringType = ZodString.create;
3489
+ var numberType = ZodNumber.create;
3490
+ var nanType = ZodNaN.create;
3491
+ var bigIntType = ZodBigInt.create;
3492
+ var booleanType = ZodBoolean.create;
3493
+ var dateType = ZodDate.create;
3494
+ var symbolType = ZodSymbol.create;
3495
+ var undefinedType = ZodUndefined.create;
3496
+ var nullType = ZodNull.create;
3497
+ var anyType = ZodAny.create;
3498
+ var unknownType = ZodUnknown.create;
3499
+ var neverType = ZodNever.create;
3500
+ var voidType = ZodVoid.create;
3501
+ var arrayType = ZodArray.create;
3502
+ var objectType = ZodObject.create;
3503
+ var strictObjectType = ZodObject.strictCreate;
3504
+ var unionType = ZodUnion.create;
3505
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
3506
+ var intersectionType = ZodIntersection.create;
3507
+ var tupleType = ZodTuple.create;
3508
+ var recordType = ZodRecord.create;
3509
+ var mapType = ZodMap.create;
3510
+ var setType = ZodSet.create;
3511
+ var functionType = ZodFunction.create;
3512
+ var lazyType = ZodLazy.create;
3513
+ var literalType = ZodLiteral.create;
3514
+ var enumType = ZodEnum.create;
3515
+ var nativeEnumType = ZodNativeEnum.create;
3516
+ var promiseType = ZodPromise.create;
3517
+ var effectsType = ZodEffects.create;
3518
+ var optionalType = ZodOptional.create;
3519
+ var nullableType = ZodNullable.create;
3520
+ var preprocessType = ZodEffects.createWithPreprocess;
3521
+ var pipelineType = ZodPipeline.create;
3522
+ var ostring = () => stringType().optional();
3523
+ var onumber = () => numberType().optional();
3524
+ var oboolean = () => booleanType().optional();
3525
+ var coerce = {
3526
+ string: (arg) => ZodString.create(__spreadProps(__spreadValues({}, arg), { coerce: true })),
3527
+ number: (arg) => ZodNumber.create(__spreadProps(__spreadValues({}, arg), { coerce: true })),
3528
+ boolean: (arg) => ZodBoolean.create(__spreadProps(__spreadValues({}, arg), {
3529
+ coerce: true
3530
+ })),
3531
+ bigint: (arg) => ZodBigInt.create(__spreadProps(__spreadValues({}, arg), { coerce: true })),
3532
+ date: (arg) => ZodDate.create(__spreadProps(__spreadValues({}, arg), { coerce: true }))
3533
+ };
3534
+ var NEVER = INVALID;
3535
+ var z = /* @__PURE__ */ Object.freeze({
3536
+ __proto__: null,
3537
+ defaultErrorMap: errorMap,
3538
+ setErrorMap,
3539
+ getErrorMap,
3540
+ makeIssue,
3541
+ EMPTY_PATH,
3542
+ addIssueToContext,
3543
+ ParseStatus,
3544
+ INVALID,
3545
+ DIRTY,
3546
+ OK,
3547
+ isAborted,
3548
+ isDirty,
3549
+ isValid,
3550
+ isAsync,
3551
+ get util() {
3552
+ return util;
3553
+ },
3554
+ get objectUtil() {
3555
+ return objectUtil;
3556
+ },
3557
+ ZodParsedType,
3558
+ getParsedType,
3559
+ ZodType,
3560
+ ZodString,
3561
+ ZodNumber,
3562
+ ZodBigInt,
3563
+ ZodBoolean,
3564
+ ZodDate,
3565
+ ZodSymbol,
3566
+ ZodUndefined,
3567
+ ZodNull,
3568
+ ZodAny,
3569
+ ZodUnknown,
3570
+ ZodNever,
3571
+ ZodVoid,
3572
+ ZodArray,
3573
+ ZodObject,
3574
+ ZodUnion,
3575
+ ZodDiscriminatedUnion,
3576
+ ZodIntersection,
3577
+ ZodTuple,
3578
+ ZodRecord,
3579
+ ZodMap,
3580
+ ZodSet,
3581
+ ZodFunction,
3582
+ ZodLazy,
3583
+ ZodLiteral,
3584
+ ZodEnum,
3585
+ ZodNativeEnum,
3586
+ ZodPromise,
3587
+ ZodEffects,
3588
+ ZodTransformer: ZodEffects,
3589
+ ZodOptional,
3590
+ ZodNullable,
3591
+ ZodDefault,
3592
+ ZodCatch,
3593
+ ZodNaN,
3594
+ BRAND,
3595
+ ZodBranded,
3596
+ ZodPipeline,
3597
+ ZodReadonly,
3598
+ custom,
3599
+ Schema: ZodType,
3600
+ ZodSchema: ZodType,
3601
+ late,
3602
+ get ZodFirstPartyTypeKind() {
3603
+ return ZodFirstPartyTypeKind;
3604
+ },
3605
+ coerce,
3606
+ any: anyType,
3607
+ array: arrayType,
3608
+ bigint: bigIntType,
3609
+ boolean: booleanType,
3610
+ date: dateType,
3611
+ discriminatedUnion: discriminatedUnionType,
3612
+ effect: effectsType,
3613
+ "enum": enumType,
3614
+ "function": functionType,
3615
+ "instanceof": instanceOfType,
3616
+ intersection: intersectionType,
3617
+ lazy: lazyType,
3618
+ literal: literalType,
3619
+ map: mapType,
3620
+ nan: nanType,
3621
+ nativeEnum: nativeEnumType,
3622
+ never: neverType,
3623
+ "null": nullType,
3624
+ nullable: nullableType,
3625
+ number: numberType,
3626
+ object: objectType,
3627
+ oboolean,
3628
+ onumber,
3629
+ optional: optionalType,
3630
+ ostring,
3631
+ pipeline: pipelineType,
3632
+ preprocess: preprocessType,
3633
+ promise: promiseType,
3634
+ record: recordType,
3635
+ set: setType,
3636
+ strictObject: strictObjectType,
3637
+ string: stringType,
3638
+ symbol: symbolType,
3639
+ transformer: effectsType,
3640
+ tuple: tupleType,
3641
+ "undefined": undefinedType,
3642
+ union: unionType,
3643
+ unknown: unknownType,
3644
+ "void": voidType,
3645
+ NEVER,
3646
+ ZodIssueCode,
3647
+ quotelessJson,
3648
+ ZodError
3649
+ });
3650
+
3651
+ // src/zod/schemas.ts
3652
+ var imageSchema = z.object({
3653
+ text: z.string().optional(),
3654
+ url: z.string(),
3655
+ accessibilityDescription: z.string().optional()
3656
+ });
3657
+ var httpMethodSchema = z.union([
3658
+ z.literal("GET"),
3659
+ z.literal("POST"),
3660
+ z.literal("PUT"),
3661
+ z.literal("PATCH"),
3662
+ z.literal("DELETE")
3663
+ ]);
3664
+ var iconNamedSchema = z.object({
3665
+ name: z.string()
3666
+ });
3667
+ var contextSchema = z.union([
3668
+ z.literal("positive"),
3669
+ z.literal("neutral"),
3670
+ z.literal("warning"),
3671
+ z.literal("negative"),
3672
+ z.literal("success"),
3673
+ z.literal("failure"),
3674
+ z.literal("info"),
3675
+ z.literal("primary")
3676
+ ]);
3677
+ var iconTextSchema = z.object({
3678
+ text: z.string()
3679
+ });
3680
+ var sizeSchema = z.union([
3681
+ z.literal("xs"),
3682
+ z.literal("sm"),
3683
+ z.literal("md"),
3684
+ z.literal("lg"),
3685
+ z.literal("xl")
3686
+ ]);
3687
+ var alignSchema = z.union([z.literal("left"), z.literal("center"), z.literal("right")]);
3688
+ var iconSchema = z.union([iconNamedSchema, iconTextSchema]);
3689
+ var autocompleteTokenSchema = z.union([
3690
+ z.literal("on"),
3691
+ z.literal("name"),
3692
+ z.literal("name-prefix"),
3693
+ z.literal("given-name"),
3694
+ z.literal("additional-name"),
3695
+ z.literal("family-name"),
3696
+ z.literal("name-suffix"),
3697
+ z.literal("nickname"),
3698
+ z.literal("email"),
3699
+ z.literal("username"),
3700
+ z.literal("new-username"),
3701
+ z.literal("new-password"),
3702
+ z.literal("password"),
3703
+ z.literal("one-time-code"),
3704
+ z.literal("job-title"),
3705
+ z.literal("organization-name"),
3706
+ z.literal("full-street-address"),
3707
+ z.literal("street-address-line-1"),
3708
+ z.literal("street-address-line-2"),
3709
+ z.literal("street-address-line-3"),
3710
+ z.literal("address-level-1"),
3711
+ z.literal("address-level-2"),
3712
+ z.literal("address-level-3"),
3713
+ z.literal("address-level-4"),
3714
+ z.literal("country-code"),
3715
+ z.literal("country-name"),
3716
+ z.literal("postal-code"),
3717
+ z.literal("credit-card-name"),
3718
+ z.literal("credit-card-given-name"),
3719
+ z.literal("credit-card-middle-name"),
3720
+ z.literal("credit-card-family-name"),
3721
+ z.literal("credit-card-number"),
3722
+ z.literal("credit-card-expiration"),
3723
+ z.literal("credit-card-expiration-month"),
3724
+ z.literal("credit-card-expiration-year"),
3725
+ z.literal("credit-card-security-code"),
3726
+ z.literal("credit-card-type"),
3727
+ z.literal("transaction-currency"),
3728
+ z.literal("transaction-amount"),
3729
+ z.literal("language"),
3730
+ z.literal("birthdate"),
3731
+ z.literal("birthdate-day"),
3732
+ z.literal("birthdate-month"),
3733
+ z.literal("birthdate-year"),
3734
+ z.literal("gender"),
3735
+ z.literal("phone-number"),
3736
+ z.literal("phone-country-code"),
3737
+ z.literal("phone-national"),
3738
+ z.literal("phone-area-code"),
3739
+ z.literal("phone-local"),
3740
+ z.literal("phone-local-prefix"),
3741
+ z.literal("phone-local-suffix"),
3742
+ z.literal("phone-extension"),
3743
+ z.literal("url"),
3744
+ z.literal("photo"),
3745
+ z.literal("impp"),
3746
+ z.literal("shipping"),
3747
+ z.literal("billing"),
3748
+ z.literal("home"),
3749
+ z.literal("work"),
3750
+ z.literal("mobile"),
3751
+ z.literal("fax"),
3752
+ z.literal("pager")
3753
+ ]);
3754
+ var loadingIndicatorLayoutSchema = z.object({
3755
+ type: z.literal("loading-indicator"),
3756
+ size: sizeSchema.optional(),
3757
+ control: z.string().optional(),
3758
+ margin: sizeSchema.optional()
3759
+ });
3760
+ var alertLayoutSchema = z.object({
3761
+ type: z.literal("alert"),
3762
+ markdown: z.string(),
3763
+ context: contextSchema.optional(),
3764
+ control: z.string().optional(),
3765
+ margin: sizeSchema.optional()
3766
+ });
3767
+ var paragraphLayoutSchema = z.object({
3768
+ type: z.literal("paragraph"),
3769
+ text: z.string(),
3770
+ align: alignSchema.optional(),
3771
+ control: z.string().optional(),
3772
+ margin: sizeSchema.optional()
3773
+ });
3774
+ var dividerLayoutSchema = z.object({
3775
+ type: z.literal("divider"),
3776
+ control: z.string().optional(),
3777
+ margin: sizeSchema.optional()
3778
+ });
3779
+ var listLayoutStatusSchema = z.union([
3780
+ z.literal("warning"),
3781
+ z.literal("neutral"),
3782
+ z.literal("positive")
3783
+ ]);
3784
+ var formLayoutSchemaReferenceSchema = z.object({
3785
+ $ref: z.string()
3786
+ });
3787
+ var imageLayoutSchema = z.object({
3788
+ type: z.literal("image"),
3789
+ text: z.string().optional(),
3790
+ url: z.string(),
3791
+ size: sizeSchema.optional(),
3792
+ accessibilityDescription: z.string().optional(),
3793
+ control: z.string().optional(),
3794
+ margin: sizeSchema.optional()
3795
+ });
3796
+ var statusListLayoutStatusSchema = z.union([
3797
+ z.literal("not-done"),
3798
+ z.literal("pending"),
3799
+ z.literal("done")
3800
+ ]);
3801
+ var instructionsLayoutItemSchema = z.object({
3802
+ text: z.string(),
3803
+ context: contextSchema
3804
+ });
3805
+ var modalLayoutTriggerSchema = z.object({
3806
+ title: z.string()
3807
+ });
3808
+ var searchLayoutSchema = z.object({
3809
+ type: z.literal("search"),
3810
+ title: z.string(),
3811
+ method: httpMethodSchema,
3812
+ url: z.string(),
3813
+ param: z.string(),
3814
+ emptyMessage: z.string().optional(),
3815
+ control: z.string().optional(),
3816
+ margin: sizeSchema.optional()
3817
+ });
3818
+ var infoLayoutSchema = z.object({
3819
+ type: z.literal("info"),
3820
+ markdown: z.string(),
3821
+ align: alignSchema.optional(),
3822
+ control: z.string().optional(),
3823
+ margin: sizeSchema.optional()
3824
+ });
3825
+ var formLayoutSchema = z.object({
3826
+ type: z.literal("form"),
3827
+ schema: formLayoutSchemaReferenceSchema.optional(),
3828
+ schemaId: z.string(),
3829
+ control: z.string().optional(),
3830
+ margin: sizeSchema.optional()
3831
+ });
3832
+ var headingLayoutSchema = z.object({
3833
+ type: z.literal("heading"),
3834
+ text: z.string(),
3835
+ size: sizeSchema.optional(),
3836
+ align: alignSchema.optional(),
3837
+ control: z.string().optional(),
3838
+ margin: sizeSchema.optional()
3839
+ });
3840
+ var markdownLayoutSchema = z.object({
3841
+ type: z.literal("markdown"),
3842
+ content: z.string(),
3843
+ align: alignSchema.optional(),
3844
+ control: z.string().optional(),
3845
+ margin: sizeSchema.optional()
3846
+ });
3847
+ var columnsLayoutBiasSchema = z.union([
3848
+ z.literal("none"),
3849
+ z.literal("left"),
3850
+ z.literal("right")
3851
+ ]);
3852
+ var helpSchema = z.object({
3853
+ markdown: z.string()
3854
+ });
3855
+ var searchSearchRequestSchema = z.object({
3856
+ url: z.string(),
3857
+ method: httpMethodSchema,
3858
+ param: z.string(),
3859
+ query: z.string()
3860
+ });
3861
+ var jsonElementSchema = z.lazy(
3862
+ () => z.union([
3863
+ z.string(),
3864
+ z.number(),
3865
+ z.boolean(),
3866
+ z.record(jsonElementSchema),
3867
+ z.array(jsonElementSchema)
3868
+ ]).nullable()
3869
+ );
3870
+ var externalSchema = z.object({
3871
+ url: z.string()
3872
+ });
3873
+ var stepErrorSchema = z.object({
3874
+ error: z.string().optional(),
3875
+ validation: jsonElementSchema.optional()
3876
+ });
3877
+ var stringSchemaFormatSchema = z.union([
3878
+ z.literal("date"),
3879
+ z.literal("email"),
3880
+ z.literal("numeric"),
3881
+ z.literal("password"),
3882
+ z.literal("phone-number"),
3883
+ z.literal("base64url")
3884
+ ]);
3885
+ var summarySummariserSchema = z.object({
3886
+ defaultTitle: z.string().optional(),
3887
+ defaultDescription: z.string().optional(),
3888
+ defaultIcon: iconSchema.optional(),
3889
+ defaultImage: imageLayoutSchema.optional(),
3890
+ providesTitle: z.boolean().optional(),
3891
+ providesDescription: z.boolean().optional(),
3892
+ providesIcon: z.boolean().optional(),
3893
+ providesImage: z.boolean().optional()
3894
+ });
3895
+ var validateAsyncSchema = z.object({
3896
+ param: z.string(),
3897
+ method: httpMethodSchema,
3898
+ url: z.string()
3899
+ });
3900
+ var summaryProviderSchema = z.object({
3901
+ providesTitle: z.boolean().optional(),
3902
+ providesDescription: z.boolean().optional(),
3903
+ providesIcon: z.boolean().optional(),
3904
+ providesImage: z.boolean().optional()
3905
+ });
3906
+ var uploadSourceSchema = z.union([z.literal("camera"), z.literal("file")]);
3907
+ var navigationStackBehaviorSchema = z.union([
3908
+ z.literal("default"),
3909
+ z.literal("remove-previous"),
3910
+ z.literal("remove-all"),
3911
+ z.literal("replace-current")
3912
+ ]);
3913
+ var actionTypeSchema = z.union([
3914
+ z.literal("primary"),
3915
+ z.literal("secondary"),
3916
+ z.literal("link"),
3917
+ z.literal("positive"),
3918
+ z.literal("negative")
3919
+ ]);
3920
+ var summarySchema = z.union([summaryProviderSchema, summarySummariserSchema]);
3921
+ var actionSchema = z.object({
3922
+ title: z.string().optional(),
3923
+ type: actionTypeSchema.optional(),
3924
+ disabled: z.boolean().optional(),
3925
+ $id: z.string().optional(),
3926
+ $ref: z.string().optional(),
3927
+ id: z.string().optional(),
3928
+ url: z.string().optional(),
3929
+ method: httpMethodSchema.optional(),
3930
+ exit: z.boolean().optional(),
3931
+ result: jsonElementSchema.optional(),
3932
+ data: jsonElementSchema.optional(),
3933
+ timeout: z.number().optional(),
3934
+ skipValidation: z.boolean().optional()
3935
+ });
3936
+ var listLayoutItemSchema = z.object({
3937
+ title: z.string(),
3938
+ description: z.string().optional(),
3939
+ icon: iconSchema,
3940
+ status: listLayoutStatusSchema.optional()
3941
+ });
3942
+ var decisionLayoutOptionSchema = z.object({
3943
+ action: actionSchema,
3944
+ title: z.string(),
3945
+ description: z.string().optional(),
3946
+ disabled: z.boolean().optional(),
3947
+ icon: iconSchema.optional(),
3948
+ image: imageLayoutSchema.optional()
3949
+ });
3950
+ var statusListLayoutItemSchema = z.object({
3951
+ title: z.string(),
3952
+ description: z.string().optional(),
3953
+ icon: iconSchema,
3954
+ status: statusListLayoutStatusSchema.optional()
3955
+ });
3956
+ var instructionsLayoutSchema = z.object({
3957
+ type: z.literal("instructions"),
3958
+ title: z.string().optional(),
3959
+ items: z.array(instructionsLayoutItemSchema),
3960
+ control: z.string().optional(),
3961
+ margin: sizeSchema.optional()
3962
+ });
3963
+ var buttonLayoutSchema = z.object({
3964
+ type: z.literal("button"),
3965
+ size: sizeSchema.optional(),
3966
+ title: z.string().optional(),
3967
+ action: actionSchema,
3968
+ context: contextSchema.optional(),
3969
+ disabled: z.boolean().optional(),
3970
+ pinOrder: z.number().optional(),
3971
+ control: z.string().optional(),
3972
+ margin: sizeSchema.optional()
3973
+ });
3974
+ var reviewLayoutFieldSchema = z.object({
3975
+ label: z.string(),
3976
+ value: z.string(),
3977
+ help: helpSchema.optional()
3978
+ });
3979
+ var searchResultSearchSchema = z.object({
3980
+ type: z.literal("search"),
3981
+ title: z.string(),
3982
+ description: z.string().optional(),
3983
+ icon: iconSchema.optional(),
3984
+ image: imageLayoutSchema.optional(),
3985
+ value: searchSearchRequestSchema
3986
+ });
3987
+ var searchResultActionSchema = z.object({
3988
+ type: z.literal("action"),
3989
+ title: z.string(),
3990
+ description: z.string().optional(),
3991
+ icon: iconSchema.optional(),
3992
+ image: imageLayoutSchema.optional(),
3993
+ value: actionSchema
3994
+ });
3995
+ var actionResponseBodySchema = z.object({
3996
+ action: actionSchema
3997
+ });
3998
+ var errorResponseBodySchema = z.object({
3999
+ refreshFormUrl: z.string().optional(),
4000
+ analytics: z.record(z.string()).optional(),
4001
+ error: z.string().optional(),
4002
+ validation: jsonElementSchema.optional(),
4003
+ refreshUrl: z.string().optional()
4004
+ });
4005
+ var linkHandlerSchema = z.object({
4006
+ regexPattern: z.string(),
4007
+ action: actionSchema
4008
+ });
4009
+ var blobSchemaSchema = z.object({
4010
+ type: z.literal("blob"),
4011
+ promoted: z.boolean().optional(),
4012
+ $id: z.string().optional(),
4013
+ title: z.string().optional(),
4014
+ description: z.string().optional(),
4015
+ control: z.string().optional(),
4016
+ hidden: z.boolean().optional(),
4017
+ icon: iconSchema.optional(),
4018
+ image: imageSchema.optional(),
4019
+ keywords: z.array(z.string()).optional(),
4020
+ summary: summaryProviderSchema.optional(),
4021
+ analyticsId: z.string().optional(),
4022
+ validationAsync: validateAsyncSchema.optional(),
4023
+ validationMessages: z.record(z.string()).optional(),
4024
+ alert: alertLayoutSchema.optional(),
4025
+ cameraConfig: jsonElementSchema.optional(),
4026
+ accepts: z.array(z.string()).optional(),
4027
+ maxSize: z.number().optional(),
4028
+ source: uploadSourceSchema.optional(),
4029
+ disabled: z.boolean().optional()
4030
+ });
4031
+ var constSchemaSchema = z.object({
4032
+ hidden: z.boolean().optional(),
4033
+ alert: alertLayoutSchema.optional(),
4034
+ control: z.string().optional(),
4035
+ promoted: z.boolean().optional(),
4036
+ $id: z.string().optional(),
4037
+ const: jsonElementSchema,
4038
+ title: z.string().optional(),
4039
+ description: z.string().optional(),
4040
+ icon: iconSchema.optional(),
4041
+ image: imageSchema.optional(),
4042
+ keywords: z.array(z.string()).optional(),
4043
+ summary: summaryProviderSchema.optional(),
4044
+ analyticsId: z.string().optional(),
4045
+ disabled: z.boolean().optional()
4046
+ });
4047
+ var pollingOnErrorSchema = z.object({
4048
+ action: actionSchema
4049
+ });
4050
+ var navigationBackBehaviourSchema = z.object({
4051
+ title: z.string().optional(),
4052
+ action: actionSchema
4053
+ });
4054
+ var reviewLayoutCallToActionSchema = z.object({
4055
+ title: z.string(),
4056
+ action: actionSchema
4057
+ });
4058
+ var listLayoutSchema = z.object({
4059
+ type: z.literal("list"),
4060
+ items: z.array(listLayoutItemSchema),
4061
+ title: z.string().optional(),
4062
+ control: z.string().optional(),
4063
+ margin: sizeSchema.optional()
4064
+ });
4065
+ var decisionLayoutSchema = z.object({
4066
+ type: z.literal("decision"),
4067
+ options: z.array(decisionLayoutOptionSchema),
4068
+ control: z.string().optional(),
4069
+ margin: sizeSchema.optional()
4070
+ });
4071
+ var statusListLayoutSchema = z.object({
4072
+ type: z.literal("status-list"),
4073
+ items: z.array(statusListLayoutItemSchema),
4074
+ title: z.string().optional(),
4075
+ control: z.string().optional(),
4076
+ margin: sizeSchema.optional()
4077
+ });
4078
+ var reviewLayoutSchema = z.object({
4079
+ type: z.literal("review"),
4080
+ orientation: z.string().optional(),
4081
+ action: actionSchema.optional(),
4082
+ fields: z.array(reviewLayoutFieldSchema),
4083
+ title: z.string().optional(),
4084
+ callToAction: reviewLayoutCallToActionSchema.optional(),
4085
+ control: z.string().optional(),
4086
+ margin: sizeSchema.optional()
4087
+ });
4088
+ var searchResultSchema = z.union([searchResultActionSchema, searchResultSearchSchema]);
4089
+ var pollingSchema = z.object({
4090
+ url: z.string(),
4091
+ interval: z.number(),
4092
+ maxAttempts: z.number(),
4093
+ onError: pollingOnErrorSchema
4094
+ });
4095
+ var navigationSchema = z.object({
4096
+ backButton: navigationBackBehaviourSchema.optional(),
4097
+ back: navigationBackBehaviourSchema.optional(),
4098
+ stackBehavior: navigationStackBehaviorSchema.optional()
4099
+ });
4100
+ var searchResponseBodySchema = z.object({
4101
+ results: z.array(searchResultSchema)
4102
+ });
4103
+ var layoutSchema = z.lazy(
4104
+ () => z.union([
4105
+ alertLayoutSchema,
4106
+ boxLayoutSchema,
4107
+ buttonLayoutSchema,
4108
+ columnsLayoutSchema,
4109
+ decisionLayoutSchema,
4110
+ dividerLayoutSchema,
4111
+ formLayoutSchema,
4112
+ headingLayoutSchema,
4113
+ imageLayoutSchema,
4114
+ infoLayoutSchema,
4115
+ instructionsLayoutSchema,
4116
+ listLayoutSchema,
4117
+ loadingIndicatorLayoutSchema,
4118
+ markdownLayoutSchema,
4119
+ modalLayoutSchema,
4120
+ paragraphLayoutSchema,
4121
+ reviewLayoutSchema,
4122
+ searchLayoutSchema,
4123
+ statusListLayoutSchema
4124
+ ])
4125
+ );
4126
+ var boxLayoutSchema = z.lazy(
4127
+ () => z.object({
4128
+ type: z.literal("box"),
4129
+ components: z.array(layoutSchema),
4130
+ width: sizeSchema.optional(),
4131
+ border: z.boolean().optional(),
4132
+ control: z.string().optional(),
4133
+ margin: sizeSchema.optional()
4134
+ })
4135
+ );
4136
+ var columnsLayoutSchema = z.lazy(
4137
+ () => z.object({
4138
+ type: z.literal("columns"),
4139
+ left: z.array(layoutSchema),
4140
+ right: z.array(layoutSchema),
4141
+ bias: columnsLayoutBiasSchema.optional(),
4142
+ control: z.string().optional(),
4143
+ margin: sizeSchema.optional()
4144
+ })
4145
+ );
4146
+ var modalLayoutSchema = z.lazy(
4147
+ () => z.object({
4148
+ type: z.literal("modal"),
4149
+ control: z.string().optional(),
4150
+ margin: sizeSchema.optional(),
4151
+ trigger: modalLayoutTriggerSchema,
4152
+ content: modalLayoutContentSchema
4153
+ })
4154
+ );
4155
+ var modalLayoutContentSchema = z.lazy(
4156
+ () => z.object({
4157
+ components: z.array(layoutSchema)
4158
+ })
4159
+ );
4160
+ var stepSchema = z.lazy(
4161
+ () => z.object({
4162
+ key: z.string().optional(),
4163
+ type: z.string().optional(),
4164
+ description: z.string().optional(),
4165
+ actions: z.array(actionSchema).optional(),
4166
+ refreshFormUrl: z.string().optional(),
4167
+ id: z.string(),
4168
+ title: z.string(),
4169
+ schemas: z.array(schemaSchema),
4170
+ layout: z.array(layoutSchema),
4171
+ model: jsonElementSchema.optional(),
4172
+ external: externalSchema.optional(),
4173
+ polling: pollingSchema.optional(),
4174
+ linkHandlers: z.array(linkHandlerSchema).optional(),
4175
+ analytics: z.record(z.string()).optional(),
4176
+ errors: stepErrorSchema.optional(),
4177
+ navigation: navigationSchema.optional(),
4178
+ refreshUrl: z.string().optional()
4179
+ })
4180
+ );
4181
+ var schemaSchema = z.lazy(
4182
+ () => z.union([
4183
+ allOfSchemaSchema,
4184
+ arraySchemaSchema,
4185
+ blobSchemaSchema,
4186
+ booleanSchemaSchema,
4187
+ constSchemaSchema,
4188
+ integerSchemaSchema,
4189
+ numberSchemaSchema,
4190
+ objectSchemaSchema,
4191
+ oneOfSchemaSchema,
4192
+ stringSchemaSchema
4193
+ ])
4194
+ );
4195
+ var allOfSchemaSchema = z.lazy(
4196
+ () => z.object({
4197
+ disabled: z.boolean().optional(),
4198
+ promoted: z.boolean().optional(),
4199
+ allOf: z.array(schemaSchema),
4200
+ $id: z.string().optional(),
4201
+ title: z.string().optional(),
4202
+ description: z.string().optional(),
4203
+ control: z.string().optional(),
4204
+ hidden: z.boolean().optional(),
4205
+ icon: iconSchema.optional(),
4206
+ image: imageSchema.optional(),
4207
+ keywords: z.array(z.string()).optional(),
4208
+ summary: summaryProviderSchema.optional(),
4209
+ analyticsId: z.string().optional(),
4210
+ alert: alertLayoutSchema.optional()
4211
+ })
4212
+ );
4213
+ var arraySchemaSchema = z.lazy(
4214
+ () => z.union([arraySchemaListSchema, arraySchemaTupleSchema])
4215
+ );
4216
+ var booleanSchemaSchema = z.lazy(
4217
+ () => z.object({
4218
+ type: z.literal("boolean"),
4219
+ autofillProvider: z.string().optional(),
4220
+ promoted: z.boolean().optional(),
4221
+ refreshFormOnChange: z.boolean().optional(),
4222
+ refreshUrl: z.string().optional(),
4223
+ refreshFormUrl: z.string().optional(),
4224
+ $id: z.string().optional(),
4225
+ title: z.string().optional(),
4226
+ description: z.string().optional(),
4227
+ control: z.string().optional(),
4228
+ default: z.boolean().optional(),
4229
+ hidden: z.boolean().optional(),
4230
+ disabled: z.boolean().optional(),
4231
+ icon: iconSchema.optional(),
4232
+ image: imageSchema.optional(),
4233
+ keywords: z.array(z.string()).optional(),
4234
+ summary: summaryProviderSchema.optional(),
4235
+ analyticsId: z.string().optional(),
4236
+ persistAsync: persistAsyncSchema.optional(),
4237
+ refreshStepOnChange: z.boolean().optional(),
4238
+ validationAsync: validateAsyncSchema.optional(),
4239
+ alert: alertLayoutSchema.optional(),
4240
+ autofillKey: z.string().optional(),
4241
+ help: helpSchema.optional()
4242
+ })
4243
+ );
4244
+ var integerSchemaSchema = z.lazy(
4245
+ () => z.object({
4246
+ type: z.literal("integer"),
4247
+ autofillProvider: z.string().optional(),
4248
+ promoted: z.boolean().optional(),
4249
+ refreshFormOnChange: z.boolean().optional(),
4250
+ refreshUrl: z.string().optional(),
4251
+ refreshFormUrl: z.string().optional(),
4252
+ placeholder: z.string().optional(),
4253
+ minimum: z.number().optional(),
4254
+ maximum: z.number().optional(),
4255
+ $id: z.string().optional(),
4256
+ title: z.string().optional(),
4257
+ description: z.string().optional(),
4258
+ control: z.string().optional(),
4259
+ default: z.number().optional(),
4260
+ hidden: z.boolean().optional(),
4261
+ disabled: z.boolean().optional(),
4262
+ icon: iconSchema.optional(),
4263
+ image: imageSchema.optional(),
4264
+ keywords: z.array(z.string()).optional(),
4265
+ summary: summaryProviderSchema.optional(),
4266
+ analyticsId: z.string().optional(),
4267
+ persistAsync: persistAsyncSchema.optional(),
4268
+ refreshStepOnChange: z.boolean().optional(),
4269
+ validationAsync: validateAsyncSchema.optional(),
4270
+ validationMessages: z.record(z.string()).optional(),
4271
+ alert: alertLayoutSchema.optional(),
4272
+ autocompleteHint: z.array(autocompleteTokenSchema).optional(),
4273
+ autofillKey: z.string().optional(),
4274
+ help: helpSchema.optional()
4275
+ })
4276
+ );
4277
+ var numberSchemaSchema = z.lazy(
4278
+ () => z.object({
4279
+ type: z.literal("number"),
4280
+ autofillProvider: z.string().optional(),
4281
+ promoted: z.boolean().optional(),
4282
+ refreshFormOnChange: z.boolean().optional(),
4283
+ refreshUrl: z.string().optional(),
4284
+ refreshFormUrl: z.string().optional(),
4285
+ placeholder: z.string().optional(),
4286
+ minimum: z.number().optional(),
4287
+ maximum: z.number().optional(),
4288
+ $id: z.string().optional(),
4289
+ title: z.string().optional(),
4290
+ description: z.string().optional(),
4291
+ control: z.string().optional(),
4292
+ default: z.number().optional(),
4293
+ hidden: z.boolean().optional(),
4294
+ disabled: z.boolean().optional(),
4295
+ icon: iconSchema.optional(),
4296
+ image: imageSchema.optional(),
4297
+ keywords: z.array(z.string()).optional(),
4298
+ summary: summaryProviderSchema.optional(),
4299
+ analyticsId: z.string().optional(),
4300
+ persistAsync: persistAsyncSchema.optional(),
4301
+ refreshStepOnChange: z.boolean().optional(),
4302
+ validationAsync: validateAsyncSchema.optional(),
4303
+ validationMessages: z.record(z.string()).optional(),
4304
+ alert: alertLayoutSchema.optional(),
4305
+ autocompleteHint: z.array(autocompleteTokenSchema).optional(),
4306
+ autofillKey: z.string().optional(),
4307
+ help: helpSchema.optional()
4308
+ })
4309
+ );
4310
+ var objectSchemaSchema = z.lazy(
4311
+ () => z.object({
4312
+ type: z.literal("object"),
4313
+ disabled: z.boolean().optional(),
4314
+ promoted: z.boolean().optional(),
4315
+ help: helpSchema.optional(),
4316
+ properties: z.record(schemaSchema),
4317
+ displayOrder: z.array(z.string()),
4318
+ required: z.array(z.string()).optional(),
4319
+ $id: z.string().optional(),
4320
+ title: z.string().optional(),
4321
+ description: z.string().optional(),
4322
+ control: z.string().optional(),
4323
+ hidden: z.boolean().optional(),
4324
+ icon: iconSchema.optional(),
4325
+ image: imageSchema.optional(),
4326
+ keywords: z.array(z.string()).optional(),
4327
+ summary: summaryProviderSchema.optional(),
4328
+ analyticsId: z.string().optional(),
4329
+ alert: alertLayoutSchema.optional()
4330
+ })
4331
+ );
4332
+ var oneOfSchemaSchema = z.lazy(
4333
+ () => z.object({
4334
+ autofillProvider: z.string().optional(),
4335
+ promoted: z.boolean().optional(),
4336
+ refreshFormOnChange: z.boolean().optional(),
4337
+ refreshUrl: z.string().optional(),
4338
+ refreshFormUrl: z.string().optional(),
4339
+ promotion: jsonElementSchema.optional(),
4340
+ oneOf: z.array(schemaSchema),
4341
+ placeholder: z.string().optional(),
4342
+ $id: z.string().optional(),
4343
+ title: z.string().optional(),
4344
+ description: z.string().optional(),
4345
+ control: z.string().optional(),
4346
+ default: jsonElementSchema.optional(),
4347
+ hidden: z.boolean().optional(),
4348
+ icon: iconSchema.optional(),
4349
+ image: imageSchema.optional(),
4350
+ keywords: z.array(z.string()).optional(),
4351
+ summary: summaryProviderSchema.optional(),
4352
+ analyticsId: z.string().optional(),
4353
+ refreshStepOnChange: z.boolean().optional(),
4354
+ alert: alertLayoutSchema.optional(),
4355
+ help: helpSchema.optional(),
4356
+ autocompleteHint: z.array(autocompleteTokenSchema).optional(),
4357
+ autofillKey: z.string().optional(),
4358
+ validationMessages: z.record(z.string()).optional(),
4359
+ disabled: z.boolean().optional()
4360
+ })
4361
+ );
4362
+ var stringSchemaSchema = z.lazy(
4363
+ () => z.object({
4364
+ type: z.literal("string"),
4365
+ autofillProvider: z.string().optional(),
4366
+ promoted: z.boolean().optional(),
4367
+ refreshFormOnChange: z.boolean().optional(),
4368
+ refreshUrl: z.string().optional(),
4369
+ refreshFormUrl: z.string().optional(),
4370
+ format: stringSchemaFormatSchema.optional(),
4371
+ displayFormat: z.string().optional(),
4372
+ placeholder: z.string().optional(),
4373
+ minLength: z.number().optional(),
4374
+ maxLength: z.number().optional(),
4375
+ minimum: z.string().optional(),
4376
+ maximum: z.string().optional(),
4377
+ pattern: z.string().optional(),
4378
+ $id: z.string().optional(),
4379
+ title: z.string().optional(),
4380
+ description: z.string().optional(),
4381
+ control: z.string().optional(),
4382
+ default: z.string().optional(),
4383
+ hidden: z.boolean().optional(),
4384
+ disabled: z.boolean().optional(),
4385
+ icon: iconSchema.optional(),
4386
+ image: imageSchema.optional(),
4387
+ keywords: z.array(z.string()).optional(),
4388
+ summary: summaryProviderSchema.optional(),
4389
+ analyticsId: z.string().optional(),
4390
+ persistAsync: persistAsyncSchema.optional(),
4391
+ refreshStepOnChange: z.boolean().optional(),
4392
+ validationAsync: validateAsyncSchema.optional(),
4393
+ validationMessages: z.record(z.string()).optional(),
4394
+ alert: alertLayoutSchema.optional(),
4395
+ cameraConfig: jsonElementSchema.optional(),
4396
+ accepts: z.array(z.string()).optional(),
4397
+ maxSize: z.number().optional(),
4398
+ source: uploadSourceSchema.optional(),
4399
+ autocompleteHint: z.array(autocompleteTokenSchema).optional(),
4400
+ autofillKey: z.string().optional(),
4401
+ help: helpSchema.optional()
4402
+ })
4403
+ );
4404
+ var arraySchemaListSchema = z.lazy(
4405
+ () => z.object({
4406
+ type: z.literal("array"),
4407
+ promoted: z.boolean().optional(),
4408
+ $id: z.string().optional(),
4409
+ items: schemaSchema,
4410
+ addItemTitle: z.string(),
4411
+ editItemTitle: z.string(),
4412
+ minItems: z.number().optional(),
4413
+ maxItems: z.number().optional(),
4414
+ placeholder: z.string().optional(),
4415
+ title: z.string().optional(),
4416
+ description: z.string().optional(),
4417
+ control: z.string().optional(),
4418
+ hidden: z.boolean().optional(),
4419
+ icon: iconSchema.optional(),
4420
+ image: imageSchema.optional(),
4421
+ keywords: z.array(z.string()).optional(),
4422
+ summary: summarySummariserSchema.optional(),
4423
+ analyticsId: z.string().optional(),
4424
+ persistAsync: persistAsyncSchema.optional(),
4425
+ validationAsync: validateAsyncSchema.optional(),
4426
+ alert: alertLayoutSchema.optional(),
4427
+ validationMessages: z.record(z.string()).optional(),
4428
+ disabled: z.boolean().optional()
4429
+ })
4430
+ );
4431
+ var persistAsyncSchema = z.lazy(
4432
+ () => z.object({
4433
+ param: z.string(),
4434
+ idProperty: z.string(),
4435
+ schema: schemaSchema,
4436
+ url: z.string(),
4437
+ method: httpMethodSchema
4438
+ })
4439
+ );
4440
+ var arraySchemaTupleSchema = z.lazy(
4441
+ () => z.object({
4442
+ type: z.literal("array"),
4443
+ promoted: z.boolean().optional(),
4444
+ $id: z.string().optional(),
4445
+ items: z.array(schemaSchema),
4446
+ title: z.string().optional(),
4447
+ description: z.string().optional(),
4448
+ control: z.string().optional(),
4449
+ hidden: z.boolean().optional(),
4450
+ icon: iconSchema.optional(),
4451
+ image: imageSchema.optional(),
4452
+ keywords: z.array(z.string()).optional(),
4453
+ summary: summaryProviderSchema.optional(),
4454
+ analyticsId: z.string().optional(),
4455
+ persistAsync: persistAsyncSchema.optional(),
4456
+ validationAsync: validateAsyncSchema.optional(),
4457
+ alert: alertLayoutSchema.optional()
4458
+ })
4459
+ );
4460
+
4461
+ // src/zod/validators.ts
4462
+ var validateStep = (step) => validate(step, stepSchema);
4463
+ var validateActionResponse = (response) => validate(response, actionResponseBodySchema);
4464
+ var validateErrorResponse = (response) => validate(response, errorResponseBodySchema);
4465
+ var validate = (value, schema) => {
4466
+ const parseResult = schema.safeParse(value);
4467
+ if (parseResult.success) {
4468
+ return { valid: true };
4469
+ }
4470
+ return {
4471
+ valid: false,
4472
+ errors: JSON.stringify(flattenZodErrors(parseResult.error.errors))
4473
+ };
4474
+ };
4475
+ var flattenZodErrors = (zodError) => zodError.flatMap((e) => {
4476
+ if (e.code === "invalid_type") {
4477
+ return e;
4478
+ }
4479
+ if (e.code === "invalid_union") {
4480
+ return e.unionErrors.flatMap(
4481
+ (ue) => ue.issues.every((issue) => issue.code !== "invalid_literal") ? flattenZodErrors(ue.issues) : void 0
4482
+ );
4483
+ }
4484
+ return void 0;
4485
+ }).filter(Boolean);
4486
+ export {
4487
+ validateActionResponse,
4488
+ validateErrorResponse,
4489
+ validateStep
4490
+ };