@c3-oss/prosa 0.8.1 → 0.8.2

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/bin/prosa.js CHANGED
@@ -9077,8 +9077,8 @@ var init_service_error_classification = __esm({
9077
9077
  "Load failed",
9078
9078
  "Network request failed"
9079
9079
  ]);
9080
- const isValid = error && error instanceof TypeError;
9081
- if (!isValid) {
9080
+ const isValid2 = error && error instanceof TypeError;
9081
+ if (!isValid2) {
9082
9082
  return false;
9083
9083
  }
9084
9084
  return errorMessages.has(error.message);
@@ -12436,11 +12436,11 @@ function validate2(xmlData, options) {
12436
12436
  if (attrStr[attrStr.length - 1] === "/") {
12437
12437
  const attrStrStart = i6 - attrStr.length;
12438
12438
  attrStr = attrStr.substring(0, attrStr.length - 1);
12439
- const isValid = validateAttributeString(attrStr, options);
12440
- if (isValid === true) {
12439
+ const isValid2 = validateAttributeString(attrStr, options);
12440
+ if (isValid2 === true) {
12441
12441
  tagFound = true;
12442
12442
  } else {
12443
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
12443
+ return getErrorObject(isValid2.err.code, isValid2.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid2.err.line));
12444
12444
  }
12445
12445
  } else if (closingTag) {
12446
12446
  if (!result.tagClosed) {
@@ -12460,9 +12460,9 @@ function validate2(xmlData, options) {
12460
12460
  }
12461
12461
  }
12462
12462
  } else {
12463
- const isValid = validateAttributeString(attrStr, options);
12464
- if (isValid !== true) {
12465
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i6 - attrStr.length + isValid.err.line));
12463
+ const isValid2 = validateAttributeString(attrStr, options);
12464
+ if (isValid2 !== true) {
12465
+ return getErrorObject(isValid2.err.code, isValid2.err.msg, getLineNumberForPosition(xmlData, i6 - attrStr.length + isValid2.err.line));
12466
12466
  }
12467
12467
  if (reachedRoot === true) {
12468
12468
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i6));
@@ -28397,7 +28397,4757 @@ import path2 from "path";
28397
28397
  // src/cli/auth/client.ts
28398
28398
  import { request as httpRequest } from "http";
28399
28399
  import { request as httpsRequest } from "https";
28400
- import { OBJECT_PACK_BINARY_CONTENT_TYPE, encodeBinaryObjectPack } from "@c3-oss/prosa-sync";
28400
+
28401
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
28402
+ var external_exports = {};
28403
+ __export(external_exports, {
28404
+ BRAND: () => BRAND,
28405
+ DIRTY: () => DIRTY,
28406
+ EMPTY_PATH: () => EMPTY_PATH,
28407
+ INVALID: () => INVALID,
28408
+ NEVER: () => NEVER,
28409
+ OK: () => OK,
28410
+ ParseStatus: () => ParseStatus,
28411
+ Schema: () => ZodType,
28412
+ ZodAny: () => ZodAny,
28413
+ ZodArray: () => ZodArray,
28414
+ ZodBigInt: () => ZodBigInt,
28415
+ ZodBoolean: () => ZodBoolean,
28416
+ ZodBranded: () => ZodBranded,
28417
+ ZodCatch: () => ZodCatch,
28418
+ ZodDate: () => ZodDate,
28419
+ ZodDefault: () => ZodDefault,
28420
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
28421
+ ZodEffects: () => ZodEffects,
28422
+ ZodEnum: () => ZodEnum,
28423
+ ZodError: () => ZodError,
28424
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
28425
+ ZodFunction: () => ZodFunction,
28426
+ ZodIntersection: () => ZodIntersection,
28427
+ ZodIssueCode: () => ZodIssueCode,
28428
+ ZodLazy: () => ZodLazy,
28429
+ ZodLiteral: () => ZodLiteral,
28430
+ ZodMap: () => ZodMap,
28431
+ ZodNaN: () => ZodNaN,
28432
+ ZodNativeEnum: () => ZodNativeEnum,
28433
+ ZodNever: () => ZodNever,
28434
+ ZodNull: () => ZodNull,
28435
+ ZodNullable: () => ZodNullable,
28436
+ ZodNumber: () => ZodNumber,
28437
+ ZodObject: () => ZodObject,
28438
+ ZodOptional: () => ZodOptional,
28439
+ ZodParsedType: () => ZodParsedType,
28440
+ ZodPipeline: () => ZodPipeline,
28441
+ ZodPromise: () => ZodPromise,
28442
+ ZodReadonly: () => ZodReadonly,
28443
+ ZodRecord: () => ZodRecord,
28444
+ ZodSchema: () => ZodType,
28445
+ ZodSet: () => ZodSet,
28446
+ ZodString: () => ZodString,
28447
+ ZodSymbol: () => ZodSymbol,
28448
+ ZodTransformer: () => ZodEffects,
28449
+ ZodTuple: () => ZodTuple,
28450
+ ZodType: () => ZodType,
28451
+ ZodUndefined: () => ZodUndefined,
28452
+ ZodUnion: () => ZodUnion,
28453
+ ZodUnknown: () => ZodUnknown,
28454
+ ZodVoid: () => ZodVoid,
28455
+ addIssueToContext: () => addIssueToContext,
28456
+ any: () => anyType,
28457
+ array: () => arrayType,
28458
+ bigint: () => bigIntType,
28459
+ boolean: () => booleanType,
28460
+ coerce: () => coerce,
28461
+ custom: () => custom,
28462
+ date: () => dateType,
28463
+ datetimeRegex: () => datetimeRegex,
28464
+ defaultErrorMap: () => en_default,
28465
+ discriminatedUnion: () => discriminatedUnionType,
28466
+ effect: () => effectsType,
28467
+ enum: () => enumType,
28468
+ function: () => functionType,
28469
+ getErrorMap: () => getErrorMap,
28470
+ getParsedType: () => getParsedType,
28471
+ instanceof: () => instanceOfType,
28472
+ intersection: () => intersectionType,
28473
+ isAborted: () => isAborted,
28474
+ isAsync: () => isAsync,
28475
+ isDirty: () => isDirty,
28476
+ isValid: () => isValid,
28477
+ late: () => late,
28478
+ lazy: () => lazyType,
28479
+ literal: () => literalType,
28480
+ makeIssue: () => makeIssue,
28481
+ map: () => mapType,
28482
+ nan: () => nanType,
28483
+ nativeEnum: () => nativeEnumType,
28484
+ never: () => neverType,
28485
+ null: () => nullType,
28486
+ nullable: () => nullableType,
28487
+ number: () => numberType,
28488
+ object: () => objectType,
28489
+ objectUtil: () => objectUtil,
28490
+ oboolean: () => oboolean,
28491
+ onumber: () => onumber,
28492
+ optional: () => optionalType,
28493
+ ostring: () => ostring,
28494
+ pipeline: () => pipelineType,
28495
+ preprocess: () => preprocessType,
28496
+ promise: () => promiseType,
28497
+ quotelessJson: () => quotelessJson,
28498
+ record: () => recordType,
28499
+ set: () => setType,
28500
+ setErrorMap: () => setErrorMap,
28501
+ strictObject: () => strictObjectType,
28502
+ string: () => stringType,
28503
+ symbol: () => symbolType,
28504
+ transformer: () => effectsType,
28505
+ tuple: () => tupleType,
28506
+ undefined: () => undefinedType,
28507
+ union: () => unionType,
28508
+ unknown: () => unknownType,
28509
+ util: () => util,
28510
+ void: () => voidType
28511
+ });
28512
+
28513
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
28514
+ var util;
28515
+ (function(util2) {
28516
+ util2.assertEqual = (_) => {
28517
+ };
28518
+ function assertIs(_arg) {
28519
+ }
28520
+ __name(assertIs, "assertIs");
28521
+ util2.assertIs = assertIs;
28522
+ function assertNever(_x2) {
28523
+ throw new Error();
28524
+ }
28525
+ __name(assertNever, "assertNever");
28526
+ util2.assertNever = assertNever;
28527
+ util2.arrayToEnum = (items) => {
28528
+ const obj = {};
28529
+ for (const item of items) {
28530
+ obj[item] = item;
28531
+ }
28532
+ return obj;
28533
+ };
28534
+ util2.getValidEnumValues = (obj) => {
28535
+ const validKeys = util2.objectKeys(obj).filter((k6) => typeof obj[obj[k6]] !== "number");
28536
+ const filtered = {};
28537
+ for (const k6 of validKeys) {
28538
+ filtered[k6] = obj[k6];
28539
+ }
28540
+ return util2.objectValues(filtered);
28541
+ };
28542
+ util2.objectValues = (obj) => {
28543
+ return util2.objectKeys(obj).map(function(e6) {
28544
+ return obj[e6];
28545
+ });
28546
+ };
28547
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
28548
+ const keys = [];
28549
+ for (const key in object) {
28550
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
28551
+ keys.push(key);
28552
+ }
28553
+ }
28554
+ return keys;
28555
+ };
28556
+ util2.find = (arr, checker) => {
28557
+ for (const item of arr) {
28558
+ if (checker(item)) return item;
28559
+ }
28560
+ return void 0;
28561
+ };
28562
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
28563
+ function joinValues(array, separator = " | ") {
28564
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
28565
+ }
28566
+ __name(joinValues, "joinValues");
28567
+ util2.joinValues = joinValues;
28568
+ util2.jsonStringifyReplacer = (_, value) => {
28569
+ if (typeof value === "bigint") {
28570
+ return value.toString();
28571
+ }
28572
+ return value;
28573
+ };
28574
+ })(util || (util = {}));
28575
+ var objectUtil;
28576
+ (function(objectUtil2) {
28577
+ objectUtil2.mergeShapes = (first, second) => {
28578
+ return {
28579
+ ...first,
28580
+ ...second
28581
+ };
28582
+ };
28583
+ })(objectUtil || (objectUtil = {}));
28584
+ var ZodParsedType = util.arrayToEnum([
28585
+ "string",
28586
+ "nan",
28587
+ "number",
28588
+ "integer",
28589
+ "float",
28590
+ "boolean",
28591
+ "date",
28592
+ "bigint",
28593
+ "symbol",
28594
+ "function",
28595
+ "undefined",
28596
+ "null",
28597
+ "array",
28598
+ "object",
28599
+ "unknown",
28600
+ "promise",
28601
+ "void",
28602
+ "never",
28603
+ "map",
28604
+ "set"
28605
+ ]);
28606
+ var getParsedType = /* @__PURE__ */ __name((data) => {
28607
+ const t8 = typeof data;
28608
+ switch (t8) {
28609
+ case "undefined":
28610
+ return ZodParsedType.undefined;
28611
+ case "string":
28612
+ return ZodParsedType.string;
28613
+ case "number":
28614
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
28615
+ case "boolean":
28616
+ return ZodParsedType.boolean;
28617
+ case "function":
28618
+ return ZodParsedType.function;
28619
+ case "bigint":
28620
+ return ZodParsedType.bigint;
28621
+ case "symbol":
28622
+ return ZodParsedType.symbol;
28623
+ case "object":
28624
+ if (Array.isArray(data)) {
28625
+ return ZodParsedType.array;
28626
+ }
28627
+ if (data === null) {
28628
+ return ZodParsedType.null;
28629
+ }
28630
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
28631
+ return ZodParsedType.promise;
28632
+ }
28633
+ if (typeof Map !== "undefined" && data instanceof Map) {
28634
+ return ZodParsedType.map;
28635
+ }
28636
+ if (typeof Set !== "undefined" && data instanceof Set) {
28637
+ return ZodParsedType.set;
28638
+ }
28639
+ if (typeof Date !== "undefined" && data instanceof Date) {
28640
+ return ZodParsedType.date;
28641
+ }
28642
+ return ZodParsedType.object;
28643
+ default:
28644
+ return ZodParsedType.unknown;
28645
+ }
28646
+ }, "getParsedType");
28647
+
28648
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
28649
+ var ZodIssueCode = util.arrayToEnum([
28650
+ "invalid_type",
28651
+ "invalid_literal",
28652
+ "custom",
28653
+ "invalid_union",
28654
+ "invalid_union_discriminator",
28655
+ "invalid_enum_value",
28656
+ "unrecognized_keys",
28657
+ "invalid_arguments",
28658
+ "invalid_return_type",
28659
+ "invalid_date",
28660
+ "invalid_string",
28661
+ "too_small",
28662
+ "too_big",
28663
+ "invalid_intersection_types",
28664
+ "not_multiple_of",
28665
+ "not_finite"
28666
+ ]);
28667
+ var quotelessJson = /* @__PURE__ */ __name((obj) => {
28668
+ const json = JSON.stringify(obj, null, 2);
28669
+ return json.replace(/"([^"]+)":/g, "$1:");
28670
+ }, "quotelessJson");
28671
+ var ZodError = class _ZodError extends Error {
28672
+ static {
28673
+ __name(this, "ZodError");
28674
+ }
28675
+ get errors() {
28676
+ return this.issues;
28677
+ }
28678
+ constructor(issues) {
28679
+ super();
28680
+ this.issues = [];
28681
+ this.addIssue = (sub) => {
28682
+ this.issues = [
28683
+ ...this.issues,
28684
+ sub
28685
+ ];
28686
+ };
28687
+ this.addIssues = (subs = []) => {
28688
+ this.issues = [
28689
+ ...this.issues,
28690
+ ...subs
28691
+ ];
28692
+ };
28693
+ const actualProto = new.target.prototype;
28694
+ if (Object.setPrototypeOf) {
28695
+ Object.setPrototypeOf(this, actualProto);
28696
+ } else {
28697
+ this.__proto__ = actualProto;
28698
+ }
28699
+ this.name = "ZodError";
28700
+ this.issues = issues;
28701
+ }
28702
+ format(_mapper) {
28703
+ const mapper = _mapper || function(issue) {
28704
+ return issue.message;
28705
+ };
28706
+ const fieldErrors = {
28707
+ _errors: []
28708
+ };
28709
+ const processError = /* @__PURE__ */ __name((error) => {
28710
+ for (const issue of error.issues) {
28711
+ if (issue.code === "invalid_union") {
28712
+ issue.unionErrors.map(processError);
28713
+ } else if (issue.code === "invalid_return_type") {
28714
+ processError(issue.returnTypeError);
28715
+ } else if (issue.code === "invalid_arguments") {
28716
+ processError(issue.argumentsError);
28717
+ } else if (issue.path.length === 0) {
28718
+ fieldErrors._errors.push(mapper(issue));
28719
+ } else {
28720
+ let curr = fieldErrors;
28721
+ let i6 = 0;
28722
+ while (i6 < issue.path.length) {
28723
+ const el = issue.path[i6];
28724
+ const terminal = i6 === issue.path.length - 1;
28725
+ if (!terminal) {
28726
+ curr[el] = curr[el] || {
28727
+ _errors: []
28728
+ };
28729
+ } else {
28730
+ curr[el] = curr[el] || {
28731
+ _errors: []
28732
+ };
28733
+ curr[el]._errors.push(mapper(issue));
28734
+ }
28735
+ curr = curr[el];
28736
+ i6++;
28737
+ }
28738
+ }
28739
+ }
28740
+ }, "processError");
28741
+ processError(this);
28742
+ return fieldErrors;
28743
+ }
28744
+ static assert(value) {
28745
+ if (!(value instanceof _ZodError)) {
28746
+ throw new Error(`Not a ZodError: ${value}`);
28747
+ }
28748
+ }
28749
+ toString() {
28750
+ return this.message;
28751
+ }
28752
+ get message() {
28753
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
28754
+ }
28755
+ get isEmpty() {
28756
+ return this.issues.length === 0;
28757
+ }
28758
+ flatten(mapper = (issue) => issue.message) {
28759
+ const fieldErrors = {};
28760
+ const formErrors = [];
28761
+ for (const sub of this.issues) {
28762
+ if (sub.path.length > 0) {
28763
+ const firstEl = sub.path[0];
28764
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
28765
+ fieldErrors[firstEl].push(mapper(sub));
28766
+ } else {
28767
+ formErrors.push(mapper(sub));
28768
+ }
28769
+ }
28770
+ return {
28771
+ formErrors,
28772
+ fieldErrors
28773
+ };
28774
+ }
28775
+ get formErrors() {
28776
+ return this.flatten();
28777
+ }
28778
+ };
28779
+ ZodError.create = (issues) => {
28780
+ const error = new ZodError(issues);
28781
+ return error;
28782
+ };
28783
+
28784
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
28785
+ var errorMap = /* @__PURE__ */ __name((issue, _ctx) => {
28786
+ let message;
28787
+ switch (issue.code) {
28788
+ case ZodIssueCode.invalid_type:
28789
+ if (issue.received === ZodParsedType.undefined) {
28790
+ message = "Required";
28791
+ } else {
28792
+ message = `Expected ${issue.expected}, received ${issue.received}`;
28793
+ }
28794
+ break;
28795
+ case ZodIssueCode.invalid_literal:
28796
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
28797
+ break;
28798
+ case ZodIssueCode.unrecognized_keys:
28799
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
28800
+ break;
28801
+ case ZodIssueCode.invalid_union:
28802
+ message = `Invalid input`;
28803
+ break;
28804
+ case ZodIssueCode.invalid_union_discriminator:
28805
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
28806
+ break;
28807
+ case ZodIssueCode.invalid_enum_value:
28808
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
28809
+ break;
28810
+ case ZodIssueCode.invalid_arguments:
28811
+ message = `Invalid function arguments`;
28812
+ break;
28813
+ case ZodIssueCode.invalid_return_type:
28814
+ message = `Invalid function return type`;
28815
+ break;
28816
+ case ZodIssueCode.invalid_date:
28817
+ message = `Invalid date`;
28818
+ break;
28819
+ case ZodIssueCode.invalid_string:
28820
+ if (typeof issue.validation === "object") {
28821
+ if ("includes" in issue.validation) {
28822
+ message = `Invalid input: must include "${issue.validation.includes}"`;
28823
+ if (typeof issue.validation.position === "number") {
28824
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
28825
+ }
28826
+ } else if ("startsWith" in issue.validation) {
28827
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
28828
+ } else if ("endsWith" in issue.validation) {
28829
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
28830
+ } else {
28831
+ util.assertNever(issue.validation);
28832
+ }
28833
+ } else if (issue.validation !== "regex") {
28834
+ message = `Invalid ${issue.validation}`;
28835
+ } else {
28836
+ message = "Invalid";
28837
+ }
28838
+ break;
28839
+ case ZodIssueCode.too_small:
28840
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
28841
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
28842
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
28843
+ else if (issue.type === "bigint") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
28844
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
28845
+ else message = "Invalid input";
28846
+ break;
28847
+ case ZodIssueCode.too_big:
28848
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
28849
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
28850
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
28851
+ else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
28852
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
28853
+ else message = "Invalid input";
28854
+ break;
28855
+ case ZodIssueCode.custom:
28856
+ message = `Invalid input`;
28857
+ break;
28858
+ case ZodIssueCode.invalid_intersection_types:
28859
+ message = `Intersection results could not be merged`;
28860
+ break;
28861
+ case ZodIssueCode.not_multiple_of:
28862
+ message = `Number must be a multiple of ${issue.multipleOf}`;
28863
+ break;
28864
+ case ZodIssueCode.not_finite:
28865
+ message = "Number must be finite";
28866
+ break;
28867
+ default:
28868
+ message = _ctx.defaultError;
28869
+ util.assertNever(issue);
28870
+ }
28871
+ return {
28872
+ message
28873
+ };
28874
+ }, "errorMap");
28875
+ var en_default = errorMap;
28876
+
28877
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
28878
+ var overrideErrorMap = en_default;
28879
+ function setErrorMap(map) {
28880
+ overrideErrorMap = map;
28881
+ }
28882
+ __name(setErrorMap, "setErrorMap");
28883
+ function getErrorMap() {
28884
+ return overrideErrorMap;
28885
+ }
28886
+ __name(getErrorMap, "getErrorMap");
28887
+
28888
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
28889
+ var makeIssue = /* @__PURE__ */ __name((params) => {
28890
+ const { data, path: path14, errorMaps, issueData } = params;
28891
+ const fullPath = [
28892
+ ...path14,
28893
+ ...issueData.path || []
28894
+ ];
28895
+ const fullIssue = {
28896
+ ...issueData,
28897
+ path: fullPath
28898
+ };
28899
+ if (issueData.message !== void 0) {
28900
+ return {
28901
+ ...issueData,
28902
+ path: fullPath,
28903
+ message: issueData.message
28904
+ };
28905
+ }
28906
+ let errorMessage = "";
28907
+ const maps = errorMaps.filter((m4) => !!m4).slice().reverse();
28908
+ for (const map of maps) {
28909
+ errorMessage = map(fullIssue, {
28910
+ data,
28911
+ defaultError: errorMessage
28912
+ }).message;
28913
+ }
28914
+ return {
28915
+ ...issueData,
28916
+ path: fullPath,
28917
+ message: errorMessage
28918
+ };
28919
+ }, "makeIssue");
28920
+ var EMPTY_PATH = [];
28921
+ function addIssueToContext(ctx, issueData) {
28922
+ const overrideMap = getErrorMap();
28923
+ const issue = makeIssue({
28924
+ issueData,
28925
+ data: ctx.data,
28926
+ path: ctx.path,
28927
+ errorMaps: [
28928
+ ctx.common.contextualErrorMap,
28929
+ ctx.schemaErrorMap,
28930
+ overrideMap,
28931
+ overrideMap === en_default ? void 0 : en_default
28932
+ ].filter((x2) => !!x2)
28933
+ });
28934
+ ctx.common.issues.push(issue);
28935
+ }
28936
+ __name(addIssueToContext, "addIssueToContext");
28937
+ var ParseStatus = class _ParseStatus {
28938
+ static {
28939
+ __name(this, "ParseStatus");
28940
+ }
28941
+ constructor() {
28942
+ this.value = "valid";
28943
+ }
28944
+ dirty() {
28945
+ if (this.value === "valid") this.value = "dirty";
28946
+ }
28947
+ abort() {
28948
+ if (this.value !== "aborted") this.value = "aborted";
28949
+ }
28950
+ static mergeArray(status, results) {
28951
+ const arrayValue = [];
28952
+ for (const s2 of results) {
28953
+ if (s2.status === "aborted") return INVALID;
28954
+ if (s2.status === "dirty") status.dirty();
28955
+ arrayValue.push(s2.value);
28956
+ }
28957
+ return {
28958
+ status: status.value,
28959
+ value: arrayValue
28960
+ };
28961
+ }
28962
+ static async mergeObjectAsync(status, pairs) {
28963
+ const syncPairs = [];
28964
+ for (const pair of pairs) {
28965
+ const key = await pair.key;
28966
+ const value = await pair.value;
28967
+ syncPairs.push({
28968
+ key,
28969
+ value
28970
+ });
28971
+ }
28972
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
28973
+ }
28974
+ static mergeObjectSync(status, pairs) {
28975
+ const finalObject = {};
28976
+ for (const pair of pairs) {
28977
+ const { key, value } = pair;
28978
+ if (key.status === "aborted") return INVALID;
28979
+ if (value.status === "aborted") return INVALID;
28980
+ if (key.status === "dirty") status.dirty();
28981
+ if (value.status === "dirty") status.dirty();
28982
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
28983
+ finalObject[key.value] = value.value;
28984
+ }
28985
+ }
28986
+ return {
28987
+ status: status.value,
28988
+ value: finalObject
28989
+ };
28990
+ }
28991
+ };
28992
+ var INVALID = Object.freeze({
28993
+ status: "aborted"
28994
+ });
28995
+ var DIRTY = /* @__PURE__ */ __name((value) => ({
28996
+ status: "dirty",
28997
+ value
28998
+ }), "DIRTY");
28999
+ var OK = /* @__PURE__ */ __name((value) => ({
29000
+ status: "valid",
29001
+ value
29002
+ }), "OK");
29003
+ var isAborted = /* @__PURE__ */ __name((x2) => x2.status === "aborted", "isAborted");
29004
+ var isDirty = /* @__PURE__ */ __name((x2) => x2.status === "dirty", "isDirty");
29005
+ var isValid = /* @__PURE__ */ __name((x2) => x2.status === "valid", "isValid");
29006
+ var isAsync = /* @__PURE__ */ __name((x2) => typeof Promise !== "undefined" && x2 instanceof Promise, "isAsync");
29007
+
29008
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
29009
+ var errorUtil;
29010
+ (function(errorUtil2) {
29011
+ errorUtil2.errToObj = (message) => typeof message === "string" ? {
29012
+ message
29013
+ } : message || {};
29014
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
29015
+ })(errorUtil || (errorUtil = {}));
29016
+
29017
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
29018
+ var ParseInputLazyPath = class ParseInputLazyPath2 {
29019
+ static {
29020
+ __name(this, "ParseInputLazyPath");
29021
+ }
29022
+ constructor(parent, value, path14, key) {
29023
+ this._cachedPath = [];
29024
+ this.parent = parent;
29025
+ this.data = value;
29026
+ this._path = path14;
29027
+ this._key = key;
29028
+ }
29029
+ get path() {
29030
+ if (!this._cachedPath.length) {
29031
+ if (Array.isArray(this._key)) {
29032
+ this._cachedPath.push(...this._path, ...this._key);
29033
+ } else {
29034
+ this._cachedPath.push(...this._path, this._key);
29035
+ }
29036
+ }
29037
+ return this._cachedPath;
29038
+ }
29039
+ };
29040
+ var handleResult = /* @__PURE__ */ __name((ctx, result) => {
29041
+ if (isValid(result)) {
29042
+ return {
29043
+ success: true,
29044
+ data: result.value
29045
+ };
29046
+ } else {
29047
+ if (!ctx.common.issues.length) {
29048
+ throw new Error("Validation failed but no issues detected.");
29049
+ }
29050
+ return {
29051
+ success: false,
29052
+ get error() {
29053
+ if (this._error) return this._error;
29054
+ const error = new ZodError(ctx.common.issues);
29055
+ this._error = error;
29056
+ return this._error;
29057
+ }
29058
+ };
29059
+ }
29060
+ }, "handleResult");
29061
+ function processCreateParams(params) {
29062
+ if (!params) return {};
29063
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
29064
+ if (errorMap2 && (invalid_type_error || required_error)) {
29065
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
29066
+ }
29067
+ if (errorMap2) return {
29068
+ errorMap: errorMap2,
29069
+ description
29070
+ };
29071
+ const customMap = /* @__PURE__ */ __name((iss, ctx) => {
29072
+ const { message } = params;
29073
+ if (iss.code === "invalid_enum_value") {
29074
+ return {
29075
+ message: message ?? ctx.defaultError
29076
+ };
29077
+ }
29078
+ if (typeof ctx.data === "undefined") {
29079
+ return {
29080
+ message: message ?? required_error ?? ctx.defaultError
29081
+ };
29082
+ }
29083
+ if (iss.code !== "invalid_type") return {
29084
+ message: ctx.defaultError
29085
+ };
29086
+ return {
29087
+ message: message ?? invalid_type_error ?? ctx.defaultError
29088
+ };
29089
+ }, "customMap");
29090
+ return {
29091
+ errorMap: customMap,
29092
+ description
29093
+ };
29094
+ }
29095
+ __name(processCreateParams, "processCreateParams");
29096
+ var ZodType = class {
29097
+ static {
29098
+ __name(this, "ZodType");
29099
+ }
29100
+ get description() {
29101
+ return this._def.description;
29102
+ }
29103
+ _getType(input) {
29104
+ return getParsedType(input.data);
29105
+ }
29106
+ _getOrReturnCtx(input, ctx) {
29107
+ return ctx || {
29108
+ common: input.parent.common,
29109
+ data: input.data,
29110
+ parsedType: getParsedType(input.data),
29111
+ schemaErrorMap: this._def.errorMap,
29112
+ path: input.path,
29113
+ parent: input.parent
29114
+ };
29115
+ }
29116
+ _processInputParams(input) {
29117
+ return {
29118
+ status: new ParseStatus(),
29119
+ ctx: {
29120
+ common: input.parent.common,
29121
+ data: input.data,
29122
+ parsedType: getParsedType(input.data),
29123
+ schemaErrorMap: this._def.errorMap,
29124
+ path: input.path,
29125
+ parent: input.parent
29126
+ }
29127
+ };
29128
+ }
29129
+ _parseSync(input) {
29130
+ const result = this._parse(input);
29131
+ if (isAsync(result)) {
29132
+ throw new Error("Synchronous parse encountered promise.");
29133
+ }
29134
+ return result;
29135
+ }
29136
+ _parseAsync(input) {
29137
+ const result = this._parse(input);
29138
+ return Promise.resolve(result);
29139
+ }
29140
+ parse(data, params) {
29141
+ const result = this.safeParse(data, params);
29142
+ if (result.success) return result.data;
29143
+ throw result.error;
29144
+ }
29145
+ safeParse(data, params) {
29146
+ const ctx = {
29147
+ common: {
29148
+ issues: [],
29149
+ async: params?.async ?? false,
29150
+ contextualErrorMap: params?.errorMap
29151
+ },
29152
+ path: params?.path || [],
29153
+ schemaErrorMap: this._def.errorMap,
29154
+ parent: null,
29155
+ data,
29156
+ parsedType: getParsedType(data)
29157
+ };
29158
+ const result = this._parseSync({
29159
+ data,
29160
+ path: ctx.path,
29161
+ parent: ctx
29162
+ });
29163
+ return handleResult(ctx, result);
29164
+ }
29165
+ "~validate"(data) {
29166
+ const ctx = {
29167
+ common: {
29168
+ issues: [],
29169
+ async: !!this["~standard"].async
29170
+ },
29171
+ path: [],
29172
+ schemaErrorMap: this._def.errorMap,
29173
+ parent: null,
29174
+ data,
29175
+ parsedType: getParsedType(data)
29176
+ };
29177
+ if (!this["~standard"].async) {
29178
+ try {
29179
+ const result = this._parseSync({
29180
+ data,
29181
+ path: [],
29182
+ parent: ctx
29183
+ });
29184
+ return isValid(result) ? {
29185
+ value: result.value
29186
+ } : {
29187
+ issues: ctx.common.issues
29188
+ };
29189
+ } catch (err) {
29190
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
29191
+ this["~standard"].async = true;
29192
+ }
29193
+ ctx.common = {
29194
+ issues: [],
29195
+ async: true
29196
+ };
29197
+ }
29198
+ }
29199
+ return this._parseAsync({
29200
+ data,
29201
+ path: [],
29202
+ parent: ctx
29203
+ }).then((result) => isValid(result) ? {
29204
+ value: result.value
29205
+ } : {
29206
+ issues: ctx.common.issues
29207
+ });
29208
+ }
29209
+ async parseAsync(data, params) {
29210
+ const result = await this.safeParseAsync(data, params);
29211
+ if (result.success) return result.data;
29212
+ throw result.error;
29213
+ }
29214
+ async safeParseAsync(data, params) {
29215
+ const ctx = {
29216
+ common: {
29217
+ issues: [],
29218
+ contextualErrorMap: params?.errorMap,
29219
+ async: true
29220
+ },
29221
+ path: params?.path || [],
29222
+ schemaErrorMap: this._def.errorMap,
29223
+ parent: null,
29224
+ data,
29225
+ parsedType: getParsedType(data)
29226
+ };
29227
+ const maybeAsyncResult = this._parse({
29228
+ data,
29229
+ path: ctx.path,
29230
+ parent: ctx
29231
+ });
29232
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
29233
+ return handleResult(ctx, result);
29234
+ }
29235
+ refine(check, message) {
29236
+ const getIssueProperties = /* @__PURE__ */ __name((val) => {
29237
+ if (typeof message === "string" || typeof message === "undefined") {
29238
+ return {
29239
+ message
29240
+ };
29241
+ } else if (typeof message === "function") {
29242
+ return message(val);
29243
+ } else {
29244
+ return message;
29245
+ }
29246
+ }, "getIssueProperties");
29247
+ return this._refinement((val, ctx) => {
29248
+ const result = check(val);
29249
+ const setError = /* @__PURE__ */ __name(() => ctx.addIssue({
29250
+ code: ZodIssueCode.custom,
29251
+ ...getIssueProperties(val)
29252
+ }), "setError");
29253
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
29254
+ return result.then((data) => {
29255
+ if (!data) {
29256
+ setError();
29257
+ return false;
29258
+ } else {
29259
+ return true;
29260
+ }
29261
+ });
29262
+ }
29263
+ if (!result) {
29264
+ setError();
29265
+ return false;
29266
+ } else {
29267
+ return true;
29268
+ }
29269
+ });
29270
+ }
29271
+ refinement(check, refinementData) {
29272
+ return this._refinement((val, ctx) => {
29273
+ if (!check(val)) {
29274
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
29275
+ return false;
29276
+ } else {
29277
+ return true;
29278
+ }
29279
+ });
29280
+ }
29281
+ _refinement(refinement) {
29282
+ return new ZodEffects({
29283
+ schema: this,
29284
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
29285
+ effect: {
29286
+ type: "refinement",
29287
+ refinement
29288
+ }
29289
+ });
29290
+ }
29291
+ superRefine(refinement) {
29292
+ return this._refinement(refinement);
29293
+ }
29294
+ constructor(def) {
29295
+ this.spa = this.safeParseAsync;
29296
+ this._def = def;
29297
+ this.parse = this.parse.bind(this);
29298
+ this.safeParse = this.safeParse.bind(this);
29299
+ this.parseAsync = this.parseAsync.bind(this);
29300
+ this.safeParseAsync = this.safeParseAsync.bind(this);
29301
+ this.spa = this.spa.bind(this);
29302
+ this.refine = this.refine.bind(this);
29303
+ this.refinement = this.refinement.bind(this);
29304
+ this.superRefine = this.superRefine.bind(this);
29305
+ this.optional = this.optional.bind(this);
29306
+ this.nullable = this.nullable.bind(this);
29307
+ this.nullish = this.nullish.bind(this);
29308
+ this.array = this.array.bind(this);
29309
+ this.promise = this.promise.bind(this);
29310
+ this.or = this.or.bind(this);
29311
+ this.and = this.and.bind(this);
29312
+ this.transform = this.transform.bind(this);
29313
+ this.brand = this.brand.bind(this);
29314
+ this.default = this.default.bind(this);
29315
+ this.catch = this.catch.bind(this);
29316
+ this.describe = this.describe.bind(this);
29317
+ this.pipe = this.pipe.bind(this);
29318
+ this.readonly = this.readonly.bind(this);
29319
+ this.isNullable = this.isNullable.bind(this);
29320
+ this.isOptional = this.isOptional.bind(this);
29321
+ this["~standard"] = {
29322
+ version: 1,
29323
+ vendor: "zod",
29324
+ validate: /* @__PURE__ */ __name((data) => this["~validate"](data), "validate")
29325
+ };
29326
+ }
29327
+ optional() {
29328
+ return ZodOptional.create(this, this._def);
29329
+ }
29330
+ nullable() {
29331
+ return ZodNullable.create(this, this._def);
29332
+ }
29333
+ nullish() {
29334
+ return this.nullable().optional();
29335
+ }
29336
+ array() {
29337
+ return ZodArray.create(this);
29338
+ }
29339
+ promise() {
29340
+ return ZodPromise.create(this, this._def);
29341
+ }
29342
+ or(option) {
29343
+ return ZodUnion.create([
29344
+ this,
29345
+ option
29346
+ ], this._def);
29347
+ }
29348
+ and(incoming) {
29349
+ return ZodIntersection.create(this, incoming, this._def);
29350
+ }
29351
+ transform(transform) {
29352
+ return new ZodEffects({
29353
+ ...processCreateParams(this._def),
29354
+ schema: this,
29355
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
29356
+ effect: {
29357
+ type: "transform",
29358
+ transform
29359
+ }
29360
+ });
29361
+ }
29362
+ default(def) {
29363
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
29364
+ return new ZodDefault({
29365
+ ...processCreateParams(this._def),
29366
+ innerType: this,
29367
+ defaultValue: defaultValueFunc,
29368
+ typeName: ZodFirstPartyTypeKind.ZodDefault
29369
+ });
29370
+ }
29371
+ brand() {
29372
+ return new ZodBranded({
29373
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
29374
+ type: this,
29375
+ ...processCreateParams(this._def)
29376
+ });
29377
+ }
29378
+ catch(def) {
29379
+ const catchValueFunc = typeof def === "function" ? def : () => def;
29380
+ return new ZodCatch({
29381
+ ...processCreateParams(this._def),
29382
+ innerType: this,
29383
+ catchValue: catchValueFunc,
29384
+ typeName: ZodFirstPartyTypeKind.ZodCatch
29385
+ });
29386
+ }
29387
+ describe(description) {
29388
+ const This = this.constructor;
29389
+ return new This({
29390
+ ...this._def,
29391
+ description
29392
+ });
29393
+ }
29394
+ pipe(target) {
29395
+ return ZodPipeline.create(this, target);
29396
+ }
29397
+ readonly() {
29398
+ return ZodReadonly.create(this);
29399
+ }
29400
+ isOptional() {
29401
+ return this.safeParse(void 0).success;
29402
+ }
29403
+ isNullable() {
29404
+ return this.safeParse(null).success;
29405
+ }
29406
+ };
29407
+ var cuidRegex = /^c[^\s-]{8,}$/i;
29408
+ var cuid2Regex = /^[0-9a-z]+$/;
29409
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
29410
+ 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;
29411
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
29412
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
29413
+ 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)?)??$/;
29414
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
29415
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
29416
+ var emojiRegex;
29417
+ 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])$/;
29418
+ 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])$/;
29419
+ 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]))$/;
29420
+ 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])$/;
29421
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
29422
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
29423
+ 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])))`;
29424
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
29425
+ function timeRegexSource(args) {
29426
+ let secondsRegexSource = `[0-5]\\d`;
29427
+ if (args.precision) {
29428
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
29429
+ } else if (args.precision == null) {
29430
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
29431
+ }
29432
+ const secondsQuantifier = args.precision ? "+" : "?";
29433
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
29434
+ }
29435
+ __name(timeRegexSource, "timeRegexSource");
29436
+ function timeRegex(args) {
29437
+ return new RegExp(`^${timeRegexSource(args)}$`);
29438
+ }
29439
+ __name(timeRegex, "timeRegex");
29440
+ function datetimeRegex(args) {
29441
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
29442
+ const opts = [];
29443
+ opts.push(args.local ? `Z?` : `Z`);
29444
+ if (args.offset) opts.push(`([+-]\\d{2}:?\\d{2})`);
29445
+ regex = `${regex}(${opts.join("|")})`;
29446
+ return new RegExp(`^${regex}$`);
29447
+ }
29448
+ __name(datetimeRegex, "datetimeRegex");
29449
+ function isValidIP(ip, version) {
29450
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
29451
+ return true;
29452
+ }
29453
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
29454
+ return true;
29455
+ }
29456
+ return false;
29457
+ }
29458
+ __name(isValidIP, "isValidIP");
29459
+ function isValidJWT(jwt, alg) {
29460
+ if (!jwtRegex.test(jwt)) return false;
29461
+ try {
29462
+ const [header] = jwt.split(".");
29463
+ if (!header) return false;
29464
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
29465
+ const decoded = JSON.parse(atob(base64));
29466
+ if (typeof decoded !== "object" || decoded === null) return false;
29467
+ if ("typ" in decoded && decoded?.typ !== "JWT") return false;
29468
+ if (!decoded.alg) return false;
29469
+ if (alg && decoded.alg !== alg) return false;
29470
+ return true;
29471
+ } catch {
29472
+ return false;
29473
+ }
29474
+ }
29475
+ __name(isValidJWT, "isValidJWT");
29476
+ function isValidCidr(ip, version) {
29477
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
29478
+ return true;
29479
+ }
29480
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
29481
+ return true;
29482
+ }
29483
+ return false;
29484
+ }
29485
+ __name(isValidCidr, "isValidCidr");
29486
+ var ZodString = class _ZodString extends ZodType {
29487
+ static {
29488
+ __name(this, "ZodString");
29489
+ }
29490
+ _parse(input) {
29491
+ if (this._def.coerce) {
29492
+ input.data = String(input.data);
29493
+ }
29494
+ const parsedType = this._getType(input);
29495
+ if (parsedType !== ZodParsedType.string) {
29496
+ const ctx2 = this._getOrReturnCtx(input);
29497
+ addIssueToContext(ctx2, {
29498
+ code: ZodIssueCode.invalid_type,
29499
+ expected: ZodParsedType.string,
29500
+ received: ctx2.parsedType
29501
+ });
29502
+ return INVALID;
29503
+ }
29504
+ const status = new ParseStatus();
29505
+ let ctx = void 0;
29506
+ for (const check of this._def.checks) {
29507
+ if (check.kind === "min") {
29508
+ if (input.data.length < check.value) {
29509
+ ctx = this._getOrReturnCtx(input, ctx);
29510
+ addIssueToContext(ctx, {
29511
+ code: ZodIssueCode.too_small,
29512
+ minimum: check.value,
29513
+ type: "string",
29514
+ inclusive: true,
29515
+ exact: false,
29516
+ message: check.message
29517
+ });
29518
+ status.dirty();
29519
+ }
29520
+ } else if (check.kind === "max") {
29521
+ if (input.data.length > check.value) {
29522
+ ctx = this._getOrReturnCtx(input, ctx);
29523
+ addIssueToContext(ctx, {
29524
+ code: ZodIssueCode.too_big,
29525
+ maximum: check.value,
29526
+ type: "string",
29527
+ inclusive: true,
29528
+ exact: false,
29529
+ message: check.message
29530
+ });
29531
+ status.dirty();
29532
+ }
29533
+ } else if (check.kind === "length") {
29534
+ const tooBig = input.data.length > check.value;
29535
+ const tooSmall = input.data.length < check.value;
29536
+ if (tooBig || tooSmall) {
29537
+ ctx = this._getOrReturnCtx(input, ctx);
29538
+ if (tooBig) {
29539
+ addIssueToContext(ctx, {
29540
+ code: ZodIssueCode.too_big,
29541
+ maximum: check.value,
29542
+ type: "string",
29543
+ inclusive: true,
29544
+ exact: true,
29545
+ message: check.message
29546
+ });
29547
+ } else if (tooSmall) {
29548
+ addIssueToContext(ctx, {
29549
+ code: ZodIssueCode.too_small,
29550
+ minimum: check.value,
29551
+ type: "string",
29552
+ inclusive: true,
29553
+ exact: true,
29554
+ message: check.message
29555
+ });
29556
+ }
29557
+ status.dirty();
29558
+ }
29559
+ } else if (check.kind === "email") {
29560
+ if (!emailRegex.test(input.data)) {
29561
+ ctx = this._getOrReturnCtx(input, ctx);
29562
+ addIssueToContext(ctx, {
29563
+ validation: "email",
29564
+ code: ZodIssueCode.invalid_string,
29565
+ message: check.message
29566
+ });
29567
+ status.dirty();
29568
+ }
29569
+ } else if (check.kind === "emoji") {
29570
+ if (!emojiRegex) {
29571
+ emojiRegex = new RegExp(_emojiRegex, "u");
29572
+ }
29573
+ if (!emojiRegex.test(input.data)) {
29574
+ ctx = this._getOrReturnCtx(input, ctx);
29575
+ addIssueToContext(ctx, {
29576
+ validation: "emoji",
29577
+ code: ZodIssueCode.invalid_string,
29578
+ message: check.message
29579
+ });
29580
+ status.dirty();
29581
+ }
29582
+ } else if (check.kind === "uuid") {
29583
+ if (!uuidRegex.test(input.data)) {
29584
+ ctx = this._getOrReturnCtx(input, ctx);
29585
+ addIssueToContext(ctx, {
29586
+ validation: "uuid",
29587
+ code: ZodIssueCode.invalid_string,
29588
+ message: check.message
29589
+ });
29590
+ status.dirty();
29591
+ }
29592
+ } else if (check.kind === "nanoid") {
29593
+ if (!nanoidRegex.test(input.data)) {
29594
+ ctx = this._getOrReturnCtx(input, ctx);
29595
+ addIssueToContext(ctx, {
29596
+ validation: "nanoid",
29597
+ code: ZodIssueCode.invalid_string,
29598
+ message: check.message
29599
+ });
29600
+ status.dirty();
29601
+ }
29602
+ } else if (check.kind === "cuid") {
29603
+ if (!cuidRegex.test(input.data)) {
29604
+ ctx = this._getOrReturnCtx(input, ctx);
29605
+ addIssueToContext(ctx, {
29606
+ validation: "cuid",
29607
+ code: ZodIssueCode.invalid_string,
29608
+ message: check.message
29609
+ });
29610
+ status.dirty();
29611
+ }
29612
+ } else if (check.kind === "cuid2") {
29613
+ if (!cuid2Regex.test(input.data)) {
29614
+ ctx = this._getOrReturnCtx(input, ctx);
29615
+ addIssueToContext(ctx, {
29616
+ validation: "cuid2",
29617
+ code: ZodIssueCode.invalid_string,
29618
+ message: check.message
29619
+ });
29620
+ status.dirty();
29621
+ }
29622
+ } else if (check.kind === "ulid") {
29623
+ if (!ulidRegex.test(input.data)) {
29624
+ ctx = this._getOrReturnCtx(input, ctx);
29625
+ addIssueToContext(ctx, {
29626
+ validation: "ulid",
29627
+ code: ZodIssueCode.invalid_string,
29628
+ message: check.message
29629
+ });
29630
+ status.dirty();
29631
+ }
29632
+ } else if (check.kind === "url") {
29633
+ try {
29634
+ new URL(input.data);
29635
+ } catch {
29636
+ ctx = this._getOrReturnCtx(input, ctx);
29637
+ addIssueToContext(ctx, {
29638
+ validation: "url",
29639
+ code: ZodIssueCode.invalid_string,
29640
+ message: check.message
29641
+ });
29642
+ status.dirty();
29643
+ }
29644
+ } else if (check.kind === "regex") {
29645
+ check.regex.lastIndex = 0;
29646
+ const testResult = check.regex.test(input.data);
29647
+ if (!testResult) {
29648
+ ctx = this._getOrReturnCtx(input, ctx);
29649
+ addIssueToContext(ctx, {
29650
+ validation: "regex",
29651
+ code: ZodIssueCode.invalid_string,
29652
+ message: check.message
29653
+ });
29654
+ status.dirty();
29655
+ }
29656
+ } else if (check.kind === "trim") {
29657
+ input.data = input.data.trim();
29658
+ } else if (check.kind === "includes") {
29659
+ if (!input.data.includes(check.value, check.position)) {
29660
+ ctx = this._getOrReturnCtx(input, ctx);
29661
+ addIssueToContext(ctx, {
29662
+ code: ZodIssueCode.invalid_string,
29663
+ validation: {
29664
+ includes: check.value,
29665
+ position: check.position
29666
+ },
29667
+ message: check.message
29668
+ });
29669
+ status.dirty();
29670
+ }
29671
+ } else if (check.kind === "toLowerCase") {
29672
+ input.data = input.data.toLowerCase();
29673
+ } else if (check.kind === "toUpperCase") {
29674
+ input.data = input.data.toUpperCase();
29675
+ } else if (check.kind === "startsWith") {
29676
+ if (!input.data.startsWith(check.value)) {
29677
+ ctx = this._getOrReturnCtx(input, ctx);
29678
+ addIssueToContext(ctx, {
29679
+ code: ZodIssueCode.invalid_string,
29680
+ validation: {
29681
+ startsWith: check.value
29682
+ },
29683
+ message: check.message
29684
+ });
29685
+ status.dirty();
29686
+ }
29687
+ } else if (check.kind === "endsWith") {
29688
+ if (!input.data.endsWith(check.value)) {
29689
+ ctx = this._getOrReturnCtx(input, ctx);
29690
+ addIssueToContext(ctx, {
29691
+ code: ZodIssueCode.invalid_string,
29692
+ validation: {
29693
+ endsWith: check.value
29694
+ },
29695
+ message: check.message
29696
+ });
29697
+ status.dirty();
29698
+ }
29699
+ } else if (check.kind === "datetime") {
29700
+ const regex = datetimeRegex(check);
29701
+ if (!regex.test(input.data)) {
29702
+ ctx = this._getOrReturnCtx(input, ctx);
29703
+ addIssueToContext(ctx, {
29704
+ code: ZodIssueCode.invalid_string,
29705
+ validation: "datetime",
29706
+ message: check.message
29707
+ });
29708
+ status.dirty();
29709
+ }
29710
+ } else if (check.kind === "date") {
29711
+ const regex = dateRegex;
29712
+ if (!regex.test(input.data)) {
29713
+ ctx = this._getOrReturnCtx(input, ctx);
29714
+ addIssueToContext(ctx, {
29715
+ code: ZodIssueCode.invalid_string,
29716
+ validation: "date",
29717
+ message: check.message
29718
+ });
29719
+ status.dirty();
29720
+ }
29721
+ } else if (check.kind === "time") {
29722
+ const regex = timeRegex(check);
29723
+ if (!regex.test(input.data)) {
29724
+ ctx = this._getOrReturnCtx(input, ctx);
29725
+ addIssueToContext(ctx, {
29726
+ code: ZodIssueCode.invalid_string,
29727
+ validation: "time",
29728
+ message: check.message
29729
+ });
29730
+ status.dirty();
29731
+ }
29732
+ } else if (check.kind === "duration") {
29733
+ if (!durationRegex.test(input.data)) {
29734
+ ctx = this._getOrReturnCtx(input, ctx);
29735
+ addIssueToContext(ctx, {
29736
+ validation: "duration",
29737
+ code: ZodIssueCode.invalid_string,
29738
+ message: check.message
29739
+ });
29740
+ status.dirty();
29741
+ }
29742
+ } else if (check.kind === "ip") {
29743
+ if (!isValidIP(input.data, check.version)) {
29744
+ ctx = this._getOrReturnCtx(input, ctx);
29745
+ addIssueToContext(ctx, {
29746
+ validation: "ip",
29747
+ code: ZodIssueCode.invalid_string,
29748
+ message: check.message
29749
+ });
29750
+ status.dirty();
29751
+ }
29752
+ } else if (check.kind === "jwt") {
29753
+ if (!isValidJWT(input.data, check.alg)) {
29754
+ ctx = this._getOrReturnCtx(input, ctx);
29755
+ addIssueToContext(ctx, {
29756
+ validation: "jwt",
29757
+ code: ZodIssueCode.invalid_string,
29758
+ message: check.message
29759
+ });
29760
+ status.dirty();
29761
+ }
29762
+ } else if (check.kind === "cidr") {
29763
+ if (!isValidCidr(input.data, check.version)) {
29764
+ ctx = this._getOrReturnCtx(input, ctx);
29765
+ addIssueToContext(ctx, {
29766
+ validation: "cidr",
29767
+ code: ZodIssueCode.invalid_string,
29768
+ message: check.message
29769
+ });
29770
+ status.dirty();
29771
+ }
29772
+ } else if (check.kind === "base64") {
29773
+ if (!base64Regex.test(input.data)) {
29774
+ ctx = this._getOrReturnCtx(input, ctx);
29775
+ addIssueToContext(ctx, {
29776
+ validation: "base64",
29777
+ code: ZodIssueCode.invalid_string,
29778
+ message: check.message
29779
+ });
29780
+ status.dirty();
29781
+ }
29782
+ } else if (check.kind === "base64url") {
29783
+ if (!base64urlRegex.test(input.data)) {
29784
+ ctx = this._getOrReturnCtx(input, ctx);
29785
+ addIssueToContext(ctx, {
29786
+ validation: "base64url",
29787
+ code: ZodIssueCode.invalid_string,
29788
+ message: check.message
29789
+ });
29790
+ status.dirty();
29791
+ }
29792
+ } else {
29793
+ util.assertNever(check);
29794
+ }
29795
+ }
29796
+ return {
29797
+ status: status.value,
29798
+ value: input.data
29799
+ };
29800
+ }
29801
+ _regex(regex, validation, message) {
29802
+ return this.refinement((data) => regex.test(data), {
29803
+ validation,
29804
+ code: ZodIssueCode.invalid_string,
29805
+ ...errorUtil.errToObj(message)
29806
+ });
29807
+ }
29808
+ _addCheck(check) {
29809
+ return new _ZodString({
29810
+ ...this._def,
29811
+ checks: [
29812
+ ...this._def.checks,
29813
+ check
29814
+ ]
29815
+ });
29816
+ }
29817
+ email(message) {
29818
+ return this._addCheck({
29819
+ kind: "email",
29820
+ ...errorUtil.errToObj(message)
29821
+ });
29822
+ }
29823
+ url(message) {
29824
+ return this._addCheck({
29825
+ kind: "url",
29826
+ ...errorUtil.errToObj(message)
29827
+ });
29828
+ }
29829
+ emoji(message) {
29830
+ return this._addCheck({
29831
+ kind: "emoji",
29832
+ ...errorUtil.errToObj(message)
29833
+ });
29834
+ }
29835
+ uuid(message) {
29836
+ return this._addCheck({
29837
+ kind: "uuid",
29838
+ ...errorUtil.errToObj(message)
29839
+ });
29840
+ }
29841
+ nanoid(message) {
29842
+ return this._addCheck({
29843
+ kind: "nanoid",
29844
+ ...errorUtil.errToObj(message)
29845
+ });
29846
+ }
29847
+ cuid(message) {
29848
+ return this._addCheck({
29849
+ kind: "cuid",
29850
+ ...errorUtil.errToObj(message)
29851
+ });
29852
+ }
29853
+ cuid2(message) {
29854
+ return this._addCheck({
29855
+ kind: "cuid2",
29856
+ ...errorUtil.errToObj(message)
29857
+ });
29858
+ }
29859
+ ulid(message) {
29860
+ return this._addCheck({
29861
+ kind: "ulid",
29862
+ ...errorUtil.errToObj(message)
29863
+ });
29864
+ }
29865
+ base64(message) {
29866
+ return this._addCheck({
29867
+ kind: "base64",
29868
+ ...errorUtil.errToObj(message)
29869
+ });
29870
+ }
29871
+ base64url(message) {
29872
+ return this._addCheck({
29873
+ kind: "base64url",
29874
+ ...errorUtil.errToObj(message)
29875
+ });
29876
+ }
29877
+ jwt(options) {
29878
+ return this._addCheck({
29879
+ kind: "jwt",
29880
+ ...errorUtil.errToObj(options)
29881
+ });
29882
+ }
29883
+ ip(options) {
29884
+ return this._addCheck({
29885
+ kind: "ip",
29886
+ ...errorUtil.errToObj(options)
29887
+ });
29888
+ }
29889
+ cidr(options) {
29890
+ return this._addCheck({
29891
+ kind: "cidr",
29892
+ ...errorUtil.errToObj(options)
29893
+ });
29894
+ }
29895
+ datetime(options) {
29896
+ if (typeof options === "string") {
29897
+ return this._addCheck({
29898
+ kind: "datetime",
29899
+ precision: null,
29900
+ offset: false,
29901
+ local: false,
29902
+ message: options
29903
+ });
29904
+ }
29905
+ return this._addCheck({
29906
+ kind: "datetime",
29907
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
29908
+ offset: options?.offset ?? false,
29909
+ local: options?.local ?? false,
29910
+ ...errorUtil.errToObj(options?.message)
29911
+ });
29912
+ }
29913
+ date(message) {
29914
+ return this._addCheck({
29915
+ kind: "date",
29916
+ message
29917
+ });
29918
+ }
29919
+ time(options) {
29920
+ if (typeof options === "string") {
29921
+ return this._addCheck({
29922
+ kind: "time",
29923
+ precision: null,
29924
+ message: options
29925
+ });
29926
+ }
29927
+ return this._addCheck({
29928
+ kind: "time",
29929
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
29930
+ ...errorUtil.errToObj(options?.message)
29931
+ });
29932
+ }
29933
+ duration(message) {
29934
+ return this._addCheck({
29935
+ kind: "duration",
29936
+ ...errorUtil.errToObj(message)
29937
+ });
29938
+ }
29939
+ regex(regex, message) {
29940
+ return this._addCheck({
29941
+ kind: "regex",
29942
+ regex,
29943
+ ...errorUtil.errToObj(message)
29944
+ });
29945
+ }
29946
+ includes(value, options) {
29947
+ return this._addCheck({
29948
+ kind: "includes",
29949
+ value,
29950
+ position: options?.position,
29951
+ ...errorUtil.errToObj(options?.message)
29952
+ });
29953
+ }
29954
+ startsWith(value, message) {
29955
+ return this._addCheck({
29956
+ kind: "startsWith",
29957
+ value,
29958
+ ...errorUtil.errToObj(message)
29959
+ });
29960
+ }
29961
+ endsWith(value, message) {
29962
+ return this._addCheck({
29963
+ kind: "endsWith",
29964
+ value,
29965
+ ...errorUtil.errToObj(message)
29966
+ });
29967
+ }
29968
+ min(minLength, message) {
29969
+ return this._addCheck({
29970
+ kind: "min",
29971
+ value: minLength,
29972
+ ...errorUtil.errToObj(message)
29973
+ });
29974
+ }
29975
+ max(maxLength, message) {
29976
+ return this._addCheck({
29977
+ kind: "max",
29978
+ value: maxLength,
29979
+ ...errorUtil.errToObj(message)
29980
+ });
29981
+ }
29982
+ length(len, message) {
29983
+ return this._addCheck({
29984
+ kind: "length",
29985
+ value: len,
29986
+ ...errorUtil.errToObj(message)
29987
+ });
29988
+ }
29989
+ /**
29990
+ * Equivalent to `.min(1)`
29991
+ */
29992
+ nonempty(message) {
29993
+ return this.min(1, errorUtil.errToObj(message));
29994
+ }
29995
+ trim() {
29996
+ return new _ZodString({
29997
+ ...this._def,
29998
+ checks: [
29999
+ ...this._def.checks,
30000
+ {
30001
+ kind: "trim"
30002
+ }
30003
+ ]
30004
+ });
30005
+ }
30006
+ toLowerCase() {
30007
+ return new _ZodString({
30008
+ ...this._def,
30009
+ checks: [
30010
+ ...this._def.checks,
30011
+ {
30012
+ kind: "toLowerCase"
30013
+ }
30014
+ ]
30015
+ });
30016
+ }
30017
+ toUpperCase() {
30018
+ return new _ZodString({
30019
+ ...this._def,
30020
+ checks: [
30021
+ ...this._def.checks,
30022
+ {
30023
+ kind: "toUpperCase"
30024
+ }
30025
+ ]
30026
+ });
30027
+ }
30028
+ get isDatetime() {
30029
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
30030
+ }
30031
+ get isDate() {
30032
+ return !!this._def.checks.find((ch) => ch.kind === "date");
30033
+ }
30034
+ get isTime() {
30035
+ return !!this._def.checks.find((ch) => ch.kind === "time");
30036
+ }
30037
+ get isDuration() {
30038
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
30039
+ }
30040
+ get isEmail() {
30041
+ return !!this._def.checks.find((ch) => ch.kind === "email");
30042
+ }
30043
+ get isURL() {
30044
+ return !!this._def.checks.find((ch) => ch.kind === "url");
30045
+ }
30046
+ get isEmoji() {
30047
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
30048
+ }
30049
+ get isUUID() {
30050
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
30051
+ }
30052
+ get isNANOID() {
30053
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
30054
+ }
30055
+ get isCUID() {
30056
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
30057
+ }
30058
+ get isCUID2() {
30059
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
30060
+ }
30061
+ get isULID() {
30062
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
30063
+ }
30064
+ get isIP() {
30065
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
30066
+ }
30067
+ get isCIDR() {
30068
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
30069
+ }
30070
+ get isBase64() {
30071
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
30072
+ }
30073
+ get isBase64url() {
30074
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
30075
+ }
30076
+ get minLength() {
30077
+ let min = null;
30078
+ for (const ch of this._def.checks) {
30079
+ if (ch.kind === "min") {
30080
+ if (min === null || ch.value > min) min = ch.value;
30081
+ }
30082
+ }
30083
+ return min;
30084
+ }
30085
+ get maxLength() {
30086
+ let max = null;
30087
+ for (const ch of this._def.checks) {
30088
+ if (ch.kind === "max") {
30089
+ if (max === null || ch.value < max) max = ch.value;
30090
+ }
30091
+ }
30092
+ return max;
30093
+ }
30094
+ };
30095
+ ZodString.create = (params) => {
30096
+ return new ZodString({
30097
+ checks: [],
30098
+ typeName: ZodFirstPartyTypeKind.ZodString,
30099
+ coerce: params?.coerce ?? false,
30100
+ ...processCreateParams(params)
30101
+ });
30102
+ };
30103
+ function floatSafeRemainder(val, step) {
30104
+ const valDecCount = (val.toString().split(".")[1] || "").length;
30105
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
30106
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
30107
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
30108
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
30109
+ return valInt % stepInt / 10 ** decCount;
30110
+ }
30111
+ __name(floatSafeRemainder, "floatSafeRemainder");
30112
+ var ZodNumber = class _ZodNumber extends ZodType {
30113
+ static {
30114
+ __name(this, "ZodNumber");
30115
+ }
30116
+ constructor() {
30117
+ super(...arguments);
30118
+ this.min = this.gte;
30119
+ this.max = this.lte;
30120
+ this.step = this.multipleOf;
30121
+ }
30122
+ _parse(input) {
30123
+ if (this._def.coerce) {
30124
+ input.data = Number(input.data);
30125
+ }
30126
+ const parsedType = this._getType(input);
30127
+ if (parsedType !== ZodParsedType.number) {
30128
+ const ctx2 = this._getOrReturnCtx(input);
30129
+ addIssueToContext(ctx2, {
30130
+ code: ZodIssueCode.invalid_type,
30131
+ expected: ZodParsedType.number,
30132
+ received: ctx2.parsedType
30133
+ });
30134
+ return INVALID;
30135
+ }
30136
+ let ctx = void 0;
30137
+ const status = new ParseStatus();
30138
+ for (const check of this._def.checks) {
30139
+ if (check.kind === "int") {
30140
+ if (!util.isInteger(input.data)) {
30141
+ ctx = this._getOrReturnCtx(input, ctx);
30142
+ addIssueToContext(ctx, {
30143
+ code: ZodIssueCode.invalid_type,
30144
+ expected: "integer",
30145
+ received: "float",
30146
+ message: check.message
30147
+ });
30148
+ status.dirty();
30149
+ }
30150
+ } else if (check.kind === "min") {
30151
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
30152
+ if (tooSmall) {
30153
+ ctx = this._getOrReturnCtx(input, ctx);
30154
+ addIssueToContext(ctx, {
30155
+ code: ZodIssueCode.too_small,
30156
+ minimum: check.value,
30157
+ type: "number",
30158
+ inclusive: check.inclusive,
30159
+ exact: false,
30160
+ message: check.message
30161
+ });
30162
+ status.dirty();
30163
+ }
30164
+ } else if (check.kind === "max") {
30165
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
30166
+ if (tooBig) {
30167
+ ctx = this._getOrReturnCtx(input, ctx);
30168
+ addIssueToContext(ctx, {
30169
+ code: ZodIssueCode.too_big,
30170
+ maximum: check.value,
30171
+ type: "number",
30172
+ inclusive: check.inclusive,
30173
+ exact: false,
30174
+ message: check.message
30175
+ });
30176
+ status.dirty();
30177
+ }
30178
+ } else if (check.kind === "multipleOf") {
30179
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
30180
+ ctx = this._getOrReturnCtx(input, ctx);
30181
+ addIssueToContext(ctx, {
30182
+ code: ZodIssueCode.not_multiple_of,
30183
+ multipleOf: check.value,
30184
+ message: check.message
30185
+ });
30186
+ status.dirty();
30187
+ }
30188
+ } else if (check.kind === "finite") {
30189
+ if (!Number.isFinite(input.data)) {
30190
+ ctx = this._getOrReturnCtx(input, ctx);
30191
+ addIssueToContext(ctx, {
30192
+ code: ZodIssueCode.not_finite,
30193
+ message: check.message
30194
+ });
30195
+ status.dirty();
30196
+ }
30197
+ } else {
30198
+ util.assertNever(check);
30199
+ }
30200
+ }
30201
+ return {
30202
+ status: status.value,
30203
+ value: input.data
30204
+ };
30205
+ }
30206
+ gte(value, message) {
30207
+ return this.setLimit("min", value, true, errorUtil.toString(message));
30208
+ }
30209
+ gt(value, message) {
30210
+ return this.setLimit("min", value, false, errorUtil.toString(message));
30211
+ }
30212
+ lte(value, message) {
30213
+ return this.setLimit("max", value, true, errorUtil.toString(message));
30214
+ }
30215
+ lt(value, message) {
30216
+ return this.setLimit("max", value, false, errorUtil.toString(message));
30217
+ }
30218
+ setLimit(kind, value, inclusive, message) {
30219
+ return new _ZodNumber({
30220
+ ...this._def,
30221
+ checks: [
30222
+ ...this._def.checks,
30223
+ {
30224
+ kind,
30225
+ value,
30226
+ inclusive,
30227
+ message: errorUtil.toString(message)
30228
+ }
30229
+ ]
30230
+ });
30231
+ }
30232
+ _addCheck(check) {
30233
+ return new _ZodNumber({
30234
+ ...this._def,
30235
+ checks: [
30236
+ ...this._def.checks,
30237
+ check
30238
+ ]
30239
+ });
30240
+ }
30241
+ int(message) {
30242
+ return this._addCheck({
30243
+ kind: "int",
30244
+ message: errorUtil.toString(message)
30245
+ });
30246
+ }
30247
+ positive(message) {
30248
+ return this._addCheck({
30249
+ kind: "min",
30250
+ value: 0,
30251
+ inclusive: false,
30252
+ message: errorUtil.toString(message)
30253
+ });
30254
+ }
30255
+ negative(message) {
30256
+ return this._addCheck({
30257
+ kind: "max",
30258
+ value: 0,
30259
+ inclusive: false,
30260
+ message: errorUtil.toString(message)
30261
+ });
30262
+ }
30263
+ nonpositive(message) {
30264
+ return this._addCheck({
30265
+ kind: "max",
30266
+ value: 0,
30267
+ inclusive: true,
30268
+ message: errorUtil.toString(message)
30269
+ });
30270
+ }
30271
+ nonnegative(message) {
30272
+ return this._addCheck({
30273
+ kind: "min",
30274
+ value: 0,
30275
+ inclusive: true,
30276
+ message: errorUtil.toString(message)
30277
+ });
30278
+ }
30279
+ multipleOf(value, message) {
30280
+ return this._addCheck({
30281
+ kind: "multipleOf",
30282
+ value,
30283
+ message: errorUtil.toString(message)
30284
+ });
30285
+ }
30286
+ finite(message) {
30287
+ return this._addCheck({
30288
+ kind: "finite",
30289
+ message: errorUtil.toString(message)
30290
+ });
30291
+ }
30292
+ safe(message) {
30293
+ return this._addCheck({
30294
+ kind: "min",
30295
+ inclusive: true,
30296
+ value: Number.MIN_SAFE_INTEGER,
30297
+ message: errorUtil.toString(message)
30298
+ })._addCheck({
30299
+ kind: "max",
30300
+ inclusive: true,
30301
+ value: Number.MAX_SAFE_INTEGER,
30302
+ message: errorUtil.toString(message)
30303
+ });
30304
+ }
30305
+ get minValue() {
30306
+ let min = null;
30307
+ for (const ch of this._def.checks) {
30308
+ if (ch.kind === "min") {
30309
+ if (min === null || ch.value > min) min = ch.value;
30310
+ }
30311
+ }
30312
+ return min;
30313
+ }
30314
+ get maxValue() {
30315
+ let max = null;
30316
+ for (const ch of this._def.checks) {
30317
+ if (ch.kind === "max") {
30318
+ if (max === null || ch.value < max) max = ch.value;
30319
+ }
30320
+ }
30321
+ return max;
30322
+ }
30323
+ get isInt() {
30324
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
30325
+ }
30326
+ get isFinite() {
30327
+ let max = null;
30328
+ let min = null;
30329
+ for (const ch of this._def.checks) {
30330
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
30331
+ return true;
30332
+ } else if (ch.kind === "min") {
30333
+ if (min === null || ch.value > min) min = ch.value;
30334
+ } else if (ch.kind === "max") {
30335
+ if (max === null || ch.value < max) max = ch.value;
30336
+ }
30337
+ }
30338
+ return Number.isFinite(min) && Number.isFinite(max);
30339
+ }
30340
+ };
30341
+ ZodNumber.create = (params) => {
30342
+ return new ZodNumber({
30343
+ checks: [],
30344
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
30345
+ coerce: params?.coerce || false,
30346
+ ...processCreateParams(params)
30347
+ });
30348
+ };
30349
+ var ZodBigInt = class _ZodBigInt extends ZodType {
30350
+ static {
30351
+ __name(this, "ZodBigInt");
30352
+ }
30353
+ constructor() {
30354
+ super(...arguments);
30355
+ this.min = this.gte;
30356
+ this.max = this.lte;
30357
+ }
30358
+ _parse(input) {
30359
+ if (this._def.coerce) {
30360
+ try {
30361
+ input.data = BigInt(input.data);
30362
+ } catch {
30363
+ return this._getInvalidInput(input);
30364
+ }
30365
+ }
30366
+ const parsedType = this._getType(input);
30367
+ if (parsedType !== ZodParsedType.bigint) {
30368
+ return this._getInvalidInput(input);
30369
+ }
30370
+ let ctx = void 0;
30371
+ const status = new ParseStatus();
30372
+ for (const check of this._def.checks) {
30373
+ if (check.kind === "min") {
30374
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
30375
+ if (tooSmall) {
30376
+ ctx = this._getOrReturnCtx(input, ctx);
30377
+ addIssueToContext(ctx, {
30378
+ code: ZodIssueCode.too_small,
30379
+ type: "bigint",
30380
+ minimum: check.value,
30381
+ inclusive: check.inclusive,
30382
+ message: check.message
30383
+ });
30384
+ status.dirty();
30385
+ }
30386
+ } else if (check.kind === "max") {
30387
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
30388
+ if (tooBig) {
30389
+ ctx = this._getOrReturnCtx(input, ctx);
30390
+ addIssueToContext(ctx, {
30391
+ code: ZodIssueCode.too_big,
30392
+ type: "bigint",
30393
+ maximum: check.value,
30394
+ inclusive: check.inclusive,
30395
+ message: check.message
30396
+ });
30397
+ status.dirty();
30398
+ }
30399
+ } else if (check.kind === "multipleOf") {
30400
+ if (input.data % check.value !== BigInt(0)) {
30401
+ ctx = this._getOrReturnCtx(input, ctx);
30402
+ addIssueToContext(ctx, {
30403
+ code: ZodIssueCode.not_multiple_of,
30404
+ multipleOf: check.value,
30405
+ message: check.message
30406
+ });
30407
+ status.dirty();
30408
+ }
30409
+ } else {
30410
+ util.assertNever(check);
30411
+ }
30412
+ }
30413
+ return {
30414
+ status: status.value,
30415
+ value: input.data
30416
+ };
30417
+ }
30418
+ _getInvalidInput(input) {
30419
+ const ctx = this._getOrReturnCtx(input);
30420
+ addIssueToContext(ctx, {
30421
+ code: ZodIssueCode.invalid_type,
30422
+ expected: ZodParsedType.bigint,
30423
+ received: ctx.parsedType
30424
+ });
30425
+ return INVALID;
30426
+ }
30427
+ gte(value, message) {
30428
+ return this.setLimit("min", value, true, errorUtil.toString(message));
30429
+ }
30430
+ gt(value, message) {
30431
+ return this.setLimit("min", value, false, errorUtil.toString(message));
30432
+ }
30433
+ lte(value, message) {
30434
+ return this.setLimit("max", value, true, errorUtil.toString(message));
30435
+ }
30436
+ lt(value, message) {
30437
+ return this.setLimit("max", value, false, errorUtil.toString(message));
30438
+ }
30439
+ setLimit(kind, value, inclusive, message) {
30440
+ return new _ZodBigInt({
30441
+ ...this._def,
30442
+ checks: [
30443
+ ...this._def.checks,
30444
+ {
30445
+ kind,
30446
+ value,
30447
+ inclusive,
30448
+ message: errorUtil.toString(message)
30449
+ }
30450
+ ]
30451
+ });
30452
+ }
30453
+ _addCheck(check) {
30454
+ return new _ZodBigInt({
30455
+ ...this._def,
30456
+ checks: [
30457
+ ...this._def.checks,
30458
+ check
30459
+ ]
30460
+ });
30461
+ }
30462
+ positive(message) {
30463
+ return this._addCheck({
30464
+ kind: "min",
30465
+ value: BigInt(0),
30466
+ inclusive: false,
30467
+ message: errorUtil.toString(message)
30468
+ });
30469
+ }
30470
+ negative(message) {
30471
+ return this._addCheck({
30472
+ kind: "max",
30473
+ value: BigInt(0),
30474
+ inclusive: false,
30475
+ message: errorUtil.toString(message)
30476
+ });
30477
+ }
30478
+ nonpositive(message) {
30479
+ return this._addCheck({
30480
+ kind: "max",
30481
+ value: BigInt(0),
30482
+ inclusive: true,
30483
+ message: errorUtil.toString(message)
30484
+ });
30485
+ }
30486
+ nonnegative(message) {
30487
+ return this._addCheck({
30488
+ kind: "min",
30489
+ value: BigInt(0),
30490
+ inclusive: true,
30491
+ message: errorUtil.toString(message)
30492
+ });
30493
+ }
30494
+ multipleOf(value, message) {
30495
+ return this._addCheck({
30496
+ kind: "multipleOf",
30497
+ value,
30498
+ message: errorUtil.toString(message)
30499
+ });
30500
+ }
30501
+ get minValue() {
30502
+ let min = null;
30503
+ for (const ch of this._def.checks) {
30504
+ if (ch.kind === "min") {
30505
+ if (min === null || ch.value > min) min = ch.value;
30506
+ }
30507
+ }
30508
+ return min;
30509
+ }
30510
+ get maxValue() {
30511
+ let max = null;
30512
+ for (const ch of this._def.checks) {
30513
+ if (ch.kind === "max") {
30514
+ if (max === null || ch.value < max) max = ch.value;
30515
+ }
30516
+ }
30517
+ return max;
30518
+ }
30519
+ };
30520
+ ZodBigInt.create = (params) => {
30521
+ return new ZodBigInt({
30522
+ checks: [],
30523
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
30524
+ coerce: params?.coerce ?? false,
30525
+ ...processCreateParams(params)
30526
+ });
30527
+ };
30528
+ var ZodBoolean = class extends ZodType {
30529
+ static {
30530
+ __name(this, "ZodBoolean");
30531
+ }
30532
+ _parse(input) {
30533
+ if (this._def.coerce) {
30534
+ input.data = Boolean(input.data);
30535
+ }
30536
+ const parsedType = this._getType(input);
30537
+ if (parsedType !== ZodParsedType.boolean) {
30538
+ const ctx = this._getOrReturnCtx(input);
30539
+ addIssueToContext(ctx, {
30540
+ code: ZodIssueCode.invalid_type,
30541
+ expected: ZodParsedType.boolean,
30542
+ received: ctx.parsedType
30543
+ });
30544
+ return INVALID;
30545
+ }
30546
+ return OK(input.data);
30547
+ }
30548
+ };
30549
+ ZodBoolean.create = (params) => {
30550
+ return new ZodBoolean({
30551
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
30552
+ coerce: params?.coerce || false,
30553
+ ...processCreateParams(params)
30554
+ });
30555
+ };
30556
+ var ZodDate = class _ZodDate extends ZodType {
30557
+ static {
30558
+ __name(this, "ZodDate");
30559
+ }
30560
+ _parse(input) {
30561
+ if (this._def.coerce) {
30562
+ input.data = new Date(input.data);
30563
+ }
30564
+ const parsedType = this._getType(input);
30565
+ if (parsedType !== ZodParsedType.date) {
30566
+ const ctx2 = this._getOrReturnCtx(input);
30567
+ addIssueToContext(ctx2, {
30568
+ code: ZodIssueCode.invalid_type,
30569
+ expected: ZodParsedType.date,
30570
+ received: ctx2.parsedType
30571
+ });
30572
+ return INVALID;
30573
+ }
30574
+ if (Number.isNaN(input.data.getTime())) {
30575
+ const ctx2 = this._getOrReturnCtx(input);
30576
+ addIssueToContext(ctx2, {
30577
+ code: ZodIssueCode.invalid_date
30578
+ });
30579
+ return INVALID;
30580
+ }
30581
+ const status = new ParseStatus();
30582
+ let ctx = void 0;
30583
+ for (const check of this._def.checks) {
30584
+ if (check.kind === "min") {
30585
+ if (input.data.getTime() < check.value) {
30586
+ ctx = this._getOrReturnCtx(input, ctx);
30587
+ addIssueToContext(ctx, {
30588
+ code: ZodIssueCode.too_small,
30589
+ message: check.message,
30590
+ inclusive: true,
30591
+ exact: false,
30592
+ minimum: check.value,
30593
+ type: "date"
30594
+ });
30595
+ status.dirty();
30596
+ }
30597
+ } else if (check.kind === "max") {
30598
+ if (input.data.getTime() > check.value) {
30599
+ ctx = this._getOrReturnCtx(input, ctx);
30600
+ addIssueToContext(ctx, {
30601
+ code: ZodIssueCode.too_big,
30602
+ message: check.message,
30603
+ inclusive: true,
30604
+ exact: false,
30605
+ maximum: check.value,
30606
+ type: "date"
30607
+ });
30608
+ status.dirty();
30609
+ }
30610
+ } else {
30611
+ util.assertNever(check);
30612
+ }
30613
+ }
30614
+ return {
30615
+ status: status.value,
30616
+ value: new Date(input.data.getTime())
30617
+ };
30618
+ }
30619
+ _addCheck(check) {
30620
+ return new _ZodDate({
30621
+ ...this._def,
30622
+ checks: [
30623
+ ...this._def.checks,
30624
+ check
30625
+ ]
30626
+ });
30627
+ }
30628
+ min(minDate, message) {
30629
+ return this._addCheck({
30630
+ kind: "min",
30631
+ value: minDate.getTime(),
30632
+ message: errorUtil.toString(message)
30633
+ });
30634
+ }
30635
+ max(maxDate, message) {
30636
+ return this._addCheck({
30637
+ kind: "max",
30638
+ value: maxDate.getTime(),
30639
+ message: errorUtil.toString(message)
30640
+ });
30641
+ }
30642
+ get minDate() {
30643
+ let min = null;
30644
+ for (const ch of this._def.checks) {
30645
+ if (ch.kind === "min") {
30646
+ if (min === null || ch.value > min) min = ch.value;
30647
+ }
30648
+ }
30649
+ return min != null ? new Date(min) : null;
30650
+ }
30651
+ get maxDate() {
30652
+ let max = null;
30653
+ for (const ch of this._def.checks) {
30654
+ if (ch.kind === "max") {
30655
+ if (max === null || ch.value < max) max = ch.value;
30656
+ }
30657
+ }
30658
+ return max != null ? new Date(max) : null;
30659
+ }
30660
+ };
30661
+ ZodDate.create = (params) => {
30662
+ return new ZodDate({
30663
+ checks: [],
30664
+ coerce: params?.coerce || false,
30665
+ typeName: ZodFirstPartyTypeKind.ZodDate,
30666
+ ...processCreateParams(params)
30667
+ });
30668
+ };
30669
+ var ZodSymbol = class extends ZodType {
30670
+ static {
30671
+ __name(this, "ZodSymbol");
30672
+ }
30673
+ _parse(input) {
30674
+ const parsedType = this._getType(input);
30675
+ if (parsedType !== ZodParsedType.symbol) {
30676
+ const ctx = this._getOrReturnCtx(input);
30677
+ addIssueToContext(ctx, {
30678
+ code: ZodIssueCode.invalid_type,
30679
+ expected: ZodParsedType.symbol,
30680
+ received: ctx.parsedType
30681
+ });
30682
+ return INVALID;
30683
+ }
30684
+ return OK(input.data);
30685
+ }
30686
+ };
30687
+ ZodSymbol.create = (params) => {
30688
+ return new ZodSymbol({
30689
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
30690
+ ...processCreateParams(params)
30691
+ });
30692
+ };
30693
+ var ZodUndefined = class extends ZodType {
30694
+ static {
30695
+ __name(this, "ZodUndefined");
30696
+ }
30697
+ _parse(input) {
30698
+ const parsedType = this._getType(input);
30699
+ if (parsedType !== ZodParsedType.undefined) {
30700
+ const ctx = this._getOrReturnCtx(input);
30701
+ addIssueToContext(ctx, {
30702
+ code: ZodIssueCode.invalid_type,
30703
+ expected: ZodParsedType.undefined,
30704
+ received: ctx.parsedType
30705
+ });
30706
+ return INVALID;
30707
+ }
30708
+ return OK(input.data);
30709
+ }
30710
+ };
30711
+ ZodUndefined.create = (params) => {
30712
+ return new ZodUndefined({
30713
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
30714
+ ...processCreateParams(params)
30715
+ });
30716
+ };
30717
+ var ZodNull = class extends ZodType {
30718
+ static {
30719
+ __name(this, "ZodNull");
30720
+ }
30721
+ _parse(input) {
30722
+ const parsedType = this._getType(input);
30723
+ if (parsedType !== ZodParsedType.null) {
30724
+ const ctx = this._getOrReturnCtx(input);
30725
+ addIssueToContext(ctx, {
30726
+ code: ZodIssueCode.invalid_type,
30727
+ expected: ZodParsedType.null,
30728
+ received: ctx.parsedType
30729
+ });
30730
+ return INVALID;
30731
+ }
30732
+ return OK(input.data);
30733
+ }
30734
+ };
30735
+ ZodNull.create = (params) => {
30736
+ return new ZodNull({
30737
+ typeName: ZodFirstPartyTypeKind.ZodNull,
30738
+ ...processCreateParams(params)
30739
+ });
30740
+ };
30741
+ var ZodAny = class extends ZodType {
30742
+ static {
30743
+ __name(this, "ZodAny");
30744
+ }
30745
+ constructor() {
30746
+ super(...arguments);
30747
+ this._any = true;
30748
+ }
30749
+ _parse(input) {
30750
+ return OK(input.data);
30751
+ }
30752
+ };
30753
+ ZodAny.create = (params) => {
30754
+ return new ZodAny({
30755
+ typeName: ZodFirstPartyTypeKind.ZodAny,
30756
+ ...processCreateParams(params)
30757
+ });
30758
+ };
30759
+ var ZodUnknown = class extends ZodType {
30760
+ static {
30761
+ __name(this, "ZodUnknown");
30762
+ }
30763
+ constructor() {
30764
+ super(...arguments);
30765
+ this._unknown = true;
30766
+ }
30767
+ _parse(input) {
30768
+ return OK(input.data);
30769
+ }
30770
+ };
30771
+ ZodUnknown.create = (params) => {
30772
+ return new ZodUnknown({
30773
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
30774
+ ...processCreateParams(params)
30775
+ });
30776
+ };
30777
+ var ZodNever = class extends ZodType {
30778
+ static {
30779
+ __name(this, "ZodNever");
30780
+ }
30781
+ _parse(input) {
30782
+ const ctx = this._getOrReturnCtx(input);
30783
+ addIssueToContext(ctx, {
30784
+ code: ZodIssueCode.invalid_type,
30785
+ expected: ZodParsedType.never,
30786
+ received: ctx.parsedType
30787
+ });
30788
+ return INVALID;
30789
+ }
30790
+ };
30791
+ ZodNever.create = (params) => {
30792
+ return new ZodNever({
30793
+ typeName: ZodFirstPartyTypeKind.ZodNever,
30794
+ ...processCreateParams(params)
30795
+ });
30796
+ };
30797
+ var ZodVoid = class extends ZodType {
30798
+ static {
30799
+ __name(this, "ZodVoid");
30800
+ }
30801
+ _parse(input) {
30802
+ const parsedType = this._getType(input);
30803
+ if (parsedType !== ZodParsedType.undefined) {
30804
+ const ctx = this._getOrReturnCtx(input);
30805
+ addIssueToContext(ctx, {
30806
+ code: ZodIssueCode.invalid_type,
30807
+ expected: ZodParsedType.void,
30808
+ received: ctx.parsedType
30809
+ });
30810
+ return INVALID;
30811
+ }
30812
+ return OK(input.data);
30813
+ }
30814
+ };
30815
+ ZodVoid.create = (params) => {
30816
+ return new ZodVoid({
30817
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
30818
+ ...processCreateParams(params)
30819
+ });
30820
+ };
30821
+ var ZodArray = class _ZodArray extends ZodType {
30822
+ static {
30823
+ __name(this, "ZodArray");
30824
+ }
30825
+ _parse(input) {
30826
+ const { ctx, status } = this._processInputParams(input);
30827
+ const def = this._def;
30828
+ if (ctx.parsedType !== ZodParsedType.array) {
30829
+ addIssueToContext(ctx, {
30830
+ code: ZodIssueCode.invalid_type,
30831
+ expected: ZodParsedType.array,
30832
+ received: ctx.parsedType
30833
+ });
30834
+ return INVALID;
30835
+ }
30836
+ if (def.exactLength !== null) {
30837
+ const tooBig = ctx.data.length > def.exactLength.value;
30838
+ const tooSmall = ctx.data.length < def.exactLength.value;
30839
+ if (tooBig || tooSmall) {
30840
+ addIssueToContext(ctx, {
30841
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
30842
+ minimum: tooSmall ? def.exactLength.value : void 0,
30843
+ maximum: tooBig ? def.exactLength.value : void 0,
30844
+ type: "array",
30845
+ inclusive: true,
30846
+ exact: true,
30847
+ message: def.exactLength.message
30848
+ });
30849
+ status.dirty();
30850
+ }
30851
+ }
30852
+ if (def.minLength !== null) {
30853
+ if (ctx.data.length < def.minLength.value) {
30854
+ addIssueToContext(ctx, {
30855
+ code: ZodIssueCode.too_small,
30856
+ minimum: def.minLength.value,
30857
+ type: "array",
30858
+ inclusive: true,
30859
+ exact: false,
30860
+ message: def.minLength.message
30861
+ });
30862
+ status.dirty();
30863
+ }
30864
+ }
30865
+ if (def.maxLength !== null) {
30866
+ if (ctx.data.length > def.maxLength.value) {
30867
+ addIssueToContext(ctx, {
30868
+ code: ZodIssueCode.too_big,
30869
+ maximum: def.maxLength.value,
30870
+ type: "array",
30871
+ inclusive: true,
30872
+ exact: false,
30873
+ message: def.maxLength.message
30874
+ });
30875
+ status.dirty();
30876
+ }
30877
+ }
30878
+ if (ctx.common.async) {
30879
+ return Promise.all([
30880
+ ...ctx.data
30881
+ ].map((item, i6) => {
30882
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i6));
30883
+ })).then((result2) => {
30884
+ return ParseStatus.mergeArray(status, result2);
30885
+ });
30886
+ }
30887
+ const result = [
30888
+ ...ctx.data
30889
+ ].map((item, i6) => {
30890
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i6));
30891
+ });
30892
+ return ParseStatus.mergeArray(status, result);
30893
+ }
30894
+ get element() {
30895
+ return this._def.type;
30896
+ }
30897
+ min(minLength, message) {
30898
+ return new _ZodArray({
30899
+ ...this._def,
30900
+ minLength: {
30901
+ value: minLength,
30902
+ message: errorUtil.toString(message)
30903
+ }
30904
+ });
30905
+ }
30906
+ max(maxLength, message) {
30907
+ return new _ZodArray({
30908
+ ...this._def,
30909
+ maxLength: {
30910
+ value: maxLength,
30911
+ message: errorUtil.toString(message)
30912
+ }
30913
+ });
30914
+ }
30915
+ length(len, message) {
30916
+ return new _ZodArray({
30917
+ ...this._def,
30918
+ exactLength: {
30919
+ value: len,
30920
+ message: errorUtil.toString(message)
30921
+ }
30922
+ });
30923
+ }
30924
+ nonempty(message) {
30925
+ return this.min(1, message);
30926
+ }
30927
+ };
30928
+ ZodArray.create = (schema, params) => {
30929
+ return new ZodArray({
30930
+ type: schema,
30931
+ minLength: null,
30932
+ maxLength: null,
30933
+ exactLength: null,
30934
+ typeName: ZodFirstPartyTypeKind.ZodArray,
30935
+ ...processCreateParams(params)
30936
+ });
30937
+ };
30938
+ function deepPartialify(schema) {
30939
+ if (schema instanceof ZodObject) {
30940
+ const newShape = {};
30941
+ for (const key in schema.shape) {
30942
+ const fieldSchema = schema.shape[key];
30943
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
30944
+ }
30945
+ return new ZodObject({
30946
+ ...schema._def,
30947
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
30948
+ });
30949
+ } else if (schema instanceof ZodArray) {
30950
+ return new ZodArray({
30951
+ ...schema._def,
30952
+ type: deepPartialify(schema.element)
30953
+ });
30954
+ } else if (schema instanceof ZodOptional) {
30955
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
30956
+ } else if (schema instanceof ZodNullable) {
30957
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
30958
+ } else if (schema instanceof ZodTuple) {
30959
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
30960
+ } else {
30961
+ return schema;
30962
+ }
30963
+ }
30964
+ __name(deepPartialify, "deepPartialify");
30965
+ var ZodObject = class _ZodObject extends ZodType {
30966
+ static {
30967
+ __name(this, "ZodObject");
30968
+ }
30969
+ constructor() {
30970
+ super(...arguments);
30971
+ this._cached = null;
30972
+ this.nonstrict = this.passthrough;
30973
+ this.augment = this.extend;
30974
+ }
30975
+ _getCached() {
30976
+ if (this._cached !== null) return this._cached;
30977
+ const shape = this._def.shape();
30978
+ const keys = util.objectKeys(shape);
30979
+ this._cached = {
30980
+ shape,
30981
+ keys
30982
+ };
30983
+ return this._cached;
30984
+ }
30985
+ _parse(input) {
30986
+ const parsedType = this._getType(input);
30987
+ if (parsedType !== ZodParsedType.object) {
30988
+ const ctx2 = this._getOrReturnCtx(input);
30989
+ addIssueToContext(ctx2, {
30990
+ code: ZodIssueCode.invalid_type,
30991
+ expected: ZodParsedType.object,
30992
+ received: ctx2.parsedType
30993
+ });
30994
+ return INVALID;
30995
+ }
30996
+ const { status, ctx } = this._processInputParams(input);
30997
+ const { shape, keys: shapeKeys } = this._getCached();
30998
+ const extraKeys = [];
30999
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
31000
+ for (const key in ctx.data) {
31001
+ if (!shapeKeys.includes(key)) {
31002
+ extraKeys.push(key);
31003
+ }
31004
+ }
31005
+ }
31006
+ const pairs = [];
31007
+ for (const key of shapeKeys) {
31008
+ const keyValidator = shape[key];
31009
+ const value = ctx.data[key];
31010
+ pairs.push({
31011
+ key: {
31012
+ status: "valid",
31013
+ value: key
31014
+ },
31015
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
31016
+ alwaysSet: key in ctx.data
31017
+ });
31018
+ }
31019
+ if (this._def.catchall instanceof ZodNever) {
31020
+ const unknownKeys = this._def.unknownKeys;
31021
+ if (unknownKeys === "passthrough") {
31022
+ for (const key of extraKeys) {
31023
+ pairs.push({
31024
+ key: {
31025
+ status: "valid",
31026
+ value: key
31027
+ },
31028
+ value: {
31029
+ status: "valid",
31030
+ value: ctx.data[key]
31031
+ }
31032
+ });
31033
+ }
31034
+ } else if (unknownKeys === "strict") {
31035
+ if (extraKeys.length > 0) {
31036
+ addIssueToContext(ctx, {
31037
+ code: ZodIssueCode.unrecognized_keys,
31038
+ keys: extraKeys
31039
+ });
31040
+ status.dirty();
31041
+ }
31042
+ } else if (unknownKeys === "strip") {
31043
+ } else {
31044
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
31045
+ }
31046
+ } else {
31047
+ const catchall = this._def.catchall;
31048
+ for (const key of extraKeys) {
31049
+ const value = ctx.data[key];
31050
+ pairs.push({
31051
+ key: {
31052
+ status: "valid",
31053
+ value: key
31054
+ },
31055
+ value: catchall._parse(
31056
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
31057
+ //, ctx.child(key), value, getParsedType(value)
31058
+ ),
31059
+ alwaysSet: key in ctx.data
31060
+ });
31061
+ }
31062
+ }
31063
+ if (ctx.common.async) {
31064
+ return Promise.resolve().then(async () => {
31065
+ const syncPairs = [];
31066
+ for (const pair of pairs) {
31067
+ const key = await pair.key;
31068
+ const value = await pair.value;
31069
+ syncPairs.push({
31070
+ key,
31071
+ value,
31072
+ alwaysSet: pair.alwaysSet
31073
+ });
31074
+ }
31075
+ return syncPairs;
31076
+ }).then((syncPairs) => {
31077
+ return ParseStatus.mergeObjectSync(status, syncPairs);
31078
+ });
31079
+ } else {
31080
+ return ParseStatus.mergeObjectSync(status, pairs);
31081
+ }
31082
+ }
31083
+ get shape() {
31084
+ return this._def.shape();
31085
+ }
31086
+ strict(message) {
31087
+ errorUtil.errToObj;
31088
+ return new _ZodObject({
31089
+ ...this._def,
31090
+ unknownKeys: "strict",
31091
+ ...message !== void 0 ? {
31092
+ errorMap: /* @__PURE__ */ __name((issue, ctx) => {
31093
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
31094
+ if (issue.code === "unrecognized_keys") return {
31095
+ message: errorUtil.errToObj(message).message ?? defaultError
31096
+ };
31097
+ return {
31098
+ message: defaultError
31099
+ };
31100
+ }, "errorMap")
31101
+ } : {}
31102
+ });
31103
+ }
31104
+ strip() {
31105
+ return new _ZodObject({
31106
+ ...this._def,
31107
+ unknownKeys: "strip"
31108
+ });
31109
+ }
31110
+ passthrough() {
31111
+ return new _ZodObject({
31112
+ ...this._def,
31113
+ unknownKeys: "passthrough"
31114
+ });
31115
+ }
31116
+ // const AugmentFactory =
31117
+ // <Def extends ZodObjectDef>(def: Def) =>
31118
+ // <Augmentation extends ZodRawShape>(
31119
+ // augmentation: Augmentation
31120
+ // ): ZodObject<
31121
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
31122
+ // Def["unknownKeys"],
31123
+ // Def["catchall"]
31124
+ // > => {
31125
+ // return new ZodObject({
31126
+ // ...def,
31127
+ // shape: () => ({
31128
+ // ...def.shape(),
31129
+ // ...augmentation,
31130
+ // }),
31131
+ // }) as any;
31132
+ // };
31133
+ extend(augmentation) {
31134
+ return new _ZodObject({
31135
+ ...this._def,
31136
+ shape: /* @__PURE__ */ __name(() => ({
31137
+ ...this._def.shape(),
31138
+ ...augmentation
31139
+ }), "shape")
31140
+ });
31141
+ }
31142
+ /**
31143
+ * Prior to zod@1.0.12 there was a bug in the
31144
+ * inferred type of merged objects. Please
31145
+ * upgrade if you are experiencing issues.
31146
+ */
31147
+ merge(merging) {
31148
+ const merged = new _ZodObject({
31149
+ unknownKeys: merging._def.unknownKeys,
31150
+ catchall: merging._def.catchall,
31151
+ shape: /* @__PURE__ */ __name(() => ({
31152
+ ...this._def.shape(),
31153
+ ...merging._def.shape()
31154
+ }), "shape"),
31155
+ typeName: ZodFirstPartyTypeKind.ZodObject
31156
+ });
31157
+ return merged;
31158
+ }
31159
+ // merge<
31160
+ // Incoming extends AnyZodObject,
31161
+ // Augmentation extends Incoming["shape"],
31162
+ // NewOutput extends {
31163
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
31164
+ // ? Augmentation[k]["_output"]
31165
+ // : k extends keyof Output
31166
+ // ? Output[k]
31167
+ // : never;
31168
+ // },
31169
+ // NewInput extends {
31170
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
31171
+ // ? Augmentation[k]["_input"]
31172
+ // : k extends keyof Input
31173
+ // ? Input[k]
31174
+ // : never;
31175
+ // }
31176
+ // >(
31177
+ // merging: Incoming
31178
+ // ): ZodObject<
31179
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
31180
+ // Incoming["_def"]["unknownKeys"],
31181
+ // Incoming["_def"]["catchall"],
31182
+ // NewOutput,
31183
+ // NewInput
31184
+ // > {
31185
+ // const merged: any = new ZodObject({
31186
+ // unknownKeys: merging._def.unknownKeys,
31187
+ // catchall: merging._def.catchall,
31188
+ // shape: () =>
31189
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
31190
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
31191
+ // }) as any;
31192
+ // return merged;
31193
+ // }
31194
+ setKey(key, schema) {
31195
+ return this.augment({
31196
+ [key]: schema
31197
+ });
31198
+ }
31199
+ // merge<Incoming extends AnyZodObject>(
31200
+ // merging: Incoming
31201
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
31202
+ // ZodObject<
31203
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
31204
+ // Incoming["_def"]["unknownKeys"],
31205
+ // Incoming["_def"]["catchall"]
31206
+ // > {
31207
+ // // const mergedShape = objectUtil.mergeShapes(
31208
+ // // this._def.shape(),
31209
+ // // merging._def.shape()
31210
+ // // );
31211
+ // const merged: any = new ZodObject({
31212
+ // unknownKeys: merging._def.unknownKeys,
31213
+ // catchall: merging._def.catchall,
31214
+ // shape: () =>
31215
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
31216
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
31217
+ // }) as any;
31218
+ // return merged;
31219
+ // }
31220
+ catchall(index) {
31221
+ return new _ZodObject({
31222
+ ...this._def,
31223
+ catchall: index
31224
+ });
31225
+ }
31226
+ pick(mask) {
31227
+ const shape = {};
31228
+ for (const key of util.objectKeys(mask)) {
31229
+ if (mask[key] && this.shape[key]) {
31230
+ shape[key] = this.shape[key];
31231
+ }
31232
+ }
31233
+ return new _ZodObject({
31234
+ ...this._def,
31235
+ shape: /* @__PURE__ */ __name(() => shape, "shape")
31236
+ });
31237
+ }
31238
+ omit(mask) {
31239
+ const shape = {};
31240
+ for (const key of util.objectKeys(this.shape)) {
31241
+ if (!mask[key]) {
31242
+ shape[key] = this.shape[key];
31243
+ }
31244
+ }
31245
+ return new _ZodObject({
31246
+ ...this._def,
31247
+ shape: /* @__PURE__ */ __name(() => shape, "shape")
31248
+ });
31249
+ }
31250
+ /**
31251
+ * @deprecated
31252
+ */
31253
+ deepPartial() {
31254
+ return deepPartialify(this);
31255
+ }
31256
+ partial(mask) {
31257
+ const newShape = {};
31258
+ for (const key of util.objectKeys(this.shape)) {
31259
+ const fieldSchema = this.shape[key];
31260
+ if (mask && !mask[key]) {
31261
+ newShape[key] = fieldSchema;
31262
+ } else {
31263
+ newShape[key] = fieldSchema.optional();
31264
+ }
31265
+ }
31266
+ return new _ZodObject({
31267
+ ...this._def,
31268
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
31269
+ });
31270
+ }
31271
+ required(mask) {
31272
+ const newShape = {};
31273
+ for (const key of util.objectKeys(this.shape)) {
31274
+ if (mask && !mask[key]) {
31275
+ newShape[key] = this.shape[key];
31276
+ } else {
31277
+ const fieldSchema = this.shape[key];
31278
+ let newField = fieldSchema;
31279
+ while (newField instanceof ZodOptional) {
31280
+ newField = newField._def.innerType;
31281
+ }
31282
+ newShape[key] = newField;
31283
+ }
31284
+ }
31285
+ return new _ZodObject({
31286
+ ...this._def,
31287
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
31288
+ });
31289
+ }
31290
+ keyof() {
31291
+ return createZodEnum(util.objectKeys(this.shape));
31292
+ }
31293
+ };
31294
+ ZodObject.create = (shape, params) => {
31295
+ return new ZodObject({
31296
+ shape: /* @__PURE__ */ __name(() => shape, "shape"),
31297
+ unknownKeys: "strip",
31298
+ catchall: ZodNever.create(),
31299
+ typeName: ZodFirstPartyTypeKind.ZodObject,
31300
+ ...processCreateParams(params)
31301
+ });
31302
+ };
31303
+ ZodObject.strictCreate = (shape, params) => {
31304
+ return new ZodObject({
31305
+ shape: /* @__PURE__ */ __name(() => shape, "shape"),
31306
+ unknownKeys: "strict",
31307
+ catchall: ZodNever.create(),
31308
+ typeName: ZodFirstPartyTypeKind.ZodObject,
31309
+ ...processCreateParams(params)
31310
+ });
31311
+ };
31312
+ ZodObject.lazycreate = (shape, params) => {
31313
+ return new ZodObject({
31314
+ shape,
31315
+ unknownKeys: "strip",
31316
+ catchall: ZodNever.create(),
31317
+ typeName: ZodFirstPartyTypeKind.ZodObject,
31318
+ ...processCreateParams(params)
31319
+ });
31320
+ };
31321
+ var ZodUnion = class extends ZodType {
31322
+ static {
31323
+ __name(this, "ZodUnion");
31324
+ }
31325
+ _parse(input) {
31326
+ const { ctx } = this._processInputParams(input);
31327
+ const options = this._def.options;
31328
+ function handleResults(results) {
31329
+ for (const result of results) {
31330
+ if (result.result.status === "valid") {
31331
+ return result.result;
31332
+ }
31333
+ }
31334
+ for (const result of results) {
31335
+ if (result.result.status === "dirty") {
31336
+ ctx.common.issues.push(...result.ctx.common.issues);
31337
+ return result.result;
31338
+ }
31339
+ }
31340
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
31341
+ addIssueToContext(ctx, {
31342
+ code: ZodIssueCode.invalid_union,
31343
+ unionErrors
31344
+ });
31345
+ return INVALID;
31346
+ }
31347
+ __name(handleResults, "handleResults");
31348
+ if (ctx.common.async) {
31349
+ return Promise.all(options.map(async (option) => {
31350
+ const childCtx = {
31351
+ ...ctx,
31352
+ common: {
31353
+ ...ctx.common,
31354
+ issues: []
31355
+ },
31356
+ parent: null
31357
+ };
31358
+ return {
31359
+ result: await option._parseAsync({
31360
+ data: ctx.data,
31361
+ path: ctx.path,
31362
+ parent: childCtx
31363
+ }),
31364
+ ctx: childCtx
31365
+ };
31366
+ })).then(handleResults);
31367
+ } else {
31368
+ let dirty = void 0;
31369
+ const issues = [];
31370
+ for (const option of options) {
31371
+ const childCtx = {
31372
+ ...ctx,
31373
+ common: {
31374
+ ...ctx.common,
31375
+ issues: []
31376
+ },
31377
+ parent: null
31378
+ };
31379
+ const result = option._parseSync({
31380
+ data: ctx.data,
31381
+ path: ctx.path,
31382
+ parent: childCtx
31383
+ });
31384
+ if (result.status === "valid") {
31385
+ return result;
31386
+ } else if (result.status === "dirty" && !dirty) {
31387
+ dirty = {
31388
+ result,
31389
+ ctx: childCtx
31390
+ };
31391
+ }
31392
+ if (childCtx.common.issues.length) {
31393
+ issues.push(childCtx.common.issues);
31394
+ }
31395
+ }
31396
+ if (dirty) {
31397
+ ctx.common.issues.push(...dirty.ctx.common.issues);
31398
+ return dirty.result;
31399
+ }
31400
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
31401
+ addIssueToContext(ctx, {
31402
+ code: ZodIssueCode.invalid_union,
31403
+ unionErrors
31404
+ });
31405
+ return INVALID;
31406
+ }
31407
+ }
31408
+ get options() {
31409
+ return this._def.options;
31410
+ }
31411
+ };
31412
+ ZodUnion.create = (types, params) => {
31413
+ return new ZodUnion({
31414
+ options: types,
31415
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
31416
+ ...processCreateParams(params)
31417
+ });
31418
+ };
31419
+ var getDiscriminator = /* @__PURE__ */ __name((type) => {
31420
+ if (type instanceof ZodLazy) {
31421
+ return getDiscriminator(type.schema);
31422
+ } else if (type instanceof ZodEffects) {
31423
+ return getDiscriminator(type.innerType());
31424
+ } else if (type instanceof ZodLiteral) {
31425
+ return [
31426
+ type.value
31427
+ ];
31428
+ } else if (type instanceof ZodEnum) {
31429
+ return type.options;
31430
+ } else if (type instanceof ZodNativeEnum) {
31431
+ return util.objectValues(type.enum);
31432
+ } else if (type instanceof ZodDefault) {
31433
+ return getDiscriminator(type._def.innerType);
31434
+ } else if (type instanceof ZodUndefined) {
31435
+ return [
31436
+ void 0
31437
+ ];
31438
+ } else if (type instanceof ZodNull) {
31439
+ return [
31440
+ null
31441
+ ];
31442
+ } else if (type instanceof ZodOptional) {
31443
+ return [
31444
+ void 0,
31445
+ ...getDiscriminator(type.unwrap())
31446
+ ];
31447
+ } else if (type instanceof ZodNullable) {
31448
+ return [
31449
+ null,
31450
+ ...getDiscriminator(type.unwrap())
31451
+ ];
31452
+ } else if (type instanceof ZodBranded) {
31453
+ return getDiscriminator(type.unwrap());
31454
+ } else if (type instanceof ZodReadonly) {
31455
+ return getDiscriminator(type.unwrap());
31456
+ } else if (type instanceof ZodCatch) {
31457
+ return getDiscriminator(type._def.innerType);
31458
+ } else {
31459
+ return [];
31460
+ }
31461
+ }, "getDiscriminator");
31462
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
31463
+ static {
31464
+ __name(this, "ZodDiscriminatedUnion");
31465
+ }
31466
+ _parse(input) {
31467
+ const { ctx } = this._processInputParams(input);
31468
+ if (ctx.parsedType !== ZodParsedType.object) {
31469
+ addIssueToContext(ctx, {
31470
+ code: ZodIssueCode.invalid_type,
31471
+ expected: ZodParsedType.object,
31472
+ received: ctx.parsedType
31473
+ });
31474
+ return INVALID;
31475
+ }
31476
+ const discriminator = this.discriminator;
31477
+ const discriminatorValue = ctx.data[discriminator];
31478
+ const option = this.optionsMap.get(discriminatorValue);
31479
+ if (!option) {
31480
+ addIssueToContext(ctx, {
31481
+ code: ZodIssueCode.invalid_union_discriminator,
31482
+ options: Array.from(this.optionsMap.keys()),
31483
+ path: [
31484
+ discriminator
31485
+ ]
31486
+ });
31487
+ return INVALID;
31488
+ }
31489
+ if (ctx.common.async) {
31490
+ return option._parseAsync({
31491
+ data: ctx.data,
31492
+ path: ctx.path,
31493
+ parent: ctx
31494
+ });
31495
+ } else {
31496
+ return option._parseSync({
31497
+ data: ctx.data,
31498
+ path: ctx.path,
31499
+ parent: ctx
31500
+ });
31501
+ }
31502
+ }
31503
+ get discriminator() {
31504
+ return this._def.discriminator;
31505
+ }
31506
+ get options() {
31507
+ return this._def.options;
31508
+ }
31509
+ get optionsMap() {
31510
+ return this._def.optionsMap;
31511
+ }
31512
+ /**
31513
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
31514
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
31515
+ * have a different value for each object in the union.
31516
+ * @param discriminator the name of the discriminator property
31517
+ * @param types an array of object schemas
31518
+ * @param params
31519
+ */
31520
+ static create(discriminator, options, params) {
31521
+ const optionsMap = /* @__PURE__ */ new Map();
31522
+ for (const type of options) {
31523
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
31524
+ if (!discriminatorValues.length) {
31525
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
31526
+ }
31527
+ for (const value of discriminatorValues) {
31528
+ if (optionsMap.has(value)) {
31529
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
31530
+ }
31531
+ optionsMap.set(value, type);
31532
+ }
31533
+ }
31534
+ return new _ZodDiscriminatedUnion({
31535
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
31536
+ discriminator,
31537
+ options,
31538
+ optionsMap,
31539
+ ...processCreateParams(params)
31540
+ });
31541
+ }
31542
+ };
31543
+ function mergeValues(a6, b6) {
31544
+ const aType = getParsedType(a6);
31545
+ const bType = getParsedType(b6);
31546
+ if (a6 === b6) {
31547
+ return {
31548
+ valid: true,
31549
+ data: a6
31550
+ };
31551
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
31552
+ const bKeys = util.objectKeys(b6);
31553
+ const sharedKeys = util.objectKeys(a6).filter((key) => bKeys.indexOf(key) !== -1);
31554
+ const newObj = {
31555
+ ...a6,
31556
+ ...b6
31557
+ };
31558
+ for (const key of sharedKeys) {
31559
+ const sharedValue = mergeValues(a6[key], b6[key]);
31560
+ if (!sharedValue.valid) {
31561
+ return {
31562
+ valid: false
31563
+ };
31564
+ }
31565
+ newObj[key] = sharedValue.data;
31566
+ }
31567
+ return {
31568
+ valid: true,
31569
+ data: newObj
31570
+ };
31571
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
31572
+ if (a6.length !== b6.length) {
31573
+ return {
31574
+ valid: false
31575
+ };
31576
+ }
31577
+ const newArray = [];
31578
+ for (let index = 0; index < a6.length; index++) {
31579
+ const itemA = a6[index];
31580
+ const itemB = b6[index];
31581
+ const sharedValue = mergeValues(itemA, itemB);
31582
+ if (!sharedValue.valid) {
31583
+ return {
31584
+ valid: false
31585
+ };
31586
+ }
31587
+ newArray.push(sharedValue.data);
31588
+ }
31589
+ return {
31590
+ valid: true,
31591
+ data: newArray
31592
+ };
31593
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a6 === +b6) {
31594
+ return {
31595
+ valid: true,
31596
+ data: a6
31597
+ };
31598
+ } else {
31599
+ return {
31600
+ valid: false
31601
+ };
31602
+ }
31603
+ }
31604
+ __name(mergeValues, "mergeValues");
31605
+ var ZodIntersection = class extends ZodType {
31606
+ static {
31607
+ __name(this, "ZodIntersection");
31608
+ }
31609
+ _parse(input) {
31610
+ const { status, ctx } = this._processInputParams(input);
31611
+ const handleParsed = /* @__PURE__ */ __name((parsedLeft, parsedRight) => {
31612
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
31613
+ return INVALID;
31614
+ }
31615
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
31616
+ if (!merged.valid) {
31617
+ addIssueToContext(ctx, {
31618
+ code: ZodIssueCode.invalid_intersection_types
31619
+ });
31620
+ return INVALID;
31621
+ }
31622
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
31623
+ status.dirty();
31624
+ }
31625
+ return {
31626
+ status: status.value,
31627
+ value: merged.data
31628
+ };
31629
+ }, "handleParsed");
31630
+ if (ctx.common.async) {
31631
+ return Promise.all([
31632
+ this._def.left._parseAsync({
31633
+ data: ctx.data,
31634
+ path: ctx.path,
31635
+ parent: ctx
31636
+ }),
31637
+ this._def.right._parseAsync({
31638
+ data: ctx.data,
31639
+ path: ctx.path,
31640
+ parent: ctx
31641
+ })
31642
+ ]).then(([left, right]) => handleParsed(left, right));
31643
+ } else {
31644
+ return handleParsed(this._def.left._parseSync({
31645
+ data: ctx.data,
31646
+ path: ctx.path,
31647
+ parent: ctx
31648
+ }), this._def.right._parseSync({
31649
+ data: ctx.data,
31650
+ path: ctx.path,
31651
+ parent: ctx
31652
+ }));
31653
+ }
31654
+ }
31655
+ };
31656
+ ZodIntersection.create = (left, right, params) => {
31657
+ return new ZodIntersection({
31658
+ left,
31659
+ right,
31660
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
31661
+ ...processCreateParams(params)
31662
+ });
31663
+ };
31664
+ var ZodTuple = class _ZodTuple extends ZodType {
31665
+ static {
31666
+ __name(this, "ZodTuple");
31667
+ }
31668
+ _parse(input) {
31669
+ const { status, ctx } = this._processInputParams(input);
31670
+ if (ctx.parsedType !== ZodParsedType.array) {
31671
+ addIssueToContext(ctx, {
31672
+ code: ZodIssueCode.invalid_type,
31673
+ expected: ZodParsedType.array,
31674
+ received: ctx.parsedType
31675
+ });
31676
+ return INVALID;
31677
+ }
31678
+ if (ctx.data.length < this._def.items.length) {
31679
+ addIssueToContext(ctx, {
31680
+ code: ZodIssueCode.too_small,
31681
+ minimum: this._def.items.length,
31682
+ inclusive: true,
31683
+ exact: false,
31684
+ type: "array"
31685
+ });
31686
+ return INVALID;
31687
+ }
31688
+ const rest = this._def.rest;
31689
+ if (!rest && ctx.data.length > this._def.items.length) {
31690
+ addIssueToContext(ctx, {
31691
+ code: ZodIssueCode.too_big,
31692
+ maximum: this._def.items.length,
31693
+ inclusive: true,
31694
+ exact: false,
31695
+ type: "array"
31696
+ });
31697
+ status.dirty();
31698
+ }
31699
+ const items = [
31700
+ ...ctx.data
31701
+ ].map((item, itemIndex) => {
31702
+ const schema = this._def.items[itemIndex] || this._def.rest;
31703
+ if (!schema) return null;
31704
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
31705
+ }).filter((x2) => !!x2);
31706
+ if (ctx.common.async) {
31707
+ return Promise.all(items).then((results) => {
31708
+ return ParseStatus.mergeArray(status, results);
31709
+ });
31710
+ } else {
31711
+ return ParseStatus.mergeArray(status, items);
31712
+ }
31713
+ }
31714
+ get items() {
31715
+ return this._def.items;
31716
+ }
31717
+ rest(rest) {
31718
+ return new _ZodTuple({
31719
+ ...this._def,
31720
+ rest
31721
+ });
31722
+ }
31723
+ };
31724
+ ZodTuple.create = (schemas, params) => {
31725
+ if (!Array.isArray(schemas)) {
31726
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
31727
+ }
31728
+ return new ZodTuple({
31729
+ items: schemas,
31730
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
31731
+ rest: null,
31732
+ ...processCreateParams(params)
31733
+ });
31734
+ };
31735
+ var ZodRecord = class _ZodRecord extends ZodType {
31736
+ static {
31737
+ __name(this, "ZodRecord");
31738
+ }
31739
+ get keySchema() {
31740
+ return this._def.keyType;
31741
+ }
31742
+ get valueSchema() {
31743
+ return this._def.valueType;
31744
+ }
31745
+ _parse(input) {
31746
+ const { status, ctx } = this._processInputParams(input);
31747
+ if (ctx.parsedType !== ZodParsedType.object) {
31748
+ addIssueToContext(ctx, {
31749
+ code: ZodIssueCode.invalid_type,
31750
+ expected: ZodParsedType.object,
31751
+ received: ctx.parsedType
31752
+ });
31753
+ return INVALID;
31754
+ }
31755
+ const pairs = [];
31756
+ const keyType = this._def.keyType;
31757
+ const valueType = this._def.valueType;
31758
+ for (const key in ctx.data) {
31759
+ pairs.push({
31760
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
31761
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
31762
+ alwaysSet: key in ctx.data
31763
+ });
31764
+ }
31765
+ if (ctx.common.async) {
31766
+ return ParseStatus.mergeObjectAsync(status, pairs);
31767
+ } else {
31768
+ return ParseStatus.mergeObjectSync(status, pairs);
31769
+ }
31770
+ }
31771
+ get element() {
31772
+ return this._def.valueType;
31773
+ }
31774
+ static create(first, second, third) {
31775
+ if (second instanceof ZodType) {
31776
+ return new _ZodRecord({
31777
+ keyType: first,
31778
+ valueType: second,
31779
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
31780
+ ...processCreateParams(third)
31781
+ });
31782
+ }
31783
+ return new _ZodRecord({
31784
+ keyType: ZodString.create(),
31785
+ valueType: first,
31786
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
31787
+ ...processCreateParams(second)
31788
+ });
31789
+ }
31790
+ };
31791
+ var ZodMap = class extends ZodType {
31792
+ static {
31793
+ __name(this, "ZodMap");
31794
+ }
31795
+ get keySchema() {
31796
+ return this._def.keyType;
31797
+ }
31798
+ get valueSchema() {
31799
+ return this._def.valueType;
31800
+ }
31801
+ _parse(input) {
31802
+ const { status, ctx } = this._processInputParams(input);
31803
+ if (ctx.parsedType !== ZodParsedType.map) {
31804
+ addIssueToContext(ctx, {
31805
+ code: ZodIssueCode.invalid_type,
31806
+ expected: ZodParsedType.map,
31807
+ received: ctx.parsedType
31808
+ });
31809
+ return INVALID;
31810
+ }
31811
+ const keyType = this._def.keyType;
31812
+ const valueType = this._def.valueType;
31813
+ const pairs = [
31814
+ ...ctx.data.entries()
31815
+ ].map(([key, value], index) => {
31816
+ return {
31817
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
31818
+ index,
31819
+ "key"
31820
+ ])),
31821
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [
31822
+ index,
31823
+ "value"
31824
+ ]))
31825
+ };
31826
+ });
31827
+ if (ctx.common.async) {
31828
+ const finalMap = /* @__PURE__ */ new Map();
31829
+ return Promise.resolve().then(async () => {
31830
+ for (const pair of pairs) {
31831
+ const key = await pair.key;
31832
+ const value = await pair.value;
31833
+ if (key.status === "aborted" || value.status === "aborted") {
31834
+ return INVALID;
31835
+ }
31836
+ if (key.status === "dirty" || value.status === "dirty") {
31837
+ status.dirty();
31838
+ }
31839
+ finalMap.set(key.value, value.value);
31840
+ }
31841
+ return {
31842
+ status: status.value,
31843
+ value: finalMap
31844
+ };
31845
+ });
31846
+ } else {
31847
+ const finalMap = /* @__PURE__ */ new Map();
31848
+ for (const pair of pairs) {
31849
+ const key = pair.key;
31850
+ const value = pair.value;
31851
+ if (key.status === "aborted" || value.status === "aborted") {
31852
+ return INVALID;
31853
+ }
31854
+ if (key.status === "dirty" || value.status === "dirty") {
31855
+ status.dirty();
31856
+ }
31857
+ finalMap.set(key.value, value.value);
31858
+ }
31859
+ return {
31860
+ status: status.value,
31861
+ value: finalMap
31862
+ };
31863
+ }
31864
+ }
31865
+ };
31866
+ ZodMap.create = (keyType, valueType, params) => {
31867
+ return new ZodMap({
31868
+ valueType,
31869
+ keyType,
31870
+ typeName: ZodFirstPartyTypeKind.ZodMap,
31871
+ ...processCreateParams(params)
31872
+ });
31873
+ };
31874
+ var ZodSet = class _ZodSet extends ZodType {
31875
+ static {
31876
+ __name(this, "ZodSet");
31877
+ }
31878
+ _parse(input) {
31879
+ const { status, ctx } = this._processInputParams(input);
31880
+ if (ctx.parsedType !== ZodParsedType.set) {
31881
+ addIssueToContext(ctx, {
31882
+ code: ZodIssueCode.invalid_type,
31883
+ expected: ZodParsedType.set,
31884
+ received: ctx.parsedType
31885
+ });
31886
+ return INVALID;
31887
+ }
31888
+ const def = this._def;
31889
+ if (def.minSize !== null) {
31890
+ if (ctx.data.size < def.minSize.value) {
31891
+ addIssueToContext(ctx, {
31892
+ code: ZodIssueCode.too_small,
31893
+ minimum: def.minSize.value,
31894
+ type: "set",
31895
+ inclusive: true,
31896
+ exact: false,
31897
+ message: def.minSize.message
31898
+ });
31899
+ status.dirty();
31900
+ }
31901
+ }
31902
+ if (def.maxSize !== null) {
31903
+ if (ctx.data.size > def.maxSize.value) {
31904
+ addIssueToContext(ctx, {
31905
+ code: ZodIssueCode.too_big,
31906
+ maximum: def.maxSize.value,
31907
+ type: "set",
31908
+ inclusive: true,
31909
+ exact: false,
31910
+ message: def.maxSize.message
31911
+ });
31912
+ status.dirty();
31913
+ }
31914
+ }
31915
+ const valueType = this._def.valueType;
31916
+ function finalizeSet(elements2) {
31917
+ const parsedSet = /* @__PURE__ */ new Set();
31918
+ for (const element of elements2) {
31919
+ if (element.status === "aborted") return INVALID;
31920
+ if (element.status === "dirty") status.dirty();
31921
+ parsedSet.add(element.value);
31922
+ }
31923
+ return {
31924
+ status: status.value,
31925
+ value: parsedSet
31926
+ };
31927
+ }
31928
+ __name(finalizeSet, "finalizeSet");
31929
+ const elements = [
31930
+ ...ctx.data.values()
31931
+ ].map((item, i6) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i6)));
31932
+ if (ctx.common.async) {
31933
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
31934
+ } else {
31935
+ return finalizeSet(elements);
31936
+ }
31937
+ }
31938
+ min(minSize, message) {
31939
+ return new _ZodSet({
31940
+ ...this._def,
31941
+ minSize: {
31942
+ value: minSize,
31943
+ message: errorUtil.toString(message)
31944
+ }
31945
+ });
31946
+ }
31947
+ max(maxSize, message) {
31948
+ return new _ZodSet({
31949
+ ...this._def,
31950
+ maxSize: {
31951
+ value: maxSize,
31952
+ message: errorUtil.toString(message)
31953
+ }
31954
+ });
31955
+ }
31956
+ size(size, message) {
31957
+ return this.min(size, message).max(size, message);
31958
+ }
31959
+ nonempty(message) {
31960
+ return this.min(1, message);
31961
+ }
31962
+ };
31963
+ ZodSet.create = (valueType, params) => {
31964
+ return new ZodSet({
31965
+ valueType,
31966
+ minSize: null,
31967
+ maxSize: null,
31968
+ typeName: ZodFirstPartyTypeKind.ZodSet,
31969
+ ...processCreateParams(params)
31970
+ });
31971
+ };
31972
+ var ZodFunction = class _ZodFunction extends ZodType {
31973
+ static {
31974
+ __name(this, "ZodFunction");
31975
+ }
31976
+ constructor() {
31977
+ super(...arguments);
31978
+ this.validate = this.implement;
31979
+ }
31980
+ _parse(input) {
31981
+ const { ctx } = this._processInputParams(input);
31982
+ if (ctx.parsedType !== ZodParsedType.function) {
31983
+ addIssueToContext(ctx, {
31984
+ code: ZodIssueCode.invalid_type,
31985
+ expected: ZodParsedType.function,
31986
+ received: ctx.parsedType
31987
+ });
31988
+ return INVALID;
31989
+ }
31990
+ function makeArgsIssue(args, error) {
31991
+ return makeIssue({
31992
+ data: args,
31993
+ path: ctx.path,
31994
+ errorMaps: [
31995
+ ctx.common.contextualErrorMap,
31996
+ ctx.schemaErrorMap,
31997
+ getErrorMap(),
31998
+ en_default
31999
+ ].filter((x2) => !!x2),
32000
+ issueData: {
32001
+ code: ZodIssueCode.invalid_arguments,
32002
+ argumentsError: error
32003
+ }
32004
+ });
32005
+ }
32006
+ __name(makeArgsIssue, "makeArgsIssue");
32007
+ function makeReturnsIssue(returns, error) {
32008
+ return makeIssue({
32009
+ data: returns,
32010
+ path: ctx.path,
32011
+ errorMaps: [
32012
+ ctx.common.contextualErrorMap,
32013
+ ctx.schemaErrorMap,
32014
+ getErrorMap(),
32015
+ en_default
32016
+ ].filter((x2) => !!x2),
32017
+ issueData: {
32018
+ code: ZodIssueCode.invalid_return_type,
32019
+ returnTypeError: error
32020
+ }
32021
+ });
32022
+ }
32023
+ __name(makeReturnsIssue, "makeReturnsIssue");
32024
+ const params = {
32025
+ errorMap: ctx.common.contextualErrorMap
32026
+ };
32027
+ const fn = ctx.data;
32028
+ if (this._def.returns instanceof ZodPromise) {
32029
+ const me = this;
32030
+ return OK(async function(...args) {
32031
+ const error = new ZodError([]);
32032
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e6) => {
32033
+ error.addIssue(makeArgsIssue(args, e6));
32034
+ throw error;
32035
+ });
32036
+ const result = await Reflect.apply(fn, this, parsedArgs);
32037
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e6) => {
32038
+ error.addIssue(makeReturnsIssue(result, e6));
32039
+ throw error;
32040
+ });
32041
+ return parsedReturns;
32042
+ });
32043
+ } else {
32044
+ const me = this;
32045
+ return OK(function(...args) {
32046
+ const parsedArgs = me._def.args.safeParse(args, params);
32047
+ if (!parsedArgs.success) {
32048
+ throw new ZodError([
32049
+ makeArgsIssue(args, parsedArgs.error)
32050
+ ]);
32051
+ }
32052
+ const result = Reflect.apply(fn, this, parsedArgs.data);
32053
+ const parsedReturns = me._def.returns.safeParse(result, params);
32054
+ if (!parsedReturns.success) {
32055
+ throw new ZodError([
32056
+ makeReturnsIssue(result, parsedReturns.error)
32057
+ ]);
32058
+ }
32059
+ return parsedReturns.data;
32060
+ });
32061
+ }
32062
+ }
32063
+ parameters() {
32064
+ return this._def.args;
32065
+ }
32066
+ returnType() {
32067
+ return this._def.returns;
32068
+ }
32069
+ args(...items) {
32070
+ return new _ZodFunction({
32071
+ ...this._def,
32072
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
32073
+ });
32074
+ }
32075
+ returns(returnType) {
32076
+ return new _ZodFunction({
32077
+ ...this._def,
32078
+ returns: returnType
32079
+ });
32080
+ }
32081
+ implement(func) {
32082
+ const validatedFunc = this.parse(func);
32083
+ return validatedFunc;
32084
+ }
32085
+ strictImplement(func) {
32086
+ const validatedFunc = this.parse(func);
32087
+ return validatedFunc;
32088
+ }
32089
+ static create(args, returns, params) {
32090
+ return new _ZodFunction({
32091
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
32092
+ returns: returns || ZodUnknown.create(),
32093
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
32094
+ ...processCreateParams(params)
32095
+ });
32096
+ }
32097
+ };
32098
+ var ZodLazy = class extends ZodType {
32099
+ static {
32100
+ __name(this, "ZodLazy");
32101
+ }
32102
+ get schema() {
32103
+ return this._def.getter();
32104
+ }
32105
+ _parse(input) {
32106
+ const { ctx } = this._processInputParams(input);
32107
+ const lazySchema = this._def.getter();
32108
+ return lazySchema._parse({
32109
+ data: ctx.data,
32110
+ path: ctx.path,
32111
+ parent: ctx
32112
+ });
32113
+ }
32114
+ };
32115
+ ZodLazy.create = (getter, params) => {
32116
+ return new ZodLazy({
32117
+ getter,
32118
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
32119
+ ...processCreateParams(params)
32120
+ });
32121
+ };
32122
+ var ZodLiteral = class extends ZodType {
32123
+ static {
32124
+ __name(this, "ZodLiteral");
32125
+ }
32126
+ _parse(input) {
32127
+ if (input.data !== this._def.value) {
32128
+ const ctx = this._getOrReturnCtx(input);
32129
+ addIssueToContext(ctx, {
32130
+ received: ctx.data,
32131
+ code: ZodIssueCode.invalid_literal,
32132
+ expected: this._def.value
32133
+ });
32134
+ return INVALID;
32135
+ }
32136
+ return {
32137
+ status: "valid",
32138
+ value: input.data
32139
+ };
32140
+ }
32141
+ get value() {
32142
+ return this._def.value;
32143
+ }
32144
+ };
32145
+ ZodLiteral.create = (value, params) => {
32146
+ return new ZodLiteral({
32147
+ value,
32148
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
32149
+ ...processCreateParams(params)
32150
+ });
32151
+ };
32152
+ function createZodEnum(values, params) {
32153
+ return new ZodEnum({
32154
+ values,
32155
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
32156
+ ...processCreateParams(params)
32157
+ });
32158
+ }
32159
+ __name(createZodEnum, "createZodEnum");
32160
+ var ZodEnum = class _ZodEnum extends ZodType {
32161
+ static {
32162
+ __name(this, "ZodEnum");
32163
+ }
32164
+ _parse(input) {
32165
+ if (typeof input.data !== "string") {
32166
+ const ctx = this._getOrReturnCtx(input);
32167
+ const expectedValues = this._def.values;
32168
+ addIssueToContext(ctx, {
32169
+ expected: util.joinValues(expectedValues),
32170
+ received: ctx.parsedType,
32171
+ code: ZodIssueCode.invalid_type
32172
+ });
32173
+ return INVALID;
32174
+ }
32175
+ if (!this._cache) {
32176
+ this._cache = new Set(this._def.values);
32177
+ }
32178
+ if (!this._cache.has(input.data)) {
32179
+ const ctx = this._getOrReturnCtx(input);
32180
+ const expectedValues = this._def.values;
32181
+ addIssueToContext(ctx, {
32182
+ received: ctx.data,
32183
+ code: ZodIssueCode.invalid_enum_value,
32184
+ options: expectedValues
32185
+ });
32186
+ return INVALID;
32187
+ }
32188
+ return OK(input.data);
32189
+ }
32190
+ get options() {
32191
+ return this._def.values;
32192
+ }
32193
+ get enum() {
32194
+ const enumValues = {};
32195
+ for (const val of this._def.values) {
32196
+ enumValues[val] = val;
32197
+ }
32198
+ return enumValues;
32199
+ }
32200
+ get Values() {
32201
+ const enumValues = {};
32202
+ for (const val of this._def.values) {
32203
+ enumValues[val] = val;
32204
+ }
32205
+ return enumValues;
32206
+ }
32207
+ get Enum() {
32208
+ const enumValues = {};
32209
+ for (const val of this._def.values) {
32210
+ enumValues[val] = val;
32211
+ }
32212
+ return enumValues;
32213
+ }
32214
+ extract(values, newDef = this._def) {
32215
+ return _ZodEnum.create(values, {
32216
+ ...this._def,
32217
+ ...newDef
32218
+ });
32219
+ }
32220
+ exclude(values, newDef = this._def) {
32221
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
32222
+ ...this._def,
32223
+ ...newDef
32224
+ });
32225
+ }
32226
+ };
32227
+ ZodEnum.create = createZodEnum;
32228
+ var ZodNativeEnum = class extends ZodType {
32229
+ static {
32230
+ __name(this, "ZodNativeEnum");
32231
+ }
32232
+ _parse(input) {
32233
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
32234
+ const ctx = this._getOrReturnCtx(input);
32235
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
32236
+ const expectedValues = util.objectValues(nativeEnumValues);
32237
+ addIssueToContext(ctx, {
32238
+ expected: util.joinValues(expectedValues),
32239
+ received: ctx.parsedType,
32240
+ code: ZodIssueCode.invalid_type
32241
+ });
32242
+ return INVALID;
32243
+ }
32244
+ if (!this._cache) {
32245
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
32246
+ }
32247
+ if (!this._cache.has(input.data)) {
32248
+ const expectedValues = util.objectValues(nativeEnumValues);
32249
+ addIssueToContext(ctx, {
32250
+ received: ctx.data,
32251
+ code: ZodIssueCode.invalid_enum_value,
32252
+ options: expectedValues
32253
+ });
32254
+ return INVALID;
32255
+ }
32256
+ return OK(input.data);
32257
+ }
32258
+ get enum() {
32259
+ return this._def.values;
32260
+ }
32261
+ };
32262
+ ZodNativeEnum.create = (values, params) => {
32263
+ return new ZodNativeEnum({
32264
+ values,
32265
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
32266
+ ...processCreateParams(params)
32267
+ });
32268
+ };
32269
+ var ZodPromise = class extends ZodType {
32270
+ static {
32271
+ __name(this, "ZodPromise");
32272
+ }
32273
+ unwrap() {
32274
+ return this._def.type;
32275
+ }
32276
+ _parse(input) {
32277
+ const { ctx } = this._processInputParams(input);
32278
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
32279
+ addIssueToContext(ctx, {
32280
+ code: ZodIssueCode.invalid_type,
32281
+ expected: ZodParsedType.promise,
32282
+ received: ctx.parsedType
32283
+ });
32284
+ return INVALID;
32285
+ }
32286
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
32287
+ return OK(promisified.then((data) => {
32288
+ return this._def.type.parseAsync(data, {
32289
+ path: ctx.path,
32290
+ errorMap: ctx.common.contextualErrorMap
32291
+ });
32292
+ }));
32293
+ }
32294
+ };
32295
+ ZodPromise.create = (schema, params) => {
32296
+ return new ZodPromise({
32297
+ type: schema,
32298
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
32299
+ ...processCreateParams(params)
32300
+ });
32301
+ };
32302
+ var ZodEffects = class extends ZodType {
32303
+ static {
32304
+ __name(this, "ZodEffects");
32305
+ }
32306
+ innerType() {
32307
+ return this._def.schema;
32308
+ }
32309
+ sourceType() {
32310
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
32311
+ }
32312
+ _parse(input) {
32313
+ const { status, ctx } = this._processInputParams(input);
32314
+ const effect = this._def.effect || null;
32315
+ const checkCtx = {
32316
+ addIssue: /* @__PURE__ */ __name((arg) => {
32317
+ addIssueToContext(ctx, arg);
32318
+ if (arg.fatal) {
32319
+ status.abort();
32320
+ } else {
32321
+ status.dirty();
32322
+ }
32323
+ }, "addIssue"),
32324
+ get path() {
32325
+ return ctx.path;
32326
+ }
32327
+ };
32328
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
32329
+ if (effect.type === "preprocess") {
32330
+ const processed = effect.transform(ctx.data, checkCtx);
32331
+ if (ctx.common.async) {
32332
+ return Promise.resolve(processed).then(async (processed2) => {
32333
+ if (status.value === "aborted") return INVALID;
32334
+ const result = await this._def.schema._parseAsync({
32335
+ data: processed2,
32336
+ path: ctx.path,
32337
+ parent: ctx
32338
+ });
32339
+ if (result.status === "aborted") return INVALID;
32340
+ if (result.status === "dirty") return DIRTY(result.value);
32341
+ if (status.value === "dirty") return DIRTY(result.value);
32342
+ return result;
32343
+ });
32344
+ } else {
32345
+ if (status.value === "aborted") return INVALID;
32346
+ const result = this._def.schema._parseSync({
32347
+ data: processed,
32348
+ path: ctx.path,
32349
+ parent: ctx
32350
+ });
32351
+ if (result.status === "aborted") return INVALID;
32352
+ if (result.status === "dirty") return DIRTY(result.value);
32353
+ if (status.value === "dirty") return DIRTY(result.value);
32354
+ return result;
32355
+ }
32356
+ }
32357
+ if (effect.type === "refinement") {
32358
+ const executeRefinement = /* @__PURE__ */ __name((acc) => {
32359
+ const result = effect.refinement(acc, checkCtx);
32360
+ if (ctx.common.async) {
32361
+ return Promise.resolve(result);
32362
+ }
32363
+ if (result instanceof Promise) {
32364
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
32365
+ }
32366
+ return acc;
32367
+ }, "executeRefinement");
32368
+ if (ctx.common.async === false) {
32369
+ const inner = this._def.schema._parseSync({
32370
+ data: ctx.data,
32371
+ path: ctx.path,
32372
+ parent: ctx
32373
+ });
32374
+ if (inner.status === "aborted") return INVALID;
32375
+ if (inner.status === "dirty") status.dirty();
32376
+ executeRefinement(inner.value);
32377
+ return {
32378
+ status: status.value,
32379
+ value: inner.value
32380
+ };
32381
+ } else {
32382
+ return this._def.schema._parseAsync({
32383
+ data: ctx.data,
32384
+ path: ctx.path,
32385
+ parent: ctx
32386
+ }).then((inner) => {
32387
+ if (inner.status === "aborted") return INVALID;
32388
+ if (inner.status === "dirty") status.dirty();
32389
+ return executeRefinement(inner.value).then(() => {
32390
+ return {
32391
+ status: status.value,
32392
+ value: inner.value
32393
+ };
32394
+ });
32395
+ });
32396
+ }
32397
+ }
32398
+ if (effect.type === "transform") {
32399
+ if (ctx.common.async === false) {
32400
+ const base = this._def.schema._parseSync({
32401
+ data: ctx.data,
32402
+ path: ctx.path,
32403
+ parent: ctx
32404
+ });
32405
+ if (!isValid(base)) return INVALID;
32406
+ const result = effect.transform(base.value, checkCtx);
32407
+ if (result instanceof Promise) {
32408
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
32409
+ }
32410
+ return {
32411
+ status: status.value,
32412
+ value: result
32413
+ };
32414
+ } else {
32415
+ return this._def.schema._parseAsync({
32416
+ data: ctx.data,
32417
+ path: ctx.path,
32418
+ parent: ctx
32419
+ }).then((base) => {
32420
+ if (!isValid(base)) return INVALID;
32421
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
32422
+ status: status.value,
32423
+ value: result
32424
+ }));
32425
+ });
32426
+ }
32427
+ }
32428
+ util.assertNever(effect);
32429
+ }
32430
+ };
32431
+ ZodEffects.create = (schema, effect, params) => {
32432
+ return new ZodEffects({
32433
+ schema,
32434
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
32435
+ effect,
32436
+ ...processCreateParams(params)
32437
+ });
32438
+ };
32439
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
32440
+ return new ZodEffects({
32441
+ schema,
32442
+ effect: {
32443
+ type: "preprocess",
32444
+ transform: preprocess
32445
+ },
32446
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
32447
+ ...processCreateParams(params)
32448
+ });
32449
+ };
32450
+ var ZodOptional = class extends ZodType {
32451
+ static {
32452
+ __name(this, "ZodOptional");
32453
+ }
32454
+ _parse(input) {
32455
+ const parsedType = this._getType(input);
32456
+ if (parsedType === ZodParsedType.undefined) {
32457
+ return OK(void 0);
32458
+ }
32459
+ return this._def.innerType._parse(input);
32460
+ }
32461
+ unwrap() {
32462
+ return this._def.innerType;
32463
+ }
32464
+ };
32465
+ ZodOptional.create = (type, params) => {
32466
+ return new ZodOptional({
32467
+ innerType: type,
32468
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
32469
+ ...processCreateParams(params)
32470
+ });
32471
+ };
32472
+ var ZodNullable = class extends ZodType {
32473
+ static {
32474
+ __name(this, "ZodNullable");
32475
+ }
32476
+ _parse(input) {
32477
+ const parsedType = this._getType(input);
32478
+ if (parsedType === ZodParsedType.null) {
32479
+ return OK(null);
32480
+ }
32481
+ return this._def.innerType._parse(input);
32482
+ }
32483
+ unwrap() {
32484
+ return this._def.innerType;
32485
+ }
32486
+ };
32487
+ ZodNullable.create = (type, params) => {
32488
+ return new ZodNullable({
32489
+ innerType: type,
32490
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
32491
+ ...processCreateParams(params)
32492
+ });
32493
+ };
32494
+ var ZodDefault = class extends ZodType {
32495
+ static {
32496
+ __name(this, "ZodDefault");
32497
+ }
32498
+ _parse(input) {
32499
+ const { ctx } = this._processInputParams(input);
32500
+ let data = ctx.data;
32501
+ if (ctx.parsedType === ZodParsedType.undefined) {
32502
+ data = this._def.defaultValue();
32503
+ }
32504
+ return this._def.innerType._parse({
32505
+ data,
32506
+ path: ctx.path,
32507
+ parent: ctx
32508
+ });
32509
+ }
32510
+ removeDefault() {
32511
+ return this._def.innerType;
32512
+ }
32513
+ };
32514
+ ZodDefault.create = (type, params) => {
32515
+ return new ZodDefault({
32516
+ innerType: type,
32517
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
32518
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
32519
+ ...processCreateParams(params)
32520
+ });
32521
+ };
32522
+ var ZodCatch = class extends ZodType {
32523
+ static {
32524
+ __name(this, "ZodCatch");
32525
+ }
32526
+ _parse(input) {
32527
+ const { ctx } = this._processInputParams(input);
32528
+ const newCtx = {
32529
+ ...ctx,
32530
+ common: {
32531
+ ...ctx.common,
32532
+ issues: []
32533
+ }
32534
+ };
32535
+ const result = this._def.innerType._parse({
32536
+ data: newCtx.data,
32537
+ path: newCtx.path,
32538
+ parent: {
32539
+ ...newCtx
32540
+ }
32541
+ });
32542
+ if (isAsync(result)) {
32543
+ return result.then((result2) => {
32544
+ return {
32545
+ status: "valid",
32546
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
32547
+ get error() {
32548
+ return new ZodError(newCtx.common.issues);
32549
+ },
32550
+ input: newCtx.data
32551
+ })
32552
+ };
32553
+ });
32554
+ } else {
32555
+ return {
32556
+ status: "valid",
32557
+ value: result.status === "valid" ? result.value : this._def.catchValue({
32558
+ get error() {
32559
+ return new ZodError(newCtx.common.issues);
32560
+ },
32561
+ input: newCtx.data
32562
+ })
32563
+ };
32564
+ }
32565
+ }
32566
+ removeCatch() {
32567
+ return this._def.innerType;
32568
+ }
32569
+ };
32570
+ ZodCatch.create = (type, params) => {
32571
+ return new ZodCatch({
32572
+ innerType: type,
32573
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
32574
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
32575
+ ...processCreateParams(params)
32576
+ });
32577
+ };
32578
+ var ZodNaN = class extends ZodType {
32579
+ static {
32580
+ __name(this, "ZodNaN");
32581
+ }
32582
+ _parse(input) {
32583
+ const parsedType = this._getType(input);
32584
+ if (parsedType !== ZodParsedType.nan) {
32585
+ const ctx = this._getOrReturnCtx(input);
32586
+ addIssueToContext(ctx, {
32587
+ code: ZodIssueCode.invalid_type,
32588
+ expected: ZodParsedType.nan,
32589
+ received: ctx.parsedType
32590
+ });
32591
+ return INVALID;
32592
+ }
32593
+ return {
32594
+ status: "valid",
32595
+ value: input.data
32596
+ };
32597
+ }
32598
+ };
32599
+ ZodNaN.create = (params) => {
32600
+ return new ZodNaN({
32601
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
32602
+ ...processCreateParams(params)
32603
+ });
32604
+ };
32605
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
32606
+ var ZodBranded = class extends ZodType {
32607
+ static {
32608
+ __name(this, "ZodBranded");
32609
+ }
32610
+ _parse(input) {
32611
+ const { ctx } = this._processInputParams(input);
32612
+ const data = ctx.data;
32613
+ return this._def.type._parse({
32614
+ data,
32615
+ path: ctx.path,
32616
+ parent: ctx
32617
+ });
32618
+ }
32619
+ unwrap() {
32620
+ return this._def.type;
32621
+ }
32622
+ };
32623
+ var ZodPipeline = class _ZodPipeline extends ZodType {
32624
+ static {
32625
+ __name(this, "ZodPipeline");
32626
+ }
32627
+ _parse(input) {
32628
+ const { status, ctx } = this._processInputParams(input);
32629
+ if (ctx.common.async) {
32630
+ const handleAsync = /* @__PURE__ */ __name(async () => {
32631
+ const inResult = await this._def.in._parseAsync({
32632
+ data: ctx.data,
32633
+ path: ctx.path,
32634
+ parent: ctx
32635
+ });
32636
+ if (inResult.status === "aborted") return INVALID;
32637
+ if (inResult.status === "dirty") {
32638
+ status.dirty();
32639
+ return DIRTY(inResult.value);
32640
+ } else {
32641
+ return this._def.out._parseAsync({
32642
+ data: inResult.value,
32643
+ path: ctx.path,
32644
+ parent: ctx
32645
+ });
32646
+ }
32647
+ }, "handleAsync");
32648
+ return handleAsync();
32649
+ } else {
32650
+ const inResult = this._def.in._parseSync({
32651
+ data: ctx.data,
32652
+ path: ctx.path,
32653
+ parent: ctx
32654
+ });
32655
+ if (inResult.status === "aborted") return INVALID;
32656
+ if (inResult.status === "dirty") {
32657
+ status.dirty();
32658
+ return {
32659
+ status: "dirty",
32660
+ value: inResult.value
32661
+ };
32662
+ } else {
32663
+ return this._def.out._parseSync({
32664
+ data: inResult.value,
32665
+ path: ctx.path,
32666
+ parent: ctx
32667
+ });
32668
+ }
32669
+ }
32670
+ }
32671
+ static create(a6, b6) {
32672
+ return new _ZodPipeline({
32673
+ in: a6,
32674
+ out: b6,
32675
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
32676
+ });
32677
+ }
32678
+ };
32679
+ var ZodReadonly = class extends ZodType {
32680
+ static {
32681
+ __name(this, "ZodReadonly");
32682
+ }
32683
+ _parse(input) {
32684
+ const result = this._def.innerType._parse(input);
32685
+ const freeze = /* @__PURE__ */ __name((data) => {
32686
+ if (isValid(data)) {
32687
+ data.value = Object.freeze(data.value);
32688
+ }
32689
+ return data;
32690
+ }, "freeze");
32691
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
32692
+ }
32693
+ unwrap() {
32694
+ return this._def.innerType;
32695
+ }
32696
+ };
32697
+ ZodReadonly.create = (type, params) => {
32698
+ return new ZodReadonly({
32699
+ innerType: type,
32700
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
32701
+ ...processCreateParams(params)
32702
+ });
32703
+ };
32704
+ function cleanParams(params, data) {
32705
+ const p3 = typeof params === "function" ? params(data) : typeof params === "string" ? {
32706
+ message: params
32707
+ } : params;
32708
+ const p22 = typeof p3 === "string" ? {
32709
+ message: p3
32710
+ } : p3;
32711
+ return p22;
32712
+ }
32713
+ __name(cleanParams, "cleanParams");
32714
+ function custom(check, _params = {}, fatal) {
32715
+ if (check) return ZodAny.create().superRefine((data, ctx) => {
32716
+ const r6 = check(data);
32717
+ if (r6 instanceof Promise) {
32718
+ return r6.then((r7) => {
32719
+ if (!r7) {
32720
+ const params = cleanParams(_params, data);
32721
+ const _fatal = params.fatal ?? fatal ?? true;
32722
+ ctx.addIssue({
32723
+ code: "custom",
32724
+ ...params,
32725
+ fatal: _fatal
32726
+ });
32727
+ }
32728
+ });
32729
+ }
32730
+ if (!r6) {
32731
+ const params = cleanParams(_params, data);
32732
+ const _fatal = params.fatal ?? fatal ?? true;
32733
+ ctx.addIssue({
32734
+ code: "custom",
32735
+ ...params,
32736
+ fatal: _fatal
32737
+ });
32738
+ }
32739
+ return;
32740
+ });
32741
+ return ZodAny.create();
32742
+ }
32743
+ __name(custom, "custom");
32744
+ var late = {
32745
+ object: ZodObject.lazycreate
32746
+ };
32747
+ var ZodFirstPartyTypeKind;
32748
+ (function(ZodFirstPartyTypeKind2) {
32749
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
32750
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
32751
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
32752
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
32753
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
32754
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
32755
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
32756
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
32757
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
32758
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
32759
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
32760
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
32761
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
32762
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
32763
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
32764
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
32765
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
32766
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
32767
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
32768
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
32769
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
32770
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
32771
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
32772
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
32773
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
32774
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
32775
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
32776
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
32777
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
32778
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
32779
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
32780
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
32781
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
32782
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
32783
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
32784
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
32785
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
32786
+ var instanceOfType = /* @__PURE__ */ __name((cls, params = {
32787
+ message: `Input not instance of ${cls.name}`
32788
+ }) => custom((data) => data instanceof cls, params), "instanceOfType");
32789
+ var stringType = ZodString.create;
32790
+ var numberType = ZodNumber.create;
32791
+ var nanType = ZodNaN.create;
32792
+ var bigIntType = ZodBigInt.create;
32793
+ var booleanType = ZodBoolean.create;
32794
+ var dateType = ZodDate.create;
32795
+ var symbolType = ZodSymbol.create;
32796
+ var undefinedType = ZodUndefined.create;
32797
+ var nullType = ZodNull.create;
32798
+ var anyType = ZodAny.create;
32799
+ var unknownType = ZodUnknown.create;
32800
+ var neverType = ZodNever.create;
32801
+ var voidType = ZodVoid.create;
32802
+ var arrayType = ZodArray.create;
32803
+ var objectType = ZodObject.create;
32804
+ var strictObjectType = ZodObject.strictCreate;
32805
+ var unionType = ZodUnion.create;
32806
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
32807
+ var intersectionType = ZodIntersection.create;
32808
+ var tupleType = ZodTuple.create;
32809
+ var recordType = ZodRecord.create;
32810
+ var mapType = ZodMap.create;
32811
+ var setType = ZodSet.create;
32812
+ var functionType = ZodFunction.create;
32813
+ var lazyType = ZodLazy.create;
32814
+ var literalType = ZodLiteral.create;
32815
+ var enumType = ZodEnum.create;
32816
+ var nativeEnumType = ZodNativeEnum.create;
32817
+ var promiseType = ZodPromise.create;
32818
+ var effectsType = ZodEffects.create;
32819
+ var optionalType = ZodOptional.create;
32820
+ var nullableType = ZodNullable.create;
32821
+ var preprocessType = ZodEffects.createWithPreprocess;
32822
+ var pipelineType = ZodPipeline.create;
32823
+ var ostring = /* @__PURE__ */ __name(() => stringType().optional(), "ostring");
32824
+ var onumber = /* @__PURE__ */ __name(() => numberType().optional(), "onumber");
32825
+ var oboolean = /* @__PURE__ */ __name(() => booleanType().optional(), "oboolean");
32826
+ var coerce = {
32827
+ string: /* @__PURE__ */ __name((arg) => ZodString.create({
32828
+ ...arg,
32829
+ coerce: true
32830
+ }), "string"),
32831
+ number: /* @__PURE__ */ __name((arg) => ZodNumber.create({
32832
+ ...arg,
32833
+ coerce: true
32834
+ }), "number"),
32835
+ boolean: /* @__PURE__ */ __name((arg) => ZodBoolean.create({
32836
+ ...arg,
32837
+ coerce: true
32838
+ }), "boolean"),
32839
+ bigint: /* @__PURE__ */ __name((arg) => ZodBigInt.create({
32840
+ ...arg,
32841
+ coerce: true
32842
+ }), "bigint"),
32843
+ date: /* @__PURE__ */ __name((arg) => ZodDate.create({
32844
+ ...arg,
32845
+ coerce: true
32846
+ }), "date")
32847
+ };
32848
+ var NEVER = INVALID;
32849
+
32850
+ // ../../packages/prosa-sync/src/schemas.ts
32851
+ var PROTOCOL_VERSION = 1;
32852
+ var objectManifestEntrySchema = external_exports.object({
32853
+ /** Canonical object id derived from the BLAKE3 of the original payload. */
32854
+ objectId: external_exports.string().regex(/^blake3:[0-9a-f]{64}$/i),
32855
+ /** BLAKE3 of the original (uncompressed) payload. */
32856
+ hash: external_exports.string().regex(/^[0-9a-f]{64}$/i),
32857
+ hashAlgorithm: external_exports.literal("blake3").default("blake3"),
32858
+ uncompressedSize: external_exports.number().int().nonnegative(),
32859
+ compressedSize: external_exports.number().int().nonnegative(),
32860
+ /**
32861
+ * Compression used for the on-disk / on-transport bytes. Defaults to `zstd`
32862
+ * to match the local bundle layout; `none` is used when compression would
32863
+ * not shrink the payload.
32864
+ */
32865
+ compression: external_exports.enum([
32866
+ "zstd",
32867
+ "none"
32868
+ ]).default("zstd"),
32869
+ /**
32870
+ * BLAKE3 of the bytes-on-the-wire (`compressed` bytes for `compression=zstd`,
32871
+ * identical to `hash` for `compression=none`). The server verifies the
32872
+ * uploaded body against this hash; `hash`/`objectId` remain canonical for
32873
+ * the original payload.
32874
+ */
32875
+ transportHash: external_exports.string().regex(/^[0-9a-f]{64}$/i).optional(),
32876
+ contentType: external_exports.string().optional()
32877
+ }).superRefine((value, ctx) => {
32878
+ if (value.objectId.toLowerCase() !== `blake3:${value.hash.toLowerCase()}`) {
32879
+ ctx.addIssue({
32880
+ code: external_exports.ZodIssueCode.custom,
32881
+ path: [
32882
+ "objectId"
32883
+ ],
32884
+ message: "objectId must be blake3:<hash>"
32885
+ });
32886
+ }
32887
+ });
32888
+ var sourceFileRowSchema = external_exports.object({
32889
+ id: external_exports.string().min(1),
32890
+ sourceKind: external_exports.string().min(1),
32891
+ path: external_exports.string().min(1),
32892
+ objectId: external_exports.string().min(1).nullable().optional(),
32893
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32894
+ });
32895
+ var rawRecordRowSchema = external_exports.object({
32896
+ id: external_exports.string().min(1),
32897
+ sourceFileId: external_exports.string().min(1),
32898
+ sequence: external_exports.number().int().nonnegative(),
32899
+ payload: external_exports.unknown(),
32900
+ objectId: external_exports.string().min(1).nullable().optional()
32901
+ });
32902
+ var projectionSessionRowSchema = external_exports.object({
32903
+ id: external_exports.string().min(1),
32904
+ sourceKind: external_exports.string().min(1),
32905
+ projectId: external_exports.string().min(1).nullable().optional(),
32906
+ title: external_exports.string().nullable().optional(),
32907
+ startedAt: external_exports.string().datetime().nullable().optional(),
32908
+ endedAt: external_exports.string().datetime().nullable().optional(),
32909
+ turnCount: external_exports.number().int().nonnegative().default(0),
32910
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32911
+ });
32912
+ var searchDocRowSchema = external_exports.object({
32913
+ id: external_exports.string().min(1),
32914
+ sessionId: external_exports.string().min(1),
32915
+ kind: external_exports.string().min(1),
32916
+ body: external_exports.string()
32917
+ });
32918
+ var projectionToolCallRowSchema = external_exports.object({
32919
+ id: external_exports.string().min(1),
32920
+ sessionId: external_exports.string().min(1),
32921
+ turnId: external_exports.string().min(1).nullable().optional(),
32922
+ name: external_exports.string().min(1),
32923
+ status: external_exports.string().nullable().optional(),
32924
+ inputObjectId: external_exports.string().min(1).nullable().optional(),
32925
+ createdAt: external_exports.string().datetime().nullable().optional()
32926
+ });
32927
+ var projectionToolResultRowSchema = external_exports.object({
32928
+ id: external_exports.string().min(1),
32929
+ toolCallId: external_exports.string().min(1),
32930
+ outputObjectId: external_exports.string().min(1).nullable().optional(),
32931
+ status: external_exports.string().nullable().optional(),
32932
+ finishedAt: external_exports.string().datetime().nullable().optional()
32933
+ });
32934
+ var projectionMessageRowSchema = external_exports.object({
32935
+ id: external_exports.string().min(1),
32936
+ sessionId: external_exports.string().min(1),
32937
+ turnId: external_exports.string().min(1).nullable().optional(),
32938
+ role: external_exports.string().min(1),
32939
+ model: external_exports.string().nullable().optional(),
32940
+ createdAt: external_exports.string().datetime().nullable().optional()
32941
+ });
32942
+ var projectionContentBlockRowSchema = external_exports.object({
32943
+ id: external_exports.string().min(1),
32944
+ messageId: external_exports.string().min(1),
32945
+ sequence: external_exports.number().int().nonnegative(),
32946
+ kind: external_exports.string().min(1),
32947
+ text: external_exports.string().nullable().optional(),
32948
+ objectId: external_exports.string().min(1).nullable().optional(),
32949
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32950
+ });
32951
+ var projectionEventRowSchema = external_exports.object({
32952
+ id: external_exports.string().min(1),
32953
+ sessionId: external_exports.string().min(1),
32954
+ turnId: external_exports.string().min(1).nullable().optional(),
32955
+ sequence: external_exports.number().int().nonnegative(),
32956
+ kind: external_exports.string().min(1),
32957
+ payload: external_exports.unknown().optional(),
32958
+ occurredAt: external_exports.string().datetime().nullable().optional()
32959
+ });
32960
+ var projectionArtifactRowSchema = external_exports.object({
32961
+ id: external_exports.string().min(1),
32962
+ sessionId: external_exports.string().min(1).nullable().optional(),
32963
+ kind: external_exports.string().min(1),
32964
+ objectId: external_exports.string().min(1).nullable().optional(),
32965
+ sizeBytes: external_exports.number().int().nonnegative().nullable().optional(),
32966
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32967
+ });
32968
+ var projectionPayloadSchema = external_exports.object({
32969
+ sourceFiles: external_exports.array(sourceFileRowSchema).default([]),
32970
+ rawRecords: external_exports.array(rawRecordRowSchema).default([]),
32971
+ sessions: external_exports.array(projectionSessionRowSchema).default([]),
32972
+ searchDocs: external_exports.array(searchDocRowSchema).default([]),
32973
+ toolCalls: external_exports.array(projectionToolCallRowSchema).default([]),
32974
+ toolResults: external_exports.array(projectionToolResultRowSchema).default([]),
32975
+ // New transcript projections (F3). Older CLIs can omit them entirely.
32976
+ messages: external_exports.array(projectionMessageRowSchema).default([]),
32977
+ contentBlocks: external_exports.array(projectionContentBlockRowSchema).default([]),
32978
+ events: external_exports.array(projectionEventRowSchema).default([]),
32979
+ artifacts: external_exports.array(projectionArtifactRowSchema).default([])
32980
+ });
32981
+ var handshakeInputSchema = external_exports.object({
32982
+ cliVersion: external_exports.string().min(1),
32983
+ protocolVersion: external_exports.number().int().min(1).default(PROTOCOL_VERSION),
32984
+ device: external_exports.object({
32985
+ name: external_exports.string().min(1),
32986
+ platform: external_exports.string().optional()
32987
+ }),
32988
+ store: external_exports.object({
32989
+ path: external_exports.string().min(1),
32990
+ bundleVersion: external_exports.string().min(1)
32991
+ })
32992
+ });
32993
+ var handshakeOutputSchema = external_exports.object({
32994
+ serverVersion: external_exports.string(),
32995
+ protocolVersion: external_exports.number().int(),
32996
+ deviceId: external_exports.string().min(1),
32997
+ promoted: external_exports.boolean(),
32998
+ limits: external_exports.object({
32999
+ maxObjectsPerPlan: external_exports.number().int().positive(),
33000
+ maxRowsPerCommit: external_exports.number().int().positive(),
33001
+ maxObjectBytes: external_exports.number().int().positive()
33002
+ })
33003
+ });
33004
+ var planUploadInputSchema = external_exports.object({
33005
+ deviceId: external_exports.string().min(1),
33006
+ storePath: external_exports.string().min(1),
33007
+ objects: external_exports.array(objectManifestEntrySchema).default([])
33008
+ });
33009
+ var planUploadOutputSchema = external_exports.object({
33010
+ batchId: external_exports.string().min(1),
33011
+ missingObjectIds: external_exports.array(external_exports.string()),
33012
+ uploadUrlTemplate: external_exports.string()
33013
+ });
33014
+ var commitUploadInputSchema = external_exports.object({
33015
+ batchId: external_exports.string().min(1),
33016
+ deviceId: external_exports.string().min(1),
33017
+ storePath: external_exports.string().min(1),
33018
+ objects: external_exports.array(objectManifestEntrySchema).default([]),
33019
+ projection: projectionPayloadSchema.default({})
33020
+ });
33021
+ var commitUploadOutputSchema = external_exports.object({
33022
+ batchId: external_exports.string(),
33023
+ committedObjects: external_exports.number().int().nonnegative(),
33024
+ committedRows: external_exports.number().int().nonnegative()
33025
+ });
33026
+ var verifyPromotionInputSchema = external_exports.object({
33027
+ batchId: external_exports.string().min(1),
33028
+ storePath: external_exports.string().min(1),
33029
+ sampleSessionIds: external_exports.array(external_exports.string()).max(20).default([]),
33030
+ /**
33031
+ * Object IDs the client uploaded in this batch. Every entry must have a
33032
+ * matching `tenant_object` provenance row for the caller's tenant before
33033
+ * `verifyPromotion` will emit a receipt. Used to authorize destructive
33034
+ * cleanup.
33035
+ */
33036
+ declaredObjectIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33037
+ /** Source file ids the client claims were uploaded; verifier confirms each. */
33038
+ declaredSourceFileIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33039
+ /** Raw record ids the client claims were uploaded; verifier confirms each. */
33040
+ declaredRawRecordIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33041
+ /** Session ids the client claims were uploaded; verifier confirms each. */
33042
+ declaredSessionIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33043
+ /** Search doc ids the client claims were uploaded; verifier confirms each. */
33044
+ declaredSearchDocIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33045
+ /** Tool call ids the client claims were uploaded; verifier confirms each. */
33046
+ declaredToolCallIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33047
+ /** Tool result ids the client claims were uploaded; verifier confirms each. */
33048
+ declaredToolResultIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33049
+ /** Message ids the client claims were uploaded; verifier confirms each. (F3) */
33050
+ declaredMessageIds: external_exports.array(external_exports.string()).max(5e4).default([]),
33051
+ /** Content-block ids the client claims were uploaded; verifier confirms each. (F3) */
33052
+ declaredContentBlockIds: external_exports.array(external_exports.string()).max(1e5).default([]),
33053
+ /** Event ids the client claims were uploaded; verifier confirms each. (F3) */
33054
+ declaredEventIds: external_exports.array(external_exports.string()).max(1e5).default([]),
33055
+ /** Artifact ids the client claims were uploaded; verifier confirms each. (F3) */
33056
+ declaredArtifactIds: external_exports.array(external_exports.string()).max(1e4).default([])
33057
+ });
33058
+ var promotionReceiptSchema = external_exports.object({
33059
+ batchId: external_exports.string(),
33060
+ tenantId: external_exports.string(),
33061
+ deviceId: external_exports.string(),
33062
+ storePath: external_exports.string(),
33063
+ manifestHash: external_exports.string(),
33064
+ sessionCount: external_exports.number().int().nonnegative(),
33065
+ objectCount: external_exports.number().int().nonnegative(),
33066
+ searchDocCount: external_exports.number().int().nonnegative(),
33067
+ batchObjectCount: external_exports.number().int().nonnegative().default(0),
33068
+ batchSourceFileCount: external_exports.number().int().nonnegative().default(0),
33069
+ batchRawRecordCount: external_exports.number().int().nonnegative().default(0),
33070
+ batchSessionCount: external_exports.number().int().nonnegative().default(0),
33071
+ batchSearchDocCount: external_exports.number().int().nonnegative().default(0),
33072
+ batchToolCallCount: external_exports.number().int().nonnegative().default(0),
33073
+ batchToolResultCount: external_exports.number().int().nonnegative().default(0),
33074
+ batchMessageCount: external_exports.number().int().nonnegative().default(0),
33075
+ batchContentBlockCount: external_exports.number().int().nonnegative().default(0),
33076
+ batchEventCount: external_exports.number().int().nonnegative().default(0),
33077
+ batchArtifactCount: external_exports.number().int().nonnegative().default(0),
33078
+ declaredObjectsVerified: external_exports.number().int().nonnegative().default(0),
33079
+ declaredSourceFilesVerified: external_exports.number().int().nonnegative().default(0),
33080
+ declaredRawRecordsVerified: external_exports.number().int().nonnegative().default(0),
33081
+ declaredSessionsVerified: external_exports.number().int().nonnegative().default(0),
33082
+ declaredSearchDocsVerified: external_exports.number().int().nonnegative().default(0),
33083
+ declaredToolCallsVerified: external_exports.number().int().nonnegative().default(0),
33084
+ declaredToolResultsVerified: external_exports.number().int().nonnegative().default(0),
33085
+ declaredMessagesVerified: external_exports.number().int().nonnegative().default(0),
33086
+ declaredContentBlocksVerified: external_exports.number().int().nonnegative().default(0),
33087
+ declaredEventsVerified: external_exports.number().int().nonnegative().default(0),
33088
+ declaredArtifactsVerified: external_exports.number().int().nonnegative().default(0),
33089
+ cleanupEligible: external_exports.boolean().default(false),
33090
+ verifiedAt: external_exports.string().datetime()
33091
+ });
33092
+ var verifyPromotionOutputSchema = external_exports.object({
33093
+ receipt: promotionReceiptSchema,
33094
+ sampledSessions: external_exports.array(external_exports.object({
33095
+ id: external_exports.string(),
33096
+ title: external_exports.string().nullable(),
33097
+ turnCount: external_exports.number().int()
33098
+ }))
33099
+ });
33100
+ var ackCleanupInputSchema = external_exports.object({
33101
+ batchId: external_exports.string().min(1),
33102
+ storePath: external_exports.string().min(1),
33103
+ removedPaths: external_exports.array(external_exports.string()).default([])
33104
+ });
33105
+
33106
+ // ../../packages/prosa-sync/src/object-pack.ts
33107
+ var OBJECT_PACK_BINARY_CONTENT_TYPE = "application/vnd.prosa.object-pack.v1+binary";
33108
+ var OBJECT_PACK_BINARY_MAGIC = "PROSAOP1";
33109
+ var MAGIC_BYTES = new TextEncoder().encode(OBJECT_PACK_BINARY_MAGIC);
33110
+ var HEADER_LENGTH_BYTES = 4;
33111
+ var textEncoder = new TextEncoder();
33112
+ var textDecoder = new TextDecoder("utf-8", {
33113
+ fatal: true
33114
+ });
33115
+ var objectPackWireEntrySchema = objectManifestEntrySchema.and(external_exports.object({
33116
+ offset: external_exports.number().int().nonnegative(),
33117
+ length: external_exports.number().int().nonnegative()
33118
+ }));
33119
+ var objectPackBinaryHeaderSchema = external_exports.object({
33120
+ entries: external_exports.array(objectPackWireEntrySchema)
33121
+ });
33122
+ var BinaryObjectPackFormatError = class extends Error {
33123
+ static {
33124
+ __name(this, "BinaryObjectPackFormatError");
33125
+ }
33126
+ name = "BinaryObjectPackFormatError";
33127
+ };
33128
+ function formatError(message) {
33129
+ throw new BinaryObjectPackFormatError(message);
33130
+ }
33131
+ __name(formatError, "formatError");
33132
+ function encodeBinaryObjectPack(pack) {
33133
+ const headerBytes = textEncoder.encode(JSON.stringify({
33134
+ entries: pack.entries
33135
+ }));
33136
+ if (headerBytes.byteLength > 4294967295) {
33137
+ formatError("binary object pack header is too large");
33138
+ }
33139
+ const headerOffset = MAGIC_BYTES.byteLength + HEADER_LENGTH_BYTES;
33140
+ const payloadOffset = headerOffset + headerBytes.byteLength;
33141
+ const out = new Uint8Array(payloadOffset + pack.payload.byteLength);
33142
+ out.set(MAGIC_BYTES, 0);
33143
+ new DataView(out.buffer, out.byteOffset + MAGIC_BYTES.byteLength, HEADER_LENGTH_BYTES).setUint32(0, headerBytes.byteLength);
33144
+ out.set(headerBytes, headerOffset);
33145
+ out.set(pack.payload, payloadOffset);
33146
+ return out;
33147
+ }
33148
+ __name(encodeBinaryObjectPack, "encodeBinaryObjectPack");
33149
+
33150
+ // src/cli/auth/client.ts
28401
33151
  var OBJECT_UPLOAD_MAX_ATTEMPTS = 6;
28402
33152
  var OBJECT_UPLOAD_BASE_BACKOFF_MS = 500;
28403
33153
  var OBJECT_UPLOAD_MAX_BACKOFF_MS = 15e3;
@@ -52709,8 +57459,8 @@ var getSsecPlugin = /* @__PURE__ */ __name((config) => ({
52709
57459
  }, "applyToStack")
52710
57460
  }), "getSsecPlugin");
52711
57461
  function isValidBase64EncodedSSECustomerKey(str, options) {
52712
- const base64Regex = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
52713
- if (!base64Regex.test(str)) return false;
57462
+ const base64Regex2 = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
57463
+ if (!base64Regex2.test(str)) return false;
52714
57464
  try {
52715
57465
  const decodedBytes = options.base64Decoder(str);
52716
57466
  return decodedBytes.length === 32;