@rastrokit/sdk 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3660,7 +3660,7 @@ var require_string_width = __commonJS({
3660
3660
  "use strict";
3661
3661
  var stripAnsi = require_strip_ansi();
3662
3662
  var isFullwidthCodePoint = require_is_fullwidth_code_point();
3663
- var emojiRegex = require_emoji_regex();
3663
+ var emojiRegex2 = require_emoji_regex();
3664
3664
  var stringWidth = (string4) => {
3665
3665
  if (typeof string4 !== "string" || string4.length === 0) {
3666
3666
  return 0;
@@ -3669,7 +3669,7 @@ var require_string_width = __commonJS({
3669
3669
  if (string4.length === 0) {
3670
3670
  return 0;
3671
3671
  }
3672
- string4 = string4.replace(emojiRegex(), " ");
3672
+ string4 = string4.replace(emojiRegex2(), " ");
3673
3673
  let width = 0;
3674
3674
  for (let i = 0; i < string4.length; i++) {
3675
3675
  const code = string4.codePointAt(i);
@@ -11852,10 +11852,10 @@ var require_utf7 = __commonJS({
11852
11852
  this.inBase64 = false;
11853
11853
  this.base64Accum = "";
11854
11854
  }
11855
- var base64Regex = /[A-Za-z0-9\/+]/;
11855
+ var base64Regex2 = /[A-Za-z0-9\/+]/;
11856
11856
  var base64Chars = [];
11857
11857
  for (i = 0; i < 256; i++) {
11858
- base64Chars[i] = base64Regex.test(String.fromCharCode(i));
11858
+ base64Chars[i] = base64Regex2.test(String.fromCharCode(i));
11859
11859
  }
11860
11860
  var i;
11861
11861
  var plusChar = "+".charCodeAt(0);
@@ -15689,11 +15689,11 @@ var require_Observable = __commonJS({
15689
15689
  var _a3;
15690
15690
  return (_a3 = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config_1.config.Promise) !== null && _a3 !== void 0 ? _a3 : Promise;
15691
15691
  }
15692
- function isObserver(value) {
15692
+ function isObserver2(value) {
15693
15693
  return value && isFunction_1.isFunction(value.next) && isFunction_1.isFunction(value.error) && isFunction_1.isFunction(value.complete);
15694
15694
  }
15695
15695
  function isSubscriber(value) {
15696
- return value && value instanceof Subscriber_1.Subscriber || isObserver(value) && Subscription_1.isSubscription(value);
15696
+ return value && value instanceof Subscriber_1.Subscriber || isObserver2(value) && Subscription_1.isSubscription(value);
15697
15697
  }
15698
15698
  }
15699
15699
  });
@@ -28394,14 +28394,14 @@ var esm_default2 = createPrompt((config2, done) => {
28394
28394
  useKeypress(async (key) => {
28395
28395
  if (isEnterKey(key)) {
28396
28396
  const selection = items.filter(isChecked);
28397
- const isValid = await validate2([...selection]);
28397
+ const isValid2 = await validate2([...selection]);
28398
28398
  if (required2 && !items.some(isChecked)) {
28399
28399
  setError("At least one choice must be selected");
28400
- } else if (isValid === true) {
28400
+ } else if (isValid2 === true) {
28401
28401
  setStatus("done");
28402
28402
  done(selection.map((choice) => choice.value));
28403
28403
  } else {
28404
- setError(isValid || "You must select a valid value");
28404
+ setError(isValid2 || "You must select a valid value");
28405
28405
  }
28406
28406
  } else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
28407
28407
  if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
@@ -28713,8 +28713,8 @@ var esm_default3 = createPrompt((config2, done) => {
28713
28713
  } else {
28714
28714
  setStatus("loading");
28715
28715
  const finalAnswer = answer ?? "";
28716
- const isValid = await validate2(finalAnswer);
28717
- if (isValid === true) {
28716
+ const isValid2 = await validate2(finalAnswer);
28717
+ if (isValid2 === true) {
28718
28718
  setError(void 0);
28719
28719
  setStatus("done");
28720
28720
  done(finalAnswer);
@@ -28724,7 +28724,7 @@ var esm_default3 = createPrompt((config2, done) => {
28724
28724
  } else {
28725
28725
  setValue(finalAnswer);
28726
28726
  }
28727
- setError(isValid || "You must provide a valid value");
28727
+ setError(isValid2 || "You must provide a valid value");
28728
28728
  setStatus("idle");
28729
28729
  }
28730
28730
  }
@@ -28840,8 +28840,8 @@ var esm_default5 = createPrompt((config2, done) => {
28840
28840
  if (isEnterKey(key)) {
28841
28841
  const answer = value || defaultValue;
28842
28842
  setStatus("loading");
28843
- const isValid = await validate2(answer);
28844
- if (isValid === true) {
28843
+ const isValid2 = await validate2(answer);
28844
+ if (isValid2 === true) {
28845
28845
  setValue(answer);
28846
28846
  setStatus("done");
28847
28847
  done(answer);
@@ -28851,7 +28851,7 @@ var esm_default5 = createPrompt((config2, done) => {
28851
28851
  } else {
28852
28852
  rl.write(value);
28853
28853
  }
28854
- setError(isValid);
28854
+ setError(isValid2);
28855
28855
  setStatus("idle");
28856
28856
  }
28857
28857
  } else if (isBackspaceKey(key) && !value) {
@@ -28927,20 +28927,20 @@ var esm_default6 = createPrompt((config2, done) => {
28927
28927
  const input2 = value || defaultValue;
28928
28928
  const answer = input2 === "" ? void 0 : Number(input2);
28929
28929
  setStatus("loading");
28930
- let isValid = true;
28930
+ let isValid2 = true;
28931
28931
  if (required2 || answer != null) {
28932
- isValid = validateNumber(answer, { min, max, step });
28932
+ isValid2 = validateNumber(answer, { min, max, step });
28933
28933
  }
28934
- if (isValid === true) {
28935
- isValid = await validate2(answer);
28934
+ if (isValid2 === true) {
28935
+ isValid2 = await validate2(answer);
28936
28936
  }
28937
- if (isValid === true) {
28937
+ if (isValid2 === true) {
28938
28938
  setValue(String(answer ?? ""));
28939
28939
  setStatus("done");
28940
28940
  done(answer);
28941
28941
  } else {
28942
28942
  rl.write(value);
28943
- setError(isValid || "You must provide a valid numeric value");
28943
+ setError(isValid2 || "You must provide a valid numeric value");
28944
28944
  setStatus("idle");
28945
28945
  }
28946
28946
  } else if (isBackspaceKey(key) && !value) {
@@ -29195,14 +29195,14 @@ var esm_default9 = createPrompt((config2, done) => {
29195
29195
  if (isEnterKey(key)) {
29196
29196
  const answer = value;
29197
29197
  setStatus("loading");
29198
- const isValid = await validate2(answer);
29199
- if (isValid === true) {
29198
+ const isValid2 = await validate2(answer);
29199
+ if (isValid2 === true) {
29200
29200
  setValue(answer);
29201
29201
  setStatus("done");
29202
29202
  done(answer);
29203
29203
  } else {
29204
29204
  rl.write(value);
29205
- setError(isValid || "You must provide a valid value");
29205
+ setError(isValid2 || "You must provide a valid value");
29206
29206
  setStatus("idle");
29207
29207
  }
29208
29208
  } else {
@@ -29314,13 +29314,13 @@ var esm_default10 = createPrompt((config2, done) => {
29314
29314
  if (isEnterKey(key)) {
29315
29315
  if (selectedChoice) {
29316
29316
  setStatus("loading");
29317
- const isValid = await validate2(selectedChoice.value);
29317
+ const isValid2 = await validate2(selectedChoice.value);
29318
29318
  setStatus("idle");
29319
- if (isValid === true) {
29319
+ if (isValid2 === true) {
29320
29320
  setStatus("done");
29321
29321
  done(selectedChoice.value);
29322
29322
  } else if (selectedChoice.name === searchTerm) {
29323
- setSearchError(isValid || "You must provide a valid value");
29323
+ setSearchError(isValid2 || "You must provide a valid value");
29324
29324
  } else {
29325
29325
  rl.write(selectedChoice.name);
29326
29326
  setSearchTerm(selectedChoice.name);
@@ -34963,8 +34963,8 @@ function datetime(args) {
34963
34963
  if (args.offset)
34964
34964
  opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
34965
34965
  const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
34966
- const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
34967
- return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
34966
+ const timeRegex2 = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
34967
+ return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
34968
34968
  }
34969
34969
  var anyString = /^[\s\S]{0,}$/;
34970
34970
  var string = (params) => {
@@ -35549,7 +35549,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
35549
35549
  const runChecks = (payload, checks2, ctx) => {
35550
35550
  if (payload.memo)
35551
35551
  return payload;
35552
- let isAborted = aborted(payload);
35552
+ let isAborted2 = aborted(payload);
35553
35553
  let asyncResult;
35554
35554
  for (const ch of checks2) {
35555
35555
  if (ch._zod.def.when) {
@@ -35558,7 +35558,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
35558
35558
  const shouldRun = ch._zod.def.when(payload);
35559
35559
  if (!shouldRun)
35560
35560
  continue;
35561
- } else if (isAborted) {
35561
+ } else if (isAborted2) {
35562
35562
  continue;
35563
35563
  }
35564
35564
  const currLen = payload.issues.length;
@@ -35573,16 +35573,16 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
35573
35573
  if (nextLen === currLen)
35574
35574
  return;
35575
35575
  attachSchema(payload.issues, currLen, inst);
35576
- if (!isAborted)
35577
- isAborted = aborted(payload, currLen);
35576
+ if (!isAborted2)
35577
+ isAborted2 = aborted(payload, currLen);
35578
35578
  });
35579
35579
  } else {
35580
35580
  const nextLen = payload.issues.length;
35581
35581
  if (nextLen === currLen)
35582
35582
  continue;
35583
35583
  attachSchema(payload.issues, currLen, inst);
35584
- if (!isAborted)
35585
- isAborted = aborted(payload, currLen);
35584
+ if (!isAborted2)
35585
+ isAborted2 = aborted(payload, currLen);
35586
35586
  }
35587
35587
  }
35588
35588
  if (asyncResult) {
@@ -51654,7 +51654,7 @@ function getErrorMap() {
51654
51654
  return config().customError;
51655
51655
  }
51656
51656
  var ZodFirstPartyTypeKind;
51657
- /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
51657
+ /* @__PURE__ */ (function(ZodFirstPartyTypeKind3) {
51658
51658
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
51659
51659
 
51660
51660
  // node_modules/zod/v4/classic/iso.js
@@ -52705,7 +52705,7 @@ var VALID_ADDON_CAPABILITIES = [
52705
52705
  "auth",
52706
52706
  "dataSource",
52707
52707
  "analytics",
52708
- "watcher",
52708
+ "observer",
52709
52709
  "calendar",
52710
52710
  "punch",
52711
52711
  "theme"
@@ -52718,8 +52718,4127 @@ function isDataSource(capabilities) {
52718
52718
  return hasCapability(capabilities, "dataSource");
52719
52719
  }
52720
52720
 
52721
- // src/contracts/manifest/IAddonManifest.ts
52721
+ // ../../packages/domain/node_modules/zod/v3/external.js
52722
+ var external_exports2 = {};
52723
+ __export(external_exports2, {
52724
+ BRAND: () => BRAND,
52725
+ DIRTY: () => DIRTY,
52726
+ EMPTY_PATH: () => EMPTY_PATH,
52727
+ INVALID: () => INVALID2,
52728
+ NEVER: () => NEVER2,
52729
+ OK: () => OK,
52730
+ ParseStatus: () => ParseStatus,
52731
+ Schema: () => ZodType2,
52732
+ ZodAny: () => ZodAny2,
52733
+ ZodArray: () => ZodArray2,
52734
+ ZodBigInt: () => ZodBigInt2,
52735
+ ZodBoolean: () => ZodBoolean2,
52736
+ ZodBranded: () => ZodBranded,
52737
+ ZodCatch: () => ZodCatch2,
52738
+ ZodDate: () => ZodDate2,
52739
+ ZodDefault: () => ZodDefault2,
52740
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion2,
52741
+ ZodEffects: () => ZodEffects,
52742
+ ZodEnum: () => ZodEnum2,
52743
+ ZodError: () => ZodError2,
52744
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind2,
52745
+ ZodFunction: () => ZodFunction2,
52746
+ ZodIntersection: () => ZodIntersection2,
52747
+ ZodIssueCode: () => ZodIssueCode2,
52748
+ ZodLazy: () => ZodLazy2,
52749
+ ZodLiteral: () => ZodLiteral2,
52750
+ ZodMap: () => ZodMap2,
52751
+ ZodNaN: () => ZodNaN2,
52752
+ ZodNativeEnum: () => ZodNativeEnum,
52753
+ ZodNever: () => ZodNever2,
52754
+ ZodNull: () => ZodNull2,
52755
+ ZodNullable: () => ZodNullable2,
52756
+ ZodNumber: () => ZodNumber2,
52757
+ ZodObject: () => ZodObject2,
52758
+ ZodOptional: () => ZodOptional2,
52759
+ ZodParsedType: () => ZodParsedType,
52760
+ ZodPipeline: () => ZodPipeline,
52761
+ ZodPromise: () => ZodPromise2,
52762
+ ZodReadonly: () => ZodReadonly2,
52763
+ ZodRecord: () => ZodRecord2,
52764
+ ZodSchema: () => ZodType2,
52765
+ ZodSet: () => ZodSet2,
52766
+ ZodString: () => ZodString2,
52767
+ ZodSymbol: () => ZodSymbol2,
52768
+ ZodTransformer: () => ZodEffects,
52769
+ ZodTuple: () => ZodTuple2,
52770
+ ZodType: () => ZodType2,
52771
+ ZodUndefined: () => ZodUndefined2,
52772
+ ZodUnion: () => ZodUnion2,
52773
+ ZodUnknown: () => ZodUnknown2,
52774
+ ZodVoid: () => ZodVoid2,
52775
+ addIssueToContext: () => addIssueToContext,
52776
+ any: () => anyType,
52777
+ array: () => arrayType,
52778
+ bigint: () => bigIntType,
52779
+ boolean: () => booleanType,
52780
+ coerce: () => coerce,
52781
+ custom: () => custom2,
52782
+ date: () => dateType,
52783
+ datetimeRegex: () => datetimeRegex,
52784
+ defaultErrorMap: () => en_default2,
52785
+ discriminatedUnion: () => discriminatedUnionType,
52786
+ effect: () => effectsType,
52787
+ enum: () => enumType,
52788
+ function: () => functionType,
52789
+ getErrorMap: () => getErrorMap2,
52790
+ getParsedType: () => getParsedType2,
52791
+ instanceof: () => instanceOfType,
52792
+ intersection: () => intersectionType,
52793
+ isAborted: () => isAborted,
52794
+ isAsync: () => isAsync,
52795
+ isDirty: () => isDirty,
52796
+ isValid: () => isValid,
52797
+ late: () => late,
52798
+ lazy: () => lazyType,
52799
+ literal: () => literalType,
52800
+ makeIssue: () => makeIssue,
52801
+ map: () => mapType,
52802
+ nan: () => nanType,
52803
+ nativeEnum: () => nativeEnumType,
52804
+ never: () => neverType,
52805
+ null: () => nullType,
52806
+ nullable: () => nullableType,
52807
+ number: () => numberType,
52808
+ object: () => objectType,
52809
+ objectUtil: () => objectUtil,
52810
+ oboolean: () => oboolean,
52811
+ onumber: () => onumber,
52812
+ optional: () => optionalType,
52813
+ ostring: () => ostring,
52814
+ pipeline: () => pipelineType,
52815
+ preprocess: () => preprocessType,
52816
+ promise: () => promiseType,
52817
+ quotelessJson: () => quotelessJson,
52818
+ record: () => recordType,
52819
+ set: () => setType,
52820
+ setErrorMap: () => setErrorMap2,
52821
+ strictObject: () => strictObjectType,
52822
+ string: () => stringType,
52823
+ symbol: () => symbolType,
52824
+ transformer: () => effectsType,
52825
+ tuple: () => tupleType,
52826
+ undefined: () => undefinedType,
52827
+ union: () => unionType,
52828
+ unknown: () => unknownType,
52829
+ util: () => util,
52830
+ void: () => voidType
52831
+ });
52832
+
52833
+ // ../../packages/domain/node_modules/zod/v3/helpers/util.js
52834
+ var util;
52835
+ (function(util2) {
52836
+ util2.assertEqual = (_2) => {
52837
+ };
52838
+ function assertIs2(_arg) {
52839
+ }
52840
+ util2.assertIs = assertIs2;
52841
+ function assertNever2(_x) {
52842
+ throw new Error();
52843
+ }
52844
+ util2.assertNever = assertNever2;
52845
+ util2.arrayToEnum = (items) => {
52846
+ const obj = {};
52847
+ for (const item of items) {
52848
+ obj[item] = item;
52849
+ }
52850
+ return obj;
52851
+ };
52852
+ util2.getValidEnumValues = (obj) => {
52853
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
52854
+ const filtered = {};
52855
+ for (const k of validKeys) {
52856
+ filtered[k] = obj[k];
52857
+ }
52858
+ return util2.objectValues(filtered);
52859
+ };
52860
+ util2.objectValues = (obj) => {
52861
+ return util2.objectKeys(obj).map(function(e) {
52862
+ return obj[e];
52863
+ });
52864
+ };
52865
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
52866
+ const keys = [];
52867
+ for (const key in object2) {
52868
+ if (Object.prototype.hasOwnProperty.call(object2, key)) {
52869
+ keys.push(key);
52870
+ }
52871
+ }
52872
+ return keys;
52873
+ };
52874
+ util2.find = (arr, checker) => {
52875
+ for (const item of arr) {
52876
+ if (checker(item))
52877
+ return item;
52878
+ }
52879
+ return void 0;
52880
+ };
52881
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
52882
+ function joinValues2(array2, separator = " | ") {
52883
+ return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
52884
+ }
52885
+ util2.joinValues = joinValues2;
52886
+ util2.jsonStringifyReplacer = (_2, value) => {
52887
+ if (typeof value === "bigint") {
52888
+ return value.toString();
52889
+ }
52890
+ return value;
52891
+ };
52892
+ })(util || (util = {}));
52893
+ var objectUtil;
52894
+ (function(objectUtil2) {
52895
+ objectUtil2.mergeShapes = (first, second) => {
52896
+ return {
52897
+ ...first,
52898
+ ...second
52899
+ // second overwrites first
52900
+ };
52901
+ };
52902
+ })(objectUtil || (objectUtil = {}));
52903
+ var ZodParsedType = util.arrayToEnum([
52904
+ "string",
52905
+ "nan",
52906
+ "number",
52907
+ "integer",
52908
+ "float",
52909
+ "boolean",
52910
+ "date",
52911
+ "bigint",
52912
+ "symbol",
52913
+ "function",
52914
+ "undefined",
52915
+ "null",
52916
+ "array",
52917
+ "object",
52918
+ "unknown",
52919
+ "promise",
52920
+ "void",
52921
+ "never",
52922
+ "map",
52923
+ "set"
52924
+ ]);
52925
+ var getParsedType2 = (data) => {
52926
+ const t = typeof data;
52927
+ switch (t) {
52928
+ case "undefined":
52929
+ return ZodParsedType.undefined;
52930
+ case "string":
52931
+ return ZodParsedType.string;
52932
+ case "number":
52933
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
52934
+ case "boolean":
52935
+ return ZodParsedType.boolean;
52936
+ case "function":
52937
+ return ZodParsedType.function;
52938
+ case "bigint":
52939
+ return ZodParsedType.bigint;
52940
+ case "symbol":
52941
+ return ZodParsedType.symbol;
52942
+ case "object":
52943
+ if (Array.isArray(data)) {
52944
+ return ZodParsedType.array;
52945
+ }
52946
+ if (data === null) {
52947
+ return ZodParsedType.null;
52948
+ }
52949
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
52950
+ return ZodParsedType.promise;
52951
+ }
52952
+ if (typeof Map !== "undefined" && data instanceof Map) {
52953
+ return ZodParsedType.map;
52954
+ }
52955
+ if (typeof Set !== "undefined" && data instanceof Set) {
52956
+ return ZodParsedType.set;
52957
+ }
52958
+ if (typeof Date !== "undefined" && data instanceof Date) {
52959
+ return ZodParsedType.date;
52960
+ }
52961
+ return ZodParsedType.object;
52962
+ default:
52963
+ return ZodParsedType.unknown;
52964
+ }
52965
+ };
52966
+
52967
+ // ../../packages/domain/node_modules/zod/v3/ZodError.js
52968
+ var ZodIssueCode2 = util.arrayToEnum([
52969
+ "invalid_type",
52970
+ "invalid_literal",
52971
+ "custom",
52972
+ "invalid_union",
52973
+ "invalid_union_discriminator",
52974
+ "invalid_enum_value",
52975
+ "unrecognized_keys",
52976
+ "invalid_arguments",
52977
+ "invalid_return_type",
52978
+ "invalid_date",
52979
+ "invalid_string",
52980
+ "too_small",
52981
+ "too_big",
52982
+ "invalid_intersection_types",
52983
+ "not_multiple_of",
52984
+ "not_finite"
52985
+ ]);
52986
+ var quotelessJson = (obj) => {
52987
+ const json3 = JSON.stringify(obj, null, 2);
52988
+ return json3.replace(/"([^"]+)":/g, "$1:");
52989
+ };
52990
+ var ZodError2 = class _ZodError extends Error {
52991
+ get errors() {
52992
+ return this.issues;
52993
+ }
52994
+ constructor(issues) {
52995
+ super();
52996
+ this.issues = [];
52997
+ this.addIssue = (sub) => {
52998
+ this.issues = [...this.issues, sub];
52999
+ };
53000
+ this.addIssues = (subs = []) => {
53001
+ this.issues = [...this.issues, ...subs];
53002
+ };
53003
+ const actualProto = new.target.prototype;
53004
+ if (Object.setPrototypeOf) {
53005
+ Object.setPrototypeOf(this, actualProto);
53006
+ } else {
53007
+ this.__proto__ = actualProto;
53008
+ }
53009
+ this.name = "ZodError";
53010
+ this.issues = issues;
53011
+ }
53012
+ format(_mapper) {
53013
+ const mapper = _mapper || function(issue2) {
53014
+ return issue2.message;
53015
+ };
53016
+ const fieldErrors = { _errors: [] };
53017
+ const processError = (error62) => {
53018
+ for (const issue2 of error62.issues) {
53019
+ if (issue2.code === "invalid_union") {
53020
+ issue2.unionErrors.map(processError);
53021
+ } else if (issue2.code === "invalid_return_type") {
53022
+ processError(issue2.returnTypeError);
53023
+ } else if (issue2.code === "invalid_arguments") {
53024
+ processError(issue2.argumentsError);
53025
+ } else if (issue2.path.length === 0) {
53026
+ fieldErrors._errors.push(mapper(issue2));
53027
+ } else {
53028
+ let curr = fieldErrors;
53029
+ let i = 0;
53030
+ while (i < issue2.path.length) {
53031
+ const el = issue2.path[i];
53032
+ const terminal = i === issue2.path.length - 1;
53033
+ if (!terminal) {
53034
+ curr[el] = curr[el] || { _errors: [] };
53035
+ } else {
53036
+ curr[el] = curr[el] || { _errors: [] };
53037
+ curr[el]._errors.push(mapper(issue2));
53038
+ }
53039
+ curr = curr[el];
53040
+ i++;
53041
+ }
53042
+ }
53043
+ }
53044
+ };
53045
+ processError(this);
53046
+ return fieldErrors;
53047
+ }
53048
+ static assert(value) {
53049
+ if (!(value instanceof _ZodError)) {
53050
+ throw new Error(`Not a ZodError: ${value}`);
53051
+ }
53052
+ }
53053
+ toString() {
53054
+ return this.message;
53055
+ }
53056
+ get message() {
53057
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
53058
+ }
53059
+ get isEmpty() {
53060
+ return this.issues.length === 0;
53061
+ }
53062
+ flatten(mapper = (issue2) => issue2.message) {
53063
+ const fieldErrors = {};
53064
+ const formErrors = [];
53065
+ for (const sub of this.issues) {
53066
+ if (sub.path.length > 0) {
53067
+ const firstEl = sub.path[0];
53068
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
53069
+ fieldErrors[firstEl].push(mapper(sub));
53070
+ } else {
53071
+ formErrors.push(mapper(sub));
53072
+ }
53073
+ }
53074
+ return { formErrors, fieldErrors };
53075
+ }
53076
+ get formErrors() {
53077
+ return this.flatten();
53078
+ }
53079
+ };
53080
+ ZodError2.create = (issues) => {
53081
+ const error62 = new ZodError2(issues);
53082
+ return error62;
53083
+ };
53084
+
53085
+ // ../../packages/domain/node_modules/zod/v3/locales/en.js
53086
+ var errorMap = (issue2, _ctx) => {
53087
+ let message;
53088
+ switch (issue2.code) {
53089
+ case ZodIssueCode2.invalid_type:
53090
+ if (issue2.received === ZodParsedType.undefined) {
53091
+ message = "Required";
53092
+ } else {
53093
+ message = `Expected ${issue2.expected}, received ${issue2.received}`;
53094
+ }
53095
+ break;
53096
+ case ZodIssueCode2.invalid_literal:
53097
+ message = `Invalid literal value, expected ${JSON.stringify(issue2.expected, util.jsonStringifyReplacer)}`;
53098
+ break;
53099
+ case ZodIssueCode2.unrecognized_keys:
53100
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue2.keys, ", ")}`;
53101
+ break;
53102
+ case ZodIssueCode2.invalid_union:
53103
+ message = `Invalid input`;
53104
+ break;
53105
+ case ZodIssueCode2.invalid_union_discriminator:
53106
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue2.options)}`;
53107
+ break;
53108
+ case ZodIssueCode2.invalid_enum_value:
53109
+ message = `Invalid enum value. Expected ${util.joinValues(issue2.options)}, received '${issue2.received}'`;
53110
+ break;
53111
+ case ZodIssueCode2.invalid_arguments:
53112
+ message = `Invalid function arguments`;
53113
+ break;
53114
+ case ZodIssueCode2.invalid_return_type:
53115
+ message = `Invalid function return type`;
53116
+ break;
53117
+ case ZodIssueCode2.invalid_date:
53118
+ message = `Invalid date`;
53119
+ break;
53120
+ case ZodIssueCode2.invalid_string:
53121
+ if (typeof issue2.validation === "object") {
53122
+ if ("includes" in issue2.validation) {
53123
+ message = `Invalid input: must include "${issue2.validation.includes}"`;
53124
+ if (typeof issue2.validation.position === "number") {
53125
+ message = `${message} at one or more positions greater than or equal to ${issue2.validation.position}`;
53126
+ }
53127
+ } else if ("startsWith" in issue2.validation) {
53128
+ message = `Invalid input: must start with "${issue2.validation.startsWith}"`;
53129
+ } else if ("endsWith" in issue2.validation) {
53130
+ message = `Invalid input: must end with "${issue2.validation.endsWith}"`;
53131
+ } else {
53132
+ util.assertNever(issue2.validation);
53133
+ }
53134
+ } else if (issue2.validation !== "regex") {
53135
+ message = `Invalid ${issue2.validation}`;
53136
+ } else {
53137
+ message = "Invalid";
53138
+ }
53139
+ break;
53140
+ case ZodIssueCode2.too_small:
53141
+ if (issue2.type === "array")
53142
+ message = `Array must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `more than`} ${issue2.minimum} element(s)`;
53143
+ else if (issue2.type === "string")
53144
+ message = `String must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `over`} ${issue2.minimum} character(s)`;
53145
+ else if (issue2.type === "number")
53146
+ message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
53147
+ else if (issue2.type === "bigint")
53148
+ message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
53149
+ else if (issue2.type === "date")
53150
+ message = `Date must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue2.minimum))}`;
53151
+ else
53152
+ message = "Invalid input";
53153
+ break;
53154
+ case ZodIssueCode2.too_big:
53155
+ if (issue2.type === "array")
53156
+ message = `Array must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `less than`} ${issue2.maximum} element(s)`;
53157
+ else if (issue2.type === "string")
53158
+ message = `String must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `under`} ${issue2.maximum} character(s)`;
53159
+ else if (issue2.type === "number")
53160
+ message = `Number must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
53161
+ else if (issue2.type === "bigint")
53162
+ message = `BigInt must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
53163
+ else if (issue2.type === "date")
53164
+ message = `Date must be ${issue2.exact ? `exactly` : issue2.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue2.maximum))}`;
53165
+ else
53166
+ message = "Invalid input";
53167
+ break;
53168
+ case ZodIssueCode2.custom:
53169
+ message = `Invalid input`;
53170
+ break;
53171
+ case ZodIssueCode2.invalid_intersection_types:
53172
+ message = `Intersection results could not be merged`;
53173
+ break;
53174
+ case ZodIssueCode2.not_multiple_of:
53175
+ message = `Number must be a multiple of ${issue2.multipleOf}`;
53176
+ break;
53177
+ case ZodIssueCode2.not_finite:
53178
+ message = "Number must be finite";
53179
+ break;
53180
+ default:
53181
+ message = _ctx.defaultError;
53182
+ util.assertNever(issue2);
53183
+ }
53184
+ return { message };
53185
+ };
53186
+ var en_default2 = errorMap;
53187
+
53188
+ // ../../packages/domain/node_modules/zod/v3/errors.js
53189
+ var overrideErrorMap = en_default2;
53190
+ function setErrorMap2(map3) {
53191
+ overrideErrorMap = map3;
53192
+ }
53193
+ function getErrorMap2() {
53194
+ return overrideErrorMap;
53195
+ }
53196
+
53197
+ // ../../packages/domain/node_modules/zod/v3/helpers/parseUtil.js
53198
+ var makeIssue = (params) => {
53199
+ const { data, path: path11, errorMaps, issueData } = params;
53200
+ const fullPath = [...path11, ...issueData.path || []];
53201
+ const fullIssue = {
53202
+ ...issueData,
53203
+ path: fullPath
53204
+ };
53205
+ if (issueData.message !== void 0) {
53206
+ return {
53207
+ ...issueData,
53208
+ path: fullPath,
53209
+ message: issueData.message
53210
+ };
53211
+ }
53212
+ let errorMessage = "";
53213
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
53214
+ for (const map3 of maps) {
53215
+ errorMessage = map3(fullIssue, { data, defaultError: errorMessage }).message;
53216
+ }
53217
+ return {
53218
+ ...issueData,
53219
+ path: fullPath,
53220
+ message: errorMessage
53221
+ };
53222
+ };
53223
+ var EMPTY_PATH = [];
53224
+ function addIssueToContext(ctx, issueData) {
53225
+ const overrideMap = getErrorMap2();
53226
+ const issue2 = makeIssue({
53227
+ issueData,
53228
+ data: ctx.data,
53229
+ path: ctx.path,
53230
+ errorMaps: [
53231
+ ctx.common.contextualErrorMap,
53232
+ // contextual error map is first priority
53233
+ ctx.schemaErrorMap,
53234
+ // then schema-bound map if available
53235
+ overrideMap,
53236
+ // then global override map
53237
+ overrideMap === en_default2 ? void 0 : en_default2
53238
+ // then global default map
53239
+ ].filter((x) => !!x)
53240
+ });
53241
+ ctx.common.issues.push(issue2);
53242
+ }
53243
+ var ParseStatus = class _ParseStatus {
53244
+ constructor() {
53245
+ this.value = "valid";
53246
+ }
53247
+ dirty() {
53248
+ if (this.value === "valid")
53249
+ this.value = "dirty";
53250
+ }
53251
+ abort() {
53252
+ if (this.value !== "aborted")
53253
+ this.value = "aborted";
53254
+ }
53255
+ static mergeArray(status, results) {
53256
+ const arrayValue = [];
53257
+ for (const s of results) {
53258
+ if (s.status === "aborted")
53259
+ return INVALID2;
53260
+ if (s.status === "dirty")
53261
+ status.dirty();
53262
+ arrayValue.push(s.value);
53263
+ }
53264
+ return { status: status.value, value: arrayValue };
53265
+ }
53266
+ static async mergeObjectAsync(status, pairs2) {
53267
+ const syncPairs = [];
53268
+ for (const pair of pairs2) {
53269
+ const key = await pair.key;
53270
+ const value = await pair.value;
53271
+ syncPairs.push({
53272
+ key,
53273
+ value
53274
+ });
53275
+ }
53276
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
53277
+ }
53278
+ static mergeObjectSync(status, pairs2) {
53279
+ const finalObject = {};
53280
+ for (const pair of pairs2) {
53281
+ const { key, value } = pair;
53282
+ if (key.status === "aborted")
53283
+ return INVALID2;
53284
+ if (value.status === "aborted")
53285
+ return INVALID2;
53286
+ if (key.status === "dirty")
53287
+ status.dirty();
53288
+ if (value.status === "dirty")
53289
+ status.dirty();
53290
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
53291
+ finalObject[key.value] = value.value;
53292
+ }
53293
+ }
53294
+ return { status: status.value, value: finalObject };
53295
+ }
53296
+ };
53297
+ var INVALID2 = Object.freeze({
53298
+ status: "aborted"
53299
+ });
53300
+ var DIRTY = (value) => ({ status: "dirty", value });
53301
+ var OK = (value) => ({ status: "valid", value });
53302
+ var isAborted = (x) => x.status === "aborted";
53303
+ var isDirty = (x) => x.status === "dirty";
53304
+ var isValid = (x) => x.status === "valid";
53305
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
53306
+
53307
+ // ../../packages/domain/node_modules/zod/v3/helpers/errorUtil.js
53308
+ var errorUtil;
53309
+ (function(errorUtil2) {
53310
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
53311
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
53312
+ })(errorUtil || (errorUtil = {}));
53313
+
53314
+ // ../../packages/domain/node_modules/zod/v3/types.js
53315
+ var ParseInputLazyPath = class {
53316
+ constructor(parent, value, path11, key) {
53317
+ this._cachedPath = [];
53318
+ this.parent = parent;
53319
+ this.data = value;
53320
+ this._path = path11;
53321
+ this._key = key;
53322
+ }
53323
+ get path() {
53324
+ if (!this._cachedPath.length) {
53325
+ if (Array.isArray(this._key)) {
53326
+ this._cachedPath.push(...this._path, ...this._key);
53327
+ } else {
53328
+ this._cachedPath.push(...this._path, this._key);
53329
+ }
53330
+ }
53331
+ return this._cachedPath;
53332
+ }
53333
+ };
53334
+ var handleResult = (ctx, result) => {
53335
+ if (isValid(result)) {
53336
+ return { success: true, data: result.value };
53337
+ } else {
53338
+ if (!ctx.common.issues.length) {
53339
+ throw new Error("Validation failed but no issues detected.");
53340
+ }
53341
+ return {
53342
+ success: false,
53343
+ get error() {
53344
+ if (this._error)
53345
+ return this._error;
53346
+ const error62 = new ZodError2(ctx.common.issues);
53347
+ this._error = error62;
53348
+ return this._error;
53349
+ }
53350
+ };
53351
+ }
53352
+ };
53353
+ function processCreateParams(params) {
53354
+ if (!params)
53355
+ return {};
53356
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
53357
+ if (errorMap2 && (invalid_type_error || required_error)) {
53358
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
53359
+ }
53360
+ if (errorMap2)
53361
+ return { errorMap: errorMap2, description };
53362
+ const customMap = (iss, ctx) => {
53363
+ const { message } = params;
53364
+ if (iss.code === "invalid_enum_value") {
53365
+ return { message: message ?? ctx.defaultError };
53366
+ }
53367
+ if (typeof ctx.data === "undefined") {
53368
+ return { message: message ?? required_error ?? ctx.defaultError };
53369
+ }
53370
+ if (iss.code !== "invalid_type")
53371
+ return { message: ctx.defaultError };
53372
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
53373
+ };
53374
+ return { errorMap: customMap, description };
53375
+ }
53376
+ var ZodType2 = class {
53377
+ get description() {
53378
+ return this._def.description;
53379
+ }
53380
+ _getType(input2) {
53381
+ return getParsedType2(input2.data);
53382
+ }
53383
+ _getOrReturnCtx(input2, ctx) {
53384
+ return ctx || {
53385
+ common: input2.parent.common,
53386
+ data: input2.data,
53387
+ parsedType: getParsedType2(input2.data),
53388
+ schemaErrorMap: this._def.errorMap,
53389
+ path: input2.path,
53390
+ parent: input2.parent
53391
+ };
53392
+ }
53393
+ _processInputParams(input2) {
53394
+ return {
53395
+ status: new ParseStatus(),
53396
+ ctx: {
53397
+ common: input2.parent.common,
53398
+ data: input2.data,
53399
+ parsedType: getParsedType2(input2.data),
53400
+ schemaErrorMap: this._def.errorMap,
53401
+ path: input2.path,
53402
+ parent: input2.parent
53403
+ }
53404
+ };
53405
+ }
53406
+ _parseSync(input2) {
53407
+ const result = this._parse(input2);
53408
+ if (isAsync(result)) {
53409
+ throw new Error("Synchronous parse encountered promise.");
53410
+ }
53411
+ return result;
53412
+ }
53413
+ _parseAsync(input2) {
53414
+ const result = this._parse(input2);
53415
+ return Promise.resolve(result);
53416
+ }
53417
+ parse(data, params) {
53418
+ const result = this.safeParse(data, params);
53419
+ if (result.success)
53420
+ return result.data;
53421
+ throw result.error;
53422
+ }
53423
+ safeParse(data, params) {
53424
+ const ctx = {
53425
+ common: {
53426
+ issues: [],
53427
+ async: params?.async ?? false,
53428
+ contextualErrorMap: params?.errorMap
53429
+ },
53430
+ path: params?.path || [],
53431
+ schemaErrorMap: this._def.errorMap,
53432
+ parent: null,
53433
+ data,
53434
+ parsedType: getParsedType2(data)
53435
+ };
53436
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
53437
+ return handleResult(ctx, result);
53438
+ }
53439
+ "~validate"(data) {
53440
+ const ctx = {
53441
+ common: {
53442
+ issues: [],
53443
+ async: !!this["~standard"].async
53444
+ },
53445
+ path: [],
53446
+ schemaErrorMap: this._def.errorMap,
53447
+ parent: null,
53448
+ data,
53449
+ parsedType: getParsedType2(data)
53450
+ };
53451
+ if (!this["~standard"].async) {
53452
+ try {
53453
+ const result = this._parseSync({ data, path: [], parent: ctx });
53454
+ return isValid(result) ? {
53455
+ value: result.value
53456
+ } : {
53457
+ issues: ctx.common.issues
53458
+ };
53459
+ } catch (err) {
53460
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
53461
+ this["~standard"].async = true;
53462
+ }
53463
+ ctx.common = {
53464
+ issues: [],
53465
+ async: true
53466
+ };
53467
+ }
53468
+ }
53469
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
53470
+ value: result.value
53471
+ } : {
53472
+ issues: ctx.common.issues
53473
+ });
53474
+ }
53475
+ async parseAsync(data, params) {
53476
+ const result = await this.safeParseAsync(data, params);
53477
+ if (result.success)
53478
+ return result.data;
53479
+ throw result.error;
53480
+ }
53481
+ async safeParseAsync(data, params) {
53482
+ const ctx = {
53483
+ common: {
53484
+ issues: [],
53485
+ contextualErrorMap: params?.errorMap,
53486
+ async: true
53487
+ },
53488
+ path: params?.path || [],
53489
+ schemaErrorMap: this._def.errorMap,
53490
+ parent: null,
53491
+ data,
53492
+ parsedType: getParsedType2(data)
53493
+ };
53494
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
53495
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
53496
+ return handleResult(ctx, result);
53497
+ }
53498
+ refine(check3, message) {
53499
+ const getIssueProperties = (val) => {
53500
+ if (typeof message === "string" || typeof message === "undefined") {
53501
+ return { message };
53502
+ } else if (typeof message === "function") {
53503
+ return message(val);
53504
+ } else {
53505
+ return message;
53506
+ }
53507
+ };
53508
+ return this._refinement((val, ctx) => {
53509
+ const result = check3(val);
53510
+ const setError = () => ctx.addIssue({
53511
+ code: ZodIssueCode2.custom,
53512
+ ...getIssueProperties(val)
53513
+ });
53514
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
53515
+ return result.then((data) => {
53516
+ if (!data) {
53517
+ setError();
53518
+ return false;
53519
+ } else {
53520
+ return true;
53521
+ }
53522
+ });
53523
+ }
53524
+ if (!result) {
53525
+ setError();
53526
+ return false;
53527
+ } else {
53528
+ return true;
53529
+ }
53530
+ });
53531
+ }
53532
+ refinement(check3, refinementData) {
53533
+ return this._refinement((val, ctx) => {
53534
+ if (!check3(val)) {
53535
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
53536
+ return false;
53537
+ } else {
53538
+ return true;
53539
+ }
53540
+ });
53541
+ }
53542
+ _refinement(refinement) {
53543
+ return new ZodEffects({
53544
+ schema: this,
53545
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
53546
+ effect: { type: "refinement", refinement }
53547
+ });
53548
+ }
53549
+ superRefine(refinement) {
53550
+ return this._refinement(refinement);
53551
+ }
53552
+ constructor(def) {
53553
+ this.spa = this.safeParseAsync;
53554
+ this._def = def;
53555
+ this.parse = this.parse.bind(this);
53556
+ this.safeParse = this.safeParse.bind(this);
53557
+ this.parseAsync = this.parseAsync.bind(this);
53558
+ this.safeParseAsync = this.safeParseAsync.bind(this);
53559
+ this.spa = this.spa.bind(this);
53560
+ this.refine = this.refine.bind(this);
53561
+ this.refinement = this.refinement.bind(this);
53562
+ this.superRefine = this.superRefine.bind(this);
53563
+ this.optional = this.optional.bind(this);
53564
+ this.nullable = this.nullable.bind(this);
53565
+ this.nullish = this.nullish.bind(this);
53566
+ this.array = this.array.bind(this);
53567
+ this.promise = this.promise.bind(this);
53568
+ this.or = this.or.bind(this);
53569
+ this.and = this.and.bind(this);
53570
+ this.transform = this.transform.bind(this);
53571
+ this.brand = this.brand.bind(this);
53572
+ this.default = this.default.bind(this);
53573
+ this.catch = this.catch.bind(this);
53574
+ this.describe = this.describe.bind(this);
53575
+ this.pipe = this.pipe.bind(this);
53576
+ this.readonly = this.readonly.bind(this);
53577
+ this.isNullable = this.isNullable.bind(this);
53578
+ this.isOptional = this.isOptional.bind(this);
53579
+ this["~standard"] = {
53580
+ version: 1,
53581
+ vendor: "zod",
53582
+ validate: (data) => this["~validate"](data)
53583
+ };
53584
+ }
53585
+ optional() {
53586
+ return ZodOptional2.create(this, this._def);
53587
+ }
53588
+ nullable() {
53589
+ return ZodNullable2.create(this, this._def);
53590
+ }
53591
+ nullish() {
53592
+ return this.nullable().optional();
53593
+ }
53594
+ array() {
53595
+ return ZodArray2.create(this);
53596
+ }
53597
+ promise() {
53598
+ return ZodPromise2.create(this, this._def);
53599
+ }
53600
+ or(option) {
53601
+ return ZodUnion2.create([this, option], this._def);
53602
+ }
53603
+ and(incoming) {
53604
+ return ZodIntersection2.create(this, incoming, this._def);
53605
+ }
53606
+ transform(transform2) {
53607
+ return new ZodEffects({
53608
+ ...processCreateParams(this._def),
53609
+ schema: this,
53610
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
53611
+ effect: { type: "transform", transform: transform2 }
53612
+ });
53613
+ }
53614
+ default(def) {
53615
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
53616
+ return new ZodDefault2({
53617
+ ...processCreateParams(this._def),
53618
+ innerType: this,
53619
+ defaultValue: defaultValueFunc,
53620
+ typeName: ZodFirstPartyTypeKind2.ZodDefault
53621
+ });
53622
+ }
53623
+ brand() {
53624
+ return new ZodBranded({
53625
+ typeName: ZodFirstPartyTypeKind2.ZodBranded,
53626
+ type: this,
53627
+ ...processCreateParams(this._def)
53628
+ });
53629
+ }
53630
+ catch(def) {
53631
+ const catchValueFunc = typeof def === "function" ? def : () => def;
53632
+ return new ZodCatch2({
53633
+ ...processCreateParams(this._def),
53634
+ innerType: this,
53635
+ catchValue: catchValueFunc,
53636
+ typeName: ZodFirstPartyTypeKind2.ZodCatch
53637
+ });
53638
+ }
53639
+ describe(description) {
53640
+ const This = this.constructor;
53641
+ return new This({
53642
+ ...this._def,
53643
+ description
53644
+ });
53645
+ }
53646
+ pipe(target) {
53647
+ return ZodPipeline.create(this, target);
53648
+ }
53649
+ readonly() {
53650
+ return ZodReadonly2.create(this);
53651
+ }
53652
+ isOptional() {
53653
+ return this.safeParse(void 0).success;
53654
+ }
53655
+ isNullable() {
53656
+ return this.safeParse(null).success;
53657
+ }
53658
+ };
53659
+ var cuidRegex = /^c[^\s-]{8,}$/i;
53660
+ var cuid2Regex = /^[0-9a-z]+$/;
53661
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
53662
+ 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;
53663
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
53664
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
53665
+ 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)?)??$/;
53666
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
53667
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
53668
+ var emojiRegex;
53669
+ 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])$/;
53670
+ 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])$/;
53671
+ 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]))$/;
53672
+ 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])$/;
53673
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
53674
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
53675
+ 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])))`;
53676
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
53677
+ function timeRegexSource(args) {
53678
+ let secondsRegexSource = `[0-5]\\d`;
53679
+ if (args.precision) {
53680
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
53681
+ } else if (args.precision == null) {
53682
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
53683
+ }
53684
+ const secondsQuantifier = args.precision ? "+" : "?";
53685
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
53686
+ }
53687
+ function timeRegex(args) {
53688
+ return new RegExp(`^${timeRegexSource(args)}$`);
53689
+ }
53690
+ function datetimeRegex(args) {
53691
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
53692
+ const opts = [];
53693
+ opts.push(args.local ? `Z?` : `Z`);
53694
+ if (args.offset)
53695
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
53696
+ regex = `${regex}(${opts.join("|")})`;
53697
+ return new RegExp(`^${regex}$`);
53698
+ }
53699
+ function isValidIP(ip, version2) {
53700
+ if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
53701
+ return true;
53702
+ }
53703
+ if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
53704
+ return true;
53705
+ }
53706
+ return false;
53707
+ }
53708
+ function isValidJWT2(jwt2, alg) {
53709
+ if (!jwtRegex.test(jwt2))
53710
+ return false;
53711
+ try {
53712
+ const [header] = jwt2.split(".");
53713
+ if (!header)
53714
+ return false;
53715
+ const base643 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
53716
+ const decoded = JSON.parse(atob(base643));
53717
+ if (typeof decoded !== "object" || decoded === null)
53718
+ return false;
53719
+ if ("typ" in decoded && decoded?.typ !== "JWT")
53720
+ return false;
53721
+ if (!decoded.alg)
53722
+ return false;
53723
+ if (alg && decoded.alg !== alg)
53724
+ return false;
53725
+ return true;
53726
+ } catch {
53727
+ return false;
53728
+ }
53729
+ }
53730
+ function isValidCidr(ip, version2) {
53731
+ if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
53732
+ return true;
53733
+ }
53734
+ if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
53735
+ return true;
53736
+ }
53737
+ return false;
53738
+ }
53739
+ var ZodString2 = class _ZodString2 extends ZodType2 {
53740
+ _parse(input2) {
53741
+ if (this._def.coerce) {
53742
+ input2.data = String(input2.data);
53743
+ }
53744
+ const parsedType2 = this._getType(input2);
53745
+ if (parsedType2 !== ZodParsedType.string) {
53746
+ const ctx2 = this._getOrReturnCtx(input2);
53747
+ addIssueToContext(ctx2, {
53748
+ code: ZodIssueCode2.invalid_type,
53749
+ expected: ZodParsedType.string,
53750
+ received: ctx2.parsedType
53751
+ });
53752
+ return INVALID2;
53753
+ }
53754
+ const status = new ParseStatus();
53755
+ let ctx = void 0;
53756
+ for (const check3 of this._def.checks) {
53757
+ if (check3.kind === "min") {
53758
+ if (input2.data.length < check3.value) {
53759
+ ctx = this._getOrReturnCtx(input2, ctx);
53760
+ addIssueToContext(ctx, {
53761
+ code: ZodIssueCode2.too_small,
53762
+ minimum: check3.value,
53763
+ type: "string",
53764
+ inclusive: true,
53765
+ exact: false,
53766
+ message: check3.message
53767
+ });
53768
+ status.dirty();
53769
+ }
53770
+ } else if (check3.kind === "max") {
53771
+ if (input2.data.length > check3.value) {
53772
+ ctx = this._getOrReturnCtx(input2, ctx);
53773
+ addIssueToContext(ctx, {
53774
+ code: ZodIssueCode2.too_big,
53775
+ maximum: check3.value,
53776
+ type: "string",
53777
+ inclusive: true,
53778
+ exact: false,
53779
+ message: check3.message
53780
+ });
53781
+ status.dirty();
53782
+ }
53783
+ } else if (check3.kind === "length") {
53784
+ const tooBig = input2.data.length > check3.value;
53785
+ const tooSmall = input2.data.length < check3.value;
53786
+ if (tooBig || tooSmall) {
53787
+ ctx = this._getOrReturnCtx(input2, ctx);
53788
+ if (tooBig) {
53789
+ addIssueToContext(ctx, {
53790
+ code: ZodIssueCode2.too_big,
53791
+ maximum: check3.value,
53792
+ type: "string",
53793
+ inclusive: true,
53794
+ exact: true,
53795
+ message: check3.message
53796
+ });
53797
+ } else if (tooSmall) {
53798
+ addIssueToContext(ctx, {
53799
+ code: ZodIssueCode2.too_small,
53800
+ minimum: check3.value,
53801
+ type: "string",
53802
+ inclusive: true,
53803
+ exact: true,
53804
+ message: check3.message
53805
+ });
53806
+ }
53807
+ status.dirty();
53808
+ }
53809
+ } else if (check3.kind === "email") {
53810
+ if (!emailRegex.test(input2.data)) {
53811
+ ctx = this._getOrReturnCtx(input2, ctx);
53812
+ addIssueToContext(ctx, {
53813
+ validation: "email",
53814
+ code: ZodIssueCode2.invalid_string,
53815
+ message: check3.message
53816
+ });
53817
+ status.dirty();
53818
+ }
53819
+ } else if (check3.kind === "emoji") {
53820
+ if (!emojiRegex) {
53821
+ emojiRegex = new RegExp(_emojiRegex, "u");
53822
+ }
53823
+ if (!emojiRegex.test(input2.data)) {
53824
+ ctx = this._getOrReturnCtx(input2, ctx);
53825
+ addIssueToContext(ctx, {
53826
+ validation: "emoji",
53827
+ code: ZodIssueCode2.invalid_string,
53828
+ message: check3.message
53829
+ });
53830
+ status.dirty();
53831
+ }
53832
+ } else if (check3.kind === "uuid") {
53833
+ if (!uuidRegex.test(input2.data)) {
53834
+ ctx = this._getOrReturnCtx(input2, ctx);
53835
+ addIssueToContext(ctx, {
53836
+ validation: "uuid",
53837
+ code: ZodIssueCode2.invalid_string,
53838
+ message: check3.message
53839
+ });
53840
+ status.dirty();
53841
+ }
53842
+ } else if (check3.kind === "nanoid") {
53843
+ if (!nanoidRegex.test(input2.data)) {
53844
+ ctx = this._getOrReturnCtx(input2, ctx);
53845
+ addIssueToContext(ctx, {
53846
+ validation: "nanoid",
53847
+ code: ZodIssueCode2.invalid_string,
53848
+ message: check3.message
53849
+ });
53850
+ status.dirty();
53851
+ }
53852
+ } else if (check3.kind === "cuid") {
53853
+ if (!cuidRegex.test(input2.data)) {
53854
+ ctx = this._getOrReturnCtx(input2, ctx);
53855
+ addIssueToContext(ctx, {
53856
+ validation: "cuid",
53857
+ code: ZodIssueCode2.invalid_string,
53858
+ message: check3.message
53859
+ });
53860
+ status.dirty();
53861
+ }
53862
+ } else if (check3.kind === "cuid2") {
53863
+ if (!cuid2Regex.test(input2.data)) {
53864
+ ctx = this._getOrReturnCtx(input2, ctx);
53865
+ addIssueToContext(ctx, {
53866
+ validation: "cuid2",
53867
+ code: ZodIssueCode2.invalid_string,
53868
+ message: check3.message
53869
+ });
53870
+ status.dirty();
53871
+ }
53872
+ } else if (check3.kind === "ulid") {
53873
+ if (!ulidRegex.test(input2.data)) {
53874
+ ctx = this._getOrReturnCtx(input2, ctx);
53875
+ addIssueToContext(ctx, {
53876
+ validation: "ulid",
53877
+ code: ZodIssueCode2.invalid_string,
53878
+ message: check3.message
53879
+ });
53880
+ status.dirty();
53881
+ }
53882
+ } else if (check3.kind === "url") {
53883
+ try {
53884
+ new URL(input2.data);
53885
+ } catch {
53886
+ ctx = this._getOrReturnCtx(input2, ctx);
53887
+ addIssueToContext(ctx, {
53888
+ validation: "url",
53889
+ code: ZodIssueCode2.invalid_string,
53890
+ message: check3.message
53891
+ });
53892
+ status.dirty();
53893
+ }
53894
+ } else if (check3.kind === "regex") {
53895
+ check3.regex.lastIndex = 0;
53896
+ const testResult = check3.regex.test(input2.data);
53897
+ if (!testResult) {
53898
+ ctx = this._getOrReturnCtx(input2, ctx);
53899
+ addIssueToContext(ctx, {
53900
+ validation: "regex",
53901
+ code: ZodIssueCode2.invalid_string,
53902
+ message: check3.message
53903
+ });
53904
+ status.dirty();
53905
+ }
53906
+ } else if (check3.kind === "trim") {
53907
+ input2.data = input2.data.trim();
53908
+ } else if (check3.kind === "includes") {
53909
+ if (!input2.data.includes(check3.value, check3.position)) {
53910
+ ctx = this._getOrReturnCtx(input2, ctx);
53911
+ addIssueToContext(ctx, {
53912
+ code: ZodIssueCode2.invalid_string,
53913
+ validation: { includes: check3.value, position: check3.position },
53914
+ message: check3.message
53915
+ });
53916
+ status.dirty();
53917
+ }
53918
+ } else if (check3.kind === "toLowerCase") {
53919
+ input2.data = input2.data.toLowerCase();
53920
+ } else if (check3.kind === "toUpperCase") {
53921
+ input2.data = input2.data.toUpperCase();
53922
+ } else if (check3.kind === "startsWith") {
53923
+ if (!input2.data.startsWith(check3.value)) {
53924
+ ctx = this._getOrReturnCtx(input2, ctx);
53925
+ addIssueToContext(ctx, {
53926
+ code: ZodIssueCode2.invalid_string,
53927
+ validation: { startsWith: check3.value },
53928
+ message: check3.message
53929
+ });
53930
+ status.dirty();
53931
+ }
53932
+ } else if (check3.kind === "endsWith") {
53933
+ if (!input2.data.endsWith(check3.value)) {
53934
+ ctx = this._getOrReturnCtx(input2, ctx);
53935
+ addIssueToContext(ctx, {
53936
+ code: ZodIssueCode2.invalid_string,
53937
+ validation: { endsWith: check3.value },
53938
+ message: check3.message
53939
+ });
53940
+ status.dirty();
53941
+ }
53942
+ } else if (check3.kind === "datetime") {
53943
+ const regex = datetimeRegex(check3);
53944
+ if (!regex.test(input2.data)) {
53945
+ ctx = this._getOrReturnCtx(input2, ctx);
53946
+ addIssueToContext(ctx, {
53947
+ code: ZodIssueCode2.invalid_string,
53948
+ validation: "datetime",
53949
+ message: check3.message
53950
+ });
53951
+ status.dirty();
53952
+ }
53953
+ } else if (check3.kind === "date") {
53954
+ const regex = dateRegex;
53955
+ if (!regex.test(input2.data)) {
53956
+ ctx = this._getOrReturnCtx(input2, ctx);
53957
+ addIssueToContext(ctx, {
53958
+ code: ZodIssueCode2.invalid_string,
53959
+ validation: "date",
53960
+ message: check3.message
53961
+ });
53962
+ status.dirty();
53963
+ }
53964
+ } else if (check3.kind === "time") {
53965
+ const regex = timeRegex(check3);
53966
+ if (!regex.test(input2.data)) {
53967
+ ctx = this._getOrReturnCtx(input2, ctx);
53968
+ addIssueToContext(ctx, {
53969
+ code: ZodIssueCode2.invalid_string,
53970
+ validation: "time",
53971
+ message: check3.message
53972
+ });
53973
+ status.dirty();
53974
+ }
53975
+ } else if (check3.kind === "duration") {
53976
+ if (!durationRegex.test(input2.data)) {
53977
+ ctx = this._getOrReturnCtx(input2, ctx);
53978
+ addIssueToContext(ctx, {
53979
+ validation: "duration",
53980
+ code: ZodIssueCode2.invalid_string,
53981
+ message: check3.message
53982
+ });
53983
+ status.dirty();
53984
+ }
53985
+ } else if (check3.kind === "ip") {
53986
+ if (!isValidIP(input2.data, check3.version)) {
53987
+ ctx = this._getOrReturnCtx(input2, ctx);
53988
+ addIssueToContext(ctx, {
53989
+ validation: "ip",
53990
+ code: ZodIssueCode2.invalid_string,
53991
+ message: check3.message
53992
+ });
53993
+ status.dirty();
53994
+ }
53995
+ } else if (check3.kind === "jwt") {
53996
+ if (!isValidJWT2(input2.data, check3.alg)) {
53997
+ ctx = this._getOrReturnCtx(input2, ctx);
53998
+ addIssueToContext(ctx, {
53999
+ validation: "jwt",
54000
+ code: ZodIssueCode2.invalid_string,
54001
+ message: check3.message
54002
+ });
54003
+ status.dirty();
54004
+ }
54005
+ } else if (check3.kind === "cidr") {
54006
+ if (!isValidCidr(input2.data, check3.version)) {
54007
+ ctx = this._getOrReturnCtx(input2, ctx);
54008
+ addIssueToContext(ctx, {
54009
+ validation: "cidr",
54010
+ code: ZodIssueCode2.invalid_string,
54011
+ message: check3.message
54012
+ });
54013
+ status.dirty();
54014
+ }
54015
+ } else if (check3.kind === "base64") {
54016
+ if (!base64Regex.test(input2.data)) {
54017
+ ctx = this._getOrReturnCtx(input2, ctx);
54018
+ addIssueToContext(ctx, {
54019
+ validation: "base64",
54020
+ code: ZodIssueCode2.invalid_string,
54021
+ message: check3.message
54022
+ });
54023
+ status.dirty();
54024
+ }
54025
+ } else if (check3.kind === "base64url") {
54026
+ if (!base64urlRegex.test(input2.data)) {
54027
+ ctx = this._getOrReturnCtx(input2, ctx);
54028
+ addIssueToContext(ctx, {
54029
+ validation: "base64url",
54030
+ code: ZodIssueCode2.invalid_string,
54031
+ message: check3.message
54032
+ });
54033
+ status.dirty();
54034
+ }
54035
+ } else {
54036
+ util.assertNever(check3);
54037
+ }
54038
+ }
54039
+ return { status: status.value, value: input2.data };
54040
+ }
54041
+ _regex(regex, validation, message) {
54042
+ return this.refinement((data) => regex.test(data), {
54043
+ validation,
54044
+ code: ZodIssueCode2.invalid_string,
54045
+ ...errorUtil.errToObj(message)
54046
+ });
54047
+ }
54048
+ _addCheck(check3) {
54049
+ return new _ZodString2({
54050
+ ...this._def,
54051
+ checks: [...this._def.checks, check3]
54052
+ });
54053
+ }
54054
+ email(message) {
54055
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
54056
+ }
54057
+ url(message) {
54058
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
54059
+ }
54060
+ emoji(message) {
54061
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
54062
+ }
54063
+ uuid(message) {
54064
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
54065
+ }
54066
+ nanoid(message) {
54067
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
54068
+ }
54069
+ cuid(message) {
54070
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
54071
+ }
54072
+ cuid2(message) {
54073
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
54074
+ }
54075
+ ulid(message) {
54076
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
54077
+ }
54078
+ base64(message) {
54079
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
54080
+ }
54081
+ base64url(message) {
54082
+ return this._addCheck({
54083
+ kind: "base64url",
54084
+ ...errorUtil.errToObj(message)
54085
+ });
54086
+ }
54087
+ jwt(options) {
54088
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
54089
+ }
54090
+ ip(options) {
54091
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
54092
+ }
54093
+ cidr(options) {
54094
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
54095
+ }
54096
+ datetime(options) {
54097
+ if (typeof options === "string") {
54098
+ return this._addCheck({
54099
+ kind: "datetime",
54100
+ precision: null,
54101
+ offset: false,
54102
+ local: false,
54103
+ message: options
54104
+ });
54105
+ }
54106
+ return this._addCheck({
54107
+ kind: "datetime",
54108
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
54109
+ offset: options?.offset ?? false,
54110
+ local: options?.local ?? false,
54111
+ ...errorUtil.errToObj(options?.message)
54112
+ });
54113
+ }
54114
+ date(message) {
54115
+ return this._addCheck({ kind: "date", message });
54116
+ }
54117
+ time(options) {
54118
+ if (typeof options === "string") {
54119
+ return this._addCheck({
54120
+ kind: "time",
54121
+ precision: null,
54122
+ message: options
54123
+ });
54124
+ }
54125
+ return this._addCheck({
54126
+ kind: "time",
54127
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
54128
+ ...errorUtil.errToObj(options?.message)
54129
+ });
54130
+ }
54131
+ duration(message) {
54132
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
54133
+ }
54134
+ regex(regex, message) {
54135
+ return this._addCheck({
54136
+ kind: "regex",
54137
+ regex,
54138
+ ...errorUtil.errToObj(message)
54139
+ });
54140
+ }
54141
+ includes(value, options) {
54142
+ return this._addCheck({
54143
+ kind: "includes",
54144
+ value,
54145
+ position: options?.position,
54146
+ ...errorUtil.errToObj(options?.message)
54147
+ });
54148
+ }
54149
+ startsWith(value, message) {
54150
+ return this._addCheck({
54151
+ kind: "startsWith",
54152
+ value,
54153
+ ...errorUtil.errToObj(message)
54154
+ });
54155
+ }
54156
+ endsWith(value, message) {
54157
+ return this._addCheck({
54158
+ kind: "endsWith",
54159
+ value,
54160
+ ...errorUtil.errToObj(message)
54161
+ });
54162
+ }
54163
+ min(minLength, message) {
54164
+ return this._addCheck({
54165
+ kind: "min",
54166
+ value: minLength,
54167
+ ...errorUtil.errToObj(message)
54168
+ });
54169
+ }
54170
+ max(maxLength, message) {
54171
+ return this._addCheck({
54172
+ kind: "max",
54173
+ value: maxLength,
54174
+ ...errorUtil.errToObj(message)
54175
+ });
54176
+ }
54177
+ length(len, message) {
54178
+ return this._addCheck({
54179
+ kind: "length",
54180
+ value: len,
54181
+ ...errorUtil.errToObj(message)
54182
+ });
54183
+ }
54184
+ /**
54185
+ * Equivalent to `.min(1)`
54186
+ */
54187
+ nonempty(message) {
54188
+ return this.min(1, errorUtil.errToObj(message));
54189
+ }
54190
+ trim() {
54191
+ return new _ZodString2({
54192
+ ...this._def,
54193
+ checks: [...this._def.checks, { kind: "trim" }]
54194
+ });
54195
+ }
54196
+ toLowerCase() {
54197
+ return new _ZodString2({
54198
+ ...this._def,
54199
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
54200
+ });
54201
+ }
54202
+ toUpperCase() {
54203
+ return new _ZodString2({
54204
+ ...this._def,
54205
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
54206
+ });
54207
+ }
54208
+ get isDatetime() {
54209
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
54210
+ }
54211
+ get isDate() {
54212
+ return !!this._def.checks.find((ch) => ch.kind === "date");
54213
+ }
54214
+ get isTime() {
54215
+ return !!this._def.checks.find((ch) => ch.kind === "time");
54216
+ }
54217
+ get isDuration() {
54218
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
54219
+ }
54220
+ get isEmail() {
54221
+ return !!this._def.checks.find((ch) => ch.kind === "email");
54222
+ }
54223
+ get isURL() {
54224
+ return !!this._def.checks.find((ch) => ch.kind === "url");
54225
+ }
54226
+ get isEmoji() {
54227
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
54228
+ }
54229
+ get isUUID() {
54230
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
54231
+ }
54232
+ get isNANOID() {
54233
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
54234
+ }
54235
+ get isCUID() {
54236
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
54237
+ }
54238
+ get isCUID2() {
54239
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
54240
+ }
54241
+ get isULID() {
54242
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
54243
+ }
54244
+ get isIP() {
54245
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
54246
+ }
54247
+ get isCIDR() {
54248
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
54249
+ }
54250
+ get isBase64() {
54251
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
54252
+ }
54253
+ get isBase64url() {
54254
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
54255
+ }
54256
+ get minLength() {
54257
+ let min = null;
54258
+ for (const ch of this._def.checks) {
54259
+ if (ch.kind === "min") {
54260
+ if (min === null || ch.value > min)
54261
+ min = ch.value;
54262
+ }
54263
+ }
54264
+ return min;
54265
+ }
54266
+ get maxLength() {
54267
+ let max = null;
54268
+ for (const ch of this._def.checks) {
54269
+ if (ch.kind === "max") {
54270
+ if (max === null || ch.value < max)
54271
+ max = ch.value;
54272
+ }
54273
+ }
54274
+ return max;
54275
+ }
54276
+ };
54277
+ ZodString2.create = (params) => {
54278
+ return new ZodString2({
54279
+ checks: [],
54280
+ typeName: ZodFirstPartyTypeKind2.ZodString,
54281
+ coerce: params?.coerce ?? false,
54282
+ ...processCreateParams(params)
54283
+ });
54284
+ };
54285
+ function floatSafeRemainder2(val, step) {
54286
+ const valDecCount = (val.toString().split(".")[1] || "").length;
54287
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
54288
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
54289
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
54290
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
54291
+ return valInt % stepInt / 10 ** decCount;
54292
+ }
54293
+ var ZodNumber2 = class _ZodNumber extends ZodType2 {
54294
+ constructor() {
54295
+ super(...arguments);
54296
+ this.min = this.gte;
54297
+ this.max = this.lte;
54298
+ this.step = this.multipleOf;
54299
+ }
54300
+ _parse(input2) {
54301
+ if (this._def.coerce) {
54302
+ input2.data = Number(input2.data);
54303
+ }
54304
+ const parsedType2 = this._getType(input2);
54305
+ if (parsedType2 !== ZodParsedType.number) {
54306
+ const ctx2 = this._getOrReturnCtx(input2);
54307
+ addIssueToContext(ctx2, {
54308
+ code: ZodIssueCode2.invalid_type,
54309
+ expected: ZodParsedType.number,
54310
+ received: ctx2.parsedType
54311
+ });
54312
+ return INVALID2;
54313
+ }
54314
+ let ctx = void 0;
54315
+ const status = new ParseStatus();
54316
+ for (const check3 of this._def.checks) {
54317
+ if (check3.kind === "int") {
54318
+ if (!util.isInteger(input2.data)) {
54319
+ ctx = this._getOrReturnCtx(input2, ctx);
54320
+ addIssueToContext(ctx, {
54321
+ code: ZodIssueCode2.invalid_type,
54322
+ expected: "integer",
54323
+ received: "float",
54324
+ message: check3.message
54325
+ });
54326
+ status.dirty();
54327
+ }
54328
+ } else if (check3.kind === "min") {
54329
+ const tooSmall = check3.inclusive ? input2.data < check3.value : input2.data <= check3.value;
54330
+ if (tooSmall) {
54331
+ ctx = this._getOrReturnCtx(input2, ctx);
54332
+ addIssueToContext(ctx, {
54333
+ code: ZodIssueCode2.too_small,
54334
+ minimum: check3.value,
54335
+ type: "number",
54336
+ inclusive: check3.inclusive,
54337
+ exact: false,
54338
+ message: check3.message
54339
+ });
54340
+ status.dirty();
54341
+ }
54342
+ } else if (check3.kind === "max") {
54343
+ const tooBig = check3.inclusive ? input2.data > check3.value : input2.data >= check3.value;
54344
+ if (tooBig) {
54345
+ ctx = this._getOrReturnCtx(input2, ctx);
54346
+ addIssueToContext(ctx, {
54347
+ code: ZodIssueCode2.too_big,
54348
+ maximum: check3.value,
54349
+ type: "number",
54350
+ inclusive: check3.inclusive,
54351
+ exact: false,
54352
+ message: check3.message
54353
+ });
54354
+ status.dirty();
54355
+ }
54356
+ } else if (check3.kind === "multipleOf") {
54357
+ if (floatSafeRemainder2(input2.data, check3.value) !== 0) {
54358
+ ctx = this._getOrReturnCtx(input2, ctx);
54359
+ addIssueToContext(ctx, {
54360
+ code: ZodIssueCode2.not_multiple_of,
54361
+ multipleOf: check3.value,
54362
+ message: check3.message
54363
+ });
54364
+ status.dirty();
54365
+ }
54366
+ } else if (check3.kind === "finite") {
54367
+ if (!Number.isFinite(input2.data)) {
54368
+ ctx = this._getOrReturnCtx(input2, ctx);
54369
+ addIssueToContext(ctx, {
54370
+ code: ZodIssueCode2.not_finite,
54371
+ message: check3.message
54372
+ });
54373
+ status.dirty();
54374
+ }
54375
+ } else {
54376
+ util.assertNever(check3);
54377
+ }
54378
+ }
54379
+ return { status: status.value, value: input2.data };
54380
+ }
54381
+ gte(value, message) {
54382
+ return this.setLimit("min", value, true, errorUtil.toString(message));
54383
+ }
54384
+ gt(value, message) {
54385
+ return this.setLimit("min", value, false, errorUtil.toString(message));
54386
+ }
54387
+ lte(value, message) {
54388
+ return this.setLimit("max", value, true, errorUtil.toString(message));
54389
+ }
54390
+ lt(value, message) {
54391
+ return this.setLimit("max", value, false, errorUtil.toString(message));
54392
+ }
54393
+ setLimit(kind, value, inclusive, message) {
54394
+ return new _ZodNumber({
54395
+ ...this._def,
54396
+ checks: [
54397
+ ...this._def.checks,
54398
+ {
54399
+ kind,
54400
+ value,
54401
+ inclusive,
54402
+ message: errorUtil.toString(message)
54403
+ }
54404
+ ]
54405
+ });
54406
+ }
54407
+ _addCheck(check3) {
54408
+ return new _ZodNumber({
54409
+ ...this._def,
54410
+ checks: [...this._def.checks, check3]
54411
+ });
54412
+ }
54413
+ int(message) {
54414
+ return this._addCheck({
54415
+ kind: "int",
54416
+ message: errorUtil.toString(message)
54417
+ });
54418
+ }
54419
+ positive(message) {
54420
+ return this._addCheck({
54421
+ kind: "min",
54422
+ value: 0,
54423
+ inclusive: false,
54424
+ message: errorUtil.toString(message)
54425
+ });
54426
+ }
54427
+ negative(message) {
54428
+ return this._addCheck({
54429
+ kind: "max",
54430
+ value: 0,
54431
+ inclusive: false,
54432
+ message: errorUtil.toString(message)
54433
+ });
54434
+ }
54435
+ nonpositive(message) {
54436
+ return this._addCheck({
54437
+ kind: "max",
54438
+ value: 0,
54439
+ inclusive: true,
54440
+ message: errorUtil.toString(message)
54441
+ });
54442
+ }
54443
+ nonnegative(message) {
54444
+ return this._addCheck({
54445
+ kind: "min",
54446
+ value: 0,
54447
+ inclusive: true,
54448
+ message: errorUtil.toString(message)
54449
+ });
54450
+ }
54451
+ multipleOf(value, message) {
54452
+ return this._addCheck({
54453
+ kind: "multipleOf",
54454
+ value,
54455
+ message: errorUtil.toString(message)
54456
+ });
54457
+ }
54458
+ finite(message) {
54459
+ return this._addCheck({
54460
+ kind: "finite",
54461
+ message: errorUtil.toString(message)
54462
+ });
54463
+ }
54464
+ safe(message) {
54465
+ return this._addCheck({
54466
+ kind: "min",
54467
+ inclusive: true,
54468
+ value: Number.MIN_SAFE_INTEGER,
54469
+ message: errorUtil.toString(message)
54470
+ })._addCheck({
54471
+ kind: "max",
54472
+ inclusive: true,
54473
+ value: Number.MAX_SAFE_INTEGER,
54474
+ message: errorUtil.toString(message)
54475
+ });
54476
+ }
54477
+ get minValue() {
54478
+ let min = null;
54479
+ for (const ch of this._def.checks) {
54480
+ if (ch.kind === "min") {
54481
+ if (min === null || ch.value > min)
54482
+ min = ch.value;
54483
+ }
54484
+ }
54485
+ return min;
54486
+ }
54487
+ get maxValue() {
54488
+ let max = null;
54489
+ for (const ch of this._def.checks) {
54490
+ if (ch.kind === "max") {
54491
+ if (max === null || ch.value < max)
54492
+ max = ch.value;
54493
+ }
54494
+ }
54495
+ return max;
54496
+ }
54497
+ get isInt() {
54498
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
54499
+ }
54500
+ get isFinite() {
54501
+ let max = null;
54502
+ let min = null;
54503
+ for (const ch of this._def.checks) {
54504
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
54505
+ return true;
54506
+ } else if (ch.kind === "min") {
54507
+ if (min === null || ch.value > min)
54508
+ min = ch.value;
54509
+ } else if (ch.kind === "max") {
54510
+ if (max === null || ch.value < max)
54511
+ max = ch.value;
54512
+ }
54513
+ }
54514
+ return Number.isFinite(min) && Number.isFinite(max);
54515
+ }
54516
+ };
54517
+ ZodNumber2.create = (params) => {
54518
+ return new ZodNumber2({
54519
+ checks: [],
54520
+ typeName: ZodFirstPartyTypeKind2.ZodNumber,
54521
+ coerce: params?.coerce || false,
54522
+ ...processCreateParams(params)
54523
+ });
54524
+ };
54525
+ var ZodBigInt2 = class _ZodBigInt extends ZodType2 {
54526
+ constructor() {
54527
+ super(...arguments);
54528
+ this.min = this.gte;
54529
+ this.max = this.lte;
54530
+ }
54531
+ _parse(input2) {
54532
+ if (this._def.coerce) {
54533
+ try {
54534
+ input2.data = BigInt(input2.data);
54535
+ } catch {
54536
+ return this._getInvalidInput(input2);
54537
+ }
54538
+ }
54539
+ const parsedType2 = this._getType(input2);
54540
+ if (parsedType2 !== ZodParsedType.bigint) {
54541
+ return this._getInvalidInput(input2);
54542
+ }
54543
+ let ctx = void 0;
54544
+ const status = new ParseStatus();
54545
+ for (const check3 of this._def.checks) {
54546
+ if (check3.kind === "min") {
54547
+ const tooSmall = check3.inclusive ? input2.data < check3.value : input2.data <= check3.value;
54548
+ if (tooSmall) {
54549
+ ctx = this._getOrReturnCtx(input2, ctx);
54550
+ addIssueToContext(ctx, {
54551
+ code: ZodIssueCode2.too_small,
54552
+ type: "bigint",
54553
+ minimum: check3.value,
54554
+ inclusive: check3.inclusive,
54555
+ message: check3.message
54556
+ });
54557
+ status.dirty();
54558
+ }
54559
+ } else if (check3.kind === "max") {
54560
+ const tooBig = check3.inclusive ? input2.data > check3.value : input2.data >= check3.value;
54561
+ if (tooBig) {
54562
+ ctx = this._getOrReturnCtx(input2, ctx);
54563
+ addIssueToContext(ctx, {
54564
+ code: ZodIssueCode2.too_big,
54565
+ type: "bigint",
54566
+ maximum: check3.value,
54567
+ inclusive: check3.inclusive,
54568
+ message: check3.message
54569
+ });
54570
+ status.dirty();
54571
+ }
54572
+ } else if (check3.kind === "multipleOf") {
54573
+ if (input2.data % check3.value !== BigInt(0)) {
54574
+ ctx = this._getOrReturnCtx(input2, ctx);
54575
+ addIssueToContext(ctx, {
54576
+ code: ZodIssueCode2.not_multiple_of,
54577
+ multipleOf: check3.value,
54578
+ message: check3.message
54579
+ });
54580
+ status.dirty();
54581
+ }
54582
+ } else {
54583
+ util.assertNever(check3);
54584
+ }
54585
+ }
54586
+ return { status: status.value, value: input2.data };
54587
+ }
54588
+ _getInvalidInput(input2) {
54589
+ const ctx = this._getOrReturnCtx(input2);
54590
+ addIssueToContext(ctx, {
54591
+ code: ZodIssueCode2.invalid_type,
54592
+ expected: ZodParsedType.bigint,
54593
+ received: ctx.parsedType
54594
+ });
54595
+ return INVALID2;
54596
+ }
54597
+ gte(value, message) {
54598
+ return this.setLimit("min", value, true, errorUtil.toString(message));
54599
+ }
54600
+ gt(value, message) {
54601
+ return this.setLimit("min", value, false, errorUtil.toString(message));
54602
+ }
54603
+ lte(value, message) {
54604
+ return this.setLimit("max", value, true, errorUtil.toString(message));
54605
+ }
54606
+ lt(value, message) {
54607
+ return this.setLimit("max", value, false, errorUtil.toString(message));
54608
+ }
54609
+ setLimit(kind, value, inclusive, message) {
54610
+ return new _ZodBigInt({
54611
+ ...this._def,
54612
+ checks: [
54613
+ ...this._def.checks,
54614
+ {
54615
+ kind,
54616
+ value,
54617
+ inclusive,
54618
+ message: errorUtil.toString(message)
54619
+ }
54620
+ ]
54621
+ });
54622
+ }
54623
+ _addCheck(check3) {
54624
+ return new _ZodBigInt({
54625
+ ...this._def,
54626
+ checks: [...this._def.checks, check3]
54627
+ });
54628
+ }
54629
+ positive(message) {
54630
+ return this._addCheck({
54631
+ kind: "min",
54632
+ value: BigInt(0),
54633
+ inclusive: false,
54634
+ message: errorUtil.toString(message)
54635
+ });
54636
+ }
54637
+ negative(message) {
54638
+ return this._addCheck({
54639
+ kind: "max",
54640
+ value: BigInt(0),
54641
+ inclusive: false,
54642
+ message: errorUtil.toString(message)
54643
+ });
54644
+ }
54645
+ nonpositive(message) {
54646
+ return this._addCheck({
54647
+ kind: "max",
54648
+ value: BigInt(0),
54649
+ inclusive: true,
54650
+ message: errorUtil.toString(message)
54651
+ });
54652
+ }
54653
+ nonnegative(message) {
54654
+ return this._addCheck({
54655
+ kind: "min",
54656
+ value: BigInt(0),
54657
+ inclusive: true,
54658
+ message: errorUtil.toString(message)
54659
+ });
54660
+ }
54661
+ multipleOf(value, message) {
54662
+ return this._addCheck({
54663
+ kind: "multipleOf",
54664
+ value,
54665
+ message: errorUtil.toString(message)
54666
+ });
54667
+ }
54668
+ get minValue() {
54669
+ let min = null;
54670
+ for (const ch of this._def.checks) {
54671
+ if (ch.kind === "min") {
54672
+ if (min === null || ch.value > min)
54673
+ min = ch.value;
54674
+ }
54675
+ }
54676
+ return min;
54677
+ }
54678
+ get maxValue() {
54679
+ let max = null;
54680
+ for (const ch of this._def.checks) {
54681
+ if (ch.kind === "max") {
54682
+ if (max === null || ch.value < max)
54683
+ max = ch.value;
54684
+ }
54685
+ }
54686
+ return max;
54687
+ }
54688
+ };
54689
+ ZodBigInt2.create = (params) => {
54690
+ return new ZodBigInt2({
54691
+ checks: [],
54692
+ typeName: ZodFirstPartyTypeKind2.ZodBigInt,
54693
+ coerce: params?.coerce ?? false,
54694
+ ...processCreateParams(params)
54695
+ });
54696
+ };
54697
+ var ZodBoolean2 = class extends ZodType2 {
54698
+ _parse(input2) {
54699
+ if (this._def.coerce) {
54700
+ input2.data = Boolean(input2.data);
54701
+ }
54702
+ const parsedType2 = this._getType(input2);
54703
+ if (parsedType2 !== ZodParsedType.boolean) {
54704
+ const ctx = this._getOrReturnCtx(input2);
54705
+ addIssueToContext(ctx, {
54706
+ code: ZodIssueCode2.invalid_type,
54707
+ expected: ZodParsedType.boolean,
54708
+ received: ctx.parsedType
54709
+ });
54710
+ return INVALID2;
54711
+ }
54712
+ return OK(input2.data);
54713
+ }
54714
+ };
54715
+ ZodBoolean2.create = (params) => {
54716
+ return new ZodBoolean2({
54717
+ typeName: ZodFirstPartyTypeKind2.ZodBoolean,
54718
+ coerce: params?.coerce || false,
54719
+ ...processCreateParams(params)
54720
+ });
54721
+ };
54722
+ var ZodDate2 = class _ZodDate extends ZodType2 {
54723
+ _parse(input2) {
54724
+ if (this._def.coerce) {
54725
+ input2.data = new Date(input2.data);
54726
+ }
54727
+ const parsedType2 = this._getType(input2);
54728
+ if (parsedType2 !== ZodParsedType.date) {
54729
+ const ctx2 = this._getOrReturnCtx(input2);
54730
+ addIssueToContext(ctx2, {
54731
+ code: ZodIssueCode2.invalid_type,
54732
+ expected: ZodParsedType.date,
54733
+ received: ctx2.parsedType
54734
+ });
54735
+ return INVALID2;
54736
+ }
54737
+ if (Number.isNaN(input2.data.getTime())) {
54738
+ const ctx2 = this._getOrReturnCtx(input2);
54739
+ addIssueToContext(ctx2, {
54740
+ code: ZodIssueCode2.invalid_date
54741
+ });
54742
+ return INVALID2;
54743
+ }
54744
+ const status = new ParseStatus();
54745
+ let ctx = void 0;
54746
+ for (const check3 of this._def.checks) {
54747
+ if (check3.kind === "min") {
54748
+ if (input2.data.getTime() < check3.value) {
54749
+ ctx = this._getOrReturnCtx(input2, ctx);
54750
+ addIssueToContext(ctx, {
54751
+ code: ZodIssueCode2.too_small,
54752
+ message: check3.message,
54753
+ inclusive: true,
54754
+ exact: false,
54755
+ minimum: check3.value,
54756
+ type: "date"
54757
+ });
54758
+ status.dirty();
54759
+ }
54760
+ } else if (check3.kind === "max") {
54761
+ if (input2.data.getTime() > check3.value) {
54762
+ ctx = this._getOrReturnCtx(input2, ctx);
54763
+ addIssueToContext(ctx, {
54764
+ code: ZodIssueCode2.too_big,
54765
+ message: check3.message,
54766
+ inclusive: true,
54767
+ exact: false,
54768
+ maximum: check3.value,
54769
+ type: "date"
54770
+ });
54771
+ status.dirty();
54772
+ }
54773
+ } else {
54774
+ util.assertNever(check3);
54775
+ }
54776
+ }
54777
+ return {
54778
+ status: status.value,
54779
+ value: new Date(input2.data.getTime())
54780
+ };
54781
+ }
54782
+ _addCheck(check3) {
54783
+ return new _ZodDate({
54784
+ ...this._def,
54785
+ checks: [...this._def.checks, check3]
54786
+ });
54787
+ }
54788
+ min(minDate, message) {
54789
+ return this._addCheck({
54790
+ kind: "min",
54791
+ value: minDate.getTime(),
54792
+ message: errorUtil.toString(message)
54793
+ });
54794
+ }
54795
+ max(maxDate, message) {
54796
+ return this._addCheck({
54797
+ kind: "max",
54798
+ value: maxDate.getTime(),
54799
+ message: errorUtil.toString(message)
54800
+ });
54801
+ }
54802
+ get minDate() {
54803
+ let min = null;
54804
+ for (const ch of this._def.checks) {
54805
+ if (ch.kind === "min") {
54806
+ if (min === null || ch.value > min)
54807
+ min = ch.value;
54808
+ }
54809
+ }
54810
+ return min != null ? new Date(min) : null;
54811
+ }
54812
+ get maxDate() {
54813
+ let max = null;
54814
+ for (const ch of this._def.checks) {
54815
+ if (ch.kind === "max") {
54816
+ if (max === null || ch.value < max)
54817
+ max = ch.value;
54818
+ }
54819
+ }
54820
+ return max != null ? new Date(max) : null;
54821
+ }
54822
+ };
54823
+ ZodDate2.create = (params) => {
54824
+ return new ZodDate2({
54825
+ checks: [],
54826
+ coerce: params?.coerce || false,
54827
+ typeName: ZodFirstPartyTypeKind2.ZodDate,
54828
+ ...processCreateParams(params)
54829
+ });
54830
+ };
54831
+ var ZodSymbol2 = class extends ZodType2 {
54832
+ _parse(input2) {
54833
+ const parsedType2 = this._getType(input2);
54834
+ if (parsedType2 !== ZodParsedType.symbol) {
54835
+ const ctx = this._getOrReturnCtx(input2);
54836
+ addIssueToContext(ctx, {
54837
+ code: ZodIssueCode2.invalid_type,
54838
+ expected: ZodParsedType.symbol,
54839
+ received: ctx.parsedType
54840
+ });
54841
+ return INVALID2;
54842
+ }
54843
+ return OK(input2.data);
54844
+ }
54845
+ };
54846
+ ZodSymbol2.create = (params) => {
54847
+ return new ZodSymbol2({
54848
+ typeName: ZodFirstPartyTypeKind2.ZodSymbol,
54849
+ ...processCreateParams(params)
54850
+ });
54851
+ };
54852
+ var ZodUndefined2 = class extends ZodType2 {
54853
+ _parse(input2) {
54854
+ const parsedType2 = this._getType(input2);
54855
+ if (parsedType2 !== ZodParsedType.undefined) {
54856
+ const ctx = this._getOrReturnCtx(input2);
54857
+ addIssueToContext(ctx, {
54858
+ code: ZodIssueCode2.invalid_type,
54859
+ expected: ZodParsedType.undefined,
54860
+ received: ctx.parsedType
54861
+ });
54862
+ return INVALID2;
54863
+ }
54864
+ return OK(input2.data);
54865
+ }
54866
+ };
54867
+ ZodUndefined2.create = (params) => {
54868
+ return new ZodUndefined2({
54869
+ typeName: ZodFirstPartyTypeKind2.ZodUndefined,
54870
+ ...processCreateParams(params)
54871
+ });
54872
+ };
54873
+ var ZodNull2 = class extends ZodType2 {
54874
+ _parse(input2) {
54875
+ const parsedType2 = this._getType(input2);
54876
+ if (parsedType2 !== ZodParsedType.null) {
54877
+ const ctx = this._getOrReturnCtx(input2);
54878
+ addIssueToContext(ctx, {
54879
+ code: ZodIssueCode2.invalid_type,
54880
+ expected: ZodParsedType.null,
54881
+ received: ctx.parsedType
54882
+ });
54883
+ return INVALID2;
54884
+ }
54885
+ return OK(input2.data);
54886
+ }
54887
+ };
54888
+ ZodNull2.create = (params) => {
54889
+ return new ZodNull2({
54890
+ typeName: ZodFirstPartyTypeKind2.ZodNull,
54891
+ ...processCreateParams(params)
54892
+ });
54893
+ };
54894
+ var ZodAny2 = class extends ZodType2 {
54895
+ constructor() {
54896
+ super(...arguments);
54897
+ this._any = true;
54898
+ }
54899
+ _parse(input2) {
54900
+ return OK(input2.data);
54901
+ }
54902
+ };
54903
+ ZodAny2.create = (params) => {
54904
+ return new ZodAny2({
54905
+ typeName: ZodFirstPartyTypeKind2.ZodAny,
54906
+ ...processCreateParams(params)
54907
+ });
54908
+ };
54909
+ var ZodUnknown2 = class extends ZodType2 {
54910
+ constructor() {
54911
+ super(...arguments);
54912
+ this._unknown = true;
54913
+ }
54914
+ _parse(input2) {
54915
+ return OK(input2.data);
54916
+ }
54917
+ };
54918
+ ZodUnknown2.create = (params) => {
54919
+ return new ZodUnknown2({
54920
+ typeName: ZodFirstPartyTypeKind2.ZodUnknown,
54921
+ ...processCreateParams(params)
54922
+ });
54923
+ };
54924
+ var ZodNever2 = class extends ZodType2 {
54925
+ _parse(input2) {
54926
+ const ctx = this._getOrReturnCtx(input2);
54927
+ addIssueToContext(ctx, {
54928
+ code: ZodIssueCode2.invalid_type,
54929
+ expected: ZodParsedType.never,
54930
+ received: ctx.parsedType
54931
+ });
54932
+ return INVALID2;
54933
+ }
54934
+ };
54935
+ ZodNever2.create = (params) => {
54936
+ return new ZodNever2({
54937
+ typeName: ZodFirstPartyTypeKind2.ZodNever,
54938
+ ...processCreateParams(params)
54939
+ });
54940
+ };
54941
+ var ZodVoid2 = class extends ZodType2 {
54942
+ _parse(input2) {
54943
+ const parsedType2 = this._getType(input2);
54944
+ if (parsedType2 !== ZodParsedType.undefined) {
54945
+ const ctx = this._getOrReturnCtx(input2);
54946
+ addIssueToContext(ctx, {
54947
+ code: ZodIssueCode2.invalid_type,
54948
+ expected: ZodParsedType.void,
54949
+ received: ctx.parsedType
54950
+ });
54951
+ return INVALID2;
54952
+ }
54953
+ return OK(input2.data);
54954
+ }
54955
+ };
54956
+ ZodVoid2.create = (params) => {
54957
+ return new ZodVoid2({
54958
+ typeName: ZodFirstPartyTypeKind2.ZodVoid,
54959
+ ...processCreateParams(params)
54960
+ });
54961
+ };
54962
+ var ZodArray2 = class _ZodArray extends ZodType2 {
54963
+ _parse(input2) {
54964
+ const { ctx, status } = this._processInputParams(input2);
54965
+ const def = this._def;
54966
+ if (ctx.parsedType !== ZodParsedType.array) {
54967
+ addIssueToContext(ctx, {
54968
+ code: ZodIssueCode2.invalid_type,
54969
+ expected: ZodParsedType.array,
54970
+ received: ctx.parsedType
54971
+ });
54972
+ return INVALID2;
54973
+ }
54974
+ if (def.exactLength !== null) {
54975
+ const tooBig = ctx.data.length > def.exactLength.value;
54976
+ const tooSmall = ctx.data.length < def.exactLength.value;
54977
+ if (tooBig || tooSmall) {
54978
+ addIssueToContext(ctx, {
54979
+ code: tooBig ? ZodIssueCode2.too_big : ZodIssueCode2.too_small,
54980
+ minimum: tooSmall ? def.exactLength.value : void 0,
54981
+ maximum: tooBig ? def.exactLength.value : void 0,
54982
+ type: "array",
54983
+ inclusive: true,
54984
+ exact: true,
54985
+ message: def.exactLength.message
54986
+ });
54987
+ status.dirty();
54988
+ }
54989
+ }
54990
+ if (def.minLength !== null) {
54991
+ if (ctx.data.length < def.minLength.value) {
54992
+ addIssueToContext(ctx, {
54993
+ code: ZodIssueCode2.too_small,
54994
+ minimum: def.minLength.value,
54995
+ type: "array",
54996
+ inclusive: true,
54997
+ exact: false,
54998
+ message: def.minLength.message
54999
+ });
55000
+ status.dirty();
55001
+ }
55002
+ }
55003
+ if (def.maxLength !== null) {
55004
+ if (ctx.data.length > def.maxLength.value) {
55005
+ addIssueToContext(ctx, {
55006
+ code: ZodIssueCode2.too_big,
55007
+ maximum: def.maxLength.value,
55008
+ type: "array",
55009
+ inclusive: true,
55010
+ exact: false,
55011
+ message: def.maxLength.message
55012
+ });
55013
+ status.dirty();
55014
+ }
55015
+ }
55016
+ if (ctx.common.async) {
55017
+ return Promise.all([...ctx.data].map((item, i) => {
55018
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
55019
+ })).then((result2) => {
55020
+ return ParseStatus.mergeArray(status, result2);
55021
+ });
55022
+ }
55023
+ const result = [...ctx.data].map((item, i) => {
55024
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
55025
+ });
55026
+ return ParseStatus.mergeArray(status, result);
55027
+ }
55028
+ get element() {
55029
+ return this._def.type;
55030
+ }
55031
+ min(minLength, message) {
55032
+ return new _ZodArray({
55033
+ ...this._def,
55034
+ minLength: { value: minLength, message: errorUtil.toString(message) }
55035
+ });
55036
+ }
55037
+ max(maxLength, message) {
55038
+ return new _ZodArray({
55039
+ ...this._def,
55040
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
55041
+ });
55042
+ }
55043
+ length(len, message) {
55044
+ return new _ZodArray({
55045
+ ...this._def,
55046
+ exactLength: { value: len, message: errorUtil.toString(message) }
55047
+ });
55048
+ }
55049
+ nonempty(message) {
55050
+ return this.min(1, message);
55051
+ }
55052
+ };
55053
+ ZodArray2.create = (schema2, params) => {
55054
+ return new ZodArray2({
55055
+ type: schema2,
55056
+ minLength: null,
55057
+ maxLength: null,
55058
+ exactLength: null,
55059
+ typeName: ZodFirstPartyTypeKind2.ZodArray,
55060
+ ...processCreateParams(params)
55061
+ });
55062
+ };
55063
+ function deepPartialify(schema2) {
55064
+ if (schema2 instanceof ZodObject2) {
55065
+ const newShape = {};
55066
+ for (const key in schema2.shape) {
55067
+ const fieldSchema = schema2.shape[key];
55068
+ newShape[key] = ZodOptional2.create(deepPartialify(fieldSchema));
55069
+ }
55070
+ return new ZodObject2({
55071
+ ...schema2._def,
55072
+ shape: () => newShape
55073
+ });
55074
+ } else if (schema2 instanceof ZodArray2) {
55075
+ return new ZodArray2({
55076
+ ...schema2._def,
55077
+ type: deepPartialify(schema2.element)
55078
+ });
55079
+ } else if (schema2 instanceof ZodOptional2) {
55080
+ return ZodOptional2.create(deepPartialify(schema2.unwrap()));
55081
+ } else if (schema2 instanceof ZodNullable2) {
55082
+ return ZodNullable2.create(deepPartialify(schema2.unwrap()));
55083
+ } else if (schema2 instanceof ZodTuple2) {
55084
+ return ZodTuple2.create(schema2.items.map((item) => deepPartialify(item)));
55085
+ } else {
55086
+ return schema2;
55087
+ }
55088
+ }
55089
+ var ZodObject2 = class _ZodObject extends ZodType2 {
55090
+ constructor() {
55091
+ super(...arguments);
55092
+ this._cached = null;
55093
+ this.nonstrict = this.passthrough;
55094
+ this.augment = this.extend;
55095
+ }
55096
+ _getCached() {
55097
+ if (this._cached !== null)
55098
+ return this._cached;
55099
+ const shape = this._def.shape();
55100
+ const keys = util.objectKeys(shape);
55101
+ this._cached = { shape, keys };
55102
+ return this._cached;
55103
+ }
55104
+ _parse(input2) {
55105
+ const parsedType2 = this._getType(input2);
55106
+ if (parsedType2 !== ZodParsedType.object) {
55107
+ const ctx2 = this._getOrReturnCtx(input2);
55108
+ addIssueToContext(ctx2, {
55109
+ code: ZodIssueCode2.invalid_type,
55110
+ expected: ZodParsedType.object,
55111
+ received: ctx2.parsedType
55112
+ });
55113
+ return INVALID2;
55114
+ }
55115
+ const { status, ctx } = this._processInputParams(input2);
55116
+ const { shape, keys: shapeKeys } = this._getCached();
55117
+ const extraKeys = [];
55118
+ if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) {
55119
+ for (const key in ctx.data) {
55120
+ if (!shapeKeys.includes(key)) {
55121
+ extraKeys.push(key);
55122
+ }
55123
+ }
55124
+ }
55125
+ const pairs2 = [];
55126
+ for (const key of shapeKeys) {
55127
+ const keyValidator = shape[key];
55128
+ const value = ctx.data[key];
55129
+ pairs2.push({
55130
+ key: { status: "valid", value: key },
55131
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
55132
+ alwaysSet: key in ctx.data
55133
+ });
55134
+ }
55135
+ if (this._def.catchall instanceof ZodNever2) {
55136
+ const unknownKeys = this._def.unknownKeys;
55137
+ if (unknownKeys === "passthrough") {
55138
+ for (const key of extraKeys) {
55139
+ pairs2.push({
55140
+ key: { status: "valid", value: key },
55141
+ value: { status: "valid", value: ctx.data[key] }
55142
+ });
55143
+ }
55144
+ } else if (unknownKeys === "strict") {
55145
+ if (extraKeys.length > 0) {
55146
+ addIssueToContext(ctx, {
55147
+ code: ZodIssueCode2.unrecognized_keys,
55148
+ keys: extraKeys
55149
+ });
55150
+ status.dirty();
55151
+ }
55152
+ } else if (unknownKeys === "strip") {
55153
+ } else {
55154
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
55155
+ }
55156
+ } else {
55157
+ const catchall = this._def.catchall;
55158
+ for (const key of extraKeys) {
55159
+ const value = ctx.data[key];
55160
+ pairs2.push({
55161
+ key: { status: "valid", value: key },
55162
+ value: catchall._parse(
55163
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
55164
+ //, ctx.child(key), value, getParsedType(value)
55165
+ ),
55166
+ alwaysSet: key in ctx.data
55167
+ });
55168
+ }
55169
+ }
55170
+ if (ctx.common.async) {
55171
+ return Promise.resolve().then(async () => {
55172
+ const syncPairs = [];
55173
+ for (const pair of pairs2) {
55174
+ const key = await pair.key;
55175
+ const value = await pair.value;
55176
+ syncPairs.push({
55177
+ key,
55178
+ value,
55179
+ alwaysSet: pair.alwaysSet
55180
+ });
55181
+ }
55182
+ return syncPairs;
55183
+ }).then((syncPairs) => {
55184
+ return ParseStatus.mergeObjectSync(status, syncPairs);
55185
+ });
55186
+ } else {
55187
+ return ParseStatus.mergeObjectSync(status, pairs2);
55188
+ }
55189
+ }
55190
+ get shape() {
55191
+ return this._def.shape();
55192
+ }
55193
+ strict(message) {
55194
+ errorUtil.errToObj;
55195
+ return new _ZodObject({
55196
+ ...this._def,
55197
+ unknownKeys: "strict",
55198
+ ...message !== void 0 ? {
55199
+ errorMap: (issue2, ctx) => {
55200
+ const defaultError = this._def.errorMap?.(issue2, ctx).message ?? ctx.defaultError;
55201
+ if (issue2.code === "unrecognized_keys")
55202
+ return {
55203
+ message: errorUtil.errToObj(message).message ?? defaultError
55204
+ };
55205
+ return {
55206
+ message: defaultError
55207
+ };
55208
+ }
55209
+ } : {}
55210
+ });
55211
+ }
55212
+ strip() {
55213
+ return new _ZodObject({
55214
+ ...this._def,
55215
+ unknownKeys: "strip"
55216
+ });
55217
+ }
55218
+ passthrough() {
55219
+ return new _ZodObject({
55220
+ ...this._def,
55221
+ unknownKeys: "passthrough"
55222
+ });
55223
+ }
55224
+ // const AugmentFactory =
55225
+ // <Def extends ZodObjectDef>(def: Def) =>
55226
+ // <Augmentation extends ZodRawShape>(
55227
+ // augmentation: Augmentation
55228
+ // ): ZodObject<
55229
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
55230
+ // Def["unknownKeys"],
55231
+ // Def["catchall"]
55232
+ // > => {
55233
+ // return new ZodObject({
55234
+ // ...def,
55235
+ // shape: () => ({
55236
+ // ...def.shape(),
55237
+ // ...augmentation,
55238
+ // }),
55239
+ // }) as any;
55240
+ // };
55241
+ extend(augmentation) {
55242
+ return new _ZodObject({
55243
+ ...this._def,
55244
+ shape: () => ({
55245
+ ...this._def.shape(),
55246
+ ...augmentation
55247
+ })
55248
+ });
55249
+ }
55250
+ /**
55251
+ * Prior to zod@1.0.12 there was a bug in the
55252
+ * inferred type of merged objects. Please
55253
+ * upgrade if you are experiencing issues.
55254
+ */
55255
+ merge(merging) {
55256
+ const merged = new _ZodObject({
55257
+ unknownKeys: merging._def.unknownKeys,
55258
+ catchall: merging._def.catchall,
55259
+ shape: () => ({
55260
+ ...this._def.shape(),
55261
+ ...merging._def.shape()
55262
+ }),
55263
+ typeName: ZodFirstPartyTypeKind2.ZodObject
55264
+ });
55265
+ return merged;
55266
+ }
55267
+ // merge<
55268
+ // Incoming extends AnyZodObject,
55269
+ // Augmentation extends Incoming["shape"],
55270
+ // NewOutput extends {
55271
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
55272
+ // ? Augmentation[k]["_output"]
55273
+ // : k extends keyof Output
55274
+ // ? Output[k]
55275
+ // : never;
55276
+ // },
55277
+ // NewInput extends {
55278
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
55279
+ // ? Augmentation[k]["_input"]
55280
+ // : k extends keyof Input
55281
+ // ? Input[k]
55282
+ // : never;
55283
+ // }
55284
+ // >(
55285
+ // merging: Incoming
55286
+ // ): ZodObject<
55287
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
55288
+ // Incoming["_def"]["unknownKeys"],
55289
+ // Incoming["_def"]["catchall"],
55290
+ // NewOutput,
55291
+ // NewInput
55292
+ // > {
55293
+ // const merged: any = new ZodObject({
55294
+ // unknownKeys: merging._def.unknownKeys,
55295
+ // catchall: merging._def.catchall,
55296
+ // shape: () =>
55297
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
55298
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
55299
+ // }) as any;
55300
+ // return merged;
55301
+ // }
55302
+ setKey(key, schema2) {
55303
+ return this.augment({ [key]: schema2 });
55304
+ }
55305
+ // merge<Incoming extends AnyZodObject>(
55306
+ // merging: Incoming
55307
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
55308
+ // ZodObject<
55309
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
55310
+ // Incoming["_def"]["unknownKeys"],
55311
+ // Incoming["_def"]["catchall"]
55312
+ // > {
55313
+ // // const mergedShape = objectUtil.mergeShapes(
55314
+ // // this._def.shape(),
55315
+ // // merging._def.shape()
55316
+ // // );
55317
+ // const merged: any = new ZodObject({
55318
+ // unknownKeys: merging._def.unknownKeys,
55319
+ // catchall: merging._def.catchall,
55320
+ // shape: () =>
55321
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
55322
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
55323
+ // }) as any;
55324
+ // return merged;
55325
+ // }
55326
+ catchall(index) {
55327
+ return new _ZodObject({
55328
+ ...this._def,
55329
+ catchall: index
55330
+ });
55331
+ }
55332
+ pick(mask) {
55333
+ const shape = {};
55334
+ for (const key of util.objectKeys(mask)) {
55335
+ if (mask[key] && this.shape[key]) {
55336
+ shape[key] = this.shape[key];
55337
+ }
55338
+ }
55339
+ return new _ZodObject({
55340
+ ...this._def,
55341
+ shape: () => shape
55342
+ });
55343
+ }
55344
+ omit(mask) {
55345
+ const shape = {};
55346
+ for (const key of util.objectKeys(this.shape)) {
55347
+ if (!mask[key]) {
55348
+ shape[key] = this.shape[key];
55349
+ }
55350
+ }
55351
+ return new _ZodObject({
55352
+ ...this._def,
55353
+ shape: () => shape
55354
+ });
55355
+ }
55356
+ /**
55357
+ * @deprecated
55358
+ */
55359
+ deepPartial() {
55360
+ return deepPartialify(this);
55361
+ }
55362
+ partial(mask) {
55363
+ const newShape = {};
55364
+ for (const key of util.objectKeys(this.shape)) {
55365
+ const fieldSchema = this.shape[key];
55366
+ if (mask && !mask[key]) {
55367
+ newShape[key] = fieldSchema;
55368
+ } else {
55369
+ newShape[key] = fieldSchema.optional();
55370
+ }
55371
+ }
55372
+ return new _ZodObject({
55373
+ ...this._def,
55374
+ shape: () => newShape
55375
+ });
55376
+ }
55377
+ required(mask) {
55378
+ const newShape = {};
55379
+ for (const key of util.objectKeys(this.shape)) {
55380
+ if (mask && !mask[key]) {
55381
+ newShape[key] = this.shape[key];
55382
+ } else {
55383
+ const fieldSchema = this.shape[key];
55384
+ let newField = fieldSchema;
55385
+ while (newField instanceof ZodOptional2) {
55386
+ newField = newField._def.innerType;
55387
+ }
55388
+ newShape[key] = newField;
55389
+ }
55390
+ }
55391
+ return new _ZodObject({
55392
+ ...this._def,
55393
+ shape: () => newShape
55394
+ });
55395
+ }
55396
+ keyof() {
55397
+ return createZodEnum(util.objectKeys(this.shape));
55398
+ }
55399
+ };
55400
+ ZodObject2.create = (shape, params) => {
55401
+ return new ZodObject2({
55402
+ shape: () => shape,
55403
+ unknownKeys: "strip",
55404
+ catchall: ZodNever2.create(),
55405
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
55406
+ ...processCreateParams(params)
55407
+ });
55408
+ };
55409
+ ZodObject2.strictCreate = (shape, params) => {
55410
+ return new ZodObject2({
55411
+ shape: () => shape,
55412
+ unknownKeys: "strict",
55413
+ catchall: ZodNever2.create(),
55414
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
55415
+ ...processCreateParams(params)
55416
+ });
55417
+ };
55418
+ ZodObject2.lazycreate = (shape, params) => {
55419
+ return new ZodObject2({
55420
+ shape,
55421
+ unknownKeys: "strip",
55422
+ catchall: ZodNever2.create(),
55423
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
55424
+ ...processCreateParams(params)
55425
+ });
55426
+ };
55427
+ var ZodUnion2 = class extends ZodType2 {
55428
+ _parse(input2) {
55429
+ const { ctx } = this._processInputParams(input2);
55430
+ const options = this._def.options;
55431
+ function handleResults(results) {
55432
+ for (const result of results) {
55433
+ if (result.result.status === "valid") {
55434
+ return result.result;
55435
+ }
55436
+ }
55437
+ for (const result of results) {
55438
+ if (result.result.status === "dirty") {
55439
+ ctx.common.issues.push(...result.ctx.common.issues);
55440
+ return result.result;
55441
+ }
55442
+ }
55443
+ const unionErrors = results.map((result) => new ZodError2(result.ctx.common.issues));
55444
+ addIssueToContext(ctx, {
55445
+ code: ZodIssueCode2.invalid_union,
55446
+ unionErrors
55447
+ });
55448
+ return INVALID2;
55449
+ }
55450
+ if (ctx.common.async) {
55451
+ return Promise.all(options.map(async (option) => {
55452
+ const childCtx = {
55453
+ ...ctx,
55454
+ common: {
55455
+ ...ctx.common,
55456
+ issues: []
55457
+ },
55458
+ parent: null
55459
+ };
55460
+ return {
55461
+ result: await option._parseAsync({
55462
+ data: ctx.data,
55463
+ path: ctx.path,
55464
+ parent: childCtx
55465
+ }),
55466
+ ctx: childCtx
55467
+ };
55468
+ })).then(handleResults);
55469
+ } else {
55470
+ let dirty = void 0;
55471
+ const issues = [];
55472
+ for (const option of options) {
55473
+ const childCtx = {
55474
+ ...ctx,
55475
+ common: {
55476
+ ...ctx.common,
55477
+ issues: []
55478
+ },
55479
+ parent: null
55480
+ };
55481
+ const result = option._parseSync({
55482
+ data: ctx.data,
55483
+ path: ctx.path,
55484
+ parent: childCtx
55485
+ });
55486
+ if (result.status === "valid") {
55487
+ return result;
55488
+ } else if (result.status === "dirty" && !dirty) {
55489
+ dirty = { result, ctx: childCtx };
55490
+ }
55491
+ if (childCtx.common.issues.length) {
55492
+ issues.push(childCtx.common.issues);
55493
+ }
55494
+ }
55495
+ if (dirty) {
55496
+ ctx.common.issues.push(...dirty.ctx.common.issues);
55497
+ return dirty.result;
55498
+ }
55499
+ const unionErrors = issues.map((issues2) => new ZodError2(issues2));
55500
+ addIssueToContext(ctx, {
55501
+ code: ZodIssueCode2.invalid_union,
55502
+ unionErrors
55503
+ });
55504
+ return INVALID2;
55505
+ }
55506
+ }
55507
+ get options() {
55508
+ return this._def.options;
55509
+ }
55510
+ };
55511
+ ZodUnion2.create = (types2, params) => {
55512
+ return new ZodUnion2({
55513
+ options: types2,
55514
+ typeName: ZodFirstPartyTypeKind2.ZodUnion,
55515
+ ...processCreateParams(params)
55516
+ });
55517
+ };
55518
+ var getDiscriminator = (type2) => {
55519
+ if (type2 instanceof ZodLazy2) {
55520
+ return getDiscriminator(type2.schema);
55521
+ } else if (type2 instanceof ZodEffects) {
55522
+ return getDiscriminator(type2.innerType());
55523
+ } else if (type2 instanceof ZodLiteral2) {
55524
+ return [type2.value];
55525
+ } else if (type2 instanceof ZodEnum2) {
55526
+ return type2.options;
55527
+ } else if (type2 instanceof ZodNativeEnum) {
55528
+ return util.objectValues(type2.enum);
55529
+ } else if (type2 instanceof ZodDefault2) {
55530
+ return getDiscriminator(type2._def.innerType);
55531
+ } else if (type2 instanceof ZodUndefined2) {
55532
+ return [void 0];
55533
+ } else if (type2 instanceof ZodNull2) {
55534
+ return [null];
55535
+ } else if (type2 instanceof ZodOptional2) {
55536
+ return [void 0, ...getDiscriminator(type2.unwrap())];
55537
+ } else if (type2 instanceof ZodNullable2) {
55538
+ return [null, ...getDiscriminator(type2.unwrap())];
55539
+ } else if (type2 instanceof ZodBranded) {
55540
+ return getDiscriminator(type2.unwrap());
55541
+ } else if (type2 instanceof ZodReadonly2) {
55542
+ return getDiscriminator(type2.unwrap());
55543
+ } else if (type2 instanceof ZodCatch2) {
55544
+ return getDiscriminator(type2._def.innerType);
55545
+ } else {
55546
+ return [];
55547
+ }
55548
+ };
55549
+ var ZodDiscriminatedUnion2 = class _ZodDiscriminatedUnion extends ZodType2 {
55550
+ _parse(input2) {
55551
+ const { ctx } = this._processInputParams(input2);
55552
+ if (ctx.parsedType !== ZodParsedType.object) {
55553
+ addIssueToContext(ctx, {
55554
+ code: ZodIssueCode2.invalid_type,
55555
+ expected: ZodParsedType.object,
55556
+ received: ctx.parsedType
55557
+ });
55558
+ return INVALID2;
55559
+ }
55560
+ const discriminator = this.discriminator;
55561
+ const discriminatorValue = ctx.data[discriminator];
55562
+ const option = this.optionsMap.get(discriminatorValue);
55563
+ if (!option) {
55564
+ addIssueToContext(ctx, {
55565
+ code: ZodIssueCode2.invalid_union_discriminator,
55566
+ options: Array.from(this.optionsMap.keys()),
55567
+ path: [discriminator]
55568
+ });
55569
+ return INVALID2;
55570
+ }
55571
+ if (ctx.common.async) {
55572
+ return option._parseAsync({
55573
+ data: ctx.data,
55574
+ path: ctx.path,
55575
+ parent: ctx
55576
+ });
55577
+ } else {
55578
+ return option._parseSync({
55579
+ data: ctx.data,
55580
+ path: ctx.path,
55581
+ parent: ctx
55582
+ });
55583
+ }
55584
+ }
55585
+ get discriminator() {
55586
+ return this._def.discriminator;
55587
+ }
55588
+ get options() {
55589
+ return this._def.options;
55590
+ }
55591
+ get optionsMap() {
55592
+ return this._def.optionsMap;
55593
+ }
55594
+ /**
55595
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
55596
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
55597
+ * have a different value for each object in the union.
55598
+ * @param discriminator the name of the discriminator property
55599
+ * @param types an array of object schemas
55600
+ * @param params
55601
+ */
55602
+ static create(discriminator, options, params) {
55603
+ const optionsMap = /* @__PURE__ */ new Map();
55604
+ for (const type2 of options) {
55605
+ const discriminatorValues = getDiscriminator(type2.shape[discriminator]);
55606
+ if (!discriminatorValues.length) {
55607
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
55608
+ }
55609
+ for (const value of discriminatorValues) {
55610
+ if (optionsMap.has(value)) {
55611
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
55612
+ }
55613
+ optionsMap.set(value, type2);
55614
+ }
55615
+ }
55616
+ return new _ZodDiscriminatedUnion({
55617
+ typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion,
55618
+ discriminator,
55619
+ options,
55620
+ optionsMap,
55621
+ ...processCreateParams(params)
55622
+ });
55623
+ }
55624
+ };
55625
+ function mergeValues2(a, b) {
55626
+ const aType = getParsedType2(a);
55627
+ const bType = getParsedType2(b);
55628
+ if (a === b) {
55629
+ return { valid: true, data: a };
55630
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
55631
+ const bKeys = util.objectKeys(b);
55632
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
55633
+ const newObj = { ...a, ...b };
55634
+ for (const key of sharedKeys) {
55635
+ const sharedValue = mergeValues2(a[key], b[key]);
55636
+ if (!sharedValue.valid) {
55637
+ return { valid: false };
55638
+ }
55639
+ newObj[key] = sharedValue.data;
55640
+ }
55641
+ return { valid: true, data: newObj };
55642
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
55643
+ if (a.length !== b.length) {
55644
+ return { valid: false };
55645
+ }
55646
+ const newArray = [];
55647
+ for (let index = 0; index < a.length; index++) {
55648
+ const itemA = a[index];
55649
+ const itemB = b[index];
55650
+ const sharedValue = mergeValues2(itemA, itemB);
55651
+ if (!sharedValue.valid) {
55652
+ return { valid: false };
55653
+ }
55654
+ newArray.push(sharedValue.data);
55655
+ }
55656
+ return { valid: true, data: newArray };
55657
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
55658
+ return { valid: true, data: a };
55659
+ } else {
55660
+ return { valid: false };
55661
+ }
55662
+ }
55663
+ var ZodIntersection2 = class extends ZodType2 {
55664
+ _parse(input2) {
55665
+ const { status, ctx } = this._processInputParams(input2);
55666
+ const handleParsed = (parsedLeft, parsedRight) => {
55667
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
55668
+ return INVALID2;
55669
+ }
55670
+ const merged = mergeValues2(parsedLeft.value, parsedRight.value);
55671
+ if (!merged.valid) {
55672
+ addIssueToContext(ctx, {
55673
+ code: ZodIssueCode2.invalid_intersection_types
55674
+ });
55675
+ return INVALID2;
55676
+ }
55677
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
55678
+ status.dirty();
55679
+ }
55680
+ return { status: status.value, value: merged.data };
55681
+ };
55682
+ if (ctx.common.async) {
55683
+ return Promise.all([
55684
+ this._def.left._parseAsync({
55685
+ data: ctx.data,
55686
+ path: ctx.path,
55687
+ parent: ctx
55688
+ }),
55689
+ this._def.right._parseAsync({
55690
+ data: ctx.data,
55691
+ path: ctx.path,
55692
+ parent: ctx
55693
+ })
55694
+ ]).then(([left, right]) => handleParsed(left, right));
55695
+ } else {
55696
+ return handleParsed(this._def.left._parseSync({
55697
+ data: ctx.data,
55698
+ path: ctx.path,
55699
+ parent: ctx
55700
+ }), this._def.right._parseSync({
55701
+ data: ctx.data,
55702
+ path: ctx.path,
55703
+ parent: ctx
55704
+ }));
55705
+ }
55706
+ }
55707
+ };
55708
+ ZodIntersection2.create = (left, right, params) => {
55709
+ return new ZodIntersection2({
55710
+ left,
55711
+ right,
55712
+ typeName: ZodFirstPartyTypeKind2.ZodIntersection,
55713
+ ...processCreateParams(params)
55714
+ });
55715
+ };
55716
+ var ZodTuple2 = class _ZodTuple extends ZodType2 {
55717
+ _parse(input2) {
55718
+ const { status, ctx } = this._processInputParams(input2);
55719
+ if (ctx.parsedType !== ZodParsedType.array) {
55720
+ addIssueToContext(ctx, {
55721
+ code: ZodIssueCode2.invalid_type,
55722
+ expected: ZodParsedType.array,
55723
+ received: ctx.parsedType
55724
+ });
55725
+ return INVALID2;
55726
+ }
55727
+ if (ctx.data.length < this._def.items.length) {
55728
+ addIssueToContext(ctx, {
55729
+ code: ZodIssueCode2.too_small,
55730
+ minimum: this._def.items.length,
55731
+ inclusive: true,
55732
+ exact: false,
55733
+ type: "array"
55734
+ });
55735
+ return INVALID2;
55736
+ }
55737
+ const rest = this._def.rest;
55738
+ if (!rest && ctx.data.length > this._def.items.length) {
55739
+ addIssueToContext(ctx, {
55740
+ code: ZodIssueCode2.too_big,
55741
+ maximum: this._def.items.length,
55742
+ inclusive: true,
55743
+ exact: false,
55744
+ type: "array"
55745
+ });
55746
+ status.dirty();
55747
+ }
55748
+ const items = [...ctx.data].map((item, itemIndex) => {
55749
+ const schema2 = this._def.items[itemIndex] || this._def.rest;
55750
+ if (!schema2)
55751
+ return null;
55752
+ return schema2._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
55753
+ }).filter((x) => !!x);
55754
+ if (ctx.common.async) {
55755
+ return Promise.all(items).then((results) => {
55756
+ return ParseStatus.mergeArray(status, results);
55757
+ });
55758
+ } else {
55759
+ return ParseStatus.mergeArray(status, items);
55760
+ }
55761
+ }
55762
+ get items() {
55763
+ return this._def.items;
55764
+ }
55765
+ rest(rest) {
55766
+ return new _ZodTuple({
55767
+ ...this._def,
55768
+ rest
55769
+ });
55770
+ }
55771
+ };
55772
+ ZodTuple2.create = (schemas, params) => {
55773
+ if (!Array.isArray(schemas)) {
55774
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
55775
+ }
55776
+ return new ZodTuple2({
55777
+ items: schemas,
55778
+ typeName: ZodFirstPartyTypeKind2.ZodTuple,
55779
+ rest: null,
55780
+ ...processCreateParams(params)
55781
+ });
55782
+ };
55783
+ var ZodRecord2 = class _ZodRecord extends ZodType2 {
55784
+ get keySchema() {
55785
+ return this._def.keyType;
55786
+ }
55787
+ get valueSchema() {
55788
+ return this._def.valueType;
55789
+ }
55790
+ _parse(input2) {
55791
+ const { status, ctx } = this._processInputParams(input2);
55792
+ if (ctx.parsedType !== ZodParsedType.object) {
55793
+ addIssueToContext(ctx, {
55794
+ code: ZodIssueCode2.invalid_type,
55795
+ expected: ZodParsedType.object,
55796
+ received: ctx.parsedType
55797
+ });
55798
+ return INVALID2;
55799
+ }
55800
+ const pairs2 = [];
55801
+ const keyType = this._def.keyType;
55802
+ const valueType = this._def.valueType;
55803
+ for (const key in ctx.data) {
55804
+ pairs2.push({
55805
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
55806
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
55807
+ alwaysSet: key in ctx.data
55808
+ });
55809
+ }
55810
+ if (ctx.common.async) {
55811
+ return ParseStatus.mergeObjectAsync(status, pairs2);
55812
+ } else {
55813
+ return ParseStatus.mergeObjectSync(status, pairs2);
55814
+ }
55815
+ }
55816
+ get element() {
55817
+ return this._def.valueType;
55818
+ }
55819
+ static create(first, second, third) {
55820
+ if (second instanceof ZodType2) {
55821
+ return new _ZodRecord({
55822
+ keyType: first,
55823
+ valueType: second,
55824
+ typeName: ZodFirstPartyTypeKind2.ZodRecord,
55825
+ ...processCreateParams(third)
55826
+ });
55827
+ }
55828
+ return new _ZodRecord({
55829
+ keyType: ZodString2.create(),
55830
+ valueType: first,
55831
+ typeName: ZodFirstPartyTypeKind2.ZodRecord,
55832
+ ...processCreateParams(second)
55833
+ });
55834
+ }
55835
+ };
55836
+ var ZodMap2 = class extends ZodType2 {
55837
+ get keySchema() {
55838
+ return this._def.keyType;
55839
+ }
55840
+ get valueSchema() {
55841
+ return this._def.valueType;
55842
+ }
55843
+ _parse(input2) {
55844
+ const { status, ctx } = this._processInputParams(input2);
55845
+ if (ctx.parsedType !== ZodParsedType.map) {
55846
+ addIssueToContext(ctx, {
55847
+ code: ZodIssueCode2.invalid_type,
55848
+ expected: ZodParsedType.map,
55849
+ received: ctx.parsedType
55850
+ });
55851
+ return INVALID2;
55852
+ }
55853
+ const keyType = this._def.keyType;
55854
+ const valueType = this._def.valueType;
55855
+ const pairs2 = [...ctx.data.entries()].map(([key, value], index) => {
55856
+ return {
55857
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
55858
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
55859
+ };
55860
+ });
55861
+ if (ctx.common.async) {
55862
+ const finalMap = /* @__PURE__ */ new Map();
55863
+ return Promise.resolve().then(async () => {
55864
+ for (const pair of pairs2) {
55865
+ const key = await pair.key;
55866
+ const value = await pair.value;
55867
+ if (key.status === "aborted" || value.status === "aborted") {
55868
+ return INVALID2;
55869
+ }
55870
+ if (key.status === "dirty" || value.status === "dirty") {
55871
+ status.dirty();
55872
+ }
55873
+ finalMap.set(key.value, value.value);
55874
+ }
55875
+ return { status: status.value, value: finalMap };
55876
+ });
55877
+ } else {
55878
+ const finalMap = /* @__PURE__ */ new Map();
55879
+ for (const pair of pairs2) {
55880
+ const key = pair.key;
55881
+ const value = pair.value;
55882
+ if (key.status === "aborted" || value.status === "aborted") {
55883
+ return INVALID2;
55884
+ }
55885
+ if (key.status === "dirty" || value.status === "dirty") {
55886
+ status.dirty();
55887
+ }
55888
+ finalMap.set(key.value, value.value);
55889
+ }
55890
+ return { status: status.value, value: finalMap };
55891
+ }
55892
+ }
55893
+ };
55894
+ ZodMap2.create = (keyType, valueType, params) => {
55895
+ return new ZodMap2({
55896
+ valueType,
55897
+ keyType,
55898
+ typeName: ZodFirstPartyTypeKind2.ZodMap,
55899
+ ...processCreateParams(params)
55900
+ });
55901
+ };
55902
+ var ZodSet2 = class _ZodSet extends ZodType2 {
55903
+ _parse(input2) {
55904
+ const { status, ctx } = this._processInputParams(input2);
55905
+ if (ctx.parsedType !== ZodParsedType.set) {
55906
+ addIssueToContext(ctx, {
55907
+ code: ZodIssueCode2.invalid_type,
55908
+ expected: ZodParsedType.set,
55909
+ received: ctx.parsedType
55910
+ });
55911
+ return INVALID2;
55912
+ }
55913
+ const def = this._def;
55914
+ if (def.minSize !== null) {
55915
+ if (ctx.data.size < def.minSize.value) {
55916
+ addIssueToContext(ctx, {
55917
+ code: ZodIssueCode2.too_small,
55918
+ minimum: def.minSize.value,
55919
+ type: "set",
55920
+ inclusive: true,
55921
+ exact: false,
55922
+ message: def.minSize.message
55923
+ });
55924
+ status.dirty();
55925
+ }
55926
+ }
55927
+ if (def.maxSize !== null) {
55928
+ if (ctx.data.size > def.maxSize.value) {
55929
+ addIssueToContext(ctx, {
55930
+ code: ZodIssueCode2.too_big,
55931
+ maximum: def.maxSize.value,
55932
+ type: "set",
55933
+ inclusive: true,
55934
+ exact: false,
55935
+ message: def.maxSize.message
55936
+ });
55937
+ status.dirty();
55938
+ }
55939
+ }
55940
+ const valueType = this._def.valueType;
55941
+ function finalizeSet(elements2) {
55942
+ const parsedSet = /* @__PURE__ */ new Set();
55943
+ for (const element of elements2) {
55944
+ if (element.status === "aborted")
55945
+ return INVALID2;
55946
+ if (element.status === "dirty")
55947
+ status.dirty();
55948
+ parsedSet.add(element.value);
55949
+ }
55950
+ return { status: status.value, value: parsedSet };
55951
+ }
55952
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
55953
+ if (ctx.common.async) {
55954
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
55955
+ } else {
55956
+ return finalizeSet(elements);
55957
+ }
55958
+ }
55959
+ min(minSize, message) {
55960
+ return new _ZodSet({
55961
+ ...this._def,
55962
+ minSize: { value: minSize, message: errorUtil.toString(message) }
55963
+ });
55964
+ }
55965
+ max(maxSize, message) {
55966
+ return new _ZodSet({
55967
+ ...this._def,
55968
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
55969
+ });
55970
+ }
55971
+ size(size, message) {
55972
+ return this.min(size, message).max(size, message);
55973
+ }
55974
+ nonempty(message) {
55975
+ return this.min(1, message);
55976
+ }
55977
+ };
55978
+ ZodSet2.create = (valueType, params) => {
55979
+ return new ZodSet2({
55980
+ valueType,
55981
+ minSize: null,
55982
+ maxSize: null,
55983
+ typeName: ZodFirstPartyTypeKind2.ZodSet,
55984
+ ...processCreateParams(params)
55985
+ });
55986
+ };
55987
+ var ZodFunction2 = class _ZodFunction extends ZodType2 {
55988
+ constructor() {
55989
+ super(...arguments);
55990
+ this.validate = this.implement;
55991
+ }
55992
+ _parse(input2) {
55993
+ const { ctx } = this._processInputParams(input2);
55994
+ if (ctx.parsedType !== ZodParsedType.function) {
55995
+ addIssueToContext(ctx, {
55996
+ code: ZodIssueCode2.invalid_type,
55997
+ expected: ZodParsedType.function,
55998
+ received: ctx.parsedType
55999
+ });
56000
+ return INVALID2;
56001
+ }
56002
+ function makeArgsIssue(args, error62) {
56003
+ return makeIssue({
56004
+ data: args,
56005
+ path: ctx.path,
56006
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
56007
+ issueData: {
56008
+ code: ZodIssueCode2.invalid_arguments,
56009
+ argumentsError: error62
56010
+ }
56011
+ });
56012
+ }
56013
+ function makeReturnsIssue(returns, error62) {
56014
+ return makeIssue({
56015
+ data: returns,
56016
+ path: ctx.path,
56017
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
56018
+ issueData: {
56019
+ code: ZodIssueCode2.invalid_return_type,
56020
+ returnTypeError: error62
56021
+ }
56022
+ });
56023
+ }
56024
+ const params = { errorMap: ctx.common.contextualErrorMap };
56025
+ const fn = ctx.data;
56026
+ if (this._def.returns instanceof ZodPromise2) {
56027
+ const me = this;
56028
+ return OK(async function(...args) {
56029
+ const error62 = new ZodError2([]);
56030
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
56031
+ error62.addIssue(makeArgsIssue(args, e));
56032
+ throw error62;
56033
+ });
56034
+ const result = await Reflect.apply(fn, this, parsedArgs);
56035
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
56036
+ error62.addIssue(makeReturnsIssue(result, e));
56037
+ throw error62;
56038
+ });
56039
+ return parsedReturns;
56040
+ });
56041
+ } else {
56042
+ const me = this;
56043
+ return OK(function(...args) {
56044
+ const parsedArgs = me._def.args.safeParse(args, params);
56045
+ if (!parsedArgs.success) {
56046
+ throw new ZodError2([makeArgsIssue(args, parsedArgs.error)]);
56047
+ }
56048
+ const result = Reflect.apply(fn, this, parsedArgs.data);
56049
+ const parsedReturns = me._def.returns.safeParse(result, params);
56050
+ if (!parsedReturns.success) {
56051
+ throw new ZodError2([makeReturnsIssue(result, parsedReturns.error)]);
56052
+ }
56053
+ return parsedReturns.data;
56054
+ });
56055
+ }
56056
+ }
56057
+ parameters() {
56058
+ return this._def.args;
56059
+ }
56060
+ returnType() {
56061
+ return this._def.returns;
56062
+ }
56063
+ args(...items) {
56064
+ return new _ZodFunction({
56065
+ ...this._def,
56066
+ args: ZodTuple2.create(items).rest(ZodUnknown2.create())
56067
+ });
56068
+ }
56069
+ returns(returnType) {
56070
+ return new _ZodFunction({
56071
+ ...this._def,
56072
+ returns: returnType
56073
+ });
56074
+ }
56075
+ implement(func) {
56076
+ const validatedFunc = this.parse(func);
56077
+ return validatedFunc;
56078
+ }
56079
+ strictImplement(func) {
56080
+ const validatedFunc = this.parse(func);
56081
+ return validatedFunc;
56082
+ }
56083
+ static create(args, returns, params) {
56084
+ return new _ZodFunction({
56085
+ args: args ? args : ZodTuple2.create([]).rest(ZodUnknown2.create()),
56086
+ returns: returns || ZodUnknown2.create(),
56087
+ typeName: ZodFirstPartyTypeKind2.ZodFunction,
56088
+ ...processCreateParams(params)
56089
+ });
56090
+ }
56091
+ };
56092
+ var ZodLazy2 = class extends ZodType2 {
56093
+ get schema() {
56094
+ return this._def.getter();
56095
+ }
56096
+ _parse(input2) {
56097
+ const { ctx } = this._processInputParams(input2);
56098
+ const lazySchema = this._def.getter();
56099
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
56100
+ }
56101
+ };
56102
+ ZodLazy2.create = (getter, params) => {
56103
+ return new ZodLazy2({
56104
+ getter,
56105
+ typeName: ZodFirstPartyTypeKind2.ZodLazy,
56106
+ ...processCreateParams(params)
56107
+ });
56108
+ };
56109
+ var ZodLiteral2 = class extends ZodType2 {
56110
+ _parse(input2) {
56111
+ if (input2.data !== this._def.value) {
56112
+ const ctx = this._getOrReturnCtx(input2);
56113
+ addIssueToContext(ctx, {
56114
+ received: ctx.data,
56115
+ code: ZodIssueCode2.invalid_literal,
56116
+ expected: this._def.value
56117
+ });
56118
+ return INVALID2;
56119
+ }
56120
+ return { status: "valid", value: input2.data };
56121
+ }
56122
+ get value() {
56123
+ return this._def.value;
56124
+ }
56125
+ };
56126
+ ZodLiteral2.create = (value, params) => {
56127
+ return new ZodLiteral2({
56128
+ value,
56129
+ typeName: ZodFirstPartyTypeKind2.ZodLiteral,
56130
+ ...processCreateParams(params)
56131
+ });
56132
+ };
56133
+ function createZodEnum(values, params) {
56134
+ return new ZodEnum2({
56135
+ values,
56136
+ typeName: ZodFirstPartyTypeKind2.ZodEnum,
56137
+ ...processCreateParams(params)
56138
+ });
56139
+ }
56140
+ var ZodEnum2 = class _ZodEnum extends ZodType2 {
56141
+ _parse(input2) {
56142
+ if (typeof input2.data !== "string") {
56143
+ const ctx = this._getOrReturnCtx(input2);
56144
+ const expectedValues = this._def.values;
56145
+ addIssueToContext(ctx, {
56146
+ expected: util.joinValues(expectedValues),
56147
+ received: ctx.parsedType,
56148
+ code: ZodIssueCode2.invalid_type
56149
+ });
56150
+ return INVALID2;
56151
+ }
56152
+ if (!this._cache) {
56153
+ this._cache = new Set(this._def.values);
56154
+ }
56155
+ if (!this._cache.has(input2.data)) {
56156
+ const ctx = this._getOrReturnCtx(input2);
56157
+ const expectedValues = this._def.values;
56158
+ addIssueToContext(ctx, {
56159
+ received: ctx.data,
56160
+ code: ZodIssueCode2.invalid_enum_value,
56161
+ options: expectedValues
56162
+ });
56163
+ return INVALID2;
56164
+ }
56165
+ return OK(input2.data);
56166
+ }
56167
+ get options() {
56168
+ return this._def.values;
56169
+ }
56170
+ get enum() {
56171
+ const enumValues = {};
56172
+ for (const val of this._def.values) {
56173
+ enumValues[val] = val;
56174
+ }
56175
+ return enumValues;
56176
+ }
56177
+ get Values() {
56178
+ const enumValues = {};
56179
+ for (const val of this._def.values) {
56180
+ enumValues[val] = val;
56181
+ }
56182
+ return enumValues;
56183
+ }
56184
+ get Enum() {
56185
+ const enumValues = {};
56186
+ for (const val of this._def.values) {
56187
+ enumValues[val] = val;
56188
+ }
56189
+ return enumValues;
56190
+ }
56191
+ extract(values, newDef = this._def) {
56192
+ return _ZodEnum.create(values, {
56193
+ ...this._def,
56194
+ ...newDef
56195
+ });
56196
+ }
56197
+ exclude(values, newDef = this._def) {
56198
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
56199
+ ...this._def,
56200
+ ...newDef
56201
+ });
56202
+ }
56203
+ };
56204
+ ZodEnum2.create = createZodEnum;
56205
+ var ZodNativeEnum = class extends ZodType2 {
56206
+ _parse(input2) {
56207
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
56208
+ const ctx = this._getOrReturnCtx(input2);
56209
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
56210
+ const expectedValues = util.objectValues(nativeEnumValues);
56211
+ addIssueToContext(ctx, {
56212
+ expected: util.joinValues(expectedValues),
56213
+ received: ctx.parsedType,
56214
+ code: ZodIssueCode2.invalid_type
56215
+ });
56216
+ return INVALID2;
56217
+ }
56218
+ if (!this._cache) {
56219
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
56220
+ }
56221
+ if (!this._cache.has(input2.data)) {
56222
+ const expectedValues = util.objectValues(nativeEnumValues);
56223
+ addIssueToContext(ctx, {
56224
+ received: ctx.data,
56225
+ code: ZodIssueCode2.invalid_enum_value,
56226
+ options: expectedValues
56227
+ });
56228
+ return INVALID2;
56229
+ }
56230
+ return OK(input2.data);
56231
+ }
56232
+ get enum() {
56233
+ return this._def.values;
56234
+ }
56235
+ };
56236
+ ZodNativeEnum.create = (values, params) => {
56237
+ return new ZodNativeEnum({
56238
+ values,
56239
+ typeName: ZodFirstPartyTypeKind2.ZodNativeEnum,
56240
+ ...processCreateParams(params)
56241
+ });
56242
+ };
56243
+ var ZodPromise2 = class extends ZodType2 {
56244
+ unwrap() {
56245
+ return this._def.type;
56246
+ }
56247
+ _parse(input2) {
56248
+ const { ctx } = this._processInputParams(input2);
56249
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
56250
+ addIssueToContext(ctx, {
56251
+ code: ZodIssueCode2.invalid_type,
56252
+ expected: ZodParsedType.promise,
56253
+ received: ctx.parsedType
56254
+ });
56255
+ return INVALID2;
56256
+ }
56257
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
56258
+ return OK(promisified.then((data) => {
56259
+ return this._def.type.parseAsync(data, {
56260
+ path: ctx.path,
56261
+ errorMap: ctx.common.contextualErrorMap
56262
+ });
56263
+ }));
56264
+ }
56265
+ };
56266
+ ZodPromise2.create = (schema2, params) => {
56267
+ return new ZodPromise2({
56268
+ type: schema2,
56269
+ typeName: ZodFirstPartyTypeKind2.ZodPromise,
56270
+ ...processCreateParams(params)
56271
+ });
56272
+ };
56273
+ var ZodEffects = class extends ZodType2 {
56274
+ innerType() {
56275
+ return this._def.schema;
56276
+ }
56277
+ sourceType() {
56278
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
56279
+ }
56280
+ _parse(input2) {
56281
+ const { status, ctx } = this._processInputParams(input2);
56282
+ const effect = this._def.effect || null;
56283
+ const checkCtx = {
56284
+ addIssue: (arg) => {
56285
+ addIssueToContext(ctx, arg);
56286
+ if (arg.fatal) {
56287
+ status.abort();
56288
+ } else {
56289
+ status.dirty();
56290
+ }
56291
+ },
56292
+ get path() {
56293
+ return ctx.path;
56294
+ }
56295
+ };
56296
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
56297
+ if (effect.type === "preprocess") {
56298
+ const processed = effect.transform(ctx.data, checkCtx);
56299
+ if (ctx.common.async) {
56300
+ return Promise.resolve(processed).then(async (processed2) => {
56301
+ if (status.value === "aborted")
56302
+ return INVALID2;
56303
+ const result = await this._def.schema._parseAsync({
56304
+ data: processed2,
56305
+ path: ctx.path,
56306
+ parent: ctx
56307
+ });
56308
+ if (result.status === "aborted")
56309
+ return INVALID2;
56310
+ if (result.status === "dirty")
56311
+ return DIRTY(result.value);
56312
+ if (status.value === "dirty")
56313
+ return DIRTY(result.value);
56314
+ return result;
56315
+ });
56316
+ } else {
56317
+ if (status.value === "aborted")
56318
+ return INVALID2;
56319
+ const result = this._def.schema._parseSync({
56320
+ data: processed,
56321
+ path: ctx.path,
56322
+ parent: ctx
56323
+ });
56324
+ if (result.status === "aborted")
56325
+ return INVALID2;
56326
+ if (result.status === "dirty")
56327
+ return DIRTY(result.value);
56328
+ if (status.value === "dirty")
56329
+ return DIRTY(result.value);
56330
+ return result;
56331
+ }
56332
+ }
56333
+ if (effect.type === "refinement") {
56334
+ const executeRefinement = (acc) => {
56335
+ const result = effect.refinement(acc, checkCtx);
56336
+ if (ctx.common.async) {
56337
+ return Promise.resolve(result);
56338
+ }
56339
+ if (result instanceof Promise) {
56340
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
56341
+ }
56342
+ return acc;
56343
+ };
56344
+ if (ctx.common.async === false) {
56345
+ const inner = this._def.schema._parseSync({
56346
+ data: ctx.data,
56347
+ path: ctx.path,
56348
+ parent: ctx
56349
+ });
56350
+ if (inner.status === "aborted")
56351
+ return INVALID2;
56352
+ if (inner.status === "dirty")
56353
+ status.dirty();
56354
+ executeRefinement(inner.value);
56355
+ return { status: status.value, value: inner.value };
56356
+ } else {
56357
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
56358
+ if (inner.status === "aborted")
56359
+ return INVALID2;
56360
+ if (inner.status === "dirty")
56361
+ status.dirty();
56362
+ return executeRefinement(inner.value).then(() => {
56363
+ return { status: status.value, value: inner.value };
56364
+ });
56365
+ });
56366
+ }
56367
+ }
56368
+ if (effect.type === "transform") {
56369
+ if (ctx.common.async === false) {
56370
+ const base = this._def.schema._parseSync({
56371
+ data: ctx.data,
56372
+ path: ctx.path,
56373
+ parent: ctx
56374
+ });
56375
+ if (!isValid(base))
56376
+ return INVALID2;
56377
+ const result = effect.transform(base.value, checkCtx);
56378
+ if (result instanceof Promise) {
56379
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
56380
+ }
56381
+ return { status: status.value, value: result };
56382
+ } else {
56383
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
56384
+ if (!isValid(base))
56385
+ return INVALID2;
56386
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
56387
+ status: status.value,
56388
+ value: result
56389
+ }));
56390
+ });
56391
+ }
56392
+ }
56393
+ util.assertNever(effect);
56394
+ }
56395
+ };
56396
+ ZodEffects.create = (schema2, effect, params) => {
56397
+ return new ZodEffects({
56398
+ schema: schema2,
56399
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
56400
+ effect,
56401
+ ...processCreateParams(params)
56402
+ });
56403
+ };
56404
+ ZodEffects.createWithPreprocess = (preprocess2, schema2, params) => {
56405
+ return new ZodEffects({
56406
+ schema: schema2,
56407
+ effect: { type: "preprocess", transform: preprocess2 },
56408
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
56409
+ ...processCreateParams(params)
56410
+ });
56411
+ };
56412
+ var ZodOptional2 = class extends ZodType2 {
56413
+ _parse(input2) {
56414
+ const parsedType2 = this._getType(input2);
56415
+ if (parsedType2 === ZodParsedType.undefined) {
56416
+ return OK(void 0);
56417
+ }
56418
+ return this._def.innerType._parse(input2);
56419
+ }
56420
+ unwrap() {
56421
+ return this._def.innerType;
56422
+ }
56423
+ };
56424
+ ZodOptional2.create = (type2, params) => {
56425
+ return new ZodOptional2({
56426
+ innerType: type2,
56427
+ typeName: ZodFirstPartyTypeKind2.ZodOptional,
56428
+ ...processCreateParams(params)
56429
+ });
56430
+ };
56431
+ var ZodNullable2 = class extends ZodType2 {
56432
+ _parse(input2) {
56433
+ const parsedType2 = this._getType(input2);
56434
+ if (parsedType2 === ZodParsedType.null) {
56435
+ return OK(null);
56436
+ }
56437
+ return this._def.innerType._parse(input2);
56438
+ }
56439
+ unwrap() {
56440
+ return this._def.innerType;
56441
+ }
56442
+ };
56443
+ ZodNullable2.create = (type2, params) => {
56444
+ return new ZodNullable2({
56445
+ innerType: type2,
56446
+ typeName: ZodFirstPartyTypeKind2.ZodNullable,
56447
+ ...processCreateParams(params)
56448
+ });
56449
+ };
56450
+ var ZodDefault2 = class extends ZodType2 {
56451
+ _parse(input2) {
56452
+ const { ctx } = this._processInputParams(input2);
56453
+ let data = ctx.data;
56454
+ if (ctx.parsedType === ZodParsedType.undefined) {
56455
+ data = this._def.defaultValue();
56456
+ }
56457
+ return this._def.innerType._parse({
56458
+ data,
56459
+ path: ctx.path,
56460
+ parent: ctx
56461
+ });
56462
+ }
56463
+ removeDefault() {
56464
+ return this._def.innerType;
56465
+ }
56466
+ };
56467
+ ZodDefault2.create = (type2, params) => {
56468
+ return new ZodDefault2({
56469
+ innerType: type2,
56470
+ typeName: ZodFirstPartyTypeKind2.ZodDefault,
56471
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
56472
+ ...processCreateParams(params)
56473
+ });
56474
+ };
56475
+ var ZodCatch2 = class extends ZodType2 {
56476
+ _parse(input2) {
56477
+ const { ctx } = this._processInputParams(input2);
56478
+ const newCtx = {
56479
+ ...ctx,
56480
+ common: {
56481
+ ...ctx.common,
56482
+ issues: []
56483
+ }
56484
+ };
56485
+ const result = this._def.innerType._parse({
56486
+ data: newCtx.data,
56487
+ path: newCtx.path,
56488
+ parent: {
56489
+ ...newCtx
56490
+ }
56491
+ });
56492
+ if (isAsync(result)) {
56493
+ return result.then((result2) => {
56494
+ return {
56495
+ status: "valid",
56496
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
56497
+ get error() {
56498
+ return new ZodError2(newCtx.common.issues);
56499
+ },
56500
+ input: newCtx.data
56501
+ })
56502
+ };
56503
+ });
56504
+ } else {
56505
+ return {
56506
+ status: "valid",
56507
+ value: result.status === "valid" ? result.value : this._def.catchValue({
56508
+ get error() {
56509
+ return new ZodError2(newCtx.common.issues);
56510
+ },
56511
+ input: newCtx.data
56512
+ })
56513
+ };
56514
+ }
56515
+ }
56516
+ removeCatch() {
56517
+ return this._def.innerType;
56518
+ }
56519
+ };
56520
+ ZodCatch2.create = (type2, params) => {
56521
+ return new ZodCatch2({
56522
+ innerType: type2,
56523
+ typeName: ZodFirstPartyTypeKind2.ZodCatch,
56524
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
56525
+ ...processCreateParams(params)
56526
+ });
56527
+ };
56528
+ var ZodNaN2 = class extends ZodType2 {
56529
+ _parse(input2) {
56530
+ const parsedType2 = this._getType(input2);
56531
+ if (parsedType2 !== ZodParsedType.nan) {
56532
+ const ctx = this._getOrReturnCtx(input2);
56533
+ addIssueToContext(ctx, {
56534
+ code: ZodIssueCode2.invalid_type,
56535
+ expected: ZodParsedType.nan,
56536
+ received: ctx.parsedType
56537
+ });
56538
+ return INVALID2;
56539
+ }
56540
+ return { status: "valid", value: input2.data };
56541
+ }
56542
+ };
56543
+ ZodNaN2.create = (params) => {
56544
+ return new ZodNaN2({
56545
+ typeName: ZodFirstPartyTypeKind2.ZodNaN,
56546
+ ...processCreateParams(params)
56547
+ });
56548
+ };
56549
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
56550
+ var ZodBranded = class extends ZodType2 {
56551
+ _parse(input2) {
56552
+ const { ctx } = this._processInputParams(input2);
56553
+ const data = ctx.data;
56554
+ return this._def.type._parse({
56555
+ data,
56556
+ path: ctx.path,
56557
+ parent: ctx
56558
+ });
56559
+ }
56560
+ unwrap() {
56561
+ return this._def.type;
56562
+ }
56563
+ };
56564
+ var ZodPipeline = class _ZodPipeline extends ZodType2 {
56565
+ _parse(input2) {
56566
+ const { status, ctx } = this._processInputParams(input2);
56567
+ if (ctx.common.async) {
56568
+ const handleAsync = async () => {
56569
+ const inResult = await this._def.in._parseAsync({
56570
+ data: ctx.data,
56571
+ path: ctx.path,
56572
+ parent: ctx
56573
+ });
56574
+ if (inResult.status === "aborted")
56575
+ return INVALID2;
56576
+ if (inResult.status === "dirty") {
56577
+ status.dirty();
56578
+ return DIRTY(inResult.value);
56579
+ } else {
56580
+ return this._def.out._parseAsync({
56581
+ data: inResult.value,
56582
+ path: ctx.path,
56583
+ parent: ctx
56584
+ });
56585
+ }
56586
+ };
56587
+ return handleAsync();
56588
+ } else {
56589
+ const inResult = this._def.in._parseSync({
56590
+ data: ctx.data,
56591
+ path: ctx.path,
56592
+ parent: ctx
56593
+ });
56594
+ if (inResult.status === "aborted")
56595
+ return INVALID2;
56596
+ if (inResult.status === "dirty") {
56597
+ status.dirty();
56598
+ return {
56599
+ status: "dirty",
56600
+ value: inResult.value
56601
+ };
56602
+ } else {
56603
+ return this._def.out._parseSync({
56604
+ data: inResult.value,
56605
+ path: ctx.path,
56606
+ parent: ctx
56607
+ });
56608
+ }
56609
+ }
56610
+ }
56611
+ static create(a, b) {
56612
+ return new _ZodPipeline({
56613
+ in: a,
56614
+ out: b,
56615
+ typeName: ZodFirstPartyTypeKind2.ZodPipeline
56616
+ });
56617
+ }
56618
+ };
56619
+ var ZodReadonly2 = class extends ZodType2 {
56620
+ _parse(input2) {
56621
+ const result = this._def.innerType._parse(input2);
56622
+ const freeze = (data) => {
56623
+ if (isValid(data)) {
56624
+ data.value = Object.freeze(data.value);
56625
+ }
56626
+ return data;
56627
+ };
56628
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
56629
+ }
56630
+ unwrap() {
56631
+ return this._def.innerType;
56632
+ }
56633
+ };
56634
+ ZodReadonly2.create = (type2, params) => {
56635
+ return new ZodReadonly2({
56636
+ innerType: type2,
56637
+ typeName: ZodFirstPartyTypeKind2.ZodReadonly,
56638
+ ...processCreateParams(params)
56639
+ });
56640
+ };
56641
+ function cleanParams(params, data) {
56642
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
56643
+ const p2 = typeof p === "string" ? { message: p } : p;
56644
+ return p2;
56645
+ }
56646
+ function custom2(check3, _params = {}, fatal) {
56647
+ if (check3)
56648
+ return ZodAny2.create().superRefine((data, ctx) => {
56649
+ const r = check3(data);
56650
+ if (r instanceof Promise) {
56651
+ return r.then((r2) => {
56652
+ if (!r2) {
56653
+ const params = cleanParams(_params, data);
56654
+ const _fatal = params.fatal ?? fatal ?? true;
56655
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
56656
+ }
56657
+ });
56658
+ }
56659
+ if (!r) {
56660
+ const params = cleanParams(_params, data);
56661
+ const _fatal = params.fatal ?? fatal ?? true;
56662
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
56663
+ }
56664
+ return;
56665
+ });
56666
+ return ZodAny2.create();
56667
+ }
56668
+ var late = {
56669
+ object: ZodObject2.lazycreate
56670
+ };
56671
+ var ZodFirstPartyTypeKind2;
56672
+ (function(ZodFirstPartyTypeKind3) {
56673
+ ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
56674
+ ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
56675
+ ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
56676
+ ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
56677
+ ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
56678
+ ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
56679
+ ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
56680
+ ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
56681
+ ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
56682
+ ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
56683
+ ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
56684
+ ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
56685
+ ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
56686
+ ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
56687
+ ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
56688
+ ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
56689
+ ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
56690
+ ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
56691
+ ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
56692
+ ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
56693
+ ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
56694
+ ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
56695
+ ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
56696
+ ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
56697
+ ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
56698
+ ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
56699
+ ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
56700
+ ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
56701
+ ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
56702
+ ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
56703
+ ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
56704
+ ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
56705
+ ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
56706
+ ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
56707
+ ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
56708
+ ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
56709
+ })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
56710
+ var instanceOfType = (cls, params = {
56711
+ message: `Input not instance of ${cls.name}`
56712
+ }) => custom2((data) => data instanceof cls, params);
56713
+ var stringType = ZodString2.create;
56714
+ var numberType = ZodNumber2.create;
56715
+ var nanType = ZodNaN2.create;
56716
+ var bigIntType = ZodBigInt2.create;
56717
+ var booleanType = ZodBoolean2.create;
56718
+ var dateType = ZodDate2.create;
56719
+ var symbolType = ZodSymbol2.create;
56720
+ var undefinedType = ZodUndefined2.create;
56721
+ var nullType = ZodNull2.create;
56722
+ var anyType = ZodAny2.create;
56723
+ var unknownType = ZodUnknown2.create;
56724
+ var neverType = ZodNever2.create;
56725
+ var voidType = ZodVoid2.create;
56726
+ var arrayType = ZodArray2.create;
56727
+ var objectType = ZodObject2.create;
56728
+ var strictObjectType = ZodObject2.strictCreate;
56729
+ var unionType = ZodUnion2.create;
56730
+ var discriminatedUnionType = ZodDiscriminatedUnion2.create;
56731
+ var intersectionType = ZodIntersection2.create;
56732
+ var tupleType = ZodTuple2.create;
56733
+ var recordType = ZodRecord2.create;
56734
+ var mapType = ZodMap2.create;
56735
+ var setType = ZodSet2.create;
56736
+ var functionType = ZodFunction2.create;
56737
+ var lazyType = ZodLazy2.create;
56738
+ var literalType = ZodLiteral2.create;
56739
+ var enumType = ZodEnum2.create;
56740
+ var nativeEnumType = ZodNativeEnum.create;
56741
+ var promiseType = ZodPromise2.create;
56742
+ var effectsType = ZodEffects.create;
56743
+ var optionalType = ZodOptional2.create;
56744
+ var nullableType = ZodNullable2.create;
56745
+ var preprocessType = ZodEffects.createWithPreprocess;
56746
+ var pipelineType = ZodPipeline.create;
56747
+ var ostring = () => stringType().optional();
56748
+ var onumber = () => numberType().optional();
56749
+ var oboolean = () => booleanType().optional();
56750
+ var coerce = {
56751
+ string: ((arg) => ZodString2.create({ ...arg, coerce: true })),
56752
+ number: ((arg) => ZodNumber2.create({ ...arg, coerce: true })),
56753
+ boolean: ((arg) => ZodBoolean2.create({
56754
+ ...arg,
56755
+ coerce: true
56756
+ })),
56757
+ bigint: ((arg) => ZodBigInt2.create({ ...arg, coerce: true })),
56758
+ date: ((arg) => ZodDate2.create({ ...arg, coerce: true }))
56759
+ };
56760
+ var NEVER2 = INVALID2;
56761
+
56762
+ // ../../packages/domain/node_modules/zod/index.js
56763
+ var zod_default = external_exports2;
56764
+
56765
+ // ../../packages/domain/dist/index.js
56766
+ var MemberSchema = zod_default.object({
56767
+ id: zod_default.number().positive("id deve ser um n\xFAmero positivo"),
56768
+ login: zod_default.string().min(1, "login \xE9 obrigat\xF3rio"),
56769
+ firstname: zod_default.string().min(1, "firstname \xE9 obrigat\xF3rio"),
56770
+ lastname: zod_default.string().min(1, "lastname \xE9 obrigat\xF3rio"),
56771
+ admin: zod_default.boolean(),
56772
+ customFields: zod_default.array(
56773
+ zod_default.object({
56774
+ id: zod_default.number(),
56775
+ name: zod_default.string(),
56776
+ value: zod_default.string()
56777
+ })
56778
+ )
56779
+ });
56780
+ var TaskSchema = zod_default.object({
56781
+ title: zod_default.string().min(1, "title \xE9 obrigat\xF3rio").min(3, "title deve ter no m\xEDnimo 3 caracteres"),
56782
+ description: zod_default.string().min(1, "description \xE9 obrigat\xF3rio"),
56783
+ workspaceId: zod_default.string().min(1, "workspaceId \xE9 obrigat\xF3rio"),
56784
+ isFallback: zod_default.boolean().optional(),
56785
+ externalId: zod_default.string().optional(),
56786
+ externalType: zod_default.string().optional()
56787
+ });
56788
+ var CommentSchema = zod_default.string().max(255, "O coment\xE1rio n\xE3o pode ter mais que 255 caracteres").nullable().optional();
56789
+ var UserSchema = zod_default.object({
56790
+ id: zod_default.string().min(1, "user.id \xE9 obrigat\xF3rio"),
56791
+ name: zod_default.string().optional()
56792
+ });
56793
+ var ActivitySchema = zod_default.object({
56794
+ id: zod_default.string().min(1, "activity.id \xE9 obrigat\xF3rio"),
56795
+ name: zod_default.string().optional()
56796
+ });
56797
+ var TimeEntrySchema = zod_default.object({
56798
+ id: zod_default.string().optional(),
56799
+ task: zod_default.object({ id: zod_default.string() }),
56800
+ activity: ActivitySchema,
56801
+ user: UserSchema,
56802
+ startDate: zod_default.date().optional(),
56803
+ endDate: zod_default.date().optional(),
56804
+ timeSpent: zod_default.number().nonnegative().optional(),
56805
+ comments: CommentSchema
56806
+ });
56807
+ var avatarUrlSchema = zod_default.string().optional().or(zod_default.literal("")).refine(
56808
+ (val) => {
56809
+ if (!val) return true;
56810
+ if (val.startsWith("blob:")) return true;
56811
+ if (!URL.canParse(val)) return false;
56812
+ const url2 = new URL(val);
56813
+ if (!url2.hostname) return false;
56814
+ const isWebUrl = url2.protocol === "https:" || url2.protocol === "http:";
56815
+ if (url2.origin !== "null" && !isWebUrl) return false;
56816
+ if (["data:", "file:", "javascript:"].includes(url2.protocol)) return false;
56817
+ return /\.(png|jpe?g|gif|svg|webp)$/i.test(url2.pathname);
56818
+ },
56819
+ {
56820
+ message: "Avatar deve ser uma URL v\xE1lida de imagem (png, jpg, jpeg, gif, svg, webp)"
56821
+ }
56822
+ );
56823
+ var WorkspaceSchema = zod_default.object({
56824
+ name: zod_default.string().min(1, "Nome \xE9 obrigat\xF3rio").min(3, "Nome deve ter pelo menos 3 caracteres"),
56825
+ description: zod_default.string().max(500, "Descri\xE7\xE3o n\xE3o pode ter mais que 500 caracteres").optional().or(zod_default.literal("")),
56826
+ avatarUrl: avatarUrlSchema
56827
+ });
52722
56828
  var VALID_ADDON_TIERS = ["free", "plus"];
56829
+ var OFFLINE_AUTHORIZATION_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
56830
+ var CLOCK_LEEWAY_MS = 60 * 1e3;
56831
+ var offlineAuthorizationClaimsSchema = external_exports2.object({
56832
+ formatVersion: external_exports2.literal(1),
56833
+ keyId: external_exports2.string().min(1),
56834
+ licenseId: external_exports2.string().min(1),
56835
+ installationId: external_exports2.string().min(1),
56836
+ plan: external_exports2.literal("plus"),
56837
+ status: external_exports2.enum(["active", "revoked"]),
56838
+ issuedAt: external_exports2.number().int().positive().max(864e13).finite(),
56839
+ paidThrough: external_exports2.number().int().positive().max(864e13).finite(),
56840
+ offlineThrough: external_exports2.number().int().positive().max(864e13).finite()
56841
+ }).strict();
52723
56842
 
52724
56843
  // src/contracts/manifest/ISignedAddonCatalogManifest.ts
52725
56844
  var ADDON_CATALOG_RECEIPT_FILE = "catalog-version.json";
@@ -52804,7 +56923,7 @@ async function runInitWizard(targetDirName) {
52804
56923
  pack: "rastro pack ."
52805
56924
  },
52806
56925
  devDependencies: {
52807
- "@rastrokit/sdk": `^${"0.16.0"}`,
56926
+ "@rastrokit/sdk": `^${"0.17.0"}`,
52808
56927
  tsup: "^8.5.0",
52809
56928
  typescript: "^5.8.0"
52810
56929
  }
@@ -52840,7 +56959,7 @@ async function runInitWizard(targetDirName) {
52840
56959
  description: answers.description,
52841
56960
  tags: [...answers.capabilities, "rastro"],
52842
56961
  screenshots: [],
52843
- requiredApiVersion: `^${"0.16.0"}`,
56962
+ requiredApiVersion: `^${"0.17.0"}`,
52844
56963
  releaseDate: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
52845
56964
  changelog: ["Vers\xE3o inicial do plugin"]
52846
56965
  };
@@ -53099,7 +57218,7 @@ async function runManifestWizard(addonDir) {
53099
57218
  }
53100
57219
 
53101
57220
  // src/cli/pkg.ts
53102
- import crypto from "crypto";
57221
+ import crypto2 from "crypto";
53103
57222
  import fs7 from "fs";
53104
57223
  import path7 from "path";
53105
57224
 
@@ -53231,9 +57350,9 @@ function validateAddon(addonDir) {
53231
57350
  );
53232
57351
  }
53233
57352
  const rawCapabilities = extractCapabilities(manifest);
53234
- if (rawCapabilities.length === 0) {
57353
+ if (!Array.isArray(manifest.capabilities)) {
53235
57354
  errors.push(
53236
- `Campo "capabilities" \xE9 obrigat\xF3rio. Deve conter ao menos uma capacidade: ${VALID_ADDON_CAPABILITIES.join(", ")}`
57355
+ `Campo "capabilities" deve ser uma lista (pode ser vazia para addons gerais). Capacidades v\xE1lidas: ${VALID_ADDON_CAPABILITIES.join(", ")}`
53237
57356
  );
53238
57357
  }
53239
57358
  const seenCapabilities = /* @__PURE__ */ new Set();
@@ -53467,7 +57586,7 @@ function buildAddon(addonDir, options) {
53467
57586
  const files = collectAddonPackageFiles(filesToInclude, rootDir);
53468
57587
  const inventory = files.map((file2) => ({
53469
57588
  path: file2.path,
53470
- sha256: crypto.createHash("sha256").update(file2.contents).digest("hex")
57589
+ sha256: crypto2.createHash("sha256").update(file2.contents).digest("hex")
53471
57590
  }));
53472
57591
  if (signing) {
53473
57592
  if (tier === void 0)
@@ -53490,7 +57609,7 @@ function buildAddon(addonDir, options) {
53490
57609
  }
53491
57610
  packageAddon(files, outFile);
53492
57611
  const archiveBuffer = fs7.readFileSync(outFile);
53493
- const sha256 = crypto.createHash("sha256").update(archiveBuffer).digest("hex");
57612
+ const sha256 = crypto2.createHash("sha256").update(archiveBuffer).digest("hex");
53494
57613
  const size = archiveBuffer.byteLength;
53495
57614
  let catalogManifestFile;
53496
57615
  if (signing) {
@@ -53762,7 +57881,7 @@ function parseCliTier(rawTier) {
53762
57881
  if (normalized === "free") return "free";
53763
57882
  return void 0;
53764
57883
  }
53765
- program.name("rastro").description("CLI do Rastro SDK para criar, validar e empacotar plugins").version("0.16.0");
57884
+ program.name("rastro").description("CLI do Rastro SDK para criar, validar e empacotar plugins").version("0.17.0");
53766
57885
  program.command("init [name]").description(
53767
57886
  "Inicializa um novo projeto de plugin com TypeScript e boilerplates"
53768
57887
  ).action(async (name) => {
@@ -53798,7 +57917,7 @@ program.command("pack [addonDir]").alias("pkg").description("Empacota o plugin e
53798
57917
  downloadUrl = answer.downloadUrl;
53799
57918
  }
53800
57919
  buildAddon(addonDir, {
53801
- apiVersion: "0.16.0",
57920
+ apiVersion: "0.17.0",
53802
57921
  signing: readCatalogSigningEnvironment(process.env),
53803
57922
  downloadUrl,
53804
57923
  tier: cliTier,