@cloudflare/deploy-helpers 0.5.0 → 0.5.1

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/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { __commonJS, __name, __require, __toESM, fetchResult, fetchListResult, logger, confirm, fetchPagedListResult, prompt, select } from './chunk-HE3NAOND.mjs';
2
- export { initDeployHelpersContext } from './chunk-HE3NAOND.mjs';
1
+ import { __commonJS, __name, __require, __toESM, fetchResult, __export, fetchListResult, logger, confirm, fetchPagedListResult, prompt, select } from './chunk-E3FPD2SU.mjs';
2
+ export { initDeployHelpersContext } from './chunk-E3FPD2SU.mjs';
3
3
  import assert4 from 'node:assert';
4
4
  import { readFileSync, mkdirSync, writeFileSync, createReadStream } from 'node:fs';
5
5
  import * as path from 'node:path';
@@ -23,7 +23,6 @@ import { sync } from 'command-exists';
23
23
  import readline from 'node:readline';
24
24
  import { parse } from 'dotenv';
25
25
  import { stripVTControlCharacters } from 'node:util';
26
- import { z } from 'zod';
27
26
  import { getFreshSourceMapSupport, getNodeCompat } from 'miniflare';
28
27
  import { createHash } from 'node:crypto';
29
28
 
@@ -2196,7 +2195,7 @@ var require_colors = __commonJS({
2196
2195
  var colors = {};
2197
2196
  module["exports"] = colors;
2198
2197
  colors.themes = {};
2199
- var util = __require("util");
2198
+ var util2 = __require("util");
2200
2199
  var ansiStyles = colors.styles = require_styles();
2201
2200
  var defineProps = Object.defineProperties;
2202
2201
  var newLineRegex = new RegExp(/[\r\n]+/g);
@@ -2260,7 +2259,7 @@ var require_colors = __commonJS({
2260
2259
  if (arg != null && arg.constructor === String) {
2261
2260
  return arg;
2262
2261
  } else {
2263
- return util.inspect(arg);
2262
+ return util2.inspect(arg);
2264
2263
  }
2265
2264
  }).join(" ");
2266
2265
  if (!colors.enabled || !str) {
@@ -9464,65 +9463,4250 @@ See https://developers.cloudflare.com/workers/configuration/secrets/#secrets-on-
9464
9463
  }
9465
9464
  }
9466
9465
  __name(handleMissingSecretsError, "handleMissingSecretsError");
9467
- var InternalConfigSchema = z.object({
9468
- account_id: z.number().optional(),
9469
- script_id: z.number().optional(),
9470
- debug: z.boolean().optional()
9466
+
9467
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
9468
+ var external_exports = {};
9469
+ __export(external_exports, {
9470
+ BRAND: () => BRAND,
9471
+ DIRTY: () => DIRTY,
9472
+ EMPTY_PATH: () => EMPTY_PATH,
9473
+ INVALID: () => INVALID,
9474
+ NEVER: () => NEVER,
9475
+ OK: () => OK,
9476
+ ParseStatus: () => ParseStatus,
9477
+ Schema: () => ZodType,
9478
+ ZodAny: () => ZodAny,
9479
+ ZodArray: () => ZodArray,
9480
+ ZodBigInt: () => ZodBigInt,
9481
+ ZodBoolean: () => ZodBoolean,
9482
+ ZodBranded: () => ZodBranded,
9483
+ ZodCatch: () => ZodCatch,
9484
+ ZodDate: () => ZodDate,
9485
+ ZodDefault: () => ZodDefault,
9486
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
9487
+ ZodEffects: () => ZodEffects,
9488
+ ZodEnum: () => ZodEnum,
9489
+ ZodError: () => ZodError,
9490
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
9491
+ ZodFunction: () => ZodFunction,
9492
+ ZodIntersection: () => ZodIntersection,
9493
+ ZodIssueCode: () => ZodIssueCode,
9494
+ ZodLazy: () => ZodLazy,
9495
+ ZodLiteral: () => ZodLiteral,
9496
+ ZodMap: () => ZodMap,
9497
+ ZodNaN: () => ZodNaN,
9498
+ ZodNativeEnum: () => ZodNativeEnum,
9499
+ ZodNever: () => ZodNever,
9500
+ ZodNull: () => ZodNull,
9501
+ ZodNullable: () => ZodNullable,
9502
+ ZodNumber: () => ZodNumber,
9503
+ ZodObject: () => ZodObject,
9504
+ ZodOptional: () => ZodOptional,
9505
+ ZodParsedType: () => ZodParsedType,
9506
+ ZodPipeline: () => ZodPipeline,
9507
+ ZodPromise: () => ZodPromise,
9508
+ ZodReadonly: () => ZodReadonly,
9509
+ ZodRecord: () => ZodRecord,
9510
+ ZodSchema: () => ZodType,
9511
+ ZodSet: () => ZodSet,
9512
+ ZodString: () => ZodString,
9513
+ ZodSymbol: () => ZodSymbol,
9514
+ ZodTransformer: () => ZodEffects,
9515
+ ZodTuple: () => ZodTuple,
9516
+ ZodType: () => ZodType,
9517
+ ZodUndefined: () => ZodUndefined,
9518
+ ZodUnion: () => ZodUnion,
9519
+ ZodUnknown: () => ZodUnknown,
9520
+ ZodVoid: () => ZodVoid,
9521
+ addIssueToContext: () => addIssueToContext,
9522
+ any: () => anyType,
9523
+ array: () => arrayType,
9524
+ bigint: () => bigIntType,
9525
+ boolean: () => booleanType,
9526
+ coerce: () => coerce,
9527
+ custom: () => custom,
9528
+ date: () => dateType,
9529
+ datetimeRegex: () => datetimeRegex,
9530
+ defaultErrorMap: () => en_default,
9531
+ discriminatedUnion: () => discriminatedUnionType,
9532
+ effect: () => effectsType,
9533
+ enum: () => enumType,
9534
+ function: () => functionType,
9535
+ getErrorMap: () => getErrorMap,
9536
+ getParsedType: () => getParsedType,
9537
+ instanceof: () => instanceOfType,
9538
+ intersection: () => intersectionType,
9539
+ isAborted: () => isAborted,
9540
+ isAsync: () => isAsync,
9541
+ isDirty: () => isDirty,
9542
+ isValid: () => isValid,
9543
+ late: () => late,
9544
+ lazy: () => lazyType,
9545
+ literal: () => literalType,
9546
+ makeIssue: () => makeIssue,
9547
+ map: () => mapType,
9548
+ nan: () => nanType,
9549
+ nativeEnum: () => nativeEnumType,
9550
+ never: () => neverType,
9551
+ null: () => nullType,
9552
+ nullable: () => nullableType,
9553
+ number: () => numberType,
9554
+ object: () => objectType,
9555
+ objectUtil: () => objectUtil,
9556
+ oboolean: () => oboolean,
9557
+ onumber: () => onumber,
9558
+ optional: () => optionalType,
9559
+ ostring: () => ostring,
9560
+ pipeline: () => pipelineType,
9561
+ preprocess: () => preprocessType,
9562
+ promise: () => promiseType,
9563
+ quotelessJson: () => quotelessJson,
9564
+ record: () => recordType,
9565
+ set: () => setType,
9566
+ setErrorMap: () => setErrorMap,
9567
+ strictObject: () => strictObjectType,
9568
+ string: () => stringType,
9569
+ symbol: () => symbolType,
9570
+ transformer: () => effectsType,
9571
+ tuple: () => tupleType,
9572
+ undefined: () => undefinedType,
9573
+ union: () => unionType,
9574
+ unknown: () => unknownType,
9575
+ util: () => util,
9576
+ void: () => voidType
9577
+ });
9578
+
9579
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
9580
+ var util;
9581
+ (function(util2) {
9582
+ util2.assertEqual = (_) => {
9583
+ };
9584
+ function assertIs(_arg) {
9585
+ }
9586
+ __name(assertIs, "assertIs");
9587
+ util2.assertIs = assertIs;
9588
+ function assertNever3(_x) {
9589
+ throw new Error();
9590
+ }
9591
+ __name(assertNever3, "assertNever");
9592
+ util2.assertNever = assertNever3;
9593
+ util2.arrayToEnum = (items) => {
9594
+ const obj = {};
9595
+ for (const item of items) {
9596
+ obj[item] = item;
9597
+ }
9598
+ return obj;
9599
+ };
9600
+ util2.getValidEnumValues = (obj) => {
9601
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
9602
+ const filtered = {};
9603
+ for (const k of validKeys) {
9604
+ filtered[k] = obj[k];
9605
+ }
9606
+ return util2.objectValues(filtered);
9607
+ };
9608
+ util2.objectValues = (obj) => {
9609
+ return util2.objectKeys(obj).map(function(e) {
9610
+ return obj[e];
9611
+ });
9612
+ };
9613
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
9614
+ const keys = [];
9615
+ for (const key in object) {
9616
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
9617
+ keys.push(key);
9618
+ }
9619
+ }
9620
+ return keys;
9621
+ };
9622
+ util2.find = (arr, checker) => {
9623
+ for (const item of arr) {
9624
+ if (checker(item))
9625
+ return item;
9626
+ }
9627
+ return void 0;
9628
+ };
9629
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
9630
+ function joinValues(array, separator = " | ") {
9631
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
9632
+ }
9633
+ __name(joinValues, "joinValues");
9634
+ util2.joinValues = joinValues;
9635
+ util2.jsonStringifyReplacer = (_, value) => {
9636
+ if (typeof value === "bigint") {
9637
+ return value.toString();
9638
+ }
9639
+ return value;
9640
+ };
9641
+ })(util || (util = {}));
9642
+ var objectUtil;
9643
+ (function(objectUtil2) {
9644
+ objectUtil2.mergeShapes = (first, second) => {
9645
+ return {
9646
+ ...first,
9647
+ ...second
9648
+ // second overwrites first
9649
+ };
9650
+ };
9651
+ })(objectUtil || (objectUtil = {}));
9652
+ var ZodParsedType = util.arrayToEnum([
9653
+ "string",
9654
+ "nan",
9655
+ "number",
9656
+ "integer",
9657
+ "float",
9658
+ "boolean",
9659
+ "date",
9660
+ "bigint",
9661
+ "symbol",
9662
+ "function",
9663
+ "undefined",
9664
+ "null",
9665
+ "array",
9666
+ "object",
9667
+ "unknown",
9668
+ "promise",
9669
+ "void",
9670
+ "never",
9671
+ "map",
9672
+ "set"
9673
+ ]);
9674
+ var getParsedType = /* @__PURE__ */ __name((data) => {
9675
+ const t = typeof data;
9676
+ switch (t) {
9677
+ case "undefined":
9678
+ return ZodParsedType.undefined;
9679
+ case "string":
9680
+ return ZodParsedType.string;
9681
+ case "number":
9682
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
9683
+ case "boolean":
9684
+ return ZodParsedType.boolean;
9685
+ case "function":
9686
+ return ZodParsedType.function;
9687
+ case "bigint":
9688
+ return ZodParsedType.bigint;
9689
+ case "symbol":
9690
+ return ZodParsedType.symbol;
9691
+ case "object":
9692
+ if (Array.isArray(data)) {
9693
+ return ZodParsedType.array;
9694
+ }
9695
+ if (data === null) {
9696
+ return ZodParsedType.null;
9697
+ }
9698
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
9699
+ return ZodParsedType.promise;
9700
+ }
9701
+ if (typeof Map !== "undefined" && data instanceof Map) {
9702
+ return ZodParsedType.map;
9703
+ }
9704
+ if (typeof Set !== "undefined" && data instanceof Set) {
9705
+ return ZodParsedType.set;
9706
+ }
9707
+ if (typeof Date !== "undefined" && data instanceof Date) {
9708
+ return ZodParsedType.date;
9709
+ }
9710
+ return ZodParsedType.object;
9711
+ default:
9712
+ return ZodParsedType.unknown;
9713
+ }
9714
+ }, "getParsedType");
9715
+
9716
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
9717
+ var ZodIssueCode = util.arrayToEnum([
9718
+ "invalid_type",
9719
+ "invalid_literal",
9720
+ "custom",
9721
+ "invalid_union",
9722
+ "invalid_union_discriminator",
9723
+ "invalid_enum_value",
9724
+ "unrecognized_keys",
9725
+ "invalid_arguments",
9726
+ "invalid_return_type",
9727
+ "invalid_date",
9728
+ "invalid_string",
9729
+ "too_small",
9730
+ "too_big",
9731
+ "invalid_intersection_types",
9732
+ "not_multiple_of",
9733
+ "not_finite"
9734
+ ]);
9735
+ var quotelessJson = /* @__PURE__ */ __name((obj) => {
9736
+ const json = JSON.stringify(obj, null, 2);
9737
+ return json.replace(/"([^"]+)":/g, "$1:");
9738
+ }, "quotelessJson");
9739
+ var ZodError = class _ZodError extends Error {
9740
+ static {
9741
+ __name(this, "ZodError");
9742
+ }
9743
+ get errors() {
9744
+ return this.issues;
9745
+ }
9746
+ constructor(issues) {
9747
+ super();
9748
+ this.issues = [];
9749
+ this.addIssue = (sub) => {
9750
+ this.issues = [...this.issues, sub];
9751
+ };
9752
+ this.addIssues = (subs = []) => {
9753
+ this.issues = [...this.issues, ...subs];
9754
+ };
9755
+ const actualProto = new.target.prototype;
9756
+ if (Object.setPrototypeOf) {
9757
+ Object.setPrototypeOf(this, actualProto);
9758
+ } else {
9759
+ this.__proto__ = actualProto;
9760
+ }
9761
+ this.name = "ZodError";
9762
+ this.issues = issues;
9763
+ }
9764
+ format(_mapper) {
9765
+ const mapper = _mapper || function(issue) {
9766
+ return issue.message;
9767
+ };
9768
+ const fieldErrors = { _errors: [] };
9769
+ const processError = /* @__PURE__ */ __name((error) => {
9770
+ for (const issue of error.issues) {
9771
+ if (issue.code === "invalid_union") {
9772
+ issue.unionErrors.map(processError);
9773
+ } else if (issue.code === "invalid_return_type") {
9774
+ processError(issue.returnTypeError);
9775
+ } else if (issue.code === "invalid_arguments") {
9776
+ processError(issue.argumentsError);
9777
+ } else if (issue.path.length === 0) {
9778
+ fieldErrors._errors.push(mapper(issue));
9779
+ } else {
9780
+ let curr = fieldErrors;
9781
+ let i = 0;
9782
+ while (i < issue.path.length) {
9783
+ const el = issue.path[i];
9784
+ const terminal = i === issue.path.length - 1;
9785
+ if (!terminal) {
9786
+ curr[el] = curr[el] || { _errors: [] };
9787
+ } else {
9788
+ curr[el] = curr[el] || { _errors: [] };
9789
+ curr[el]._errors.push(mapper(issue));
9790
+ }
9791
+ curr = curr[el];
9792
+ i++;
9793
+ }
9794
+ }
9795
+ }
9796
+ }, "processError");
9797
+ processError(this);
9798
+ return fieldErrors;
9799
+ }
9800
+ static assert(value) {
9801
+ if (!(value instanceof _ZodError)) {
9802
+ throw new Error(`Not a ZodError: ${value}`);
9803
+ }
9804
+ }
9805
+ toString() {
9806
+ return this.message;
9807
+ }
9808
+ get message() {
9809
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
9810
+ }
9811
+ get isEmpty() {
9812
+ return this.issues.length === 0;
9813
+ }
9814
+ flatten(mapper = (issue) => issue.message) {
9815
+ const fieldErrors = {};
9816
+ const formErrors = [];
9817
+ for (const sub of this.issues) {
9818
+ if (sub.path.length > 0) {
9819
+ const firstEl = sub.path[0];
9820
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
9821
+ fieldErrors[firstEl].push(mapper(sub));
9822
+ } else {
9823
+ formErrors.push(mapper(sub));
9824
+ }
9825
+ }
9826
+ return { formErrors, fieldErrors };
9827
+ }
9828
+ get formErrors() {
9829
+ return this.flatten();
9830
+ }
9831
+ };
9832
+ ZodError.create = (issues) => {
9833
+ const error = new ZodError(issues);
9834
+ return error;
9835
+ };
9836
+
9837
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
9838
+ var errorMap = /* @__PURE__ */ __name((issue, _ctx) => {
9839
+ let message;
9840
+ switch (issue.code) {
9841
+ case ZodIssueCode.invalid_type:
9842
+ if (issue.received === ZodParsedType.undefined) {
9843
+ message = "Required";
9844
+ } else {
9845
+ message = `Expected ${issue.expected}, received ${issue.received}`;
9846
+ }
9847
+ break;
9848
+ case ZodIssueCode.invalid_literal:
9849
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
9850
+ break;
9851
+ case ZodIssueCode.unrecognized_keys:
9852
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
9853
+ break;
9854
+ case ZodIssueCode.invalid_union:
9855
+ message = `Invalid input`;
9856
+ break;
9857
+ case ZodIssueCode.invalid_union_discriminator:
9858
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
9859
+ break;
9860
+ case ZodIssueCode.invalid_enum_value:
9861
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
9862
+ break;
9863
+ case ZodIssueCode.invalid_arguments:
9864
+ message = `Invalid function arguments`;
9865
+ break;
9866
+ case ZodIssueCode.invalid_return_type:
9867
+ message = `Invalid function return type`;
9868
+ break;
9869
+ case ZodIssueCode.invalid_date:
9870
+ message = `Invalid date`;
9871
+ break;
9872
+ case ZodIssueCode.invalid_string:
9873
+ if (typeof issue.validation === "object") {
9874
+ if ("includes" in issue.validation) {
9875
+ message = `Invalid input: must include "${issue.validation.includes}"`;
9876
+ if (typeof issue.validation.position === "number") {
9877
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
9878
+ }
9879
+ } else if ("startsWith" in issue.validation) {
9880
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
9881
+ } else if ("endsWith" in issue.validation) {
9882
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
9883
+ } else {
9884
+ util.assertNever(issue.validation);
9885
+ }
9886
+ } else if (issue.validation !== "regex") {
9887
+ message = `Invalid ${issue.validation}`;
9888
+ } else {
9889
+ message = "Invalid";
9890
+ }
9891
+ break;
9892
+ case ZodIssueCode.too_small:
9893
+ if (issue.type === "array")
9894
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
9895
+ else if (issue.type === "string")
9896
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
9897
+ else if (issue.type === "number")
9898
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
9899
+ else if (issue.type === "bigint")
9900
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
9901
+ else if (issue.type === "date")
9902
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
9903
+ else
9904
+ message = "Invalid input";
9905
+ break;
9906
+ case ZodIssueCode.too_big:
9907
+ if (issue.type === "array")
9908
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
9909
+ else if (issue.type === "string")
9910
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
9911
+ else if (issue.type === "number")
9912
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
9913
+ else if (issue.type === "bigint")
9914
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
9915
+ else if (issue.type === "date")
9916
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
9917
+ else
9918
+ message = "Invalid input";
9919
+ break;
9920
+ case ZodIssueCode.custom:
9921
+ message = `Invalid input`;
9922
+ break;
9923
+ case ZodIssueCode.invalid_intersection_types:
9924
+ message = `Intersection results could not be merged`;
9925
+ break;
9926
+ case ZodIssueCode.not_multiple_of:
9927
+ message = `Number must be a multiple of ${issue.multipleOf}`;
9928
+ break;
9929
+ case ZodIssueCode.not_finite:
9930
+ message = "Number must be finite";
9931
+ break;
9932
+ default:
9933
+ message = _ctx.defaultError;
9934
+ util.assertNever(issue);
9935
+ }
9936
+ return { message };
9937
+ }, "errorMap");
9938
+ var en_default = errorMap;
9939
+
9940
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
9941
+ var overrideErrorMap = en_default;
9942
+ function setErrorMap(map) {
9943
+ overrideErrorMap = map;
9944
+ }
9945
+ __name(setErrorMap, "setErrorMap");
9946
+ function getErrorMap() {
9947
+ return overrideErrorMap;
9948
+ }
9949
+ __name(getErrorMap, "getErrorMap");
9950
+
9951
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
9952
+ var makeIssue = /* @__PURE__ */ __name((params) => {
9953
+ const { data, path: path10, errorMaps, issueData } = params;
9954
+ const fullPath = [...path10, ...issueData.path || []];
9955
+ const fullIssue = {
9956
+ ...issueData,
9957
+ path: fullPath
9958
+ };
9959
+ if (issueData.message !== void 0) {
9960
+ return {
9961
+ ...issueData,
9962
+ path: fullPath,
9963
+ message: issueData.message
9964
+ };
9965
+ }
9966
+ let errorMessage = "";
9967
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
9968
+ for (const map of maps) {
9969
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
9970
+ }
9971
+ return {
9972
+ ...issueData,
9973
+ path: fullPath,
9974
+ message: errorMessage
9975
+ };
9976
+ }, "makeIssue");
9977
+ var EMPTY_PATH = [];
9978
+ function addIssueToContext(ctx, issueData) {
9979
+ const overrideMap = getErrorMap();
9980
+ const issue = makeIssue({
9981
+ issueData,
9982
+ data: ctx.data,
9983
+ path: ctx.path,
9984
+ errorMaps: [
9985
+ ctx.common.contextualErrorMap,
9986
+ // contextual error map is first priority
9987
+ ctx.schemaErrorMap,
9988
+ // then schema-bound map if available
9989
+ overrideMap,
9990
+ // then global override map
9991
+ overrideMap === en_default ? void 0 : en_default
9992
+ // then global default map
9993
+ ].filter((x) => !!x)
9994
+ });
9995
+ ctx.common.issues.push(issue);
9996
+ }
9997
+ __name(addIssueToContext, "addIssueToContext");
9998
+ var ParseStatus = class _ParseStatus {
9999
+ static {
10000
+ __name(this, "ParseStatus");
10001
+ }
10002
+ constructor() {
10003
+ this.value = "valid";
10004
+ }
10005
+ dirty() {
10006
+ if (this.value === "valid")
10007
+ this.value = "dirty";
10008
+ }
10009
+ abort() {
10010
+ if (this.value !== "aborted")
10011
+ this.value = "aborted";
10012
+ }
10013
+ static mergeArray(status, results) {
10014
+ const arrayValue = [];
10015
+ for (const s of results) {
10016
+ if (s.status === "aborted")
10017
+ return INVALID;
10018
+ if (s.status === "dirty")
10019
+ status.dirty();
10020
+ arrayValue.push(s.value);
10021
+ }
10022
+ return { status: status.value, value: arrayValue };
10023
+ }
10024
+ static async mergeObjectAsync(status, pairs) {
10025
+ const syncPairs = [];
10026
+ for (const pair of pairs) {
10027
+ const key = await pair.key;
10028
+ const value = await pair.value;
10029
+ syncPairs.push({
10030
+ key,
10031
+ value
10032
+ });
10033
+ }
10034
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
10035
+ }
10036
+ static mergeObjectSync(status, pairs) {
10037
+ const finalObject = {};
10038
+ for (const pair of pairs) {
10039
+ const { key, value } = pair;
10040
+ if (key.status === "aborted")
10041
+ return INVALID;
10042
+ if (value.status === "aborted")
10043
+ return INVALID;
10044
+ if (key.status === "dirty")
10045
+ status.dirty();
10046
+ if (value.status === "dirty")
10047
+ status.dirty();
10048
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
10049
+ finalObject[key.value] = value.value;
10050
+ }
10051
+ }
10052
+ return { status: status.value, value: finalObject };
10053
+ }
10054
+ };
10055
+ var INVALID = Object.freeze({
10056
+ status: "aborted"
10057
+ });
10058
+ var DIRTY = /* @__PURE__ */ __name((value) => ({ status: "dirty", value }), "DIRTY");
10059
+ var OK = /* @__PURE__ */ __name((value) => ({ status: "valid", value }), "OK");
10060
+ var isAborted = /* @__PURE__ */ __name((x) => x.status === "aborted", "isAborted");
10061
+ var isDirty = /* @__PURE__ */ __name((x) => x.status === "dirty", "isDirty");
10062
+ var isValid = /* @__PURE__ */ __name((x) => x.status === "valid", "isValid");
10063
+ var isAsync = /* @__PURE__ */ __name((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
10064
+
10065
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
10066
+ var errorUtil;
10067
+ (function(errorUtil2) {
10068
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
10069
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
10070
+ })(errorUtil || (errorUtil = {}));
10071
+
10072
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
10073
+ var ParseInputLazyPath = class {
10074
+ static {
10075
+ __name(this, "ParseInputLazyPath");
10076
+ }
10077
+ constructor(parent, value, path10, key) {
10078
+ this._cachedPath = [];
10079
+ this.parent = parent;
10080
+ this.data = value;
10081
+ this._path = path10;
10082
+ this._key = key;
10083
+ }
10084
+ get path() {
10085
+ if (!this._cachedPath.length) {
10086
+ if (Array.isArray(this._key)) {
10087
+ this._cachedPath.push(...this._path, ...this._key);
10088
+ } else {
10089
+ this._cachedPath.push(...this._path, this._key);
10090
+ }
10091
+ }
10092
+ return this._cachedPath;
10093
+ }
10094
+ };
10095
+ var handleResult = /* @__PURE__ */ __name((ctx, result) => {
10096
+ if (isValid(result)) {
10097
+ return { success: true, data: result.value };
10098
+ } else {
10099
+ if (!ctx.common.issues.length) {
10100
+ throw new Error("Validation failed but no issues detected.");
10101
+ }
10102
+ return {
10103
+ success: false,
10104
+ get error() {
10105
+ if (this._error)
10106
+ return this._error;
10107
+ const error = new ZodError(ctx.common.issues);
10108
+ this._error = error;
10109
+ return this._error;
10110
+ }
10111
+ };
10112
+ }
10113
+ }, "handleResult");
10114
+ function processCreateParams(params) {
10115
+ if (!params)
10116
+ return {};
10117
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
10118
+ if (errorMap2 && (invalid_type_error || required_error)) {
10119
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
10120
+ }
10121
+ if (errorMap2)
10122
+ return { errorMap: errorMap2, description };
10123
+ const customMap = /* @__PURE__ */ __name((iss, ctx) => {
10124
+ const { message } = params;
10125
+ if (iss.code === "invalid_enum_value") {
10126
+ return { message: message ?? ctx.defaultError };
10127
+ }
10128
+ if (typeof ctx.data === "undefined") {
10129
+ return { message: message ?? required_error ?? ctx.defaultError };
10130
+ }
10131
+ if (iss.code !== "invalid_type")
10132
+ return { message: ctx.defaultError };
10133
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
10134
+ }, "customMap");
10135
+ return { errorMap: customMap, description };
10136
+ }
10137
+ __name(processCreateParams, "processCreateParams");
10138
+ var ZodType = class {
10139
+ static {
10140
+ __name(this, "ZodType");
10141
+ }
10142
+ get description() {
10143
+ return this._def.description;
10144
+ }
10145
+ _getType(input) {
10146
+ return getParsedType(input.data);
10147
+ }
10148
+ _getOrReturnCtx(input, ctx) {
10149
+ return ctx || {
10150
+ common: input.parent.common,
10151
+ data: input.data,
10152
+ parsedType: getParsedType(input.data),
10153
+ schemaErrorMap: this._def.errorMap,
10154
+ path: input.path,
10155
+ parent: input.parent
10156
+ };
10157
+ }
10158
+ _processInputParams(input) {
10159
+ return {
10160
+ status: new ParseStatus(),
10161
+ ctx: {
10162
+ common: input.parent.common,
10163
+ data: input.data,
10164
+ parsedType: getParsedType(input.data),
10165
+ schemaErrorMap: this._def.errorMap,
10166
+ path: input.path,
10167
+ parent: input.parent
10168
+ }
10169
+ };
10170
+ }
10171
+ _parseSync(input) {
10172
+ const result = this._parse(input);
10173
+ if (isAsync(result)) {
10174
+ throw new Error("Synchronous parse encountered promise.");
10175
+ }
10176
+ return result;
10177
+ }
10178
+ _parseAsync(input) {
10179
+ const result = this._parse(input);
10180
+ return Promise.resolve(result);
10181
+ }
10182
+ parse(data, params) {
10183
+ const result = this.safeParse(data, params);
10184
+ if (result.success)
10185
+ return result.data;
10186
+ throw result.error;
10187
+ }
10188
+ safeParse(data, params) {
10189
+ const ctx = {
10190
+ common: {
10191
+ issues: [],
10192
+ async: params?.async ?? false,
10193
+ contextualErrorMap: params?.errorMap
10194
+ },
10195
+ path: params?.path || [],
10196
+ schemaErrorMap: this._def.errorMap,
10197
+ parent: null,
10198
+ data,
10199
+ parsedType: getParsedType(data)
10200
+ };
10201
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
10202
+ return handleResult(ctx, result);
10203
+ }
10204
+ "~validate"(data) {
10205
+ const ctx = {
10206
+ common: {
10207
+ issues: [],
10208
+ async: !!this["~standard"].async
10209
+ },
10210
+ path: [],
10211
+ schemaErrorMap: this._def.errorMap,
10212
+ parent: null,
10213
+ data,
10214
+ parsedType: getParsedType(data)
10215
+ };
10216
+ if (!this["~standard"].async) {
10217
+ try {
10218
+ const result = this._parseSync({ data, path: [], parent: ctx });
10219
+ return isValid(result) ? {
10220
+ value: result.value
10221
+ } : {
10222
+ issues: ctx.common.issues
10223
+ };
10224
+ } catch (err) {
10225
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
10226
+ this["~standard"].async = true;
10227
+ }
10228
+ ctx.common = {
10229
+ issues: [],
10230
+ async: true
10231
+ };
10232
+ }
10233
+ }
10234
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
10235
+ value: result.value
10236
+ } : {
10237
+ issues: ctx.common.issues
10238
+ });
10239
+ }
10240
+ async parseAsync(data, params) {
10241
+ const result = await this.safeParseAsync(data, params);
10242
+ if (result.success)
10243
+ return result.data;
10244
+ throw result.error;
10245
+ }
10246
+ async safeParseAsync(data, params) {
10247
+ const ctx = {
10248
+ common: {
10249
+ issues: [],
10250
+ contextualErrorMap: params?.errorMap,
10251
+ async: true
10252
+ },
10253
+ path: params?.path || [],
10254
+ schemaErrorMap: this._def.errorMap,
10255
+ parent: null,
10256
+ data,
10257
+ parsedType: getParsedType(data)
10258
+ };
10259
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
10260
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
10261
+ return handleResult(ctx, result);
10262
+ }
10263
+ refine(check, message) {
10264
+ const getIssueProperties = /* @__PURE__ */ __name((val) => {
10265
+ if (typeof message === "string" || typeof message === "undefined") {
10266
+ return { message };
10267
+ } else if (typeof message === "function") {
10268
+ return message(val);
10269
+ } else {
10270
+ return message;
10271
+ }
10272
+ }, "getIssueProperties");
10273
+ return this._refinement((val, ctx) => {
10274
+ const result = check(val);
10275
+ const setError = /* @__PURE__ */ __name(() => ctx.addIssue({
10276
+ code: ZodIssueCode.custom,
10277
+ ...getIssueProperties(val)
10278
+ }), "setError");
10279
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
10280
+ return result.then((data) => {
10281
+ if (!data) {
10282
+ setError();
10283
+ return false;
10284
+ } else {
10285
+ return true;
10286
+ }
10287
+ });
10288
+ }
10289
+ if (!result) {
10290
+ setError();
10291
+ return false;
10292
+ } else {
10293
+ return true;
10294
+ }
10295
+ });
10296
+ }
10297
+ refinement(check, refinementData) {
10298
+ return this._refinement((val, ctx) => {
10299
+ if (!check(val)) {
10300
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
10301
+ return false;
10302
+ } else {
10303
+ return true;
10304
+ }
10305
+ });
10306
+ }
10307
+ _refinement(refinement) {
10308
+ return new ZodEffects({
10309
+ schema: this,
10310
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
10311
+ effect: { type: "refinement", refinement }
10312
+ });
10313
+ }
10314
+ superRefine(refinement) {
10315
+ return this._refinement(refinement);
10316
+ }
10317
+ constructor(def) {
10318
+ this.spa = this.safeParseAsync;
10319
+ this._def = def;
10320
+ this.parse = this.parse.bind(this);
10321
+ this.safeParse = this.safeParse.bind(this);
10322
+ this.parseAsync = this.parseAsync.bind(this);
10323
+ this.safeParseAsync = this.safeParseAsync.bind(this);
10324
+ this.spa = this.spa.bind(this);
10325
+ this.refine = this.refine.bind(this);
10326
+ this.refinement = this.refinement.bind(this);
10327
+ this.superRefine = this.superRefine.bind(this);
10328
+ this.optional = this.optional.bind(this);
10329
+ this.nullable = this.nullable.bind(this);
10330
+ this.nullish = this.nullish.bind(this);
10331
+ this.array = this.array.bind(this);
10332
+ this.promise = this.promise.bind(this);
10333
+ this.or = this.or.bind(this);
10334
+ this.and = this.and.bind(this);
10335
+ this.transform = this.transform.bind(this);
10336
+ this.brand = this.brand.bind(this);
10337
+ this.default = this.default.bind(this);
10338
+ this.catch = this.catch.bind(this);
10339
+ this.describe = this.describe.bind(this);
10340
+ this.pipe = this.pipe.bind(this);
10341
+ this.readonly = this.readonly.bind(this);
10342
+ this.isNullable = this.isNullable.bind(this);
10343
+ this.isOptional = this.isOptional.bind(this);
10344
+ this["~standard"] = {
10345
+ version: 1,
10346
+ vendor: "zod",
10347
+ validate: /* @__PURE__ */ __name((data) => this["~validate"](data), "validate")
10348
+ };
10349
+ }
10350
+ optional() {
10351
+ return ZodOptional.create(this, this._def);
10352
+ }
10353
+ nullable() {
10354
+ return ZodNullable.create(this, this._def);
10355
+ }
10356
+ nullish() {
10357
+ return this.nullable().optional();
10358
+ }
10359
+ array() {
10360
+ return ZodArray.create(this);
10361
+ }
10362
+ promise() {
10363
+ return ZodPromise.create(this, this._def);
10364
+ }
10365
+ or(option) {
10366
+ return ZodUnion.create([this, option], this._def);
10367
+ }
10368
+ and(incoming) {
10369
+ return ZodIntersection.create(this, incoming, this._def);
10370
+ }
10371
+ transform(transform) {
10372
+ return new ZodEffects({
10373
+ ...processCreateParams(this._def),
10374
+ schema: this,
10375
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
10376
+ effect: { type: "transform", transform }
10377
+ });
10378
+ }
10379
+ default(def) {
10380
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
10381
+ return new ZodDefault({
10382
+ ...processCreateParams(this._def),
10383
+ innerType: this,
10384
+ defaultValue: defaultValueFunc,
10385
+ typeName: ZodFirstPartyTypeKind.ZodDefault
10386
+ });
10387
+ }
10388
+ brand() {
10389
+ return new ZodBranded({
10390
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
10391
+ type: this,
10392
+ ...processCreateParams(this._def)
10393
+ });
10394
+ }
10395
+ catch(def) {
10396
+ const catchValueFunc = typeof def === "function" ? def : () => def;
10397
+ return new ZodCatch({
10398
+ ...processCreateParams(this._def),
10399
+ innerType: this,
10400
+ catchValue: catchValueFunc,
10401
+ typeName: ZodFirstPartyTypeKind.ZodCatch
10402
+ });
10403
+ }
10404
+ describe(description) {
10405
+ const This = this.constructor;
10406
+ return new This({
10407
+ ...this._def,
10408
+ description
10409
+ });
10410
+ }
10411
+ pipe(target) {
10412
+ return ZodPipeline.create(this, target);
10413
+ }
10414
+ readonly() {
10415
+ return ZodReadonly.create(this);
10416
+ }
10417
+ isOptional() {
10418
+ return this.safeParse(void 0).success;
10419
+ }
10420
+ isNullable() {
10421
+ return this.safeParse(null).success;
10422
+ }
10423
+ };
10424
+ var cuidRegex = /^c[^\s-]{8,}$/i;
10425
+ var cuid2Regex = /^[0-9a-z]+$/;
10426
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
10427
+ 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;
10428
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
10429
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
10430
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
10431
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
10432
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
10433
+ var emojiRegex;
10434
+ var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
10435
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
10436
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
10437
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
10438
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
10439
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
10440
+ var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
10441
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
10442
+ function timeRegexSource(args) {
10443
+ let secondsRegexSource = `[0-5]\\d`;
10444
+ if (args.precision) {
10445
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
10446
+ } else if (args.precision == null) {
10447
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
10448
+ }
10449
+ const secondsQuantifier = args.precision ? "+" : "?";
10450
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
10451
+ }
10452
+ __name(timeRegexSource, "timeRegexSource");
10453
+ function timeRegex(args) {
10454
+ return new RegExp(`^${timeRegexSource(args)}$`);
10455
+ }
10456
+ __name(timeRegex, "timeRegex");
10457
+ function datetimeRegex(args) {
10458
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
10459
+ const opts = [];
10460
+ opts.push(args.local ? `Z?` : `Z`);
10461
+ if (args.offset)
10462
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
10463
+ regex = `${regex}(${opts.join("|")})`;
10464
+ return new RegExp(`^${regex}$`);
10465
+ }
10466
+ __name(datetimeRegex, "datetimeRegex");
10467
+ function isValidIP(ip, version) {
10468
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
10469
+ return true;
10470
+ }
10471
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
10472
+ return true;
10473
+ }
10474
+ return false;
10475
+ }
10476
+ __name(isValidIP, "isValidIP");
10477
+ function isValidJWT(jwt, alg) {
10478
+ if (!jwtRegex.test(jwt))
10479
+ return false;
10480
+ try {
10481
+ const [header] = jwt.split(".");
10482
+ if (!header)
10483
+ return false;
10484
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
10485
+ const decoded = JSON.parse(atob(base64));
10486
+ if (typeof decoded !== "object" || decoded === null)
10487
+ return false;
10488
+ if ("typ" in decoded && decoded?.typ !== "JWT")
10489
+ return false;
10490
+ if (!decoded.alg)
10491
+ return false;
10492
+ if (alg && decoded.alg !== alg)
10493
+ return false;
10494
+ return true;
10495
+ } catch {
10496
+ return false;
10497
+ }
10498
+ }
10499
+ __name(isValidJWT, "isValidJWT");
10500
+ function isValidCidr(ip, version) {
10501
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
10502
+ return true;
10503
+ }
10504
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
10505
+ return true;
10506
+ }
10507
+ return false;
10508
+ }
10509
+ __name(isValidCidr, "isValidCidr");
10510
+ var ZodString = class _ZodString extends ZodType {
10511
+ static {
10512
+ __name(this, "ZodString");
10513
+ }
10514
+ _parse(input) {
10515
+ if (this._def.coerce) {
10516
+ input.data = String(input.data);
10517
+ }
10518
+ const parsedType = this._getType(input);
10519
+ if (parsedType !== ZodParsedType.string) {
10520
+ const ctx2 = this._getOrReturnCtx(input);
10521
+ addIssueToContext(ctx2, {
10522
+ code: ZodIssueCode.invalid_type,
10523
+ expected: ZodParsedType.string,
10524
+ received: ctx2.parsedType
10525
+ });
10526
+ return INVALID;
10527
+ }
10528
+ const status = new ParseStatus();
10529
+ let ctx = void 0;
10530
+ for (const check of this._def.checks) {
10531
+ if (check.kind === "min") {
10532
+ if (input.data.length < check.value) {
10533
+ ctx = this._getOrReturnCtx(input, ctx);
10534
+ addIssueToContext(ctx, {
10535
+ code: ZodIssueCode.too_small,
10536
+ minimum: check.value,
10537
+ type: "string",
10538
+ inclusive: true,
10539
+ exact: false,
10540
+ message: check.message
10541
+ });
10542
+ status.dirty();
10543
+ }
10544
+ } else if (check.kind === "max") {
10545
+ if (input.data.length > check.value) {
10546
+ ctx = this._getOrReturnCtx(input, ctx);
10547
+ addIssueToContext(ctx, {
10548
+ code: ZodIssueCode.too_big,
10549
+ maximum: check.value,
10550
+ type: "string",
10551
+ inclusive: true,
10552
+ exact: false,
10553
+ message: check.message
10554
+ });
10555
+ status.dirty();
10556
+ }
10557
+ } else if (check.kind === "length") {
10558
+ const tooBig = input.data.length > check.value;
10559
+ const tooSmall = input.data.length < check.value;
10560
+ if (tooBig || tooSmall) {
10561
+ ctx = this._getOrReturnCtx(input, ctx);
10562
+ if (tooBig) {
10563
+ addIssueToContext(ctx, {
10564
+ code: ZodIssueCode.too_big,
10565
+ maximum: check.value,
10566
+ type: "string",
10567
+ inclusive: true,
10568
+ exact: true,
10569
+ message: check.message
10570
+ });
10571
+ } else if (tooSmall) {
10572
+ addIssueToContext(ctx, {
10573
+ code: ZodIssueCode.too_small,
10574
+ minimum: check.value,
10575
+ type: "string",
10576
+ inclusive: true,
10577
+ exact: true,
10578
+ message: check.message
10579
+ });
10580
+ }
10581
+ status.dirty();
10582
+ }
10583
+ } else if (check.kind === "email") {
10584
+ if (!emailRegex.test(input.data)) {
10585
+ ctx = this._getOrReturnCtx(input, ctx);
10586
+ addIssueToContext(ctx, {
10587
+ validation: "email",
10588
+ code: ZodIssueCode.invalid_string,
10589
+ message: check.message
10590
+ });
10591
+ status.dirty();
10592
+ }
10593
+ } else if (check.kind === "emoji") {
10594
+ if (!emojiRegex) {
10595
+ emojiRegex = new RegExp(_emojiRegex, "u");
10596
+ }
10597
+ if (!emojiRegex.test(input.data)) {
10598
+ ctx = this._getOrReturnCtx(input, ctx);
10599
+ addIssueToContext(ctx, {
10600
+ validation: "emoji",
10601
+ code: ZodIssueCode.invalid_string,
10602
+ message: check.message
10603
+ });
10604
+ status.dirty();
10605
+ }
10606
+ } else if (check.kind === "uuid") {
10607
+ if (!uuidRegex.test(input.data)) {
10608
+ ctx = this._getOrReturnCtx(input, ctx);
10609
+ addIssueToContext(ctx, {
10610
+ validation: "uuid",
10611
+ code: ZodIssueCode.invalid_string,
10612
+ message: check.message
10613
+ });
10614
+ status.dirty();
10615
+ }
10616
+ } else if (check.kind === "nanoid") {
10617
+ if (!nanoidRegex.test(input.data)) {
10618
+ ctx = this._getOrReturnCtx(input, ctx);
10619
+ addIssueToContext(ctx, {
10620
+ validation: "nanoid",
10621
+ code: ZodIssueCode.invalid_string,
10622
+ message: check.message
10623
+ });
10624
+ status.dirty();
10625
+ }
10626
+ } else if (check.kind === "cuid") {
10627
+ if (!cuidRegex.test(input.data)) {
10628
+ ctx = this._getOrReturnCtx(input, ctx);
10629
+ addIssueToContext(ctx, {
10630
+ validation: "cuid",
10631
+ code: ZodIssueCode.invalid_string,
10632
+ message: check.message
10633
+ });
10634
+ status.dirty();
10635
+ }
10636
+ } else if (check.kind === "cuid2") {
10637
+ if (!cuid2Regex.test(input.data)) {
10638
+ ctx = this._getOrReturnCtx(input, ctx);
10639
+ addIssueToContext(ctx, {
10640
+ validation: "cuid2",
10641
+ code: ZodIssueCode.invalid_string,
10642
+ message: check.message
10643
+ });
10644
+ status.dirty();
10645
+ }
10646
+ } else if (check.kind === "ulid") {
10647
+ if (!ulidRegex.test(input.data)) {
10648
+ ctx = this._getOrReturnCtx(input, ctx);
10649
+ addIssueToContext(ctx, {
10650
+ validation: "ulid",
10651
+ code: ZodIssueCode.invalid_string,
10652
+ message: check.message
10653
+ });
10654
+ status.dirty();
10655
+ }
10656
+ } else if (check.kind === "url") {
10657
+ try {
10658
+ new URL(input.data);
10659
+ } catch {
10660
+ ctx = this._getOrReturnCtx(input, ctx);
10661
+ addIssueToContext(ctx, {
10662
+ validation: "url",
10663
+ code: ZodIssueCode.invalid_string,
10664
+ message: check.message
10665
+ });
10666
+ status.dirty();
10667
+ }
10668
+ } else if (check.kind === "regex") {
10669
+ check.regex.lastIndex = 0;
10670
+ const testResult = check.regex.test(input.data);
10671
+ if (!testResult) {
10672
+ ctx = this._getOrReturnCtx(input, ctx);
10673
+ addIssueToContext(ctx, {
10674
+ validation: "regex",
10675
+ code: ZodIssueCode.invalid_string,
10676
+ message: check.message
10677
+ });
10678
+ status.dirty();
10679
+ }
10680
+ } else if (check.kind === "trim") {
10681
+ input.data = input.data.trim();
10682
+ } else if (check.kind === "includes") {
10683
+ if (!input.data.includes(check.value, check.position)) {
10684
+ ctx = this._getOrReturnCtx(input, ctx);
10685
+ addIssueToContext(ctx, {
10686
+ code: ZodIssueCode.invalid_string,
10687
+ validation: { includes: check.value, position: check.position },
10688
+ message: check.message
10689
+ });
10690
+ status.dirty();
10691
+ }
10692
+ } else if (check.kind === "toLowerCase") {
10693
+ input.data = input.data.toLowerCase();
10694
+ } else if (check.kind === "toUpperCase") {
10695
+ input.data = input.data.toUpperCase();
10696
+ } else if (check.kind === "startsWith") {
10697
+ if (!input.data.startsWith(check.value)) {
10698
+ ctx = this._getOrReturnCtx(input, ctx);
10699
+ addIssueToContext(ctx, {
10700
+ code: ZodIssueCode.invalid_string,
10701
+ validation: { startsWith: check.value },
10702
+ message: check.message
10703
+ });
10704
+ status.dirty();
10705
+ }
10706
+ } else if (check.kind === "endsWith") {
10707
+ if (!input.data.endsWith(check.value)) {
10708
+ ctx = this._getOrReturnCtx(input, ctx);
10709
+ addIssueToContext(ctx, {
10710
+ code: ZodIssueCode.invalid_string,
10711
+ validation: { endsWith: check.value },
10712
+ message: check.message
10713
+ });
10714
+ status.dirty();
10715
+ }
10716
+ } else if (check.kind === "datetime") {
10717
+ const regex = datetimeRegex(check);
10718
+ if (!regex.test(input.data)) {
10719
+ ctx = this._getOrReturnCtx(input, ctx);
10720
+ addIssueToContext(ctx, {
10721
+ code: ZodIssueCode.invalid_string,
10722
+ validation: "datetime",
10723
+ message: check.message
10724
+ });
10725
+ status.dirty();
10726
+ }
10727
+ } else if (check.kind === "date") {
10728
+ const regex = dateRegex;
10729
+ if (!regex.test(input.data)) {
10730
+ ctx = this._getOrReturnCtx(input, ctx);
10731
+ addIssueToContext(ctx, {
10732
+ code: ZodIssueCode.invalid_string,
10733
+ validation: "date",
10734
+ message: check.message
10735
+ });
10736
+ status.dirty();
10737
+ }
10738
+ } else if (check.kind === "time") {
10739
+ const regex = timeRegex(check);
10740
+ if (!regex.test(input.data)) {
10741
+ ctx = this._getOrReturnCtx(input, ctx);
10742
+ addIssueToContext(ctx, {
10743
+ code: ZodIssueCode.invalid_string,
10744
+ validation: "time",
10745
+ message: check.message
10746
+ });
10747
+ status.dirty();
10748
+ }
10749
+ } else if (check.kind === "duration") {
10750
+ if (!durationRegex.test(input.data)) {
10751
+ ctx = this._getOrReturnCtx(input, ctx);
10752
+ addIssueToContext(ctx, {
10753
+ validation: "duration",
10754
+ code: ZodIssueCode.invalid_string,
10755
+ message: check.message
10756
+ });
10757
+ status.dirty();
10758
+ }
10759
+ } else if (check.kind === "ip") {
10760
+ if (!isValidIP(input.data, check.version)) {
10761
+ ctx = this._getOrReturnCtx(input, ctx);
10762
+ addIssueToContext(ctx, {
10763
+ validation: "ip",
10764
+ code: ZodIssueCode.invalid_string,
10765
+ message: check.message
10766
+ });
10767
+ status.dirty();
10768
+ }
10769
+ } else if (check.kind === "jwt") {
10770
+ if (!isValidJWT(input.data, check.alg)) {
10771
+ ctx = this._getOrReturnCtx(input, ctx);
10772
+ addIssueToContext(ctx, {
10773
+ validation: "jwt",
10774
+ code: ZodIssueCode.invalid_string,
10775
+ message: check.message
10776
+ });
10777
+ status.dirty();
10778
+ }
10779
+ } else if (check.kind === "cidr") {
10780
+ if (!isValidCidr(input.data, check.version)) {
10781
+ ctx = this._getOrReturnCtx(input, ctx);
10782
+ addIssueToContext(ctx, {
10783
+ validation: "cidr",
10784
+ code: ZodIssueCode.invalid_string,
10785
+ message: check.message
10786
+ });
10787
+ status.dirty();
10788
+ }
10789
+ } else if (check.kind === "base64") {
10790
+ if (!base64Regex.test(input.data)) {
10791
+ ctx = this._getOrReturnCtx(input, ctx);
10792
+ addIssueToContext(ctx, {
10793
+ validation: "base64",
10794
+ code: ZodIssueCode.invalid_string,
10795
+ message: check.message
10796
+ });
10797
+ status.dirty();
10798
+ }
10799
+ } else if (check.kind === "base64url") {
10800
+ if (!base64urlRegex.test(input.data)) {
10801
+ ctx = this._getOrReturnCtx(input, ctx);
10802
+ addIssueToContext(ctx, {
10803
+ validation: "base64url",
10804
+ code: ZodIssueCode.invalid_string,
10805
+ message: check.message
10806
+ });
10807
+ status.dirty();
10808
+ }
10809
+ } else {
10810
+ util.assertNever(check);
10811
+ }
10812
+ }
10813
+ return { status: status.value, value: input.data };
10814
+ }
10815
+ _regex(regex, validation, message) {
10816
+ return this.refinement((data) => regex.test(data), {
10817
+ validation,
10818
+ code: ZodIssueCode.invalid_string,
10819
+ ...errorUtil.errToObj(message)
10820
+ });
10821
+ }
10822
+ _addCheck(check) {
10823
+ return new _ZodString({
10824
+ ...this._def,
10825
+ checks: [...this._def.checks, check]
10826
+ });
10827
+ }
10828
+ email(message) {
10829
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
10830
+ }
10831
+ url(message) {
10832
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
10833
+ }
10834
+ emoji(message) {
10835
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
10836
+ }
10837
+ uuid(message) {
10838
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
10839
+ }
10840
+ nanoid(message) {
10841
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
10842
+ }
10843
+ cuid(message) {
10844
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
10845
+ }
10846
+ cuid2(message) {
10847
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
10848
+ }
10849
+ ulid(message) {
10850
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
10851
+ }
10852
+ base64(message) {
10853
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
10854
+ }
10855
+ base64url(message) {
10856
+ return this._addCheck({
10857
+ kind: "base64url",
10858
+ ...errorUtil.errToObj(message)
10859
+ });
10860
+ }
10861
+ jwt(options) {
10862
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
10863
+ }
10864
+ ip(options) {
10865
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
10866
+ }
10867
+ cidr(options) {
10868
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
10869
+ }
10870
+ datetime(options) {
10871
+ if (typeof options === "string") {
10872
+ return this._addCheck({
10873
+ kind: "datetime",
10874
+ precision: null,
10875
+ offset: false,
10876
+ local: false,
10877
+ message: options
10878
+ });
10879
+ }
10880
+ return this._addCheck({
10881
+ kind: "datetime",
10882
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
10883
+ offset: options?.offset ?? false,
10884
+ local: options?.local ?? false,
10885
+ ...errorUtil.errToObj(options?.message)
10886
+ });
10887
+ }
10888
+ date(message) {
10889
+ return this._addCheck({ kind: "date", message });
10890
+ }
10891
+ time(options) {
10892
+ if (typeof options === "string") {
10893
+ return this._addCheck({
10894
+ kind: "time",
10895
+ precision: null,
10896
+ message: options
10897
+ });
10898
+ }
10899
+ return this._addCheck({
10900
+ kind: "time",
10901
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
10902
+ ...errorUtil.errToObj(options?.message)
10903
+ });
10904
+ }
10905
+ duration(message) {
10906
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
10907
+ }
10908
+ regex(regex, message) {
10909
+ return this._addCheck({
10910
+ kind: "regex",
10911
+ regex,
10912
+ ...errorUtil.errToObj(message)
10913
+ });
10914
+ }
10915
+ includes(value, options) {
10916
+ return this._addCheck({
10917
+ kind: "includes",
10918
+ value,
10919
+ position: options?.position,
10920
+ ...errorUtil.errToObj(options?.message)
10921
+ });
10922
+ }
10923
+ startsWith(value, message) {
10924
+ return this._addCheck({
10925
+ kind: "startsWith",
10926
+ value,
10927
+ ...errorUtil.errToObj(message)
10928
+ });
10929
+ }
10930
+ endsWith(value, message) {
10931
+ return this._addCheck({
10932
+ kind: "endsWith",
10933
+ value,
10934
+ ...errorUtil.errToObj(message)
10935
+ });
10936
+ }
10937
+ min(minLength, message) {
10938
+ return this._addCheck({
10939
+ kind: "min",
10940
+ value: minLength,
10941
+ ...errorUtil.errToObj(message)
10942
+ });
10943
+ }
10944
+ max(maxLength, message) {
10945
+ return this._addCheck({
10946
+ kind: "max",
10947
+ value: maxLength,
10948
+ ...errorUtil.errToObj(message)
10949
+ });
10950
+ }
10951
+ length(len, message) {
10952
+ return this._addCheck({
10953
+ kind: "length",
10954
+ value: len,
10955
+ ...errorUtil.errToObj(message)
10956
+ });
10957
+ }
10958
+ /**
10959
+ * Equivalent to `.min(1)`
10960
+ */
10961
+ nonempty(message) {
10962
+ return this.min(1, errorUtil.errToObj(message));
10963
+ }
10964
+ trim() {
10965
+ return new _ZodString({
10966
+ ...this._def,
10967
+ checks: [...this._def.checks, { kind: "trim" }]
10968
+ });
10969
+ }
10970
+ toLowerCase() {
10971
+ return new _ZodString({
10972
+ ...this._def,
10973
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
10974
+ });
10975
+ }
10976
+ toUpperCase() {
10977
+ return new _ZodString({
10978
+ ...this._def,
10979
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
10980
+ });
10981
+ }
10982
+ get isDatetime() {
10983
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
10984
+ }
10985
+ get isDate() {
10986
+ return !!this._def.checks.find((ch) => ch.kind === "date");
10987
+ }
10988
+ get isTime() {
10989
+ return !!this._def.checks.find((ch) => ch.kind === "time");
10990
+ }
10991
+ get isDuration() {
10992
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
10993
+ }
10994
+ get isEmail() {
10995
+ return !!this._def.checks.find((ch) => ch.kind === "email");
10996
+ }
10997
+ get isURL() {
10998
+ return !!this._def.checks.find((ch) => ch.kind === "url");
10999
+ }
11000
+ get isEmoji() {
11001
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
11002
+ }
11003
+ get isUUID() {
11004
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
11005
+ }
11006
+ get isNANOID() {
11007
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
11008
+ }
11009
+ get isCUID() {
11010
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
11011
+ }
11012
+ get isCUID2() {
11013
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
11014
+ }
11015
+ get isULID() {
11016
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
11017
+ }
11018
+ get isIP() {
11019
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
11020
+ }
11021
+ get isCIDR() {
11022
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
11023
+ }
11024
+ get isBase64() {
11025
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
11026
+ }
11027
+ get isBase64url() {
11028
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
11029
+ }
11030
+ get minLength() {
11031
+ let min = null;
11032
+ for (const ch of this._def.checks) {
11033
+ if (ch.kind === "min") {
11034
+ if (min === null || ch.value > min)
11035
+ min = ch.value;
11036
+ }
11037
+ }
11038
+ return min;
11039
+ }
11040
+ get maxLength() {
11041
+ let max = null;
11042
+ for (const ch of this._def.checks) {
11043
+ if (ch.kind === "max") {
11044
+ if (max === null || ch.value < max)
11045
+ max = ch.value;
11046
+ }
11047
+ }
11048
+ return max;
11049
+ }
11050
+ };
11051
+ ZodString.create = (params) => {
11052
+ return new ZodString({
11053
+ checks: [],
11054
+ typeName: ZodFirstPartyTypeKind.ZodString,
11055
+ coerce: params?.coerce ?? false,
11056
+ ...processCreateParams(params)
11057
+ });
11058
+ };
11059
+ function floatSafeRemainder(val, step) {
11060
+ const valDecCount = (val.toString().split(".")[1] || "").length;
11061
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
11062
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
11063
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
11064
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
11065
+ return valInt % stepInt / 10 ** decCount;
11066
+ }
11067
+ __name(floatSafeRemainder, "floatSafeRemainder");
11068
+ var ZodNumber = class _ZodNumber extends ZodType {
11069
+ static {
11070
+ __name(this, "ZodNumber");
11071
+ }
11072
+ constructor() {
11073
+ super(...arguments);
11074
+ this.min = this.gte;
11075
+ this.max = this.lte;
11076
+ this.step = this.multipleOf;
11077
+ }
11078
+ _parse(input) {
11079
+ if (this._def.coerce) {
11080
+ input.data = Number(input.data);
11081
+ }
11082
+ const parsedType = this._getType(input);
11083
+ if (parsedType !== ZodParsedType.number) {
11084
+ const ctx2 = this._getOrReturnCtx(input);
11085
+ addIssueToContext(ctx2, {
11086
+ code: ZodIssueCode.invalid_type,
11087
+ expected: ZodParsedType.number,
11088
+ received: ctx2.parsedType
11089
+ });
11090
+ return INVALID;
11091
+ }
11092
+ let ctx = void 0;
11093
+ const status = new ParseStatus();
11094
+ for (const check of this._def.checks) {
11095
+ if (check.kind === "int") {
11096
+ if (!util.isInteger(input.data)) {
11097
+ ctx = this._getOrReturnCtx(input, ctx);
11098
+ addIssueToContext(ctx, {
11099
+ code: ZodIssueCode.invalid_type,
11100
+ expected: "integer",
11101
+ received: "float",
11102
+ message: check.message
11103
+ });
11104
+ status.dirty();
11105
+ }
11106
+ } else if (check.kind === "min") {
11107
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
11108
+ if (tooSmall) {
11109
+ ctx = this._getOrReturnCtx(input, ctx);
11110
+ addIssueToContext(ctx, {
11111
+ code: ZodIssueCode.too_small,
11112
+ minimum: check.value,
11113
+ type: "number",
11114
+ inclusive: check.inclusive,
11115
+ exact: false,
11116
+ message: check.message
11117
+ });
11118
+ status.dirty();
11119
+ }
11120
+ } else if (check.kind === "max") {
11121
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
11122
+ if (tooBig) {
11123
+ ctx = this._getOrReturnCtx(input, ctx);
11124
+ addIssueToContext(ctx, {
11125
+ code: ZodIssueCode.too_big,
11126
+ maximum: check.value,
11127
+ type: "number",
11128
+ inclusive: check.inclusive,
11129
+ exact: false,
11130
+ message: check.message
11131
+ });
11132
+ status.dirty();
11133
+ }
11134
+ } else if (check.kind === "multipleOf") {
11135
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
11136
+ ctx = this._getOrReturnCtx(input, ctx);
11137
+ addIssueToContext(ctx, {
11138
+ code: ZodIssueCode.not_multiple_of,
11139
+ multipleOf: check.value,
11140
+ message: check.message
11141
+ });
11142
+ status.dirty();
11143
+ }
11144
+ } else if (check.kind === "finite") {
11145
+ if (!Number.isFinite(input.data)) {
11146
+ ctx = this._getOrReturnCtx(input, ctx);
11147
+ addIssueToContext(ctx, {
11148
+ code: ZodIssueCode.not_finite,
11149
+ message: check.message
11150
+ });
11151
+ status.dirty();
11152
+ }
11153
+ } else {
11154
+ util.assertNever(check);
11155
+ }
11156
+ }
11157
+ return { status: status.value, value: input.data };
11158
+ }
11159
+ gte(value, message) {
11160
+ return this.setLimit("min", value, true, errorUtil.toString(message));
11161
+ }
11162
+ gt(value, message) {
11163
+ return this.setLimit("min", value, false, errorUtil.toString(message));
11164
+ }
11165
+ lte(value, message) {
11166
+ return this.setLimit("max", value, true, errorUtil.toString(message));
11167
+ }
11168
+ lt(value, message) {
11169
+ return this.setLimit("max", value, false, errorUtil.toString(message));
11170
+ }
11171
+ setLimit(kind, value, inclusive, message) {
11172
+ return new _ZodNumber({
11173
+ ...this._def,
11174
+ checks: [
11175
+ ...this._def.checks,
11176
+ {
11177
+ kind,
11178
+ value,
11179
+ inclusive,
11180
+ message: errorUtil.toString(message)
11181
+ }
11182
+ ]
11183
+ });
11184
+ }
11185
+ _addCheck(check) {
11186
+ return new _ZodNumber({
11187
+ ...this._def,
11188
+ checks: [...this._def.checks, check]
11189
+ });
11190
+ }
11191
+ int(message) {
11192
+ return this._addCheck({
11193
+ kind: "int",
11194
+ message: errorUtil.toString(message)
11195
+ });
11196
+ }
11197
+ positive(message) {
11198
+ return this._addCheck({
11199
+ kind: "min",
11200
+ value: 0,
11201
+ inclusive: false,
11202
+ message: errorUtil.toString(message)
11203
+ });
11204
+ }
11205
+ negative(message) {
11206
+ return this._addCheck({
11207
+ kind: "max",
11208
+ value: 0,
11209
+ inclusive: false,
11210
+ message: errorUtil.toString(message)
11211
+ });
11212
+ }
11213
+ nonpositive(message) {
11214
+ return this._addCheck({
11215
+ kind: "max",
11216
+ value: 0,
11217
+ inclusive: true,
11218
+ message: errorUtil.toString(message)
11219
+ });
11220
+ }
11221
+ nonnegative(message) {
11222
+ return this._addCheck({
11223
+ kind: "min",
11224
+ value: 0,
11225
+ inclusive: true,
11226
+ message: errorUtil.toString(message)
11227
+ });
11228
+ }
11229
+ multipleOf(value, message) {
11230
+ return this._addCheck({
11231
+ kind: "multipleOf",
11232
+ value,
11233
+ message: errorUtil.toString(message)
11234
+ });
11235
+ }
11236
+ finite(message) {
11237
+ return this._addCheck({
11238
+ kind: "finite",
11239
+ message: errorUtil.toString(message)
11240
+ });
11241
+ }
11242
+ safe(message) {
11243
+ return this._addCheck({
11244
+ kind: "min",
11245
+ inclusive: true,
11246
+ value: Number.MIN_SAFE_INTEGER,
11247
+ message: errorUtil.toString(message)
11248
+ })._addCheck({
11249
+ kind: "max",
11250
+ inclusive: true,
11251
+ value: Number.MAX_SAFE_INTEGER,
11252
+ message: errorUtil.toString(message)
11253
+ });
11254
+ }
11255
+ get minValue() {
11256
+ let min = null;
11257
+ for (const ch of this._def.checks) {
11258
+ if (ch.kind === "min") {
11259
+ if (min === null || ch.value > min)
11260
+ min = ch.value;
11261
+ }
11262
+ }
11263
+ return min;
11264
+ }
11265
+ get maxValue() {
11266
+ let max = null;
11267
+ for (const ch of this._def.checks) {
11268
+ if (ch.kind === "max") {
11269
+ if (max === null || ch.value < max)
11270
+ max = ch.value;
11271
+ }
11272
+ }
11273
+ return max;
11274
+ }
11275
+ get isInt() {
11276
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
11277
+ }
11278
+ get isFinite() {
11279
+ let max = null;
11280
+ let min = null;
11281
+ for (const ch of this._def.checks) {
11282
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
11283
+ return true;
11284
+ } else if (ch.kind === "min") {
11285
+ if (min === null || ch.value > min)
11286
+ min = ch.value;
11287
+ } else if (ch.kind === "max") {
11288
+ if (max === null || ch.value < max)
11289
+ max = ch.value;
11290
+ }
11291
+ }
11292
+ return Number.isFinite(min) && Number.isFinite(max);
11293
+ }
11294
+ };
11295
+ ZodNumber.create = (params) => {
11296
+ return new ZodNumber({
11297
+ checks: [],
11298
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
11299
+ coerce: params?.coerce || false,
11300
+ ...processCreateParams(params)
11301
+ });
11302
+ };
11303
+ var ZodBigInt = class _ZodBigInt extends ZodType {
11304
+ static {
11305
+ __name(this, "ZodBigInt");
11306
+ }
11307
+ constructor() {
11308
+ super(...arguments);
11309
+ this.min = this.gte;
11310
+ this.max = this.lte;
11311
+ }
11312
+ _parse(input) {
11313
+ if (this._def.coerce) {
11314
+ try {
11315
+ input.data = BigInt(input.data);
11316
+ } catch {
11317
+ return this._getInvalidInput(input);
11318
+ }
11319
+ }
11320
+ const parsedType = this._getType(input);
11321
+ if (parsedType !== ZodParsedType.bigint) {
11322
+ return this._getInvalidInput(input);
11323
+ }
11324
+ let ctx = void 0;
11325
+ const status = new ParseStatus();
11326
+ for (const check of this._def.checks) {
11327
+ if (check.kind === "min") {
11328
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
11329
+ if (tooSmall) {
11330
+ ctx = this._getOrReturnCtx(input, ctx);
11331
+ addIssueToContext(ctx, {
11332
+ code: ZodIssueCode.too_small,
11333
+ type: "bigint",
11334
+ minimum: check.value,
11335
+ inclusive: check.inclusive,
11336
+ message: check.message
11337
+ });
11338
+ status.dirty();
11339
+ }
11340
+ } else if (check.kind === "max") {
11341
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
11342
+ if (tooBig) {
11343
+ ctx = this._getOrReturnCtx(input, ctx);
11344
+ addIssueToContext(ctx, {
11345
+ code: ZodIssueCode.too_big,
11346
+ type: "bigint",
11347
+ maximum: check.value,
11348
+ inclusive: check.inclusive,
11349
+ message: check.message
11350
+ });
11351
+ status.dirty();
11352
+ }
11353
+ } else if (check.kind === "multipleOf") {
11354
+ if (input.data % check.value !== BigInt(0)) {
11355
+ ctx = this._getOrReturnCtx(input, ctx);
11356
+ addIssueToContext(ctx, {
11357
+ code: ZodIssueCode.not_multiple_of,
11358
+ multipleOf: check.value,
11359
+ message: check.message
11360
+ });
11361
+ status.dirty();
11362
+ }
11363
+ } else {
11364
+ util.assertNever(check);
11365
+ }
11366
+ }
11367
+ return { status: status.value, value: input.data };
11368
+ }
11369
+ _getInvalidInput(input) {
11370
+ const ctx = this._getOrReturnCtx(input);
11371
+ addIssueToContext(ctx, {
11372
+ code: ZodIssueCode.invalid_type,
11373
+ expected: ZodParsedType.bigint,
11374
+ received: ctx.parsedType
11375
+ });
11376
+ return INVALID;
11377
+ }
11378
+ gte(value, message) {
11379
+ return this.setLimit("min", value, true, errorUtil.toString(message));
11380
+ }
11381
+ gt(value, message) {
11382
+ return this.setLimit("min", value, false, errorUtil.toString(message));
11383
+ }
11384
+ lte(value, message) {
11385
+ return this.setLimit("max", value, true, errorUtil.toString(message));
11386
+ }
11387
+ lt(value, message) {
11388
+ return this.setLimit("max", value, false, errorUtil.toString(message));
11389
+ }
11390
+ setLimit(kind, value, inclusive, message) {
11391
+ return new _ZodBigInt({
11392
+ ...this._def,
11393
+ checks: [
11394
+ ...this._def.checks,
11395
+ {
11396
+ kind,
11397
+ value,
11398
+ inclusive,
11399
+ message: errorUtil.toString(message)
11400
+ }
11401
+ ]
11402
+ });
11403
+ }
11404
+ _addCheck(check) {
11405
+ return new _ZodBigInt({
11406
+ ...this._def,
11407
+ checks: [...this._def.checks, check]
11408
+ });
11409
+ }
11410
+ positive(message) {
11411
+ return this._addCheck({
11412
+ kind: "min",
11413
+ value: BigInt(0),
11414
+ inclusive: false,
11415
+ message: errorUtil.toString(message)
11416
+ });
11417
+ }
11418
+ negative(message) {
11419
+ return this._addCheck({
11420
+ kind: "max",
11421
+ value: BigInt(0),
11422
+ inclusive: false,
11423
+ message: errorUtil.toString(message)
11424
+ });
11425
+ }
11426
+ nonpositive(message) {
11427
+ return this._addCheck({
11428
+ kind: "max",
11429
+ value: BigInt(0),
11430
+ inclusive: true,
11431
+ message: errorUtil.toString(message)
11432
+ });
11433
+ }
11434
+ nonnegative(message) {
11435
+ return this._addCheck({
11436
+ kind: "min",
11437
+ value: BigInt(0),
11438
+ inclusive: true,
11439
+ message: errorUtil.toString(message)
11440
+ });
11441
+ }
11442
+ multipleOf(value, message) {
11443
+ return this._addCheck({
11444
+ kind: "multipleOf",
11445
+ value,
11446
+ message: errorUtil.toString(message)
11447
+ });
11448
+ }
11449
+ get minValue() {
11450
+ let min = null;
11451
+ for (const ch of this._def.checks) {
11452
+ if (ch.kind === "min") {
11453
+ if (min === null || ch.value > min)
11454
+ min = ch.value;
11455
+ }
11456
+ }
11457
+ return min;
11458
+ }
11459
+ get maxValue() {
11460
+ let max = null;
11461
+ for (const ch of this._def.checks) {
11462
+ if (ch.kind === "max") {
11463
+ if (max === null || ch.value < max)
11464
+ max = ch.value;
11465
+ }
11466
+ }
11467
+ return max;
11468
+ }
11469
+ };
11470
+ ZodBigInt.create = (params) => {
11471
+ return new ZodBigInt({
11472
+ checks: [],
11473
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
11474
+ coerce: params?.coerce ?? false,
11475
+ ...processCreateParams(params)
11476
+ });
11477
+ };
11478
+ var ZodBoolean = class extends ZodType {
11479
+ static {
11480
+ __name(this, "ZodBoolean");
11481
+ }
11482
+ _parse(input) {
11483
+ if (this._def.coerce) {
11484
+ input.data = Boolean(input.data);
11485
+ }
11486
+ const parsedType = this._getType(input);
11487
+ if (parsedType !== ZodParsedType.boolean) {
11488
+ const ctx = this._getOrReturnCtx(input);
11489
+ addIssueToContext(ctx, {
11490
+ code: ZodIssueCode.invalid_type,
11491
+ expected: ZodParsedType.boolean,
11492
+ received: ctx.parsedType
11493
+ });
11494
+ return INVALID;
11495
+ }
11496
+ return OK(input.data);
11497
+ }
11498
+ };
11499
+ ZodBoolean.create = (params) => {
11500
+ return new ZodBoolean({
11501
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
11502
+ coerce: params?.coerce || false,
11503
+ ...processCreateParams(params)
11504
+ });
11505
+ };
11506
+ var ZodDate = class _ZodDate extends ZodType {
11507
+ static {
11508
+ __name(this, "ZodDate");
11509
+ }
11510
+ _parse(input) {
11511
+ if (this._def.coerce) {
11512
+ input.data = new Date(input.data);
11513
+ }
11514
+ const parsedType = this._getType(input);
11515
+ if (parsedType !== ZodParsedType.date) {
11516
+ const ctx2 = this._getOrReturnCtx(input);
11517
+ addIssueToContext(ctx2, {
11518
+ code: ZodIssueCode.invalid_type,
11519
+ expected: ZodParsedType.date,
11520
+ received: ctx2.parsedType
11521
+ });
11522
+ return INVALID;
11523
+ }
11524
+ if (Number.isNaN(input.data.getTime())) {
11525
+ const ctx2 = this._getOrReturnCtx(input);
11526
+ addIssueToContext(ctx2, {
11527
+ code: ZodIssueCode.invalid_date
11528
+ });
11529
+ return INVALID;
11530
+ }
11531
+ const status = new ParseStatus();
11532
+ let ctx = void 0;
11533
+ for (const check of this._def.checks) {
11534
+ if (check.kind === "min") {
11535
+ if (input.data.getTime() < check.value) {
11536
+ ctx = this._getOrReturnCtx(input, ctx);
11537
+ addIssueToContext(ctx, {
11538
+ code: ZodIssueCode.too_small,
11539
+ message: check.message,
11540
+ inclusive: true,
11541
+ exact: false,
11542
+ minimum: check.value,
11543
+ type: "date"
11544
+ });
11545
+ status.dirty();
11546
+ }
11547
+ } else if (check.kind === "max") {
11548
+ if (input.data.getTime() > check.value) {
11549
+ ctx = this._getOrReturnCtx(input, ctx);
11550
+ addIssueToContext(ctx, {
11551
+ code: ZodIssueCode.too_big,
11552
+ message: check.message,
11553
+ inclusive: true,
11554
+ exact: false,
11555
+ maximum: check.value,
11556
+ type: "date"
11557
+ });
11558
+ status.dirty();
11559
+ }
11560
+ } else {
11561
+ util.assertNever(check);
11562
+ }
11563
+ }
11564
+ return {
11565
+ status: status.value,
11566
+ value: new Date(input.data.getTime())
11567
+ };
11568
+ }
11569
+ _addCheck(check) {
11570
+ return new _ZodDate({
11571
+ ...this._def,
11572
+ checks: [...this._def.checks, check]
11573
+ });
11574
+ }
11575
+ min(minDate, message) {
11576
+ return this._addCheck({
11577
+ kind: "min",
11578
+ value: minDate.getTime(),
11579
+ message: errorUtil.toString(message)
11580
+ });
11581
+ }
11582
+ max(maxDate, message) {
11583
+ return this._addCheck({
11584
+ kind: "max",
11585
+ value: maxDate.getTime(),
11586
+ message: errorUtil.toString(message)
11587
+ });
11588
+ }
11589
+ get minDate() {
11590
+ let min = null;
11591
+ for (const ch of this._def.checks) {
11592
+ if (ch.kind === "min") {
11593
+ if (min === null || ch.value > min)
11594
+ min = ch.value;
11595
+ }
11596
+ }
11597
+ return min != null ? new Date(min) : null;
11598
+ }
11599
+ get maxDate() {
11600
+ let max = null;
11601
+ for (const ch of this._def.checks) {
11602
+ if (ch.kind === "max") {
11603
+ if (max === null || ch.value < max)
11604
+ max = ch.value;
11605
+ }
11606
+ }
11607
+ return max != null ? new Date(max) : null;
11608
+ }
11609
+ };
11610
+ ZodDate.create = (params) => {
11611
+ return new ZodDate({
11612
+ checks: [],
11613
+ coerce: params?.coerce || false,
11614
+ typeName: ZodFirstPartyTypeKind.ZodDate,
11615
+ ...processCreateParams(params)
11616
+ });
11617
+ };
11618
+ var ZodSymbol = class extends ZodType {
11619
+ static {
11620
+ __name(this, "ZodSymbol");
11621
+ }
11622
+ _parse(input) {
11623
+ const parsedType = this._getType(input);
11624
+ if (parsedType !== ZodParsedType.symbol) {
11625
+ const ctx = this._getOrReturnCtx(input);
11626
+ addIssueToContext(ctx, {
11627
+ code: ZodIssueCode.invalid_type,
11628
+ expected: ZodParsedType.symbol,
11629
+ received: ctx.parsedType
11630
+ });
11631
+ return INVALID;
11632
+ }
11633
+ return OK(input.data);
11634
+ }
11635
+ };
11636
+ ZodSymbol.create = (params) => {
11637
+ return new ZodSymbol({
11638
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
11639
+ ...processCreateParams(params)
11640
+ });
11641
+ };
11642
+ var ZodUndefined = class extends ZodType {
11643
+ static {
11644
+ __name(this, "ZodUndefined");
11645
+ }
11646
+ _parse(input) {
11647
+ const parsedType = this._getType(input);
11648
+ if (parsedType !== ZodParsedType.undefined) {
11649
+ const ctx = this._getOrReturnCtx(input);
11650
+ addIssueToContext(ctx, {
11651
+ code: ZodIssueCode.invalid_type,
11652
+ expected: ZodParsedType.undefined,
11653
+ received: ctx.parsedType
11654
+ });
11655
+ return INVALID;
11656
+ }
11657
+ return OK(input.data);
11658
+ }
11659
+ };
11660
+ ZodUndefined.create = (params) => {
11661
+ return new ZodUndefined({
11662
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
11663
+ ...processCreateParams(params)
11664
+ });
11665
+ };
11666
+ var ZodNull = class extends ZodType {
11667
+ static {
11668
+ __name(this, "ZodNull");
11669
+ }
11670
+ _parse(input) {
11671
+ const parsedType = this._getType(input);
11672
+ if (parsedType !== ZodParsedType.null) {
11673
+ const ctx = this._getOrReturnCtx(input);
11674
+ addIssueToContext(ctx, {
11675
+ code: ZodIssueCode.invalid_type,
11676
+ expected: ZodParsedType.null,
11677
+ received: ctx.parsedType
11678
+ });
11679
+ return INVALID;
11680
+ }
11681
+ return OK(input.data);
11682
+ }
11683
+ };
11684
+ ZodNull.create = (params) => {
11685
+ return new ZodNull({
11686
+ typeName: ZodFirstPartyTypeKind.ZodNull,
11687
+ ...processCreateParams(params)
11688
+ });
11689
+ };
11690
+ var ZodAny = class extends ZodType {
11691
+ static {
11692
+ __name(this, "ZodAny");
11693
+ }
11694
+ constructor() {
11695
+ super(...arguments);
11696
+ this._any = true;
11697
+ }
11698
+ _parse(input) {
11699
+ return OK(input.data);
11700
+ }
11701
+ };
11702
+ ZodAny.create = (params) => {
11703
+ return new ZodAny({
11704
+ typeName: ZodFirstPartyTypeKind.ZodAny,
11705
+ ...processCreateParams(params)
11706
+ });
11707
+ };
11708
+ var ZodUnknown = class extends ZodType {
11709
+ static {
11710
+ __name(this, "ZodUnknown");
11711
+ }
11712
+ constructor() {
11713
+ super(...arguments);
11714
+ this._unknown = true;
11715
+ }
11716
+ _parse(input) {
11717
+ return OK(input.data);
11718
+ }
11719
+ };
11720
+ ZodUnknown.create = (params) => {
11721
+ return new ZodUnknown({
11722
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
11723
+ ...processCreateParams(params)
11724
+ });
11725
+ };
11726
+ var ZodNever = class extends ZodType {
11727
+ static {
11728
+ __name(this, "ZodNever");
11729
+ }
11730
+ _parse(input) {
11731
+ const ctx = this._getOrReturnCtx(input);
11732
+ addIssueToContext(ctx, {
11733
+ code: ZodIssueCode.invalid_type,
11734
+ expected: ZodParsedType.never,
11735
+ received: ctx.parsedType
11736
+ });
11737
+ return INVALID;
11738
+ }
11739
+ };
11740
+ ZodNever.create = (params) => {
11741
+ return new ZodNever({
11742
+ typeName: ZodFirstPartyTypeKind.ZodNever,
11743
+ ...processCreateParams(params)
11744
+ });
11745
+ };
11746
+ var ZodVoid = class extends ZodType {
11747
+ static {
11748
+ __name(this, "ZodVoid");
11749
+ }
11750
+ _parse(input) {
11751
+ const parsedType = this._getType(input);
11752
+ if (parsedType !== ZodParsedType.undefined) {
11753
+ const ctx = this._getOrReturnCtx(input);
11754
+ addIssueToContext(ctx, {
11755
+ code: ZodIssueCode.invalid_type,
11756
+ expected: ZodParsedType.void,
11757
+ received: ctx.parsedType
11758
+ });
11759
+ return INVALID;
11760
+ }
11761
+ return OK(input.data);
11762
+ }
11763
+ };
11764
+ ZodVoid.create = (params) => {
11765
+ return new ZodVoid({
11766
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
11767
+ ...processCreateParams(params)
11768
+ });
11769
+ };
11770
+ var ZodArray = class _ZodArray extends ZodType {
11771
+ static {
11772
+ __name(this, "ZodArray");
11773
+ }
11774
+ _parse(input) {
11775
+ const { ctx, status } = this._processInputParams(input);
11776
+ const def = this._def;
11777
+ if (ctx.parsedType !== ZodParsedType.array) {
11778
+ addIssueToContext(ctx, {
11779
+ code: ZodIssueCode.invalid_type,
11780
+ expected: ZodParsedType.array,
11781
+ received: ctx.parsedType
11782
+ });
11783
+ return INVALID;
11784
+ }
11785
+ if (def.exactLength !== null) {
11786
+ const tooBig = ctx.data.length > def.exactLength.value;
11787
+ const tooSmall = ctx.data.length < def.exactLength.value;
11788
+ if (tooBig || tooSmall) {
11789
+ addIssueToContext(ctx, {
11790
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
11791
+ minimum: tooSmall ? def.exactLength.value : void 0,
11792
+ maximum: tooBig ? def.exactLength.value : void 0,
11793
+ type: "array",
11794
+ inclusive: true,
11795
+ exact: true,
11796
+ message: def.exactLength.message
11797
+ });
11798
+ status.dirty();
11799
+ }
11800
+ }
11801
+ if (def.minLength !== null) {
11802
+ if (ctx.data.length < def.minLength.value) {
11803
+ addIssueToContext(ctx, {
11804
+ code: ZodIssueCode.too_small,
11805
+ minimum: def.minLength.value,
11806
+ type: "array",
11807
+ inclusive: true,
11808
+ exact: false,
11809
+ message: def.minLength.message
11810
+ });
11811
+ status.dirty();
11812
+ }
11813
+ }
11814
+ if (def.maxLength !== null) {
11815
+ if (ctx.data.length > def.maxLength.value) {
11816
+ addIssueToContext(ctx, {
11817
+ code: ZodIssueCode.too_big,
11818
+ maximum: def.maxLength.value,
11819
+ type: "array",
11820
+ inclusive: true,
11821
+ exact: false,
11822
+ message: def.maxLength.message
11823
+ });
11824
+ status.dirty();
11825
+ }
11826
+ }
11827
+ if (ctx.common.async) {
11828
+ return Promise.all([...ctx.data].map((item, i) => {
11829
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
11830
+ })).then((result2) => {
11831
+ return ParseStatus.mergeArray(status, result2);
11832
+ });
11833
+ }
11834
+ const result = [...ctx.data].map((item, i) => {
11835
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
11836
+ });
11837
+ return ParseStatus.mergeArray(status, result);
11838
+ }
11839
+ get element() {
11840
+ return this._def.type;
11841
+ }
11842
+ min(minLength, message) {
11843
+ return new _ZodArray({
11844
+ ...this._def,
11845
+ minLength: { value: minLength, message: errorUtil.toString(message) }
11846
+ });
11847
+ }
11848
+ max(maxLength, message) {
11849
+ return new _ZodArray({
11850
+ ...this._def,
11851
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
11852
+ });
11853
+ }
11854
+ length(len, message) {
11855
+ return new _ZodArray({
11856
+ ...this._def,
11857
+ exactLength: { value: len, message: errorUtil.toString(message) }
11858
+ });
11859
+ }
11860
+ nonempty(message) {
11861
+ return this.min(1, message);
11862
+ }
11863
+ };
11864
+ ZodArray.create = (schema, params) => {
11865
+ return new ZodArray({
11866
+ type: schema,
11867
+ minLength: null,
11868
+ maxLength: null,
11869
+ exactLength: null,
11870
+ typeName: ZodFirstPartyTypeKind.ZodArray,
11871
+ ...processCreateParams(params)
11872
+ });
11873
+ };
11874
+ function deepPartialify(schema) {
11875
+ if (schema instanceof ZodObject) {
11876
+ const newShape = {};
11877
+ for (const key in schema.shape) {
11878
+ const fieldSchema = schema.shape[key];
11879
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
11880
+ }
11881
+ return new ZodObject({
11882
+ ...schema._def,
11883
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
11884
+ });
11885
+ } else if (schema instanceof ZodArray) {
11886
+ return new ZodArray({
11887
+ ...schema._def,
11888
+ type: deepPartialify(schema.element)
11889
+ });
11890
+ } else if (schema instanceof ZodOptional) {
11891
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
11892
+ } else if (schema instanceof ZodNullable) {
11893
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
11894
+ } else if (schema instanceof ZodTuple) {
11895
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
11896
+ } else {
11897
+ return schema;
11898
+ }
11899
+ }
11900
+ __name(deepPartialify, "deepPartialify");
11901
+ var ZodObject = class _ZodObject extends ZodType {
11902
+ static {
11903
+ __name(this, "ZodObject");
11904
+ }
11905
+ constructor() {
11906
+ super(...arguments);
11907
+ this._cached = null;
11908
+ this.nonstrict = this.passthrough;
11909
+ this.augment = this.extend;
11910
+ }
11911
+ _getCached() {
11912
+ if (this._cached !== null)
11913
+ return this._cached;
11914
+ const shape = this._def.shape();
11915
+ const keys = util.objectKeys(shape);
11916
+ this._cached = { shape, keys };
11917
+ return this._cached;
11918
+ }
11919
+ _parse(input) {
11920
+ const parsedType = this._getType(input);
11921
+ if (parsedType !== ZodParsedType.object) {
11922
+ const ctx2 = this._getOrReturnCtx(input);
11923
+ addIssueToContext(ctx2, {
11924
+ code: ZodIssueCode.invalid_type,
11925
+ expected: ZodParsedType.object,
11926
+ received: ctx2.parsedType
11927
+ });
11928
+ return INVALID;
11929
+ }
11930
+ const { status, ctx } = this._processInputParams(input);
11931
+ const { shape, keys: shapeKeys } = this._getCached();
11932
+ const extraKeys = [];
11933
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
11934
+ for (const key in ctx.data) {
11935
+ if (!shapeKeys.includes(key)) {
11936
+ extraKeys.push(key);
11937
+ }
11938
+ }
11939
+ }
11940
+ const pairs = [];
11941
+ for (const key of shapeKeys) {
11942
+ const keyValidator = shape[key];
11943
+ const value = ctx.data[key];
11944
+ pairs.push({
11945
+ key: { status: "valid", value: key },
11946
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
11947
+ alwaysSet: key in ctx.data
11948
+ });
11949
+ }
11950
+ if (this._def.catchall instanceof ZodNever) {
11951
+ const unknownKeys = this._def.unknownKeys;
11952
+ if (unknownKeys === "passthrough") {
11953
+ for (const key of extraKeys) {
11954
+ pairs.push({
11955
+ key: { status: "valid", value: key },
11956
+ value: { status: "valid", value: ctx.data[key] }
11957
+ });
11958
+ }
11959
+ } else if (unknownKeys === "strict") {
11960
+ if (extraKeys.length > 0) {
11961
+ addIssueToContext(ctx, {
11962
+ code: ZodIssueCode.unrecognized_keys,
11963
+ keys: extraKeys
11964
+ });
11965
+ status.dirty();
11966
+ }
11967
+ } else if (unknownKeys === "strip") ; else {
11968
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
11969
+ }
11970
+ } else {
11971
+ const catchall = this._def.catchall;
11972
+ for (const key of extraKeys) {
11973
+ const value = ctx.data[key];
11974
+ pairs.push({
11975
+ key: { status: "valid", value: key },
11976
+ value: catchall._parse(
11977
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
11978
+ //, ctx.child(key), value, getParsedType(value)
11979
+ ),
11980
+ alwaysSet: key in ctx.data
11981
+ });
11982
+ }
11983
+ }
11984
+ if (ctx.common.async) {
11985
+ return Promise.resolve().then(async () => {
11986
+ const syncPairs = [];
11987
+ for (const pair of pairs) {
11988
+ const key = await pair.key;
11989
+ const value = await pair.value;
11990
+ syncPairs.push({
11991
+ key,
11992
+ value,
11993
+ alwaysSet: pair.alwaysSet
11994
+ });
11995
+ }
11996
+ return syncPairs;
11997
+ }).then((syncPairs) => {
11998
+ return ParseStatus.mergeObjectSync(status, syncPairs);
11999
+ });
12000
+ } else {
12001
+ return ParseStatus.mergeObjectSync(status, pairs);
12002
+ }
12003
+ }
12004
+ get shape() {
12005
+ return this._def.shape();
12006
+ }
12007
+ strict(message) {
12008
+ errorUtil.errToObj;
12009
+ return new _ZodObject({
12010
+ ...this._def,
12011
+ unknownKeys: "strict",
12012
+ ...message !== void 0 ? {
12013
+ errorMap: /* @__PURE__ */ __name((issue, ctx) => {
12014
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
12015
+ if (issue.code === "unrecognized_keys")
12016
+ return {
12017
+ message: errorUtil.errToObj(message).message ?? defaultError
12018
+ };
12019
+ return {
12020
+ message: defaultError
12021
+ };
12022
+ }, "errorMap")
12023
+ } : {}
12024
+ });
12025
+ }
12026
+ strip() {
12027
+ return new _ZodObject({
12028
+ ...this._def,
12029
+ unknownKeys: "strip"
12030
+ });
12031
+ }
12032
+ passthrough() {
12033
+ return new _ZodObject({
12034
+ ...this._def,
12035
+ unknownKeys: "passthrough"
12036
+ });
12037
+ }
12038
+ // const AugmentFactory =
12039
+ // <Def extends ZodObjectDef>(def: Def) =>
12040
+ // <Augmentation extends ZodRawShape>(
12041
+ // augmentation: Augmentation
12042
+ // ): ZodObject<
12043
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
12044
+ // Def["unknownKeys"],
12045
+ // Def["catchall"]
12046
+ // > => {
12047
+ // return new ZodObject({
12048
+ // ...def,
12049
+ // shape: () => ({
12050
+ // ...def.shape(),
12051
+ // ...augmentation,
12052
+ // }),
12053
+ // }) as any;
12054
+ // };
12055
+ extend(augmentation) {
12056
+ return new _ZodObject({
12057
+ ...this._def,
12058
+ shape: /* @__PURE__ */ __name(() => ({
12059
+ ...this._def.shape(),
12060
+ ...augmentation
12061
+ }), "shape")
12062
+ });
12063
+ }
12064
+ /**
12065
+ * Prior to zod@1.0.12 there was a bug in the
12066
+ * inferred type of merged objects. Please
12067
+ * upgrade if you are experiencing issues.
12068
+ */
12069
+ merge(merging) {
12070
+ const merged = new _ZodObject({
12071
+ unknownKeys: merging._def.unknownKeys,
12072
+ catchall: merging._def.catchall,
12073
+ shape: /* @__PURE__ */ __name(() => ({
12074
+ ...this._def.shape(),
12075
+ ...merging._def.shape()
12076
+ }), "shape"),
12077
+ typeName: ZodFirstPartyTypeKind.ZodObject
12078
+ });
12079
+ return merged;
12080
+ }
12081
+ // merge<
12082
+ // Incoming extends AnyZodObject,
12083
+ // Augmentation extends Incoming["shape"],
12084
+ // NewOutput extends {
12085
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
12086
+ // ? Augmentation[k]["_output"]
12087
+ // : k extends keyof Output
12088
+ // ? Output[k]
12089
+ // : never;
12090
+ // },
12091
+ // NewInput extends {
12092
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
12093
+ // ? Augmentation[k]["_input"]
12094
+ // : k extends keyof Input
12095
+ // ? Input[k]
12096
+ // : never;
12097
+ // }
12098
+ // >(
12099
+ // merging: Incoming
12100
+ // ): ZodObject<
12101
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
12102
+ // Incoming["_def"]["unknownKeys"],
12103
+ // Incoming["_def"]["catchall"],
12104
+ // NewOutput,
12105
+ // NewInput
12106
+ // > {
12107
+ // const merged: any = new ZodObject({
12108
+ // unknownKeys: merging._def.unknownKeys,
12109
+ // catchall: merging._def.catchall,
12110
+ // shape: () =>
12111
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
12112
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
12113
+ // }) as any;
12114
+ // return merged;
12115
+ // }
12116
+ setKey(key, schema) {
12117
+ return this.augment({ [key]: schema });
12118
+ }
12119
+ // merge<Incoming extends AnyZodObject>(
12120
+ // merging: Incoming
12121
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
12122
+ // ZodObject<
12123
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
12124
+ // Incoming["_def"]["unknownKeys"],
12125
+ // Incoming["_def"]["catchall"]
12126
+ // > {
12127
+ // // const mergedShape = objectUtil.mergeShapes(
12128
+ // // this._def.shape(),
12129
+ // // merging._def.shape()
12130
+ // // );
12131
+ // const merged: any = new ZodObject({
12132
+ // unknownKeys: merging._def.unknownKeys,
12133
+ // catchall: merging._def.catchall,
12134
+ // shape: () =>
12135
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
12136
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
12137
+ // }) as any;
12138
+ // return merged;
12139
+ // }
12140
+ catchall(index) {
12141
+ return new _ZodObject({
12142
+ ...this._def,
12143
+ catchall: index
12144
+ });
12145
+ }
12146
+ pick(mask) {
12147
+ const shape = {};
12148
+ for (const key of util.objectKeys(mask)) {
12149
+ if (mask[key] && this.shape[key]) {
12150
+ shape[key] = this.shape[key];
12151
+ }
12152
+ }
12153
+ return new _ZodObject({
12154
+ ...this._def,
12155
+ shape: /* @__PURE__ */ __name(() => shape, "shape")
12156
+ });
12157
+ }
12158
+ omit(mask) {
12159
+ const shape = {};
12160
+ for (const key of util.objectKeys(this.shape)) {
12161
+ if (!mask[key]) {
12162
+ shape[key] = this.shape[key];
12163
+ }
12164
+ }
12165
+ return new _ZodObject({
12166
+ ...this._def,
12167
+ shape: /* @__PURE__ */ __name(() => shape, "shape")
12168
+ });
12169
+ }
12170
+ /**
12171
+ * @deprecated
12172
+ */
12173
+ deepPartial() {
12174
+ return deepPartialify(this);
12175
+ }
12176
+ partial(mask) {
12177
+ const newShape = {};
12178
+ for (const key of util.objectKeys(this.shape)) {
12179
+ const fieldSchema = this.shape[key];
12180
+ if (mask && !mask[key]) {
12181
+ newShape[key] = fieldSchema;
12182
+ } else {
12183
+ newShape[key] = fieldSchema.optional();
12184
+ }
12185
+ }
12186
+ return new _ZodObject({
12187
+ ...this._def,
12188
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
12189
+ });
12190
+ }
12191
+ required(mask) {
12192
+ const newShape = {};
12193
+ for (const key of util.objectKeys(this.shape)) {
12194
+ if (mask && !mask[key]) {
12195
+ newShape[key] = this.shape[key];
12196
+ } else {
12197
+ const fieldSchema = this.shape[key];
12198
+ let newField = fieldSchema;
12199
+ while (newField instanceof ZodOptional) {
12200
+ newField = newField._def.innerType;
12201
+ }
12202
+ newShape[key] = newField;
12203
+ }
12204
+ }
12205
+ return new _ZodObject({
12206
+ ...this._def,
12207
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
12208
+ });
12209
+ }
12210
+ keyof() {
12211
+ return createZodEnum(util.objectKeys(this.shape));
12212
+ }
12213
+ };
12214
+ ZodObject.create = (shape, params) => {
12215
+ return new ZodObject({
12216
+ shape: /* @__PURE__ */ __name(() => shape, "shape"),
12217
+ unknownKeys: "strip",
12218
+ catchall: ZodNever.create(),
12219
+ typeName: ZodFirstPartyTypeKind.ZodObject,
12220
+ ...processCreateParams(params)
12221
+ });
12222
+ };
12223
+ ZodObject.strictCreate = (shape, params) => {
12224
+ return new ZodObject({
12225
+ shape: /* @__PURE__ */ __name(() => shape, "shape"),
12226
+ unknownKeys: "strict",
12227
+ catchall: ZodNever.create(),
12228
+ typeName: ZodFirstPartyTypeKind.ZodObject,
12229
+ ...processCreateParams(params)
12230
+ });
12231
+ };
12232
+ ZodObject.lazycreate = (shape, params) => {
12233
+ return new ZodObject({
12234
+ shape,
12235
+ unknownKeys: "strip",
12236
+ catchall: ZodNever.create(),
12237
+ typeName: ZodFirstPartyTypeKind.ZodObject,
12238
+ ...processCreateParams(params)
12239
+ });
12240
+ };
12241
+ var ZodUnion = class extends ZodType {
12242
+ static {
12243
+ __name(this, "ZodUnion");
12244
+ }
12245
+ _parse(input) {
12246
+ const { ctx } = this._processInputParams(input);
12247
+ const options = this._def.options;
12248
+ function handleResults(results) {
12249
+ for (const result of results) {
12250
+ if (result.result.status === "valid") {
12251
+ return result.result;
12252
+ }
12253
+ }
12254
+ for (const result of results) {
12255
+ if (result.result.status === "dirty") {
12256
+ ctx.common.issues.push(...result.ctx.common.issues);
12257
+ return result.result;
12258
+ }
12259
+ }
12260
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
12261
+ addIssueToContext(ctx, {
12262
+ code: ZodIssueCode.invalid_union,
12263
+ unionErrors
12264
+ });
12265
+ return INVALID;
12266
+ }
12267
+ __name(handleResults, "handleResults");
12268
+ if (ctx.common.async) {
12269
+ return Promise.all(options.map(async (option) => {
12270
+ const childCtx = {
12271
+ ...ctx,
12272
+ common: {
12273
+ ...ctx.common,
12274
+ issues: []
12275
+ },
12276
+ parent: null
12277
+ };
12278
+ return {
12279
+ result: await option._parseAsync({
12280
+ data: ctx.data,
12281
+ path: ctx.path,
12282
+ parent: childCtx
12283
+ }),
12284
+ ctx: childCtx
12285
+ };
12286
+ })).then(handleResults);
12287
+ } else {
12288
+ let dirty = void 0;
12289
+ const issues = [];
12290
+ for (const option of options) {
12291
+ const childCtx = {
12292
+ ...ctx,
12293
+ common: {
12294
+ ...ctx.common,
12295
+ issues: []
12296
+ },
12297
+ parent: null
12298
+ };
12299
+ const result = option._parseSync({
12300
+ data: ctx.data,
12301
+ path: ctx.path,
12302
+ parent: childCtx
12303
+ });
12304
+ if (result.status === "valid") {
12305
+ return result;
12306
+ } else if (result.status === "dirty" && !dirty) {
12307
+ dirty = { result, ctx: childCtx };
12308
+ }
12309
+ if (childCtx.common.issues.length) {
12310
+ issues.push(childCtx.common.issues);
12311
+ }
12312
+ }
12313
+ if (dirty) {
12314
+ ctx.common.issues.push(...dirty.ctx.common.issues);
12315
+ return dirty.result;
12316
+ }
12317
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
12318
+ addIssueToContext(ctx, {
12319
+ code: ZodIssueCode.invalid_union,
12320
+ unionErrors
12321
+ });
12322
+ return INVALID;
12323
+ }
12324
+ }
12325
+ get options() {
12326
+ return this._def.options;
12327
+ }
12328
+ };
12329
+ ZodUnion.create = (types3, params) => {
12330
+ return new ZodUnion({
12331
+ options: types3,
12332
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
12333
+ ...processCreateParams(params)
12334
+ });
12335
+ };
12336
+ var getDiscriminator = /* @__PURE__ */ __name((type) => {
12337
+ if (type instanceof ZodLazy) {
12338
+ return getDiscriminator(type.schema);
12339
+ } else if (type instanceof ZodEffects) {
12340
+ return getDiscriminator(type.innerType());
12341
+ } else if (type instanceof ZodLiteral) {
12342
+ return [type.value];
12343
+ } else if (type instanceof ZodEnum) {
12344
+ return type.options;
12345
+ } else if (type instanceof ZodNativeEnum) {
12346
+ return util.objectValues(type.enum);
12347
+ } else if (type instanceof ZodDefault) {
12348
+ return getDiscriminator(type._def.innerType);
12349
+ } else if (type instanceof ZodUndefined) {
12350
+ return [void 0];
12351
+ } else if (type instanceof ZodNull) {
12352
+ return [null];
12353
+ } else if (type instanceof ZodOptional) {
12354
+ return [void 0, ...getDiscriminator(type.unwrap())];
12355
+ } else if (type instanceof ZodNullable) {
12356
+ return [null, ...getDiscriminator(type.unwrap())];
12357
+ } else if (type instanceof ZodBranded) {
12358
+ return getDiscriminator(type.unwrap());
12359
+ } else if (type instanceof ZodReadonly) {
12360
+ return getDiscriminator(type.unwrap());
12361
+ } else if (type instanceof ZodCatch) {
12362
+ return getDiscriminator(type._def.innerType);
12363
+ } else {
12364
+ return [];
12365
+ }
12366
+ }, "getDiscriminator");
12367
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
12368
+ static {
12369
+ __name(this, "ZodDiscriminatedUnion");
12370
+ }
12371
+ _parse(input) {
12372
+ const { ctx } = this._processInputParams(input);
12373
+ if (ctx.parsedType !== ZodParsedType.object) {
12374
+ addIssueToContext(ctx, {
12375
+ code: ZodIssueCode.invalid_type,
12376
+ expected: ZodParsedType.object,
12377
+ received: ctx.parsedType
12378
+ });
12379
+ return INVALID;
12380
+ }
12381
+ const discriminator = this.discriminator;
12382
+ const discriminatorValue = ctx.data[discriminator];
12383
+ const option = this.optionsMap.get(discriminatorValue);
12384
+ if (!option) {
12385
+ addIssueToContext(ctx, {
12386
+ code: ZodIssueCode.invalid_union_discriminator,
12387
+ options: Array.from(this.optionsMap.keys()),
12388
+ path: [discriminator]
12389
+ });
12390
+ return INVALID;
12391
+ }
12392
+ if (ctx.common.async) {
12393
+ return option._parseAsync({
12394
+ data: ctx.data,
12395
+ path: ctx.path,
12396
+ parent: ctx
12397
+ });
12398
+ } else {
12399
+ return option._parseSync({
12400
+ data: ctx.data,
12401
+ path: ctx.path,
12402
+ parent: ctx
12403
+ });
12404
+ }
12405
+ }
12406
+ get discriminator() {
12407
+ return this._def.discriminator;
12408
+ }
12409
+ get options() {
12410
+ return this._def.options;
12411
+ }
12412
+ get optionsMap() {
12413
+ return this._def.optionsMap;
12414
+ }
12415
+ /**
12416
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
12417
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
12418
+ * have a different value for each object in the union.
12419
+ * @param discriminator the name of the discriminator property
12420
+ * @param types an array of object schemas
12421
+ * @param params
12422
+ */
12423
+ static create(discriminator, options, params) {
12424
+ const optionsMap = /* @__PURE__ */ new Map();
12425
+ for (const type of options) {
12426
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
12427
+ if (!discriminatorValues.length) {
12428
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
12429
+ }
12430
+ for (const value of discriminatorValues) {
12431
+ if (optionsMap.has(value)) {
12432
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
12433
+ }
12434
+ optionsMap.set(value, type);
12435
+ }
12436
+ }
12437
+ return new _ZodDiscriminatedUnion({
12438
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
12439
+ discriminator,
12440
+ options,
12441
+ optionsMap,
12442
+ ...processCreateParams(params)
12443
+ });
12444
+ }
12445
+ };
12446
+ function mergeValues(a, b) {
12447
+ const aType = getParsedType(a);
12448
+ const bType = getParsedType(b);
12449
+ if (a === b) {
12450
+ return { valid: true, data: a };
12451
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
12452
+ const bKeys = util.objectKeys(b);
12453
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
12454
+ const newObj = { ...a, ...b };
12455
+ for (const key of sharedKeys) {
12456
+ const sharedValue = mergeValues(a[key], b[key]);
12457
+ if (!sharedValue.valid) {
12458
+ return { valid: false };
12459
+ }
12460
+ newObj[key] = sharedValue.data;
12461
+ }
12462
+ return { valid: true, data: newObj };
12463
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
12464
+ if (a.length !== b.length) {
12465
+ return { valid: false };
12466
+ }
12467
+ const newArray = [];
12468
+ for (let index = 0; index < a.length; index++) {
12469
+ const itemA = a[index];
12470
+ const itemB = b[index];
12471
+ const sharedValue = mergeValues(itemA, itemB);
12472
+ if (!sharedValue.valid) {
12473
+ return { valid: false };
12474
+ }
12475
+ newArray.push(sharedValue.data);
12476
+ }
12477
+ return { valid: true, data: newArray };
12478
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
12479
+ return { valid: true, data: a };
12480
+ } else {
12481
+ return { valid: false };
12482
+ }
12483
+ }
12484
+ __name(mergeValues, "mergeValues");
12485
+ var ZodIntersection = class extends ZodType {
12486
+ static {
12487
+ __name(this, "ZodIntersection");
12488
+ }
12489
+ _parse(input) {
12490
+ const { status, ctx } = this._processInputParams(input);
12491
+ const handleParsed = /* @__PURE__ */ __name((parsedLeft, parsedRight) => {
12492
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
12493
+ return INVALID;
12494
+ }
12495
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
12496
+ if (!merged.valid) {
12497
+ addIssueToContext(ctx, {
12498
+ code: ZodIssueCode.invalid_intersection_types
12499
+ });
12500
+ return INVALID;
12501
+ }
12502
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
12503
+ status.dirty();
12504
+ }
12505
+ return { status: status.value, value: merged.data };
12506
+ }, "handleParsed");
12507
+ if (ctx.common.async) {
12508
+ return Promise.all([
12509
+ this._def.left._parseAsync({
12510
+ data: ctx.data,
12511
+ path: ctx.path,
12512
+ parent: ctx
12513
+ }),
12514
+ this._def.right._parseAsync({
12515
+ data: ctx.data,
12516
+ path: ctx.path,
12517
+ parent: ctx
12518
+ })
12519
+ ]).then(([left, right]) => handleParsed(left, right));
12520
+ } else {
12521
+ return handleParsed(this._def.left._parseSync({
12522
+ data: ctx.data,
12523
+ path: ctx.path,
12524
+ parent: ctx
12525
+ }), this._def.right._parseSync({
12526
+ data: ctx.data,
12527
+ path: ctx.path,
12528
+ parent: ctx
12529
+ }));
12530
+ }
12531
+ }
12532
+ };
12533
+ ZodIntersection.create = (left, right, params) => {
12534
+ return new ZodIntersection({
12535
+ left,
12536
+ right,
12537
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
12538
+ ...processCreateParams(params)
12539
+ });
12540
+ };
12541
+ var ZodTuple = class _ZodTuple extends ZodType {
12542
+ static {
12543
+ __name(this, "ZodTuple");
12544
+ }
12545
+ _parse(input) {
12546
+ const { status, ctx } = this._processInputParams(input);
12547
+ if (ctx.parsedType !== ZodParsedType.array) {
12548
+ addIssueToContext(ctx, {
12549
+ code: ZodIssueCode.invalid_type,
12550
+ expected: ZodParsedType.array,
12551
+ received: ctx.parsedType
12552
+ });
12553
+ return INVALID;
12554
+ }
12555
+ if (ctx.data.length < this._def.items.length) {
12556
+ addIssueToContext(ctx, {
12557
+ code: ZodIssueCode.too_small,
12558
+ minimum: this._def.items.length,
12559
+ inclusive: true,
12560
+ exact: false,
12561
+ type: "array"
12562
+ });
12563
+ return INVALID;
12564
+ }
12565
+ const rest = this._def.rest;
12566
+ if (!rest && ctx.data.length > this._def.items.length) {
12567
+ addIssueToContext(ctx, {
12568
+ code: ZodIssueCode.too_big,
12569
+ maximum: this._def.items.length,
12570
+ inclusive: true,
12571
+ exact: false,
12572
+ type: "array"
12573
+ });
12574
+ status.dirty();
12575
+ }
12576
+ const items = [...ctx.data].map((item, itemIndex) => {
12577
+ const schema = this._def.items[itemIndex] || this._def.rest;
12578
+ if (!schema)
12579
+ return null;
12580
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
12581
+ }).filter((x) => !!x);
12582
+ if (ctx.common.async) {
12583
+ return Promise.all(items).then((results) => {
12584
+ return ParseStatus.mergeArray(status, results);
12585
+ });
12586
+ } else {
12587
+ return ParseStatus.mergeArray(status, items);
12588
+ }
12589
+ }
12590
+ get items() {
12591
+ return this._def.items;
12592
+ }
12593
+ rest(rest) {
12594
+ return new _ZodTuple({
12595
+ ...this._def,
12596
+ rest
12597
+ });
12598
+ }
12599
+ };
12600
+ ZodTuple.create = (schemas, params) => {
12601
+ if (!Array.isArray(schemas)) {
12602
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
12603
+ }
12604
+ return new ZodTuple({
12605
+ items: schemas,
12606
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
12607
+ rest: null,
12608
+ ...processCreateParams(params)
12609
+ });
12610
+ };
12611
+ var ZodRecord = class _ZodRecord extends ZodType {
12612
+ static {
12613
+ __name(this, "ZodRecord");
12614
+ }
12615
+ get keySchema() {
12616
+ return this._def.keyType;
12617
+ }
12618
+ get valueSchema() {
12619
+ return this._def.valueType;
12620
+ }
12621
+ _parse(input) {
12622
+ const { status, ctx } = this._processInputParams(input);
12623
+ if (ctx.parsedType !== ZodParsedType.object) {
12624
+ addIssueToContext(ctx, {
12625
+ code: ZodIssueCode.invalid_type,
12626
+ expected: ZodParsedType.object,
12627
+ received: ctx.parsedType
12628
+ });
12629
+ return INVALID;
12630
+ }
12631
+ const pairs = [];
12632
+ const keyType = this._def.keyType;
12633
+ const valueType = this._def.valueType;
12634
+ for (const key in ctx.data) {
12635
+ pairs.push({
12636
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
12637
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
12638
+ alwaysSet: key in ctx.data
12639
+ });
12640
+ }
12641
+ if (ctx.common.async) {
12642
+ return ParseStatus.mergeObjectAsync(status, pairs);
12643
+ } else {
12644
+ return ParseStatus.mergeObjectSync(status, pairs);
12645
+ }
12646
+ }
12647
+ get element() {
12648
+ return this._def.valueType;
12649
+ }
12650
+ static create(first, second, third) {
12651
+ if (second instanceof ZodType) {
12652
+ return new _ZodRecord({
12653
+ keyType: first,
12654
+ valueType: second,
12655
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
12656
+ ...processCreateParams(third)
12657
+ });
12658
+ }
12659
+ return new _ZodRecord({
12660
+ keyType: ZodString.create(),
12661
+ valueType: first,
12662
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
12663
+ ...processCreateParams(second)
12664
+ });
12665
+ }
12666
+ };
12667
+ var ZodMap = class extends ZodType {
12668
+ static {
12669
+ __name(this, "ZodMap");
12670
+ }
12671
+ get keySchema() {
12672
+ return this._def.keyType;
12673
+ }
12674
+ get valueSchema() {
12675
+ return this._def.valueType;
12676
+ }
12677
+ _parse(input) {
12678
+ const { status, ctx } = this._processInputParams(input);
12679
+ if (ctx.parsedType !== ZodParsedType.map) {
12680
+ addIssueToContext(ctx, {
12681
+ code: ZodIssueCode.invalid_type,
12682
+ expected: ZodParsedType.map,
12683
+ received: ctx.parsedType
12684
+ });
12685
+ return INVALID;
12686
+ }
12687
+ const keyType = this._def.keyType;
12688
+ const valueType = this._def.valueType;
12689
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
12690
+ return {
12691
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
12692
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
12693
+ };
12694
+ });
12695
+ if (ctx.common.async) {
12696
+ const finalMap = /* @__PURE__ */ new Map();
12697
+ return Promise.resolve().then(async () => {
12698
+ for (const pair of pairs) {
12699
+ const key = await pair.key;
12700
+ const value = await pair.value;
12701
+ if (key.status === "aborted" || value.status === "aborted") {
12702
+ return INVALID;
12703
+ }
12704
+ if (key.status === "dirty" || value.status === "dirty") {
12705
+ status.dirty();
12706
+ }
12707
+ finalMap.set(key.value, value.value);
12708
+ }
12709
+ return { status: status.value, value: finalMap };
12710
+ });
12711
+ } else {
12712
+ const finalMap = /* @__PURE__ */ new Map();
12713
+ for (const pair of pairs) {
12714
+ const key = pair.key;
12715
+ const value = pair.value;
12716
+ if (key.status === "aborted" || value.status === "aborted") {
12717
+ return INVALID;
12718
+ }
12719
+ if (key.status === "dirty" || value.status === "dirty") {
12720
+ status.dirty();
12721
+ }
12722
+ finalMap.set(key.value, value.value);
12723
+ }
12724
+ return { status: status.value, value: finalMap };
12725
+ }
12726
+ }
12727
+ };
12728
+ ZodMap.create = (keyType, valueType, params) => {
12729
+ return new ZodMap({
12730
+ valueType,
12731
+ keyType,
12732
+ typeName: ZodFirstPartyTypeKind.ZodMap,
12733
+ ...processCreateParams(params)
12734
+ });
12735
+ };
12736
+ var ZodSet = class _ZodSet extends ZodType {
12737
+ static {
12738
+ __name(this, "ZodSet");
12739
+ }
12740
+ _parse(input) {
12741
+ const { status, ctx } = this._processInputParams(input);
12742
+ if (ctx.parsedType !== ZodParsedType.set) {
12743
+ addIssueToContext(ctx, {
12744
+ code: ZodIssueCode.invalid_type,
12745
+ expected: ZodParsedType.set,
12746
+ received: ctx.parsedType
12747
+ });
12748
+ return INVALID;
12749
+ }
12750
+ const def = this._def;
12751
+ if (def.minSize !== null) {
12752
+ if (ctx.data.size < def.minSize.value) {
12753
+ addIssueToContext(ctx, {
12754
+ code: ZodIssueCode.too_small,
12755
+ minimum: def.minSize.value,
12756
+ type: "set",
12757
+ inclusive: true,
12758
+ exact: false,
12759
+ message: def.minSize.message
12760
+ });
12761
+ status.dirty();
12762
+ }
12763
+ }
12764
+ if (def.maxSize !== null) {
12765
+ if (ctx.data.size > def.maxSize.value) {
12766
+ addIssueToContext(ctx, {
12767
+ code: ZodIssueCode.too_big,
12768
+ maximum: def.maxSize.value,
12769
+ type: "set",
12770
+ inclusive: true,
12771
+ exact: false,
12772
+ message: def.maxSize.message
12773
+ });
12774
+ status.dirty();
12775
+ }
12776
+ }
12777
+ const valueType = this._def.valueType;
12778
+ function finalizeSet(elements2) {
12779
+ const parsedSet = /* @__PURE__ */ new Set();
12780
+ for (const element of elements2) {
12781
+ if (element.status === "aborted")
12782
+ return INVALID;
12783
+ if (element.status === "dirty")
12784
+ status.dirty();
12785
+ parsedSet.add(element.value);
12786
+ }
12787
+ return { status: status.value, value: parsedSet };
12788
+ }
12789
+ __name(finalizeSet, "finalizeSet");
12790
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
12791
+ if (ctx.common.async) {
12792
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
12793
+ } else {
12794
+ return finalizeSet(elements);
12795
+ }
12796
+ }
12797
+ min(minSize, message) {
12798
+ return new _ZodSet({
12799
+ ...this._def,
12800
+ minSize: { value: minSize, message: errorUtil.toString(message) }
12801
+ });
12802
+ }
12803
+ max(maxSize, message) {
12804
+ return new _ZodSet({
12805
+ ...this._def,
12806
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
12807
+ });
12808
+ }
12809
+ size(size, message) {
12810
+ return this.min(size, message).max(size, message);
12811
+ }
12812
+ nonempty(message) {
12813
+ return this.min(1, message);
12814
+ }
12815
+ };
12816
+ ZodSet.create = (valueType, params) => {
12817
+ return new ZodSet({
12818
+ valueType,
12819
+ minSize: null,
12820
+ maxSize: null,
12821
+ typeName: ZodFirstPartyTypeKind.ZodSet,
12822
+ ...processCreateParams(params)
12823
+ });
12824
+ };
12825
+ var ZodFunction = class _ZodFunction extends ZodType {
12826
+ static {
12827
+ __name(this, "ZodFunction");
12828
+ }
12829
+ constructor() {
12830
+ super(...arguments);
12831
+ this.validate = this.implement;
12832
+ }
12833
+ _parse(input) {
12834
+ const { ctx } = this._processInputParams(input);
12835
+ if (ctx.parsedType !== ZodParsedType.function) {
12836
+ addIssueToContext(ctx, {
12837
+ code: ZodIssueCode.invalid_type,
12838
+ expected: ZodParsedType.function,
12839
+ received: ctx.parsedType
12840
+ });
12841
+ return INVALID;
12842
+ }
12843
+ function makeArgsIssue(args, error) {
12844
+ return makeIssue({
12845
+ data: args,
12846
+ path: ctx.path,
12847
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
12848
+ issueData: {
12849
+ code: ZodIssueCode.invalid_arguments,
12850
+ argumentsError: error
12851
+ }
12852
+ });
12853
+ }
12854
+ __name(makeArgsIssue, "makeArgsIssue");
12855
+ function makeReturnsIssue(returns, error) {
12856
+ return makeIssue({
12857
+ data: returns,
12858
+ path: ctx.path,
12859
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
12860
+ issueData: {
12861
+ code: ZodIssueCode.invalid_return_type,
12862
+ returnTypeError: error
12863
+ }
12864
+ });
12865
+ }
12866
+ __name(makeReturnsIssue, "makeReturnsIssue");
12867
+ const params = { errorMap: ctx.common.contextualErrorMap };
12868
+ const fn = ctx.data;
12869
+ if (this._def.returns instanceof ZodPromise) {
12870
+ const me = this;
12871
+ return OK(async function(...args) {
12872
+ const error = new ZodError([]);
12873
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
12874
+ error.addIssue(makeArgsIssue(args, e));
12875
+ throw error;
12876
+ });
12877
+ const result = await Reflect.apply(fn, this, parsedArgs);
12878
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
12879
+ error.addIssue(makeReturnsIssue(result, e));
12880
+ throw error;
12881
+ });
12882
+ return parsedReturns;
12883
+ });
12884
+ } else {
12885
+ const me = this;
12886
+ return OK(function(...args) {
12887
+ const parsedArgs = me._def.args.safeParse(args, params);
12888
+ if (!parsedArgs.success) {
12889
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
12890
+ }
12891
+ const result = Reflect.apply(fn, this, parsedArgs.data);
12892
+ const parsedReturns = me._def.returns.safeParse(result, params);
12893
+ if (!parsedReturns.success) {
12894
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
12895
+ }
12896
+ return parsedReturns.data;
12897
+ });
12898
+ }
12899
+ }
12900
+ parameters() {
12901
+ return this._def.args;
12902
+ }
12903
+ returnType() {
12904
+ return this._def.returns;
12905
+ }
12906
+ args(...items) {
12907
+ return new _ZodFunction({
12908
+ ...this._def,
12909
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
12910
+ });
12911
+ }
12912
+ returns(returnType) {
12913
+ return new _ZodFunction({
12914
+ ...this._def,
12915
+ returns: returnType
12916
+ });
12917
+ }
12918
+ implement(func) {
12919
+ const validatedFunc = this.parse(func);
12920
+ return validatedFunc;
12921
+ }
12922
+ strictImplement(func) {
12923
+ const validatedFunc = this.parse(func);
12924
+ return validatedFunc;
12925
+ }
12926
+ static create(args, returns, params) {
12927
+ return new _ZodFunction({
12928
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
12929
+ returns: returns || ZodUnknown.create(),
12930
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
12931
+ ...processCreateParams(params)
12932
+ });
12933
+ }
12934
+ };
12935
+ var ZodLazy = class extends ZodType {
12936
+ static {
12937
+ __name(this, "ZodLazy");
12938
+ }
12939
+ get schema() {
12940
+ return this._def.getter();
12941
+ }
12942
+ _parse(input) {
12943
+ const { ctx } = this._processInputParams(input);
12944
+ const lazySchema = this._def.getter();
12945
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
12946
+ }
12947
+ };
12948
+ ZodLazy.create = (getter, params) => {
12949
+ return new ZodLazy({
12950
+ getter,
12951
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
12952
+ ...processCreateParams(params)
12953
+ });
12954
+ };
12955
+ var ZodLiteral = class extends ZodType {
12956
+ static {
12957
+ __name(this, "ZodLiteral");
12958
+ }
12959
+ _parse(input) {
12960
+ if (input.data !== this._def.value) {
12961
+ const ctx = this._getOrReturnCtx(input);
12962
+ addIssueToContext(ctx, {
12963
+ received: ctx.data,
12964
+ code: ZodIssueCode.invalid_literal,
12965
+ expected: this._def.value
12966
+ });
12967
+ return INVALID;
12968
+ }
12969
+ return { status: "valid", value: input.data };
12970
+ }
12971
+ get value() {
12972
+ return this._def.value;
12973
+ }
12974
+ };
12975
+ ZodLiteral.create = (value, params) => {
12976
+ return new ZodLiteral({
12977
+ value,
12978
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
12979
+ ...processCreateParams(params)
12980
+ });
12981
+ };
12982
+ function createZodEnum(values, params) {
12983
+ return new ZodEnum({
12984
+ values,
12985
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
12986
+ ...processCreateParams(params)
12987
+ });
12988
+ }
12989
+ __name(createZodEnum, "createZodEnum");
12990
+ var ZodEnum = class _ZodEnum extends ZodType {
12991
+ static {
12992
+ __name(this, "ZodEnum");
12993
+ }
12994
+ _parse(input) {
12995
+ if (typeof input.data !== "string") {
12996
+ const ctx = this._getOrReturnCtx(input);
12997
+ const expectedValues = this._def.values;
12998
+ addIssueToContext(ctx, {
12999
+ expected: util.joinValues(expectedValues),
13000
+ received: ctx.parsedType,
13001
+ code: ZodIssueCode.invalid_type
13002
+ });
13003
+ return INVALID;
13004
+ }
13005
+ if (!this._cache) {
13006
+ this._cache = new Set(this._def.values);
13007
+ }
13008
+ if (!this._cache.has(input.data)) {
13009
+ const ctx = this._getOrReturnCtx(input);
13010
+ const expectedValues = this._def.values;
13011
+ addIssueToContext(ctx, {
13012
+ received: ctx.data,
13013
+ code: ZodIssueCode.invalid_enum_value,
13014
+ options: expectedValues
13015
+ });
13016
+ return INVALID;
13017
+ }
13018
+ return OK(input.data);
13019
+ }
13020
+ get options() {
13021
+ return this._def.values;
13022
+ }
13023
+ get enum() {
13024
+ const enumValues = {};
13025
+ for (const val of this._def.values) {
13026
+ enumValues[val] = val;
13027
+ }
13028
+ return enumValues;
13029
+ }
13030
+ get Values() {
13031
+ const enumValues = {};
13032
+ for (const val of this._def.values) {
13033
+ enumValues[val] = val;
13034
+ }
13035
+ return enumValues;
13036
+ }
13037
+ get Enum() {
13038
+ const enumValues = {};
13039
+ for (const val of this._def.values) {
13040
+ enumValues[val] = val;
13041
+ }
13042
+ return enumValues;
13043
+ }
13044
+ extract(values, newDef = this._def) {
13045
+ return _ZodEnum.create(values, {
13046
+ ...this._def,
13047
+ ...newDef
13048
+ });
13049
+ }
13050
+ exclude(values, newDef = this._def) {
13051
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
13052
+ ...this._def,
13053
+ ...newDef
13054
+ });
13055
+ }
13056
+ };
13057
+ ZodEnum.create = createZodEnum;
13058
+ var ZodNativeEnum = class extends ZodType {
13059
+ static {
13060
+ __name(this, "ZodNativeEnum");
13061
+ }
13062
+ _parse(input) {
13063
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
13064
+ const ctx = this._getOrReturnCtx(input);
13065
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
13066
+ const expectedValues = util.objectValues(nativeEnumValues);
13067
+ addIssueToContext(ctx, {
13068
+ expected: util.joinValues(expectedValues),
13069
+ received: ctx.parsedType,
13070
+ code: ZodIssueCode.invalid_type
13071
+ });
13072
+ return INVALID;
13073
+ }
13074
+ if (!this._cache) {
13075
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
13076
+ }
13077
+ if (!this._cache.has(input.data)) {
13078
+ const expectedValues = util.objectValues(nativeEnumValues);
13079
+ addIssueToContext(ctx, {
13080
+ received: ctx.data,
13081
+ code: ZodIssueCode.invalid_enum_value,
13082
+ options: expectedValues
13083
+ });
13084
+ return INVALID;
13085
+ }
13086
+ return OK(input.data);
13087
+ }
13088
+ get enum() {
13089
+ return this._def.values;
13090
+ }
13091
+ };
13092
+ ZodNativeEnum.create = (values, params) => {
13093
+ return new ZodNativeEnum({
13094
+ values,
13095
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
13096
+ ...processCreateParams(params)
13097
+ });
13098
+ };
13099
+ var ZodPromise = class extends ZodType {
13100
+ static {
13101
+ __name(this, "ZodPromise");
13102
+ }
13103
+ unwrap() {
13104
+ return this._def.type;
13105
+ }
13106
+ _parse(input) {
13107
+ const { ctx } = this._processInputParams(input);
13108
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
13109
+ addIssueToContext(ctx, {
13110
+ code: ZodIssueCode.invalid_type,
13111
+ expected: ZodParsedType.promise,
13112
+ received: ctx.parsedType
13113
+ });
13114
+ return INVALID;
13115
+ }
13116
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
13117
+ return OK(promisified.then((data) => {
13118
+ return this._def.type.parseAsync(data, {
13119
+ path: ctx.path,
13120
+ errorMap: ctx.common.contextualErrorMap
13121
+ });
13122
+ }));
13123
+ }
13124
+ };
13125
+ ZodPromise.create = (schema, params) => {
13126
+ return new ZodPromise({
13127
+ type: schema,
13128
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
13129
+ ...processCreateParams(params)
13130
+ });
13131
+ };
13132
+ var ZodEffects = class extends ZodType {
13133
+ static {
13134
+ __name(this, "ZodEffects");
13135
+ }
13136
+ innerType() {
13137
+ return this._def.schema;
13138
+ }
13139
+ sourceType() {
13140
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
13141
+ }
13142
+ _parse(input) {
13143
+ const { status, ctx } = this._processInputParams(input);
13144
+ const effect = this._def.effect || null;
13145
+ const checkCtx = {
13146
+ addIssue: /* @__PURE__ */ __name((arg) => {
13147
+ addIssueToContext(ctx, arg);
13148
+ if (arg.fatal) {
13149
+ status.abort();
13150
+ } else {
13151
+ status.dirty();
13152
+ }
13153
+ }, "addIssue"),
13154
+ get path() {
13155
+ return ctx.path;
13156
+ }
13157
+ };
13158
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
13159
+ if (effect.type === "preprocess") {
13160
+ const processed = effect.transform(ctx.data, checkCtx);
13161
+ if (ctx.common.async) {
13162
+ return Promise.resolve(processed).then(async (processed2) => {
13163
+ if (status.value === "aborted")
13164
+ return INVALID;
13165
+ const result = await this._def.schema._parseAsync({
13166
+ data: processed2,
13167
+ path: ctx.path,
13168
+ parent: ctx
13169
+ });
13170
+ if (result.status === "aborted")
13171
+ return INVALID;
13172
+ if (result.status === "dirty")
13173
+ return DIRTY(result.value);
13174
+ if (status.value === "dirty")
13175
+ return DIRTY(result.value);
13176
+ return result;
13177
+ });
13178
+ } else {
13179
+ if (status.value === "aborted")
13180
+ return INVALID;
13181
+ const result = this._def.schema._parseSync({
13182
+ data: processed,
13183
+ path: ctx.path,
13184
+ parent: ctx
13185
+ });
13186
+ if (result.status === "aborted")
13187
+ return INVALID;
13188
+ if (result.status === "dirty")
13189
+ return DIRTY(result.value);
13190
+ if (status.value === "dirty")
13191
+ return DIRTY(result.value);
13192
+ return result;
13193
+ }
13194
+ }
13195
+ if (effect.type === "refinement") {
13196
+ const executeRefinement = /* @__PURE__ */ __name((acc) => {
13197
+ const result = effect.refinement(acc, checkCtx);
13198
+ if (ctx.common.async) {
13199
+ return Promise.resolve(result);
13200
+ }
13201
+ if (result instanceof Promise) {
13202
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
13203
+ }
13204
+ return acc;
13205
+ }, "executeRefinement");
13206
+ if (ctx.common.async === false) {
13207
+ const inner = this._def.schema._parseSync({
13208
+ data: ctx.data,
13209
+ path: ctx.path,
13210
+ parent: ctx
13211
+ });
13212
+ if (inner.status === "aborted")
13213
+ return INVALID;
13214
+ if (inner.status === "dirty")
13215
+ status.dirty();
13216
+ executeRefinement(inner.value);
13217
+ return { status: status.value, value: inner.value };
13218
+ } else {
13219
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
13220
+ if (inner.status === "aborted")
13221
+ return INVALID;
13222
+ if (inner.status === "dirty")
13223
+ status.dirty();
13224
+ return executeRefinement(inner.value).then(() => {
13225
+ return { status: status.value, value: inner.value };
13226
+ });
13227
+ });
13228
+ }
13229
+ }
13230
+ if (effect.type === "transform") {
13231
+ if (ctx.common.async === false) {
13232
+ const base = this._def.schema._parseSync({
13233
+ data: ctx.data,
13234
+ path: ctx.path,
13235
+ parent: ctx
13236
+ });
13237
+ if (!isValid(base))
13238
+ return INVALID;
13239
+ const result = effect.transform(base.value, checkCtx);
13240
+ if (result instanceof Promise) {
13241
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
13242
+ }
13243
+ return { status: status.value, value: result };
13244
+ } else {
13245
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
13246
+ if (!isValid(base))
13247
+ return INVALID;
13248
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
13249
+ status: status.value,
13250
+ value: result
13251
+ }));
13252
+ });
13253
+ }
13254
+ }
13255
+ util.assertNever(effect);
13256
+ }
13257
+ };
13258
+ ZodEffects.create = (schema, effect, params) => {
13259
+ return new ZodEffects({
13260
+ schema,
13261
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
13262
+ effect,
13263
+ ...processCreateParams(params)
13264
+ });
13265
+ };
13266
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
13267
+ return new ZodEffects({
13268
+ schema,
13269
+ effect: { type: "preprocess", transform: preprocess },
13270
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
13271
+ ...processCreateParams(params)
13272
+ });
13273
+ };
13274
+ var ZodOptional = class extends ZodType {
13275
+ static {
13276
+ __name(this, "ZodOptional");
13277
+ }
13278
+ _parse(input) {
13279
+ const parsedType = this._getType(input);
13280
+ if (parsedType === ZodParsedType.undefined) {
13281
+ return OK(void 0);
13282
+ }
13283
+ return this._def.innerType._parse(input);
13284
+ }
13285
+ unwrap() {
13286
+ return this._def.innerType;
13287
+ }
13288
+ };
13289
+ ZodOptional.create = (type, params) => {
13290
+ return new ZodOptional({
13291
+ innerType: type,
13292
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
13293
+ ...processCreateParams(params)
13294
+ });
13295
+ };
13296
+ var ZodNullable = class extends ZodType {
13297
+ static {
13298
+ __name(this, "ZodNullable");
13299
+ }
13300
+ _parse(input) {
13301
+ const parsedType = this._getType(input);
13302
+ if (parsedType === ZodParsedType.null) {
13303
+ return OK(null);
13304
+ }
13305
+ return this._def.innerType._parse(input);
13306
+ }
13307
+ unwrap() {
13308
+ return this._def.innerType;
13309
+ }
13310
+ };
13311
+ ZodNullable.create = (type, params) => {
13312
+ return new ZodNullable({
13313
+ innerType: type,
13314
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
13315
+ ...processCreateParams(params)
13316
+ });
13317
+ };
13318
+ var ZodDefault = class extends ZodType {
13319
+ static {
13320
+ __name(this, "ZodDefault");
13321
+ }
13322
+ _parse(input) {
13323
+ const { ctx } = this._processInputParams(input);
13324
+ let data = ctx.data;
13325
+ if (ctx.parsedType === ZodParsedType.undefined) {
13326
+ data = this._def.defaultValue();
13327
+ }
13328
+ return this._def.innerType._parse({
13329
+ data,
13330
+ path: ctx.path,
13331
+ parent: ctx
13332
+ });
13333
+ }
13334
+ removeDefault() {
13335
+ return this._def.innerType;
13336
+ }
13337
+ };
13338
+ ZodDefault.create = (type, params) => {
13339
+ return new ZodDefault({
13340
+ innerType: type,
13341
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
13342
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
13343
+ ...processCreateParams(params)
13344
+ });
13345
+ };
13346
+ var ZodCatch = class extends ZodType {
13347
+ static {
13348
+ __name(this, "ZodCatch");
13349
+ }
13350
+ _parse(input) {
13351
+ const { ctx } = this._processInputParams(input);
13352
+ const newCtx = {
13353
+ ...ctx,
13354
+ common: {
13355
+ ...ctx.common,
13356
+ issues: []
13357
+ }
13358
+ };
13359
+ const result = this._def.innerType._parse({
13360
+ data: newCtx.data,
13361
+ path: newCtx.path,
13362
+ parent: {
13363
+ ...newCtx
13364
+ }
13365
+ });
13366
+ if (isAsync(result)) {
13367
+ return result.then((result2) => {
13368
+ return {
13369
+ status: "valid",
13370
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
13371
+ get error() {
13372
+ return new ZodError(newCtx.common.issues);
13373
+ },
13374
+ input: newCtx.data
13375
+ })
13376
+ };
13377
+ });
13378
+ } else {
13379
+ return {
13380
+ status: "valid",
13381
+ value: result.status === "valid" ? result.value : this._def.catchValue({
13382
+ get error() {
13383
+ return new ZodError(newCtx.common.issues);
13384
+ },
13385
+ input: newCtx.data
13386
+ })
13387
+ };
13388
+ }
13389
+ }
13390
+ removeCatch() {
13391
+ return this._def.innerType;
13392
+ }
13393
+ };
13394
+ ZodCatch.create = (type, params) => {
13395
+ return new ZodCatch({
13396
+ innerType: type,
13397
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
13398
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
13399
+ ...processCreateParams(params)
13400
+ });
13401
+ };
13402
+ var ZodNaN = class extends ZodType {
13403
+ static {
13404
+ __name(this, "ZodNaN");
13405
+ }
13406
+ _parse(input) {
13407
+ const parsedType = this._getType(input);
13408
+ if (parsedType !== ZodParsedType.nan) {
13409
+ const ctx = this._getOrReturnCtx(input);
13410
+ addIssueToContext(ctx, {
13411
+ code: ZodIssueCode.invalid_type,
13412
+ expected: ZodParsedType.nan,
13413
+ received: ctx.parsedType
13414
+ });
13415
+ return INVALID;
13416
+ }
13417
+ return { status: "valid", value: input.data };
13418
+ }
13419
+ };
13420
+ ZodNaN.create = (params) => {
13421
+ return new ZodNaN({
13422
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
13423
+ ...processCreateParams(params)
13424
+ });
13425
+ };
13426
+ var BRAND = Symbol("zod_brand");
13427
+ var ZodBranded = class extends ZodType {
13428
+ static {
13429
+ __name(this, "ZodBranded");
13430
+ }
13431
+ _parse(input) {
13432
+ const { ctx } = this._processInputParams(input);
13433
+ const data = ctx.data;
13434
+ return this._def.type._parse({
13435
+ data,
13436
+ path: ctx.path,
13437
+ parent: ctx
13438
+ });
13439
+ }
13440
+ unwrap() {
13441
+ return this._def.type;
13442
+ }
13443
+ };
13444
+ var ZodPipeline = class _ZodPipeline extends ZodType {
13445
+ static {
13446
+ __name(this, "ZodPipeline");
13447
+ }
13448
+ _parse(input) {
13449
+ const { status, ctx } = this._processInputParams(input);
13450
+ if (ctx.common.async) {
13451
+ const handleAsync = /* @__PURE__ */ __name(async () => {
13452
+ const inResult = await this._def.in._parseAsync({
13453
+ data: ctx.data,
13454
+ path: ctx.path,
13455
+ parent: ctx
13456
+ });
13457
+ if (inResult.status === "aborted")
13458
+ return INVALID;
13459
+ if (inResult.status === "dirty") {
13460
+ status.dirty();
13461
+ return DIRTY(inResult.value);
13462
+ } else {
13463
+ return this._def.out._parseAsync({
13464
+ data: inResult.value,
13465
+ path: ctx.path,
13466
+ parent: ctx
13467
+ });
13468
+ }
13469
+ }, "handleAsync");
13470
+ return handleAsync();
13471
+ } else {
13472
+ const inResult = this._def.in._parseSync({
13473
+ data: ctx.data,
13474
+ path: ctx.path,
13475
+ parent: ctx
13476
+ });
13477
+ if (inResult.status === "aborted")
13478
+ return INVALID;
13479
+ if (inResult.status === "dirty") {
13480
+ status.dirty();
13481
+ return {
13482
+ status: "dirty",
13483
+ value: inResult.value
13484
+ };
13485
+ } else {
13486
+ return this._def.out._parseSync({
13487
+ data: inResult.value,
13488
+ path: ctx.path,
13489
+ parent: ctx
13490
+ });
13491
+ }
13492
+ }
13493
+ }
13494
+ static create(a, b) {
13495
+ return new _ZodPipeline({
13496
+ in: a,
13497
+ out: b,
13498
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
13499
+ });
13500
+ }
13501
+ };
13502
+ var ZodReadonly = class extends ZodType {
13503
+ static {
13504
+ __name(this, "ZodReadonly");
13505
+ }
13506
+ _parse(input) {
13507
+ const result = this._def.innerType._parse(input);
13508
+ const freeze = /* @__PURE__ */ __name((data) => {
13509
+ if (isValid(data)) {
13510
+ data.value = Object.freeze(data.value);
13511
+ }
13512
+ return data;
13513
+ }, "freeze");
13514
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
13515
+ }
13516
+ unwrap() {
13517
+ return this._def.innerType;
13518
+ }
13519
+ };
13520
+ ZodReadonly.create = (type, params) => {
13521
+ return new ZodReadonly({
13522
+ innerType: type,
13523
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
13524
+ ...processCreateParams(params)
13525
+ });
13526
+ };
13527
+ function cleanParams(params, data) {
13528
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
13529
+ const p2 = typeof p === "string" ? { message: p } : p;
13530
+ return p2;
13531
+ }
13532
+ __name(cleanParams, "cleanParams");
13533
+ function custom(check, _params = {}, fatal) {
13534
+ if (check)
13535
+ return ZodAny.create().superRefine((data, ctx) => {
13536
+ const r = check(data);
13537
+ if (r instanceof Promise) {
13538
+ return r.then((r2) => {
13539
+ if (!r2) {
13540
+ const params = cleanParams(_params, data);
13541
+ const _fatal = params.fatal ?? fatal ?? true;
13542
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
13543
+ }
13544
+ });
13545
+ }
13546
+ if (!r) {
13547
+ const params = cleanParams(_params, data);
13548
+ const _fatal = params.fatal ?? fatal ?? true;
13549
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
13550
+ }
13551
+ return;
13552
+ });
13553
+ return ZodAny.create();
13554
+ }
13555
+ __name(custom, "custom");
13556
+ var late = {
13557
+ object: ZodObject.lazycreate
13558
+ };
13559
+ var ZodFirstPartyTypeKind;
13560
+ (function(ZodFirstPartyTypeKind2) {
13561
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
13562
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
13563
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
13564
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
13565
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
13566
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
13567
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
13568
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
13569
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
13570
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
13571
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
13572
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
13573
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
13574
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
13575
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
13576
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
13577
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
13578
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
13579
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
13580
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
13581
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
13582
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
13583
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
13584
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
13585
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
13586
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
13587
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
13588
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
13589
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
13590
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
13591
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
13592
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
13593
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
13594
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
13595
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
13596
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
13597
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
13598
+ var instanceOfType = /* @__PURE__ */ __name((cls, params = {
13599
+ message: `Input not instance of ${cls.name}`
13600
+ }) => custom((data) => data instanceof cls, params), "instanceOfType");
13601
+ var stringType = ZodString.create;
13602
+ var numberType = ZodNumber.create;
13603
+ var nanType = ZodNaN.create;
13604
+ var bigIntType = ZodBigInt.create;
13605
+ var booleanType = ZodBoolean.create;
13606
+ var dateType = ZodDate.create;
13607
+ var symbolType = ZodSymbol.create;
13608
+ var undefinedType = ZodUndefined.create;
13609
+ var nullType = ZodNull.create;
13610
+ var anyType = ZodAny.create;
13611
+ var unknownType = ZodUnknown.create;
13612
+ var neverType = ZodNever.create;
13613
+ var voidType = ZodVoid.create;
13614
+ var arrayType = ZodArray.create;
13615
+ var objectType = ZodObject.create;
13616
+ var strictObjectType = ZodObject.strictCreate;
13617
+ var unionType = ZodUnion.create;
13618
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
13619
+ var intersectionType = ZodIntersection.create;
13620
+ var tupleType = ZodTuple.create;
13621
+ var recordType = ZodRecord.create;
13622
+ var mapType = ZodMap.create;
13623
+ var setType = ZodSet.create;
13624
+ var functionType = ZodFunction.create;
13625
+ var lazyType = ZodLazy.create;
13626
+ var literalType = ZodLiteral.create;
13627
+ var enumType = ZodEnum.create;
13628
+ var nativeEnumType = ZodNativeEnum.create;
13629
+ var promiseType = ZodPromise.create;
13630
+ var effectsType = ZodEffects.create;
13631
+ var optionalType = ZodOptional.create;
13632
+ var nullableType = ZodNullable.create;
13633
+ var preprocessType = ZodEffects.createWithPreprocess;
13634
+ var pipelineType = ZodPipeline.create;
13635
+ var ostring = /* @__PURE__ */ __name(() => stringType().optional(), "ostring");
13636
+ var onumber = /* @__PURE__ */ __name(() => numberType().optional(), "onumber");
13637
+ var oboolean = /* @__PURE__ */ __name(() => booleanType().optional(), "oboolean");
13638
+ var coerce = {
13639
+ string: /* @__PURE__ */ __name((arg) => ZodString.create({ ...arg, coerce: true }), "string"),
13640
+ number: /* @__PURE__ */ __name((arg) => ZodNumber.create({ ...arg, coerce: true }), "number"),
13641
+ boolean: /* @__PURE__ */ __name((arg) => ZodBoolean.create({
13642
+ ...arg,
13643
+ coerce: true
13644
+ }), "boolean"),
13645
+ bigint: /* @__PURE__ */ __name((arg) => ZodBigInt.create({ ...arg, coerce: true }), "bigint"),
13646
+ date: /* @__PURE__ */ __name((arg) => ZodDate.create({ ...arg, coerce: true }), "date")
13647
+ };
13648
+ var NEVER = INVALID;
13649
+
13650
+ // ../workers-shared/utils/types.ts
13651
+ var InternalConfigSchema = external_exports.object({
13652
+ account_id: external_exports.number().optional(),
13653
+ script_id: external_exports.number().optional(),
13654
+ debug: external_exports.boolean().optional()
9471
13655
  });
9472
- var StaticRoutingSchema = z.object({
9473
- user_worker: z.array(z.string()),
9474
- asset_worker: z.array(z.string()).optional()
13656
+ var StaticRoutingSchema = external_exports.object({
13657
+ user_worker: external_exports.array(external_exports.string()),
13658
+ asset_worker: external_exports.array(external_exports.string()).optional()
9475
13659
  });
9476
- z.object({
9477
- invoke_user_worker_ahead_of_assets: z.boolean().optional(),
13660
+ external_exports.object({
13661
+ invoke_user_worker_ahead_of_assets: external_exports.boolean().optional(),
9478
13662
  static_routing: StaticRoutingSchema.optional(),
9479
- has_user_worker: z.boolean().optional(),
13663
+ has_user_worker: external_exports.boolean().optional(),
9480
13664
  ...InternalConfigSchema.shape
9481
13665
  });
9482
- z.union([
9483
- z.object({
9484
- limitedAssetsOnly: z.boolean().optional()
13666
+ external_exports.union([
13667
+ external_exports.object({
13668
+ limitedAssetsOnly: external_exports.boolean().optional()
9485
13669
  }),
9486
- z.null()
13670
+ external_exports.null()
9487
13671
  ]);
9488
- var MetadataStaticRedirectEntry = z.object({
9489
- status: z.number(),
9490
- to: z.string(),
9491
- lineNumber: z.number()
13672
+ var MetadataStaticRedirectEntry = external_exports.object({
13673
+ status: external_exports.number(),
13674
+ to: external_exports.string(),
13675
+ lineNumber: external_exports.number()
9492
13676
  });
9493
- var MetadataRedirectEntry = z.object({
9494
- status: z.number(),
9495
- to: z.string()
13677
+ var MetadataRedirectEntry = external_exports.object({
13678
+ status: external_exports.number(),
13679
+ to: external_exports.string()
9496
13680
  });
9497
- var MetadataStaticRedirects = z.record(MetadataStaticRedirectEntry);
9498
- var MetadataRedirects = z.record(MetadataRedirectEntry);
9499
- var MetadataHeaderEntry = z.object({
9500
- set: z.record(z.string()).optional(),
9501
- unset: z.array(z.string()).optional()
13681
+ var MetadataStaticRedirects = external_exports.record(MetadataStaticRedirectEntry);
13682
+ var MetadataRedirects = external_exports.record(MetadataRedirectEntry);
13683
+ var MetadataHeaderEntry = external_exports.object({
13684
+ set: external_exports.record(external_exports.string()).optional(),
13685
+ unset: external_exports.array(external_exports.string()).optional()
9502
13686
  });
9503
- var MetadataHeaders = z.record(MetadataHeaderEntry);
9504
- var RedirectsSchema = z.object({
9505
- version: z.literal(1),
13687
+ var MetadataHeaders = external_exports.record(MetadataHeaderEntry);
13688
+ var RedirectsSchema = external_exports.object({
13689
+ version: external_exports.literal(1),
9506
13690
  staticRules: MetadataStaticRedirects,
9507
13691
  rules: MetadataRedirects
9508
13692
  }).optional();
9509
- var HeadersSchema = z.object({
9510
- version: z.literal(2),
13693
+ var HeadersSchema = external_exports.object({
13694
+ version: external_exports.literal(2),
9511
13695
  rules: MetadataHeaders
9512
13696
  }).optional();
9513
- z.object({
9514
- compatibility_date: z.string().optional(),
9515
- compatibility_flags: z.array(z.string()).optional(),
9516
- html_handling: z.enum([
13697
+ external_exports.object({
13698
+ compatibility_date: external_exports.string().optional(),
13699
+ compatibility_flags: external_exports.array(external_exports.string()).optional(),
13700
+ html_handling: external_exports.enum([
9517
13701
  "auto-trailing-slash",
9518
13702
  "force-trailing-slash",
9519
13703
  "drop-trailing-slash",
9520
13704
  "none"
9521
13705
  ]).optional(),
9522
- not_found_handling: z.enum(["single-page-application", "404-page", "none"]).optional(),
13706
+ not_found_handling: external_exports.enum(["single-page-application", "404-page", "none"]).optional(),
9523
13707
  redirects: RedirectsSchema,
9524
13708
  headers: HeadersSchema,
9525
- has_static_routing: z.boolean().optional(),
13709
+ has_static_routing: external_exports.boolean().optional(),
9526
13710
  ...InternalConfigSchema.shape
9527
13711
  });
9528
13712
  function maybeRetrieveFileSourceMap(filePath) {
@@ -10840,6 +15024,12 @@ Edits that have been made via the script API will be overridden by your local co
10840
15024
  }
10841
15025
  }
10842
15026
  await ensureQueuesExistByConfig(config, accountId);
15027
+ const wantsWorkersDev = props.command === "deploy" && getSubdomainValues(config.workers_dev, config.preview_urls, props.routes).workers_dev;
15028
+ if (!workerExists && wantsWorkersDev) {
15029
+ await getWorkersDevSubdomain(config, accountId, {
15030
+ configPath: config.configPath
15031
+ });
15032
+ }
10843
15033
  return { workerTag, tags, workerExists, aborted: false };
10844
15034
  }
10845
15035
  __name(preUploadApiChecks, "preUploadApiChecks");