@kevisual/router 0.0.26-alpha.5 → 0.0.27

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.
@@ -144,6 +144,12 @@ class $ZodAsyncError extends Error {
144
144
  super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
145
145
  }
146
146
  }
147
+ class $ZodEncodeError extends Error {
148
+ constructor(name) {
149
+ super(`Encountered unidirectional transform during encode: ${name}`);
150
+ this.name = "ZodEncodeError";
151
+ }
152
+ }
147
153
  const globalConfig = {};
148
154
  function config(newConfig) {
149
155
  return globalConfig;
@@ -221,9 +227,6 @@ function defineLazy(object, key, getter) {
221
227
  configurable: true,
222
228
  });
223
229
  }
224
- function objectClone(obj) {
225
- return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
226
- }
227
230
  function assignProp(target, prop, value) {
228
231
  Object.defineProperty(target, prop, {
229
232
  value,
@@ -244,7 +247,7 @@ function esc(str) {
244
247
  return JSON.stringify(str);
245
248
  }
246
249
  const captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
247
- function isObject(data) {
250
+ function isObject$1(data) {
248
251
  return typeof data === "object" && data !== null && !Array.isArray(data);
249
252
  }
250
253
  const allowsEval = cached(() => {
@@ -262,7 +265,7 @@ const allowsEval = cached(() => {
262
265
  }
263
266
  });
264
267
  function isPlainObject(o) {
265
- if (isObject(o) === false)
268
+ if (isObject$1(o) === false)
266
269
  return false;
267
270
  // modified constructor
268
271
  const ctor = o.constructor;
@@ -270,7 +273,7 @@ function isPlainObject(o) {
270
273
  return true;
271
274
  // modified prototype
272
275
  const prot = ctor.prototype;
273
- if (isObject(prot) === false)
276
+ if (isObject$1(prot) === false)
274
277
  return false;
275
278
  // ctor doesn't have static `isPrototypeOf`
276
279
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
@@ -281,6 +284,8 @@ function isPlainObject(o) {
281
284
  function shallowClone(o) {
282
285
  if (isPlainObject(o))
283
286
  return { ...o };
287
+ if (Array.isArray(o))
288
+ return [...o];
284
289
  return o;
285
290
  }
286
291
  const propertyKeyTypes = new Set(["string", "number", "symbol"]);
@@ -366,6 +371,11 @@ function extend(schema, shape) {
366
371
  if (!isPlainObject(shape)) {
367
372
  throw new Error("Invalid input to extend: expected a plain object");
368
373
  }
374
+ const checks = schema._zod.def.checks;
375
+ const hasChecks = checks && checks.length > 0;
376
+ if (hasChecks) {
377
+ throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
378
+ }
369
379
  const def = mergeDefs(schema._zod.def, {
370
380
  get shape() {
371
381
  const _shape = { ...schema._zod.def.shape, ...shape };
@@ -376,6 +386,21 @@ function extend(schema, shape) {
376
386
  });
377
387
  return clone(schema, def);
378
388
  }
389
+ function safeExtend(schema, shape) {
390
+ if (!isPlainObject(shape)) {
391
+ throw new Error("Invalid input to safeExtend: expected a plain object");
392
+ }
393
+ const def = {
394
+ ...schema._zod.def,
395
+ get shape() {
396
+ const _shape = { ...schema._zod.def.shape, ...shape };
397
+ assignProp(this, "shape", _shape); // self-caching
398
+ return _shape;
399
+ },
400
+ checks: schema._zod.def.checks,
401
+ };
402
+ return clone(schema, def);
403
+ }
379
404
  function merge(a, b) {
380
405
  const def = mergeDefs(a._zod.def, {
381
406
  get shape() {
@@ -466,6 +491,8 @@ function required(Class, schema, mask) {
466
491
  }
467
492
  // invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
468
493
  function aborted(x, startIndex = 0) {
494
+ if (x.aborted === true)
495
+ return true;
469
496
  for (let i = startIndex; i < x.issues.length; i++) {
470
497
  if (x.issues[i]?.continue !== true) {
471
498
  return true;
@@ -555,11 +582,7 @@ function flattenError(error, mapper = (issue) => issue.message) {
555
582
  }
556
583
  return { formErrors, fieldErrors };
557
584
  }
558
- function formatError(error, _mapper) {
559
- const mapper = _mapper ||
560
- function (issue) {
561
- return issue.message;
562
- };
585
+ function formatError(error, mapper = (issue) => issue.message) {
563
586
  const fieldErrors = { _errors: [] };
564
587
  const processError = (error) => {
565
588
  for (const issue of error.issues) {
@@ -650,6 +673,34 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
650
673
  : { success: true, data: result.value };
651
674
  };
652
675
  const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
676
+ const _encode = (_Err) => (schema, value, _ctx) => {
677
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
678
+ return _parse(_Err)(schema, value, ctx);
679
+ };
680
+ const _decode = (_Err) => (schema, value, _ctx) => {
681
+ return _parse(_Err)(schema, value, _ctx);
682
+ };
683
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
684
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
685
+ return _parseAsync(_Err)(schema, value, ctx);
686
+ };
687
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
688
+ return _parseAsync(_Err)(schema, value, _ctx);
689
+ };
690
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
691
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
692
+ return _safeParse(_Err)(schema, value, ctx);
693
+ };
694
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
695
+ return _safeParse(_Err)(schema, value, _ctx);
696
+ };
697
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
698
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
699
+ return _safeParseAsync(_Err)(schema, value, ctx);
700
+ };
701
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
702
+ return _safeParseAsync(_Err)(schema, value, _ctx);
703
+ };
653
704
 
654
705
  const cuid = /^[cC][^\s-]{8,}$/;
655
706
  const cuid2 = /^[0-9a-z]+$/;
@@ -666,7 +717,7 @@ const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9
666
717
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
667
718
  const uuid = (version) => {
668
719
  if (!version)
669
- return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
720
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
670
721
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
671
722
  };
672
723
  /** Practical email validation */
@@ -677,7 +728,7 @@ function emoji() {
677
728
  return new RegExp(_emoji$1, "u");
678
729
  }
679
730
  const ipv4 = /^(?:(?: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])$/;
680
- const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
731
+ const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
681
732
  const cidrv4 = /^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/;
682
733
  const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
683
734
  // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
@@ -721,9 +772,9 @@ const string$1 = (params) => {
721
772
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
722
773
  return new RegExp(`^${regex}$`);
723
774
  };
724
- const integer = /^\d+$/;
725
- const number$1 = /^-?\d+(?:\.\d+)?/i;
726
- const boolean$1 = /true|false/i;
775
+ const integer = /^-?\d+$/;
776
+ const number$1 = /^-?\d+(?:\.\d+)?/;
777
+ const boolean$1 = /^(?:true|false)$/i;
727
778
  // regex for string with no uppercase letters
728
779
  const lowercase = /^[^A-Z]*$/;
729
780
  // regex for string with no lowercase letters
@@ -1175,8 +1226,8 @@ class Doc {
1175
1226
 
1176
1227
  const version = {
1177
1228
  major: 4,
1178
- minor: 0,
1179
- patch: 17,
1229
+ minor: 1,
1230
+ patch: 12,
1180
1231
  };
1181
1232
 
1182
1233
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
@@ -1190,7 +1241,6 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1190
1241
  if (inst._zod.traits.has("$ZodCheck")) {
1191
1242
  checks.unshift(inst);
1192
1243
  }
1193
- //
1194
1244
  for (const ch of checks) {
1195
1245
  for (const fn of ch._zod.onattach) {
1196
1246
  fn(inst);
@@ -1247,7 +1297,47 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1247
1297
  }
1248
1298
  return payload;
1249
1299
  };
1300
+ // const handleChecksResult = (
1301
+ // checkResult: ParsePayload,
1302
+ // originalResult: ParsePayload,
1303
+ // ctx: ParseContextInternal
1304
+ // ): util.MaybeAsync<ParsePayload> => {
1305
+ // // if the checks mutated the value && there are no issues, re-parse the result
1306
+ // if (checkResult.value !== originalResult.value && !checkResult.issues.length)
1307
+ // return inst._zod.parse(checkResult, ctx);
1308
+ // return originalResult;
1309
+ // };
1310
+ const handleCanaryResult = (canary, payload, ctx) => {
1311
+ // abort if the canary is aborted
1312
+ if (aborted(canary)) {
1313
+ canary.aborted = true;
1314
+ return canary;
1315
+ }
1316
+ // run checks first, then
1317
+ const checkResult = runChecks(payload, checks, ctx);
1318
+ if (checkResult instanceof Promise) {
1319
+ if (ctx.async === false)
1320
+ throw new $ZodAsyncError();
1321
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1322
+ }
1323
+ return inst._zod.parse(checkResult, ctx);
1324
+ };
1250
1325
  inst._zod.run = (payload, ctx) => {
1326
+ if (ctx.skipChecks) {
1327
+ return inst._zod.parse(payload, ctx);
1328
+ }
1329
+ if (ctx.direction === "backward") {
1330
+ // run canary
1331
+ // initial pass (no checks)
1332
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
1333
+ if (canary instanceof Promise) {
1334
+ return canary.then((canary) => {
1335
+ return handleCanaryResult(canary, payload, ctx);
1336
+ });
1337
+ }
1338
+ return handleCanaryResult(canary, payload, ctx);
1339
+ }
1340
+ // forward
1251
1341
  const result = inst._zod.parse(payload, ctx);
1252
1342
  if (result instanceof Promise) {
1253
1343
  if (ctx.async === false)
@@ -1467,8 +1557,11 @@ const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1467
1557
  def.pattern ?? (def.pattern = cidrv6); // not used for validation
1468
1558
  $ZodStringFormat.init(inst, def);
1469
1559
  inst._zod.check = (payload) => {
1470
- const [address, prefix] = payload.value.split("/");
1560
+ const parts = payload.value.split("/");
1471
1561
  try {
1562
+ if (parts.length !== 2)
1563
+ throw new Error();
1564
+ const [address, prefix] = parts;
1472
1565
  if (!prefix)
1473
1566
  throw new Error();
1474
1567
  const prefixNum = Number(prefix);
@@ -1718,25 +1811,75 @@ function handlePropertyResult(result, final, key, input) {
1718
1811
  final.value[key] = result.value;
1719
1812
  }
1720
1813
  }
1814
+ function normalizeDef(def) {
1815
+ const keys = Object.keys(def.shape);
1816
+ for (const k of keys) {
1817
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1818
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1819
+ }
1820
+ }
1821
+ const okeys = optionalKeys(def.shape);
1822
+ return {
1823
+ ...def,
1824
+ keys,
1825
+ keySet: new Set(keys),
1826
+ numKeys: keys.length,
1827
+ optionalKeys: new Set(okeys),
1828
+ };
1829
+ }
1830
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1831
+ const unrecognized = [];
1832
+ // iterate over input keys
1833
+ const keySet = def.keySet;
1834
+ const _catchall = def.catchall._zod;
1835
+ const t = _catchall.def.type;
1836
+ for (const key of Object.keys(input)) {
1837
+ if (keySet.has(key))
1838
+ continue;
1839
+ if (t === "never") {
1840
+ unrecognized.push(key);
1841
+ continue;
1842
+ }
1843
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1844
+ if (r instanceof Promise) {
1845
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1846
+ }
1847
+ else {
1848
+ handlePropertyResult(r, payload, key, input);
1849
+ }
1850
+ }
1851
+ if (unrecognized.length) {
1852
+ payload.issues.push({
1853
+ code: "unrecognized_keys",
1854
+ keys: unrecognized,
1855
+ input,
1856
+ inst,
1857
+ });
1858
+ }
1859
+ if (!proms.length)
1860
+ return payload;
1861
+ return Promise.all(proms).then(() => {
1862
+ return payload;
1863
+ });
1864
+ }
1721
1865
  const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1722
1866
  // requires cast because technically $ZodObject doesn't extend
1723
1867
  $ZodType.init(inst, def);
1724
- const _normalized = cached(() => {
1725
- const keys = Object.keys(def.shape);
1726
- for (const k of keys) {
1727
- if (!def.shape[k]._zod.traits.has("$ZodType")) {
1728
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1729
- }
1730
- }
1731
- const okeys = optionalKeys(def.shape);
1732
- return {
1733
- shape: def.shape,
1734
- keys,
1735
- keySet: new Set(keys),
1736
- numKeys: keys.length,
1737
- optionalKeys: new Set(okeys),
1738
- };
1739
- });
1868
+ // const sh = def.shape;
1869
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
1870
+ if (!desc?.get) {
1871
+ const sh = def.shape;
1872
+ Object.defineProperty(def, "shape", {
1873
+ get: () => {
1874
+ const newSh = { ...sh };
1875
+ Object.defineProperty(def, "shape", {
1876
+ value: newSh,
1877
+ });
1878
+ return newSh;
1879
+ },
1880
+ });
1881
+ }
1882
+ const _normalized = cached(() => normalizeDef(def));
1740
1883
  defineLazy(inst._zod, "propValues", () => {
1741
1884
  const shape = def.shape;
1742
1885
  const propValues = {};
@@ -1750,6 +1893,45 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1750
1893
  }
1751
1894
  return propValues;
1752
1895
  });
1896
+ const isObject = isObject$1;
1897
+ const catchall = def.catchall;
1898
+ let value;
1899
+ inst._zod.parse = (payload, ctx) => {
1900
+ value ?? (value = _normalized.value);
1901
+ const input = payload.value;
1902
+ if (!isObject(input)) {
1903
+ payload.issues.push({
1904
+ expected: "object",
1905
+ code: "invalid_type",
1906
+ input,
1907
+ inst,
1908
+ });
1909
+ return payload;
1910
+ }
1911
+ payload.value = {};
1912
+ const proms = [];
1913
+ const shape = value.shape;
1914
+ for (const key of value.keys) {
1915
+ const el = shape[key];
1916
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1917
+ if (r instanceof Promise) {
1918
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1919
+ }
1920
+ else {
1921
+ handlePropertyResult(r, payload, key, input);
1922
+ }
1923
+ }
1924
+ if (!catchall) {
1925
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
1926
+ }
1927
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1928
+ };
1929
+ });
1930
+ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1931
+ // requires cast because technically $ZodObject doesn't extend
1932
+ $ZodObject.init(inst, def);
1933
+ const superParse = inst._zod.parse;
1934
+ const _normalized = cached(() => normalizeDef(def));
1753
1935
  const generateFastpass = (shape) => {
1754
1936
  const doc = new Doc(["shape", "payload", "ctx"]);
1755
1937
  const normalized = _normalized.value;
@@ -1764,7 +1946,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1764
1946
  ids[key] = `key_${counter++}`;
1765
1947
  }
1766
1948
  // A: preserve key order {
1767
- doc.write(`const newResult = {}`);
1949
+ doc.write(`const newResult = {};`);
1768
1950
  for (const key of normalized.keys) {
1769
1951
  const id = ids[key];
1770
1952
  const k = esc(key);
@@ -1777,6 +1959,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1777
1959
  })));
1778
1960
  }
1779
1961
 
1962
+
1780
1963
  if (${id}.value === undefined) {
1781
1964
  if (${k} in input) {
1782
1965
  newResult[${k}] = undefined;
@@ -1784,6 +1967,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1784
1967
  } else {
1785
1968
  newResult[${k}] = ${id}.value;
1786
1969
  }
1970
+
1787
1971
  `);
1788
1972
  }
1789
1973
  doc.write(`payload.value = newResult;`);
@@ -1792,7 +1976,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1792
1976
  return (payload, ctx) => fn(shape, payload, ctx);
1793
1977
  };
1794
1978
  let fastpass;
1795
- const isObject$1 = isObject;
1979
+ const isObject = isObject$1;
1796
1980
  const jit = !globalConfig.jitless;
1797
1981
  const allowsEval$1 = allowsEval;
1798
1982
  const fastEnabled = jit && allowsEval$1.value; // && !def.catchall;
@@ -1801,7 +1985,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1801
1985
  inst._zod.parse = (payload, ctx) => {
1802
1986
  value ?? (value = _normalized.value);
1803
1987
  const input = payload.value;
1804
- if (!isObject$1(input)) {
1988
+ if (!isObject(input)) {
1805
1989
  payload.issues.push({
1806
1990
  expected: "object",
1807
1991
  code: "invalid_type",
@@ -1810,63 +1994,16 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1810
1994
  });
1811
1995
  return payload;
1812
1996
  }
1813
- const proms = [];
1814
1997
  if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1815
1998
  // always synchronous
1816
1999
  if (!fastpass)
1817
2000
  fastpass = generateFastpass(def.shape);
1818
2001
  payload = fastpass(payload, ctx);
2002
+ if (!catchall)
2003
+ return payload;
2004
+ return handleCatchall([], input, payload, ctx, value, inst);
1819
2005
  }
1820
- else {
1821
- payload.value = {};
1822
- const shape = value.shape;
1823
- for (const key of value.keys) {
1824
- const el = shape[key];
1825
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1826
- if (r instanceof Promise) {
1827
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1828
- }
1829
- else {
1830
- handlePropertyResult(r, payload, key, input);
1831
- }
1832
- }
1833
- }
1834
- if (!catchall) {
1835
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
1836
- }
1837
- const unrecognized = [];
1838
- // iterate over input keys
1839
- const keySet = value.keySet;
1840
- const _catchall = catchall._zod;
1841
- const t = _catchall.def.type;
1842
- for (const key of Object.keys(input)) {
1843
- if (keySet.has(key))
1844
- continue;
1845
- if (t === "never") {
1846
- unrecognized.push(key);
1847
- continue;
1848
- }
1849
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1850
- if (r instanceof Promise) {
1851
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1852
- }
1853
- else {
1854
- handlePropertyResult(r, payload, key, input);
1855
- }
1856
- }
1857
- if (unrecognized.length) {
1858
- payload.issues.push({
1859
- code: "unrecognized_keys",
1860
- keys: unrecognized,
1861
- input,
1862
- inst,
1863
- });
1864
- }
1865
- if (!proms.length)
1866
- return payload;
1867
- return Promise.all(proms).then(() => {
1868
- return payload;
1869
- });
2006
+ return superParse(payload, ctx);
1870
2007
  };
1871
2008
  });
1872
2009
  function handleUnionResults(results, final, inst, ctx) {
@@ -2038,9 +2175,12 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2038
2175
  });
2039
2176
  const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2040
2177
  $ZodType.init(inst, def);
2041
- inst._zod.parse = (payload, _ctx) => {
2178
+ inst._zod.parse = (payload, ctx) => {
2179
+ if (ctx.direction === "backward") {
2180
+ throw new $ZodEncodeError(inst.constructor.name);
2181
+ }
2042
2182
  const _out = def.transform(payload.value, payload);
2043
- if (_ctx.async) {
2183
+ if (ctx.async) {
2044
2184
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2045
2185
  return output.then((output) => {
2046
2186
  payload.value = output;
@@ -2096,6 +2236,7 @@ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2096
2236
  return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
2097
2237
  });
2098
2238
  inst._zod.parse = (payload, ctx) => {
2239
+ // Forward direction (decode): allow null to pass through
2099
2240
  if (payload.value === null)
2100
2241
  return payload;
2101
2242
  return def.innerType._zod.run(payload, ctx);
@@ -2107,13 +2248,18 @@ const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2107
2248
  inst._zod.optin = "optional";
2108
2249
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2109
2250
  inst._zod.parse = (payload, ctx) => {
2251
+ if (ctx.direction === "backward") {
2252
+ return def.innerType._zod.run(payload, ctx);
2253
+ }
2254
+ // Forward direction (decode): apply defaults for undefined input
2110
2255
  if (payload.value === undefined) {
2111
2256
  payload.value = def.defaultValue;
2112
2257
  /**
2113
- * $ZodDefault always returns the default value immediately.
2258
+ * $ZodDefault returns the default value immediately in forward direction.
2114
2259
  * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2115
2260
  return payload;
2116
2261
  }
2262
+ // Forward direction: continue with default handling
2117
2263
  const result = def.innerType._zod.run(payload, ctx);
2118
2264
  if (result instanceof Promise) {
2119
2265
  return result.then((result) => handleDefaultResult(result, def));
@@ -2132,6 +2278,10 @@ const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2132
2278
  inst._zod.optin = "optional";
2133
2279
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2134
2280
  inst._zod.parse = (payload, ctx) => {
2281
+ if (ctx.direction === "backward") {
2282
+ return def.innerType._zod.run(payload, ctx);
2283
+ }
2284
+ // Forward direction (decode): apply prefault for undefined input
2135
2285
  if (payload.value === undefined) {
2136
2286
  payload.value = def.defaultValue;
2137
2287
  }
@@ -2169,6 +2319,10 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2169
2319
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2170
2320
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2171
2321
  inst._zod.parse = (payload, ctx) => {
2322
+ if (ctx.direction === "backward") {
2323
+ return def.innerType._zod.run(payload, ctx);
2324
+ }
2325
+ // Forward direction (decode): apply catch logic
2172
2326
  const result = def.innerType._zod.run(payload, ctx);
2173
2327
  if (result instanceof Promise) {
2174
2328
  return result.then((result) => {
@@ -2207,18 +2361,27 @@ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2207
2361
  defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2208
2362
  defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2209
2363
  inst._zod.parse = (payload, ctx) => {
2364
+ if (ctx.direction === "backward") {
2365
+ const right = def.out._zod.run(payload, ctx);
2366
+ if (right instanceof Promise) {
2367
+ return right.then((right) => handlePipeResult(right, def.in, ctx));
2368
+ }
2369
+ return handlePipeResult(right, def.in, ctx);
2370
+ }
2210
2371
  const left = def.in._zod.run(payload, ctx);
2211
2372
  if (left instanceof Promise) {
2212
- return left.then((left) => handlePipeResult(left, def, ctx));
2373
+ return left.then((left) => handlePipeResult(left, def.out, ctx));
2213
2374
  }
2214
- return handlePipeResult(left, def, ctx);
2375
+ return handlePipeResult(left, def.out, ctx);
2215
2376
  };
2216
2377
  });
2217
- function handlePipeResult(left, def, ctx) {
2378
+ function handlePipeResult(left, next, ctx) {
2218
2379
  if (left.issues.length) {
2380
+ // prevent further checks
2381
+ left.aborted = true;
2219
2382
  return left;
2220
2383
  }
2221
- return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
2384
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2222
2385
  }
2223
2386
  const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2224
2387
  $ZodType.init(inst, def);
@@ -2227,6 +2390,9 @@ const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2227
2390
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2228
2391
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2229
2392
  inst._zod.parse = (payload, ctx) => {
2393
+ if (ctx.direction === "backward") {
2394
+ return def.innerType._zod.run(payload, ctx);
2395
+ }
2230
2396
  const result = def.innerType._zod.run(payload, ctx);
2231
2397
  if (result instanceof Promise) {
2232
2398
  return result.then(handleReadonlyResult);
@@ -2272,7 +2438,7 @@ function handleRefineResult(result, payload, input, inst) {
2272
2438
 
2273
2439
  class $ZodRegistry {
2274
2440
  constructor() {
2275
- this._map = new Map();
2441
+ this._map = new WeakMap();
2276
2442
  this._idmap = new Map();
2277
2443
  }
2278
2444
  add(schema, ..._meta) {
@@ -2287,7 +2453,7 @@ class $ZodRegistry {
2287
2453
  return this;
2288
2454
  }
2289
2455
  clear() {
2290
- this._map = new Map();
2456
+ this._map = new WeakMap();
2291
2457
  this._idmap = new Map();
2292
2458
  return this;
2293
2459
  }
@@ -2765,7 +2931,7 @@ function _superRefine(fn) {
2765
2931
  _issue.code ?? (_issue.code = "custom");
2766
2932
  _issue.input ?? (_issue.input = payload.value);
2767
2933
  _issue.inst ?? (_issue.inst = ch);
2768
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2934
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort); // abort is always undefined, so this is always true...
2769
2935
  payload.issues.push(issue(_issue));
2770
2936
  }
2771
2937
  };
@@ -2861,22 +3027,29 @@ const parse = /* @__PURE__ */ _parse(ZodRealError);
2861
3027
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
2862
3028
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
2863
3029
  const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3030
+ // Codec functions
3031
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
3032
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
3033
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3034
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3035
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3036
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3037
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3038
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
2864
3039
 
2865
3040
  const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
2866
3041
  $ZodType.init(inst, def);
2867
3042
  inst.def = def;
3043
+ inst.type = def.type;
2868
3044
  Object.defineProperty(inst, "_def", { value: def });
2869
3045
  // base methods
2870
3046
  inst.check = (...checks) => {
2871
- return inst.clone({
2872
- ...def,
3047
+ return inst.clone(mergeDefs(def, {
2873
3048
  checks: [
2874
3049
  ...(def.checks ?? []),
2875
3050
  ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
2876
3051
  ],
2877
- }
2878
- // { parent: true }
2879
- );
3052
+ }));
2880
3053
  };
2881
3054
  inst.clone = (def, params) => clone(inst, def, params);
2882
3055
  inst.brand = () => inst;
@@ -2890,6 +3063,15 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
2890
3063
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
2891
3064
  inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
2892
3065
  inst.spa = inst.safeParseAsync;
3066
+ // encoding/decoding
3067
+ inst.encode = (data, params) => encode(inst, data, params);
3068
+ inst.decode = (data, params) => decode(inst, data, params);
3069
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3070
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3071
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3072
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3073
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3074
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
2893
3075
  // refinements
2894
3076
  inst.refine = (check, params) => inst.check(refine(check, params));
2895
3077
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
@@ -3171,9 +3353,11 @@ function array(element, params) {
3171
3353
  return _array(ZodArray, element, params);
3172
3354
  }
3173
3355
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
3174
- $ZodObject.init(inst, def);
3356
+ $ZodObjectJIT.init(inst, def);
3175
3357
  ZodType.init(inst, def);
3176
- defineLazy(inst, "shape", () => def.shape);
3358
+ defineLazy(inst, "shape", () => {
3359
+ return def.shape;
3360
+ });
3177
3361
  inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
3178
3362
  inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
3179
3363
  inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
@@ -3183,6 +3367,9 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
3183
3367
  inst.extend = (incoming) => {
3184
3368
  return extend(inst, incoming);
3185
3369
  };
3370
+ inst.safeExtend = (incoming) => {
3371
+ return safeExtend(inst, incoming);
3372
+ };
3186
3373
  inst.merge = (other) => merge(inst, other);
3187
3374
  inst.pick = (mask) => pick$1(inst, mask);
3188
3375
  inst.omit = (mask) => omit(inst, mask);
@@ -3192,10 +3379,7 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
3192
3379
  function object(shape, params) {
3193
3380
  const def = {
3194
3381
  type: "object",
3195
- get shape() {
3196
- assignProp(this, "shape", shape ? objectClone(shape) : {});
3197
- return this.shape;
3198
- },
3382
+ shape: shape ?? {},
3199
3383
  ...normalizeParams(params),
3200
3384
  };
3201
3385
  return new ZodObject(def);
@@ -3274,6 +3458,9 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3274
3458
  $ZodTransform.init(inst, def);
3275
3459
  ZodType.init(inst, def);
3276
3460
  inst._zod.parse = (payload, _ctx) => {
3461
+ if (_ctx.direction === "backward") {
3462
+ throw new $ZodEncodeError(inst.constructor.name);
3463
+ }
3277
3464
  payload.addIssue = (issue$1) => {
3278
3465
  if (typeof issue$1 === "string") {
3279
3466
  payload.issues.push(issue(issue$1, payload.value, def));
@@ -3479,6 +3666,1083 @@ function pick(obj, keys) {
3479
3666
  return result;
3480
3667
  }
3481
3668
 
3669
+ /** Detect free variable `global` from Node.js. */
3670
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
3671
+
3672
+ /** Detect free variable `self`. */
3673
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
3674
+
3675
+ /** Used as a reference to the global object. */
3676
+ var root = freeGlobal || freeSelf || Function('return this')();
3677
+
3678
+ /** Built-in value references. */
3679
+ var Symbol$1 = root.Symbol;
3680
+
3681
+ /** Used for built-in method references. */
3682
+ var objectProto$4 = Object.prototype;
3683
+
3684
+ /** Used to check objects for own properties. */
3685
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
3686
+
3687
+ /**
3688
+ * Used to resolve the
3689
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
3690
+ * of values.
3691
+ */
3692
+ var nativeObjectToString$1 = objectProto$4.toString;
3693
+
3694
+ /** Built-in value references. */
3695
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
3696
+
3697
+ /**
3698
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
3699
+ *
3700
+ * @private
3701
+ * @param {*} value The value to query.
3702
+ * @returns {string} Returns the raw `toStringTag`.
3703
+ */
3704
+ function getRawTag(value) {
3705
+ var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
3706
+ tag = value[symToStringTag$1];
3707
+
3708
+ try {
3709
+ value[symToStringTag$1] = undefined;
3710
+ var unmasked = true;
3711
+ } catch (e) {}
3712
+
3713
+ var result = nativeObjectToString$1.call(value);
3714
+ if (unmasked) {
3715
+ if (isOwn) {
3716
+ value[symToStringTag$1] = tag;
3717
+ } else {
3718
+ delete value[symToStringTag$1];
3719
+ }
3720
+ }
3721
+ return result;
3722
+ }
3723
+
3724
+ /** Used for built-in method references. */
3725
+ var objectProto$3 = Object.prototype;
3726
+
3727
+ /**
3728
+ * Used to resolve the
3729
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
3730
+ * of values.
3731
+ */
3732
+ var nativeObjectToString = objectProto$3.toString;
3733
+
3734
+ /**
3735
+ * Converts `value` to a string using `Object.prototype.toString`.
3736
+ *
3737
+ * @private
3738
+ * @param {*} value The value to convert.
3739
+ * @returns {string} Returns the converted string.
3740
+ */
3741
+ function objectToString(value) {
3742
+ return nativeObjectToString.call(value);
3743
+ }
3744
+
3745
+ /** `Object#toString` result references. */
3746
+ var nullTag = '[object Null]',
3747
+ undefinedTag = '[object Undefined]';
3748
+
3749
+ /** Built-in value references. */
3750
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
3751
+
3752
+ /**
3753
+ * The base implementation of `getTag` without fallbacks for buggy environments.
3754
+ *
3755
+ * @private
3756
+ * @param {*} value The value to query.
3757
+ * @returns {string} Returns the `toStringTag`.
3758
+ */
3759
+ function baseGetTag(value) {
3760
+ if (value == null) {
3761
+ return value === undefined ? undefinedTag : nullTag;
3762
+ }
3763
+ return (symToStringTag && symToStringTag in Object(value))
3764
+ ? getRawTag(value)
3765
+ : objectToString(value);
3766
+ }
3767
+
3768
+ /**
3769
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
3770
+ * and has a `typeof` result of "object".
3771
+ *
3772
+ * @static
3773
+ * @memberOf _
3774
+ * @since 4.0.0
3775
+ * @category Lang
3776
+ * @param {*} value The value to check.
3777
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3778
+ * @example
3779
+ *
3780
+ * _.isObjectLike({});
3781
+ * // => true
3782
+ *
3783
+ * _.isObjectLike([1, 2, 3]);
3784
+ * // => true
3785
+ *
3786
+ * _.isObjectLike(_.noop);
3787
+ * // => false
3788
+ *
3789
+ * _.isObjectLike(null);
3790
+ * // => false
3791
+ */
3792
+ function isObjectLike(value) {
3793
+ return value != null && typeof value == 'object';
3794
+ }
3795
+
3796
+ /** `Object#toString` result references. */
3797
+ var symbolTag = '[object Symbol]';
3798
+
3799
+ /**
3800
+ * Checks if `value` is classified as a `Symbol` primitive or object.
3801
+ *
3802
+ * @static
3803
+ * @memberOf _
3804
+ * @since 4.0.0
3805
+ * @category Lang
3806
+ * @param {*} value The value to check.
3807
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
3808
+ * @example
3809
+ *
3810
+ * _.isSymbol(Symbol.iterator);
3811
+ * // => true
3812
+ *
3813
+ * _.isSymbol('abc');
3814
+ * // => false
3815
+ */
3816
+ function isSymbol(value) {
3817
+ return typeof value == 'symbol' ||
3818
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
3819
+ }
3820
+
3821
+ /**
3822
+ * A specialized version of `_.map` for arrays without support for iteratee
3823
+ * shorthands.
3824
+ *
3825
+ * @private
3826
+ * @param {Array} [array] The array to iterate over.
3827
+ * @param {Function} iteratee The function invoked per iteration.
3828
+ * @returns {Array} Returns the new mapped array.
3829
+ */
3830
+ function arrayMap(array, iteratee) {
3831
+ var index = -1,
3832
+ length = array == null ? 0 : array.length,
3833
+ result = Array(length);
3834
+
3835
+ while (++index < length) {
3836
+ result[index] = iteratee(array[index], index, array);
3837
+ }
3838
+ return result;
3839
+ }
3840
+
3841
+ /**
3842
+ * Checks if `value` is classified as an `Array` object.
3843
+ *
3844
+ * @static
3845
+ * @memberOf _
3846
+ * @since 0.1.0
3847
+ * @category Lang
3848
+ * @param {*} value The value to check.
3849
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
3850
+ * @example
3851
+ *
3852
+ * _.isArray([1, 2, 3]);
3853
+ * // => true
3854
+ *
3855
+ * _.isArray(document.body.children);
3856
+ * // => false
3857
+ *
3858
+ * _.isArray('abc');
3859
+ * // => false
3860
+ *
3861
+ * _.isArray(_.noop);
3862
+ * // => false
3863
+ */
3864
+ var isArray = Array.isArray;
3865
+
3866
+ /** Used to convert symbols to primitives and strings. */
3867
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
3868
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
3869
+
3870
+ /**
3871
+ * The base implementation of `_.toString` which doesn't convert nullish
3872
+ * values to empty strings.
3873
+ *
3874
+ * @private
3875
+ * @param {*} value The value to process.
3876
+ * @returns {string} Returns the string.
3877
+ */
3878
+ function baseToString(value) {
3879
+ // Exit early for strings to avoid a performance hit in some environments.
3880
+ if (typeof value == 'string') {
3881
+ return value;
3882
+ }
3883
+ if (isArray(value)) {
3884
+ // Recursively convert values (susceptible to call stack limits).
3885
+ return arrayMap(value, baseToString) + '';
3886
+ }
3887
+ if (isSymbol(value)) {
3888
+ return symbolToString ? symbolToString.call(value) : '';
3889
+ }
3890
+ var result = (value + '');
3891
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
3892
+ }
3893
+
3894
+ /**
3895
+ * Checks if `value` is the
3896
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3897
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3898
+ *
3899
+ * @static
3900
+ * @memberOf _
3901
+ * @since 0.1.0
3902
+ * @category Lang
3903
+ * @param {*} value The value to check.
3904
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3905
+ * @example
3906
+ *
3907
+ * _.isObject({});
3908
+ * // => true
3909
+ *
3910
+ * _.isObject([1, 2, 3]);
3911
+ * // => true
3912
+ *
3913
+ * _.isObject(_.noop);
3914
+ * // => true
3915
+ *
3916
+ * _.isObject(null);
3917
+ * // => false
3918
+ */
3919
+ function isObject(value) {
3920
+ var type = typeof value;
3921
+ return value != null && (type == 'object' || type == 'function');
3922
+ }
3923
+
3924
+ /** `Object#toString` result references. */
3925
+ var asyncTag = '[object AsyncFunction]',
3926
+ funcTag = '[object Function]',
3927
+ genTag = '[object GeneratorFunction]',
3928
+ proxyTag = '[object Proxy]';
3929
+
3930
+ /**
3931
+ * Checks if `value` is classified as a `Function` object.
3932
+ *
3933
+ * @static
3934
+ * @memberOf _
3935
+ * @since 0.1.0
3936
+ * @category Lang
3937
+ * @param {*} value The value to check.
3938
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3939
+ * @example
3940
+ *
3941
+ * _.isFunction(_);
3942
+ * // => true
3943
+ *
3944
+ * _.isFunction(/abc/);
3945
+ * // => false
3946
+ */
3947
+ function isFunction(value) {
3948
+ if (!isObject(value)) {
3949
+ return false;
3950
+ }
3951
+ // The use of `Object#toString` avoids issues with the `typeof` operator
3952
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
3953
+ var tag = baseGetTag(value);
3954
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
3955
+ }
3956
+
3957
+ /** Used to detect overreaching core-js shims. */
3958
+ var coreJsData = root['__core-js_shared__'];
3959
+
3960
+ /** Used to detect methods masquerading as native. */
3961
+ var maskSrcKey = (function() {
3962
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
3963
+ return uid ? ('Symbol(src)_1.' + uid) : '';
3964
+ }());
3965
+
3966
+ /**
3967
+ * Checks if `func` has its source masked.
3968
+ *
3969
+ * @private
3970
+ * @param {Function} func The function to check.
3971
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
3972
+ */
3973
+ function isMasked(func) {
3974
+ return !!maskSrcKey && (maskSrcKey in func);
3975
+ }
3976
+
3977
+ /** Used for built-in method references. */
3978
+ var funcProto$1 = Function.prototype;
3979
+
3980
+ /** Used to resolve the decompiled source of functions. */
3981
+ var funcToString$1 = funcProto$1.toString;
3982
+
3983
+ /**
3984
+ * Converts `func` to its source code.
3985
+ *
3986
+ * @private
3987
+ * @param {Function} func The function to convert.
3988
+ * @returns {string} Returns the source code.
3989
+ */
3990
+ function toSource(func) {
3991
+ if (func != null) {
3992
+ try {
3993
+ return funcToString$1.call(func);
3994
+ } catch (e) {}
3995
+ try {
3996
+ return (func + '');
3997
+ } catch (e) {}
3998
+ }
3999
+ return '';
4000
+ }
4001
+
4002
+ /**
4003
+ * Used to match `RegExp`
4004
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
4005
+ */
4006
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
4007
+
4008
+ /** Used to detect host constructors (Safari). */
4009
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
4010
+
4011
+ /** Used for built-in method references. */
4012
+ var funcProto = Function.prototype,
4013
+ objectProto$2 = Object.prototype;
4014
+
4015
+ /** Used to resolve the decompiled source of functions. */
4016
+ var funcToString = funcProto.toString;
4017
+
4018
+ /** Used to check objects for own properties. */
4019
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
4020
+
4021
+ /** Used to detect if a method is native. */
4022
+ var reIsNative = RegExp('^' +
4023
+ funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
4024
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
4025
+ );
4026
+
4027
+ /**
4028
+ * The base implementation of `_.isNative` without bad shim checks.
4029
+ *
4030
+ * @private
4031
+ * @param {*} value The value to check.
4032
+ * @returns {boolean} Returns `true` if `value` is a native function,
4033
+ * else `false`.
4034
+ */
4035
+ function baseIsNative(value) {
4036
+ if (!isObject(value) || isMasked(value)) {
4037
+ return false;
4038
+ }
4039
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
4040
+ return pattern.test(toSource(value));
4041
+ }
4042
+
4043
+ /**
4044
+ * Gets the value at `key` of `object`.
4045
+ *
4046
+ * @private
4047
+ * @param {Object} [object] The object to query.
4048
+ * @param {string} key The key of the property to get.
4049
+ * @returns {*} Returns the property value.
4050
+ */
4051
+ function getValue(object, key) {
4052
+ return object == null ? undefined : object[key];
4053
+ }
4054
+
4055
+ /**
4056
+ * Gets the native function at `key` of `object`.
4057
+ *
4058
+ * @private
4059
+ * @param {Object} object The object to query.
4060
+ * @param {string} key The key of the method to get.
4061
+ * @returns {*} Returns the function if it's native, else `undefined`.
4062
+ */
4063
+ function getNative(object, key) {
4064
+ var value = getValue(object, key);
4065
+ return baseIsNative(value) ? value : undefined;
4066
+ }
4067
+
4068
+ /**
4069
+ * Performs a
4070
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
4071
+ * comparison between two values to determine if they are equivalent.
4072
+ *
4073
+ * @static
4074
+ * @memberOf _
4075
+ * @since 4.0.0
4076
+ * @category Lang
4077
+ * @param {*} value The value to compare.
4078
+ * @param {*} other The other value to compare.
4079
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
4080
+ * @example
4081
+ *
4082
+ * var object = { 'a': 1 };
4083
+ * var other = { 'a': 1 };
4084
+ *
4085
+ * _.eq(object, object);
4086
+ * // => true
4087
+ *
4088
+ * _.eq(object, other);
4089
+ * // => false
4090
+ *
4091
+ * _.eq('a', 'a');
4092
+ * // => true
4093
+ *
4094
+ * _.eq('a', Object('a'));
4095
+ * // => false
4096
+ *
4097
+ * _.eq(NaN, NaN);
4098
+ * // => true
4099
+ */
4100
+ function eq(value, other) {
4101
+ return value === other || (value !== value && other !== other);
4102
+ }
4103
+
4104
+ /** Used to match property names within property paths. */
4105
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
4106
+ reIsPlainProp = /^\w*$/;
4107
+
4108
+ /**
4109
+ * Checks if `value` is a property name and not a property path.
4110
+ *
4111
+ * @private
4112
+ * @param {*} value The value to check.
4113
+ * @param {Object} [object] The object to query keys on.
4114
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
4115
+ */
4116
+ function isKey(value, object) {
4117
+ if (isArray(value)) {
4118
+ return false;
4119
+ }
4120
+ var type = typeof value;
4121
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
4122
+ value == null || isSymbol(value)) {
4123
+ return true;
4124
+ }
4125
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
4126
+ (object != null && value in Object(object));
4127
+ }
4128
+
4129
+ /* Built-in method references that are verified to be native. */
4130
+ var nativeCreate = getNative(Object, 'create');
4131
+
4132
+ /**
4133
+ * Removes all key-value entries from the hash.
4134
+ *
4135
+ * @private
4136
+ * @name clear
4137
+ * @memberOf Hash
4138
+ */
4139
+ function hashClear() {
4140
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
4141
+ this.size = 0;
4142
+ }
4143
+
4144
+ /**
4145
+ * Removes `key` and its value from the hash.
4146
+ *
4147
+ * @private
4148
+ * @name delete
4149
+ * @memberOf Hash
4150
+ * @param {Object} hash The hash to modify.
4151
+ * @param {string} key The key of the value to remove.
4152
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
4153
+ */
4154
+ function hashDelete(key) {
4155
+ var result = this.has(key) && delete this.__data__[key];
4156
+ this.size -= result ? 1 : 0;
4157
+ return result;
4158
+ }
4159
+
4160
+ /** Used to stand-in for `undefined` hash values. */
4161
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
4162
+
4163
+ /** Used for built-in method references. */
4164
+ var objectProto$1 = Object.prototype;
4165
+
4166
+ /** Used to check objects for own properties. */
4167
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
4168
+
4169
+ /**
4170
+ * Gets the hash value for `key`.
4171
+ *
4172
+ * @private
4173
+ * @name get
4174
+ * @memberOf Hash
4175
+ * @param {string} key The key of the value to get.
4176
+ * @returns {*} Returns the entry value.
4177
+ */
4178
+ function hashGet(key) {
4179
+ var data = this.__data__;
4180
+ if (nativeCreate) {
4181
+ var result = data[key];
4182
+ return result === HASH_UNDEFINED$1 ? undefined : result;
4183
+ }
4184
+ return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
4185
+ }
4186
+
4187
+ /** Used for built-in method references. */
4188
+ var objectProto = Object.prototype;
4189
+
4190
+ /** Used to check objects for own properties. */
4191
+ var hasOwnProperty = objectProto.hasOwnProperty;
4192
+
4193
+ /**
4194
+ * Checks if a hash value for `key` exists.
4195
+ *
4196
+ * @private
4197
+ * @name has
4198
+ * @memberOf Hash
4199
+ * @param {string} key The key of the entry to check.
4200
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
4201
+ */
4202
+ function hashHas(key) {
4203
+ var data = this.__data__;
4204
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
4205
+ }
4206
+
4207
+ /** Used to stand-in for `undefined` hash values. */
4208
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
4209
+
4210
+ /**
4211
+ * Sets the hash `key` to `value`.
4212
+ *
4213
+ * @private
4214
+ * @name set
4215
+ * @memberOf Hash
4216
+ * @param {string} key The key of the value to set.
4217
+ * @param {*} value The value to set.
4218
+ * @returns {Object} Returns the hash instance.
4219
+ */
4220
+ function hashSet(key, value) {
4221
+ var data = this.__data__;
4222
+ this.size += this.has(key) ? 0 : 1;
4223
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
4224
+ return this;
4225
+ }
4226
+
4227
+ /**
4228
+ * Creates a hash object.
4229
+ *
4230
+ * @private
4231
+ * @constructor
4232
+ * @param {Array} [entries] The key-value pairs to cache.
4233
+ */
4234
+ function Hash(entries) {
4235
+ var index = -1,
4236
+ length = entries == null ? 0 : entries.length;
4237
+
4238
+ this.clear();
4239
+ while (++index < length) {
4240
+ var entry = entries[index];
4241
+ this.set(entry[0], entry[1]);
4242
+ }
4243
+ }
4244
+
4245
+ // Add methods to `Hash`.
4246
+ Hash.prototype.clear = hashClear;
4247
+ Hash.prototype['delete'] = hashDelete;
4248
+ Hash.prototype.get = hashGet;
4249
+ Hash.prototype.has = hashHas;
4250
+ Hash.prototype.set = hashSet;
4251
+
4252
+ /**
4253
+ * Removes all key-value entries from the list cache.
4254
+ *
4255
+ * @private
4256
+ * @name clear
4257
+ * @memberOf ListCache
4258
+ */
4259
+ function listCacheClear() {
4260
+ this.__data__ = [];
4261
+ this.size = 0;
4262
+ }
4263
+
4264
+ /**
4265
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
4266
+ *
4267
+ * @private
4268
+ * @param {Array} array The array to inspect.
4269
+ * @param {*} key The key to search for.
4270
+ * @returns {number} Returns the index of the matched value, else `-1`.
4271
+ */
4272
+ function assocIndexOf(array, key) {
4273
+ var length = array.length;
4274
+ while (length--) {
4275
+ if (eq(array[length][0], key)) {
4276
+ return length;
4277
+ }
4278
+ }
4279
+ return -1;
4280
+ }
4281
+
4282
+ /** Used for built-in method references. */
4283
+ var arrayProto = Array.prototype;
4284
+
4285
+ /** Built-in value references. */
4286
+ var splice = arrayProto.splice;
4287
+
4288
+ /**
4289
+ * Removes `key` and its value from the list cache.
4290
+ *
4291
+ * @private
4292
+ * @name delete
4293
+ * @memberOf ListCache
4294
+ * @param {string} key The key of the value to remove.
4295
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
4296
+ */
4297
+ function listCacheDelete(key) {
4298
+ var data = this.__data__,
4299
+ index = assocIndexOf(data, key);
4300
+
4301
+ if (index < 0) {
4302
+ return false;
4303
+ }
4304
+ var lastIndex = data.length - 1;
4305
+ if (index == lastIndex) {
4306
+ data.pop();
4307
+ } else {
4308
+ splice.call(data, index, 1);
4309
+ }
4310
+ --this.size;
4311
+ return true;
4312
+ }
4313
+
4314
+ /**
4315
+ * Gets the list cache value for `key`.
4316
+ *
4317
+ * @private
4318
+ * @name get
4319
+ * @memberOf ListCache
4320
+ * @param {string} key The key of the value to get.
4321
+ * @returns {*} Returns the entry value.
4322
+ */
4323
+ function listCacheGet(key) {
4324
+ var data = this.__data__,
4325
+ index = assocIndexOf(data, key);
4326
+
4327
+ return index < 0 ? undefined : data[index][1];
4328
+ }
4329
+
4330
+ /**
4331
+ * Checks if a list cache value for `key` exists.
4332
+ *
4333
+ * @private
4334
+ * @name has
4335
+ * @memberOf ListCache
4336
+ * @param {string} key The key of the entry to check.
4337
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
4338
+ */
4339
+ function listCacheHas(key) {
4340
+ return assocIndexOf(this.__data__, key) > -1;
4341
+ }
4342
+
4343
+ /**
4344
+ * Sets the list cache `key` to `value`.
4345
+ *
4346
+ * @private
4347
+ * @name set
4348
+ * @memberOf ListCache
4349
+ * @param {string} key The key of the value to set.
4350
+ * @param {*} value The value to set.
4351
+ * @returns {Object} Returns the list cache instance.
4352
+ */
4353
+ function listCacheSet(key, value) {
4354
+ var data = this.__data__,
4355
+ index = assocIndexOf(data, key);
4356
+
4357
+ if (index < 0) {
4358
+ ++this.size;
4359
+ data.push([key, value]);
4360
+ } else {
4361
+ data[index][1] = value;
4362
+ }
4363
+ return this;
4364
+ }
4365
+
4366
+ /**
4367
+ * Creates an list cache object.
4368
+ *
4369
+ * @private
4370
+ * @constructor
4371
+ * @param {Array} [entries] The key-value pairs to cache.
4372
+ */
4373
+ function ListCache(entries) {
4374
+ var index = -1,
4375
+ length = entries == null ? 0 : entries.length;
4376
+
4377
+ this.clear();
4378
+ while (++index < length) {
4379
+ var entry = entries[index];
4380
+ this.set(entry[0], entry[1]);
4381
+ }
4382
+ }
4383
+
4384
+ // Add methods to `ListCache`.
4385
+ ListCache.prototype.clear = listCacheClear;
4386
+ ListCache.prototype['delete'] = listCacheDelete;
4387
+ ListCache.prototype.get = listCacheGet;
4388
+ ListCache.prototype.has = listCacheHas;
4389
+ ListCache.prototype.set = listCacheSet;
4390
+
4391
+ /* Built-in method references that are verified to be native. */
4392
+ var Map$1 = getNative(root, 'Map');
4393
+
4394
+ /**
4395
+ * Removes all key-value entries from the map.
4396
+ *
4397
+ * @private
4398
+ * @name clear
4399
+ * @memberOf MapCache
4400
+ */
4401
+ function mapCacheClear() {
4402
+ this.size = 0;
4403
+ this.__data__ = {
4404
+ 'hash': new Hash,
4405
+ 'map': new (Map$1 || ListCache),
4406
+ 'string': new Hash
4407
+ };
4408
+ }
4409
+
4410
+ /**
4411
+ * Checks if `value` is suitable for use as unique object key.
4412
+ *
4413
+ * @private
4414
+ * @param {*} value The value to check.
4415
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
4416
+ */
4417
+ function isKeyable(value) {
4418
+ var type = typeof value;
4419
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
4420
+ ? (value !== '__proto__')
4421
+ : (value === null);
4422
+ }
4423
+
4424
+ /**
4425
+ * Gets the data for `map`.
4426
+ *
4427
+ * @private
4428
+ * @param {Object} map The map to query.
4429
+ * @param {string} key The reference key.
4430
+ * @returns {*} Returns the map data.
4431
+ */
4432
+ function getMapData(map, key) {
4433
+ var data = map.__data__;
4434
+ return isKeyable(key)
4435
+ ? data[typeof key == 'string' ? 'string' : 'hash']
4436
+ : data.map;
4437
+ }
4438
+
4439
+ /**
4440
+ * Removes `key` and its value from the map.
4441
+ *
4442
+ * @private
4443
+ * @name delete
4444
+ * @memberOf MapCache
4445
+ * @param {string} key The key of the value to remove.
4446
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
4447
+ */
4448
+ function mapCacheDelete(key) {
4449
+ var result = getMapData(this, key)['delete'](key);
4450
+ this.size -= result ? 1 : 0;
4451
+ return result;
4452
+ }
4453
+
4454
+ /**
4455
+ * Gets the map value for `key`.
4456
+ *
4457
+ * @private
4458
+ * @name get
4459
+ * @memberOf MapCache
4460
+ * @param {string} key The key of the value to get.
4461
+ * @returns {*} Returns the entry value.
4462
+ */
4463
+ function mapCacheGet(key) {
4464
+ return getMapData(this, key).get(key);
4465
+ }
4466
+
4467
+ /**
4468
+ * Checks if a map value for `key` exists.
4469
+ *
4470
+ * @private
4471
+ * @name has
4472
+ * @memberOf MapCache
4473
+ * @param {string} key The key of the entry to check.
4474
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
4475
+ */
4476
+ function mapCacheHas(key) {
4477
+ return getMapData(this, key).has(key);
4478
+ }
4479
+
4480
+ /**
4481
+ * Sets the map `key` to `value`.
4482
+ *
4483
+ * @private
4484
+ * @name set
4485
+ * @memberOf MapCache
4486
+ * @param {string} key The key of the value to set.
4487
+ * @param {*} value The value to set.
4488
+ * @returns {Object} Returns the map cache instance.
4489
+ */
4490
+ function mapCacheSet(key, value) {
4491
+ var data = getMapData(this, key),
4492
+ size = data.size;
4493
+
4494
+ data.set(key, value);
4495
+ this.size += data.size == size ? 0 : 1;
4496
+ return this;
4497
+ }
4498
+
4499
+ /**
4500
+ * Creates a map cache object to store key-value pairs.
4501
+ *
4502
+ * @private
4503
+ * @constructor
4504
+ * @param {Array} [entries] The key-value pairs to cache.
4505
+ */
4506
+ function MapCache(entries) {
4507
+ var index = -1,
4508
+ length = entries == null ? 0 : entries.length;
4509
+
4510
+ this.clear();
4511
+ while (++index < length) {
4512
+ var entry = entries[index];
4513
+ this.set(entry[0], entry[1]);
4514
+ }
4515
+ }
4516
+
4517
+ // Add methods to `MapCache`.
4518
+ MapCache.prototype.clear = mapCacheClear;
4519
+ MapCache.prototype['delete'] = mapCacheDelete;
4520
+ MapCache.prototype.get = mapCacheGet;
4521
+ MapCache.prototype.has = mapCacheHas;
4522
+ MapCache.prototype.set = mapCacheSet;
4523
+
4524
+ /** Error message constants. */
4525
+ var FUNC_ERROR_TEXT = 'Expected a function';
4526
+
4527
+ /**
4528
+ * Creates a function that memoizes the result of `func`. If `resolver` is
4529
+ * provided, it determines the cache key for storing the result based on the
4530
+ * arguments provided to the memoized function. By default, the first argument
4531
+ * provided to the memoized function is used as the map cache key. The `func`
4532
+ * is invoked with the `this` binding of the memoized function.
4533
+ *
4534
+ * **Note:** The cache is exposed as the `cache` property on the memoized
4535
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
4536
+ * constructor with one whose instances implement the
4537
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
4538
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
4539
+ *
4540
+ * @static
4541
+ * @memberOf _
4542
+ * @since 0.1.0
4543
+ * @category Function
4544
+ * @param {Function} func The function to have its output memoized.
4545
+ * @param {Function} [resolver] The function to resolve the cache key.
4546
+ * @returns {Function} Returns the new memoized function.
4547
+ * @example
4548
+ *
4549
+ * var object = { 'a': 1, 'b': 2 };
4550
+ * var other = { 'c': 3, 'd': 4 };
4551
+ *
4552
+ * var values = _.memoize(_.values);
4553
+ * values(object);
4554
+ * // => [1, 2]
4555
+ *
4556
+ * values(other);
4557
+ * // => [3, 4]
4558
+ *
4559
+ * object.a = 2;
4560
+ * values(object);
4561
+ * // => [1, 2]
4562
+ *
4563
+ * // Modify the result cache.
4564
+ * values.cache.set(object, ['a', 'b']);
4565
+ * values(object);
4566
+ * // => ['a', 'b']
4567
+ *
4568
+ * // Replace `_.memoize.Cache`.
4569
+ * _.memoize.Cache = WeakMap;
4570
+ */
4571
+ function memoize(func, resolver) {
4572
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
4573
+ throw new TypeError(FUNC_ERROR_TEXT);
4574
+ }
4575
+ var memoized = function() {
4576
+ var args = arguments,
4577
+ key = resolver ? resolver.apply(this, args) : args[0],
4578
+ cache = memoized.cache;
4579
+
4580
+ if (cache.has(key)) {
4581
+ return cache.get(key);
4582
+ }
4583
+ var result = func.apply(this, args);
4584
+ memoized.cache = cache.set(key, result) || cache;
4585
+ return result;
4586
+ };
4587
+ memoized.cache = new (memoize.Cache || MapCache);
4588
+ return memoized;
4589
+ }
4590
+
4591
+ // Expose `MapCache`.
4592
+ memoize.Cache = MapCache;
4593
+
4594
+ /** Used as the maximum memoize cache size. */
4595
+ var MAX_MEMOIZE_SIZE = 500;
4596
+
4597
+ /**
4598
+ * A specialized version of `_.memoize` which clears the memoized function's
4599
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
4600
+ *
4601
+ * @private
4602
+ * @param {Function} func The function to have its output memoized.
4603
+ * @returns {Function} Returns the new memoized function.
4604
+ */
4605
+ function memoizeCapped(func) {
4606
+ var result = memoize(func, function(key) {
4607
+ if (cache.size === MAX_MEMOIZE_SIZE) {
4608
+ cache.clear();
4609
+ }
4610
+ return key;
4611
+ });
4612
+
4613
+ var cache = result.cache;
4614
+ return result;
4615
+ }
4616
+
4617
+ /** Used to match property names within property paths. */
4618
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
4619
+
4620
+ /** Used to match backslashes in property paths. */
4621
+ var reEscapeChar = /\\(\\)?/g;
4622
+
4623
+ /**
4624
+ * Converts `string` to a property path array.
4625
+ *
4626
+ * @private
4627
+ * @param {string} string The string to convert.
4628
+ * @returns {Array} Returns the property path array.
4629
+ */
4630
+ var stringToPath = memoizeCapped(function(string) {
4631
+ var result = [];
4632
+ if (string.charCodeAt(0) === 46 /* . */) {
4633
+ result.push('');
4634
+ }
4635
+ string.replace(rePropName, function(match, number, quote, subString) {
4636
+ result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
4637
+ });
4638
+ return result;
4639
+ });
4640
+
4641
+ /**
4642
+ * Converts `value` to a string. An empty string is returned for `null`
4643
+ * and `undefined` values. The sign of `-0` is preserved.
4644
+ *
4645
+ * @static
4646
+ * @memberOf _
4647
+ * @since 4.0.0
4648
+ * @category Lang
4649
+ * @param {*} value The value to convert.
4650
+ * @returns {string} Returns the converted string.
4651
+ * @example
4652
+ *
4653
+ * _.toString(null);
4654
+ * // => ''
4655
+ *
4656
+ * _.toString(-0);
4657
+ * // => '-0'
4658
+ *
4659
+ * _.toString([1, 2, 3]);
4660
+ * // => '1,2,3'
4661
+ */
4662
+ function toString(value) {
4663
+ return value == null ? '' : baseToString(value);
4664
+ }
4665
+
4666
+ /**
4667
+ * Casts `value` to a path array if it's not one.
4668
+ *
4669
+ * @private
4670
+ * @param {*} value The value to inspect.
4671
+ * @param {Object} [object] The object to query keys on.
4672
+ * @returns {Array} Returns the cast property path array.
4673
+ */
4674
+ function castPath(value, object) {
4675
+ if (isArray(value)) {
4676
+ return value;
4677
+ }
4678
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
4679
+ }
4680
+
4681
+ /**
4682
+ * Converts `value` to a string key if it's not a string or symbol.
4683
+ *
4684
+ * @private
4685
+ * @param {*} value The value to inspect.
4686
+ * @returns {string|symbol} Returns the key.
4687
+ */
4688
+ function toKey(value) {
4689
+ if (typeof value == 'string' || isSymbol(value)) {
4690
+ return value;
4691
+ }
4692
+ var result = (value + '');
4693
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
4694
+ }
4695
+
4696
+ /**
4697
+ * The base implementation of `_.get` without support for default values.
4698
+ *
4699
+ * @private
4700
+ * @param {Object} object The object to query.
4701
+ * @param {Array|string} path The path of the property to get.
4702
+ * @returns {*} Returns the resolved value.
4703
+ */
4704
+ function baseGet(object, path) {
4705
+ path = castPath(path, object);
4706
+
4707
+ var index = 0,
4708
+ length = path.length;
4709
+
4710
+ while (object != null && index < length) {
4711
+ object = object[toKey(path[index++])];
4712
+ }
4713
+ return (index && index == length) ? object : undefined;
4714
+ }
4715
+
4716
+ /**
4717
+ * Gets the value at `path` of `object`. If the resolved value is
4718
+ * `undefined`, the `defaultValue` is returned in its place.
4719
+ *
4720
+ * @static
4721
+ * @memberOf _
4722
+ * @since 3.7.0
4723
+ * @category Object
4724
+ * @param {Object} object The object to query.
4725
+ * @param {Array|string} path The path of the property to get.
4726
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
4727
+ * @returns {*} Returns the resolved value.
4728
+ * @example
4729
+ *
4730
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
4731
+ *
4732
+ * _.get(object, 'a[0].b.c');
4733
+ * // => 3
4734
+ *
4735
+ * _.get(object, ['a', '0', 'b', 'c']);
4736
+ * // => 3
4737
+ *
4738
+ * _.get(object, 'a.b.c', 'default');
4739
+ * // => 'default'
4740
+ */
4741
+ function get(object, path, defaultValue) {
4742
+ var result = object == null ? undefined : baseGet(object, path);
4743
+ return result === undefined ? defaultValue : result;
4744
+ }
4745
+
3482
4746
  const pickValue = ['path', 'key', 'id', 'description', 'type', 'validator', 'middleware'];
3483
4747
  class Route {
3484
4748
  /**
@@ -3583,8 +4847,12 @@ class Route {
3583
4847
  if (schema[key]) {
3584
4848
  const result = schema[key].safeParse(value);
3585
4849
  if (!result.success) {
3586
- // TODO:
3587
- const message = 'safe error, TODO:';
4850
+ const path = result.error.errors[0]?.path?.join?.('.properties.');
4851
+ let message = 'Invalid params';
4852
+ if (path) {
4853
+ const keyS = `${key}.properties.${path}.message`;
4854
+ message = get(validator, keyS, 'Invalid params');
4855
+ }
3588
4856
  throw new CustomError(500, message);
3589
4857
  }
3590
4858
  }