@tonyclaw/llm-inspector 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/index-BIZeMR5N.js +105 -0
  3. package/.output/public/assets/index-SmtLx1lM.css +1 -0
  4. package/.output/public/assets/main-QfbQ5oBP.js +17 -0
  5. package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +1 -1
  6. package/.output/server/_libs/ajv-formats.mjs +18 -18
  7. package/.output/server/_libs/ajv.mjs +6306 -942
  8. package/.output/server/_libs/cookie-es.mjs +21 -7
  9. package/.output/server/_libs/diff.mjs +320 -0
  10. package/.output/server/_libs/floating-ui__core.mjs +17 -18
  11. package/.output/server/_libs/floating-ui__dom.mjs +20 -24
  12. package/.output/server/_libs/floating-ui__react-dom.mjs +28 -55
  13. package/.output/server/_libs/floating-ui__utils.mjs +36 -36
  14. package/.output/server/_libs/h3-v2.mjs +9 -20
  15. package/.output/server/_libs/isbot.mjs +2 -3
  16. package/.output/server/_libs/json-schema-traverse.mjs +90 -1
  17. package/.output/server/_libs/jszip.mjs +28 -28
  18. package/.output/server/_libs/lucide-react.mjs +103 -80
  19. package/.output/server/_libs/mdast-util-from-markdown.mjs +1 -1
  20. package/.output/server/_libs/pako.mjs +13 -13
  21. package/.output/server/_libs/property-information.mjs +1 -13
  22. package/.output/server/_libs/radix-ui__react-collection.mjs +1 -1
  23. package/.output/server/_libs/radix-ui__react-id.mjs +1 -1
  24. package/.output/server/_libs/react-dom.mjs +10 -10
  25. package/.output/server/_libs/react.mjs +44 -44
  26. package/.output/server/_libs/readable-stream.mjs +15 -15
  27. package/.output/server/_libs/rou3.mjs +7 -1
  28. package/.output/server/_libs/safe-buffer.mjs +3 -3
  29. package/.output/server/_libs/semver.mjs +10 -10
  30. package/.output/server/_libs/seroval-plugins.mjs +5 -5
  31. package/.output/server/_libs/seroval.mjs +596 -606
  32. package/.output/server/_libs/srvx.mjs +245 -10
  33. package/.output/server/_libs/swr.mjs +1 -1
  34. package/.output/server/_libs/tailwind-merge.mjs +41 -286
  35. package/.output/server/_libs/tanstack__history.mjs +44 -31
  36. package/.output/server/_libs/tanstack__react-router.mjs +1089 -780
  37. package/.output/server/_libs/tanstack__react-store.mjs +1 -1
  38. package/.output/server/_libs/tanstack__react-virtual.mjs +7 -82
  39. package/.output/server/_libs/tanstack__router-core.mjs +2331 -2226
  40. package/.output/server/_libs/tanstack__virtual-core.mjs +17 -58
  41. package/.output/server/_libs/tiny-invariant.mjs +12 -0
  42. package/.output/server/_libs/tiny-warning.mjs +5 -0
  43. package/.output/server/_libs/ungap__structured-clone.mjs +2 -14
  44. package/.output/server/_libs/use-sync-external-store.mjs +1 -1
  45. package/.output/server/_libs/zod.mjs +207 -505
  46. package/.output/server/_ssr/{index-XyU4WVWt.mjs → index-I_Nx8QEB.mjs} +532 -79
  47. package/.output/server/_ssr/index.mjs +776 -1098
  48. package/.output/server/_ssr/{router-BR4XO8XJ.mjs → router-BVxfVFsb.mjs} +98 -53
  49. package/.output/server/_tanstack-start-manifest_v-Cm2Owszu.mjs +4 -0
  50. package/.output/server/index.mjs +28 -28
  51. package/README.md +1 -1
  52. package/package.json +2 -1
  53. package/src/components/ProxyViewer.tsx +10 -3
  54. package/src/components/ProxyViewerContainer.tsx +6 -0
  55. package/src/components/proxy-viewer/ConversationGroup.tsx +10 -1
  56. package/src/components/proxy-viewer/LogEntry.tsx +114 -5
  57. package/src/components/proxy-viewer/diff/DiffView.tsx +319 -0
  58. package/src/components/proxy-viewer/diff/computeDiff.ts +178 -0
  59. package/src/components/proxy-viewer/diff/index.ts +3 -0
  60. package/src/components/ui/crab-logo.tsx +45 -0
  61. package/src/proxy/config.ts +3 -17
  62. package/src/proxy/dataDir.ts +56 -0
  63. package/src/proxy/formats/anthropic/stream.ts +5 -2
  64. package/src/proxy/formats/jsonSchema.ts +12 -0
  65. package/src/proxy/formats/openai/stream.ts +21 -16
  66. package/src/proxy/handler.ts +15 -5
  67. package/src/proxy/providers.ts +61 -1
  68. package/src/proxy/schemas.ts +42 -0
  69. package/src/proxy/store.ts +6 -23
  70. package/.output/public/assets/index-BFuUQkWu.js +0 -11
  71. package/.output/public/assets/index-F2ojFPJp.css +0 -1
  72. package/.output/public/assets/index-nKnhyW4Y.js +0 -122
  73. package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +0 -6
  74. package/.output/server/_tanstack-start-manifest_v-DFoSjBkb.mjs +0 -4
@@ -1,4 +1,3 @@
1
- var _a$1;
2
1
  function $constructor(name, initializer2, params) {
3
2
  function init(inst, def) {
4
3
  if (!inst._zod) {
@@ -61,8 +60,7 @@ class $ZodEncodeError extends Error {
61
60
  this.name = "ZodEncodeError";
62
61
  }
63
62
  }
64
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
65
- const globalConfig = globalThis.__zod_globalConfig;
63
+ const globalConfig = {};
66
64
  function config(newConfig) {
67
65
  return globalConfig;
68
66
  }
@@ -96,12 +94,19 @@ function cleanRegex(source) {
96
94
  return source.slice(start, end);
97
95
  }
98
96
  function floatSafeRemainder(val, step) {
99
- const ratio = val / step;
100
- const roundedRatio = Math.round(ratio);
101
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
102
- if (Math.abs(ratio - roundedRatio) < tolerance)
103
- return 0;
104
- return ratio - roundedRatio;
97
+ const valDecCount = (val.toString().split(".")[1] || "").length;
98
+ const stepString = step.toString();
99
+ let stepDecCount = (stepString.split(".")[1] || "").length;
100
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
101
+ const match = stepString.match(/\d?e-(\d?)/);
102
+ if (match?.[1]) {
103
+ stepDecCount = Number.parseInt(match[1]);
104
+ }
105
+ }
106
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
107
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
108
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
109
+ return valInt % stepInt / 10 ** decCount;
105
110
  }
106
111
  const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
107
112
  function defineLazy(object2, key, getter) {
@@ -153,10 +158,7 @@ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace
153
158
  function isObject(data) {
154
159
  return typeof data === "object" && data !== null && !Array.isArray(data);
155
160
  }
156
- const allowsEval = /* @__PURE__ */ cached(() => {
157
- if (globalConfig.jitless) {
158
- return false;
159
- }
161
+ const allowsEval = cached(() => {
160
162
  if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
161
163
  return false;
162
164
  }
@@ -189,10 +191,6 @@ function shallowClone(o) {
189
191
  return { ...o };
190
192
  if (Array.isArray(o))
191
193
  return [...o];
192
- if (o instanceof Map)
193
- return new Map(o);
194
- if (o instanceof Set)
195
- return new Set(o);
196
194
  return o;
197
195
  }
198
196
  const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
@@ -320,9 +318,6 @@ function safeExtend(schema, shape) {
320
318
  return clone(schema, def);
321
319
  }
322
320
  function merge(a, b) {
323
- if (a._zod.def.checks?.length) {
324
- throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
325
- }
326
321
  const def = mergeDefs(a._zod.def, {
327
322
  get shape() {
328
323
  const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
@@ -332,7 +327,8 @@ function merge(a, b) {
332
327
  get catchall() {
333
328
  return b._zod.def.catchall;
334
329
  },
335
- checks: b._zod.def.checks ?? []
330
+ checks: []
331
+ // delete existing checks
336
332
  });
337
333
  return clone(a, def);
338
334
  }
@@ -415,16 +411,6 @@ function aborted(x, startIndex = 0) {
415
411
  }
416
412
  return false;
417
413
  }
418
- function explicitlyAborted(x, startIndex = 0) {
419
- if (x.aborted === true)
420
- return true;
421
- for (let i = startIndex; i < x.issues.length; i++) {
422
- if (x.issues[i]?.continue === false) {
423
- return true;
424
- }
425
- }
426
- return false;
427
- }
428
414
  function prefixIssues(path, issues) {
429
415
  return issues.map((iss) => {
430
416
  var _a2;
@@ -437,14 +423,17 @@ function unwrapMessage(message) {
437
423
  return typeof message === "string" ? message : message?.message;
438
424
  }
439
425
  function finalizeIssue(iss, ctx, config2) {
440
- const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
441
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
442
- rest.path ?? (rest.path = []);
443
- rest.message = message;
444
- if (ctx?.reportInput) {
445
- rest.input = _input;
426
+ const full = { ...iss, path: iss.path ?? [] };
427
+ if (!iss.message) {
428
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
429
+ full.message = message;
430
+ }
431
+ delete full.inst;
432
+ delete full.continue;
433
+ if (!ctx?.reportInput) {
434
+ delete full.input;
446
435
  }
447
- return rest;
436
+ return full;
448
437
  }
449
438
  function getLengthableOrigin(input) {
450
439
  if (Array.isArray(input))
@@ -498,33 +487,30 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
498
487
  }
499
488
  function formatError(error, mapper = (issue2) => issue2.message) {
500
489
  const fieldErrors = { _errors: [] };
501
- const processError = (error2, path = []) => {
490
+ const processError = (error2) => {
502
491
  for (const issue2 of error2.issues) {
503
492
  if (issue2.code === "invalid_union" && issue2.errors.length) {
504
- issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
493
+ issue2.errors.map((issues) => processError({ issues }));
505
494
  } else if (issue2.code === "invalid_key") {
506
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
495
+ processError({ issues: issue2.issues });
507
496
  } else if (issue2.code === "invalid_element") {
508
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
497
+ processError({ issues: issue2.issues });
498
+ } else if (issue2.path.length === 0) {
499
+ fieldErrors._errors.push(mapper(issue2));
509
500
  } else {
510
- const fullpath = [...path, ...issue2.path];
511
- if (fullpath.length === 0) {
512
- fieldErrors._errors.push(mapper(issue2));
513
- } else {
514
- let curr = fieldErrors;
515
- let i = 0;
516
- while (i < fullpath.length) {
517
- const el = fullpath[i];
518
- const terminal = i === fullpath.length - 1;
519
- if (!terminal) {
520
- curr[el] = curr[el] || { _errors: [] };
521
- } else {
522
- curr[el] = curr[el] || { _errors: [] };
523
- curr[el]._errors.push(mapper(issue2));
524
- }
525
- curr = curr[el];
526
- i++;
501
+ let curr = fieldErrors;
502
+ let i = 0;
503
+ while (i < issue2.path.length) {
504
+ const el = issue2.path[i];
505
+ const terminal = i === issue2.path.length - 1;
506
+ if (!terminal) {
507
+ curr[el] = curr[el] || { _errors: [] };
508
+ } else {
509
+ curr[el] = curr[el] || { _errors: [] };
510
+ curr[el]._errors.push(mapper(issue2));
527
511
  }
512
+ curr = curr[el];
513
+ i++;
528
514
  }
529
515
  }
530
516
  }
@@ -533,7 +519,7 @@ function formatError(error, mapper = (issue2) => issue2.message) {
533
519
  return fieldErrors;
534
520
  }
535
521
  const _parse = (_Err) => (schema, value, _ctx, _params) => {
536
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
522
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
537
523
  const result = schema._zod.run({ value, issues: [] }, ctx);
538
524
  if (result instanceof Promise) {
539
525
  throw new $ZodAsyncError();
@@ -546,7 +532,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
546
532
  return result.value;
547
533
  };
548
534
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
549
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
535
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
550
536
  let result = schema._zod.run({ value, issues: [] }, ctx);
551
537
  if (result instanceof Promise)
552
538
  result = await result;
@@ -570,7 +556,7 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
570
556
  };
571
557
  const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
572
558
  const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
573
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
559
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
574
560
  let result = schema._zod.run({ value, issues: [] }, ctx);
575
561
  if (result instanceof Promise)
576
562
  result = await result;
@@ -581,34 +567,34 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
581
567
  };
582
568
  const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
583
569
  const _encode = (_Err) => (schema, value, _ctx) => {
584
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
570
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
585
571
  return _parse(_Err)(schema, value, ctx);
586
572
  };
587
573
  const _decode = (_Err) => (schema, value, _ctx) => {
588
574
  return _parse(_Err)(schema, value, _ctx);
589
575
  };
590
576
  const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
591
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
577
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
592
578
  return _parseAsync(_Err)(schema, value, ctx);
593
579
  };
594
580
  const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
595
581
  return _parseAsync(_Err)(schema, value, _ctx);
596
582
  };
597
583
  const _safeEncode = (_Err) => (schema, value, _ctx) => {
598
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
584
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
599
585
  return _safeParse(_Err)(schema, value, ctx);
600
586
  };
601
587
  const _safeDecode = (_Err) => (schema, value, _ctx) => {
602
588
  return _safeParse(_Err)(schema, value, _ctx);
603
589
  };
604
590
  const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
605
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
591
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
606
592
  return _safeParseAsync(_Err)(schema, value, ctx);
607
593
  };
608
594
  const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
609
595
  return _safeParseAsync(_Err)(schema, value, _ctx);
610
596
  };
611
- const cuid = /^[cC][0-9a-z]{6,}$/;
597
+ const cuid = /^[cC][^\s-]{8,}$/;
612
598
  const cuid2 = /^[0-9a-z]+$/;
613
599
  const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
614
600
  const xid = /^[0-9a-vA-V]{20}$/;
@@ -632,7 +618,6 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
632
618
  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])$/;
633
619
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
634
620
  const base64url = /^[A-Za-z0-9_-]*$/;
635
- const httpProtocol = /^https?$/;
636
621
  const e164 = /^\+[1-9]\d{6,14}$/;
637
622
  const dateSource = `(?:(?:\\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])))`;
638
623
  const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
@@ -1088,8 +1073,8 @@ class Doc {
1088
1073
  }
1089
1074
  const version = {
1090
1075
  major: 4,
1091
- minor: 4,
1092
- patch: 3
1076
+ minor: 3,
1077
+ patch: 6
1093
1078
  };
1094
1079
  const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1095
1080
  var _a2;
@@ -1117,8 +1102,6 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1117
1102
  let asyncResult;
1118
1103
  for (const ch of checks2) {
1119
1104
  if (ch._zod.def.when) {
1120
- if (explicitlyAborted(payload))
1121
- continue;
1122
1105
  const shouldRun = ch._zod.def.when(payload);
1123
1106
  if (!shouldRun)
1124
1107
  continue;
@@ -1259,19 +1242,6 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1259
1242
  inst._zod.check = (payload) => {
1260
1243
  try {
1261
1244
  const trimmed = payload.value.trim();
1262
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1263
- if (!/^https?:\/\//i.test(trimmed)) {
1264
- payload.issues.push({
1265
- code: "invalid_format",
1266
- format: "url",
1267
- note: "Invalid URL format",
1268
- input: payload.value,
1269
- inst,
1270
- continue: !def.abort
1271
- });
1272
- return;
1273
- }
1274
- }
1275
1245
  const url = new URL(trimmed);
1276
1246
  if (def.hostname) {
1277
1247
  def.hostname.lastIndex = 0;
@@ -1420,8 +1390,6 @@ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1420
1390
  function isValidBase64(data) {
1421
1391
  if (data === "")
1422
1392
  return true;
1423
- if (/\s/.test(data))
1424
- return false;
1425
1393
  if (data.length % 4 !== 0)
1426
1394
  return false;
1427
1395
  try {
@@ -1629,27 +1597,15 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1629
1597
  return payload;
1630
1598
  };
1631
1599
  });
1632
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1633
- const isPresent = key in input;
1600
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1634
1601
  if (result.issues.length) {
1635
- if (isOptionalIn && isOptionalOut && !isPresent) {
1602
+ if (isOptionalOut && !(key in input)) {
1636
1603
  return;
1637
1604
  }
1638
1605
  final.issues.push(...prefixIssues(key, result.issues));
1639
1606
  }
1640
- if (!isPresent && !isOptionalIn) {
1641
- if (!result.issues.length) {
1642
- final.issues.push({
1643
- code: "invalid_type",
1644
- expected: "nonoptional",
1645
- input: void 0,
1646
- path: [key]
1647
- });
1648
- }
1649
- return;
1650
- }
1651
1607
  if (result.value === void 0) {
1652
- if (isPresent) {
1608
+ if (key in input) {
1653
1609
  final.value[key] = void 0;
1654
1610
  }
1655
1611
  } else {
@@ -1677,11 +1633,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1677
1633
  const keySet = def.keySet;
1678
1634
  const _catchall = def.catchall._zod;
1679
1635
  const t = _catchall.def.type;
1680
- const isOptionalIn = _catchall.optin === "optional";
1681
1636
  const isOptionalOut = _catchall.optout === "optional";
1682
1637
  for (const key in input) {
1683
- if (key === "__proto__")
1684
- continue;
1685
1638
  if (keySet.has(key))
1686
1639
  continue;
1687
1640
  if (t === "never") {
@@ -1690,9 +1643,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1690
1643
  }
1691
1644
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1692
1645
  if (r instanceof Promise) {
1693
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
1646
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1694
1647
  } else {
1695
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1648
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1696
1649
  }
1697
1650
  }
1698
1651
  if (unrecognized.length) {
@@ -1758,13 +1711,12 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1758
1711
  const shape = value.shape;
1759
1712
  for (const key of value.keys) {
1760
1713
  const el = shape[key];
1761
- const isOptionalIn = el._zod.optin === "optional";
1762
1714
  const isOptionalOut = el._zod.optout === "optional";
1763
1715
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1764
1716
  if (r instanceof Promise) {
1765
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
1717
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1766
1718
  } else {
1767
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1719
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1768
1720
  }
1769
1721
  }
1770
1722
  if (!catchall) {
@@ -1795,10 +1747,9 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
1795
1747
  const id = ids[key];
1796
1748
  const k = esc(key);
1797
1749
  const schema = shape[key];
1798
- const isOptionalIn = schema?._zod?.optin === "optional";
1799
1750
  const isOptionalOut = schema?._zod?.optout === "optional";
1800
1751
  doc.write(`const ${id} = ${parseStr(key)};`);
1801
- if (isOptionalIn && isOptionalOut) {
1752
+ if (isOptionalOut) {
1802
1753
  doc.write(`
1803
1754
  if (${id}.issues.length) {
1804
1755
  if (${k} in input) {
@@ -1817,33 +1768,6 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
1817
1768
  newResult[${k}] = ${id}.value;
1818
1769
  }
1819
1770
 
1820
- `);
1821
- } else if (!isOptionalIn) {
1822
- doc.write(`
1823
- const ${id}_present = ${k} in input;
1824
- if (${id}.issues.length) {
1825
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1826
- ...iss,
1827
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1828
- })));
1829
- }
1830
- if (!${id}_present && !${id}.issues.length) {
1831
- payload.issues.push({
1832
- code: "invalid_type",
1833
- expected: "nonoptional",
1834
- input: undefined,
1835
- path: [${k}]
1836
- });
1837
- }
1838
-
1839
- if (${id}_present) {
1840
- if (${id}.value === undefined) {
1841
- newResult[${k}] = undefined;
1842
- } else {
1843
- newResult[${k}] = ${id}.value;
1844
- }
1845
- }
1846
-
1847
1771
  `);
1848
1772
  } else {
1849
1773
  doc.write(`
@@ -1937,9 +1861,10 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1937
1861
  }
1938
1862
  return void 0;
1939
1863
  });
1940
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1864
+ const single = def.options.length === 1;
1865
+ const first = def.options[0]._zod.run;
1941
1866
  inst._zod.parse = (payload, ctx) => {
1942
- if (first) {
1867
+ if (single) {
1943
1868
  return first(payload, ctx);
1944
1869
  }
1945
1870
  let async = false;
@@ -2016,7 +1941,7 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
2016
1941
  if (opt) {
2017
1942
  return opt._zod.run(payload, ctx);
2018
1943
  }
2019
- if (def.unionFallback || ctx.direction === "backward") {
1944
+ if (def.unionFallback) {
2020
1945
  return _super(payload, ctx);
2021
1946
  }
2022
1947
  payload.issues.push({
@@ -2024,7 +1949,6 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
2024
1949
  errors: [],
2025
1950
  note: "No matching discriminator",
2026
1951
  discriminator: def.discriminator,
2027
- options: Array.from(disc.value.keys()),
2028
1952
  input,
2029
1953
  path: [def.discriminator],
2030
1954
  inst
@@ -2151,35 +2075,19 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2151
2075
  for (const key of values) {
2152
2076
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2153
2077
  recordKeys.add(typeof key === "number" ? key.toString() : key);
2154
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2155
- if (keyResult instanceof Promise) {
2156
- throw new Error("Async schemas not supported in object keys currently");
2157
- }
2158
- if (keyResult.issues.length) {
2159
- payload.issues.push({
2160
- code: "invalid_key",
2161
- origin: "record",
2162
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2163
- input: key,
2164
- path: [key],
2165
- inst
2166
- });
2167
- continue;
2168
- }
2169
- const outKey = keyResult.value;
2170
2078
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2171
2079
  if (result instanceof Promise) {
2172
2080
  proms.push(result.then((result2) => {
2173
2081
  if (result2.issues.length) {
2174
2082
  payload.issues.push(...prefixIssues(key, result2.issues));
2175
2083
  }
2176
- payload.value[outKey] = result2.value;
2084
+ payload.value[key] = result2.value;
2177
2085
  }));
2178
2086
  } else {
2179
2087
  if (result.issues.length) {
2180
2088
  payload.issues.push(...prefixIssues(key, result.issues));
2181
2089
  }
2182
- payload.value[outKey] = result.value;
2090
+ payload.value[key] = result.value;
2183
2091
  }
2184
2092
  }
2185
2093
  }
@@ -2203,8 +2111,6 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2203
2111
  for (const key of Reflect.ownKeys(input)) {
2204
2112
  if (key === "__proto__")
2205
2113
  continue;
2206
- if (!Object.prototype.propertyIsEnumerable.call(input, key))
2207
- continue;
2208
2114
  let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2209
2115
  if (keyResult instanceof Promise) {
2210
2116
  throw new Error("Async schemas not supported in object keys currently");
@@ -2300,7 +2206,6 @@ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
2300
2206
  });
2301
2207
  const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2302
2208
  $ZodType.init(inst, def);
2303
- inst._zod.optin = "optional";
2304
2209
  inst._zod.parse = (payload, ctx) => {
2305
2210
  if (ctx.direction === "backward") {
2306
2211
  throw new $ZodEncodeError(inst.constructor.name);
@@ -2310,7 +2215,6 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
2310
2215
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2311
2216
  return output.then((output2) => {
2312
2217
  payload.value = output2;
2313
- payload.fallback = true;
2314
2218
  return payload;
2315
2219
  });
2316
2220
  }
@@ -2318,12 +2222,11 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
2318
2222
  throw new $ZodAsyncError();
2319
2223
  }
2320
2224
  payload.value = _out;
2321
- payload.fallback = true;
2322
2225
  return payload;
2323
2226
  };
2324
2227
  });
2325
2228
  function handleOptionalResult(result, input) {
2326
- if (input === void 0 && (result.issues.length || result.fallback)) {
2229
+ if (result.issues.length && input === void 0) {
2327
2230
  return { issues: [], value: void 0 };
2328
2231
  }
2329
2232
  return result;
@@ -2341,11 +2244,10 @@ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) =>
2341
2244
  });
2342
2245
  inst._zod.parse = (payload, ctx) => {
2343
2246
  if (def.innerType._zod.optin === "optional") {
2344
- const input = payload.value;
2345
2247
  const result = def.innerType._zod.run(payload, ctx);
2346
2248
  if (result instanceof Promise)
2347
- return result.then((r) => handleOptionalResult(r, input));
2348
- return handleOptionalResult(result, input);
2249
+ return result.then((r) => handleOptionalResult(r, payload.value));
2250
+ return handleOptionalResult(result, payload.value);
2349
2251
  }
2350
2252
  if (payload.value === void 0) {
2351
2253
  return payload;
@@ -2444,7 +2346,7 @@ function handleNonOptionalResult(payload, inst) {
2444
2346
  }
2445
2347
  const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2446
2348
  $ZodType.init(inst, def);
2447
- inst._zod.optin = "optional";
2349
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2448
2350
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2449
2351
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2450
2352
  inst._zod.parse = (payload, ctx) => {
@@ -2464,7 +2366,6 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2464
2366
  input: payload.value
2465
2367
  });
2466
2368
  payload.issues = [];
2467
- payload.fallback = true;
2468
2369
  }
2469
2370
  return payload;
2470
2371
  });
@@ -2479,7 +2380,6 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2479
2380
  input: payload.value
2480
2381
  });
2481
2382
  payload.issues = [];
2482
- payload.fallback = true;
2483
2383
  }
2484
2384
  return payload;
2485
2385
  };
@@ -2510,7 +2410,7 @@ function handlePipeResult(left, next, ctx) {
2510
2410
  left.aborted = true;
2511
2411
  return left;
2512
2412
  }
2513
- return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
2413
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2514
2414
  }
2515
2415
  const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2516
2416
  $ZodType.init(inst, def);
@@ -2535,12 +2435,7 @@ function handleReadonlyResult(payload) {
2535
2435
  }
2536
2436
  const $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
2537
2437
  $ZodType.init(inst, def);
2538
- defineLazy(inst._zod, "innerType", () => {
2539
- const d = def;
2540
- if (!d._cachedInner)
2541
- d._cachedInner = def.getter();
2542
- return d._cachedInner;
2543
- });
2438
+ defineLazy(inst._zod, "innerType", () => def.getter());
2544
2439
  defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
2545
2440
  defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
2546
2441
  defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
@@ -3114,7 +3009,7 @@ function _refine(Class, fn, _params) {
3114
3009
  return schema;
3115
3010
  }
3116
3011
  // @__NO_SIDE_EFFECTS__
3117
- function _superRefine(fn, params) {
3012
+ function _superRefine(fn) {
3118
3013
  const ch = /* @__PURE__ */ _check((payload) => {
3119
3014
  payload.addIssue = (issue$1) => {
3120
3015
  if (typeof issue$1 === "string") {
@@ -3131,7 +3026,7 @@ function _superRefine(fn, params) {
3131
3026
  }
3132
3027
  };
3133
3028
  return fn(payload.value, payload);
3134
- }, params);
3029
+ });
3135
3030
  return ch;
3136
3031
  }
3137
3032
  // @__NO_SIDE_EFFECTS__
@@ -3212,7 +3107,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
3212
3107
  delete result.schema.examples;
3213
3108
  delete result.schema.default;
3214
3109
  }
3215
- if (ctx.io === "input" && "_prefault" in result.schema)
3110
+ if (ctx.io === "input" && result.schema._prefault)
3216
3111
  (_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
3217
3112
  delete result.schema._prefault;
3218
3113
  const _result = ctx.seen.get(schema);
@@ -3393,15 +3288,10 @@ function finalize(ctx, schema) {
3393
3288
  result.$id = ctx.external.uri(id);
3394
3289
  }
3395
3290
  Object.assign(result, root.def ?? root.schema);
3396
- const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
3397
- if (rootMetaId !== void 0 && result.id === rootMetaId)
3398
- delete result.id;
3399
3291
  const defs = ctx.external?.defs ?? {};
3400
3292
  for (const entry of ctx.seen.entries()) {
3401
3293
  const seen = entry[1];
3402
3294
  if (seen.def && seen.defId) {
3403
- if (seen.def.id === seen.defId)
3404
- delete seen.def.id;
3405
3295
  defs[seen.defId] = seen.def;
3406
3296
  }
3407
3297
  }
@@ -3457,8 +3347,6 @@ function isTransforming(_schema, _ctx) {
3457
3347
  return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3458
3348
  }
3459
3349
  if (def.type === "pipe") {
3460
- if (_schema._zod.traits.has("$ZodCodec"))
3461
- return true;
3462
3350
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3463
3351
  }
3464
3352
  if (def.type === "object") {
@@ -3546,28 +3434,39 @@ const numberProcessor = (schema, ctx, _json, _params) => {
3546
3434
  json.type = "integer";
3547
3435
  else
3548
3436
  json.type = "number";
3549
- const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3550
- const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3551
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
3552
- if (exMin) {
3553
- if (legacy) {
3437
+ if (typeof exclusiveMinimum === "number") {
3438
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3554
3439
  json.minimum = exclusiveMinimum;
3555
3440
  json.exclusiveMinimum = true;
3556
3441
  } else {
3557
3442
  json.exclusiveMinimum = exclusiveMinimum;
3558
3443
  }
3559
- } else if (typeof minimum === "number") {
3444
+ }
3445
+ if (typeof minimum === "number") {
3560
3446
  json.minimum = minimum;
3447
+ if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
3448
+ if (exclusiveMinimum >= minimum)
3449
+ delete json.minimum;
3450
+ else
3451
+ delete json.exclusiveMinimum;
3452
+ }
3561
3453
  }
3562
- if (exMax) {
3563
- if (legacy) {
3454
+ if (typeof exclusiveMaximum === "number") {
3455
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3564
3456
  json.maximum = exclusiveMaximum;
3565
3457
  json.exclusiveMaximum = true;
3566
3458
  } else {
3567
3459
  json.exclusiveMaximum = exclusiveMaximum;
3568
3460
  }
3569
- } else if (typeof maximum === "number") {
3461
+ }
3462
+ if (typeof maximum === "number") {
3570
3463
  json.maximum = maximum;
3464
+ if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
3465
+ if (exclusiveMaximum <= maximum)
3466
+ delete json.maximum;
3467
+ else
3468
+ delete json.exclusiveMaximum;
3469
+ }
3571
3470
  }
3572
3471
  if (typeof multipleOf === "number")
3573
3472
  json.multipleOf = multipleOf;
@@ -3656,10 +3555,7 @@ const arrayProcessor = (schema, ctx, _json, params) => {
3656
3555
  if (typeof maximum === "number")
3657
3556
  json.maxItems = maximum;
3658
3557
  json.type = "array";
3659
- json.items = process(def.element, ctx, {
3660
- ...params,
3661
- path: [...params.path, "items"]
3662
- });
3558
+ json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
3663
3559
  };
3664
3560
  const objectProcessor = (schema, ctx, _json, params) => {
3665
3561
  const json = _json;
@@ -3810,8 +3706,7 @@ const catchProcessor = (schema, ctx, json, params) => {
3810
3706
  };
3811
3707
  const pipeProcessor = (schema, ctx, _json, params) => {
3812
3708
  const def = schema._zod.def;
3813
- const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3814
- const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3709
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3815
3710
  process(innerType, ctx, params);
3816
3711
  const seen = ctx.seen.get(schema);
3817
3712
  seen.ref = innerType;
@@ -3897,7 +3792,7 @@ const initializer = (inst, issues) => {
3897
3792
  }
3898
3793
  });
3899
3794
  };
3900
- const ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer, {
3795
+ const ZodRealError = $constructor("ZodError", initializer, {
3901
3796
  Parent: Error
3902
3797
  });
3903
3798
  const parse = /* @__PURE__ */ _parse(ZodRealError);
@@ -3912,43 +3807,6 @@ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3912
3807
  const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3913
3808
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3914
3809
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3915
- const _installedGroups = /* @__PURE__ */ new WeakMap();
3916
- function _installLazyMethods(inst, group, methods) {
3917
- const proto = Object.getPrototypeOf(inst);
3918
- let installed = _installedGroups.get(proto);
3919
- if (!installed) {
3920
- installed = /* @__PURE__ */ new Set();
3921
- _installedGroups.set(proto, installed);
3922
- }
3923
- if (installed.has(group))
3924
- return;
3925
- installed.add(group);
3926
- for (const key in methods) {
3927
- const fn = methods[key];
3928
- Object.defineProperty(proto, key, {
3929
- configurable: true,
3930
- enumerable: false,
3931
- get() {
3932
- const bound = fn.bind(this);
3933
- Object.defineProperty(this, key, {
3934
- configurable: true,
3935
- writable: true,
3936
- enumerable: true,
3937
- value: bound
3938
- });
3939
- return bound;
3940
- },
3941
- set(v) {
3942
- Object.defineProperty(this, key, {
3943
- configurable: true,
3944
- writable: true,
3945
- enumerable: true,
3946
- value: v
3947
- });
3948
- }
3949
- });
3950
- }
3951
- }
3952
3810
  const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3953
3811
  $ZodType.init(inst, def);
3954
3812
  Object.assign(inst["~standard"], {
@@ -3961,6 +3819,23 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3961
3819
  inst.def = def;
3962
3820
  inst.type = def.type;
3963
3821
  Object.defineProperty(inst, "_def", { value: def });
3822
+ inst.check = (...checks) => {
3823
+ return inst.clone(mergeDefs(def, {
3824
+ checks: [
3825
+ ...def.checks ?? [],
3826
+ ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
3827
+ ]
3828
+ }), {
3829
+ parent: true
3830
+ });
3831
+ };
3832
+ inst.with = inst.check;
3833
+ inst.clone = (def2, params) => clone(inst, def2, params);
3834
+ inst.brand = () => inst;
3835
+ inst.register = ((reg, meta) => {
3836
+ reg.add(inst, meta);
3837
+ return inst;
3838
+ });
3964
3839
  inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3965
3840
  inst.safeParse = (data, params) => safeParse(inst, data, params);
3966
3841
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
@@ -3974,108 +3849,45 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3974
3849
  inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3975
3850
  inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3976
3851
  inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3977
- _installLazyMethods(inst, "ZodType", {
3978
- check(...chks) {
3979
- const def2 = this.def;
3980
- return this.clone(mergeDefs(def2, {
3981
- checks: [
3982
- ...def2.checks ?? [],
3983
- ...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
3984
- ]
3985
- }), { parent: true });
3986
- },
3987
- with(...chks) {
3988
- return this.check(...chks);
3989
- },
3990
- clone(def2, params) {
3991
- return clone(this, def2, params);
3992
- },
3993
- brand() {
3994
- return this;
3995
- },
3996
- register(reg, meta) {
3997
- reg.add(this, meta);
3998
- return this;
3999
- },
4000
- refine(check, params) {
4001
- return this.check(refine(check, params));
4002
- },
4003
- superRefine(refinement, params) {
4004
- return this.check(superRefine(refinement, params));
4005
- },
4006
- overwrite(fn) {
4007
- return this.check(/* @__PURE__ */ _overwrite(fn));
4008
- },
4009
- optional() {
4010
- return optional(this);
4011
- },
4012
- exactOptional() {
4013
- return exactOptional(this);
4014
- },
4015
- nullable() {
4016
- return nullable(this);
4017
- },
4018
- nullish() {
4019
- return optional(nullable(this));
4020
- },
4021
- nonoptional(params) {
4022
- return nonoptional(this, params);
4023
- },
4024
- array() {
4025
- return array(this);
4026
- },
4027
- or(arg) {
4028
- return union([this, arg]);
4029
- },
4030
- and(arg) {
4031
- return intersection(this, arg);
4032
- },
4033
- transform(tx) {
4034
- return pipe(this, transform(tx));
4035
- },
4036
- default(d) {
4037
- return _default(this, d);
4038
- },
4039
- prefault(d) {
4040
- return prefault(this, d);
4041
- },
4042
- catch(params) {
4043
- return _catch(this, params);
4044
- },
4045
- pipe(target) {
4046
- return pipe(this, target);
4047
- },
4048
- readonly() {
4049
- return readonly(this);
4050
- },
4051
- describe(description) {
4052
- const cl = this.clone();
4053
- globalRegistry.add(cl, { description });
4054
- return cl;
4055
- },
4056
- meta(...args) {
4057
- if (args.length === 0)
4058
- return globalRegistry.get(this);
4059
- const cl = this.clone();
4060
- globalRegistry.add(cl, args[0]);
4061
- return cl;
4062
- },
4063
- isOptional() {
4064
- return this.safeParse(void 0).success;
4065
- },
4066
- isNullable() {
4067
- return this.safeParse(null).success;
4068
- },
4069
- apply(fn) {
4070
- return fn(this);
4071
- }
4072
- });
3852
+ inst.refine = (check, params) => inst.check(refine(check, params));
3853
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3854
+ inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
3855
+ inst.optional = () => optional(inst);
3856
+ inst.exactOptional = () => exactOptional(inst);
3857
+ inst.nullable = () => nullable(inst);
3858
+ inst.nullish = () => optional(nullable(inst));
3859
+ inst.nonoptional = (params) => nonoptional(inst, params);
3860
+ inst.array = () => array(inst);
3861
+ inst.or = (arg) => union([inst, arg]);
3862
+ inst.and = (arg) => intersection(inst, arg);
3863
+ inst.transform = (tx) => pipe(inst, transform(tx));
3864
+ inst.default = (def2) => _default(inst, def2);
3865
+ inst.prefault = (def2) => prefault(inst, def2);
3866
+ inst.catch = (params) => _catch(inst, params);
3867
+ inst.pipe = (target) => pipe(inst, target);
3868
+ inst.readonly = () => readonly(inst);
3869
+ inst.describe = (description) => {
3870
+ const cl = inst.clone();
3871
+ globalRegistry.add(cl, { description });
3872
+ return cl;
3873
+ };
4073
3874
  Object.defineProperty(inst, "description", {
4074
3875
  get() {
4075
3876
  return globalRegistry.get(inst)?.description;
4076
3877
  },
4077
3878
  configurable: true
4078
3879
  });
3880
+ inst.meta = (...args) => {
3881
+ if (args.length === 0) {
3882
+ return globalRegistry.get(inst);
3883
+ }
3884
+ const cl = inst.clone();
3885
+ globalRegistry.add(cl, args[0]);
3886
+ return cl;
3887
+ };
3888
+ inst.isOptional = () => inst.safeParse(void 0).success;
3889
+ inst.isNullable = () => inst.safeParse(null).success;
3890
+ inst.apply = (fn) => fn(inst);
4079
3891
  return inst;
4080
3892
  });
4081
3893
  const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
@@ -4086,53 +3898,21 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
4086
3898
  inst.format = bag.format ?? null;
4087
3899
  inst.minLength = bag.minimum ?? null;
4088
3900
  inst.maxLength = bag.maximum ?? null;
4089
- _installLazyMethods(inst, "_ZodString", {
4090
- regex(...args) {
4091
- return this.check(/* @__PURE__ */ _regex(...args));
4092
- },
4093
- includes(...args) {
4094
- return this.check(/* @__PURE__ */ _includes(...args));
4095
- },
4096
- startsWith(...args) {
4097
- return this.check(/* @__PURE__ */ _startsWith(...args));
4098
- },
4099
- endsWith(...args) {
4100
- return this.check(/* @__PURE__ */ _endsWith(...args));
4101
- },
4102
- min(...args) {
4103
- return this.check(/* @__PURE__ */ _minLength(...args));
4104
- },
4105
- max(...args) {
4106
- return this.check(/* @__PURE__ */ _maxLength(...args));
4107
- },
4108
- length(...args) {
4109
- return this.check(/* @__PURE__ */ _length(...args));
4110
- },
4111
- nonempty(...args) {
4112
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
4113
- },
4114
- lowercase(params) {
4115
- return this.check(/* @__PURE__ */ _lowercase(params));
4116
- },
4117
- uppercase(params) {
4118
- return this.check(/* @__PURE__ */ _uppercase(params));
4119
- },
4120
- trim() {
4121
- return this.check(/* @__PURE__ */ _trim());
4122
- },
4123
- normalize(...args) {
4124
- return this.check(/* @__PURE__ */ _normalize(...args));
4125
- },
4126
- toLowerCase() {
4127
- return this.check(/* @__PURE__ */ _toLowerCase());
4128
- },
4129
- toUpperCase() {
4130
- return this.check(/* @__PURE__ */ _toUpperCase());
4131
- },
4132
- slugify() {
4133
- return this.check(/* @__PURE__ */ _slugify());
4134
- }
4135
- });
3901
+ inst.regex = (...args) => inst.check(/* @__PURE__ */ _regex(...args));
3902
+ inst.includes = (...args) => inst.check(/* @__PURE__ */ _includes(...args));
3903
+ inst.startsWith = (...args) => inst.check(/* @__PURE__ */ _startsWith(...args));
3904
+ inst.endsWith = (...args) => inst.check(/* @__PURE__ */ _endsWith(...args));
3905
+ inst.min = (...args) => inst.check(/* @__PURE__ */ _minLength(...args));
3906
+ inst.max = (...args) => inst.check(/* @__PURE__ */ _maxLength(...args));
3907
+ inst.length = (...args) => inst.check(/* @__PURE__ */ _length(...args));
3908
+ inst.nonempty = (...args) => inst.check(/* @__PURE__ */ _minLength(1, ...args));
3909
+ inst.lowercase = (params) => inst.check(/* @__PURE__ */ _lowercase(params));
3910
+ inst.uppercase = (params) => inst.check(/* @__PURE__ */ _uppercase(params));
3911
+ inst.trim = () => inst.check(/* @__PURE__ */ _trim());
3912
+ inst.normalize = (...args) => inst.check(/* @__PURE__ */ _normalize(...args));
3913
+ inst.toLowerCase = () => inst.check(/* @__PURE__ */ _toLowerCase());
3914
+ inst.toUpperCase = () => inst.check(/* @__PURE__ */ _toUpperCase());
3915
+ inst.slugify = () => inst.check(/* @__PURE__ */ _slugify());
4136
3916
  });
4137
3917
  const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
4138
3918
  $ZodString.init(inst, def);
@@ -4252,53 +4032,21 @@ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
4252
4032
  $ZodNumber.init(inst, def);
4253
4033
  ZodType.init(inst, def);
4254
4034
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json);
4255
- _installLazyMethods(inst, "ZodNumber", {
4256
- gt(value, params) {
4257
- return this.check(/* @__PURE__ */ _gt(value, params));
4258
- },
4259
- gte(value, params) {
4260
- return this.check(/* @__PURE__ */ _gte(value, params));
4261
- },
4262
- min(value, params) {
4263
- return this.check(/* @__PURE__ */ _gte(value, params));
4264
- },
4265
- lt(value, params) {
4266
- return this.check(/* @__PURE__ */ _lt(value, params));
4267
- },
4268
- lte(value, params) {
4269
- return this.check(/* @__PURE__ */ _lte(value, params));
4270
- },
4271
- max(value, params) {
4272
- return this.check(/* @__PURE__ */ _lte(value, params));
4273
- },
4274
- int(params) {
4275
- return this.check(int(params));
4276
- },
4277
- safe(params) {
4278
- return this.check(int(params));
4279
- },
4280
- positive(params) {
4281
- return this.check(/* @__PURE__ */ _gt(0, params));
4282
- },
4283
- nonnegative(params) {
4284
- return this.check(/* @__PURE__ */ _gte(0, params));
4285
- },
4286
- negative(params) {
4287
- return this.check(/* @__PURE__ */ _lt(0, params));
4288
- },
4289
- nonpositive(params) {
4290
- return this.check(/* @__PURE__ */ _lte(0, params));
4291
- },
4292
- multipleOf(value, params) {
4293
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
4294
- },
4295
- step(value, params) {
4296
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
4297
- },
4298
- finite() {
4299
- return this;
4300
- }
4301
- });
4035
+ inst.gt = (value, params) => inst.check(/* @__PURE__ */ _gt(value, params));
4036
+ inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
4037
+ inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
4038
+ inst.lt = (value, params) => inst.check(/* @__PURE__ */ _lt(value, params));
4039
+ inst.lte = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
4040
+ inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
4041
+ inst.int = (params) => inst.check(int(params));
4042
+ inst.safe = (params) => inst.check(int(params));
4043
+ inst.positive = (params) => inst.check(/* @__PURE__ */ _gt(0, params));
4044
+ inst.nonnegative = (params) => inst.check(/* @__PURE__ */ _gte(0, params));
4045
+ inst.negative = (params) => inst.check(/* @__PURE__ */ _lt(0, params));
4046
+ inst.nonpositive = (params) => inst.check(/* @__PURE__ */ _lte(0, params));
4047
+ inst.multipleOf = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
4048
+ inst.step = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
4049
+ inst.finite = () => inst;
4302
4050
  const bag = inst._zod.bag;
4303
4051
  inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
4304
4052
  inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
@@ -4353,23 +4101,11 @@ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
4353
4101
  ZodType.init(inst, def);
4354
4102
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4355
4103
  inst.element = def.element;
4356
- _installLazyMethods(inst, "ZodArray", {
4357
- min(n, params) {
4358
- return this.check(/* @__PURE__ */ _minLength(n, params));
4359
- },
4360
- nonempty(params) {
4361
- return this.check(/* @__PURE__ */ _minLength(1, params));
4362
- },
4363
- max(n, params) {
4364
- return this.check(/* @__PURE__ */ _maxLength(n, params));
4365
- },
4366
- length(n, params) {
4367
- return this.check(/* @__PURE__ */ _length(n, params));
4368
- },
4369
- unwrap() {
4370
- return this.element;
4371
- }
4372
- });
4104
+ inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
4105
+ inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
4106
+ inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
4107
+ inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
4108
+ inst.unwrap = () => inst.element;
4373
4109
  });
4374
4110
  function array(element, params) {
4375
4111
  return /* @__PURE__ */ _array(ZodArray, element, params);
@@ -4381,47 +4117,23 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4381
4117
  defineLazy(inst, "shape", () => {
4382
4118
  return def.shape;
4383
4119
  });
4384
- _installLazyMethods(inst, "ZodObject", {
4385
- keyof() {
4386
- return _enum(Object.keys(this._zod.def.shape));
4387
- },
4388
- catchall(catchall) {
4389
- return this.clone({ ...this._zod.def, catchall });
4390
- },
4391
- passthrough() {
4392
- return this.clone({ ...this._zod.def, catchall: unknown() });
4393
- },
4394
- loose() {
4395
- return this.clone({ ...this._zod.def, catchall: unknown() });
4396
- },
4397
- strict() {
4398
- return this.clone({ ...this._zod.def, catchall: never() });
4399
- },
4400
- strip() {
4401
- return this.clone({ ...this._zod.def, catchall: void 0 });
4402
- },
4403
- extend(incoming) {
4404
- return extend(this, incoming);
4405
- },
4406
- safeExtend(incoming) {
4407
- return safeExtend(this, incoming);
4408
- },
4409
- merge(other) {
4410
- return merge(this, other);
4411
- },
4412
- pick(mask) {
4413
- return pick(this, mask);
4414
- },
4415
- omit(mask) {
4416
- return omit(this, mask);
4417
- },
4418
- partial(...args) {
4419
- return partial(ZodOptional, this, args[0]);
4420
- },
4421
- required(...args) {
4422
- return required(ZodNonOptional, this, args[0]);
4423
- }
4424
- });
4120
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
4121
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
4122
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4123
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4124
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
4125
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
4126
+ inst.extend = (incoming) => {
4127
+ return extend(inst, incoming);
4128
+ };
4129
+ inst.safeExtend = (incoming) => {
4130
+ return safeExtend(inst, incoming);
4131
+ };
4132
+ inst.merge = (other) => merge(inst, other);
4133
+ inst.pick = (mask) => pick(inst, mask);
4134
+ inst.omit = (mask) => omit(inst, mask);
4135
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
4136
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
4425
4137
  });
4426
4138
  function object(shape, params) {
4427
4139
  const def = {
@@ -4476,14 +4188,6 @@ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4476
4188
  inst.valueType = def.valueType;
4477
4189
  });
4478
4190
  function record(keyType, valueType, params) {
4479
- if (!valueType || !valueType._zod) {
4480
- return new ZodRecord({
4481
- type: "record",
4482
- keyType: string(),
4483
- valueType: keyType,
4484
- ...normalizeParams(valueType)
4485
- });
4486
- }
4487
4191
  return new ZodRecord({
4488
4192
  type: "record",
4489
4193
  keyType,
@@ -4583,12 +4287,10 @@ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) =>
4583
4287
  if (output instanceof Promise) {
4584
4288
  return output.then((output2) => {
4585
4289
  payload.value = output2;
4586
- payload.fallback = true;
4587
4290
  return payload;
4588
4291
  });
4589
4292
  }
4590
4293
  payload.value = output;
4591
- payload.fallback = true;
4592
4294
  return payload;
4593
4295
  };
4594
4296
  });
@@ -4739,16 +4441,16 @@ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4739
4441
  function refine(fn, _params = {}) {
4740
4442
  return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
4741
4443
  }
4742
- function superRefine(fn, params) {
4743
- return /* @__PURE__ */ _superRefine(fn, params);
4444
+ function superRefine(fn) {
4445
+ return /* @__PURE__ */ _superRefine(fn);
4744
4446
  }
4745
4447
  export {
4746
4448
  _enum as _,
4747
4449
  array as a,
4748
4450
  boolean as b,
4749
- lazy as c,
4451
+ _null as c,
4750
4452
  discriminatedUnion as d,
4751
- _null as e,
4453
+ lazy as e,
4752
4454
  unknown as f,
4753
4455
  literal as l,
4754
4456
  number as n,