@budibase/shared-core 3.2.16 → 3.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -719,7 +719,7 @@ var require_lodash = __commonJS({
719
719
  }
720
720
  return true;
721
721
  }
722
- function arrayFilter(array, predicate) {
722
+ function arrayFilter2(array, predicate) {
723
723
  var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
724
724
  while (++index < length) {
725
725
  var value = array[index];
@@ -1044,10 +1044,10 @@ var require_lodash = __commonJS({
1044
1044
  }();
1045
1045
  var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1046
1046
  var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
1047
- var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
1048
- var metaMap = WeakMap && new WeakMap();
1047
+ var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap2 = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
1048
+ var metaMap = WeakMap2 && new WeakMap2();
1049
1049
  var realNames = {};
1050
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap);
1050
+ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2);
1051
1051
  var symbolProto = Symbol2 ? Symbol2.prototype : undefined2, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined2, symbolToString = symbolProto ? symbolProto.toString : undefined2;
1052
1052
  function lodash(value) {
1053
1053
  if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
@@ -1652,7 +1652,7 @@ var require_lodash = __commonJS({
1652
1652
  return object && baseForRight(object, iteratee2, keys);
1653
1653
  }
1654
1654
  function baseFunctions(object, props) {
1655
- return arrayFilter(props, function(key) {
1655
+ return arrayFilter2(props, function(key) {
1656
1656
  return isFunction(object[key]);
1657
1657
  });
1658
1658
  }
@@ -3088,7 +3088,7 @@ var require_lodash = __commonJS({
3088
3088
  return [];
3089
3089
  }
3090
3090
  object = Object2(object);
3091
- return arrayFilter(nativeGetSymbols(object), function(symbol) {
3091
+ return arrayFilter2(nativeGetSymbols(object), function(symbol) {
3092
3092
  return propertyIsEnumerable.call(object, symbol);
3093
3093
  });
3094
3094
  };
@@ -3101,7 +3101,7 @@ var require_lodash = __commonJS({
3101
3101
  return result2;
3102
3102
  };
3103
3103
  var getTag = baseGetTag;
3104
- if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
3104
+ if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) {
3105
3105
  getTag = function(value) {
3106
3106
  var result2 = baseGetTag(value), Ctor = result2 == objectTag ? value.constructor : undefined2, ctorString = Ctor ? toSource(Ctor) : "";
3107
3107
  if (ctorString) {
@@ -3797,7 +3797,7 @@ var require_lodash = __commonJS({
3797
3797
  return [];
3798
3798
  }
3799
3799
  var length = 0;
3800
- array = arrayFilter(array, function(group) {
3800
+ array = arrayFilter2(array, function(group) {
3801
3801
  if (isArrayLikeObject(group)) {
3802
3802
  length = nativeMax(group.length, length);
3803
3803
  return true;
@@ -3823,19 +3823,19 @@ var require_lodash = __commonJS({
3823
3823
  return isArrayLikeObject(array) ? baseDifference(array, values3) : [];
3824
3824
  });
3825
3825
  var xor = baseRest(function(arrays) {
3826
- return baseXor(arrayFilter(arrays, isArrayLikeObject));
3826
+ return baseXor(arrayFilter2(arrays, isArrayLikeObject));
3827
3827
  });
3828
3828
  var xorBy = baseRest(function(arrays) {
3829
3829
  var iteratee2 = last(arrays);
3830
3830
  if (isArrayLikeObject(iteratee2)) {
3831
3831
  iteratee2 = undefined2;
3832
3832
  }
3833
- return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee2, 2));
3833
+ return baseXor(arrayFilter2(arrays, isArrayLikeObject), getIteratee(iteratee2, 2));
3834
3834
  });
3835
3835
  var xorWith = baseRest(function(arrays) {
3836
3836
  var comparator = last(arrays);
3837
3837
  comparator = typeof comparator == "function" ? comparator : undefined2;
3838
- return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined2, comparator);
3838
+ return baseXor(arrayFilter2(arrays, isArrayLikeObject), undefined2, comparator);
3839
3839
  });
3840
3840
  var zip = baseRest(unzip);
3841
3841
  function zipObject(props, values3) {
@@ -3949,7 +3949,7 @@ var require_lodash = __commonJS({
3949
3949
  return func(collection, getIteratee(predicate, 3));
3950
3950
  }
3951
3951
  function filter(collection, predicate) {
3952
- var func = isArray(collection) ? arrayFilter : baseFilter;
3952
+ var func = isArray(collection) ? arrayFilter2 : baseFilter;
3953
3953
  return func(collection, getIteratee(predicate, 3));
3954
3954
  }
3955
3955
  var find2 = createFind(findIndex);
@@ -4029,7 +4029,7 @@ var require_lodash = __commonJS({
4029
4029
  return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEachRight);
4030
4030
  }
4031
4031
  function reject(collection, predicate) {
4032
- var func = isArray(collection) ? arrayFilter : baseFilter;
4032
+ var func = isArray(collection) ? arrayFilter2 : baseFilter;
4033
4033
  return func(collection, negate(getIteratee(predicate, 3)));
4034
4034
  }
4035
4035
  function sample(collection) {
@@ -4424,7 +4424,7 @@ var require_lodash = __commonJS({
4424
4424
  var tag = baseGetTag(value);
4425
4425
  return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject2(value);
4426
4426
  }
4427
- function isFinite(value) {
4427
+ function isFinite2(value) {
4428
4428
  return typeof value == "number" && nativeIsFinite(value);
4429
4429
  }
4430
4430
  function isFunction(value) {
@@ -5525,7 +5525,7 @@ var require_lodash = __commonJS({
5525
5525
  lodash.isEqual = isEqual;
5526
5526
  lodash.isEqualWith = isEqualWith;
5527
5527
  lodash.isError = isError;
5528
- lodash.isFinite = isFinite;
5528
+ lodash.isFinite = isFinite2;
5529
5529
  lodash.isFunction = isFunction;
5530
5530
  lodash.isInteger = isInteger;
5531
5531
  lodash.isLength = isLength;
@@ -6439,15 +6439,15 @@ var require_luxon = __commonJS({
6439
6439
  var PolyDateFormatter = class {
6440
6440
  constructor(dt, intl, opts) {
6441
6441
  this.opts = opts;
6442
- let z = void 0;
6442
+ let z2 = void 0;
6443
6443
  if (dt.zone.isUniversal) {
6444
6444
  const gmtOffset = -1 * (dt.offset / 60);
6445
6445
  const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
6446
6446
  if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
6447
- z = offsetZ;
6447
+ z2 = offsetZ;
6448
6448
  this.dt = dt;
6449
6449
  } else {
6450
- z = "UTC";
6450
+ z2 = "UTC";
6451
6451
  if (opts.timeZoneName) {
6452
6452
  this.dt = dt;
6453
6453
  } else {
@@ -6458,12 +6458,12 @@ var require_luxon = __commonJS({
6458
6458
  this.dt = dt;
6459
6459
  } else {
6460
6460
  this.dt = dt;
6461
- z = dt.zone.name;
6461
+ z2 = dt.zone.name;
6462
6462
  }
6463
6463
  const intlOpts = {
6464
6464
  ...this.opts
6465
6465
  };
6466
- intlOpts.timeZone = intlOpts.timeZone || z;
6466
+ intlOpts.timeZone = intlOpts.timeZone || z2;
6467
6467
  this.dtf = getCachedDTF(intl, intlOpts);
6468
6468
  }
6469
6469
  format() {
@@ -9929,7 +9929,7 @@ var require_luxon = __commonJS({
9929
9929
  } else
9930
9930
  return false;
9931
9931
  }
9932
- var INVALID = "Invalid DateTime";
9932
+ var INVALID2 = "Invalid DateTime";
9933
9933
  var MAX_DATE = 864e13;
9934
9934
  function unsupportedZone(zone) {
9935
9935
  return new Invalid("unsupported zone", `the zone "${zone.name}" is not supported`);
@@ -11191,7 +11191,7 @@ var require_luxon = __commonJS({
11191
11191
  * @return {string}
11192
11192
  */
11193
11193
  toFormat(fmt, opts = {}) {
11194
- return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID;
11194
+ return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID2;
11195
11195
  }
11196
11196
  /**
11197
11197
  * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE`.
@@ -11213,7 +11213,7 @@ var require_luxon = __commonJS({
11213
11213
  * @return {string}
11214
11214
  */
11215
11215
  toLocaleString(formatOpts = DATE_SHORT, opts = {}) {
11216
- return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID;
11216
+ return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID2;
11217
11217
  }
11218
11218
  /**
11219
11219
  * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output.
@@ -11398,7 +11398,7 @@ var require_luxon = __commonJS({
11398
11398
  * @return {string}
11399
11399
  */
11400
11400
  toString() {
11401
- return this.isValid ? this.toISO() : INVALID;
11401
+ return this.isValid ? this.toISO() : INVALID2;
11402
11402
  }
11403
11403
  /**
11404
11404
  * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime#toMillis}
@@ -12264,7 +12264,7 @@ var require_expression = __commonJS({
12264
12264
  }
12265
12265
  function parseSequence(val) {
12266
12266
  var stack = [];
12267
- function handleResult(result) {
12267
+ function handleResult2(result) {
12268
12268
  if (result instanceof Array) {
12269
12269
  for (var i2 = 0, c2 = result.length; i2 < c2; i2++) {
12270
12270
  var value2 = result[i2];
@@ -12304,10 +12304,10 @@ var require_expression = __commonJS({
12304
12304
  }
12305
12305
  if (atoms.length > 1) {
12306
12306
  for (var i = 0, c = atoms.length; i < c; i++) {
12307
- handleResult(parseRepeat(atoms[i]));
12307
+ handleResult2(parseRepeat(atoms[i]));
12308
12308
  }
12309
12309
  } else {
12310
- handleResult(parseRepeat(val));
12310
+ handleResult2(parseRepeat(val));
12311
12311
  }
12312
12312
  stack.sort(CronExpression._sortCompareFn);
12313
12313
  return stack;
@@ -13011,7 +13011,7 @@ var require_lodash_min = __commonJS({
13011
13011
  function R(n2) {
13012
13012
  return n2 ? n2.slice(0, H(n2) + 1).replace(Lt, "") : n2;
13013
13013
  }
13014
- function z(n2) {
13014
+ function z2(n2) {
13015
13015
  return function(t2) {
13016
13016
  return n2(t2);
13017
13017
  };
@@ -13605,7 +13605,7 @@ var require_lodash_min = __commonJS({
13605
13605
  var u2 = -1, i2 = o, a2 = true, l2 = n2.length, s2 = [], h2 = t2.length;
13606
13606
  if (!l2)
13607
13607
  return s2;
13608
- r2 && (t2 = c(t2, z(r2))), e2 ? (i2 = f, a2 = false) : t2.length >= tn && (i2 = S, a2 = false, t2 = new yr2(t2));
13608
+ r2 && (t2 = c(t2, z2(r2))), e2 ? (i2 = f, a2 = false) : t2.length >= tn && (i2 = S, a2 = false, t2 = new yr2(t2));
13609
13609
  n:
13610
13610
  for (; ++u2 < l2; ) {
13611
13611
  var p3 = n2[u2], _4 = null == r2 ? p3 : r2(p3);
@@ -13692,7 +13692,7 @@ var require_lodash_min = __commonJS({
13692
13692
  function ke(n2, t2, r2) {
13693
13693
  for (var e2 = r2 ? f : o, u2 = n2[0].length, i2 = n2.length, a2 = i2, l2 = il(i2), s2 = 1 / 0, h2 = []; a2--; ) {
13694
13694
  var p3 = n2[a2];
13695
- a2 && t2 && (p3 = c(p3, z(t2))), s2 = Hl(p3.length, s2), l2[a2] = !r2 && (t2 || u2 >= 120 && p3.length >= 120) ? new yr2(a2 && p3) : X;
13695
+ a2 && t2 && (p3 = c(p3, z2(t2))), s2 = Hl(p3.length, s2), l2[a2] = !r2 && (t2 || u2 >= 120 && p3.length >= 120) ? new yr2(a2 && p3) : X;
13696
13696
  }
13697
13697
  p3 = n2[0];
13698
13698
  var _4 = -1, v2 = l2[0];
@@ -13865,7 +13865,7 @@ var require_lodash_min = __commonJS({
13865
13865
  } : n3;
13866
13866
  }) : [La];
13867
13867
  var e2 = -1;
13868
- return t2 = c(t2, z(mi())), A(Pe(n2, function(n3, r3, u2) {
13868
+ return t2 = c(t2, z2(mi())), A(Pe(n2, function(n3, r3, u2) {
13869
13869
  return { criteria: c(t2, function(t3) {
13870
13870
  return t3(n3);
13871
13871
  }), index: ++e2, value: n3 };
@@ -13892,7 +13892,7 @@ var require_lodash_min = __commonJS({
13892
13892
  }
13893
13893
  function Xe(n2, t2, r2, e2) {
13894
13894
  var u2 = e2 ? d : y, i2 = -1, o2 = t2.length, f2 = n2;
13895
- for (n2 === t2 && (t2 = Tu(t2)), r2 && (f2 = c(n2, z(r2))); ++i2 < o2; )
13895
+ for (n2 === t2 && (t2 = Tu(t2)), r2 && (f2 = c(n2, z2(r2))); ++i2 < o2; )
13896
13896
  for (var a2 = 0, l2 = t2[i2], s2 = r2 ? r2(l2) : l2; (a2 = u2(f2, s2, a2, e2)) > -1; )
13897
13897
  f2 !== n2 && Ll.call(f2, a2, 1), Ll.call(n2, a2, 1);
13898
13898
  return n2;
@@ -14331,7 +14331,7 @@ var require_lodash_min = __commonJS({
14331
14331
  }
14332
14332
  function ti(t2) {
14333
14333
  return gi(function(r2) {
14334
- return r2 = c(r2, z(mi())), uu(function(e2) {
14334
+ return r2 = c(r2, z2(mi())), uu(function(e2) {
14335
14335
  var u2 = this;
14336
14336
  return t2(r2, function(t3) {
14337
14337
  return n(t3, u2, e2);
@@ -16001,7 +16001,7 @@ var require_lodash_min = __commonJS({
16001
16001
  });
16002
16002
  Cf.Cache = sr2;
16003
16003
  var hh = js(function(t2, r2) {
16004
- r2 = 1 == r2.length && bh(r2[0]) ? c(r2[0], z(mi())) : c(ee2(r2, 1), z(mi()));
16004
+ r2 = 1 == r2.length && bh(r2[0]) ? c(r2[0], z2(mi())) : c(ee2(r2, 1), z2(mi()));
16005
16005
  var e2 = r2.length;
16006
16006
  return uu(function(u2) {
16007
16007
  for (var i2 = -1, o2 = Hl(u2.length, e2); ++i2 < o2; )
@@ -16020,7 +16020,7 @@ var require_lodash_min = __commonJS({
16020
16020
  return arguments;
16021
16021
  }()) ? Re : function(n2) {
16022
16022
  return cc(n2) && bl.call(n2, "callee") && !Wl.call(n2, "callee");
16023
- }, bh = il.isArray, wh = ce ? z(ce) : ze, mh = ql || qa, xh = ae ? z(ae) : Ee, jh = le ? z(le) : Le, Ah = se ? z(se) : Be, kh = he ? z(he) : Te, Oh = pe ? z(pe) : $e, Ih = ii(Ne), Rh = ii(function(n2, t2) {
16023
+ }, bh = il.isArray, wh = ce ? z2(ce) : ze, mh = ql || qa, xh = ae ? z2(ae) : Ee, jh = le ? z2(le) : Le, Ah = se ? z2(se) : Be, kh = he ? z2(he) : Te, Oh = pe ? z2(pe) : $e, Ih = ii(Ne), Rh = ii(function(n2, t2) {
16024
16024
  return n2 <= t2;
16025
16025
  }), zh = Nu(function(n2, t2) {
16026
16026
  if (Mi(t2) || Hf(t2))
@@ -16793,7 +16793,7 @@ var require_baseConvert = __commonJS({
16793
16793
  return result;
16794
16794
  };
16795
16795
  }
16796
- function baseConvert(util, name, func, options) {
16796
+ function baseConvert(util2, name, func, options) {
16797
16797
  var isLib = typeof name == "function", isObj = name === Object(name);
16798
16798
  if (isObj) {
16799
16799
  options = func;
@@ -16813,20 +16813,20 @@ var require_baseConvert = __commonJS({
16813
16813
  };
16814
16814
  var defaultHolder = isLib ? func : fallbackHolder, forceCurry = "curry" in options && options.curry, forceFixed = "fixed" in options && options.fixed, forceRearg = "rearg" in options && options.rearg, pristine = isLib ? func.runInContext() : void 0;
16815
16815
  var helpers = isLib ? func : {
16816
- "ary": util.ary,
16817
- "assign": util.assign,
16818
- "clone": util.clone,
16819
- "curry": util.curry,
16820
- "forEach": util.forEach,
16821
- "isArray": util.isArray,
16822
- "isError": util.isError,
16823
- "isFunction": util.isFunction,
16824
- "isWeakMap": util.isWeakMap,
16825
- "iteratee": util.iteratee,
16826
- "keys": util.keys,
16827
- "rearg": util.rearg,
16828
- "toInteger": util.toInteger,
16829
- "toPath": util.toPath
16816
+ "ary": util2.ary,
16817
+ "assign": util2.assign,
16818
+ "clone": util2.clone,
16819
+ "curry": util2.curry,
16820
+ "forEach": util2.forEach,
16821
+ "isArray": util2.isArray,
16822
+ "isError": util2.isError,
16823
+ "isFunction": util2.isFunction,
16824
+ "isWeakMap": util2.isWeakMap,
16825
+ "iteratee": util2.iteratee,
16826
+ "keys": util2.keys,
16827
+ "rearg": util2.rearg,
16828
+ "toInteger": util2.toInteger,
16829
+ "toPath": util2.toPath
16830
16830
  };
16831
16831
  var ary = helpers.ary, assign = helpers.assign, clone = helpers.clone, curry = helpers.curry, each = helpers.forEach, isArray = helpers.isArray, isError = helpers.isError, isFunction = helpers.isFunction, isWeakMap = helpers.isWeakMap, keys = helpers.keys, rearg = helpers.rearg, toInteger = helpers.toInteger, toPath = helpers.toPath;
16832
16832
  var aryMethodKeys = keys(mapping.aryMethod);
@@ -16885,7 +16885,7 @@ var require_baseConvert = __commonJS({
16885
16885
  },
16886
16886
  "runInContext": function(runInContext) {
16887
16887
  return function(context) {
16888
- return baseConvert(util, runInContext(context), options);
16888
+ return baseConvert(util2, runInContext(context), options);
16889
16889
  };
16890
16890
  }
16891
16891
  };
@@ -17088,6 +17088,7 @@ __export(src_exports, {
17088
17088
  findDuplicateInternalColumns: () => findDuplicateInternalColumns,
17089
17089
  getThemeClassNames: () => getThemeClassNames,
17090
17090
  helpers: () => helpers_exports,
17091
+ isExternalColumnName: () => isExternalColumnName,
17091
17092
  isInternalColumnName: () => isInternalColumnName,
17092
17093
  sdk: () => sdk_exports,
17093
17094
  utils: () => utils_exports
@@ -17150,6 +17151,11 @@ function isArraySearchOperator(value) {
17150
17151
  function isRangeSearchOperator(value) {
17151
17152
  return Object.values(RangeOperator).includes(value);
17152
17153
  }
17154
+ var EmptyFilterOption = /* @__PURE__ */ ((EmptyFilterOption2) => {
17155
+ EmptyFilterOption2["RETURN_ALL"] = "all";
17156
+ EmptyFilterOption2["RETURN_NONE"] = "none";
17157
+ return EmptyFilterOption2;
17158
+ })(EmptyFilterOption || {});
17153
17159
 
17154
17160
  // ../types/src/sdk/cli/constants.ts
17155
17161
  var AnalyticsEvent = {
@@ -17276,6 +17282,3990 @@ var BREAKDOWN_QUOTA_NAMES = [
17276
17282
  "automations" /* AUTOMATIONS */
17277
17283
  ];
17278
17284
 
17285
+ // ../types/src/api/web/pagination.ts
17286
+ var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
17287
+ SortOrder2["ASCENDING"] = "ascending";
17288
+ SortOrder2["DESCENDING"] = "descending";
17289
+ return SortOrder2;
17290
+ })(SortOrder || {});
17291
+ var SortType = /* @__PURE__ */ ((SortType2) => {
17292
+ SortType2["STRING"] = "string";
17293
+ SortType2["NUMBER"] = "number";
17294
+ return SortType2;
17295
+ })(SortType || {});
17296
+
17297
+ // ../../node_modules/zod/lib/index.mjs
17298
+ var util;
17299
+ (function(util2) {
17300
+ util2.assertEqual = (val) => val;
17301
+ function assertIs(_arg) {
17302
+ }
17303
+ util2.assertIs = assertIs;
17304
+ function assertNever(_x) {
17305
+ throw new Error();
17306
+ }
17307
+ util2.assertNever = assertNever;
17308
+ util2.arrayToEnum = (items) => {
17309
+ const obj = {};
17310
+ for (const item of items) {
17311
+ obj[item] = item;
17312
+ }
17313
+ return obj;
17314
+ };
17315
+ util2.getValidEnumValues = (obj) => {
17316
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
17317
+ const filtered = {};
17318
+ for (const k of validKeys) {
17319
+ filtered[k] = obj[k];
17320
+ }
17321
+ return util2.objectValues(filtered);
17322
+ };
17323
+ util2.objectValues = (obj) => {
17324
+ return util2.objectKeys(obj).map(function(e) {
17325
+ return obj[e];
17326
+ });
17327
+ };
17328
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
17329
+ const keys = [];
17330
+ for (const key in object) {
17331
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
17332
+ keys.push(key);
17333
+ }
17334
+ }
17335
+ return keys;
17336
+ };
17337
+ util2.find = (arr, checker) => {
17338
+ for (const item of arr) {
17339
+ if (checker(item))
17340
+ return item;
17341
+ }
17342
+ return void 0;
17343
+ };
17344
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
17345
+ function joinValues(array, separator = " | ") {
17346
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
17347
+ }
17348
+ util2.joinValues = joinValues;
17349
+ util2.jsonStringifyReplacer = (_3, value) => {
17350
+ if (typeof value === "bigint") {
17351
+ return value.toString();
17352
+ }
17353
+ return value;
17354
+ };
17355
+ })(util || (util = {}));
17356
+ var objectUtil;
17357
+ (function(objectUtil2) {
17358
+ objectUtil2.mergeShapes = (first, second) => {
17359
+ return {
17360
+ ...first,
17361
+ ...second
17362
+ // second overwrites first
17363
+ };
17364
+ };
17365
+ })(objectUtil || (objectUtil = {}));
17366
+ var ZodParsedType = util.arrayToEnum([
17367
+ "string",
17368
+ "nan",
17369
+ "number",
17370
+ "integer",
17371
+ "float",
17372
+ "boolean",
17373
+ "date",
17374
+ "bigint",
17375
+ "symbol",
17376
+ "function",
17377
+ "undefined",
17378
+ "null",
17379
+ "array",
17380
+ "object",
17381
+ "unknown",
17382
+ "promise",
17383
+ "void",
17384
+ "never",
17385
+ "map",
17386
+ "set"
17387
+ ]);
17388
+ var getParsedType = (data) => {
17389
+ const t = typeof data;
17390
+ switch (t) {
17391
+ case "undefined":
17392
+ return ZodParsedType.undefined;
17393
+ case "string":
17394
+ return ZodParsedType.string;
17395
+ case "number":
17396
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
17397
+ case "boolean":
17398
+ return ZodParsedType.boolean;
17399
+ case "function":
17400
+ return ZodParsedType.function;
17401
+ case "bigint":
17402
+ return ZodParsedType.bigint;
17403
+ case "symbol":
17404
+ return ZodParsedType.symbol;
17405
+ case "object":
17406
+ if (Array.isArray(data)) {
17407
+ return ZodParsedType.array;
17408
+ }
17409
+ if (data === null) {
17410
+ return ZodParsedType.null;
17411
+ }
17412
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
17413
+ return ZodParsedType.promise;
17414
+ }
17415
+ if (typeof Map !== "undefined" && data instanceof Map) {
17416
+ return ZodParsedType.map;
17417
+ }
17418
+ if (typeof Set !== "undefined" && data instanceof Set) {
17419
+ return ZodParsedType.set;
17420
+ }
17421
+ if (typeof Date !== "undefined" && data instanceof Date) {
17422
+ return ZodParsedType.date;
17423
+ }
17424
+ return ZodParsedType.object;
17425
+ default:
17426
+ return ZodParsedType.unknown;
17427
+ }
17428
+ };
17429
+ var ZodIssueCode = util.arrayToEnum([
17430
+ "invalid_type",
17431
+ "invalid_literal",
17432
+ "custom",
17433
+ "invalid_union",
17434
+ "invalid_union_discriminator",
17435
+ "invalid_enum_value",
17436
+ "unrecognized_keys",
17437
+ "invalid_arguments",
17438
+ "invalid_return_type",
17439
+ "invalid_date",
17440
+ "invalid_string",
17441
+ "too_small",
17442
+ "too_big",
17443
+ "invalid_intersection_types",
17444
+ "not_multiple_of",
17445
+ "not_finite"
17446
+ ]);
17447
+ var quotelessJson = (obj) => {
17448
+ const json = JSON.stringify(obj, null, 2);
17449
+ return json.replace(/"([^"]+)":/g, "$1:");
17450
+ };
17451
+ var ZodError = class _ZodError extends Error {
17452
+ constructor(issues) {
17453
+ super();
17454
+ this.issues = [];
17455
+ this.addIssue = (sub) => {
17456
+ this.issues = [...this.issues, sub];
17457
+ };
17458
+ this.addIssues = (subs = []) => {
17459
+ this.issues = [...this.issues, ...subs];
17460
+ };
17461
+ const actualProto = new.target.prototype;
17462
+ if (Object.setPrototypeOf) {
17463
+ Object.setPrototypeOf(this, actualProto);
17464
+ } else {
17465
+ this.__proto__ = actualProto;
17466
+ }
17467
+ this.name = "ZodError";
17468
+ this.issues = issues;
17469
+ }
17470
+ get errors() {
17471
+ return this.issues;
17472
+ }
17473
+ format(_mapper) {
17474
+ const mapper = _mapper || function(issue) {
17475
+ return issue.message;
17476
+ };
17477
+ const fieldErrors = { _errors: [] };
17478
+ const processError = (error) => {
17479
+ for (const issue of error.issues) {
17480
+ if (issue.code === "invalid_union") {
17481
+ issue.unionErrors.map(processError);
17482
+ } else if (issue.code === "invalid_return_type") {
17483
+ processError(issue.returnTypeError);
17484
+ } else if (issue.code === "invalid_arguments") {
17485
+ processError(issue.argumentsError);
17486
+ } else if (issue.path.length === 0) {
17487
+ fieldErrors._errors.push(mapper(issue));
17488
+ } else {
17489
+ let curr = fieldErrors;
17490
+ let i = 0;
17491
+ while (i < issue.path.length) {
17492
+ const el = issue.path[i];
17493
+ const terminal = i === issue.path.length - 1;
17494
+ if (!terminal) {
17495
+ curr[el] = curr[el] || { _errors: [] };
17496
+ } else {
17497
+ curr[el] = curr[el] || { _errors: [] };
17498
+ curr[el]._errors.push(mapper(issue));
17499
+ }
17500
+ curr = curr[el];
17501
+ i++;
17502
+ }
17503
+ }
17504
+ }
17505
+ };
17506
+ processError(this);
17507
+ return fieldErrors;
17508
+ }
17509
+ static assert(value) {
17510
+ if (!(value instanceof _ZodError)) {
17511
+ throw new Error(`Not a ZodError: ${value}`);
17512
+ }
17513
+ }
17514
+ toString() {
17515
+ return this.message;
17516
+ }
17517
+ get message() {
17518
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
17519
+ }
17520
+ get isEmpty() {
17521
+ return this.issues.length === 0;
17522
+ }
17523
+ flatten(mapper = (issue) => issue.message) {
17524
+ const fieldErrors = {};
17525
+ const formErrors = [];
17526
+ for (const sub of this.issues) {
17527
+ if (sub.path.length > 0) {
17528
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
17529
+ fieldErrors[sub.path[0]].push(mapper(sub));
17530
+ } else {
17531
+ formErrors.push(mapper(sub));
17532
+ }
17533
+ }
17534
+ return { formErrors, fieldErrors };
17535
+ }
17536
+ get formErrors() {
17537
+ return this.flatten();
17538
+ }
17539
+ };
17540
+ ZodError.create = (issues) => {
17541
+ const error = new ZodError(issues);
17542
+ return error;
17543
+ };
17544
+ var errorMap = (issue, _ctx) => {
17545
+ let message;
17546
+ switch (issue.code) {
17547
+ case ZodIssueCode.invalid_type:
17548
+ if (issue.received === ZodParsedType.undefined) {
17549
+ message = "Required";
17550
+ } else {
17551
+ message = `Expected ${issue.expected}, received ${issue.received}`;
17552
+ }
17553
+ break;
17554
+ case ZodIssueCode.invalid_literal:
17555
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
17556
+ break;
17557
+ case ZodIssueCode.unrecognized_keys:
17558
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
17559
+ break;
17560
+ case ZodIssueCode.invalid_union:
17561
+ message = `Invalid input`;
17562
+ break;
17563
+ case ZodIssueCode.invalid_union_discriminator:
17564
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
17565
+ break;
17566
+ case ZodIssueCode.invalid_enum_value:
17567
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
17568
+ break;
17569
+ case ZodIssueCode.invalid_arguments:
17570
+ message = `Invalid function arguments`;
17571
+ break;
17572
+ case ZodIssueCode.invalid_return_type:
17573
+ message = `Invalid function return type`;
17574
+ break;
17575
+ case ZodIssueCode.invalid_date:
17576
+ message = `Invalid date`;
17577
+ break;
17578
+ case ZodIssueCode.invalid_string:
17579
+ if (typeof issue.validation === "object") {
17580
+ if ("includes" in issue.validation) {
17581
+ message = `Invalid input: must include "${issue.validation.includes}"`;
17582
+ if (typeof issue.validation.position === "number") {
17583
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
17584
+ }
17585
+ } else if ("startsWith" in issue.validation) {
17586
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
17587
+ } else if ("endsWith" in issue.validation) {
17588
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
17589
+ } else {
17590
+ util.assertNever(issue.validation);
17591
+ }
17592
+ } else if (issue.validation !== "regex") {
17593
+ message = `Invalid ${issue.validation}`;
17594
+ } else {
17595
+ message = "Invalid";
17596
+ }
17597
+ break;
17598
+ case ZodIssueCode.too_small:
17599
+ if (issue.type === "array")
17600
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
17601
+ else if (issue.type === "string")
17602
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
17603
+ else if (issue.type === "number")
17604
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
17605
+ else if (issue.type === "date")
17606
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
17607
+ else
17608
+ message = "Invalid input";
17609
+ break;
17610
+ case ZodIssueCode.too_big:
17611
+ if (issue.type === "array")
17612
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
17613
+ else if (issue.type === "string")
17614
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
17615
+ else if (issue.type === "number")
17616
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
17617
+ else if (issue.type === "bigint")
17618
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
17619
+ else if (issue.type === "date")
17620
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
17621
+ else
17622
+ message = "Invalid input";
17623
+ break;
17624
+ case ZodIssueCode.custom:
17625
+ message = `Invalid input`;
17626
+ break;
17627
+ case ZodIssueCode.invalid_intersection_types:
17628
+ message = `Intersection results could not be merged`;
17629
+ break;
17630
+ case ZodIssueCode.not_multiple_of:
17631
+ message = `Number must be a multiple of ${issue.multipleOf}`;
17632
+ break;
17633
+ case ZodIssueCode.not_finite:
17634
+ message = "Number must be finite";
17635
+ break;
17636
+ default:
17637
+ message = _ctx.defaultError;
17638
+ util.assertNever(issue);
17639
+ }
17640
+ return { message };
17641
+ };
17642
+ var overrideErrorMap = errorMap;
17643
+ function setErrorMap(map) {
17644
+ overrideErrorMap = map;
17645
+ }
17646
+ function getErrorMap() {
17647
+ return overrideErrorMap;
17648
+ }
17649
+ var makeIssue = (params) => {
17650
+ const { data, path, errorMaps, issueData } = params;
17651
+ const fullPath = [...path, ...issueData.path || []];
17652
+ const fullIssue = {
17653
+ ...issueData,
17654
+ path: fullPath
17655
+ };
17656
+ if (issueData.message !== void 0) {
17657
+ return {
17658
+ ...issueData,
17659
+ path: fullPath,
17660
+ message: issueData.message
17661
+ };
17662
+ }
17663
+ let errorMessage = "";
17664
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
17665
+ for (const map of maps) {
17666
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
17667
+ }
17668
+ return {
17669
+ ...issueData,
17670
+ path: fullPath,
17671
+ message: errorMessage
17672
+ };
17673
+ };
17674
+ var EMPTY_PATH = [];
17675
+ function addIssueToContext(ctx, issueData) {
17676
+ const overrideMap = getErrorMap();
17677
+ const issue = makeIssue({
17678
+ issueData,
17679
+ data: ctx.data,
17680
+ path: ctx.path,
17681
+ errorMaps: [
17682
+ ctx.common.contextualErrorMap,
17683
+ ctx.schemaErrorMap,
17684
+ overrideMap,
17685
+ overrideMap === errorMap ? void 0 : errorMap
17686
+ // then global default map
17687
+ ].filter((x) => !!x)
17688
+ });
17689
+ ctx.common.issues.push(issue);
17690
+ }
17691
+ var ParseStatus = class _ParseStatus {
17692
+ constructor() {
17693
+ this.value = "valid";
17694
+ }
17695
+ dirty() {
17696
+ if (this.value === "valid")
17697
+ this.value = "dirty";
17698
+ }
17699
+ abort() {
17700
+ if (this.value !== "aborted")
17701
+ this.value = "aborted";
17702
+ }
17703
+ static mergeArray(status, results) {
17704
+ const arrayValue = [];
17705
+ for (const s of results) {
17706
+ if (s.status === "aborted")
17707
+ return INVALID;
17708
+ if (s.status === "dirty")
17709
+ status.dirty();
17710
+ arrayValue.push(s.value);
17711
+ }
17712
+ return { status: status.value, value: arrayValue };
17713
+ }
17714
+ static async mergeObjectAsync(status, pairs) {
17715
+ const syncPairs = [];
17716
+ for (const pair of pairs) {
17717
+ const key = await pair.key;
17718
+ const value = await pair.value;
17719
+ syncPairs.push({
17720
+ key,
17721
+ value
17722
+ });
17723
+ }
17724
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
17725
+ }
17726
+ static mergeObjectSync(status, pairs) {
17727
+ const finalObject = {};
17728
+ for (const pair of pairs) {
17729
+ const { key, value } = pair;
17730
+ if (key.status === "aborted")
17731
+ return INVALID;
17732
+ if (value.status === "aborted")
17733
+ return INVALID;
17734
+ if (key.status === "dirty")
17735
+ status.dirty();
17736
+ if (value.status === "dirty")
17737
+ status.dirty();
17738
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
17739
+ finalObject[key.value] = value.value;
17740
+ }
17741
+ }
17742
+ return { status: status.value, value: finalObject };
17743
+ }
17744
+ };
17745
+ var INVALID = Object.freeze({
17746
+ status: "aborted"
17747
+ });
17748
+ var DIRTY = (value) => ({ status: "dirty", value });
17749
+ var OK = (value) => ({ status: "valid", value });
17750
+ var isAborted = (x) => x.status === "aborted";
17751
+ var isDirty = (x) => x.status === "dirty";
17752
+ var isValid = (x) => x.status === "valid";
17753
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
17754
+ function __classPrivateFieldGet(receiver, state, kind, f) {
17755
+ if (kind === "a" && !f)
17756
+ throw new TypeError("Private accessor was defined without a getter");
17757
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
17758
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
17759
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
17760
+ }
17761
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
17762
+ if (kind === "m")
17763
+ throw new TypeError("Private method is not writable");
17764
+ if (kind === "a" && !f)
17765
+ throw new TypeError("Private accessor was defined without a setter");
17766
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
17767
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
17768
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
17769
+ }
17770
+ var errorUtil;
17771
+ (function(errorUtil2) {
17772
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
17773
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
17774
+ })(errorUtil || (errorUtil = {}));
17775
+ var _ZodEnum_cache;
17776
+ var _ZodNativeEnum_cache;
17777
+ var ParseInputLazyPath = class {
17778
+ constructor(parent, value, path, key) {
17779
+ this._cachedPath = [];
17780
+ this.parent = parent;
17781
+ this.data = value;
17782
+ this._path = path;
17783
+ this._key = key;
17784
+ }
17785
+ get path() {
17786
+ if (!this._cachedPath.length) {
17787
+ if (this._key instanceof Array) {
17788
+ this._cachedPath.push(...this._path, ...this._key);
17789
+ } else {
17790
+ this._cachedPath.push(...this._path, this._key);
17791
+ }
17792
+ }
17793
+ return this._cachedPath;
17794
+ }
17795
+ };
17796
+ var handleResult = (ctx, result) => {
17797
+ if (isValid(result)) {
17798
+ return { success: true, data: result.value };
17799
+ } else {
17800
+ if (!ctx.common.issues.length) {
17801
+ throw new Error("Validation failed but no issues detected.");
17802
+ }
17803
+ return {
17804
+ success: false,
17805
+ get error() {
17806
+ if (this._error)
17807
+ return this._error;
17808
+ const error = new ZodError(ctx.common.issues);
17809
+ this._error = error;
17810
+ return this._error;
17811
+ }
17812
+ };
17813
+ }
17814
+ };
17815
+ function processCreateParams(params) {
17816
+ if (!params)
17817
+ return {};
17818
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
17819
+ if (errorMap2 && (invalid_type_error || required_error)) {
17820
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
17821
+ }
17822
+ if (errorMap2)
17823
+ return { errorMap: errorMap2, description };
17824
+ const customMap = (iss, ctx) => {
17825
+ var _a, _b;
17826
+ const { message } = params;
17827
+ if (iss.code === "invalid_enum_value") {
17828
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
17829
+ }
17830
+ if (typeof ctx.data === "undefined") {
17831
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
17832
+ }
17833
+ if (iss.code !== "invalid_type")
17834
+ return { message: ctx.defaultError };
17835
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
17836
+ };
17837
+ return { errorMap: customMap, description };
17838
+ }
17839
+ var ZodType = class {
17840
+ constructor(def) {
17841
+ this.spa = this.safeParseAsync;
17842
+ this._def = def;
17843
+ this.parse = this.parse.bind(this);
17844
+ this.safeParse = this.safeParse.bind(this);
17845
+ this.parseAsync = this.parseAsync.bind(this);
17846
+ this.safeParseAsync = this.safeParseAsync.bind(this);
17847
+ this.spa = this.spa.bind(this);
17848
+ this.refine = this.refine.bind(this);
17849
+ this.refinement = this.refinement.bind(this);
17850
+ this.superRefine = this.superRefine.bind(this);
17851
+ this.optional = this.optional.bind(this);
17852
+ this.nullable = this.nullable.bind(this);
17853
+ this.nullish = this.nullish.bind(this);
17854
+ this.array = this.array.bind(this);
17855
+ this.promise = this.promise.bind(this);
17856
+ this.or = this.or.bind(this);
17857
+ this.and = this.and.bind(this);
17858
+ this.transform = this.transform.bind(this);
17859
+ this.brand = this.brand.bind(this);
17860
+ this.default = this.default.bind(this);
17861
+ this.catch = this.catch.bind(this);
17862
+ this.describe = this.describe.bind(this);
17863
+ this.pipe = this.pipe.bind(this);
17864
+ this.readonly = this.readonly.bind(this);
17865
+ this.isNullable = this.isNullable.bind(this);
17866
+ this.isOptional = this.isOptional.bind(this);
17867
+ }
17868
+ get description() {
17869
+ return this._def.description;
17870
+ }
17871
+ _getType(input) {
17872
+ return getParsedType(input.data);
17873
+ }
17874
+ _getOrReturnCtx(input, ctx) {
17875
+ return ctx || {
17876
+ common: input.parent.common,
17877
+ data: input.data,
17878
+ parsedType: getParsedType(input.data),
17879
+ schemaErrorMap: this._def.errorMap,
17880
+ path: input.path,
17881
+ parent: input.parent
17882
+ };
17883
+ }
17884
+ _processInputParams(input) {
17885
+ return {
17886
+ status: new ParseStatus(),
17887
+ ctx: {
17888
+ common: input.parent.common,
17889
+ data: input.data,
17890
+ parsedType: getParsedType(input.data),
17891
+ schemaErrorMap: this._def.errorMap,
17892
+ path: input.path,
17893
+ parent: input.parent
17894
+ }
17895
+ };
17896
+ }
17897
+ _parseSync(input) {
17898
+ const result = this._parse(input);
17899
+ if (isAsync(result)) {
17900
+ throw new Error("Synchronous parse encountered promise.");
17901
+ }
17902
+ return result;
17903
+ }
17904
+ _parseAsync(input) {
17905
+ const result = this._parse(input);
17906
+ return Promise.resolve(result);
17907
+ }
17908
+ parse(data, params) {
17909
+ const result = this.safeParse(data, params);
17910
+ if (result.success)
17911
+ return result.data;
17912
+ throw result.error;
17913
+ }
17914
+ safeParse(data, params) {
17915
+ var _a;
17916
+ const ctx = {
17917
+ common: {
17918
+ issues: [],
17919
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
17920
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
17921
+ },
17922
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
17923
+ schemaErrorMap: this._def.errorMap,
17924
+ parent: null,
17925
+ data,
17926
+ parsedType: getParsedType(data)
17927
+ };
17928
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
17929
+ return handleResult(ctx, result);
17930
+ }
17931
+ async parseAsync(data, params) {
17932
+ const result = await this.safeParseAsync(data, params);
17933
+ if (result.success)
17934
+ return result.data;
17935
+ throw result.error;
17936
+ }
17937
+ async safeParseAsync(data, params) {
17938
+ const ctx = {
17939
+ common: {
17940
+ issues: [],
17941
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
17942
+ async: true
17943
+ },
17944
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
17945
+ schemaErrorMap: this._def.errorMap,
17946
+ parent: null,
17947
+ data,
17948
+ parsedType: getParsedType(data)
17949
+ };
17950
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
17951
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
17952
+ return handleResult(ctx, result);
17953
+ }
17954
+ refine(check, message) {
17955
+ const getIssueProperties = (val) => {
17956
+ if (typeof message === "string" || typeof message === "undefined") {
17957
+ return { message };
17958
+ } else if (typeof message === "function") {
17959
+ return message(val);
17960
+ } else {
17961
+ return message;
17962
+ }
17963
+ };
17964
+ return this._refinement((val, ctx) => {
17965
+ const result = check(val);
17966
+ const setError = () => ctx.addIssue({
17967
+ code: ZodIssueCode.custom,
17968
+ ...getIssueProperties(val)
17969
+ });
17970
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
17971
+ return result.then((data) => {
17972
+ if (!data) {
17973
+ setError();
17974
+ return false;
17975
+ } else {
17976
+ return true;
17977
+ }
17978
+ });
17979
+ }
17980
+ if (!result) {
17981
+ setError();
17982
+ return false;
17983
+ } else {
17984
+ return true;
17985
+ }
17986
+ });
17987
+ }
17988
+ refinement(check, refinementData) {
17989
+ return this._refinement((val, ctx) => {
17990
+ if (!check(val)) {
17991
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
17992
+ return false;
17993
+ } else {
17994
+ return true;
17995
+ }
17996
+ });
17997
+ }
17998
+ _refinement(refinement) {
17999
+ return new ZodEffects({
18000
+ schema: this,
18001
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
18002
+ effect: { type: "refinement", refinement }
18003
+ });
18004
+ }
18005
+ superRefine(refinement) {
18006
+ return this._refinement(refinement);
18007
+ }
18008
+ optional() {
18009
+ return ZodOptional.create(this, this._def);
18010
+ }
18011
+ nullable() {
18012
+ return ZodNullable.create(this, this._def);
18013
+ }
18014
+ nullish() {
18015
+ return this.nullable().optional();
18016
+ }
18017
+ array() {
18018
+ return ZodArray.create(this, this._def);
18019
+ }
18020
+ promise() {
18021
+ return ZodPromise.create(this, this._def);
18022
+ }
18023
+ or(option) {
18024
+ return ZodUnion.create([this, option], this._def);
18025
+ }
18026
+ and(incoming) {
18027
+ return ZodIntersection.create(this, incoming, this._def);
18028
+ }
18029
+ transform(transform) {
18030
+ return new ZodEffects({
18031
+ ...processCreateParams(this._def),
18032
+ schema: this,
18033
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
18034
+ effect: { type: "transform", transform }
18035
+ });
18036
+ }
18037
+ default(def) {
18038
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
18039
+ return new ZodDefault({
18040
+ ...processCreateParams(this._def),
18041
+ innerType: this,
18042
+ defaultValue: defaultValueFunc,
18043
+ typeName: ZodFirstPartyTypeKind.ZodDefault
18044
+ });
18045
+ }
18046
+ brand() {
18047
+ return new ZodBranded({
18048
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
18049
+ type: this,
18050
+ ...processCreateParams(this._def)
18051
+ });
18052
+ }
18053
+ catch(def) {
18054
+ const catchValueFunc = typeof def === "function" ? def : () => def;
18055
+ return new ZodCatch({
18056
+ ...processCreateParams(this._def),
18057
+ innerType: this,
18058
+ catchValue: catchValueFunc,
18059
+ typeName: ZodFirstPartyTypeKind.ZodCatch
18060
+ });
18061
+ }
18062
+ describe(description) {
18063
+ const This = this.constructor;
18064
+ return new This({
18065
+ ...this._def,
18066
+ description
18067
+ });
18068
+ }
18069
+ pipe(target) {
18070
+ return ZodPipeline.create(this, target);
18071
+ }
18072
+ readonly() {
18073
+ return ZodReadonly.create(this);
18074
+ }
18075
+ isOptional() {
18076
+ return this.safeParse(void 0).success;
18077
+ }
18078
+ isNullable() {
18079
+ return this.safeParse(null).success;
18080
+ }
18081
+ };
18082
+ var cuidRegex = /^c[^\s-]{8,}$/i;
18083
+ var cuid2Regex = /^[0-9a-z]+$/;
18084
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
18085
+ 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;
18086
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
18087
+ 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)?)??$/;
18088
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
18089
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
18090
+ var emojiRegex;
18091
+ 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])$/;
18092
+ var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
18093
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
18094
+ 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])))`;
18095
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
18096
+ function timeRegexSource(args) {
18097
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
18098
+ if (args.precision) {
18099
+ regex = `${regex}\\.\\d{${args.precision}}`;
18100
+ } else if (args.precision == null) {
18101
+ regex = `${regex}(\\.\\d+)?`;
18102
+ }
18103
+ return regex;
18104
+ }
18105
+ function timeRegex(args) {
18106
+ return new RegExp(`^${timeRegexSource(args)}$`);
18107
+ }
18108
+ function datetimeRegex(args) {
18109
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
18110
+ const opts = [];
18111
+ opts.push(args.local ? `Z?` : `Z`);
18112
+ if (args.offset)
18113
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
18114
+ regex = `${regex}(${opts.join("|")})`;
18115
+ return new RegExp(`^${regex}$`);
18116
+ }
18117
+ function isValidIP(ip, version) {
18118
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
18119
+ return true;
18120
+ }
18121
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
18122
+ return true;
18123
+ }
18124
+ return false;
18125
+ }
18126
+ var ZodString = class _ZodString extends ZodType {
18127
+ _parse(input) {
18128
+ if (this._def.coerce) {
18129
+ input.data = String(input.data);
18130
+ }
18131
+ const parsedType = this._getType(input);
18132
+ if (parsedType !== ZodParsedType.string) {
18133
+ const ctx2 = this._getOrReturnCtx(input);
18134
+ addIssueToContext(ctx2, {
18135
+ code: ZodIssueCode.invalid_type,
18136
+ expected: ZodParsedType.string,
18137
+ received: ctx2.parsedType
18138
+ });
18139
+ return INVALID;
18140
+ }
18141
+ const status = new ParseStatus();
18142
+ let ctx = void 0;
18143
+ for (const check of this._def.checks) {
18144
+ if (check.kind === "min") {
18145
+ if (input.data.length < check.value) {
18146
+ ctx = this._getOrReturnCtx(input, ctx);
18147
+ addIssueToContext(ctx, {
18148
+ code: ZodIssueCode.too_small,
18149
+ minimum: check.value,
18150
+ type: "string",
18151
+ inclusive: true,
18152
+ exact: false,
18153
+ message: check.message
18154
+ });
18155
+ status.dirty();
18156
+ }
18157
+ } else if (check.kind === "max") {
18158
+ if (input.data.length > check.value) {
18159
+ ctx = this._getOrReturnCtx(input, ctx);
18160
+ addIssueToContext(ctx, {
18161
+ code: ZodIssueCode.too_big,
18162
+ maximum: check.value,
18163
+ type: "string",
18164
+ inclusive: true,
18165
+ exact: false,
18166
+ message: check.message
18167
+ });
18168
+ status.dirty();
18169
+ }
18170
+ } else if (check.kind === "length") {
18171
+ const tooBig = input.data.length > check.value;
18172
+ const tooSmall = input.data.length < check.value;
18173
+ if (tooBig || tooSmall) {
18174
+ ctx = this._getOrReturnCtx(input, ctx);
18175
+ if (tooBig) {
18176
+ addIssueToContext(ctx, {
18177
+ code: ZodIssueCode.too_big,
18178
+ maximum: check.value,
18179
+ type: "string",
18180
+ inclusive: true,
18181
+ exact: true,
18182
+ message: check.message
18183
+ });
18184
+ } else if (tooSmall) {
18185
+ addIssueToContext(ctx, {
18186
+ code: ZodIssueCode.too_small,
18187
+ minimum: check.value,
18188
+ type: "string",
18189
+ inclusive: true,
18190
+ exact: true,
18191
+ message: check.message
18192
+ });
18193
+ }
18194
+ status.dirty();
18195
+ }
18196
+ } else if (check.kind === "email") {
18197
+ if (!emailRegex.test(input.data)) {
18198
+ ctx = this._getOrReturnCtx(input, ctx);
18199
+ addIssueToContext(ctx, {
18200
+ validation: "email",
18201
+ code: ZodIssueCode.invalid_string,
18202
+ message: check.message
18203
+ });
18204
+ status.dirty();
18205
+ }
18206
+ } else if (check.kind === "emoji") {
18207
+ if (!emojiRegex) {
18208
+ emojiRegex = new RegExp(_emojiRegex, "u");
18209
+ }
18210
+ if (!emojiRegex.test(input.data)) {
18211
+ ctx = this._getOrReturnCtx(input, ctx);
18212
+ addIssueToContext(ctx, {
18213
+ validation: "emoji",
18214
+ code: ZodIssueCode.invalid_string,
18215
+ message: check.message
18216
+ });
18217
+ status.dirty();
18218
+ }
18219
+ } else if (check.kind === "uuid") {
18220
+ if (!uuidRegex.test(input.data)) {
18221
+ ctx = this._getOrReturnCtx(input, ctx);
18222
+ addIssueToContext(ctx, {
18223
+ validation: "uuid",
18224
+ code: ZodIssueCode.invalid_string,
18225
+ message: check.message
18226
+ });
18227
+ status.dirty();
18228
+ }
18229
+ } else if (check.kind === "nanoid") {
18230
+ if (!nanoidRegex.test(input.data)) {
18231
+ ctx = this._getOrReturnCtx(input, ctx);
18232
+ addIssueToContext(ctx, {
18233
+ validation: "nanoid",
18234
+ code: ZodIssueCode.invalid_string,
18235
+ message: check.message
18236
+ });
18237
+ status.dirty();
18238
+ }
18239
+ } else if (check.kind === "cuid") {
18240
+ if (!cuidRegex.test(input.data)) {
18241
+ ctx = this._getOrReturnCtx(input, ctx);
18242
+ addIssueToContext(ctx, {
18243
+ validation: "cuid",
18244
+ code: ZodIssueCode.invalid_string,
18245
+ message: check.message
18246
+ });
18247
+ status.dirty();
18248
+ }
18249
+ } else if (check.kind === "cuid2") {
18250
+ if (!cuid2Regex.test(input.data)) {
18251
+ ctx = this._getOrReturnCtx(input, ctx);
18252
+ addIssueToContext(ctx, {
18253
+ validation: "cuid2",
18254
+ code: ZodIssueCode.invalid_string,
18255
+ message: check.message
18256
+ });
18257
+ status.dirty();
18258
+ }
18259
+ } else if (check.kind === "ulid") {
18260
+ if (!ulidRegex.test(input.data)) {
18261
+ ctx = this._getOrReturnCtx(input, ctx);
18262
+ addIssueToContext(ctx, {
18263
+ validation: "ulid",
18264
+ code: ZodIssueCode.invalid_string,
18265
+ message: check.message
18266
+ });
18267
+ status.dirty();
18268
+ }
18269
+ } else if (check.kind === "url") {
18270
+ try {
18271
+ new URL(input.data);
18272
+ } catch (_a) {
18273
+ ctx = this._getOrReturnCtx(input, ctx);
18274
+ addIssueToContext(ctx, {
18275
+ validation: "url",
18276
+ code: ZodIssueCode.invalid_string,
18277
+ message: check.message
18278
+ });
18279
+ status.dirty();
18280
+ }
18281
+ } else if (check.kind === "regex") {
18282
+ check.regex.lastIndex = 0;
18283
+ const testResult = check.regex.test(input.data);
18284
+ if (!testResult) {
18285
+ ctx = this._getOrReturnCtx(input, ctx);
18286
+ addIssueToContext(ctx, {
18287
+ validation: "regex",
18288
+ code: ZodIssueCode.invalid_string,
18289
+ message: check.message
18290
+ });
18291
+ status.dirty();
18292
+ }
18293
+ } else if (check.kind === "trim") {
18294
+ input.data = input.data.trim();
18295
+ } else if (check.kind === "includes") {
18296
+ if (!input.data.includes(check.value, check.position)) {
18297
+ ctx = this._getOrReturnCtx(input, ctx);
18298
+ addIssueToContext(ctx, {
18299
+ code: ZodIssueCode.invalid_string,
18300
+ validation: { includes: check.value, position: check.position },
18301
+ message: check.message
18302
+ });
18303
+ status.dirty();
18304
+ }
18305
+ } else if (check.kind === "toLowerCase") {
18306
+ input.data = input.data.toLowerCase();
18307
+ } else if (check.kind === "toUpperCase") {
18308
+ input.data = input.data.toUpperCase();
18309
+ } else if (check.kind === "startsWith") {
18310
+ if (!input.data.startsWith(check.value)) {
18311
+ ctx = this._getOrReturnCtx(input, ctx);
18312
+ addIssueToContext(ctx, {
18313
+ code: ZodIssueCode.invalid_string,
18314
+ validation: { startsWith: check.value },
18315
+ message: check.message
18316
+ });
18317
+ status.dirty();
18318
+ }
18319
+ } else if (check.kind === "endsWith") {
18320
+ if (!input.data.endsWith(check.value)) {
18321
+ ctx = this._getOrReturnCtx(input, ctx);
18322
+ addIssueToContext(ctx, {
18323
+ code: ZodIssueCode.invalid_string,
18324
+ validation: { endsWith: check.value },
18325
+ message: check.message
18326
+ });
18327
+ status.dirty();
18328
+ }
18329
+ } else if (check.kind === "datetime") {
18330
+ const regex = datetimeRegex(check);
18331
+ if (!regex.test(input.data)) {
18332
+ ctx = this._getOrReturnCtx(input, ctx);
18333
+ addIssueToContext(ctx, {
18334
+ code: ZodIssueCode.invalid_string,
18335
+ validation: "datetime",
18336
+ message: check.message
18337
+ });
18338
+ status.dirty();
18339
+ }
18340
+ } else if (check.kind === "date") {
18341
+ const regex = dateRegex;
18342
+ if (!regex.test(input.data)) {
18343
+ ctx = this._getOrReturnCtx(input, ctx);
18344
+ addIssueToContext(ctx, {
18345
+ code: ZodIssueCode.invalid_string,
18346
+ validation: "date",
18347
+ message: check.message
18348
+ });
18349
+ status.dirty();
18350
+ }
18351
+ } else if (check.kind === "time") {
18352
+ const regex = timeRegex(check);
18353
+ if (!regex.test(input.data)) {
18354
+ ctx = this._getOrReturnCtx(input, ctx);
18355
+ addIssueToContext(ctx, {
18356
+ code: ZodIssueCode.invalid_string,
18357
+ validation: "time",
18358
+ message: check.message
18359
+ });
18360
+ status.dirty();
18361
+ }
18362
+ } else if (check.kind === "duration") {
18363
+ if (!durationRegex.test(input.data)) {
18364
+ ctx = this._getOrReturnCtx(input, ctx);
18365
+ addIssueToContext(ctx, {
18366
+ validation: "duration",
18367
+ code: ZodIssueCode.invalid_string,
18368
+ message: check.message
18369
+ });
18370
+ status.dirty();
18371
+ }
18372
+ } else if (check.kind === "ip") {
18373
+ if (!isValidIP(input.data, check.version)) {
18374
+ ctx = this._getOrReturnCtx(input, ctx);
18375
+ addIssueToContext(ctx, {
18376
+ validation: "ip",
18377
+ code: ZodIssueCode.invalid_string,
18378
+ message: check.message
18379
+ });
18380
+ status.dirty();
18381
+ }
18382
+ } else if (check.kind === "base64") {
18383
+ if (!base64Regex.test(input.data)) {
18384
+ ctx = this._getOrReturnCtx(input, ctx);
18385
+ addIssueToContext(ctx, {
18386
+ validation: "base64",
18387
+ code: ZodIssueCode.invalid_string,
18388
+ message: check.message
18389
+ });
18390
+ status.dirty();
18391
+ }
18392
+ } else {
18393
+ util.assertNever(check);
18394
+ }
18395
+ }
18396
+ return { status: status.value, value: input.data };
18397
+ }
18398
+ _regex(regex, validation, message) {
18399
+ return this.refinement((data) => regex.test(data), {
18400
+ validation,
18401
+ code: ZodIssueCode.invalid_string,
18402
+ ...errorUtil.errToObj(message)
18403
+ });
18404
+ }
18405
+ _addCheck(check) {
18406
+ return new _ZodString({
18407
+ ...this._def,
18408
+ checks: [...this._def.checks, check]
18409
+ });
18410
+ }
18411
+ email(message) {
18412
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
18413
+ }
18414
+ url(message) {
18415
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
18416
+ }
18417
+ emoji(message) {
18418
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
18419
+ }
18420
+ uuid(message) {
18421
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
18422
+ }
18423
+ nanoid(message) {
18424
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
18425
+ }
18426
+ cuid(message) {
18427
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
18428
+ }
18429
+ cuid2(message) {
18430
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
18431
+ }
18432
+ ulid(message) {
18433
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
18434
+ }
18435
+ base64(message) {
18436
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
18437
+ }
18438
+ ip(options) {
18439
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
18440
+ }
18441
+ datetime(options) {
18442
+ var _a, _b;
18443
+ if (typeof options === "string") {
18444
+ return this._addCheck({
18445
+ kind: "datetime",
18446
+ precision: null,
18447
+ offset: false,
18448
+ local: false,
18449
+ message: options
18450
+ });
18451
+ }
18452
+ return this._addCheck({
18453
+ kind: "datetime",
18454
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
18455
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
18456
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
18457
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
18458
+ });
18459
+ }
18460
+ date(message) {
18461
+ return this._addCheck({ kind: "date", message });
18462
+ }
18463
+ time(options) {
18464
+ if (typeof options === "string") {
18465
+ return this._addCheck({
18466
+ kind: "time",
18467
+ precision: null,
18468
+ message: options
18469
+ });
18470
+ }
18471
+ return this._addCheck({
18472
+ kind: "time",
18473
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
18474
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
18475
+ });
18476
+ }
18477
+ duration(message) {
18478
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
18479
+ }
18480
+ regex(regex, message) {
18481
+ return this._addCheck({
18482
+ kind: "regex",
18483
+ regex,
18484
+ ...errorUtil.errToObj(message)
18485
+ });
18486
+ }
18487
+ includes(value, options) {
18488
+ return this._addCheck({
18489
+ kind: "includes",
18490
+ value,
18491
+ position: options === null || options === void 0 ? void 0 : options.position,
18492
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
18493
+ });
18494
+ }
18495
+ startsWith(value, message) {
18496
+ return this._addCheck({
18497
+ kind: "startsWith",
18498
+ value,
18499
+ ...errorUtil.errToObj(message)
18500
+ });
18501
+ }
18502
+ endsWith(value, message) {
18503
+ return this._addCheck({
18504
+ kind: "endsWith",
18505
+ value,
18506
+ ...errorUtil.errToObj(message)
18507
+ });
18508
+ }
18509
+ min(minLength, message) {
18510
+ return this._addCheck({
18511
+ kind: "min",
18512
+ value: minLength,
18513
+ ...errorUtil.errToObj(message)
18514
+ });
18515
+ }
18516
+ max(maxLength, message) {
18517
+ return this._addCheck({
18518
+ kind: "max",
18519
+ value: maxLength,
18520
+ ...errorUtil.errToObj(message)
18521
+ });
18522
+ }
18523
+ length(len, message) {
18524
+ return this._addCheck({
18525
+ kind: "length",
18526
+ value: len,
18527
+ ...errorUtil.errToObj(message)
18528
+ });
18529
+ }
18530
+ /**
18531
+ * @deprecated Use z.string().min(1) instead.
18532
+ * @see {@link ZodString.min}
18533
+ */
18534
+ nonempty(message) {
18535
+ return this.min(1, errorUtil.errToObj(message));
18536
+ }
18537
+ trim() {
18538
+ return new _ZodString({
18539
+ ...this._def,
18540
+ checks: [...this._def.checks, { kind: "trim" }]
18541
+ });
18542
+ }
18543
+ toLowerCase() {
18544
+ return new _ZodString({
18545
+ ...this._def,
18546
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
18547
+ });
18548
+ }
18549
+ toUpperCase() {
18550
+ return new _ZodString({
18551
+ ...this._def,
18552
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
18553
+ });
18554
+ }
18555
+ get isDatetime() {
18556
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
18557
+ }
18558
+ get isDate() {
18559
+ return !!this._def.checks.find((ch) => ch.kind === "date");
18560
+ }
18561
+ get isTime() {
18562
+ return !!this._def.checks.find((ch) => ch.kind === "time");
18563
+ }
18564
+ get isDuration() {
18565
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
18566
+ }
18567
+ get isEmail() {
18568
+ return !!this._def.checks.find((ch) => ch.kind === "email");
18569
+ }
18570
+ get isURL() {
18571
+ return !!this._def.checks.find((ch) => ch.kind === "url");
18572
+ }
18573
+ get isEmoji() {
18574
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
18575
+ }
18576
+ get isUUID() {
18577
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
18578
+ }
18579
+ get isNANOID() {
18580
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
18581
+ }
18582
+ get isCUID() {
18583
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
18584
+ }
18585
+ get isCUID2() {
18586
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
18587
+ }
18588
+ get isULID() {
18589
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
18590
+ }
18591
+ get isIP() {
18592
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
18593
+ }
18594
+ get isBase64() {
18595
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
18596
+ }
18597
+ get minLength() {
18598
+ let min = null;
18599
+ for (const ch of this._def.checks) {
18600
+ if (ch.kind === "min") {
18601
+ if (min === null || ch.value > min)
18602
+ min = ch.value;
18603
+ }
18604
+ }
18605
+ return min;
18606
+ }
18607
+ get maxLength() {
18608
+ let max = null;
18609
+ for (const ch of this._def.checks) {
18610
+ if (ch.kind === "max") {
18611
+ if (max === null || ch.value < max)
18612
+ max = ch.value;
18613
+ }
18614
+ }
18615
+ return max;
18616
+ }
18617
+ };
18618
+ ZodString.create = (params) => {
18619
+ var _a;
18620
+ return new ZodString({
18621
+ checks: [],
18622
+ typeName: ZodFirstPartyTypeKind.ZodString,
18623
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
18624
+ ...processCreateParams(params)
18625
+ });
18626
+ };
18627
+ function floatSafeRemainder(val, step) {
18628
+ const valDecCount = (val.toString().split(".")[1] || "").length;
18629
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
18630
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
18631
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
18632
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
18633
+ return valInt % stepInt / Math.pow(10, decCount);
18634
+ }
18635
+ var ZodNumber = class _ZodNumber extends ZodType {
18636
+ constructor() {
18637
+ super(...arguments);
18638
+ this.min = this.gte;
18639
+ this.max = this.lte;
18640
+ this.step = this.multipleOf;
18641
+ }
18642
+ _parse(input) {
18643
+ if (this._def.coerce) {
18644
+ input.data = Number(input.data);
18645
+ }
18646
+ const parsedType = this._getType(input);
18647
+ if (parsedType !== ZodParsedType.number) {
18648
+ const ctx2 = this._getOrReturnCtx(input);
18649
+ addIssueToContext(ctx2, {
18650
+ code: ZodIssueCode.invalid_type,
18651
+ expected: ZodParsedType.number,
18652
+ received: ctx2.parsedType
18653
+ });
18654
+ return INVALID;
18655
+ }
18656
+ let ctx = void 0;
18657
+ const status = new ParseStatus();
18658
+ for (const check of this._def.checks) {
18659
+ if (check.kind === "int") {
18660
+ if (!util.isInteger(input.data)) {
18661
+ ctx = this._getOrReturnCtx(input, ctx);
18662
+ addIssueToContext(ctx, {
18663
+ code: ZodIssueCode.invalid_type,
18664
+ expected: "integer",
18665
+ received: "float",
18666
+ message: check.message
18667
+ });
18668
+ status.dirty();
18669
+ }
18670
+ } else if (check.kind === "min") {
18671
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
18672
+ if (tooSmall) {
18673
+ ctx = this._getOrReturnCtx(input, ctx);
18674
+ addIssueToContext(ctx, {
18675
+ code: ZodIssueCode.too_small,
18676
+ minimum: check.value,
18677
+ type: "number",
18678
+ inclusive: check.inclusive,
18679
+ exact: false,
18680
+ message: check.message
18681
+ });
18682
+ status.dirty();
18683
+ }
18684
+ } else if (check.kind === "max") {
18685
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
18686
+ if (tooBig) {
18687
+ ctx = this._getOrReturnCtx(input, ctx);
18688
+ addIssueToContext(ctx, {
18689
+ code: ZodIssueCode.too_big,
18690
+ maximum: check.value,
18691
+ type: "number",
18692
+ inclusive: check.inclusive,
18693
+ exact: false,
18694
+ message: check.message
18695
+ });
18696
+ status.dirty();
18697
+ }
18698
+ } else if (check.kind === "multipleOf") {
18699
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
18700
+ ctx = this._getOrReturnCtx(input, ctx);
18701
+ addIssueToContext(ctx, {
18702
+ code: ZodIssueCode.not_multiple_of,
18703
+ multipleOf: check.value,
18704
+ message: check.message
18705
+ });
18706
+ status.dirty();
18707
+ }
18708
+ } else if (check.kind === "finite") {
18709
+ if (!Number.isFinite(input.data)) {
18710
+ ctx = this._getOrReturnCtx(input, ctx);
18711
+ addIssueToContext(ctx, {
18712
+ code: ZodIssueCode.not_finite,
18713
+ message: check.message
18714
+ });
18715
+ status.dirty();
18716
+ }
18717
+ } else {
18718
+ util.assertNever(check);
18719
+ }
18720
+ }
18721
+ return { status: status.value, value: input.data };
18722
+ }
18723
+ gte(value, message) {
18724
+ return this.setLimit("min", value, true, errorUtil.toString(message));
18725
+ }
18726
+ gt(value, message) {
18727
+ return this.setLimit("min", value, false, errorUtil.toString(message));
18728
+ }
18729
+ lte(value, message) {
18730
+ return this.setLimit("max", value, true, errorUtil.toString(message));
18731
+ }
18732
+ lt(value, message) {
18733
+ return this.setLimit("max", value, false, errorUtil.toString(message));
18734
+ }
18735
+ setLimit(kind, value, inclusive, message) {
18736
+ return new _ZodNumber({
18737
+ ...this._def,
18738
+ checks: [
18739
+ ...this._def.checks,
18740
+ {
18741
+ kind,
18742
+ value,
18743
+ inclusive,
18744
+ message: errorUtil.toString(message)
18745
+ }
18746
+ ]
18747
+ });
18748
+ }
18749
+ _addCheck(check) {
18750
+ return new _ZodNumber({
18751
+ ...this._def,
18752
+ checks: [...this._def.checks, check]
18753
+ });
18754
+ }
18755
+ int(message) {
18756
+ return this._addCheck({
18757
+ kind: "int",
18758
+ message: errorUtil.toString(message)
18759
+ });
18760
+ }
18761
+ positive(message) {
18762
+ return this._addCheck({
18763
+ kind: "min",
18764
+ value: 0,
18765
+ inclusive: false,
18766
+ message: errorUtil.toString(message)
18767
+ });
18768
+ }
18769
+ negative(message) {
18770
+ return this._addCheck({
18771
+ kind: "max",
18772
+ value: 0,
18773
+ inclusive: false,
18774
+ message: errorUtil.toString(message)
18775
+ });
18776
+ }
18777
+ nonpositive(message) {
18778
+ return this._addCheck({
18779
+ kind: "max",
18780
+ value: 0,
18781
+ inclusive: true,
18782
+ message: errorUtil.toString(message)
18783
+ });
18784
+ }
18785
+ nonnegative(message) {
18786
+ return this._addCheck({
18787
+ kind: "min",
18788
+ value: 0,
18789
+ inclusive: true,
18790
+ message: errorUtil.toString(message)
18791
+ });
18792
+ }
18793
+ multipleOf(value, message) {
18794
+ return this._addCheck({
18795
+ kind: "multipleOf",
18796
+ value,
18797
+ message: errorUtil.toString(message)
18798
+ });
18799
+ }
18800
+ finite(message) {
18801
+ return this._addCheck({
18802
+ kind: "finite",
18803
+ message: errorUtil.toString(message)
18804
+ });
18805
+ }
18806
+ safe(message) {
18807
+ return this._addCheck({
18808
+ kind: "min",
18809
+ inclusive: true,
18810
+ value: Number.MIN_SAFE_INTEGER,
18811
+ message: errorUtil.toString(message)
18812
+ })._addCheck({
18813
+ kind: "max",
18814
+ inclusive: true,
18815
+ value: Number.MAX_SAFE_INTEGER,
18816
+ message: errorUtil.toString(message)
18817
+ });
18818
+ }
18819
+ get minValue() {
18820
+ let min = null;
18821
+ for (const ch of this._def.checks) {
18822
+ if (ch.kind === "min") {
18823
+ if (min === null || ch.value > min)
18824
+ min = ch.value;
18825
+ }
18826
+ }
18827
+ return min;
18828
+ }
18829
+ get maxValue() {
18830
+ let max = null;
18831
+ for (const ch of this._def.checks) {
18832
+ if (ch.kind === "max") {
18833
+ if (max === null || ch.value < max)
18834
+ max = ch.value;
18835
+ }
18836
+ }
18837
+ return max;
18838
+ }
18839
+ get isInt() {
18840
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
18841
+ }
18842
+ get isFinite() {
18843
+ let max = null, min = null;
18844
+ for (const ch of this._def.checks) {
18845
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
18846
+ return true;
18847
+ } else if (ch.kind === "min") {
18848
+ if (min === null || ch.value > min)
18849
+ min = ch.value;
18850
+ } else if (ch.kind === "max") {
18851
+ if (max === null || ch.value < max)
18852
+ max = ch.value;
18853
+ }
18854
+ }
18855
+ return Number.isFinite(min) && Number.isFinite(max);
18856
+ }
18857
+ };
18858
+ ZodNumber.create = (params) => {
18859
+ return new ZodNumber({
18860
+ checks: [],
18861
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
18862
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
18863
+ ...processCreateParams(params)
18864
+ });
18865
+ };
18866
+ var ZodBigInt = class _ZodBigInt extends ZodType {
18867
+ constructor() {
18868
+ super(...arguments);
18869
+ this.min = this.gte;
18870
+ this.max = this.lte;
18871
+ }
18872
+ _parse(input) {
18873
+ if (this._def.coerce) {
18874
+ input.data = BigInt(input.data);
18875
+ }
18876
+ const parsedType = this._getType(input);
18877
+ if (parsedType !== ZodParsedType.bigint) {
18878
+ const ctx2 = this._getOrReturnCtx(input);
18879
+ addIssueToContext(ctx2, {
18880
+ code: ZodIssueCode.invalid_type,
18881
+ expected: ZodParsedType.bigint,
18882
+ received: ctx2.parsedType
18883
+ });
18884
+ return INVALID;
18885
+ }
18886
+ let ctx = void 0;
18887
+ const status = new ParseStatus();
18888
+ for (const check of this._def.checks) {
18889
+ if (check.kind === "min") {
18890
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
18891
+ if (tooSmall) {
18892
+ ctx = this._getOrReturnCtx(input, ctx);
18893
+ addIssueToContext(ctx, {
18894
+ code: ZodIssueCode.too_small,
18895
+ type: "bigint",
18896
+ minimum: check.value,
18897
+ inclusive: check.inclusive,
18898
+ message: check.message
18899
+ });
18900
+ status.dirty();
18901
+ }
18902
+ } else if (check.kind === "max") {
18903
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
18904
+ if (tooBig) {
18905
+ ctx = this._getOrReturnCtx(input, ctx);
18906
+ addIssueToContext(ctx, {
18907
+ code: ZodIssueCode.too_big,
18908
+ type: "bigint",
18909
+ maximum: check.value,
18910
+ inclusive: check.inclusive,
18911
+ message: check.message
18912
+ });
18913
+ status.dirty();
18914
+ }
18915
+ } else if (check.kind === "multipleOf") {
18916
+ if (input.data % check.value !== BigInt(0)) {
18917
+ ctx = this._getOrReturnCtx(input, ctx);
18918
+ addIssueToContext(ctx, {
18919
+ code: ZodIssueCode.not_multiple_of,
18920
+ multipleOf: check.value,
18921
+ message: check.message
18922
+ });
18923
+ status.dirty();
18924
+ }
18925
+ } else {
18926
+ util.assertNever(check);
18927
+ }
18928
+ }
18929
+ return { status: status.value, value: input.data };
18930
+ }
18931
+ gte(value, message) {
18932
+ return this.setLimit("min", value, true, errorUtil.toString(message));
18933
+ }
18934
+ gt(value, message) {
18935
+ return this.setLimit("min", value, false, errorUtil.toString(message));
18936
+ }
18937
+ lte(value, message) {
18938
+ return this.setLimit("max", value, true, errorUtil.toString(message));
18939
+ }
18940
+ lt(value, message) {
18941
+ return this.setLimit("max", value, false, errorUtil.toString(message));
18942
+ }
18943
+ setLimit(kind, value, inclusive, message) {
18944
+ return new _ZodBigInt({
18945
+ ...this._def,
18946
+ checks: [
18947
+ ...this._def.checks,
18948
+ {
18949
+ kind,
18950
+ value,
18951
+ inclusive,
18952
+ message: errorUtil.toString(message)
18953
+ }
18954
+ ]
18955
+ });
18956
+ }
18957
+ _addCheck(check) {
18958
+ return new _ZodBigInt({
18959
+ ...this._def,
18960
+ checks: [...this._def.checks, check]
18961
+ });
18962
+ }
18963
+ positive(message) {
18964
+ return this._addCheck({
18965
+ kind: "min",
18966
+ value: BigInt(0),
18967
+ inclusive: false,
18968
+ message: errorUtil.toString(message)
18969
+ });
18970
+ }
18971
+ negative(message) {
18972
+ return this._addCheck({
18973
+ kind: "max",
18974
+ value: BigInt(0),
18975
+ inclusive: false,
18976
+ message: errorUtil.toString(message)
18977
+ });
18978
+ }
18979
+ nonpositive(message) {
18980
+ return this._addCheck({
18981
+ kind: "max",
18982
+ value: BigInt(0),
18983
+ inclusive: true,
18984
+ message: errorUtil.toString(message)
18985
+ });
18986
+ }
18987
+ nonnegative(message) {
18988
+ return this._addCheck({
18989
+ kind: "min",
18990
+ value: BigInt(0),
18991
+ inclusive: true,
18992
+ message: errorUtil.toString(message)
18993
+ });
18994
+ }
18995
+ multipleOf(value, message) {
18996
+ return this._addCheck({
18997
+ kind: "multipleOf",
18998
+ value,
18999
+ message: errorUtil.toString(message)
19000
+ });
19001
+ }
19002
+ get minValue() {
19003
+ let min = null;
19004
+ for (const ch of this._def.checks) {
19005
+ if (ch.kind === "min") {
19006
+ if (min === null || ch.value > min)
19007
+ min = ch.value;
19008
+ }
19009
+ }
19010
+ return min;
19011
+ }
19012
+ get maxValue() {
19013
+ let max = null;
19014
+ for (const ch of this._def.checks) {
19015
+ if (ch.kind === "max") {
19016
+ if (max === null || ch.value < max)
19017
+ max = ch.value;
19018
+ }
19019
+ }
19020
+ return max;
19021
+ }
19022
+ };
19023
+ ZodBigInt.create = (params) => {
19024
+ var _a;
19025
+ return new ZodBigInt({
19026
+ checks: [],
19027
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
19028
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
19029
+ ...processCreateParams(params)
19030
+ });
19031
+ };
19032
+ var ZodBoolean = class extends ZodType {
19033
+ _parse(input) {
19034
+ if (this._def.coerce) {
19035
+ input.data = Boolean(input.data);
19036
+ }
19037
+ const parsedType = this._getType(input);
19038
+ if (parsedType !== ZodParsedType.boolean) {
19039
+ const ctx = this._getOrReturnCtx(input);
19040
+ addIssueToContext(ctx, {
19041
+ code: ZodIssueCode.invalid_type,
19042
+ expected: ZodParsedType.boolean,
19043
+ received: ctx.parsedType
19044
+ });
19045
+ return INVALID;
19046
+ }
19047
+ return OK(input.data);
19048
+ }
19049
+ };
19050
+ ZodBoolean.create = (params) => {
19051
+ return new ZodBoolean({
19052
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
19053
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
19054
+ ...processCreateParams(params)
19055
+ });
19056
+ };
19057
+ var ZodDate = class _ZodDate extends ZodType {
19058
+ _parse(input) {
19059
+ if (this._def.coerce) {
19060
+ input.data = new Date(input.data);
19061
+ }
19062
+ const parsedType = this._getType(input);
19063
+ if (parsedType !== ZodParsedType.date) {
19064
+ const ctx2 = this._getOrReturnCtx(input);
19065
+ addIssueToContext(ctx2, {
19066
+ code: ZodIssueCode.invalid_type,
19067
+ expected: ZodParsedType.date,
19068
+ received: ctx2.parsedType
19069
+ });
19070
+ return INVALID;
19071
+ }
19072
+ if (isNaN(input.data.getTime())) {
19073
+ const ctx2 = this._getOrReturnCtx(input);
19074
+ addIssueToContext(ctx2, {
19075
+ code: ZodIssueCode.invalid_date
19076
+ });
19077
+ return INVALID;
19078
+ }
19079
+ const status = new ParseStatus();
19080
+ let ctx = void 0;
19081
+ for (const check of this._def.checks) {
19082
+ if (check.kind === "min") {
19083
+ if (input.data.getTime() < check.value) {
19084
+ ctx = this._getOrReturnCtx(input, ctx);
19085
+ addIssueToContext(ctx, {
19086
+ code: ZodIssueCode.too_small,
19087
+ message: check.message,
19088
+ inclusive: true,
19089
+ exact: false,
19090
+ minimum: check.value,
19091
+ type: "date"
19092
+ });
19093
+ status.dirty();
19094
+ }
19095
+ } else if (check.kind === "max") {
19096
+ if (input.data.getTime() > check.value) {
19097
+ ctx = this._getOrReturnCtx(input, ctx);
19098
+ addIssueToContext(ctx, {
19099
+ code: ZodIssueCode.too_big,
19100
+ message: check.message,
19101
+ inclusive: true,
19102
+ exact: false,
19103
+ maximum: check.value,
19104
+ type: "date"
19105
+ });
19106
+ status.dirty();
19107
+ }
19108
+ } else {
19109
+ util.assertNever(check);
19110
+ }
19111
+ }
19112
+ return {
19113
+ status: status.value,
19114
+ value: new Date(input.data.getTime())
19115
+ };
19116
+ }
19117
+ _addCheck(check) {
19118
+ return new _ZodDate({
19119
+ ...this._def,
19120
+ checks: [...this._def.checks, check]
19121
+ });
19122
+ }
19123
+ min(minDate, message) {
19124
+ return this._addCheck({
19125
+ kind: "min",
19126
+ value: minDate.getTime(),
19127
+ message: errorUtil.toString(message)
19128
+ });
19129
+ }
19130
+ max(maxDate, message) {
19131
+ return this._addCheck({
19132
+ kind: "max",
19133
+ value: maxDate.getTime(),
19134
+ message: errorUtil.toString(message)
19135
+ });
19136
+ }
19137
+ get minDate() {
19138
+ let min = null;
19139
+ for (const ch of this._def.checks) {
19140
+ if (ch.kind === "min") {
19141
+ if (min === null || ch.value > min)
19142
+ min = ch.value;
19143
+ }
19144
+ }
19145
+ return min != null ? new Date(min) : null;
19146
+ }
19147
+ get maxDate() {
19148
+ let max = null;
19149
+ for (const ch of this._def.checks) {
19150
+ if (ch.kind === "max") {
19151
+ if (max === null || ch.value < max)
19152
+ max = ch.value;
19153
+ }
19154
+ }
19155
+ return max != null ? new Date(max) : null;
19156
+ }
19157
+ };
19158
+ ZodDate.create = (params) => {
19159
+ return new ZodDate({
19160
+ checks: [],
19161
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
19162
+ typeName: ZodFirstPartyTypeKind.ZodDate,
19163
+ ...processCreateParams(params)
19164
+ });
19165
+ };
19166
+ var ZodSymbol = class extends ZodType {
19167
+ _parse(input) {
19168
+ const parsedType = this._getType(input);
19169
+ if (parsedType !== ZodParsedType.symbol) {
19170
+ const ctx = this._getOrReturnCtx(input);
19171
+ addIssueToContext(ctx, {
19172
+ code: ZodIssueCode.invalid_type,
19173
+ expected: ZodParsedType.symbol,
19174
+ received: ctx.parsedType
19175
+ });
19176
+ return INVALID;
19177
+ }
19178
+ return OK(input.data);
19179
+ }
19180
+ };
19181
+ ZodSymbol.create = (params) => {
19182
+ return new ZodSymbol({
19183
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
19184
+ ...processCreateParams(params)
19185
+ });
19186
+ };
19187
+ var ZodUndefined = class extends ZodType {
19188
+ _parse(input) {
19189
+ const parsedType = this._getType(input);
19190
+ if (parsedType !== ZodParsedType.undefined) {
19191
+ const ctx = this._getOrReturnCtx(input);
19192
+ addIssueToContext(ctx, {
19193
+ code: ZodIssueCode.invalid_type,
19194
+ expected: ZodParsedType.undefined,
19195
+ received: ctx.parsedType
19196
+ });
19197
+ return INVALID;
19198
+ }
19199
+ return OK(input.data);
19200
+ }
19201
+ };
19202
+ ZodUndefined.create = (params) => {
19203
+ return new ZodUndefined({
19204
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
19205
+ ...processCreateParams(params)
19206
+ });
19207
+ };
19208
+ var ZodNull = class extends ZodType {
19209
+ _parse(input) {
19210
+ const parsedType = this._getType(input);
19211
+ if (parsedType !== ZodParsedType.null) {
19212
+ const ctx = this._getOrReturnCtx(input);
19213
+ addIssueToContext(ctx, {
19214
+ code: ZodIssueCode.invalid_type,
19215
+ expected: ZodParsedType.null,
19216
+ received: ctx.parsedType
19217
+ });
19218
+ return INVALID;
19219
+ }
19220
+ return OK(input.data);
19221
+ }
19222
+ };
19223
+ ZodNull.create = (params) => {
19224
+ return new ZodNull({
19225
+ typeName: ZodFirstPartyTypeKind.ZodNull,
19226
+ ...processCreateParams(params)
19227
+ });
19228
+ };
19229
+ var ZodAny = class extends ZodType {
19230
+ constructor() {
19231
+ super(...arguments);
19232
+ this._any = true;
19233
+ }
19234
+ _parse(input) {
19235
+ return OK(input.data);
19236
+ }
19237
+ };
19238
+ ZodAny.create = (params) => {
19239
+ return new ZodAny({
19240
+ typeName: ZodFirstPartyTypeKind.ZodAny,
19241
+ ...processCreateParams(params)
19242
+ });
19243
+ };
19244
+ var ZodUnknown = class extends ZodType {
19245
+ constructor() {
19246
+ super(...arguments);
19247
+ this._unknown = true;
19248
+ }
19249
+ _parse(input) {
19250
+ return OK(input.data);
19251
+ }
19252
+ };
19253
+ ZodUnknown.create = (params) => {
19254
+ return new ZodUnknown({
19255
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
19256
+ ...processCreateParams(params)
19257
+ });
19258
+ };
19259
+ var ZodNever = class extends ZodType {
19260
+ _parse(input) {
19261
+ const ctx = this._getOrReturnCtx(input);
19262
+ addIssueToContext(ctx, {
19263
+ code: ZodIssueCode.invalid_type,
19264
+ expected: ZodParsedType.never,
19265
+ received: ctx.parsedType
19266
+ });
19267
+ return INVALID;
19268
+ }
19269
+ };
19270
+ ZodNever.create = (params) => {
19271
+ return new ZodNever({
19272
+ typeName: ZodFirstPartyTypeKind.ZodNever,
19273
+ ...processCreateParams(params)
19274
+ });
19275
+ };
19276
+ var ZodVoid = class extends ZodType {
19277
+ _parse(input) {
19278
+ const parsedType = this._getType(input);
19279
+ if (parsedType !== ZodParsedType.undefined) {
19280
+ const ctx = this._getOrReturnCtx(input);
19281
+ addIssueToContext(ctx, {
19282
+ code: ZodIssueCode.invalid_type,
19283
+ expected: ZodParsedType.void,
19284
+ received: ctx.parsedType
19285
+ });
19286
+ return INVALID;
19287
+ }
19288
+ return OK(input.data);
19289
+ }
19290
+ };
19291
+ ZodVoid.create = (params) => {
19292
+ return new ZodVoid({
19293
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
19294
+ ...processCreateParams(params)
19295
+ });
19296
+ };
19297
+ var ZodArray = class _ZodArray extends ZodType {
19298
+ _parse(input) {
19299
+ const { ctx, status } = this._processInputParams(input);
19300
+ const def = this._def;
19301
+ if (ctx.parsedType !== ZodParsedType.array) {
19302
+ addIssueToContext(ctx, {
19303
+ code: ZodIssueCode.invalid_type,
19304
+ expected: ZodParsedType.array,
19305
+ received: ctx.parsedType
19306
+ });
19307
+ return INVALID;
19308
+ }
19309
+ if (def.exactLength !== null) {
19310
+ const tooBig = ctx.data.length > def.exactLength.value;
19311
+ const tooSmall = ctx.data.length < def.exactLength.value;
19312
+ if (tooBig || tooSmall) {
19313
+ addIssueToContext(ctx, {
19314
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
19315
+ minimum: tooSmall ? def.exactLength.value : void 0,
19316
+ maximum: tooBig ? def.exactLength.value : void 0,
19317
+ type: "array",
19318
+ inclusive: true,
19319
+ exact: true,
19320
+ message: def.exactLength.message
19321
+ });
19322
+ status.dirty();
19323
+ }
19324
+ }
19325
+ if (def.minLength !== null) {
19326
+ if (ctx.data.length < def.minLength.value) {
19327
+ addIssueToContext(ctx, {
19328
+ code: ZodIssueCode.too_small,
19329
+ minimum: def.minLength.value,
19330
+ type: "array",
19331
+ inclusive: true,
19332
+ exact: false,
19333
+ message: def.minLength.message
19334
+ });
19335
+ status.dirty();
19336
+ }
19337
+ }
19338
+ if (def.maxLength !== null) {
19339
+ if (ctx.data.length > def.maxLength.value) {
19340
+ addIssueToContext(ctx, {
19341
+ code: ZodIssueCode.too_big,
19342
+ maximum: def.maxLength.value,
19343
+ type: "array",
19344
+ inclusive: true,
19345
+ exact: false,
19346
+ message: def.maxLength.message
19347
+ });
19348
+ status.dirty();
19349
+ }
19350
+ }
19351
+ if (ctx.common.async) {
19352
+ return Promise.all([...ctx.data].map((item, i) => {
19353
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
19354
+ })).then((result2) => {
19355
+ return ParseStatus.mergeArray(status, result2);
19356
+ });
19357
+ }
19358
+ const result = [...ctx.data].map((item, i) => {
19359
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
19360
+ });
19361
+ return ParseStatus.mergeArray(status, result);
19362
+ }
19363
+ get element() {
19364
+ return this._def.type;
19365
+ }
19366
+ min(minLength, message) {
19367
+ return new _ZodArray({
19368
+ ...this._def,
19369
+ minLength: { value: minLength, message: errorUtil.toString(message) }
19370
+ });
19371
+ }
19372
+ max(maxLength, message) {
19373
+ return new _ZodArray({
19374
+ ...this._def,
19375
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
19376
+ });
19377
+ }
19378
+ length(len, message) {
19379
+ return new _ZodArray({
19380
+ ...this._def,
19381
+ exactLength: { value: len, message: errorUtil.toString(message) }
19382
+ });
19383
+ }
19384
+ nonempty(message) {
19385
+ return this.min(1, message);
19386
+ }
19387
+ };
19388
+ ZodArray.create = (schema, params) => {
19389
+ return new ZodArray({
19390
+ type: schema,
19391
+ minLength: null,
19392
+ maxLength: null,
19393
+ exactLength: null,
19394
+ typeName: ZodFirstPartyTypeKind.ZodArray,
19395
+ ...processCreateParams(params)
19396
+ });
19397
+ };
19398
+ function deepPartialify(schema) {
19399
+ if (schema instanceof ZodObject) {
19400
+ const newShape = {};
19401
+ for (const key in schema.shape) {
19402
+ const fieldSchema = schema.shape[key];
19403
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
19404
+ }
19405
+ return new ZodObject({
19406
+ ...schema._def,
19407
+ shape: () => newShape
19408
+ });
19409
+ } else if (schema instanceof ZodArray) {
19410
+ return new ZodArray({
19411
+ ...schema._def,
19412
+ type: deepPartialify(schema.element)
19413
+ });
19414
+ } else if (schema instanceof ZodOptional) {
19415
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
19416
+ } else if (schema instanceof ZodNullable) {
19417
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
19418
+ } else if (schema instanceof ZodTuple) {
19419
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
19420
+ } else {
19421
+ return schema;
19422
+ }
19423
+ }
19424
+ var ZodObject = class _ZodObject extends ZodType {
19425
+ constructor() {
19426
+ super(...arguments);
19427
+ this._cached = null;
19428
+ this.nonstrict = this.passthrough;
19429
+ this.augment = this.extend;
19430
+ }
19431
+ _getCached() {
19432
+ if (this._cached !== null)
19433
+ return this._cached;
19434
+ const shape = this._def.shape();
19435
+ const keys = util.objectKeys(shape);
19436
+ return this._cached = { shape, keys };
19437
+ }
19438
+ _parse(input) {
19439
+ const parsedType = this._getType(input);
19440
+ if (parsedType !== ZodParsedType.object) {
19441
+ const ctx2 = this._getOrReturnCtx(input);
19442
+ addIssueToContext(ctx2, {
19443
+ code: ZodIssueCode.invalid_type,
19444
+ expected: ZodParsedType.object,
19445
+ received: ctx2.parsedType
19446
+ });
19447
+ return INVALID;
19448
+ }
19449
+ const { status, ctx } = this._processInputParams(input);
19450
+ const { shape, keys: shapeKeys } = this._getCached();
19451
+ const extraKeys = [];
19452
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
19453
+ for (const key in ctx.data) {
19454
+ if (!shapeKeys.includes(key)) {
19455
+ extraKeys.push(key);
19456
+ }
19457
+ }
19458
+ }
19459
+ const pairs = [];
19460
+ for (const key of shapeKeys) {
19461
+ const keyValidator = shape[key];
19462
+ const value = ctx.data[key];
19463
+ pairs.push({
19464
+ key: { status: "valid", value: key },
19465
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
19466
+ alwaysSet: key in ctx.data
19467
+ });
19468
+ }
19469
+ if (this._def.catchall instanceof ZodNever) {
19470
+ const unknownKeys = this._def.unknownKeys;
19471
+ if (unknownKeys === "passthrough") {
19472
+ for (const key of extraKeys) {
19473
+ pairs.push({
19474
+ key: { status: "valid", value: key },
19475
+ value: { status: "valid", value: ctx.data[key] }
19476
+ });
19477
+ }
19478
+ } else if (unknownKeys === "strict") {
19479
+ if (extraKeys.length > 0) {
19480
+ addIssueToContext(ctx, {
19481
+ code: ZodIssueCode.unrecognized_keys,
19482
+ keys: extraKeys
19483
+ });
19484
+ status.dirty();
19485
+ }
19486
+ } else if (unknownKeys === "strip")
19487
+ ;
19488
+ else {
19489
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
19490
+ }
19491
+ } else {
19492
+ const catchall = this._def.catchall;
19493
+ for (const key of extraKeys) {
19494
+ const value = ctx.data[key];
19495
+ pairs.push({
19496
+ key: { status: "valid", value: key },
19497
+ value: catchall._parse(
19498
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
19499
+ //, ctx.child(key), value, getParsedType(value)
19500
+ ),
19501
+ alwaysSet: key in ctx.data
19502
+ });
19503
+ }
19504
+ }
19505
+ if (ctx.common.async) {
19506
+ return Promise.resolve().then(async () => {
19507
+ const syncPairs = [];
19508
+ for (const pair of pairs) {
19509
+ const key = await pair.key;
19510
+ const value = await pair.value;
19511
+ syncPairs.push({
19512
+ key,
19513
+ value,
19514
+ alwaysSet: pair.alwaysSet
19515
+ });
19516
+ }
19517
+ return syncPairs;
19518
+ }).then((syncPairs) => {
19519
+ return ParseStatus.mergeObjectSync(status, syncPairs);
19520
+ });
19521
+ } else {
19522
+ return ParseStatus.mergeObjectSync(status, pairs);
19523
+ }
19524
+ }
19525
+ get shape() {
19526
+ return this._def.shape();
19527
+ }
19528
+ strict(message) {
19529
+ errorUtil.errToObj;
19530
+ return new _ZodObject({
19531
+ ...this._def,
19532
+ unknownKeys: "strict",
19533
+ ...message !== void 0 ? {
19534
+ errorMap: (issue, ctx) => {
19535
+ var _a, _b, _c, _d;
19536
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
19537
+ if (issue.code === "unrecognized_keys")
19538
+ return {
19539
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
19540
+ };
19541
+ return {
19542
+ message: defaultError
19543
+ };
19544
+ }
19545
+ } : {}
19546
+ });
19547
+ }
19548
+ strip() {
19549
+ return new _ZodObject({
19550
+ ...this._def,
19551
+ unknownKeys: "strip"
19552
+ });
19553
+ }
19554
+ passthrough() {
19555
+ return new _ZodObject({
19556
+ ...this._def,
19557
+ unknownKeys: "passthrough"
19558
+ });
19559
+ }
19560
+ // const AugmentFactory =
19561
+ // <Def extends ZodObjectDef>(def: Def) =>
19562
+ // <Augmentation extends ZodRawShape>(
19563
+ // augmentation: Augmentation
19564
+ // ): ZodObject<
19565
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
19566
+ // Def["unknownKeys"],
19567
+ // Def["catchall"]
19568
+ // > => {
19569
+ // return new ZodObject({
19570
+ // ...def,
19571
+ // shape: () => ({
19572
+ // ...def.shape(),
19573
+ // ...augmentation,
19574
+ // }),
19575
+ // }) as any;
19576
+ // };
19577
+ extend(augmentation) {
19578
+ return new _ZodObject({
19579
+ ...this._def,
19580
+ shape: () => ({
19581
+ ...this._def.shape(),
19582
+ ...augmentation
19583
+ })
19584
+ });
19585
+ }
19586
+ /**
19587
+ * Prior to zod@1.0.12 there was a bug in the
19588
+ * inferred type of merged objects. Please
19589
+ * upgrade if you are experiencing issues.
19590
+ */
19591
+ merge(merging) {
19592
+ const merged = new _ZodObject({
19593
+ unknownKeys: merging._def.unknownKeys,
19594
+ catchall: merging._def.catchall,
19595
+ shape: () => ({
19596
+ ...this._def.shape(),
19597
+ ...merging._def.shape()
19598
+ }),
19599
+ typeName: ZodFirstPartyTypeKind.ZodObject
19600
+ });
19601
+ return merged;
19602
+ }
19603
+ // merge<
19604
+ // Incoming extends AnyZodObject,
19605
+ // Augmentation extends Incoming["shape"],
19606
+ // NewOutput extends {
19607
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
19608
+ // ? Augmentation[k]["_output"]
19609
+ // : k extends keyof Output
19610
+ // ? Output[k]
19611
+ // : never;
19612
+ // },
19613
+ // NewInput extends {
19614
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
19615
+ // ? Augmentation[k]["_input"]
19616
+ // : k extends keyof Input
19617
+ // ? Input[k]
19618
+ // : never;
19619
+ // }
19620
+ // >(
19621
+ // merging: Incoming
19622
+ // ): ZodObject<
19623
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
19624
+ // Incoming["_def"]["unknownKeys"],
19625
+ // Incoming["_def"]["catchall"],
19626
+ // NewOutput,
19627
+ // NewInput
19628
+ // > {
19629
+ // const merged: any = new ZodObject({
19630
+ // unknownKeys: merging._def.unknownKeys,
19631
+ // catchall: merging._def.catchall,
19632
+ // shape: () =>
19633
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
19634
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
19635
+ // }) as any;
19636
+ // return merged;
19637
+ // }
19638
+ setKey(key, schema) {
19639
+ return this.augment({ [key]: schema });
19640
+ }
19641
+ // merge<Incoming extends AnyZodObject>(
19642
+ // merging: Incoming
19643
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
19644
+ // ZodObject<
19645
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
19646
+ // Incoming["_def"]["unknownKeys"],
19647
+ // Incoming["_def"]["catchall"]
19648
+ // > {
19649
+ // // const mergedShape = objectUtil.mergeShapes(
19650
+ // // this._def.shape(),
19651
+ // // merging._def.shape()
19652
+ // // );
19653
+ // const merged: any = new ZodObject({
19654
+ // unknownKeys: merging._def.unknownKeys,
19655
+ // catchall: merging._def.catchall,
19656
+ // shape: () =>
19657
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
19658
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
19659
+ // }) as any;
19660
+ // return merged;
19661
+ // }
19662
+ catchall(index) {
19663
+ return new _ZodObject({
19664
+ ...this._def,
19665
+ catchall: index
19666
+ });
19667
+ }
19668
+ pick(mask) {
19669
+ const shape = {};
19670
+ util.objectKeys(mask).forEach((key) => {
19671
+ if (mask[key] && this.shape[key]) {
19672
+ shape[key] = this.shape[key];
19673
+ }
19674
+ });
19675
+ return new _ZodObject({
19676
+ ...this._def,
19677
+ shape: () => shape
19678
+ });
19679
+ }
19680
+ omit(mask) {
19681
+ const shape = {};
19682
+ util.objectKeys(this.shape).forEach((key) => {
19683
+ if (!mask[key]) {
19684
+ shape[key] = this.shape[key];
19685
+ }
19686
+ });
19687
+ return new _ZodObject({
19688
+ ...this._def,
19689
+ shape: () => shape
19690
+ });
19691
+ }
19692
+ /**
19693
+ * @deprecated
19694
+ */
19695
+ deepPartial() {
19696
+ return deepPartialify(this);
19697
+ }
19698
+ partial(mask) {
19699
+ const newShape = {};
19700
+ util.objectKeys(this.shape).forEach((key) => {
19701
+ const fieldSchema = this.shape[key];
19702
+ if (mask && !mask[key]) {
19703
+ newShape[key] = fieldSchema;
19704
+ } else {
19705
+ newShape[key] = fieldSchema.optional();
19706
+ }
19707
+ });
19708
+ return new _ZodObject({
19709
+ ...this._def,
19710
+ shape: () => newShape
19711
+ });
19712
+ }
19713
+ required(mask) {
19714
+ const newShape = {};
19715
+ util.objectKeys(this.shape).forEach((key) => {
19716
+ if (mask && !mask[key]) {
19717
+ newShape[key] = this.shape[key];
19718
+ } else {
19719
+ const fieldSchema = this.shape[key];
19720
+ let newField = fieldSchema;
19721
+ while (newField instanceof ZodOptional) {
19722
+ newField = newField._def.innerType;
19723
+ }
19724
+ newShape[key] = newField;
19725
+ }
19726
+ });
19727
+ return new _ZodObject({
19728
+ ...this._def,
19729
+ shape: () => newShape
19730
+ });
19731
+ }
19732
+ keyof() {
19733
+ return createZodEnum(util.objectKeys(this.shape));
19734
+ }
19735
+ };
19736
+ ZodObject.create = (shape, params) => {
19737
+ return new ZodObject({
19738
+ shape: () => shape,
19739
+ unknownKeys: "strip",
19740
+ catchall: ZodNever.create(),
19741
+ typeName: ZodFirstPartyTypeKind.ZodObject,
19742
+ ...processCreateParams(params)
19743
+ });
19744
+ };
19745
+ ZodObject.strictCreate = (shape, params) => {
19746
+ return new ZodObject({
19747
+ shape: () => shape,
19748
+ unknownKeys: "strict",
19749
+ catchall: ZodNever.create(),
19750
+ typeName: ZodFirstPartyTypeKind.ZodObject,
19751
+ ...processCreateParams(params)
19752
+ });
19753
+ };
19754
+ ZodObject.lazycreate = (shape, params) => {
19755
+ return new ZodObject({
19756
+ shape,
19757
+ unknownKeys: "strip",
19758
+ catchall: ZodNever.create(),
19759
+ typeName: ZodFirstPartyTypeKind.ZodObject,
19760
+ ...processCreateParams(params)
19761
+ });
19762
+ };
19763
+ var ZodUnion = class extends ZodType {
19764
+ _parse(input) {
19765
+ const { ctx } = this._processInputParams(input);
19766
+ const options = this._def.options;
19767
+ function handleResults(results) {
19768
+ for (const result of results) {
19769
+ if (result.result.status === "valid") {
19770
+ return result.result;
19771
+ }
19772
+ }
19773
+ for (const result of results) {
19774
+ if (result.result.status === "dirty") {
19775
+ ctx.common.issues.push(...result.ctx.common.issues);
19776
+ return result.result;
19777
+ }
19778
+ }
19779
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
19780
+ addIssueToContext(ctx, {
19781
+ code: ZodIssueCode.invalid_union,
19782
+ unionErrors
19783
+ });
19784
+ return INVALID;
19785
+ }
19786
+ if (ctx.common.async) {
19787
+ return Promise.all(options.map(async (option) => {
19788
+ const childCtx = {
19789
+ ...ctx,
19790
+ common: {
19791
+ ...ctx.common,
19792
+ issues: []
19793
+ },
19794
+ parent: null
19795
+ };
19796
+ return {
19797
+ result: await option._parseAsync({
19798
+ data: ctx.data,
19799
+ path: ctx.path,
19800
+ parent: childCtx
19801
+ }),
19802
+ ctx: childCtx
19803
+ };
19804
+ })).then(handleResults);
19805
+ } else {
19806
+ let dirty = void 0;
19807
+ const issues = [];
19808
+ for (const option of options) {
19809
+ const childCtx = {
19810
+ ...ctx,
19811
+ common: {
19812
+ ...ctx.common,
19813
+ issues: []
19814
+ },
19815
+ parent: null
19816
+ };
19817
+ const result = option._parseSync({
19818
+ data: ctx.data,
19819
+ path: ctx.path,
19820
+ parent: childCtx
19821
+ });
19822
+ if (result.status === "valid") {
19823
+ return result;
19824
+ } else if (result.status === "dirty" && !dirty) {
19825
+ dirty = { result, ctx: childCtx };
19826
+ }
19827
+ if (childCtx.common.issues.length) {
19828
+ issues.push(childCtx.common.issues);
19829
+ }
19830
+ }
19831
+ if (dirty) {
19832
+ ctx.common.issues.push(...dirty.ctx.common.issues);
19833
+ return dirty.result;
19834
+ }
19835
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
19836
+ addIssueToContext(ctx, {
19837
+ code: ZodIssueCode.invalid_union,
19838
+ unionErrors
19839
+ });
19840
+ return INVALID;
19841
+ }
19842
+ }
19843
+ get options() {
19844
+ return this._def.options;
19845
+ }
19846
+ };
19847
+ ZodUnion.create = (types, params) => {
19848
+ return new ZodUnion({
19849
+ options: types,
19850
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
19851
+ ...processCreateParams(params)
19852
+ });
19853
+ };
19854
+ var getDiscriminator = (type) => {
19855
+ if (type instanceof ZodLazy) {
19856
+ return getDiscriminator(type.schema);
19857
+ } else if (type instanceof ZodEffects) {
19858
+ return getDiscriminator(type.innerType());
19859
+ } else if (type instanceof ZodLiteral) {
19860
+ return [type.value];
19861
+ } else if (type instanceof ZodEnum) {
19862
+ return type.options;
19863
+ } else if (type instanceof ZodNativeEnum) {
19864
+ return util.objectValues(type.enum);
19865
+ } else if (type instanceof ZodDefault) {
19866
+ return getDiscriminator(type._def.innerType);
19867
+ } else if (type instanceof ZodUndefined) {
19868
+ return [void 0];
19869
+ } else if (type instanceof ZodNull) {
19870
+ return [null];
19871
+ } else if (type instanceof ZodOptional) {
19872
+ return [void 0, ...getDiscriminator(type.unwrap())];
19873
+ } else if (type instanceof ZodNullable) {
19874
+ return [null, ...getDiscriminator(type.unwrap())];
19875
+ } else if (type instanceof ZodBranded) {
19876
+ return getDiscriminator(type.unwrap());
19877
+ } else if (type instanceof ZodReadonly) {
19878
+ return getDiscriminator(type.unwrap());
19879
+ } else if (type instanceof ZodCatch) {
19880
+ return getDiscriminator(type._def.innerType);
19881
+ } else {
19882
+ return [];
19883
+ }
19884
+ };
19885
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
19886
+ _parse(input) {
19887
+ const { ctx } = this._processInputParams(input);
19888
+ if (ctx.parsedType !== ZodParsedType.object) {
19889
+ addIssueToContext(ctx, {
19890
+ code: ZodIssueCode.invalid_type,
19891
+ expected: ZodParsedType.object,
19892
+ received: ctx.parsedType
19893
+ });
19894
+ return INVALID;
19895
+ }
19896
+ const discriminator = this.discriminator;
19897
+ const discriminatorValue = ctx.data[discriminator];
19898
+ const option = this.optionsMap.get(discriminatorValue);
19899
+ if (!option) {
19900
+ addIssueToContext(ctx, {
19901
+ code: ZodIssueCode.invalid_union_discriminator,
19902
+ options: Array.from(this.optionsMap.keys()),
19903
+ path: [discriminator]
19904
+ });
19905
+ return INVALID;
19906
+ }
19907
+ if (ctx.common.async) {
19908
+ return option._parseAsync({
19909
+ data: ctx.data,
19910
+ path: ctx.path,
19911
+ parent: ctx
19912
+ });
19913
+ } else {
19914
+ return option._parseSync({
19915
+ data: ctx.data,
19916
+ path: ctx.path,
19917
+ parent: ctx
19918
+ });
19919
+ }
19920
+ }
19921
+ get discriminator() {
19922
+ return this._def.discriminator;
19923
+ }
19924
+ get options() {
19925
+ return this._def.options;
19926
+ }
19927
+ get optionsMap() {
19928
+ return this._def.optionsMap;
19929
+ }
19930
+ /**
19931
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
19932
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
19933
+ * have a different value for each object in the union.
19934
+ * @param discriminator the name of the discriminator property
19935
+ * @param types an array of object schemas
19936
+ * @param params
19937
+ */
19938
+ static create(discriminator, options, params) {
19939
+ const optionsMap = /* @__PURE__ */ new Map();
19940
+ for (const type of options) {
19941
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
19942
+ if (!discriminatorValues.length) {
19943
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
19944
+ }
19945
+ for (const value of discriminatorValues) {
19946
+ if (optionsMap.has(value)) {
19947
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
19948
+ }
19949
+ optionsMap.set(value, type);
19950
+ }
19951
+ }
19952
+ return new _ZodDiscriminatedUnion({
19953
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
19954
+ discriminator,
19955
+ options,
19956
+ optionsMap,
19957
+ ...processCreateParams(params)
19958
+ });
19959
+ }
19960
+ };
19961
+ function mergeValues(a, b) {
19962
+ const aType = getParsedType(a);
19963
+ const bType = getParsedType(b);
19964
+ if (a === b) {
19965
+ return { valid: true, data: a };
19966
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
19967
+ const bKeys = util.objectKeys(b);
19968
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
19969
+ const newObj = { ...a, ...b };
19970
+ for (const key of sharedKeys) {
19971
+ const sharedValue = mergeValues(a[key], b[key]);
19972
+ if (!sharedValue.valid) {
19973
+ return { valid: false };
19974
+ }
19975
+ newObj[key] = sharedValue.data;
19976
+ }
19977
+ return { valid: true, data: newObj };
19978
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
19979
+ if (a.length !== b.length) {
19980
+ return { valid: false };
19981
+ }
19982
+ const newArray = [];
19983
+ for (let index = 0; index < a.length; index++) {
19984
+ const itemA = a[index];
19985
+ const itemB = b[index];
19986
+ const sharedValue = mergeValues(itemA, itemB);
19987
+ if (!sharedValue.valid) {
19988
+ return { valid: false };
19989
+ }
19990
+ newArray.push(sharedValue.data);
19991
+ }
19992
+ return { valid: true, data: newArray };
19993
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
19994
+ return { valid: true, data: a };
19995
+ } else {
19996
+ return { valid: false };
19997
+ }
19998
+ }
19999
+ var ZodIntersection = class extends ZodType {
20000
+ _parse(input) {
20001
+ const { status, ctx } = this._processInputParams(input);
20002
+ const handleParsed = (parsedLeft, parsedRight) => {
20003
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
20004
+ return INVALID;
20005
+ }
20006
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
20007
+ if (!merged.valid) {
20008
+ addIssueToContext(ctx, {
20009
+ code: ZodIssueCode.invalid_intersection_types
20010
+ });
20011
+ return INVALID;
20012
+ }
20013
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
20014
+ status.dirty();
20015
+ }
20016
+ return { status: status.value, value: merged.data };
20017
+ };
20018
+ if (ctx.common.async) {
20019
+ return Promise.all([
20020
+ this._def.left._parseAsync({
20021
+ data: ctx.data,
20022
+ path: ctx.path,
20023
+ parent: ctx
20024
+ }),
20025
+ this._def.right._parseAsync({
20026
+ data: ctx.data,
20027
+ path: ctx.path,
20028
+ parent: ctx
20029
+ })
20030
+ ]).then(([left, right]) => handleParsed(left, right));
20031
+ } else {
20032
+ return handleParsed(this._def.left._parseSync({
20033
+ data: ctx.data,
20034
+ path: ctx.path,
20035
+ parent: ctx
20036
+ }), this._def.right._parseSync({
20037
+ data: ctx.data,
20038
+ path: ctx.path,
20039
+ parent: ctx
20040
+ }));
20041
+ }
20042
+ }
20043
+ };
20044
+ ZodIntersection.create = (left, right, params) => {
20045
+ return new ZodIntersection({
20046
+ left,
20047
+ right,
20048
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
20049
+ ...processCreateParams(params)
20050
+ });
20051
+ };
20052
+ var ZodTuple = class _ZodTuple extends ZodType {
20053
+ _parse(input) {
20054
+ const { status, ctx } = this._processInputParams(input);
20055
+ if (ctx.parsedType !== ZodParsedType.array) {
20056
+ addIssueToContext(ctx, {
20057
+ code: ZodIssueCode.invalid_type,
20058
+ expected: ZodParsedType.array,
20059
+ received: ctx.parsedType
20060
+ });
20061
+ return INVALID;
20062
+ }
20063
+ if (ctx.data.length < this._def.items.length) {
20064
+ addIssueToContext(ctx, {
20065
+ code: ZodIssueCode.too_small,
20066
+ minimum: this._def.items.length,
20067
+ inclusive: true,
20068
+ exact: false,
20069
+ type: "array"
20070
+ });
20071
+ return INVALID;
20072
+ }
20073
+ const rest = this._def.rest;
20074
+ if (!rest && ctx.data.length > this._def.items.length) {
20075
+ addIssueToContext(ctx, {
20076
+ code: ZodIssueCode.too_big,
20077
+ maximum: this._def.items.length,
20078
+ inclusive: true,
20079
+ exact: false,
20080
+ type: "array"
20081
+ });
20082
+ status.dirty();
20083
+ }
20084
+ const items = [...ctx.data].map((item, itemIndex) => {
20085
+ const schema = this._def.items[itemIndex] || this._def.rest;
20086
+ if (!schema)
20087
+ return null;
20088
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
20089
+ }).filter((x) => !!x);
20090
+ if (ctx.common.async) {
20091
+ return Promise.all(items).then((results) => {
20092
+ return ParseStatus.mergeArray(status, results);
20093
+ });
20094
+ } else {
20095
+ return ParseStatus.mergeArray(status, items);
20096
+ }
20097
+ }
20098
+ get items() {
20099
+ return this._def.items;
20100
+ }
20101
+ rest(rest) {
20102
+ return new _ZodTuple({
20103
+ ...this._def,
20104
+ rest
20105
+ });
20106
+ }
20107
+ };
20108
+ ZodTuple.create = (schemas, params) => {
20109
+ if (!Array.isArray(schemas)) {
20110
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
20111
+ }
20112
+ return new ZodTuple({
20113
+ items: schemas,
20114
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
20115
+ rest: null,
20116
+ ...processCreateParams(params)
20117
+ });
20118
+ };
20119
+ var ZodRecord = class _ZodRecord extends ZodType {
20120
+ get keySchema() {
20121
+ return this._def.keyType;
20122
+ }
20123
+ get valueSchema() {
20124
+ return this._def.valueType;
20125
+ }
20126
+ _parse(input) {
20127
+ const { status, ctx } = this._processInputParams(input);
20128
+ if (ctx.parsedType !== ZodParsedType.object) {
20129
+ addIssueToContext(ctx, {
20130
+ code: ZodIssueCode.invalid_type,
20131
+ expected: ZodParsedType.object,
20132
+ received: ctx.parsedType
20133
+ });
20134
+ return INVALID;
20135
+ }
20136
+ const pairs = [];
20137
+ const keyType = this._def.keyType;
20138
+ const valueType = this._def.valueType;
20139
+ for (const key in ctx.data) {
20140
+ pairs.push({
20141
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
20142
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
20143
+ alwaysSet: key in ctx.data
20144
+ });
20145
+ }
20146
+ if (ctx.common.async) {
20147
+ return ParseStatus.mergeObjectAsync(status, pairs);
20148
+ } else {
20149
+ return ParseStatus.mergeObjectSync(status, pairs);
20150
+ }
20151
+ }
20152
+ get element() {
20153
+ return this._def.valueType;
20154
+ }
20155
+ static create(first, second, third) {
20156
+ if (second instanceof ZodType) {
20157
+ return new _ZodRecord({
20158
+ keyType: first,
20159
+ valueType: second,
20160
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
20161
+ ...processCreateParams(third)
20162
+ });
20163
+ }
20164
+ return new _ZodRecord({
20165
+ keyType: ZodString.create(),
20166
+ valueType: first,
20167
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
20168
+ ...processCreateParams(second)
20169
+ });
20170
+ }
20171
+ };
20172
+ var ZodMap = class extends ZodType {
20173
+ get keySchema() {
20174
+ return this._def.keyType;
20175
+ }
20176
+ get valueSchema() {
20177
+ return this._def.valueType;
20178
+ }
20179
+ _parse(input) {
20180
+ const { status, ctx } = this._processInputParams(input);
20181
+ if (ctx.parsedType !== ZodParsedType.map) {
20182
+ addIssueToContext(ctx, {
20183
+ code: ZodIssueCode.invalid_type,
20184
+ expected: ZodParsedType.map,
20185
+ received: ctx.parsedType
20186
+ });
20187
+ return INVALID;
20188
+ }
20189
+ const keyType = this._def.keyType;
20190
+ const valueType = this._def.valueType;
20191
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
20192
+ return {
20193
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
20194
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
20195
+ };
20196
+ });
20197
+ if (ctx.common.async) {
20198
+ const finalMap = /* @__PURE__ */ new Map();
20199
+ return Promise.resolve().then(async () => {
20200
+ for (const pair of pairs) {
20201
+ const key = await pair.key;
20202
+ const value = await pair.value;
20203
+ if (key.status === "aborted" || value.status === "aborted") {
20204
+ return INVALID;
20205
+ }
20206
+ if (key.status === "dirty" || value.status === "dirty") {
20207
+ status.dirty();
20208
+ }
20209
+ finalMap.set(key.value, value.value);
20210
+ }
20211
+ return { status: status.value, value: finalMap };
20212
+ });
20213
+ } else {
20214
+ const finalMap = /* @__PURE__ */ new Map();
20215
+ for (const pair of pairs) {
20216
+ const key = pair.key;
20217
+ const value = pair.value;
20218
+ if (key.status === "aborted" || value.status === "aborted") {
20219
+ return INVALID;
20220
+ }
20221
+ if (key.status === "dirty" || value.status === "dirty") {
20222
+ status.dirty();
20223
+ }
20224
+ finalMap.set(key.value, value.value);
20225
+ }
20226
+ return { status: status.value, value: finalMap };
20227
+ }
20228
+ }
20229
+ };
20230
+ ZodMap.create = (keyType, valueType, params) => {
20231
+ return new ZodMap({
20232
+ valueType,
20233
+ keyType,
20234
+ typeName: ZodFirstPartyTypeKind.ZodMap,
20235
+ ...processCreateParams(params)
20236
+ });
20237
+ };
20238
+ var ZodSet = class _ZodSet extends ZodType {
20239
+ _parse(input) {
20240
+ const { status, ctx } = this._processInputParams(input);
20241
+ if (ctx.parsedType !== ZodParsedType.set) {
20242
+ addIssueToContext(ctx, {
20243
+ code: ZodIssueCode.invalid_type,
20244
+ expected: ZodParsedType.set,
20245
+ received: ctx.parsedType
20246
+ });
20247
+ return INVALID;
20248
+ }
20249
+ const def = this._def;
20250
+ if (def.minSize !== null) {
20251
+ if (ctx.data.size < def.minSize.value) {
20252
+ addIssueToContext(ctx, {
20253
+ code: ZodIssueCode.too_small,
20254
+ minimum: def.minSize.value,
20255
+ type: "set",
20256
+ inclusive: true,
20257
+ exact: false,
20258
+ message: def.minSize.message
20259
+ });
20260
+ status.dirty();
20261
+ }
20262
+ }
20263
+ if (def.maxSize !== null) {
20264
+ if (ctx.data.size > def.maxSize.value) {
20265
+ addIssueToContext(ctx, {
20266
+ code: ZodIssueCode.too_big,
20267
+ maximum: def.maxSize.value,
20268
+ type: "set",
20269
+ inclusive: true,
20270
+ exact: false,
20271
+ message: def.maxSize.message
20272
+ });
20273
+ status.dirty();
20274
+ }
20275
+ }
20276
+ const valueType = this._def.valueType;
20277
+ function finalizeSet(elements2) {
20278
+ const parsedSet = /* @__PURE__ */ new Set();
20279
+ for (const element of elements2) {
20280
+ if (element.status === "aborted")
20281
+ return INVALID;
20282
+ if (element.status === "dirty")
20283
+ status.dirty();
20284
+ parsedSet.add(element.value);
20285
+ }
20286
+ return { status: status.value, value: parsedSet };
20287
+ }
20288
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
20289
+ if (ctx.common.async) {
20290
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
20291
+ } else {
20292
+ return finalizeSet(elements);
20293
+ }
20294
+ }
20295
+ min(minSize, message) {
20296
+ return new _ZodSet({
20297
+ ...this._def,
20298
+ minSize: { value: minSize, message: errorUtil.toString(message) }
20299
+ });
20300
+ }
20301
+ max(maxSize, message) {
20302
+ return new _ZodSet({
20303
+ ...this._def,
20304
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
20305
+ });
20306
+ }
20307
+ size(size, message) {
20308
+ return this.min(size, message).max(size, message);
20309
+ }
20310
+ nonempty(message) {
20311
+ return this.min(1, message);
20312
+ }
20313
+ };
20314
+ ZodSet.create = (valueType, params) => {
20315
+ return new ZodSet({
20316
+ valueType,
20317
+ minSize: null,
20318
+ maxSize: null,
20319
+ typeName: ZodFirstPartyTypeKind.ZodSet,
20320
+ ...processCreateParams(params)
20321
+ });
20322
+ };
20323
+ var ZodFunction = class _ZodFunction extends ZodType {
20324
+ constructor() {
20325
+ super(...arguments);
20326
+ this.validate = this.implement;
20327
+ }
20328
+ _parse(input) {
20329
+ const { ctx } = this._processInputParams(input);
20330
+ if (ctx.parsedType !== ZodParsedType.function) {
20331
+ addIssueToContext(ctx, {
20332
+ code: ZodIssueCode.invalid_type,
20333
+ expected: ZodParsedType.function,
20334
+ received: ctx.parsedType
20335
+ });
20336
+ return INVALID;
20337
+ }
20338
+ function makeArgsIssue(args, error) {
20339
+ return makeIssue({
20340
+ data: args,
20341
+ path: ctx.path,
20342
+ errorMaps: [
20343
+ ctx.common.contextualErrorMap,
20344
+ ctx.schemaErrorMap,
20345
+ getErrorMap(),
20346
+ errorMap
20347
+ ].filter((x) => !!x),
20348
+ issueData: {
20349
+ code: ZodIssueCode.invalid_arguments,
20350
+ argumentsError: error
20351
+ }
20352
+ });
20353
+ }
20354
+ function makeReturnsIssue(returns, error) {
20355
+ return makeIssue({
20356
+ data: returns,
20357
+ path: ctx.path,
20358
+ errorMaps: [
20359
+ ctx.common.contextualErrorMap,
20360
+ ctx.schemaErrorMap,
20361
+ getErrorMap(),
20362
+ errorMap
20363
+ ].filter((x) => !!x),
20364
+ issueData: {
20365
+ code: ZodIssueCode.invalid_return_type,
20366
+ returnTypeError: error
20367
+ }
20368
+ });
20369
+ }
20370
+ const params = { errorMap: ctx.common.contextualErrorMap };
20371
+ const fn = ctx.data;
20372
+ if (this._def.returns instanceof ZodPromise) {
20373
+ const me = this;
20374
+ return OK(async function(...args) {
20375
+ const error = new ZodError([]);
20376
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
20377
+ error.addIssue(makeArgsIssue(args, e));
20378
+ throw error;
20379
+ });
20380
+ const result = await Reflect.apply(fn, this, parsedArgs);
20381
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
20382
+ error.addIssue(makeReturnsIssue(result, e));
20383
+ throw error;
20384
+ });
20385
+ return parsedReturns;
20386
+ });
20387
+ } else {
20388
+ const me = this;
20389
+ return OK(function(...args) {
20390
+ const parsedArgs = me._def.args.safeParse(args, params);
20391
+ if (!parsedArgs.success) {
20392
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
20393
+ }
20394
+ const result = Reflect.apply(fn, this, parsedArgs.data);
20395
+ const parsedReturns = me._def.returns.safeParse(result, params);
20396
+ if (!parsedReturns.success) {
20397
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
20398
+ }
20399
+ return parsedReturns.data;
20400
+ });
20401
+ }
20402
+ }
20403
+ parameters() {
20404
+ return this._def.args;
20405
+ }
20406
+ returnType() {
20407
+ return this._def.returns;
20408
+ }
20409
+ args(...items) {
20410
+ return new _ZodFunction({
20411
+ ...this._def,
20412
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
20413
+ });
20414
+ }
20415
+ returns(returnType) {
20416
+ return new _ZodFunction({
20417
+ ...this._def,
20418
+ returns: returnType
20419
+ });
20420
+ }
20421
+ implement(func) {
20422
+ const validatedFunc = this.parse(func);
20423
+ return validatedFunc;
20424
+ }
20425
+ strictImplement(func) {
20426
+ const validatedFunc = this.parse(func);
20427
+ return validatedFunc;
20428
+ }
20429
+ static create(args, returns, params) {
20430
+ return new _ZodFunction({
20431
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
20432
+ returns: returns || ZodUnknown.create(),
20433
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
20434
+ ...processCreateParams(params)
20435
+ });
20436
+ }
20437
+ };
20438
+ var ZodLazy = class extends ZodType {
20439
+ get schema() {
20440
+ return this._def.getter();
20441
+ }
20442
+ _parse(input) {
20443
+ const { ctx } = this._processInputParams(input);
20444
+ const lazySchema = this._def.getter();
20445
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
20446
+ }
20447
+ };
20448
+ ZodLazy.create = (getter, params) => {
20449
+ return new ZodLazy({
20450
+ getter,
20451
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
20452
+ ...processCreateParams(params)
20453
+ });
20454
+ };
20455
+ var ZodLiteral = class extends ZodType {
20456
+ _parse(input) {
20457
+ if (input.data !== this._def.value) {
20458
+ const ctx = this._getOrReturnCtx(input);
20459
+ addIssueToContext(ctx, {
20460
+ received: ctx.data,
20461
+ code: ZodIssueCode.invalid_literal,
20462
+ expected: this._def.value
20463
+ });
20464
+ return INVALID;
20465
+ }
20466
+ return { status: "valid", value: input.data };
20467
+ }
20468
+ get value() {
20469
+ return this._def.value;
20470
+ }
20471
+ };
20472
+ ZodLiteral.create = (value, params) => {
20473
+ return new ZodLiteral({
20474
+ value,
20475
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
20476
+ ...processCreateParams(params)
20477
+ });
20478
+ };
20479
+ function createZodEnum(values2, params) {
20480
+ return new ZodEnum({
20481
+ values: values2,
20482
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
20483
+ ...processCreateParams(params)
20484
+ });
20485
+ }
20486
+ var ZodEnum = class _ZodEnum extends ZodType {
20487
+ constructor() {
20488
+ super(...arguments);
20489
+ _ZodEnum_cache.set(this, void 0);
20490
+ }
20491
+ _parse(input) {
20492
+ if (typeof input.data !== "string") {
20493
+ const ctx = this._getOrReturnCtx(input);
20494
+ const expectedValues = this._def.values;
20495
+ addIssueToContext(ctx, {
20496
+ expected: util.joinValues(expectedValues),
20497
+ received: ctx.parsedType,
20498
+ code: ZodIssueCode.invalid_type
20499
+ });
20500
+ return INVALID;
20501
+ }
20502
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
20503
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
20504
+ }
20505
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
20506
+ const ctx = this._getOrReturnCtx(input);
20507
+ const expectedValues = this._def.values;
20508
+ addIssueToContext(ctx, {
20509
+ received: ctx.data,
20510
+ code: ZodIssueCode.invalid_enum_value,
20511
+ options: expectedValues
20512
+ });
20513
+ return INVALID;
20514
+ }
20515
+ return OK(input.data);
20516
+ }
20517
+ get options() {
20518
+ return this._def.values;
20519
+ }
20520
+ get enum() {
20521
+ const enumValues = {};
20522
+ for (const val of this._def.values) {
20523
+ enumValues[val] = val;
20524
+ }
20525
+ return enumValues;
20526
+ }
20527
+ get Values() {
20528
+ const enumValues = {};
20529
+ for (const val of this._def.values) {
20530
+ enumValues[val] = val;
20531
+ }
20532
+ return enumValues;
20533
+ }
20534
+ get Enum() {
20535
+ const enumValues = {};
20536
+ for (const val of this._def.values) {
20537
+ enumValues[val] = val;
20538
+ }
20539
+ return enumValues;
20540
+ }
20541
+ extract(values2, newDef = this._def) {
20542
+ return _ZodEnum.create(values2, {
20543
+ ...this._def,
20544
+ ...newDef
20545
+ });
20546
+ }
20547
+ exclude(values2, newDef = this._def) {
20548
+ return _ZodEnum.create(this.options.filter((opt) => !values2.includes(opt)), {
20549
+ ...this._def,
20550
+ ...newDef
20551
+ });
20552
+ }
20553
+ };
20554
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
20555
+ ZodEnum.create = createZodEnum;
20556
+ var ZodNativeEnum = class extends ZodType {
20557
+ constructor() {
20558
+ super(...arguments);
20559
+ _ZodNativeEnum_cache.set(this, void 0);
20560
+ }
20561
+ _parse(input) {
20562
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
20563
+ const ctx = this._getOrReturnCtx(input);
20564
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
20565
+ const expectedValues = util.objectValues(nativeEnumValues);
20566
+ addIssueToContext(ctx, {
20567
+ expected: util.joinValues(expectedValues),
20568
+ received: ctx.parsedType,
20569
+ code: ZodIssueCode.invalid_type
20570
+ });
20571
+ return INVALID;
20572
+ }
20573
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
20574
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
20575
+ }
20576
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
20577
+ const expectedValues = util.objectValues(nativeEnumValues);
20578
+ addIssueToContext(ctx, {
20579
+ received: ctx.data,
20580
+ code: ZodIssueCode.invalid_enum_value,
20581
+ options: expectedValues
20582
+ });
20583
+ return INVALID;
20584
+ }
20585
+ return OK(input.data);
20586
+ }
20587
+ get enum() {
20588
+ return this._def.values;
20589
+ }
20590
+ };
20591
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
20592
+ ZodNativeEnum.create = (values2, params) => {
20593
+ return new ZodNativeEnum({
20594
+ values: values2,
20595
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
20596
+ ...processCreateParams(params)
20597
+ });
20598
+ };
20599
+ var ZodPromise = class extends ZodType {
20600
+ unwrap() {
20601
+ return this._def.type;
20602
+ }
20603
+ _parse(input) {
20604
+ const { ctx } = this._processInputParams(input);
20605
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
20606
+ addIssueToContext(ctx, {
20607
+ code: ZodIssueCode.invalid_type,
20608
+ expected: ZodParsedType.promise,
20609
+ received: ctx.parsedType
20610
+ });
20611
+ return INVALID;
20612
+ }
20613
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
20614
+ return OK(promisified.then((data) => {
20615
+ return this._def.type.parseAsync(data, {
20616
+ path: ctx.path,
20617
+ errorMap: ctx.common.contextualErrorMap
20618
+ });
20619
+ }));
20620
+ }
20621
+ };
20622
+ ZodPromise.create = (schema, params) => {
20623
+ return new ZodPromise({
20624
+ type: schema,
20625
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
20626
+ ...processCreateParams(params)
20627
+ });
20628
+ };
20629
+ var ZodEffects = class extends ZodType {
20630
+ innerType() {
20631
+ return this._def.schema;
20632
+ }
20633
+ sourceType() {
20634
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
20635
+ }
20636
+ _parse(input) {
20637
+ const { status, ctx } = this._processInputParams(input);
20638
+ const effect = this._def.effect || null;
20639
+ const checkCtx = {
20640
+ addIssue: (arg) => {
20641
+ addIssueToContext(ctx, arg);
20642
+ if (arg.fatal) {
20643
+ status.abort();
20644
+ } else {
20645
+ status.dirty();
20646
+ }
20647
+ },
20648
+ get path() {
20649
+ return ctx.path;
20650
+ }
20651
+ };
20652
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
20653
+ if (effect.type === "preprocess") {
20654
+ const processed = effect.transform(ctx.data, checkCtx);
20655
+ if (ctx.common.async) {
20656
+ return Promise.resolve(processed).then(async (processed2) => {
20657
+ if (status.value === "aborted")
20658
+ return INVALID;
20659
+ const result = await this._def.schema._parseAsync({
20660
+ data: processed2,
20661
+ path: ctx.path,
20662
+ parent: ctx
20663
+ });
20664
+ if (result.status === "aborted")
20665
+ return INVALID;
20666
+ if (result.status === "dirty")
20667
+ return DIRTY(result.value);
20668
+ if (status.value === "dirty")
20669
+ return DIRTY(result.value);
20670
+ return result;
20671
+ });
20672
+ } else {
20673
+ if (status.value === "aborted")
20674
+ return INVALID;
20675
+ const result = this._def.schema._parseSync({
20676
+ data: processed,
20677
+ path: ctx.path,
20678
+ parent: ctx
20679
+ });
20680
+ if (result.status === "aborted")
20681
+ return INVALID;
20682
+ if (result.status === "dirty")
20683
+ return DIRTY(result.value);
20684
+ if (status.value === "dirty")
20685
+ return DIRTY(result.value);
20686
+ return result;
20687
+ }
20688
+ }
20689
+ if (effect.type === "refinement") {
20690
+ const executeRefinement = (acc) => {
20691
+ const result = effect.refinement(acc, checkCtx);
20692
+ if (ctx.common.async) {
20693
+ return Promise.resolve(result);
20694
+ }
20695
+ if (result instanceof Promise) {
20696
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
20697
+ }
20698
+ return acc;
20699
+ };
20700
+ if (ctx.common.async === false) {
20701
+ const inner = this._def.schema._parseSync({
20702
+ data: ctx.data,
20703
+ path: ctx.path,
20704
+ parent: ctx
20705
+ });
20706
+ if (inner.status === "aborted")
20707
+ return INVALID;
20708
+ if (inner.status === "dirty")
20709
+ status.dirty();
20710
+ executeRefinement(inner.value);
20711
+ return { status: status.value, value: inner.value };
20712
+ } else {
20713
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
20714
+ if (inner.status === "aborted")
20715
+ return INVALID;
20716
+ if (inner.status === "dirty")
20717
+ status.dirty();
20718
+ return executeRefinement(inner.value).then(() => {
20719
+ return { status: status.value, value: inner.value };
20720
+ });
20721
+ });
20722
+ }
20723
+ }
20724
+ if (effect.type === "transform") {
20725
+ if (ctx.common.async === false) {
20726
+ const base = this._def.schema._parseSync({
20727
+ data: ctx.data,
20728
+ path: ctx.path,
20729
+ parent: ctx
20730
+ });
20731
+ if (!isValid(base))
20732
+ return base;
20733
+ const result = effect.transform(base.value, checkCtx);
20734
+ if (result instanceof Promise) {
20735
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
20736
+ }
20737
+ return { status: status.value, value: result };
20738
+ } else {
20739
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
20740
+ if (!isValid(base))
20741
+ return base;
20742
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
20743
+ });
20744
+ }
20745
+ }
20746
+ util.assertNever(effect);
20747
+ }
20748
+ };
20749
+ ZodEffects.create = (schema, effect, params) => {
20750
+ return new ZodEffects({
20751
+ schema,
20752
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
20753
+ effect,
20754
+ ...processCreateParams(params)
20755
+ });
20756
+ };
20757
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
20758
+ return new ZodEffects({
20759
+ schema,
20760
+ effect: { type: "preprocess", transform: preprocess },
20761
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
20762
+ ...processCreateParams(params)
20763
+ });
20764
+ };
20765
+ var ZodOptional = class extends ZodType {
20766
+ _parse(input) {
20767
+ const parsedType = this._getType(input);
20768
+ if (parsedType === ZodParsedType.undefined) {
20769
+ return OK(void 0);
20770
+ }
20771
+ return this._def.innerType._parse(input);
20772
+ }
20773
+ unwrap() {
20774
+ return this._def.innerType;
20775
+ }
20776
+ };
20777
+ ZodOptional.create = (type, params) => {
20778
+ return new ZodOptional({
20779
+ innerType: type,
20780
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
20781
+ ...processCreateParams(params)
20782
+ });
20783
+ };
20784
+ var ZodNullable = class extends ZodType {
20785
+ _parse(input) {
20786
+ const parsedType = this._getType(input);
20787
+ if (parsedType === ZodParsedType.null) {
20788
+ return OK(null);
20789
+ }
20790
+ return this._def.innerType._parse(input);
20791
+ }
20792
+ unwrap() {
20793
+ return this._def.innerType;
20794
+ }
20795
+ };
20796
+ ZodNullable.create = (type, params) => {
20797
+ return new ZodNullable({
20798
+ innerType: type,
20799
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
20800
+ ...processCreateParams(params)
20801
+ });
20802
+ };
20803
+ var ZodDefault = class extends ZodType {
20804
+ _parse(input) {
20805
+ const { ctx } = this._processInputParams(input);
20806
+ let data = ctx.data;
20807
+ if (ctx.parsedType === ZodParsedType.undefined) {
20808
+ data = this._def.defaultValue();
20809
+ }
20810
+ return this._def.innerType._parse({
20811
+ data,
20812
+ path: ctx.path,
20813
+ parent: ctx
20814
+ });
20815
+ }
20816
+ removeDefault() {
20817
+ return this._def.innerType;
20818
+ }
20819
+ };
20820
+ ZodDefault.create = (type, params) => {
20821
+ return new ZodDefault({
20822
+ innerType: type,
20823
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
20824
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
20825
+ ...processCreateParams(params)
20826
+ });
20827
+ };
20828
+ var ZodCatch = class extends ZodType {
20829
+ _parse(input) {
20830
+ const { ctx } = this._processInputParams(input);
20831
+ const newCtx = {
20832
+ ...ctx,
20833
+ common: {
20834
+ ...ctx.common,
20835
+ issues: []
20836
+ }
20837
+ };
20838
+ const result = this._def.innerType._parse({
20839
+ data: newCtx.data,
20840
+ path: newCtx.path,
20841
+ parent: {
20842
+ ...newCtx
20843
+ }
20844
+ });
20845
+ if (isAsync(result)) {
20846
+ return result.then((result2) => {
20847
+ return {
20848
+ status: "valid",
20849
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
20850
+ get error() {
20851
+ return new ZodError(newCtx.common.issues);
20852
+ },
20853
+ input: newCtx.data
20854
+ })
20855
+ };
20856
+ });
20857
+ } else {
20858
+ return {
20859
+ status: "valid",
20860
+ value: result.status === "valid" ? result.value : this._def.catchValue({
20861
+ get error() {
20862
+ return new ZodError(newCtx.common.issues);
20863
+ },
20864
+ input: newCtx.data
20865
+ })
20866
+ };
20867
+ }
20868
+ }
20869
+ removeCatch() {
20870
+ return this._def.innerType;
20871
+ }
20872
+ };
20873
+ ZodCatch.create = (type, params) => {
20874
+ return new ZodCatch({
20875
+ innerType: type,
20876
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
20877
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
20878
+ ...processCreateParams(params)
20879
+ });
20880
+ };
20881
+ var ZodNaN = class extends ZodType {
20882
+ _parse(input) {
20883
+ const parsedType = this._getType(input);
20884
+ if (parsedType !== ZodParsedType.nan) {
20885
+ const ctx = this._getOrReturnCtx(input);
20886
+ addIssueToContext(ctx, {
20887
+ code: ZodIssueCode.invalid_type,
20888
+ expected: ZodParsedType.nan,
20889
+ received: ctx.parsedType
20890
+ });
20891
+ return INVALID;
20892
+ }
20893
+ return { status: "valid", value: input.data };
20894
+ }
20895
+ };
20896
+ ZodNaN.create = (params) => {
20897
+ return new ZodNaN({
20898
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
20899
+ ...processCreateParams(params)
20900
+ });
20901
+ };
20902
+ var BRAND = Symbol("zod_brand");
20903
+ var ZodBranded = class extends ZodType {
20904
+ _parse(input) {
20905
+ const { ctx } = this._processInputParams(input);
20906
+ const data = ctx.data;
20907
+ return this._def.type._parse({
20908
+ data,
20909
+ path: ctx.path,
20910
+ parent: ctx
20911
+ });
20912
+ }
20913
+ unwrap() {
20914
+ return this._def.type;
20915
+ }
20916
+ };
20917
+ var ZodPipeline = class _ZodPipeline extends ZodType {
20918
+ _parse(input) {
20919
+ const { status, ctx } = this._processInputParams(input);
20920
+ if (ctx.common.async) {
20921
+ const handleAsync = async () => {
20922
+ const inResult = await this._def.in._parseAsync({
20923
+ data: ctx.data,
20924
+ path: ctx.path,
20925
+ parent: ctx
20926
+ });
20927
+ if (inResult.status === "aborted")
20928
+ return INVALID;
20929
+ if (inResult.status === "dirty") {
20930
+ status.dirty();
20931
+ return DIRTY(inResult.value);
20932
+ } else {
20933
+ return this._def.out._parseAsync({
20934
+ data: inResult.value,
20935
+ path: ctx.path,
20936
+ parent: ctx
20937
+ });
20938
+ }
20939
+ };
20940
+ return handleAsync();
20941
+ } else {
20942
+ const inResult = this._def.in._parseSync({
20943
+ data: ctx.data,
20944
+ path: ctx.path,
20945
+ parent: ctx
20946
+ });
20947
+ if (inResult.status === "aborted")
20948
+ return INVALID;
20949
+ if (inResult.status === "dirty") {
20950
+ status.dirty();
20951
+ return {
20952
+ status: "dirty",
20953
+ value: inResult.value
20954
+ };
20955
+ } else {
20956
+ return this._def.out._parseSync({
20957
+ data: inResult.value,
20958
+ path: ctx.path,
20959
+ parent: ctx
20960
+ });
20961
+ }
20962
+ }
20963
+ }
20964
+ static create(a, b) {
20965
+ return new _ZodPipeline({
20966
+ in: a,
20967
+ out: b,
20968
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
20969
+ });
20970
+ }
20971
+ };
20972
+ var ZodReadonly = class extends ZodType {
20973
+ _parse(input) {
20974
+ const result = this._def.innerType._parse(input);
20975
+ const freeze = (data) => {
20976
+ if (isValid(data)) {
20977
+ data.value = Object.freeze(data.value);
20978
+ }
20979
+ return data;
20980
+ };
20981
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
20982
+ }
20983
+ unwrap() {
20984
+ return this._def.innerType;
20985
+ }
20986
+ };
20987
+ ZodReadonly.create = (type, params) => {
20988
+ return new ZodReadonly({
20989
+ innerType: type,
20990
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
20991
+ ...processCreateParams(params)
20992
+ });
20993
+ };
20994
+ function custom(check, params = {}, fatal) {
20995
+ if (check)
20996
+ return ZodAny.create().superRefine((data, ctx) => {
20997
+ var _a, _b;
20998
+ if (!check(data)) {
20999
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
21000
+ const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
21001
+ const p2 = typeof p === "string" ? { message: p } : p;
21002
+ ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
21003
+ }
21004
+ });
21005
+ return ZodAny.create();
21006
+ }
21007
+ var late = {
21008
+ object: ZodObject.lazycreate
21009
+ };
21010
+ var ZodFirstPartyTypeKind;
21011
+ (function(ZodFirstPartyTypeKind2) {
21012
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
21013
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
21014
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
21015
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
21016
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
21017
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
21018
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
21019
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
21020
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
21021
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
21022
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
21023
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
21024
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
21025
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
21026
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
21027
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
21028
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
21029
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
21030
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
21031
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
21032
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
21033
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
21034
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
21035
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
21036
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
21037
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
21038
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
21039
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
21040
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
21041
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
21042
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
21043
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
21044
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
21045
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
21046
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
21047
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
21048
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
21049
+ var instanceOfType = (cls, params = {
21050
+ message: `Input not instance of ${cls.name}`
21051
+ }) => custom((data) => data instanceof cls, params);
21052
+ var stringType = ZodString.create;
21053
+ var numberType = ZodNumber.create;
21054
+ var nanType = ZodNaN.create;
21055
+ var bigIntType = ZodBigInt.create;
21056
+ var booleanType = ZodBoolean.create;
21057
+ var dateType = ZodDate.create;
21058
+ var symbolType = ZodSymbol.create;
21059
+ var undefinedType = ZodUndefined.create;
21060
+ var nullType = ZodNull.create;
21061
+ var anyType = ZodAny.create;
21062
+ var unknownType = ZodUnknown.create;
21063
+ var neverType = ZodNever.create;
21064
+ var voidType = ZodVoid.create;
21065
+ var arrayType = ZodArray.create;
21066
+ var objectType = ZodObject.create;
21067
+ var strictObjectType = ZodObject.strictCreate;
21068
+ var unionType = ZodUnion.create;
21069
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
21070
+ var intersectionType = ZodIntersection.create;
21071
+ var tupleType = ZodTuple.create;
21072
+ var recordType = ZodRecord.create;
21073
+ var mapType = ZodMap.create;
21074
+ var setType = ZodSet.create;
21075
+ var functionType = ZodFunction.create;
21076
+ var lazyType = ZodLazy.create;
21077
+ var literalType = ZodLiteral.create;
21078
+ var enumType = ZodEnum.create;
21079
+ var nativeEnumType = ZodNativeEnum.create;
21080
+ var promiseType = ZodPromise.create;
21081
+ var effectsType = ZodEffects.create;
21082
+ var optionalType = ZodOptional.create;
21083
+ var nullableType = ZodNullable.create;
21084
+ var preprocessType = ZodEffects.createWithPreprocess;
21085
+ var pipelineType = ZodPipeline.create;
21086
+ var ostring = () => stringType().optional();
21087
+ var onumber = () => numberType().optional();
21088
+ var oboolean = () => booleanType().optional();
21089
+ var coerce = {
21090
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
21091
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
21092
+ boolean: (arg) => ZodBoolean.create({
21093
+ ...arg,
21094
+ coerce: true
21095
+ }),
21096
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
21097
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
21098
+ };
21099
+ var NEVER = INVALID;
21100
+ var z = /* @__PURE__ */ Object.freeze({
21101
+ __proto__: null,
21102
+ defaultErrorMap: errorMap,
21103
+ setErrorMap,
21104
+ getErrorMap,
21105
+ makeIssue,
21106
+ EMPTY_PATH,
21107
+ addIssueToContext,
21108
+ ParseStatus,
21109
+ INVALID,
21110
+ DIRTY,
21111
+ OK,
21112
+ isAborted,
21113
+ isDirty,
21114
+ isValid,
21115
+ isAsync,
21116
+ get util() {
21117
+ return util;
21118
+ },
21119
+ get objectUtil() {
21120
+ return objectUtil;
21121
+ },
21122
+ ZodParsedType,
21123
+ getParsedType,
21124
+ ZodType,
21125
+ datetimeRegex,
21126
+ ZodString,
21127
+ ZodNumber,
21128
+ ZodBigInt,
21129
+ ZodBoolean,
21130
+ ZodDate,
21131
+ ZodSymbol,
21132
+ ZodUndefined,
21133
+ ZodNull,
21134
+ ZodAny,
21135
+ ZodUnknown,
21136
+ ZodNever,
21137
+ ZodVoid,
21138
+ ZodArray,
21139
+ ZodObject,
21140
+ ZodUnion,
21141
+ ZodDiscriminatedUnion,
21142
+ ZodIntersection,
21143
+ ZodTuple,
21144
+ ZodRecord,
21145
+ ZodMap,
21146
+ ZodSet,
21147
+ ZodFunction,
21148
+ ZodLazy,
21149
+ ZodLiteral,
21150
+ ZodEnum,
21151
+ ZodNativeEnum,
21152
+ ZodPromise,
21153
+ ZodEffects,
21154
+ ZodTransformer: ZodEffects,
21155
+ ZodOptional,
21156
+ ZodNullable,
21157
+ ZodDefault,
21158
+ ZodCatch,
21159
+ ZodNaN,
21160
+ BRAND,
21161
+ ZodBranded,
21162
+ ZodPipeline,
21163
+ ZodReadonly,
21164
+ custom,
21165
+ Schema: ZodType,
21166
+ ZodSchema: ZodType,
21167
+ late,
21168
+ get ZodFirstPartyTypeKind() {
21169
+ return ZodFirstPartyTypeKind;
21170
+ },
21171
+ coerce,
21172
+ any: anyType,
21173
+ array: arrayType,
21174
+ bigint: bigIntType,
21175
+ boolean: booleanType,
21176
+ date: dateType,
21177
+ discriminatedUnion: discriminatedUnionType,
21178
+ effect: effectsType,
21179
+ "enum": enumType,
21180
+ "function": functionType,
21181
+ "instanceof": instanceOfType,
21182
+ intersection: intersectionType,
21183
+ lazy: lazyType,
21184
+ literal: literalType,
21185
+ map: mapType,
21186
+ nan: nanType,
21187
+ nativeEnum: nativeEnumType,
21188
+ never: neverType,
21189
+ "null": nullType,
21190
+ nullable: nullableType,
21191
+ number: numberType,
21192
+ object: objectType,
21193
+ oboolean,
21194
+ onumber,
21195
+ optional: optionalType,
21196
+ ostring,
21197
+ pipeline: pipelineType,
21198
+ preprocess: preprocessType,
21199
+ promise: promiseType,
21200
+ record: recordType,
21201
+ set: setType,
21202
+ strictObject: strictObjectType,
21203
+ string: stringType,
21204
+ symbol: symbolType,
21205
+ transformer: effectsType,
21206
+ tuple: tupleType,
21207
+ "undefined": undefinedType,
21208
+ union: unionType,
21209
+ unknown: unknownType,
21210
+ "void": voidType,
21211
+ NEVER,
21212
+ ZodIssueCode,
21213
+ quotelessJson,
21214
+ ZodError
21215
+ });
21216
+
21217
+ // ../types/src/api/web/app/rows/search.ts
21218
+ var fieldKey = z.string().refine((s) => s !== "_complexIdOperator" /* COMPLEX_ID_OPERATOR */, {
21219
+ message: `Key '${"_complexIdOperator" /* COMPLEX_ID_OPERATOR */}' is not allowed`
21220
+ });
21221
+ var stringBasicFilter = z.record(fieldKey, z.string());
21222
+ var basicFilter = z.record(fieldKey, z.any());
21223
+ var arrayFilter = z.record(fieldKey, z.union([z.any().array(), z.string()]));
21224
+ var logicFilter = z.lazy(
21225
+ () => z.object({
21226
+ conditions: z.array(z.object(queryFilterValidation))
21227
+ })
21228
+ );
21229
+ var stringOrNumber = z.union([z.string(), z.number()]);
21230
+ var queryFilterValidation = {
21231
+ ["string" /* STRING */]: stringBasicFilter.optional(),
21232
+ ["fuzzy" /* FUZZY */]: stringBasicFilter.optional(),
21233
+ ["range" /* RANGE */]: z.record(
21234
+ fieldKey,
21235
+ z.union([
21236
+ z.object({ high: stringOrNumber, low: stringOrNumber }),
21237
+ z.object({ high: stringOrNumber }),
21238
+ z.object({ low: stringOrNumber })
21239
+ ])
21240
+ ).optional(),
21241
+ ["equal" /* EQUAL */]: basicFilter.optional(),
21242
+ ["notEqual" /* NOT_EQUAL */]: basicFilter.optional(),
21243
+ ["empty" /* EMPTY */]: basicFilter.optional(),
21244
+ ["notEmpty" /* NOT_EMPTY */]: basicFilter.optional(),
21245
+ ["oneOf" /* ONE_OF */]: arrayFilter.optional(),
21246
+ ["contains" /* CONTAINS */]: arrayFilter.optional(),
21247
+ ["notContains" /* NOT_CONTAINS */]: arrayFilter.optional(),
21248
+ ["containsAny" /* CONTAINS_ANY */]: arrayFilter.optional(),
21249
+ ["$and" /* AND */]: logicFilter.optional(),
21250
+ ["$or" /* OR */]: logicFilter.optional()
21251
+ };
21252
+ var searchRowRequest = z.object({
21253
+ query: z.object({
21254
+ allOr: z.boolean().optional(),
21255
+ onEmptyFilter: z.nativeEnum(EmptyFilterOption).optional(),
21256
+ ...queryFilterValidation
21257
+ }).optional(),
21258
+ paginate: z.boolean().optional(),
21259
+ bookmark: z.union([z.string(), z.number()]).nullish(),
21260
+ limit: z.number().optional(),
21261
+ sort: z.string().nullish(),
21262
+ sortOrder: z.nativeEnum(SortOrder).optional(),
21263
+ sortType: z.nativeEnum(SortType).nullish(),
21264
+ version: z.string().optional(),
21265
+ disableEscaping: z.boolean().optional(),
21266
+ countRows: z.boolean().optional()
21267
+ });
21268
+
17279
21269
  // src/constants/ai.ts
17280
21270
  var AIOperations = {
17281
21271
  SUMMARISE_TEXT: {
@@ -17403,6 +21393,9 @@ var PROTECTED_EXTERNAL_COLUMNS = ["_id", "_rev", "tableId"];
17403
21393
  function isInternalColumnName(name) {
17404
21394
  return PROTECTED_INTERNAL_COLUMNS.includes(name);
17405
21395
  }
21396
+ function isExternalColumnName(name) {
21397
+ return PROTECTED_EXTERNAL_COLUMNS.includes(name);
21398
+ }
17406
21399
 
17407
21400
  // src/constants/colors.ts
17408
21401
  var RoleColor = /* @__PURE__ */ ((RoleColor2) => {
@@ -19067,6 +23060,7 @@ var ensureValidTheme = (theme, fallback = "darkest" /* DARKEST */) => {
19067
23060
  findDuplicateInternalColumns,
19068
23061
  getThemeClassNames,
19069
23062
  helpers,
23063
+ isExternalColumnName,
19070
23064
  isInternalColumnName,
19071
23065
  sdk,
19072
23066
  utils