@casys/mcp-erpnext 3.1.0-beta.6 → 3.1.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mcp-erpnext.mjs CHANGED
@@ -1876,8 +1876,8 @@ var require_keyword2 = __commonJS({
1876
1876
  var _a3;
1877
1877
  const { gen, keyword, schema, parentSchema, $data, it } = cxt;
1878
1878
  checkAsyncKeyword(it, def);
1879
- const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
1880
- const validateRef = useKeyword(gen, keyword, validate);
1879
+ const validate2 = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
1880
+ const validateRef = useKeyword(gen, keyword, validate2);
1881
1881
  const valid = gen.let("valid");
1882
1882
  cxt.block$data(valid, validateKeyword);
1883
1883
  cxt.ok((_a3 = def.valid) !== null && _a3 !== void 0 ? _a3 : valid);
@@ -1888,13 +1888,13 @@ var require_keyword2 = __commonJS({
1888
1888
  modifyData(cxt);
1889
1889
  reportErrs(() => cxt.error());
1890
1890
  } else {
1891
- const ruleErrs = def.async ? validateAsync() : validateSync();
1891
+ const ruleErrs = def.async ? validateAsync3() : validateSync();
1892
1892
  if (def.modifying)
1893
1893
  modifyData(cxt);
1894
1894
  reportErrs(() => addErrs(cxt, ruleErrs));
1895
1895
  }
1896
1896
  }
1897
- function validateAsync() {
1897
+ function validateAsync3() {
1898
1898
  const ruleErrs = gen.let("ruleErrs", null);
1899
1899
  gen.try(() => assignValid((0, codegen_1._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1._)`${e}.errors`), () => gen.throw(e)));
1900
1900
  return ruleErrs;
@@ -2950,28 +2950,28 @@ var require_compile2 = __commonJS({
2950
2950
  if (this.opts.code.process)
2951
2951
  sourceCode = this.opts.code.process(sourceCode, sch);
2952
2952
  const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode);
2953
- const validate = makeValidate(this, this.scope.get());
2954
- this.scope.value(validateName, { ref: validate });
2955
- validate.errors = null;
2956
- validate.schema = sch.schema;
2957
- validate.schemaEnv = sch;
2953
+ const validate2 = makeValidate(this, this.scope.get());
2954
+ this.scope.value(validateName, { ref: validate2 });
2955
+ validate2.errors = null;
2956
+ validate2.schema = sch.schema;
2957
+ validate2.schemaEnv = sch;
2958
2958
  if (sch.$async)
2959
- validate.$async = true;
2959
+ validate2.$async = true;
2960
2960
  if (this.opts.code.source === true) {
2961
- validate.source = { validateName, validateCode, scopeValues: gen._values };
2961
+ validate2.source = { validateName, validateCode, scopeValues: gen._values };
2962
2962
  }
2963
2963
  if (this.opts.unevaluated) {
2964
2964
  const { props, items } = schemaCxt;
2965
- validate.evaluated = {
2965
+ validate2.evaluated = {
2966
2966
  props: props instanceof codegen_1.Name ? void 0 : props,
2967
2967
  items: items instanceof codegen_1.Name ? void 0 : items,
2968
2968
  dynamicProps: props instanceof codegen_1.Name,
2969
2969
  dynamicItems: items instanceof codegen_1.Name
2970
2970
  };
2971
- if (validate.source)
2972
- validate.source.evaluated = (0, codegen_1.stringify)(validate.evaluated);
2971
+ if (validate2.source)
2972
+ validate2.source.evaluated = (0, codegen_1.stringify)(validate2.evaluated);
2973
2973
  }
2974
- sch.validate = validate;
2974
+ sch.validate = validate2;
2975
2975
  return sch;
2976
2976
  } catch (e) {
2977
2977
  delete sch.validate;
@@ -3115,6 +3115,7 @@ var require_utils2 = __commonJS({
3115
3115
  "use strict";
3116
3116
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3117
3117
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3118
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
3118
3119
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3119
3120
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3120
3121
  var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
@@ -3580,8 +3581,12 @@ var require_utils2 = __commonJS({
3580
3581
  uriTokens.push(host);
3581
3582
  }
3582
3583
  if (typeof component.port === "number" || typeof component.port === "string") {
3584
+ const port = String(component.port);
3585
+ if (!isPort(port)) {
3586
+ throw new TypeError("URI port is malformed.");
3587
+ }
3583
3588
  uriTokens.push(":");
3584
- uriTokens.push(String(component.port));
3589
+ uriTokens.push(port);
3585
3590
  }
3586
3591
  return uriTokens.length ? uriTokens.join("") : void 0;
3587
3592
  }
@@ -3838,7 +3843,7 @@ var require_fast_uri2 = __commonJS({
3838
3843
  normalizeString(uri, options);
3839
3844
  } else if (typeof uri === "object") {
3840
3845
  uri = /** @type {T} */
3841
- parse3(serialize(uri, options), options);
3846
+ parse2(serialize(uri, options), options);
3842
3847
  }
3843
3848
  return uri;
3844
3849
  }
@@ -3878,8 +3883,8 @@ var require_fast_uri2 = __commonJS({
3878
3883
  function resolveComponent(base, relative, options, skipNormalization) {
3879
3884
  const target = {};
3880
3885
  if (!skipNormalization) {
3881
- base = parse3(serialize(base, options), options);
3882
- relative = parse3(serialize(relative, options), options);
3886
+ base = parse2(serialize(base, options), options);
3887
+ relative = parse2(serialize(relative, options), options);
3883
3888
  }
3884
3889
  options = options || {};
3885
3890
  if (!options.tolerant && relative.scheme) {
@@ -4024,12 +4029,15 @@ var require_fast_uri2 = __commonJS({
4024
4029
  }
4025
4030
  return false;
4026
4031
  }
4032
+ function isIPLiteral(host) {
4033
+ return host[0] === "[" && host[host.length - 1] === "]";
4034
+ }
4027
4035
  function hasMalformedComponentPercentEncoding(matches) {
4028
4036
  const host = matches[4];
4029
- return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host[0] === "[" && host[host.length - 1] === "]") && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4037
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4030
4038
  }
4031
4039
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4032
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host[0] !== "[" && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4040
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4033
4041
  try {
4034
4042
  parsed.host = new URL("http://" + parsed.host).hostname;
4035
4043
  } catch (e) {
@@ -4116,10 +4124,11 @@ var require_fast_uri2 = __commonJS({
4116
4124
  if (parsed.host) {
4117
4125
  const ipv4result = isIPv4(parsed.host);
4118
4126
  if (ipv4result === false) {
4119
- const bracketedIPLiteral = parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
4127
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
4128
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
4120
4129
  const ipv6result = normalizeIPv6(parsed.host);
4121
4130
  isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4122
- malformedIPLiteral = bracketedIPLiteral && ipv6result.error === true;
4131
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4123
4132
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4124
4133
  if (malformedIPLiteral) {
4125
4134
  parsed.error = parsed.error || "URI host is malformed.";
@@ -4142,7 +4151,9 @@ var require_fast_uri2 = __commonJS({
4142
4151
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
4143
4152
  }
4144
4153
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
4145
- malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4154
+ if (!malformedIPLiteral) {
4155
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4156
+ }
4146
4157
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4147
4158
  if (uri.indexOf("%") !== -1) {
4148
4159
  if (parsed.host !== void 0 && !malformedIPLiteral) {
@@ -4171,7 +4182,7 @@ var require_fast_uri2 = __commonJS({
4171
4182
  }
4172
4183
  return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
4173
4184
  }
4174
- function parse3(uri, opts) {
4185
+ function parse2(uri, opts) {
4175
4186
  return parseWithStatus(uri, opts).parsed;
4176
4187
  }
4177
4188
  function normalizeString(uri, opts) {
@@ -4208,7 +4219,7 @@ var require_fast_uri2 = __commonJS({
4208
4219
  resolveComponent,
4209
4220
  equal,
4210
4221
  serialize,
4211
- parse: parse3
4222
+ parse: parse2
4212
4223
  };
4213
4224
  module.exports = fastUri;
4214
4225
  module.exports.default = fastUri;
@@ -6403,8 +6414,8 @@ var require_dynamicAnchor2 = __commonJS({
6403
6414
  const { gen, it } = cxt;
6404
6415
  it.schemaEnv.root.dynamicAnchors[anchor2] = true;
6405
6416
  const v = (0, codegen_1._)`${names_1.default.dynamicAnchors}${(0, codegen_1.getProperty)(anchor2)}`;
6406
- const validate = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
6407
- gen.if((0, codegen_1._)`!${v}`, () => gen.assign(v, validate));
6417
+ const validate2 = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
6418
+ gen.if((0, codegen_1._)`!${v}`, () => gen.assign(v, validate2));
6408
6419
  }
6409
6420
  exports.dynamicAnchor = dynamicAnchor;
6410
6421
  function _getValidate(cxt) {
@@ -6453,11 +6464,11 @@ var require_dynamicRef2 = __commonJS({
6453
6464
  _callRef(it.validateName, valid)();
6454
6465
  }
6455
6466
  }
6456
- function _callRef(validate, valid) {
6467
+ function _callRef(validate2, valid) {
6457
6468
  return valid ? () => gen.block(() => {
6458
- (0, ref_1.callRef)(cxt, validate);
6469
+ (0, ref_1.callRef)(cxt, validate2);
6459
6470
  gen.let(valid, true);
6460
- }) : () => (0, ref_1.callRef)(cxt, validate);
6471
+ }) : () => (0, ref_1.callRef)(cxt, validate2);
6461
6472
  }
6462
6473
  }
6463
6474
  exports.dynamicRef = dynamicRef;
@@ -8391,36 +8402,38 @@ var require_Alias = __commonJS({
8391
8402
  if (node2.anchor === this.source)
8392
8403
  found = node2;
8393
8404
  }
8405
+ if (found && ctx) {
8406
+ const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
8407
+ let data = anchors2.get(found);
8408
+ if (!data) {
8409
+ toJS.toJS(found, null, ctx);
8410
+ data = anchors2.get(found);
8411
+ }
8412
+ if (data?.res === void 0) {
8413
+ const msg = "This should not happen: Alias anchor was not resolved?";
8414
+ throw new ReferenceError(msg);
8415
+ }
8416
+ if (maxAliasCount >= 0) {
8417
+ data.count += 1;
8418
+ if (data.aliasCount === 0)
8419
+ data.aliasCount = getAliasCount(doc2, found, anchors2);
8420
+ if (data.count * data.aliasCount > maxAliasCount) {
8421
+ const msg = "Excessive alias count indicates a resource exhaustion attack";
8422
+ throw new ReferenceError(msg);
8423
+ }
8424
+ }
8425
+ }
8394
8426
  return found;
8395
8427
  }
8396
8428
  toJSON(_arg, ctx) {
8397
8429
  if (!ctx)
8398
8430
  return { source: this.source };
8399
- const { anchors: anchors2, doc, maxAliasCount } = ctx;
8400
- const source = this.resolve(doc, ctx);
8431
+ const source = this.resolve(ctx.doc, ctx);
8401
8432
  if (!source) {
8402
8433
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
8403
8434
  throw new ReferenceError(msg);
8404
8435
  }
8405
- let data = anchors2.get(source);
8406
- if (!data) {
8407
- toJS.toJS(source, null, ctx);
8408
- data = anchors2.get(source);
8409
- }
8410
- if (data?.res === void 0) {
8411
- const msg = "This should not happen: Alias anchor was not resolved?";
8412
- throw new ReferenceError(msg);
8413
- }
8414
- if (maxAliasCount >= 0) {
8415
- data.count += 1;
8416
- if (data.aliasCount === 0)
8417
- data.aliasCount = getAliasCount(doc, source, anchors2);
8418
- if (data.count * data.aliasCount > maxAliasCount) {
8419
- const msg = "Excessive alias count indicates a resource exhaustion attack";
8420
- throw new ReferenceError(msg);
8421
- }
8422
- }
8423
- return data.res;
8436
+ return ctx.anchors.get(source).res;
8424
8437
  }
8425
8438
  toString(ctx, _onComment, _onChompKeep) {
8426
8439
  const src = `*${this.source}`;
@@ -12422,37 +12435,38 @@ var require_resolve_flow_scalar = __commonJS({
12422
12435
  }
12423
12436
  if (badChar)
12424
12437
  onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
12425
- return foldLines(source);
12438
+ return unfoldLines(source);
12426
12439
  }
12427
12440
  function singleQuotedValue(source, onError) {
12428
12441
  if (source[source.length - 1] !== "'" || source.length === 1)
12429
12442
  onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
12430
- return foldLines(source.slice(1, -1)).replace(/''/g, "'");
12443
+ return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
12431
12444
  }
12432
- function foldLines(source) {
12433
- let first, line;
12445
+ function unfoldLines(source) {
12446
+ const line = /(.*?)\r?\n/sy;
12447
+ let match2 = line.exec(source);
12448
+ if (!match2)
12449
+ return source;
12450
+ let trimEnd, trimBoth;
12434
12451
  try {
12435
- first = new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
12436
- line = new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
12452
+ trimEnd = new RegExp("(?<![ ])[ ]+$");
12453
+ trimBoth = new RegExp("^[ ]+|(?<![ ])[ ]+$", "g");
12437
12454
  } catch {
12438
- first = /(.*?)[ \t]*\r?\n/sy;
12439
- line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
12455
+ trimEnd = /[ \t]+$/;
12456
+ trimBoth = /^[ \t]+|[ \t]+$/g;
12440
12457
  }
12441
- let match2 = first.exec(source);
12442
- if (!match2)
12443
- return source;
12444
- let res = match2[1];
12458
+ let res = match2[1].replace(trimEnd, "");
12445
12459
  let sep = " ";
12446
- let pos = first.lastIndex;
12447
- line.lastIndex = pos;
12460
+ let pos = line.lastIndex;
12448
12461
  while (match2 = line.exec(source)) {
12449
- if (match2[1] === "") {
12462
+ const lm = match2[1].replace(trimBoth, "");
12463
+ if (lm === "") {
12450
12464
  if (sep === "\n")
12451
12465
  res += sep;
12452
12466
  else
12453
12467
  sep = "\n";
12454
12468
  } else {
12455
- res += sep + match2[1];
12469
+ res += sep + lm;
12456
12470
  sep = " ";
12457
12471
  }
12458
12472
  pos = line.lastIndex;
@@ -14994,7 +15008,7 @@ var require_public_api = __commonJS({
14994
15008
  }
14995
15009
  return doc;
14996
15010
  }
14997
- function parse3(src, reviver, options) {
15011
+ function parse2(src, reviver, options) {
14998
15012
  let _reviver = void 0;
14999
15013
  if (typeof reviver === "function") {
15000
15014
  _reviver = reviver;
@@ -15035,7 +15049,7 @@ var require_public_api = __commonJS({
15035
15049
  return value.toString(options);
15036
15050
  return new Document.Document(value, _replacer, options).toString(options);
15037
15051
  }
15038
- exports.parse = parse3;
15052
+ exports.parse = parse2;
15039
15053
  exports.parseAllDocuments = parseAllDocuments;
15040
15054
  exports.parseDocument = parseDocument;
15041
15055
  exports.stringify = stringify;
@@ -15278,6 +15292,7 @@ __export(util_exports, {
15278
15292
  createTransparentProxy: () => createTransparentProxy,
15279
15293
  defineLazy: () => defineLazy,
15280
15294
  defineLazyInternal: () => defineLazyInternal,
15295
+ derived: () => derived,
15281
15296
  esc: () => esc,
15282
15297
  escapeRegex: () => escapeRegex,
15283
15298
  explicitlyAborted: () => explicitlyAborted,
@@ -15315,6 +15330,7 @@ __export(util_exports, {
15315
15330
  promiseAllObject: () => promiseAllObject,
15316
15331
  propertyKeyTypes: () => propertyKeyTypes,
15317
15332
  randomString: () => randomString,
15333
+ rawShape: () => rawShape,
15318
15334
  required: () => required,
15319
15335
  safeExtend: () => safeExtend,
15320
15336
  shallowClone: () => shallowClone,
@@ -15355,18 +15371,22 @@ function jsonStringifyReplacer(_, value) {
15355
15371
  return value.toString();
15356
15372
  return value;
15357
15373
  }
15358
- function cached(getter) {
15359
- const set = false;
15360
- return {
15361
- get value() {
15362
- if (!set) {
15363
- const value = getter();
15364
- Object.defineProperty(this, "value", { value });
15365
- return value;
15366
- }
15367
- throw new Error("cached value already set");
15374
+ var Cached = class {
15375
+ constructor(getter) {
15376
+ this._getter = getter;
15377
+ this._value = void 0;
15378
+ }
15379
+ get value() {
15380
+ const getter = this._getter;
15381
+ if (getter !== void 0) {
15382
+ this._value = getter();
15383
+ this._getter = void 0;
15368
15384
  }
15369
- };
15385
+ return this._value;
15386
+ }
15387
+ };
15388
+ function cached(getter) {
15389
+ return new Cached(getter);
15370
15390
  }
15371
15391
  function nullish(input) {
15372
15392
  return input === null || input === void 0;
@@ -15418,6 +15438,56 @@ function assignProp(target, prop, value) {
15418
15438
  configurable: true
15419
15439
  });
15420
15440
  }
15441
+ function rawShape(def) {
15442
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
15443
+ return desc?.get ? desc.get.raw : desc?.value;
15444
+ }
15445
+ function sourceShape(schema) {
15446
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
15447
+ }
15448
+ function deferProp(target, key, getter) {
15449
+ Object.defineProperty(target, key, {
15450
+ get() {
15451
+ const value = getter();
15452
+ assignProp(this, key, value);
15453
+ return value;
15454
+ },
15455
+ enumerable: true,
15456
+ configurable: true
15457
+ });
15458
+ }
15459
+ function putProp(target, key, value) {
15460
+ if (key in target)
15461
+ assignProp(target, key, value);
15462
+ else
15463
+ target[key] = value;
15464
+ }
15465
+ function mirrorShape(target, source, keys, wrap) {
15466
+ const raw2 = sourceShape(source);
15467
+ for (const key of keys) {
15468
+ const desc = Object.getOwnPropertyDescriptor(raw2, key);
15469
+ if (!desc.enumerable)
15470
+ continue;
15471
+ if (desc.get) {
15472
+ deferProp(target, key, () => {
15473
+ const value = source._zod.def.shape[key];
15474
+ return wrap ? wrap(value, key) : value;
15475
+ });
15476
+ } else
15477
+ putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
15478
+ }
15479
+ }
15480
+ function mirrorProps(target, source) {
15481
+ for (const key of Reflect.ownKeys(source)) {
15482
+ const desc = Object.getOwnPropertyDescriptor(source, key);
15483
+ if (!desc.enumerable)
15484
+ continue;
15485
+ if (desc.get)
15486
+ deferProp(target, key, () => source[key]);
15487
+ else
15488
+ putProp(target, key, desc.value);
15489
+ }
15490
+ }
15421
15491
  function mergeDefs(...defs) {
15422
15492
  const mergedDescriptors = {};
15423
15493
  for (const def of defs) {
@@ -15656,23 +15726,21 @@ function pick(schema, mask) {
15656
15726
  if (hasChecks) {
15657
15727
  throw new Error(".pick() cannot be used on object schemas containing refinements");
15658
15728
  }
15659
- const def = mergeDefs(schema._zod.def, {
15660
- get shape() {
15661
- const newShape = {};
15662
- for (const key of Reflect.ownKeys(mask)) {
15663
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
15664
- throw new Error(`Unrecognized key: "${String(key)}"`);
15665
- }
15666
- if (!mask[key])
15667
- continue;
15668
- assignProp(newShape, key, currDef.shape[key]);
15669
- }
15670
- assignProp(this, "shape", newShape);
15671
- return newShape;
15672
- },
15673
- checks: []
15674
- });
15675
- return clone(schema, def);
15729
+ const newShape = {};
15730
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
15731
+ return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
15732
+ }
15733
+ function maskedKeys(schema, mask) {
15734
+ const raw2 = sourceShape(schema);
15735
+ const keys = [];
15736
+ for (const key of Reflect.ownKeys(mask)) {
15737
+ if (!Object.getOwnPropertyDescriptor(raw2, key)?.enumerable) {
15738
+ throw new Error(`Unrecognized key: "${String(key)}"`);
15739
+ }
15740
+ if (mask[key])
15741
+ keys.push(key);
15742
+ }
15743
+ return keys;
15676
15744
  }
15677
15745
  function omit(schema, mask) {
15678
15746
  const currDef = schema._zod.def;
@@ -15681,23 +15749,10 @@ function omit(schema, mask) {
15681
15749
  if (hasChecks) {
15682
15750
  throw new Error(".omit() cannot be used on object schemas containing refinements");
15683
15751
  }
15684
- const def = mergeDefs(schema._zod.def, {
15685
- get shape() {
15686
- const newShape = { ...schema._zod.def.shape };
15687
- for (const key of Reflect.ownKeys(mask)) {
15688
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
15689
- throw new Error(`Unrecognized key: "${String(key)}"`);
15690
- }
15691
- if (!mask[key])
15692
- continue;
15693
- delete newShape[key];
15694
- }
15695
- assignProp(this, "shape", newShape);
15696
- return newShape;
15697
- },
15698
- checks: []
15699
- });
15700
- return clone(schema, def);
15752
+ const omitted = new Set(maskedKeys(schema, mask));
15753
+ const newShape = {};
15754
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
15755
+ return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
15701
15756
  }
15702
15757
  function extend(schema, shape) {
15703
15758
  if (!isPlainObject(shape)) {
@@ -15706,34 +15761,26 @@ function extend(schema, shape) {
15706
15761
  const checks = schema._zod.def.checks;
15707
15762
  const hasChecks = checks && checks.length > 0;
15708
15763
  if (hasChecks) {
15709
- const existingShape = schema._zod.def.shape;
15764
+ const existingShape = sourceShape(schema);
15710
15765
  for (const key of Reflect.ownKeys(shape)) {
15711
15766
  if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
15712
15767
  throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
15713
15768
  }
15714
15769
  }
15715
15770
  }
15716
- const def = mergeDefs(schema._zod.def, {
15717
- get shape() {
15718
- const _shape = { ...schema._zod.def.shape, ...shape };
15719
- assignProp(this, "shape", _shape);
15720
- return _shape;
15721
- }
15722
- });
15723
- return clone(schema, def);
15771
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
15772
+ }
15773
+ function extended(schema, shape) {
15774
+ const newShape = {};
15775
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
15776
+ mirrorProps(newShape, shape);
15777
+ return newShape;
15724
15778
  }
15725
15779
  function safeExtend(schema, shape) {
15726
15780
  if (!isPlainObject(shape)) {
15727
15781
  throw new Error("Invalid input to safeExtend: expected a plain object");
15728
15782
  }
15729
- const def = mergeDefs(schema._zod.def, {
15730
- get shape() {
15731
- const _shape = { ...schema._zod.def.shape, ...shape };
15732
- assignProp(this, "shape", _shape);
15733
- return _shape;
15734
- }
15735
- });
15736
- return clone(schema, def);
15783
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
15737
15784
  }
15738
15785
  function merge(a, b) {
15739
15786
  if (!b?._zod?.def) {
@@ -15742,12 +15789,11 @@ function merge(a, b) {
15742
15789
  if (a._zod.def.checks?.length) {
15743
15790
  throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
15744
15791
  }
15792
+ const newShape = {};
15793
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
15794
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
15745
15795
  const def = mergeDefs(a._zod.def, {
15746
- get shape() {
15747
- const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
15748
- assignProp(this, "shape", _shape);
15749
- return _shape;
15750
- },
15796
+ shape: newShape,
15751
15797
  get catchall() {
15752
15798
  return b._zod.def.catchall;
15753
15799
  },
@@ -15762,67 +15808,19 @@ function partial(Class2, schema, mask, name = "partial") {
15762
15808
  if (hasChecks) {
15763
15809
  throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
15764
15810
  }
15765
- const def = mergeDefs(schema._zod.def, {
15766
- get shape() {
15767
- const oldShape = schema._zod.def.shape;
15768
- const shape = { ...oldShape };
15769
- if (mask) {
15770
- for (const key of Reflect.ownKeys(mask)) {
15771
- if (!Object.prototype.hasOwnProperty.call(oldShape, key)) {
15772
- throw new Error(`Unrecognized key: "${String(key)}"`);
15773
- }
15774
- if (!mask[key])
15775
- continue;
15776
- shape[key] = Class2 ? new Class2({
15777
- type: "optional",
15778
- innerType: oldShape[key]
15779
- }) : oldShape[key];
15780
- }
15781
- } else {
15782
- for (const key of Reflect.ownKeys(oldShape)) {
15783
- shape[key] = Class2 ? new Class2({
15784
- type: "optional",
15785
- innerType: oldShape[key]
15786
- }) : oldShape[key];
15787
- }
15788
- }
15789
- assignProp(this, "shape", shape);
15790
- return shape;
15791
- },
15792
- checks: []
15793
- });
15794
- return clone(schema, def);
15811
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
15812
+ const newShape = {};
15813
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key) => selected && !selected.has(key) ? value : new Class2({ type: "optional", innerType: value })));
15814
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
15795
15815
  }
15796
15816
  function required(Class2, schema, mask) {
15797
- const def = mergeDefs(schema._zod.def, {
15798
- get shape() {
15799
- const oldShape = schema._zod.def.shape;
15800
- const shape = { ...oldShape };
15801
- if (mask) {
15802
- for (const key of Reflect.ownKeys(mask)) {
15803
- if (!Object.prototype.hasOwnProperty.call(shape, key)) {
15804
- throw new Error(`Unrecognized key: "${String(key)}"`);
15805
- }
15806
- if (!mask[key])
15807
- continue;
15808
- shape[key] = new Class2({
15809
- type: "nonoptional",
15810
- innerType: oldShape[key]
15811
- });
15812
- }
15813
- } else {
15814
- for (const key of Reflect.ownKeys(oldShape)) {
15815
- shape[key] = new Class2({
15816
- type: "nonoptional",
15817
- innerType: oldShape[key]
15818
- });
15819
- }
15820
- }
15821
- assignProp(this, "shape", shape);
15822
- return shape;
15823
- }
15824
- });
15825
- return clone(schema, def);
15817
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
15818
+ const newShape = {};
15819
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => (
15820
+ // overwrite with non-optional
15821
+ selected && !selected.has(key) ? value : new Class2({ type: "nonoptional", innerType: value })
15822
+ ));
15823
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
15826
15824
  }
15827
15825
  function aborted(x, startIndex = 0) {
15828
15826
  if (x.aborted === true)
@@ -15872,13 +15870,18 @@ function finalizeIssue(iss, ctx, config2) {
15872
15870
  }
15873
15871
  const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
15874
15872
  const message2 = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
15875
- const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
15876
- rest.path ?? (rest.path = []);
15877
- rest.message = message2;
15873
+ const full = {};
15874
+ for (const k of Object.keys(iss)) {
15875
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
15876
+ continue;
15877
+ full[k] = iss[k];
15878
+ }
15879
+ full.path ?? (full.path = []);
15880
+ full.message = message2;
15878
15881
  if (ctx?.reportInput) {
15879
- rest.input = _input;
15882
+ full.input = iss.input;
15880
15883
  }
15881
- return rest;
15884
+ return full;
15882
15885
  }
15883
15886
  function getSizableOrigin(input) {
15884
15887
  if (input instanceof Set)
@@ -15997,6 +16000,9 @@ function members(proto, table2) {
15997
16000
  else
15998
16001
  defineBound(proto, key, desc.value);
15999
16002
  }
16003
+ for (const sym of Object.getOwnPropertySymbols(table2)) {
16004
+ defineBound(proto, sym, table2[sym]);
16005
+ }
16000
16006
  }
16001
16007
  function own(inst, key, value, enumerable = true) {
16002
16008
  Object.defineProperty(inst, key, { configurable: true, writable: true, enumerable, value });
@@ -16005,6 +16011,23 @@ function own(inst, key, value, enumerable = true) {
16005
16011
  function hide(inst, key, value) {
16006
16012
  return own(inst, key, value, false);
16007
16013
  }
16014
+ // @__NO_SIDE_EFFECTS__
16015
+ function derived(computes, table2) {
16016
+ for (const key in computes) {
16017
+ const compute = computes[key];
16018
+ Object.defineProperty(table2, key, {
16019
+ configurable: true,
16020
+ enumerable: true,
16021
+ get() {
16022
+ return own(this, key, compute(this));
16023
+ },
16024
+ set(value) {
16025
+ own(this, key, value);
16026
+ }
16027
+ });
16028
+ }
16029
+ return table2;
16030
+ }
16008
16031
  function defineBound(proto, key, fn) {
16009
16032
  Object.defineProperty(proto, key, {
16010
16033
  configurable: true,
@@ -16223,16 +16246,12 @@ var _messageDesc = {
16223
16246
  enumerable: true,
16224
16247
  configurable: true
16225
16248
  };
16226
- var _zodDesc2 = { value: void 0, enumerable: false };
16227
16249
  var _issuesDesc = { value: void 0, enumerable: false };
16228
16250
  var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
16229
16251
  var initializer = (inst, def) => {
16230
16252
  inst.name = "$ZodError";
16231
- _zodDesc2.value = inst._zod;
16232
- Object.defineProperty(inst, "_zod", _zodDesc2);
16233
16253
  _issuesDesc.value = def;
16234
16254
  Object.defineProperty(inst, "issues", _issuesDesc);
16235
- _zodDesc2.value = void 0;
16236
16255
  _issuesDesc.value = void 0;
16237
16256
  Object.defineProperty(inst, "message", _messageDesc);
16238
16257
  const proto = Object.getPrototypeOf(inst);
@@ -16368,50 +16387,95 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
16368
16387
  if (result instanceof Promise) {
16369
16388
  throw new $ZodAsyncError();
16370
16389
  }
16371
- return result.issues.length ? {
16372
- success: false,
16373
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
16374
- } : { success: true, data: result.value };
16390
+ return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
16375
16391
  };
16376
- var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
16392
+ function failure(Err, issues, ctx) {
16393
+ let error2;
16394
+ return {
16395
+ success: false,
16396
+ get error() {
16397
+ if (!error2) {
16398
+ error2 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
16399
+ issues = void 0;
16400
+ ctx = void 0;
16401
+ }
16402
+ return error2;
16403
+ },
16404
+ set error(e) {
16405
+ error2 = e;
16406
+ issues = void 0;
16407
+ ctx = void 0;
16408
+ }
16409
+ };
16410
+ }
16377
16411
  var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
16378
16412
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
16379
16413
  let result = schema._zod.run({ value, issues: [] }, ctx);
16380
16414
  if (result instanceof Promise)
16381
16415
  result = await result;
16382
- return result.issues.length ? {
16383
- success: false,
16384
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
16385
- } : { success: true, data: result.value };
16416
+ return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
16417
+ };
16418
+ var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
16419
+ var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
16420
+ var validate = ((schema, value, _ctx) => {
16421
+ const validator = schema._zod.bag.validator;
16422
+ if (validator !== void 0) {
16423
+ if (validator(value) !== COMPILE_INVALID)
16424
+ return true;
16425
+ if (validator.definite === true && _ctx === void 0)
16426
+ return false;
16427
+ }
16428
+ return validateFallback(schema, value, _ctx);
16429
+ });
16430
+ function validateFallback(schema, value, _ctx) {
16431
+ const ctx = _ctx ? { ..._ctx, async: false, abortEarly: true } : { async: false, abortEarly: true };
16432
+ const fallbackRun = schema._zod.bag.fallbackRun;
16433
+ let result;
16434
+ if (fallbackRun) {
16435
+ ctx[COMPILE_FALLBACK] = true;
16436
+ result = fallbackRun({ value, issues: [] }, ctx);
16437
+ } else {
16438
+ result = schema._zod.run({ value, issues: [] }, ctx);
16439
+ }
16440
+ if (result instanceof Promise) {
16441
+ throw new $ZodAsyncError();
16442
+ }
16443
+ return result.issues.length === 0;
16444
+ }
16445
+ var validateAsync = async (schema, value, _ctx) => {
16446
+ const ctx = _ctx ? { ..._ctx, async: true, abortEarly: true } : { async: true, abortEarly: true };
16447
+ let result = schema._zod.run({ value, issues: [] }, ctx);
16448
+ if (result instanceof Promise)
16449
+ result = await result;
16450
+ return result.issues.length === 0;
16386
16451
  };
16387
- var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
16388
16452
  var _encode = (_Err) => {
16389
- const parse3 = _parse(_Err);
16453
+ const parse2 = _parse(_Err);
16390
16454
  const fn = (schema, value, _ctx, _params) => {
16391
16455
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
16392
- return parse3(schema, value, ctx, finalizeParams(fn, _params));
16456
+ return parse2(schema, value, ctx, finalizeParams(fn, _params));
16393
16457
  };
16394
16458
  return fn;
16395
16459
  };
16396
16460
  var _decode = (_Err) => {
16397
- const parse3 = _parse(_Err);
16461
+ const parse2 = _parse(_Err);
16398
16462
  const fn = (schema, value, _ctx, _params) => {
16399
- return parse3(schema, value, _ctx, finalizeParams(fn, _params));
16463
+ return parse2(schema, value, _ctx, finalizeParams(fn, _params));
16400
16464
  };
16401
16465
  return fn;
16402
16466
  };
16403
16467
  var _encodeAsync = (_Err) => {
16404
- const parseAsync3 = _parseAsync(_Err);
16468
+ const parseAsync2 = _parseAsync(_Err);
16405
16469
  const fn = async (schema, value, _ctx, _params) => {
16406
16470
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
16407
- return await parseAsync3(schema, value, ctx, finalizeParams(fn, _params));
16471
+ return await parseAsync2(schema, value, ctx, finalizeParams(fn, _params));
16408
16472
  };
16409
16473
  return fn;
16410
16474
  };
16411
16475
  var _decodeAsync = (_Err) => {
16412
- const parseAsync3 = _parseAsync(_Err);
16476
+ const parseAsync2 = _parseAsync(_Err);
16413
16477
  const fn = async (schema, value, _ctx, _params) => {
16414
- return await parseAsync3(schema, value, _ctx, finalizeParams(fn, _params));
16478
+ return await parseAsync2(schema, value, _ctx, finalizeParams(fn, _params));
16415
16479
  };
16416
16480
  return fn;
16417
16481
  };
@@ -16447,8 +16511,8 @@ var uuid = (version2) => {
16447
16511
  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)$/;
16448
16512
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
16449
16513
  };
16450
- var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
16451
- var _emoji = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
16514
+ var email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
16515
+ var _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
16452
16516
  function emoji() {
16453
16517
  return new RegExp(_emoji, "u");
16454
16518
  }
@@ -16457,7 +16521,7 @@ var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|(
16457
16521
  var 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])$/;
16458
16522
  var cidrv6 = /^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
16459
16523
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
16460
- var base64url = /^[A-Za-z0-9_-]*$/;
16524
+ var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
16461
16525
  var httpProtocol = /^https?$/;
16462
16526
  var e164 = /^\+[1-9]\d{6,14}$/;
16463
16527
  var 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])))`;
@@ -16481,10 +16545,7 @@ function datetime(args) {
16481
16545
  const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
16482
16546
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
16483
16547
  }
16484
- var string = (params) => {
16485
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
16486
- return new RegExp(`^${regex}$`);
16487
- };
16548
+ var anyString = /^[\s\S]{0,}$/;
16488
16549
  var bigint = /^-?\d+n?$/;
16489
16550
  var integer = /^-?\d+$/;
16490
16551
  var number = /^-?\d+(?:\.\d+)?$/;
@@ -16512,16 +16573,6 @@ var numericOriginMap = {
16512
16573
  var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
16513
16574
  $ZodCheck.init(inst, def);
16514
16575
  const origin = numericOriginMap[typeof def.value];
16515
- inst._zod.onattach.push((inst2) => {
16516
- const bag = inst2._zod.bag;
16517
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
16518
- if (def.value < curr) {
16519
- if (def.inclusive)
16520
- bag.maximum = def.value;
16521
- else
16522
- bag.exclusiveMaximum = def.value;
16523
- }
16524
- });
16525
16576
  inst._zod.check = (payload) => {
16526
16577
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
16527
16578
  return;
@@ -16540,16 +16591,6 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
16540
16591
  var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
16541
16592
  $ZodCheck.init(inst, def);
16542
16593
  const origin = numericOriginMap[typeof def.value];
16543
- inst._zod.onattach.push((inst2) => {
16544
- const bag = inst2._zod.bag;
16545
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
16546
- if (def.value > curr) {
16547
- if (def.inclusive)
16548
- bag.minimum = def.value;
16549
- else
16550
- bag.exclusiveMinimum = def.value;
16551
- }
16552
- });
16553
16594
  inst._zod.check = (payload) => {
16554
16595
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
16555
16596
  return;
@@ -16567,10 +16608,6 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
16567
16608
  });
16568
16609
  var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
16569
16610
  $ZodCheck.init(inst, def);
16570
- inst._zod.onattach.push((inst2) => {
16571
- var _a3;
16572
- (_a3 = inst2._zod.bag).multipleOf ?? (_a3.multipleOf = def.value);
16573
- });
16574
16611
  inst._zod.check = (payload) => {
16575
16612
  if (typeof payload.value !== typeof def.value)
16576
16613
  throw new Error("Cannot mix number and bigint in multiple_of check.");
@@ -16596,14 +16633,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
16596
16633
  const isInt = def.format?.includes("int");
16597
16634
  const origin = isInt ? "int" : "number";
16598
16635
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
16599
- inst._zod.onattach.push((inst2) => {
16600
- const bag = inst2._zod.bag;
16601
- bag.format = def.format;
16602
- bag.minimum = minimum;
16603
- bag.maximum = maximum;
16604
- if (isInt)
16605
- bag.pattern = integer;
16606
- });
16607
16636
  inst._zod.check = (payload) => {
16608
16637
  const input = payload.value;
16609
16638
  if (isInt) {
@@ -16673,11 +16702,6 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
16673
16702
  var _a3;
16674
16703
  $ZodCheck.init(inst, def);
16675
16704
  (_a3 = inst._zod.def).when ?? (_a3.when = _whenHasLength);
16676
- inst._zod.onattach.push((inst2) => {
16677
- const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
16678
- if (def.maximum < curr)
16679
- inst2._zod.bag.maximum = def.maximum;
16680
- });
16681
16705
  inst._zod.check = (payload) => {
16682
16706
  const input = payload.value;
16683
16707
  const units = input.length;
@@ -16700,11 +16724,6 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
16700
16724
  var _a3;
16701
16725
  $ZodCheck.init(inst, def);
16702
16726
  (_a3 = inst._zod.def).when ?? (_a3.when = _whenHasLength);
16703
- inst._zod.onattach.push((inst2) => {
16704
- const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
16705
- if (def.minimum > curr)
16706
- inst2._zod.bag.minimum = def.minimum;
16707
- });
16708
16727
  inst._zod.check = (payload) => {
16709
16728
  const input = payload.value;
16710
16729
  const units = input.length;
@@ -16727,12 +16746,6 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
16727
16746
  var _a3;
16728
16747
  $ZodCheck.init(inst, def);
16729
16748
  (_a3 = inst._zod.def).when ?? (_a3.when = _whenHasLength);
16730
- inst._zod.onattach.push((inst2) => {
16731
- const bag = inst2._zod.bag;
16732
- bag.minimum = def.length;
16733
- bag.maximum = def.length;
16734
- bag.length = def.length;
16735
- });
16736
16749
  inst._zod.check = (payload) => {
16737
16750
  const input = payload.value;
16738
16751
  const units = input.length;
@@ -16755,14 +16768,6 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
16755
16768
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
16756
16769
  var _a3, _b;
16757
16770
  $ZodCheck.init(inst, def);
16758
- inst._zod.onattach.push((inst2) => {
16759
- const bag = inst2._zod.bag;
16760
- bag.format = def.format;
16761
- if (def.pattern) {
16762
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
16763
- bag.patterns.add(def.pattern);
16764
- }
16765
- });
16766
16771
  if (def.pattern)
16767
16772
  (_a3 = inst._zod).check ?? (_a3.check = (payload) => {
16768
16773
  def.pattern.lastIndex = 0;
@@ -16812,11 +16817,6 @@ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst,
16812
16817
  const escapedRegex = escapeRegex(def.includes);
16813
16818
  const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
16814
16819
  def.pattern = pattern;
16815
- inst._zod.onattach.push((inst2) => {
16816
- const bag = inst2._zod.bag;
16817
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
16818
- bag.patterns.add(pattern);
16819
- });
16820
16820
  inst._zod.check = (payload) => {
16821
16821
  if (payload.value.includes(def.includes, def.position))
16822
16822
  return;
@@ -16835,11 +16835,6 @@ var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (i
16835
16835
  $ZodCheck.init(inst, def);
16836
16836
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
16837
16837
  def.pattern ?? (def.pattern = pattern);
16838
- inst._zod.onattach.push((inst2) => {
16839
- const bag = inst2._zod.bag;
16840
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
16841
- bag.patterns.add(pattern);
16842
- });
16843
16838
  inst._zod.check = (payload) => {
16844
16839
  if (payload.value.startsWith(def.prefix))
16845
16840
  return;
@@ -16858,11 +16853,6 @@ var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst,
16858
16853
  $ZodCheck.init(inst, def);
16859
16854
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
16860
16855
  def.pattern ?? (def.pattern = pattern);
16861
- inst._zod.onattach.push((inst2) => {
16862
- const bag = inst2._zod.bag;
16863
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
16864
- bag.patterns.add(pattern);
16865
- });
16866
16856
  inst._zod.check = (payload) => {
16867
16857
  if (payload.value.endsWith(def.suffix))
16868
16858
  return;
@@ -16892,10 +16882,14 @@ var Doc = class {
16892
16882
  this.args = args;
16893
16883
  this.closed = closed;
16894
16884
  }
16885
+ // the compiler catches a child's throw and keeps writing into this doc, so the indent has to unwind with it
16895
16886
  indented(fn) {
16896
16887
  this.indent += 1;
16897
- fn(this);
16898
- this.indent -= 1;
16888
+ try {
16889
+ fn(this);
16890
+ } finally {
16891
+ this.indent -= 1;
16892
+ }
16899
16893
  }
16900
16894
  write(arg) {
16901
16895
  if (typeof arg === "function") {
@@ -16924,8 +16918,8 @@ ${content.join("\n")}
16924
16918
  // node_modules/zod/v4/core/versions.js
16925
16919
  var version = {
16926
16920
  major: 4,
16927
- minor: 5,
16928
- patch: 4
16921
+ minor: 6,
16922
+ patch: 2
16929
16923
  };
16930
16924
 
16931
16925
  // node_modules/zod/v4/core/schemas.js
@@ -17038,15 +17032,22 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
17038
17032
  own(this, "~standard", value);
17039
17033
  }
17040
17034
  });
17041
- var toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
17035
+ var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
17036
+ async function validateAsync2(inst, value) {
17037
+ const ctx = { async: true };
17038
+ return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
17039
+ }
17042
17040
  function standardProps(inst) {
17043
17041
  return {
17044
17042
  validate: (value) => {
17043
+ const ctx = { async: false };
17045
17044
  try {
17046
- return toStandardResult(safeParse(inst, value));
17045
+ const r = inst._zod.run({ value, issues: [] }, ctx);
17046
+ if (!(r instanceof Promise))
17047
+ return toStandardResult(r, ctx);
17047
17048
  } catch (_) {
17048
- return safeParseAsync(inst, value).then(toStandardResult);
17049
17049
  }
17050
+ return validateAsync2(inst, value);
17050
17051
  },
17051
17052
  vendor: "zod",
17052
17053
  version: 1
@@ -17054,7 +17055,7 @@ function standardProps(inst) {
17054
17055
  }
17055
17056
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
17056
17057
  $ZodType.init(inst, def);
17057
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
17058
+ inst._zod.pattern = def.pattern ?? anyString;
17058
17059
  inst._zod.parse = (payload, _) => {
17059
17060
  if (def.coerce)
17060
17061
  try {
@@ -17223,12 +17224,6 @@ var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
17223
17224
  var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
17224
17225
  def.pattern ?? (def.pattern = datetime(def));
17225
17226
  $ZodStringFormat.init(inst, def);
17226
- if (def.local || def.precision === -1) {
17227
- inst._zod.bag.laxFormat = true;
17228
- inst._zod.onattach.push((s) => {
17229
- s._zod.bag.laxFormat = true;
17230
- });
17231
- }
17232
17227
  });
17233
17228
  var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
17234
17229
  def.pattern ?? (def.pattern = date);
@@ -17245,7 +17240,6 @@ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def
17245
17240
  var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
17246
17241
  def.pattern ?? (def.pattern = ipv4);
17247
17242
  $ZodStringFormat.init(inst, def);
17248
- inst._zod.bag.format = `ipv4`;
17249
17243
  });
17250
17244
  var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
17251
17245
  function isValidIPv6(value) {
@@ -17261,7 +17255,6 @@ function isValidIPv6(value) {
17261
17255
  var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
17262
17256
  def.pattern ?? (def.pattern = ipv6);
17263
17257
  $ZodStringFormat.init(inst, def);
17264
- inst._zod.bag.format = `ipv6`;
17265
17258
  inst._zod.check = (payload) => {
17266
17259
  if (!isValidIPv6(payload.value)) {
17267
17260
  payload.issues.push({
@@ -17321,10 +17314,10 @@ function isValidBase64(data) {
17321
17314
  return false;
17322
17315
  }
17323
17316
  }
17317
+ var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
17324
17318
  var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
17325
- def.pattern ?? (def.pattern = base64);
17319
+ def.pattern ?? (def.pattern = base64Charset);
17326
17320
  $ZodStringFormat.init(inst, def);
17327
- inst._zod.bag.contentEncoding = "base64";
17328
17321
  inst._zod.check = (payload) => {
17329
17322
  if (isValidBase64(payload.value))
17330
17323
  return;
@@ -17337,17 +17330,17 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
17337
17330
  });
17338
17331
  };
17339
17332
  });
17333
+ var base64urlCharset = /^[A-Za-z0-9_-]*$/;
17340
17334
  function isValidBase64URL(data) {
17341
- if (!base64url.test(data))
17335
+ if (!base64urlCharset.test(data))
17342
17336
  return false;
17343
17337
  const base642 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
17344
17338
  const padded = base642.padEnd(Math.ceil(base642.length / 4) * 4, "=");
17345
17339
  return isValidBase64(padded);
17346
17340
  }
17347
17341
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
17348
- def.pattern ?? (def.pattern = base64url);
17342
+ def.pattern ?? (def.pattern = base64urlCharset);
17349
17343
  $ZodStringFormat.init(inst, def);
17350
- inst._zod.bag.contentEncoding = "base64url";
17351
17344
  inst._zod.check = (payload) => {
17352
17345
  if (isValidBase64URL(payload.value))
17353
17346
  return;
@@ -17400,7 +17393,7 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
17400
17393
  });
17401
17394
  var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
17402
17395
  $ZodType.init(inst, def);
17403
- inst._zod.pattern = inst._zod.bag.pattern ?? number;
17396
+ inst._zod.pattern = number;
17404
17397
  inst._zod.parse = (payload, _ctx) => {
17405
17398
  if (def.coerce)
17406
17399
  try {
@@ -17551,6 +17544,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
17551
17544
  }
17552
17545
  payload.value = memo3 ? memo3.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
17553
17546
  const proms = [];
17547
+ const abortEarly = ctx?.abortEarly;
17554
17548
  for (let i = 0; i < input.length; i++) {
17555
17549
  const item = input[i];
17556
17550
  const result = def.element._zod.run({
@@ -17561,6 +17555,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
17561
17555
  proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
17562
17556
  } else {
17563
17557
  handleArrayResult(result, payload, i);
17558
+ if (abortEarly && result.issues.length !== 0 && aborted(result))
17559
+ break;
17564
17560
  }
17565
17561
  }
17566
17562
  if (proms.length) {
@@ -17593,7 +17589,7 @@ function handlePropertyResult(result, final, key, input, optin, optout) {
17593
17589
  return;
17594
17590
  }
17595
17591
  if (result.value === void 0) {
17596
- if (isPresent) {
17592
+ if (isPresent || optin === "defaulted" && !isOptionalOut) {
17597
17593
  final.value[key] = void 0;
17598
17594
  }
17599
17595
  } else {
@@ -17622,14 +17618,20 @@ function normalizeDef(def) {
17622
17618
  optionalKeys: new Set(okeys)
17623
17619
  };
17624
17620
  }
17625
- function handleCatchall(proms, input, payload, ctx, def, inst) {
17621
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
17626
17622
  const unrecognized = [];
17627
17623
  const keySet = def.keySet;
17628
17624
  const _catchall = def.catchall._zod;
17629
17625
  const t = _catchall.def.type;
17630
17626
  const optin = _catchall.optin;
17631
17627
  const optout = _catchall.optout;
17628
+ let seen = 0;
17632
17629
  for (const key in input) {
17630
+ if (abortEarly && payload.issues.length !== seen) {
17631
+ if (aborted(payload, seen))
17632
+ break;
17633
+ seen = payload.issues.length;
17634
+ }
17633
17635
  if (keySet.has(key))
17634
17636
  continue;
17635
17637
  if (key === "__proto__") {
@@ -17664,23 +17666,19 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
17664
17666
  return payload;
17665
17667
  });
17666
17668
  }
17667
- var propShapes = /* @__PURE__ */ new WeakMap();
17668
17669
  var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
17669
17670
  $ZodType.init(inst, def);
17670
17671
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
17671
- if (!desc?.get) {
17672
- const sh = def.shape;
17673
- propShapes.set(def, sh);
17674
- Object.defineProperty(def, "shape", {
17675
- get: () => {
17676
- const newSh = { ...sh };
17677
- Object.defineProperty(def, "shape", {
17678
- value: newSh
17679
- });
17680
- propShapes.set(def, newSh);
17681
- return newSh;
17682
- }
17683
- });
17672
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
17673
+ if (sh) {
17674
+ const get = () => {
17675
+ const newSh = { ...sh };
17676
+ Object.defineProperty(def, "shape", { value: newSh });
17677
+ get.raw = newSh;
17678
+ return newSh;
17679
+ };
17680
+ get.raw = sh;
17681
+ Object.defineProperty(def, "shape", { get });
17684
17682
  }
17685
17683
  const _normalized = cached(() => normalizeDef(def));
17686
17684
  defineLazyInternal(inst, "propValues", (zod) => {
@@ -17720,7 +17718,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
17720
17718
  payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
17721
17719
  const proms = [];
17722
17720
  const shape = value.shape;
17721
+ const abortEarly = ctx?.abortEarly;
17722
+ let seen = payload.issues.length;
17723
17723
  for (const key of value.allKeys) {
17724
+ if (abortEarly && payload.issues.length !== seen) {
17725
+ if (aborted(payload, seen))
17726
+ break;
17727
+ seen = payload.issues.length;
17728
+ }
17724
17729
  if (key === "__proto__")
17725
17730
  continue;
17726
17731
  const el = shape[key];
@@ -17736,7 +17741,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
17736
17741
  if (!catchall) {
17737
17742
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
17738
17743
  }
17739
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
17744
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
17740
17745
  };
17741
17746
  });
17742
17747
  var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -17750,10 +17755,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
17750
17755
  const doc = new Doc(["payload", "ctx"], { shape, inst, memo: memo3, syms });
17751
17756
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
17752
17757
  const prefixStr = (id, k) => `
17758
+ let ${id}_ab = false;
17753
17759
  for (let i = 0; i < ${id}.issues.length; i++) {
17754
17760
  const iss = ${id}.issues[i];
17755
17761
  iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
17756
17762
  payload.issues.push(iss);
17763
+ if (iss.continue !== true) ${id}_ab = true;
17764
+ }
17765
+ if (${id}_ab && ctx && ctx.abortEarly) {
17766
+ payload.value = newResult;
17767
+ return payload;
17757
17768
  }`;
17758
17769
  doc.write(`const input = payload.value;`);
17759
17770
  const ids = /* @__PURE__ */ Object.create(null);
@@ -17799,6 +17810,10 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
17799
17810
  input: undefined,
17800
17811
  path: [${k}]
17801
17812
  });
17813
+ if (ctx && ctx.abortEarly) {
17814
+ payload.value = newResult;
17815
+ return payload;
17816
+ }
17802
17817
  }
17803
17818
 
17804
17819
  if (${id}_present) {
@@ -17810,16 +17825,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
17810
17825
  doc.write(`
17811
17826
  if (${id}.issues.length) {${prefixStr(id, k)}
17812
17827
  }
17813
-
17814
- if (${id}.value === undefined) {
17815
- if (${isPresent}) {
17816
- newResult[${k}] = undefined;
17817
- }
17828
+ `);
17829
+ if (optin === "defaulted") {
17830
+ doc.write(`newResult[${k}] = ${id}.value;`);
17818
17831
  } else {
17832
+ doc.write(`
17833
+ if (${id}.value !== undefined || ${isPresent}) {
17819
17834
  newResult[${k}] = ${id}.value;
17820
17835
  }
17821
-
17822
17836
  `);
17837
+ }
17823
17838
  }
17824
17839
  }
17825
17840
  doc.write(`payload.value = newResult;`);
@@ -17851,7 +17866,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
17851
17866
  payload = fastpass(payload, ctx);
17852
17867
  if (!catchall)
17853
17868
  return payload;
17854
- return handleCatchall([], input, payload, ctx, value, inst);
17869
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
17855
17870
  }
17856
17871
  return superParse(payload, ctx);
17857
17872
  };
@@ -17921,16 +17936,37 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
17921
17936
  });
17922
17937
  };
17923
17938
  });
17939
+ function discriminatorMap(def) {
17940
+ const map = /* @__PURE__ */ new Map();
17941
+ for (const option of def.options) {
17942
+ const values = option._zod.propValues?.[def.discriminator];
17943
+ if (!values || values.size === 0)
17944
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
17945
+ for (const value of values) {
17946
+ if (map.has(value)) {
17947
+ if (value !== void 0)
17948
+ throw new Error(`Duplicate discriminator value "${String(value)}"`);
17949
+ map.set(value, null);
17950
+ } else {
17951
+ map.set(value, option);
17952
+ }
17953
+ }
17954
+ }
17955
+ return map;
17956
+ }
17924
17957
  var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
17925
17958
  def.inclusive = false;
17926
17959
  $ZodUnion.init(inst, def);
17927
17960
  const _super = inst._zod.parse;
17928
17961
  defineLazyInternal(inst, "propValues", (zod) => {
17929
17962
  const propValues = {};
17963
+ let undefinedCount = 0;
17930
17964
  for (const option of zod.def.options) {
17931
17965
  const pv = option._zod.propValues;
17932
17966
  if (!pv || Object.keys(pv).length === 0)
17933
17967
  throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
17968
+ if (pv[zod.def.discriminator]?.has(void 0))
17969
+ undefinedCount++;
17934
17970
  for (const [k, v] of Object.entries(pv)) {
17935
17971
  if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
17936
17972
  assignProp(propValues, k, /* @__PURE__ */ new Set());
@@ -17940,30 +17976,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
17940
17976
  }
17941
17977
  }
17942
17978
  }
17979
+ if (!zod.def.unionFallback && undefinedCount > 1)
17980
+ propValues[zod.def.discriminator]?.delete(void 0);
17943
17981
  return propValues;
17944
17982
  });
17945
17983
  def.options.forEach((option, i) => {
17946
- const propShape = propShapes.get(option._zod.def);
17984
+ const propShape = rawShape(option._zod.def);
17947
17985
  if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
17948
17986
  throw new Error(`Invalid discriminated union option at index "${i}"`);
17949
17987
  }
17950
17988
  });
17951
- const disc = cached(() => {
17952
- const opts = def.options;
17953
- const map = /* @__PURE__ */ new Map();
17954
- for (const o of opts) {
17955
- const values = o._zod.propValues?.[def.discriminator];
17956
- if (!values || values.size === 0)
17957
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
17958
- for (const v of values) {
17959
- if (map.has(v)) {
17960
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
17961
- }
17962
- map.set(v, o);
17963
- }
17964
- }
17965
- return map;
17966
- });
17989
+ const disc = cached(() => discriminatorMap(def));
17967
17990
  inst._zod.parse = (payload, ctx) => {
17968
17991
  const input = payload.value;
17969
17992
  if (!isObject(input)) {
@@ -17975,8 +17998,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
17975
17998
  });
17976
17999
  return payload;
17977
18000
  }
17978
- const opt = disc.value.get(input?.[def.discriminator]);
17979
- if (opt) {
18001
+ const value = input?.[def.discriminator];
18002
+ const opt = disc.value.get(value);
18003
+ if (opt && (value !== void 0 || ctx.direction !== "backward")) {
17980
18004
  return opt._zod.run(payload, ctx);
17981
18005
  }
17982
18006
  if (def.unionFallback || ctx.direction === "backward") {
@@ -17987,7 +18011,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
17987
18011
  errors: [],
17988
18012
  note: "No matching discriminator",
17989
18013
  discriminator: def.discriminator,
17990
- options: Array.from(disc.value.keys()),
18014
+ options: Array.from(disc.value.keys()).filter((value2) => disc.value.get(value2) !== null),
17991
18015
  input,
17992
18016
  path: [def.discriminator],
17993
18017
  inst
@@ -18269,8 +18293,10 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
18269
18293
  const values = getEnumValues(def.entries);
18270
18294
  const valuesSet = new Set(values);
18271
18295
  inst._zod.values = valuesSet;
18272
- const patternValues = values.filter((k) => propertyKeyTypes.has(typeof k));
18273
- inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
18296
+ defineLazyInternal(inst, "pattern", (zod) => {
18297
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
18298
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
18299
+ });
18274
18300
  inst._zod.parse = (payload, _ctx) => {
18275
18301
  const input = payload.value;
18276
18302
  if (valuesSet.has(input)) {
@@ -18289,7 +18315,10 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
18289
18315
  $ZodType.init(inst, def);
18290
18316
  const values = new Set(def.values);
18291
18317
  inst._zod.values = values;
18292
- inst._zod.pattern = new RegExp(def.values.length ? `^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
18318
+ defineLazyInternal(inst, "pattern", (zod) => {
18319
+ const vals = zod.def.values;
18320
+ return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
18321
+ });
18293
18322
  inst._zod.parse = (payload, _ctx) => {
18294
18323
  const input = payload.value;
18295
18324
  if (values.has(input)) {
@@ -18590,31 +18619,59 @@ var $ZodCyclicError = class extends Error {
18590
18619
  };
18591
18620
  var STATE = "~memo";
18592
18621
  var NO_ISSUES = [];
18622
+ function isRef(value) {
18623
+ return value !== null && (typeof value === "object" || typeof value === "function");
18624
+ }
18593
18625
  function cloneIssues(issues) {
18594
18626
  return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
18595
18627
  }
18596
18628
  var recursive = /* @__PURE__ */ new WeakMap();
18597
- function isRecursive(inst, stack) {
18598
- const cached3 = recursive.get(inst);
18599
- if (cached3 !== void 0)
18600
- return cached3;
18629
+ var NONE = 0;
18630
+ var ASSUMED = 1;
18631
+ var PROVEN = 2;
18632
+ function isRecursive(inst, stack, resolve) {
18633
+ const cached2 = recursive.get(inst);
18634
+ if (cached2 !== void 0)
18635
+ return cached2 ? PROVEN : NONE;
18601
18636
  if (stack.has(inst))
18602
- return true;
18637
+ return PROVEN;
18603
18638
  stack.add(inst);
18604
- let result = false;
18639
+ let result = NONE;
18605
18640
  const check = (child) => {
18606
- if (!result && child?._zod && isRecursive(child, stack))
18607
- result = true;
18641
+ if (result !== PROVEN && child?._zod) {
18642
+ const answer = isRecursive(child, stack, resolve);
18643
+ if (answer > result)
18644
+ result = answer;
18645
+ }
18646
+ };
18647
+ const shape = (sh, spread) => {
18648
+ let answer = NONE;
18649
+ for (const key of Reflect.ownKeys(sh)) {
18650
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
18651
+ if (spread && !desc.enumerable)
18652
+ continue;
18653
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
18654
+ if (child > answer)
18655
+ answer = child;
18656
+ }
18657
+ return answer;
18658
+ };
18659
+ const merge2 = (answer) => {
18660
+ if (answer > result)
18661
+ result = answer;
18608
18662
  };
18609
18663
  const def = inst._zod.def;
18610
18664
  const kind = def.type;
18611
18665
  switch (kind) {
18612
18666
  case "object": {
18613
- for (const key of Reflect.ownKeys(def.shape))
18614
- check(def.shape[key]);
18667
+ const raw2 = rawShape(def);
18668
+ merge2(raw2 ? shape(raw2, true) : ASSUMED);
18615
18669
  check(def.catchall);
18616
18670
  break;
18617
18671
  }
18672
+ case "properties":
18673
+ merge2(shape(def.shape, false));
18674
+ break;
18618
18675
  case "array":
18619
18676
  check(def.element);
18620
18677
  break;
@@ -18658,10 +18715,12 @@ function isRecursive(inst, stack) {
18658
18715
  check(def.input);
18659
18716
  check(def.output);
18660
18717
  break;
18661
- // reading `_zod.innerType` resolves the getter once and caches it
18662
- case "lazy":
18663
- check(inst._zod.innerType);
18718
+ // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
18719
+ case "lazy": {
18720
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
18721
+ merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
18664
18722
  break;
18723
+ }
18665
18724
  // a leaf by choice: `parts` are regex fragments, not data positions
18666
18725
  case "template_literal":
18667
18726
  // leaves
@@ -18703,13 +18762,17 @@ function isRecursive(inst, stack) {
18703
18762
  }
18704
18763
  }
18705
18764
  stack.delete(inst);
18706
- recursive.set(inst, result);
18707
- return result;
18765
+ return settle(inst, result);
18766
+ }
18767
+ function settle(inst, answer) {
18768
+ if (answer !== ASSUMED)
18769
+ recursive.set(inst, answer === PROVEN);
18770
+ return answer;
18708
18771
  }
18709
18772
  function bucketFor(state, inst) {
18710
18773
  let bucket = state.buckets.get(inst);
18711
18774
  if (!bucket) {
18712
- bucket = /* @__PURE__ */ new Map();
18775
+ bucket = /* @__PURE__ */ new WeakMap();
18713
18776
  state.buckets.set(inst, bucket);
18714
18777
  }
18715
18778
  return bucket;
@@ -18745,6 +18808,7 @@ var memo = {
18745
18808
  attach(inst) {
18746
18809
  var _a3;
18747
18810
  let isRecursiveInst;
18811
+ let rechecked = false;
18748
18812
  let lastCtx;
18749
18813
  let lastBucket;
18750
18814
  (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
@@ -18752,20 +18816,24 @@ var memo = {
18752
18816
  const base = inst._zod.parse;
18753
18817
  const wrapped = (payload, ctx) => {
18754
18818
  if (isRecursiveInst === void 0) {
18755
- isRecursiveInst = isRecursive(inst, /* @__PURE__ */ new Set());
18756
- if (!isRecursiveInst) {
18819
+ const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
18820
+ if (walked === NONE) {
18757
18821
  inst._zod.parse = base;
18758
18822
  if (inst._zod.run === wrapped)
18759
18823
  inst._zod.run = base;
18760
18824
  return base(payload, ctx);
18761
18825
  }
18826
+ if (walked === PROVEN || rechecked)
18827
+ isRecursiveInst = true;
18828
+ else
18829
+ rechecked = true;
18762
18830
  }
18763
18831
  const input = payload.value;
18764
- if (input === null || typeof input !== "object")
18832
+ if (!isRef(input))
18765
18833
  return base(payload, ctx);
18766
18834
  let state = ctx[STATE];
18767
18835
  if (!state) {
18768
- state = { buckets: /* @__PURE__ */ new Map(), backEdges: void 0 };
18836
+ state = { buckets: /* @__PURE__ */ new WeakMap(), backEdges: void 0 };
18769
18837
  ctx[STATE] = state;
18770
18838
  }
18771
18839
  let bucket;
@@ -18784,7 +18852,7 @@ var memo = {
18784
18852
  payload.issues.push(...cloneIssues(hit.issues));
18785
18853
  } else {
18786
18854
  payload.memo = true;
18787
- state.backEdges ?? (state.backEdges = /* @__PURE__ */ new Set());
18855
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
18788
18856
  state.backEdges.add(hit.value);
18789
18857
  }
18790
18858
  return payload;
@@ -18816,7 +18884,7 @@ function memoizer() {
18816
18884
  }
18817
18885
  function isBackEdge(ctx, value) {
18818
18886
  const backEdges = ctx[STATE]?.backEdges;
18819
- return backEdges !== void 0 && value !== null && typeof value === "object" && backEdges.has(value);
18887
+ return backEdges !== void 0 && isRef(value) && backEdges.has(value);
18820
18888
  }
18821
18889
 
18822
18890
  // node_modules/zod/v4/locales/en.js
@@ -18860,6 +18928,7 @@ var error = () => {
18860
18928
  json_string: "JSON string",
18861
18929
  e164: "E.164 number",
18862
18930
  credit_card: "credit card number",
18931
+ iban: "IBAN",
18863
18932
  jwt: "JWT",
18864
18933
  template_literal: "input"
18865
18934
  };
@@ -19611,7 +19680,7 @@ function handleUnrepresentable(schema, ctx, json, params, message2) {
19611
19680
  Object.assign(json, result);
19612
19681
  return true;
19613
19682
  }
19614
- function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
19683
+ function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
19615
19684
  var _a3;
19616
19685
  const def = schema._zod.def;
19617
19686
  const seen = ctx.seen.get(schema);
@@ -19650,7 +19719,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
19650
19719
  if (parent) {
19651
19720
  if (!result.ref)
19652
19721
  result.ref = parent;
19653
- process2(parent, ctx, params);
19722
+ processSchema(parent, ctx, params);
19654
19723
  ctx.seen.get(parent).isParent = true;
19655
19724
  }
19656
19725
  }
@@ -19757,7 +19826,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19757
19826
  if (seen.count > 1) {
19758
19827
  if (ctx.reused === "ref") {
19759
19828
  extractToDef(entry);
19760
- continue;
19761
19829
  }
19762
19830
  }
19763
19831
  }
@@ -20085,19 +20153,107 @@ function isTransforming(_schema, _ctx) {
20085
20153
  }
20086
20154
  var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
20087
20155
  const ctx = initializeContext({ ...params, processors });
20088
- process2(schema, ctx);
20156
+ processSchema(schema, ctx);
20089
20157
  extractDefs(ctx, schema);
20090
20158
  return finalize(ctx, schema);
20091
20159
  };
20092
20160
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
20093
20161
  const { libraryOptions, target } = params ?? {};
20094
20162
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
20095
- process2(schema, ctx);
20163
+ processSchema(schema, ctx);
20096
20164
  extractDefs(ctx, schema);
20097
20165
  return finalize(ctx, schema);
20098
20166
  };
20099
20167
 
20100
20168
  // node_modules/zod/v4/core/json-schema-processors.js
20169
+ var narrowMin = (agg, key, value) => {
20170
+ if (agg[key] === void 0 || value > agg[key])
20171
+ agg[key] = value;
20172
+ };
20173
+ var narrowMax = (agg, key, value) => {
20174
+ if (agg[key] === void 0 || value < agg[key])
20175
+ agg[key] = value;
20176
+ };
20177
+ var narrowBoth = (agg, value) => {
20178
+ narrowMin(agg, "minimum", value);
20179
+ narrowMax(agg, "maximum", value);
20180
+ };
20181
+ var addDivisor = (agg, value) => {
20182
+ agg.multipleOf ?? (agg.multipleOf = []);
20183
+ if (!agg.multipleOf.includes(value))
20184
+ agg.multipleOf.push(value);
20185
+ };
20186
+ var addPattern = (agg, pattern) => {
20187
+ agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
20188
+ agg.patterns.add(pattern);
20189
+ };
20190
+ var intersectMime = (agg, mime) => {
20191
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
20192
+ };
20193
+ var setFormat = (agg, format) => {
20194
+ agg.format = format;
20195
+ if (format.includes("int"))
20196
+ agg.isInt = true;
20197
+ };
20198
+ var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
20199
+ var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
20200
+ var formatContributor = (ranges) => (agg, def) => {
20201
+ setFormat(agg, def.format);
20202
+ const [minimum, maximum] = ranges[def.format];
20203
+ narrowMin(agg, "minimum", minimum);
20204
+ narrowMax(agg, "maximum", maximum);
20205
+ };
20206
+ var contributors = {
20207
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
20208
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
20209
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
20210
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
20211
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
20212
+ min_length: minContributor,
20213
+ max_length: maxContributor,
20214
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
20215
+ min_size: minContributor,
20216
+ max_size: maxContributor,
20217
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
20218
+ string_format: (agg, def) => {
20219
+ setFormat(agg, def.format);
20220
+ if (def.pattern)
20221
+ addPattern(agg, def.pattern);
20222
+ if (def.format === "base64" || def.format === "base64url")
20223
+ agg.contentEncoding = def.format;
20224
+ if (def.local || def.precision === -1)
20225
+ agg.laxFormat = true;
20226
+ },
20227
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
20228
+ };
20229
+ function aggregateChecks(schema) {
20230
+ const agg = {};
20231
+ const def = schema._zod.def;
20232
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
20233
+ for (const ch of list)
20234
+ contributors[ch._zod.def.check]?.(agg, ch._zod.def);
20235
+ const bag = schema._zod.bag;
20236
+ if (bag.minimum !== void 0)
20237
+ narrowMin(agg, "minimum", bag.minimum);
20238
+ if (bag.exclusiveMinimum !== void 0)
20239
+ narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
20240
+ if (bag.maximum !== void 0)
20241
+ narrowMax(agg, "maximum", bag.maximum);
20242
+ if (bag.exclusiveMaximum !== void 0)
20243
+ narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
20244
+ if (bag.multipleOf !== void 0)
20245
+ addDivisor(agg, bag.multipleOf);
20246
+ if (bag.format !== void 0) {
20247
+ agg.format ?? (agg.format = bag.format);
20248
+ if (bag.format.includes("int"))
20249
+ agg.isInt = true;
20250
+ }
20251
+ if (bag.mime)
20252
+ intersectMime(agg, bag.mime);
20253
+ for (const pattern of bag.patterns ?? [])
20254
+ addPattern(agg, pattern);
20255
+ return agg;
20256
+ }
20101
20257
  var formatMap = {
20102
20258
  guid: "uuid",
20103
20259
  url: "uri",
@@ -20106,10 +20262,15 @@ var formatMap = {
20106
20262
  regex: ""
20107
20263
  // do not set
20108
20264
  };
20265
+ var exactPatterns = /* @__PURE__ */ new Map([
20266
+ [base64Charset, base64],
20267
+ [base64urlCharset, base64url]
20268
+ ]);
20269
+ var exactPattern = (p) => exactPatterns.get(p) ?? p;
20109
20270
  var stringProcessor = (schema, ctx, _json, _params) => {
20110
20271
  const json = _json;
20111
20272
  json.type = "string";
20112
- const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = schema._zod.bag;
20273
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
20113
20274
  if (typeof minimum === "number")
20114
20275
  json.minLength = minimum;
20115
20276
  if (typeof maximum === "number")
@@ -20125,7 +20286,7 @@ var stringProcessor = (schema, ctx, _json, _params) => {
20125
20286
  if (contentEncoding)
20126
20287
  json.contentEncoding = contentEncoding;
20127
20288
  if (patterns && patterns.size > 0) {
20128
- const patternList = [...patterns];
20289
+ const patternList = [...patterns].map(exactPattern);
20129
20290
  if (patternList.length === 1)
20130
20291
  json.pattern = patternList[0].source;
20131
20292
  else if (patternList.length > 1) {
@@ -20140,11 +20301,8 @@ var stringProcessor = (schema, ctx, _json, _params) => {
20140
20301
  };
20141
20302
  var numberProcessor = (schema, ctx, _json, params) => {
20142
20303
  const json = _json;
20143
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
20144
- if (typeof format === "string" && format.includes("int"))
20145
- json.type = "integer";
20146
- else
20147
- json.type = "number";
20304
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
20305
+ json.type = isInt ? "integer" : "number";
20148
20306
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
20149
20307
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
20150
20308
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -20168,11 +20326,19 @@ var numberProcessor = (schema, ctx, _json, params) => {
20168
20326
  } else if (typeof maximum === "number") {
20169
20327
  json.maximum = maximum;
20170
20328
  }
20171
- if (typeof multipleOf === "number") {
20172
- if (Number.isFinite(multipleOf) && multipleOf !== 0)
20173
- json.multipleOf = Math.abs(multipleOf);
20174
- else
20175
- handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${multipleOf} cannot be represented in JSON Schema`);
20329
+ if (multipleOf) {
20330
+ const divisors = /* @__PURE__ */ new Set();
20331
+ for (const divisor of multipleOf) {
20332
+ if (Number.isFinite(divisor) && divisor !== 0)
20333
+ divisors.add(Math.abs(divisor));
20334
+ else
20335
+ handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
20336
+ }
20337
+ const [first, ...rest] = divisors;
20338
+ if (first !== void 0)
20339
+ json.multipleOf = first;
20340
+ if (rest.length)
20341
+ json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
20176
20342
  }
20177
20343
  };
20178
20344
  var booleanProcessor = (_schema, _ctx, json, _params) => {
@@ -20275,27 +20441,22 @@ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
20275
20441
  };
20276
20442
  var fileProcessor = (schema, _ctx, json, _params) => {
20277
20443
  const _json = json;
20278
- const file = {
20279
- type: "string",
20280
- format: "binary",
20281
- contentEncoding: "binary"
20282
- };
20283
- const { minimum, maximum, mime } = schema._zod.bag;
20444
+ _json.type = "string";
20445
+ _json.format = "binary";
20446
+ _json.contentEncoding = "binary";
20447
+ const { minimum, maximum, mime } = aggregateChecks(schema);
20284
20448
  if (minimum !== void 0)
20285
- file.minLength = minimum;
20449
+ _json.minLength = minimum;
20286
20450
  if (maximum !== void 0)
20287
- file.maxLength = maximum;
20288
- if (mime) {
20289
- if (mime.length === 1) {
20290
- file.contentMediaType = mime[0];
20291
- Object.assign(_json, file);
20292
- } else {
20293
- Object.assign(_json, file);
20294
- _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
20295
- }
20296
- } else {
20297
- Object.assign(_json, file);
20298
- }
20451
+ _json.maxLength = maximum;
20452
+ if (!mime)
20453
+ return;
20454
+ if (mime.length === 0)
20455
+ _json.not = {};
20456
+ else if (mime.length === 1)
20457
+ _json.contentMediaType = mime[0];
20458
+ else
20459
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
20299
20460
  };
20300
20461
  var successProcessor = (_schema, _ctx, json, _params) => {
20301
20462
  json.type = "boolean";
@@ -20318,13 +20479,13 @@ var setProcessor = (schema, ctx, json, params) => {
20318
20479
  var arrayProcessor = (schema, ctx, _json, params) => {
20319
20480
  const json = _json;
20320
20481
  const def = schema._zod.def;
20321
- const { minimum, maximum } = schema._zod.bag;
20482
+ const { minimum, maximum } = aggregateChecks(schema);
20322
20483
  if (typeof minimum === "number")
20323
20484
  json.minItems = minimum;
20324
20485
  if (typeof maximum === "number")
20325
20486
  json.maxItems = maximum;
20326
20487
  json.type = "array";
20327
- json.items = process2(def.element, ctx, {
20488
+ json.items = processSchema(def.element, ctx, {
20328
20489
  ...params,
20329
20490
  path: [...params.path, "items"]
20330
20491
  });
@@ -20350,7 +20511,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
20350
20511
  json.type = "object";
20351
20512
  json.properties = {};
20352
20513
  for (const key in shape) {
20353
- assignProp(json.properties, key, process2(shape[key], ctx, {
20514
+ assignProp(json.properties, key, processSchema(shape[key], ctx, {
20354
20515
  ...params,
20355
20516
  path: [...params.path, "properties", key]
20356
20517
  }));
@@ -20373,16 +20534,41 @@ var objectProcessor = (schema, ctx, _json, params) => {
20373
20534
  if (ctx.io === "output")
20374
20535
  json.additionalProperties = false;
20375
20536
  } else if (def.catchall) {
20376
- json.additionalProperties = process2(def.catchall, ctx, {
20537
+ json.additionalProperties = processSchema(def.catchall, ctx, {
20377
20538
  ...params,
20378
20539
  path: [...params.path, "additionalProperties"]
20379
20540
  });
20380
20541
  }
20381
20542
  };
20543
+ var propertiesProcessor = (schema, ctx, _json, params) => {
20544
+ const json = _json;
20545
+ const def = schema._zod.def;
20546
+ if (Object.getOwnPropertySymbols(def.shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) {
20547
+ return;
20548
+ }
20549
+ if (ctx.io === "output") {
20550
+ for (const key in def.shape) {
20551
+ if (isTransforming(def.shape[key]) && handleUnrepresentable(schema, ctx, json, params, `z.properties() returns its input, so the output of a transforming schema at key "${key}" cannot be represented in JSON Schema`)) {
20552
+ return;
20553
+ }
20554
+ }
20555
+ }
20556
+ json.type = "object";
20557
+ json.properties = {};
20558
+ for (const key in def.shape) {
20559
+ assignProp(json.properties, key, processSchema(def.shape[key], ctx, {
20560
+ ...params,
20561
+ path: [...params.path, "properties", key]
20562
+ }));
20563
+ }
20564
+ const required2 = Object.keys(def.shape).filter((key) => inputOptin(def.shape[key]) === void 0);
20565
+ if (required2.length > 0)
20566
+ json.required = required2;
20567
+ };
20382
20568
  var unionProcessor = (schema, ctx, json, params) => {
20383
20569
  const def = schema._zod.def;
20384
20570
  const isExclusive = def.inclusive === false;
20385
- const options = def.options.map((x, i) => process2(x, ctx, {
20571
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
20386
20572
  ...params,
20387
20573
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
20388
20574
  }));
@@ -20394,11 +20580,11 @@ var unionProcessor = (schema, ctx, json, params) => {
20394
20580
  };
20395
20581
  var intersectionProcessor = (schema, ctx, json, params) => {
20396
20582
  const def = schema._zod.def;
20397
- const a = process2(def.left, ctx, {
20583
+ const a = processSchema(def.left, ctx, {
20398
20584
  ...params,
20399
20585
  path: [...params.path, "allOf", 0]
20400
20586
  });
20401
- const b = process2(def.right, ctx, {
20587
+ const b = processSchema(def.right, ctx, {
20402
20588
  ...params,
20403
20589
  path: [...params.path, "allOf", 1]
20404
20590
  });
@@ -20416,11 +20602,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
20416
20602
  json.type = "array";
20417
20603
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
20418
20604
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
20419
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
20605
+ const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
20420
20606
  ...params,
20421
20607
  path: [...params.path, prefixPath, i]
20422
20608
  }));
20423
- const rest = def.rest ? process2(def.rest, ctx, {
20609
+ const rest = def.rest ? processSchema(def.rest, ctx, {
20424
20610
  ...params,
20425
20611
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
20426
20612
  }) : null;
@@ -20468,7 +20654,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
20468
20654
  if (isClosed)
20469
20655
  json.maxItems = maxItems;
20470
20656
  }
20471
- const { minimum, maximum } = schema._zod.bag;
20657
+ const { minimum, maximum } = aggregateChecks(schema);
20472
20658
  if (typeof minimum === "number")
20473
20659
  json.minItems = minimum;
20474
20660
  if (typeof maximum === "number")
@@ -20542,20 +20728,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
20542
20728
  const def = schema._zod.def;
20543
20729
  json.type = "object";
20544
20730
  const keyType = def.keyType;
20545
- const keyBag = keyType._zod.bag;
20546
- const patterns = keyBag?.patterns;
20731
+ const patterns = aggregateChecks(keyType).patterns;
20547
20732
  if (def.mode === "loose" && patterns && patterns.size > 0) {
20548
- const valueSchema = process2(def.valueType, ctx, {
20733
+ const valueSchema = processSchema(def.valueType, ctx, {
20549
20734
  ...params,
20550
20735
  path: [...params.path, "patternProperties", "*"]
20551
20736
  });
20552
20737
  json.patternProperties = {};
20553
20738
  for (const pattern of patterns) {
20554
- assignProp(json.patternProperties, pattern.source, valueSchema);
20739
+ assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
20555
20740
  }
20556
20741
  } else {
20557
20742
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
20558
- json.propertyNames = process2(def.keyType, ctx, {
20743
+ json.propertyNames = processSchema(def.keyType, ctx, {
20559
20744
  ...params,
20560
20745
  path: [...params.path, "propertyNames"]
20561
20746
  });
@@ -20567,7 +20752,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
20567
20752
  }
20568
20753
  pending.push(schema);
20569
20754
  }
20570
- json.additionalProperties = process2(def.valueType, ctx, {
20755
+ json.additionalProperties = processSchema(def.valueType, ctx, {
20571
20756
  ...params,
20572
20757
  path: [...params.path, "additionalProperties"]
20573
20758
  });
@@ -20583,7 +20768,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
20583
20768
  };
20584
20769
  var nullableProcessor = (schema, ctx, json, params) => {
20585
20770
  const def = schema._zod.def;
20586
- const inner = process2(def.innerType, ctx, params);
20771
+ const inner = processSchema(def.innerType, ctx, params);
20587
20772
  const seen = ctx.seen.get(schema);
20588
20773
  if (ctx.target === "openapi-3.0") {
20589
20774
  seen.ref = def.innerType;
@@ -20594,7 +20779,7 @@ var nullableProcessor = (schema, ctx, json, params) => {
20594
20779
  };
20595
20780
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
20596
20781
  const def = schema._zod.def;
20597
- process2(def.innerType, ctx, params);
20782
+ processSchema(def.innerType, ctx, params);
20598
20783
  const seen = ctx.seen.get(schema);
20599
20784
  seen.ref = def.innerType;
20600
20785
  };
@@ -20614,7 +20799,7 @@ function serializeDefaultValue(value, schema, ctx, json, params) {
20614
20799
  }
20615
20800
  var defaultProcessor = (schema, ctx, json, params) => {
20616
20801
  const def = schema._zod.def;
20617
- process2(def.innerType, ctx, params);
20802
+ processSchema(def.innerType, ctx, params);
20618
20803
  const seen = ctx.seen.get(schema);
20619
20804
  seen.ref = def.innerType;
20620
20805
  const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
@@ -20623,7 +20808,7 @@ var defaultProcessor = (schema, ctx, json, params) => {
20623
20808
  };
20624
20809
  var prefaultProcessor = (schema, ctx, json, params) => {
20625
20810
  const def = schema._zod.def;
20626
- process2(def.innerType, ctx, params);
20811
+ processSchema(def.innerType, ctx, params);
20627
20812
  const seen = ctx.seen.get(schema);
20628
20813
  seen.ref = def.innerType;
20629
20814
  if (ctx.io !== "input")
@@ -20634,7 +20819,7 @@ var prefaultProcessor = (schema, ctx, json, params) => {
20634
20819
  };
20635
20820
  var catchProcessor = (schema, ctx, json, params) => {
20636
20821
  const def = schema._zod.def;
20637
- process2(def.innerType, ctx, params);
20822
+ processSchema(def.innerType, ctx, params);
20638
20823
  const seen = ctx.seen.get(schema);
20639
20824
  seen.ref = def.innerType;
20640
20825
  let catchValue;
@@ -20650,32 +20835,32 @@ var pipeProcessor = (schema, ctx, _json, params) => {
20650
20835
  const def = schema._zod.def;
20651
20836
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
20652
20837
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
20653
- process2(innerType, ctx, params);
20838
+ processSchema(innerType, ctx, params);
20654
20839
  const seen = ctx.seen.get(schema);
20655
20840
  seen.ref = innerType;
20656
20841
  };
20657
20842
  var readonlyProcessor = (schema, ctx, json, params) => {
20658
20843
  const def = schema._zod.def;
20659
- process2(def.innerType, ctx, params);
20844
+ processSchema(def.innerType, ctx, params);
20660
20845
  const seen = ctx.seen.get(schema);
20661
20846
  seen.ref = def.innerType;
20662
20847
  json.readOnly = true;
20663
20848
  };
20664
20849
  var promiseProcessor = (schema, ctx, _json, params) => {
20665
20850
  const def = schema._zod.def;
20666
- process2(def.innerType, ctx, params);
20851
+ processSchema(def.innerType, ctx, params);
20667
20852
  const seen = ctx.seen.get(schema);
20668
20853
  seen.ref = def.innerType;
20669
20854
  };
20670
20855
  var optionalProcessor = (schema, ctx, _json, params) => {
20671
20856
  const def = schema._zod.def;
20672
- process2(def.innerType, ctx, params);
20857
+ processSchema(def.innerType, ctx, params);
20673
20858
  const seen = ctx.seen.get(schema);
20674
20859
  seen.ref = def.innerType;
20675
20860
  };
20676
20861
  var lazyProcessor = (schema, ctx, _json, params) => {
20677
20862
  const innerType = schema._zod.innerType;
20678
- process2(innerType, ctx, params);
20863
+ processSchema(innerType, ctx, params);
20679
20864
  const seen = ctx.seen.get(schema);
20680
20865
  seen.ref = innerType;
20681
20866
  };
@@ -20699,6 +20884,7 @@ var allProcessors = {
20699
20884
  file: fileProcessor,
20700
20885
  success: successProcessor,
20701
20886
  custom: customProcessor,
20887
+ properties: propertiesProcessor,
20702
20888
  function: functionProcessor,
20703
20889
  transform: transformProcessor,
20704
20890
  map: mapProcessor,
@@ -20727,7 +20913,7 @@ function toJSONSchema(input, params) {
20727
20913
  const defs = {};
20728
20914
  for (const entry of registry2._idmap.entries()) {
20729
20915
  const [_, schema] = entry;
20730
- process2(schema, ctx2);
20916
+ processSchema(schema, ctx2);
20731
20917
  }
20732
20918
  const schemas = {};
20733
20919
  const external = {
@@ -20750,7 +20936,7 @@ function toJSONSchema(input, params) {
20750
20936
  return { schemas };
20751
20937
  }
20752
20938
  const ctx = initializeContext({ ...params, processors: allProcessors });
20753
- process2(input, ctx);
20939
+ processSchema(input, ctx);
20754
20940
  extractDefs(ctx, input);
20755
20941
  return finalize(ctx, input);
20756
20942
  }
@@ -20801,10 +20987,10 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, void 0
20801
20987
  });
20802
20988
 
20803
20989
  // node_modules/zod/v4/classic/parse.js
20804
- var parse2 = /* @__PURE__ */ _parse(ZodRealError);
20805
- var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
20806
- var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
20807
- var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
20990
+ var parse = /* @__PURE__ */ _parse(ZodRealError);
20991
+ var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
20992
+ var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
20993
+ var safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
20808
20994
  var encode = /* @__PURE__ */ _encode(ZodRealError);
20809
20995
  var decode = /* @__PURE__ */ _decode(ZodRealError);
20810
20996
  var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
@@ -20938,16 +21124,16 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
20938
21124
  util_exports.own(this, "~standard", value);
20939
21125
  },
20940
21126
  parse: function _parse2(data, params) {
20941
- return parse2(this, data, params, { callee: _parse2 });
21127
+ return parse(this, data, params, { callee: _parse2 });
20942
21128
  },
20943
21129
  parseAsync: async function _parseAsync2(data, params) {
20944
- return await parseAsync2(this, data, params, { callee: _parseAsync2 });
21130
+ return await parseAsync(this, data, params, { callee: _parseAsync2 });
20945
21131
  },
20946
21132
  safeParse(data, params) {
20947
- return safeParse2(this, data, params);
21133
+ return safeParse(this, data, params);
20948
21134
  },
20949
21135
  async safeParseAsync(data, params) {
20950
- return safeParseAsync2(this, data, params);
21136
+ return safeParseAsync(this, data, params);
20951
21137
  },
20952
21138
  // `spa` is an alias: same function object as `safeParseAsync`, as before.
20953
21139
  get spa() {
@@ -20956,6 +21142,12 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
20956
21142
  set spa(value) {
20957
21143
  util_exports.own(this, "spa", value);
20958
21144
  },
21145
+ validate(data, params) {
21146
+ return validate(this, data, params);
21147
+ },
21148
+ validateAsync(data, params) {
21149
+ return validateAsync(this, data, params);
21150
+ },
20959
21151
  encode: function _encode2(data, params) {
20960
21152
  return encode(this, data, params, { callee: _encode2 });
20961
21153
  },
@@ -20992,61 +21184,65 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
20992
21184
  return this._zod.def;
20993
21185
  }
20994
21186
  });
20995
- var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
20996
- $ZodString.init(inst, def);
20997
- ZodType.init(inst, def);
20998
- inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
20999
- const bag = inst._zod.bag;
21000
- inst.format = bag.format ?? null;
21001
- inst.minLength = bag.minimum ?? null;
21002
- inst.maxLength = bag.maximum ?? null;
21003
- }, {
21004
- regex(...args) {
21005
- return this.check(_regex(...args));
21006
- },
21007
- includes(...args) {
21008
- return this.check(_includes(...args));
21009
- },
21010
- startsWith(...args) {
21011
- return this.check(_startsWith(...args));
21012
- },
21013
- endsWith(...args) {
21014
- return this.check(_endsWith(...args));
21015
- },
21016
- min(...args) {
21017
- return this.check(_minLength(...args));
21018
- },
21019
- max(...args) {
21020
- return this.check(_maxLength(...args));
21021
- },
21022
- length(...args) {
21023
- return this.check(_length(...args));
21024
- },
21025
- nonempty(...args) {
21026
- return this.check(_minLength(1, ...args));
21027
- },
21028
- lowercase(params) {
21029
- return this.check(_lowercase(params));
21030
- },
21031
- uppercase(params) {
21032
- return this.check(_uppercase(params));
21033
- },
21034
- trim() {
21035
- return this.check(_trim());
21036
- },
21037
- normalize(...args) {
21038
- return this.check(_normalize(...args));
21039
- },
21040
- toLowerCase() {
21041
- return this.check(_toLowerCase());
21042
- },
21043
- toUpperCase() {
21044
- return this.check(_toUpperCase());
21045
- },
21046
- slugify() {
21047
- return this.check(_slugify());
21048
- }
21049
- });
21187
+ var _ZodString = /* @__PURE__ */ $constructor(
21188
+ "_ZodString",
21189
+ (inst, def) => {
21190
+ $ZodString.init(inst, def);
21191
+ ZodType.init(inst, def);
21192
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
21193
+ },
21194
+ /* @__PURE__ */ util_exports.derived({
21195
+ format: (inst) => aggregateChecks(inst).format ?? null,
21196
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
21197
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
21198
+ }, {
21199
+ regex(...args) {
21200
+ return this.check(_regex(...args));
21201
+ },
21202
+ includes(...args) {
21203
+ return this.check(_includes(...args));
21204
+ },
21205
+ startsWith(...args) {
21206
+ return this.check(_startsWith(...args));
21207
+ },
21208
+ endsWith(...args) {
21209
+ return this.check(_endsWith(...args));
21210
+ },
21211
+ min(...args) {
21212
+ return this.check(_minLength(...args));
21213
+ },
21214
+ max(...args) {
21215
+ return this.check(_maxLength(...args));
21216
+ },
21217
+ length(...args) {
21218
+ return this.check(_length(...args));
21219
+ },
21220
+ nonempty(...args) {
21221
+ return this.check(_minLength(1, ...args));
21222
+ },
21223
+ lowercase(params) {
21224
+ return this.check(_lowercase(params));
21225
+ },
21226
+ uppercase(params) {
21227
+ return this.check(_uppercase(params));
21228
+ },
21229
+ trim() {
21230
+ return this.check(_trim());
21231
+ },
21232
+ normalize(...args) {
21233
+ return this.check(_normalize(...args));
21234
+ },
21235
+ toLowerCase() {
21236
+ return this.check(_toLowerCase());
21237
+ },
21238
+ toUpperCase() {
21239
+ return this.check(_toUpperCase());
21240
+ },
21241
+ slugify() {
21242
+ return this.check(_slugify());
21243
+ }
21244
+ })
21245
+ );
21050
21246
  var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
21051
21247
  $ZodString.init(inst, def);
21052
21248
  _ZodString.init(inst, def);
@@ -21235,63 +21431,76 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
21235
21431
  $ZodJWT.init(inst, def);
21236
21432
  ZodStringFormat.init(inst, def);
21237
21433
  });
21238
- var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
21239
- $ZodNumber.init(inst, def);
21240
- ZodType.init(inst, def);
21241
- inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
21242
- const bag = inst._zod.bag;
21243
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
21244
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
21245
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
21246
- inst.isFinite = true;
21247
- inst.format = bag.format ?? null;
21248
- }, {
21249
- gt(value, params) {
21250
- return this.check(_gt(value, params));
21251
- },
21252
- gte(value, params) {
21253
- return this.check(_gte(value, params));
21254
- },
21255
- min(value, params) {
21256
- return this.check(_gte(value, params));
21257
- },
21258
- lt(value, params) {
21259
- return this.check(_lt(value, params));
21260
- },
21261
- lte(value, params) {
21262
- return this.check(_lte(value, params));
21263
- },
21264
- max(value, params) {
21265
- return this.check(_lte(value, params));
21266
- },
21267
- int(params) {
21268
- return this.check(int(params));
21269
- },
21270
- safe(params) {
21271
- return this.check(int(params));
21272
- },
21273
- positive(params) {
21274
- return this.check(_gt(0, params));
21275
- },
21276
- nonnegative(params) {
21277
- return this.check(_gte(0, params));
21278
- },
21279
- negative(params) {
21280
- return this.check(_lt(0, params));
21281
- },
21282
- nonpositive(params) {
21283
- return this.check(_lte(0, params));
21284
- },
21285
- multipleOf(value, params) {
21286
- return this.check(_multipleOf(value, params));
21287
- },
21288
- step(value, params) {
21289
- return this.check(_multipleOf(value, params));
21290
- },
21291
- finite() {
21292
- return this;
21293
- }
21294
- });
21434
+ var ZodNumber = /* @__PURE__ */ $constructor(
21435
+ "ZodNumber",
21436
+ (inst, def) => {
21437
+ $ZodNumber.init(inst, def);
21438
+ ZodType.init(inst, def);
21439
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
21440
+ inst.isFinite = true;
21441
+ },
21442
+ /* @__PURE__ */ util_exports.derived({
21443
+ minValue: (inst) => {
21444
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
21445
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
21446
+ },
21447
+ maxValue: (inst) => {
21448
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
21449
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
21450
+ },
21451
+ isInt: (inst) => {
21452
+ const { isInt, multipleOf } = aggregateChecks(inst);
21453
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
21454
+ },
21455
+ format: (inst) => aggregateChecks(inst).format ?? null
21456
+ }, {
21457
+ gt(value, params) {
21458
+ return this.check(_gt(value, params));
21459
+ },
21460
+ gte(value, params) {
21461
+ return this.check(_gte(value, params));
21462
+ },
21463
+ min(value, params) {
21464
+ return this.check(_gte(value, params));
21465
+ },
21466
+ lt(value, params) {
21467
+ return this.check(_lt(value, params));
21468
+ },
21469
+ lte(value, params) {
21470
+ return this.check(_lte(value, params));
21471
+ },
21472
+ max(value, params) {
21473
+ return this.check(_lte(value, params));
21474
+ },
21475
+ int(params) {
21476
+ return this.check(int(params));
21477
+ },
21478
+ safe(params) {
21479
+ return this.check(int(params));
21480
+ },
21481
+ positive(params) {
21482
+ return this.check(_gt(0, params));
21483
+ },
21484
+ nonnegative(params) {
21485
+ return this.check(_gte(0, params));
21486
+ },
21487
+ negative(params) {
21488
+ return this.check(_lt(0, params));
21489
+ },
21490
+ nonpositive(params) {
21491
+ return this.check(_lte(0, params));
21492
+ },
21493
+ multipleOf(value, params) {
21494
+ return this.check(_multipleOf(value, params));
21495
+ },
21496
+ step(value, params) {
21497
+ return this.check(_multipleOf(value, params));
21498
+ },
21499
+ finite() {
21500
+ return this;
21501
+ }
21502
+ })
21503
+ );
21295
21504
  function number2(params) {
21296
21505
  return _number(ZodNumber, params);
21297
21506
  }
@@ -21310,49 +21519,53 @@ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
21310
21519
  function boolean2(params) {
21311
21520
  return _boolean(ZodBoolean, params);
21312
21521
  }
21313
- var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
21314
- $ZodBigInt.init(inst, def);
21315
- ZodType.init(inst, def);
21316
- inst._zod.processJSONSchema = (ctx, json, params) => bigintProcessor(inst, ctx, json, params);
21317
- const bag = inst._zod.bag;
21318
- inst.minValue = bag.minimum ?? null;
21319
- inst.maxValue = bag.maximum ?? null;
21320
- inst.format = bag.format ?? null;
21321
- }, {
21322
- gte(value, params) {
21323
- return this.check(_gte(value, params));
21324
- },
21325
- min(value, params) {
21326
- return this.check(_gte(value, params));
21327
- },
21328
- gt(value, params) {
21329
- return this.check(_gt(value, params));
21330
- },
21331
- lt(value, params) {
21332
- return this.check(_lt(value, params));
21333
- },
21334
- lte(value, params) {
21335
- return this.check(_lte(value, params));
21336
- },
21337
- max(value, params) {
21338
- return this.check(_lte(value, params));
21339
- },
21340
- positive(params) {
21341
- return this.check(_gt(BigInt(0), params));
21342
- },
21343
- negative(params) {
21344
- return this.check(_lt(BigInt(0), params));
21345
- },
21346
- nonpositive(params) {
21347
- return this.check(_lte(BigInt(0), params));
21348
- },
21349
- nonnegative(params) {
21350
- return this.check(_gte(BigInt(0), params));
21351
- },
21352
- multipleOf(value, params) {
21353
- return this.check(_multipleOf(value, params));
21354
- }
21355
- });
21522
+ var ZodBigInt = /* @__PURE__ */ $constructor(
21523
+ "ZodBigInt",
21524
+ (inst, def) => {
21525
+ $ZodBigInt.init(inst, def);
21526
+ ZodType.init(inst, def);
21527
+ inst._zod.processJSONSchema = (ctx, json, params) => bigintProcessor(inst, ctx, json, params);
21528
+ },
21529
+ /* @__PURE__ */ util_exports.derived({
21530
+ minValue: (inst) => aggregateChecks(inst).minimum ?? null,
21531
+ maxValue: (inst) => aggregateChecks(inst).maximum ?? null,
21532
+ format: (inst) => aggregateChecks(inst).format ?? null
21533
+ }, {
21534
+ gte(value, params) {
21535
+ return this.check(_gte(value, params));
21536
+ },
21537
+ min(value, params) {
21538
+ return this.check(_gte(value, params));
21539
+ },
21540
+ gt(value, params) {
21541
+ return this.check(_gt(value, params));
21542
+ },
21543
+ lt(value, params) {
21544
+ return this.check(_lt(value, params));
21545
+ },
21546
+ lte(value, params) {
21547
+ return this.check(_lte(value, params));
21548
+ },
21549
+ max(value, params) {
21550
+ return this.check(_lte(value, params));
21551
+ },
21552
+ positive(params) {
21553
+ return this.check(_gt(BigInt(0), params));
21554
+ },
21555
+ negative(params) {
21556
+ return this.check(_lt(BigInt(0), params));
21557
+ },
21558
+ nonpositive(params) {
21559
+ return this.check(_lte(BigInt(0), params));
21560
+ },
21561
+ nonnegative(params) {
21562
+ return this.check(_gte(BigInt(0), params));
21563
+ },
21564
+ multipleOf(value, params) {
21565
+ return this.check(_multipleOf(value, params));
21566
+ }
21567
+ })
21568
+ );
21356
21569
  var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
21357
21570
  $ZodNull.init(inst, def);
21358
21571
  ZodType.init(inst, def);
@@ -21385,16 +21598,26 @@ var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
21385
21598
  function never(params) {
21386
21599
  return _never(ZodNever, params);
21387
21600
  }
21388
- var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
21389
- $ZodDate.init(inst, def);
21390
- ZodType.init(inst, def);
21391
- inst._zod.processJSONSchema = (ctx, json, params) => dateProcessor(inst, ctx, json, params);
21392
- inst.min = (value, params) => inst.check(_gte(value, params));
21393
- inst.max = (value, params) => inst.check(_lte(value, params));
21394
- const c = inst._zod.bag;
21395
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
21396
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
21397
- });
21601
+ var ZodDate = /* @__PURE__ */ $constructor(
21602
+ "ZodDate",
21603
+ (inst, def) => {
21604
+ $ZodDate.init(inst, def);
21605
+ ZodType.init(inst, def);
21606
+ inst._zod.processJSONSchema = (ctx, json, params) => dateProcessor(inst, ctx, json, params);
21607
+ inst.min = (value, params) => inst.check(_gte(value, params));
21608
+ inst.max = (value, params) => inst.check(_lte(value, params));
21609
+ },
21610
+ /* @__PURE__ */ util_exports.derived({
21611
+ minDate: (inst) => {
21612
+ const { minimum } = aggregateChecks(inst);
21613
+ return minimum ? new Date(minimum) : null;
21614
+ },
21615
+ maxDate: (inst) => {
21616
+ const { maximum } = aggregateChecks(inst);
21617
+ return maximum ? new Date(maximum) : null;
21618
+ }
21619
+ }, {})
21620
+ );
21398
21621
  var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
21399
21622
  _ensureDefaultMemoizer();
21400
21623
  $ZodArray.init(inst, def);
@@ -21432,19 +21655,19 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
21432
21655
  return _enum(Object.keys(this._zod.def.shape));
21433
21656
  },
21434
21657
  catchall(catchall) {
21435
- return this.clone({ ...this._zod.def, catchall });
21658
+ return this.clone(util_exports.mergeDefs(this._zod.def, { catchall }));
21436
21659
  },
21437
21660
  passthrough() {
21438
- return this.clone({ ...this._zod.def, catchall: unknown() });
21661
+ return this.clone(util_exports.mergeDefs(this._zod.def, { catchall: unknown() }));
21439
21662
  },
21440
21663
  loose() {
21441
- return this.clone({ ...this._zod.def, catchall: unknown() });
21664
+ return this.clone(util_exports.mergeDefs(this._zod.def, { catchall: unknown() }));
21442
21665
  },
21443
21666
  strict() {
21444
- return this.clone({ ...this._zod.def, catchall: never() });
21667
+ return this.clone(util_exports.mergeDefs(this._zod.def, { catchall: never() }));
21445
21668
  },
21446
21669
  strip() {
21447
- return this.clone({ ...this._zod.def, catchall: void 0 });
21670
+ return this.clone(util_exports.mergeDefs(this._zod.def, { catchall: void 0 }));
21448
21671
  },
21449
21672
  extend(incoming) {
21450
21673
  return util_exports.extend(this, incoming);
@@ -21553,7 +21776,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
21553
21776
  ZodType.init(inst, def);
21554
21777
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
21555
21778
  inst.enum = def.entries;
21556
- inst.options = Object.values(def.entries);
21779
+ inst.options = [...inst._zod.values];
21557
21780
  const keys = new Set(Object.keys(def.entries));
21558
21781
  inst.extract = (values, params) => {
21559
21782
  const newEntries = {};
@@ -25965,7 +26188,7 @@ function modernOnlyStrictRejection(route, supportedVersions) {
25965
26188
  }
25966
26189
  }
25967
26190
  function parseSchema(schema, data) {
25968
- return safeParse2(schema, data);
26191
+ return safeParse(schema, data);
25969
26192
  }
25970
26193
  function shapeKeys(schemas) {
25971
26194
  return new Set(schemas.flatMap((schema) => Object.keys(schema.shape)));
@@ -26855,9 +27078,9 @@ var Protocol = class {
26855
27078
  const sendCodec = this._resolveOutboundCodec(r.method);
26856
27079
  this._assertOutboundRequestInEra(sendCodec, r.method);
26857
27080
  if (isStandardSchema(schemaOrOptions)) return sendRequest(r, schemaOrOptions, maybeOptions);
26858
- const validate = codecResultValidator(sendCodec, r.method);
26859
- if (validate === void 0) throw new TypeError(`'${r.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);
26860
- return sendRequest(r, validate, schemaOrOptions);
27081
+ const validate2 = codecResultValidator(sendCodec, r.method);
27082
+ if (validate2 === void 0) throw new TypeError(`'${r.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);
27083
+ return sendRequest(r, validate2, schemaOrOptions);
26861
27084
  }),
26862
27085
  notify: sendNotification
26863
27086
  },
@@ -26950,9 +27173,9 @@ var Protocol = class {
26950
27173
  const codec = this._resolveOutboundCodec(request.method);
26951
27174
  this._assertOutboundRequestInEra(codec, request.method);
26952
27175
  if (isStandardSchema(schemaOrOptions)) return this._requestWithSchemaViaCodec(codec, request, schemaOrOptions, maybeOptions);
26953
- const validate = codecResultValidator(codec, request.method);
26954
- if (validate === void 0) throw new TypeError(`'${request.method}' is not a spec method; pass a result schema as the second argument to request().`);
26955
- return this._requestWithSchemaViaCodec(codec, request, validate, schemaOrOptions);
27176
+ const validate2 = codecResultValidator(codec, request.method);
27177
+ if (validate2 === void 0) throw new TypeError(`'${request.method}' is not a spec method; pass a result schema as the second argument to request().`);
27178
+ return this._requestWithSchemaViaCodec(codec, request, validate2, schemaOrOptions);
26956
27179
  }
26957
27180
  /**
26958
27181
  * The wire codec for this instance's negotiated era — the phase-2 truth:
@@ -27305,8 +27528,8 @@ var require_content_type = /* @__PURE__ */ __commonJSMin(((exports) => {
27305
27528
  var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
27306
27529
  var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
27307
27530
  var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
27308
- exports.parse = parse3;
27309
- function parse3(string4) {
27531
+ exports.parse = parse2;
27532
+ function parse2(string4) {
27310
27533
  if (!string4) throw new TypeError("argument string is required");
27311
27534
  var header = typeof string4 === "object" ? getcontenttype(string4) : string4;
27312
27535
  if (typeof header !== "string") throw new TypeError("argument string is required to be a string");
@@ -29105,12 +29328,12 @@ var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
29105
29328
  if (def.modifying) modifyData(cxt);
29106
29329
  reportErrs(() => cxt.error());
29107
29330
  } else {
29108
- const ruleErrs = def.async ? validateAsync() : validateSync();
29331
+ const ruleErrs = def.async ? validateAsync3() : validateSync();
29109
29332
  if (def.modifying) modifyData(cxt);
29110
29333
  reportErrs(() => addErrs(cxt, ruleErrs));
29111
29334
  }
29112
29335
  }
29113
- function validateAsync() {
29336
+ function validateAsync3() {
29114
29337
  const ruleErrs = gen.let("ruleErrs", null);
29115
29338
  gen.try(() => assignValid((0, codegen_1._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1._)`${e}.errors`), () => gen.throw(e)));
29116
29339
  return ruleErrs;
@@ -29984,28 +30207,28 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
29984
30207
  const validateCode = gen.toString();
29985
30208
  sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${validateCode}`;
29986
30209
  if (this.opts.code.process) sourceCode = this.opts.code.process(sourceCode, sch);
29987
- const validate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode)(this, this.scope.get());
29988
- this.scope.value(validateName, { ref: validate });
29989
- validate.errors = null;
29990
- validate.schema = sch.schema;
29991
- validate.schemaEnv = sch;
29992
- if (sch.$async) validate.$async = true;
29993
- if (this.opts.code.source === true) validate.source = {
30210
+ const validate2 = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode)(this, this.scope.get());
30211
+ this.scope.value(validateName, { ref: validate2 });
30212
+ validate2.errors = null;
30213
+ validate2.schema = sch.schema;
30214
+ validate2.schemaEnv = sch;
30215
+ if (sch.$async) validate2.$async = true;
30216
+ if (this.opts.code.source === true) validate2.source = {
29994
30217
  validateName,
29995
30218
  validateCode,
29996
30219
  scopeValues: gen._values
29997
30220
  };
29998
30221
  if (this.opts.unevaluated) {
29999
30222
  const { props, items } = schemaCxt;
30000
- validate.evaluated = {
30223
+ validate2.evaluated = {
30001
30224
  props: props instanceof codegen_1.Name ? void 0 : props,
30002
30225
  items: items instanceof codegen_1.Name ? void 0 : items,
30003
30226
  dynamicProps: props instanceof codegen_1.Name,
30004
30227
  dynamicItems: items instanceof codegen_1.Name
30005
30228
  };
30006
- if (validate.source) validate.source.evaluated = (0, codegen_1.stringify)(validate.evaluated);
30229
+ if (validate2.source) validate2.source.evaluated = (0, codegen_1.stringify)(validate2.evaluated);
30007
30230
  }
30008
- sch.validate = validate;
30231
+ sch.validate = validate2;
30009
30232
  return sch;
30010
30233
  } catch (e) {
30011
30234
  delete sch.validate;
@@ -30494,21 +30717,21 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
30494
30717
  const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
30495
30718
  const { SCHEMES, getSchemeHandler } = require_schemes();
30496
30719
  function normalize2(uri, options) {
30497
- if (typeof uri === "string") uri = serialize(parse3(uri, options), options);
30498
- else if (typeof uri === "object") uri = parse3(serialize(uri, options), options);
30720
+ if (typeof uri === "string") uri = serialize(parse2(uri, options), options);
30721
+ else if (typeof uri === "object") uri = parse2(serialize(uri, options), options);
30499
30722
  return uri;
30500
30723
  }
30501
30724
  function resolve(baseURI, relativeURI, options) {
30502
30725
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
30503
- const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
30726
+ const resolved = resolveComponent(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true);
30504
30727
  schemelessOptions.skipEscape = true;
30505
30728
  return serialize(resolved, schemelessOptions);
30506
30729
  }
30507
30730
  function resolveComponent(base, relative, options, skipNormalization) {
30508
30731
  const target = {};
30509
30732
  if (!skipNormalization) {
30510
- base = parse3(serialize(base, options), options);
30511
- relative = parse3(serialize(relative, options), options);
30733
+ base = parse2(serialize(base, options), options);
30734
+ relative = parse2(serialize(relative, options), options);
30512
30735
  }
30513
30736
  options = options || {};
30514
30737
  if (!options.tolerant && relative.scheme) {
@@ -30552,7 +30775,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
30552
30775
  function equal(uriA, uriB, options) {
30553
30776
  if (typeof uriA === "string") {
30554
30777
  uriA = unescape(uriA);
30555
- uriA = serialize(normalizeComponentEncoding(parse3(uriA, options), true), {
30778
+ uriA = serialize(normalizeComponentEncoding(parse2(uriA, options), true), {
30556
30779
  ...options,
30557
30780
  skipEscape: true
30558
30781
  });
@@ -30562,7 +30785,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
30562
30785
  });
30563
30786
  if (typeof uriB === "string") {
30564
30787
  uriB = unescape(uriB);
30565
- uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), {
30788
+ uriB = serialize(normalizeComponentEncoding(parse2(uriB, options), true), {
30566
30789
  ...options,
30567
30790
  skipEscape: true
30568
30791
  });
@@ -30615,7 +30838,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
30615
30838
  return uriTokens.join("");
30616
30839
  }
30617
30840
  const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
30618
- function parse3(uri, opts) {
30841
+ function parse2(uri, opts) {
30619
30842
  const options = Object.assign({}, opts);
30620
30843
  const parsed = {
30621
30844
  scheme: void 0,
@@ -30676,7 +30899,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
30676
30899
  resolveComponent,
30677
30900
  equal,
30678
30901
  serialize,
30679
- parse: parse3
30902
+ parse: parse2
30680
30903
  };
30681
30904
  module.exports = fastUri;
30682
30905
  module.exports.default = fastUri;
@@ -33001,8 +33224,8 @@ var require_dynamicAnchor = /* @__PURE__ */ __commonJSMin(((exports) => {
33001
33224
  const { gen, it } = cxt;
33002
33225
  it.schemaEnv.root.dynamicAnchors[anchor2] = true;
33003
33226
  const v = (0, codegen_1._)`${names_1.default.dynamicAnchors}${(0, codegen_1.getProperty)(anchor2)}`;
33004
- const validate = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
33005
- gen.if((0, codegen_1._)`!${v}`, () => gen.assign(v, validate));
33227
+ const validate2 = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
33228
+ gen.if((0, codegen_1._)`!${v}`, () => gen.assign(v, validate2));
33006
33229
  }
33007
33230
  exports.dynamicAnchor = dynamicAnchor;
33008
33231
  function _getValidate(cxt) {
@@ -33049,11 +33272,11 @@ var require_dynamicRef = /* @__PURE__ */ __commonJSMin(((exports) => {
33049
33272
  gen.if(v, _callRef(v, valid), _callRef(it.validateName, valid));
33050
33273
  } else _callRef(it.validateName, valid)();
33051
33274
  }
33052
- function _callRef(validate, valid) {
33275
+ function _callRef(validate2, valid) {
33053
33276
  return valid ? () => gen.block(() => {
33054
- (0, ref_1.callRef)(cxt, validate);
33277
+ (0, ref_1.callRef)(cxt, validate2);
33055
33278
  gen.let(valid, true);
33056
- }) : () => (0, ref_1.callRef)(cxt, validate);
33279
+ }) : () => (0, ref_1.callRef)(cxt, validate2);
33057
33280
  }
33058
33281
  }
33059
33282
  exports.dynamicRef = dynamicRef;
@@ -34094,9 +34317,9 @@ var require__2020 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
34094
34317
  var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
34095
34318
  Object.defineProperty(exports, "__esModule", { value: true });
34096
34319
  exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
34097
- function fmtDef(validate, compare) {
34320
+ function fmtDef(validate2, compare) {
34098
34321
  return {
34099
- validate,
34322
+ validate: validate2,
34100
34323
  compare
34101
34324
  };
34102
34325
  }
@@ -34460,7 +34683,7 @@ var AjvJsonSchemaValidator = class {
34460
34683
  var Ajv = import_ajv.Ajv;
34461
34684
 
34462
34685
  // node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
34463
- import process3 from "node:process";
34686
+ import process2 from "node:process";
34464
34687
 
34465
34688
  // node_modules/@modelcontextprotocol/server/dist/mcp-DXXb3Vv3.mjs
34466
34689
  var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
@@ -35988,7 +36211,7 @@ var StdioServerTransport = class {
35988
36211
  _readBuffer;
35989
36212
  _started = false;
35990
36213
  _closed = false;
35991
- constructor(_stdin = process3.stdin, _stdout = process3.stdout, options) {
36214
+ constructor(_stdin = process2.stdin, _stdout = process2.stdout, options) {
35992
36215
  this._stdin = _stdin;
35993
36216
  this._stdout = _stdout;
35994
36217
  this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
@@ -39108,13 +39331,14 @@ var Hono = class _Hono {
39108
39331
  const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
39109
39332
  allMethods.forEach((method) => {
39110
39333
  this[method] = (args1, ...args) => {
39334
+ const methodName = method.toUpperCase();
39111
39335
  if (typeof args1 === "string") {
39112
39336
  this.#path = args1;
39113
39337
  } else {
39114
- this.#addRoute(method, this.#path, args1);
39338
+ this.#addRoute(methodName, this.#path, args1);
39115
39339
  }
39116
39340
  args.forEach((handler) => {
39117
- this.#addRoute(method, this.#path, handler);
39341
+ this.#addRoute(methodName, this.#path, handler);
39118
39342
  });
39119
39343
  return this;
39120
39344
  };
@@ -39123,9 +39347,10 @@ var Hono = class _Hono {
39123
39347
  for (const p of [path].flat()) {
39124
39348
  this.#path = p;
39125
39349
  for (const m of [method].flat()) {
39126
- handlers.map((handler) => {
39127
- this.#addRoute(m.toUpperCase(), this.#path, handler);
39128
- });
39350
+ const methodName = m.toUpperCase();
39351
+ for (const handler of handlers) {
39352
+ this.#addRoute(methodName, this.#path, handler);
39353
+ }
39129
39354
  }
39130
39355
  }
39131
39356
  return this;
@@ -39326,7 +39551,6 @@ var Hono = class _Hono {
39326
39551
  return this;
39327
39552
  }
39328
39553
  #addRoute(method, path, handler, baseRoutePath) {
39329
- method = method.toUpperCase();
39330
39554
  path = mergePath(this._basePath, path);
39331
39555
  const r = {
39332
39556
  basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
@@ -40340,8 +40564,8 @@ var SchemaValidator = class {
40340
40564
  * @param schema - JSON Schema for tool arguments
40341
40565
  */
40342
40566
  addSchema(toolName, schema) {
40343
- const validate = this.ajv.compile(schema);
40344
- this.validators.set(toolName, validate);
40567
+ const validate2 = this.ajv.compile(schema);
40568
+ this.validators.set(toolName, validate2);
40345
40569
  }
40346
40570
  /**
40347
40571
  * Remove a schema
@@ -40363,15 +40587,15 @@ var SchemaValidator = class {
40363
40587
  * @returns Validation result with errors if invalid
40364
40588
  */
40365
40589
  validate(toolName, args) {
40366
- const validate = this.validators.get(toolName);
40367
- if (!validate) {
40590
+ const validate2 = this.validators.get(toolName);
40591
+ if (!validate2) {
40368
40592
  return { valid: true, errors: [] };
40369
40593
  }
40370
- const valid = validate(args);
40594
+ const valid = validate2(args);
40371
40595
  if (valid) {
40372
40596
  return { valid: true, errors: [] };
40373
40597
  }
40374
- const errors = this.formatErrors(validate.errors || []);
40598
+ const errors = this.formatErrors(validate2.errors || []);
40375
40599
  return { valid: false, errors };
40376
40600
  }
40377
40601
  /**
@@ -41579,88 +41803,48 @@ var decoder = new TextDecoder();
41579
41803
  var strictDecoder = new TextDecoder("utf-8", { fatal: true });
41580
41804
  var MAX_INT32 = 2 ** 32;
41581
41805
  function concat(...buffers) {
41582
- const size = buffers.reduce((acc, { length }) => acc + length, 0);
41583
- const buf = new Uint8Array(size);
41806
+ const size = buffers.reduce((acc, { length }) => acc + length, 0), buf = new Uint8Array(size);
41584
41807
  let i = 0;
41585
- for (const buffer of buffers) {
41586
- buf.set(buffer, i);
41587
- i += buffer.length;
41588
- }
41808
+ for (const buffer of buffers)
41809
+ buf.set(buffer, i), i += buffer.length;
41589
41810
  return buf;
41590
41811
  }
41812
+ var NON_ASCII = /[^\x00-\x7f]/;
41591
41813
  function encode2(string4) {
41814
+ if (typeof string4 == "string" && string4.length >= 128) {
41815
+ if (NON_ASCII.test(string4))
41816
+ throw new TypeError("non-ASCII string encountered in encode()");
41817
+ return encoder.encode(string4);
41818
+ }
41592
41819
  const bytes = new Uint8Array(string4.length);
41593
41820
  for (let i = 0; i < string4.length; i++) {
41594
41821
  const code = string4.charCodeAt(i);
41595
- if (code > 127) {
41822
+ if (code > 127)
41596
41823
  throw new TypeError("non-ASCII string encountered in encode()");
41597
- }
41598
41824
  bytes[i] = code;
41599
41825
  }
41600
41826
  return bytes;
41601
41827
  }
41602
-
41603
- // node_modules/jose/dist/webapi/lib/crypto_key.js
41604
- var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
41605
- function checkUsage(key, usage) {
41606
- if (usage && !key.usages.includes(usage)) {
41607
- throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
41608
- }
41609
- }
41610
- function checkModulusLength(alg, key) {
41611
- const { modulusLength } = key.algorithm;
41612
- if (typeof modulusLength !== "number" || modulusLength < 2048) {
41613
- throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
41614
- }
41615
- }
41616
- function checkCryptoKey(key, expected, usage) {
41617
- const algorithm = key.algorithm;
41618
- if (algorithm.name !== expected.name) {
41619
- throw unusable(expected.name);
41620
- }
41621
- if (expected.hash && algorithm.hash?.name !== expected.hash) {
41622
- throw unusable(expected.hash, "algorithm.hash");
41623
- }
41624
- if (expected.namedCurve && algorithm.namedCurve !== expected.namedCurve) {
41625
- throw unusable(expected.namedCurve, "algorithm.namedCurve");
41828
+ function decodeBase64(encoded, url2 = false) {
41829
+ if (Uint8Array.fromBase64)
41830
+ return Uint8Array.fromBase64(encoded, { alphabet: url2 ? "base64url" : "base64" });
41831
+ if (url2) {
41832
+ if (encoded.includes("+") || encoded.includes("/"))
41833
+ throw new TypeError("Invalid base64url");
41834
+ encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
41626
41835
  }
41627
- if (expected.length !== void 0 && algorithm.length !== expected.length) {
41628
- throw unusable(expected.length, "algorithm.length");
41629
- }
41630
- checkUsage(key, usage);
41631
- }
41632
-
41633
- // node_modules/jose/dist/webapi/lib/invalid_key_input.js
41634
- function message(msg, actual, ...types) {
41635
- if (types.length > 2) {
41636
- const last = types.pop();
41637
- msg += `one of type ${types.join(", ")}, or ${last}.`;
41638
- } else if (types.length === 2) {
41639
- msg += `one of type ${types[0]} or ${types[1]}.`;
41640
- } else {
41641
- msg += `of type ${types[0]}.`;
41642
- }
41643
- if (actual == null) {
41644
- msg += ` Received ${actual}`;
41645
- } else if (typeof actual === "function" && actual.name) {
41646
- msg += ` Received function ${actual.name}`;
41647
- } else if (typeof actual === "object" && actual != null) {
41648
- if (actual.constructor?.name) {
41649
- msg += ` Received an instance of ${actual.constructor.name}`;
41650
- }
41651
- }
41652
- return msg;
41836
+ const binary = atob(encoded), bytes = new Uint8Array(binary.length);
41837
+ for (let i = 0; i < binary.length; i++)
41838
+ bytes[i] = binary.charCodeAt(i);
41839
+ return bytes;
41653
41840
  }
41654
- var withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
41655
41841
 
41656
41842
  // node_modules/jose/dist/webapi/util/errors.js
41657
41843
  var JOSEError = class extends Error {
41658
41844
  static code = "ERR_JOSE_GENERIC";
41659
41845
  code = "ERR_JOSE_GENERIC";
41660
41846
  constructor(message2, options) {
41661
- super(message2, options);
41662
- this.name = this.constructor.name;
41663
- Error.captureStackTrace?.(this, this.constructor);
41847
+ super(message2, options), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
41664
41848
  }
41665
41849
  };
41666
41850
  var JWTClaimValidationFailed = class extends JOSEError {
@@ -41670,10 +41854,7 @@ var JWTClaimValidationFailed = class extends JOSEError {
41670
41854
  reason;
41671
41855
  payload;
41672
41856
  constructor(message2, payload, claim2 = "unspecified", reason = "unspecified") {
41673
- super(message2, { cause: { claim: claim2, reason, payload } });
41674
- this.claim = claim2;
41675
- this.reason = reason;
41676
- this.payload = payload;
41857
+ super(message2, { cause: { claim: claim2, reason, payload } }), this.claim = claim2, this.reason = reason, this.payload = payload;
41677
41858
  }
41678
41859
  };
41679
41860
  var JWTExpired = class extends JOSEError {
@@ -41683,10 +41864,7 @@ var JWTExpired = class extends JOSEError {
41683
41864
  reason;
41684
41865
  payload;
41685
41866
  constructor(message2, payload, claim2 = "unspecified", reason = "unspecified") {
41686
- super(message2, { cause: { claim: claim2, reason, payload } });
41687
- this.claim = claim2;
41688
- this.reason = reason;
41689
- this.payload = payload;
41867
+ super(message2, { cause: { claim: claim2, reason, payload } }), this.claim = claim2, this.reason = reason, this.payload = payload;
41690
41868
  }
41691
41869
  };
41692
41870
  var JOSEAlgNotAllowed = class extends JOSEError {
@@ -41740,73 +41918,37 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
41740
41918
  }
41741
41919
  };
41742
41920
 
41743
- // node_modules/jose/dist/webapi/lib/is_key_like.js
41744
- var isCryptoKey = (key) => {
41745
- if (key?.[Symbol.toStringTag] === "CryptoKey")
41746
- return true;
41747
- try {
41748
- return key instanceof CryptoKey;
41749
- } catch {
41750
- return false;
41751
- }
41752
- };
41753
- var isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
41754
- var isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
41755
-
41756
- // node_modules/jose/dist/webapi/lib/base64.js
41757
- function decodeBase64(encoded) {
41758
- if (Uint8Array.fromBase64) {
41759
- return Uint8Array.fromBase64(encoded);
41760
- }
41761
- const binary = atob(encoded);
41762
- const bytes = new Uint8Array(binary.length);
41763
- for (let i = 0; i < binary.length; i++) {
41764
- bytes[i] = binary.charCodeAt(i);
41765
- }
41766
- return bytes;
41767
- }
41768
-
41769
41921
  // node_modules/jose/dist/webapi/util/base64url.js
41770
41922
  var invalid = "The input to be decoded is not correctly encoded.";
41771
41923
  function decode2(input) {
41772
- if (Uint8Array.fromBase64) {
41773
- try {
41774
- return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
41775
- alphabet: "base64url"
41776
- });
41777
- } catch (cause) {
41778
- throw new TypeError(invalid, { cause });
41779
- }
41780
- }
41781
- let encoded = input;
41782
- if (encoded instanceof Uint8Array) {
41783
- encoded = decoder.decode(encoded);
41784
- }
41785
- if (encoded.includes("+") || encoded.includes("/")) {
41786
- throw new TypeError(invalid);
41787
- }
41788
- encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
41789
41924
  try {
41790
- return decodeBase64(encoded);
41791
- } catch {
41792
- throw new TypeError(invalid);
41925
+ return decodeBase64(typeof input == "string" ? input : decoder.decode(input), true);
41926
+ } catch (cause) {
41927
+ throw new TypeError(invalid, { cause });
41793
41928
  }
41794
41929
  }
41795
41930
 
41796
- // node_modules/jose/dist/webapi/lib/type_checks.js
41931
+ // node_modules/jose/dist/webapi/lib/validate.js
41797
41932
  function isObject2(input) {
41798
- if (typeof input !== "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]") {
41933
+ if (typeof input != "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]")
41799
41934
  return false;
41800
- }
41801
41935
  const prototype = Object.getPrototypeOf(input);
41802
41936
  return prototype === null || Object.getPrototypeOf(prototype) === null;
41803
41937
  }
41804
41938
  function isJwkSet(input) {
41805
41939
  return isObject2(input) && Array.isArray(input.keys) && Array.from(input.keys).every(isObject2);
41806
41940
  }
41807
-
41808
- // node_modules/jose/dist/webapi/lib/helpers.js
41809
- var unprotected = Symbol();
41941
+ function isDisjoint(...headers) {
41942
+ const parameters = /* @__PURE__ */ new Set();
41943
+ for (const header of headers)
41944
+ if (header)
41945
+ for (const parameter of Object.keys(header)) {
41946
+ if (parameters.has(parameter))
41947
+ return false;
41948
+ parameters.add(parameter);
41949
+ }
41950
+ return true;
41951
+ }
41810
41952
  function decodeBase64url(value, label, ErrorClass) {
41811
41953
  try {
41812
41954
  return decode2(value);
@@ -41828,48 +41970,42 @@ function parseJoseHeader(b64, ErrorClass, message2) {
41828
41970
  } catch {
41829
41971
  throw new ErrorClass(message2);
41830
41972
  }
41831
- if (!isObject2(parsed)) {
41973
+ if (!isObject2(parsed))
41832
41974
  throw new ErrorClass(message2);
41833
- }
41834
41975
  return parsed;
41835
41976
  }
41836
-
41837
- // node_modules/jose/dist/webapi/lib/jwk_to_key.js
41838
- async function jwkToKey(entry, jwk) {
41839
- if (jwk.kty === "RSA" && "oth" in jwk && jwk.oth !== void 0) {
41840
- throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
41841
- }
41842
- if (!entry.kty.includes(jwk.kty)) {
41843
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
41844
- }
41845
- const algorithm = entry.resolve?.({ kty: jwk.kty, crv: jwk.crv }) ?? entry.subtle;
41846
- const isPrivate = !!(jwk.d || jwk.priv);
41847
- const keyData = { ...jwk };
41848
- if (keyData.kty !== "AKP") {
41849
- delete keyData.alg;
41850
- }
41851
- delete keyData.use;
41852
- return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
41853
- }
41854
-
41855
- // node_modules/jose/dist/webapi/lib/jwk_metadata.js
41856
- function snapshotJwk(jwk) {
41857
- return { __proto__: null, ...jwk };
41977
+ var JWS_RECOGNIZED = { __proto__: null, b64: true };
41978
+ function validateAlgorithms(option, algorithms) {
41979
+ if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s != "string")))
41980
+ throw new TypeError(`"${option}" option must be an array of strings`);
41981
+ return algorithms === void 0 ? void 0 : new Set(algorithms);
41858
41982
  }
41859
- function normalizeJwk(jwk) {
41860
- const normalized = snapshotJwk(jwk);
41861
- if (normalized.ext !== void 0 && typeof normalized.ext !== "boolean") {
41862
- throw new TypeError('"ext" (Extractable) Parameter must be a boolean');
41983
+ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
41984
+ if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0)
41985
+ throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
41986
+ if (!protectedHeader || protectedHeader.crit === void 0)
41987
+ return [];
41988
+ if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input != "string" || input.length === 0))
41989
+ throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
41990
+ const recognized = recognizedOption === void 0 ? recognizedDefault : { __proto__: null, ...recognizedOption, ...recognizedDefault };
41991
+ for (const parameter of protectedHeader.crit) {
41992
+ if (!(parameter in recognized))
41993
+ throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
41994
+ if (!Object.hasOwn(joseHeader, parameter) || joseHeader[parameter] === void 0)
41995
+ throw new Err(`Extension Header Parameter "${parameter}" is missing`);
41996
+ if (recognized[parameter] && (!Object.hasOwn(protectedHeader, parameter) || protectedHeader[parameter] === void 0))
41997
+ throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
41863
41998
  }
41864
- if (normalized.key_ops !== void 0) {
41865
- const value = normalized.key_ops;
41866
- const keyOps = Array.isArray(value) ? [...value] : void 0;
41867
- if (!keyOps || keyOps.some((operation) => typeof operation !== "string") || new Set(keyOps).size !== keyOps.length) {
41868
- throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');
41869
- }
41870
- normalized.key_ops = keyOps;
41999
+ return protectedHeader.crit;
42000
+ }
42001
+ function validateB64(protectedHeader, extensions) {
42002
+ if (extensions.includes("b64")) {
42003
+ const b64 = protectedHeader.b64;
42004
+ if (typeof b64 != "boolean")
42005
+ throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
42006
+ return b64;
41871
42007
  }
41872
- return normalized;
42008
+ return true;
41873
42009
  }
41874
42010
 
41875
42011
  // node_modules/jose/dist/webapi/lib/key.js
@@ -41878,60 +42014,55 @@ var jwkMatchesOp = (entry, key, usage) => {
41878
42014
  const { alg } = entry;
41879
42015
  if (key.use !== void 0) {
41880
42016
  const expected = usage === "sign" || usage === "verify" ? "sig" : "enc";
41881
- if (key.use !== expected) {
42017
+ if (key.use !== expected)
41882
42018
  throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
41883
- }
41884
42019
  }
41885
- if (key.alg !== void 0 && key.alg !== alg) {
42020
+ if (key.alg !== void 0 && key.alg !== alg)
41886
42021
  throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
41887
- }
41888
42022
  if (Array.isArray(key.key_ops)) {
41889
42023
  const expectedKeyOp = usage === "encrypt" || usage === "decrypt" ? entry.ops?.[usage === "encrypt" ? 0 : 1] : usage;
41890
- if (expectedKeyOp && !key.key_ops.includes(expectedKeyOp)) {
42024
+ if (expectedKeyOp && !key.key_ops.includes(expectedKeyOp))
41891
42025
  throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
41892
- }
41893
42026
  }
41894
42027
  };
41895
- function checkKeyType(entry, key, usage) {
41896
- const { alg, secret } = entry;
41897
- const privateKey = usage === "decrypt" || usage === "sign";
42028
+ async function prepareKey(entry, key, usage) {
42029
+ const { alg, secret } = entry, privateKey = usage === "decrypt" || usage === "sign";
41898
42030
  if (secret && key instanceof Uint8Array)
41899
- return [BYTES, key];
42031
+ return key;
42032
+ let normalized, keyObject;
41900
42033
  if (isObject2(key)) {
41901
- const normalized = normalizeJwk(key);
41902
- if (typeof normalized.kty !== "string") {
41903
- throw new TypeError(secret ? withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array") : withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
41904
- }
41905
- const valid = secret ? normalized.kty === "oct" && typeof normalized.k === "string" : normalized.kty !== "oct" && (privateKey ? normalized.kty === "AKP" && typeof normalized.priv === "string" || typeof normalized.d === "string" : normalized.d === void 0 && normalized.priv === void 0);
41906
- if (!valid) {
41907
- throw new TypeError(secret ? `JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present` : `JSON Web Key for this operation must be a ${privateKey ? "private" : "public"} JWK`);
41908
- }
41909
- jwkMatchesOp(entry, normalized, usage);
41910
- return [JWK, key, normalized];
41911
- }
41912
- if (!isKeyLike(key)) {
41913
- throw new TypeError(secret ? withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array") : withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
41914
- }
41915
- if (secret) {
41916
- if (key.type !== "secret") {
41917
- throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
42034
+ if (normalized = normalizeJwk(key), typeof normalized.kty != "string")
42035
+ throw invalidKeyType(alg, key, secret);
42036
+ if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (privateKey ? normalized.kty === "AKP" && typeof normalized.priv == "string" || typeof normalized.d == "string" : normalized.d === void 0 && normalized.priv === void 0)))
42037
+ throw new TypeError(secret ? 'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present' : `JSON Web Key for this operation must be a ${privateKey ? "private" : "public"} JWK`);
42038
+ if (jwkMatchesOp(entry, normalized, usage), normalized.kty === "oct")
42039
+ return decode2(normalized.k);
42040
+ if (!Object.isFrozen(key)) {
42041
+ const { key_ops } = key;
42042
+ Array.isArray(key_ops) && Object.freeze(key_ops), Object.freeze(key);
41918
42043
  }
41919
42044
  } else {
41920
- if (key.type === "secret") {
41921
- throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
41922
- }
41923
- const expectedType = privateKey ? "private" : "public";
41924
- if ((key.type === "public" || key.type === "private") && key.type !== expectedType) {
41925
- const operation = usage === "sign" ? "signing" : usage === "verify" ? "verifying" : `${usage.slice(0, -1)}tion`;
41926
- throw new TypeError(`${tag(key)} instances for asymmetric algorithm ${operation} must be of type "${expectedType}"`);
41927
- }
42045
+ if (!isKeyLike(key))
42046
+ throw invalidKeyType(alg, key, secret);
42047
+ const expectedType = secret ? "secret" : privateKey ? "private" : "public";
42048
+ if (key.type !== expectedType && (secret || ["secret", "public", "private"].includes(key.type)))
42049
+ throw new TypeError(`${tag(key)} instances must be of type "${expectedType}" for the ${alg} algorithm`);
42050
+ if (isCryptoKey(key))
42051
+ return key;
42052
+ if (keyObject = key, keyObject.type === "secret")
42053
+ return keyObject.export();
42054
+ }
42055
+ cache ||= /* @__PURE__ */ new WeakMap();
42056
+ const cacheKey = key;
42057
+ let cached2 = cache.get(cacheKey);
42058
+ if (cached2?.[alg])
42059
+ return cached2[alg];
42060
+ if (cached2 || cache.set(cacheKey, cached2 = {}), keyObject && typeof keyObject.toCryptoKey == "function") {
42061
+ const isPublic = keyObject.type === "public", crv = nist[keyObject.asymmetricKeyDetails?.namedCurve], params = entry.resolve?.({ crv, asymmetricKeyType: keyObject.asymmetricKeyType }) ?? entry.subtle;
42062
+ return cached2[alg] = keyObject.toCryptoKey(params, isPublic, entry.usages[isPublic ? 0 : 1]);
41928
42063
  }
41929
- return isCryptoKey(key) ? [CRYPTO, key] : [KEYOBJECT, key];
42064
+ return normalized ??= keyObject.export({ format: "jwk" }), normalized.alg = alg, cached2[alg] = await jwkToKey(entry, normalized);
41930
42065
  }
41931
- var BYTES = 0;
41932
- var CRYPTO = 1;
41933
- var KEYOBJECT = 2;
41934
- var JWK = 3;
41935
42066
  var cache;
41936
42067
  var nist = {
41937
42068
  __proto__: null,
@@ -41939,139 +42070,83 @@ var nist = {
41939
42070
  secp384r1: "P-384",
41940
42071
  secp521r1: "P-521"
41941
42072
  };
41942
- function cached2(key, alg, value) {
41943
- cache ||= /* @__PURE__ */ new WeakMap();
41944
- const entry = cache.get(key);
41945
- if (value) {
41946
- if (entry) {
41947
- entry[alg] = value;
41948
- } else {
41949
- cache.set(key, { [alg]: value });
41950
- }
41951
- }
41952
- return value ?? entry?.[alg];
41953
- }
41954
- var handleJWK = async (key, jwk, entry) => cached2(key, entry.alg) ?? cached2(key, entry.alg, await jwkToKey(entry, { ...jwk, alg: entry.alg }));
41955
- var handleKeyObject = (keyObject, entry) => {
41956
- const hit = cached2(keyObject, entry.alg);
41957
- if (hit)
41958
- return hit;
41959
- const isPublic = keyObject.type === "public";
41960
- const usages = entry.usages[isPublic ? 0 : 1];
41961
- const { asymmetricKeyType } = keyObject;
41962
- const crv = nist[keyObject.asymmetricKeyDetails?.namedCurve];
41963
- const params = entry.resolve?.({ crv, asymmetricKeyType }) ?? entry.subtle;
41964
- return cached2(keyObject, entry.alg, keyObject.toCryptoKey(params, isPublic, usages));
42073
+ var isCryptoKey = (key) => {
42074
+ if (key?.[Symbol.toStringTag] === "CryptoKey")
42075
+ return true;
42076
+ try {
42077
+ return key instanceof CryptoKey;
42078
+ } catch {
42079
+ return false;
42080
+ }
41965
42081
  };
41966
- async function prepareKey(entry, key, usage) {
41967
- const tagged = checkKeyType(entry, key, usage);
41968
- switch (tagged[0]) {
41969
- case BYTES:
41970
- case CRYPTO:
41971
- return tagged[1];
41972
- case JWK: {
41973
- const key2 = tagged[1];
41974
- const normalized = tagged[2];
41975
- if (normalized.kty === "oct") {
41976
- return decode2(normalized.k);
41977
- }
41978
- if (!Object.isFrozen(key2)) {
41979
- const { key_ops } = key2;
41980
- if (Array.isArray(key_ops))
41981
- Object.freeze(key_ops);
41982
- Object.freeze(key2);
41983
- }
41984
- return handleJWK(key2, normalized, entry);
41985
- }
41986
- case KEYOBJECT: {
41987
- const keyObject = tagged[1];
41988
- if (keyObject.type === "secret") {
41989
- return keyObject.export();
41990
- }
41991
- if ("toCryptoKey" in keyObject && typeof keyObject.toCryptoKey === "function") {
41992
- return handleKeyObject(keyObject, entry);
41993
- }
41994
- return handleJWK(keyObject, keyObject.export({ format: "jwk" }), entry);
41995
- }
42082
+ var isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
42083
+ var isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
42084
+ function message(msg, actual, ...types) {
42085
+ if (types.length > 2) {
42086
+ const last = types.pop();
42087
+ msg += `one of type ${types.join(", ")}, or ${last}.`;
42088
+ } else types.length === 2 ? msg += `one of type ${types[0]} or ${types[1]}.` : msg += `of type ${types[0]}.`;
42089
+ return actual == null ? msg += ` Received ${actual}` : typeof actual == "function" && actual.name ? msg += ` Received function ${actual.name}` : typeof actual == "object" && actual != null && actual.constructor?.name && (msg += ` Received an instance of ${actual.constructor.name}`), msg;
42090
+ }
42091
+ function invalidKeyType(alg, actual, secret) {
42092
+ const types = ["CryptoKey", "KeyObject", "JSON Web Key"];
42093
+ return secret && types.push("Uint8Array"), new TypeError(message(`Key for the ${alg} algorithm must be `, actual, ...types));
42094
+ }
42095
+ var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
42096
+ function checkUsage(key, usage) {
42097
+ if (usage && !key.usages.includes(usage))
42098
+ throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
42099
+ }
42100
+ function checkModulusLength(alg, key) {
42101
+ const { modulusLength } = key.algorithm;
42102
+ if (typeof modulusLength != "number" || modulusLength < 2048)
42103
+ throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
42104
+ }
42105
+ function checkCryptoKey(key, expected, usage) {
42106
+ const algorithm = key.algorithm;
42107
+ if (algorithm.name !== expected.name)
42108
+ throw unusable(expected.name);
42109
+ if (expected.hash && algorithm.hash?.name !== expected.hash)
42110
+ throw unusable(expected.hash, "algorithm.hash");
42111
+ if (expected.namedCurve && algorithm.namedCurve !== expected.namedCurve)
42112
+ throw unusable(expected.namedCurve, "algorithm.namedCurve");
42113
+ if (expected.length !== void 0 && algorithm.length !== expected.length)
42114
+ throw unusable(expected.length, "algorithm.length");
42115
+ checkUsage(key, usage);
42116
+ }
42117
+ function snapshotJwk(jwk) {
42118
+ return { __proto__: null, ...jwk };
42119
+ }
42120
+ function normalizeJwk(jwk) {
42121
+ const normalized = snapshotJwk(jwk);
42122
+ if (normalized.ext !== void 0 && typeof normalized.ext != "boolean")
42123
+ throw new TypeError('"ext" (Extractable) Parameter must be a boolean');
42124
+ if (normalized.key_ops !== void 0) {
42125
+ const value = normalized.key_ops, keyOps = Array.isArray(value) ? [...value] : void 0;
42126
+ if (!keyOps || keyOps.some((operation) => typeof operation != "string") || new Set(keyOps).size !== keyOps.length)
42127
+ throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');
42128
+ normalized.key_ops = keyOps;
41996
42129
  }
42130
+ return normalized;
42131
+ }
42132
+ async function jwkToKey(entry, jwk, extractable) {
42133
+ if (!entry.kty.includes(jwk.kty))
42134
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
42135
+ const algorithm = entry.resolve?.({ kty: jwk.kty, crv: jwk.crv }) ?? entry.subtle, isPrivate = !!(jwk.d || jwk.priv), keyData = { ...jwk, ext: extractable ?? jwk.ext };
42136
+ return keyData.kty !== "AKP" && delete keyData.alg, delete keyData.use, crypto.subtle.importKey("jwk", keyData, algorithm, keyData.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
42137
+ }
42138
+ async function rawKey(key, expected, usage, extractable = false) {
42139
+ return key instanceof Uint8Array && (key = await crypto.subtle.importKey("raw", key, expected, extractable, [usage])), checkCryptoKey(key, expected, usage), key;
41997
42140
  }
41998
42141
 
41999
42142
  // node_modules/jose/dist/webapi/lib/key_descriptor.js
42000
42143
  function table(entries) {
42001
42144
  const out = { __proto__: null };
42002
- for (const alg in entries) {
42145
+ for (const alg in entries)
42003
42146
  out[alg] = { ...entries[alg], alg };
42004
- }
42005
42147
  return out;
42006
42148
  }
42007
42149
 
42008
- // node_modules/jose/dist/webapi/lib/options.js
42009
- var JWS_RECOGNIZED = { __proto__: null, b64: true };
42010
- function validateAlgorithms(option, algorithms) {
42011
- if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
42012
- throw new TypeError(`"${option}" option must be an array of strings`);
42013
- }
42014
- if (!algorithms) {
42015
- return void 0;
42016
- }
42017
- return new Set(algorithms);
42018
- }
42019
- function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
42020
- if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) {
42021
- throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
42022
- }
42023
- if (!protectedHeader || protectedHeader.crit === void 0) {
42024
- return [];
42025
- }
42026
- if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
42027
- throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
42028
- }
42029
- const recognized = recognizedOption === void 0 ? recognizedDefault : { __proto__: null, ...recognizedOption, ...recognizedDefault };
42030
- for (const parameter of protectedHeader.crit) {
42031
- if (!(parameter in recognized)) {
42032
- throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
42033
- }
42034
- if (!Object.hasOwn(joseHeader, parameter) || joseHeader[parameter] === void 0) {
42035
- throw new Err(`Extension Header Parameter "${parameter}" is missing`);
42036
- }
42037
- if (recognized[parameter] && (!Object.hasOwn(protectedHeader, parameter) || protectedHeader[parameter] === void 0)) {
42038
- throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
42039
- }
42040
- }
42041
- return protectedHeader.crit;
42042
- }
42043
- function validateB64(protectedHeader, extensions) {
42044
- if (extensions.includes("b64")) {
42045
- const b64 = protectedHeader.b64;
42046
- if (typeof b64 !== "boolean") {
42047
- throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
42048
- }
42049
- return b64;
42050
- }
42051
- return true;
42052
- }
42053
-
42054
- // node_modules/jose/dist/webapi/lib/signing.js
42055
- async function getSigKey(entry, key, usage) {
42056
- if (key instanceof Uint8Array) {
42057
- return crypto.subtle.importKey("raw", key, entry.subtle, false, [
42058
- usage
42059
- ]);
42060
- }
42061
- checkCryptoKey(key, entry.subtle, usage);
42062
- if (entry.minRsaBits)
42063
- checkModulusLength(entry.alg, key);
42064
- return key;
42065
- }
42066
- async function verify(entry, key, signature, data) {
42067
- const cryptoKey = await getSigKey(entry, key, "verify");
42068
- try {
42069
- return await crypto.subtle.verify(entry.signing, cryptoKey, signature, data);
42070
- } catch {
42071
- return false;
42072
- }
42073
- }
42074
-
42075
42150
  // node_modules/jose/dist/webapi/lib/jws_algorithms.js
42076
42151
  var sig = [["verify"], ["sign"]];
42077
42152
  function hmac(bits) {
@@ -42079,8 +42154,7 @@ function hmac(bits) {
42079
42154
  return { kty: ["oct"], secret: true, subtle, signing: subtle, usages: sig };
42080
42155
  }
42081
42156
  function rsa(bits, saltLength) {
42082
- const name = saltLength ? "RSA-PSS" : "RSASSA-PKCS1-v1_5";
42083
- const subtle = { name, hash: `SHA-${bits}` };
42157
+ const subtle = { name: saltLength ? "RSA-PSS" : "RSASSA-PKCS1-v1_5", hash: `SHA-${bits}` };
42084
42158
  return {
42085
42159
  kty: ["RSA"],
42086
42160
  subtle,
@@ -42109,8 +42183,7 @@ function eddsa() {
42109
42183
  };
42110
42184
  }
42111
42185
  function mldsa(bits) {
42112
- const name = `ML-DSA-${bits}`;
42113
- const subtle = { name };
42186
+ const subtle = { name: `ML-DSA-${bits}` };
42114
42187
  return {
42115
42188
  kty: ["AKP"],
42116
42189
  subtle,
@@ -42138,10 +42211,9 @@ var JWS = table({
42138
42211
  "ML-DSA-87": mldsa(87)
42139
42212
  });
42140
42213
  function jwsAlgorithm(alg) {
42141
- const entry = typeof alg === "string" ? JWS[alg] : void 0;
42142
- if (!entry) {
42214
+ const entry = typeof alg == "string" ? JWS[alg] : void 0;
42215
+ if (!entry)
42143
42216
  throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
42144
- }
42145
42217
  return entry;
42146
42218
  }
42147
42219
 
@@ -42149,19 +42221,8 @@ function jwsAlgorithm(alg) {
42149
42221
  function prepareVerify(options) {
42150
42222
  return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
42151
42223
  }
42152
- function parseProtectedHeader(encodedProtected, parsedProtected = encodedProtected === void 0 ? {} : parseJoseHeader(encodedProtected, JWSInvalid, "JWS Protected Header is invalid")) {
42153
- return parsedProtected;
42154
- }
42155
- function validateJwsHeaders(parsedProt, joseHeader, shared) {
42156
- const b64 = validateB64(parsedProt, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], parsedProt, joseHeader));
42157
- const alg = joseHeader.alg;
42158
- if (typeof alg !== "string" || !alg) {
42159
- throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
42160
- }
42161
- if (shared[0] && !shared[0].has(alg)) {
42162
- throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
42163
- }
42164
- return [b64, alg];
42224
+ function parseProtectedHeader(encodedProtected) {
42225
+ return encodedProtected === void 0 ? {} : parseJoseHeader(encodedProtected, JWSInvalid, "JWS Protected Header is invalid");
42165
42226
  }
42166
42227
  function encodeCompactUnencodedPayload(payload) {
42167
42228
  try {
@@ -42170,39 +42231,42 @@ function encodeCompactUnencodedPayload(payload) {
42170
42231
  throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters");
42171
42232
  }
42172
42233
  }
42173
- async function verifyPrepared(jws, shared, key, encodedProtected, parsedProt, alg, signingPayload) {
42234
+ async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedProtected) {
42235
+ const { protected: encodedProtected, header, payload: inputPayload } = jws, parsedProt = parsedProtected ?? parseProtectedHeader(encodedProtected);
42236
+ if (!isDisjoint(parsedProt, header))
42237
+ throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
42238
+ const joseHeader = { ...parsedProt, ...header }, b64 = validateB64(parsedProt, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], parsedProt, joseHeader)), { alg } = joseHeader;
42239
+ if (typeof alg != "string" || !alg)
42240
+ throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
42241
+ if (shared[0] && !shared[0].has(alg))
42242
+ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
42243
+ if (b64) {
42244
+ if (typeof inputPayload != "string")
42245
+ throw new JWSInvalid("JWS Payload must be a string");
42246
+ } else if (typeof inputPayload != "string" && !(inputPayload instanceof Uint8Array))
42247
+ throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
42248
+ const signingPayload = b64 || typeof inputPayload != "string" ? inputPayload : encodeUnencodedPayload(inputPayload);
42174
42249
  let resolvedKey = false;
42175
- if (typeof key === "function") {
42176
- key = await key(parsedProt, jws);
42177
- resolvedKey = true;
42178
- }
42179
- const b64 = typeof signingPayload === "string";
42180
- const entry = jwsAlgorithm(alg);
42181
- const data = concat(encodedProtected !== void 0 ? encode2(encodedProtected) : new Uint8Array(), encode2("."), b64 ? shared[2] ??= encodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload);
42182
- const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
42183
- const k = await prepareKey(entry, key, "verify");
42184
- if (!await verify(entry, k, signature, data)) {
42185
- throw new JWSSignatureVerificationFailed();
42250
+ typeof key == "function" && (key = await key(parsedProt, jws), resolvedKey = true);
42251
+ const entry = jwsAlgorithm(alg), data = concat(encodedProtected !== void 0 ? encode2(encodedProtected) : new Uint8Array(), encode2("."), typeof signingPayload == "string" ? shared[2] ??= encodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload), signature = decodeBase64url(jws.signature, "signature", JWSInvalid), k = await prepareKey(entry, key, "verify"), cryptoKey = await rawKey(k, entry.subtle, "verify");
42252
+ entry.minRsaBits && checkModulusLength(entry.alg, cryptoKey);
42253
+ let verified = false;
42254
+ try {
42255
+ verified = await crypto.subtle.verify(entry.signing, cryptoKey, signature, data);
42256
+ } catch {
42186
42257
  }
42187
- const payload = b64 ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload;
42188
- return [payload, parsedProt, b64, k, resolvedKey];
42258
+ if (!verified)
42259
+ throw new JWSSignatureVerificationFailed();
42260
+ const result = { payload: typeof signingPayload == "string" ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload };
42261
+ return encodedProtected !== void 0 && (result.protectedHeader = parsedProt), header !== void 0 && (result.unprotectedHeader = header), resolvedKey ? [{ ...result, key: k }, b64] : [result, b64];
42189
42262
  }
42190
42263
  async function verifyCompact(jws, shared, key) {
42191
- if (jws instanceof Uint8Array) {
42192
- jws = decoder.decode(jws);
42193
- }
42194
- if (typeof jws !== "string") {
42264
+ if (jws instanceof Uint8Array && (jws = decoder.decode(jws)), typeof jws != "string")
42195
42265
  throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
42196
- }
42197
42266
  const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split(".");
42198
- if (length !== 3) {
42267
+ if (length !== 3)
42199
42268
  throw new JWSInvalid("Invalid Compact JWS");
42200
- }
42201
- const compactJws = { payload, protected: protectedHeader, signature };
42202
- const parsedProt = parseProtectedHeader(protectedHeader);
42203
- const [b64, alg] = validateJwsHeaders(parsedProt, parsedProt, shared);
42204
- const signingPayload = b64 ? payload : encodeCompactUnencodedPayload(payload);
42205
- return verifyPrepared(compactJws, shared, key, protectedHeader, parsedProt, alg, signingPayload);
42269
+ return verifySignature({ payload, protected: protectedHeader, signature }, shared, key, encodeCompactUnencodedPayload);
42206
42270
  }
42207
42271
 
42208
42272
  // node_modules/jose/dist/webapi/lib/jwt_claims_set.js
@@ -42221,50 +42285,29 @@ function invalidDuration() {
42221
42285
  throw new TypeError("Invalid time period format");
42222
42286
  }
42223
42287
  function secs(str) {
42224
- if (typeof str !== "string") {
42225
- invalidDuration();
42226
- }
42288
+ typeof str != "string" && invalidDuration();
42227
42289
  const matched = REGEX.exec(str);
42228
- if (!matched || matched[4] && matched[1]) {
42229
- invalidDuration();
42230
- }
42231
- const value = parseFloat(matched[2]);
42232
- const numericDate = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
42233
- if (!Number.isFinite(numericDate)) {
42234
- invalidDuration();
42235
- }
42236
- if (matched[1] === "-" || matched[4] === "ago") {
42237
- return -numericDate;
42238
- }
42239
- return numericDate;
42290
+ (!matched || matched[4] && matched[1]) && invalidDuration();
42291
+ const value = parseFloat(matched[2]), numericDate2 = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
42292
+ return Number.isFinite(numericDate2) || invalidDuration(), matched[1] === "-" || matched[4] === "ago" ? -numericDate2 : numericDate2;
42240
42293
  }
42241
42294
  function validateInput(label, input) {
42242
- if (!Number.isFinite(input)) {
42295
+ if (!Number.isFinite(input))
42243
42296
  throw new TypeError(`Invalid ${label} input`);
42244
- }
42245
42297
  return input;
42246
42298
  }
42247
42299
  var normalizeTyp = (value) => {
42248
42300
  const normalized = value.toLowerCase();
42249
42301
  return value.includes("/") ? normalized : `application/${normalized}`;
42250
42302
  };
42251
- var checkAudiencePresence = (audPayload, audOption) => {
42252
- if (typeof audPayload === "string") {
42253
- return audOption.includes(audPayload);
42254
- }
42255
- if (Array.isArray(audPayload)) {
42256
- return audOption.some((aud) => audPayload.includes(aud));
42257
- }
42258
- return false;
42259
- };
42303
+ var checkAudiencePresence = (audPayload, audOption) => typeof audPayload == "string" ? audOption.includes(audPayload) : Array.isArray(audPayload) ? audOption.some((aud) => audPayload.includes(aud)) : false;
42260
42304
  function validateNumericDate(payload, claim2, required2 = false) {
42261
42305
  const value = payload[claim2];
42262
- if (value === void 0 && !required2)
42263
- return void 0;
42264
- if (typeof value !== "number") {
42265
- throw new JWTClaimValidationFailed(`"${claim2}" claim must be a number`, payload, claim2, "invalid");
42306
+ if (!(value === void 0 && !required2)) {
42307
+ if (typeof value != "number")
42308
+ throw new JWTClaimValidationFailed(`"${claim2}" claim must be a number`, payload, claim2, "invalid");
42309
+ return value;
42266
42310
  }
42267
- return value;
42268
42311
  }
42269
42312
  function unexpectedClaim(payload, claim2) {
42270
42313
  throw new JWTClaimValidationFailed(`unexpected "${claim2}" claim value`, payload, claim2, checkFailed);
@@ -42275,107 +42318,70 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
42275
42318
  payload = JSON.parse(strictDecoder.decode(encodedPayload));
42276
42319
  } catch {
42277
42320
  }
42278
- if (!isObject2(payload)) {
42321
+ if (!isObject2(payload))
42279
42322
  throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
42280
- }
42281
42323
  const { typ } = options;
42282
- if (typ !== void 0 && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
42324
+ if (typ !== void 0 && (typeof protectedHeader.typ != "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ)))
42283
42325
  throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', payload, "typ", checkFailed);
42284
- }
42285
- const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
42286
- const presenceCheck = [...requiredClaims];
42287
- if (maxTokenAge !== void 0)
42288
- presenceCheck.push("iat");
42289
- if (audience !== void 0)
42290
- presenceCheck.push("aud");
42291
- if (subject !== void 0)
42292
- presenceCheck.push("sub");
42293
- if (issuer !== void 0)
42294
- presenceCheck.push("iss");
42295
- for (const claim2 of new Set(presenceCheck.reverse())) {
42296
- if (!Object.hasOwn(payload, claim2)) {
42326
+ const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options, presenceCheck = [...requiredClaims];
42327
+ maxTokenAge !== void 0 && presenceCheck.push("iat"), audience !== void 0 && presenceCheck.push("aud"), subject !== void 0 && presenceCheck.push("sub"), issuer !== void 0 && presenceCheck.push("iss");
42328
+ for (const claim2 of new Set(presenceCheck.reverse()))
42329
+ if (!Object.hasOwn(payload, claim2))
42297
42330
  throw new JWTClaimValidationFailed(`missing required "${claim2}" claim`, payload, claim2, "missing");
42298
- }
42299
- }
42300
- if (issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {
42301
- unexpectedClaim(payload, "iss");
42302
- }
42303
- if (subject !== void 0 && payload.sub !== subject) {
42304
- unexpectedClaim(payload, "sub");
42305
- }
42306
- if (audience !== void 0 && !checkAudiencePresence(payload.aud, typeof audience === "string" ? [audience] : audience)) {
42307
- unexpectedClaim(payload, "aud");
42308
- }
42331
+ issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss) && unexpectedClaim(payload, "iss"), subject !== void 0 && payload.sub !== subject && unexpectedClaim(payload, "sub"), audience !== void 0 && !checkAudiencePresence(payload.aud, typeof audience == "string" ? [audience] : audience) && unexpectedClaim(payload, "aud");
42309
42332
  const { clockTolerance } = options;
42310
42333
  let tolerance = 0;
42311
- if (typeof clockTolerance === "string") {
42334
+ if (typeof clockTolerance == "string")
42312
42335
  tolerance = secs(clockTolerance);
42313
- } else if (clockTolerance !== void 0) {
42314
- if (typeof clockTolerance !== "number") {
42336
+ else if (clockTolerance !== void 0) {
42337
+ if (typeof clockTolerance != "number")
42315
42338
  throw new TypeError("Invalid clockTolerance option type");
42316
- }
42317
42339
  tolerance = clockTolerance;
42318
42340
  }
42319
42341
  validateInput("clockTolerance option", tolerance);
42320
- const { currentDate } = options;
42321
- const now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate));
42322
- const iat = validateNumericDate(payload, "iat", maxTokenAge !== void 0);
42323
- const nbf = validateNumericDate(payload, "nbf");
42324
- if (nbf !== void 0) {
42325
- if (nbf > now + tolerance) {
42326
- throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', payload, "nbf", checkFailed);
42327
- }
42328
- }
42342
+ const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(payload, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(payload, "nbf");
42343
+ if (nbf !== void 0 && nbf > now + tolerance)
42344
+ throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', payload, "nbf", checkFailed);
42329
42345
  const exp = validateNumericDate(payload, "exp");
42330
- if (exp !== void 0) {
42331
- if (exp <= now - tolerance) {
42332
- throw new JWTExpired('"exp" claim timestamp check failed', payload, "exp", checkFailed);
42333
- }
42334
- }
42346
+ if (exp !== void 0 && exp <= now - tolerance)
42347
+ throw new JWTExpired('"exp" claim timestamp check failed', payload, "exp", checkFailed);
42335
42348
  if (maxTokenAge !== void 0) {
42336
- const age = now - iat;
42337
- const max = validateInput("maxTokenAge option", typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge));
42338
- if (age - tolerance > max) {
42349
+ const age = now - iat, max = validateInput("maxTokenAge option", typeof maxTokenAge == "number" ? maxTokenAge : secs(maxTokenAge));
42350
+ if (age - tolerance > max)
42339
42351
  throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload, "iat", checkFailed);
42340
- }
42341
- if (age < -tolerance) {
42352
+ if (age < -tolerance)
42342
42353
  throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', payload, "iat", checkFailed);
42343
- }
42344
42354
  }
42345
42355
  return payload;
42346
42356
  }
42347
42357
 
42348
42358
  // node_modules/jose/dist/webapi/jwt/verify.js
42349
42359
  async function jwtVerify(jwt, key, options) {
42350
- const verified = await verifyCompact(jwt, prepareVerify(options), key);
42351
- if (!verified[2]) {
42360
+ const [verified, b64] = await verifyCompact(jwt, prepareVerify(options), key);
42361
+ if (!b64)
42352
42362
  throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
42353
- }
42354
- const payload = validateClaimsSet(verified[1], verified[0], options);
42355
- const result = { payload, protectedHeader: verified[1] };
42356
- if (typeof key === "function") {
42357
- return { ...result, key: verified[3] };
42358
- }
42359
- return result;
42363
+ const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);
42364
+ return { ...verified, payload };
42360
42365
  }
42361
42366
 
42362
42367
  // node_modules/jose/dist/webapi/jwks/local.js
42363
42368
  function isUsableJWK(jwk, entry, alg, kid) {
42364
- const { kty, key_ops, ext, kid: jwkKid, alg: jwkAlg, use, crv } = snapshotJwk(jwk);
42365
- const keyOps = Array.isArray(key_ops) ? [...key_ops] : key_ops;
42366
- return (ext === void 0 || typeof ext === "boolean") && (keyOps === void 0 || Array.isArray(keyOps) && keyOps.every((operation, index) => typeof operation === "string" && keyOps.indexOf(operation) === index) && keyOps.includes("verify")) && entry.kty.includes(kty) && (kid === void 0 || typeof kid === "string" && kid === jwkKid) && (jwkAlg === void 0 ? kty !== "AKP" : alg === jwkAlg) && (use === void 0 || use === "sig") && (!entry.crv || crv === entry.crv);
42369
+ const { kty, key_ops: keyOps, ext, kid: jwkKid, alg: jwkAlg, use, crv } = jwk;
42370
+ return (ext === void 0 || typeof ext == "boolean") && (keyOps === void 0 || Array.isArray(keyOps) && keyOps.every((operation, index) => typeof operation == "string" && keyOps.indexOf(operation) === index) && keyOps.includes("verify")) && entry.kty.includes(kty) && (kid === void 0 || typeof kid == "string" && kid === jwkKid) && (jwkAlg === void 0 ? kty !== "AKP" : alg === jwkAlg) && (use === void 0 || use === "sig") && (!entry.crv || crv === entry.crv);
42367
42371
  }
42368
42372
  async function importWithAlgCache(cache2, jwk, entry) {
42369
- const cached3 = cache2.get(jwk) || cache2.set(jwk, {}).get(jwk);
42370
- const { alg } = entry;
42371
- if (cached3[alg] === void 0) {
42372
- const key = await jwkToKey(entry, { ...jwk, alg, ext: true });
42373
- if (key.type !== "public") {
42374
- throw new JWKSInvalid("JSON Web Key Set members must be public keys");
42375
- }
42376
- cached3[alg] = key;
42373
+ const cached2 = cache2.get(jwk) || cache2.set(jwk, {}).get(jwk), { alg } = entry;
42374
+ if (cached2[alg] === void 0) {
42375
+ const pending = jwkToKey(entry, jwk, true).then((key) => {
42376
+ if (key.type !== "public")
42377
+ throw new JWKSInvalid("JSON Web Key Set members must be public keys");
42378
+ return cached2[alg] = key, key;
42379
+ }).catch((error2) => {
42380
+ throw cached2[alg] === pending && delete cached2[alg], error2;
42381
+ });
42382
+ cached2[alg] = pending;
42377
42383
  }
42378
- return cached3[alg];
42384
+ return cached2[alg];
42379
42385
  }
42380
42386
  function createLocalJWKSet(jwks) {
42381
42387
  let snapshot;
@@ -42383,51 +42389,42 @@ function createLocalJWKSet(jwks) {
42383
42389
  snapshot = structuredClone(jwks);
42384
42390
  } catch {
42385
42391
  }
42386
- if (!isJwkSet(snapshot)) {
42392
+ if (!isJwkSet(snapshot))
42387
42393
  throw new JWKSInvalid("JSON Web Key Set malformed");
42388
- }
42389
- const cached3 = /* @__PURE__ */ new WeakMap();
42390
- const localJWKSet = async (protectedHeader, token) => {
42391
- const { alg, kid } = { ...protectedHeader, ...token?.header };
42392
- const entry = typeof alg === "string" ? JWS[alg] : void 0;
42393
- if (!entry || entry.secret) {
42394
+ const metadata = snapshot.keys.map((jwk) => {
42395
+ const normalized = snapshotJwk(jwk);
42396
+ return Array.isArray(normalized.key_ops) && (normalized.key_ops = [...normalized.key_ops]), normalized;
42397
+ }), cached2 = /* @__PURE__ */ new WeakMap();
42398
+ return Object.defineProperty(async (protectedHeader, token) => {
42399
+ const { alg, kid } = { ...protectedHeader, ...token?.header }, entry = typeof alg == "string" ? JWS[alg] : void 0;
42400
+ if (!entry || entry.secret)
42394
42401
  throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
42395
- }
42396
- const candidates = snapshot.keys.filter((jwk2) => isUsableJWK(jwk2, entry, alg, kid));
42397
- const { 0: jwk, length } = candidates;
42398
- if (!length) {
42402
+ const candidates = snapshot.keys.filter((_, index) => isUsableJWK(metadata[index], entry, alg, kid)), { 0: jwk, length } = candidates;
42403
+ if (!length)
42399
42404
  throw new JWKSNoMatchingKey();
42400
- }
42401
42405
  if (length !== 1) {
42402
42406
  const error2 = new JWKSMultipleMatchingKeys();
42403
- error2[Symbol.asyncIterator] = async function* () {
42404
- for (const jwk2 of candidates) {
42407
+ throw error2[Symbol.asyncIterator] = async function* () {
42408
+ for (const jwk2 of candidates)
42405
42409
  try {
42406
- yield await importWithAlgCache(cached3, jwk2, entry);
42410
+ yield await importWithAlgCache(cached2, jwk2, entry);
42407
42411
  } catch {
42408
42412
  }
42409
- }
42410
- };
42411
- throw error2;
42413
+ }, error2;
42412
42414
  }
42413
- return importWithAlgCache(cached3, jwk, entry);
42414
- };
42415
- return Object.defineProperty(localJWKSet, "jwks", {
42415
+ return importWithAlgCache(cached2, jwk, entry);
42416
+ }, "jwks", {
42416
42417
  value: () => structuredClone(snapshot)
42417
42418
  });
42418
42419
  }
42419
42420
 
42420
42421
  // node_modules/jose/dist/webapi/jwks/remote.js
42421
42422
  function isCloudflareWorkers() {
42422
- return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
42423
+ return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
42423
42424
  }
42424
42425
  var USER_AGENT;
42425
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
42426
- const NAME = "jose";
42427
- const VERSION2 = "v6.2.10";
42428
- USER_AGENT = `${NAME}/${VERSION2}`;
42429
- }
42430
- var customFetch = Symbol();
42426
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.12");
42427
+ var customFetch = /* @__PURE__ */ Symbol();
42431
42428
  async function fetchJwks(url2, headers, signal, fetchImpl = fetch) {
42432
42429
  const response = await fetchImpl(url2, {
42433
42430
  method: "GET",
@@ -42435,106 +42432,64 @@ async function fetchJwks(url2, headers, signal, fetchImpl = fetch) {
42435
42432
  redirect: "manual",
42436
42433
  headers
42437
42434
  }).catch((err) => {
42438
- if (err.name === "TimeoutError") {
42439
- throw new JWKSTimeout();
42440
- }
42441
- throw err;
42435
+ throw err.name === "TimeoutError" ? new JWKSTimeout() : err;
42442
42436
  });
42443
- if (response.status !== 200) {
42437
+ if (response.status !== 200)
42444
42438
  throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
42445
- }
42446
42439
  try {
42447
42440
  return await response.json();
42448
42441
  } catch {
42449
42442
  throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
42450
42443
  }
42451
42444
  }
42452
- var jwksCache = Symbol();
42445
+ var jwksCache = /* @__PURE__ */ Symbol();
42453
42446
  function isFreshFor(timestamp, duration3) {
42454
42447
  return Number.isFinite(timestamp) && Date.now() < timestamp + duration3;
42455
42448
  }
42456
42449
  function validateDuration(value, fallback, option) {
42457
- if (Number.isNaN(value)) {
42450
+ if (Number.isNaN(value))
42458
42451
  throw new TypeError(`"${option}" option must not be NaN`);
42459
- }
42460
- return typeof value === "number" ? value : fallback;
42452
+ return typeof value == "number" ? value : fallback;
42461
42453
  }
42462
42454
  function createRemoteJWKSet(url2, options) {
42463
- if (!(url2 instanceof URL)) {
42455
+ if (!(url2 instanceof URL))
42464
42456
  throw new TypeError("url must be an instance of URL");
42465
- }
42466
- const href = new URL(url2.href).href;
42467
- const opts = options ?? {};
42468
- const timeoutOption = opts.timeoutDuration;
42469
- if (typeof timeoutOption === "number" && (!Number.isInteger(timeoutOption) || timeoutOption < 0)) {
42457
+ const href = new URL(url2.href).href, opts = options ?? {}, timeoutOption = opts.timeoutDuration;
42458
+ if (typeof timeoutOption == "number" && (!Number.isInteger(timeoutOption) || timeoutOption < 0))
42470
42459
  throw new TypeError('"timeoutDuration" option must be a non-negative integer');
42471
- }
42472
- const timeoutDuration = typeof timeoutOption === "number" ? timeoutOption : 5e3;
42473
- const cooldownDuration = validateDuration(opts.cooldownDuration, 3e4, "cooldownDuration");
42474
- const cacheMaxAge = validateDuration(opts.cacheMaxAge, 6e5, "cacheMaxAge");
42475
- const headers = new Headers(opts.headers);
42476
- if (USER_AGENT && !headers.has("User-Agent")) {
42477
- headers.set("User-Agent", USER_AGENT);
42478
- }
42479
- if (!headers.has("accept")) {
42480
- headers.set("accept", "application/json, application/jwk-set+json");
42481
- }
42482
- const fetchImpl = opts[customFetch];
42483
- const cache2 = opts[jwksCache];
42484
- let jwksTimestamp;
42485
- let pendingFetch;
42486
- let reloadSequence = 0;
42487
- let appliedSequence = 0;
42488
- let local;
42489
- if (cache2 && typeof cache2 === "object") {
42460
+ const timeoutDuration = typeof timeoutOption == "number" ? timeoutOption : 5e3, cooldownDuration = validateDuration(opts.cooldownDuration, 3e4, "cooldownDuration"), cacheMaxAge = validateDuration(opts.cacheMaxAge, 6e5, "cacheMaxAge"), headers = new Headers(opts.headers);
42461
+ USER_AGENT && !headers.has("User-Agent") && headers.set("User-Agent", USER_AGENT), headers.has("accept") || headers.set("accept", "application/json, application/jwk-set+json");
42462
+ const fetchImpl = opts[customFetch], cache2 = opts[jwksCache];
42463
+ let jwksTimestamp, pendingFetch, reloadSequence = 0, appliedSequence = 0, local;
42464
+ if (cache2 && typeof cache2 == "object") {
42490
42465
  const { uat, jwks } = cache2;
42491
- if (isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks)) {
42492
- jwksTimestamp = uat;
42493
- local = createLocalJWKSet(jwks);
42494
- }
42466
+ isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks) && (jwksTimestamp = uat, local = createLocalJWKSet(jwks));
42495
42467
  }
42496
42468
  const reload = async () => {
42497
- if (pendingFetch && isCloudflareWorkers()) {
42498
- pendingFetch = void 0;
42499
- }
42500
- if (!pendingFetch) {
42501
- const sequence = ++reloadSequence;
42502
- const current = pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl).then((json) => {
42469
+ if (pendingFetch && isCloudflareWorkers() && (pendingFetch = void 0), !pendingFetch) {
42470
+ const sequence = ++reloadSequence, current = pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl).then((json) => {
42503
42471
  const next = createLocalJWKSet(json);
42504
- if (sequence <= appliedSequence) {
42472
+ if (sequence <= appliedSequence)
42505
42473
  return;
42506
- }
42507
42474
  local = next;
42508
42475
  const updatedAt = Date.now();
42509
- if (cache2) {
42510
- cache2.uat = updatedAt;
42511
- cache2.jwks = json;
42512
- }
42513
- jwksTimestamp = updatedAt;
42514
- appliedSequence = sequence;
42476
+ cache2 && (cache2.uat = updatedAt, cache2.jwks = json), jwksTimestamp = updatedAt, appliedSequence = sequence;
42515
42477
  }).finally(() => {
42516
- if (pendingFetch === current) {
42517
- pendingFetch = void 0;
42518
- }
42478
+ pendingFetch === current && (pendingFetch = void 0);
42519
42479
  });
42520
42480
  }
42521
42481
  await pendingFetch;
42522
42482
  };
42523
- const remoteJWKSet = async (protectedHeader, token) => {
42524
- if (!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) {
42525
- await reload();
42526
- }
42483
+ return Object.defineProperties(async (protectedHeader, token) => {
42484
+ (!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) && await reload();
42527
42485
  try {
42528
42486
  return await local(protectedHeader, token);
42529
42487
  } catch (err) {
42530
- if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration)) {
42531
- await reload();
42532
- return local(protectedHeader, token);
42533
- }
42488
+ if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration))
42489
+ return await reload(), local(protectedHeader, token);
42534
42490
  throw err;
42535
42491
  }
42536
- };
42537
- return Object.defineProperties(remoteJWKSet, {
42492
+ }, {
42538
42493
  coolingDown: {
42539
42494
  get: () => isFreshFor(jwksTimestamp, cooldownDuration),
42540
42495
  enumerable: true
@@ -42637,16 +42592,16 @@ var JwtAuthProvider = class _JwtAuthProvider extends AuthProvider {
42637
42592
  }
42638
42593
  async verifyToken(token) {
42639
42594
  const cacheKey = await this.hashToken(token);
42640
- const cached3 = this.tokenCache.get(cacheKey);
42641
- if (cached3 && Date.now() < cached3.expiresAt) {
42595
+ const cached2 = this.tokenCache.get(cacheKey);
42596
+ if (cached2 && Date.now() < cached2.expiresAt) {
42642
42597
  if (isOtelEnabled()) {
42643
42598
  recordAuthEvent("cache_hit", {
42644
- subject: cached3.authInfo.subject ?? ""
42599
+ subject: cached2.authInfo.subject ?? ""
42645
42600
  });
42646
42601
  }
42647
- return cached3.authInfo;
42602
+ return cached2.authInfo;
42648
42603
  }
42649
- if (cached3) this.tokenCache.delete(cacheKey);
42604
+ if (cached2) this.tokenCache.delete(cacheKey);
42650
42605
  try {
42651
42606
  const { payload } = await jwtVerify(token, this.jwks, {
42652
42607
  issuer: this.options.issuer,
@@ -48785,8 +48740,8 @@ var FrappeClient = class {
48785
48740
  async list(doctype, options = {}, opts = {}) {
48786
48741
  const cacheKey = `list:${doctype}:${stableStringify(options)}`;
48787
48742
  if (!opts.skipCache) {
48788
- const cached3 = this.cache.get(cacheKey);
48789
- if (cached3 !== void 0) return cached3;
48743
+ const cached2 = this.cache.get(cacheKey);
48744
+ if (cached2 !== void 0) return cached2;
48790
48745
  }
48791
48746
  const params = new URLSearchParams();
48792
48747
  if (options.fields && options.fields.length > 0) {
@@ -48826,8 +48781,8 @@ var FrappeClient = class {
48826
48781
  async get(doctype, name, opts = {}) {
48827
48782
  const cacheKey = `get:${doctype}:${name}`;
48828
48783
  if (!opts.skipCache) {
48829
- const cached3 = this.cache.get(cacheKey);
48830
- if (cached3 !== void 0) return cached3;
48784
+ const cached2 = this.cache.get(cacheKey);
48785
+ if (cached2 !== void 0) return cached2;
48831
48786
  }
48832
48787
  const res = await this.request(
48833
48788
  "GET",
@@ -54126,6 +54081,62 @@ function loadMethodAllowlist() {
54126
54081
  return parseAllowlist(env6("ERPNEXT_METHOD_ALLOWLIST"));
54127
54082
  }
54128
54083
 
54084
+ // src/tools/purchase-invoice-hints.ts
54085
+ var PURCHASE_INVOICE_DOCTYPE = "Purchase Invoice";
54086
+ var PARTY_ACCOUNT_HINT = "Set data.credit_to, or configure Supplier/Supplier Group accounts, or Company.default_payable_account.";
54087
+ var GRNI_HINT = "Company.stock_received_but_not_billed is required with perpetual inventory even if update_stock is 0.";
54088
+ function isPurchaseInvoiceDoctype(doctype) {
54089
+ return doctype === PURCHASE_INVOICE_DOCTYPE;
54090
+ }
54091
+ function stripHtml(text) {
54092
+ return text.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
54093
+ }
54094
+ function purchaseInvoiceAccountHint(text) {
54095
+ const haystack = stripHtml(text);
54096
+ if (isEmptyPartyAccountCurrencyNone(haystack)) {
54097
+ return PARTY_ACCOUNT_HINT;
54098
+ }
54099
+ if (/please set default stock received but not billed in company/i.test(
54100
+ haystack
54101
+ )) {
54102
+ return GRNI_HINT;
54103
+ }
54104
+ return void 0;
54105
+ }
54106
+ function annotateKnownPurchaseInvoiceAccountError(error2) {
54107
+ if (error2 instanceof FrappeAPIError && error2.status === 417) {
54108
+ let hint = purchaseInvoiceAccountHint(error2.message);
54109
+ if (!hint) {
54110
+ const bodyMessage = readErrorBodyMessage(error2.body);
54111
+ if (bodyMessage) {
54112
+ hint = purchaseInvoiceAccountHint(bodyMessage);
54113
+ }
54114
+ }
54115
+ if (hint && !error2.message.includes(hint)) {
54116
+ error2.message = `${error2.message} ${hint}`;
54117
+ }
54118
+ }
54119
+ throw error2;
54120
+ }
54121
+ async function withPurchaseInvoiceAccountHints(fn) {
54122
+ try {
54123
+ return await fn();
54124
+ } catch (error2) {
54125
+ annotateKnownPurchaseInvoiceAccountError(error2);
54126
+ }
54127
+ }
54128
+ function readErrorBodyMessage(body) {
54129
+ if (typeof body === "string") return body;
54130
+ if (body === null || typeof body !== "object" || Array.isArray(body)) {
54131
+ return void 0;
54132
+ }
54133
+ const message2 = body.message;
54134
+ return typeof message2 === "string" ? message2 : void 0;
54135
+ }
54136
+ function isEmptyPartyAccountCurrencyNone(text) {
54137
+ return /party account\s+(?:none\s+)?currency\s*\(\s*none\s*\)\s+and document currency\s*\([^)]*\)\s+should be same/i.test(text);
54138
+ }
54139
+
54129
54140
  // src/tools/operations.ts
54130
54141
  function bytesToBase64(bytes) {
54131
54142
  const chunkSize = 32 * 1024;
@@ -54137,6 +54148,9 @@ function bytesToBase64(bytes) {
54137
54148
  }
54138
54149
  return btoa(binary);
54139
54150
  }
54151
+ async function withPiAccountHintsIfNeeded(doctype, fn) {
54152
+ return isPurchaseInvoiceDoctype(doctype) ? await withPurchaseInvoiceAccountHints(fn) : await fn();
54153
+ }
54140
54154
  var operationsTools = [
54141
54155
  // ── File Attachments ───────────────────────────────────────────────────────
54142
54156
  {
@@ -54398,9 +54412,12 @@ var operationsTools = [
54398
54412
  "[erpnext_doc_create] 'data' must be an object with document fields"
54399
54413
  );
54400
54414
  }
54401
- const doc = await ctx.client.create(
54415
+ const doc = await withPiAccountHintsIfNeeded(
54402
54416
  input.doctype,
54403
- input.data
54417
+ () => ctx.client.create(
54418
+ input.doctype,
54419
+ input.data
54420
+ )
54404
54421
  );
54405
54422
  return {
54406
54423
  data: doc,
@@ -54444,10 +54461,13 @@ var operationsTools = [
54444
54461
  "[erpnext_doc_update] 'data' must be an object with fields to update"
54445
54462
  );
54446
54463
  }
54447
- const doc = await ctx.client.update(
54464
+ const doc = await withPiAccountHintsIfNeeded(
54448
54465
  input.doctype,
54449
- input.name,
54450
- input.data
54466
+ () => ctx.client.update(
54467
+ input.doctype,
54468
+ input.name,
54469
+ input.data
54470
+ )
54451
54471
  );
54452
54472
  return {
54453
54473
  data: doc,
@@ -54518,25 +54538,30 @@ var operationsTools = [
54518
54538
  if (!input.name) {
54519
54539
  throw new Error("[erpnext_doc_submit] 'name' is required");
54520
54540
  }
54521
- const doc = await ctx.client.get(
54522
- input.doctype,
54523
- input.name,
54524
- { skipCache: true }
54525
- );
54526
- const docWithDoctype = { ...doc, doctype: input.doctype };
54527
- const patchedDoc = withRoundedTotalFallback(docWithDoctype);
54528
- const result = await ctx.client.callMethod("frappe.client.submit", {
54529
- doc: patchedDoc
54541
+ return await withPiAccountHintsIfNeeded(input.doctype, async () => {
54542
+ const doc = await ctx.client.get(
54543
+ input.doctype,
54544
+ input.name,
54545
+ { skipCache: true }
54546
+ );
54547
+ const docWithDoctype = { ...doc, doctype: input.doctype };
54548
+ const patchedDoc = withRoundedTotalFallback(docWithDoctype);
54549
+ const result = await ctx.client.callMethod("frappe.client.submit", {
54550
+ doc: patchedDoc
54551
+ });
54552
+ ctx.client.invalidate(input.doctype, input.name);
54553
+ const warnings = roundedTotalFallbackWarning(
54554
+ docWithDoctype,
54555
+ patchedDoc
54556
+ );
54557
+ return {
54558
+ data: result,
54559
+ message: `${input.doctype} ${input.name} submitted successfully`,
54560
+ doctype: input.doctype,
54561
+ name: input.name,
54562
+ ...warnings.length > 0 ? { warnings } : {}
54563
+ };
54530
54564
  });
54531
- ctx.client.invalidate(input.doctype, input.name);
54532
- const warnings = roundedTotalFallbackWarning(docWithDoctype, patchedDoc);
54533
- return {
54534
- data: result,
54535
- message: `${input.doctype} ${input.name} submitted successfully`,
54536
- doctype: input.doctype,
54537
- name: input.name,
54538
- ...warnings.length > 0 ? { warnings } : {}
54539
- };
54540
54565
  }
54541
54566
  },
54542
54567
  // ── Generic Cancel ────────────────────────────────────────────────────────
@@ -55056,6 +55081,29 @@ var setupTools = [
55056
55081
 
55057
55082
  // src/tools/analytics.ts
55058
55083
  var MAX_RADAR_ITEMS = 8;
55084
+ function monthlyLabels(now, count) {
55085
+ const labels = [];
55086
+ for (let offset = count - 1; offset >= 0; offset--) {
55087
+ const month = new Date(now.getFullYear(), now.getMonth() - offset, 1);
55088
+ labels.push(
55089
+ `${month.toLocaleString("en", { month: "short" })} ${month.getFullYear().toString().slice(2)}`
55090
+ );
55091
+ }
55092
+ return labels;
55093
+ }
55094
+ function frappeCalendarMonth(value) {
55095
+ if (typeof value !== "string") return null;
55096
+ const match2 = /^(\d{4})-(\d{2})-\d{2}$/.exec(value.trim());
55097
+ if (!match2) return null;
55098
+ const year = Number(match2[1]);
55099
+ const month = Number(match2[2]) - 1;
55100
+ return Number.isInteger(year) && month >= 0 && month <= 11 ? { year, month } : null;
55101
+ }
55102
+ function localCalendarDate(date4) {
55103
+ const month = String(date4.getMonth() + 1).padStart(2, "0");
55104
+ const day = String(date4.getDate()).padStart(2, "0");
55105
+ return `${date4.getFullYear()}-${month}-${day}`;
55106
+ }
55059
55107
  var analyticsTools = [
55060
55108
  // ── Stock Chart ───────────────────────────────────────────────────────────
55061
55109
  {
@@ -55295,29 +55343,20 @@ var analyticsTools = [
55295
55343
  now.getMonth() - monthsBack + 1,
55296
55344
  1
55297
55345
  );
55298
- const startStr = startDate.toISOString().split("T")[0];
55346
+ const startStr = localCalendarDate(startDate);
55299
55347
  const orders = await ctx.client.list("Sales Order", {
55300
55348
  fields: ["customer_name", "grand_total", "transaction_date"],
55301
55349
  filters: [["transaction_date", ">=", startStr], ["docstatus", "!=", 2]],
55302
55350
  limit: 1e3,
55303
55351
  order_by: "transaction_date asc"
55304
55352
  });
55305
- const months = [];
55306
- for (let m = 0; m < monthsBack; m++) {
55307
- const d = new Date(
55308
- now.getFullYear(),
55309
- now.getMonth() - monthsBack + 1 + m,
55310
- 1
55311
- );
55312
- months.push(
55313
- `${d.toLocaleString("en", { month: "short" })} ${d.getFullYear().toString().slice(2)}`
55314
- );
55315
- }
55353
+ const months = monthlyLabels(now, monthsBack);
55316
55354
  if (groupBy === "customer") {
55317
55355
  const byCustomerMonth = {};
55318
55356
  for (const order2 of orders) {
55319
- const d = new Date(order2.transaction_date);
55320
- const mIdx = (d.getFullYear() - startDate.getFullYear()) * 12 + d.getMonth() - startDate.getMonth();
55357
+ const calendarMonth = frappeCalendarMonth(order2.transaction_date);
55358
+ if (!calendarMonth) continue;
55359
+ const mIdx = (calendarMonth.year - startDate.getFullYear()) * 12 + calendarMonth.month - startDate.getMonth();
55321
55360
  if (mIdx < 0 || mIdx >= monthsBack) continue;
55322
55361
  const cust = order2.customer_name ?? "Unknown";
55323
55362
  if (!byCustomerMonth[cust]) {
@@ -55348,8 +55387,9 @@ var analyticsTools = [
55348
55387
  }
55349
55388
  const monthlyTotals = new Array(monthsBack).fill(0);
55350
55389
  for (const order2 of orders) {
55351
- const d = new Date(order2.transaction_date);
55352
- const mIdx = (d.getFullYear() - startDate.getFullYear()) * 12 + d.getMonth() - startDate.getMonth();
55390
+ const calendarMonth = frappeCalendarMonth(order2.transaction_date);
55391
+ if (!calendarMonth) continue;
55392
+ const mIdx = (calendarMonth.year - startDate.getFullYear()) * 12 + calendarMonth.month - startDate.getMonth();
55353
55393
  if (mIdx >= 0 && mIdx < monthsBack) {
55354
55394
  monthlyTotals[mIdx] += Number(order2.grand_total) || 0;
55355
55395
  }
@@ -55781,7 +55821,7 @@ var analyticsTools = [
55781
55821
  handler: async (_input, ctx) => {
55782
55822
  const now = /* @__PURE__ */ new Date();
55783
55823
  const sixMonthsAgo = new Date(now.getFullYear(), now.getMonth() - 5, 1);
55784
- const sinceStr = sixMonthsAgo.toISOString().split("T")[0];
55824
+ const sinceStr = localCalendarDate(sixMonthsAgo);
55785
55825
  const allOrders = await ctx.client.list("Sales Order", {
55786
55826
  fields: ["grand_total", "transaction_date"],
55787
55827
  filters: [
@@ -55791,9 +55831,11 @@ var analyticsTools = [
55791
55831
  limit: 5e3
55792
55832
  });
55793
55833
  const sparkline = [0, 0, 0, 0, 0, 0];
55834
+ const sparklineLabels = monthlyLabels(now, sparkline.length);
55794
55835
  for (const o of allOrders) {
55795
- const d = new Date(o.transaction_date);
55796
- const monthDiff = (now.getFullYear() - d.getFullYear()) * 12 + (now.getMonth() - d.getMonth());
55836
+ const calendarMonth = frappeCalendarMonth(o.transaction_date);
55837
+ if (!calendarMonth) continue;
55838
+ const monthDiff = (now.getFullYear() - calendarMonth.year) * 12 + (now.getMonth() - calendarMonth.month);
55797
55839
  const idx = 5 - monthDiff;
55798
55840
  if (idx >= 0 && idx < 6) {
55799
55841
  sparkline[idx] += Number(o.grand_total) || 0;
@@ -55811,6 +55853,7 @@ var analyticsTools = [
55811
55853
  trend: delta > 0 ? "up" : delta < 0 ? "down" : "flat",
55812
55854
  trendIsGood: true,
55813
55855
  sparkline,
55856
+ sparklineLabels,
55814
55857
  color: "#60a5fa",
55815
55858
  _meta: KPI_META
55816
55859
  };
@@ -59077,7 +59120,7 @@ async function main() {
59077
59120
  );
59078
59121
  const server = new McpApp({
59079
59122
  name: "mcp-erpnext",
59080
- version: "3.1.0-beta.6",
59123
+ version: "3.1.0-beta.7",
59081
59124
  transport: "stateless",
59082
59125
  cache: {
59083
59126
  ttlMs: 36e5,