xmcp 1.10.4 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/adapter-express.js +15 -15
- package/dist/runtime/adapter-fastify.js +15 -15
- package/dist/runtime/adapter-fetch-cloudflare.js +20 -20
- package/dist/runtime/adapter-fetch.js +15 -15
- package/dist/runtime/adapter-nestjs.js +15 -15
- package/dist/runtime/adapter-nextjs.js +15 -15
- package/dist/runtime/cloudflare-worker.js +27 -27
- package/dist/runtime/contexts/request-context.d.ts +1 -1
- package/dist/runtime/http.js +21 -21
- package/dist/runtime/stdio.js +18 -18
- package/dist/runtime/utils/mcp-authorization.d.ts +33 -0
- package/dist/runtime/utils/mcp-middleware.d.ts +7 -2
- package/dist/runtime/utils/skills.d.ts +6 -1
- package/dist/runtime/vercel.js +22 -22
- package/dist/types/mcp-middleware.d.ts +52 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
let e,t,r,i,n,o,a,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k;import{AsyncLocalStorage as x}from"async_hooks";var C,$,T,P,E,O,I,q,j,A,z,L,N,M,Z={},U={};function F(e){var t=U[e];if(void 0!==t)return t.exports;var r=U[e]={exports:{}};return Z[e](r,r.exports,F),r.exports}F.d=(e,t,r)=>{var i=(t,r)=>{for(var i in t)F.o(t,i)&&!F.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,[r]:t[i]})};i(t,"get"),i(r,"value")},F.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),F.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var H={};F.d(H,{A:()=>h$});var D=Object.create,V=Object.defineProperty,J=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyNames,W=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;let K=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Y=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),X=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Q=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function ee(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function et(e,t="|"){return e.map(e=>eR(e)).join(t)}function er(e,t){return"bigint"==typeof t?t.toString():t}class ei{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function en(e){return new ei(e)}function eo(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let ea=Symbol("evaluating");function es(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function el(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ec(e){return el(e._zod.def)??e._zod.def.shape}function eu(e,t,r){Object.defineProperty(e,t,{get(){let e=r();return es(this,t,e),e},enumerable:!0,configurable:!0})}function ed(e,t,r){t in e?es(e,t,r):e[t]=r}function ep(e,t,r,i){let n=ec(t);for(let o of r){let r=Object.getOwnPropertyDescriptor(n,o);r.enumerable&&(r.get?eu(e,o,()=>{let e=t._zod.def.shape[o];return i?i(e,o):e}):ed(e,o,i?i(r.value,o):r.value))}}function em(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}let eh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ef(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eg=en(()=>{if(eK.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function ey(e){if(!1===ef(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==ef(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ev(e){return ey(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let e_=new Set(["string","number","symbol"]);function eb(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eS(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function ew(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function eR(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}let ek={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ex={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function eC(e,t){let r=ec(e),i=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&i.push(e)}return i}function e$(e,t){let r={};ep(r,e,Reflect.ownKeys(ec(e)));for(let e of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,e);i.enumerable&&(i.get?eu(r,e,()=>t[e]):ed(r,e,i.value))}return r}function eT(e,t,r,i="partial"){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let o=r?new Set(eC(t,r)):void 0,a={};return ep(a,t,Reflect.ownKeys(ec(t)),e&&((t,r)=>o&&!o.has(r)?t:new e({type:"optional",innerType:t}))),eS(t,em(t._zod.def,{shape:a,checks:[]}))}function eP(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function eE(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eO(e){return"string"==typeof e?e:e?.message}function eI(e){let t=[];for(let r of e??[]){let e=r._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let i=e.maximum??e.length??e.size;i>=0&&t.push([i,r])}return t}function eq(e,t,r){var i;for(let n=t;n<e.length;n++)(i=e[n]).schema??(i.schema=r)}function ej(e,t,r){let i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?e.schema??(e.schema=e.inst):e.schema=e.inst);let n=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:eO(e.inst?._zod.def?.error?.(e))??eO(n?.(e))??eO(t?.error?.(e))??eO(r.customError?.(e))??eO(r.localeError?.(e))??"Invalid input",a={};for(let t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(a[t]=e[t]);return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=e.input),a}let eA=/[\uD800-\uDBFF]/;function ez(e){let t=e.length;if(!eA.test(e))return t;let r=t;for(let i=0;i<t-1;i++)(64512&e.charCodeAt(i))==55296&&(64512&e.charCodeAt(i+1))==56320&&(r--,i++);return r}function eL(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eN(...e){let[t,r,i]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:i}:{...t}}function eM(e,t,r,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function eZ(e,t){for(let r in e){let i=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return eM(this,r,i(this))},set(e){eM(this,r,e)}})}return t}let eU=!1,eF={configurable:!0,get(){eU=!0}};function eH(t,r,i){let n=Object.getPrototypeOf(t._zod);if(r in n&&e!==t._zod){e=void 0;return}e=t._zod,Object.defineProperty(n,r,{configurable:!0,get(){Object.defineProperty(this,r,eF);let e=eU;eU=!1;try{let t=i(this);return eU?delete this[r]:Object.defineProperty(this,r,{configurable:!0,writable:!0,value:t}),eU=eU||e,t}catch(t){throw delete this[r],eU=eU||e,t}},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,value:e})}})}let eD=Object.freeze({status:"aborted"}),eV={value:void 0,enumerable:!1},eJ="captureStackTrace"in Error?Error:null;function eB(e,t,r,i){function n(e){this.def=e,this.constr=c,this.traits=new Set}n.prototype={};let o=r&&new WeakSet;function a(i,a){if(i._zod){if(i._zod.traits.has(e))return}else{eV.value=new n(a);try{Object.defineProperty(i,"_zod",eV)}finally{eV.value=void 0}}if(i._zod.traits.add(e),t(i,a),o){let e=Object.getPrototypeOf(i),t=i._zod.constr.prototype,n=e;for(;n&&n!==t;)n=Object.getPrototypeOf(n);let a=n??e;if(!o.has(a)){o.add(a);for(let e in r){let t=Object.getOwnPropertyDescriptor(r,e);t.get?Object.defineProperty(a,e,{...t,enumerable:!1}):function(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:eM(this,t,r.bind(this))},set(e){eM(this,t,e)}})}(a,e,t.value)}}}let s=c.prototype;for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&(e in i||(i[e]=s[e].bind(i)))}let s=i?.Parent??Object;class l extends s{}function c(e){let t=i?.Parent?function(e){let t=eJ;if(t){let r=t.stackTraceLimit;if("number"==typeof r){try{t.stackTraceLimit=0}catch{return eJ=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}(l):this;a(t,e);let r=t._zod.deferred;if(r){for(let e of r)e();t._zod.deferred=void 0}let n=globalThis.__zod_globalConfig?.postProcessor;return n&&n(t),t}return Object.defineProperty(l,"name",{value:e}),Object.defineProperty(c,"init",{value:a}),Object.defineProperty(c,Symbol.hasInstance,{value:t=>!!i?.Parent&&t instanceof i.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(c,"name",{value:e}),c}class eW extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eG extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(q=globalThis).__zod_globalConfig??(q.__zod_globalConfig={});let eK=globalThis.__zod_globalConfig;function eY(e){return e&&Object.assign(eK,e),eK}class eX extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let eQ="~memo",e0=[];function e1(e){return null!==e&&"object"==typeof e}function e2(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let e9=new WeakMap,e4=[],e5={alloc(e,r,i){let n=t;if(!n)return i;t=void 0;let o={value:i,issues:null};return n.set(r.value,o),e4.push(o),i},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(e,r)=>{var i,n;let o;if("backward"!==r.direction&&(i=r,n=e.value,void 0!==(o=i[eQ]?.backEdges)&&e1(n)&&o.has(n)))throw new eX;return t(e,r)};e._zod.parse=r,e._zod.run===t&&(e._zod.run=r)})},attach(e){var r;let i,n,o,a=!1;(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,s=(l,c)=>{let u;if(void 0===i){let t=function e(t,r,i){var n,o;let a=e9.get(t);if(void 0!==a)return 2*!!a;if(r.has(t))return 2;r.add(t);let s=0,l=t=>{if(2!==s&&t?._zod){let n=e(t,r,i);n>s&&(s=n)}},c=e=>{e>s&&(s=e)},u=t._zod.def;switch(u.type){case"object":{let t=el(u);c(t?((t,n)=>{let o=0;for(let a of Reflect.ownKeys(t)){let s=Object.getOwnPropertyDescriptor(t,a);if(n&&!s.enumerable)continue;let l=s.get?1:s.value?._zod?e(s.value,r,i):0;l>o&&(o=l)}return o})(t,!0):1),l(u.catchall);break}case"array":l(u.element);break;case"tuple":for(let e of u.items)l(e);l(u.rest);break;case"record":case"map":l(u.keyType),l(u.valueType);break;case"set":l(u.valueType);break;case"union":for(let e of u.options)l(e);break;case"intersection":l(u.left),l(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":l(u.innerType);break;case"pipe":l(u.in),l(u.out);break;case"function":l(u.input),l(u.output);break;case"lazy":{let n=u._cachedInner??(i?t._zod.innerType:void 0);c(n?e(n,r,!1):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let e in u){let t=Object.getOwnPropertyDescriptor(u,e);if(!t||t.get)continue;let r=t.value;if(r&&"object"==typeof r){if(r._zod)l(r);else if(Array.isArray(r))for(let e of r)l(e)}}}return r.delete(t),n=t,1!==(o=s)&&e9.set(n,2===o),o}(e,new Set,!1);if(0===t)return e._zod.parse=r,e._zod.run===s&&(e._zod.run=r),r(l,c);2===t||a?i=!0:a=!0}let d=l.value;if(!e1(d))return r(l,c);let p=c[eQ];if(p||(p={buckets:new WeakMap,backEdges:void 0},c[eQ]=p),n===c)u=o;else{var m;let t;(t=(m=p).buckets.get(e))||(t=new WeakMap,m.buckets.set(e,t)),u=t,n=c,o=u}let h=u.get(d);if(h)return l.value=h.value,h.issues?h.issues.length&&l.issues.push(...e2(h.issues)):(l.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value)),l;t=u;let f=e4.length,g=r(l,c);t=void 0;let y=e4.length>f?e4.pop():void 0;return g instanceof Promise?g.then(e=>(y&&(y.issues=e.issues.length?e2(e.issues):e0),e)):(y&&(y.issues=g.issues.length?e2(g.issues):e0),g)};e._zod.parse=s,e._zod.run===r&&(e._zod.run=s)})}},e3=/^[cC][0-9a-z]{6,}$/,e6=/^[0-9a-z]+$/,e7=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,e8=/^[0-9a-vA-V]{20}$/,te=/^[A-Za-z0-9]{27}$/,tt=/^[a-zA-Z0-9_-]{21}$/,tr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ti=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([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)$/,to=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ta=/^(?:(?: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])$/,ts=/^(([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}|:))$/,tl=/^((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])$/,tc=/^(([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])$/,tu=/^https?$/,td=/^\+[1-9]\d{6,14}$/,tp="(?:(?:\\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])))",tm=RegExp(`^${tp}$`);function th(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let tf=/^[\s\S]{0,}$/,tg=/^-?\d+$/,ty=/^-?\d+(?:\.\d+)?$/,tv=/^(?:true|false)$/i,t_=/^null$/i,tb=/^[^A-Z]*$/,tS=/^[^a-z]*$/,tw=eB("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tR=e=>{let t=e.value;return null!=t&&void 0!==t.length},tk={number:"number",bigint:"bigint",object:"date"},tx=eB("$ZodCheckLessThan",(e,t)=>{tw.init(e,t);let r=tk[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:tk[typeof i.value]??r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tC=eB("$ZodCheckGreaterThan",(e,t)=>{tw.init(e,t);let r=tk[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:tk[typeof i.value]??r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),t$=eB("$ZodCheckMultipleOf",(e,t)=>{tw.init(e,t),e._zod.check=r=>{let i,n,o;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):0==(n=Math.round(i=r.value/t.value),o=4*Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<o?0:i-n))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),tT=eB("$ZodCheckNumberFormat",(e,t)=>{tw.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,o]=ek[t.format];e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s))return void a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}))}s<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),tP=eB("$ZodCheckMaxLength",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length;if(("string"==typeof i&&n>t.maximum?ez(i):n)<=t.maximum)return;let o=eL(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tE=eB("$ZodCheckMinLength",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length;if(("string"==typeof i&&n>=t.minimum&&n<2*t.minimum?ez(i):n)>=t.minimum)return;let o=eL(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tO=eB("$ZodCheckLengthEquals",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length,o="string"==typeof i&&n>=t.length&&n<=2*t.length?ez(i):n;if(o===t.length)return;let a=eL(i),s=o>t.length;r.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),tI=eB("$ZodCheckStringFormat",(e,t)=>{var r,i;tw.init(e,t),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),tq=eB("$ZodCheckRegex",(e,t)=>{tI.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tj=eB("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=tb),tI.init(e,t)}),tA=eB("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=tS),tI.init(e,t)}),tz=eB("$ZodCheckIncludes",(e,t)=>{tw.init(e,t);let r=eb(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position},}${r}`:r);t.pattern=i,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),tL=eB("$ZodCheckStartsWith",(e,t)=>{tw.init(e,t);let r=RegExp(`^${eb(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),tN=eB("$ZodCheckEndsWith",(e,t)=>{tw.init(e,t);let r=RegExp(`.*${eb(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),tM=eB("$ZodCheckOverwrite",(e,t)=>{tw.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class tZ{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
1
|
+
let e,t,r,i,n,o,a,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k;import{AsyncLocalStorage as x}from"async_hooks";var C,$,T,P,O,E,I,q,j,A,z,L,N,M,Z={},U={};function F(e){var t=U[e];if(void 0!==t)return t.exports;var r=U[e]={exports:{}};return Z[e](r,r.exports,F),r.exports}F.d=(e,t,r)=>{var i=(t,r)=>{for(var i in t)F.o(t,i)&&!F.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,[r]:t[i]})};i(t,"get"),i(r,"value")},F.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),F.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var H={};F.d(H,{A:()=>hI});var D=Object.create,V=Object.defineProperty,J=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyNames,W=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;let K=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Y=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),X=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Q=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function ee(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function et(e,t="|"){return e.map(e=>eR(e)).join(t)}function er(e,t){return"bigint"==typeof t?t.toString():t}class ei{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function en(e){return new ei(e)}function eo(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let ea=Symbol("evaluating");function es(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function el(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ec(e){return el(e._zod.def)??e._zod.def.shape}function eu(e,t,r){Object.defineProperty(e,t,{get(){let e=r();return es(this,t,e),e},enumerable:!0,configurable:!0})}function ed(e,t,r){t in e?es(e,t,r):e[t]=r}function ep(e,t,r,i){let n=ec(t);for(let o of r){let r=Object.getOwnPropertyDescriptor(n,o);r.enumerable&&(r.get?eu(e,o,()=>{let e=t._zod.def.shape[o];return i?i(e,o):e}):ed(e,o,i?i(r.value,o):r.value))}}function em(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}let eh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ef(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eg=en(()=>{if(eK.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function ey(e){if(!1===ef(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==ef(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ev(e){return ey(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let e_=new Set(["string","number","symbol"]);function eb(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eS(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function ew(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function eR(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}let ek={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ex={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function eC(e,t){let r=ec(e),i=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&i.push(e)}return i}function e$(e,t){let r={};ep(r,e,Reflect.ownKeys(ec(e)));for(let e of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,e);i.enumerable&&(i.get?eu(r,e,()=>t[e]):ed(r,e,i.value))}return r}function eT(e,t,r,i="partial"){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let o=r?new Set(eC(t,r)):void 0,a={};return ep(a,t,Reflect.ownKeys(ec(t)),e&&((t,r)=>o&&!o.has(r)?t:new e({type:"optional",innerType:t}))),eS(t,em(t._zod.def,{shape:a,checks:[]}))}function eP(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function eO(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eE(e){return"string"==typeof e?e:e?.message}function eI(e){let t=[];for(let r of e??[]){let e=r._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let i=e.maximum??e.length??e.size;i>=0&&t.push([i,r])}return t}function eq(e,t,r){var i;for(let n=t;n<e.length;n++)(i=e[n]).schema??(i.schema=r)}function ej(e,t,r){let i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?e.schema??(e.schema=e.inst):e.schema=e.inst);let n=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:eE(e.inst?._zod.def?.error?.(e))??eE(n?.(e))??eE(t?.error?.(e))??eE(r.customError?.(e))??eE(r.localeError?.(e))??"Invalid input",a={};for(let t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(a[t]=e[t]);return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=e.input),a}let eA=/[\uD800-\uDBFF]/;function ez(e){let t=e.length;if(!eA.test(e))return t;let r=t;for(let i=0;i<t-1;i++)(64512&e.charCodeAt(i))==55296&&(64512&e.charCodeAt(i+1))==56320&&(r--,i++);return r}function eL(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eN(...e){let[t,r,i]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:i}:{...t}}function eM(e,t,r,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function eZ(e,t){for(let r in e){let i=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return eM(this,r,i(this))},set(e){eM(this,r,e)}})}return t}let eU=!1,eF={configurable:!0,get(){eU=!0}};function eH(t,r,i){let n=Object.getPrototypeOf(t._zod);if(r in n&&e!==t._zod){e=void 0;return}e=t._zod,Object.defineProperty(n,r,{configurable:!0,get(){Object.defineProperty(this,r,eF);let e=eU;eU=!1;try{let t=i(this);return eU?delete this[r]:Object.defineProperty(this,r,{configurable:!0,writable:!0,value:t}),eU=eU||e,t}catch(t){throw delete this[r],eU=eU||e,t}},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,value:e})}})}let eD=Object.freeze({status:"aborted"}),eV={value:void 0,enumerable:!1},eJ="captureStackTrace"in Error?Error:null;function eB(e,t,r,i){function n(e){this.def=e,this.constr=c,this.traits=new Set}n.prototype={};let o=r&&new WeakSet;function a(i,a){if(i._zod){if(i._zod.traits.has(e))return}else{eV.value=new n(a);try{Object.defineProperty(i,"_zod",eV)}finally{eV.value=void 0}}if(i._zod.traits.add(e),t(i,a),o){let e=Object.getPrototypeOf(i),t=i._zod.constr.prototype,n=e;for(;n&&n!==t;)n=Object.getPrototypeOf(n);let a=n??e;if(!o.has(a)){o.add(a);for(let e in r){let t=Object.getOwnPropertyDescriptor(r,e);t.get?Object.defineProperty(a,e,{...t,enumerable:!1}):function(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:eM(this,t,r.bind(this))},set(e){eM(this,t,e)}})}(a,e,t.value)}}}let s=c.prototype;for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&(e in i||(i[e]=s[e].bind(i)))}let s=i?.Parent??Object;class l extends s{}function c(e){let t=i?.Parent?function(e){let t=eJ;if(t){let r=t.stackTraceLimit;if("number"==typeof r){try{t.stackTraceLimit=0}catch{return eJ=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}(l):this;a(t,e);let r=t._zod.deferred;if(r){for(let e of r)e();t._zod.deferred=void 0}let n=globalThis.__zod_globalConfig?.postProcessor;return n&&n(t),t}return Object.defineProperty(l,"name",{value:e}),Object.defineProperty(c,"init",{value:a}),Object.defineProperty(c,Symbol.hasInstance,{value:t=>!!i?.Parent&&t instanceof i.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(c,"name",{value:e}),c}class eW extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eG extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(q=globalThis).__zod_globalConfig??(q.__zod_globalConfig={});let eK=globalThis.__zod_globalConfig;function eY(e){return e&&Object.assign(eK,e),eK}class eX extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let eQ="~memo",e0=[];function e1(e){return null!==e&&"object"==typeof e}function e2(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let e9=new WeakMap,e4=[],e5={alloc(e,r,i){let n=t;if(!n)return i;t=void 0;let o={value:i,issues:null};return n.set(r.value,o),e4.push(o),i},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(e,r)=>{var i,n;let o;if("backward"!==r.direction&&(i=r,n=e.value,void 0!==(o=i[eQ]?.backEdges)&&e1(n)&&o.has(n)))throw new eX;return t(e,r)};e._zod.parse=r,e._zod.run===t&&(e._zod.run=r)})},attach(e){var r;let i,n,o,a=!1;(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,s=(l,c)=>{let u;if(void 0===i){let t=function e(t,r,i){var n,o;let a=e9.get(t);if(void 0!==a)return 2*!!a;if(r.has(t))return 2;r.add(t);let s=0,l=t=>{if(2!==s&&t?._zod){let n=e(t,r,i);n>s&&(s=n)}},c=e=>{e>s&&(s=e)},u=t._zod.def;switch(u.type){case"object":{let t=el(u);c(t?((t,n)=>{let o=0;for(let a of Reflect.ownKeys(t)){let s=Object.getOwnPropertyDescriptor(t,a);if(n&&!s.enumerable)continue;let l=s.get?1:s.value?._zod?e(s.value,r,i):0;l>o&&(o=l)}return o})(t,!0):1),l(u.catchall);break}case"array":l(u.element);break;case"tuple":for(let e of u.items)l(e);l(u.rest);break;case"record":case"map":l(u.keyType),l(u.valueType);break;case"set":l(u.valueType);break;case"union":for(let e of u.options)l(e);break;case"intersection":l(u.left),l(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":l(u.innerType);break;case"pipe":l(u.in),l(u.out);break;case"function":l(u.input),l(u.output);break;case"lazy":{let n=u._cachedInner??(i?t._zod.innerType:void 0);c(n?e(n,r,!1):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let e in u){let t=Object.getOwnPropertyDescriptor(u,e);if(!t||t.get)continue;let r=t.value;if(r&&"object"==typeof r){if(r._zod)l(r);else if(Array.isArray(r))for(let e of r)l(e)}}}return r.delete(t),n=t,1!==(o=s)&&e9.set(n,2===o),o}(e,new Set,!1);if(0===t)return e._zod.parse=r,e._zod.run===s&&(e._zod.run=r),r(l,c);2===t||a?i=!0:a=!0}let d=l.value;if(!e1(d))return r(l,c);let p=c[eQ];if(p||(p={buckets:new WeakMap,backEdges:void 0},c[eQ]=p),n===c)u=o;else{var m;let t;(t=(m=p).buckets.get(e))||(t=new WeakMap,m.buckets.set(e,t)),u=t,n=c,o=u}let h=u.get(d);if(h)return l.value=h.value,h.issues?h.issues.length&&l.issues.push(...e2(h.issues)):(l.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value)),l;t=u;let f=e4.length,g=r(l,c);t=void 0;let y=e4.length>f?e4.pop():void 0;return g instanceof Promise?g.then(e=>(y&&(y.issues=e.issues.length?e2(e.issues):e0),e)):(y&&(y.issues=g.issues.length?e2(g.issues):e0),g)};e._zod.parse=s,e._zod.run===r&&(e._zod.run=s)})}},e3=/^[cC][0-9a-z]{6,}$/,e6=/^[0-9a-z]+$/,e7=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,e8=/^[0-9a-vA-V]{20}$/,te=/^[A-Za-z0-9]{27}$/,tt=/^[a-zA-Z0-9_-]{21}$/,tr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ti=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([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)$/,to=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ta=/^(?:(?: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])$/,ts=/^(([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}|:))$/,tl=/^((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])$/,tc=/^(([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])$/,tu=/^https?$/,td=/^\+[1-9]\d{6,14}$/,tp="(?:(?:\\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])))",tm=RegExp(`^${tp}$`);function th(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let tf=/^[\s\S]{0,}$/,tg=/^-?\d+$/,ty=/^-?\d+(?:\.\d+)?$/,tv=/^(?:true|false)$/i,t_=/^null$/i,tb=/^[^A-Z]*$/,tS=/^[^a-z]*$/,tw=eB("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tR=e=>{let t=e.value;return null!=t&&void 0!==t.length},tk={number:"number",bigint:"bigint",object:"date"},tx=eB("$ZodCheckLessThan",(e,t)=>{tw.init(e,t);let r=tk[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:tk[typeof i.value]??r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tC=eB("$ZodCheckGreaterThan",(e,t)=>{tw.init(e,t);let r=tk[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:tk[typeof i.value]??r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),t$=eB("$ZodCheckMultipleOf",(e,t)=>{tw.init(e,t),e._zod.check=r=>{let i,n,o;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):0==(n=Math.round(i=r.value/t.value),o=4*Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<o?0:i-n))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),tT=eB("$ZodCheckNumberFormat",(e,t)=>{tw.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,o]=ek[t.format];e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s))return void a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}))}s<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),tP=eB("$ZodCheckMaxLength",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length;if(("string"==typeof i&&n>t.maximum?ez(i):n)<=t.maximum)return;let o=eL(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tO=eB("$ZodCheckMinLength",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length;if(("string"==typeof i&&n>=t.minimum&&n<2*t.minimum?ez(i):n)>=t.minimum)return;let o=eL(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tE=eB("$ZodCheckLengthEquals",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length,o="string"==typeof i&&n>=t.length&&n<=2*t.length?ez(i):n;if(o===t.length)return;let a=eL(i),s=o>t.length;r.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),tI=eB("$ZodCheckStringFormat",(e,t)=>{var r,i;tw.init(e,t),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),tq=eB("$ZodCheckRegex",(e,t)=>{tI.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tj=eB("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=tb),tI.init(e,t)}),tA=eB("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=tS),tI.init(e,t)}),tz=eB("$ZodCheckIncludes",(e,t)=>{tw.init(e,t);let r=eb(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position},}${r}`:r);t.pattern=i,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),tL=eB("$ZodCheckStartsWith",(e,t)=>{tw.init(e,t);let r=RegExp(`^${eb(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),tN=eB("$ZodCheckEndsWith",(e,t)=>{tw.init(e,t);let r=RegExp(`.*${eb(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),tM=eB("$ZodCheckOverwrite",(e,t)=>{tw.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class tZ{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
2
2
|
${t.join("\n")}
|
|
3
|
-
};`)(...Object.values(this.closed))}}let tU={major:4,minor:6,patch:7},tF=eB("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tU;let i=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let t of n)for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,r,i)=>{let n;if(t.memo)return t;let o=eP(t);for(let a of r){if(a._zod.def.when){if(function(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}(t)||!a._zod.def.when(t))continue}else if(o)continue;let r=t.issues.length,s=a._zod.check(t);if(s instanceof Promise&&i?.async===!1)throw new eW;if(n||s instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await s,t.issues.length!==r&&(eq(t.issues,r,e),o||(o=eP(t,r)))});else{if(t.issues.length===r)continue;eq(t.issues,r,e),o||(o=eP(t,r))}}return n?n.then(()=>t):t},r=(r,i,o)=>{if(eP(r))return r.aborted=!0,r;let a=t(i,n,o);if(a instanceof Promise){if(!1===o.async)throw new eW;return a.then(t=>e._zod.parse(t,o))}return e._zod.parse(a,o)};e._zod.run=(i,o)=>{if(o.skipChecks)return e._zod.parse(i,o);if("backward"===o.direction){let t=e._zod.parse({value:i.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,o)):r(t,i,o)}let a=e._zod.parse(i,o);if(a instanceof Promise){if(!1===o.async)throw new eW;return a.then(e=>t(e,n,o))}return t(a,n,o)}}},{get"~standard"(){return eM(this,"~standard",tD(this),!1)},set"~standard"(e){eM(this,"~standard",e)}}),tH=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ej(e,t,eY()))}:{value:e.value};function tD(e){return{validate:t=>{let r={async:!1};try{let i=e._zod.run({value:t,issues:[]},r);if(!(i instanceof Promise))return tH(i,r)}catch(e){}return async function(e,t){let r={async:!0};return tH(await e._zod.run({value:t,issues:[]},r),r)}(e,t)},vendor:"zod",version:1}}let tV=eB("$ZodString",(e,t)=>{tF.init(e,t),e._zod.pattern=t.pattern??tf,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tJ=eB("$ZodStringFormat",(e,t)=>{tI.init(e,t),tV.init(e,t)}),tB=eB("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ti),tJ.init(e,t)}),tW=eB("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=tn(e))}else t.pattern??(t.pattern=tn());tJ.init(e,t)}),tG=eB("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=to),tJ.init(e,t)});function tK(e){try{if("u">typeof URL&&"function"==typeof URL.canParse)return URL.canParse(e);return new URL(e),!0}catch{return!1}}let tY=/[\t\n\r]/g;function tX(e){return e.replace(tY,"")}let tQ=eB("$ZodURL",(e,t)=>{tJ.init(e,t),e._zod.check=r=>{try{var i,n;let o=r.value.trim(),a="normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===tu.source&&!/^https?:\/\//i.test(e))return 1;try{if("u">typeof URL){let t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(o,t):tK(o)||2;if(1===a)return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});if(2===a)return void r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});if(!0===a){r.value=tX(o);return}t.hostname&&((i=t.hostname).lastIndex=0,!i.test(a.hostname))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&((n=t.protocol).lastIndex=0,!n.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?a.href:tX(o);return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),t0=eB("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),tJ.init(e,t)}),t1=eB("$ZodNanoID",(e,t)=>{var r;if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=void 0===t.length?tt:(r=t.length,RegExp(`^[a-zA-Z0-9_-]{${r}}$`))),tJ.init(e,t)}),t2=eB("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=e3),tJ.init(e,t)}),t9=eB("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=e6),tJ.init(e,t)}),t4=eB("$ZodULID",(e,t)=>{t.pattern??(t.pattern=e7),tJ.init(e,t)}),t5=eB("$ZodXID",(e,t)=>{t.pattern??(t.pattern=e8),tJ.init(e,t)}),t3=eB("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=te),tJ.init(e,t)}),t6=eB("$ZodISODateTime",(e,t)=>{let r,i,n;t.pattern??(r=["Z"],t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),i=`${th({precision:t.precision,seconds:!0})}(?:${r.join("|")})`,n=t.local?`${i}|${th({precision:t.precision})}`:i,t.pattern=RegExp(`^${tp}T(?:${n})$`)),tJ.init(e,t)}),t7=eB("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=tm),tJ.init(e,t)}),t8=eB("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${th(t)}$`)),tJ.init(e,t)}),re=eB("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=tr),tJ.init(e,t)}),rt=eB("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ta),tJ.init(e,t)}),rr=/^[0-9a-fA-F:.]+$/;function ri(e){return!!rr.test(e)&&tK(`http://[${e}]`)}let rn=eB("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ts),tJ.init(e,t),e._zod.check=r=>{ri(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),ro=eB("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=tl),tJ.init(e,t)}),ra=eB("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tc),tJ.init(e,t),e._zod.check=r=>{!function(e){let t=e.split("/");if(2!==t.length)return!1;let[r,i]=t;if(!i)return!1;let n=Number(i);return`${n}`===i&&!(n<0)&&!(n>128)&&ri(r)}(r.value)&&r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function rs(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let rl=/^[0-9a-zA-Z+/]*={0,2}$/,rc=eB("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rl),tJ.init(e,t),e._zod.check=r=>{rs(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ru=/^[A-Za-z0-9_-]*$/,rd=eB("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ru),tJ.init(e,t),e._zod.check=r=>{!function(e){if(!ru.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return rs(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),rp=eB("$ZodE164",(e,t)=>{t.pattern??(t.pattern=td),tJ.init(e,t)}),rm=eB("$ZodJWT",(e,t)=>{tJ.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));if("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),rh=eB("$ZodNumber",(e,t)=>{tF.init(e,t),e._zod.pattern=ty,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let n=r.value;if("number"==typeof n&&!Number.isNaN(n)&&Number.isFinite(n))return r;let o="number"==typeof n?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:String(n):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...o?{received:o}:{}}),r}}),rf=eB("$ZodNumberFormat",(e,t)=>{tT.init(e,t),rh.init(e,t)}),rg=eB("$ZodBoolean",(e,t)=>{tF.init(e,t),e._zod.pattern=tv,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let n=r.value;return"boolean"==typeof n||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),ry=eB("$ZodNull",(e,t)=>{tF.init(e,t),e._zod.pattern=t_,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let i=t.value;return null===i||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),t}}),rv=eB("$ZodAny",(e,t)=>{tF.init(e,t),e._zod.parse=e=>e}),r_=eB("$ZodUnknown",(e,t)=>{tF.init(e,t),e._zod.parse=e=>e}),rb=eB("$ZodNever",(e,t)=>{tF.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),rS=e=>Array.isArray(e)?e.length:-1;function rw(e,t,r){e.issues.length&&t.issues.push(...eE(r,e.issues)),t.value[r]=e.value}let rR=eB("$ZodArray",(e,t)=>{tF.init(e,t);let r=eK.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),i;i.value=r?r.alloc(e,i,Array(o.length),n):Array(o.length);let a=[],s=n?.abortEarly;for(let e=0;e<o.length;e++){let r=o[e],l=t.element._zod.run({value:r,issues:[]},n);if(l instanceof Promise)a.push(l.then(t=>rw(t,i,e)));else if(rw(l,i,e),s&&0!==l.issues.length&&eP(l))break}return a.length?Promise.all(a).then(()=>i):i},function(e,t){let r=eI(e._zod.def.checks);if(!r.length)return;let i=Math.min(...r.map(e=>e[0])),n=e._zod.parse;e._zod.parse=(r,o)=>{let a=t(r.value);if(a>i&&!o?.skipChecks&&o?.direction!=="backward"){for(let[t,i]of eI(e._zod.def.checks))if(a>t&&i._zod.def.when(r)){let t=r.issues.length;return i._zod.check(r),r.issues[t].continue=!1,eq(r.issues,t,e),r}}return n(r,o)}}(e,rS)});function rk(e,t,r,i,n,o){let a=r in i,s="optional"===o;if(a||!s||"optional"!==n){if(e.issues.length){if(void 0!==n&&s&&!a)return;t.issues.push(...eE(r,e.issues))}if(!a&&void 0===n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?(a||"defaulted"===n&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}let rx=[];function rC(e){var t;let r=Object.keys(e.shape),i=Object.getOwnPropertySymbols(e.shape),n=i.length?i:rx,o=n.length?[...r,...n]:r;for(let t of o)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Object.keys(t=e.shape).filter(e=>void 0!==t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(a)}}function r$(e,t,r,i,n,o,a){let s=[],l=n.keySet,c=n.catchall._zod,u=c.def.type,d=c.optin,p=c.optout,m=0;for(let n in t){if(a&&r.issues.length!==m){if(eP(r,m))break;m=r.issues.length}if(l.has(n))continue;if("__proto__"===n){"never"===u&&s.push(n);continue}if("never"===u){s.push(n);continue}let o=c.run({value:t[n],issues:[]},i);o instanceof Promise?e.push(o.then(e=>rk(e,r,n,t,d,p))):rk(o,r,n,t,d,p)}return(s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o,continue:!0}),e.length)?Promise.all(e).then(()=>r):r}let rT=eB("$ZodObject",(e,t)=>{let r;tF.init(e,t);let i=Object.getOwnPropertyDescriptor(t,"shape"),n=i?.get?i.get.raw:t.shape??{};if(n){let e=()=>{let r={...n};return Object.defineProperty(t,"shape",{value:r}),e.raw=r,r};e.raw=n,Object.defineProperty(t,"shape",{get:e})}let o=en(()=>rC(t));eH(e,"propValues",e=>{let t=e.def.shape,r={};for(let e in t){let i=t[e]._zod;if(i.values){for(let t of(Object.prototype.hasOwnProperty.call(r,e)||es(r,e,new Set),i.values))r[e].add(t);void 0!==i.optin&&r[e].add(void 0)}}return r});let a=t.catchall,s=eK.memoizer;s?.attach(e),e._zod.parse=(t,i)=>{r??(r=o.value);let n=t.value;if(!ef(n))return t.issues.push({expected:"object",code:"invalid_type",input:n,inst:e}),t;t.value=s?s.alloc(e,t,{},i):{};let l=[],c=r.shape,u=i?.abortEarly,d=t.issues.length;for(let e of r.allKeys){if(u&&t.issues.length!==d){if(eP(t,d))break;d=t.issues.length}if("__proto__"===e)continue;let r=c[e],o=r._zod.optin,a=r._zod.optout,s=r._zod.run({value:n[e],issues:[]},i);s instanceof Promise?l.push(s.then(r=>rk(r,t,e,n,o,a))):rk(s,t,e,n,o,a)}return a?r$(l,n,t,i,o.value,e,!0===u):l.length?Promise.all(l).then(()=>t):t}}),rP=eB("$ZodObjectJIT",(e,t)=>{let r,i;rT.init(e,t);let n=e._zod.parse,o=en(()=>rC(t)),a=eK.memoizer,s=!eK.jitless,l=s&&eg.value,c=t.catchall;e._zod.parse=(u,d)=>{i??(i=o.value);let p=u.value;return ef(p)?s&&l&&d?.async===!1&&!0!==d.jitless?(r||(r=(t=>{let r=o.value,i=r.symbolKeys,n=new tZ(["payload","ctx"],{shape:t,inst:e,memo:a,syms:i}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,l=(e,t)=>`
|
|
3
|
+
};`)(...Object.values(this.closed))}}let tU={major:4,minor:6,patch:7},tF=eB("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tU;let i=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let t of n)for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,r,i)=>{let n;if(t.memo)return t;let o=eP(t);for(let a of r){if(a._zod.def.when){if(function(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}(t)||!a._zod.def.when(t))continue}else if(o)continue;let r=t.issues.length,s=a._zod.check(t);if(s instanceof Promise&&i?.async===!1)throw new eW;if(n||s instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await s,t.issues.length!==r&&(eq(t.issues,r,e),o||(o=eP(t,r)))});else{if(t.issues.length===r)continue;eq(t.issues,r,e),o||(o=eP(t,r))}}return n?n.then(()=>t):t},r=(r,i,o)=>{if(eP(r))return r.aborted=!0,r;let a=t(i,n,o);if(a instanceof Promise){if(!1===o.async)throw new eW;return a.then(t=>e._zod.parse(t,o))}return e._zod.parse(a,o)};e._zod.run=(i,o)=>{if(o.skipChecks)return e._zod.parse(i,o);if("backward"===o.direction){let t=e._zod.parse({value:i.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,o)):r(t,i,o)}let a=e._zod.parse(i,o);if(a instanceof Promise){if(!1===o.async)throw new eW;return a.then(e=>t(e,n,o))}return t(a,n,o)}}},{get"~standard"(){return eM(this,"~standard",tD(this),!1)},set"~standard"(e){eM(this,"~standard",e)}}),tH=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ej(e,t,eY()))}:{value:e.value};function tD(e){return{validate:t=>{let r={async:!1};try{let i=e._zod.run({value:t,issues:[]},r);if(!(i instanceof Promise))return tH(i,r)}catch(e){}return async function(e,t){let r={async:!0};return tH(await e._zod.run({value:t,issues:[]},r),r)}(e,t)},vendor:"zod",version:1}}let tV=eB("$ZodString",(e,t)=>{tF.init(e,t),e._zod.pattern=t.pattern??tf,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tJ=eB("$ZodStringFormat",(e,t)=>{tI.init(e,t),tV.init(e,t)}),tB=eB("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ti),tJ.init(e,t)}),tW=eB("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=tn(e))}else t.pattern??(t.pattern=tn());tJ.init(e,t)}),tG=eB("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=to),tJ.init(e,t)});function tK(e){try{if("u">typeof URL&&"function"==typeof URL.canParse)return URL.canParse(e);return new URL(e),!0}catch{return!1}}let tY=/[\t\n\r]/g;function tX(e){return e.replace(tY,"")}let tQ=eB("$ZodURL",(e,t)=>{tJ.init(e,t),e._zod.check=r=>{try{var i,n;let o=r.value.trim(),a="normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===tu.source&&!/^https?:\/\//i.test(e))return 1;try{if("u">typeof URL){let t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(o,t):tK(o)||2;if(1===a)return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});if(2===a)return void r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});if(!0===a){r.value=tX(o);return}t.hostname&&((i=t.hostname).lastIndex=0,!i.test(a.hostname))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&((n=t.protocol).lastIndex=0,!n.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?a.href:tX(o);return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),t0=eB("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),tJ.init(e,t)}),t1=eB("$ZodNanoID",(e,t)=>{var r;if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=void 0===t.length?tt:(r=t.length,RegExp(`^[a-zA-Z0-9_-]{${r}}$`))),tJ.init(e,t)}),t2=eB("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=e3),tJ.init(e,t)}),t9=eB("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=e6),tJ.init(e,t)}),t4=eB("$ZodULID",(e,t)=>{t.pattern??(t.pattern=e7),tJ.init(e,t)}),t5=eB("$ZodXID",(e,t)=>{t.pattern??(t.pattern=e8),tJ.init(e,t)}),t3=eB("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=te),tJ.init(e,t)}),t6=eB("$ZodISODateTime",(e,t)=>{let r,i,n;t.pattern??(r=["Z"],t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),i=`${th({precision:t.precision,seconds:!0})}(?:${r.join("|")})`,n=t.local?`${i}|${th({precision:t.precision})}`:i,t.pattern=RegExp(`^${tp}T(?:${n})$`)),tJ.init(e,t)}),t7=eB("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=tm),tJ.init(e,t)}),t8=eB("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${th(t)}$`)),tJ.init(e,t)}),re=eB("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=tr),tJ.init(e,t)}),rt=eB("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ta),tJ.init(e,t)}),rr=/^[0-9a-fA-F:.]+$/;function ri(e){return!!rr.test(e)&&tK(`http://[${e}]`)}let rn=eB("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ts),tJ.init(e,t),e._zod.check=r=>{ri(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),ro=eB("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=tl),tJ.init(e,t)}),ra=eB("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tc),tJ.init(e,t),e._zod.check=r=>{!function(e){let t=e.split("/");if(2!==t.length)return!1;let[r,i]=t;if(!i)return!1;let n=Number(i);return`${n}`===i&&!(n<0)&&!(n>128)&&ri(r)}(r.value)&&r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function rs(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let rl=/^[0-9a-zA-Z+/]*={0,2}$/,rc=eB("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rl),tJ.init(e,t),e._zod.check=r=>{rs(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ru=/^[A-Za-z0-9_-]*$/,rd=eB("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ru),tJ.init(e,t),e._zod.check=r=>{!function(e){if(!ru.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return rs(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),rp=eB("$ZodE164",(e,t)=>{t.pattern??(t.pattern=td),tJ.init(e,t)}),rm=eB("$ZodJWT",(e,t)=>{tJ.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));if("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),rh=eB("$ZodNumber",(e,t)=>{tF.init(e,t),e._zod.pattern=ty,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let n=r.value;if("number"==typeof n&&!Number.isNaN(n)&&Number.isFinite(n))return r;let o="number"==typeof n?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:String(n):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...o?{received:o}:{}}),r}}),rf=eB("$ZodNumberFormat",(e,t)=>{tT.init(e,t),rh.init(e,t)}),rg=eB("$ZodBoolean",(e,t)=>{tF.init(e,t),e._zod.pattern=tv,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let n=r.value;return"boolean"==typeof n||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),ry=eB("$ZodNull",(e,t)=>{tF.init(e,t),e._zod.pattern=t_,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let i=t.value;return null===i||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),t}}),rv=eB("$ZodAny",(e,t)=>{tF.init(e,t),e._zod.parse=e=>e}),r_=eB("$ZodUnknown",(e,t)=>{tF.init(e,t),e._zod.parse=e=>e}),rb=eB("$ZodNever",(e,t)=>{tF.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),rS=e=>Array.isArray(e)?e.length:-1;function rw(e,t,r){e.issues.length&&t.issues.push(...eO(r,e.issues)),t.value[r]=e.value}let rR=eB("$ZodArray",(e,t)=>{tF.init(e,t);let r=eK.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),i;i.value=r?r.alloc(e,i,Array(o.length),n):Array(o.length);let a=[],s=n?.abortEarly;for(let e=0;e<o.length;e++){let r=o[e],l=t.element._zod.run({value:r,issues:[]},n);if(l instanceof Promise)a.push(l.then(t=>rw(t,i,e)));else if(rw(l,i,e),s&&0!==l.issues.length&&eP(l))break}return a.length?Promise.all(a).then(()=>i):i},function(e,t){let r=eI(e._zod.def.checks);if(!r.length)return;let i=Math.min(...r.map(e=>e[0])),n=e._zod.parse;e._zod.parse=(r,o)=>{let a=t(r.value);if(a>i&&!o?.skipChecks&&o?.direction!=="backward"){for(let[t,i]of eI(e._zod.def.checks))if(a>t&&i._zod.def.when(r)){let t=r.issues.length;return i._zod.check(r),r.issues[t].continue=!1,eq(r.issues,t,e),r}}return n(r,o)}}(e,rS)});function rk(e,t,r,i,n,o){let a=r in i,s="optional"===o;if(a||!s||"optional"!==n){if(e.issues.length){if(void 0!==n&&s&&!a)return;t.issues.push(...eO(r,e.issues))}if(!a&&void 0===n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?(a||"defaulted"===n&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}let rx=[];function rC(e){var t;let r=Object.keys(e.shape),i=Object.getOwnPropertySymbols(e.shape),n=i.length?i:rx,o=n.length?[...r,...n]:r;for(let t of o)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Object.keys(t=e.shape).filter(e=>void 0!==t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(a)}}function r$(e,t,r,i,n,o,a){let s=[],l=n.keySet,c=n.catchall._zod,u=c.def.type,d=c.optin,p=c.optout,m=0;for(let n in t){if(a&&r.issues.length!==m){if(eP(r,m))break;m=r.issues.length}if(l.has(n))continue;if("__proto__"===n){"never"===u&&s.push(n);continue}if("never"===u){s.push(n);continue}let o=c.run({value:t[n],issues:[]},i);o instanceof Promise?e.push(o.then(e=>rk(e,r,n,t,d,p))):rk(o,r,n,t,d,p)}return(s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o,continue:!0}),e.length)?Promise.all(e).then(()=>r):r}let rT=eB("$ZodObject",(e,t)=>{let r;tF.init(e,t);let i=Object.getOwnPropertyDescriptor(t,"shape"),n=i?.get?i.get.raw:t.shape??{};if(n){let e=()=>{let r={...n};return Object.defineProperty(t,"shape",{value:r}),e.raw=r,r};e.raw=n,Object.defineProperty(t,"shape",{get:e})}let o=en(()=>rC(t));eH(e,"propValues",e=>{let t=e.def.shape,r={};for(let e in t){let i=t[e]._zod;if(i.values){for(let t of(Object.prototype.hasOwnProperty.call(r,e)||es(r,e,new Set),i.values))r[e].add(t);void 0!==i.optin&&r[e].add(void 0)}}return r});let a=t.catchall,s=eK.memoizer;s?.attach(e),e._zod.parse=(t,i)=>{r??(r=o.value);let n=t.value;if(!ef(n))return t.issues.push({expected:"object",code:"invalid_type",input:n,inst:e}),t;t.value=s?s.alloc(e,t,{},i):{};let l=[],c=r.shape,u=i?.abortEarly,d=t.issues.length;for(let e of r.allKeys){if(u&&t.issues.length!==d){if(eP(t,d))break;d=t.issues.length}if("__proto__"===e)continue;let r=c[e],o=r._zod.optin,a=r._zod.optout,s=r._zod.run({value:n[e],issues:[]},i);s instanceof Promise?l.push(s.then(r=>rk(r,t,e,n,o,a))):rk(s,t,e,n,o,a)}return a?r$(l,n,t,i,o.value,e,!0===u):l.length?Promise.all(l).then(()=>t):t}}),rP=eB("$ZodObjectJIT",(e,t)=>{let r,i;rT.init(e,t);let n=e._zod.parse,o=en(()=>rC(t)),a=eK.memoizer,s=!eK.jitless,l=s&&eg.value,c=t.catchall;e._zod.parse=(u,d)=>{i??(i=o.value);let p=u.value;return ef(p)?s&&l&&d?.async===!1&&!0!==d.jitless?(r||(r=(t=>{let r=o.value,i=r.symbolKeys,n=new tZ(["payload","ctx"],{shape:t,inst:e,memo:a,syms:i}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,l=(e,t)=>`
|
|
4
4
|
let ${e}_ab = false;
|
|
5
5
|
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
6
6
|
const iss = ${e}.issues[i];
|
|
@@ -50,16 +50,16 @@ ${t.join("\n")}
|
|
|
50
50
|
newResult[${o}] = ${r}.value;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
`)}return n.write("payload.value = newResult;"),n.write("return payload;"),n.compile()})(t.shape)),u=r(u,d),c)?r$([],p,u,d,i,e,d?.abortEarly===!0):u:n(u,d):(u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u)}});function rE(e,t,r,i){for(let r of e)if(0===r.issues.length)return t.value=r.value,t;let n=e.filter(e=>!eP(e));return 1===n.length?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>ej(e,i,eY())))}),t)}let rO=eB("$ZodUnion",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),eH(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),eH(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),eH(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>eo(e.source)).join("|")})$`)}});let r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let o=!1,a=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},n);if(t instanceof Promise)a.push(t),o=!0;else{if(0===t.issues.length)return t;a.push(t)}}return o?Promise.all(a).then(t=>rE(t,i,e,n)):rE(a,i,e,n)}}),rI=eB("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,rO.init(e,t);let r=e._zod.parse;eH(e,"propValues",e=>{let t={},r=0;for(let i of e.def.options){let n=i._zod.propValues;if(!n||0===Object.keys(n).length)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(i)}"`);for(let[i,o]of(n[e.def.discriminator]?.has(void 0)&&r++,Object.entries(n)))for(let e of(Object.prototype.hasOwnProperty.call(t,i)||es(t,i,new Set),o))t[i].add(e)}return!e.def.unionFallback&&r>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,r)=>{let i=el(e._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${r}"`)});let i=en(()=>(function(e){let t=new Map;for(let r of e.options){let i=r._zod.propValues?.[e.discriminator];if(!i||0===i.size)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let e of i)if(t.has(e)){if(void 0!==e)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,r)}return t})(t));e._zod.parse=(n,o)=>{let a=n.value;if(!ef(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;let s=a?.[t.discriminator],l=i.value.get(s);return l&&(void 0!==s||"backward"!==o.direction)?l._zod.run(n,o):t.unionFallback||"backward"===o.direction?r(n,o):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter(e=>null!==i.value.get(e)),input:a,path:[t.discriminator],inst:e}),n)}}),rq=eB("$ZodIntersection",(e,t)=>{tF.init(e,t),e._zod.parse=(e,r)=>{let i=e.value,n=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return n instanceof Promise||o instanceof Promise?Promise.all([n,o]).then(([t,r])=>rj(e,t,r)):rj(e,n,o)}});function rj(e,t,r){let i,n=new Map,o=new Map,a=(e,t)=>{let r;if("unrecognized_keys"!==e.code||e.path?.length)if("invalid_key"!==e.code||"record"!==e.origin||e.path?.length!==1)return!1;else{let t=String(e.path[0]);o.has(t)||o.set(t,e),r=[t]}else i??(i=e),r=e.keys;for(let e of r)n.has(e)||n.set(e,{}),n.get(e)[t]=!0;return!0};for(let r of t.issues)a(r,"l")||e.issues.push(r);for(let t of r.issues)a(t,"r")||e.issues.push(t);let s=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];for(let r of(t.length&&e.issues.push({...i,keys:t}),s))!t.includes(r)&&o.has(r)&&e.issues.push(o.get(r))}let l=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(ey(t)&&ey(r)){let i=Object.keys(r),n=Object.keys(t).filter(e=>-1!==i.indexOf(e)),o={...t,...r};for(let i of(Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__,n)){if("__proto__"===i)continue;let n=e(t[i],r[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};let i=[];for(let n=0;n<t.length;n++){let o=e(t[n],r[n]);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};i.push(o.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);if(!l.valid){if(eP(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return e.value=l.data,e}let rA=eB("$ZodRecord",(e,t)=>{tF.init(e,t);let r=eK.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!ey(o))return i.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),i;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){let l;i.value=r?r.alloc(e,i,{},n):{};let c=new Set;for(let r of s)if("string"==typeof r||"number"==typeof r||"symbol"==typeof r){if(c.add("number"==typeof r?r.toString():r),"__proto__"===r)continue;let s=t.keyType._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(s.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>ej(e,n,eY())),input:r,path:[r],inst:e});continue}let l=s.value;if("__proto__"===l)continue;let u=t.valueType._zod.run({value:o[r],issues:[]},n);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&i.issues.push(...eE(r,e.issues)),i.value[l]=e.value})):(u.issues.length&&i.issues.push(...eE(r,u.issues)),i.value[l]=u.value)}for(let e in o)if(!c.has(e))if("loose"===t.mode){if("__proto__"===e)continue;i.value[e]=o[e]}else(l=l??[]).push(e);l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}else{let l;for(let c of(i.value=r?r.alloc(e,i,{},n):{},Reflect.ownKeys(o))){if("__proto__"===c||!Object.prototype.propertyIsEnumerable.call(o,c))continue;let r=t.keyType._zod.run({value:c,issues:[]},n);if(r instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof c&&ty.test(c)&&r.issues.length){let e=t.keyType._zod.run({value:Number(c),issues:[]},n);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(r=e)}if(r.issues.length){"loose"===t.mode?i.value[c]=o[c]:s?(l=l??[]).push(c):i.issues.push({code:"invalid_key",origin:"record",issues:r.issues.map(e=>ej(e,n,eY())),input:c,path:[c],inst:e});continue}let u=r.value;if("__proto__"===u)continue;let d=t.valueType._zod.run({value:o[c],issues:[]},n);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&i.issues.push(...eE(c,e.issues)),i.value[u]=e.value})):(d.issues.length&&i.issues.push(...eE(c,d.issues)),i.value[u]=d.value)}l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}return a.length?Promise.all(a).then(()=>i):i}}),rz=eB("$ZodEnum",(e,t)=>{tF.init(e,t);let r=ee(t.entries),i=new Set(r);e._zod.values=i,eH(e,"pattern",e=>{let t=ee(e.def.entries).filter(e=>e_.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>eb(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,n)=>{let o=t.value;return i.has(o)||t.issues.push({code:"invalid_value",values:r,input:o,inst:e}),t}}),rL=eB("$ZodLiteral",(e,t)=>{tF.init(e,t);let r=new Set(t.values);e._zod.values=r,eH(e,"pattern",e=>{let t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?eb(e):e?eb(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,n)=>{let o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),rN=eB("$ZodTransform",(e,t)=>{tF.init(e,t),e._zod.optin="optional",eK.memoizer?.guard(e),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new eG(e.constructor.name);let n=t.transform(r.value,r);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(e=>(r.value=e,r));if(n instanceof Promise)throw new eW;return r.value=n,r}});function rM(e,t){return e.value=t.issues.length?void 0:t.value,e}let rZ=eB("$ZodOptional",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",eH(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),eH(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${eo(t.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;let i=t.innerType._zod.run({value:e.value,issues:[]},r);return i instanceof Promise?i.then(t=>rM(e,t)):rM(e,i)}return t.innerType._zod.run(e,r)}}),rU=eB("$ZodExactOptional",(e,t)=>{rZ.init(e,t),eH(e,"values",e=>e.def.innerType._zod.values),eH(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),rF=eB("$ZodNullable",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>e.def.innerType._zod.optin),eH(e,"optout",e=>e.def.innerType._zod.optout),eH(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${eo(t.source)}|null)$`):void 0}),eH(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),rH=eB("$ZodDefault",(e,t)=>{tF.init(e,t),e._zod.optin="defaulted",eH(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;let i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(e=>rD(e,t)):rD(i,t)}});function rD(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let rV=eB("$ZodPrefault",(e,t)=>{tF.init(e,t),e._zod.optin="defaulted",eH(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),rJ=eB("$ZodNonOptional",(e,t)=>{tF.init(e,t),eH(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,i)=>{let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(t=>rB(t,e)):rB(n,e)}});function rB(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function rW(e,t,r,i){return t.issues.length?e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>ej(e,i,eY()))},input:e.value}):(e.value=t.value,t.memo&&(e.memo=!0)),e}let rG=eB("$ZodCatch",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),eH(e,"optout",e=>e.def.innerType._zod.optout),eH(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let i=t.innerType._zod.run({value:e.value,issues:[]},r);return i instanceof Promise?i.then(i=>rW(e,i,t,r)):rW(e,i,t,r)}}),rK=eB("$ZodPipe",(e,t)=>{tF.init(e,t),eH(e,"values",e=>e.def.in._zod.values),eH(e,"optin",e=>e.def.in._zod.optin),eH(e,"optout",e=>e.def.out._zod.optout),eH(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){let i=t.out._zod.run(e,r);return i instanceof Promise?i.then(e=>rY(e,t.in,r)):rY(i,t.in,r)}let i=t.in._zod.run(e,r);return i instanceof Promise?i.then(e=>rY(e,t.out,r)):rY(i,t.out,r)}});function rY(e,t,r){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}let rX=eB("$ZodPreprocess",(e,t)=>{rK.init(e,t)}),rQ=eB("$ZodReadonly",(e,t)=>{tF.init(e,t),eH(e,"propValues",e=>e.def.innerType._zod.propValues),eH(e,"values",e=>e.def.innerType._zod.values),eH(e,"optin",e=>e.def.innerType?._zod?.optin),eH(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(r0):r0(i)}});function r0(e){return e.memo||(e.value=Object.freeze(e.value)),e}let r1=eB("$ZodLazy",(e,t)=>{var r;let i;tF.init(e,t),r=e._zod,Object.defineProperty(r,"innerType",{get(){if(i!==ea)return void 0===i&&(i=ea,i=(()=>(t._cachedInner||(t._cachedInner=t.getter()),t._cachedInner))()),i},set(e){Object.defineProperty(r,"innerType",{value:e})},configurable:!0}),eH(e,"pattern",e=>e.innerType?._zod?.pattern),eH(e,"propValues",e=>e.innerType?._zod?.propValues),eH(e,"optin",e=>e.innerType?._zod?.optin??void 0),eH(e,"optout",e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),r2=eB("$ZodCustom",(e,t)=>{tw.init(e,t),tF.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{let i=r.value,n=t.fn(i);if(n instanceof Promise)return n.then(t=>r9(t,r,i,e));r9(n,r,i,e)}});function r9(e,t,r,i){if(!e){let e={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(eN(e))}}(j=globalThis).__zod_globalRegistry??(j.__zod_globalRegistry=new class e{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});let r4=globalThis.__zod_globalRegistry;function r5(e){return e.checks&&(e.checks=[...e.checks]),e}function r3(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ew(t)})}function r6(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ew(t)})}function r7(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ew(t)})}function r8(e,t){return new e({type:"string",format:"date",check:"string_format",...ew(t)})}function ie(e,t){return new tx({check:"less_than",...ew(t),value:e,inclusive:!1})}function it(e,t){return new tx({check:"less_than",...ew(t),value:e,inclusive:!0})}function ir(e,t){return new tC({check:"greater_than",...ew(t),value:e,inclusive:!1})}function ii(e,t){return new tC({check:"greater_than",...ew(t),value:e,inclusive:!0})}function io(e,t){return new t$({check:"multiple_of",...ew(t),value:e})}function ia(e,t){return new tP({check:"max_length",...ew(t),maximum:e})}function is(e,t){return new tE({check:"min_length",...ew(t),minimum:e})}function il(e,t){return new tO({check:"length_equals",...ew(t),length:e})}function ic(e){return new tM({check:"overwrite",tx:e})}function iu(e,...t){for(let r of t)for(let t of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,t)&&es(e,t,r[t]);return e}function id(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??r4,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ip(e,t,r,i,n){let o="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:i.path,message:n}):t.unrepresentable;if("any"===o)return!1;if(void 0===o||"throw"===o)throw Error(n);return Object.assign(r,o),!0}function im(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let i={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,i);else{let r=a.schema,o=t.processors[n.type];if(!o)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);o(e,t,r,i)}let o=e._zod.parent;o&&(a.ref||(a.ref=o),im(o,t,i),t.seen.get(o).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&iu(a.schema,l),"input"===t.io&&function e(t,r){let i=r??{seen:new Set};if(i.seen.has(t))return!1;i.seen.add(t);let n=t._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return e(n.element,i);if("set"===n.type)return e(n.valueType,i);if("lazy"===n.type)return e(n.getter(),i);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type||"catch"===n.type)return e(n.innerType,i);if("intersection"===n.type)return e(n.left,i)||e(n.right,i);if("record"===n.type||"map"===n.type)return e(n.keyType,i)||e(n.valueType,i);if("pipe"===n.type)return!!t._zod.traits.has("$ZodCodec")||e(n.in,i)||e(n.out,i);if("object"===n.type){for(let t in n.shape)if(e(n.shape[t],i))return!0;return!1}if("union"===n.type){for(let t of n.options)if(e(t,i))return!0;return!1}if("tuple"===n.type){for(let t of n.items)if(e(t,i))return!0;if(n.rest&&e(n.rest,i))return!0}return!1}(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function ih(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ig(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let t of e.seen.entries()){let r=e.metadataRegistry.get(t[0])?.id;if(r){let e=i.get(r);if(e&&e!==t[0])throw Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(r,t[0])}}let n=t=>{if(t[1].schema.$ref)return;let i=t[1],{ref:n,defId:o}=(t=>{let i="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let r=e.external.registry.get(t[0])?.id,n=e.external.uri??(e=>e);if(r)return{ref:n(r)};let o=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=o,{defId:o,ref:`${n("__shared")}#/${i}/${ih(o)}`}}let n=`#/${i}/`;if(t[1]===r&&!t[1].schema.id)return{ref:"#"};let o=t[1].schema.id??`__schema${e.counter++}`;return{defId:o,ref:n+ih(o)}})(t);i.def={...i.schema},o&&(i.defId=o);let a=i.schema;for(let e in a)delete a[e];a.$ref=n};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
|
|
53
|
+
`)}return n.write("payload.value = newResult;"),n.write("return payload;"),n.compile()})(t.shape)),u=r(u,d),c)?r$([],p,u,d,i,e,d?.abortEarly===!0):u:n(u,d):(u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u)}});function rO(e,t,r,i){for(let r of e)if(0===r.issues.length)return t.value=r.value,t;let n=e.filter(e=>!eP(e));return 1===n.length?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>ej(e,i,eY())))}),t)}let rE=eB("$ZodUnion",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),eH(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),eH(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),eH(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>eo(e.source)).join("|")})$`)}});let r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let o=!1,a=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},n);if(t instanceof Promise)a.push(t),o=!0;else{if(0===t.issues.length)return t;a.push(t)}}return o?Promise.all(a).then(t=>rO(t,i,e,n)):rO(a,i,e,n)}}),rI=eB("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,rE.init(e,t);let r=e._zod.parse;eH(e,"propValues",e=>{let t={},r=0;for(let i of e.def.options){let n=i._zod.propValues;if(!n||0===Object.keys(n).length)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(i)}"`);for(let[i,o]of(n[e.def.discriminator]?.has(void 0)&&r++,Object.entries(n)))for(let e of(Object.prototype.hasOwnProperty.call(t,i)||es(t,i,new Set),o))t[i].add(e)}return!e.def.unionFallback&&r>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,r)=>{let i=el(e._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${r}"`)});let i=en(()=>(function(e){let t=new Map;for(let r of e.options){let i=r._zod.propValues?.[e.discriminator];if(!i||0===i.size)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let e of i)if(t.has(e)){if(void 0!==e)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,r)}return t})(t));e._zod.parse=(n,o)=>{let a=n.value;if(!ef(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;let s=a?.[t.discriminator],l=i.value.get(s);return l&&(void 0!==s||"backward"!==o.direction)?l._zod.run(n,o):t.unionFallback||"backward"===o.direction?r(n,o):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter(e=>null!==i.value.get(e)),input:a,path:[t.discriminator],inst:e}),n)}}),rq=eB("$ZodIntersection",(e,t)=>{tF.init(e,t),e._zod.parse=(e,r)=>{let i=e.value,n=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return n instanceof Promise||o instanceof Promise?Promise.all([n,o]).then(([t,r])=>rj(e,t,r)):rj(e,n,o)}});function rj(e,t,r){let i,n=new Map,o=new Map,a=(e,t)=>{let r;if("unrecognized_keys"!==e.code||e.path?.length)if("invalid_key"!==e.code||"record"!==e.origin||e.path?.length!==1)return!1;else{let t=String(e.path[0]);o.has(t)||o.set(t,e),r=[t]}else i??(i=e),r=e.keys;for(let e of r)n.has(e)||n.set(e,{}),n.get(e)[t]=!0;return!0};for(let r of t.issues)a(r,"l")||e.issues.push(r);for(let t of r.issues)a(t,"r")||e.issues.push(t);let s=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];for(let r of(t.length&&e.issues.push({...i,keys:t}),s))!t.includes(r)&&o.has(r)&&e.issues.push(o.get(r))}let l=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(ey(t)&&ey(r)){let i=Object.keys(r),n=Object.keys(t).filter(e=>-1!==i.indexOf(e)),o={...t,...r};for(let i of(Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__,n)){if("__proto__"===i)continue;let n=e(t[i],r[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};let i=[];for(let n=0;n<t.length;n++){let o=e(t[n],r[n]);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};i.push(o.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);if(!l.valid){if(eP(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return e.value=l.data,e}let rA=eB("$ZodRecord",(e,t)=>{tF.init(e,t);let r=eK.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!ey(o))return i.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),i;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){let l;i.value=r?r.alloc(e,i,{},n):{};let c=new Set;for(let r of s)if("string"==typeof r||"number"==typeof r||"symbol"==typeof r){if(c.add("number"==typeof r?r.toString():r),"__proto__"===r)continue;let s=t.keyType._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(s.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>ej(e,n,eY())),input:r,path:[r],inst:e});continue}let l=s.value;if("__proto__"===l)continue;let u=t.valueType._zod.run({value:o[r],issues:[]},n);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&i.issues.push(...eO(r,e.issues)),i.value[l]=e.value})):(u.issues.length&&i.issues.push(...eO(r,u.issues)),i.value[l]=u.value)}for(let e in o)if(!c.has(e))if("loose"===t.mode){if("__proto__"===e)continue;i.value[e]=o[e]}else(l=l??[]).push(e);l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}else{let l;for(let c of(i.value=r?r.alloc(e,i,{},n):{},Reflect.ownKeys(o))){if("__proto__"===c||!Object.prototype.propertyIsEnumerable.call(o,c))continue;let r=t.keyType._zod.run({value:c,issues:[]},n);if(r instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof c&&ty.test(c)&&r.issues.length){let e=t.keyType._zod.run({value:Number(c),issues:[]},n);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(r=e)}if(r.issues.length){"loose"===t.mode?i.value[c]=o[c]:s?(l=l??[]).push(c):i.issues.push({code:"invalid_key",origin:"record",issues:r.issues.map(e=>ej(e,n,eY())),input:c,path:[c],inst:e});continue}let u=r.value;if("__proto__"===u)continue;let d=t.valueType._zod.run({value:o[c],issues:[]},n);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&i.issues.push(...eO(c,e.issues)),i.value[u]=e.value})):(d.issues.length&&i.issues.push(...eO(c,d.issues)),i.value[u]=d.value)}l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}return a.length?Promise.all(a).then(()=>i):i}}),rz=eB("$ZodEnum",(e,t)=>{tF.init(e,t);let r=ee(t.entries),i=new Set(r);e._zod.values=i,eH(e,"pattern",e=>{let t=ee(e.def.entries).filter(e=>e_.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>eb(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,n)=>{let o=t.value;return i.has(o)||t.issues.push({code:"invalid_value",values:r,input:o,inst:e}),t}}),rL=eB("$ZodLiteral",(e,t)=>{tF.init(e,t);let r=new Set(t.values);e._zod.values=r,eH(e,"pattern",e=>{let t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?eb(e):e?eb(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,n)=>{let o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),rN=eB("$ZodTransform",(e,t)=>{tF.init(e,t),e._zod.optin="optional",eK.memoizer?.guard(e),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new eG(e.constructor.name);let n=t.transform(r.value,r);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(e=>(r.value=e,r));if(n instanceof Promise)throw new eW;return r.value=n,r}});function rM(e,t){return e.value=t.issues.length?void 0:t.value,e}let rZ=eB("$ZodOptional",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",eH(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),eH(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${eo(t.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;let i=t.innerType._zod.run({value:e.value,issues:[]},r);return i instanceof Promise?i.then(t=>rM(e,t)):rM(e,i)}return t.innerType._zod.run(e,r)}}),rU=eB("$ZodExactOptional",(e,t)=>{rZ.init(e,t),eH(e,"values",e=>e.def.innerType._zod.values),eH(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),rF=eB("$ZodNullable",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>e.def.innerType._zod.optin),eH(e,"optout",e=>e.def.innerType._zod.optout),eH(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${eo(t.source)}|null)$`):void 0}),eH(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),rH=eB("$ZodDefault",(e,t)=>{tF.init(e,t),e._zod.optin="defaulted",eH(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;let i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(e=>rD(e,t)):rD(i,t)}});function rD(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let rV=eB("$ZodPrefault",(e,t)=>{tF.init(e,t),e._zod.optin="defaulted",eH(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),rJ=eB("$ZodNonOptional",(e,t)=>{tF.init(e,t),eH(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,i)=>{let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(t=>rB(t,e)):rB(n,e)}});function rB(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function rW(e,t,r,i){return t.issues.length?e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>ej(e,i,eY()))},input:e.value}):(e.value=t.value,t.memo&&(e.memo=!0)),e}let rG=eB("$ZodCatch",(e,t)=>{tF.init(e,t),eH(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),eH(e,"optout",e=>e.def.innerType._zod.optout),eH(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let i=t.innerType._zod.run({value:e.value,issues:[]},r);return i instanceof Promise?i.then(i=>rW(e,i,t,r)):rW(e,i,t,r)}}),rK=eB("$ZodPipe",(e,t)=>{tF.init(e,t),eH(e,"values",e=>e.def.in._zod.values),eH(e,"optin",e=>e.def.in._zod.optin),eH(e,"optout",e=>e.def.out._zod.optout),eH(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){let i=t.out._zod.run(e,r);return i instanceof Promise?i.then(e=>rY(e,t.in,r)):rY(i,t.in,r)}let i=t.in._zod.run(e,r);return i instanceof Promise?i.then(e=>rY(e,t.out,r)):rY(i,t.out,r)}});function rY(e,t,r){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}let rX=eB("$ZodPreprocess",(e,t)=>{rK.init(e,t)}),rQ=eB("$ZodReadonly",(e,t)=>{tF.init(e,t),eH(e,"propValues",e=>e.def.innerType._zod.propValues),eH(e,"values",e=>e.def.innerType._zod.values),eH(e,"optin",e=>e.def.innerType?._zod?.optin),eH(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(r0):r0(i)}});function r0(e){return e.memo||(e.value=Object.freeze(e.value)),e}let r1=eB("$ZodLazy",(e,t)=>{var r;let i;tF.init(e,t),r=e._zod,Object.defineProperty(r,"innerType",{get(){if(i!==ea)return void 0===i&&(i=ea,i=(()=>(t._cachedInner||(t._cachedInner=t.getter()),t._cachedInner))()),i},set(e){Object.defineProperty(r,"innerType",{value:e})},configurable:!0}),eH(e,"pattern",e=>e.innerType?._zod?.pattern),eH(e,"propValues",e=>e.innerType?._zod?.propValues),eH(e,"optin",e=>e.innerType?._zod?.optin??void 0),eH(e,"optout",e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),r2=eB("$ZodCustom",(e,t)=>{tw.init(e,t),tF.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{let i=r.value,n=t.fn(i);if(n instanceof Promise)return n.then(t=>r9(t,r,i,e));r9(n,r,i,e)}});function r9(e,t,r,i){if(!e){let e={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(eN(e))}}(j=globalThis).__zod_globalRegistry??(j.__zod_globalRegistry=new class e{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});let r4=globalThis.__zod_globalRegistry;function r5(e){return e.checks&&(e.checks=[...e.checks]),e}function r3(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ew(t)})}function r6(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ew(t)})}function r7(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ew(t)})}function r8(e,t){return new e({type:"string",format:"date",check:"string_format",...ew(t)})}function ie(e,t){return new tx({check:"less_than",...ew(t),value:e,inclusive:!1})}function it(e,t){return new tx({check:"less_than",...ew(t),value:e,inclusive:!0})}function ir(e,t){return new tC({check:"greater_than",...ew(t),value:e,inclusive:!1})}function ii(e,t){return new tC({check:"greater_than",...ew(t),value:e,inclusive:!0})}function io(e,t){return new t$({check:"multiple_of",...ew(t),value:e})}function ia(e,t){return new tP({check:"max_length",...ew(t),maximum:e})}function is(e,t){return new tO({check:"min_length",...ew(t),minimum:e})}function il(e,t){return new tE({check:"length_equals",...ew(t),length:e})}function ic(e){return new tM({check:"overwrite",tx:e})}function iu(e,...t){for(let r of t)for(let t of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,t)&&es(e,t,r[t]);return e}function id(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??r4,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ip(e,t,r,i,n){let o="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:i.path,message:n}):t.unrepresentable;if("any"===o)return!1;if(void 0===o||"throw"===o)throw Error(n);return Object.assign(r,o),!0}function im(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let i={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,i);else{let r=a.schema,o=t.processors[n.type];if(!o)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);o(e,t,r,i)}let o=e._zod.parent;o&&(a.ref||(a.ref=o),im(o,t,i),t.seen.get(o).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&iu(a.schema,l),"input"===t.io&&function e(t,r){let i=r??{seen:new Set};if(i.seen.has(t))return!1;i.seen.add(t);let n=t._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return e(n.element,i);if("set"===n.type)return e(n.valueType,i);if("lazy"===n.type)return e(n.getter(),i);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type||"catch"===n.type)return e(n.innerType,i);if("intersection"===n.type)return e(n.left,i)||e(n.right,i);if("record"===n.type||"map"===n.type)return e(n.keyType,i)||e(n.valueType,i);if("pipe"===n.type)return!!t._zod.traits.has("$ZodCodec")||e(n.in,i)||e(n.out,i);if("object"===n.type){for(let t in n.shape)if(e(n.shape[t],i))return!0;return!1}if("union"===n.type){for(let t of n.options)if(e(t,i))return!0;return!1}if("tuple"===n.type){for(let t of n.items)if(e(t,i))return!0;if(n.rest&&e(n.rest,i))return!0}return!1}(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function ih(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ig(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let t of e.seen.entries()){let r=e.metadataRegistry.get(t[0])?.id;if(r){let e=i.get(r);if(e&&e!==t[0])throw Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(r,t[0])}}let n=t=>{if(t[1].schema.$ref)return;let i=t[1],{ref:n,defId:o}=(t=>{let i="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let r=e.external.registry.get(t[0])?.id,n=e.external.uri??(e=>e);if(r)return{ref:n(r)};let o=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=o,{defId:o,ref:`${n("__shared")}#/${i}/${ih(o)}`}}let n=`#/${i}/`;if(t[1]===r&&!t[1].schema.id)return{ref:"#"};let o=t[1].schema.id??`__schema${e.counter++}`;return{defId:o,ref:n+ih(o)}})(t);i.def={...i.schema},o&&(i.defId=o);let a=i.schema;for(let e in a)delete a[e];a.$ref=n};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
|
|
54
54
|
|
|
55
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let r of e.seen.entries()){let i=r[1];if(t===r[0]){n(r);continue}if(e.external){let i=e.external.registry.get(r[0])?.id;if(t!==r[0]&&i){n(r);continue}}if(e.metadataRegistry.get(r[0])?.id||i.cycle){n(r);continue}i.count>1&&"ref"===e.reused&&n(r)}e.external&&(e.sharedDefsExtractedFor=e.external)}let iy=new Set(["type","properties","required","additionalProperties"]),iv=["oneOf","anyOf"];function i_(e){let t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function ib(e){let t=[];for(let r of e){if("object"!=typeof r||"object"!==r.type)return null;for(let e in r)if(!iy.has(e))return null;t.push(r)}let r={},i=new Set;for(let e of t){for(let i in e.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let e=[];for(let r of t){let t=r.properties?.[i]??i_(r);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}es(r,i,1===e.length?e[0]:ib(e)??{allOf:e})}for(let t of e.required??[])i.add(t)}let n={type:"object",properties:r};if(i.size&&(n.required=[...i]),t.every(e=>!1===e.additionalProperties))n.additionalProperties=!1;else{let e=[];for(let r of t){let t=i_(r);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?n.additionalProperties=e[0]:e.length>1&&(n.additionalProperties={allOf:e})}return n}function iS(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let i=t=>{let r=e.seen.get(t);if(null===r.ref)return;let n=r.def??r.schema,o={...n},a=r.ref;if(r.ref=null,a){i(a);let r=e.seen.get(a),s=r.schema;if(s.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(n.allOf=n.allOf??[],n.allOf.push(s)):iu(n,s),iu(n,o),t._zod.parent===a)for(let e in n)"$ref"!==e&&"allOf"!==e&&(e in o||delete n[e]);if(s.$ref&&r.def)for(let e in n)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(n[e])===JSON.stringify(r.def[e])&&delete n[e]}let s=t._zod.parent;if(s&&s!==a){i(s);let t=e.seen.get(s);if(t?.schema.$ref&&(n.$ref=t.schema.$ref,t.def))for(let e in n)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(n[e])===JSON.stringify(t.def[e])&&delete n[e]}e.override({zodSchema:t,jsonSchema:n,path:r.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())i(t[0]);if("openapi-3.0"!==e.target)for(let t of e.seen.entries())!function e(t){let r=t.anyOf;if(!Array.isArray(r)||0===r.length||void 0!==t.type)return;let i=[];for(let t of r){if(!t||"object"!=typeof t)return;e(t);let r=Object.keys(t);if(1!==r.length||"type"!==r[0])return;let n=t.type;for(let e of Array.isArray(n)?n:[n]){if("string"!=typeof e)return;i.includes(e)||i.push(e)}}delete t.anyOf,t.type=1===i.length?i[0]:i}(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let r of e.seen.values())for(let e of[r.schema,r.def]){let r=e?.allOf;if(!Array.isArray(r))continue;let i=t.get(r);i?i.push(e):t.set(r,[e])}for(let r of e.intersections)for(let e of t.get(r)??[])!function(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of iy)if(t in e)return;let r=t.filter(e=>iv.some(t=>Array.isArray(e[t]))),i=null;if(r.length){let e=r[0],n=iv.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;let o=t.filter(t=>t!==e),a=e[n].map(e=>ib([...o,e]));if(a.some(e=>!e))return;i={[n]:a}}else i=ib(t);i&&(delete e.allOf,iu(e,i))}(e)}}let n={};if("draft-2020-12"===e.target?n.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?n.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let r=e.external.registry.get(t)?.id;if(!r)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(r)}iu(n,r.defId?r.schema:r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;void 0!==o&&n.id===o&&delete n.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,es(a,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?n.$defs=a:n.definitions=a);try{let r=JSON.parse(JSON.stringify(n));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:iw(t,"input",e.processors),output:iw(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let iw=(e,t,r={})=>i=>{let{libraryOptions:n,target:o}=i??{},a=id({...n??{},target:o,io:t,processors:r});return im(e,a),ig(a,e),iS(a,e)},iR=(e,t,r)=>{(void 0===e[t]||r>e[t])&&(e[t]=r)},ik=(e,t,r)=>{(void 0===e[t]||r<e[t])&&(e[t]=r)},ix=(e,t)=>{iR(e,"minimum",t),ik(e,"maximum",t)},iC=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},i$=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},iT=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},iP=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},iE=(e,t)=>iR(e,"minimum",t.minimum),iO=(e,t)=>ik(e,"maximum",t.maximum),iI=e=>(t,r)=>{iP(t,r.format);let[i,n]=e[r.format];iR(t,"minimum",i),ik(t,"maximum",n)},iq={greater_than:(e,t)=>iR(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ik(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>iC(e,t.value),number_format:iI(ek),bigint_format:iI(ex),min_length:iE,max_length:iO,length_equals:(e,t)=>ix(e,t.length),min_size:iE,max_size:iO,size_equals:(e,t)=>ix(e,t.size),string_format:(e,t)=>{iP(e,t.format),t.pattern&&i$(e,t.pattern),("base64"===t.format||"base64url"===t.format)&&(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>iT(e,t.mime)};function ij(e){let t={},r=e._zod.def;for(let i of e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[])iq[i._zod.def.check]?.(t,i._zod.def);let i=e._zod.bag;for(let e of(void 0!==i.minimum&&iR(t,"minimum",i.minimum),void 0!==i.exclusiveMinimum&&iR(t,"exclusiveMinimum",i.exclusiveMinimum),void 0!==i.maximum&&ik(t,"maximum",i.maximum),void 0!==i.exclusiveMaximum&&ik(t,"exclusiveMaximum",i.exclusiveMaximum),void 0!==i.multipleOf&&iC(t,i.multipleOf),void 0!==i.format&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&iT(t,i.mime),i.patterns??[]))i$(t,e);return t}let iA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},iz=new Map([[rl,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[ru,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),iL=e=>iz.get(e)??e,iN=(e,t,r,i)=>{r.type="string";let{minimum:n,maximum:o,format:a,patterns:s,contentEncoding:l,laxFormat:c}=ij(e);if("number"==typeof n&&(r.minLength=n),"number"==typeof o&&(r.maxLength=o),a&&(r.format=iA[a]??a,""===r.format&&delete r.format,("time"===a||c)&&delete r.format),l&&(r.contentEncoding=l),s&&s.size>0){let e=[...s].map(iL);1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}},iM=(e,t,r,i)=>{let{minimum:n,maximum:o,multipleOf:a,exclusiveMaximum:s,exclusiveMinimum:l,isInt:c}=ij(e);r.type=c?"integer":"number";let u="number"==typeof l&&l>=(n??-1/0),d="number"==typeof s&&s<=(o??1/0),p="draft-04"===t.target||"openapi-3.0"===t.target;if(u?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof n&&(r.minimum=n),d?p?(r.maximum=s,r.exclusiveMaximum=!0):r.exclusiveMaximum=s:"number"==typeof o&&(r.maximum=o),a){let n=new Set;for(let o of a)Number.isFinite(o)&&0!==o?n.add(Math.abs(o)):ip(e,t,r,i,`A multipleOf divisor of ${o} cannot be represented in JSON Schema`);let[o,...s]=n;void 0!==o&&(r.multipleOf=o),s.length&&(r.allOf=[...r.allOf??[],...s.map(e=>({multipleOf:e}))])}},iZ=(e,t,r,i)=>{r.type="boolean"},iU=(e,t,r,i)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},iF=(e,t,r,i)=>{r.not={}},iH=(e,t,r,i)=>{},iD=(e,t,r,i)=>{},iV=(e,t,r,i)=>{let n=ee(e._zod.def.entries);if(0===n.length){r.not={};return}n.every(e=>"number"==typeof e)&&(r.type="number"),n.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=n},iJ=(e,t,r,i)=>{let n=e._zod.def;if(0===n.values.length){r.not={};return}let o=[];for(let a of n.values)if(void 0===a){if(ip(e,t,r,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof a){if(ip(e,t,r,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(0===o.length);else if(1===o.length){let e=o[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else o.every(e=>"number"==typeof e)&&(r.type="number"),o.every(e=>"string"==typeof e)&&(r.type="string"),o.every(e=>"boolean"==typeof e)&&(r.type="boolean"),o.every(e=>null===e)&&(r.type="null"),r.enum=o},iB=(e,t,r,i)=>{ip(e,t,r,i,"Custom types cannot be represented in JSON Schema")},iW=(e,t,r,i)=>{ip(e,t,r,i,"Transforms cannot be represented in JSON Schema")},iG=(e,t,r,i)=>{let n=e._zod.def,{minimum:o,maximum:a}=ij(e);"number"==typeof o&&(r.minItems=o),"number"==typeof a&&(r.maxItems=a),r.type="array",r.items=im(n.element,t,{...i,path:[...i.path,"items"]})};function iK(e){let t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?iK(t.out):"catch"===t.type?iK(t.innerType):e._zod.optin}let iY=(e,t,r,i)=>{let n=e._zod.def,o=n.shape;if(Object.getOwnPropertySymbols(o).length&&ip(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;for(let e in r.type="object",r.properties={},o)es(r.properties,e,im(o[e],t,{...i,path:[...i.path,"properties",e]}));let a=[];for(let e of Object.keys(o)){let r=n.shape[e];("input"===t.io?void 0===iK(r):void 0===r._zod.optout)&&a.push(e)}a.length>0&&(r.required=a),n.catchall?._zod.def.type==="never"?r.additionalProperties=!1:n.catchall?n.catchall&&(r.additionalProperties=im(n.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)},iX=(e,t,r,i)=>{let n=e._zod.def,o=!1===n.inclusive,a=n.options.map((e,r)=>im(e,t,{...i,path:[...i.path,o?"oneOf":"anyOf",r]}));o?r.oneOf=a:r.anyOf=a},iQ=(e,t,r,i)=>{let n=e._zod.def,o=im(n.left,t,{...i,path:[...i.path,"allOf",0]}),a=im(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length,l=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=l,t.intersections.push(l)},i0=new WeakMap,i1=(e,t,r,i)=>{let n=e._zod.def;r.type="object";let o=n.keyType,a=ij(o).patterns;if("loose"===n.mode&&a&&a.size>0){let e=im(n.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});for(let t of(r.patternProperties={},a))es(r.patternProperties,iL(t).source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){r.propertyNames=im(n.keyType,t,{...i,path:[...i.path,"propertyNames"]});let o=i0.get(t);o||(o=[],i0.set(t,o),t.deferred.push(()=>(function(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let r=new Map;for(let i of i0.get(e)??[]){let n=e.seen.get(i),o=(n?.def??n?.schema)?.propertyNames;if(!o||!0===o||r.has(o))continue;let a=function e(t,r,i){if(r.$ref){if(i.has(r))return r;i.add(r);let n=t.get(r)?.def;if(!n)return r;let o=e(t,n,i);return o===n?r:o}for(let n of["anyOf","oneOf"]){let o=r[n];if(!Array.isArray(o))continue;let a=o.map(r=>e(t,r,i));a.some((e,t)=>e!==o[t])&&(r={...r,[n]:a})}let n=Array.isArray(r.type)?r.type:[r.type],o=!n.includes("string")&&n.some(e=>"number"===e||"integer"===e),a=r.enum??(void 0!==r.const?[r.const]:void 0);if(!o&&!a?.some(e=>"number"==typeof e))return r;let{minimum:s,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:p,id:m,...h}=r;return h.enum?h.enum=h.enum.map(e=>"number"==typeof e?String(e):e):"number"==typeof h.const&&(h.const=String(h.const)),o&&(h.type="string",a||(h.pattern=(n.includes("number")?ty:tg).source)),h}(t,o,new Set);a!==o&&r.set(o,a)}if(r.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&r.get(e.propertyNames);t&&(e.propertyNames=t)}})(t))),o.push(e)}r.additionalProperties=im(n.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let s=o._zod.values,l="input"===t.io&&void 0!==iK(n.valueType);if(s&&!n.partial&&!l){let e=[...s].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(r.required=e.map(String))}},i2=(e,t,r,i)=>{let n=e._zod.def,o=im(n.innerType,t,i),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},i9=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},i4=Symbol();function i5(e,t,r,i,n){let o=!1,a=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(o=!0,null));return o?(ip(t,r,i,n,"BigInt defaults cannot be represented in JSON Schema"),i4):JSON.parse(a)}let i3=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType;let o=i5(n.defaultValue,e,t,r,i);o!==i4&&(r.default=o)},i6=(e,t,r,i)=>{let n=e._zod.def;if(im(n.innerType,t,i),t.seen.get(e).ref=n.innerType,"input"!==t.io)return;let o=i5(n.defaultValue,e,t,r,i);o!==i4&&(r._prefault=o)},i7=(e,t,r,i)=>{let n,o=e._zod.def;im(o.innerType,t,i),t.seen.get(e).ref=o.innerType;try{n=o.catchValue(void 0)}catch{ip(e,t,r,i,"Dynamic catch values are not supported in JSON Schema");return}r.default=n},i8=(e,t,r,i)=>{let n=e._zod.def,o=n.in._zod.traits.has("$ZodTransform"),a="input"===t.io?o?n.out:n.in:n.out;im(a,t,i),t.seen.get(e).ref=a},ne=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType,r.readOnly=!0},nt=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},nr=(e,t,r,i)=>{let n=e._zod.innerType;im(n,t,i),t.seen.get(e).ref=n},ni={string:iN,number:iM,boolean:iZ,bigint:(e,t,r,i)=>{ip(e,t,r,i,"BigInt cannot be represented in JSON Schema")},symbol:(e,t,r,i)=>{ip(e,t,r,i,"Symbols cannot be represented in JSON Schema")},null:iU,undefined:(e,t,r,i)=>{ip(e,t,r,i,"Undefined cannot be represented in JSON Schema")},void:(e,t,r,i)=>{ip(e,t,r,i,"Void cannot be represented in JSON Schema")},never:iF,any:iH,unknown:iD,date:(e,t,r,i)=>{ip(e,t,r,i,"Date cannot be represented in JSON Schema")},enum:iV,literal:iJ,nan:(e,t,r,i)=>{ip(e,t,r,i,"NaN cannot be represented in JSON Schema")},template_literal:(e,t,r,i)=>{let n=e._zod.pattern;if(!n)throw Error("Pattern not found in template literal");r.type="string",r.pattern=n.source},file:(e,t,r,i)=>{r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:n,maximum:o,mime:a}=ij(e);void 0!==n&&(r.minLength=n),void 0!==o&&(r.maxLength=o),a&&(0===a.length?r.not={}:1===a.length?r.contentMediaType=a[0]:r.anyOf=a.map(e=>({contentMediaType:e})))},success:(e,t,r,i)=>{r.type="boolean"},custom:iB,function:(e,t,r,i)=>{ip(e,t,r,i,"Function types cannot be represented in JSON Schema")},transform:iW,map:(e,t,r,i)=>{ip(e,t,r,i,"Map cannot be represented in JSON Schema")},set:(e,t,r,i)=>{ip(e,t,r,i,"Set cannot be represented in JSON Schema")},array:iG,object:iY,union:iX,intersection:iQ,tuple:(e,t,r,i)=>{let n=e._zod.def;r.type="array";let o="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",s=n.items.map((e,r)=>im(e,t,{...i,path:[...i.path,o,r]})),l=n.rest?im(n.rest,t,{...i,path:[...i.path,a,..."openapi-3.0"===t.target?[n.items.length]:[]]}):null,c=n.items.length;for(;c>0;){let e=n.items[c-1];if(!("input"===t.io?void 0!==iK(e):"optional"===e._zod.optout))break;c--}let u=n.items.length,d=!n.rest;"draft-2020-12"===t.target?(r.prefixItems=s,d?r.items=!1:l&&(r.items=l)):"openapi-3.0"===t.target?(r.items={anyOf:s},l&&r.items.anyOf.push(l)):(r.items=s,d?r.additionalItems=!1:l&&(r.additionalItems=l)),c>0&&(r.minItems=c),d&&(r.maxItems=u);let{minimum:p,maximum:m}=ij(e);"number"==typeof p&&(r.minItems=p),"number"==typeof m&&(r.maxItems=m)},record:i1,nullable:i2,nonoptional:i9,default:i3,prefault:i6,catch:i7,pipe:i8,readonly:ne,promise:(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},optional:nt,lazy:nr};function nn(e,t){if("_idmap"in e){let r=id({...t,processors:ni}),i={};for(let t of e._idmap.entries()){let[e,i]=t;im(i,r)}let n={};for(let o of(r.external={registry:e,uri:t?.uri,defs:i},e._idmap.entries())){let[e,t]=o;ig(r,t),es(n,e,iS(r,t))}return Object.keys(i).length>0&&(n.__shared={["draft-2020-12"===r.target?"$defs":"definitions"]:i}),{schemas:n}}let r=id({...t,processors:ni});return im(e,r),ig(r,e),iS(r,e)}let no={get:function(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,er,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},na={value:void 0,enumerable:!1},ns=new WeakSet([Object.prototype,Error.prototype]),nl=(e,t)=>{e.name="$ZodError",na.value=t,Object.defineProperty(e,"issues",na),na.value=void 0,Object.defineProperty(e,"message",no);let r=Object.getPrototypeOf(e);ns.has(r)||(ns.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},nc=eB("$ZodError",nl);function nu(e,t){return{callee:t?.callee??e,Err:t?.Err}}eB("$ZodError",nl,void 0,{Parent:Error});let nd=e=>{let t=(r,i,n,o)=>{let a=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise)throw new eW;if(s.issues.length){let r=new(o?.Err??e)(s.issues.map(e=>ej(e,a,eY())));throw eh(r,o?.callee??t),r}return s.value};return t},np=e=>{let t=async(r,i,n,o)=>{let a=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let r=new(o?.Err??e)(s.issues.map(e=>ej(e,a,eY())));throw eh(r,o?.callee??t),r}return s.value};return t},nm=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},n);if(o instanceof Promise)throw new eW;return o.issues.length?nh(e,o.issues,n):{success:!0,data:o.value}};function nh(e,t,r){let i;return{success:!1,get error(){return i||(i=new e(t.map(e=>ej(e,r,eY()))),t=void 0,r=void 0),i},set error(e){i=e,t=void 0,r=void 0}}}let nf=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length?nh(e,o.issues,n):{success:!0,data:o.value}},ng=Symbol.for("zod.compile.invalid"),ny=Symbol.for("zod.compile.fallback"),nv=new WeakSet([Object.prototype,Error.prototype]);function n_(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=r(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let nb=eB("ZodError",(e,t)=>{nc.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);nv.has(r)||(nv.add(r),n_(r,"format",e=>t=>(function(e,t=e=>e.message){let r={_errors:[]},i=(e,n=[])=>{for(let o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>i({issues:e},[...n,...o.path]));else if("invalid_key"===o.code)i({issues:o.issues},[...n,...o.path]);else if("invalid_element"===o.code)i({issues:o.issues},[...n,...o.path]);else{let e=[...n,...o.path];if(0===e.length)r._errors.push(t(o));else{let i=r,n=0;for(;n<e.length;){let r=e[n],a=n===e.length-1;if("_errors"===r){a&&i._errors.push(t(o)),n++;continue}Object.prototype.hasOwnProperty.call(i,r)||Object.defineProperty(i,r,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=i[r];a&&s._errors.push(t(o)),i=s,n++}}}};return i(e),r})(e,t)),n_(r,"flatten",e=>t=>(function(e,t=e=>e.message){let r={},i=[];for(let a of e.issues)if(a.path.length>0){var n,o;(n=a.path[0],o=()=>[],!Object.prototype.hasOwnProperty.call(r,n)&&("__proto__"===n?Object.defineProperty(r,n,{value:o(),writable:!0,enumerable:!0,configurable:!0}):r[n]=o()),r[n]).push(t(a))}else i.push(t(a));return{formErrors:i,fieldErrors:r}})(e,t)),n_(r,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,er,2)}),n_(r,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,er,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),nS=nd(nb),nw=np(nb),nR=nm(nb),nk=nf(nb),nx=(m=nd(nb),h=(e,t,r,i)=>m(e,t,r?{...r,direction:"backward"}:{direction:"backward"},nu(h,i))),nC=(f=nd(nb),g=(e,t,r,i)=>f(e,t,r,nu(g,i))),n$=(y=np(nb),v=async(e,t,r,i)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return await y(e,t,n,nu(v,i))}),nT=(_=np(nb),b=async(e,t,r,i)=>await _(e,t,r,nu(b,i))),nP=(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return nm(nb)(e,t,i)},nE=(e,t,r)=>nm(nb)(e,t,r),nO=async(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return nf(nb)(e,t,i)},nI=async(e,t,r)=>nf(nb)(e,t,r);function nq(){eK.memoizer||eY({memoizer:e5})}let nj=eB("ZodType",(e,t)=>(eK.localeError||eY({localeError:(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}},t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return r=>{switch(r.code){case"invalid_type":{let e=i(r.expected),t=i(function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t}(r.input),r.input);return`Invalid input: expected ${e}, received ${t}`}case"invalid_value":if(1===r.values.length)return`Invalid input: expected ${eR(r.values[0])}`;return`Invalid option: expected one of ${et(r.values,"|")}`;case"too_big":{let t=r.exact?"exactly ":r.inclusive?"<=":"<",i=e[r.origin]??null;if(i)return`Too big: expected ${r.origin??"value"} to have ${t}${r.maximum.toString()} ${i.unit??"elements"}`;return`Too big: expected ${r.origin??"value"} to be ${t}${r.maximum.toString()}`}case"too_small":{let t=r.exact?"exactly ":r.inclusive?">=":">",i=e[r.origin]??null;if(i)return`Too small: expected ${r.origin} to have ${t}${r.minimum.toString()} ${i.unit}`;return`Too small: expected ${r.origin} to be ${t}${r.minimum.toString()}`}case"invalid_format":if("starts_with"===r.format)return`Invalid string: must start with "${r.prefix}"`;if("ends_with"===r.format)return`Invalid string: must end with "${r.suffix}"`;if("includes"===r.format)return`Invalid string: must include "${r.includes}"`;if("regex"===r.format)return`Invalid string: must match pattern ${r.pattern}`;return`Invalid ${t[r.format]??r.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${et(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":if(r.options&&Array.isArray(r.options)&&r.options.length>0){let e=r.options.map(e=>`'${e}'`).join(" | ");return`Invalid discriminator value. Expected ${e}`}if(!1===r.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}})()}),tF.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(em(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eS(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return new oD({type:"custom",check:"custom",fn:e,...ew(t)})}(e,t))},superRefine(e,t){return this.check(function(e,t){var r;let i,n;return r=t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(eN(e,t.value,i._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),"input"in e||(e.input=t.value),e.inst??(e.inst=i),e.continue??(e.continue=!i._zod.def.abort),t.issues.push(eN(e)))},e(t.value,t)),(n=new tw({check:"custom",...ew(t)}))._zod.check=r,i=n}(e,t))},overwrite(e){return this.check(ic(e))},optional(){return oE(this)},exactOptional(){var e;return e=this,new oO({type:"optional",innerType:e})},nullable(){return oq(this)},nullish(){return oE(oq(this))},nonoptional(e){var t;return t=this,new oz({type:"nonoptional",innerType:t,...ew(e)})},array(){return od(this)},or(e){return og([this,e])},and(e){return ob(this,e)},transform(e){return oM(this,oT(e))},default(e){var t,r;return t=this,r=e,new oj({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():ev(r)}})},prefault(e){var t,r;return t=this,r=e,new oA({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():ev(r)}})},catch(e){return function(e,t){let r;return new oL({type:"catch",innerType:e,catchValue:"function"==typeof t?t:((r=()=>t)["~constantCatch"]=!0,r)})}(this,e)},pipe(e){return oM(this,e)},readonly(){var e;return e=this,new oU({type:"readonly",innerType:e})},describe(e){let t=this.clone();return r4.add(t,{description:e}),t},meta(...e){if(0===e.length)return r4.get(this);let t=this.clone();return r4.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return eM(this,"~standard",{...tD(this),jsonSchema:{input:iw(this,"input"),output:iw(this,"output")}},!1)},set"~standard"(e){eM(this,"~standard",e)},parse:function e(t,r){return nS(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await nw(this,t,r,{callee:e})},safeParse(e,t){return nR(this,e,t)},async safeParseAsync(e,t){return nk(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){eM(this,"spa",e)},validate(e,t){let r=this._zod.bag.validator;if(void 0!==r){if(r(e)!==ng)return!0;if(!0===r.definite&&void 0===t)return!1}return function(e,t,r){let i,n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;if(o?(n[ny]=!0,i=o({value:t,issues:[]},n)):i=e._zod.run({value:t,issues:[]},n),i instanceof Promise)throw new eW;return 0===i.issues.length}(this,e,t)},validateAsync(e,t){return(async(e,t,r)=>{let i=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},i);return n instanceof Promise&&(n=await n),0===n.issues.length})(this,e,t)},encode:function e(t,r){return nx(this,t,r,{callee:e})},decode:function e(t,r){return nC(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await n$(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await nT(this,t,r,{callee:e})},safeEncode(e,t){return nP(this,e,t)},safeDecode(e,t){return nE(this,e,t)},async safeEncodeAsync(e,t){return nO(this,e,t)},async safeDecodeAsync(e,t){return nI(this,e,t)},toJSONSchema(e){return((e,t={})=>r=>{let i=id({...r,processors:t});return im(e,i),ig(i,e),iS(i,e)})(this,{})(e)},get description(){return r4.get(this)?.description},get _def(){return this._zod.def}}),nA=eB("_ZodString",(e,t)=>{tV.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iN(e,t,r,i)},eZ({format:e=>ij(e).format??null,minLength:e=>ij(e).minimum??null,maxLength:e=>ij(e).maximum??null},{regex(...e){return this.check(function(e,t){return new tq({check:"string_format",format:"regex",...ew(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new tz({check:"string_format",format:"includes",...ew(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new tL({check:"string_format",format:"starts_with",...ew(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new tN({check:"string_format",format:"ends_with",...ew(t),suffix:e})}(...e))},min(...e){return this.check(is(...e))},max(...e){return this.check(ia(...e))},length(...e){return this.check(il(...e))},nonempty(...e){return this.check(is(1,...e))},lowercase(e){return this.check(new tj({check:"string_format",format:"lowercase",...ew(e)}))},uppercase(e){return this.check(new tA({check:"string_format",format:"uppercase",...ew(e)}))},trim(){return this.check(ic(e=>e.trim()))},normalize(...e){return this.check(function(e){return ic(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(ic(e=>e.toLowerCase()))},toUpperCase(){return this.check(ic(e=>e.toUpperCase()))},slugify(){return this.check(ic(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})),nz=eB("ZodString",(e,t)=>{tV.init(e,t),nA.init(e,t)},{email(e){return this.check(r3(nH,e))},url(e){return this.check(r6(nJ,e))},jwt(e){return this.check(new n6({type:"string",format:"jwt",check:"string_format",abort:!1,...ew(e)}))},emoji(e){return this.check(new nB({type:"string",format:"emoji",check:"string_format",abort:!1,...ew(e)}))},guid(e){return this.check(new nD({type:"string",format:"guid",check:"string_format",abort:!1,...ew(e)}))},uuid(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,...ew(e)}))},uuidv4(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ew(e)}))},uuidv6(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ew(e)}))},uuidv7(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ew(e)}))},nanoid(e){return this.check(new nW({type:"string",format:"nanoid",check:"string_format",abort:!1,...ew(e)}))},cuid(e){return this.check(new nG({type:"string",format:"cuid",check:"string_format",abort:!1,...ew(e)}))},cuid2(e){return this.check(new nK({type:"string",format:"cuid2",check:"string_format",abort:!1,...ew(e)}))},ulid(e){return this.check(new nY({type:"string",format:"ulid",check:"string_format",abort:!1,...ew(e)}))},base64(e){return this.check(new n4({type:"string",format:"base64",check:"string_format",abort:!1,...ew(e)}))},base64url(e){return this.check(new n5({type:"string",format:"base64url",check:"string_format",abort:!1,...ew(e)}))},xid(e){return this.check(new nX({type:"string",format:"xid",check:"string_format",abort:!1,...ew(e)}))},ksuid(e){return this.check(new nQ({type:"string",format:"ksuid",check:"string_format",abort:!1,...ew(e)}))},ipv4(e){return this.check(new n0({type:"string",format:"ipv4",check:"string_format",abort:!1,...ew(e)}))},ipv6(e){return this.check(new n1({type:"string",format:"ipv6",check:"string_format",abort:!1,...ew(e)}))},cidrv4(e){return this.check(new n2({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ew(e)}))},cidrv6(e){return this.check(new n9({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ew(e)}))},e164(e){return this.check(new n3({type:"string",format:"e164",check:"string_format",abort:!1,...ew(e)}))},datetime(e){return this.check(r7(nM,e))},date(e){return this.check(r8(nZ,e))},time(e){return this.check(new nU({type:"string",format:"time",check:"string_format",precision:null,...ew(e)}))},duration(e){return this.check(new nF({type:"string",format:"duration",check:"string_format",...ew(e)}))}});function nL(e){return new nz(r5({type:"string",...ew(e)}))}let nN=eB("ZodStringFormat",(e,t)=>{tJ.init(e,t),nA.init(e,t)}),nM=eB("ZodISODateTime",(e,t)=>{t6.init(e,t),nN.init(e,t)}),nZ=eB("ZodISODate",(e,t)=>{t7.init(e,t),nN.init(e,t)}),nU=eB("ZodISOTime",(e,t)=>{t8.init(e,t),nN.init(e,t)}),nF=eB("ZodISODuration",(e,t)=>{re.init(e,t),nN.init(e,t)}),nH=eB("ZodEmail",(e,t)=>{tG.init(e,t),nN.init(e,t)}),nD=eB("ZodGUID",(e,t)=>{tB.init(e,t),nN.init(e,t)}),nV=eB("ZodUUID",(e,t)=>{tW.init(e,t),nN.init(e,t)}),nJ=eB("ZodURL",(e,t)=>{tQ.init(e,t),nN.init(e,t)}),nB=eB("ZodEmoji",(e,t)=>{t0.init(e,t),nN.init(e,t)}),nW=eB("ZodNanoID",(e,t)=>{t1.init(e,t),nN.init(e,t)}),nG=eB("ZodCUID",(e,t)=>{t2.init(e,t),nN.init(e,t)}),nK=eB("ZodCUID2",(e,t)=>{t9.init(e,t),nN.init(e,t)}),nY=eB("ZodULID",(e,t)=>{t4.init(e,t),nN.init(e,t)}),nX=eB("ZodXID",(e,t)=>{t5.init(e,t),nN.init(e,t)}),nQ=eB("ZodKSUID",(e,t)=>{t3.init(e,t),nN.init(e,t)}),n0=eB("ZodIPv4",(e,t)=>{rt.init(e,t),nN.init(e,t)}),n1=eB("ZodIPv6",(e,t)=>{rn.init(e,t),nN.init(e,t)}),n2=eB("ZodCIDRv4",(e,t)=>{ro.init(e,t),nN.init(e,t)}),n9=eB("ZodCIDRv6",(e,t)=>{ra.init(e,t),nN.init(e,t)}),n4=eB("ZodBase64",(e,t)=>{rc.init(e,t),nN.init(e,t)}),n5=eB("ZodBase64URL",(e,t)=>{rd.init(e,t),nN.init(e,t)}),n3=eB("ZodE164",(e,t)=>{rp.init(e,t),nN.init(e,t)}),n6=eB("ZodJWT",(e,t)=>{rm.init(e,t),nN.init(e,t)}),n7=eB("ZodNumber",(e,t)=>{rh.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iM(e,t,r,i),e.isFinite=!0},eZ({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ij(e);return Math.max(t??-1/0,r??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ij(e);return Math.min(t??1/0,r??1/0)},isInt:e=>{let{isInt:t,multipleOf:r}=ij(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ij(e).format??null},{gt(e,t){return this.check(ir(e,t))},gte(e,t){return this.check(ii(e,t))},min(e,t){return this.check(ii(e,t))},lt(e,t){return this.check(ie(e,t))},lte(e,t){return this.check(it(e,t))},max(e,t){return this.check(it(e,t))},int(e){return this.check(ot(e))},safe(e){return this.check(ot(e))},positive(e){return this.check(ir(0,e))},nonnegative(e){return this.check(ii(0,e))},negative(e){return this.check(ie(0,e))},nonpositive(e){return this.check(it(0,e))},multipleOf(e,t){return this.check(io(e,t))},step(e,t){return this.check(io(e,t))},finite(){return this}}));function n8(e){return new n7(r5({type:"number",checks:[],...ew(e)}))}let oe=eB("ZodNumberFormat",(e,t)=>{rf.init(e,t),n7.init(e,t)});function ot(e){return new oe({type:"number",check:"number_format",abort:!1,format:"safeint",...ew(e)})}let or=eB("ZodBoolean",(e,t)=>{rg.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iZ(e,t,r,i)});function oi(e){return new or({type:"boolean",...ew(e)})}let on=eB("ZodNull",(e,t)=>{ry.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iU(e,t,r,i)});function oo(e){return new on({type:"null",...ew(e)})}let oa=eB("ZodAny",(e,t)=>{rv.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iH(e,t,r,i)}),os=eB("ZodUnknown",(e,t)=>{r_.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iD(e,t,r,i)});function ol(){return new os({type:"unknown"})}let oc=eB("ZodNever",(e,t)=>{rb.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iF(e,t,r,i)}),ou=eB("ZodArray",(e,t)=>{nq(),rR.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iG(e,t,r,i),e.element=t.element},{min(e,t){return this.check(is(e,t))},nonempty(e){return this.check(is(1,e))},max(e,t){return this.check(ia(e,t))},length(e,t){return this.check(il(e,t))},unwrap(){return this.element}});function od(e,t){return new ou({type:"array",element:e,...ew(t)})}let op=eB("ZodObject",(e,t)=>{var r;let i,n;nq(),rP.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iY(e,t,r,i),r="shape",(n=r in(i=Object.getPrototypeOf(e))?void 0:i)&&Object.defineProperty(n,r,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:!1,value:void 0};return Object.defineProperty(this,r,e),e.value=(e=>e._zod.def.shape)(this),Object.defineProperty(this,r,e),e.value},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,enumerable:!1,value:e})}})},{keyof(){return ok(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(em(this._zod.def,{catchall:e}))},passthrough(){return this.clone(em(this._zod.def,{catchall:ol()}))},loose(){return this.clone(em(this._zod.def,{catchall:ol()}))},strict(){return this.clone(em(this._zod.def,{catchall:new oc({type:"never",...ew(void 0)})}))},strip(){return this.clone(em(this._zod.def,{catchall:void 0}))},extend(e){if(!ey(e))throw Error("Invalid input to extend: expected a plain object");let t=this._zod.def.checks;if(t&&t.length>0){let t=ec(this);for(let r of Reflect.ownKeys(e))if(void 0!==Object.getOwnPropertyDescriptor(t,r))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eS(this,em(this._zod.def,{shape:e$(this,e)}))},safeExtend(e){if(!ey(e))throw Error("Invalid input to safeExtend: expected a plain object");return eS(this,em(this._zod.def,{shape:e$(this,e)}))},merge(e){if(!e?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(this._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t={};return ep(t,this,Reflect.ownKeys(ec(this))),ep(t,e,Reflect.ownKeys(ec(e))),eS(this,em(this._zod.def,{shape:t,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]}))},pick(e){return function(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let n={};return ep(n,e,eC(e,t)),eS(e,em(r,{shape:n,checks:[]}))}(this,e)},omit(e){return function(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let n=new Set(eC(e,t)),o={};return ep(o,e,Reflect.ownKeys(ec(e)).filter(e=>!n.has(e))),eS(e,em(r,{shape:o,checks:[]}))}(this,e)},partial(...e){return eT(oP,this,e[0])},exactPartial(...e){return eT(oO,this,e[0],"exactPartial")},required(...e){var t;let r,i;return r=(t=e[0])?new Set(eC(this,t)):void 0,ep(i={},this,Reflect.ownKeys(ec(this)),(e,t)=>r&&!r.has(t)?e:new oz({type:"nonoptional",innerType:e})),eS(this,em(this._zod.def,{shape:i}))}});function om(e,t){return new op({type:"object",shape:e??{},...ew(t)})}function oh(e,t){return new op({type:"object",shape:e,catchall:ol(),...ew(t)})}let of=eB("ZodUnion",(e,t)=>{rO.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iX(e,t,r,i),e.options=t.options});function og(e,t){return new of({type:"union",options:e,...ew(t)})}let oy=eB("ZodDiscriminatedUnion",(e,t)=>{of.init(e,t),rI.init(e,t)});function ov(e,t,r){return new oy({type:"union",options:t,discriminator:e,...ew(r)})}let o_=eB("ZodIntersection",(e,t)=>{rq.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iQ(e,t,r,i)});function ob(e,t){return new o_({type:"intersection",left:e,right:t})}let oS=eB("ZodRecord",(e,t)=>{nq(),rA.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i1(e,t,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function ow(e,t,r){return new oS(t&&t._zod?{type:"record",keyType:e,valueType:t,...ew(r)}:{type:"record",keyType:nL(),valueType:e,...ew(t)})}let oR=eB("ZodEnum",(e,t)=>{rz.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iV(e,t,r,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(e,i)=>{let n={};for(let i of e)if(r.has(i))n[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new oR({...t,checks:[],...ew(i),entries:n})},e.exclude=(e,i)=>{let n={...t.entries};for(let t of e)if(r.has(t))delete n[t];else throw Error(`Key ${t} not found in enum`);return new oR({...t,checks:[],...ew(i),entries:n})}});function ok(e,t){return new oR({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ew(t)})}let ox=eB("ZodLiteral",(e,t)=>{rL.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iJ(e,t,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function oC(e,t){return new ox({type:"literal",values:Array.isArray(e)?e:[e],...ew(t)})}let o$=eB("ZodTransform",(e,t)=>{nq(),rN.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iW(e,t,r,i),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new eG(e.constructor.name);r.addIssue=i=>{"string"==typeof i?r.issues.push(eN(i,r.value,t)):(i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(eN(i)))};let n=t.transform(r.value,r);return n instanceof Promise?n.then(e=>(r.value=e,r)):(r.value=n,r)}});function oT(e){return new o$({type:"transform",transform:e})}let oP=eB("ZodOptional",(e,t)=>{rZ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nt(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function oE(e){return new oP({type:"optional",innerType:e})}let oO=eB("ZodExactOptional",(e,t)=>{rU.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nt(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oI=eB("ZodNullable",(e,t)=>{rF.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i2(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function oq(e){return new oI({type:"nullable",innerType:e})}let oj=eB("ZodDefault",(e,t)=>{rH.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i3(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),oA=eB("ZodPrefault",(e,t)=>{rV.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i6(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oz=eB("ZodNonOptional",(e,t)=>{rJ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i9(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oL=eB("ZodCatch",(e,t)=>{rG.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i7(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),oN=eB("ZodPipe",(e,t)=>{rK.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i8(e,t,r,i),e.in=t.in,e.out=t.out});function oM(e,t){return new oN({type:"pipe",in:e,out:t})}let oZ=eB("ZodPreprocess",(e,t)=>{oN.init(e,t),rX.init(e,t)}),oU=eB("ZodReadonly",(e,t)=>{rQ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>ne(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oF=eB("ZodLazy",(e,t)=>{r1.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nr(e,t,r,i),e.unwrap=()=>e._zod.def.getter()});function oH(e){return new oF({type:"lazy",getter:e})}let oD=eB("ZodCustom",(e,t)=>{r2.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iB(e,t,r,i)});function oV(e,t){return new oZ({type:"pipe",in:oT(e),out:t})}let oJ="2025-11-25",oB=[oJ,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],oW="io.modelcontextprotocol/protocolVersion",oG="io.modelcontextprotocol/clientInfo",oK="io.modelcontextprotocol/serverInfo",oY="io.modelcontextprotocol/clientCapabilities",oX="io.modelcontextprotocol/subscriptionId",oQ="io.modelcontextprotocol/logLevel",o0=oH(()=>og([nL(),n8(),oi(),oo(),ow(nL(),o0),od(o0)])),o1=ow(nL(),o0),o2=od(o0),o9=og([nL(),n8().int()]),o4=nL(),o5=om({ttl:n8().optional()}),o3=om({taskId:nL()}),o6=oh({progressToken:o9.optional(),"io.modelcontextprotocol/related-task":o3.optional()}),o7=om({_meta:o6.optional()}),o8=o7.extend({task:o5.optional()}),ae=om({method:nL(),params:o7.loose().optional()}),at=om({_meta:o6.optional()}),ar=om({method:nL(),params:at.loose().optional()}),ai=oh({get[oK](){return av.optional().catch(void 0)}}),an=oh({_meta:ai.optional()}),ao=og([nL(),n8().int()]),aa=om({jsonrpc:oC("2.0"),id:ao,...ae.shape}).strict(),as=om({jsonrpc:oC("2.0"),...ar.shape}).strict(),al=om({jsonrpc:oC("2.0"),id:ao,result:an}).strict(),ac=om({jsonrpc:oC("2.0"),id:ao.optional(),error:om({code:n8().int(),message:nL(),data:ol().optional()})}).strict(),au=og([aa,as,al,ac]),ad=og([al,ac]),ap=an.strict(),am=at.extend({requestId:ao.optional(),reason:nL().optional()}),ah=ar.extend({method:oC("notifications/cancelled"),params:am}),af=om({src:nL(),mimeType:nL().optional(),sizes:od(nL()).optional(),theme:ok(["light","dark"]).optional()}),ag=om({icons:od(af).optional()}),ay=om({name:nL(),title:nL().optional()}),av=ay.extend({...ay.shape,...ag.shape,version:nL(),websiteUrl:nL().optional(),description:nL().optional()}),a_=ob(om({applyDefaults:oi().optional()}),o1),ab=oV(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ob(om({form:a_.optional(),url:o1.optional()}),o1.optional())),aS=oh({list:o1.optional(),cancel:o1.optional(),requests:oh({sampling:oh({createMessage:o1.optional()}).optional(),elicitation:oh({create:o1.optional()}).optional()}).optional()}),aw=oh({list:o1.optional(),cancel:o1.optional(),requests:oh({tools:oh({call:o1.optional()}).optional()}).optional()}),aR=om({experimental:ow(nL(),o1).optional(),sampling:om({context:o1.optional(),tools:o1.optional()}).optional(),elicitation:ab.optional(),roots:om({listChanged:oi().optional()}).optional(),tasks:aS.optional(),extensions:ow(nL(),o1).optional()}),ak=o7.extend({protocolVersion:nL(),capabilities:aR,clientInfo:av}),ax=ae.extend({method:oC("initialize"),params:ak}),aC=om({experimental:ow(nL(),o1).optional(),logging:o1.optional(),completions:o1.optional(),prompts:om({listChanged:oi().optional()}).optional(),resources:om({subscribe:oi().optional(),listChanged:oi().optional()}).optional(),tools:om({listChanged:oi().optional()}).optional(),tasks:aw.optional(),extensions:ow(nL(),o1).optional()}),a$=an.extend({protocolVersion:nL(),capabilities:aC,serverInfo:av,instructions:nL().optional()}),aT=ar.extend({method:oC("notifications/initialized"),params:at.optional()}),aP=ae.extend({method:oC("server/discover"),params:o7.optional()}),aE=an.extend({supportedVersions:od(nL()),capabilities:aC,instructions:nL().optional()}),aO=ae.extend({method:oC("ping"),params:o7.optional()}),aI=om({progress:n8(),total:oE(n8()),message:oE(nL())}),aq=om({...at.shape,...aI.shape,progressToken:o9}),aj=ar.extend({method:oC("notifications/progress"),params:aq}),aA=o7.extend({cursor:o4.optional()}),az=ae.extend({params:aA.optional()}),aL=an.extend({nextCursor:o4.optional()}),aN=om({uri:nL(),mimeType:oE(nL()),_meta:ow(nL(),ol()).optional()}),aM=aN.extend({text:nL()}),aZ=nL().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),aU=aN.extend({blob:aZ}),aF=ok(["user","assistant"]),aH=om({audience:od(aF).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nM,{offset:!0}).optional()}),aD=om({...ay.shape,...ag.shape,uri:nL(),description:oE(nL()),mimeType:oE(nL()),size:oE(n8()),annotations:aH.optional(),_meta:oE(oh({}))}),aV=om({...ay.shape,...ag.shape,uriTemplate:nL(),description:oE(nL()),mimeType:oE(nL()),annotations:aH.optional(),_meta:oE(oh({}))}),aJ=az.extend({method:oC("resources/list")}),aB=aL.extend({resources:od(aD)}),aW=az.extend({method:oC("resources/templates/list")}),aG=aL.extend({resourceTemplates:od(aV)}),aK=o7.extend({uri:nL()}),aY=ae.extend({method:oC("resources/read"),params:aK}),aX=an.extend({contents:od(og([aM,aU]))}),aQ=ar.extend({method:oC("notifications/resources/list_changed"),params:at.optional()}),a0=ae.extend({method:oC("resources/subscribe"),params:aK}),a1=ae.extend({method:oC("resources/unsubscribe"),params:aK}),a2=om({toolsListChanged:oi().optional(),promptsListChanged:oi().optional(),resourcesListChanged:oi().optional(),resourceSubscriptions:od(nL()).optional()}),a9=o7.extend({notifications:a2}),a4=ae.extend({method:oC("subscriptions/listen"),params:a9}),a5=at.extend({notifications:a2}),a3=ar.extend({method:oC("notifications/subscriptions/acknowledged"),params:a5}),a6=ai.extend({[oX]:ao}),a7=an.extend({_meta:a6}),a8=at.extend({uri:nL()}),se=ar.extend({method:oC("notifications/resources/updated"),params:a8}),st=om({name:nL(),description:oE(nL()),required:oE(oi())}),sr=om({...ay.shape,...ag.shape,description:oE(nL()),arguments:oE(od(st)),_meta:oE(oh({}))}),si=az.extend({method:oC("prompts/list")}),sn=aL.extend({prompts:od(sr)}),so=o7.extend({name:nL(),arguments:ow(nL(),nL()).optional()}),sa=ae.extend({method:oC("prompts/get"),params:so}),ss=om({type:oC("text"),text:nL(),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),sl=om({type:oC("image"),data:aZ,mimeType:nL(),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),sc=om({type:oC("audio"),data:aZ,mimeType:nL(),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),su=om({type:oC("tool_use"),name:nL(),id:nL(),input:ow(nL(),ol()),_meta:ow(nL(),ol()).optional()}),sd=om({type:oC("resource"),resource:og([aM,aU]),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),sp=aD.extend({type:oC("resource_link")}),sm=og([ss,sl,sc,sp,sd]),sh=om({role:aF,content:sm}),sf=an.extend({description:nL().optional(),messages:od(sh)}),sg=ar.extend({method:oC("notifications/prompts/list_changed"),params:at.optional()}),sy=om({title:nL().optional(),readOnlyHint:oi().optional(),destructiveHint:oi().optional(),idempotentHint:oi().optional(),openWorldHint:oi().optional()}),sv=om({taskSupport:ok(["required","optional","forbidden"]).optional()}),s_=om({...ay.shape,...ag.shape,description:nL().optional(),inputSchema:om({type:oC("object"),properties:ow(nL(),o0).optional(),required:od(nL()).optional()}).catchall(ol()),outputSchema:oh({$schema:nL().optional()}).optional(),annotations:sy.optional(),execution:sv.optional(),_meta:ow(nL(),ol()).optional()}),sb=az.extend({method:oC("tools/list")}),sS=aL.extend({tools:od(s_)}),sw=an.extend({content:od(sm).default([]),structuredContent:ol().optional(),isError:oi().optional()}),sR=sw.or(an.extend({toolResult:ol()})),sk=o8.extend({name:nL(),arguments:ow(nL(),ol()).optional()}),sx=ae.extend({method:oC("tools/call"),params:sk}),sC=ar.extend({method:oC("notifications/tools/list_changed"),params:at.optional()}),s$=om({autoRefresh:oi().default(!0),debounceMs:n8().int().nonnegative().default(300)}),sT=ok(["debug","info","notice","warning","error","critical","alert","emergency"]),sP=o7.extend({level:sT}),sE=ae.extend({method:oC("logging/setLevel"),params:sP}),sO=at.extend({level:sT,logger:nL().optional(),data:ol()}),sI=ar.extend({method:oC("notifications/message"),params:sO}),sq=om({name:nL().optional()}),sj=om({hints:od(sq).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),sA=om({mode:ok(["auto","required","none"]).optional()}),sz=om({type:oC("tool_result"),toolUseId:nL().describe("The unique identifier for the corresponding tool call."),content:od(sm),structuredContent:ol().optional(),isError:oi().optional(),_meta:ow(nL(),ol()).optional()}),sL=ov("type",[ss,sl,sc]),sN=ov("type",[ss,sl,sc,su,sz]),sM=om({role:aF,content:og([sN,od(sN)]),_meta:ow(nL(),ol()).optional()}),sZ=o8.extend({messages:od(sM),modelPreferences:sj.optional(),systemPrompt:nL().optional(),includeContext:ok(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:od(nL()).optional(),metadata:o1.optional(),tools:od(s_).optional(),toolChoice:sA.optional()}),sU=ae.extend({method:oC("sampling/createMessage"),params:sZ}),sF=an.extend({model:nL(),stopReason:oE(ok(["endTurn","stopSequence","maxTokens"]).or(nL())),role:aF,content:sL}),sH=an.extend({model:nL(),stopReason:oE(ok(["endTurn","stopSequence","maxTokens","toolUse"]).or(nL())),role:aF,content:og([sN,od(sN)])}),sD=om({type:oC("boolean"),title:nL().optional(),description:nL().optional(),default:oi().optional()}),sV=om({type:oC("string"),title:nL().optional(),description:nL().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ok(["email","uri","date","date-time"]).optional(),default:nL().optional()}),sJ=om({type:ok(["number","integer"]),title:nL().optional(),description:nL().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),sB=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),default:nL().optional()}),sW=om({type:oC("string"),title:nL().optional(),description:nL().optional(),oneOf:od(om({const:nL(),title:nL()})),default:nL().optional()}),sG=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),enumNames:od(nL()).optional(),default:nL().optional()}),sK=og([sB,sW]),sY=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({type:oC("string"),enum:od(nL())}),default:od(nL()).optional()}),sX=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({anyOf:od(om({const:nL(),title:nL()}))}),default:od(nL()).optional()}),sQ=og([sY,sX]),s0=og([sG,sK,sQ]),s1=og([s0,sD,sV,sJ]),s2=o8.extend({mode:oC("form").optional(),message:nL(),requestedSchema:om({type:oC("object"),properties:ow(nL(),s1),required:od(nL()).optional()}).catchall(ol())}),s9=o8.extend({mode:oC("url"),message:nL(),elicitationId:nL(),url:nL().url()}),s4=og([s2,s9]),s5=ae.extend({method:oC("elicitation/create"),params:s4}),s3=at.extend({elicitationId:nL()}),s6=ar.extend({method:oC("notifications/elicitation/complete"),params:s3}),s7=an.extend({action:ok(["accept","decline","cancel"]),content:oV(e=>null===e?void 0:e,ow(nL(),og([nL(),n8(),oi(),od(nL())])).optional())}),s8=om({type:oC("ref/resource"),uri:nL()}),le=om({type:oC("ref/prompt"),name:nL()}),lt=o7.extend({ref:og([le,s8]),argument:om({name:nL(),value:nL()}),context:om({arguments:ow(nL(),nL()).optional()}).optional()}),lr=ae.extend({method:oC("completion/complete"),params:lt}),li=an.extend({completion:oh({values:od(nL()).max(100),total:oE(n8().int()),hasMore:oE(oi())})}),ln=om({uri:nL().startsWith("file://"),name:nL().optional(),_meta:ow(nL(),ol()).optional()}),lo=ae.extend({method:oC("roots/list"),params:o7.optional()}),la=an.extend({roots:od(ln)}),ls=ar.extend({method:oC("notifications/roots/list_changed"),params:at.optional()}),ll=oh({ttl:n8().optional(),pollInterval:n8().optional()}),lc=ok(["working","input_required","completed","failed","cancelled"]),lu=om({taskId:nL(),status:lc,ttl:og([n8(),oo()]),createdAt:nL(),lastUpdatedAt:nL(),pollInterval:oE(n8()),statusMessage:oE(nL())}),ld=an.extend({task:lu}),lp=at.merge(lu),lm=ar.extend({method:oC("notifications/tasks/status"),params:lp}),lh=ae.extend({method:oC("tasks/get"),params:o7.extend({taskId:nL()})}),lf=an.merge(lu),lg=ae.extend({method:oC("tasks/result"),params:o7.extend({taskId:nL()})}),ly=an.loose(),lv=az.extend({method:oC("tasks/list")}),l_=aL.extend({tasks:od(lu)}),lb=ae.extend({method:oC("tasks/cancel"),params:o7.extend({taskId:nL()})}),lS=an.merge(lu),lw=og([aO,ax,aP,lr,sE,sa,si,aJ,aW,aY,a0,a1,a4,sx,sb]),lR=og([ah,aj,aT,ls]),lk=og([ap,sF,sH,s7,la]),lx=og([aO,sU,s5,lo]),lC=og([ah,aj,sI,se,aQ,sC,sg,a3,s6]),l$=og([ap,a$,aE,li,sf,sn,aB,aG,aX,sw,sS,a7]);A||(A={});let lT=r6(nJ,void 0).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),eD}).refine(e=>{let t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),lP=oh({resource:nL().url(),authorization_servers:od(lT).optional(),jwks_uri:nL().url().optional(),scopes_supported:od(nL()).optional(),bearer_methods_supported:od(nL()).optional(),resource_signing_alg_values_supported:od(nL()).optional(),resource_name:nL().optional(),resource_documentation:nL().optional(),resource_policy_uri:nL().url().optional(),resource_tos_uri:nL().url().optional(),tls_client_certificate_bound_access_tokens:oi().optional(),authorization_details_types_supported:od(nL()).optional(),dpop_signing_alg_values_supported:od(nL()).optional(),dpop_bound_access_tokens_required:oi().optional()}),lE=oh({issuer:nL(),authorization_endpoint:lT,token_endpoint:lT,registration_endpoint:lT.optional(),scopes_supported:od(nL()).optional(),response_types_supported:od(nL()),response_modes_supported:od(nL()).optional(),grant_types_supported:od(nL()).optional(),token_endpoint_auth_methods_supported:od(nL()).optional(),token_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),service_documentation:lT.optional(),revocation_endpoint:lT.optional(),revocation_endpoint_auth_methods_supported:od(nL()).optional(),revocation_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),introspection_endpoint:nL().optional(),introspection_endpoint_auth_methods_supported:od(nL()).optional(),introspection_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),code_challenge_methods_supported:od(nL()).optional(),client_id_metadata_document_supported:oi().optional(),authorization_response_iss_parameter_supported:oi().optional().catch(void 0),dpop_signing_alg_values_supported:od(nL()).optional()}),lO=oh({issuer:nL(),authorization_endpoint:lT,token_endpoint:lT,userinfo_endpoint:lT.optional(),jwks_uri:lT,registration_endpoint:lT.optional(),scopes_supported:od(nL()).optional(),response_types_supported:od(nL()),response_modes_supported:od(nL()).optional(),grant_types_supported:od(nL()).optional(),acr_values_supported:od(nL()).optional(),subject_types_supported:od(nL()),id_token_signing_alg_values_supported:od(nL()),id_token_encryption_alg_values_supported:od(nL()).optional(),id_token_encryption_enc_values_supported:od(nL()).optional(),userinfo_signing_alg_values_supported:od(nL()).optional(),userinfo_encryption_alg_values_supported:od(nL()).optional(),userinfo_encryption_enc_values_supported:od(nL()).optional(),request_object_signing_alg_values_supported:od(nL()).optional(),request_object_encryption_alg_values_supported:od(nL()).optional(),request_object_encryption_enc_values_supported:od(nL()).optional(),token_endpoint_auth_methods_supported:od(nL()).optional(),token_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),display_values_supported:od(nL()).optional(),claim_types_supported:od(nL()).optional(),claims_supported:od(nL()).optional(),service_documentation:nL().optional(),claims_locales_supported:od(nL()).optional(),ui_locales_supported:od(nL()).optional(),claims_parameter_supported:oi().optional(),request_parameter_supported:oi().optional(),request_uri_parameter_supported:oi().optional(),require_request_uri_registration:oi().optional(),op_policy_uri:lT.optional(),op_tos_uri:lT.optional(),client_id_metadata_document_supported:oi().optional(),authorization_response_iss_parameter_supported:oi().optional().catch(void 0)}),lI=om({...lO.shape,...lE.pick({code_challenge_methods_supported:!0}).shape}),lq=om({access_token:nL(),id_token:nL().optional(),token_type:nL(),expires_in:new n7(r5({type:"number",coerce:!0,checks:[],...ew(void 0)})).optional(),scope:nL().optional(),refresh_token:nL().optional(),issuer:nL().optional().catch(void 0)}).strip(),lj=om({issued_token_type:oC("urn:ietf:params:oauth:token-type:id-jag"),access_token:nL(),token_type:nL().optional(),expires_in:n8().optional(),scope:nL().optional()}).strip(),lA=om({error:nL(),error_description:nL().optional(),error_uri:nL().optional()}),lz=lT.optional().or(oC("").transform(()=>void 0)),lL=om({redirect_uris:od(lT),token_endpoint_auth_method:nL().optional(),grant_types:od(nL()).optional(),response_types:od(nL()).optional(),application_type:nL().optional(),client_name:nL().optional(),client_uri:lT.optional(),logo_uri:lz,scope:nL().optional(),contacts:od(nL()).optional(),tos_uri:lz,policy_uri:nL().optional(),jwks_uri:lT.optional(),jwks:new oa({type:"any"}).optional(),software_id:nL().optional(),software_version:nL().optional(),software_statement:nL().optional()}).strip(),lN=om({client_id:nL(),client_secret:nL().optional(),client_id_issued_at:n8().optional(),client_secret_expires_at:n8().optional(),issuer:nL().optional().catch(void 0)}).strip(),lM=lL.merge(lN),lZ=om({error:nL(),error_description:nL().optional()}).strip(),lU=om({token:nL(),token_type_hint:nL().optional()}).strip(),lF=Symbol.for("mcp.sdk.errorBrands");function lH(e,t){let r=new Set,i=t;for(;"function"==typeof i;){let e=i.mcpBrand;Object.prototype.hasOwnProperty.call(i,"mcpBrand")&&"string"==typeof e&&r.add(e),i=Object.getPrototypeOf(i)}0!==r.size&&Object.defineProperty(e,lF,{value:r,enumerable:!1,configurable:!0})}function lD(e,t){try{if("object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&"string"==typeof e.mcpBrand&&Object.prototype.hasOwnProperty.call(t,lF)){let r=t[lF];if(r&&"function"==typeof r.has&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}let lV=((C={}).InvalidRequest="invalid_request",C.InvalidClient="invalid_client",C.InvalidGrant="invalid_grant",C.UnauthorizedClient="unauthorized_client",C.UnsupportedGrantType="unsupported_grant_type",C.InvalidScope="invalid_scope",C.AccessDenied="access_denied",C.ServerError="server_error",C.TemporarilyUnavailable="temporarily_unavailable",C.UnsupportedResponseType="unsupported_response_type",C.UnsupportedTokenType="unsupported_token_type",C.InvalidToken="invalid_token",C.MethodNotAllowed="method_not_allowed",C.TooManyRequests="too_many_requests",C.InvalidClientMetadata="invalid_client_metadata",C.InvalidRedirectUri="invalid_redirect_uri",C.InsufficientScope="insufficient_scope",C.InvalidTarget="invalid_target",C.InvalidDpopProof="invalid_dpop_proof",C.UseDpopNonce="use_dpop_nonce",C);var lJ=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](e){return lD(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lD(this,e)}constructor(e,t,r){super(t),this.code=e,this.errorUri=r,this.name="OAuthError",lH(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}};let lB=(($={}).NotConnected="NOT_CONNECTED",$.AlreadyConnected="ALREADY_CONNECTED",$.NotInitialized="NOT_INITIALIZED",$.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",$.RequestTimeout="REQUEST_TIMEOUT",$.ConnectionClosed="CONNECTION_CLOSED",$.SendFailed="SEND_FAILED",$.InvalidResult="INVALID_RESULT",$.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",$.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",$.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",$.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",$.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",$.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",$.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",$.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",$.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",$.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",$.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",$);var lW=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return lD(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lD(this,e)}constructor(e,t,r,i){super(t,i),this.code=e,this.data=r,this.name="SdkError",lH(this,new.target)}};(class extends lW{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,i){super(e,t,r,i),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let lG={};function lK(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lY(e,t){let r={};for(let[i,n]of Object.entries(e)){if(void 0===n)continue;let e=void 0===t?void 0:t[i];if(void 0===e){r[i]=n;continue}if(lK(n)&&lK(e)){let t={};for(let[r,o]of Object.entries(n))void 0!==o&&void 0===e[r]&&("elicitation"!==i||"form"!==r||void 0!==e.form||void 0!==e.url)&&(t[r]=o);Object.keys(t).length>0&&(r[i]=t)}}return Object.keys(r).length>0?r:void 0}let lX="2026-07-28",lQ=[lX];function l0(e){return e.filter(e=>e>=lX)}function l1(e){let t=e.structuredContent;return void 0===t||!("object"!=typeof t||null===t||Array.isArray(t))||e.content?.some(e=>"text"===e.type)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}let l2=["task","inputRequests","requestState"];function l9(e){return null===e||"object"!=typeof e||Array.isArray(e)||void 0!==e.content||l2.some(t=>t in e)?e:{...e,content:[]}}function l4(){let e,t,i,n,o,a,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k,x,C,$,T,P,E,O,I,q,j,A,z,L,N,M,Z,U,F,H,D,V,J,B,W,G,K,Y,X,Q,ee,et,er,ei,en,eo,ea,es,el,ec,eu,ed,ep,em,eh,ef,eg,ey,ev,e_,eb,eS,ew,eR,ek,ex,eC,e$,eT,eP,eE,eO,eI,eq,ej,eA,ez,eL,eN,eM,eZ,eU,eF,eH,eD,eV,eJ,eB,eW,eG,eK,eY,eX,eQ,e0,e1,e2,e9,e4,e5,e3,e6,e7,e8,te,tt,tr,ti,tn,to,ta,ts,tl,tc,tu,td,tp,tm,th,tf,tg,ty,tv,t_,tb,tS,tw;return r??=(e=oH(()=>og([nL(),n8(),oi(),oo(),ow(nL(),e),od(e)])),t=ow(nL(),e),i=og([nL(),n8().int()]),n=nL(),o=om({ttl:n8().optional()}),a=om({taskId:nL()}),c=(l=om({_meta:(s=oh({progressToken:i.optional(),"io.modelcontextprotocol/related-task":a.optional()})).optional()})).extend({task:o.optional()}),u=om({method:nL(),params:l.loose().optional()}),d=om({_meta:s.optional()}),p=om({method:nL(),params:d.loose().optional()}),m=oh({_meta:s.optional()}),h=og([nL(),n8().int()]),f=m.strict(),g=d.extend({requestId:h.optional(),reason:nL().optional()}),y=p.extend({method:oC("notifications/cancelled"),params:g}),v=om({src:nL(),mimeType:nL().optional(),sizes:od(nL()).optional(),theme:ok(["light","dark"]).optional()}),_=om({icons:od(v).optional()}),S=(b=om({name:nL(),title:nL().optional()})).extend({...b.shape,..._.shape,version:nL(),websiteUrl:nL().optional(),description:nL().optional()}),w=ob(om({applyDefaults:oi().optional()}),t),R=oV(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ob(om({form:w.optional(),url:t.optional()}),t.optional())),k=oh({list:t.optional(),cancel:t.optional(),requests:oh({sampling:oh({createMessage:t.optional()}).optional(),elicitation:oh({create:t.optional()}).optional()}).optional()}),x=oh({list:t.optional(),cancel:t.optional(),requests:oh({tools:oh({call:t.optional()}).optional()}).optional()}),C=om({experimental:ow(nL(),t).optional(),sampling:om({context:t.optional(),tools:t.optional()}).optional(),elicitation:R.optional(),roots:om({listChanged:oi().optional()}).optional(),tasks:k.optional(),extensions:ow(nL(),t).optional()}),$=l.extend({protocolVersion:nL(),capabilities:C,clientInfo:S}),T=u.extend({method:oC("initialize"),params:$}),P=om({experimental:ow(nL(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:om({listChanged:oi().optional()}).optional(),resources:om({subscribe:oi().optional(),listChanged:oi().optional()}).optional(),tools:om({listChanged:oi().optional()}).optional(),tasks:x.optional(),extensions:ow(nL(),t).optional()}),E=m.extend({protocolVersion:nL(),capabilities:P,serverInfo:S,instructions:nL().optional()}),O=p.extend({method:oC("notifications/initialized"),params:d.optional()}),I=u.extend({method:oC("ping"),params:l.optional()}),q=om({progress:n8(),total:oE(n8()),message:oE(nL())}),j=om({...d.shape,...q.shape,progressToken:i}),A=p.extend({method:oC("notifications/progress"),params:j}),z=l.extend({cursor:n.optional()}),L=u.extend({params:z.optional()}),N=m.extend({nextCursor:n.optional()}),Z=(M=om({uri:nL(),mimeType:oE(nL()),_meta:ow(nL(),ol()).optional()})).extend({text:nL()}),U=nL().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),F=M.extend({blob:U}),D=om({audience:od(H=ok(["user","assistant"])).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nM,{offset:!0}).optional()}),V=om({...b.shape,..._.shape,uri:nL(),description:oE(nL()),mimeType:oE(nL()),size:oE(n8()),annotations:D.optional(),_meta:oE(oh({}))}),J=om({...b.shape,..._.shape,uriTemplate:nL(),description:oE(nL()),mimeType:oE(nL()),annotations:D.optional(),_meta:oE(oh({}))}),B=L.extend({method:oC("resources/list")}),W=N.extend({resources:od(V)}),G=L.extend({method:oC("resources/templates/list")}),K=N.extend({resourceTemplates:od(J)}),Y=l.extend({uri:nL()}),X=u.extend({method:oC("resources/read"),params:Y}),Q=m.extend({contents:od(og([Z,F]))}),ee=p.extend({method:oC("notifications/resources/list_changed"),params:d.optional()}),et=u.extend({method:oC("resources/subscribe"),params:Y}),er=u.extend({method:oC("resources/unsubscribe"),params:Y}),ei=d.extend({uri:nL()}),en=p.extend({method:oC("notifications/resources/updated"),params:ei}),eo=om({name:nL(),description:oE(nL()),required:oE(oi())}),ea=om({...b.shape,..._.shape,description:oE(nL()),arguments:oE(od(eo)),_meta:oE(oh({}))}),es=L.extend({method:oC("prompts/list")}),el=N.extend({prompts:od(ea)}),ec=l.extend({name:nL(),arguments:ow(nL(),nL()).optional()}),eu=u.extend({method:oC("prompts/get"),params:ec}),ed=om({type:oC("text"),text:nL(),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),ep=om({type:oC("image"),data:U,mimeType:nL(),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),em=om({type:oC("audio"),data:U,mimeType:nL(),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),eh=om({type:oC("tool_use"),name:nL(),id:nL(),input:ow(nL(),ol()),_meta:ow(nL(),ol()).optional()}),ef=om({type:oC("resource"),resource:og([Z,F]),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),ev=om({role:H,content:ey=og([ed,ep,em,eg=V.extend({type:oC("resource_link")}),ef])}),e_=m.extend({description:nL().optional(),messages:od(ev)}),eb=p.extend({method:oC("notifications/prompts/list_changed"),params:d.optional()}),eS=om({title:nL().optional(),readOnlyHint:oi().optional(),destructiveHint:oi().optional(),idempotentHint:oi().optional(),openWorldHint:oi().optional()}),ew=om({taskSupport:ok(["required","optional","forbidden"]).optional()}),eR=om({...b.shape,..._.shape,description:nL().optional(),inputSchema:om({type:oC("object"),properties:ow(nL(),e).optional(),required:od(nL()).optional()}).catchall(ol()),outputSchema:om({type:oC("object"),properties:ow(nL(),e).optional(),required:od(nL()).optional()}).catchall(ol()).optional(),annotations:eS.optional(),execution:ew.optional(),_meta:ow(nL(),ol()).optional()}),ek=L.extend({method:oC("tools/list")}),ex=N.extend({tools:od(eR)}),eC=m.extend({content:od(ey),structuredContent:ow(nL(),ol()).optional(),isError:oi().optional()}),e$=c.extend({name:nL(),arguments:ow(nL(),ol()).optional()}),eT=u.extend({method:oC("tools/call"),params:e$}),eP=p.extend({method:oC("notifications/tools/list_changed"),params:d.optional()}),eE=ok(["debug","info","notice","warning","error","critical","alert","emergency"]),eO=l.extend({level:eE}),eI=u.extend({method:oC("logging/setLevel"),params:eO}),eq=d.extend({level:eE,logger:nL().optional(),data:ol()}),ej=p.extend({method:oC("notifications/message"),params:eq}),eA=om({name:nL().optional()}),ez=om({hints:od(eA).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),eL=om({mode:ok(["auto","required","none"]).optional()}),eN=om({type:oC("tool_result"),toolUseId:nL().describe("The unique identifier for the corresponding tool call."),content:od(ey),structuredContent:om({}).loose().optional(),isError:oi().optional(),_meta:ow(nL(),ol()).optional()}),eM=ov("type",[ed,ep,em]),eU=om({role:H,content:og([eZ=ov("type",[ed,ep,em,eh,eN]),od(eZ)]),_meta:ow(nL(),ol()).optional()}),eF=c.extend({messages:od(eU),modelPreferences:ez.optional(),systemPrompt:nL().optional(),includeContext:ok(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:od(nL()).optional(),metadata:t.optional(),tools:od(eR).optional(),toolChoice:eL.optional()}),eH=u.extend({method:oC("sampling/createMessage"),params:eF}),eD=m.extend({model:nL(),stopReason:oE(ok(["endTurn","stopSequence","maxTokens"]).or(nL())),role:H,content:eM}),eV=m.extend({model:nL(),stopReason:oE(ok(["endTurn","stopSequence","maxTokens","toolUse"]).or(nL())),role:H,content:og([eZ,od(eZ)])}),eJ=om({type:oC("boolean"),title:nL().optional(),description:nL().optional(),default:oi().optional()}),eB=om({type:oC("string"),title:nL().optional(),description:nL().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ok(["email","uri","date","date-time"]).optional(),default:nL().optional()}),eW=om({type:ok(["number","integer"]),title:nL().optional(),description:nL().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),eG=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),default:nL().optional()}),eK=om({type:oC("string"),title:nL().optional(),description:nL().optional(),oneOf:od(om({const:nL(),title:nL()})),default:nL().optional()}),eY=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),enumNames:od(nL()).optional(),default:nL().optional()}),eX=og([eG,eK]),eQ=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({type:oC("string"),enum:od(nL())}),default:od(nL()).optional()}),e1=og([eQ,e0=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({anyOf:od(om({const:nL(),title:nL()}))}),default:od(nL()).optional()})]),e2=og([eY,eX,e1]),e9=og([e2,eJ,eB,eW]),e4=c.extend({mode:oC("form").optional(),message:nL(),requestedSchema:om({type:oC("object"),properties:ow(nL(),e9),required:od(nL()).optional()}).catchall(ol())}),e3=og([e4,e5=c.extend({mode:oC("url"),message:nL(),elicitationId:nL(),url:nL().url()})]),e6=u.extend({method:oC("elicitation/create"),params:e3}),e7=d.extend({elicitationId:nL()}),e8=p.extend({method:oC("notifications/elicitation/complete"),params:e7}),te=m.extend({action:ok(["accept","decline","cancel"]),content:oV(e=>null===e?void 0:e,ow(nL(),og([nL(),n8(),oi(),od(nL())])).optional())}),tt=om({type:oC("ref/resource"),uri:nL()}),tr=om({type:oC("ref/prompt"),name:nL()}),ti=l.extend({ref:og([tr,tt]),argument:om({name:nL(),value:nL()}),context:om({arguments:ow(nL(),nL()).optional()}).optional()}),tn=u.extend({method:oC("completion/complete"),params:ti}),to=m.extend({completion:oh({values:od(nL()).max(100),total:oE(n8().int()),hasMore:oE(oi())})}),ta=om({uri:nL().startsWith("file://"),name:nL().optional(),_meta:ow(nL(),ol()).optional()}),ts=u.extend({method:oC("roots/list"),params:l.optional()}),tl=m.extend({roots:od(ta)}),tc=p.extend({method:oC("notifications/roots/list_changed"),params:d.optional()}),tu=oh({ttl:n8().optional(),pollInterval:n8().optional()}),td=ok(["working","input_required","completed","failed","cancelled"]),tp=om({taskId:nL(),status:td,ttl:og([n8(),oo()]),createdAt:nL(),lastUpdatedAt:nL(),pollInterval:oE(n8()),statusMessage:oE(nL())}),tm=m.extend({task:tp}),th=d.merge(tp),tf=p.extend({method:oC("notifications/tasks/status"),params:th}),tg=u.extend({method:oC("tasks/get"),params:l.extend({taskId:nL()})}),ty=m.merge(tp),tv=u.extend({method:oC("tasks/result"),params:l.extend({taskId:nL()})}),t_=m.loose(),tb=L.extend({method:oC("tasks/list")}),tS=N.extend({tasks:od(tp)}),tw=u.extend({method:oC("tasks/cancel"),params:l.extend({taskId:nL()})}),{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:i,CursorSchema:n,TaskMetadataSchema:o,RelatedTaskMetadataSchema:a,RequestMetaSchema:s,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:c,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:p,ResultSchema:m,RequestIdSchema:h,EmptyResultSchema:f,CancelledNotificationParamsSchema:g,CancelledNotificationSchema:y,IconSchema:v,IconsSchema:_,BaseMetadataSchema:b,ImplementationSchema:S,ClientTasksCapabilitySchema:k,ServerTasksCapabilitySchema:x,ClientCapabilitiesSchema:C,InitializeRequestParamsSchema:$,InitializeRequestSchema:T,ServerCapabilitiesSchema:P,InitializeResultSchema:E,InitializedNotificationSchema:O,PingRequestSchema:I,ProgressSchema:q,ProgressNotificationParamsSchema:j,ProgressNotificationSchema:A,PaginatedRequestParamsSchema:z,PaginatedRequestSchema:L,PaginatedResultSchema:N,ResourceContentsSchema:M,TextResourceContentsSchema:Z,BlobResourceContentsSchema:F,RoleSchema:H,AnnotationsSchema:D,ResourceSchema:V,ResourceTemplateSchema:J,ListResourcesRequestSchema:B,ListResourcesResultSchema:W,ListResourceTemplatesRequestSchema:G,ListResourceTemplatesResultSchema:K,ResourceRequestParamsSchema:Y,ReadResourceRequestParamsSchema:Y,ReadResourceRequestSchema:X,ReadResourceResultSchema:Q,ResourceListChangedNotificationSchema:ee,SubscribeRequestParamsSchema:Y,SubscribeRequestSchema:et,UnsubscribeRequestParamsSchema:Y,UnsubscribeRequestSchema:er,ResourceUpdatedNotificationParamsSchema:ei,ResourceUpdatedNotificationSchema:en,PromptArgumentSchema:eo,PromptSchema:ea,ListPromptsRequestSchema:es,ListPromptsResultSchema:el,GetPromptRequestParamsSchema:ec,GetPromptRequestSchema:eu,TextContentSchema:ed,ImageContentSchema:ep,AudioContentSchema:em,ToolUseContentSchema:eh,EmbeddedResourceSchema:ef,ResourceLinkSchema:eg,ContentBlockSchema:ey,PromptMessageSchema:ev,GetPromptResultSchema:e_,PromptListChangedNotificationSchema:eb,ToolAnnotationsSchema:eS,ToolExecutionSchema:ew,ToolSchema:eR,ListToolsRequestSchema:ek,ListToolsResultSchema:ex,CallToolResultSchema:eC,CallToolRequestParamsSchema:e$,CallToolRequestSchema:eT,ToolListChangedNotificationSchema:eP,LoggingLevelSchema:eE,SetLevelRequestParamsSchema:eO,SetLevelRequestSchema:eI,LoggingMessageNotificationParamsSchema:eq,LoggingMessageNotificationSchema:ej,ModelHintSchema:eA,ModelPreferencesSchema:ez,ToolChoiceSchema:eL,ToolResultContentSchema:eN,SamplingContentSchema:eM,SamplingMessageContentBlockSchema:eZ,SamplingMessageSchema:eU,CreateMessageRequestParamsSchema:eF,CreateMessageRequestSchema:eH,CreateMessageResultSchema:eD,CreateMessageResultWithToolsSchema:eV,BooleanSchemaSchema:eJ,StringSchemaSchema:eB,NumberSchemaSchema:eW,UntitledSingleSelectEnumSchemaSchema:eG,TitledSingleSelectEnumSchemaSchema:eK,LegacyTitledEnumSchemaSchema:eY,SingleSelectEnumSchemaSchema:eX,UntitledMultiSelectEnumSchemaSchema:eQ,TitledMultiSelectEnumSchemaSchema:e0,MultiSelectEnumSchemaSchema:e1,EnumSchemaSchema:e2,PrimitiveSchemaDefinitionSchema:e9,ElicitRequestFormParamsSchema:e4,ElicitRequestURLParamsSchema:e5,ElicitRequestParamsSchema:e3,ElicitRequestSchema:e6,ElicitationCompleteNotificationParamsSchema:e7,ElicitationCompleteNotificationSchema:e8,ElicitResultSchema:te,ResourceTemplateReferenceSchema:tt,PromptReferenceSchema:tr,CompleteRequestParamsSchema:ti,CompleteRequestSchema:tn,CompleteResultSchema:to,RootSchema:ta,ListRootsRequestSchema:ts,ListRootsResultSchema:tl,RootsListChangedNotificationSchema:tc,TaskCreationParamsSchema:tu,TaskStatusSchema:td,TaskSchema:tp,CreateTaskResultSchema:tm,TaskStatusNotificationParamsSchema:th,TaskStatusNotificationSchema:tf,GetTaskRequestSchema:tg,GetTaskResultSchema:ty,GetTaskPayloadRequestSchema:tv,GetTaskPayloadResultSchema:t_,ListTasksRequestSchema:tb,ListTasksResultSchema:tS,CancelTaskRequestSchema:tw,CancelTaskResultSchema:m.merge(tp),ClientRequestSchema:og([I,T,tn,eI,eu,es,B,G,X,et,er,eT,ek,tg,tv,tb,tw]),ClientNotificationSchema:og([y,A,O,tc,tf]),ClientResultSchema:og([f,eD,eV,te,tl,ty,tS,tm]),ServerRequestSchema:og([I,eH,e6,ts,tg,tv,tb,tw]),ServerNotificationSchema:og([y,A,ej,en,ee,eP,eb,tf,e8]),ServerResultSchema:og([f,E,to,e_,el,W,K,Q,eC,ex,ty,tS,tm]),CallToolResultWireSchema:ol().superRefine((e,t)=>{if(!("object"!=typeof e||null===e||Array.isArray(e))&&void 0===e.content){for(let r of l2)if(r in e)return void t.addIssue({code:"custom",message:`content is required when the body carries '${r}' — another result family cannot default into an empty tools/call success`})}}).transform(l9).pipe(eC)})}function l5(e){return"object"!==e.type}let l3=new Set(["const","enum","default","examples"]),l6=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function l7(e){return void 0!==e&&!("string"==typeof e&&e.startsWith("#"))}let l8={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},ce={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},ct={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function cr(){if(i)return i;let e=l4();return i={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}}}function ci(e){return Object.prototype.hasOwnProperty.call(l8,e)}function cn(e){return Object.prototype.hasOwnProperty.call(ce,e)}function co(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function ca(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}Object.keys(l8),Object.keys(ce);let cs={ok:!1,reason:"not-in-era"};function cl(e){return co(e)&&co(e.outputSchema)&&l5(e.outputSchema)}let cc={era:"2025-11-25",hasRequestMethod:ci,hasNotificationMethod:cn,validateRequest:(e,t)=>ca(ci(e)?cr().requestSchemas[e]:void 0,t),validateResult:(e,t)=>ca(Object.prototype.hasOwnProperty.call(ct,e)?cr().resultSchemas[e]:void 0,t),validateNotification:(e,t)=>ca(cn(e)?cr().notificationSchemas[e]:void 0,t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>cs,validateInputResponse:()=>cs,samplingResultVariant:(e,t)=>{let r=l4();return ca(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)},outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=l1(e),i=r.structuredContent;if(void 0===i)return r;let n="object"!=typeof i||null===i||Array.isArray(i),o=void 0!==t&&l5(t);return n||o?{...r,structuredContent:{result:i}}:r},decodeResult(e,t){if(co(t)&&"resultType"in t){let e={...t};return delete e.resultType,{kind:"complete",result:e}}return{kind:"complete",result:t}},encodeResult(e,t){if("tools/list"!==e)return t;let r=t.tools;return Array.isArray(r)&&r.some(e=>cl(e))?{...t,tools:r.map(e=>cl(e)?{...e,outputSchema:function(e){var t;let r="string"==typeof e.$schema?e.$schema:void 0;if(l7(e.$id))return{...void 0!==r&&{$schema:r},type:"object",properties:{result:e},required:["result"]};let i="string"==typeof(t=e.$schema)&&Y.has(t.replace(/#$/,""))&&!0!==e.$recursiveAnchor,n=(e,t)=>{if(Array.isArray(e))return e.map(e=>n(e,!1));if(null===e||"object"!=typeof e||!t&&l7(e.$id))return e;let r={},o=!1;for(let[a,s]of Object.entries(e))t?r[a]=n(s,!1):("$ref"===a||"$dynamicRef"===a)&&"string"==typeof s?r[a]="#"===s?"#/properties/result":s.startsWith("#/")?`#/properties/result${s.slice(1)}`:s:"$recursiveRef"===a&&"#"===s&&i?o=!0:l3.has(a)?r[a]=s:l6.has(a)?r[a]=n(s,!0):r[a]=n(s,!1);return o&&("$ref"in r?r.allOf=[...Array.isArray(r.allOf)?r.allOf:[],{$ref:"#/properties/result"}]:r.$ref="#/properties/result"),r};return{...void 0!==r&&{$schema:r},type:"object",properties:{result:n(e,!1)},required:["result"]}}(e.outputSchema)}:e)}:t},encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope:e=>void 0};function cu(){return n??=function(){let e=oH(()=>og([nL(),n8(),oi(),oo(),ow(nL(),e),od(e)])),t=ow(nL(),e),r=og([nL(),n8().int()]),i=nL(),n=og([nL(),n8().int()]),o=ok(["user","assistant"]),a=ok(["debug","info","notice","warning","error","critical","alert","emergency"]),s=nL().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=om({ttl:n8().optional()}),c=om({taskId:nL()}),u=oh({progressToken:r.optional(),"io.modelcontextprotocol/related-task":c.optional()}),d=om({_meta:u.optional()}),p=d.extend({task:l.optional()}),m=om({_meta:u.optional()}),h=om({method:nL(),params:m.loose().optional()}),f=om({src:nL(),mimeType:nL().optional(),sizes:od(nL()).optional(),theme:ok(["light","dark"]).optional()}),g=om({icons:od(f).optional()}),y=om({name:nL(),title:nL().optional()}),v=y.extend({...y.shape,...g.shape,version:nL(),websiteUrl:nL().optional(),description:nL().optional()}),_=ob(om({applyDefaults:oi().optional()}),t),b=oV(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ob(om({form:_.optional(),url:t.optional()}),t.optional())),S=oh({list:t.optional(),cancel:t.optional(),requests:oh({sampling:oh({createMessage:t.optional()}).optional(),elicitation:oh({create:t.optional()}).optional()}).optional()}),w=oh({list:t.optional(),cancel:t.optional(),requests:oh({tools:oh({call:t.optional()}).optional()}).optional()}),R=om({experimental:ow(nL(),t).optional(),sampling:om({context:t.optional(),tools:t.optional()}).optional(),elicitation:b.optional(),roots:om({listChanged:oi().optional()}).optional(),tasks:S.optional(),extensions:ow(nL(),t).optional()}),k=om({experimental:ow(nL(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:om({listChanged:oi().optional()}).optional(),resources:om({subscribe:oi().optional(),listChanged:oi().optional()}).optional(),tools:om({listChanged:oi().optional()}).optional(),tasks:w.optional(),extensions:ow(nL(),t).optional()}),x=om({progress:n8(),total:oE(n8()),message:oE(nL())}),C=om({...m.shape,...x.shape,progressToken:r}),$=h.extend({method:oC("notifications/progress"),params:C}),T=m.extend({level:a,logger:nL().optional(),data:ol()}),P=h.extend({method:oC("notifications/message"),params:T}),E=om({uri:nL(),mimeType:oE(nL()),_meta:ow(nL(),ol()).optional()}),O=E.extend({text:nL()}),I=E.extend({blob:s}),q=om({audience:od(o).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nM,{offset:!0}).optional()}),j=om({...y.shape,...g.shape,uri:nL(),description:oE(nL()),mimeType:oE(nL()),size:oE(n8()),annotations:q.optional(),_meta:oE(oh({}))}),A=om({...y.shape,...g.shape,uriTemplate:nL(),description:oE(nL()),mimeType:oE(nL()),annotations:q.optional(),_meta:oE(oh({}))}),z=h.extend({method:oC("notifications/resources/list_changed"),params:m.optional()}),L=m.extend({uri:nL()}),N=h.extend({method:oC("notifications/resources/updated"),params:L}),M=om({name:nL(),description:oE(nL()),required:oE(oi())}),Z=om({...y.shape,...g.shape,description:oE(nL()),arguments:oE(od(M)),_meta:oE(oh({}))}),U=h.extend({method:oC("notifications/prompts/list_changed"),params:m.optional()}),F=om({type:oC("text"),text:nL(),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),H=om({type:oC("image"),data:s,mimeType:nL(),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),D=om({type:oC("audio"),data:s,mimeType:nL(),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),V=om({type:oC("tool_use"),name:nL(),id:nL(),input:ow(nL(),ol()),_meta:ow(nL(),ol()).optional()}),J=om({type:oC("resource"),resource:og([O,I]),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),B=j.extend({type:oC("resource_link")}),W=og([F,H,D,B,J]),G=om({role:o,content:W}),K=om({title:nL().optional(),readOnlyHint:oi().optional(),destructiveHint:oi().optional(),idempotentHint:oi().optional(),openWorldHint:oi().optional()}),Y=h.extend({method:oC("notifications/tools/list_changed"),params:m.optional()}),X=om({name:nL().optional()}),Q=om({hints:od(X).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),ee=om({mode:ok(["auto","required","none"]).optional()}),et=om({type:oC("boolean"),title:nL().optional(),description:nL().optional(),default:oi().optional()}),er=om({type:oC("string"),title:nL().optional(),description:nL().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ok(["email","uri","date","date-time"]).optional(),default:nL().optional()}),ei=om({type:ok(["number","integer"]),title:nL().optional(),description:nL().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),en=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),default:nL().optional()}),eo=om({type:oC("string"),title:nL().optional(),description:nL().optional(),oneOf:od(om({const:nL(),title:nL()})),default:nL().optional()}),ea=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),enumNames:od(nL()).optional(),default:nL().optional()}),es=og([en,eo]),el=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({type:oC("string"),enum:od(nL())}),default:od(nL()).optional()}),ec=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({anyOf:od(om({const:nL(),title:nL()}))}),default:od(nL()).optional()}),eu=og([el,ec]),ed=og([ea,es,eu]),ep=og([ed,et,er,ei]),em=p.extend({mode:oC("form").optional(),message:nL(),requestedSchema:om({type:oC("object"),properties:ow(nL(),ep),required:od(nL()).optional()}).catchall(ol())}),eh=om({type:oC("ref/resource"),uri:nL()}),ef=om({type:oC("ref/prompt"),name:nL()}),eg=om({uri:nL().startsWith("file://"),name:nL().optional(),_meta:ow(nL(),ol()).optional()}),ey=R.shape,ev=om({experimental:ey.experimental,sampling:ey.sampling,elicitation:ey.elicitation,roots:ey.roots,extensions:ey.extensions}),e_=k.shape,eb=om({experimental:e_.experimental,logging:e_.logging,completions:e_.completions,prompts:e_.prompts,resources:e_.resources,tools:e_.tools,extensions:e_.extensions}),eS=oh({progressToken:r.optional(),[oW]:nL(),[oG]:v.optional(),[oY]:ev,[oQ]:a.optional()}),ew=om({...y.shape,...g.shape,description:nL().optional(),inputSchema:oh({$schema:nL().optional(),type:oC("object")}),outputSchema:oh({$schema:nL().optional()}).optional(),annotations:K.optional(),_meta:ow(nL(),ol()).optional()}),eR=om({type:oC("tool_result"),toolUseId:nL(),content:od(W),structuredContent:ol().optional(),isError:oi().optional(),_meta:ow(nL(),ol()).optional()}),ek=og([F,H,D,V,eR]),ex=om({role:o,content:og([ek,od(ek)]),_meta:ow(nL(),ol()).optional()}),eC=nL(),e$=oh({[oK]:v.optional().catch(void 0)}),eT=e$.optional();function eP(e){return oh({_meta:eT,resultType:eC.default("complete"),...e})}let eE=eP({}),eO=eP({nextCursor:i.optional()}),eI=eP({content:od(W),structuredContent:ol().optional(),isError:oi().optional()}),eq=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),tools:od(ew),nextCursor:i.optional()}),ej=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),prompts:od(Z),nextCursor:i.optional()}),eA=eP({description:nL().optional(),messages:od(G)}),ez=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resources:od(j),nextCursor:i.optional()}),eL=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resourceTemplates:od(A),nextCursor:i.optional()}),eN=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),contents:od(og([O,I]))}),eM=eP({completion:om({values:od(nL()).max(100),total:n8().int().optional(),hasMore:oi().optional()}).loose()}),eZ=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"])}),eU=eP({ttlMs:n8().int().min(0).catch(0),cacheScope:ok(["public","private"]).catch("private"),supportedVersions:od(nL()),capabilities:eb,instructions:nL().optional()}),eF=om({messages:od(ex),modelPreferences:Q.optional(),systemPrompt:nL().optional(),includeContext:ok(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:od(nL()).optional(),metadata:t.optional(),tools:od(ew).optional(),toolChoice:ee.optional()}),eH=om({method:oC("sampling/createMessage"),params:eF}),eD=om({method:oC("roots/list"),params:om({_meta:ow(nL(),ol()).optional()}).optional()}),eV=om({...ex.shape,model:nL(),stopReason:nL().optional()}),eJ=om({roots:od(eg)}),eB=om({action:ok(["accept","decline","cancel"]),content:ow(nL(),og([nL(),n8(),oi(),od(nL())])).optional()}),eW=om({mode:oC("url"),message:nL(),url:nL().url()}),eG=og([em,eW]),eK=om({method:oC("elicitation/create"),params:eG}),eY=og([eH,eD,eK]),eX=og([eV,eJ,eB]),eQ=ow(nL(),eY),e0=ow(nL(),eX),e1=eP({inputRequests:eQ.optional(),requestState:nL().optional()}),e2={inputResponses:e0.optional(),requestState:nL().optional()},e9=om({_meta:eS,...e2}),e4=oh({progressToken:r.optional()});function e5(e,t){return om({method:oC(e),params:om({_meta:eS,...t})})}function e3(e,t){return om({method:oC(e),params:om({_meta:e4.optional(),...t}).optional()})}let e6={name:nL(),arguments:ow(nL(),ol()).optional(),...e2},e7={cursor:i.optional()},e8=e5("tools/call",e6),te=e5("tools/list",e7),tt=e5("prompts/list",e7),tr=e5("prompts/get",{name:nL(),arguments:ow(nL(),nL()).optional(),...e2}),ti=e5("resources/list",e7),tn=e5("resources/templates/list",e7),to=e5("resources/read",{uri:nL(),...e2}),ta={ref:og([ef,eh]),argument:om({name:nL(),value:nL()}),context:om({arguments:ow(nL(),nL()).optional()}).optional()},ts=e5("completion/complete",ta),tl=e5("server/discover",{}),tc=om({toolsListChanged:oi().optional(),promptsListChanged:oi().optional(),resourcesListChanged:oi().optional(),resourceSubscriptions:od(nL()).optional()}),tu={notifications:tc},td=e5("subscriptions/listen",tu),tp=e$.extend({"io.modelcontextprotocol/subscriptionId":n}),tm=oh({_meta:tp,resultType:eC.default("complete")}),th={"tools/call":e3("tools/call",e6),"tools/list":e3("tools/list",e7),"prompts/get":e3("prompts/get",{name:nL(),arguments:ow(nL(),nL()).optional()}),"prompts/list":e3("prompts/list",e7),"resources/list":e3("resources/list",e7),"resources/templates/list":e3("resources/templates/list",e7),"resources/read":e3("resources/read",{uri:nL()}),"completion/complete":e3("completion/complete",ta),"server/discover":e3("server/discover",{}),"subscriptions/listen":e3("subscriptions/listen",tu)};function tf(e){return oh({_meta:eT,...e})}let tg={"tools/call":tf({content:od(W),structuredContent:ol().optional(),isError:oi().optional()}),"tools/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),tools:od(ew),nextCursor:i.optional()}),"prompts/get":tf({description:nL().optional(),messages:od(G)}),"prompts/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),prompts:od(Z),nextCursor:i.optional()}),"resources/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resources:od(j),nextCursor:i.optional()}),"resources/templates/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resourceTemplates:od(A),nextCursor:i.optional()}),"resources/read":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),contents:od(og([O,I]))}),"completion/complete":tf({completion:om({values:od(nL()).max(100),total:n8().int().optional(),hasMore:oi().optional()}).loose()}),"server/discover":tf({ttlMs:n8().int().min(0).catch(0),cacheScope:ok(["public","private"]).catch("private"),supportedVersions:od(nL()),capabilities:eb,instructions:nL().optional()}),"subscriptions/listen":tf({})},ty=oh({"io.modelcontextprotocol/subscriptionId":n.optional()}),tv=om({method:oC("notifications/subscriptions/acknowledged"),params:om({_meta:ty.optional(),notifications:tc})}),t_=om({_meta:ty.optional(),requestId:n,reason:nL().optional()}),tb=om({method:oC("notifications/cancelled"),params:t_}),tS=e=>om({jsonrpc:oC("2.0"),id:og([nL(),n8().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:i,RequestIdSchema:n,RoleSchema:o,LoggingLevelSchema:a,TaskMetadataSchema:l,RelatedTaskMetadataSchema:c,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:p,NotificationsParamsSchema:m,NotificationSchema:h,IconSchema:f,IconsSchema:g,BaseMetadataSchema:y,ImplementationSchema:v,ClientTasksCapabilitySchema:S,ServerTasksCapabilitySchema:w,ClientCapabilitiesSchema:R,ServerCapabilitiesSchema:k,ProgressSchema:x,ProgressNotificationParamsSchema:C,ProgressNotificationSchema:$,LoggingMessageNotificationParamsSchema:T,LoggingMessageNotificationSchema:P,ResourceContentsSchema:E,TextResourceContentsSchema:O,BlobResourceContentsSchema:I,AnnotationsSchema:q,ResourceSchema:j,ResourceTemplateSchema:A,ResourceListChangedNotificationSchema:z,ResourceUpdatedNotificationParamsSchema:L,ResourceUpdatedNotificationSchema:N,PromptArgumentSchema:M,PromptSchema:Z,PromptListChangedNotificationSchema:U,TextContentSchema:F,ImageContentSchema:H,AudioContentSchema:D,ToolUseContentSchema:V,EmbeddedResourceSchema:J,ResourceLinkSchema:B,ContentBlockSchema:W,PromptMessageSchema:G,ToolAnnotationsSchema:K,ToolListChangedNotificationSchema:Y,ModelHintSchema:X,ModelPreferencesSchema:Q,ToolChoiceSchema:ee,BooleanSchemaSchema:et,StringSchemaSchema:er,NumberSchemaSchema:ei,UntitledSingleSelectEnumSchemaSchema:en,TitledSingleSelectEnumSchemaSchema:eo,LegacyTitledEnumSchemaSchema:ea,SingleSelectEnumSchemaSchema:es,UntitledMultiSelectEnumSchemaSchema:el,TitledMultiSelectEnumSchemaSchema:ec,MultiSelectEnumSchemaSchema:eu,EnumSchemaSchema:ed,PrimitiveSchemaDefinitionSchema:ep,ElicitRequestFormParamsSchema:em,ResourceTemplateReferenceSchema:eh,PromptReferenceSchema:ef,RootSchema:eg,ClientCapabilities2026Schema:ev,ServerCapabilities2026Schema:eb,RequestMetaEnvelopeSchema:eS,ToolSchema:ew,ToolResultContentSchema:eR,SamplingMessageContentBlockSchema:ek,SamplingMessageSchema:ex,ResultTypeSchema:eC,ResultMetaSchema:e$,ResultSchema:eE,PaginatedResultSchema:eO,CallToolResultSchema:eI,ListToolsResultSchema:eq,ListPromptsResultSchema:ej,GetPromptResultSchema:eA,ListResourcesResultSchema:ez,ListResourceTemplatesResultSchema:eL,ReadResourceResultSchema:eN,CompleteResultSchema:eM,CacheableResultSchema:eZ,DiscoverResultSchema:eU,CreateMessageRequestParamsSchema:eF,CreateMessageRequestSchema:eH,ListRootsRequestSchema:eD,CreateMessageResultSchema:eV,ListRootsResultSchema:eJ,ElicitResultSchema:eB,ElicitRequestURLParamsSchema:eW,ElicitRequestParamsSchema:eG,ElicitRequestSchema:eK,InputRequestSchema:eY,InputResponseSchema:eX,InputRequestsSchema:eQ,InputResponsesSchema:e0,InputRequiredResultSchema:e1,InputResponseRequestParamsSchema:e9,CallToolRequestSchema:e8,ListToolsRequestSchema:te,ListPromptsRequestSchema:tt,GetPromptRequestSchema:tr,ListResourcesRequestSchema:ti,ListResourceTemplatesRequestSchema:tn,ReadResourceRequestSchema:to,CompleteRequestSchema:ts,DiscoverRequestSchema:tl,SubscriptionFilterSchema:tc,SubscriptionsListenRequestSchema:td,SubscriptionsListenResultMetaSchema:tp,SubscriptionsListenResultSchema:tm,dispatchRequestSchemas:th,dispatchResultSchemas:tg,NotificationMetaSchema:ty,SubscriptionsAcknowledgedNotificationSchema:tv,CancelledNotificationParamsSchema:t_,CancelledNotificationSchema:tb,notificationSchemas2026:{"notifications/cancelled":tb,"notifications/progress":$,"notifications/message":P,"notifications/resources/updated":N,"notifications/resources/list_changed":z,"notifications/tools/list_changed":Y,"notifications/prompts/list_changed":U,"notifications/subscriptions/acknowledged":tv},JSONRPCResultResponseSchema:tS(eE),CallToolResultResponseSchema:tS(og([eI,e1])),ListToolsResultResponseSchema:tS(eq),ListPromptsResultResponseSchema:tS(ej),GetPromptResultResponseSchema:tS(og([eA,e1])),ListResourcesResultResponseSchema:tS(ez),ListResourceTemplatesResultResponseSchema:tS(eL),ReadResourceResultResponseSchema:tS(og([eN,e1])),CompleteResultResponseSchema:tS(eM),DiscoverResultResponseSchema:tS(eU),SubscriptionsListenResultResponseSchema:tS(tm)}}()}let cd=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],cp=Symbol("modelcontextprotocol.resultCacheHintFallback");function cm(e,t){if(void 0===t)return e;let r=e[cp];if(void 0===r)return{...e,[cp]:t};let i={},n=r.ttlMs??t.ttlMs;void 0!==n&&(i.ttlMs=n);let o=r.cacheScope??t.cacheScope;return void 0!==o&&(i.cacheScope=o),{...e,[cp]:i}}function ch(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function cf(e){return"public"===e||"private"===e}function cg(e,t){if(void 0!==e.ttlMs&&!ch(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(void 0!==e.cacheScope&&!cf(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}let cy=((T={})[T.ParseError=-32700]="ParseError",T[T.InvalidRequest=-32600]="InvalidRequest",T[T.MethodNotFound=-32601]="MethodNotFound",T[T.InvalidParams=-32602]="InvalidParams",T[T.InternalError=-32603]="InternalError",T[T.ResourceNotFound=-32002]="ResourceNotFound",T[T.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",T[T.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",T[T.UrlElicitationRequired=-32042]="UrlElicitationRequired",T);var cv=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](e){return lD(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lD(this,e)}constructor(e,t,r){super(t),this.code=e,this.data=r,this.name="ProtocolError",lH(this,new.target)}static fromError(t,r,i){return t===cy.UrlElicitationRequired&&i&&i.elicitations?new cb(i.elicitations,r):t===cy.UnsupportedProtocolVersion&&i&&Array.isArray(i.supported)&&"string"==typeof i.requested?new cS({supported:i.supported,requested:i.requested},r):(t===cy.InvalidParams||t===cy.ResourceNotFound)&&"string"==typeof i?.uri&&(t===cy.ResourceNotFound||1===Object.keys(i).length)?new c_(i.uri,r):t===cy.MissingRequiredClientCapability&&i&&null!==i.requiredCapabilities&&"object"==typeof i.requiredCapabilities&&!Array.isArray(i.requiredCapabilities)?new cw({requiredCapabilities:i.requiredCapabilities},r):new e(t,r,i)}},c_=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(cy.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},cb=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(cy.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},cS=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(cy.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},cw=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(cy.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};let cR=["tools/call","prompts/get","resources/read"],ck=["elicitation/create","sampling/createMessage","roots/list"];function cx(){if(o)return o;let e=cu();return o={request:{"elicitation/create":om({method:oC("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":om({method:oC("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":om({method:oC("roots/list"),params:oh({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}}}function cC(e){return ck.includes(e)}function c$(e){return cC(e)?cx().request[e]:void 0}let cT={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},cP={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function cE(e){return Object.prototype.hasOwnProperty.call(cT,e)}function cO(e){return Object.prototype.hasOwnProperty.call(cP,e)}function cI(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function cq(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}Object.keys(cT),Object.keys(cP);let cj={ok:!1,reason:"not-in-era"},cA=[oW,oY],cz={era:"2026-07-28",hasRequestMethod:cE,hasNotificationMethod:cO,hasInputRequestMethod:e=>void 0!==c$(e),validateRequest:(e,t)=>cq(cE(e)?cu().dispatchRequestSchemas[e]:void 0,t),validateResult:(e,t)=>cq(Object.prototype.hasOwnProperty.call(cT,e)?cu().dispatchResultSchemas[e]:void 0,t),validateNotification:(e,t)=>cq(cO(e)?cu().notificationSchemas2026[e]:void 0,t),validateInputRequest:(e,t)=>cq(c$(e),t),validateInputResponse:(e,t)=>cq(cC(e)?cx().response[e]:void 0,t),samplingResultVariant:()=>cj,outboundEnvelope:e=>({[oW]:e.protocolVersion,[oG]:e.clientInfo,[oY]:e.clientCapabilities,...void 0!==e.logLevel&&{[oQ]:e.logLevel}}),validateEnvelopeMeta(e){let t=[];for(let r of cA)r in e||t.push({key:r,problem:"missing"});let r=cu().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let e of r.error.issues){let r=e.path.map(String),i=r.length>0?r.join("."):"_meta";1===r.length&&t.some(e=>e.key===i&&"missing"===e.problem)||t.push({key:i,problem:e.message})}return t},projectCallToolResult:e=>l1(e),inputRequestSchema:c$,decodeResult(e,t){if(!cI(t))return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(void 0===r)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if("string"!=typeof r)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if("input_required"===r){let r=t.inputRequests,i=cI(r)?r:{},n=t.requestState,o=void 0===t._meta?void 0:cu().ResultMetaSchema.safeParse(t._meta),a=o?.success?o.data:void 0;return 0===Object.keys(i).length&&"string"!=typeof n?{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:i,..."string"==typeof n&&{requestState:n},...void 0!==a&&{_meta:a}}}if("complete"!==r)return{kind:"invalid",error:new lW(lB.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let i=cL(),n=Object.hasOwn(i,e)?i[e]:void 0;if(void 0!==n){let r=n.safeParse(t);if(!r.success)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: ${r.error}`,{method:e})}}let o={...t};return delete o.resultType,{kind:"complete",result:o}},encodeResult:(e,t,r)=>(function(e,t){if(void 0===t)return e;let r=e._meta;return void 0===r?{...e,_meta:{[oK]:t}}:null===r||"object"!=typeof r||Array.isArray(r)||void 0!==r[oK]?e:{...e,_meta:{...r,[oK]:t}}})(function(e,t){var r,i;let n=t[cp];if("complete"!==t.resultType||!cd.includes(e)){let e;return void 0===n?t:(e={...t},delete e[cp],e)}let o=ch(t.ttlMs)?t.ttlMs:void 0!==(r=n)&&ch(r.ttlMs)?r.ttlMs:0,a=cf(t.cacheScope)?t.cacheScope:void 0!==(i=n)&&cf(i.cacheScope)?i.cacheScope:"private",s={...t,ttlMs:o,cacheScope:a};return delete s[cp],s}(e,function(e,t){let r=t.resultType;if(void 0===r)return{...t,resultType:"complete"};if("complete"===r||cR.includes(e))return t;throw new cv(cy.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}(e,function(e,t){let r=t,i=!1,n=()=>(i||(r={...r},i=!0),r),o=t.tools;"tools/list"===e&&Array.isArray(o)&&o.some(e=>cI(e)&&"execution"in e)&&(n().tools=o.map(e=>{if(!cI(e)||!("execution"in e))return e;let t={...e};return delete t.execution,t}));let a=t.capabilities;if(cI(a)&&"tasks"in a){let e={...a};delete e.tasks,n().capabilities=e}return r}(e,t))),r),encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope(e){if(void 0===e.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=cu().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join("; ")}`}};function cL(){if(a)return a;let e=cu();return a={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema}}let cN="2026-07-28";function cM(e){return void 0!==e&&e>=lX?cz:cc}function cZ(e){return void 0!==e.revision?cM(e.revision).era:"modern"===e.era?cz.era:cc.era}function cU(e){return cD.some(t=>t.hasRequestMethod(e))}function cF(e){return cD.some(t=>t.hasNotificationMethod(e))}function cH(e){return"tasks/get"===e||"tasks/cancel"===e}let cD=[cc,cz];function cV(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function cJ(e){if(!cV(e))return;let t=e._meta;return cV(t)?t:void 0}function cB(e){let t=cJ(e);return void 0!==t&&oW in t}function cW(e){let t=cJ(e)?.[oW];return"string"==typeof t?t:void 0}function cG(e){return cM(cN).validateEnvelopeMeta(e)}var cK=(e=>{let t={};for(var r in e)V(t,r,{get:e[r],enumerable:!0});return t})({AnnotationsSchema:()=>aH,AudioContentSchema:()=>sc,BaseMetadataSchema:()=>ay,BaseRequestParamsSchema:()=>o7,BlobResourceContentsSchema:()=>aU,BooleanSchemaSchema:()=>sD,CallToolRequestParamsSchema:()=>sk,CallToolRequestSchema:()=>sx,CallToolResultSchema:()=>sw,CancelTaskRequestSchema:()=>lb,CancelTaskResultSchema:()=>lS,CancelledNotificationParamsSchema:()=>am,CancelledNotificationSchema:()=>ah,ClientCapabilitiesSchema:()=>aR,ClientNotificationSchema:()=>lR,ClientRequestSchema:()=>lw,ClientResultSchema:()=>lk,ClientTasksCapabilitySchema:()=>aS,CompatibilityCallToolResultSchema:()=>sR,CompleteRequestParamsSchema:()=>lt,CompleteRequestSchema:()=>lr,CompleteResultSchema:()=>li,ContentBlockSchema:()=>sm,CreateMessageRequestParamsSchema:()=>sZ,CreateMessageRequestSchema:()=>sU,CreateMessageResultSchema:()=>sF,CreateMessageResultWithToolsSchema:()=>sH,CreateTaskResultSchema:()=>ld,CursorSchema:()=>o4,DiscoverRequestSchema:()=>aP,DiscoverResultSchema:()=>aE,ElicitRequestFormParamsSchema:()=>s2,ElicitRequestParamsSchema:()=>s4,ElicitRequestSchema:()=>s5,ElicitRequestURLParamsSchema:()=>s9,ElicitResultSchema:()=>s7,ElicitationCompleteNotificationParamsSchema:()=>s3,ElicitationCompleteNotificationSchema:()=>s6,EmbeddedResourceSchema:()=>sd,EmptyResultSchema:()=>ap,EnumSchemaSchema:()=>s0,GetPromptRequestParamsSchema:()=>so,GetPromptRequestSchema:()=>sa,GetPromptResultSchema:()=>sf,GetTaskPayloadRequestSchema:()=>lg,GetTaskPayloadResultSchema:()=>ly,GetTaskRequestSchema:()=>lh,GetTaskResultSchema:()=>lf,IconSchema:()=>af,IconsSchema:()=>ag,ImageContentSchema:()=>sl,ImplementationSchema:()=>av,InitializeRequestParamsSchema:()=>ak,InitializeRequestSchema:()=>ax,InitializeResultSchema:()=>a$,InitializedNotificationSchema:()=>aT,JSONArraySchema:()=>o2,JSONObjectSchema:()=>o1,JSONRPCErrorResponseSchema:()=>ac,JSONRPCMessageSchema:()=>au,JSONRPCNotificationSchema:()=>as,JSONRPCRequestSchema:()=>aa,JSONRPCResponseSchema:()=>ad,JSONRPCResultResponseSchema:()=>al,JSONValueSchema:()=>o0,LegacyTitledEnumSchemaSchema:()=>sG,ListChangedOptionsBaseSchema:()=>s$,ListPromptsRequestSchema:()=>si,ListPromptsResultSchema:()=>sn,ListResourceTemplatesRequestSchema:()=>aW,ListResourceTemplatesResultSchema:()=>aG,ListResourcesRequestSchema:()=>aJ,ListResourcesResultSchema:()=>aB,ListRootsRequestSchema:()=>lo,ListRootsResultSchema:()=>la,ListTasksRequestSchema:()=>lv,ListTasksResultSchema:()=>l_,ListToolsRequestSchema:()=>sb,ListToolsResultSchema:()=>sS,LoggingLevelSchema:()=>sT,LoggingMessageNotificationParamsSchema:()=>sO,LoggingMessageNotificationSchema:()=>sI,ModelHintSchema:()=>sq,ModelPreferencesSchema:()=>sj,MultiSelectEnumSchemaSchema:()=>sQ,NotificationSchema:()=>ar,NotificationsParamsSchema:()=>at,NumberSchemaSchema:()=>sJ,PaginatedRequestParamsSchema:()=>aA,PaginatedRequestSchema:()=>az,PaginatedResultSchema:()=>aL,PingRequestSchema:()=>aO,PrimitiveSchemaDefinitionSchema:()=>s1,ProgressNotificationParamsSchema:()=>aq,ProgressNotificationSchema:()=>aj,ProgressSchema:()=>aI,ProgressTokenSchema:()=>o9,PromptArgumentSchema:()=>st,PromptListChangedNotificationSchema:()=>sg,PromptMessageSchema:()=>sh,PromptReferenceSchema:()=>le,PromptSchema:()=>sr,ReadResourceRequestParamsSchema:()=>aK,ReadResourceRequestSchema:()=>aY,ReadResourceResultSchema:()=>aX,RelatedTaskMetadataSchema:()=>o3,RequestIdSchema:()=>ao,RequestMetaSchema:()=>o6,RequestSchema:()=>ae,ResourceContentsSchema:()=>aN,ResourceLinkSchema:()=>sp,ResourceListChangedNotificationSchema:()=>aQ,ResourceRequestParamsSchema:()=>aK,ResourceSchema:()=>aD,ResourceTemplateReferenceSchema:()=>s8,ResourceTemplateSchema:()=>aV,ResourceUpdatedNotificationParamsSchema:()=>a8,ResourceUpdatedNotificationSchema:()=>se,ResultMetaObjectSchema:()=>ai,ResultSchema:()=>an,RoleSchema:()=>aF,RootSchema:()=>ln,RootsListChangedNotificationSchema:()=>ls,SamplingContentSchema:()=>sL,SamplingMessageContentBlockSchema:()=>sN,SamplingMessageSchema:()=>sM,ServerCapabilitiesSchema:()=>aC,ServerNotificationSchema:()=>lC,ServerRequestSchema:()=>lx,ServerResultSchema:()=>l$,ServerTasksCapabilitySchema:()=>aw,SetLevelRequestParamsSchema:()=>sP,SetLevelRequestSchema:()=>sE,SingleSelectEnumSchemaSchema:()=>sK,StringSchemaSchema:()=>sV,SubscribeRequestParamsSchema:()=>aK,SubscribeRequestSchema:()=>a0,SubscriptionFilterSchema:()=>a2,SubscriptionsAcknowledgedNotificationParamsSchema:()=>a5,SubscriptionsAcknowledgedNotificationSchema:()=>a3,SubscriptionsListenRequestParamsSchema:()=>a9,SubscriptionsListenRequestSchema:()=>a4,SubscriptionsListenResultMetaSchema:()=>a6,SubscriptionsListenResultSchema:()=>a7,TaskAugmentedRequestParamsSchema:()=>o8,TaskCreationParamsSchema:()=>ll,TaskMetadataSchema:()=>o5,TaskSchema:()=>lu,TaskStatusNotificationParamsSchema:()=>lp,TaskStatusNotificationSchema:()=>lm,TaskStatusSchema:()=>lc,TextContentSchema:()=>ss,TextResourceContentsSchema:()=>aM,TitledMultiSelectEnumSchemaSchema:()=>sX,TitledSingleSelectEnumSchemaSchema:()=>sW,ToolAnnotationsSchema:()=>sy,ToolChoiceSchema:()=>sA,ToolExecutionSchema:()=>sv,ToolListChangedNotificationSchema:()=>sC,ToolResultContentSchema:()=>sz,ToolSchema:()=>s_,ToolUseContentSchema:()=>su,UnsubscribeRequestParamsSchema:()=>aK,UnsubscribeRequestSchema:()=>a1,UntitledMultiSelectEnumSchemaSchema:()=>sY,UntitledSingleSelectEnumSchemaSchema:()=>sB});let cY=e=>aa.safeParse(e).success,cX=e=>as.safeParse(e).success,cQ=e=>al.safeParse(e).success,c0=e=>ac.safeParse(e).success,c1=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"input_required"===e.resultType,c2="x-mcp-header",c9=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,c4=new Set(["string","integer","boolean"]);function c5(e){let t,r=[],i=new Map,n=(e,o,a)=>{if(null===e||"object"!=typeof e)return;if(c2 in e){if(!a||0===o.length)return`${c7(o)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let n=e[c2];if("string"!=typeof n||0===n.length)return`${c7(o)}: x-mcp-header MUST be a non-empty string`;if(!c9.test(n))return`${c7(o)}: x-mcp-header '${n}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let s="string"==typeof e.type?e.type:void 0;if(void 0===s||!c4.has(s)){let e=`${c7(o)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${s??"<none>"}`;if("number"!==s)return e;t??=e}let l=n.toLowerCase(),c=i.get(l);if(void 0!==c)return`x-mcp-header '${n}' is not case-insensitively unique (also declared as '${c}')`;i.set(l,n),r.push({path:o,headerName:n,type:s})}let s=e.properties;if(null!==s&&"object"==typeof s)for(let[e,t]of Object.entries(s)){let r=n(t,[...o,e],a);if(void 0!==r)return r}for(let t of c3){let r=e[t];if(void 0!==r)for(let e of Array.isArray(r)?r:null!==r&&"object"==typeof r&&c6.has(t)?Object.values(r):[r]){let r=n(e,[...o,`<${t}>`],!1);if(void 0!==r)return r}}},o=n(e,[],!0);return void 0!==o?{valid:!1,reason:t??o}:void 0===t?{valid:!0,declarations:r}:{valid:!1,reason:t,declarations:r}}let c3=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],c6=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function c7(e){return 0===e.length?"<root>":e.join(".")}let c8=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,ue=/^-?\d+(\.\d+)?$/;function ut(e){if(!(e.startsWith("=?base64?")&&e.endsWith("?=")))return e;let t=e.slice(9,e.length-2);if(c8.test(t))try{let e=atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.codePointAt(t);return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{return}}function ur(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:ui,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}let ui=-32020;cy.InvalidRequest,cy.UnsupportedProtocolVersion,cy.InvalidParams,cy.MethodNotFound,cy.InvalidParams,cy.MissingRequiredClientCapability;let un={[cy.ParseError]:400,[cy.InvalidRequest]:400,[cy.MethodNotFound]:404,[cy.UnsupportedProtocolVersion]:400,[cy.MissingRequiredClientCapability]:400,[ui]:400};function uo(e,t,r,i,n){return{kind:"reject",rung:e,cell:t,httpStatus:r,code:i.code,message:i.message,...void 0!==i.data&&{data:i.data},settled:n}}function ua(e,t,r,i="era-classification"){return uo(i,e,400,new cv(ui,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}let us={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function ul(e){let t=0;for(;t<e.length;){let r=e.codePointAt(t);if(9!==r&&32!==r)break;t+=1}let r=e.length;for(;r>t;){let t=e.codePointAt(r-1);if(9!==t&&32!==t)break;r-=1}return 0===t&&r===e.length?e:e.slice(t,r)}function uc(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function uu(e){return void 0===e?{era:"modern"}:{era:e>=lX?"modern":"legacy",revision:e}}function ud(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function up(e){if(null==e)return!1;let t=typeof e;return("object"===t||"function"===t)&&"~standard"in e&&"function"==typeof e["~standard"]?.validate}let um=!1,uh="draft-2020-12";function uf(e,t="input"){let r,i=e["~standard"];if(i.jsonSchema)r=i.jsonSchema[t]({target:uh});else if("zod"===i.vendor){if(!("_zod"in e))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");um||(um=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=nn(e,{target:uh,io:t})}else throw Error(`Schema library "${i.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===t)return void 0!==r.type||!function e(t,r=t){if("properties"in t||"patternProperties"in t||"additionalProperties"in t||"required"in t)return!0;let i="string"==typeof t.$ref&&ug.exec(t.$ref);if(i&&r[i[1]]?.[i[2]]?.type==="object")return!0;for(let i of["oneOf","anyOf","allOf"]){let n=t[i];if(Array.isArray(n)&&n.length>0)return n.every(t=>null!==t&&"object"==typeof t&&("object"===t.type||e(t,"$id"in t?{}:r)))}return!1}(r)?r:{type:"object",...r};if(void 0!==r.type&&"object"!==r.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...r}}let ug=/^#\/(\$defs|definitions)\/([^/~%]+)$/;async function uy(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(e=>e.path?.length?`${e.path.map(e=>String("object"==typeof e?e.key:e)).join(".")}: ${e.message}`:e.message).join(", ")}:{success:!0,data:r.value}}let uv=/\\\.\\d\{(\d+)\}/;function u_(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let ub=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function uS(e){return ub.has(e)||e.startsWith("x-")}let uw=new Set(["$schema",...Object.keys(s2.shape.requestedSchema.shape)]),uR={string:ud([sV,sB,sW,sG]),number:ud([sJ]),integer:ud([sJ]),boolean:ud([sD]),array:ud([sY,sX])},uk=new Set(sV.shape.format.unwrap().options);Object.assign(function(e){let t=void 0!==e.inputRequests&&Object.keys(e.inputRequests).length>0,r="string"==typeof e.requestState;if(!t&&!r)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==e.inputRequests&&{inputRequests:e.inputRequests},...void 0!==e.requestState&&{requestState:e.requestState}}},{elicit(e){try{return{method:"elicitation/create",params:function(e){var t;if(!up(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let r=e.requestedSchema["~standard"].vendor,i=function(e,t){let r={},i=[];for(let[n,o]of Object.entries(e))"properties"===n&&u_(o)?r[n]=Object.fromEntries(Object.entries(o).map(([e,r])=>[e,function(e,t,r,i){if(!u_(e))return e;let n="string"==typeof e.type&&Object.hasOwn(uR,e.type)?uR[e.type]:void 0;if(void 0===n)return e;let o={};for(let[s,l]of Object.entries(e))if(n.has(s)||uS(s))o[s]=l;else if("pattern"===s&&"string"===e.type&&"string"==typeof e.format)if(uk.has(e.format)){var a;"string"==typeof l&&(a=e.format,"zod"!==r||(function(e,t){let r;switch(e){case"email":r=[r3(nH,void 0)];break;case"uri":r=[r6(nJ,void 0)];break;case"date":r=[r8(nZ,void 0)];break;case"date-time":let i,n;i=uv.exec(t),n=[void 0,-1,0],i&&n.push(Number(i[1])),r=[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(r=>r7(nM,{local:e,offset:t,precision:r}))))}return new Set(r.map(e=>{let t;return t=nn(e,{target:uh,io:"input"}),"string"==typeof t.pattern?t.pattern:void 0}).filter(e=>void 0!==e))})(a,l).has(l))||i.push(`${t}.${s}`)}else o[s]=l;else i.push(`${t}.${s}`);return o}(r,`properties.${e}`,t,i)])):uw.has(n)?r[n]=o:uS(n)||i.push(n);if(i.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(", ")}`);return r}(function(e){try{return uf(e,"input")}catch(t){let e=t instanceof Error?t.message:String(t);throw new cv(cy.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${e}`)}}(e.requestedSchema),r),n=(t=s2.shape.requestedSchema,nR(t,i));if(!n.success)throw new cv(cy.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(e,t){if(!u_(e.properties))return t;let r=Object.entries(e.properties).filter(([,e])=>!nR(s1,e).success).map(([e])=>`properties.${e}`);return r.length>0?r.join(", "):t}(i,n.error.message)}`);let o=function e(t,r,i=""){return Array.isArray(t)&&Array.isArray(r)?t.flatMap((t,n)=>e(t,r[n],`${i}[${n}]`)):u_(t)&&u_(r)?Object.entries(t).flatMap(([t,n])=>{let o=i?`${i}.${t}`:t;return Object.prototype.hasOwnProperty.call(r,t)?e(n,r[t],o):uS(t)?[]:[o]}):[]}(i,n.data);if(o.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);let a=(n.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(n.data.properties,e));if(a.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(", ")}`);return{...e,mode:"form",requestedSchema:n.data}}(e)}}catch(e){throw e instanceof cv?TypeError(e.message,{cause:e}):e}},elicitUrl:e=>({method:"elicitation/create",params:{...e,mode:"url"}}),createMessage:e=>({method:"sampling/createMessage",params:e}),listRoots:()=>({method:"roots/list"})});let ux={},uC={};function u$(e,t){let r=e.slice(0,-6);ux[r]=t,uC[r]=e=>t.safeParse(e).success}for(let e of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])u$(e,cK[e]);for(let[e,t]of Object.entries({IdJagTokenExchangeResponseSchema:lj,OAuthClientInformationFullSchema:lM,OAuthClientInformationSchema:lN,OAuthClientMetadataSchema:lL,OAuthClientRegistrationErrorSchema:lZ,OAuthErrorResponseSchema:lA,OAuthMetadataSchema:lE,OAuthProtectedResourceMetadataSchema:lP,OAuthTokenRevocationRequestSchema:lU,OAuthTokensSchema:lq,OpenIdProviderDiscoveryMetadataSchema:lI,OpenIdProviderMetadataSchema:lO}))u$(e,t);let uT=Object.freeze(ux);Object.freeze(uC);let uP=[oW,oG,oY,oQ],uE=["inputResponses","requestState"];function uO(e,t){let r=e.params;if(!uz(r))return{message:e,lifted:{}};let i=r._meta,n=uz(i)?uP.filter(e=>e in i):[],o="request"===t?uE.filter(e=>e in r):[];if(0===n.length&&0===o.length)return{message:e,lifted:{}};let a={},s={...r};if(n.length>0&&uz(i)){let e={},t={...i};for(let r of n)e[r]=i[r],delete t[r];a.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of o)"inputResponses"===e&&(a.inputResponses=s[e]),"requestState"===e&&(a.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:a}}function uI(e,t){let r=e.validateResult(t,void 0);if(r.ok||"not-in-era"!==r.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let i=e.validateResult(t,r);return i.ok?{value:i.value}:{issues:[{message:"invalid"===i.reason?i.message:`not-in-era: ${t}`}]}}}}}let uq=(P=void 0,()=>P);function uj(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:()=>t}}}var uA=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{s=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??oB,this.setNotificationHandler("notifications/cancelled",e=>{this._oncancel(e)}),this.setNotificationHandler("notifications/progress",e=>{this._onprogress(e)}),this.setRequestHandler("ping",e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(void 0===t)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new lW(lB.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){void 0!==e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,i,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:n,onTimeout:i})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new lW(lB.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};let i=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{i?.(e,t),cQ(e)||c0(e)?this._onresponse(e):cY(e)?this._onrequest(e,t):cX(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;for(let e of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new lW(lB.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(r);for(let e of t.values())e.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=uO(e,"notification"),i=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return;if(t?.classification!==void 0){let e=cZ(t.classification);if(e!==i.era)return void this._onerror(Error(`Era mismatch on inbound notification '${r.method}': classified as ${e} but this instance serves ${i.era}`))}if(cF(r.method)&&!i.hasNotificationMethod(r.method))return;let n=this._notificationHandlers.get(r.method),o=this.fallbackNotificationHandler;(void 0!==n||void 0!==o)&&Promise.resolve().then(()=>void 0===n?o(r):n(r,i)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){var r;let{message:i,lifted:n}=uO(e,"request"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return void this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));let a=this._transport,s=(e,t,r)=>{let n={jsonrpc:"2.0",id:i.id,error:{code:e,message:t,...void 0!==r&&{data:r}}};a?.send(n).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=cZ(t.classification);if(e!==o.era){this._onerror(Error(`Era mismatch on inbound request '${i.method}': classified as ${e} but this instance serves ${o.era}`));let r=t.classification.revision??e;s(cy.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(cU(i.method)&&!o.hasRequestMethod(i.method)&&!(cH(i.method)&&this._customSchemaRequestMethods.has(i.method)))return void s(cy.MethodNotFound,"Method not found");let l=this._requestHandlers.get(i.method)??this.fallbackRequestHandler;if(void 0===l)return void s(cy.MethodNotFound,"Method not found");let c=o.checkInboundEnvelope(n);if(void 0!==c)return void s(cy.InvalidParams,c);let u=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:i.id}),d=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:i.id}),p=new AbortController;this._requestHandlerAbortControllers.set(i.id,p);let m=void 0===n.inputResponses?void 0:function(e){let t={},r=[];if(!uL(e))return{accepted:t,droppedKeys:r};for(let[i,n]of Object.entries(e)){if(!uL(n)||"method"in n||"result"in n){r.push(i);continue}t[i]=n}return{accepted:t,droppedKeys:r}}(n.inputResponses),h={sessionId:a?.sessionId,mcpReq:{id:i.id,method:i.method,_meta:i.params?._meta,...void 0!==n.envelope&&{envelope:n.envelope},...void 0!==m&&{inputResponses:m.accepted},...void 0!==m&&m.droppedKeys.length>0&&{droppedInputResponseKeys:m.droppedKeys},requestState:void 0===n.requestState?uq:(r=n.requestState,()=>r),signal:p.signal,send:(e,t,r)=>{let i=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(i,e.method),up(t))return d(e,t,r);let n=uI(i,e.method);if(void 0===n)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(e,n,t)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},f=this.buildContext(h,t);Promise.resolve().then(()=>l(i,f)).then(async e=>{let t;if(p.signal.aborted)return;try{t=o.encodeResult(i.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${i.method}: ${e}`)),s(cy.InternalError,"Internal error");return}let r={result:t,jsonrpc:"2.0",id:i.id};await a?.send(r)},async e=>{if(p.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:cy.InternalError,r={jsonrpc:"2.0",id:i.id,error:{code:o.encodeErrorCode(t),message:e.message??"Internal error",...void 0!==e.data&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(i.id)===p&&this._requestHandlerAbortControllers.delete(i.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,i=Number(t),n=this._progressHandlers.get(i);if(!n)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));let o=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&o&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(e){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),o(e);return}n(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);void 0===r?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`)):(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),r(cQ(e)?e:cv.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let i=this._resolveOutboundCodec(e.method);if(up(t))return cH(e.method)||this._assertOutboundRequestInEra(i,e.method),this._requestWithSchemaViaCodec(i,e,t,r);this._assertOutboundRequestInEra(i,e.method);let n=uI(i,e.method);if(void 0===n)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(i,e,n,t)}_negotiatedWireCodec(){return cM(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(void 0===this._negotiatedProtocolVersion){let t=function(e){switch(e){case"initialize":case"notifications/initialized":return cM(void 0);case"server/discover":return cM(cN);default:return}}(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(cU(t)&&!e.hasRequestMethod(t))throw new lW(lB.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let i=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(i,e.method),this._requestWithSchemaViaCodec(i,e,t,r)}_requestWithSchemaViaCodec(e,t,r,i){let n,o,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l,headers:c}=i??{},u=Date.now();return new Promise((d,p)=>{let m=e=>{p(e)};if(!this._transport)return void m(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){m(e);return}if(i?.signal?.aborted){let e=i.signal.reason;throw e instanceof lW?e:new lW(lB.RequestTimeout,String(e))}let h=e.era===cN&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,f=this._requestMessageId++;o=f;let g={...t,jsonrpc:"2.0",id:f};i?.onprogress&&(this._progressHandlers.set(f,i.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:f}});let y=this._envelopeOutbound(g),v=!1,_=e=>{v||(this._progressHandlers.delete(f),void 0===h?"initialize"!==t.method&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(e)}}),{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):h.abort(),p(e instanceof lW?e:new lW(lB.RequestTimeout,String(e))))};this._responseHandlers.set(f,n=>{let o;if(!i?.signal?.aborted){if(v=!0,n instanceof Error)return p(n);try{o=e.decodeResult(t.method,n.result)}catch(e){return p(e instanceof Error?e:Error(String(e)))}if("invalid"===o.kind)return p(o.error);if("input_required"===o.kind){var a;return i?.allowInputRequired===!0?d({resultType:"input_required",inputRequests:(a=o).inputRequests,...void 0!==a.requestState&&{requestState:a.requestState},...void 0!==a._meta&&{_meta:a._meta}}):d(this._resolveNonCompleteResult(o,{codec:e,request:t,resultSchema:r,options:i,flowStartedAt:u,retry:(i,n)=>this._requestWithSchemaViaCodec(e,void 0===i?{method:t.method}:{method:t.method,params:i},r,n)}))}uy(r,o.result).then(e=>{e.success?d(e.data):p(new lW(lB.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},p)}}),n=()=>_(i?.signal?.reason),i?.signal?.addEventListener("abort",n,{once:!0});let b=i?.timeout??6e4;this._setupTimeout(f,b,i?.maxTotalTimeout,()=>_(new lW(lB.RequestTimeout,"Request timed out",{timeout:b})),i?.resetTimeoutOnProgress??!1),this._transport.send(y,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l,headers:c,requestSignal:h?.signal}).catch(e=>{this._progressHandlers.delete(f),p(e)})}).finally(()=>{n&&i?.signal?.removeEventListener("abort",n),void 0!==o&&(this._responseHandlers.delete(o),this._cleanupTimeout(o))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new lW(lB.NotConnected,"Not connected");if(cF(t.method)&&!e.hasNotificationMethod(t.method))throw new lW(lB.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let i=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(i,r).catch(e=>this._onerror(e))});return}await this._transport.send(i,r)}setRequestHandler(e,t,r){let i;if(this.assertRequestHandlerCapability(e),"function"==typeof t){if(!cU(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);i=(r,i)=>{let n=this._negotiatedWireCodec(),o=n.validateRequest(e,r);if(o.ok||"not-in-era"!==o.reason||(o=n.validateInputRequest(e,r)),!o.ok){if("not-in-era"===o.reason)throw new cv(cy.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(o.message)}return Promise.resolve(t(o.value,i))}}else if(r)i=async(i,n)=>{let o=await uy(t.params,{...i.params});if(!o.success)throw new cv(cy.InvalidParams,`Invalid params for ${e}: ${o.error}`);return r(o.data,n)};else throw TypeError("setRequestHandler: handler is required");"function"==typeof t?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,i))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if("function"==typeof t){if(!cF(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,i)=>{let n=i.validateNotification(e,r);if(!n.ok){if("not-in-era"===n.reason)throw new cv(cy.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(n.message)}return Promise.resolve(t(n.value))});return}if(!r)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async i=>{let n=await uy(t.params,{...i.params});if(!n.success)throw new cv(cy.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,i)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function uz(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function uL(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var uN=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var i,n=B(t),o=0,a=n.length;o<a;o++)i=n[o],G.call(e,i)||void 0===i||V(e,i,{get:(e=>t[e]).bind(null,i),enumerable:!(r=J(t,i))||r.enumerable});return e})(V(null!=(R=(S=e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,i=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function n(e){this.parameters=Object.create(null),this.type=e}e.parse=function(e){if(!e)throw TypeError("argument string is required");var o,a,s,l="object"==typeof e?function(e){var t;if("function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]),"string"!=typeof t)throw TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof l)throw TypeError("argument string is required to be a string");var c=l.indexOf(";"),u=-1!==c?l.slice(0,c).trim():l.trim();if(!i.test(u))throw TypeError("invalid media type");var d=new n(u.toLowerCase());if(-1!==c){for(t.lastIndex=c;a=t.exec(l);){if(a.index!==c)throw TypeError("invalid parameter format");c+=a[0].length,o=a[1].toLowerCase(),34===(s=a[2]).charCodeAt(0)&&-1!==(s=s.slice(1,-1)).indexOf("\\")&&(s=s.replace(r,"$1")),d.parameters[o]=s}if(c!==l.length)throw TypeError("invalid parameter format")}return d}},()=>(w||S((w={exports:{}}).exports),w.exports))())?D(W(R)):{},"default",{value:R,enumerable:!0}),R);function uM(e){if(e)try{return uN.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();if(""===t||e.slice(t.length).includes(","))return;return t}}function uZ(e){return"application/json"===e||"application/json"===uM(e)}let uU=/^[A-Za-z0-9._-]{1,128}$/;function uF(e){let t=function(e){let t=[];if(0===e.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!uU.test(e)){let r=[...e].filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,r)=>r.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${r.map(e=>`"${e}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}(e);var r=t.warnings;if(r.length>0){for(let t of(console.warn(`Tool name validation warning for "${e}":`),r))console.warn(` - ${t}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}return t.isValid}var uH=class e{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,r){if(e.length>t)throw Error(`${r} exceeds maximum length of ${t} characters (got ${e.length})`)}template;parts;get variableNames(){return this.parts.flatMap(e=>"string"==typeof e?[]:e.names)}constructor(t){e.validateLength(t,1e6,"Template"),this.template=t,this.parts=this.parse(t)}toString(){return this.template}parse(t){let r=[],i="",n=0,o=0;for(;n<t.length;)if("{"===t[n]){i&&(r.push(i),i="");let a=t.indexOf("}",n);if(-1===a)throw Error("Unclosed template expression");if(++o>1e4)throw Error("Template contains too many expressions (max 10000)");let s=t.slice(n+1,a),l=this.getOperator(s),c=s.includes("*"),u=this.getNames(s),d=u[0];for(let t of u)e.validateLength(t,1e6,"Variable name");r.push({name:d,operator:l,names:u,exploded:c}),n=a+1}else i+=t[n],n++;return i&&r.push(i),r}getOperator(e){return["+","#",".","/","?","&"].find(t=>e.startsWith(t))||""}getNames(e){let t=this.getOperator(e);return e.slice(t.length).split(",").map(e=>e.replace("*","").trim()).filter(e=>e.length>0)}encodeValue(t,r){return(e.validateLength(t,1e6,"Variable value"),"+"===r||"#"===r)?encodeURI(t):encodeURIComponent(t)}expandPart(e,t){if("?"===e.operator||"&"===e.operator){let r=e.names.map(r=>{let i=t[r];return void 0===i?"":`${r}=${Array.isArray(i)?i.map(t=>this.encodeValue(t,e.operator)).join(","):this.encodeValue(i.toString(),e.operator)}`}).filter(e=>e.length>0);return 0===r.length?"":("?"===e.operator?"?":"&")+r.join("&")}if(e.names.length>1){let r=e.names.map(e=>t[e]).filter(e=>void 0!==e);return 0===r.length?"":r.map(e=>Array.isArray(e)?e[0]:e).join(",")}let r=t[e.name];if(void 0===r)return"";let i=(Array.isArray(r)?r:[r]).map(t=>this.encodeValue(t,e.operator));switch(e.operator){case"":case"+":default:return i.join(",");case"#":return"#"+i.join(",");case".":return"."+i.join(".");case"/":return"/"+i.join("/")}}expand(e){let t="",r=!1;for(let i of this.parts){if("string"==typeof i){t+=i;continue}let n=this.expandPart(i,e);n&&(t+=("?"===i.operator||"&"===i.operator)&&r?n.replace("?","&"):n,("?"===i.operator||"&"===i.operator)&&(r=!0))}return t}escapeRegExp(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(t){let r,i=[];for(let r of t.names)e.validateLength(r,1e6,"Variable name");if("?"===t.operator||"&"===t.operator){for(let e=0;e<t.names.length;e++){let r=t.names[e],n=0===e?"\\"+t.operator:"&";i.push({pattern:n+this.escapeRegExp(r)+"=([^&]+)",name:r})}return i}let n=t.name;switch(t.operator){case"":r=t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":r="(.+)";break;case".":r=String.raw`\.([^/,]+)`;break;case"/":r="/"+(t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:r="([^/]+)"}return i.push({pattern:r,name:n}),i}match(t){e.validateLength(t,1e6,"URI");let r="^",i=[];for(let e of this.parts)if("string"==typeof e)r+=this.escapeRegExp(e);else for(let{pattern:t,name:n}of this.partToRegExp(e))r+=t,i.push({name:n,exploded:e.exploded});r+="$",e.validateLength(r,1e6,"Generated regex pattern");let n=new RegExp(r),o=t.match(n);if(!o)return null;let a={};for(let[e,t]of i.entries()){let{name:r,exploded:i}=t,n=o[e+1];a[r.replace("*","")]=i&&n.includes(",")?n.split(","):n}return a}};function uD(e){if(void 0!==e){if(function(e){if("object"!=typeof e||null===e||up(e))return!1;let t=Object.getPrototypeOf(e);return(t===Object.prototype||null===t)&&Object.values(e).every(e=>"object"==typeof e&&null!==e&&"_zod"in e)}(e))return om(e);if("object"==typeof e&&null!==e&&!up(e)&&Object.values(e).some(e=>"object"==typeof e&&null!==e&&!("_zod"in e)&&"_def"in e&&"string"==typeof e._def?.typeName))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!up(e))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return e}}function uV(){l4(),cu(),cr(),cx(),cL()}function uJ(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let i=0;i<r;i++)if(!uJ(e[i],t[i]))return!1;return!0}if("object"===r){if(!e||!t)return e===t;let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!uJ(e[i],t[i]))return!1;return!0}return e===t}function uB(e){return encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1"))}let uW={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},uG={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},uK={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},uY="u">typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function uX(e,t=Object.create(null),r=uY,i=""){if(e&&"object"==typeof e&&!Array.isArray(e)){let n=e.$id||e.id;if(n){let o=new URL(n,r.href);o.hash.length>1?t[o.href]=e:(o.hash="",""===i?r=o:uX(e,t,r))}}else if(!0!==e&&!1!==e)return t;let n=r.href+(i?"#"+i:"");if(void 0!==t[n])throw Error(`Duplicate schema URI "${n}".`);if(t[n]=e,!0===e||!1===e)return t;if(void 0===e.__absolute_uri__&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&void 0===e.__absolute_ref__){let t=new URL(e.$ref,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&void 0===e.__absolute_recursive_ref__){let t=new URL(e.$recursiveRef,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}for(let n in e.$anchor&&(t[new URL("#"+e.$anchor,r.href).href]=e),e){if(uK[n])continue;let o=`${i}/${uB(n)}`,a=e[n];if(Array.isArray(a)){if(uW[n]){let e=a.length;for(let i=0;i<e;i++)uX(a[i],t,r,`${o}/${i}`)}}else if(uG[n])for(let e in a)uX(a[e],t,r,`${o}/${uB(e)}`);else uX(a,t,r,o)}return t}let uQ=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,u0=[0,31,28,31,30,31,30,31,31,30,31,30,31],u1=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function u2(e){return e.test.bind(e)}let u9={date:u4,time:u5.bind(void 0,!1),"date-time":function(e){let t=e.split(u3);return 2==t.length&&u4(t[0])&&u5(!0,t[1])},duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),uri:function(e){return u6.test(e)&&u7.test(e)},"uri-reference":u2(/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i),"uri-template":u2(/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i),url:u2(/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu),email:e=>{if('"'===e[0])return!1;let[t,r,...i]=e.split("@");return!(!t||!r||0!==i.length||t.length>64||r.length>253||"."===t[0]||t.endsWith(".")||t.includes(".."))&&!!/^[a-z0-9.-]+$/i.test(r)&&!!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)&&r.split(".").every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},hostname:u2(/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i),ipv4:u2(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:u2(/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i),regex:function(e){if(u8.test(e))return!1;try{return RegExp(e,"u"),!0}catch(e){return!1}},uuid:u2(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":u2(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":u2(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":u2(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function u4(e){var t;let r=e.match(uQ);if(!r)return!1;let i=+r[1],n=+r[2],o=+r[3];return n>=1&&n<=12&&o>=1&&o<=(2==n&&(t=i)%4==0&&(t%100!=0||t%400==0)?29:u0[n])}function u5(e,t){let r=t.match(u1);if(!r)return!1;let i=+r[1],n=+r[2],o=+r[3],a=!!r[5];return(i<=23&&n<=59&&o<=59||23==i&&59==n&&60==o)&&(!e||a)}let u3=/t|\s/i,u6=/\/|:/,u7=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,u8=/[^\\]\\Z/;var de=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",r=!0){this.schema=e,this.draft=t,this.shortCircuit=r,this.lookup=uX(e)}validate(e){return function e(t,r,i="2019-09",n=uX(r),o=!0,a=null,s="#",l="#",c=Object.create(null)){let u;if(!0===r)return{valid:!0,errors:[]};if(!1===r)return{valid:!1,errors:[{instanceLocation:s,keyword:"false",keywordLocation:s,error:"False boolean schema."}]};let d=typeof t;switch(d){case"boolean":case"number":case"string":u=d;break;case"object":u=null===t?"null":Array.isArray(t)?"array":"object";break;default:throw Error(`Instances of "${d}" type are not supported.`)}let{$ref:p,$recursiveRef:m,$recursiveAnchor:h,type:f,const:g,enum:y,required:v,not:_,anyOf:b,allOf:S,oneOf:w,if:R,then:k,else:x,format:C,properties:$,patternProperties:T,additionalProperties:P,unevaluatedProperties:E,minProperties:O,maxProperties:I,propertyNames:q,dependentRequired:j,dependentSchemas:A,dependencies:z,prefixItems:L,items:N,additionalItems:M,unevaluatedItems:Z,contains:U,minContains:F,maxContains:H,minItems:D,maxItems:V,uniqueItems:J,minimum:B,maximum:W,exclusiveMinimum:G,exclusiveMaximum:K,multipleOf:Y,minLength:X,maxLength:Q,pattern:ee,__absolute_ref__:et,__absolute_recursive_ref__:er}=r,ei=[];if(!0===h&&null===a&&(a=r),"#"===m){let u=null===a?n[er]:a,d=`${l}/$recursiveRef`,p=e(t,null===a?r:a,i,n,o,u,s,d,c);p.valid||ei.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:d,error:"A subschema had errors."},...p.errors)}if(void 0!==p){let r=n[et||p];if(void 0===r){let e=`Unresolved $ref "${p}".`;throw et&&et!==p&&(e+=` Absolute URI "${et}".`),Error(e+=`
|
|
55
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let r of e.seen.entries()){let i=r[1];if(t===r[0]){n(r);continue}if(e.external){let i=e.external.registry.get(r[0])?.id;if(t!==r[0]&&i){n(r);continue}}if(e.metadataRegistry.get(r[0])?.id||i.cycle){n(r);continue}i.count>1&&"ref"===e.reused&&n(r)}e.external&&(e.sharedDefsExtractedFor=e.external)}let iy=new Set(["type","properties","required","additionalProperties"]),iv=["oneOf","anyOf"];function i_(e){let t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function ib(e){let t=[];for(let r of e){if("object"!=typeof r||"object"!==r.type)return null;for(let e in r)if(!iy.has(e))return null;t.push(r)}let r={},i=new Set;for(let e of t){for(let i in e.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let e=[];for(let r of t){let t=r.properties?.[i]??i_(r);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}es(r,i,1===e.length?e[0]:ib(e)??{allOf:e})}for(let t of e.required??[])i.add(t)}let n={type:"object",properties:r};if(i.size&&(n.required=[...i]),t.every(e=>!1===e.additionalProperties))n.additionalProperties=!1;else{let e=[];for(let r of t){let t=i_(r);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?n.additionalProperties=e[0]:e.length>1&&(n.additionalProperties={allOf:e})}return n}function iS(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let i=t=>{let r=e.seen.get(t);if(null===r.ref)return;let n=r.def??r.schema,o={...n},a=r.ref;if(r.ref=null,a){i(a);let r=e.seen.get(a),s=r.schema;if(s.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(n.allOf=n.allOf??[],n.allOf.push(s)):iu(n,s),iu(n,o),t._zod.parent===a)for(let e in n)"$ref"!==e&&"allOf"!==e&&(e in o||delete n[e]);if(s.$ref&&r.def)for(let e in n)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(n[e])===JSON.stringify(r.def[e])&&delete n[e]}let s=t._zod.parent;if(s&&s!==a){i(s);let t=e.seen.get(s);if(t?.schema.$ref&&(n.$ref=t.schema.$ref,t.def))for(let e in n)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(n[e])===JSON.stringify(t.def[e])&&delete n[e]}e.override({zodSchema:t,jsonSchema:n,path:r.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())i(t[0]);if("openapi-3.0"!==e.target)for(let t of e.seen.entries())!function e(t){let r=t.anyOf;if(!Array.isArray(r)||0===r.length||void 0!==t.type)return;let i=[];for(let t of r){if(!t||"object"!=typeof t)return;e(t);let r=Object.keys(t);if(1!==r.length||"type"!==r[0])return;let n=t.type;for(let e of Array.isArray(n)?n:[n]){if("string"!=typeof e)return;i.includes(e)||i.push(e)}}delete t.anyOf,t.type=1===i.length?i[0]:i}(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let r of e.seen.values())for(let e of[r.schema,r.def]){let r=e?.allOf;if(!Array.isArray(r))continue;let i=t.get(r);i?i.push(e):t.set(r,[e])}for(let r of e.intersections)for(let e of t.get(r)??[])!function(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of iy)if(t in e)return;let r=t.filter(e=>iv.some(t=>Array.isArray(e[t]))),i=null;if(r.length){let e=r[0],n=iv.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;let o=t.filter(t=>t!==e),a=e[n].map(e=>ib([...o,e]));if(a.some(e=>!e))return;i={[n]:a}}else i=ib(t);i&&(delete e.allOf,iu(e,i))}(e)}}let n={};if("draft-2020-12"===e.target?n.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?n.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let r=e.external.registry.get(t)?.id;if(!r)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(r)}iu(n,r.defId?r.schema:r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;void 0!==o&&n.id===o&&delete n.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,es(a,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?n.$defs=a:n.definitions=a);try{let r=JSON.parse(JSON.stringify(n));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:iw(t,"input",e.processors),output:iw(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let iw=(e,t,r={})=>i=>{let{libraryOptions:n,target:o}=i??{},a=id({...n??{},target:o,io:t,processors:r});return im(e,a),ig(a,e),iS(a,e)},iR=(e,t,r)=>{(void 0===e[t]||r>e[t])&&(e[t]=r)},ik=(e,t,r)=>{(void 0===e[t]||r<e[t])&&(e[t]=r)},ix=(e,t)=>{iR(e,"minimum",t),ik(e,"maximum",t)},iC=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},i$=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},iT=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},iP=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},iO=(e,t)=>iR(e,"minimum",t.minimum),iE=(e,t)=>ik(e,"maximum",t.maximum),iI=e=>(t,r)=>{iP(t,r.format);let[i,n]=e[r.format];iR(t,"minimum",i),ik(t,"maximum",n)},iq={greater_than:(e,t)=>iR(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ik(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>iC(e,t.value),number_format:iI(ek),bigint_format:iI(ex),min_length:iO,max_length:iE,length_equals:(e,t)=>ix(e,t.length),min_size:iO,max_size:iE,size_equals:(e,t)=>ix(e,t.size),string_format:(e,t)=>{iP(e,t.format),t.pattern&&i$(e,t.pattern),("base64"===t.format||"base64url"===t.format)&&(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>iT(e,t.mime)};function ij(e){let t={},r=e._zod.def;for(let i of e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[])iq[i._zod.def.check]?.(t,i._zod.def);let i=e._zod.bag;for(let e of(void 0!==i.minimum&&iR(t,"minimum",i.minimum),void 0!==i.exclusiveMinimum&&iR(t,"exclusiveMinimum",i.exclusiveMinimum),void 0!==i.maximum&&ik(t,"maximum",i.maximum),void 0!==i.exclusiveMaximum&&ik(t,"exclusiveMaximum",i.exclusiveMaximum),void 0!==i.multipleOf&&iC(t,i.multipleOf),void 0!==i.format&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&iT(t,i.mime),i.patterns??[]))i$(t,e);return t}let iA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},iz=new Map([[rl,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[ru,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),iL=e=>iz.get(e)??e,iN=(e,t,r,i)=>{r.type="string";let{minimum:n,maximum:o,format:a,patterns:s,contentEncoding:l,laxFormat:c}=ij(e);if("number"==typeof n&&(r.minLength=n),"number"==typeof o&&(r.maxLength=o),a&&(r.format=iA[a]??a,""===r.format&&delete r.format,("time"===a||c)&&delete r.format),l&&(r.contentEncoding=l),s&&s.size>0){let e=[...s].map(iL);1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}},iM=(e,t,r,i)=>{let{minimum:n,maximum:o,multipleOf:a,exclusiveMaximum:s,exclusiveMinimum:l,isInt:c}=ij(e);r.type=c?"integer":"number";let u="number"==typeof l&&l>=(n??-1/0),d="number"==typeof s&&s<=(o??1/0),p="draft-04"===t.target||"openapi-3.0"===t.target;if(u?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof n&&(r.minimum=n),d?p?(r.maximum=s,r.exclusiveMaximum=!0):r.exclusiveMaximum=s:"number"==typeof o&&(r.maximum=o),a){let n=new Set;for(let o of a)Number.isFinite(o)&&0!==o?n.add(Math.abs(o)):ip(e,t,r,i,`A multipleOf divisor of ${o} cannot be represented in JSON Schema`);let[o,...s]=n;void 0!==o&&(r.multipleOf=o),s.length&&(r.allOf=[...r.allOf??[],...s.map(e=>({multipleOf:e}))])}},iZ=(e,t,r,i)=>{r.type="boolean"},iU=(e,t,r,i)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},iF=(e,t,r,i)=>{r.not={}},iH=(e,t,r,i)=>{},iD=(e,t,r,i)=>{},iV=(e,t,r,i)=>{let n=ee(e._zod.def.entries);if(0===n.length){r.not={};return}n.every(e=>"number"==typeof e)&&(r.type="number"),n.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=n},iJ=(e,t,r,i)=>{let n=e._zod.def;if(0===n.values.length){r.not={};return}let o=[];for(let a of n.values)if(void 0===a){if(ip(e,t,r,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof a){if(ip(e,t,r,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(0===o.length);else if(1===o.length){let e=o[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else o.every(e=>"number"==typeof e)&&(r.type="number"),o.every(e=>"string"==typeof e)&&(r.type="string"),o.every(e=>"boolean"==typeof e)&&(r.type="boolean"),o.every(e=>null===e)&&(r.type="null"),r.enum=o},iB=(e,t,r,i)=>{ip(e,t,r,i,"Custom types cannot be represented in JSON Schema")},iW=(e,t,r,i)=>{ip(e,t,r,i,"Transforms cannot be represented in JSON Schema")},iG=(e,t,r,i)=>{let n=e._zod.def,{minimum:o,maximum:a}=ij(e);"number"==typeof o&&(r.minItems=o),"number"==typeof a&&(r.maxItems=a),r.type="array",r.items=im(n.element,t,{...i,path:[...i.path,"items"]})};function iK(e){let t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?iK(t.out):"catch"===t.type?iK(t.innerType):e._zod.optin}let iY=(e,t,r,i)=>{let n=e._zod.def,o=n.shape;if(Object.getOwnPropertySymbols(o).length&&ip(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;for(let e in r.type="object",r.properties={},o)es(r.properties,e,im(o[e],t,{...i,path:[...i.path,"properties",e]}));let a=[];for(let e of Object.keys(o)){let r=n.shape[e];("input"===t.io?void 0===iK(r):void 0===r._zod.optout)&&a.push(e)}a.length>0&&(r.required=a),n.catchall?._zod.def.type==="never"?r.additionalProperties=!1:n.catchall?n.catchall&&(r.additionalProperties=im(n.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)},iX=(e,t,r,i)=>{let n=e._zod.def,o=!1===n.inclusive,a=n.options.map((e,r)=>im(e,t,{...i,path:[...i.path,o?"oneOf":"anyOf",r]}));o?r.oneOf=a:r.anyOf=a},iQ=(e,t,r,i)=>{let n=e._zod.def,o=im(n.left,t,{...i,path:[...i.path,"allOf",0]}),a=im(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length,l=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=l,t.intersections.push(l)},i0=new WeakMap,i1=(e,t,r,i)=>{let n=e._zod.def;r.type="object";let o=n.keyType,a=ij(o).patterns;if("loose"===n.mode&&a&&a.size>0){let e=im(n.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});for(let t of(r.patternProperties={},a))es(r.patternProperties,iL(t).source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){r.propertyNames=im(n.keyType,t,{...i,path:[...i.path,"propertyNames"]});let o=i0.get(t);o||(o=[],i0.set(t,o),t.deferred.push(()=>(function(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let r=new Map;for(let i of i0.get(e)??[]){let n=e.seen.get(i),o=(n?.def??n?.schema)?.propertyNames;if(!o||!0===o||r.has(o))continue;let a=function e(t,r,i){if(r.$ref){if(i.has(r))return r;i.add(r);let n=t.get(r)?.def;if(!n)return r;let o=e(t,n,i);return o===n?r:o}for(let n of["anyOf","oneOf"]){let o=r[n];if(!Array.isArray(o))continue;let a=o.map(r=>e(t,r,i));a.some((e,t)=>e!==o[t])&&(r={...r,[n]:a})}let n=Array.isArray(r.type)?r.type:[r.type],o=!n.includes("string")&&n.some(e=>"number"===e||"integer"===e),a=r.enum??(void 0!==r.const?[r.const]:void 0);if(!o&&!a?.some(e=>"number"==typeof e))return r;let{minimum:s,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:p,id:m,...h}=r;return h.enum?h.enum=h.enum.map(e=>"number"==typeof e?String(e):e):"number"==typeof h.const&&(h.const=String(h.const)),o&&(h.type="string",a||(h.pattern=(n.includes("number")?ty:tg).source)),h}(t,o,new Set);a!==o&&r.set(o,a)}if(r.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&r.get(e.propertyNames);t&&(e.propertyNames=t)}})(t))),o.push(e)}r.additionalProperties=im(n.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let s=o._zod.values,l="input"===t.io&&void 0!==iK(n.valueType);if(s&&!n.partial&&!l){let e=[...s].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(r.required=e.map(String))}},i2=(e,t,r,i)=>{let n=e._zod.def,o=im(n.innerType,t,i),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},i9=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},i4=Symbol();function i5(e,t,r,i,n){let o=!1,a=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(o=!0,null));return o?(ip(t,r,i,n,"BigInt defaults cannot be represented in JSON Schema"),i4):JSON.parse(a)}let i3=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType;let o=i5(n.defaultValue,e,t,r,i);o!==i4&&(r.default=o)},i6=(e,t,r,i)=>{let n=e._zod.def;if(im(n.innerType,t,i),t.seen.get(e).ref=n.innerType,"input"!==t.io)return;let o=i5(n.defaultValue,e,t,r,i);o!==i4&&(r._prefault=o)},i7=(e,t,r,i)=>{let n,o=e._zod.def;im(o.innerType,t,i),t.seen.get(e).ref=o.innerType;try{n=o.catchValue(void 0)}catch{ip(e,t,r,i,"Dynamic catch values are not supported in JSON Schema");return}r.default=n},i8=(e,t,r,i)=>{let n=e._zod.def,o=n.in._zod.traits.has("$ZodTransform"),a="input"===t.io?o?n.out:n.in:n.out;im(a,t,i),t.seen.get(e).ref=a},ne=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType,r.readOnly=!0},nt=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},nr=(e,t,r,i)=>{let n=e._zod.innerType;im(n,t,i),t.seen.get(e).ref=n},ni={string:iN,number:iM,boolean:iZ,bigint:(e,t,r,i)=>{ip(e,t,r,i,"BigInt cannot be represented in JSON Schema")},symbol:(e,t,r,i)=>{ip(e,t,r,i,"Symbols cannot be represented in JSON Schema")},null:iU,undefined:(e,t,r,i)=>{ip(e,t,r,i,"Undefined cannot be represented in JSON Schema")},void:(e,t,r,i)=>{ip(e,t,r,i,"Void cannot be represented in JSON Schema")},never:iF,any:iH,unknown:iD,date:(e,t,r,i)=>{ip(e,t,r,i,"Date cannot be represented in JSON Schema")},enum:iV,literal:iJ,nan:(e,t,r,i)=>{ip(e,t,r,i,"NaN cannot be represented in JSON Schema")},template_literal:(e,t,r,i)=>{let n=e._zod.pattern;if(!n)throw Error("Pattern not found in template literal");r.type="string",r.pattern=n.source},file:(e,t,r,i)=>{r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:n,maximum:o,mime:a}=ij(e);void 0!==n&&(r.minLength=n),void 0!==o&&(r.maxLength=o),a&&(0===a.length?r.not={}:1===a.length?r.contentMediaType=a[0]:r.anyOf=a.map(e=>({contentMediaType:e})))},success:(e,t,r,i)=>{r.type="boolean"},custom:iB,function:(e,t,r,i)=>{ip(e,t,r,i,"Function types cannot be represented in JSON Schema")},transform:iW,map:(e,t,r,i)=>{ip(e,t,r,i,"Map cannot be represented in JSON Schema")},set:(e,t,r,i)=>{ip(e,t,r,i,"Set cannot be represented in JSON Schema")},array:iG,object:iY,union:iX,intersection:iQ,tuple:(e,t,r,i)=>{let n=e._zod.def;r.type="array";let o="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",s=n.items.map((e,r)=>im(e,t,{...i,path:[...i.path,o,r]})),l=n.rest?im(n.rest,t,{...i,path:[...i.path,a,..."openapi-3.0"===t.target?[n.items.length]:[]]}):null,c=n.items.length;for(;c>0;){let e=n.items[c-1];if(!("input"===t.io?void 0!==iK(e):"optional"===e._zod.optout))break;c--}let u=n.items.length,d=!n.rest;"draft-2020-12"===t.target?(r.prefixItems=s,d?r.items=!1:l&&(r.items=l)):"openapi-3.0"===t.target?(r.items={anyOf:s},l&&r.items.anyOf.push(l)):(r.items=s,d?r.additionalItems=!1:l&&(r.additionalItems=l)),c>0&&(r.minItems=c),d&&(r.maxItems=u);let{minimum:p,maximum:m}=ij(e);"number"==typeof p&&(r.minItems=p),"number"==typeof m&&(r.maxItems=m)},record:i1,nullable:i2,nonoptional:i9,default:i3,prefault:i6,catch:i7,pipe:i8,readonly:ne,promise:(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},optional:nt,lazy:nr};function nn(e,t){if("_idmap"in e){let r=id({...t,processors:ni}),i={};for(let t of e._idmap.entries()){let[e,i]=t;im(i,r)}let n={};for(let o of(r.external={registry:e,uri:t?.uri,defs:i},e._idmap.entries())){let[e,t]=o;ig(r,t),es(n,e,iS(r,t))}return Object.keys(i).length>0&&(n.__shared={["draft-2020-12"===r.target?"$defs":"definitions"]:i}),{schemas:n}}let r=id({...t,processors:ni});return im(e,r),ig(r,e),iS(r,e)}let no={get:function(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,er,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},na={value:void 0,enumerable:!1},ns=new WeakSet([Object.prototype,Error.prototype]),nl=(e,t)=>{e.name="$ZodError",na.value=t,Object.defineProperty(e,"issues",na),na.value=void 0,Object.defineProperty(e,"message",no);let r=Object.getPrototypeOf(e);ns.has(r)||(ns.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},nc=eB("$ZodError",nl);function nu(e,t){return{callee:t?.callee??e,Err:t?.Err}}eB("$ZodError",nl,void 0,{Parent:Error});let nd=e=>{let t=(r,i,n,o)=>{let a=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise)throw new eW;if(s.issues.length){let r=new(o?.Err??e)(s.issues.map(e=>ej(e,a,eY())));throw eh(r,o?.callee??t),r}return s.value};return t},np=e=>{let t=async(r,i,n,o)=>{let a=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let r=new(o?.Err??e)(s.issues.map(e=>ej(e,a,eY())));throw eh(r,o?.callee??t),r}return s.value};return t},nm=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},n);if(o instanceof Promise)throw new eW;return o.issues.length?nh(e,o.issues,n):{success:!0,data:o.value}};function nh(e,t,r){let i;return{success:!1,get error(){return i||(i=new e(t.map(e=>ej(e,r,eY()))),t=void 0,r=void 0),i},set error(e){i=e,t=void 0,r=void 0}}}let nf=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length?nh(e,o.issues,n):{success:!0,data:o.value}},ng=Symbol.for("zod.compile.invalid"),ny=Symbol.for("zod.compile.fallback"),nv=new WeakSet([Object.prototype,Error.prototype]);function n_(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=r(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let nb=eB("ZodError",(e,t)=>{nc.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);nv.has(r)||(nv.add(r),n_(r,"format",e=>t=>(function(e,t=e=>e.message){let r={_errors:[]},i=(e,n=[])=>{for(let o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>i({issues:e},[...n,...o.path]));else if("invalid_key"===o.code)i({issues:o.issues},[...n,...o.path]);else if("invalid_element"===o.code)i({issues:o.issues},[...n,...o.path]);else{let e=[...n,...o.path];if(0===e.length)r._errors.push(t(o));else{let i=r,n=0;for(;n<e.length;){let r=e[n],a=n===e.length-1;if("_errors"===r){a&&i._errors.push(t(o)),n++;continue}Object.prototype.hasOwnProperty.call(i,r)||Object.defineProperty(i,r,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=i[r];a&&s._errors.push(t(o)),i=s,n++}}}};return i(e),r})(e,t)),n_(r,"flatten",e=>t=>(function(e,t=e=>e.message){let r={},i=[];for(let a of e.issues)if(a.path.length>0){var n,o;(n=a.path[0],o=()=>[],!Object.prototype.hasOwnProperty.call(r,n)&&("__proto__"===n?Object.defineProperty(r,n,{value:o(),writable:!0,enumerable:!0,configurable:!0}):r[n]=o()),r[n]).push(t(a))}else i.push(t(a));return{formErrors:i,fieldErrors:r}})(e,t)),n_(r,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,er,2)}),n_(r,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,er,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),nS=nd(nb),nw=np(nb),nR=nm(nb),nk=nf(nb),nx=(m=nd(nb),h=(e,t,r,i)=>m(e,t,r?{...r,direction:"backward"}:{direction:"backward"},nu(h,i))),nC=(f=nd(nb),g=(e,t,r,i)=>f(e,t,r,nu(g,i))),n$=(y=np(nb),v=async(e,t,r,i)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return await y(e,t,n,nu(v,i))}),nT=(_=np(nb),b=async(e,t,r,i)=>await _(e,t,r,nu(b,i))),nP=(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return nm(nb)(e,t,i)},nO=(e,t,r)=>nm(nb)(e,t,r),nE=async(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return nf(nb)(e,t,i)},nI=async(e,t,r)=>nf(nb)(e,t,r);function nq(){eK.memoizer||eY({memoizer:e5})}let nj=eB("ZodType",(e,t)=>(eK.localeError||eY({localeError:(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}},t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return r=>{switch(r.code){case"invalid_type":{let e=i(r.expected),t=i(function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t}(r.input),r.input);return`Invalid input: expected ${e}, received ${t}`}case"invalid_value":if(1===r.values.length)return`Invalid input: expected ${eR(r.values[0])}`;return`Invalid option: expected one of ${et(r.values,"|")}`;case"too_big":{let t=r.exact?"exactly ":r.inclusive?"<=":"<",i=e[r.origin]??null;if(i)return`Too big: expected ${r.origin??"value"} to have ${t}${r.maximum.toString()} ${i.unit??"elements"}`;return`Too big: expected ${r.origin??"value"} to be ${t}${r.maximum.toString()}`}case"too_small":{let t=r.exact?"exactly ":r.inclusive?">=":">",i=e[r.origin]??null;if(i)return`Too small: expected ${r.origin} to have ${t}${r.minimum.toString()} ${i.unit}`;return`Too small: expected ${r.origin} to be ${t}${r.minimum.toString()}`}case"invalid_format":if("starts_with"===r.format)return`Invalid string: must start with "${r.prefix}"`;if("ends_with"===r.format)return`Invalid string: must end with "${r.suffix}"`;if("includes"===r.format)return`Invalid string: must include "${r.includes}"`;if("regex"===r.format)return`Invalid string: must match pattern ${r.pattern}`;return`Invalid ${t[r.format]??r.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${et(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":if(r.options&&Array.isArray(r.options)&&r.options.length>0){let e=r.options.map(e=>`'${e}'`).join(" | ");return`Invalid discriminator value. Expected ${e}`}if(!1===r.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}})()}),tF.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(em(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eS(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return new oD({type:"custom",check:"custom",fn:e,...ew(t)})}(e,t))},superRefine(e,t){return this.check(function(e,t){var r;let i,n;return r=t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(eN(e,t.value,i._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),"input"in e||(e.input=t.value),e.inst??(e.inst=i),e.continue??(e.continue=!i._zod.def.abort),t.issues.push(eN(e)))},e(t.value,t)),(n=new tw({check:"custom",...ew(t)}))._zod.check=r,i=n}(e,t))},overwrite(e){return this.check(ic(e))},optional(){return oO(this)},exactOptional(){var e;return e=this,new oE({type:"optional",innerType:e})},nullable(){return oq(this)},nullish(){return oO(oq(this))},nonoptional(e){var t;return t=this,new oz({type:"nonoptional",innerType:t,...ew(e)})},array(){return od(this)},or(e){return og([this,e])},and(e){return ob(this,e)},transform(e){return oM(this,oT(e))},default(e){var t,r;return t=this,r=e,new oj({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():ev(r)}})},prefault(e){var t,r;return t=this,r=e,new oA({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():ev(r)}})},catch(e){return function(e,t){let r;return new oL({type:"catch",innerType:e,catchValue:"function"==typeof t?t:((r=()=>t)["~constantCatch"]=!0,r)})}(this,e)},pipe(e){return oM(this,e)},readonly(){var e;return e=this,new oU({type:"readonly",innerType:e})},describe(e){let t=this.clone();return r4.add(t,{description:e}),t},meta(...e){if(0===e.length)return r4.get(this);let t=this.clone();return r4.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return eM(this,"~standard",{...tD(this),jsonSchema:{input:iw(this,"input"),output:iw(this,"output")}},!1)},set"~standard"(e){eM(this,"~standard",e)},parse:function e(t,r){return nS(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await nw(this,t,r,{callee:e})},safeParse(e,t){return nR(this,e,t)},async safeParseAsync(e,t){return nk(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){eM(this,"spa",e)},validate(e,t){let r=this._zod.bag.validator;if(void 0!==r){if(r(e)!==ng)return!0;if(!0===r.definite&&void 0===t)return!1}return function(e,t,r){let i,n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;if(o?(n[ny]=!0,i=o({value:t,issues:[]},n)):i=e._zod.run({value:t,issues:[]},n),i instanceof Promise)throw new eW;return 0===i.issues.length}(this,e,t)},validateAsync(e,t){return(async(e,t,r)=>{let i=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},i);return n instanceof Promise&&(n=await n),0===n.issues.length})(this,e,t)},encode:function e(t,r){return nx(this,t,r,{callee:e})},decode:function e(t,r){return nC(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await n$(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await nT(this,t,r,{callee:e})},safeEncode(e,t){return nP(this,e,t)},safeDecode(e,t){return nO(this,e,t)},async safeEncodeAsync(e,t){return nE(this,e,t)},async safeDecodeAsync(e,t){return nI(this,e,t)},toJSONSchema(e){return((e,t={})=>r=>{let i=id({...r,processors:t});return im(e,i),ig(i,e),iS(i,e)})(this,{})(e)},get description(){return r4.get(this)?.description},get _def(){return this._zod.def}}),nA=eB("_ZodString",(e,t)=>{tV.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iN(e,t,r,i)},eZ({format:e=>ij(e).format??null,minLength:e=>ij(e).minimum??null,maxLength:e=>ij(e).maximum??null},{regex(...e){return this.check(function(e,t){return new tq({check:"string_format",format:"regex",...ew(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new tz({check:"string_format",format:"includes",...ew(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new tL({check:"string_format",format:"starts_with",...ew(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new tN({check:"string_format",format:"ends_with",...ew(t),suffix:e})}(...e))},min(...e){return this.check(is(...e))},max(...e){return this.check(ia(...e))},length(...e){return this.check(il(...e))},nonempty(...e){return this.check(is(1,...e))},lowercase(e){return this.check(new tj({check:"string_format",format:"lowercase",...ew(e)}))},uppercase(e){return this.check(new tA({check:"string_format",format:"uppercase",...ew(e)}))},trim(){return this.check(ic(e=>e.trim()))},normalize(...e){return this.check(function(e){return ic(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(ic(e=>e.toLowerCase()))},toUpperCase(){return this.check(ic(e=>e.toUpperCase()))},slugify(){return this.check(ic(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})),nz=eB("ZodString",(e,t)=>{tV.init(e,t),nA.init(e,t)},{email(e){return this.check(r3(nH,e))},url(e){return this.check(r6(nJ,e))},jwt(e){return this.check(new n6({type:"string",format:"jwt",check:"string_format",abort:!1,...ew(e)}))},emoji(e){return this.check(new nB({type:"string",format:"emoji",check:"string_format",abort:!1,...ew(e)}))},guid(e){return this.check(new nD({type:"string",format:"guid",check:"string_format",abort:!1,...ew(e)}))},uuid(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,...ew(e)}))},uuidv4(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ew(e)}))},uuidv6(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ew(e)}))},uuidv7(e){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ew(e)}))},nanoid(e){return this.check(new nW({type:"string",format:"nanoid",check:"string_format",abort:!1,...ew(e)}))},cuid(e){return this.check(new nG({type:"string",format:"cuid",check:"string_format",abort:!1,...ew(e)}))},cuid2(e){return this.check(new nK({type:"string",format:"cuid2",check:"string_format",abort:!1,...ew(e)}))},ulid(e){return this.check(new nY({type:"string",format:"ulid",check:"string_format",abort:!1,...ew(e)}))},base64(e){return this.check(new n4({type:"string",format:"base64",check:"string_format",abort:!1,...ew(e)}))},base64url(e){return this.check(new n5({type:"string",format:"base64url",check:"string_format",abort:!1,...ew(e)}))},xid(e){return this.check(new nX({type:"string",format:"xid",check:"string_format",abort:!1,...ew(e)}))},ksuid(e){return this.check(new nQ({type:"string",format:"ksuid",check:"string_format",abort:!1,...ew(e)}))},ipv4(e){return this.check(new n0({type:"string",format:"ipv4",check:"string_format",abort:!1,...ew(e)}))},ipv6(e){return this.check(new n1({type:"string",format:"ipv6",check:"string_format",abort:!1,...ew(e)}))},cidrv4(e){return this.check(new n2({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ew(e)}))},cidrv6(e){return this.check(new n9({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ew(e)}))},e164(e){return this.check(new n3({type:"string",format:"e164",check:"string_format",abort:!1,...ew(e)}))},datetime(e){return this.check(r7(nM,e))},date(e){return this.check(r8(nZ,e))},time(e){return this.check(new nU({type:"string",format:"time",check:"string_format",precision:null,...ew(e)}))},duration(e){return this.check(new nF({type:"string",format:"duration",check:"string_format",...ew(e)}))}});function nL(e){return new nz(r5({type:"string",...ew(e)}))}let nN=eB("ZodStringFormat",(e,t)=>{tJ.init(e,t),nA.init(e,t)}),nM=eB("ZodISODateTime",(e,t)=>{t6.init(e,t),nN.init(e,t)}),nZ=eB("ZodISODate",(e,t)=>{t7.init(e,t),nN.init(e,t)}),nU=eB("ZodISOTime",(e,t)=>{t8.init(e,t),nN.init(e,t)}),nF=eB("ZodISODuration",(e,t)=>{re.init(e,t),nN.init(e,t)}),nH=eB("ZodEmail",(e,t)=>{tG.init(e,t),nN.init(e,t)}),nD=eB("ZodGUID",(e,t)=>{tB.init(e,t),nN.init(e,t)}),nV=eB("ZodUUID",(e,t)=>{tW.init(e,t),nN.init(e,t)}),nJ=eB("ZodURL",(e,t)=>{tQ.init(e,t),nN.init(e,t)}),nB=eB("ZodEmoji",(e,t)=>{t0.init(e,t),nN.init(e,t)}),nW=eB("ZodNanoID",(e,t)=>{t1.init(e,t),nN.init(e,t)}),nG=eB("ZodCUID",(e,t)=>{t2.init(e,t),nN.init(e,t)}),nK=eB("ZodCUID2",(e,t)=>{t9.init(e,t),nN.init(e,t)}),nY=eB("ZodULID",(e,t)=>{t4.init(e,t),nN.init(e,t)}),nX=eB("ZodXID",(e,t)=>{t5.init(e,t),nN.init(e,t)}),nQ=eB("ZodKSUID",(e,t)=>{t3.init(e,t),nN.init(e,t)}),n0=eB("ZodIPv4",(e,t)=>{rt.init(e,t),nN.init(e,t)}),n1=eB("ZodIPv6",(e,t)=>{rn.init(e,t),nN.init(e,t)}),n2=eB("ZodCIDRv4",(e,t)=>{ro.init(e,t),nN.init(e,t)}),n9=eB("ZodCIDRv6",(e,t)=>{ra.init(e,t),nN.init(e,t)}),n4=eB("ZodBase64",(e,t)=>{rc.init(e,t),nN.init(e,t)}),n5=eB("ZodBase64URL",(e,t)=>{rd.init(e,t),nN.init(e,t)}),n3=eB("ZodE164",(e,t)=>{rp.init(e,t),nN.init(e,t)}),n6=eB("ZodJWT",(e,t)=>{rm.init(e,t),nN.init(e,t)}),n7=eB("ZodNumber",(e,t)=>{rh.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iM(e,t,r,i),e.isFinite=!0},eZ({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ij(e);return Math.max(t??-1/0,r??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ij(e);return Math.min(t??1/0,r??1/0)},isInt:e=>{let{isInt:t,multipleOf:r}=ij(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ij(e).format??null},{gt(e,t){return this.check(ir(e,t))},gte(e,t){return this.check(ii(e,t))},min(e,t){return this.check(ii(e,t))},lt(e,t){return this.check(ie(e,t))},lte(e,t){return this.check(it(e,t))},max(e,t){return this.check(it(e,t))},int(e){return this.check(ot(e))},safe(e){return this.check(ot(e))},positive(e){return this.check(ir(0,e))},nonnegative(e){return this.check(ii(0,e))},negative(e){return this.check(ie(0,e))},nonpositive(e){return this.check(it(0,e))},multipleOf(e,t){return this.check(io(e,t))},step(e,t){return this.check(io(e,t))},finite(){return this}}));function n8(e){return new n7(r5({type:"number",checks:[],...ew(e)}))}let oe=eB("ZodNumberFormat",(e,t)=>{rf.init(e,t),n7.init(e,t)});function ot(e){return new oe({type:"number",check:"number_format",abort:!1,format:"safeint",...ew(e)})}let or=eB("ZodBoolean",(e,t)=>{rg.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iZ(e,t,r,i)});function oi(e){return new or({type:"boolean",...ew(e)})}let on=eB("ZodNull",(e,t)=>{ry.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iU(e,t,r,i)});function oo(e){return new on({type:"null",...ew(e)})}let oa=eB("ZodAny",(e,t)=>{rv.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iH(e,t,r,i)}),os=eB("ZodUnknown",(e,t)=>{r_.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iD(e,t,r,i)});function ol(){return new os({type:"unknown"})}let oc=eB("ZodNever",(e,t)=>{rb.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iF(e,t,r,i)}),ou=eB("ZodArray",(e,t)=>{nq(),rR.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iG(e,t,r,i),e.element=t.element},{min(e,t){return this.check(is(e,t))},nonempty(e){return this.check(is(1,e))},max(e,t){return this.check(ia(e,t))},length(e,t){return this.check(il(e,t))},unwrap(){return this.element}});function od(e,t){return new ou({type:"array",element:e,...ew(t)})}let op=eB("ZodObject",(e,t)=>{var r;let i,n;nq(),rP.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iY(e,t,r,i),r="shape",(n=r in(i=Object.getPrototypeOf(e))?void 0:i)&&Object.defineProperty(n,r,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:!1,value:void 0};return Object.defineProperty(this,r,e),e.value=(e=>e._zod.def.shape)(this),Object.defineProperty(this,r,e),e.value},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,enumerable:!1,value:e})}})},{keyof(){return ok(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(em(this._zod.def,{catchall:e}))},passthrough(){return this.clone(em(this._zod.def,{catchall:ol()}))},loose(){return this.clone(em(this._zod.def,{catchall:ol()}))},strict(){return this.clone(em(this._zod.def,{catchall:new oc({type:"never",...ew(void 0)})}))},strip(){return this.clone(em(this._zod.def,{catchall:void 0}))},extend(e){if(!ey(e))throw Error("Invalid input to extend: expected a plain object");let t=this._zod.def.checks;if(t&&t.length>0){let t=ec(this);for(let r of Reflect.ownKeys(e))if(void 0!==Object.getOwnPropertyDescriptor(t,r))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eS(this,em(this._zod.def,{shape:e$(this,e)}))},safeExtend(e){if(!ey(e))throw Error("Invalid input to safeExtend: expected a plain object");return eS(this,em(this._zod.def,{shape:e$(this,e)}))},merge(e){if(!e?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(this._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t={};return ep(t,this,Reflect.ownKeys(ec(this))),ep(t,e,Reflect.ownKeys(ec(e))),eS(this,em(this._zod.def,{shape:t,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]}))},pick(e){return function(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let n={};return ep(n,e,eC(e,t)),eS(e,em(r,{shape:n,checks:[]}))}(this,e)},omit(e){return function(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let n=new Set(eC(e,t)),o={};return ep(o,e,Reflect.ownKeys(ec(e)).filter(e=>!n.has(e))),eS(e,em(r,{shape:o,checks:[]}))}(this,e)},partial(...e){return eT(oP,this,e[0])},exactPartial(...e){return eT(oE,this,e[0],"exactPartial")},required(...e){var t;let r,i;return r=(t=e[0])?new Set(eC(this,t)):void 0,ep(i={},this,Reflect.ownKeys(ec(this)),(e,t)=>r&&!r.has(t)?e:new oz({type:"nonoptional",innerType:e})),eS(this,em(this._zod.def,{shape:i}))}});function om(e,t){return new op({type:"object",shape:e??{},...ew(t)})}function oh(e,t){return new op({type:"object",shape:e,catchall:ol(),...ew(t)})}let of=eB("ZodUnion",(e,t)=>{rE.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iX(e,t,r,i),e.options=t.options});function og(e,t){return new of({type:"union",options:e,...ew(t)})}let oy=eB("ZodDiscriminatedUnion",(e,t)=>{of.init(e,t),rI.init(e,t)});function ov(e,t,r){return new oy({type:"union",options:t,discriminator:e,...ew(r)})}let o_=eB("ZodIntersection",(e,t)=>{rq.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iQ(e,t,r,i)});function ob(e,t){return new o_({type:"intersection",left:e,right:t})}let oS=eB("ZodRecord",(e,t)=>{nq(),rA.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i1(e,t,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function ow(e,t,r){return new oS(t&&t._zod?{type:"record",keyType:e,valueType:t,...ew(r)}:{type:"record",keyType:nL(),valueType:e,...ew(t)})}let oR=eB("ZodEnum",(e,t)=>{rz.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iV(e,t,r,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(e,i)=>{let n={};for(let i of e)if(r.has(i))n[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new oR({...t,checks:[],...ew(i),entries:n})},e.exclude=(e,i)=>{let n={...t.entries};for(let t of e)if(r.has(t))delete n[t];else throw Error(`Key ${t} not found in enum`);return new oR({...t,checks:[],...ew(i),entries:n})}});function ok(e,t){return new oR({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ew(t)})}let ox=eB("ZodLiteral",(e,t)=>{rL.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iJ(e,t,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function oC(e,t){return new ox({type:"literal",values:Array.isArray(e)?e:[e],...ew(t)})}let o$=eB("ZodTransform",(e,t)=>{nq(),rN.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iW(e,t,r,i),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new eG(e.constructor.name);r.addIssue=i=>{"string"==typeof i?r.issues.push(eN(i,r.value,t)):(i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(eN(i)))};let n=t.transform(r.value,r);return n instanceof Promise?n.then(e=>(r.value=e,r)):(r.value=n,r)}});function oT(e){return new o$({type:"transform",transform:e})}let oP=eB("ZodOptional",(e,t)=>{rZ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nt(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function oO(e){return new oP({type:"optional",innerType:e})}let oE=eB("ZodExactOptional",(e,t)=>{rU.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nt(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oI=eB("ZodNullable",(e,t)=>{rF.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i2(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function oq(e){return new oI({type:"nullable",innerType:e})}let oj=eB("ZodDefault",(e,t)=>{rH.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i3(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),oA=eB("ZodPrefault",(e,t)=>{rV.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i6(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oz=eB("ZodNonOptional",(e,t)=>{rJ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i9(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oL=eB("ZodCatch",(e,t)=>{rG.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i7(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),oN=eB("ZodPipe",(e,t)=>{rK.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i8(e,t,r,i),e.in=t.in,e.out=t.out});function oM(e,t){return new oN({type:"pipe",in:e,out:t})}let oZ=eB("ZodPreprocess",(e,t)=>{oN.init(e,t),rX.init(e,t)}),oU=eB("ZodReadonly",(e,t)=>{rQ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>ne(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),oF=eB("ZodLazy",(e,t)=>{r1.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nr(e,t,r,i),e.unwrap=()=>e._zod.def.getter()});function oH(e){return new oF({type:"lazy",getter:e})}let oD=eB("ZodCustom",(e,t)=>{r2.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iB(e,t,r,i)});function oV(e,t){return new oZ({type:"pipe",in:oT(e),out:t})}let oJ="2025-11-25",oB=[oJ,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],oW="io.modelcontextprotocol/protocolVersion",oG="io.modelcontextprotocol/clientInfo",oK="io.modelcontextprotocol/serverInfo",oY="io.modelcontextprotocol/clientCapabilities",oX="io.modelcontextprotocol/subscriptionId",oQ="io.modelcontextprotocol/logLevel",o0=oH(()=>og([nL(),n8(),oi(),oo(),ow(nL(),o0),od(o0)])),o1=ow(nL(),o0),o2=od(o0),o9=og([nL(),n8().int()]),o4=nL(),o5=om({ttl:n8().optional()}),o3=om({taskId:nL()}),o6=oh({progressToken:o9.optional(),"io.modelcontextprotocol/related-task":o3.optional()}),o7=om({_meta:o6.optional()}),o8=o7.extend({task:o5.optional()}),ae=om({method:nL(),params:o7.loose().optional()}),at=om({_meta:o6.optional()}),ar=om({method:nL(),params:at.loose().optional()}),ai=oh({get[oK](){return av.optional().catch(void 0)}}),an=oh({_meta:ai.optional()}),ao=og([nL(),n8().int()]),aa=om({jsonrpc:oC("2.0"),id:ao,...ae.shape}).strict(),as=om({jsonrpc:oC("2.0"),...ar.shape}).strict(),al=om({jsonrpc:oC("2.0"),id:ao,result:an}).strict(),ac=om({jsonrpc:oC("2.0"),id:ao.optional(),error:om({code:n8().int(),message:nL(),data:ol().optional()})}).strict(),au=og([aa,as,al,ac]),ad=og([al,ac]),ap=an.strict(),am=at.extend({requestId:ao.optional(),reason:nL().optional()}),ah=ar.extend({method:oC("notifications/cancelled"),params:am}),af=om({src:nL(),mimeType:nL().optional(),sizes:od(nL()).optional(),theme:ok(["light","dark"]).optional()}),ag=om({icons:od(af).optional()}),ay=om({name:nL(),title:nL().optional()}),av=ay.extend({...ay.shape,...ag.shape,version:nL(),websiteUrl:nL().optional(),description:nL().optional()}),a_=ob(om({applyDefaults:oi().optional()}),o1),ab=oV(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ob(om({form:a_.optional(),url:o1.optional()}),o1.optional())),aS=oh({list:o1.optional(),cancel:o1.optional(),requests:oh({sampling:oh({createMessage:o1.optional()}).optional(),elicitation:oh({create:o1.optional()}).optional()}).optional()}),aw=oh({list:o1.optional(),cancel:o1.optional(),requests:oh({tools:oh({call:o1.optional()}).optional()}).optional()}),aR=om({experimental:ow(nL(),o1).optional(),sampling:om({context:o1.optional(),tools:o1.optional()}).optional(),elicitation:ab.optional(),roots:om({listChanged:oi().optional()}).optional(),tasks:aS.optional(),extensions:ow(nL(),o1).optional()}),ak=o7.extend({protocolVersion:nL(),capabilities:aR,clientInfo:av}),ax=ae.extend({method:oC("initialize"),params:ak}),aC=om({experimental:ow(nL(),o1).optional(),logging:o1.optional(),completions:o1.optional(),prompts:om({listChanged:oi().optional()}).optional(),resources:om({subscribe:oi().optional(),listChanged:oi().optional()}).optional(),tools:om({listChanged:oi().optional()}).optional(),tasks:aw.optional(),extensions:ow(nL(),o1).optional()}),a$=an.extend({protocolVersion:nL(),capabilities:aC,serverInfo:av,instructions:nL().optional()}),aT=ar.extend({method:oC("notifications/initialized"),params:at.optional()}),aP=ae.extend({method:oC("server/discover"),params:o7.optional()}),aO=an.extend({supportedVersions:od(nL()),capabilities:aC,instructions:nL().optional()}),aE=ae.extend({method:oC("ping"),params:o7.optional()}),aI=om({progress:n8(),total:oO(n8()),message:oO(nL())}),aq=om({...at.shape,...aI.shape,progressToken:o9}),aj=ar.extend({method:oC("notifications/progress"),params:aq}),aA=o7.extend({cursor:o4.optional()}),az=ae.extend({params:aA.optional()}),aL=an.extend({nextCursor:o4.optional()}),aN=om({uri:nL(),mimeType:oO(nL()),_meta:ow(nL(),ol()).optional()}),aM=aN.extend({text:nL()}),aZ=nL().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),aU=aN.extend({blob:aZ}),aF=ok(["user","assistant"]),aH=om({audience:od(aF).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nM,{offset:!0}).optional()}),aD=om({...ay.shape,...ag.shape,uri:nL(),description:oO(nL()),mimeType:oO(nL()),size:oO(n8()),annotations:aH.optional(),_meta:oO(oh({}))}),aV=om({...ay.shape,...ag.shape,uriTemplate:nL(),description:oO(nL()),mimeType:oO(nL()),annotations:aH.optional(),_meta:oO(oh({}))}),aJ=az.extend({method:oC("resources/list")}),aB=aL.extend({resources:od(aD)}),aW=az.extend({method:oC("resources/templates/list")}),aG=aL.extend({resourceTemplates:od(aV)}),aK=o7.extend({uri:nL()}),aY=ae.extend({method:oC("resources/read"),params:aK}),aX=an.extend({contents:od(og([aM,aU]))}),aQ=ar.extend({method:oC("notifications/resources/list_changed"),params:at.optional()}),a0=ae.extend({method:oC("resources/subscribe"),params:aK}),a1=ae.extend({method:oC("resources/unsubscribe"),params:aK}),a2=om({toolsListChanged:oi().optional(),promptsListChanged:oi().optional(),resourcesListChanged:oi().optional(),resourceSubscriptions:od(nL()).optional()}),a9=o7.extend({notifications:a2}),a4=ae.extend({method:oC("subscriptions/listen"),params:a9}),a5=at.extend({notifications:a2}),a3=ar.extend({method:oC("notifications/subscriptions/acknowledged"),params:a5}),a6=ai.extend({[oX]:ao}),a7=an.extend({_meta:a6}),a8=at.extend({uri:nL()}),se=ar.extend({method:oC("notifications/resources/updated"),params:a8}),st=om({name:nL(),description:oO(nL()),required:oO(oi())}),sr=om({...ay.shape,...ag.shape,description:oO(nL()),arguments:oO(od(st)),_meta:oO(oh({}))}),si=az.extend({method:oC("prompts/list")}),sn=aL.extend({prompts:od(sr)}),so=o7.extend({name:nL(),arguments:ow(nL(),nL()).optional()}),sa=ae.extend({method:oC("prompts/get"),params:so}),ss=om({type:oC("text"),text:nL(),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),sl=om({type:oC("image"),data:aZ,mimeType:nL(),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),sc=om({type:oC("audio"),data:aZ,mimeType:nL(),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),su=om({type:oC("tool_use"),name:nL(),id:nL(),input:ow(nL(),ol()),_meta:ow(nL(),ol()).optional()}),sd=om({type:oC("resource"),resource:og([aM,aU]),annotations:aH.optional(),_meta:ow(nL(),ol()).optional()}),sp=aD.extend({type:oC("resource_link")}),sm=og([ss,sl,sc,sp,sd]),sh=om({role:aF,content:sm}),sf=an.extend({description:nL().optional(),messages:od(sh)}),sg=ar.extend({method:oC("notifications/prompts/list_changed"),params:at.optional()}),sy=om({title:nL().optional(),readOnlyHint:oi().optional(),destructiveHint:oi().optional(),idempotentHint:oi().optional(),openWorldHint:oi().optional()}),sv=om({taskSupport:ok(["required","optional","forbidden"]).optional()}),s_=om({...ay.shape,...ag.shape,description:nL().optional(),inputSchema:om({type:oC("object"),properties:ow(nL(),o0).optional(),required:od(nL()).optional()}).catchall(ol()),outputSchema:oh({$schema:nL().optional()}).optional(),annotations:sy.optional(),execution:sv.optional(),_meta:ow(nL(),ol()).optional()}),sb=az.extend({method:oC("tools/list")}),sS=aL.extend({tools:od(s_)}),sw=an.extend({content:od(sm).default([]),structuredContent:ol().optional(),isError:oi().optional()}),sR=sw.or(an.extend({toolResult:ol()})),sk=o8.extend({name:nL(),arguments:ow(nL(),ol()).optional()}),sx=ae.extend({method:oC("tools/call"),params:sk}),sC=ar.extend({method:oC("notifications/tools/list_changed"),params:at.optional()}),s$=om({autoRefresh:oi().default(!0),debounceMs:n8().int().nonnegative().default(300)}),sT=ok(["debug","info","notice","warning","error","critical","alert","emergency"]),sP=o7.extend({level:sT}),sO=ae.extend({method:oC("logging/setLevel"),params:sP}),sE=at.extend({level:sT,logger:nL().optional(),data:ol()}),sI=ar.extend({method:oC("notifications/message"),params:sE}),sq=om({name:nL().optional()}),sj=om({hints:od(sq).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),sA=om({mode:ok(["auto","required","none"]).optional()}),sz=om({type:oC("tool_result"),toolUseId:nL().describe("The unique identifier for the corresponding tool call."),content:od(sm),structuredContent:ol().optional(),isError:oi().optional(),_meta:ow(nL(),ol()).optional()}),sL=ov("type",[ss,sl,sc]),sN=ov("type",[ss,sl,sc,su,sz]),sM=om({role:aF,content:og([sN,od(sN)]),_meta:ow(nL(),ol()).optional()}),sZ=o8.extend({messages:od(sM),modelPreferences:sj.optional(),systemPrompt:nL().optional(),includeContext:ok(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:od(nL()).optional(),metadata:o1.optional(),tools:od(s_).optional(),toolChoice:sA.optional()}),sU=ae.extend({method:oC("sampling/createMessage"),params:sZ}),sF=an.extend({model:nL(),stopReason:oO(ok(["endTurn","stopSequence","maxTokens"]).or(nL())),role:aF,content:sL}),sH=an.extend({model:nL(),stopReason:oO(ok(["endTurn","stopSequence","maxTokens","toolUse"]).or(nL())),role:aF,content:og([sN,od(sN)])}),sD=om({type:oC("boolean"),title:nL().optional(),description:nL().optional(),default:oi().optional()}),sV=om({type:oC("string"),title:nL().optional(),description:nL().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ok(["email","uri","date","date-time"]).optional(),default:nL().optional()}),sJ=om({type:ok(["number","integer"]),title:nL().optional(),description:nL().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),sB=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),default:nL().optional()}),sW=om({type:oC("string"),title:nL().optional(),description:nL().optional(),oneOf:od(om({const:nL(),title:nL()})),default:nL().optional()}),sG=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),enumNames:od(nL()).optional(),default:nL().optional()}),sK=og([sB,sW]),sY=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({type:oC("string"),enum:od(nL())}),default:od(nL()).optional()}),sX=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({anyOf:od(om({const:nL(),title:nL()}))}),default:od(nL()).optional()}),sQ=og([sY,sX]),s0=og([sG,sK,sQ]),s1=og([s0,sD,sV,sJ]),s2=o8.extend({mode:oC("form").optional(),message:nL(),requestedSchema:om({type:oC("object"),properties:ow(nL(),s1),required:od(nL()).optional()}).catchall(ol())}),s9=o8.extend({mode:oC("url"),message:nL(),elicitationId:nL(),url:nL().url()}),s4=og([s2,s9]),s5=ae.extend({method:oC("elicitation/create"),params:s4}),s3=at.extend({elicitationId:nL()}),s6=ar.extend({method:oC("notifications/elicitation/complete"),params:s3}),s7=an.extend({action:ok(["accept","decline","cancel"]),content:oV(e=>null===e?void 0:e,ow(nL(),og([nL(),n8(),oi(),od(nL())])).optional())}),s8=om({type:oC("ref/resource"),uri:nL()}),le=om({type:oC("ref/prompt"),name:nL()}),lt=o7.extend({ref:og([le,s8]),argument:om({name:nL(),value:nL()}),context:om({arguments:ow(nL(),nL()).optional()}).optional()}),lr=ae.extend({method:oC("completion/complete"),params:lt}),li=an.extend({completion:oh({values:od(nL()).max(100),total:oO(n8().int()),hasMore:oO(oi())})}),ln=om({uri:nL().startsWith("file://"),name:nL().optional(),_meta:ow(nL(),ol()).optional()}),lo=ae.extend({method:oC("roots/list"),params:o7.optional()}),la=an.extend({roots:od(ln)}),ls=ar.extend({method:oC("notifications/roots/list_changed"),params:at.optional()}),ll=oh({ttl:n8().optional(),pollInterval:n8().optional()}),lc=ok(["working","input_required","completed","failed","cancelled"]),lu=om({taskId:nL(),status:lc,ttl:og([n8(),oo()]),createdAt:nL(),lastUpdatedAt:nL(),pollInterval:oO(n8()),statusMessage:oO(nL())}),ld=an.extend({task:lu}),lp=at.merge(lu),lm=ar.extend({method:oC("notifications/tasks/status"),params:lp}),lh=ae.extend({method:oC("tasks/get"),params:o7.extend({taskId:nL()})}),lf=an.merge(lu),lg=ae.extend({method:oC("tasks/result"),params:o7.extend({taskId:nL()})}),ly=an.loose(),lv=az.extend({method:oC("tasks/list")}),l_=aL.extend({tasks:od(lu)}),lb=ae.extend({method:oC("tasks/cancel"),params:o7.extend({taskId:nL()})}),lS=an.merge(lu),lw=og([aE,ax,aP,lr,sO,sa,si,aJ,aW,aY,a0,a1,a4,sx,sb]),lR=og([ah,aj,aT,ls]),lk=og([ap,sF,sH,s7,la]),lx=og([aE,sU,s5,lo]),lC=og([ah,aj,sI,se,aQ,sC,sg,a3,s6]),l$=og([ap,a$,aO,li,sf,sn,aB,aG,aX,sw,sS,a7]);A||(A={});let lT=r6(nJ,void 0).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),eD}).refine(e=>{let t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),lP=oh({resource:nL().url(),authorization_servers:od(lT).optional(),jwks_uri:nL().url().optional(),scopes_supported:od(nL()).optional(),bearer_methods_supported:od(nL()).optional(),resource_signing_alg_values_supported:od(nL()).optional(),resource_name:nL().optional(),resource_documentation:nL().optional(),resource_policy_uri:nL().url().optional(),resource_tos_uri:nL().url().optional(),tls_client_certificate_bound_access_tokens:oi().optional(),authorization_details_types_supported:od(nL()).optional(),dpop_signing_alg_values_supported:od(nL()).optional(),dpop_bound_access_tokens_required:oi().optional()}),lO=oh({issuer:nL(),authorization_endpoint:lT,token_endpoint:lT,registration_endpoint:lT.optional(),scopes_supported:od(nL()).optional(),response_types_supported:od(nL()),response_modes_supported:od(nL()).optional(),grant_types_supported:od(nL()).optional(),token_endpoint_auth_methods_supported:od(nL()).optional(),token_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),service_documentation:lT.optional(),revocation_endpoint:lT.optional(),revocation_endpoint_auth_methods_supported:od(nL()).optional(),revocation_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),introspection_endpoint:nL().optional(),introspection_endpoint_auth_methods_supported:od(nL()).optional(),introspection_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),code_challenge_methods_supported:od(nL()).optional(),client_id_metadata_document_supported:oi().optional(),authorization_response_iss_parameter_supported:oi().optional().catch(void 0),dpop_signing_alg_values_supported:od(nL()).optional()}),lE=oh({issuer:nL(),authorization_endpoint:lT,token_endpoint:lT,userinfo_endpoint:lT.optional(),jwks_uri:lT,registration_endpoint:lT.optional(),scopes_supported:od(nL()).optional(),response_types_supported:od(nL()),response_modes_supported:od(nL()).optional(),grant_types_supported:od(nL()).optional(),acr_values_supported:od(nL()).optional(),subject_types_supported:od(nL()),id_token_signing_alg_values_supported:od(nL()),id_token_encryption_alg_values_supported:od(nL()).optional(),id_token_encryption_enc_values_supported:od(nL()).optional(),userinfo_signing_alg_values_supported:od(nL()).optional(),userinfo_encryption_alg_values_supported:od(nL()).optional(),userinfo_encryption_enc_values_supported:od(nL()).optional(),request_object_signing_alg_values_supported:od(nL()).optional(),request_object_encryption_alg_values_supported:od(nL()).optional(),request_object_encryption_enc_values_supported:od(nL()).optional(),token_endpoint_auth_methods_supported:od(nL()).optional(),token_endpoint_auth_signing_alg_values_supported:od(nL()).optional(),display_values_supported:od(nL()).optional(),claim_types_supported:od(nL()).optional(),claims_supported:od(nL()).optional(),service_documentation:nL().optional(),claims_locales_supported:od(nL()).optional(),ui_locales_supported:od(nL()).optional(),claims_parameter_supported:oi().optional(),request_parameter_supported:oi().optional(),request_uri_parameter_supported:oi().optional(),require_request_uri_registration:oi().optional(),op_policy_uri:lT.optional(),op_tos_uri:lT.optional(),client_id_metadata_document_supported:oi().optional(),authorization_response_iss_parameter_supported:oi().optional().catch(void 0)}),lI=om({...lE.shape,...lO.pick({code_challenge_methods_supported:!0}).shape}),lq=om({access_token:nL(),id_token:nL().optional(),token_type:nL(),expires_in:new n7(r5({type:"number",coerce:!0,checks:[],...ew(void 0)})).optional(),scope:nL().optional(),refresh_token:nL().optional(),issuer:nL().optional().catch(void 0)}).strip(),lj=om({issued_token_type:oC("urn:ietf:params:oauth:token-type:id-jag"),access_token:nL(),token_type:nL().optional(),expires_in:n8().optional(),scope:nL().optional()}).strip(),lA=om({error:nL(),error_description:nL().optional(),error_uri:nL().optional()}),lz=lT.optional().or(oC("").transform(()=>void 0)),lL=om({redirect_uris:od(lT),token_endpoint_auth_method:nL().optional(),grant_types:od(nL()).optional(),response_types:od(nL()).optional(),application_type:nL().optional(),client_name:nL().optional(),client_uri:lT.optional(),logo_uri:lz,scope:nL().optional(),contacts:od(nL()).optional(),tos_uri:lz,policy_uri:nL().optional(),jwks_uri:lT.optional(),jwks:new oa({type:"any"}).optional(),software_id:nL().optional(),software_version:nL().optional(),software_statement:nL().optional()}).strip(),lN=om({client_id:nL(),client_secret:nL().optional(),client_id_issued_at:n8().optional(),client_secret_expires_at:n8().optional(),issuer:nL().optional().catch(void 0)}).strip(),lM=lL.merge(lN),lZ=om({error:nL(),error_description:nL().optional()}).strip(),lU=om({token:nL(),token_type_hint:nL().optional()}).strip(),lF=Symbol.for("mcp.sdk.errorBrands");function lH(e,t){let r=new Set,i=t;for(;"function"==typeof i;){let e=i.mcpBrand;Object.prototype.hasOwnProperty.call(i,"mcpBrand")&&"string"==typeof e&&r.add(e),i=Object.getPrototypeOf(i)}0!==r.size&&Object.defineProperty(e,lF,{value:r,enumerable:!1,configurable:!0})}function lD(e,t){try{if("object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&"string"==typeof e.mcpBrand&&Object.prototype.hasOwnProperty.call(t,lF)){let r=t[lF];if(r&&"function"==typeof r.has&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}let lV=((C={}).InvalidRequest="invalid_request",C.InvalidClient="invalid_client",C.InvalidGrant="invalid_grant",C.UnauthorizedClient="unauthorized_client",C.UnsupportedGrantType="unsupported_grant_type",C.InvalidScope="invalid_scope",C.AccessDenied="access_denied",C.ServerError="server_error",C.TemporarilyUnavailable="temporarily_unavailable",C.UnsupportedResponseType="unsupported_response_type",C.UnsupportedTokenType="unsupported_token_type",C.InvalidToken="invalid_token",C.MethodNotAllowed="method_not_allowed",C.TooManyRequests="too_many_requests",C.InvalidClientMetadata="invalid_client_metadata",C.InvalidRedirectUri="invalid_redirect_uri",C.InsufficientScope="insufficient_scope",C.InvalidTarget="invalid_target",C.InvalidDpopProof="invalid_dpop_proof",C.UseDpopNonce="use_dpop_nonce",C);var lJ=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](e){return lD(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lD(this,e)}constructor(e,t,r){super(t),this.code=e,this.errorUri=r,this.name="OAuthError",lH(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}};let lB=(($={}).NotConnected="NOT_CONNECTED",$.AlreadyConnected="ALREADY_CONNECTED",$.NotInitialized="NOT_INITIALIZED",$.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",$.RequestTimeout="REQUEST_TIMEOUT",$.ConnectionClosed="CONNECTION_CLOSED",$.SendFailed="SEND_FAILED",$.InvalidResult="INVALID_RESULT",$.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",$.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",$.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",$.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",$.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",$.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",$.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",$.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",$.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",$.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",$.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",$);var lW=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return lD(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lD(this,e)}constructor(e,t,r,i){super(t,i),this.code=e,this.data=r,this.name="SdkError",lH(this,new.target)}};(class extends lW{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,i){super(e,t,r,i),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let lG={};function lK(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lY(e,t){let r={};for(let[i,n]of Object.entries(e)){if(void 0===n)continue;let e=void 0===t?void 0:t[i];if(void 0===e){r[i]=n;continue}if(lK(n)&&lK(e)){let t={};for(let[r,o]of Object.entries(n))void 0!==o&&void 0===e[r]&&("elicitation"!==i||"form"!==r||void 0!==e.form||void 0!==e.url)&&(t[r]=o);Object.keys(t).length>0&&(r[i]=t)}}return Object.keys(r).length>0?r:void 0}let lX="2026-07-28",lQ=[lX];function l0(e){return e.filter(e=>e>=lX)}function l1(e){let t=e.structuredContent;return void 0===t||!("object"!=typeof t||null===t||Array.isArray(t))||e.content?.some(e=>"text"===e.type)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}let l2=["task","inputRequests","requestState"];function l9(e){return null===e||"object"!=typeof e||Array.isArray(e)||void 0!==e.content||l2.some(t=>t in e)?e:{...e,content:[]}}function l4(){let e,t,i,n,o,a,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k,x,C,$,T,P,O,E,I,q,j,A,z,L,N,M,Z,U,F,H,D,V,J,B,W,G,K,Y,X,Q,ee,et,er,ei,en,eo,ea,es,el,ec,eu,ed,ep,em,eh,ef,eg,ey,ev,e_,eb,eS,ew,eR,ek,ex,eC,e$,eT,eP,eO,eE,eI,eq,ej,eA,ez,eL,eN,eM,eZ,eU,eF,eH,eD,eV,eJ,eB,eW,eG,eK,eY,eX,eQ,e0,e1,e2,e9,e4,e5,e3,e6,e7,e8,te,tt,tr,ti,tn,to,ta,ts,tl,tc,tu,td,tp,tm,th,tf,tg,ty,tv,t_,tb,tS,tw;return r??=(e=oH(()=>og([nL(),n8(),oi(),oo(),ow(nL(),e),od(e)])),t=ow(nL(),e),i=og([nL(),n8().int()]),n=nL(),o=om({ttl:n8().optional()}),a=om({taskId:nL()}),c=(l=om({_meta:(s=oh({progressToken:i.optional(),"io.modelcontextprotocol/related-task":a.optional()})).optional()})).extend({task:o.optional()}),u=om({method:nL(),params:l.loose().optional()}),d=om({_meta:s.optional()}),p=om({method:nL(),params:d.loose().optional()}),m=oh({_meta:s.optional()}),h=og([nL(),n8().int()]),f=m.strict(),g=d.extend({requestId:h.optional(),reason:nL().optional()}),y=p.extend({method:oC("notifications/cancelled"),params:g}),v=om({src:nL(),mimeType:nL().optional(),sizes:od(nL()).optional(),theme:ok(["light","dark"]).optional()}),_=om({icons:od(v).optional()}),S=(b=om({name:nL(),title:nL().optional()})).extend({...b.shape,..._.shape,version:nL(),websiteUrl:nL().optional(),description:nL().optional()}),w=ob(om({applyDefaults:oi().optional()}),t),R=oV(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ob(om({form:w.optional(),url:t.optional()}),t.optional())),k=oh({list:t.optional(),cancel:t.optional(),requests:oh({sampling:oh({createMessage:t.optional()}).optional(),elicitation:oh({create:t.optional()}).optional()}).optional()}),x=oh({list:t.optional(),cancel:t.optional(),requests:oh({tools:oh({call:t.optional()}).optional()}).optional()}),C=om({experimental:ow(nL(),t).optional(),sampling:om({context:t.optional(),tools:t.optional()}).optional(),elicitation:R.optional(),roots:om({listChanged:oi().optional()}).optional(),tasks:k.optional(),extensions:ow(nL(),t).optional()}),$=l.extend({protocolVersion:nL(),capabilities:C,clientInfo:S}),T=u.extend({method:oC("initialize"),params:$}),P=om({experimental:ow(nL(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:om({listChanged:oi().optional()}).optional(),resources:om({subscribe:oi().optional(),listChanged:oi().optional()}).optional(),tools:om({listChanged:oi().optional()}).optional(),tasks:x.optional(),extensions:ow(nL(),t).optional()}),O=m.extend({protocolVersion:nL(),capabilities:P,serverInfo:S,instructions:nL().optional()}),E=p.extend({method:oC("notifications/initialized"),params:d.optional()}),I=u.extend({method:oC("ping"),params:l.optional()}),q=om({progress:n8(),total:oO(n8()),message:oO(nL())}),j=om({...d.shape,...q.shape,progressToken:i}),A=p.extend({method:oC("notifications/progress"),params:j}),z=l.extend({cursor:n.optional()}),L=u.extend({params:z.optional()}),N=m.extend({nextCursor:n.optional()}),Z=(M=om({uri:nL(),mimeType:oO(nL()),_meta:ow(nL(),ol()).optional()})).extend({text:nL()}),U=nL().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),F=M.extend({blob:U}),D=om({audience:od(H=ok(["user","assistant"])).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nM,{offset:!0}).optional()}),V=om({...b.shape,..._.shape,uri:nL(),description:oO(nL()),mimeType:oO(nL()),size:oO(n8()),annotations:D.optional(),_meta:oO(oh({}))}),J=om({...b.shape,..._.shape,uriTemplate:nL(),description:oO(nL()),mimeType:oO(nL()),annotations:D.optional(),_meta:oO(oh({}))}),B=L.extend({method:oC("resources/list")}),W=N.extend({resources:od(V)}),G=L.extend({method:oC("resources/templates/list")}),K=N.extend({resourceTemplates:od(J)}),Y=l.extend({uri:nL()}),X=u.extend({method:oC("resources/read"),params:Y}),Q=m.extend({contents:od(og([Z,F]))}),ee=p.extend({method:oC("notifications/resources/list_changed"),params:d.optional()}),et=u.extend({method:oC("resources/subscribe"),params:Y}),er=u.extend({method:oC("resources/unsubscribe"),params:Y}),ei=d.extend({uri:nL()}),en=p.extend({method:oC("notifications/resources/updated"),params:ei}),eo=om({name:nL(),description:oO(nL()),required:oO(oi())}),ea=om({...b.shape,..._.shape,description:oO(nL()),arguments:oO(od(eo)),_meta:oO(oh({}))}),es=L.extend({method:oC("prompts/list")}),el=N.extend({prompts:od(ea)}),ec=l.extend({name:nL(),arguments:ow(nL(),nL()).optional()}),eu=u.extend({method:oC("prompts/get"),params:ec}),ed=om({type:oC("text"),text:nL(),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),ep=om({type:oC("image"),data:U,mimeType:nL(),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),em=om({type:oC("audio"),data:U,mimeType:nL(),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),eh=om({type:oC("tool_use"),name:nL(),id:nL(),input:ow(nL(),ol()),_meta:ow(nL(),ol()).optional()}),ef=om({type:oC("resource"),resource:og([Z,F]),annotations:D.optional(),_meta:ow(nL(),ol()).optional()}),ev=om({role:H,content:ey=og([ed,ep,em,eg=V.extend({type:oC("resource_link")}),ef])}),e_=m.extend({description:nL().optional(),messages:od(ev)}),eb=p.extend({method:oC("notifications/prompts/list_changed"),params:d.optional()}),eS=om({title:nL().optional(),readOnlyHint:oi().optional(),destructiveHint:oi().optional(),idempotentHint:oi().optional(),openWorldHint:oi().optional()}),ew=om({taskSupport:ok(["required","optional","forbidden"]).optional()}),eR=om({...b.shape,..._.shape,description:nL().optional(),inputSchema:om({type:oC("object"),properties:ow(nL(),e).optional(),required:od(nL()).optional()}).catchall(ol()),outputSchema:om({type:oC("object"),properties:ow(nL(),e).optional(),required:od(nL()).optional()}).catchall(ol()).optional(),annotations:eS.optional(),execution:ew.optional(),_meta:ow(nL(),ol()).optional()}),ek=L.extend({method:oC("tools/list")}),ex=N.extend({tools:od(eR)}),eC=m.extend({content:od(ey),structuredContent:ow(nL(),ol()).optional(),isError:oi().optional()}),e$=c.extend({name:nL(),arguments:ow(nL(),ol()).optional()}),eT=u.extend({method:oC("tools/call"),params:e$}),eP=p.extend({method:oC("notifications/tools/list_changed"),params:d.optional()}),eO=ok(["debug","info","notice","warning","error","critical","alert","emergency"]),eE=l.extend({level:eO}),eI=u.extend({method:oC("logging/setLevel"),params:eE}),eq=d.extend({level:eO,logger:nL().optional(),data:ol()}),ej=p.extend({method:oC("notifications/message"),params:eq}),eA=om({name:nL().optional()}),ez=om({hints:od(eA).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),eL=om({mode:ok(["auto","required","none"]).optional()}),eN=om({type:oC("tool_result"),toolUseId:nL().describe("The unique identifier for the corresponding tool call."),content:od(ey),structuredContent:om({}).loose().optional(),isError:oi().optional(),_meta:ow(nL(),ol()).optional()}),eM=ov("type",[ed,ep,em]),eU=om({role:H,content:og([eZ=ov("type",[ed,ep,em,eh,eN]),od(eZ)]),_meta:ow(nL(),ol()).optional()}),eF=c.extend({messages:od(eU),modelPreferences:ez.optional(),systemPrompt:nL().optional(),includeContext:ok(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:od(nL()).optional(),metadata:t.optional(),tools:od(eR).optional(),toolChoice:eL.optional()}),eH=u.extend({method:oC("sampling/createMessage"),params:eF}),eD=m.extend({model:nL(),stopReason:oO(ok(["endTurn","stopSequence","maxTokens"]).or(nL())),role:H,content:eM}),eV=m.extend({model:nL(),stopReason:oO(ok(["endTurn","stopSequence","maxTokens","toolUse"]).or(nL())),role:H,content:og([eZ,od(eZ)])}),eJ=om({type:oC("boolean"),title:nL().optional(),description:nL().optional(),default:oi().optional()}),eB=om({type:oC("string"),title:nL().optional(),description:nL().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ok(["email","uri","date","date-time"]).optional(),default:nL().optional()}),eW=om({type:ok(["number","integer"]),title:nL().optional(),description:nL().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),eG=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),default:nL().optional()}),eK=om({type:oC("string"),title:nL().optional(),description:nL().optional(),oneOf:od(om({const:nL(),title:nL()})),default:nL().optional()}),eY=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),enumNames:od(nL()).optional(),default:nL().optional()}),eX=og([eG,eK]),eQ=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({type:oC("string"),enum:od(nL())}),default:od(nL()).optional()}),e1=og([eQ,e0=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({anyOf:od(om({const:nL(),title:nL()}))}),default:od(nL()).optional()})]),e2=og([eY,eX,e1]),e9=og([e2,eJ,eB,eW]),e4=c.extend({mode:oC("form").optional(),message:nL(),requestedSchema:om({type:oC("object"),properties:ow(nL(),e9),required:od(nL()).optional()}).catchall(ol())}),e3=og([e4,e5=c.extend({mode:oC("url"),message:nL(),elicitationId:nL(),url:nL().url()})]),e6=u.extend({method:oC("elicitation/create"),params:e3}),e7=d.extend({elicitationId:nL()}),e8=p.extend({method:oC("notifications/elicitation/complete"),params:e7}),te=m.extend({action:ok(["accept","decline","cancel"]),content:oV(e=>null===e?void 0:e,ow(nL(),og([nL(),n8(),oi(),od(nL())])).optional())}),tt=om({type:oC("ref/resource"),uri:nL()}),tr=om({type:oC("ref/prompt"),name:nL()}),ti=l.extend({ref:og([tr,tt]),argument:om({name:nL(),value:nL()}),context:om({arguments:ow(nL(),nL()).optional()}).optional()}),tn=u.extend({method:oC("completion/complete"),params:ti}),to=m.extend({completion:oh({values:od(nL()).max(100),total:oO(n8().int()),hasMore:oO(oi())})}),ta=om({uri:nL().startsWith("file://"),name:nL().optional(),_meta:ow(nL(),ol()).optional()}),ts=u.extend({method:oC("roots/list"),params:l.optional()}),tl=m.extend({roots:od(ta)}),tc=p.extend({method:oC("notifications/roots/list_changed"),params:d.optional()}),tu=oh({ttl:n8().optional(),pollInterval:n8().optional()}),td=ok(["working","input_required","completed","failed","cancelled"]),tp=om({taskId:nL(),status:td,ttl:og([n8(),oo()]),createdAt:nL(),lastUpdatedAt:nL(),pollInterval:oO(n8()),statusMessage:oO(nL())}),tm=m.extend({task:tp}),th=d.merge(tp),tf=p.extend({method:oC("notifications/tasks/status"),params:th}),tg=u.extend({method:oC("tasks/get"),params:l.extend({taskId:nL()})}),ty=m.merge(tp),tv=u.extend({method:oC("tasks/result"),params:l.extend({taskId:nL()})}),t_=m.loose(),tb=L.extend({method:oC("tasks/list")}),tS=N.extend({tasks:od(tp)}),tw=u.extend({method:oC("tasks/cancel"),params:l.extend({taskId:nL()})}),{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:i,CursorSchema:n,TaskMetadataSchema:o,RelatedTaskMetadataSchema:a,RequestMetaSchema:s,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:c,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:p,ResultSchema:m,RequestIdSchema:h,EmptyResultSchema:f,CancelledNotificationParamsSchema:g,CancelledNotificationSchema:y,IconSchema:v,IconsSchema:_,BaseMetadataSchema:b,ImplementationSchema:S,ClientTasksCapabilitySchema:k,ServerTasksCapabilitySchema:x,ClientCapabilitiesSchema:C,InitializeRequestParamsSchema:$,InitializeRequestSchema:T,ServerCapabilitiesSchema:P,InitializeResultSchema:O,InitializedNotificationSchema:E,PingRequestSchema:I,ProgressSchema:q,ProgressNotificationParamsSchema:j,ProgressNotificationSchema:A,PaginatedRequestParamsSchema:z,PaginatedRequestSchema:L,PaginatedResultSchema:N,ResourceContentsSchema:M,TextResourceContentsSchema:Z,BlobResourceContentsSchema:F,RoleSchema:H,AnnotationsSchema:D,ResourceSchema:V,ResourceTemplateSchema:J,ListResourcesRequestSchema:B,ListResourcesResultSchema:W,ListResourceTemplatesRequestSchema:G,ListResourceTemplatesResultSchema:K,ResourceRequestParamsSchema:Y,ReadResourceRequestParamsSchema:Y,ReadResourceRequestSchema:X,ReadResourceResultSchema:Q,ResourceListChangedNotificationSchema:ee,SubscribeRequestParamsSchema:Y,SubscribeRequestSchema:et,UnsubscribeRequestParamsSchema:Y,UnsubscribeRequestSchema:er,ResourceUpdatedNotificationParamsSchema:ei,ResourceUpdatedNotificationSchema:en,PromptArgumentSchema:eo,PromptSchema:ea,ListPromptsRequestSchema:es,ListPromptsResultSchema:el,GetPromptRequestParamsSchema:ec,GetPromptRequestSchema:eu,TextContentSchema:ed,ImageContentSchema:ep,AudioContentSchema:em,ToolUseContentSchema:eh,EmbeddedResourceSchema:ef,ResourceLinkSchema:eg,ContentBlockSchema:ey,PromptMessageSchema:ev,GetPromptResultSchema:e_,PromptListChangedNotificationSchema:eb,ToolAnnotationsSchema:eS,ToolExecutionSchema:ew,ToolSchema:eR,ListToolsRequestSchema:ek,ListToolsResultSchema:ex,CallToolResultSchema:eC,CallToolRequestParamsSchema:e$,CallToolRequestSchema:eT,ToolListChangedNotificationSchema:eP,LoggingLevelSchema:eO,SetLevelRequestParamsSchema:eE,SetLevelRequestSchema:eI,LoggingMessageNotificationParamsSchema:eq,LoggingMessageNotificationSchema:ej,ModelHintSchema:eA,ModelPreferencesSchema:ez,ToolChoiceSchema:eL,ToolResultContentSchema:eN,SamplingContentSchema:eM,SamplingMessageContentBlockSchema:eZ,SamplingMessageSchema:eU,CreateMessageRequestParamsSchema:eF,CreateMessageRequestSchema:eH,CreateMessageResultSchema:eD,CreateMessageResultWithToolsSchema:eV,BooleanSchemaSchema:eJ,StringSchemaSchema:eB,NumberSchemaSchema:eW,UntitledSingleSelectEnumSchemaSchema:eG,TitledSingleSelectEnumSchemaSchema:eK,LegacyTitledEnumSchemaSchema:eY,SingleSelectEnumSchemaSchema:eX,UntitledMultiSelectEnumSchemaSchema:eQ,TitledMultiSelectEnumSchemaSchema:e0,MultiSelectEnumSchemaSchema:e1,EnumSchemaSchema:e2,PrimitiveSchemaDefinitionSchema:e9,ElicitRequestFormParamsSchema:e4,ElicitRequestURLParamsSchema:e5,ElicitRequestParamsSchema:e3,ElicitRequestSchema:e6,ElicitationCompleteNotificationParamsSchema:e7,ElicitationCompleteNotificationSchema:e8,ElicitResultSchema:te,ResourceTemplateReferenceSchema:tt,PromptReferenceSchema:tr,CompleteRequestParamsSchema:ti,CompleteRequestSchema:tn,CompleteResultSchema:to,RootSchema:ta,ListRootsRequestSchema:ts,ListRootsResultSchema:tl,RootsListChangedNotificationSchema:tc,TaskCreationParamsSchema:tu,TaskStatusSchema:td,TaskSchema:tp,CreateTaskResultSchema:tm,TaskStatusNotificationParamsSchema:th,TaskStatusNotificationSchema:tf,GetTaskRequestSchema:tg,GetTaskResultSchema:ty,GetTaskPayloadRequestSchema:tv,GetTaskPayloadResultSchema:t_,ListTasksRequestSchema:tb,ListTasksResultSchema:tS,CancelTaskRequestSchema:tw,CancelTaskResultSchema:m.merge(tp),ClientRequestSchema:og([I,T,tn,eI,eu,es,B,G,X,et,er,eT,ek,tg,tv,tb,tw]),ClientNotificationSchema:og([y,A,E,tc,tf]),ClientResultSchema:og([f,eD,eV,te,tl,ty,tS,tm]),ServerRequestSchema:og([I,eH,e6,ts,tg,tv,tb,tw]),ServerNotificationSchema:og([y,A,ej,en,ee,eP,eb,tf,e8]),ServerResultSchema:og([f,O,to,e_,el,W,K,Q,eC,ex,ty,tS,tm]),CallToolResultWireSchema:ol().superRefine((e,t)=>{if(!("object"!=typeof e||null===e||Array.isArray(e))&&void 0===e.content){for(let r of l2)if(r in e)return void t.addIssue({code:"custom",message:`content is required when the body carries '${r}' — another result family cannot default into an empty tools/call success`})}}).transform(l9).pipe(eC)})}function l5(e){return"object"!==e.type}let l3=new Set(["const","enum","default","examples"]),l6=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function l7(e){return void 0!==e&&!("string"==typeof e&&e.startsWith("#"))}let l8={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},ce={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},ct={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function cr(){if(i)return i;let e=l4();return i={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}}}function ci(e){return Object.prototype.hasOwnProperty.call(l8,e)}function cn(e){return Object.prototype.hasOwnProperty.call(ce,e)}function co(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function ca(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}Object.keys(l8),Object.keys(ce);let cs={ok:!1,reason:"not-in-era"};function cl(e){return co(e)&&co(e.outputSchema)&&l5(e.outputSchema)}let cc={era:"2025-11-25",hasRequestMethod:ci,hasNotificationMethod:cn,validateRequest:(e,t)=>ca(ci(e)?cr().requestSchemas[e]:void 0,t),validateResult:(e,t)=>ca(Object.prototype.hasOwnProperty.call(ct,e)?cr().resultSchemas[e]:void 0,t),validateNotification:(e,t)=>ca(cn(e)?cr().notificationSchemas[e]:void 0,t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>cs,validateInputResponse:()=>cs,samplingResultVariant:(e,t)=>{let r=l4();return ca(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)},outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=l1(e),i=r.structuredContent;if(void 0===i)return r;let n="object"!=typeof i||null===i||Array.isArray(i),o=void 0!==t&&l5(t);return n||o?{...r,structuredContent:{result:i}}:r},decodeResult(e,t){if(co(t)&&"resultType"in t){let e={...t};return delete e.resultType,{kind:"complete",result:e}}return{kind:"complete",result:t}},encodeResult(e,t){if("tools/list"!==e)return t;let r=t.tools;return Array.isArray(r)&&r.some(e=>cl(e))?{...t,tools:r.map(e=>cl(e)?{...e,outputSchema:function(e){var t;let r="string"==typeof e.$schema?e.$schema:void 0;if(l7(e.$id))return{...void 0!==r&&{$schema:r},type:"object",properties:{result:e},required:["result"]};let i="string"==typeof(t=e.$schema)&&Y.has(t.replace(/#$/,""))&&!0!==e.$recursiveAnchor,n=(e,t)=>{if(Array.isArray(e))return e.map(e=>n(e,!1));if(null===e||"object"!=typeof e||!t&&l7(e.$id))return e;let r={},o=!1;for(let[a,s]of Object.entries(e))t?r[a]=n(s,!1):("$ref"===a||"$dynamicRef"===a)&&"string"==typeof s?r[a]="#"===s?"#/properties/result":s.startsWith("#/")?`#/properties/result${s.slice(1)}`:s:"$recursiveRef"===a&&"#"===s&&i?o=!0:l3.has(a)?r[a]=s:l6.has(a)?r[a]=n(s,!0):r[a]=n(s,!1);return o&&("$ref"in r?r.allOf=[...Array.isArray(r.allOf)?r.allOf:[],{$ref:"#/properties/result"}]:r.$ref="#/properties/result"),r};return{...void 0!==r&&{$schema:r},type:"object",properties:{result:n(e,!1)},required:["result"]}}(e.outputSchema)}:e)}:t},encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope:e=>void 0};function cu(){return n??=function(){let e=oH(()=>og([nL(),n8(),oi(),oo(),ow(nL(),e),od(e)])),t=ow(nL(),e),r=og([nL(),n8().int()]),i=nL(),n=og([nL(),n8().int()]),o=ok(["user","assistant"]),a=ok(["debug","info","notice","warning","error","critical","alert","emergency"]),s=nL().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=om({ttl:n8().optional()}),c=om({taskId:nL()}),u=oh({progressToken:r.optional(),"io.modelcontextprotocol/related-task":c.optional()}),d=om({_meta:u.optional()}),p=d.extend({task:l.optional()}),m=om({_meta:u.optional()}),h=om({method:nL(),params:m.loose().optional()}),f=om({src:nL(),mimeType:nL().optional(),sizes:od(nL()).optional(),theme:ok(["light","dark"]).optional()}),g=om({icons:od(f).optional()}),y=om({name:nL(),title:nL().optional()}),v=y.extend({...y.shape,...g.shape,version:nL(),websiteUrl:nL().optional(),description:nL().optional()}),_=ob(om({applyDefaults:oi().optional()}),t),b=oV(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ob(om({form:_.optional(),url:t.optional()}),t.optional())),S=oh({list:t.optional(),cancel:t.optional(),requests:oh({sampling:oh({createMessage:t.optional()}).optional(),elicitation:oh({create:t.optional()}).optional()}).optional()}),w=oh({list:t.optional(),cancel:t.optional(),requests:oh({tools:oh({call:t.optional()}).optional()}).optional()}),R=om({experimental:ow(nL(),t).optional(),sampling:om({context:t.optional(),tools:t.optional()}).optional(),elicitation:b.optional(),roots:om({listChanged:oi().optional()}).optional(),tasks:S.optional(),extensions:ow(nL(),t).optional()}),k=om({experimental:ow(nL(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:om({listChanged:oi().optional()}).optional(),resources:om({subscribe:oi().optional(),listChanged:oi().optional()}).optional(),tools:om({listChanged:oi().optional()}).optional(),tasks:w.optional(),extensions:ow(nL(),t).optional()}),x=om({progress:n8(),total:oO(n8()),message:oO(nL())}),C=om({...m.shape,...x.shape,progressToken:r}),$=h.extend({method:oC("notifications/progress"),params:C}),T=m.extend({level:a,logger:nL().optional(),data:ol()}),P=h.extend({method:oC("notifications/message"),params:T}),O=om({uri:nL(),mimeType:oO(nL()),_meta:ow(nL(),ol()).optional()}),E=O.extend({text:nL()}),I=O.extend({blob:s}),q=om({audience:od(o).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nM,{offset:!0}).optional()}),j=om({...y.shape,...g.shape,uri:nL(),description:oO(nL()),mimeType:oO(nL()),size:oO(n8()),annotations:q.optional(),_meta:oO(oh({}))}),A=om({...y.shape,...g.shape,uriTemplate:nL(),description:oO(nL()),mimeType:oO(nL()),annotations:q.optional(),_meta:oO(oh({}))}),z=h.extend({method:oC("notifications/resources/list_changed"),params:m.optional()}),L=m.extend({uri:nL()}),N=h.extend({method:oC("notifications/resources/updated"),params:L}),M=om({name:nL(),description:oO(nL()),required:oO(oi())}),Z=om({...y.shape,...g.shape,description:oO(nL()),arguments:oO(od(M)),_meta:oO(oh({}))}),U=h.extend({method:oC("notifications/prompts/list_changed"),params:m.optional()}),F=om({type:oC("text"),text:nL(),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),H=om({type:oC("image"),data:s,mimeType:nL(),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),D=om({type:oC("audio"),data:s,mimeType:nL(),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),V=om({type:oC("tool_use"),name:nL(),id:nL(),input:ow(nL(),ol()),_meta:ow(nL(),ol()).optional()}),J=om({type:oC("resource"),resource:og([E,I]),annotations:q.optional(),_meta:ow(nL(),ol()).optional()}),B=j.extend({type:oC("resource_link")}),W=og([F,H,D,B,J]),G=om({role:o,content:W}),K=om({title:nL().optional(),readOnlyHint:oi().optional(),destructiveHint:oi().optional(),idempotentHint:oi().optional(),openWorldHint:oi().optional()}),Y=h.extend({method:oC("notifications/tools/list_changed"),params:m.optional()}),X=om({name:nL().optional()}),Q=om({hints:od(X).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),ee=om({mode:ok(["auto","required","none"]).optional()}),et=om({type:oC("boolean"),title:nL().optional(),description:nL().optional(),default:oi().optional()}),er=om({type:oC("string"),title:nL().optional(),description:nL().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ok(["email","uri","date","date-time"]).optional(),default:nL().optional()}),ei=om({type:ok(["number","integer"]),title:nL().optional(),description:nL().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),en=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),default:nL().optional()}),eo=om({type:oC("string"),title:nL().optional(),description:nL().optional(),oneOf:od(om({const:nL(),title:nL()})),default:nL().optional()}),ea=om({type:oC("string"),title:nL().optional(),description:nL().optional(),enum:od(nL()),enumNames:od(nL()).optional(),default:nL().optional()}),es=og([en,eo]),el=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({type:oC("string"),enum:od(nL())}),default:od(nL()).optional()}),ec=om({type:oC("array"),title:nL().optional(),description:nL().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:om({anyOf:od(om({const:nL(),title:nL()}))}),default:od(nL()).optional()}),eu=og([el,ec]),ed=og([ea,es,eu]),ep=og([ed,et,er,ei]),em=p.extend({mode:oC("form").optional(),message:nL(),requestedSchema:om({type:oC("object"),properties:ow(nL(),ep),required:od(nL()).optional()}).catchall(ol())}),eh=om({type:oC("ref/resource"),uri:nL()}),ef=om({type:oC("ref/prompt"),name:nL()}),eg=om({uri:nL().startsWith("file://"),name:nL().optional(),_meta:ow(nL(),ol()).optional()}),ey=R.shape,ev=om({experimental:ey.experimental,sampling:ey.sampling,elicitation:ey.elicitation,roots:ey.roots,extensions:ey.extensions}),e_=k.shape,eb=om({experimental:e_.experimental,logging:e_.logging,completions:e_.completions,prompts:e_.prompts,resources:e_.resources,tools:e_.tools,extensions:e_.extensions}),eS=oh({progressToken:r.optional(),[oW]:nL(),[oG]:v.optional(),[oY]:ev,[oQ]:a.optional()}),ew=om({...y.shape,...g.shape,description:nL().optional(),inputSchema:oh({$schema:nL().optional(),type:oC("object")}),outputSchema:oh({$schema:nL().optional()}).optional(),annotations:K.optional(),_meta:ow(nL(),ol()).optional()}),eR=om({type:oC("tool_result"),toolUseId:nL(),content:od(W),structuredContent:ol().optional(),isError:oi().optional(),_meta:ow(nL(),ol()).optional()}),ek=og([F,H,D,V,eR]),ex=om({role:o,content:og([ek,od(ek)]),_meta:ow(nL(),ol()).optional()}),eC=nL(),e$=oh({[oK]:v.optional().catch(void 0)}),eT=e$.optional();function eP(e){return oh({_meta:eT,resultType:eC.default("complete"),...e})}let eO=eP({}),eE=eP({nextCursor:i.optional()}),eI=eP({content:od(W),structuredContent:ol().optional(),isError:oi().optional()}),eq=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),tools:od(ew),nextCursor:i.optional()}),ej=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),prompts:od(Z),nextCursor:i.optional()}),eA=eP({description:nL().optional(),messages:od(G)}),ez=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resources:od(j),nextCursor:i.optional()}),eL=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resourceTemplates:od(A),nextCursor:i.optional()}),eN=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),contents:od(og([E,I]))}),eM=eP({completion:om({values:od(nL()).max(100),total:n8().int().optional(),hasMore:oi().optional()}).loose()}),eZ=eP({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"])}),eU=eP({ttlMs:n8().int().min(0).catch(0),cacheScope:ok(["public","private"]).catch("private"),supportedVersions:od(nL()),capabilities:eb,instructions:nL().optional()}),eF=om({messages:od(ex),modelPreferences:Q.optional(),systemPrompt:nL().optional(),includeContext:ok(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:od(nL()).optional(),metadata:t.optional(),tools:od(ew).optional(),toolChoice:ee.optional()}),eH=om({method:oC("sampling/createMessage"),params:eF}),eD=om({method:oC("roots/list"),params:om({_meta:ow(nL(),ol()).optional()}).optional()}),eV=om({...ex.shape,model:nL(),stopReason:nL().optional()}),eJ=om({roots:od(eg)}),eB=om({action:ok(["accept","decline","cancel"]),content:ow(nL(),og([nL(),n8(),oi(),od(nL())])).optional()}),eW=om({mode:oC("url"),message:nL(),url:nL().url()}),eG=og([em,eW]),eK=om({method:oC("elicitation/create"),params:eG}),eY=og([eH,eD,eK]),eX=og([eV,eJ,eB]),eQ=ow(nL(),eY),e0=ow(nL(),eX),e1=eP({inputRequests:eQ.optional(),requestState:nL().optional()}),e2={inputResponses:e0.optional(),requestState:nL().optional()},e9=om({_meta:eS,...e2}),e4=oh({progressToken:r.optional()});function e5(e,t){return om({method:oC(e),params:om({_meta:eS,...t})})}function e3(e,t){return om({method:oC(e),params:om({_meta:e4.optional(),...t}).optional()})}let e6={name:nL(),arguments:ow(nL(),ol()).optional(),...e2},e7={cursor:i.optional()},e8=e5("tools/call",e6),te=e5("tools/list",e7),tt=e5("prompts/list",e7),tr=e5("prompts/get",{name:nL(),arguments:ow(nL(),nL()).optional(),...e2}),ti=e5("resources/list",e7),tn=e5("resources/templates/list",e7),to=e5("resources/read",{uri:nL(),...e2}),ta={ref:og([ef,eh]),argument:om({name:nL(),value:nL()}),context:om({arguments:ow(nL(),nL()).optional()}).optional()},ts=e5("completion/complete",ta),tl=e5("server/discover",{}),tc=om({toolsListChanged:oi().optional(),promptsListChanged:oi().optional(),resourcesListChanged:oi().optional(),resourceSubscriptions:od(nL()).optional()}),tu={notifications:tc},td=e5("subscriptions/listen",tu),tp=e$.extend({"io.modelcontextprotocol/subscriptionId":n}),tm=oh({_meta:tp,resultType:eC.default("complete")}),th={"tools/call":e3("tools/call",e6),"tools/list":e3("tools/list",e7),"prompts/get":e3("prompts/get",{name:nL(),arguments:ow(nL(),nL()).optional()}),"prompts/list":e3("prompts/list",e7),"resources/list":e3("resources/list",e7),"resources/templates/list":e3("resources/templates/list",e7),"resources/read":e3("resources/read",{uri:nL()}),"completion/complete":e3("completion/complete",ta),"server/discover":e3("server/discover",{}),"subscriptions/listen":e3("subscriptions/listen",tu)};function tf(e){return oh({_meta:eT,...e})}let tg={"tools/call":tf({content:od(W),structuredContent:ol().optional(),isError:oi().optional()}),"tools/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),tools:od(ew),nextCursor:i.optional()}),"prompts/get":tf({description:nL().optional(),messages:od(G)}),"prompts/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),prompts:od(Z),nextCursor:i.optional()}),"resources/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resources:od(j),nextCursor:i.optional()}),"resources/templates/list":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),resourceTemplates:od(A),nextCursor:i.optional()}),"resources/read":tf({ttlMs:n8().int().min(0),cacheScope:ok(["public","private"]),contents:od(og([E,I]))}),"completion/complete":tf({completion:om({values:od(nL()).max(100),total:n8().int().optional(),hasMore:oi().optional()}).loose()}),"server/discover":tf({ttlMs:n8().int().min(0).catch(0),cacheScope:ok(["public","private"]).catch("private"),supportedVersions:od(nL()),capabilities:eb,instructions:nL().optional()}),"subscriptions/listen":tf({})},ty=oh({"io.modelcontextprotocol/subscriptionId":n.optional()}),tv=om({method:oC("notifications/subscriptions/acknowledged"),params:om({_meta:ty.optional(),notifications:tc})}),t_=om({_meta:ty.optional(),requestId:n,reason:nL().optional()}),tb=om({method:oC("notifications/cancelled"),params:t_}),tS=e=>om({jsonrpc:oC("2.0"),id:og([nL(),n8().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:i,RequestIdSchema:n,RoleSchema:o,LoggingLevelSchema:a,TaskMetadataSchema:l,RelatedTaskMetadataSchema:c,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:p,NotificationsParamsSchema:m,NotificationSchema:h,IconSchema:f,IconsSchema:g,BaseMetadataSchema:y,ImplementationSchema:v,ClientTasksCapabilitySchema:S,ServerTasksCapabilitySchema:w,ClientCapabilitiesSchema:R,ServerCapabilitiesSchema:k,ProgressSchema:x,ProgressNotificationParamsSchema:C,ProgressNotificationSchema:$,LoggingMessageNotificationParamsSchema:T,LoggingMessageNotificationSchema:P,ResourceContentsSchema:O,TextResourceContentsSchema:E,BlobResourceContentsSchema:I,AnnotationsSchema:q,ResourceSchema:j,ResourceTemplateSchema:A,ResourceListChangedNotificationSchema:z,ResourceUpdatedNotificationParamsSchema:L,ResourceUpdatedNotificationSchema:N,PromptArgumentSchema:M,PromptSchema:Z,PromptListChangedNotificationSchema:U,TextContentSchema:F,ImageContentSchema:H,AudioContentSchema:D,ToolUseContentSchema:V,EmbeddedResourceSchema:J,ResourceLinkSchema:B,ContentBlockSchema:W,PromptMessageSchema:G,ToolAnnotationsSchema:K,ToolListChangedNotificationSchema:Y,ModelHintSchema:X,ModelPreferencesSchema:Q,ToolChoiceSchema:ee,BooleanSchemaSchema:et,StringSchemaSchema:er,NumberSchemaSchema:ei,UntitledSingleSelectEnumSchemaSchema:en,TitledSingleSelectEnumSchemaSchema:eo,LegacyTitledEnumSchemaSchema:ea,SingleSelectEnumSchemaSchema:es,UntitledMultiSelectEnumSchemaSchema:el,TitledMultiSelectEnumSchemaSchema:ec,MultiSelectEnumSchemaSchema:eu,EnumSchemaSchema:ed,PrimitiveSchemaDefinitionSchema:ep,ElicitRequestFormParamsSchema:em,ResourceTemplateReferenceSchema:eh,PromptReferenceSchema:ef,RootSchema:eg,ClientCapabilities2026Schema:ev,ServerCapabilities2026Schema:eb,RequestMetaEnvelopeSchema:eS,ToolSchema:ew,ToolResultContentSchema:eR,SamplingMessageContentBlockSchema:ek,SamplingMessageSchema:ex,ResultTypeSchema:eC,ResultMetaSchema:e$,ResultSchema:eO,PaginatedResultSchema:eE,CallToolResultSchema:eI,ListToolsResultSchema:eq,ListPromptsResultSchema:ej,GetPromptResultSchema:eA,ListResourcesResultSchema:ez,ListResourceTemplatesResultSchema:eL,ReadResourceResultSchema:eN,CompleteResultSchema:eM,CacheableResultSchema:eZ,DiscoverResultSchema:eU,CreateMessageRequestParamsSchema:eF,CreateMessageRequestSchema:eH,ListRootsRequestSchema:eD,CreateMessageResultSchema:eV,ListRootsResultSchema:eJ,ElicitResultSchema:eB,ElicitRequestURLParamsSchema:eW,ElicitRequestParamsSchema:eG,ElicitRequestSchema:eK,InputRequestSchema:eY,InputResponseSchema:eX,InputRequestsSchema:eQ,InputResponsesSchema:e0,InputRequiredResultSchema:e1,InputResponseRequestParamsSchema:e9,CallToolRequestSchema:e8,ListToolsRequestSchema:te,ListPromptsRequestSchema:tt,GetPromptRequestSchema:tr,ListResourcesRequestSchema:ti,ListResourceTemplatesRequestSchema:tn,ReadResourceRequestSchema:to,CompleteRequestSchema:ts,DiscoverRequestSchema:tl,SubscriptionFilterSchema:tc,SubscriptionsListenRequestSchema:td,SubscriptionsListenResultMetaSchema:tp,SubscriptionsListenResultSchema:tm,dispatchRequestSchemas:th,dispatchResultSchemas:tg,NotificationMetaSchema:ty,SubscriptionsAcknowledgedNotificationSchema:tv,CancelledNotificationParamsSchema:t_,CancelledNotificationSchema:tb,notificationSchemas2026:{"notifications/cancelled":tb,"notifications/progress":$,"notifications/message":P,"notifications/resources/updated":N,"notifications/resources/list_changed":z,"notifications/tools/list_changed":Y,"notifications/prompts/list_changed":U,"notifications/subscriptions/acknowledged":tv},JSONRPCResultResponseSchema:tS(eO),CallToolResultResponseSchema:tS(og([eI,e1])),ListToolsResultResponseSchema:tS(eq),ListPromptsResultResponseSchema:tS(ej),GetPromptResultResponseSchema:tS(og([eA,e1])),ListResourcesResultResponseSchema:tS(ez),ListResourceTemplatesResultResponseSchema:tS(eL),ReadResourceResultResponseSchema:tS(og([eN,e1])),CompleteResultResponseSchema:tS(eM),DiscoverResultResponseSchema:tS(eU),SubscriptionsListenResultResponseSchema:tS(tm)}}()}let cd=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],cp=Symbol("modelcontextprotocol.resultCacheHintFallback");function cm(e,t){if(void 0===t)return e;let r=e[cp];if(void 0===r)return{...e,[cp]:t};let i={},n=r.ttlMs??t.ttlMs;void 0!==n&&(i.ttlMs=n);let o=r.cacheScope??t.cacheScope;return void 0!==o&&(i.cacheScope=o),{...e,[cp]:i}}function ch(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function cf(e){return"public"===e||"private"===e}function cg(e,t){if(void 0!==e.ttlMs&&!ch(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(void 0!==e.cacheScope&&!cf(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}let cy=((T={})[T.ParseError=-32700]="ParseError",T[T.InvalidRequest=-32600]="InvalidRequest",T[T.MethodNotFound=-32601]="MethodNotFound",T[T.InvalidParams=-32602]="InvalidParams",T[T.InternalError=-32603]="InternalError",T[T.ResourceNotFound=-32002]="ResourceNotFound",T[T.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",T[T.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",T[T.UrlElicitationRequired=-32042]="UrlElicitationRequired",T);var cv=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](e){return lD(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lD(this,e)}constructor(e,t,r){super(t),this.code=e,this.data=r,this.name="ProtocolError",lH(this,new.target)}static fromError(t,r,i){return t===cy.UrlElicitationRequired&&i&&i.elicitations?new cb(i.elicitations,r):t===cy.UnsupportedProtocolVersion&&i&&Array.isArray(i.supported)&&"string"==typeof i.requested?new cS({supported:i.supported,requested:i.requested},r):(t===cy.InvalidParams||t===cy.ResourceNotFound)&&"string"==typeof i?.uri&&(t===cy.ResourceNotFound||1===Object.keys(i).length)?new c_(i.uri,r):t===cy.MissingRequiredClientCapability&&i&&null!==i.requiredCapabilities&&"object"==typeof i.requiredCapabilities&&!Array.isArray(i.requiredCapabilities)?new cw({requiredCapabilities:i.requiredCapabilities},r):new e(t,r,i)}},c_=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(cy.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},cb=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(cy.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},cS=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(cy.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},cw=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(cy.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};let cR=["tools/call","prompts/get","resources/read"],ck=["elicitation/create","sampling/createMessage","roots/list"];function cx(){if(o)return o;let e=cu();return o={request:{"elicitation/create":om({method:oC("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":om({method:oC("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":om({method:oC("roots/list"),params:oh({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}}}function cC(e){return ck.includes(e)}function c$(e){return cC(e)?cx().request[e]:void 0}let cT={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},cP={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function cO(e){return Object.prototype.hasOwnProperty.call(cT,e)}function cE(e){return Object.prototype.hasOwnProperty.call(cP,e)}function cI(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function cq(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}Object.keys(cT),Object.keys(cP);let cj={ok:!1,reason:"not-in-era"},cA=[oW,oY],cz={era:"2026-07-28",hasRequestMethod:cO,hasNotificationMethod:cE,hasInputRequestMethod:e=>void 0!==c$(e),validateRequest:(e,t)=>cq(cO(e)?cu().dispatchRequestSchemas[e]:void 0,t),validateResult:(e,t)=>cq(Object.prototype.hasOwnProperty.call(cT,e)?cu().dispatchResultSchemas[e]:void 0,t),validateNotification:(e,t)=>cq(cE(e)?cu().notificationSchemas2026[e]:void 0,t),validateInputRequest:(e,t)=>cq(c$(e),t),validateInputResponse:(e,t)=>cq(cC(e)?cx().response[e]:void 0,t),samplingResultVariant:()=>cj,outboundEnvelope:e=>({[oW]:e.protocolVersion,[oG]:e.clientInfo,[oY]:e.clientCapabilities,...void 0!==e.logLevel&&{[oQ]:e.logLevel}}),validateEnvelopeMeta(e){let t=[];for(let r of cA)r in e||t.push({key:r,problem:"missing"});let r=cu().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let e of r.error.issues){let r=e.path.map(String),i=r.length>0?r.join("."):"_meta";1===r.length&&t.some(e=>e.key===i&&"missing"===e.problem)||t.push({key:i,problem:e.message})}return t},projectCallToolResult:e=>l1(e),inputRequestSchema:c$,decodeResult(e,t){if(!cI(t))return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(void 0===r)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if("string"!=typeof r)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if("input_required"===r){let r=t.inputRequests,i=cI(r)?r:{},n=t.requestState,o=void 0===t._meta?void 0:cu().ResultMetaSchema.safeParse(t._meta),a=o?.success?o.data:void 0;return 0===Object.keys(i).length&&"string"!=typeof n?{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:i,..."string"==typeof n&&{requestState:n},...void 0!==a&&{_meta:a}}}if("complete"!==r)return{kind:"invalid",error:new lW(lB.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let i=cL(),n=Object.hasOwn(i,e)?i[e]:void 0;if(void 0!==n){let r=n.safeParse(t);if(!r.success)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: ${r.error}`,{method:e})}}let o={...t};return delete o.resultType,{kind:"complete",result:o}},encodeResult:(e,t,r)=>(function(e,t){if(void 0===t)return e;let r=e._meta;return void 0===r?{...e,_meta:{[oK]:t}}:null===r||"object"!=typeof r||Array.isArray(r)||void 0!==r[oK]?e:{...e,_meta:{...r,[oK]:t}}})(function(e,t){var r,i;let n=t[cp];if("complete"!==t.resultType||!cd.includes(e)){let e;return void 0===n?t:(e={...t},delete e[cp],e)}let o=ch(t.ttlMs)?t.ttlMs:void 0!==(r=n)&&ch(r.ttlMs)?r.ttlMs:0,a=cf(t.cacheScope)?t.cacheScope:void 0!==(i=n)&&cf(i.cacheScope)?i.cacheScope:"private",s={...t,ttlMs:o,cacheScope:a};return delete s[cp],s}(e,function(e,t){let r=t.resultType;if(void 0===r)return{...t,resultType:"complete"};if("complete"===r||cR.includes(e))return t;throw new cv(cy.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}(e,function(e,t){let r=t,i=!1,n=()=>(i||(r={...r},i=!0),r),o=t.tools;"tools/list"===e&&Array.isArray(o)&&o.some(e=>cI(e)&&"execution"in e)&&(n().tools=o.map(e=>{if(!cI(e)||!("execution"in e))return e;let t={...e};return delete t.execution,t}));let a=t.capabilities;if(cI(a)&&"tasks"in a){let e={...a};delete e.tasks,n().capabilities=e}return r}(e,t))),r),encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope(e){if(void 0===e.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=cu().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join("; ")}`}};function cL(){if(a)return a;let e=cu();return a={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema}}let cN="2026-07-28";function cM(e){return void 0!==e&&e>=lX?cz:cc}function cZ(e){return void 0!==e.revision?cM(e.revision).era:"modern"===e.era?cz.era:cc.era}function cU(e){return cD.some(t=>t.hasRequestMethod(e))}function cF(e){return cD.some(t=>t.hasNotificationMethod(e))}function cH(e){return"tasks/get"===e||"tasks/cancel"===e}let cD=[cc,cz];function cV(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function cJ(e){if(!cV(e))return;let t=e._meta;return cV(t)?t:void 0}function cB(e){let t=cJ(e);return void 0!==t&&oW in t}function cW(e){let t=cJ(e)?.[oW];return"string"==typeof t?t:void 0}function cG(e){return cM(cN).validateEnvelopeMeta(e)}var cK=(e=>{let t={};for(var r in e)V(t,r,{get:e[r],enumerable:!0});return t})({AnnotationsSchema:()=>aH,AudioContentSchema:()=>sc,BaseMetadataSchema:()=>ay,BaseRequestParamsSchema:()=>o7,BlobResourceContentsSchema:()=>aU,BooleanSchemaSchema:()=>sD,CallToolRequestParamsSchema:()=>sk,CallToolRequestSchema:()=>sx,CallToolResultSchema:()=>sw,CancelTaskRequestSchema:()=>lb,CancelTaskResultSchema:()=>lS,CancelledNotificationParamsSchema:()=>am,CancelledNotificationSchema:()=>ah,ClientCapabilitiesSchema:()=>aR,ClientNotificationSchema:()=>lR,ClientRequestSchema:()=>lw,ClientResultSchema:()=>lk,ClientTasksCapabilitySchema:()=>aS,CompatibilityCallToolResultSchema:()=>sR,CompleteRequestParamsSchema:()=>lt,CompleteRequestSchema:()=>lr,CompleteResultSchema:()=>li,ContentBlockSchema:()=>sm,CreateMessageRequestParamsSchema:()=>sZ,CreateMessageRequestSchema:()=>sU,CreateMessageResultSchema:()=>sF,CreateMessageResultWithToolsSchema:()=>sH,CreateTaskResultSchema:()=>ld,CursorSchema:()=>o4,DiscoverRequestSchema:()=>aP,DiscoverResultSchema:()=>aO,ElicitRequestFormParamsSchema:()=>s2,ElicitRequestParamsSchema:()=>s4,ElicitRequestSchema:()=>s5,ElicitRequestURLParamsSchema:()=>s9,ElicitResultSchema:()=>s7,ElicitationCompleteNotificationParamsSchema:()=>s3,ElicitationCompleteNotificationSchema:()=>s6,EmbeddedResourceSchema:()=>sd,EmptyResultSchema:()=>ap,EnumSchemaSchema:()=>s0,GetPromptRequestParamsSchema:()=>so,GetPromptRequestSchema:()=>sa,GetPromptResultSchema:()=>sf,GetTaskPayloadRequestSchema:()=>lg,GetTaskPayloadResultSchema:()=>ly,GetTaskRequestSchema:()=>lh,GetTaskResultSchema:()=>lf,IconSchema:()=>af,IconsSchema:()=>ag,ImageContentSchema:()=>sl,ImplementationSchema:()=>av,InitializeRequestParamsSchema:()=>ak,InitializeRequestSchema:()=>ax,InitializeResultSchema:()=>a$,InitializedNotificationSchema:()=>aT,JSONArraySchema:()=>o2,JSONObjectSchema:()=>o1,JSONRPCErrorResponseSchema:()=>ac,JSONRPCMessageSchema:()=>au,JSONRPCNotificationSchema:()=>as,JSONRPCRequestSchema:()=>aa,JSONRPCResponseSchema:()=>ad,JSONRPCResultResponseSchema:()=>al,JSONValueSchema:()=>o0,LegacyTitledEnumSchemaSchema:()=>sG,ListChangedOptionsBaseSchema:()=>s$,ListPromptsRequestSchema:()=>si,ListPromptsResultSchema:()=>sn,ListResourceTemplatesRequestSchema:()=>aW,ListResourceTemplatesResultSchema:()=>aG,ListResourcesRequestSchema:()=>aJ,ListResourcesResultSchema:()=>aB,ListRootsRequestSchema:()=>lo,ListRootsResultSchema:()=>la,ListTasksRequestSchema:()=>lv,ListTasksResultSchema:()=>l_,ListToolsRequestSchema:()=>sb,ListToolsResultSchema:()=>sS,LoggingLevelSchema:()=>sT,LoggingMessageNotificationParamsSchema:()=>sE,LoggingMessageNotificationSchema:()=>sI,ModelHintSchema:()=>sq,ModelPreferencesSchema:()=>sj,MultiSelectEnumSchemaSchema:()=>sQ,NotificationSchema:()=>ar,NotificationsParamsSchema:()=>at,NumberSchemaSchema:()=>sJ,PaginatedRequestParamsSchema:()=>aA,PaginatedRequestSchema:()=>az,PaginatedResultSchema:()=>aL,PingRequestSchema:()=>aE,PrimitiveSchemaDefinitionSchema:()=>s1,ProgressNotificationParamsSchema:()=>aq,ProgressNotificationSchema:()=>aj,ProgressSchema:()=>aI,ProgressTokenSchema:()=>o9,PromptArgumentSchema:()=>st,PromptListChangedNotificationSchema:()=>sg,PromptMessageSchema:()=>sh,PromptReferenceSchema:()=>le,PromptSchema:()=>sr,ReadResourceRequestParamsSchema:()=>aK,ReadResourceRequestSchema:()=>aY,ReadResourceResultSchema:()=>aX,RelatedTaskMetadataSchema:()=>o3,RequestIdSchema:()=>ao,RequestMetaSchema:()=>o6,RequestSchema:()=>ae,ResourceContentsSchema:()=>aN,ResourceLinkSchema:()=>sp,ResourceListChangedNotificationSchema:()=>aQ,ResourceRequestParamsSchema:()=>aK,ResourceSchema:()=>aD,ResourceTemplateReferenceSchema:()=>s8,ResourceTemplateSchema:()=>aV,ResourceUpdatedNotificationParamsSchema:()=>a8,ResourceUpdatedNotificationSchema:()=>se,ResultMetaObjectSchema:()=>ai,ResultSchema:()=>an,RoleSchema:()=>aF,RootSchema:()=>ln,RootsListChangedNotificationSchema:()=>ls,SamplingContentSchema:()=>sL,SamplingMessageContentBlockSchema:()=>sN,SamplingMessageSchema:()=>sM,ServerCapabilitiesSchema:()=>aC,ServerNotificationSchema:()=>lC,ServerRequestSchema:()=>lx,ServerResultSchema:()=>l$,ServerTasksCapabilitySchema:()=>aw,SetLevelRequestParamsSchema:()=>sP,SetLevelRequestSchema:()=>sO,SingleSelectEnumSchemaSchema:()=>sK,StringSchemaSchema:()=>sV,SubscribeRequestParamsSchema:()=>aK,SubscribeRequestSchema:()=>a0,SubscriptionFilterSchema:()=>a2,SubscriptionsAcknowledgedNotificationParamsSchema:()=>a5,SubscriptionsAcknowledgedNotificationSchema:()=>a3,SubscriptionsListenRequestParamsSchema:()=>a9,SubscriptionsListenRequestSchema:()=>a4,SubscriptionsListenResultMetaSchema:()=>a6,SubscriptionsListenResultSchema:()=>a7,TaskAugmentedRequestParamsSchema:()=>o8,TaskCreationParamsSchema:()=>ll,TaskMetadataSchema:()=>o5,TaskSchema:()=>lu,TaskStatusNotificationParamsSchema:()=>lp,TaskStatusNotificationSchema:()=>lm,TaskStatusSchema:()=>lc,TextContentSchema:()=>ss,TextResourceContentsSchema:()=>aM,TitledMultiSelectEnumSchemaSchema:()=>sX,TitledSingleSelectEnumSchemaSchema:()=>sW,ToolAnnotationsSchema:()=>sy,ToolChoiceSchema:()=>sA,ToolExecutionSchema:()=>sv,ToolListChangedNotificationSchema:()=>sC,ToolResultContentSchema:()=>sz,ToolSchema:()=>s_,ToolUseContentSchema:()=>su,UnsubscribeRequestParamsSchema:()=>aK,UnsubscribeRequestSchema:()=>a1,UntitledMultiSelectEnumSchemaSchema:()=>sY,UntitledSingleSelectEnumSchemaSchema:()=>sB});let cY=e=>aa.safeParse(e).success,cX=e=>as.safeParse(e).success,cQ=e=>al.safeParse(e).success,c0=e=>ac.safeParse(e).success,c1=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"input_required"===e.resultType,c2="x-mcp-header",c9=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,c4=new Set(["string","integer","boolean"]);function c5(e){let t,r=[],i=new Map,n=(e,o,a)=>{if(null===e||"object"!=typeof e)return;if(c2 in e){if(!a||0===o.length)return`${c7(o)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let n=e[c2];if("string"!=typeof n||0===n.length)return`${c7(o)}: x-mcp-header MUST be a non-empty string`;if(!c9.test(n))return`${c7(o)}: x-mcp-header '${n}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let s="string"==typeof e.type?e.type:void 0;if(void 0===s||!c4.has(s)){let e=`${c7(o)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${s??"<none>"}`;if("number"!==s)return e;t??=e}let l=n.toLowerCase(),c=i.get(l);if(void 0!==c)return`x-mcp-header '${n}' is not case-insensitively unique (also declared as '${c}')`;i.set(l,n),r.push({path:o,headerName:n,type:s})}let s=e.properties;if(null!==s&&"object"==typeof s)for(let[e,t]of Object.entries(s)){let r=n(t,[...o,e],a);if(void 0!==r)return r}for(let t of c3){let r=e[t];if(void 0!==r)for(let e of Array.isArray(r)?r:null!==r&&"object"==typeof r&&c6.has(t)?Object.values(r):[r]){let r=n(e,[...o,`<${t}>`],!1);if(void 0!==r)return r}}},o=n(e,[],!0);return void 0!==o?{valid:!1,reason:t??o}:void 0===t?{valid:!0,declarations:r}:{valid:!1,reason:t,declarations:r}}let c3=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],c6=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function c7(e){return 0===e.length?"<root>":e.join(".")}let c8=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,ue=/^-?\d+(\.\d+)?$/;function ut(e){if(!(e.startsWith("=?base64?")&&e.endsWith("?=")))return e;let t=e.slice(9,e.length-2);if(c8.test(t))try{let e=atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.codePointAt(t);return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{return}}function ur(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:ui,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}let ui=-32020;cy.InvalidRequest,cy.UnsupportedProtocolVersion,cy.InvalidParams,cy.MethodNotFound,cy.InvalidParams,cy.MissingRequiredClientCapability;let un={[cy.ParseError]:400,[cy.InvalidRequest]:400,[cy.MethodNotFound]:404,[cy.UnsupportedProtocolVersion]:400,[cy.MissingRequiredClientCapability]:400,[ui]:400};function uo(e,t,r,i,n){return{kind:"reject",rung:e,cell:t,httpStatus:r,code:i.code,message:i.message,...void 0!==i.data&&{data:i.data},settled:n}}function ua(e,t,r,i="era-classification"){return uo(i,e,400,new cv(ui,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}let us={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function ul(e){let t=0;for(;t<e.length;){let r=e.codePointAt(t);if(9!==r&&32!==r)break;t+=1}let r=e.length;for(;r>t;){let t=e.codePointAt(r-1);if(9!==t&&32!==t)break;r-=1}return 0===t&&r===e.length?e:e.slice(t,r)}function uc(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function uu(e){return void 0===e?{era:"modern"}:{era:e>=lX?"modern":"legacy",revision:e}}function ud(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function up(e){if(null==e)return!1;let t=typeof e;return("object"===t||"function"===t)&&"~standard"in e&&"function"==typeof e["~standard"]?.validate}let um=!1,uh="draft-2020-12";function uf(e,t="input"){let r,i=e["~standard"];if(i.jsonSchema)r=i.jsonSchema[t]({target:uh});else if("zod"===i.vendor){if(!("_zod"in e))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");um||(um=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=nn(e,{target:uh,io:t})}else throw Error(`Schema library "${i.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===t)return void 0!==r.type||!function e(t,r=t){if("properties"in t||"patternProperties"in t||"additionalProperties"in t||"required"in t)return!0;let i="string"==typeof t.$ref&&ug.exec(t.$ref);if(i&&r[i[1]]?.[i[2]]?.type==="object")return!0;for(let i of["oneOf","anyOf","allOf"]){let n=t[i];if(Array.isArray(n)&&n.length>0)return n.every(t=>null!==t&&"object"==typeof t&&("object"===t.type||e(t,"$id"in t?{}:r)))}return!1}(r)?r:{type:"object",...r};if(void 0!==r.type&&"object"!==r.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...r}}let ug=/^#\/(\$defs|definitions)\/([^/~%]+)$/;async function uy(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(e=>e.path?.length?`${e.path.map(e=>String("object"==typeof e?e.key:e)).join(".")}: ${e.message}`:e.message).join(", ")}:{success:!0,data:r.value}}let uv=/\\\.\\d\{(\d+)\}/;function u_(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let ub=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function uS(e){return ub.has(e)||e.startsWith("x-")}let uw=new Set(["$schema",...Object.keys(s2.shape.requestedSchema.shape)]),uR={string:ud([sV,sB,sW,sG]),number:ud([sJ]),integer:ud([sJ]),boolean:ud([sD]),array:ud([sY,sX])},uk=new Set(sV.shape.format.unwrap().options);Object.assign(function(e){let t=void 0!==e.inputRequests&&Object.keys(e.inputRequests).length>0,r="string"==typeof e.requestState;if(!t&&!r)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==e.inputRequests&&{inputRequests:e.inputRequests},...void 0!==e.requestState&&{requestState:e.requestState}}},{elicit(e){try{return{method:"elicitation/create",params:function(e){var t;if(!up(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let r=e.requestedSchema["~standard"].vendor,i=function(e,t){let r={},i=[];for(let[n,o]of Object.entries(e))"properties"===n&&u_(o)?r[n]=Object.fromEntries(Object.entries(o).map(([e,r])=>[e,function(e,t,r,i){if(!u_(e))return e;let n="string"==typeof e.type&&Object.hasOwn(uR,e.type)?uR[e.type]:void 0;if(void 0===n)return e;let o={};for(let[s,l]of Object.entries(e))if(n.has(s)||uS(s))o[s]=l;else if("pattern"===s&&"string"===e.type&&"string"==typeof e.format)if(uk.has(e.format)){var a;"string"==typeof l&&(a=e.format,"zod"!==r||(function(e,t){let r;switch(e){case"email":r=[r3(nH,void 0)];break;case"uri":r=[r6(nJ,void 0)];break;case"date":r=[r8(nZ,void 0)];break;case"date-time":let i,n;i=uv.exec(t),n=[void 0,-1,0],i&&n.push(Number(i[1])),r=[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(r=>r7(nM,{local:e,offset:t,precision:r}))))}return new Set(r.map(e=>{let t;return t=nn(e,{target:uh,io:"input"}),"string"==typeof t.pattern?t.pattern:void 0}).filter(e=>void 0!==e))})(a,l).has(l))||i.push(`${t}.${s}`)}else o[s]=l;else i.push(`${t}.${s}`);return o}(r,`properties.${e}`,t,i)])):uw.has(n)?r[n]=o:uS(n)||i.push(n);if(i.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(", ")}`);return r}(function(e){try{return uf(e,"input")}catch(t){let e=t instanceof Error?t.message:String(t);throw new cv(cy.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${e}`)}}(e.requestedSchema),r),n=(t=s2.shape.requestedSchema,nR(t,i));if(!n.success)throw new cv(cy.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(e,t){if(!u_(e.properties))return t;let r=Object.entries(e.properties).filter(([,e])=>!nR(s1,e).success).map(([e])=>`properties.${e}`);return r.length>0?r.join(", "):t}(i,n.error.message)}`);let o=function e(t,r,i=""){return Array.isArray(t)&&Array.isArray(r)?t.flatMap((t,n)=>e(t,r[n],`${i}[${n}]`)):u_(t)&&u_(r)?Object.entries(t).flatMap(([t,n])=>{let o=i?`${i}.${t}`:t;return Object.prototype.hasOwnProperty.call(r,t)?e(n,r[t],o):uS(t)?[]:[o]}):[]}(i,n.data);if(o.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);let a=(n.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(n.data.properties,e));if(a.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(", ")}`);return{...e,mode:"form",requestedSchema:n.data}}(e)}}catch(e){throw e instanceof cv?TypeError(e.message,{cause:e}):e}},elicitUrl:e=>({method:"elicitation/create",params:{...e,mode:"url"}}),createMessage:e=>({method:"sampling/createMessage",params:e}),listRoots:()=>({method:"roots/list"})});let ux={},uC={};function u$(e,t){let r=e.slice(0,-6);ux[r]=t,uC[r]=e=>t.safeParse(e).success}for(let e of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])u$(e,cK[e]);for(let[e,t]of Object.entries({IdJagTokenExchangeResponseSchema:lj,OAuthClientInformationFullSchema:lM,OAuthClientInformationSchema:lN,OAuthClientMetadataSchema:lL,OAuthClientRegistrationErrorSchema:lZ,OAuthErrorResponseSchema:lA,OAuthMetadataSchema:lO,OAuthProtectedResourceMetadataSchema:lP,OAuthTokenRevocationRequestSchema:lU,OAuthTokensSchema:lq,OpenIdProviderDiscoveryMetadataSchema:lI,OpenIdProviderMetadataSchema:lE}))u$(e,t);let uT=Object.freeze(ux);Object.freeze(uC);let uP=[oW,oG,oY,oQ],uO=["inputResponses","requestState"];function uE(e,t){let r=e.params;if(!uz(r))return{message:e,lifted:{}};let i=r._meta,n=uz(i)?uP.filter(e=>e in i):[],o="request"===t?uO.filter(e=>e in r):[];if(0===n.length&&0===o.length)return{message:e,lifted:{}};let a={},s={...r};if(n.length>0&&uz(i)){let e={},t={...i};for(let r of n)e[r]=i[r],delete t[r];a.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of o)"inputResponses"===e&&(a.inputResponses=s[e]),"requestState"===e&&(a.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:a}}function uI(e,t){let r=e.validateResult(t,void 0);if(r.ok||"not-in-era"!==r.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let i=e.validateResult(t,r);return i.ok?{value:i.value}:{issues:[{message:"invalid"===i.reason?i.message:`not-in-era: ${t}`}]}}}}}let uq=(P=void 0,()=>P);function uj(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:()=>t}}}var uA=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{s=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??oB,this.setNotificationHandler("notifications/cancelled",e=>{this._oncancel(e)}),this.setNotificationHandler("notifications/progress",e=>{this._onprogress(e)}),this.setRequestHandler("ping",e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(void 0===t)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new lW(lB.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){void 0!==e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,i,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:n,onTimeout:i})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new lW(lB.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};let i=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{i?.(e,t),cQ(e)||c0(e)?this._onresponse(e):cY(e)?this._onrequest(e,t):cX(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;for(let e of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new lW(lB.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(r);for(let e of t.values())e.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=uE(e,"notification"),i=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return;if(t?.classification!==void 0){let e=cZ(t.classification);if(e!==i.era)return void this._onerror(Error(`Era mismatch on inbound notification '${r.method}': classified as ${e} but this instance serves ${i.era}`))}if(cF(r.method)&&!i.hasNotificationMethod(r.method))return;let n=this._notificationHandlers.get(r.method),o=this.fallbackNotificationHandler;(void 0!==n||void 0!==o)&&Promise.resolve().then(()=>void 0===n?o(r):n(r,i)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){var r;let{message:i,lifted:n}=uE(e,"request"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return void this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));let a=this._transport,s=(e,t,r)=>{let n={jsonrpc:"2.0",id:i.id,error:{code:e,message:t,...void 0!==r&&{data:r}}};a?.send(n).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=cZ(t.classification);if(e!==o.era){this._onerror(Error(`Era mismatch on inbound request '${i.method}': classified as ${e} but this instance serves ${o.era}`));let r=t.classification.revision??e;s(cy.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(cU(i.method)&&!o.hasRequestMethod(i.method)&&!(cH(i.method)&&this._customSchemaRequestMethods.has(i.method)))return void s(cy.MethodNotFound,"Method not found");let l=this._requestHandlers.get(i.method)??this.fallbackRequestHandler;if(void 0===l)return void s(cy.MethodNotFound,"Method not found");let c=o.checkInboundEnvelope(n);if(void 0!==c)return void s(cy.InvalidParams,c);let u=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:i.id}),d=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:i.id}),p=new AbortController;this._requestHandlerAbortControllers.set(i.id,p);let m=void 0===n.inputResponses?void 0:function(e){let t={},r=[];if(!uL(e))return{accepted:t,droppedKeys:r};for(let[i,n]of Object.entries(e)){if(!uL(n)||"method"in n||"result"in n){r.push(i);continue}t[i]=n}return{accepted:t,droppedKeys:r}}(n.inputResponses),h={sessionId:a?.sessionId,mcpReq:{id:i.id,method:i.method,_meta:i.params?._meta,...void 0!==n.envelope&&{envelope:n.envelope},...void 0!==m&&{inputResponses:m.accepted},...void 0!==m&&m.droppedKeys.length>0&&{droppedInputResponseKeys:m.droppedKeys},requestState:void 0===n.requestState?uq:(r=n.requestState,()=>r),signal:p.signal,send:(e,t,r)=>{let i=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(i,e.method),up(t))return d(e,t,r);let n=uI(i,e.method);if(void 0===n)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(e,n,t)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},f=this.buildContext(h,t);Promise.resolve().then(()=>l(i,f)).then(async e=>{let t;if(p.signal.aborted)return;try{t=o.encodeResult(i.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${i.method}: ${e}`)),s(cy.InternalError,"Internal error");return}let r={result:t,jsonrpc:"2.0",id:i.id};await a?.send(r)},async e=>{if(p.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:cy.InternalError,r={jsonrpc:"2.0",id:i.id,error:{code:o.encodeErrorCode(t),message:e.message??"Internal error",...void 0!==e.data&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(i.id)===p&&this._requestHandlerAbortControllers.delete(i.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,i=Number(t),n=this._progressHandlers.get(i);if(!n)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));let o=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&o&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(e){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),o(e);return}n(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);void 0===r?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`)):(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),r(cQ(e)?e:cv.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let i=this._resolveOutboundCodec(e.method);if(up(t))return cH(e.method)||this._assertOutboundRequestInEra(i,e.method),this._requestWithSchemaViaCodec(i,e,t,r);this._assertOutboundRequestInEra(i,e.method);let n=uI(i,e.method);if(void 0===n)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(i,e,n,t)}_negotiatedWireCodec(){return cM(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(void 0===this._negotiatedProtocolVersion){let t=function(e){switch(e){case"initialize":case"notifications/initialized":return cM(void 0);case"server/discover":return cM(cN);default:return}}(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(cU(t)&&!e.hasRequestMethod(t))throw new lW(lB.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let i=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(i,e.method),this._requestWithSchemaViaCodec(i,e,t,r)}_requestWithSchemaViaCodec(e,t,r,i){let n,o,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l,headers:c}=i??{},u=Date.now();return new Promise((d,p)=>{let m=e=>{p(e)};if(!this._transport)return void m(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){m(e);return}if(i?.signal?.aborted){let e=i.signal.reason;throw e instanceof lW?e:new lW(lB.RequestTimeout,String(e))}let h=e.era===cN&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,f=this._requestMessageId++;o=f;let g={...t,jsonrpc:"2.0",id:f};i?.onprogress&&(this._progressHandlers.set(f,i.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:f}});let y=this._envelopeOutbound(g),v=!1,_=e=>{v||(this._progressHandlers.delete(f),void 0===h?"initialize"!==t.method&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(e)}}),{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):h.abort(),p(e instanceof lW?e:new lW(lB.RequestTimeout,String(e))))};this._responseHandlers.set(f,n=>{let o;if(!i?.signal?.aborted){if(v=!0,n instanceof Error)return p(n);try{o=e.decodeResult(t.method,n.result)}catch(e){return p(e instanceof Error?e:Error(String(e)))}if("invalid"===o.kind)return p(o.error);if("input_required"===o.kind){var a;return i?.allowInputRequired===!0?d({resultType:"input_required",inputRequests:(a=o).inputRequests,...void 0!==a.requestState&&{requestState:a.requestState},...void 0!==a._meta&&{_meta:a._meta}}):d(this._resolveNonCompleteResult(o,{codec:e,request:t,resultSchema:r,options:i,flowStartedAt:u,retry:(i,n)=>this._requestWithSchemaViaCodec(e,void 0===i?{method:t.method}:{method:t.method,params:i},r,n)}))}uy(r,o.result).then(e=>{e.success?d(e.data):p(new lW(lB.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},p)}}),n=()=>_(i?.signal?.reason),i?.signal?.addEventListener("abort",n,{once:!0});let b=i?.timeout??6e4;this._setupTimeout(f,b,i?.maxTotalTimeout,()=>_(new lW(lB.RequestTimeout,"Request timed out",{timeout:b})),i?.resetTimeoutOnProgress??!1),this._transport.send(y,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l,headers:c,requestSignal:h?.signal}).catch(e=>{this._progressHandlers.delete(f),p(e)})}).finally(()=>{n&&i?.signal?.removeEventListener("abort",n),void 0!==o&&(this._responseHandlers.delete(o),this._cleanupTimeout(o))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new lW(lB.NotConnected,"Not connected");if(cF(t.method)&&!e.hasNotificationMethod(t.method))throw new lW(lB.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let i=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(i,r).catch(e=>this._onerror(e))});return}await this._transport.send(i,r)}setRequestHandler(e,t,r){let i;if(this.assertRequestHandlerCapability(e),"function"==typeof t){if(!cU(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);i=(r,i)=>{let n=this._negotiatedWireCodec(),o=n.validateRequest(e,r);if(o.ok||"not-in-era"!==o.reason||(o=n.validateInputRequest(e,r)),!o.ok){if("not-in-era"===o.reason)throw new cv(cy.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(o.message)}return Promise.resolve(t(o.value,i))}}else if(r)i=async(i,n)=>{let o=await uy(t.params,{...i.params});if(!o.success)throw new cv(cy.InvalidParams,`Invalid params for ${e}: ${o.error}`);return r(o.data,n)};else throw TypeError("setRequestHandler: handler is required");"function"==typeof t?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,i))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if("function"==typeof t){if(!cF(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,i)=>{let n=i.validateNotification(e,r);if(!n.ok){if("not-in-era"===n.reason)throw new cv(cy.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(n.message)}return Promise.resolve(t(n.value))});return}if(!r)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async i=>{let n=await uy(t.params,{...i.params});if(!n.success)throw new cv(cy.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,i)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function uz(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function uL(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var uN=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var i,n=B(t),o=0,a=n.length;o<a;o++)i=n[o],G.call(e,i)||void 0===i||V(e,i,{get:(e=>t[e]).bind(null,i),enumerable:!(r=J(t,i))||r.enumerable});return e})(V(null!=(R=(S=e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,i=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function n(e){this.parameters=Object.create(null),this.type=e}e.parse=function(e){if(!e)throw TypeError("argument string is required");var o,a,s,l="object"==typeof e?function(e){var t;if("function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]),"string"!=typeof t)throw TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof l)throw TypeError("argument string is required to be a string");var c=l.indexOf(";"),u=-1!==c?l.slice(0,c).trim():l.trim();if(!i.test(u))throw TypeError("invalid media type");var d=new n(u.toLowerCase());if(-1!==c){for(t.lastIndex=c;a=t.exec(l);){if(a.index!==c)throw TypeError("invalid parameter format");c+=a[0].length,o=a[1].toLowerCase(),34===(s=a[2]).charCodeAt(0)&&-1!==(s=s.slice(1,-1)).indexOf("\\")&&(s=s.replace(r,"$1")),d.parameters[o]=s}if(c!==l.length)throw TypeError("invalid parameter format")}return d}},()=>(w||S((w={exports:{}}).exports),w.exports))())?D(W(R)):{},"default",{value:R,enumerable:!0}),R);function uM(e){if(e)try{return uN.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();if(""===t||e.slice(t.length).includes(","))return;return t}}function uZ(e){return"application/json"===e||"application/json"===uM(e)}let uU=/^[A-Za-z0-9._-]{1,128}$/;function uF(e){let t=function(e){let t=[];if(0===e.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!uU.test(e)){let r=[...e].filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,r)=>r.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${r.map(e=>`"${e}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}(e);var r=t.warnings;if(r.length>0){for(let t of(console.warn(`Tool name validation warning for "${e}":`),r))console.warn(` - ${t}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}return t.isValid}var uH=class e{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,r){if(e.length>t)throw Error(`${r} exceeds maximum length of ${t} characters (got ${e.length})`)}template;parts;get variableNames(){return this.parts.flatMap(e=>"string"==typeof e?[]:e.names)}constructor(t){e.validateLength(t,1e6,"Template"),this.template=t,this.parts=this.parse(t)}toString(){return this.template}parse(t){let r=[],i="",n=0,o=0;for(;n<t.length;)if("{"===t[n]){i&&(r.push(i),i="");let a=t.indexOf("}",n);if(-1===a)throw Error("Unclosed template expression");if(++o>1e4)throw Error("Template contains too many expressions (max 10000)");let s=t.slice(n+1,a),l=this.getOperator(s),c=s.includes("*"),u=this.getNames(s),d=u[0];for(let t of u)e.validateLength(t,1e6,"Variable name");r.push({name:d,operator:l,names:u,exploded:c}),n=a+1}else i+=t[n],n++;return i&&r.push(i),r}getOperator(e){return["+","#",".","/","?","&"].find(t=>e.startsWith(t))||""}getNames(e){let t=this.getOperator(e);return e.slice(t.length).split(",").map(e=>e.replace("*","").trim()).filter(e=>e.length>0)}encodeValue(t,r){return(e.validateLength(t,1e6,"Variable value"),"+"===r||"#"===r)?encodeURI(t):encodeURIComponent(t)}expandPart(e,t){if("?"===e.operator||"&"===e.operator){let r=e.names.map(r=>{let i=t[r];return void 0===i?"":`${r}=${Array.isArray(i)?i.map(t=>this.encodeValue(t,e.operator)).join(","):this.encodeValue(i.toString(),e.operator)}`}).filter(e=>e.length>0);return 0===r.length?"":("?"===e.operator?"?":"&")+r.join("&")}if(e.names.length>1){let r=e.names.map(e=>t[e]).filter(e=>void 0!==e);return 0===r.length?"":r.map(e=>Array.isArray(e)?e[0]:e).join(",")}let r=t[e.name];if(void 0===r)return"";let i=(Array.isArray(r)?r:[r]).map(t=>this.encodeValue(t,e.operator));switch(e.operator){case"":case"+":default:return i.join(",");case"#":return"#"+i.join(",");case".":return"."+i.join(".");case"/":return"/"+i.join("/")}}expand(e){let t="",r=!1;for(let i of this.parts){if("string"==typeof i){t+=i;continue}let n=this.expandPart(i,e);n&&(t+=("?"===i.operator||"&"===i.operator)&&r?n.replace("?","&"):n,("?"===i.operator||"&"===i.operator)&&(r=!0))}return t}escapeRegExp(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(t){let r,i=[];for(let r of t.names)e.validateLength(r,1e6,"Variable name");if("?"===t.operator||"&"===t.operator){for(let e=0;e<t.names.length;e++){let r=t.names[e],n=0===e?"\\"+t.operator:"&";i.push({pattern:n+this.escapeRegExp(r)+"=([^&]+)",name:r})}return i}let n=t.name;switch(t.operator){case"":r=t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":r="(.+)";break;case".":r=String.raw`\.([^/,]+)`;break;case"/":r="/"+(t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:r="([^/]+)"}return i.push({pattern:r,name:n}),i}match(t){e.validateLength(t,1e6,"URI");let r="^",i=[];for(let e of this.parts)if("string"==typeof e)r+=this.escapeRegExp(e);else for(let{pattern:t,name:n}of this.partToRegExp(e))r+=t,i.push({name:n,exploded:e.exploded});r+="$",e.validateLength(r,1e6,"Generated regex pattern");let n=new RegExp(r),o=t.match(n);if(!o)return null;let a={};for(let[e,t]of i.entries()){let{name:r,exploded:i}=t,n=o[e+1];a[r.replace("*","")]=i&&n.includes(",")?n.split(","):n}return a}};function uD(e){if(void 0!==e){if(function(e){if("object"!=typeof e||null===e||up(e))return!1;let t=Object.getPrototypeOf(e);return(t===Object.prototype||null===t)&&Object.values(e).every(e=>"object"==typeof e&&null!==e&&"_zod"in e)}(e))return om(e);if("object"==typeof e&&null!==e&&!up(e)&&Object.values(e).some(e=>"object"==typeof e&&null!==e&&!("_zod"in e)&&"_def"in e&&"string"==typeof e._def?.typeName))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!up(e))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return e}}function uV(){l4(),cu(),cr(),cx(),cL()}function uJ(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let i=0;i<r;i++)if(!uJ(e[i],t[i]))return!1;return!0}if("object"===r){if(!e||!t)return e===t;let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!uJ(e[i],t[i]))return!1;return!0}return e===t}function uB(e){return encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1"))}let uW={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},uG={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},uK={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},uY="u">typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function uX(e,t=Object.create(null),r=uY,i=""){if(e&&"object"==typeof e&&!Array.isArray(e)){let n=e.$id||e.id;if(n){let o=new URL(n,r.href);o.hash.length>1?t[o.href]=e:(o.hash="",""===i?r=o:uX(e,t,r))}}else if(!0!==e&&!1!==e)return t;let n=r.href+(i?"#"+i:"");if(void 0!==t[n])throw Error(`Duplicate schema URI "${n}".`);if(t[n]=e,!0===e||!1===e)return t;if(void 0===e.__absolute_uri__&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&void 0===e.__absolute_ref__){let t=new URL(e.$ref,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&void 0===e.__absolute_recursive_ref__){let t=new URL(e.$recursiveRef,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}for(let n in e.$anchor&&(t[new URL("#"+e.$anchor,r.href).href]=e),e){if(uK[n])continue;let o=`${i}/${uB(n)}`,a=e[n];if(Array.isArray(a)){if(uW[n]){let e=a.length;for(let i=0;i<e;i++)uX(a[i],t,r,`${o}/${i}`)}}else if(uG[n])for(let e in a)uX(a[e],t,r,`${o}/${uB(e)}`);else uX(a,t,r,o)}return t}let uQ=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,u0=[0,31,28,31,30,31,30,31,31,30,31,30,31],u1=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function u2(e){return e.test.bind(e)}let u9={date:u4,time:u5.bind(void 0,!1),"date-time":function(e){let t=e.split(u3);return 2==t.length&&u4(t[0])&&u5(!0,t[1])},duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),uri:function(e){return u6.test(e)&&u7.test(e)},"uri-reference":u2(/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i),"uri-template":u2(/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i),url:u2(/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu),email:e=>{if('"'===e[0])return!1;let[t,r,...i]=e.split("@");return!(!t||!r||0!==i.length||t.length>64||r.length>253||"."===t[0]||t.endsWith(".")||t.includes(".."))&&!!/^[a-z0-9.-]+$/i.test(r)&&!!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)&&r.split(".").every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},hostname:u2(/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i),ipv4:u2(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:u2(/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i),regex:function(e){if(u8.test(e))return!1;try{return RegExp(e,"u"),!0}catch(e){return!1}},uuid:u2(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":u2(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":u2(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":u2(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function u4(e){var t;let r=e.match(uQ);if(!r)return!1;let i=+r[1],n=+r[2],o=+r[3];return n>=1&&n<=12&&o>=1&&o<=(2==n&&(t=i)%4==0&&(t%100!=0||t%400==0)?29:u0[n])}function u5(e,t){let r=t.match(u1);if(!r)return!1;let i=+r[1],n=+r[2],o=+r[3],a=!!r[5];return(i<=23&&n<=59&&o<=59||23==i&&59==n&&60==o)&&(!e||a)}let u3=/t|\s/i,u6=/\/|:/,u7=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,u8=/[^\\]\\Z/;var de=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",r=!0){this.schema=e,this.draft=t,this.shortCircuit=r,this.lookup=uX(e)}validate(e){return function e(t,r,i="2019-09",n=uX(r),o=!0,a=null,s="#",l="#",c=Object.create(null)){let u;if(!0===r)return{valid:!0,errors:[]};if(!1===r)return{valid:!1,errors:[{instanceLocation:s,keyword:"false",keywordLocation:s,error:"False boolean schema."}]};let d=typeof t;switch(d){case"boolean":case"number":case"string":u=d;break;case"object":u=null===t?"null":Array.isArray(t)?"array":"object";break;default:throw Error(`Instances of "${d}" type are not supported.`)}let{$ref:p,$recursiveRef:m,$recursiveAnchor:h,type:f,const:g,enum:y,required:v,not:_,anyOf:b,allOf:S,oneOf:w,if:R,then:k,else:x,format:C,properties:$,patternProperties:T,additionalProperties:P,unevaluatedProperties:O,minProperties:E,maxProperties:I,propertyNames:q,dependentRequired:j,dependentSchemas:A,dependencies:z,prefixItems:L,items:N,additionalItems:M,unevaluatedItems:Z,contains:U,minContains:F,maxContains:H,minItems:D,maxItems:V,uniqueItems:J,minimum:B,maximum:W,exclusiveMinimum:G,exclusiveMaximum:K,multipleOf:Y,minLength:X,maxLength:Q,pattern:ee,__absolute_ref__:et,__absolute_recursive_ref__:er}=r,ei=[];if(!0===h&&null===a&&(a=r),"#"===m){let u=null===a?n[er]:a,d=`${l}/$recursiveRef`,p=e(t,null===a?r:a,i,n,o,u,s,d,c);p.valid||ei.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:d,error:"A subschema had errors."},...p.errors)}if(void 0!==p){let r=n[et||p];if(void 0===r){let e=`Unresolved $ref "${p}".`;throw et&&et!==p&&(e+=` Absolute URI "${et}".`),Error(e+=`
|
|
56
56
|
Known schemas:
|
|
57
|
-
- ${Object.keys(n).join("\n- ")}`)}let u=`${l}/$ref`,d=e(t,r,i,n,o,a,s,u,c);if(d.valid||ei.push({instanceLocation:s,keyword:"$ref",keywordLocation:u,error:"A subschema had errors."},...d.errors),"4"===i||"7"===i)return{valid:0===ei.length,errors:ei}}if(Array.isArray(f)){let e=f.length,r=!1;for(let i=0;i<e;i++)if(u===f[i]||"integer"===f[i]&&"number"===u&&t%1==0&&t==t){r=!0;break}r||ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f.join('", "')}".`})}else"integer"===f?("number"!==u||t%1||t!=t)&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`}):void 0!==f&&u!==f&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`});if(void 0!==g&&("object"===u||"array"===u?uJ(t,g)||ei.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):t!==g&&ei.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),void 0!==y&&("object"===u||"array"===u?y.some(e=>uJ(t,e))||ei.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`}):y.some(e=>t===e)||ei.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`})),void 0!==_){let r=`${l}/not`;e(t,_,i,n,o,a,s,r).valid&&ei.push({instanceLocation:s,keyword:"not",keywordLocation:r,error:'Instance matched "not" schema.'})}let en=[];if(void 0!==b){let r=`${l}/anyOf`,u=ei.length,d=!1;for(let l=0;l<b.length;l++){let u=b[l],p=Object.create(c),m=e(t,u,i,n,o,!0===h?a:null,s,`${r}/${l}`,p);ei.push(...m.errors),d=d||m.valid,m.valid&&en.push(p)}d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:r,error:"Instance does not match any subschemas."})}if(void 0!==S){let r=`${l}/allOf`,u=ei.length,d=!0;for(let l=0;l<S.length;l++){let u=S[l],p=Object.create(c),m=e(t,u,i,n,o,!0===h?a:null,s,`${r}/${l}`,p);ei.push(...m.errors),d=d&&m.valid,m.valid&&en.push(p)}d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"allOf",keywordLocation:r,error:"Instance does not match every subschema."})}if(void 0!==w){let r=`${l}/oneOf`,u=ei.length,d=w.filter((l,u)=>{let d=Object.create(c),p=e(t,l,i,n,o,!0===h?a:null,s,`${r}/${u}`,d);return ei.push(...p.errors),p.valid&&en.push(d),p.valid}).length;1===d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:r,error:`Instance does not match exactly one subschema (${d} matches).`})}if(("object"===u||"array"===u)&&Object.assign(c,...en),void 0!==R){let r=`${l}/if`;if(e(t,R,i,n,o,a,s,r,c).valid){if(void 0!==k){let u=e(t,k,i,n,o,a,s,`${l}/then`,c);u.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "then" schema.'},...u.errors)}}else if(void 0!==x){let u=e(t,x,i,n,o,a,s,`${l}/else`,c);u.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "else" schema.'},...u.errors)}}if("object"===u){if(void 0!==v)for(let e of v)e in t||ei.push({instanceLocation:s,keyword:"required",keywordLocation:`${l}/required`,error:`Instance does not have required property "${e}".`});let r=Object.keys(t);if(void 0!==O&&r.length<O&&ei.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${O} properties.`}),void 0!==I&&r.length>I&&ei.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${I} properties.`}),void 0!==q){let r=`${l}/propertyNames`;for(let l in t){let t=`${s}/${uB(l)}`,c=e(l,q,i,n,o,a,t,r);c.valid||ei.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:r,error:`Property name "${l}" does not match schema.`},...c.errors)}}if(void 0!==j){let e=`${l}/dependantRequired`;for(let r in j)if(r in t)for(let i of j[r])i in t||ei.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:e,error:`Instance has "${r}" but does not have "${i}".`})}if(void 0!==A)for(let r in A){let u=`${l}/dependentSchemas`;if(r in t){let l=e(t,A[r],i,n,o,a,s,`${u}/${uB(r)}`,c);l.valid||ei.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:u,error:`Instance has "${r}" but does not match dependant schema.`},...l.errors)}}if(void 0!==z){let r=`${l}/dependencies`;for(let l in z)if(l in t){let c=z[l];if(Array.isArray(c))for(let e of c)e in t||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not have "${e}".`});else{let u=e(t,c,i,n,o,a,s,`${r}/${uB(l)}`);u.valid||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not match dependant schema.`},...u.errors)}}}let u=Object.create(null),d=!1;if(void 0!==$){let r=`${l}/properties`;for(let l in $){if(!(l in t))continue;let p=`${s}/${uB(l)}`,m=e(t[l],$[l],i,n,o,a,p,`${r}/${uB(l)}`);if(m.valid)c[l]=u[l]=!0;else if(d=o,ei.push({instanceLocation:s,keyword:"properties",keywordLocation:r,error:`Property "${l}" does not match schema.`},...m.errors),d)break}}if(!d&&void 0!==T){let r=`${l}/patternProperties`;for(let l in T){let p=RegExp(l,"u"),m=T[l];for(let h in t){if(!p.test(h))continue;let f=`${s}/${uB(h)}`,g=e(t[h],m,i,n,o,a,f,`${r}/${uB(l)}`);g.valid?c[h]=u[h]=!0:(d=o,ei.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:r,error:`Property "${h}" matches pattern "${l}" but does not match associated schema.`},...g.errors))}}}if(d||void 0===P){if(!d&&void 0!==E){let r=`${l}/unevaluatedProperties`;for(let l in t)if(!c[l]){let u=`${s}/${uB(l)}`,d=e(t[l],E,i,n,o,a,u,r);d.valid?c[l]=!0:ei.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:r,error:`Property "${l}" does not match unevaluated properties schema.`},...d.errors)}}}else{let r=`${l}/additionalProperties`;for(let l in t){if(u[l])continue;let p=`${s}/${uB(l)}`,m=e(t[l],P,i,n,o,a,p,r);m.valid?c[l]=!0:(d=o,ei.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:r,error:`Property "${l}" does not match additional properties schema.`},...m.errors))}}}else if("array"===u){void 0!==V&&t.length>V&&ei.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${t.length} > ${V}).`}),void 0!==D&&t.length<D&&ei.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${t.length} < ${D}).`});let r=t.length,u=0,d=!1;if(void 0!==L){let p=`${l}/prefixItems`,m=Math.min(L.length,r);for(;u<m;u++){let r=e(t[u],L[u],i,n,o,a,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!r.valid&&(d=o,ei.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}}if(void 0!==N){let p=`${l}/items`;if(Array.isArray(N)){let l=Math.min(N.length,r);for(;u<l;u++){let r=e(t[u],N[u],i,n,o,a,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!r.valid&&(d=o,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}}else for(;u<r;u++){let r=e(t[u],N,i,n,o,a,`${s}/${u}`,p);if(c[u]=!0,!r.valid&&(d=o,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}if(!d&&void 0!==M){let p=`${l}/additionalItems`;for(;u<r;u++){let r=e(t[u],M,i,n,o,a,`${s}/${u}`,p);c[u]=!0,r.valid||(d=o,ei.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:p,error:"Items did not match additional items schema."},...r.errors))}}}if(void 0!==U)if(0===r&&void 0===F)ei.push({instanceLocation:s,keyword:"contains",keywordLocation:`${l}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==F&&r<F)ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${r}) than minContains (${F}).`});else{let u=`${l}/contains`,d=ei.length,p=0;for(let l=0;l<r;l++){let r=e(t[l],U,i,n,o,a,`${s}/${l}`,u);r.valid?(c[l]=!0,p++):ei.push(...r.errors)}p>=(F||0)&&(ei.length=d),void 0===F&&void 0===H&&0===p?ei.splice(d,0,{instanceLocation:s,keyword:"contains",keywordLocation:u,error:"Array does not contain item matching schema."}):void 0!==F&&p<F?ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${F} items matching schema. Only ${p} items were found.`}):void 0!==H&&p>H&&ei.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${H} items matching schema. ${p} items were found.`})}if(!d&&void 0!==Z){let d=`${l}/unevaluatedItems`;for(;u<r;u++){if(c[u])continue;let r=e(t[u],Z,i,n,o,a,`${s}/${u}`,d);c[u]=!0,r.valid||ei.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:d,error:"Items did not match unevaluated items schema."},...r.errors)}}if(J)for(let e=0;e<r;e++){let i=t[e],n="object"==typeof i&&null!==i;for(let o=0;o<r;o++){if(e===o)continue;let r=t[o];(i===r||n&&"object"==typeof r&&null!==r&&uJ(i,r))&&(ei.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${e} and ${o}.`}),e=Number.MAX_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER)}}}else if("number"===u){if("4"===i?(void 0!==B&&(!0===G&&t<=B||t<B)&&ei.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${G?"or equal to ":""} ${B}.`}),void 0!==W&&(!0===K&&t>=W||t>W)&&ei.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${K?"or equal to ":""} ${W}.`})):(void 0!==B&&t<B&&ei.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${B}.`}),void 0!==W&&t>W&&ei.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${W}.`}),void 0!==G&&t<=G&&ei.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${l}/exclusiveMinimum`,error:`${t} is less than ${G}.`}),void 0!==K&&t>=K&&ei.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${l}/exclusiveMaximum`,error:`${t} is greater than or equal to ${K}.`})),void 0!==Y){let e=t%Y;Math.abs(0-e)>=11920929e-14&&Math.abs(Y-e)>=11920929e-14&&ei.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${l}/multipleOf`,error:`${t} is not a multiple of ${Y}.`})}}else if("string"===u){let e=void 0===X&&void 0===Q?0:function(e){let t,r=0,i=e.length,n=0;for(;n<i;)r++,(t=e.charCodeAt(n++))>=55296&&t<=56319&&n<i&&(64512&(t=e.charCodeAt(n)))==56320&&n++;return r}(t);void 0!==X&&e<X&&ei.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${l}/minLength`,error:`String is too short (${e} < ${X}).`}),void 0!==Q&&e>Q&&ei.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${l}/maxLength`,error:`String is too long (${e} > ${Q}).`}),void 0===ee||RegExp(ee,"u").test(t)||ei.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${l}/pattern`,error:"String does not match pattern."}),void 0!==C&&u9[C]&&!u9[C](t)&&ei.push({instanceLocation:s,keyword:"format",keywordLocation:`${l}/format`,error:`String does not match format "${C}".`})}return{valid:0===ei.length,errors:ei}}(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),uX(e,this.lookup)}},dt=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=function(e,t){if(!("$schema"in e)||"string"!=typeof e.$schema)return"2020-12";let r=e.$schema.replace(/#$/,"");if(K.has(r))return"2020-12";if(Y.has(r))return"2019-09";if(X.has(r)||Q.has(r))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return"draft-7"===t?"7":t}getValidator(e){let t=new de(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let r=t.validate(e);return r.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:r.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join("; ")}}}};uV();let dr=Symbol.for("mcp.completable");function di(e){return!!e&&"object"==typeof e&&dr in e}function dn(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,0x7fffffff));return r.unref?.(),r}var da=class{static{l=e=>e._classification}onclose;onerror;onmessage;_classification;_responseMode;_started=!1;_used=!1;_closed=!1;_terminalDelivered=!1;_dispatchWindowOpen=!1;_requestId;_deferredResponse;_sse;_abortCleanup;_keepAliveMs;constructor(e){this._classification=e.classification,this._responseMode=e.responseMode??"auto",this._keepAliveMs=e.keepAliveMs??15e3}async start(){if(this._started)throw Error("PerRequestHTTPServerTransport is already started");this._started=!0}async handleMessage(e,t){if(this._used)throw Error("PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request");if(!this._started||void 0===this.onmessage)throw Error("PerRequestHTTPServerTransport is not connected: connect a server to this transport before handling a message");if(this._closed)throw Error("PerRequestHTTPServerTransport is closed");this._used=!0;let r=t?.request?.signal;if(r?.aborted)throw await this.close(),new lW(lB.ConnectionClosed,"The request was aborted before it could be handled");let i={classification:this._classification,...t?.request!==void 0&&{request:t.request},...t?.authInfo!==void 0&&{authInfo:t.authInfo}};if(cY(e)){let t,n;this._requestId=e.id;let o=new Promise((e,r)=>{t=e,n=r});if(this._deferredResponse={promise:o,resolve:t,reject:n,settled:!1},void 0!==r){let e=()=>void this.close();r.addEventListener("abort",e,{once:!0}),this._abortCleanup=()=>r.removeEventListener("abort",e)}this._dispatchWindowOpen=!0;try{this.onmessage(e,i)}finally{this._dispatchWindowOpen=!1}return"sse"!==this._responseMode||this._closed||this._deferredResponse.settled||this.upgradeToSse(),o}return this.onmessage(e,i),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let r=cQ(e)||c0(e),i=r?e.id:t?.relatedRequestId;if(void 0===this._requestId||void 0===i||i!==this._requestId){r&&this.onerror?.(Error(`Received a response for an unknown request id: ${String(e.id)}`));return}if(r){if(this._terminalDelivered)return;this._terminalDelivered=!0;let t=c0(e)?e.error.code:void 0,r=void 0!==t&&(this._dispatchWindowOpen||t===cy.MissingRequiredClientCapability)?un[t]:void 0;if(void 0!==r&&void 0===this._sse){this.settleResponse(Response.json(e,{status:r,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}if(void 0!==this._sse||"sse"===this._responseMode){void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(e),this.finalizeStream();return}this.settleResponse(Response.json(e,{status:200,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}"json"!==this._responseMode&&(void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(e))}writeCommentFrame(e){if(this._closed||void 0===this._sse||this._sse.closed)return;let t=e.split("\n").map(e=>`: ${e}`).join("\n");this.writeFrame(`${t}
|
|
57
|
+
- ${Object.keys(n).join("\n- ")}`)}let u=`${l}/$ref`,d=e(t,r,i,n,o,a,s,u,c);if(d.valid||ei.push({instanceLocation:s,keyword:"$ref",keywordLocation:u,error:"A subschema had errors."},...d.errors),"4"===i||"7"===i)return{valid:0===ei.length,errors:ei}}if(Array.isArray(f)){let e=f.length,r=!1;for(let i=0;i<e;i++)if(u===f[i]||"integer"===f[i]&&"number"===u&&t%1==0&&t==t){r=!0;break}r||ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f.join('", "')}".`})}else"integer"===f?("number"!==u||t%1||t!=t)&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`}):void 0!==f&&u!==f&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`});if(void 0!==g&&("object"===u||"array"===u?uJ(t,g)||ei.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):t!==g&&ei.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),void 0!==y&&("object"===u||"array"===u?y.some(e=>uJ(t,e))||ei.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`}):y.some(e=>t===e)||ei.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`})),void 0!==_){let r=`${l}/not`;e(t,_,i,n,o,a,s,r).valid&&ei.push({instanceLocation:s,keyword:"not",keywordLocation:r,error:'Instance matched "not" schema.'})}let en=[];if(void 0!==b){let r=`${l}/anyOf`,u=ei.length,d=!1;for(let l=0;l<b.length;l++){let u=b[l],p=Object.create(c),m=e(t,u,i,n,o,!0===h?a:null,s,`${r}/${l}`,p);ei.push(...m.errors),d=d||m.valid,m.valid&&en.push(p)}d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:r,error:"Instance does not match any subschemas."})}if(void 0!==S){let r=`${l}/allOf`,u=ei.length,d=!0;for(let l=0;l<S.length;l++){let u=S[l],p=Object.create(c),m=e(t,u,i,n,o,!0===h?a:null,s,`${r}/${l}`,p);ei.push(...m.errors),d=d&&m.valid,m.valid&&en.push(p)}d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"allOf",keywordLocation:r,error:"Instance does not match every subschema."})}if(void 0!==w){let r=`${l}/oneOf`,u=ei.length,d=w.filter((l,u)=>{let d=Object.create(c),p=e(t,l,i,n,o,!0===h?a:null,s,`${r}/${u}`,d);return ei.push(...p.errors),p.valid&&en.push(d),p.valid}).length;1===d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:r,error:`Instance does not match exactly one subschema (${d} matches).`})}if(("object"===u||"array"===u)&&Object.assign(c,...en),void 0!==R){let r=`${l}/if`;if(e(t,R,i,n,o,a,s,r,c).valid){if(void 0!==k){let u=e(t,k,i,n,o,a,s,`${l}/then`,c);u.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "then" schema.'},...u.errors)}}else if(void 0!==x){let u=e(t,x,i,n,o,a,s,`${l}/else`,c);u.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "else" schema.'},...u.errors)}}if("object"===u){if(void 0!==v)for(let e of v)e in t||ei.push({instanceLocation:s,keyword:"required",keywordLocation:`${l}/required`,error:`Instance does not have required property "${e}".`});let r=Object.keys(t);if(void 0!==E&&r.length<E&&ei.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${E} properties.`}),void 0!==I&&r.length>I&&ei.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${I} properties.`}),void 0!==q){let r=`${l}/propertyNames`;for(let l in t){let t=`${s}/${uB(l)}`,c=e(l,q,i,n,o,a,t,r);c.valid||ei.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:r,error:`Property name "${l}" does not match schema.`},...c.errors)}}if(void 0!==j){let e=`${l}/dependantRequired`;for(let r in j)if(r in t)for(let i of j[r])i in t||ei.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:e,error:`Instance has "${r}" but does not have "${i}".`})}if(void 0!==A)for(let r in A){let u=`${l}/dependentSchemas`;if(r in t){let l=e(t,A[r],i,n,o,a,s,`${u}/${uB(r)}`,c);l.valid||ei.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:u,error:`Instance has "${r}" but does not match dependant schema.`},...l.errors)}}if(void 0!==z){let r=`${l}/dependencies`;for(let l in z)if(l in t){let c=z[l];if(Array.isArray(c))for(let e of c)e in t||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not have "${e}".`});else{let u=e(t,c,i,n,o,a,s,`${r}/${uB(l)}`);u.valid||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not match dependant schema.`},...u.errors)}}}let u=Object.create(null),d=!1;if(void 0!==$){let r=`${l}/properties`;for(let l in $){if(!(l in t))continue;let p=`${s}/${uB(l)}`,m=e(t[l],$[l],i,n,o,a,p,`${r}/${uB(l)}`);if(m.valid)c[l]=u[l]=!0;else if(d=o,ei.push({instanceLocation:s,keyword:"properties",keywordLocation:r,error:`Property "${l}" does not match schema.`},...m.errors),d)break}}if(!d&&void 0!==T){let r=`${l}/patternProperties`;for(let l in T){let p=RegExp(l,"u"),m=T[l];for(let h in t){if(!p.test(h))continue;let f=`${s}/${uB(h)}`,g=e(t[h],m,i,n,o,a,f,`${r}/${uB(l)}`);g.valid?c[h]=u[h]=!0:(d=o,ei.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:r,error:`Property "${h}" matches pattern "${l}" but does not match associated schema.`},...g.errors))}}}if(d||void 0===P){if(!d&&void 0!==O){let r=`${l}/unevaluatedProperties`;for(let l in t)if(!c[l]){let u=`${s}/${uB(l)}`,d=e(t[l],O,i,n,o,a,u,r);d.valid?c[l]=!0:ei.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:r,error:`Property "${l}" does not match unevaluated properties schema.`},...d.errors)}}}else{let r=`${l}/additionalProperties`;for(let l in t){if(u[l])continue;let p=`${s}/${uB(l)}`,m=e(t[l],P,i,n,o,a,p,r);m.valid?c[l]=!0:(d=o,ei.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:r,error:`Property "${l}" does not match additional properties schema.`},...m.errors))}}}else if("array"===u){void 0!==V&&t.length>V&&ei.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${t.length} > ${V}).`}),void 0!==D&&t.length<D&&ei.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${t.length} < ${D}).`});let r=t.length,u=0,d=!1;if(void 0!==L){let p=`${l}/prefixItems`,m=Math.min(L.length,r);for(;u<m;u++){let r=e(t[u],L[u],i,n,o,a,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!r.valid&&(d=o,ei.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}}if(void 0!==N){let p=`${l}/items`;if(Array.isArray(N)){let l=Math.min(N.length,r);for(;u<l;u++){let r=e(t[u],N[u],i,n,o,a,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!r.valid&&(d=o,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}}else for(;u<r;u++){let r=e(t[u],N,i,n,o,a,`${s}/${u}`,p);if(c[u]=!0,!r.valid&&(d=o,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}if(!d&&void 0!==M){let p=`${l}/additionalItems`;for(;u<r;u++){let r=e(t[u],M,i,n,o,a,`${s}/${u}`,p);c[u]=!0,r.valid||(d=o,ei.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:p,error:"Items did not match additional items schema."},...r.errors))}}}if(void 0!==U)if(0===r&&void 0===F)ei.push({instanceLocation:s,keyword:"contains",keywordLocation:`${l}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==F&&r<F)ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${r}) than minContains (${F}).`});else{let u=`${l}/contains`,d=ei.length,p=0;for(let l=0;l<r;l++){let r=e(t[l],U,i,n,o,a,`${s}/${l}`,u);r.valid?(c[l]=!0,p++):ei.push(...r.errors)}p>=(F||0)&&(ei.length=d),void 0===F&&void 0===H&&0===p?ei.splice(d,0,{instanceLocation:s,keyword:"contains",keywordLocation:u,error:"Array does not contain item matching schema."}):void 0!==F&&p<F?ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${F} items matching schema. Only ${p} items were found.`}):void 0!==H&&p>H&&ei.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${H} items matching schema. ${p} items were found.`})}if(!d&&void 0!==Z){let d=`${l}/unevaluatedItems`;for(;u<r;u++){if(c[u])continue;let r=e(t[u],Z,i,n,o,a,`${s}/${u}`,d);c[u]=!0,r.valid||ei.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:d,error:"Items did not match unevaluated items schema."},...r.errors)}}if(J)for(let e=0;e<r;e++){let i=t[e],n="object"==typeof i&&null!==i;for(let o=0;o<r;o++){if(e===o)continue;let r=t[o];(i===r||n&&"object"==typeof r&&null!==r&&uJ(i,r))&&(ei.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${e} and ${o}.`}),e=Number.MAX_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER)}}}else if("number"===u){if("4"===i?(void 0!==B&&(!0===G&&t<=B||t<B)&&ei.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${G?"or equal to ":""} ${B}.`}),void 0!==W&&(!0===K&&t>=W||t>W)&&ei.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${K?"or equal to ":""} ${W}.`})):(void 0!==B&&t<B&&ei.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${B}.`}),void 0!==W&&t>W&&ei.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${W}.`}),void 0!==G&&t<=G&&ei.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${l}/exclusiveMinimum`,error:`${t} is less than ${G}.`}),void 0!==K&&t>=K&&ei.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${l}/exclusiveMaximum`,error:`${t} is greater than or equal to ${K}.`})),void 0!==Y){let e=t%Y;Math.abs(0-e)>=11920929e-14&&Math.abs(Y-e)>=11920929e-14&&ei.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${l}/multipleOf`,error:`${t} is not a multiple of ${Y}.`})}}else if("string"===u){let e=void 0===X&&void 0===Q?0:function(e){let t,r=0,i=e.length,n=0;for(;n<i;)r++,(t=e.charCodeAt(n++))>=55296&&t<=56319&&n<i&&(64512&(t=e.charCodeAt(n)))==56320&&n++;return r}(t);void 0!==X&&e<X&&ei.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${l}/minLength`,error:`String is too short (${e} < ${X}).`}),void 0!==Q&&e>Q&&ei.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${l}/maxLength`,error:`String is too long (${e} > ${Q}).`}),void 0===ee||RegExp(ee,"u").test(t)||ei.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${l}/pattern`,error:"String does not match pattern."}),void 0!==C&&u9[C]&&!u9[C](t)&&ei.push({instanceLocation:s,keyword:"format",keywordLocation:`${l}/format`,error:`String does not match format "${C}".`})}return{valid:0===ei.length,errors:ei}}(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),uX(e,this.lookup)}},dt=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=function(e,t){if(!("$schema"in e)||"string"!=typeof e.$schema)return"2020-12";let r=e.$schema.replace(/#$/,"");if(K.has(r))return"2020-12";if(Y.has(r))return"2019-09";if(X.has(r)||Q.has(r))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return"draft-7"===t?"7":t}getValidator(e){let t=new de(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let r=t.validate(e);return r.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:r.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join("; ")}}}};uV();let dr=Symbol.for("mcp.completable");function di(e){return!!e&&"object"==typeof e&&dr in e}function dn(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,0x7fffffff));return r.unref?.(),r}var da=class{static{l=e=>e._classification}onclose;onerror;onmessage;_classification;_responseMode;_started=!1;_used=!1;_closed=!1;_terminalDelivered=!1;_dispatchWindowOpen=!1;_requestId;_deferredResponse;_sse;_abortCleanup;_keepAliveMs;constructor(e){this._classification=e.classification,this._responseMode=e.responseMode??"auto",this._keepAliveMs=e.keepAliveMs??15e3}async start(){if(this._started)throw Error("PerRequestHTTPServerTransport is already started");this._started=!0}async handleMessage(e,t){if(this._used)throw Error("PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request");if(!this._started||void 0===this.onmessage)throw Error("PerRequestHTTPServerTransport is not connected: connect a server to this transport before handling a message");if(this._closed)throw Error("PerRequestHTTPServerTransport is closed");this._used=!0;let r=t?.request?.signal;if(r?.aborted)throw await this.close(),new lW(lB.ConnectionClosed,"The request was aborted before it could be handled");let i={classification:this._classification,...t?.request!==void 0&&{request:t.request},...t?.authInfo!==void 0&&{authInfo:t.authInfo}};if(cY(e)){let t,n;this._requestId=e.id;let o=new Promise((e,r)=>{t=e,n=r});if(this._deferredResponse={promise:o,resolve:t,reject:n,settled:!1},void 0!==r){let e=()=>void this.close();r.addEventListener("abort",e,{once:!0}),this._abortCleanup=()=>r.removeEventListener("abort",e)}this._dispatchWindowOpen=!0;try{this.onmessage(e,i)}finally{this._dispatchWindowOpen=!1}return"sse"!==this._responseMode||this._closed||this._deferredResponse.settled||this.upgradeToSse(),o}return this.onmessage(e,i),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let r=cQ(e)||c0(e),i=r?e.id:t?.relatedRequestId;if(void 0===this._requestId||void 0===i||i!==this._requestId){r&&this.onerror?.(Error(`Received a response for an unknown request id: ${String(e.id)}`));return}if(r){if(this._terminalDelivered)return;this._terminalDelivered=!0;let t=c0(e)?e.error.code:void 0,r=void 0!==t&&(this._dispatchWindowOpen||t===cy.MissingRequiredClientCapability)?un[t]:void 0;if(void 0!==r&&void 0===this._sse){this.settleResponse(Response.json(e,{status:r,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}if(void 0!==this._sse||"sse"===this._responseMode){void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(e),this.finalizeStream();return}this.settleResponse(Response.json(e,{status:200,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}"json"!==this._responseMode&&(void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(e))}writeCommentFrame(e){if(this._closed||void 0===this._sse||this._sse.closed)return;let t=e.split("\n").map(e=>`: ${e}`).join("\n");this.writeFrame(`${t}
|
|
58
58
|
|
|
59
59
|
`)}async close(){if(!this._closed){if(this._closed=!0,this._abortCleanup?.(),this._abortCleanup=void 0,this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),void 0!==this._sse&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}void 0===this._deferredResponse||this._deferredResponse.settled||(this._deferredResponse.settled=!0,this._deferredResponse.reject(new lW(lB.ConnectionClosed,"Connection closed before a response was produced"))),this.onclose?.()}}settleResponse(e){void 0===this._deferredResponse||this._deferredResponse.settled||(this._deferredResponse.settled=!0,this._deferredResponse.resolve(e))}upgradeToSse(){let e,t=new ReadableStream({start:t=>{e=t},cancel:()=>{this.close()}});this._sse={controller:e,encoder:new TextEncoder,closed:!1},this._sse.keepAliveTimer=dn(this._keepAliveMs,()=>this.writeCommentFrame("keepalive")),this.settleResponse(new Response(t,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}))}finalizeStream(){if(this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),void 0!==this._sse&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}queueMicrotask(()=>void this.close())}writeMessageFrame(e){this.writeFrame(`event: message
|
|
60
60
|
data: ${JSON.stringify(e)}
|
|
61
61
|
|
|
62
|
-
`)}writeFrame(e){if(void 0!==this._sse&&!this._sse.closed)try{this._sse.controller.enqueue(this._sse.encoder.encode(e))}catch(e){this.onerror?.(Error(`Failed to write to the response stream: ${e}`))}}};function ds(e){return e.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function dl(e,t,r,i){let n=`Bearer error="${ds(e)}", error_description="${ds(t)}"`;return r.length>0&&(n+=`, scope="${ds(r.join(" "))}"`),i&&(n+=`, resource_metadata="${ds(i)}"`),n}async function dc(e,t,r){for(let n of e){let e=await r({request:n,...void 0!==t&&{authInfo:t}});if(void 0!==e){if(null===e||"object"!=typeof e||!Array.isArray(e.scopes)||0===e.scopes.length)throw TypeError("scope challenge must contain at least one scope");for(let[t,r]of e.scopes.entries()){var i=`scope challenge scopes[${t}]`;if("string"!=typeof r||!/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(r))throw TypeError(`${i} must satisfy the OAuth scope-token grammar`)}if(void 0!==e.errorDescription&&"string"!=typeof e.errorDescription)throw TypeError("scope challenge errorDescription must be a string");if(void 0!==e.errorDescription&&!/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(e.errorDescription))throw TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");return e}}}function du(e){if(e?.resourceMetadataUrl!==void 0)return e.resourceMetadataUrl;if(e?.resource?.protocol==="https:"||e?.resource?.protocol==="http:"){var t,r;let i,n;return i=new URL(t=e.resource),n=(r=t.pathname).length>1&&r.endsWith("/")?r.slice(0,-1):r,i.pathname=`/.well-known/oauth-protected-resource${"/"===n?"":n}`,i.hash="",i.href}}function dd(e,t){return function(e,t){let{requiredScopes:r=[],resourceMetadataUrl:i}=t??{};if(!(e instanceof lJ)){let e=new lJ(lV.ServerError,"Internal Server Error");return Response.json(e.toResponseObject(),{status:500})}switch(e.code){case lV.InvalidToken:{let t=dl(e.code,e.message,r,i);return Response.json(e.toResponseObject(),{status:401,headers:{"WWW-Authenticate":t}})}case lV.InsufficientScope:{let t=dl(e.code,e.message,r,i);return Response.json(e.toResponseObject(),{status:403,headers:{"WWW-Authenticate":t}})}case lV.ServerError:return Response.json(e.toResponseObject(),{status:500});default:return Response.json(e.toResponseObject(),{status:400})}}(new lJ(lV.InsufficientScope,e.errorDescription??"Insufficient scope"),{requiredScopes:[...e.scopes],resourceMetadataUrl:t})}function dp(e,t,r){if(null===r||"object"!=typeof r||"string"!=typeof r.method)throw new cv(cy.InternalError,`Handler for ${e} returned an invalid input request '${t}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let i=function(e){switch(e.method){case"elicitation/create":if(e.params?.mode==="url")return{elicitation:{url:{}}};return{elicitation:{form:{}}};case"sampling/createMessage":{let t=e.params;if(void 0!==t&&(void 0!==t.tools||void 0!==t.toolChoice))return{sampling:{tools:{}}};return{sampling:{}}}case"roots/list":return{roots:{}};default:return}}(r);if(void 0===i)throw new cv(cy.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${r.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:r,required:i}}function dm(e,t){if("tools/call"===e)return{content:[{type:"text",text:t}],isError:!0};throw new cv(cy.InternalError,t)}var dh=class{constructor(e){this._host=e}async fulfill(e,t,r,i,n){let{maxRounds:o,roundTimeoutMs:a}=this._host,s=i.mcpReq.signal,l=n,c=0;for(;;){let n;if((c+=1)>o)return dm(e,`Multi-round-trip request '${e}' still required input after ${o} rounds (inputRequired.maxRounds)`);let u=l.inputRequests,d=null!=u&&Object.keys(u).length>0,p="string"==typeof l.requestState?l.requestState:void 0;if(!d&&void 0===p)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(d){let t=this._host.resolvedClientCapabilities(i),r=[];for(let[i,n]of Object.entries(u)){let{embedded:o,required:a}=dp(e,i,n);if("roots/list"!==o.method&&void 0===o.params)throw new cv(cy.InternalError,`Handler for ${e} returned an input request '${i}' of kind '${o.method}' without params`);if(void 0!==lY(a,t))return dm(e,`Cannot request input '${i}' (${o.method}): the client on this 2025-era connection did not declare the required capability${void 0===t?" (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)":""}`);r.push([i,o])}let o=function(e){let t=new AbortController,r=()=>t.abort(e?.reason);return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener("abort",r)}}(s);try{let e={relatedRequestId:i.mcpReq.id,timeout:a,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:o.signal},t=await Promise.all(r.map(async([t,r])=>{try{return[t,await this._dispatchLeg(r,e)]}catch(e){throw o.abort(e),e}}));n=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return dm(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{o.dispose()}}else await function(e){return new Promise((t,r)=>{if(e?.aborted)return void r(e.reason instanceof lW?e.reason:new lW(lB.RequestTimeout,String(e.reason)));let i=setTimeout(()=>{e?.removeEventListener("abort",n),t()},250),n=()=>{clearTimeout(i),r(e?.reason instanceof lW?e.reason:new lW(lB.RequestTimeout,String(e?.reason)))};e?.addEventListener("abort",n,{once:!0})})}(s);let m={...i,mcpReq:{...i.mcpReq,inputResponses:n,droppedInputResponseKeys:void 0,requestState:function(e){return()=>e}(p)}};if(void 0!==p){let t=await this._host.verifyRequestState(p,m,e);void 0!==t&&(m=uj(m,t))}let h=await t(r,m);if(!c1(h))return h;l=h}}async _dispatchLeg(e,t){switch(e.method){case"elicitation/create":{let r=e.params;return"url"===r.mode&&void 0===r.elicitationId&&(r={...r,elicitationId:function(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;let r=[...t].map(e=>e.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}()}),await this._host.sendElicitation(r,t)}case"sampling/createMessage":return await this._host.sendSampling(e.params,t);case"roots/list":return await this._host.listRoots(e.params,t)}}};let df=new Set(["tools/call","prompts/get","resources/read"]);var dg=class extends uA{_clientCapabilities;_clientVersion;static{c=(e,t)=>{void 0!==t.clientCapabilities&&(e._clientCapabilities=t.clientCapabilities),void 0!==t.clientInfo&&(e._clientVersion=t.clientInfo)},u=(e,t)=>{let r=t.filter(t=>!e._supportedProtocolVersions.includes(t));r.length>0&&(e._supportedProtocolVersions=[...e._supportedProtocolVersions,...r]),e.setRequestHandler("server/discover",()=>e._ondiscover())},d=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_boundFromTransport=!1;_legacyInputRequiredShim(){return this._legacyShim??=new dh({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,r)=>this._verifyRequestState(e,t,r),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){if(super(t),this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new dt,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=function(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??8,roundTimeoutMs:e?.roundTimeoutMs??6e5,legacyShim:e?.legacyShim??!0}}(t?.inputRequired),t?.cacheHints!==void 0){for(let[e,r]of Object.entries(t.cacheHints))void 0!==r&&cg(r,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",e=>this._oninitialize(e)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),l0(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}async connect(e){if(void 0!==this.transport)throw new lW(lB.AlreadyConnected,"Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");this._boundFromTransport&&(this._boundFromTransport=!1,this._negotiatedProtocolVersion=void 0);let t=(e instanceof da?l(e):void 0)?.revision;void 0!==t&&!this._servedModernEra()&&lQ.includes(t)&&l0(this._supportedProtocolVersions).includes(t)&&(this._negotiatedProtocolVersion=t,this._boundFromTransport=!0),await super.connect(e)}_registerLoggingHandler(){this.setRequestHandler("logging/setLevel",async(e,t)=>{let r=t.sessionId||t.http?.req?.headers.get("mcp-session-id")||void 0,{level:i}=e.params,n=nR(sT,i);return n.success&&this._loggingLevels.set(r,n.data),{}})}buildContext(e,t){let r=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(t,r,i)=>{let n;if(!this._capabilities.logging)return Promise.resolve();if(this._servedModernEra()){if(void 0===(n=e.mcpReq.envelope?.[oQ]))return Promise.resolve()}else n=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return void 0!==n&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(n)?Promise.resolve():e.mcpReq.notify({method:"notifications/message",params:{level:t,data:r,logger:i}})},elicitInput:(e,t)=>this.elicitInput(e,t),requestSampling:(e,t)=>this.createMessage(e,t)},http:r?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(sT.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let r=this._loggingLevels.get(t);return!!r&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(r)};registerCapabilities(e){if(this.transport)throw new lW(lB.AlreadyConnected,"Cannot register capabilities after connecting to transport");let t=!!this._capabilities.logging;this._capabilities=function(e,t){let r={...e};for(let e in t){let i=t[e];if(void 0===i)continue;let n=r[e];r[e]=uz(n)&&uz(i)?{...n,...i}:i}return r}(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if("tools/call"!==e){let r=this._cacheHints?.[e],i=df.has(e);return void 0!==r||i?async(n,o)=>{let a=i?await this._invokeInputRequiredCapableHandler(e,t,n,o):await t(n,o);if(c1(a)){if(!i)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return a}return void 0===r?a:cm(a,r)}:async(r,i)=>{let n=await t(r,i);if(c1(n))throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return n}}return async(e,r)=>{let i=cM(this._negotiatedProtocolVersion),n=i.validateRequest("tools/call",e);if(!n.ok)throw new cv("not-in-era"===n.reason?cy.InternalError:cy.InvalidParams,"not-in-era"===n.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${n.message}`);let o=await this._invokeInputRequiredCapableHandler("tools/call",t,e,r);if(c1(o))return o;let a=l9(o),s=i.validateResult("tools/call",a);if(!s.ok)throw new cv("not-in-era"===s.reason?cy.InternalError:cy.InvalidParams,"not-in-era"===s.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call result: ${s.message}`);return s.value}}_servedModernEra(){return void 0!==this._negotiatedProtocolVersion&&this._negotiatedProtocolVersion>=lX}async _invokeInputRequiredCapableHandler(e,t,r,i){let n,o=this._servedModernEra(),a=i.mcpReq.requestState();if(void 0!==a&&"string"!=typeof a)throw new cv(cy.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let s=i;if("string"==typeof a){let t=await this._verifyRequestState(a,i,e);void 0!==t&&(s=uj(i,t))}try{n=await t(r,s)}catch(e){if(e instanceof cv&&e.code===cy.UrlElicitationRequired){if(!o)throw e;throw new cv(cy.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`)}throw e}if(!c1(n))return n;if(!o){if(!this._inputRequiredServing.legacyShim)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??oJ}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,r,s,n)}let l=n.inputRequests,c=null!=l&&Object.keys(l).length>0,u="string"==typeof n.requestState;if(!c&&!u)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(c){let t=this._inputRequestCapabilityView(i);for(let[r,i]of Object.entries(l)){let{embedded:n,required:o}=dp(e,r,i),a=lY(o,t);if(void 0!==a)throw new cw({requiredCapabilities:a},`Cannot request input '${r}' (${n.method}): the request's client capabilities do not declare the required capability`)}}return n}async _verifyRequestState(e,t,r){if(void 0!==this._requestStateVerify)try{return await this._requestStateVerify(e,t)}catch(e){throw this.onerror?.(Error(`requestState verification rejected ${r}: ${e instanceof Error?e.message:String(e)}`)),new cv(cy.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[oY]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new lW(lB.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${e}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:e,era:"2026-07-28"})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new lW(lB.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new lW(lB.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new lW(lB.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new lW(lB.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new lW(lB.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new lW(lB.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new lW(lB.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new lW(lB.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new lW(lB.CapabilityNotSupported,`Server does not support tools (required for ${e})`)}}async _oninitialize(e){let t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;let r=this._supportedProtocolVersions.filter(e=>!(e>=lX)),i=r.includes(t)?t:r[0]??oJ;return this._negotiatedProtocolVersion=i,this.transport?.setProtocolVersion?.(i),{protocolVersion:i,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:l0(this._supportedProtocolVersions),capabilities:{...this.getCapabilities()},...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(e,t){return this._wireCodec().projectCallToolResult(e,t)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra("ping"),this.request({method:"ping"})}async createMessage(e,t){if(this._assertPushApiInServedEra("sampling/createMessage"),(e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new lW(lB.CapabilityNotSupported,"Client does not support sampling tools capability.");if(e.messages.length>0){let t=e.messages.at(-1),r=Array.isArray(t.content)?t.content:[t.content],i=r.some(e=>"tool_result"===e.type),n=e.messages.length>1?e.messages.at(-2):void 0,o=n?Array.isArray(n.content)?n.content:[n.content]:[],a=o.some(e=>"tool_use"===e.type);if(i){if(r.some(e=>"tool_result"!==e.type))throw new cv(cy.InvalidParams,"The last message must contain only tool_result content if any is present");if(!a)throw new cv(cy.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(a){let e=new Set(o.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(r.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new cv(cy.InvalidParams,"ids of tool_result blocks and tool_use blocks from previous message do not match")}}let r=!!(e.tools||e.toolChoice),i=await this.request({method:"sampling/createMessage",params:e},t),n=this._wireCodec().samplingResultVariant(r,i);if(!n.ok)throw new lW(lB.InvalidResult,`Invalid sampling/createMessage result: ${"invalid"===n.reason?n.message:n.reason}`);return n.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra("elicitation/create"),e.mode??"form"){case"url":if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new lW(lB.CapabilityNotSupported,"Client does not support form elicitation.")}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,r){let i=e.mode??"form",n=r?.validateAcceptedContent??!0;switch(i){case"url":return this.request({method:"elicitation/create",params:e},t);case"form":{let r="form"===e.mode?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:r},t);if(n&&"accept"===i.action&&i.content&&r.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(r.requestedSchema)(i.content);if(!e.valid)throw new cv(cy.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof cv)throw e;throw new cv(cy.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return i}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,"Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this._assertPushApiInServedEra("roots/list"),this.request({method:"roots/list",params:e},t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}},dy=class{server;_maxToolInputElements;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(void 0!==t&&t.enabled){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(void 0===t.inputSchema)return db;try{let r=uf(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new dg(e,t),this._maxToolInputElements=function(e){if(void 0!==e&&1/0!==e){if("number"!=typeof e||Number.isNaN(e)||e<1)throw RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}(t?.maxToolInputElements),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return"object"==typeof e&&null!==e&&"setScopeChallengeResolver"in e&&"function"==typeof e.setScopeChallengeResolver&&e.setScopeChallengeResolver(e=>this.resolveScopeChallenge(e)),await this.server.connect(e)}async close(){await this.server.close()}resolveScopeChallenge=e=>{switch(e.request.method){case"tools/call":{let t=e.request.params?.name;if("string"!=typeof t)return;let r=this._registeredTools[t];if(void 0===r||!r.enabled)return;return r.scopeChallenge?.(e)}case"resources/read":{let t,r=e.request.params?.uri;if("string"!=typeof r)return;try{t=new URL(r)}catch{return}let i=this._registeredResources[t.toString()];if(void 0!==i)return i.enabled?i.scopeChallenge?.(e):void 0;for(let r of Object.values(this._registeredResourceTemplates))if(r.resourceTemplate.uriTemplate.match(t.toString()))return r.enabled?r.scopeChallenge?.(e):void 0;return}case"prompts/get":{let t=e.request.params?.name;if("string"!=typeof t)return;let r=this._registeredPrompts[t];if(void 0===r||!r.enabled)return;return r.scopeChallenge?.(e)}default:return}};_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler("tools/list"),this.server.assertCanSetRequestHandler("tools/call"),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler("tools/list",()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{var r;let i,n,o={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?(r=e,(n=c5(i=uf(t.inputSchema,"input"))).valid||console.warn(`[mcp-sdk] tool '${r}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${n.reason}`),i):db,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(o.outputSchema=uf(t.outputSchema,"output")),o})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new cv(cy.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Tool ${e.params.name} disabled`);try{let i=await this.validateToolInput(r,e.params.arguments,e.params.name),n=await this.executeToolHandler(r,i,t);if(await this.validateToolOutput(r,n,e.params.name),c1(n))return n;return this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(e){if(e instanceof cv&&e.code===cy.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,r){if(void 0!==this._maxToolInputElements&&function(e,t){let r=0,i=[e];for(;i.length>0;){let e=i.pop();if(null!==e&&"object"==typeof e)if(Array.isArray(e))for(let n of e){if(++r>t)return r;null!==n&&"object"==typeof n&&i.push(n)}else for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(++r>t)return r;let o=e[n];null!==o&&"object"==typeof o&&i.push(o)}}return r}(t,this._maxToolInputElements)>this._maxToolInputElements)throw new cv(cy.InvalidParams,`Invalid arguments for tool ${r}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let i=await uy(e.inputSchema,t??{});if(!i.success)throw new cv(cy.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${i.error}`);return i.data}async validateToolOutput(e,t,r){if(!e.outputSchema||c1(t)||t.isError)return;if(void 0===t.structuredContent)throw new cv(cy.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let i=await uy(e.outputSchema,t.structuredContent);if(!i.success)throw new cv(cy.InvalidParams,`Output validation error: Invalid structured content for tool ${r}: ${i.error}`)}async executeToolHandler(e,t,r){return e.executor(t,r)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler("completion/complete"),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler("completion/complete",async e=>{switch(e.params.ref.type){case"ref/prompt":if("ref/prompt"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`);return this.handlePromptCompletion(e,e.params.ref);case"ref/resource":if("ref/resource"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`);return this.handleResourceCompletion(e,e.params.ref);default:throw new cv(cy.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let r=this._registeredPrompts[t.name];if(!r)throw new cv(cy.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return dk;let i=dC(dx(r.argsSchema)?.[e.params.argument.name]);if(!di(i))return dk;let n=i[dr]?.complete;return n?dR(await n(e.params.argument.value,e.params.context)):dk}async handleResourceCompletion(e,t){let r=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!r){if(this._registeredResources[t.uri])return dk;throw new cv(cy.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let i=r.resourceTemplate.completeCallback(e.params.argument.name);return i?dR(await i(e.params.argument.value,e.params.context)):dk}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler("resources/list"),this.server.assertCanSetRequestHandler("resources/templates/list"),this.server.assertCanSetRequestHandler("resources/read"),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler("resources/list",async(e,t)=>{let r=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),i=[];for(let e of Object.values(this._registeredResourceTemplates))if(e.resourceTemplate.listCallback)for(let r of(await e.resourceTemplate.listCallback(t)).resources)i.push({...e.metadata,...r});return{resources:[...r,...i]}}),this.server.setRequestHandler("resources/templates/list",async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler("resources/read",async(e,t)=>{let r;try{r=new URL(e.params.uri)}catch{throw new cv(cy.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:"invalid_uri"})}let i=this._registeredResources[r.toString()];if(i){if(!i.enabled)throw new cv(cy.InvalidParams,`Resource ${r} disabled`);return cm(await i.readCallback(r,t),i.cacheHint)}for(let e of Object.values(this._registeredResourceTemplates)){let i=e.resourceTemplate.uriTemplate.match(r.toString());if(i){if(!e.enabled)throw new cv(cy.InvalidParams,`Resource template ${e.resourceTemplate.uriTemplate} disabled`);return cm(await e.readCallback(r,i,t),e.cacheHint)}}throw new c_(e.params.uri)}),this._resourceHandlersInitialized=!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler("prompts/list"),this.server.assertCanSetRequestHandler("prompts/get"),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler("prompts/list",()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>{let r,i,n;return{name:e,title:t.title,description:t.description,arguments:t.argsSchema?(i=(r=uf(t.argsSchema,"input")).properties||{},n=r.required||[],Object.entries(i).map(([e,t])=>({name:e,description:t?.description,required:n.includes(e)}))):void 0,icons:t.icons,_meta:t._meta}})})),this.server.setRequestHandler("prompts/get",async(e,t)=>{let r=this._registeredPrompts[e.params.name];if(!r)throw new cv(cy.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Prompt ${e.params.name} disabled`);return r.handler(e.params.arguments,t)}),this._promptHandlersInitialized=!0)}registerResource(e,t,r,i){let{cacheHint:n,scopeChallenge:o,...a}=r;if(void 0!==n&&cg(n,`resource ${e}`),"string"==typeof t){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let s=this._createRegisteredResource(e,r.title,t,a,o,i);return void 0!==n&&(s.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,r.title,t,a,o,i);return void 0!==n&&(s.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,t,r,i,n,o){let a={name:e,title:t,metadata:i,readCallback:o,scopeChallenge:n,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{void 0!==e.uri&&e.uri!==r&&(delete this._registeredResources[r],e.uri&&(this._registeredResources[e.uri]=a)),void 0!==e.name&&(a.name=e.name),void 0!==e.metadata&&(a.metadata=e.metadata),void 0!==e.title&&(a.title=e.title,a.metadata={...a.metadata,title:e.title}),void 0!==e.callback&&(a.readCallback=e.callback),void 0!==e.scopeChallenge&&(a.scopeChallenge=null===e.scopeChallenge?void 0:e.scopeChallenge),void 0!==e.enabled&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=a,a}_createRegisteredResourceTemplate(e,t,r,i,n,o){let a={resourceTemplate:r,title:t,metadata:i,readCallback:o,scopeChallenge:n,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),void 0!==t.template&&(a.resourceTemplate=t.template),void 0!==t.metadata&&(a.metadata=t.metadata),void 0!==t.title&&(a.title=t.title,a.metadata={...a.metadata,title:t.title}),void 0!==t.callback&&(a.readCallback=t.callback),void 0!==t.scopeChallenge&&(a.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t.enabled&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let s=r.uriTemplate.variableNames;return Array.isArray(s)&&s.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,r,i,n,o,a,s){let l=i,c=n,u={title:t,description:r,argsSchema:i,icons:o,scopeChallenge:a,_meta:s,handler:dw(e,i,n),enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=u)),void 0!==t.title&&(u.title=t.title),void 0!==t.description&&(u.description=t.description),void 0!==t.icons&&(u.icons=t.icons),void 0!==t.scopeChallenge&&(u.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t._meta&&(u._meta=t._meta);let r=!1;void 0!==t.argsSchema&&(u.argsSchema=t.argsSchema,l=t.argsSchema,r=!0),void 0!==t.callback&&(c=t.callback,r=!0),r&&(u.handler=dw(e,l,c)),void 0!==t.enabled&&(u.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=u,i){let e=dx(i);e&&Object.values(e).some(e=>di(dC(e)))&&this.setCompletionRequestHandler()}return u}_createRegisteredTool(e,t,r,i,n,o,a,s,l,c,u){let d;uF(e);let p=u,m={title:t,description:r,inputSchema:i,outputSchema:n,get outputSchemaJson(){return d??=dS(m.outputSchema)},set outputSchemaJson(e){d=e},annotations:o,icons:a,execution:s,scopeChallenge:l,_meta:c,handler:u,executor:d_(i,u),enabled:!0,disable:()=>m.update({enabled:!1}),enable:()=>m.update({enabled:!0}),remove:()=>m.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&("string"==typeof t.name&&uF(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=m,e=t.name)),void 0!==t.title&&(m.title=t.title),void 0!==t.description&&(m.description=t.description);let r=!1;void 0!==t.paramsSchema&&(m.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],r=!0),void 0!==t.callback&&(m.handler=t.callback,p=t.callback,r=!0),r&&(m.executor=d_(m.inputSchema,p)),void 0!==t.outputSchema&&(m.outputSchema=t.outputSchema,m.outputSchemaJson=dS(t.outputSchema)),void 0!==t.annotations&&(m.annotations=t.annotations),void 0!==t.icons&&(m.icons=t.icons),void 0!==t.scopeChallenge&&(m.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t._meta&&(m._meta=t._meta),void 0!==t.enabled&&(m.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=m,this.setToolRequestHandlers(),this.sendToolListChanged(),m}registerTool(e,t,r){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:i,description:n,inputSchema:o,outputSchema:a,annotations:s,icons:l,scopeChallenge:c,_meta:u}=t;return this._createRegisteredTool(e,i,n,uD(o),uD(a),s,l,void 0,c,u,r)}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:i,description:n,argsSchema:o,icons:a,scopeChallenge:s,_meta:l}=t,c=this._createRegisteredPrompt(e,i,n,uD(o),r,a,s,l);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},dv=class{_uriTemplate;constructor(e,t){this._callbacks=t,this._uriTemplate="string"==typeof e?new uH(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}};function d_(e,t){return e?async(e,r)=>t(e,r):async(e,r)=>t(r)}let db={type:"object",properties:{}};function dS(e){if(void 0!==e)try{return uf(e,"output")}catch{return}}function dw(e,t,r){return t?async(i,n)=>{let o=await uy(t,i??{});if(!o.success)throw new cv(cy.InvalidParams,`Invalid arguments for prompt ${e}: ${o.error}`);return r(o.data,n)}:async(e,t)=>r(t)}function dR(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}let dk={completion:{values:[],hasMore:!1}};function dx(e){if(e.shape&&"object"==typeof e.shape)return e.shape}function dC(e){return e?.type!=="optional"?e:e.def?.innerType??e}var d$=class{_listeners=new Set;constructor(e){this.onerror=e}publish(e){for(let t of this._listeners)try{t(e)}catch(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}}subscribe(e){this._listeners.add(e);let t=!0;return()=>{t&&(t=!1,this._listeners.delete(e))}}get listenerCount(){return this._listeners.size}};function dT(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function dP(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[oX]:t}}}}function dE(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function dO(e){if(void 0===e)return 4194304;if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(e)}`);return e}async function dI(e,t=4194304){if(Number(e.headers.get("content-length"))>t)return{tooLarge:!0};if(null===e.body)return{tooLarge:!1,text:""};let r=e.body.getReader(),i=new TextDecoder,n=0,o="";try{for(;;){let{done:e,value:a}=await r.read();if(e)break;if((n+=a.byteLength)>t)return{tooLarge:!0};o+=i.decode(a,{stream:!0})}}finally{r.releaseLock()}return{tooLarge:!1,text:o+i.decode()}}var dq=class{sessionIdGenerator;_started=!1;_hasHandledRequest=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId="_GET_stream";_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;_maxRequestBodySize;_scopeChallengeResolver;sessionId;onclose;onerror;onmessage;constructor(e={}){this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval,this._supportedProtocolVersions=e.supportedProtocolVersions??oB,this._keepAliveMs=e.keepAliveMs??15e3,this._maxRequestBodySize=dO(e.maxRequestBodySize)}startKeepAlive(e,t){if(this._closed)return;let r=dn(this._keepAliveMs,()=>{try{e.enqueue(t.encode(": keepalive\n\n"))}catch{void 0!==r&&clearInterval(r)}});return r}setScopeChallengeResolver(e){this._scopeChallengeResolver=e}async start(){if(this._started)throw Error("Transport already started");this._started=!0}setSupportedProtocolVersions(e){this._supportedProtocolVersions=e}createJsonErrorResponse(e,t,r,i){let n={code:t,message:r};return i?.data!==void 0&&(n.data=i.data),Response.json({jsonrpc:"2.0",error:n,id:null},{status:e,headers:{"Content-Type":"application/json",...i?.headers}})}async _checkScopeChallenge(e,t){if(!this._scopeChallengeResolver)return;let r=await dc(e.filter(e=>cY(e)),t,this._scopeChallengeResolver);return void 0===r?void 0:dd(r,du(t))}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let t=e.headers.get("host");if(!t||!this._allowedHosts.includes(t)){let e=`Invalid Host header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let t=e.headers.get("origin");if(t&&!this._allowedOrigins.includes(t)){let e=`Invalid Origin header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}}}async handleRequest(e,t){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let r=this.validateRequestHeaders(e);if(r)return r;switch(e.method){case"POST":return this.handlePostRequest(e,t);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(e){return this._supportedProtocolVersions.includes(e)&&e>="2025-11-25"}async writePrimingEvent(e,t,r,i){if(!this._eventStore||!this.supportsEmptySSEData(i))return;let n=await this._eventStore.storeEvent(r,{}),o=`id: ${n}
|
|
62
|
+
`)}writeFrame(e){if(void 0!==this._sse&&!this._sse.closed)try{this._sse.controller.enqueue(this._sse.encoder.encode(e))}catch(e){this.onerror?.(Error(`Failed to write to the response stream: ${e}`))}}};function ds(e){return e.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function dl(e,t,r,i){let n=`Bearer error="${ds(e)}", error_description="${ds(t)}"`;return r.length>0&&(n+=`, scope="${ds(r.join(" "))}"`),i&&(n+=`, resource_metadata="${ds(i)}"`),n}async function dc(e,t,r){for(let n of e){let e=await r({request:n,...void 0!==t&&{authInfo:t}});if(void 0!==e){if(null===e||"object"!=typeof e||!Array.isArray(e.scopes)||0===e.scopes.length)throw TypeError("scope challenge must contain at least one scope");for(let[t,r]of e.scopes.entries()){var i=`scope challenge scopes[${t}]`;if("string"!=typeof r||!/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(r))throw TypeError(`${i} must satisfy the OAuth scope-token grammar`)}if(void 0!==e.errorDescription&&"string"!=typeof e.errorDescription)throw TypeError("scope challenge errorDescription must be a string");if(void 0!==e.errorDescription&&!/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(e.errorDescription))throw TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");return e}}}function du(e){if(e?.resourceMetadataUrl!==void 0)return e.resourceMetadataUrl;if(e?.resource?.protocol==="https:"||e?.resource?.protocol==="http:"){var t,r;let i,n;return i=new URL(t=e.resource),n=(r=t.pathname).length>1&&r.endsWith("/")?r.slice(0,-1):r,i.pathname=`/.well-known/oauth-protected-resource${"/"===n?"":n}`,i.hash="",i.href}}function dd(e,t){return function(e,t){let{requiredScopes:r=[],resourceMetadataUrl:i}=t??{};if(!(e instanceof lJ)){let e=new lJ(lV.ServerError,"Internal Server Error");return Response.json(e.toResponseObject(),{status:500})}switch(e.code){case lV.InvalidToken:{let t=dl(e.code,e.message,r,i);return Response.json(e.toResponseObject(),{status:401,headers:{"WWW-Authenticate":t}})}case lV.InsufficientScope:{let t=dl(e.code,e.message,r,i);return Response.json(e.toResponseObject(),{status:403,headers:{"WWW-Authenticate":t}})}case lV.ServerError:return Response.json(e.toResponseObject(),{status:500});default:return Response.json(e.toResponseObject(),{status:400})}}(new lJ(lV.InsufficientScope,e.errorDescription??"Insufficient scope"),{requiredScopes:[...e.scopes],resourceMetadataUrl:t})}function dp(e,t,r){if(null===r||"object"!=typeof r||"string"!=typeof r.method)throw new cv(cy.InternalError,`Handler for ${e} returned an invalid input request '${t}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let i=function(e){switch(e.method){case"elicitation/create":if(e.params?.mode==="url")return{elicitation:{url:{}}};return{elicitation:{form:{}}};case"sampling/createMessage":{let t=e.params;if(void 0!==t&&(void 0!==t.tools||void 0!==t.toolChoice))return{sampling:{tools:{}}};return{sampling:{}}}case"roots/list":return{roots:{}};default:return}}(r);if(void 0===i)throw new cv(cy.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${r.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:r,required:i}}function dm(e,t){if("tools/call"===e)return{content:[{type:"text",text:t}],isError:!0};throw new cv(cy.InternalError,t)}var dh=class{constructor(e){this._host=e}async fulfill(e,t,r,i,n){let{maxRounds:o,roundTimeoutMs:a}=this._host,s=i.mcpReq.signal,l=n,c=0;for(;;){let n;if((c+=1)>o)return dm(e,`Multi-round-trip request '${e}' still required input after ${o} rounds (inputRequired.maxRounds)`);let u=l.inputRequests,d=null!=u&&Object.keys(u).length>0,p="string"==typeof l.requestState?l.requestState:void 0;if(!d&&void 0===p)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(d){let t=this._host.resolvedClientCapabilities(i),r=[];for(let[i,n]of Object.entries(u)){let{embedded:o,required:a}=dp(e,i,n);if("roots/list"!==o.method&&void 0===o.params)throw new cv(cy.InternalError,`Handler for ${e} returned an input request '${i}' of kind '${o.method}' without params`);if(void 0!==lY(a,t))return dm(e,`Cannot request input '${i}' (${o.method}): the client on this 2025-era connection did not declare the required capability${void 0===t?" (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)":""}`);r.push([i,o])}let o=function(e){let t=new AbortController,r=()=>t.abort(e?.reason);return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener("abort",r)}}(s);try{let e={relatedRequestId:i.mcpReq.id,timeout:a,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:o.signal},t=await Promise.all(r.map(async([t,r])=>{try{return[t,await this._dispatchLeg(r,e)]}catch(e){throw o.abort(e),e}}));n=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return dm(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{o.dispose()}}else await function(e){return new Promise((t,r)=>{if(e?.aborted)return void r(e.reason instanceof lW?e.reason:new lW(lB.RequestTimeout,String(e.reason)));let i=setTimeout(()=>{e?.removeEventListener("abort",n),t()},250),n=()=>{clearTimeout(i),r(e?.reason instanceof lW?e.reason:new lW(lB.RequestTimeout,String(e?.reason)))};e?.addEventListener("abort",n,{once:!0})})}(s);let m={...i,mcpReq:{...i.mcpReq,inputResponses:n,droppedInputResponseKeys:void 0,requestState:function(e){return()=>e}(p)}};if(void 0!==p){let t=await this._host.verifyRequestState(p,m,e);void 0!==t&&(m=uj(m,t))}let h=await t(r,m);if(!c1(h))return h;l=h}}async _dispatchLeg(e,t){switch(e.method){case"elicitation/create":{let r=e.params;return"url"===r.mode&&void 0===r.elicitationId&&(r={...r,elicitationId:function(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;let r=[...t].map(e=>e.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}()}),await this._host.sendElicitation(r,t)}case"sampling/createMessage":return await this._host.sendSampling(e.params,t);case"roots/list":return await this._host.listRoots(e.params,t)}}};let df=new Set(["tools/call","prompts/get","resources/read"]);var dg=class extends uA{_clientCapabilities;_clientVersion;static{c=(e,t)=>{void 0!==t.clientCapabilities&&(e._clientCapabilities=t.clientCapabilities),void 0!==t.clientInfo&&(e._clientVersion=t.clientInfo)},u=(e,t)=>{let r=t.filter(t=>!e._supportedProtocolVersions.includes(t));r.length>0&&(e._supportedProtocolVersions=[...e._supportedProtocolVersions,...r]),e.setRequestHandler("server/discover",()=>e._ondiscover())},d=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_boundFromTransport=!1;_legacyInputRequiredShim(){return this._legacyShim??=new dh({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,r)=>this._verifyRequestState(e,t,r),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){if(super(t),this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new dt,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=function(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??8,roundTimeoutMs:e?.roundTimeoutMs??6e5,legacyShim:e?.legacyShim??!0}}(t?.inputRequired),t?.cacheHints!==void 0){for(let[e,r]of Object.entries(t.cacheHints))void 0!==r&&cg(r,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",e=>this._oninitialize(e)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),l0(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}async connect(e){if(void 0!==this.transport)throw new lW(lB.AlreadyConnected,"Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");this._boundFromTransport&&(this._boundFromTransport=!1,this._negotiatedProtocolVersion=void 0);let t=(e instanceof da?l(e):void 0)?.revision;void 0!==t&&!this._servedModernEra()&&lQ.includes(t)&&l0(this._supportedProtocolVersions).includes(t)&&(this._negotiatedProtocolVersion=t,this._boundFromTransport=!0),await super.connect(e)}_registerLoggingHandler(){this.setRequestHandler("logging/setLevel",async(e,t)=>{let r=t.sessionId||t.http?.req?.headers.get("mcp-session-id")||void 0,{level:i}=e.params,n=nR(sT,i);return n.success&&this._loggingLevels.set(r,n.data),{}})}buildContext(e,t){let r=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(t,r,i)=>{let n;if(!this._capabilities.logging)return Promise.resolve();if(this._servedModernEra()){if(void 0===(n=e.mcpReq.envelope?.[oQ]))return Promise.resolve()}else n=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return void 0!==n&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(n)?Promise.resolve():e.mcpReq.notify({method:"notifications/message",params:{level:t,data:r,logger:i}})},elicitInput:(e,t)=>this.elicitInput(e,t),requestSampling:(e,t)=>this.createMessage(e,t)},http:r?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(sT.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let r=this._loggingLevels.get(t);return!!r&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(r)};registerCapabilities(e){if(this.transport)throw new lW(lB.AlreadyConnected,"Cannot register capabilities after connecting to transport");let t=!!this._capabilities.logging;this._capabilities=function(e,t){let r={...e};for(let e in t){let i=t[e];if(void 0===i)continue;let n=r[e];r[e]=uz(n)&&uz(i)?{...n,...i}:i}return r}(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if("tools/call"!==e){let r=this._cacheHints?.[e],i=df.has(e);return void 0!==r||i?async(n,o)=>{let a=i?await this._invokeInputRequiredCapableHandler(e,t,n,o):await t(n,o);if(c1(a)){if(!i)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return a}return void 0===r?a:cm(a,r)}:async(r,i)=>{let n=await t(r,i);if(c1(n))throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return n}}return async(e,r)=>{let i=cM(this._negotiatedProtocolVersion),n=i.validateRequest("tools/call",e);if(!n.ok)throw new cv("not-in-era"===n.reason?cy.InternalError:cy.InvalidParams,"not-in-era"===n.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${n.message}`);let o=await this._invokeInputRequiredCapableHandler("tools/call",t,e,r);if(c1(o))return o;let a=l9(o),s=i.validateResult("tools/call",a);if(!s.ok)throw new cv("not-in-era"===s.reason?cy.InternalError:cy.InvalidParams,"not-in-era"===s.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call result: ${s.message}`);return s.value}}_servedModernEra(){return void 0!==this._negotiatedProtocolVersion&&this._negotiatedProtocolVersion>=lX}async _invokeInputRequiredCapableHandler(e,t,r,i){let n,o=this._servedModernEra(),a=i.mcpReq.requestState();if(void 0!==a&&"string"!=typeof a)throw new cv(cy.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let s=i;if("string"==typeof a){let t=await this._verifyRequestState(a,i,e);void 0!==t&&(s=uj(i,t))}try{n=await t(r,s)}catch(e){if(e instanceof cv&&e.code===cy.UrlElicitationRequired){if(!o)throw e;throw new cv(cy.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`)}throw e}if(!c1(n))return n;if(!o){if(!this._inputRequiredServing.legacyShim)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??oJ}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,r,s,n)}let l=n.inputRequests,c=null!=l&&Object.keys(l).length>0,u="string"==typeof n.requestState;if(!c&&!u)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(c){let t=this._inputRequestCapabilityView(i);for(let[r,i]of Object.entries(l)){let{embedded:n,required:o}=dp(e,r,i),a=lY(o,t);if(void 0!==a)throw new cw({requiredCapabilities:a},`Cannot request input '${r}' (${n.method}): the request's client capabilities do not declare the required capability`)}}return n}async _verifyRequestState(e,t,r){if(void 0!==this._requestStateVerify)try{return await this._requestStateVerify(e,t)}catch(e){throw this.onerror?.(Error(`requestState verification rejected ${r}: ${e instanceof Error?e.message:String(e)}`)),new cv(cy.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[oY]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new lW(lB.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${e}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:e,era:"2026-07-28"})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new lW(lB.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new lW(lB.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new lW(lB.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new lW(lB.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new lW(lB.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new lW(lB.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new lW(lB.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new lW(lB.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new lW(lB.CapabilityNotSupported,`Server does not support tools (required for ${e})`)}}async _oninitialize(e){let t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;let r=this._supportedProtocolVersions.filter(e=>!(e>=lX)),i=r.includes(t)?t:r[0]??oJ;return this._negotiatedProtocolVersion=i,this.transport?.setProtocolVersion?.(i),{protocolVersion:i,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:l0(this._supportedProtocolVersions),capabilities:{...this.getCapabilities()},...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(e,t){return this._wireCodec().projectCallToolResult(e,t)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra("ping"),this.request({method:"ping"})}async createMessage(e,t){if(this._assertPushApiInServedEra("sampling/createMessage"),(e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new lW(lB.CapabilityNotSupported,"Client does not support sampling tools capability.");if(e.messages.length>0){let t=e.messages.at(-1),r=Array.isArray(t.content)?t.content:[t.content],i=r.some(e=>"tool_result"===e.type),n=e.messages.length>1?e.messages.at(-2):void 0,o=n?Array.isArray(n.content)?n.content:[n.content]:[],a=o.some(e=>"tool_use"===e.type);if(i){if(r.some(e=>"tool_result"!==e.type))throw new cv(cy.InvalidParams,"The last message must contain only tool_result content if any is present");if(!a)throw new cv(cy.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(a){let e=new Set(o.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(r.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new cv(cy.InvalidParams,"ids of tool_result blocks and tool_use blocks from previous message do not match")}}let r=!!(e.tools||e.toolChoice),i=await this.request({method:"sampling/createMessage",params:e},t),n=this._wireCodec().samplingResultVariant(r,i);if(!n.ok)throw new lW(lB.InvalidResult,`Invalid sampling/createMessage result: ${"invalid"===n.reason?n.message:n.reason}`);return n.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra("elicitation/create"),e.mode??"form"){case"url":if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new lW(lB.CapabilityNotSupported,"Client does not support form elicitation.")}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,r){let i=e.mode??"form",n=r?.validateAcceptedContent??!0;switch(i){case"url":return this.request({method:"elicitation/create",params:e},t);case"form":{let r="form"===e.mode?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:r},t);if(n&&"accept"===i.action&&i.content&&r.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(r.requestedSchema)(i.content);if(!e.valid)throw new cv(cy.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof cv)throw e;throw new cv(cy.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return i}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,"Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this._assertPushApiInServedEra("roots/list"),this.request({method:"roots/list",params:e},t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}},dy=class{server;_maxToolInputElements;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(void 0!==t&&t.enabled){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(void 0===t.inputSchema)return db;try{let r=uf(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new dg(e,t),this._maxToolInputElements=function(e){if(void 0!==e&&1/0!==e){if("number"!=typeof e||Number.isNaN(e)||e<1)throw RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}(t?.maxToolInputElements),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return"object"==typeof e&&null!==e&&"setScopeChallengeResolver"in e&&"function"==typeof e.setScopeChallengeResolver&&e.setScopeChallengeResolver(e=>this.resolveScopeChallenge(e)),await this.server.connect(e)}async close(){await this.server.close()}resolveScopeChallenge=e=>{switch(e.request.method){case"tools/call":{let t=e.request.params?.name;if("string"!=typeof t)return;let r=this._registeredTools[t];if(void 0===r||!r.enabled)return;return r.scopeChallenge?.(e)}case"resources/read":{let t,r=e.request.params?.uri;if("string"!=typeof r)return;try{t=new URL(r)}catch{return}let i=this._registeredResources[t.toString()];if(void 0!==i)return i.enabled?i.scopeChallenge?.(e):void 0;for(let r of Object.values(this._registeredResourceTemplates))if(r.resourceTemplate.uriTemplate.match(t.toString()))return r.enabled?r.scopeChallenge?.(e):void 0;return}case"prompts/get":{let t=e.request.params?.name;if("string"!=typeof t)return;let r=this._registeredPrompts[t];if(void 0===r||!r.enabled)return;return r.scopeChallenge?.(e)}default:return}};_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler("tools/list"),this.server.assertCanSetRequestHandler("tools/call"),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler("tools/list",()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{var r;let i,n,o={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?(r=e,(n=c5(i=uf(t.inputSchema,"input"))).valid||console.warn(`[mcp-sdk] tool '${r}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${n.reason}`),i):db,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(o.outputSchema=uf(t.outputSchema,"output")),o})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new cv(cy.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Tool ${e.params.name} disabled`);try{let i=await this.validateToolInput(r,e.params.arguments,e.params.name),n=await this.executeToolHandler(r,i,t);if(await this.validateToolOutput(r,n,e.params.name),c1(n))return n;return this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(e){if(e instanceof cv&&e.code===cy.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,r){if(void 0!==this._maxToolInputElements&&function(e,t){let r=0,i=[e];for(;i.length>0;){let e=i.pop();if(null!==e&&"object"==typeof e)if(Array.isArray(e))for(let n of e){if(++r>t)return r;null!==n&&"object"==typeof n&&i.push(n)}else for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(++r>t)return r;let o=e[n];null!==o&&"object"==typeof o&&i.push(o)}}return r}(t,this._maxToolInputElements)>this._maxToolInputElements)throw new cv(cy.InvalidParams,`Invalid arguments for tool ${r}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let i=await uy(e.inputSchema,t??{});if(!i.success)throw new cv(cy.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${i.error}`);return i.data}async validateToolOutput(e,t,r){if(!e.outputSchema||c1(t)||t.isError)return;if(void 0===t.structuredContent)throw new cv(cy.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let i=await uy(e.outputSchema,t.structuredContent);if(!i.success)throw new cv(cy.InvalidParams,`Output validation error: Invalid structured content for tool ${r}: ${i.error}`)}async executeToolHandler(e,t,r){return e.executor(t,r)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler("completion/complete"),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler("completion/complete",async e=>{switch(e.params.ref.type){case"ref/prompt":if("ref/prompt"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`);return this.handlePromptCompletion(e,e.params.ref);case"ref/resource":if("ref/resource"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`);return this.handleResourceCompletion(e,e.params.ref);default:throw new cv(cy.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let r=this._registeredPrompts[t.name];if(!r)throw new cv(cy.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return dk;let i=dC(dx(r.argsSchema)?.[e.params.argument.name]);if(!di(i))return dk;let n=i[dr]?.complete;return n?dR(await n(e.params.argument.value,e.params.context)):dk}async handleResourceCompletion(e,t){let r=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!r){if(this._registeredResources[t.uri])return dk;throw new cv(cy.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let i=r.resourceTemplate.completeCallback(e.params.argument.name);return i?dR(await i(e.params.argument.value,e.params.context)):dk}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler("resources/list"),this.server.assertCanSetRequestHandler("resources/templates/list"),this.server.assertCanSetRequestHandler("resources/read"),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler("resources/list",async(e,t)=>{let r=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),i=[];for(let e of Object.values(this._registeredResourceTemplates))if(e.resourceTemplate.listCallback)for(let r of(await e.resourceTemplate.listCallback(t)).resources)i.push({...e.metadata,...r});return{resources:[...r,...i]}}),this.server.setRequestHandler("resources/templates/list",async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler("resources/read",async(e,t)=>{let r;try{r=new URL(e.params.uri)}catch{throw new cv(cy.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:"invalid_uri"})}let i=this._registeredResources[r.toString()];if(i){if(!i.enabled)throw new cv(cy.InvalidParams,`Resource ${r} disabled`);return cm(await i.readCallback(r,t),i.cacheHint)}for(let e of Object.values(this._registeredResourceTemplates)){let i=e.resourceTemplate.uriTemplate.match(r.toString());if(i){if(!e.enabled)throw new cv(cy.InvalidParams,`Resource template ${e.resourceTemplate.uriTemplate} disabled`);return cm(await e.readCallback(r,i,t),e.cacheHint)}}throw new c_(e.params.uri)}),this._resourceHandlersInitialized=!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler("prompts/list"),this.server.assertCanSetRequestHandler("prompts/get"),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler("prompts/list",()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>{let r,i,n;return{name:e,title:t.title,description:t.description,arguments:t.argsSchema?(i=(r=uf(t.argsSchema,"input")).properties||{},n=r.required||[],Object.entries(i).map(([e,t])=>({name:e,description:t?.description,required:n.includes(e)}))):void 0,icons:t.icons,_meta:t._meta}})})),this.server.setRequestHandler("prompts/get",async(e,t)=>{let r=this._registeredPrompts[e.params.name];if(!r)throw new cv(cy.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Prompt ${e.params.name} disabled`);return r.handler(e.params.arguments,t)}),this._promptHandlersInitialized=!0)}registerResource(e,t,r,i){let{cacheHint:n,scopeChallenge:o,...a}=r;if(void 0!==n&&cg(n,`resource ${e}`),"string"==typeof t){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let s=this._createRegisteredResource(e,r.title,t,a,o,i);return void 0!==n&&(s.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,r.title,t,a,o,i);return void 0!==n&&(s.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,t,r,i,n,o){let a={name:e,title:t,metadata:i,readCallback:o,scopeChallenge:n,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{void 0!==e.uri&&e.uri!==r&&(delete this._registeredResources[r],e.uri&&(this._registeredResources[e.uri]=a)),void 0!==e.name&&(a.name=e.name),void 0!==e.metadata&&(a.metadata=e.metadata),void 0!==e.title&&(a.title=e.title,a.metadata={...a.metadata,title:e.title}),void 0!==e.callback&&(a.readCallback=e.callback),void 0!==e.scopeChallenge&&(a.scopeChallenge=null===e.scopeChallenge?void 0:e.scopeChallenge),void 0!==e.enabled&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=a,a}_createRegisteredResourceTemplate(e,t,r,i,n,o){let a={resourceTemplate:r,title:t,metadata:i,readCallback:o,scopeChallenge:n,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),void 0!==t.template&&(a.resourceTemplate=t.template),void 0!==t.metadata&&(a.metadata=t.metadata),void 0!==t.title&&(a.title=t.title,a.metadata={...a.metadata,title:t.title}),void 0!==t.callback&&(a.readCallback=t.callback),void 0!==t.scopeChallenge&&(a.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t.enabled&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let s=r.uriTemplate.variableNames;return Array.isArray(s)&&s.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,r,i,n,o,a,s){let l=i,c=n,u={title:t,description:r,argsSchema:i,icons:o,scopeChallenge:a,_meta:s,handler:dw(e,i,n),enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=u)),void 0!==t.title&&(u.title=t.title),void 0!==t.description&&(u.description=t.description),void 0!==t.icons&&(u.icons=t.icons),void 0!==t.scopeChallenge&&(u.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t._meta&&(u._meta=t._meta);let r=!1;void 0!==t.argsSchema&&(u.argsSchema=t.argsSchema,l=t.argsSchema,r=!0),void 0!==t.callback&&(c=t.callback,r=!0),r&&(u.handler=dw(e,l,c)),void 0!==t.enabled&&(u.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=u,i){let e=dx(i);e&&Object.values(e).some(e=>di(dC(e)))&&this.setCompletionRequestHandler()}return u}_createRegisteredTool(e,t,r,i,n,o,a,s,l,c,u){let d;uF(e);let p=u,m={title:t,description:r,inputSchema:i,outputSchema:n,get outputSchemaJson(){return d??=dS(m.outputSchema)},set outputSchemaJson(e){d=e},annotations:o,icons:a,execution:s,scopeChallenge:l,_meta:c,handler:u,executor:d_(i,u),enabled:!0,disable:()=>m.update({enabled:!1}),enable:()=>m.update({enabled:!0}),remove:()=>m.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&("string"==typeof t.name&&uF(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=m,e=t.name)),void 0!==t.title&&(m.title=t.title),void 0!==t.description&&(m.description=t.description);let r=!1;void 0!==t.paramsSchema&&(m.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],r=!0),void 0!==t.callback&&(m.handler=t.callback,p=t.callback,r=!0),r&&(m.executor=d_(m.inputSchema,p)),void 0!==t.outputSchema&&(m.outputSchema=t.outputSchema,m.outputSchemaJson=dS(t.outputSchema)),void 0!==t.annotations&&(m.annotations=t.annotations),void 0!==t.icons&&(m.icons=t.icons),void 0!==t.scopeChallenge&&(m.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t._meta&&(m._meta=t._meta),void 0!==t.enabled&&(m.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=m,this.setToolRequestHandlers(),this.sendToolListChanged(),m}registerTool(e,t,r){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:i,description:n,inputSchema:o,outputSchema:a,annotations:s,icons:l,scopeChallenge:c,_meta:u}=t;return this._createRegisteredTool(e,i,n,uD(o),uD(a),s,l,void 0,c,u,r)}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:i,description:n,argsSchema:o,icons:a,scopeChallenge:s,_meta:l}=t,c=this._createRegisteredPrompt(e,i,n,uD(o),r,a,s,l);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},dv=class{_uriTemplate;constructor(e,t){this._callbacks=t,this._uriTemplate="string"==typeof e?new uH(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}};function d_(e,t){return e?async(e,r)=>t(e,r):async(e,r)=>t(r)}let db={type:"object",properties:{}};function dS(e){if(void 0!==e)try{return uf(e,"output")}catch{return}}function dw(e,t,r){return t?async(i,n)=>{let o=await uy(t,i??{});if(!o.success)throw new cv(cy.InvalidParams,`Invalid arguments for prompt ${e}: ${o.error}`);return r(o.data,n)}:async(e,t)=>r(t)}function dR(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}let dk={completion:{values:[],hasMore:!1}};function dx(e){if(e.shape&&"object"==typeof e.shape)return e.shape}function dC(e){return e?.type!=="optional"?e:e.def?.innerType??e}var d$=class{_listeners=new Set;constructor(e){this.onerror=e}publish(e){for(let t of this._listeners)try{t(e)}catch(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}}subscribe(e){this._listeners.add(e);let t=!0;return()=>{t&&(t=!1,this._listeners.delete(e))}}get listenerCount(){return this._listeners.size}};function dT(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function dP(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[oX]:t}}}}function dO(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function dE(e){if(void 0===e)return 4194304;if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(e)}`);return e}async function dI(e,t=4194304){if(Number(e.headers.get("content-length"))>t)return{tooLarge:!0};if(null===e.body)return{tooLarge:!1,text:""};let r=e.body.getReader(),i=new TextDecoder,n=0,o="";try{for(;;){let{done:e,value:a}=await r.read();if(e)break;if((n+=a.byteLength)>t)return{tooLarge:!0};o+=i.decode(a,{stream:!0})}}finally{r.releaseLock()}return{tooLarge:!1,text:o+i.decode()}}var dq=class{sessionIdGenerator;_started=!1;_hasHandledRequest=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId="_GET_stream";_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;_maxRequestBodySize;_scopeChallengeResolver;sessionId;onclose;onerror;onmessage;constructor(e={}){this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval,this._supportedProtocolVersions=e.supportedProtocolVersions??oB,this._keepAliveMs=e.keepAliveMs??15e3,this._maxRequestBodySize=dE(e.maxRequestBodySize)}startKeepAlive(e,t){if(this._closed)return;let r=dn(this._keepAliveMs,()=>{try{e.enqueue(t.encode(": keepalive\n\n"))}catch{void 0!==r&&clearInterval(r)}});return r}setScopeChallengeResolver(e){this._scopeChallengeResolver=e}async start(){if(this._started)throw Error("Transport already started");this._started=!0}setSupportedProtocolVersions(e){this._supportedProtocolVersions=e}createJsonErrorResponse(e,t,r,i){let n={code:t,message:r};return i?.data!==void 0&&(n.data=i.data),Response.json({jsonrpc:"2.0",error:n,id:null},{status:e,headers:{"Content-Type":"application/json",...i?.headers}})}async _checkScopeChallenge(e,t){if(!this._scopeChallengeResolver)return;let r=await dc(e.filter(e=>cY(e)),t,this._scopeChallengeResolver);return void 0===r?void 0:dd(r,du(t))}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let t=e.headers.get("host");if(!t||!this._allowedHosts.includes(t)){let e=`Invalid Host header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let t=e.headers.get("origin");if(t&&!this._allowedOrigins.includes(t)){let e=`Invalid Origin header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}}}async handleRequest(e,t){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let r=this.validateRequestHeaders(e);if(r)return r;switch(e.method){case"POST":return this.handlePostRequest(e,t);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(e){return this._supportedProtocolVersions.includes(e)&&e>="2025-11-25"}async writePrimingEvent(e,t,r,i){if(!this._eventStore||!this.supportsEmptySSEData(i))return;let n=await this._eventStore.storeEvent(r,{}),o=`id: ${n}
|
|
63
63
|
data:
|
|
64
64
|
|
|
65
65
|
`;void 0!==this._retryInterval&&(o=`id: ${n}
|
|
@@ -70,17 +70,17 @@ data:
|
|
|
70
70
|
`;return i&&(n+=`id: ${i}
|
|
71
71
|
`),n+=`data: ${JSON.stringify(r)}
|
|
72
72
|
|
|
73
|
-
`,e.enqueue(t.encode(n)),!0}catch(e){return this.onerror?.(e),!1}}handleUnsupportedRequest(){return this.onerror?.(Error("Method not allowed.")),Response.json({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null},{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,t){try{let r,i,n,o,a,s=e.headers.get("accept");if(!s?.includes("application/json")||!s.includes("text/event-stream"))return this.onerror?.(Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");if(!uZ(e.headers.get("content-type")))return this.onerror?.(Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");if(t?.parsedBody===void 0)try{let t=await dI(e,this._maxRequestBodySize);if(t.tooLarge){let e=dE(this._maxRequestBodySize);return this.onerror?.(Error(e)),this.createJsonErrorResponse(413,-32e3,e)}r=JSON.parse(t.text)}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else r=t.parsedBody;if(Array.isArray(r)&&r.length>100)return this.onerror?.(Error("Invalid Request: Batch must not exceed 100 messages")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Batch must not exceed 100 messages");try{i=Array.isArray(r)?r.map(e=>au.parse(e)):[au.parse(r)]}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let l=i.some(e=>ax.safeParse(e).success);if(l){if(this._initialized&&void 0!==this.sessionId)return this.onerror?.(Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(i.length>1)return this.onerror?.(Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!l){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");try{n=await this._checkScopeChallenge(i,t?.authInfo)}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(500,-32603,"Internal server error")}if(n)return n;if(!i.some(e=>cY(e))){for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e});return new Response(null,{status:202})}let c=crypto.randomUUID(),u=i.find(e=>ax.safeParse(e).success),d=u?u.params.protocolVersion:e.headers.get("mcp-protocol-version")??"2025-03-26";if(this._enableJsonResponse)return new Promise(r=>{for(let e of(this._streamMapping.set(c,{resolveJson:r,cleanup:()=>{this._streamMapping.delete(c)}}),i))cY(e)&&this._requestToStreamMapping.set(e.id,c);for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e})});let p=new TextEncoder,m=new ReadableStream({start:e=>{o=e},cancel:()=>{void 0!==a&&clearInterval(a),this._streamMapping.get(c)?.controller===o&&this._streamMapping.delete(c)}}),h={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};for(let e of(void 0!==this.sessionId&&(h["mcp-session-id"]=this.sessionId),i))cY(e)&&(this._streamMapping.set(c,{controller:o,encoder:p,cleanup:()=>{void 0!==a&&clearInterval(a),this._streamMapping.delete(c);try{o.close()}catch{}}}),this._requestToStreamMapping.set(e.id,c));for(let r of(await this.writePrimingEvent(o,p,c,d),i)){let i,n;cY(r)&&this._eventStore&&this.supportsEmptySSEData(d)&&(i=()=>{this.closeSSEStream(r.id)},n=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(r,{authInfo:t?.authInfo,request:e,closeSSEStream:i,closeStandaloneSSEStream:n})}return this._streamMapping.get(c)?.controller===o&&(a=this.startKeepAlive(o,p)),new Response(m,{status:200,headers:h})}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(e)})}}async handleDeleteRequest(e){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(e){if(void 0===this.sessionIdGenerator)return;if(!this._initialized)return this.onerror?.(Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let t=e.headers.get("mcp-session-id");return t?t!==this.sessionId?(this.onerror?.(Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")):void 0:(this.onerror?.(Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required"))}validateProtocolVersion(e){let t=e.headers.get("mcp-protocol-version");if(null!==t&&!this._supportedProtocolVersions.includes(t)){let e=`Bad Request: Unsupported protocol version: ${t} (supported versions: ${this._supportedProtocolVersions.join(", ")})`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(400,-32e3,e)}}async close(){if(!this._closed){for(let{cleanup:e}of(this._closed=!0,this._streamMapping.values()))e();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}}closeSSEStream(e){let t=this._requestToStreamMapping.get(e);if(!t)return;let r=this._streamMapping.get(t);r&&r.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,t){let r=t?.relatedRequestId;if((cQ(e)||c0(e))&&(r=e.id),void 0===r){let t;if(cQ(e)||c0(e))throw Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");this._eventStore&&(t=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let r=this._streamMapping.get(this._standaloneSseStreamId);if(void 0===r)return;r.controller&&r.encoder&&(void 0===t||!r.replayedEventIds?.has(t))&&this.writeSSEEvent(r.controller,r.encoder,e,t);return}let i=this._requestToStreamMapping.get(r);if(!i)throw Error(`No connection established for request ID: ${String(r)}`);let n=this._streamMapping.get(i);if(!this._enableJsonResponse){let t;this._eventStore&&(t=await this._eventStore.storeEvent(i,e),n=this._streamMapping.get(i)),n?.controller&&n?.encoder&&(void 0===t||!n.replayedEventIds?.has(t))&&this.writeSSEEvent(n.controller,n.encoder,e,t)}if(cQ(e)||c0(e)){this._requestResponseMap.set(r,e);let t=[...this._requestToStreamMapping.entries()].filter(([e,t])=>t===i).map(([e])=>e);if(t.every(e=>this._requestResponseMap.has(e))){if(!n){if(this._enableJsonResponse)throw Error(`No connection established for request ID: ${String(r)}`);if(!this._eventStore){for(let e of(this.onerror?.(Error(`Response for request ID ${String(r)} is undeliverable: per-request stream is disconnected and no eventStore is configured`)),t))this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}if(this._enableJsonResponse&&n.resolveJson){let e={"Content-Type":"application/json"};void 0!==this.sessionId&&(e["mcp-session-id"]=this.sessionId);let r=t.map(e=>this._requestResponseMap.get(e));1===r.length?n.resolveJson(Response.json(r[0],{status:200,headers:e})):n.resolveJson(Response.json(r,{status:200,headers:e})),n.cleanup()}else n.cleanup();for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e)}}}};function dj(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let{method:t,id:r}=e;return"string"!=typeof t?null:"string"==typeof r||"number"==typeof r?r:null}function dA(e,t,r,i,n=null){return Response.json({jsonrpc:"2.0",error:{code:t,message:r,...void 0!==i&&{data:i}},id:n},{status:e,...405===e&&{headers:{Allow:"POST"}}})}function dz(e,t=null){return dA(e.httpStatus,e.code,e.message,e.data,t)}function dL(e){return e instanceof Error?e:Error(String(e))}function dN(e=null){return dA(500,-32603,"Internal server error",void 0,e)}function dM(e){if(void 0!==e.transport)throw Error("The factory returned an instance that is still serving another request. Return a new instance for each request.")}function dZ(e){return{protocolVersionHeader:e.headers.get("mcp-protocol-version")??void 0,mcpMethodHeader:e.headers.get("mcp-method")??void 0,mcpNameHeader:e.headers.get("mcp-name")??void 0}}let dU=(e,t)=>{globalThis[e]=t},dF=e=>globalThis[e];function dH({name:e,fallback:t=!0}){let r=Symbol.for(`xmcp-context-${e}`),i=Symbol.for(`xmcp-context-${e}-fallback-store`);if(dF(r))return dF(r);let n=new x,o=globalThis[i]??{current:null};dU(i,o);let a={provider:(e,r)=>(t&&(o.current=e),n.run(e,r)),getContext:()=>{let r=n.getStore();if(r)return r;if(t&&o.current)return o.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:r=>{let i=n.getStore()??(t?o.current:null);if(!i)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(i,r)}};return dU(r,a),a}let dD=dH({name:"http-request-context"});dD.setContext;let dV=dD.getContext,dJ=dD.provider,dB=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),dW=e=>{if(!dB(e)||"string"!=typeof e.name||"string"!=typeof e.version)return;let t={name:e.name,version:e.version};return"string"==typeof e.title&&(t.title=e.title),"string"==typeof e.websiteUrl&&(t.websiteUrl=e.websiteUrl),"string"==typeof e.description&&(t.description=e.description),t},dG=e=>{if(e&&"initialize"===e.method&&dB(e.params))return dW(e.params.clientInfo)},dK=(e,t)=>{let r=t.toLowerCase();for(let[t,i]of Object.entries(e)){if(t.toLowerCase()!==r)continue;let e=Array.isArray(i)?i[0]:i;if("string"!=typeof e)break;let n=e.trim();return n.length>0?n:void 0}};function dY(e){let{tags:t,enabled:r,...i}=e;return{...i,_meta:void 0===t?i._meta:{...i._meta,"xmcp/tags":t}}}let dX=new class{add(e,t){this.resources.set(e,t)}getAll(){return this.resources}clear(){this.resources.clear()}has(e){return this.resources.has(e)}constructor(){var e,t;e="resources",t=new Map,e in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t}},dQ=dH({name:"request-context",fallback:!1}),d0=dH({name:"client-info-context"});d0.setContext;let d1=d0.getContext;d0.provider;let d2=new Set(["message","mode","requestedSchema"]),d9=new Set(["elicitationId","message","mode","url"]),d4=new Set(["properties","required","type"]),d5=new Set(["default","description","format","maxLength","minLength","title","type"]),d3=new Set(["default","description","enum","enumNames","title","type"]),d6=new Set(["default","description","title","type"]),d7=new Set(["default","description","maximum","minimum","title","type"]),d8=new Set(["date","date-time","email","uri"]);function pe(e,t,r){let i=Object.keys(e).filter(e=>!t.has(e));if(0!==i.length)throw Error(`${r} includes unsupported key(s): ${i.join(", ")}.`)}function pt(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}function pr(e,t){if("string"!=typeof e)throw Error(t)}function pi(e,t){if("string"!=typeof e||0===e.trim().length)throw Error(t)}function pn(e,t){if(void 0!==e&&"string"!=typeof e)throw Error(t)}function po(e,t){if(void 0!==e&&"number"!=typeof e)throw Error(t)}function pa(e,t){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e))throw Error(t)}let ps=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),pl=new Set(["task","toolChoice","tools"]),pc=new Set(["text","image","audio"]);function pu(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}let pd={text:e=>"string"!=typeof e.text?{valid:!1,error:'Text content must have a "text" property of type string'}:{valid:!0},image:e=>"string"!=typeof e.data?{valid:!1,error:'Image content must have a "data" property of type string (base64-encoded image)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Image content must have a "mimeType" property of type string'}:{valid:!0},audio:e=>"string"!=typeof e.data?{valid:!1,error:'Audio content must have a "data" property of type string (base64-encoded audio)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Audio content must have a "mimeType" property of type string'}:{valid:!0},resource_link:e=>"string"!=typeof e.name?{valid:!1,error:'Resource link content must have a "name" property of type string'}:"string"!=typeof e.uri?{valid:!1,error:'Resource link content must have a "uri" property of type string'}:void 0!==e.title&&"string"!=typeof e.title?{valid:!1,error:'Resource link "title" property must be a string if provided'}:void 0!==e.description&&"string"!=typeof e.description?{valid:!1,error:'Resource link "description" property must be a string if provided'}:void 0!==e.mimeType&&"string"!=typeof e.mimeType?{valid:!1,error:'Resource link "mimeType" property must be a string if provided'}:{valid:!0}};function pp(e){if(!e||"object"!=typeof e)return{valid:!1,error:"Content must be an object"};if("string"!=typeof e.type)return{valid:!1,error:'Content must have a "type" property of type string'};if(void 0!==e._meta&&(null===e._meta||"object"!=typeof e._meta))return{valid:!1,error:'Content "_meta" property must be an object if provided'};let t=pd[e.type];return t?t(e):{valid:!0}}function pm(e,t,r,i){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`Tool "${r}" ${i}: expected a plain object.`);let n=new Set(Object.keys(t)),o=Object.keys(e).filter(e=>!n.has(e));if(o.length>0)throw Error(`Tool "${r}" ${i}: unrecognized key(s): ${o.join(", ")}`);for(let[n,o]of Object.entries(t))try{o.parse(e[n])}catch(e){throw Error(`Tool "${r}" ${i}: ${e?.message??`invalid field "${n}"`}`)}}function ph(e){return!!(e&&"object"==typeof e&&Object.keys(e).some(e=>e.startsWith("ui/")))}function pf(e){let t=e.mcpReq.envelope,r=dW(t?.[oG]);if(!r)try{let e,t=dV();r=t.clientInfo??(e=t.headers,dW({name:dK(e,"x-mcp-client-name"),version:dK(e,"x-mcp-client-version"),title:dK(e,"x-mcp-client-title"),websiteUrl:dK(e,"x-mcp-client-website-url"),description:dK(e,"x-mcp-client-description")}))}catch{}if(!r)try{r=d1().clientInfo}catch{}return r}function pg(e){let t=[...e];return(e,r,i)=>(function(e,t,r){let i,n=new Map;if(e.http){let e=dV(),t=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,Array.isArray(t)?Object.freeze([...t]):t]));i=Object.freeze({id:e.id,headers:Object.freeze(t)})}return dQ.provider(Object.freeze({clientInfo:t?Object.freeze({...t}):void 0,http:i,authInfo:e.http?.authInfo,signal:e.mcpReq.signal,set(e,t){n.set(e,t)},get:e=>n.get(e),async progress(t,r){let i=e.mcpReq._meta?.progressToken;void 0!==i&&await e.mcpReq.notify({method:"notifications/progress",params:{progressToken:i,progress:t,...void 0===r?{}:{total:r}}})},log:(t,r)=>e.mcpReq.log(t,r)}),r)})(r,pf(r),async()=>{if(0===t.length)return i();let r=Object.freeze({...function(){try{return dQ.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}(),...e,params:Object.freeze({...e.params})}),n=-1,o=async e=>{if(e<=n)throw Error("MCP middleware next() can only be called once");n=e;let a=t[e];return a?a(r,()=>o(e+1)):i()};return o(0)})}let py=new Set(["tools/list","prompts/get","prompts/list","resources/read","resources/list","resources/templates/list","completion/complete"]);function pv(e){return e.endsWith(".tsx")}let p_=Symbol("Let zodToJsonSchema decide on which parser to use"),pb={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};(E=z||(z={})).assertEqual=e=>{},E.assertIs=function(e){},E.assertNever=function(e){throw Error()},E.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},E.getValidEnumValues=e=>{let t=E.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let i of t)r[i]=e[i];return E.objectValues(r)},E.objectValues=e=>E.objectKeys(e).map(function(t){return e[t]}),E.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},E.find=(e,t)=>{for(let r of e)if(t(r))return r},E.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,E.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},E.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(L||(L={})).mergeShapes=(e,t)=>({...e,...t});let pS=z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pw=e=>{switch(typeof e){case"undefined":return pS.undefined;case"string":return pS.string;case"number":return Number.isNaN(e)?pS.nan:pS.number;case"boolean":return pS.boolean;case"function":return pS.function;case"bigint":return pS.bigint;case"symbol":return pS.symbol;case"object":if(Array.isArray(e))return pS.array;if(null===e)return pS.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return pS.promise;if("u">typeof Map&&e instanceof Map)return pS.map;if("u">typeof Set&&e instanceof Set)return pS.set;if("u">typeof Date&&e instanceof Date)return pS.date;return pS.object;default:return pS.unknown}},pR=z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class pk extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},i=e=>{for(let n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(i);else if("invalid_return_type"===n.code)i(n.returnTypeError);else if("invalid_arguments"===n.code)i(n.argumentsError);else if(0===n.path.length)r._errors.push(t(n));else{let e=r,i=0;for(;i<n.path.length;){let r=n.path[i],o=i===n.path.length-1;if("_errors"===r){o&&e._errors.push(t(n)),i++;continue}Object.prototype.hasOwnProperty.call(e,r)||("__proto__"===r?Object.defineProperty(e,r,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):e[r]={_errors:[]}),e=e[r],o&&e._errors.push(t(n)),i++}}};return i(this),r}static assert(e){if(!(e instanceof pk))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t=Object.create(null),r=[];for(let i of this.issues)if(i.path.length>0){let r=i.path[0];t[r]=t[r]||[],t[r].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}pk.create=e=>new pk(e);let px=(e,t)=>{let r;switch(e.code){case pR.invalid_type:r=e.received===pS.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case pR.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,z.jsonStringifyReplacer)}`;break;case pR.unrecognized_keys:r=`Unrecognized key(s) in object: ${z.joinValues(e.keys,", ")}`;break;case pR.invalid_union:r="Invalid input";break;case pR.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${z.joinValues(e.options)}`;break;case pR.invalid_enum_value:r=`Invalid enum value. Expected ${z.joinValues(e.options)}, received '${e.received}'`;break;case pR.invalid_arguments:r="Invalid function arguments";break;case pR.invalid_return_type:r="Invalid function return type";break;case pR.invalid_date:r="Invalid date";break;case pR.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:z.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case pR.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case pR.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case pR.custom:r="Invalid input";break;case pR.invalid_intersection_types:r="Intersection results could not be merged";break;case pR.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case pR.not_finite:r="Number must be finite";break;default:r=t.defaultError,z.assertNever(e)}return{message:r}};(O=N||(N={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},O.toString=e=>"string"==typeof e?e:e?.message;function pC(e,t){let r=(e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,o=[...r,...n.path||[]],a={...n,path:o};if(void 0!==n.message)return{...n,path:o,message:n.message};let s="";for(let e of i.filter(e=>!!e).slice().reverse())s=e(a,{data:t,defaultError:s}).message;return{...n,path:o,message:s}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,px,void 0].filter(e=>!!e)});e.common.issues.push(r)}class p${constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let i of t){if("aborted"===i.status)return pT;"dirty"===i.status&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,i=await e.value;r.push({key:t,value:i})}return p$.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let i of t){let{key:t,value:n}=i;if("aborted"===t.status||"aborted"===n.status)return pT;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==n.value||i.alwaysSet)&&(r[t.value]=n.value)}return{status:e.value,value:r}}}let pT=Object.freeze({status:"aborted"}),pP=e=>({status:"dirty",value:e}),pE=e=>({status:"valid",value:e}),pO=e=>"u">typeof Promise&&e instanceof Promise;class pI{constructor(e,t,r,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let pq=(e,t)=>{if("valid"===t.status)return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new pk(e.common.issues);return this._error=t,this._error}}};function pj(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:n}:{errorMap:(t,n)=>{let{message:o}=e;return"invalid_enum_value"===t.code?{message:o??n.defaultError}:void 0===n.data?{message:o??i??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:o??r??n.defaultError}},description:n}}class pA{get description(){return this._def.description}_getType(e){return pw(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:pw(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new p$,ctx:{common:e.parent.common,data:e.data,parsedType:pw(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(pO(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pw(e)},i=this._parseSync({data:e,path:r.path,parent:r});return pq(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pw(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return"valid"===r.status?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>"valid"===e.status?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pw(e)},i=this._parse({data:e,path:r.path,parent:r});return pq(r,await (pO(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,i)=>{let n=e(r),o=()=>i.addIssue({code:pR.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"u">typeof Promise&&n instanceof Promise?n.then(e=>!!e||(o(),!1)):!!n||(o(),!1)})}refinement(e,t){return this._refinement((r,i)=>!!e(r)||(i.addIssue("function"==typeof t?t(r,i):t),!1))}_refinement(e){return new mh({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return mf.create(this,this._def)}nullable(){return mg.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mt.create(this)}promise(){return mm.create(this,this._def)}or(e){return mi.create([this,e],this._def)}and(e){return mn.create(this,e,this._def)}transform(e){return new mh({...pj(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new my({...pj(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:M.ZodDefault})}brand(){return new mb({typeName:M.ZodBranded,type:this,...pj(this._def)})}catch(e){return new mv({...pj(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:M.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return mS.create(this,e)}readonly(){return mw.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let pz=/^c[^\s-]{8,}$/i,pL=/^[0-9a-z]+$/,pN=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pZ=/^[a-z0-9_-]{21}$/i,pU=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pF=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,pH=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pD=/^(?:(?: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])$/,pV=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,pJ=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,pB=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pW=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,pG=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,pK="((\\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])))",pY=RegExp(`^${pK}$`);function pX(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}class pQ extends pA{_parse(e){var t,r,i,n;let o;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==pS.string){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.string,received:t.parsedType}),pT}let a=new p$;for(let s of this._def.checks)if("min"===s.kind)e.data.length<s.value&&(pC(o=this._getOrReturnCtx(e,o),{code:pR.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("max"===s.kind)e.data.length>s.value&&(pC(o=this._getOrReturnCtx(e,o),{code:pR.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("length"===s.kind){let t=e.data.length>s.value,r=e.data.length<s.value;(t||r)&&(o=this._getOrReturnCtx(e,o),t?pC(o,{code:pR.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):r&&pC(o,{code:pR.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if("email"===s.kind)pH.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"email",code:pR.invalid_string,message:s.message}),a.dirty());else if("emoji"===s.kind)p||(p=RegExp("^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),p.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"emoji",code:pR.invalid_string,message:s.message}),a.dirty());else if("uuid"===s.kind)pM.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"uuid",code:pR.invalid_string,message:s.message}),a.dirty());else if("nanoid"===s.kind)pZ.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"nanoid",code:pR.invalid_string,message:s.message}),a.dirty());else if("cuid"===s.kind)pz.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"cuid",code:pR.invalid_string,message:s.message}),a.dirty());else if("cuid2"===s.kind)pL.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"cuid2",code:pR.invalid_string,message:s.message}),a.dirty());else if("ulid"===s.kind)pN.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"ulid",code:pR.invalid_string,message:s.message}),a.dirty());else if("url"===s.kind)try{new URL(e.data)}catch{pC(o=this._getOrReturnCtx(e,o),{validation:"url",code:pR.invalid_string,message:s.message}),a.dirty()}else"regex"===s.kind?(s.regex.lastIndex=0,s.regex.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"regex",code:pR.invalid_string,message:s.message}),a.dirty())):"trim"===s.kind?e.data=e.data.trim():"includes"===s.kind?e.data.includes(s.value,s.position)||(pC(o=this._getOrReturnCtx(e,o),{code:pR.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):"toLowerCase"===s.kind?e.data=e.data.toLowerCase():"toUpperCase"===s.kind?e.data=e.data.toUpperCase():"startsWith"===s.kind?e.data.startsWith(s.value)||(pC(o=this._getOrReturnCtx(e,o),{code:pR.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):"endsWith"===s.kind?e.data.endsWith(s.value)||(pC(o=this._getOrReturnCtx(e,o),{code:pR.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):"datetime"===s.kind?(function(e){let t=`${pK}T${pX(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)})(s).test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{code:pR.invalid_string,validation:"datetime",message:s.message}),a.dirty()):"date"===s.kind?pY.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{code:pR.invalid_string,validation:"date",message:s.message}),a.dirty()):"time"===s.kind?RegExp(`^${pX(s)}$`).test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{code:pR.invalid_string,validation:"time",message:s.message}),a.dirty()):"duration"===s.kind?pF.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"duration",code:pR.invalid_string,message:s.message}),a.dirty()):"ip"===s.kind?(t=e.data,!(("v4"===(r=s.version)||!r)&&pD.test(t)||("v6"===r||!r)&&pJ.test(t))&&1&&(pC(o=this._getOrReturnCtx(e,o),{validation:"ip",code:pR.invalid_string,message:s.message}),a.dirty())):"jwt"===s.kind?!function(e,t){if(!pU.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));if("object"!=typeof n||null===n||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)return!1;return!0}catch{return!1}}(e.data,s.alg)&&(pC(o=this._getOrReturnCtx(e,o),{validation:"jwt",code:pR.invalid_string,message:s.message}),a.dirty()):"cidr"===s.kind?(i=e.data,!(("v4"===(n=s.version)||!n)&&pV.test(i)||("v6"===n||!n)&&pB.test(i))&&1&&(pC(o=this._getOrReturnCtx(e,o),{validation:"cidr",code:pR.invalid_string,message:s.message}),a.dirty())):"base64"===s.kind?pW.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"base64",code:pR.invalid_string,message:s.message}),a.dirty()):"base64url"===s.kind?pG.test(e.data)||(pC(o=this._getOrReturnCtx(e,o),{validation:"base64url",code:pR.invalid_string,message:s.message}),a.dirty()):z.assertNever(s);return{status:a.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:pR.invalid_string,...N.errToObj(r)})}_addCheck(e){return new pQ({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...N.errToObj(e)})}url(e){return this._addCheck({kind:"url",...N.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...N.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...N.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...N.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...N.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...N.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...N.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...N.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...N.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...N.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...N.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...N.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...N.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...N.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...N.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...N.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...N.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...N.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...N.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...N.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...N.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...N.errToObj(t)})}nonempty(e){return this.min(1,N.errToObj(e))}trim(){return new pQ({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new pQ({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new pQ({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}pQ.create=e=>new pQ({checks:[],typeName:M.ZodString,coerce:e?.coerce??!1,...pj(e)});class p0 extends pA{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==pS.number){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.number,received:t.parsedType}),pT}let r=new p$;for(let i of this._def.checks)"int"===i.kind?z.isInteger(e.data)||(pC(t=this._getOrReturnCtx(e,t),{code:pR.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):"max"===i.kind?(i.inclusive?e.data>i.value:e.data>=i.value)&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):"multipleOf"===i.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}(e.data,i.value)&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(pC(t=this._getOrReturnCtx(e,t),{code:pR.not_finite,message:i.message}),r.dirty()):z.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,N.toString(t))}gt(e,t){return this.setLimit("min",e,!1,N.toString(t))}lte(e,t){return this.setLimit("max",e,!0,N.toString(t))}lt(e,t){return this.setLimit("max",e,!1,N.toString(t))}setLimit(e,t,r,i){return new p0({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:N.toString(i)}]})}_addCheck(e){return new p0({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:N.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:N.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:N.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&z.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}p0.create=e=>new p0({checks:[],typeName:M.ZodNumber,coerce:e?.coerce||!1,...pj(e)});class p1 extends pA{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==pS.bigint)return this._getInvalidInput(e);let r=new p$;for(let i of this._def.checks)"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"max"===i.kind?(i.inclusive?e.data>i.value:e.data>=i.value)&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):z.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.bigint,received:t.parsedType}),pT}gte(e,t){return this.setLimit("min",e,!0,N.toString(t))}gt(e,t){return this.setLimit("min",e,!1,N.toString(t))}lte(e,t){return this.setLimit("max",e,!0,N.toString(t))}lt(e,t){return this.setLimit("max",e,!1,N.toString(t))}setLimit(e,t,r,i){return new p1({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:N.toString(i)}]})}_addCheck(e){return new p1({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:N.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}p1.create=e=>new p1({checks:[],typeName:M.ZodBigInt,coerce:e?.coerce??!1,...pj(e)});class p2 extends pA{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==pS.boolean){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.boolean,received:t.parsedType}),pT}return pE(e.data)}}p2.create=e=>new p2({typeName:M.ZodBoolean,coerce:e?.coerce||!1,...pj(e)});class p9 extends pA{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==pS.date){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.date,received:t.parsedType}),pT}if(Number.isNaN(e.data.getTime()))return pC(this._getOrReturnCtx(e),{code:pR.invalid_date}),pT;let r=new p$;for(let i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(pC(t=this._getOrReturnCtx(e,t),{code:pR.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):z.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new p9({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:N.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:N.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}p9.create=e=>new p9({checks:[],coerce:e?.coerce||!1,typeName:M.ZodDate,...pj(e)});class p4 extends pA{_parse(e){if(this._getType(e)!==pS.symbol){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.symbol,received:t.parsedType}),pT}return pE(e.data)}}p4.create=e=>new p4({typeName:M.ZodSymbol,...pj(e)});class p5 extends pA{_parse(e){if(this._getType(e)!==pS.undefined){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.undefined,received:t.parsedType}),pT}return pE(e.data)}}p5.create=e=>new p5({typeName:M.ZodUndefined,...pj(e)});class p3 extends pA{_parse(e){if(this._getType(e)!==pS.null){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.null,received:t.parsedType}),pT}return pE(e.data)}}p3.create=e=>new p3({typeName:M.ZodNull,...pj(e)});class p6 extends pA{constructor(){super(...arguments),this._any=!0}_parse(e){return pE(e.data)}}p6.create=e=>new p6({typeName:M.ZodAny,...pj(e)});class p7 extends pA{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pE(e.data)}}p7.create=e=>new p7({typeName:M.ZodUnknown,...pj(e)});class p8 extends pA{_parse(e){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.never,received:t.parsedType}),pT}}p8.create=e=>new p8({typeName:M.ZodNever,...pj(e)});class me extends pA{_parse(e){if(this._getType(e)!==pS.undefined){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.void,received:t.parsedType}),pT}return pE(e.data)}}me.create=e=>new me({typeName:M.ZodVoid,...pj(e)});class mt extends pA{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==pS.array)return pC(t,{code:pR.invalid_type,expected:pS.array,received:t.parsedType}),pT;if(null!==i.exactLength){let e=t.data.length>i.exactLength.value,n=t.data.length<i.exactLength.value;(e||n)&&(pC(t,{code:e?pR.too_big:pR.too_small,minimum:n?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(null!==i.minLength&&t.data.length<i.minLength.value&&(pC(t,{code:pR.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),null!==i.maxLength&&t.data.length>i.maxLength.value&&(pC(t,{code:pR.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>i.type._parseAsync(new pI(t,e,t.path,r)))).then(e=>p$.mergeArray(r,e));let n=[...t.data].map((e,r)=>i.type._parseSync(new pI(t,e,t.path,r)));return p$.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new mt({...this._def,minLength:{value:e,message:N.toString(t)}})}max(e,t){return new mt({...this._def,maxLength:{value:e,message:N.toString(t)}})}length(e,t){return new mt({...this._def,exactLength:{value:e,message:N.toString(t)}})}nonempty(e){return this.min(1,e)}}mt.create=(e,t)=>new mt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...pj(t)});class mr extends pA{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=z.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==pS.object){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.object,received:t.parsedType}),pT}let{status:t,ctx:r}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof p8&&"strip"===this._def.unknownKeys))for(let e in r.data)n.includes(e)||o.push(e);let a=[];for(let e of n){let t=i[e],n=r.data[e];a.push({key:{status:"valid",value:e},value:t._parse(new pI(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof p8){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of o)a.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)o.length>0&&(pC(r,{code:pR.unrecognized_keys,keys:o}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of o){let i=r.data[t];a.push({key:{status:"valid",value:t},value:e._parse(new pI(r,i,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of a){let r=await t.key,i=await t.value;e.push({key:r,value:i,alwaysSet:t.alwaysSet})}return e}).then(e=>p$.mergeObjectSync(t,e)):p$.mergeObjectSync(t,a)}get shape(){return this._def.shape()}strict(e){return N.errToObj,new mr({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let i=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:N.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new mr({...this._def,unknownKeys:"strip"})}passthrough(){return new mr({...this._def,unknownKeys:"passthrough"})}extend(e){return new mr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new mr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:M.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new mr({...this._def,catchall:e})}pick(e){let t={};for(let r of z.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new mr({...this._def,shape:()=>t})}omit(e){let t={};for(let r of z.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new mr({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof mr){let r={};for(let i in t.shape){let n=t.shape[i];r[i]=mf.create(e(n))}return new mr({...t._def,shape:()=>r})}if(t instanceof mt)return new mt({...t._def,type:e(t.element)});if(t instanceof mf)return mf.create(e(t.unwrap()));if(t instanceof mg)return mg.create(e(t.unwrap()));if(t instanceof mo)return mo.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of z.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new mr({...this._def,shape:()=>t})}required(e){let t={};for(let r of z.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof mf;)e=e._def.innerType;t[r]=e}return new mr({...this._def,shape:()=>t})}keyof(){return mu(z.objectKeys(this.shape))}}mr.create=(e,t)=>new mr({shape:()=>e,unknownKeys:"strip",catchall:p8.create(),typeName:M.ZodObject,...pj(t)}),mr.strictCreate=(e,t)=>new mr({shape:()=>e,unknownKeys:"strict",catchall:p8.create(),typeName:M.ZodObject,...pj(t)}),mr.lazycreate=(e,t)=>new mr({shape:e,unknownKeys:"strip",catchall:p8.create(),typeName:M.ZodObject,...pj(t)});class mi extends pA{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new pk(e.ctx.common.issues));return pC(t,{code:pR.invalid_union,unionErrors:r}),pT});{let e,i=[];for(let n of r){let r={...t,common:{...t.common,issues:[]},parent:null},o=n._parseSync({data:t.data,path:t.path,parent:r});if("valid"===o.status)return o;"dirty"!==o.status||e||(e={result:o,ctx:r}),r.common.issues.length&&i.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let n=i.map(e=>new pk(e));return pC(t,{code:pR.invalid_union,unionErrors:n}),pT}}get options(){return this._def.options}}mi.create=(e,t)=>new mi({options:e,typeName:M.ZodUnion,...pj(t)});class mn extends pA{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=(e,i)=>{if("aborted"===e.status||"aborted"===i.status)return pT;let n=function e(t,r){let i=pw(t),n=pw(r);if(t===r)return{valid:!0,data:t};if(i===pS.object&&n===pS.object){let i=z.objectKeys(r),n=z.objectKeys(t).filter(e=>-1!==i.indexOf(e)),o={...t,...r};for(let i of(Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__,n)){if("__proto__"===i)continue;let n=e(t[i],r[i]);if(!n.valid)return{valid:!1};o[i]=n.data}return{valid:!0,data:o}}if(i===pS.array&&n===pS.array){if(t.length!==r.length)return{valid:!1};let i=[];for(let n=0;n<t.length;n++){let o=e(t[n],r[n]);if(!o.valid)return{valid:!1};i.push(o.data)}return{valid:!0,data:i}}if(i===pS.date&&n===pS.date&&+t==+r)return{valid:!0,data:t};return{valid:!1}}(e.value,i.value);return n.valid?(("dirty"===e.status||"dirty"===i.status)&&t.dirty(),{status:t.value,value:n.data}):(pC(r,{code:pR.invalid_intersection_types}),pT)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>i(e,t)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}mn.create=(e,t,r)=>new mn({left:e,right:t,typeName:M.ZodIntersection,...pj(r)});class mo extends pA{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pS.array)return pC(r,{code:pR.invalid_type,expected:pS.array,received:r.parsedType}),pT;if(r.data.length<this._def.items.length)return pC(r,{code:pR.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pT;!this._def.rest&&r.data.length>this._def.items.length&&(pC(r,{code:pR.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...r.data].map((e,t)=>{let i=this._def.items[t]||this._def.rest;return i?i._parse(new pI(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(i).then(e=>p$.mergeArray(t,e)):p$.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new mo({...this._def,rest:e})}}mo.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new mo({items:e,typeName:M.ZodTuple,rest:null,...pj(t)})};class ma extends pA{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pS.map)return pC(r,{code:pR.invalid_type,expected:pS.map,received:r.parsedType}),pT;let i=this._def.keyType,n=this._def.valueType,o=[...r.data.entries()].map(([e,t],o)=>({key:i._parse(new pI(r,e,r.path,[o,"key"])),value:n._parse(new pI(r,t,r.path,[o,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of o){let i=await r.key,n=await r.value;if("aborted"===i.status||"aborted"===n.status)return pT;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of o){let i=r.key,n=r.value;if("aborted"===i.status||"aborted"===n.status)return pT;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}}}}ma.create=(e,t,r)=>new ma({valueType:t,keyType:e,typeName:M.ZodMap,...pj(r)});class ms extends pA{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pS.set)return pC(r,{code:pR.invalid_type,expected:pS.set,received:r.parsedType}),pT;let i=this._def;null!==i.minSize&&r.data.size<i.minSize.value&&(pC(r,{code:pR.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),null!==i.maxSize&&r.data.size>i.maxSize.value&&(pC(r,{code:pR.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let n=this._def.valueType;function o(e){let r=new Set;for(let i of e){if("aborted"===i.status)return pT;"dirty"===i.status&&t.dirty(),r.add(i.value)}return{status:t.value,value:r}}let a=[...r.data.values()].map((e,t)=>n._parse(new pI(r,e,r.path,t)));return r.common.async?Promise.all(a).then(e=>o(e)):o(a)}min(e,t){return new ms({...this._def,minSize:{value:e,message:N.toString(t)}})}max(e,t){return new ms({...this._def,maxSize:{value:e,message:N.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ms.create=(e,t)=>new ms({valueType:e,minSize:null,maxSize:null,typeName:M.ZodSet,...pj(t)});class ml extends pA{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ml.create=(e,t)=>new ml({getter:e,typeName:M.ZodLazy,...pj(t)});class mc extends pA{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return pC(t,{received:t.data,code:pR.invalid_literal,expected:this._def.value}),pT}return{status:"valid",value:e.data}}get value(){return this._def.value}}function mu(e,t){return new md({values:e,typeName:M.ZodEnum,...pj(t)})}mc.create=(e,t)=>new mc({value:e,typeName:M.ZodLiteral,...pj(t)});class md extends pA{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return pC(t,{expected:z.joinValues(r),received:t.parsedType,code:pR.invalid_type}),pT}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return pC(t,{received:t.data,code:pR.invalid_enum_value,options:r}),pT}return pE(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return md.create(e,{...this._def,...t})}exclude(e,t=this._def){return md.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}md.create=mu;class mp extends pA{_parse(e){let t=z.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==pS.string&&r.parsedType!==pS.number){let e=z.objectValues(t);return pC(r,{expected:z.joinValues(e),received:r.parsedType,code:pR.invalid_type}),pT}if(this._cache||(this._cache=new Set(z.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=z.objectValues(t);return pC(r,{received:r.data,code:pR.invalid_enum_value,options:e}),pT}return pE(e.data)}get enum(){return this._def.values}}mp.create=(e,t)=>new mp({values:e,typeName:M.ZodNativeEnum,...pj(t)});class mm extends pA{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==pS.promise&&!1===t.common.async?(pC(t,{code:pR.invalid_type,expected:pS.promise,received:t.parsedType}),pT):pE((t.parsedType===pS.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}mm.create=(e,t)=>new mm({type:e,typeName:M.ZodPromise,...pj(t)});class mh extends pA{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,n={addIssue:e=>{pC(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===i.type){let e=i.transform(r.data,n);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return pT;let i=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===i.status?pT:"dirty"===i.status||"dirty"===t.value?pP(i.value):i});{if("aborted"===t.value)return pT;let i=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===i.status?pT:"dirty"===i.status||"dirty"===t.value?pP(i.value):i}}if("refinement"===i.type){let e=e=>{let t=i.refinement(e,n);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?pT:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===i.status?pT:("dirty"===i.status&&t.dirty(),e(i.value),{status:t.value,value:i.value})}}if("transform"===i.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>"valid"!==e.status?pT:Promise.resolve(i.transform(e.value,n)).then(e=>({status:t.value,value:e})));else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if("valid"!==e.status)return pT;let o=i.transform(e.value,n);if(o instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}z.assertNever(i)}}mh.create=(e,t,r)=>new mh({schema:e,typeName:M.ZodEffects,effect:t,...pj(r)}),mh.createWithPreprocess=(e,t,r)=>new mh({schema:t,effect:{type:"preprocess",transform:e},typeName:M.ZodEffects,...pj(r)});class mf extends pA{_parse(e){return this._getType(e)===pS.undefined?pE(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mf.create=(e,t)=>new mf({innerType:e,typeName:M.ZodOptional,...pj(t)});class mg extends pA{_parse(e){return this._getType(e)===pS.null?pE(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mg.create=(e,t)=>new mg({innerType:e,typeName:M.ZodNullable,...pj(t)});class my extends pA{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===pS.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}my.create=(e,t)=>new my({innerType:e,typeName:M.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...pj(t)});class mv extends pA{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return pO(i)?i.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new pk(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new pk(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}mv.create=(e,t)=>new mv({innerType:e,typeName:M.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...pj(t)});class m_ extends pA{_parse(e){if(this._getType(e)!==pS.nan){let t=this._getOrReturnCtx(e);return pC(t,{code:pR.invalid_type,expected:pS.nan,received:t.parsedType}),pT}return{status:"valid",value:e.data}}}m_.create=e=>new m_({typeName:M.ZodNaN,...pj(e)}),Symbol("zod_brand");class mb extends pA{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class mS extends pA{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?pT:"dirty"===e.status?(t.dirty(),pP(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?pT:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new mS({in:e,out:t,typeName:M.ZodPipeline})}}class mw extends pA{_parse(e){let t=this._def.innerType._parse(e),r=e=>("valid"===e.status&&(e.value=Object.freeze(e.value)),e);return pO(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}mw.create=(e,t)=>new mw({innerType:e,typeName:M.ZodReadonly,...pj(t)}),mr.lazycreate,(I=M||(M={})).ZodString="ZodString",I.ZodNumber="ZodNumber",I.ZodNaN="ZodNaN",I.ZodBigInt="ZodBigInt",I.ZodBoolean="ZodBoolean",I.ZodDate="ZodDate",I.ZodSymbol="ZodSymbol",I.ZodUndefined="ZodUndefined",I.ZodNull="ZodNull",I.ZodAny="ZodAny",I.ZodUnknown="ZodUnknown",I.ZodNever="ZodNever",I.ZodVoid="ZodVoid",I.ZodArray="ZodArray",I.ZodObject="ZodObject",I.ZodUnion="ZodUnion",I.ZodDiscriminatedUnion="ZodDiscriminatedUnion",I.ZodIntersection="ZodIntersection",I.ZodTuple="ZodTuple",I.ZodRecord="ZodRecord",I.ZodMap="ZodMap",I.ZodSet="ZodSet",I.ZodFunction="ZodFunction",I.ZodLazy="ZodLazy",I.ZodLiteral="ZodLiteral",I.ZodEnum="ZodEnum",I.ZodEffects="ZodEffects",I.ZodNativeEnum="ZodNativeEnum",I.ZodOptional="ZodOptional",I.ZodNullable="ZodNullable",I.ZodDefault="ZodDefault",I.ZodCatch="ZodCatch",I.ZodPromise="ZodPromise",I.ZodBranded="ZodBranded",I.ZodPipeline="ZodPipeline",I.ZodReadonly="ZodReadonly";let mR=pQ.create;p0.create,m_.create,p1.create,p2.create,p9.create,p4.create,p5.create,p3.create,p6.create,p7.create,p8.create,me.create,mt.create;let mk=mr.create;mr.strictCreate,mi.create,mn.create,mo.create,ma.create,ms.create,ml.create,mc.create,md.create,mp.create,mm.create,mh.create,mf.create,mg.create,mh.createWithPreprocess,mS.create;let mx=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function mC(e){if("openAi"!==e.target)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?mx(t,e.currentPath):t.join("/")}}function m$(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function mT(e,t,r,i,n){e[t]=r,m$(e,t,i,n)}function mP(e,t){return mK(e.type._def,t)}let mE=/^[cC][^\s-]{8,}$/,mO=/^[0-9a-z]+$/,mI=/^[0-9A-HJKMNP-TV-Z]{26}$/,mq=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,mj=()=>(void 0===k&&(k=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),k),mA=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,mz=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mN=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mM=/^[a-zA-Z0-9_-]{21}$/,mZ=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function mU(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":mT(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":mT(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":mD(r,"email",i.message,t);break;case"format:idn-email":mD(r,"idn-email",i.message,t);break;case"pattern:zod":mV(r,mq,i.message,t)}break;case"url":mD(r,"uri",i.message,t);break;case"uuid":mD(r,"uuid",i.message,t);break;case"regex":mV(r,i.regex,i.message,t);break;case"cuid":mV(r,mE,i.message,t);break;case"cuid2":mV(r,mO,i.message,t);break;case"startsWith":mV(r,RegExp(`^${mF(i.value,t)}`),i.message,t);break;case"endsWith":mV(r,RegExp(`${mF(i.value,t)}$`),i.message,t);break;case"datetime":mD(r,"date-time",i.message,t);break;case"date":mD(r,"date",i.message,t);break;case"time":mD(r,"time",i.message,t);break;case"duration":mD(r,"duration",i.message,t);break;case"length":mT(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t),mT(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":mV(r,RegExp(mF(i.value,t)),i.message,t);break;case"ip":"v6"!==i.version&&mD(r,"ipv4",i.message,t),"v4"!==i.version&&mD(r,"ipv6",i.message,t);break;case"base64url":mV(r,mN,i.message,t);break;case"jwt":mV(r,mZ,i.message,t);break;case"cidr":"v6"!==i.version&&mV(r,mA,i.message,t),"v4"!==i.version&&mV(r,mz,i.message,t);break;case"emoji":mV(r,mj(),i.message,t);break;case"ulid":mV(r,mI,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":mD(r,"binary",i.message,t);break;case"contentEncoding:base64":mT(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":mV(r,mL,i.message,t)}break;case"nanoid":mV(r,mM,i.message,t)}return r}function mF(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)mH.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}let mH=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function mD(e,t,r,i){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&i.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&i.errorMessages&&{errorMessage:{format:r}}})):mT(e,"format",t,r,i)}function mV(e,t,r,i){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&i.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:mJ(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):mT(e,"pattern",mJ(t,i),r,i)}function mJ(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source,n="",o=!1,a=!1,s=!1;for(let e=0;e<i.length;e++){if(o){n+=i[e],o=!1;continue}if(r.i){if(a){if(i[e].match(/[a-z]/)){s?(n+=i[e],n+=`${i[e-2]}-${i[e]}`.toUpperCase(),s=!1):"-"===i[e+1]&&i[e+2]?.match(/[a-z]/)?(n+=i[e],s=!0):n+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){n+=`[${i[e]}${i[e].toUpperCase()}]`;continue}}if(r.m){if("^"===i[e]){n+=`(^|(?<=[\r
|
|
73
|
+
`,e.enqueue(t.encode(n)),!0}catch(e){return this.onerror?.(e),!1}}handleUnsupportedRequest(){return this.onerror?.(Error("Method not allowed.")),Response.json({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null},{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,t){try{let r,i,n,o,a,s=e.headers.get("accept");if(!s?.includes("application/json")||!s.includes("text/event-stream"))return this.onerror?.(Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");if(!uZ(e.headers.get("content-type")))return this.onerror?.(Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");if(t?.parsedBody===void 0)try{let t=await dI(e,this._maxRequestBodySize);if(t.tooLarge){let e=dO(this._maxRequestBodySize);return this.onerror?.(Error(e)),this.createJsonErrorResponse(413,-32e3,e)}r=JSON.parse(t.text)}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else r=t.parsedBody;if(Array.isArray(r)&&r.length>100)return this.onerror?.(Error("Invalid Request: Batch must not exceed 100 messages")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Batch must not exceed 100 messages");try{i=Array.isArray(r)?r.map(e=>au.parse(e)):[au.parse(r)]}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let l=i.some(e=>ax.safeParse(e).success);if(l){if(this._initialized&&void 0!==this.sessionId)return this.onerror?.(Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(i.length>1)return this.onerror?.(Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!l){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");try{n=await this._checkScopeChallenge(i,t?.authInfo)}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(500,-32603,"Internal server error")}if(n)return n;if(!i.some(e=>cY(e))){for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e});return new Response(null,{status:202})}let c=crypto.randomUUID(),u=i.find(e=>ax.safeParse(e).success),d=u?u.params.protocolVersion:e.headers.get("mcp-protocol-version")??"2025-03-26";if(this._enableJsonResponse)return new Promise(r=>{for(let e of(this._streamMapping.set(c,{resolveJson:r,cleanup:()=>{this._streamMapping.delete(c)}}),i))cY(e)&&this._requestToStreamMapping.set(e.id,c);for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e})});let p=new TextEncoder,m=new ReadableStream({start:e=>{o=e},cancel:()=>{void 0!==a&&clearInterval(a),this._streamMapping.get(c)?.controller===o&&this._streamMapping.delete(c)}}),h={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};for(let e of(void 0!==this.sessionId&&(h["mcp-session-id"]=this.sessionId),i))cY(e)&&(this._streamMapping.set(c,{controller:o,encoder:p,cleanup:()=>{void 0!==a&&clearInterval(a),this._streamMapping.delete(c);try{o.close()}catch{}}}),this._requestToStreamMapping.set(e.id,c));for(let r of(await this.writePrimingEvent(o,p,c,d),i)){let i,n;cY(r)&&this._eventStore&&this.supportsEmptySSEData(d)&&(i=()=>{this.closeSSEStream(r.id)},n=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(r,{authInfo:t?.authInfo,request:e,closeSSEStream:i,closeStandaloneSSEStream:n})}return this._streamMapping.get(c)?.controller===o&&(a=this.startKeepAlive(o,p)),new Response(m,{status:200,headers:h})}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(e)})}}async handleDeleteRequest(e){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(e){if(void 0===this.sessionIdGenerator)return;if(!this._initialized)return this.onerror?.(Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let t=e.headers.get("mcp-session-id");return t?t!==this.sessionId?(this.onerror?.(Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")):void 0:(this.onerror?.(Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required"))}validateProtocolVersion(e){let t=e.headers.get("mcp-protocol-version");if(null!==t&&!this._supportedProtocolVersions.includes(t)){let e=`Bad Request: Unsupported protocol version: ${t} (supported versions: ${this._supportedProtocolVersions.join(", ")})`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(400,-32e3,e)}}async close(){if(!this._closed){for(let{cleanup:e}of(this._closed=!0,this._streamMapping.values()))e();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}}closeSSEStream(e){let t=this._requestToStreamMapping.get(e);if(!t)return;let r=this._streamMapping.get(t);r&&r.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,t){let r=t?.relatedRequestId;if((cQ(e)||c0(e))&&(r=e.id),void 0===r){let t;if(cQ(e)||c0(e))throw Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");this._eventStore&&(t=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let r=this._streamMapping.get(this._standaloneSseStreamId);if(void 0===r)return;r.controller&&r.encoder&&(void 0===t||!r.replayedEventIds?.has(t))&&this.writeSSEEvent(r.controller,r.encoder,e,t);return}let i=this._requestToStreamMapping.get(r);if(!i)throw Error(`No connection established for request ID: ${String(r)}`);let n=this._streamMapping.get(i);if(!this._enableJsonResponse){let t;this._eventStore&&(t=await this._eventStore.storeEvent(i,e),n=this._streamMapping.get(i)),n?.controller&&n?.encoder&&(void 0===t||!n.replayedEventIds?.has(t))&&this.writeSSEEvent(n.controller,n.encoder,e,t)}if(cQ(e)||c0(e)){this._requestResponseMap.set(r,e);let t=[...this._requestToStreamMapping.entries()].filter(([e,t])=>t===i).map(([e])=>e);if(t.every(e=>this._requestResponseMap.has(e))){if(!n){if(this._enableJsonResponse)throw Error(`No connection established for request ID: ${String(r)}`);if(!this._eventStore){for(let e of(this.onerror?.(Error(`Response for request ID ${String(r)} is undeliverable: per-request stream is disconnected and no eventStore is configured`)),t))this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}if(this._enableJsonResponse&&n.resolveJson){let e={"Content-Type":"application/json"};void 0!==this.sessionId&&(e["mcp-session-id"]=this.sessionId);let r=t.map(e=>this._requestResponseMap.get(e));1===r.length?n.resolveJson(Response.json(r[0],{status:200,headers:e})):n.resolveJson(Response.json(r,{status:200,headers:e})),n.cleanup()}else n.cleanup();for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e)}}}};function dj(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let{method:t,id:r}=e;return"string"!=typeof t?null:"string"==typeof r||"number"==typeof r?r:null}function dA(e,t,r,i,n=null){return Response.json({jsonrpc:"2.0",error:{code:t,message:r,...void 0!==i&&{data:i}},id:n},{status:e,...405===e&&{headers:{Allow:"POST"}}})}function dz(e,t=null){return dA(e.httpStatus,e.code,e.message,e.data,t)}function dL(e){return e instanceof Error?e:Error(String(e))}function dN(e=null){return dA(500,-32603,"Internal server error",void 0,e)}function dM(e){if(void 0!==e.transport)throw Error("The factory returned an instance that is still serving another request. Return a new instance for each request.")}function dZ(e){return{protocolVersionHeader:e.headers.get("mcp-protocol-version")??void 0,mcpMethodHeader:e.headers.get("mcp-method")??void 0,mcpNameHeader:e.headers.get("mcp-name")??void 0}}let dU=(e,t)=>{globalThis[e]=t},dF=e=>globalThis[e];function dH({name:e,fallback:t=!0}){let r=Symbol.for(`xmcp-context-${e}`),i=Symbol.for(`xmcp-context-${e}-fallback-store`);if(dF(r))return dF(r);let n=new x,o=globalThis[i]??{current:null};dU(i,o);let a={provider:(e,r)=>(t&&(o.current=e),n.run(e,r)),getContext:()=>{let r=n.getStore();if(r)return r;if(t&&o.current)return o.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:r=>{let i=n.getStore()??(t?o.current:null);if(!i)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(i,r)}};return dU(r,a),a}let dD=dH({name:"http-request-context"});dD.setContext;let dV=dD.getContext,dJ=dD.provider,dB=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),dW=e=>{if(!dB(e)||"string"!=typeof e.name||"string"!=typeof e.version)return;let t={name:e.name,version:e.version};return"string"==typeof e.title&&(t.title=e.title),"string"==typeof e.websiteUrl&&(t.websiteUrl=e.websiteUrl),"string"==typeof e.description&&(t.description=e.description),t},dG=e=>{if(e&&"initialize"===e.method&&dB(e.params))return dW(e.params.clientInfo)},dK=(e,t)=>{let r=t.toLowerCase();for(let[t,i]of Object.entries(e)){if(t.toLowerCase()!==r)continue;let e=Array.isArray(i)?i[0]:i;if("string"!=typeof e)break;let n=e.trim();return n.length>0?n:void 0}};function dY(e){let{tags:t,enabled:r,...i}=e;return{...i,_meta:void 0===t?i._meta:{...i._meta,"xmcp/tags":t}}}let dX=new class{add(e,t){this.resources.set(e,t)}getAll(){return this.resources}clear(){this.resources.clear()}has(e){return this.resources.has(e)}constructor(){var e,t;e="resources",t=new Map,e in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t}},dQ=dH({name:"request-context",fallback:!1});function d0(){try{return dQ.getContext().value}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}function d1(e,t,r,i=!1){let n;if(i){let t;try{t=dQ.getContext()}catch{}if(t?.request===e.mcpReq)return r()}let o=new Map;if(e.http){let e=dV(),t=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,Array.isArray(t)?Object.freeze([...t]):t]));n=Object.freeze({id:e.id,headers:Object.freeze(t)})}let a=Object.freeze({clientInfo:t?Object.freeze({...t}):void 0,http:n,authInfo:e.http?.authInfo,signal:e.mcpReq.signal,set(e,t){o.set(e,t)},get:e=>o.get(e),async progress(t,r){let i=e.mcpReq._meta?.progressToken;void 0!==i&&await e.mcpReq.notify({method:"notifications/progress",params:{progressToken:i,progress:t,...void 0===r?{}:{total:r}}})},log:(t,r)=>e.mcpReq.log(t,r)});return dQ.provider({request:e.mcpReq,value:a},r)}function d2(e){let t=e?.["xmcp/tags"];return Array.isArray(t)?t:void 0}function d9(e,t,r=!1){let i;try{i=new URL(t).toString()}catch{return}for(let n of r?[t,i]:[i]){let t=e.uiOwners.get(n)??e.resources.get(n);if(t)return t}for(let{component:t,template:r}of e.templates.values())if(r.uriTemplate.match(i))return t}let d4=dH({name:"client-info-context"});d4.setContext;let d5=d4.getContext;d4.provider;let d3=new Set(["message","mode","requestedSchema"]),d6=new Set(["elicitationId","message","mode","url"]),d7=new Set(["properties","required","type"]),d8=new Set(["default","description","format","maxLength","minLength","title","type"]),pe=new Set(["default","description","enum","enumNames","title","type"]),pt=new Set(["default","description","title","type"]),pr=new Set(["default","description","maximum","minimum","title","type"]),pi=new Set(["date","date-time","email","uri"]);function pn(e,t,r){let i=Object.keys(e).filter(e=>!t.has(e));if(0!==i.length)throw Error(`${r} includes unsupported key(s): ${i.join(", ")}.`)}function po(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}function pa(e,t){if("string"!=typeof e)throw Error(t)}function ps(e,t){if("string"!=typeof e||0===e.trim().length)throw Error(t)}function pl(e,t){if(void 0!==e&&"string"!=typeof e)throw Error(t)}function pc(e,t){if(void 0!==e&&"number"!=typeof e)throw Error(t)}function pu(e,t){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e))throw Error(t)}let pd=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),pp=new Set(["task","toolChoice","tools"]),pm=new Set(["text","image","audio"]);function ph(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}let pf={text:e=>"string"!=typeof e.text?{valid:!1,error:'Text content must have a "text" property of type string'}:{valid:!0},image:e=>"string"!=typeof e.data?{valid:!1,error:'Image content must have a "data" property of type string (base64-encoded image)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Image content must have a "mimeType" property of type string'}:{valid:!0},audio:e=>"string"!=typeof e.data?{valid:!1,error:'Audio content must have a "data" property of type string (base64-encoded audio)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Audio content must have a "mimeType" property of type string'}:{valid:!0},resource_link:e=>"string"!=typeof e.name?{valid:!1,error:'Resource link content must have a "name" property of type string'}:"string"!=typeof e.uri?{valid:!1,error:'Resource link content must have a "uri" property of type string'}:void 0!==e.title&&"string"!=typeof e.title?{valid:!1,error:'Resource link "title" property must be a string if provided'}:void 0!==e.description&&"string"!=typeof e.description?{valid:!1,error:'Resource link "description" property must be a string if provided'}:void 0!==e.mimeType&&"string"!=typeof e.mimeType?{valid:!1,error:'Resource link "mimeType" property must be a string if provided'}:{valid:!0}};function pg(e){if(!e||"object"!=typeof e)return{valid:!1,error:"Content must be an object"};if("string"!=typeof e.type)return{valid:!1,error:'Content must have a "type" property of type string'};if(void 0!==e._meta&&(null===e._meta||"object"!=typeof e._meta))return{valid:!1,error:'Content "_meta" property must be an object if provided'};let t=pf[e.type];return t?t(e):{valid:!0}}function py(e,t,r,i){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`Tool "${r}" ${i}: expected a plain object.`);let n=new Set(Object.keys(t)),o=Object.keys(e).filter(e=>!n.has(e));if(o.length>0)throw Error(`Tool "${r}" ${i}: unrecognized key(s): ${o.join(", ")}`);for(let[n,o]of Object.entries(t))try{o.parse(e[n])}catch(e){throw Error(`Tool "${r}" ${i}: ${e?.message??`invalid field "${n}"`}`)}}function pv(e){return!!(e&&"object"==typeof e&&Object.keys(e).some(e=>e.startsWith("ui/")))}function p_(e){let t=e.mcpReq.envelope,r=dW(t?.[oG]);if(!r)try{let e,t=dV();r=t.clientInfo??(e=t.headers,dW({name:dK(e,"x-mcp-client-name"),version:dK(e,"x-mcp-client-version"),title:dK(e,"x-mcp-client-title"),websiteUrl:dK(e,"x-mcp-client-website-url"),description:dK(e,"x-mcp-client-description")}))}catch{}if(!r)try{r=d5().clientInfo}catch{}return r}function pb(e,t=!1){let r=[...e];return(e,i,n)=>d1(i,p_(i),async()=>{if(0===r.length)return n();let t=Object.freeze({...d0(),...e,params:Object.freeze({...e.params})}),i=-1,o=async e=>{if(e<=i)throw Error("MCP middleware next() can only be called once");i=e;let a=r[e];return a?a(t,()=>o(e+1)):n()};return o(0)},t)}function pS(e,t=new WeakMap){if(null===e||"object"!=typeof e)return e;let r=Object.getPrototypeOf(e);if(!Array.isArray(e)&&r!==Object.prototype&&null!==r)return e;if(t.has(e))return t.get(e);let i=Array.isArray(e)?[]:Object.create(r);for(let[r,n]of(t.set(e,i),Object.entries(e)))Object.defineProperty(i,r,{value:pS(n,t),enumerable:!0,configurable:!0,writable:!0});return Object.freeze(i)}let pw=new Set(["tools/list","prompts/get","prompts/list","resources/read","resources/list","resources/templates/list","completion/complete"]);function pR(e){return e.endsWith(".tsx")}let pk=Symbol("Let zodToJsonSchema decide on which parser to use"),px={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};(O=z||(z={})).assertEqual=e=>{},O.assertIs=function(e){},O.assertNever=function(e){throw Error()},O.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},O.getValidEnumValues=e=>{let t=O.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let i of t)r[i]=e[i];return O.objectValues(r)},O.objectValues=e=>O.objectKeys(e).map(function(t){return e[t]}),O.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},O.find=(e,t)=>{for(let r of e)if(t(r))return r},O.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,O.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},O.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(L||(L={})).mergeShapes=(e,t)=>({...e,...t});let pC=z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),p$=e=>{switch(typeof e){case"undefined":return pC.undefined;case"string":return pC.string;case"number":return Number.isNaN(e)?pC.nan:pC.number;case"boolean":return pC.boolean;case"function":return pC.function;case"bigint":return pC.bigint;case"symbol":return pC.symbol;case"object":if(Array.isArray(e))return pC.array;if(null===e)return pC.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return pC.promise;if("u">typeof Map&&e instanceof Map)return pC.map;if("u">typeof Set&&e instanceof Set)return pC.set;if("u">typeof Date&&e instanceof Date)return pC.date;return pC.object;default:return pC.unknown}},pT=z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class pP extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},i=e=>{for(let n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(i);else if("invalid_return_type"===n.code)i(n.returnTypeError);else if("invalid_arguments"===n.code)i(n.argumentsError);else if(0===n.path.length)r._errors.push(t(n));else{let e=r,i=0;for(;i<n.path.length;){let r=n.path[i],o=i===n.path.length-1;if("_errors"===r){o&&e._errors.push(t(n)),i++;continue}Object.prototype.hasOwnProperty.call(e,r)||("__proto__"===r?Object.defineProperty(e,r,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):e[r]={_errors:[]}),e=e[r],o&&e._errors.push(t(n)),i++}}};return i(this),r}static assert(e){if(!(e instanceof pP))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t=Object.create(null),r=[];for(let i of this.issues)if(i.path.length>0){let r=i.path[0];t[r]=t[r]||[],t[r].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}pP.create=e=>new pP(e);let pO=(e,t)=>{let r;switch(e.code){case pT.invalid_type:r=e.received===pC.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case pT.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,z.jsonStringifyReplacer)}`;break;case pT.unrecognized_keys:r=`Unrecognized key(s) in object: ${z.joinValues(e.keys,", ")}`;break;case pT.invalid_union:r="Invalid input";break;case pT.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${z.joinValues(e.options)}`;break;case pT.invalid_enum_value:r=`Invalid enum value. Expected ${z.joinValues(e.options)}, received '${e.received}'`;break;case pT.invalid_arguments:r="Invalid function arguments";break;case pT.invalid_return_type:r="Invalid function return type";break;case pT.invalid_date:r="Invalid date";break;case pT.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:z.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case pT.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case pT.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case pT.custom:r="Invalid input";break;case pT.invalid_intersection_types:r="Intersection results could not be merged";break;case pT.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case pT.not_finite:r="Number must be finite";break;default:r=t.defaultError,z.assertNever(e)}return{message:r}};(E=N||(N={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},E.toString=e=>"string"==typeof e?e:e?.message;function pE(e,t){let r=(e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,o=[...r,...n.path||[]],a={...n,path:o};if(void 0!==n.message)return{...n,path:o,message:n.message};let s="";for(let e of i.filter(e=>!!e).slice().reverse())s=e(a,{data:t,defaultError:s}).message;return{...n,path:o,message:s}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,pO,void 0].filter(e=>!!e)});e.common.issues.push(r)}class pI{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let i of t){if("aborted"===i.status)return pq;"dirty"===i.status&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,i=await e.value;r.push({key:t,value:i})}return pI.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let i of t){let{key:t,value:n}=i;if("aborted"===t.status||"aborted"===n.status)return pq;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==n.value||i.alwaysSet)&&(r[t.value]=n.value)}return{status:e.value,value:r}}}let pq=Object.freeze({status:"aborted"}),pj=e=>({status:"dirty",value:e}),pA=e=>({status:"valid",value:e}),pz=e=>"u">typeof Promise&&e instanceof Promise;class pL{constructor(e,t,r,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let pN=(e,t)=>{if("valid"===t.status)return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new pP(e.common.issues);return this._error=t,this._error}}};function pM(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:n}:{errorMap:(t,n)=>{let{message:o}=e;return"invalid_enum_value"===t.code?{message:o??n.defaultError}:void 0===n.data?{message:o??i??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:o??r??n.defaultError}},description:n}}class pZ{get description(){return this._def.description}_getType(e){return p$(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:p$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new pI,ctx:{common:e.parent.common,data:e.data,parsedType:p$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(pz(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p$(e)},i=this._parseSync({data:e,path:r.path,parent:r});return pN(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p$(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return"valid"===r.status?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>"valid"===e.status?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p$(e)},i=this._parse({data:e,path:r.path,parent:r});return pN(r,await (pz(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,i)=>{let n=e(r),o=()=>i.addIssue({code:pT.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"u">typeof Promise&&n instanceof Promise?n.then(e=>!!e||(o(),!1)):!!n||(o(),!1)})}refinement(e,t){return this._refinement((r,i)=>!!e(r)||(i.addIssue("function"==typeof t?t(r,i):t),!1))}_refinement(e){return new m_({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return mb.create(this,this._def)}nullable(){return mS.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ma.create(this)}promise(){return mv.create(this,this._def)}or(e){return ml.create([this,e],this._def)}and(e){return mc.create(this,e,this._def)}transform(e){return new m_({...pM(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new mw({...pM(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:M.ZodDefault})}brand(){return new mx({typeName:M.ZodBranded,type:this,...pM(this._def)})}catch(e){return new mR({...pM(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:M.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return mC.create(this,e)}readonly(){return m$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let pU=/^c[^\s-]{8,}$/i,pF=/^[0-9a-z]+$/,pH=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pD=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pV=/^[a-z0-9_-]{21}$/i,pJ=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pB=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,pW=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pG=/^(?:(?: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])$/,pK=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,pY=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,pX=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pQ=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,p0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,p1="((\\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])))",p2=RegExp(`^${p1}$`);function p9(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}class p4 extends pZ{_parse(e){var t,r,i,n;let o;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==pC.string){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.string,received:t.parsedType}),pq}let a=new pI;for(let s of this._def.checks)if("min"===s.kind)e.data.length<s.value&&(pE(o=this._getOrReturnCtx(e,o),{code:pT.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("max"===s.kind)e.data.length>s.value&&(pE(o=this._getOrReturnCtx(e,o),{code:pT.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("length"===s.kind){let t=e.data.length>s.value,r=e.data.length<s.value;(t||r)&&(o=this._getOrReturnCtx(e,o),t?pE(o,{code:pT.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):r&&pE(o,{code:pT.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if("email"===s.kind)pW.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"email",code:pT.invalid_string,message:s.message}),a.dirty());else if("emoji"===s.kind)p||(p=RegExp("^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),p.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"emoji",code:pT.invalid_string,message:s.message}),a.dirty());else if("uuid"===s.kind)pD.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"uuid",code:pT.invalid_string,message:s.message}),a.dirty());else if("nanoid"===s.kind)pV.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"nanoid",code:pT.invalid_string,message:s.message}),a.dirty());else if("cuid"===s.kind)pU.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"cuid",code:pT.invalid_string,message:s.message}),a.dirty());else if("cuid2"===s.kind)pF.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"cuid2",code:pT.invalid_string,message:s.message}),a.dirty());else if("ulid"===s.kind)pH.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"ulid",code:pT.invalid_string,message:s.message}),a.dirty());else if("url"===s.kind)try{new URL(e.data)}catch{pE(o=this._getOrReturnCtx(e,o),{validation:"url",code:pT.invalid_string,message:s.message}),a.dirty()}else"regex"===s.kind?(s.regex.lastIndex=0,s.regex.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"regex",code:pT.invalid_string,message:s.message}),a.dirty())):"trim"===s.kind?e.data=e.data.trim():"includes"===s.kind?e.data.includes(s.value,s.position)||(pE(o=this._getOrReturnCtx(e,o),{code:pT.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):"toLowerCase"===s.kind?e.data=e.data.toLowerCase():"toUpperCase"===s.kind?e.data=e.data.toUpperCase():"startsWith"===s.kind?e.data.startsWith(s.value)||(pE(o=this._getOrReturnCtx(e,o),{code:pT.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):"endsWith"===s.kind?e.data.endsWith(s.value)||(pE(o=this._getOrReturnCtx(e,o),{code:pT.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):"datetime"===s.kind?(function(e){let t=`${p1}T${p9(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)})(s).test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{code:pT.invalid_string,validation:"datetime",message:s.message}),a.dirty()):"date"===s.kind?p2.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{code:pT.invalid_string,validation:"date",message:s.message}),a.dirty()):"time"===s.kind?RegExp(`^${p9(s)}$`).test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{code:pT.invalid_string,validation:"time",message:s.message}),a.dirty()):"duration"===s.kind?pB.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"duration",code:pT.invalid_string,message:s.message}),a.dirty()):"ip"===s.kind?(t=e.data,!(("v4"===(r=s.version)||!r)&&pG.test(t)||("v6"===r||!r)&&pY.test(t))&&1&&(pE(o=this._getOrReturnCtx(e,o),{validation:"ip",code:pT.invalid_string,message:s.message}),a.dirty())):"jwt"===s.kind?!function(e,t){if(!pJ.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));if("object"!=typeof n||null===n||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)return!1;return!0}catch{return!1}}(e.data,s.alg)&&(pE(o=this._getOrReturnCtx(e,o),{validation:"jwt",code:pT.invalid_string,message:s.message}),a.dirty()):"cidr"===s.kind?(i=e.data,!(("v4"===(n=s.version)||!n)&&pK.test(i)||("v6"===n||!n)&&pX.test(i))&&1&&(pE(o=this._getOrReturnCtx(e,o),{validation:"cidr",code:pT.invalid_string,message:s.message}),a.dirty())):"base64"===s.kind?pQ.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"base64",code:pT.invalid_string,message:s.message}),a.dirty()):"base64url"===s.kind?p0.test(e.data)||(pE(o=this._getOrReturnCtx(e,o),{validation:"base64url",code:pT.invalid_string,message:s.message}),a.dirty()):z.assertNever(s);return{status:a.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:pT.invalid_string,...N.errToObj(r)})}_addCheck(e){return new p4({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...N.errToObj(e)})}url(e){return this._addCheck({kind:"url",...N.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...N.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...N.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...N.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...N.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...N.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...N.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...N.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...N.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...N.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...N.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...N.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...N.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...N.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...N.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...N.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...N.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...N.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...N.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...N.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...N.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...N.errToObj(t)})}nonempty(e){return this.min(1,N.errToObj(e))}trim(){return new p4({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new p4({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new p4({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}p4.create=e=>new p4({checks:[],typeName:M.ZodString,coerce:e?.coerce??!1,...pM(e)});class p5 extends pZ{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==pC.number){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.number,received:t.parsedType}),pq}let r=new pI;for(let i of this._def.checks)"int"===i.kind?z.isInteger(e.data)||(pE(t=this._getOrReturnCtx(e,t),{code:pT.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):"max"===i.kind?(i.inclusive?e.data>i.value:e.data>=i.value)&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):"multipleOf"===i.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}(e.data,i.value)&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(pE(t=this._getOrReturnCtx(e,t),{code:pT.not_finite,message:i.message}),r.dirty()):z.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,N.toString(t))}gt(e,t){return this.setLimit("min",e,!1,N.toString(t))}lte(e,t){return this.setLimit("max",e,!0,N.toString(t))}lt(e,t){return this.setLimit("max",e,!1,N.toString(t))}setLimit(e,t,r,i){return new p5({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:N.toString(i)}]})}_addCheck(e){return new p5({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:N.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:N.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:N.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&z.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}p5.create=e=>new p5({checks:[],typeName:M.ZodNumber,coerce:e?.coerce||!1,...pM(e)});class p3 extends pZ{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==pC.bigint)return this._getInvalidInput(e);let r=new pI;for(let i of this._def.checks)"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"max"===i.kind?(i.inclusive?e.data>i.value:e.data>=i.value)&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):z.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.bigint,received:t.parsedType}),pq}gte(e,t){return this.setLimit("min",e,!0,N.toString(t))}gt(e,t){return this.setLimit("min",e,!1,N.toString(t))}lte(e,t){return this.setLimit("max",e,!0,N.toString(t))}lt(e,t){return this.setLimit("max",e,!1,N.toString(t))}setLimit(e,t,r,i){return new p3({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:N.toString(i)}]})}_addCheck(e){return new p3({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:N.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}p3.create=e=>new p3({checks:[],typeName:M.ZodBigInt,coerce:e?.coerce??!1,...pM(e)});class p6 extends pZ{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==pC.boolean){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.boolean,received:t.parsedType}),pq}return pA(e.data)}}p6.create=e=>new p6({typeName:M.ZodBoolean,coerce:e?.coerce||!1,...pM(e)});class p7 extends pZ{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==pC.date){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.date,received:t.parsedType}),pq}if(Number.isNaN(e.data.getTime()))return pE(this._getOrReturnCtx(e),{code:pT.invalid_date}),pq;let r=new pI;for(let i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(pE(t=this._getOrReturnCtx(e,t),{code:pT.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):z.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new p7({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:N.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:N.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}p7.create=e=>new p7({checks:[],coerce:e?.coerce||!1,typeName:M.ZodDate,...pM(e)});class p8 extends pZ{_parse(e){if(this._getType(e)!==pC.symbol){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.symbol,received:t.parsedType}),pq}return pA(e.data)}}p8.create=e=>new p8({typeName:M.ZodSymbol,...pM(e)});class me extends pZ{_parse(e){if(this._getType(e)!==pC.undefined){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.undefined,received:t.parsedType}),pq}return pA(e.data)}}me.create=e=>new me({typeName:M.ZodUndefined,...pM(e)});class mt extends pZ{_parse(e){if(this._getType(e)!==pC.null){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.null,received:t.parsedType}),pq}return pA(e.data)}}mt.create=e=>new mt({typeName:M.ZodNull,...pM(e)});class mr extends pZ{constructor(){super(...arguments),this._any=!0}_parse(e){return pA(e.data)}}mr.create=e=>new mr({typeName:M.ZodAny,...pM(e)});class mi extends pZ{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pA(e.data)}}mi.create=e=>new mi({typeName:M.ZodUnknown,...pM(e)});class mn extends pZ{_parse(e){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.never,received:t.parsedType}),pq}}mn.create=e=>new mn({typeName:M.ZodNever,...pM(e)});class mo extends pZ{_parse(e){if(this._getType(e)!==pC.undefined){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.void,received:t.parsedType}),pq}return pA(e.data)}}mo.create=e=>new mo({typeName:M.ZodVoid,...pM(e)});class ma extends pZ{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==pC.array)return pE(t,{code:pT.invalid_type,expected:pC.array,received:t.parsedType}),pq;if(null!==i.exactLength){let e=t.data.length>i.exactLength.value,n=t.data.length<i.exactLength.value;(e||n)&&(pE(t,{code:e?pT.too_big:pT.too_small,minimum:n?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(null!==i.minLength&&t.data.length<i.minLength.value&&(pE(t,{code:pT.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),null!==i.maxLength&&t.data.length>i.maxLength.value&&(pE(t,{code:pT.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>i.type._parseAsync(new pL(t,e,t.path,r)))).then(e=>pI.mergeArray(r,e));let n=[...t.data].map((e,r)=>i.type._parseSync(new pL(t,e,t.path,r)));return pI.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new ma({...this._def,minLength:{value:e,message:N.toString(t)}})}max(e,t){return new ma({...this._def,maxLength:{value:e,message:N.toString(t)}})}length(e,t){return new ma({...this._def,exactLength:{value:e,message:N.toString(t)}})}nonempty(e){return this.min(1,e)}}ma.create=(e,t)=>new ma({type:e,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...pM(t)});class ms extends pZ{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=z.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==pC.object){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.object,received:t.parsedType}),pq}let{status:t,ctx:r}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof mn&&"strip"===this._def.unknownKeys))for(let e in r.data)n.includes(e)||o.push(e);let a=[];for(let e of n){let t=i[e],n=r.data[e];a.push({key:{status:"valid",value:e},value:t._parse(new pL(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof mn){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of o)a.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)o.length>0&&(pE(r,{code:pT.unrecognized_keys,keys:o}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of o){let i=r.data[t];a.push({key:{status:"valid",value:t},value:e._parse(new pL(r,i,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of a){let r=await t.key,i=await t.value;e.push({key:r,value:i,alwaysSet:t.alwaysSet})}return e}).then(e=>pI.mergeObjectSync(t,e)):pI.mergeObjectSync(t,a)}get shape(){return this._def.shape()}strict(e){return N.errToObj,new ms({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let i=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:N.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new ms({...this._def,unknownKeys:"strip"})}passthrough(){return new ms({...this._def,unknownKeys:"passthrough"})}extend(e){return new ms({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ms({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:M.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ms({...this._def,catchall:e})}pick(e){let t={};for(let r of z.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new ms({...this._def,shape:()=>t})}omit(e){let t={};for(let r of z.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new ms({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ms){let r={};for(let i in t.shape){let n=t.shape[i];r[i]=mb.create(e(n))}return new ms({...t._def,shape:()=>r})}if(t instanceof ma)return new ma({...t._def,type:e(t.element)});if(t instanceof mb)return mb.create(e(t.unwrap()));if(t instanceof mS)return mS.create(e(t.unwrap()));if(t instanceof mu)return mu.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of z.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new ms({...this._def,shape:()=>t})}required(e){let t={};for(let r of z.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof mb;)e=e._def.innerType;t[r]=e}return new ms({...this._def,shape:()=>t})}keyof(){return mf(z.objectKeys(this.shape))}}ms.create=(e,t)=>new ms({shape:()=>e,unknownKeys:"strip",catchall:mn.create(),typeName:M.ZodObject,...pM(t)}),ms.strictCreate=(e,t)=>new ms({shape:()=>e,unknownKeys:"strict",catchall:mn.create(),typeName:M.ZodObject,...pM(t)}),ms.lazycreate=(e,t)=>new ms({shape:e,unknownKeys:"strip",catchall:mn.create(),typeName:M.ZodObject,...pM(t)});class ml extends pZ{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new pP(e.ctx.common.issues));return pE(t,{code:pT.invalid_union,unionErrors:r}),pq});{let e,i=[];for(let n of r){let r={...t,common:{...t.common,issues:[]},parent:null},o=n._parseSync({data:t.data,path:t.path,parent:r});if("valid"===o.status)return o;"dirty"!==o.status||e||(e={result:o,ctx:r}),r.common.issues.length&&i.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let n=i.map(e=>new pP(e));return pE(t,{code:pT.invalid_union,unionErrors:n}),pq}}get options(){return this._def.options}}ml.create=(e,t)=>new ml({options:e,typeName:M.ZodUnion,...pM(t)});class mc extends pZ{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=(e,i)=>{if("aborted"===e.status||"aborted"===i.status)return pq;let n=function e(t,r){let i=p$(t),n=p$(r);if(t===r)return{valid:!0,data:t};if(i===pC.object&&n===pC.object){let i=z.objectKeys(r),n=z.objectKeys(t).filter(e=>-1!==i.indexOf(e)),o={...t,...r};for(let i of(Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__,n)){if("__proto__"===i)continue;let n=e(t[i],r[i]);if(!n.valid)return{valid:!1};o[i]=n.data}return{valid:!0,data:o}}if(i===pC.array&&n===pC.array){if(t.length!==r.length)return{valid:!1};let i=[];for(let n=0;n<t.length;n++){let o=e(t[n],r[n]);if(!o.valid)return{valid:!1};i.push(o.data)}return{valid:!0,data:i}}if(i===pC.date&&n===pC.date&&+t==+r)return{valid:!0,data:t};return{valid:!1}}(e.value,i.value);return n.valid?(("dirty"===e.status||"dirty"===i.status)&&t.dirty(),{status:t.value,value:n.data}):(pE(r,{code:pT.invalid_intersection_types}),pq)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>i(e,t)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}mc.create=(e,t,r)=>new mc({left:e,right:t,typeName:M.ZodIntersection,...pM(r)});class mu extends pZ{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pC.array)return pE(r,{code:pT.invalid_type,expected:pC.array,received:r.parsedType}),pq;if(r.data.length<this._def.items.length)return pE(r,{code:pT.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pq;!this._def.rest&&r.data.length>this._def.items.length&&(pE(r,{code:pT.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...r.data].map((e,t)=>{let i=this._def.items[t]||this._def.rest;return i?i._parse(new pL(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(i).then(e=>pI.mergeArray(t,e)):pI.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new mu({...this._def,rest:e})}}mu.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new mu({items:e,typeName:M.ZodTuple,rest:null,...pM(t)})};class md extends pZ{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pC.map)return pE(r,{code:pT.invalid_type,expected:pC.map,received:r.parsedType}),pq;let i=this._def.keyType,n=this._def.valueType,o=[...r.data.entries()].map(([e,t],o)=>({key:i._parse(new pL(r,e,r.path,[o,"key"])),value:n._parse(new pL(r,t,r.path,[o,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of o){let i=await r.key,n=await r.value;if("aborted"===i.status||"aborted"===n.status)return pq;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of o){let i=r.key,n=r.value;if("aborted"===i.status||"aborted"===n.status)return pq;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}}}}md.create=(e,t,r)=>new md({valueType:t,keyType:e,typeName:M.ZodMap,...pM(r)});class mp extends pZ{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pC.set)return pE(r,{code:pT.invalid_type,expected:pC.set,received:r.parsedType}),pq;let i=this._def;null!==i.minSize&&r.data.size<i.minSize.value&&(pE(r,{code:pT.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),null!==i.maxSize&&r.data.size>i.maxSize.value&&(pE(r,{code:pT.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let n=this._def.valueType;function o(e){let r=new Set;for(let i of e){if("aborted"===i.status)return pq;"dirty"===i.status&&t.dirty(),r.add(i.value)}return{status:t.value,value:r}}let a=[...r.data.values()].map((e,t)=>n._parse(new pL(r,e,r.path,t)));return r.common.async?Promise.all(a).then(e=>o(e)):o(a)}min(e,t){return new mp({...this._def,minSize:{value:e,message:N.toString(t)}})}max(e,t){return new mp({...this._def,maxSize:{value:e,message:N.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}mp.create=(e,t)=>new mp({valueType:e,minSize:null,maxSize:null,typeName:M.ZodSet,...pM(t)});class mm extends pZ{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}mm.create=(e,t)=>new mm({getter:e,typeName:M.ZodLazy,...pM(t)});class mh extends pZ{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return pE(t,{received:t.data,code:pT.invalid_literal,expected:this._def.value}),pq}return{status:"valid",value:e.data}}get value(){return this._def.value}}function mf(e,t){return new mg({values:e,typeName:M.ZodEnum,...pM(t)})}mh.create=(e,t)=>new mh({value:e,typeName:M.ZodLiteral,...pM(t)});class mg extends pZ{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return pE(t,{expected:z.joinValues(r),received:t.parsedType,code:pT.invalid_type}),pq}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return pE(t,{received:t.data,code:pT.invalid_enum_value,options:r}),pq}return pA(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return mg.create(e,{...this._def,...t})}exclude(e,t=this._def){return mg.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}mg.create=mf;class my extends pZ{_parse(e){let t=z.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==pC.string&&r.parsedType!==pC.number){let e=z.objectValues(t);return pE(r,{expected:z.joinValues(e),received:r.parsedType,code:pT.invalid_type}),pq}if(this._cache||(this._cache=new Set(z.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=z.objectValues(t);return pE(r,{received:r.data,code:pT.invalid_enum_value,options:e}),pq}return pA(e.data)}get enum(){return this._def.values}}my.create=(e,t)=>new my({values:e,typeName:M.ZodNativeEnum,...pM(t)});class mv extends pZ{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==pC.promise&&!1===t.common.async?(pE(t,{code:pT.invalid_type,expected:pC.promise,received:t.parsedType}),pq):pA((t.parsedType===pC.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}mv.create=(e,t)=>new mv({type:e,typeName:M.ZodPromise,...pM(t)});class m_ extends pZ{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,n={addIssue:e=>{pE(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===i.type){let e=i.transform(r.data,n);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return pq;let i=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===i.status?pq:"dirty"===i.status||"dirty"===t.value?pj(i.value):i});{if("aborted"===t.value)return pq;let i=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===i.status?pq:"dirty"===i.status||"dirty"===t.value?pj(i.value):i}}if("refinement"===i.type){let e=e=>{let t=i.refinement(e,n);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?pq:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===i.status?pq:("dirty"===i.status&&t.dirty(),e(i.value),{status:t.value,value:i.value})}}if("transform"===i.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>"valid"!==e.status?pq:Promise.resolve(i.transform(e.value,n)).then(e=>({status:t.value,value:e})));else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if("valid"!==e.status)return pq;let o=i.transform(e.value,n);if(o instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}z.assertNever(i)}}m_.create=(e,t,r)=>new m_({schema:e,typeName:M.ZodEffects,effect:t,...pM(r)}),m_.createWithPreprocess=(e,t,r)=>new m_({schema:t,effect:{type:"preprocess",transform:e},typeName:M.ZodEffects,...pM(r)});class mb extends pZ{_parse(e){return this._getType(e)===pC.undefined?pA(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mb.create=(e,t)=>new mb({innerType:e,typeName:M.ZodOptional,...pM(t)});class mS extends pZ{_parse(e){return this._getType(e)===pC.null?pA(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mS.create=(e,t)=>new mS({innerType:e,typeName:M.ZodNullable,...pM(t)});class mw extends pZ{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===pC.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}mw.create=(e,t)=>new mw({innerType:e,typeName:M.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...pM(t)});class mR extends pZ{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return pz(i)?i.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new pP(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new pP(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}mR.create=(e,t)=>new mR({innerType:e,typeName:M.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...pM(t)});class mk extends pZ{_parse(e){if(this._getType(e)!==pC.nan){let t=this._getOrReturnCtx(e);return pE(t,{code:pT.invalid_type,expected:pC.nan,received:t.parsedType}),pq}return{status:"valid",value:e.data}}}mk.create=e=>new mk({typeName:M.ZodNaN,...pM(e)}),Symbol("zod_brand");class mx extends pZ{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class mC extends pZ{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?pq:"dirty"===e.status?(t.dirty(),pj(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?pq:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new mC({in:e,out:t,typeName:M.ZodPipeline})}}class m$ extends pZ{_parse(e){let t=this._def.innerType._parse(e),r=e=>("valid"===e.status&&(e.value=Object.freeze(e.value)),e);return pz(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}m$.create=(e,t)=>new m$({innerType:e,typeName:M.ZodReadonly,...pM(t)}),ms.lazycreate,(I=M||(M={})).ZodString="ZodString",I.ZodNumber="ZodNumber",I.ZodNaN="ZodNaN",I.ZodBigInt="ZodBigInt",I.ZodBoolean="ZodBoolean",I.ZodDate="ZodDate",I.ZodSymbol="ZodSymbol",I.ZodUndefined="ZodUndefined",I.ZodNull="ZodNull",I.ZodAny="ZodAny",I.ZodUnknown="ZodUnknown",I.ZodNever="ZodNever",I.ZodVoid="ZodVoid",I.ZodArray="ZodArray",I.ZodObject="ZodObject",I.ZodUnion="ZodUnion",I.ZodDiscriminatedUnion="ZodDiscriminatedUnion",I.ZodIntersection="ZodIntersection",I.ZodTuple="ZodTuple",I.ZodRecord="ZodRecord",I.ZodMap="ZodMap",I.ZodSet="ZodSet",I.ZodFunction="ZodFunction",I.ZodLazy="ZodLazy",I.ZodLiteral="ZodLiteral",I.ZodEnum="ZodEnum",I.ZodEffects="ZodEffects",I.ZodNativeEnum="ZodNativeEnum",I.ZodOptional="ZodOptional",I.ZodNullable="ZodNullable",I.ZodDefault="ZodDefault",I.ZodCatch="ZodCatch",I.ZodPromise="ZodPromise",I.ZodBranded="ZodBranded",I.ZodPipeline="ZodPipeline",I.ZodReadonly="ZodReadonly";let mT=p4.create;p5.create,mk.create,p3.create,p6.create,p7.create,p8.create,me.create,mt.create,mr.create,mi.create,mn.create,mo.create,ma.create;let mP=ms.create;ms.strictCreate,ml.create,mc.create,mu.create,md.create,mp.create,mm.create,mh.create,mg.create,my.create,mv.create,m_.create,mb.create,mS.create,m_.createWithPreprocess,mC.create;let mO=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function mE(e){if("openAi"!==e.target)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?mO(t,e.currentPath):t.join("/")}}function mI(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function mq(e,t,r,i,n){e[t]=r,mI(e,t,i,n)}function mj(e,t){return m1(e.type._def,t)}let mA=/^[cC][^\s-]{8,}$/,mz=/^[0-9a-z]+$/,mL=/^[0-9A-HJKMNP-TV-Z]{26}$/,mN=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,mM=()=>(void 0===k&&(k=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),k),mZ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,mU=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mF=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mH=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mD=/^[a-zA-Z0-9_-]{21}$/,mV=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function mJ(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":mq(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":mq(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":mG(r,"email",i.message,t);break;case"format:idn-email":mG(r,"idn-email",i.message,t);break;case"pattern:zod":mK(r,mN,i.message,t)}break;case"url":mG(r,"uri",i.message,t);break;case"uuid":mG(r,"uuid",i.message,t);break;case"regex":mK(r,i.regex,i.message,t);break;case"cuid":mK(r,mA,i.message,t);break;case"cuid2":mK(r,mz,i.message,t);break;case"startsWith":mK(r,RegExp(`^${mB(i.value,t)}`),i.message,t);break;case"endsWith":mK(r,RegExp(`${mB(i.value,t)}$`),i.message,t);break;case"datetime":mG(r,"date-time",i.message,t);break;case"date":mG(r,"date",i.message,t);break;case"time":mG(r,"time",i.message,t);break;case"duration":mG(r,"duration",i.message,t);break;case"length":mq(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t),mq(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":mK(r,RegExp(mB(i.value,t)),i.message,t);break;case"ip":"v6"!==i.version&&mG(r,"ipv4",i.message,t),"v4"!==i.version&&mG(r,"ipv6",i.message,t);break;case"base64url":mK(r,mH,i.message,t);break;case"jwt":mK(r,mV,i.message,t);break;case"cidr":"v6"!==i.version&&mK(r,mZ,i.message,t),"v4"!==i.version&&mK(r,mU,i.message,t);break;case"emoji":mK(r,mM(),i.message,t);break;case"ulid":mK(r,mL,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":mG(r,"binary",i.message,t);break;case"contentEncoding:base64":mq(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":mK(r,mF,i.message,t)}break;case"nanoid":mK(r,mD,i.message,t)}return r}function mB(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)mW.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}let mW=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function mG(e,t,r,i){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&i.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&i.errorMessages&&{errorMessage:{format:r}}})):mq(e,"format",t,r,i)}function mK(e,t,r,i){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&i.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:mY(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):mq(e,"pattern",mY(t,i),r,i)}function mY(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source,n="",o=!1,a=!1,s=!1;for(let e=0;e<i.length;e++){if(o){n+=i[e],o=!1;continue}if(r.i){if(a){if(i[e].match(/[a-z]/)){s?(n+=i[e],n+=`${i[e-2]}-${i[e]}`.toUpperCase(),s=!1):"-"===i[e+1]&&i[e+2]?.match(/[a-z]/)?(n+=i[e],s=!0):n+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){n+=`[${i[e]}${i[e].toUpperCase()}]`;continue}}if(r.m){if("^"===i[e]){n+=`(^|(?<=[\r
|
|
74
74
|
]))`;continue}else if("$"===i[e]){n+=`($|(?=[\r
|
|
75
75
|
]))`;continue}}if(r.s&&"."===i[e]){n+=a?`${i[e]}\r
|
|
76
76
|
`:`[${i[e]}\r
|
|
77
|
-
]`;continue}n+=i[e],"\\"===i[e]?o=!0:a&&"]"===i[e]?a=!1:a||"["!==i[e]||(a=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function mB(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===M.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:mK(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??mC(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:mK(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===M.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=mU(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName===M.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===M.ZodBranded&&e.keyType._def.type._def.typeName===M.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=mP(e.keyType._def,t);return{...r,propertyNames:n}}return r}let mW={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},mG=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>mK(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function mK(e,t,r=!1){let i=t.seen.get(e);if(t.override){let n=t.override?.(e,t,i,r);if(n!==p_)return n}if(i&&!r){let e=mY(i,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let o=((e,t,r)=>{switch(t){case M.ZodString:return mU(e,r);case M.ZodNumber:let i={type:"number"};if(!e.checks)return i;for(let t of e.checks)switch(t.kind){case"int":i.type="integer",m$(i,"type",t.message,r);break;case"min":"jsonSchema7"===r.target?t.inclusive?mT(i,"minimum",t.value,t.message,r):mT(i,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(i.exclusiveMinimum=!0),mT(i,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?mT(i,"maximum",t.value,t.message,r):mT(i,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(i.exclusiveMaximum=!0),mT(i,"maximum",t.value,t.message,r));break;case"multipleOf":mT(i,"multipleOf",t.value,t.message,r)}return i;case M.ZodObject:return function(e,t){let r="openAi"===t.target,i={type:"object",properties:{}},n=[],o=e.shape();for(let e in o){let a=o[e];if(void 0===a||void 0===a._def)continue;let s=function(e){try{return e.isOptional()}catch{return!0}}(a);s&&r&&("ZodOptional"===a._def.typeName&&(a=a._def.innerType),a.isNullable()||(a=a.nullable()),s=!1);let l=mK(a._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==l&&(i.properties[e]=l,s||n.push(e))}n.length&&(i.required=n);let a=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return mK(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==a&&(i.additionalProperties=a),i}(e,r);case M.ZodBigInt:let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let t of e.checks)switch(t.kind){case"min":"jsonSchema7"===r.target?t.inclusive?mT(n,"minimum",t.value,t.message,r):mT(n,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(n.exclusiveMinimum=!0),mT(n,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?mT(n,"maximum",t.value,t.message,r):mT(n,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(n.exclusiveMaximum=!0),mT(n,"maximum",t.value,t.message,r));break;case"multipleOf":mT(n,"multipleOf",t.value,t.message,r)}return n;case M.ZodBoolean:return{type:"boolean"};case M.ZodDate:return function e(t,r,i){let n=i??r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,n)=>e(t,r,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":var o=t,a=r;let s={type:"integer",format:"unix-time"};if("openApi3"===a.target)return s;for(let e of o.checks)switch(e.kind){case"min":mT(s,"minimum",e.value,e.message,a);break;case"max":mT(s,"maximum",e.value,e.message,a)}return s}}(e,r);case M.ZodUndefined:return{not:mC(r)};case M.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case M.ZodArray:let o;return o={type:"array"},e.type?._def&&e.type?._def?.typeName!==M.ZodAny&&(o.items=mK(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&mT(o,"minItems",e.minLength.value,e.minLength.message,r),e.maxLength&&mT(o,"maxItems",e.maxLength.value,e.maxLength.message,r),e.exactLength&&(mT(o,"minItems",e.exactLength.value,e.exactLength.message,r),mT(o,"maxItems",e.exactLength.value,e.exactLength.message,r)),o;case M.ZodUnion:case M.ZodDiscriminatedUnion:if("openApi3"===r.target)return mG(e,r);let a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every(e=>e._def.typeName in mW&&(!e._def.checks||!e._def.checks.length))){let e=a.reduce((e,t)=>{let r=mW[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(a.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=a.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===a.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:a.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(a.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:a.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return mG(e,r);case M.ZodIntersection:let s,l,c;return s=[mK(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),mK(e.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(e=>!!e),l="jsonSchema2019-09"===r.target?{unevaluatedProperties:!1}:void 0,c=[],s.forEach(e=>{if((!("type"in e)||"string"!==e.type)&&"allOf"in e)c.push(...e.allOf),void 0===e.unevaluatedProperties&&(l=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...i}=e;t=i}else l=void 0;c.push(t)}}),c.length?{allOf:c,...l}:void 0;case M.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>mK(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:mK(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>mK(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case M.ZodRecord:return mB(e,r);case M.ZodLiteral:let u;return"bigint"!=(u=typeof e.value)&&"number"!==u&&"boolean"!==u&&"string"!==u?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===r.target?{type:"bigint"===u?"integer":u,enum:[e.value]}:{type:"bigint"===u?"integer":u,const:e.value};case M.ZodEnum:return{type:"string",enum:Array.from(e.values)};case M.ZodNativeEnum:let d,p,m;return d=e.values,{type:1===(m=Array.from(new Set((p=Object.keys(e.values).filter(e=>"number"!=typeof d[d[e]]).map(e=>d[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:p};case M.ZodNullable:if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===r.target?{type:mW[e.innerType._def.typeName],nullable:!0}:{type:[mW[e.innerType._def.typeName],"null"]};if("openApi3"===r.target){let t=mK(e.innerType._def,{...r,currentPath:[...r.currentPath]});return t&&"$ref"in t?{allOf:[t],nullable:!0}:t&&{...t,nullable:!0}}let h=mK(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return h&&{anyOf:[h,{type:"null"}]};case M.ZodOptional:if(r.currentPath.toString()===r.propertyPath?.toString())return mK(e.innerType._def,r);let f=mK(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return f?{anyOf:[{not:mC(r)},f]}:mC(r);case M.ZodMap:if("record"===r.mapStrategy)return mB(e,r);return{type:"array",maxItems:125,items:{type:"array",items:[mK(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||mC(r),mK(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||mC(r)],minItems:2,maxItems:2}};case M.ZodSet:let g;return g={type:"array",uniqueItems:!0,items:mK(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&mT(g,"minItems",e.minSize.value,e.minSize.message,r),e.maxSize&&mT(g,"maxItems",e.maxSize.value,e.maxSize.message,r),g;case M.ZodLazy:return()=>e.getter()._def;case M.ZodPromise:return mK(e.type._def,r);case M.ZodNaN:case M.ZodNever:return"openAi"===r.target?void 0:{not:mC({...r,currentPath:[...r.currentPath,"not"]})};case M.ZodEffects:return"input"===r.effectStrategy?mK(e.schema._def,r):mC(r);case M.ZodAny:case M.ZodUnknown:return mC(r);case M.ZodDefault:return{...mK(e.innerType._def,r),default:e.defaultValue()};case M.ZodBranded:return mP(e,r);case M.ZodReadonly:case M.ZodCatch:return mK(e.innerType._def,r);case M.ZodPipeline:if("input"===r.pipeStrategy)return mK(e.in._def,r);if("output"===r.pipeStrategy)return mK(e.out._def,r);let y=mK(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),v=mK(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",y?"1":"0"]});return{allOf:[y,v].filter(e=>void 0!==e)};case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:default:return}})(e,e.typeName,t),a="function"==typeof o?mK(o(),t):o;if(a&&mX(e,t,a),t.postProcess){let r=t.postProcess(a,e,t);return n.jsonSchema=a,r}return n.jsonSchema=a,a}let mY=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:mx(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),mC(t);return"seen"===t.$refStrategy?mC(t):void 0}},mX=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function mQ(e,t={}){let{strict:r=!1}=t,i=Object.entries(e),n=e=>({target:t})=>{let n={},o=[];for(let[r,a]of i)n[r]=function(e,t,r){let i=e["~standard"];if(i.jsonSchema)return i.jsonSchema[r]({target:t});if("zod"===e["~standard"].vendor&&!("_zod"in e)&&"_def"in e){let r=((e,t)=>{let r,i,n=(i=void 0!==(r="string"==typeof t?{...pb,name:t}:{...pb,...t}).name?[...r.basePath,r.definitionPath,r.name]:r.basePath,{...r,flags:{hasReferencedOpenAiAnyType:!1},currentPath:i,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([e,t])=>[t._def,{def:t._def,path:[...r.basePath,r.definitionPath,e],jsonSchema:void 0}]))}),o="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:mK(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??mC(n)}),{}):void 0,a="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=mK(e._def,void 0===a?n:{...n,currentPath:[...n.basePath,n.definitionPath,a]},!1)??mC(n),l="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==l&&(s.title=l),n.flags.hasReferencedOpenAiAnyType&&(o||(o={}),o[n.openAiAnyTypeName]||(o[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===n.$refStrategy?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));let c=void 0===a?o?{...s,[n.definitionPath]:o}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,a].join("/"),[n.definitionPath]:{...o,[a]:s}};return"jsonSchema7"===n.target?c.$schema="http://json-schema.org/draft-07/schema#":("jsonSchema2019-09"===n.target||"openAi"===n.target)&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===n.target&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c})(e,{$refStrategy:"none",target:"openapi-3.0"===t?"openApi3":"jsonSchema7"});return delete r.$schema,r}if("zod"===i.vendor&&"_zod"in e)try{let t=nn(e);return delete t.$schema,t}catch(e){throw Error(`Failed to convert a zod schema to JSON Schema (zod v4 without "~standard.jsonSchema"). Upgrade to zod >= 4.2.0. Original error: ${e instanceof Error?e.message:String(e)}`)}throw Error(`Schema library "${i.vendor}" cannot be converted to JSON Schema. Use zod v3 (>= 3.25.76), zod >= 4.2.0, or a Standard Schema library implementing "~standard.jsonSchema".`)}(a,t,e),!function(e,t){if("function"!=typeof e.safeParse)return!1;try{let r=e.safeParse(void 0);return r.success&&("input"===t||void 0===r.data)}catch{return!1}}(a,e)&&o.push(r);let a={type:"object",properties:n};return o.length>0&&(a.required=o),r&&(a.additionalProperties=!1),a};return{shape:e,"~standard":{version:1,vendor:"xmcp",validate:async t=>{if("object"!=typeof t||null===t||Array.isArray(t))return{issues:[{message:"Expected an object."}]};let n={},o=[];for(let[e,r]of i){let i=await r["~standard"].validate(t[e]);if(i.issues)for(let t of i.issues)o.push({message:t.message,path:[e,...t.path??[]]});else(e in t||void 0!==i.value)&&(n[e]=i.value)}if(r)for(let r of Object.keys(t))r in e||o.push({message:`Unrecognized key: "${r}"`,path:[r]});return o.length>0?{issues:o}:{value:n}},jsonSchema:{input:n("input"),output:n("output")}}}}function m0(e){let t={};return!function e(r,i=""){if(r&&"object"==typeof r)for(let[n,o]of Object.entries(r)){let r=i?`${i}/${n}`:n;!o||"object"!=typeof o||Array.isArray(o)||o instanceof Date||o instanceof RegExp?t[r]=o:e(o,r)}}(e),t}let m1=["ui/resourceUri","resourceUri","visibility"],m2=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"];function m9(e){return"object"==typeof e&&null!==e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&"object"==typeof t&&null!==t&&"parse"in t&&"function"==typeof t.parse)}function m4(e){return(e.split("/").pop()||e).replace(/\.[^/.]+$/,"")}function m5(e,t,r){return e.names?.includes(t)===!0||e.tags?.some(e=>r.includes(e))===!0}function m3(e,t){return t?new Map([...e].filter(([e,{metadata:r}])=>{if(r?.enabled===!1)return!1;let i=r?.name??m4(e),n=r?.tags??[];return(!t.include||m5(t.include,i,n))&&(!t.exclude||!m5(t.exclude,i,n))})):e}function m6(e){return Error(`[xmcp] Invalid prompt file: ${e}
|
|
78
|
-
-> Default export must be a prompt handler function.`)}let
|
|
79
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} prompt${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function
|
|
80
|
-
-> Default export must be a resource handler function.`)}let
|
|
81
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} resource${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function
|
|
82
|
-
-> Default export must be a tool handler function.`)}let
|
|
83
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} tool${1===n?"":"s"} skipped due to empty files or missing default exports`)}}(),
|
|
77
|
+
]`;continue}n+=i[e],"\\"===i[e]?o=!0:a&&"]"===i[e]?a=!1:a||"["!==i[e]||(a=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function mX(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===M.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:m1(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??mE(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:m1(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===M.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=mJ(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName===M.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===M.ZodBranded&&e.keyType._def.type._def.typeName===M.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=mj(e.keyType._def,t);return{...r,propertyNames:n}}return r}let mQ={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},m0=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>m1(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function m1(e,t,r=!1){let i=t.seen.get(e);if(t.override){let n=t.override?.(e,t,i,r);if(n!==pk)return n}if(i&&!r){let e=m2(i,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let o=((e,t,r)=>{switch(t){case M.ZodString:return mJ(e,r);case M.ZodNumber:let i={type:"number"};if(!e.checks)return i;for(let t of e.checks)switch(t.kind){case"int":i.type="integer",mI(i,"type",t.message,r);break;case"min":"jsonSchema7"===r.target?t.inclusive?mq(i,"minimum",t.value,t.message,r):mq(i,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(i.exclusiveMinimum=!0),mq(i,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?mq(i,"maximum",t.value,t.message,r):mq(i,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(i.exclusiveMaximum=!0),mq(i,"maximum",t.value,t.message,r));break;case"multipleOf":mq(i,"multipleOf",t.value,t.message,r)}return i;case M.ZodObject:return function(e,t){let r="openAi"===t.target,i={type:"object",properties:{}},n=[],o=e.shape();for(let e in o){let a=o[e];if(void 0===a||void 0===a._def)continue;let s=function(e){try{return e.isOptional()}catch{return!0}}(a);s&&r&&("ZodOptional"===a._def.typeName&&(a=a._def.innerType),a.isNullable()||(a=a.nullable()),s=!1);let l=m1(a._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==l&&(i.properties[e]=l,s||n.push(e))}n.length&&(i.required=n);let a=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return m1(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==a&&(i.additionalProperties=a),i}(e,r);case M.ZodBigInt:let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let t of e.checks)switch(t.kind){case"min":"jsonSchema7"===r.target?t.inclusive?mq(n,"minimum",t.value,t.message,r):mq(n,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(n.exclusiveMinimum=!0),mq(n,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?mq(n,"maximum",t.value,t.message,r):mq(n,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(n.exclusiveMaximum=!0),mq(n,"maximum",t.value,t.message,r));break;case"multipleOf":mq(n,"multipleOf",t.value,t.message,r)}return n;case M.ZodBoolean:return{type:"boolean"};case M.ZodDate:return function e(t,r,i){let n=i??r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,n)=>e(t,r,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":var o=t,a=r;let s={type:"integer",format:"unix-time"};if("openApi3"===a.target)return s;for(let e of o.checks)switch(e.kind){case"min":mq(s,"minimum",e.value,e.message,a);break;case"max":mq(s,"maximum",e.value,e.message,a)}return s}}(e,r);case M.ZodUndefined:return{not:mE(r)};case M.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case M.ZodArray:let o;return o={type:"array"},e.type?._def&&e.type?._def?.typeName!==M.ZodAny&&(o.items=m1(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&mq(o,"minItems",e.minLength.value,e.minLength.message,r),e.maxLength&&mq(o,"maxItems",e.maxLength.value,e.maxLength.message,r),e.exactLength&&(mq(o,"minItems",e.exactLength.value,e.exactLength.message,r),mq(o,"maxItems",e.exactLength.value,e.exactLength.message,r)),o;case M.ZodUnion:case M.ZodDiscriminatedUnion:if("openApi3"===r.target)return m0(e,r);let a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every(e=>e._def.typeName in mQ&&(!e._def.checks||!e._def.checks.length))){let e=a.reduce((e,t)=>{let r=mQ[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(a.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=a.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===a.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:a.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(a.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:a.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return m0(e,r);case M.ZodIntersection:let s,l,c;return s=[m1(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),m1(e.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(e=>!!e),l="jsonSchema2019-09"===r.target?{unevaluatedProperties:!1}:void 0,c=[],s.forEach(e=>{if((!("type"in e)||"string"!==e.type)&&"allOf"in e)c.push(...e.allOf),void 0===e.unevaluatedProperties&&(l=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...i}=e;t=i}else l=void 0;c.push(t)}}),c.length?{allOf:c,...l}:void 0;case M.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>m1(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:m1(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>m1(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case M.ZodRecord:return mX(e,r);case M.ZodLiteral:let u;return"bigint"!=(u=typeof e.value)&&"number"!==u&&"boolean"!==u&&"string"!==u?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===r.target?{type:"bigint"===u?"integer":u,enum:[e.value]}:{type:"bigint"===u?"integer":u,const:e.value};case M.ZodEnum:return{type:"string",enum:Array.from(e.values)};case M.ZodNativeEnum:let d,p,m;return d=e.values,{type:1===(m=Array.from(new Set((p=Object.keys(e.values).filter(e=>"number"!=typeof d[d[e]]).map(e=>d[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:p};case M.ZodNullable:if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===r.target?{type:mQ[e.innerType._def.typeName],nullable:!0}:{type:[mQ[e.innerType._def.typeName],"null"]};if("openApi3"===r.target){let t=m1(e.innerType._def,{...r,currentPath:[...r.currentPath]});return t&&"$ref"in t?{allOf:[t],nullable:!0}:t&&{...t,nullable:!0}}let h=m1(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return h&&{anyOf:[h,{type:"null"}]};case M.ZodOptional:if(r.currentPath.toString()===r.propertyPath?.toString())return m1(e.innerType._def,r);let f=m1(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return f?{anyOf:[{not:mE(r)},f]}:mE(r);case M.ZodMap:if("record"===r.mapStrategy)return mX(e,r);return{type:"array",maxItems:125,items:{type:"array",items:[m1(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||mE(r),m1(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||mE(r)],minItems:2,maxItems:2}};case M.ZodSet:let g;return g={type:"array",uniqueItems:!0,items:m1(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&mq(g,"minItems",e.minSize.value,e.minSize.message,r),e.maxSize&&mq(g,"maxItems",e.maxSize.value,e.maxSize.message,r),g;case M.ZodLazy:return()=>e.getter()._def;case M.ZodPromise:return m1(e.type._def,r);case M.ZodNaN:case M.ZodNever:return"openAi"===r.target?void 0:{not:mE({...r,currentPath:[...r.currentPath,"not"]})};case M.ZodEffects:return"input"===r.effectStrategy?m1(e.schema._def,r):mE(r);case M.ZodAny:case M.ZodUnknown:return mE(r);case M.ZodDefault:return{...m1(e.innerType._def,r),default:e.defaultValue()};case M.ZodBranded:return mj(e,r);case M.ZodReadonly:case M.ZodCatch:return m1(e.innerType._def,r);case M.ZodPipeline:if("input"===r.pipeStrategy)return m1(e.in._def,r);if("output"===r.pipeStrategy)return m1(e.out._def,r);let y=m1(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),v=m1(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",y?"1":"0"]});return{allOf:[y,v].filter(e=>void 0!==e)};case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:default:return}})(e,e.typeName,t),a="function"==typeof o?m1(o(),t):o;if(a&&m9(e,t,a),t.postProcess){let r=t.postProcess(a,e,t);return n.jsonSchema=a,r}return n.jsonSchema=a,a}let m2=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:mO(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),mE(t);return"seen"===t.$refStrategy?mE(t):void 0}},m9=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function m4(e,t={}){let{strict:r=!1}=t,i=Object.entries(e),n=e=>({target:t})=>{let n={},o=[];for(let[r,a]of i)n[r]=function(e,t,r){let i=e["~standard"];if(i.jsonSchema)return i.jsonSchema[r]({target:t});if("zod"===e["~standard"].vendor&&!("_zod"in e)&&"_def"in e){let r=((e,t)=>{let r,i,n=(i=void 0!==(r="string"==typeof t?{...px,name:t}:{...px,...t}).name?[...r.basePath,r.definitionPath,r.name]:r.basePath,{...r,flags:{hasReferencedOpenAiAnyType:!1},currentPath:i,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([e,t])=>[t._def,{def:t._def,path:[...r.basePath,r.definitionPath,e],jsonSchema:void 0}]))}),o="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:m1(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??mE(n)}),{}):void 0,a="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=m1(e._def,void 0===a?n:{...n,currentPath:[...n.basePath,n.definitionPath,a]},!1)??mE(n),l="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==l&&(s.title=l),n.flags.hasReferencedOpenAiAnyType&&(o||(o={}),o[n.openAiAnyTypeName]||(o[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===n.$refStrategy?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));let c=void 0===a?o?{...s,[n.definitionPath]:o}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,a].join("/"),[n.definitionPath]:{...o,[a]:s}};return"jsonSchema7"===n.target?c.$schema="http://json-schema.org/draft-07/schema#":("jsonSchema2019-09"===n.target||"openAi"===n.target)&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===n.target&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c})(e,{$refStrategy:"none",target:"openapi-3.0"===t?"openApi3":"jsonSchema7"});return delete r.$schema,r}if("zod"===i.vendor&&"_zod"in e)try{let t=nn(e);return delete t.$schema,t}catch(e){throw Error(`Failed to convert a zod schema to JSON Schema (zod v4 without "~standard.jsonSchema"). Upgrade to zod >= 4.2.0. Original error: ${e instanceof Error?e.message:String(e)}`)}throw Error(`Schema library "${i.vendor}" cannot be converted to JSON Schema. Use zod v3 (>= 3.25.76), zod >= 4.2.0, or a Standard Schema library implementing "~standard.jsonSchema".`)}(a,t,e),!function(e,t){if("function"!=typeof e.safeParse)return!1;try{let r=e.safeParse(void 0);return r.success&&("input"===t||void 0===r.data)}catch{return!1}}(a,e)&&o.push(r);let a={type:"object",properties:n};return o.length>0&&(a.required=o),r&&(a.additionalProperties=!1),a};return{shape:e,"~standard":{version:1,vendor:"xmcp",validate:async t=>{if("object"!=typeof t||null===t||Array.isArray(t))return{issues:[{message:"Expected an object."}]};let n={},o=[];for(let[e,r]of i){let i=await r["~standard"].validate(t[e]);if(i.issues)for(let t of i.issues)o.push({message:t.message,path:[e,...t.path??[]]});else(e in t||void 0!==i.value)&&(n[e]=i.value)}if(r)for(let r of Object.keys(t))r in e||o.push({message:`Unrecognized key: "${r}"`,path:[r]});return o.length>0?{issues:o}:{value:n}},jsonSchema:{input:n("input"),output:n("output")}}}}function m5(e){let t={};return!function e(r,i=""){if(r&&"object"==typeof r)for(let[n,o]of Object.entries(r)){let r=i?`${i}/${n}`:n;!o||"object"!=typeof o||Array.isArray(o)||o instanceof Date||o instanceof RegExp?t[r]=o:e(o,r)}}(e),t}let m3=["ui/resourceUri","resourceUri","visibility"],m6=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"];function m7(e){return"object"==typeof e&&null!==e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&"object"==typeof t&&null!==t&&"parse"in t&&"function"==typeof t.parse)}function m8(e){return(e.split("/").pop()||e).replace(/\.[^/.]+$/,"")}function he(e,t,r){return e.names?.includes(t)===!0||e.tags?.some(e=>r.includes(e))===!0}function ht(e,t){return t?new Map([...e].filter(([e,{metadata:r}])=>{if(r?.enabled===!1)return!1;let i=r?.name??m8(e),n=r?.tags??[];return(!t.include||he(t.include,i,n))&&(!t.exclude||!he(t.exclude,i,n))})):e}function hr(e){return Error(`[xmcp] Invalid prompt file: ${e}
|
|
78
|
+
-> Default export must be a prompt handler function.`)}let hi=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load prompt file: ${t}
|
|
79
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} prompt${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function hn(e){return Error(`[xmcp] Invalid resource file: ${e}
|
|
80
|
+
-> Default export must be a resource handler function.`)}let ho=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load resource file: ${t}
|
|
81
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} resource${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function ha(e){let t=e.replace(/\\/g,"/");if(!t)throw Error("Invalid tool path: path is empty");let r=t.replace(/\.[^/.]+$/,"").replace(/\//g,"_");return{normalizedPath:t,baseName:r}}function hs(e){let t=e.split("/").filter(e=>""!==e),r=t.findIndex(e=>e.match(/^\(.+\)$/));if(-1===r)return null;let i=t[t.length-1];if(i&&i.match(/^\[.+\]\.ts$/))return null;let n=t[r].slice(1,-1),o=t.slice(r+1),a=o[o.length-1];if(a&&a.includes(".")){let e=a.split(".")[0];"index"!==e?o[o.length-1]=e:o.pop()}let s=[],l=[],c=o.map(e=>{if(!e.match(/^\[.+\]$/))return l.push(e),e;{let t=e.slice(1,-1);return s.push(t),`{${t}}`}}),u=`${n}://${c.join("/")}`,d=s.length>0?"template":"direct";return{filePath:e,uriTemplate:u,scheme:n,parameters:s,pathSegments:l,type:d}}let hl={ttlMs:0,cacheScope:"private"},hc=mP({cursor:mT().optional()}).passthrough().optional(),hu=mP({uri:mT()}).passthrough();function hd({uri:e,frontmatter:t,files:r}){return{uri:e,frontmatter:t,resources:r.map(({uri:e,digest:t,size:r})=>({uri:e,digest:t,size:r}))}}function hp(e){return Error(`[xmcp] Invalid tool file: ${e}
|
|
82
|
+
-> Default export must be a tool handler function.`)}let hm=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load tool file: ${t}
|
|
83
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} tool${1===n?"":"s"} skipped due to empty files or missing default exports`)}}(),hh=INJECTED_TOOLS,hf=INJECTED_PROMPTS,hg=INJECTED_RESOURCES,hy="u"<typeof INJECTED_SKILLS?[]:INJECTED_SKILLS??[],hv=SERVER_INFO,h_="This MCP server was bootstrapped with xmcp.",hb={cursor:`
|
|
84
84
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
85
85
|
<g clip-path="url(#cursor)">
|
|
86
86
|
<path d="M18.1937 4.73376L10.1872 0.111231C9.93007 -0.0372398 9.61283 -0.0372398 9.35573 0.111231L1.34956 4.73376C1.13344 4.85855 1 5.08934 1 5.33929V14.6606C1 14.9106 1.13344 15.1414 1.34956 15.2662L9.3561 19.8887C9.6132 20.0372 9.93044 20.0372 10.1875 19.8887L18.1941 15.2662C18.4102 15.1414 18.5436 14.9106 18.5436 14.6606V5.33929C18.5436 5.08934 18.4102 4.85855 18.1941 4.73376H18.1937ZM17.6908 5.71291L9.96164 19.1001C9.90939 19.1903 9.77145 19.1535 9.77145 19.049V10.2832C9.77145 10.108 9.67785 9.94603 9.526 9.85808L1.9348 5.47536C1.84459 5.42311 1.88143 5.28517 1.98592 5.28517H17.4442C17.6637 5.28517 17.8009 5.5231 17.6912 5.71329H17.6908V5.71291Z" fill="currentColor" />
|
|
@@ -135,7 +135,7 @@ data:
|
|
|
135
135
|
</clipPath>
|
|
136
136
|
</defs>
|
|
137
137
|
</svg>
|
|
138
|
-
`},
|
|
138
|
+
`},hS=String.raw`
|
|
139
139
|
:root {
|
|
140
140
|
color-scheme: dark;
|
|
141
141
|
--brand-white: #f7f7f7;
|
|
@@ -434,13 +434,13 @@ data:
|
|
|
434
434
|
clip: rect(0, 0, 0, 0);
|
|
435
435
|
border: 0;
|
|
436
436
|
}
|
|
437
|
-
`;function
|
|
437
|
+
`;function hw(e,t){let r={};if(void 0!==e.origin){if(!0===e.origin)t&&(r["Access-Control-Allow-Origin"]=t);else if(!1!==e.origin)if(Array.isArray(e.origin)){let i=t&&e.origin.includes(t)?t:e.origin[0]||"*";r["Access-Control-Allow-Origin"]=i}else r["Access-Control-Allow-Origin"]=String(e.origin)}return void 0!==e.methods&&(r["Access-Control-Allow-Methods"]=Array.isArray(e.methods)?e.methods.join(","):String(e.methods)),void 0!==e.allowedHeaders&&(r["Access-Control-Allow-Headers"]=Array.isArray(e.allowedHeaders)?e.allowedHeaders.join(","):String(e.allowedHeaders)),void 0!==e.exposedHeaders&&(r["Access-Control-Expose-Headers"]=Array.isArray(e.exposedHeaders)?e.exposedHeaders.join(","):String(e.exposedHeaders)),"boolean"==typeof e.credentials&&(r["Access-Control-Allow-Credentials"]=String(e.credentials)),"number"==typeof e.maxAge&&(r["Access-Control-Max-Age"]=String(e.maxAge)),r}let hR=HTTP_CORS_CONFIG;function hk(e,t){let r=new Headers(e.headers);for(let[e,i]of Object.entries(hw(hR,t)))r.set(e,i);return new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}let hx=HTTP_CONFIG,hC=TEMPLATE_CONFIG,h$=INJECTED_MIDDLEWARE,hT=null;function hP(e){return"function"==typeof e}function hO(e,...t){hx.debug&&console.log(`[Cloudflare-MCP] ${e}`,...t)}uV();let hE=function(e,t={}){var r;let{legacy:i,onerror:n,responseMode:o}=t,a=dE(t.maxRequestBodySize);if("function"==typeof i)throw TypeError("The 'legacy' option only accepts 'stateless' or 'reject', not a handler function. To serve 2025-era traffic with your own handler, route in user land with the exported isLegacyRequest(request) predicate in front of a strict (legacy: 'reject') handler.");let l=new Set,p=!1,m=e=>{try{n?.(e)}catch{}},h=t.bus??new d$(m),f={toolsChanged:()=>h.publish({kind:"tools_list_changed"}),promptsChanged:()=>h.publish({kind:"prompts_list_changed"}),resourcesChanged:()=>h.publish({kind:"resources_list_changed"}),resourceUpdated:e=>h.publish({kind:"resource_updated",uri:e})},g=function(e){let{bus:t,onerror:r}=e,i=e.maxSubscriptions??1024,n=e.keepAliveMs??15e3,o=new Set;return{serve:function(e,a,s,l){let c,u,d,p,m,h,f;if(o.size>=i)return r?.(Error(`subscriptions/listen refused: subscription limit reached (${i})`)),dT(e.id,-32603,"Subscription limit reached");let g=(m=cM(cN).validateRequest("subscriptions/listen",e)).ok?m.value.params?.notifications:void 0;if(void 0===g)return dT(e.id,-32602,"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");let y=(h={},f=e=>void 0===s||!0===e,!0===g.toolsListChanged&&f(s?.tools?.listChanged)&&(h.toolsListChanged=!0),!0===g.promptsListChanged&&f(s?.prompts?.listChanged)&&(h.promptsListChanged=!0),!0===g.resourcesListChanged&&f(s?.resources?.listChanged)&&(h.resourcesListChanged=!0),void 0!==g.resourceSubscriptions&&g.resourceSubscriptions.length>0&&f(s?.resources?.subscribe)&&(h.resourceSubscriptions=[...g.resourceSubscriptions]),h),v=e.id,_=new TextEncoder,b=!1,S=e=>{if(!b)try{c.enqueue(_.encode(e))}catch(e){r?.(e instanceof Error?e:Error(String(e)))}},w=(e,t)=>{S(`event: message
|
|
438
438
|
data: ${JSON.stringify({jsonrpc:"2.0",method:e,params:t})}
|
|
439
439
|
|
|
440
440
|
`)},R=e=>{if(!b){e&&S(`event: message
|
|
441
441
|
data: ${JSON.stringify({jsonrpc:"2.0",id:v,result:{resultType:"complete",_meta:{[oX]:v,[oK]:l}}})}
|
|
442
442
|
|
|
443
|
-
`),b=!0;try{u?.()}catch(e){r?.(e instanceof Error?e:Error(String(e)))}void 0!==d&&clearInterval(d),p?.(),o.delete(R);try{c.close()}catch{}}},k=new ReadableStream({start(e){c=e;let r=dP({method:"notifications/subscriptions/acknowledged",params:{notifications:y}},v);(w(r.method,r.params),0===Object.keys(y).length)?R(!0):(u=t.subscribe(e=>{if(b||!function(e,t){switch(t.kind){case"tools_list_changed":return!0===e.toolsListChanged;case"prompts_list_changed":return!0===e.promptsListChanged;case"resources_list_changed":return!0===e.resourcesListChanged;case"resource_updated":return void 0!==e.resourceSubscriptions&&e.resourceSubscriptions.includes(t.uri)}}(y,e))return;let t=dP(function(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed",...void 0!==e.params&&{params:e.params}};case"prompts_list_changed":return{method:"notifications/prompts/list_changed",...void 0!==e.params&&{params:e.params}};case"resources_list_changed":return{method:"notifications/resources/list_changed",...void 0!==e.params&&{params:e.params}};case"resource_updated":return{method:"notifications/resources/updated",params:{...e.params,uri:e.uri}}}}(e),v);w(t.method,t.params)}),d=dn(n,()=>S(": keepalive\n\n")),o.add(R))},cancel(){R(!1)}});if(void 0!==a)if(a.aborted)R(!1);else{let e=()=>R(!1);a.addEventListener("abort",e,{once:!0}),p=()=>a.removeEventListener("abort",e)}return new Response(k,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let e of o)e(!0)},get openCount(){return o.size}}}({bus:h,maxSubscriptions:t.maxSubscriptions??1024,keepAliveMs:t.keepAliveMs??15e3,onerror:m});"json"===o&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let y="reject"===i?void 0:(r=t.keepAliveMs,async(t,i)=>{if("POST"!==t.method.toUpperCase())return dA(405,-32e3,"Method not allowed.");try{let n=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:t}),o=new dq({sessionIdGenerator:void 0,...void 0!==r&&{keepAliveMs:r},...void 0!==a&&{maxRequestBodySize:a}});await n.connect(o);let s=()=>{o.close().catch(()=>{}),n.close().catch(()=>{})};t.signal?.addEventListener("abort",s,{once:!0});let l=await o.handleRequest(t,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(null===l.body||"text/event-stream"!==uM(l.headers.get("content-type")))return s(),l;let c=l.body.getReader(),u=!1,d=()=>{u||(u=!0,s())},p=new ReadableStream({pull:async e=>{try{let{done:t,value:r}=await c.read();if(t){d(),e.close();return}void 0!==r&&e.enqueue(r)}catch(t){d(),e.error(t)}},cancel:e=>(d(),c.cancel(e).catch(()=>{}))});return new Response(p,{status:l.status,statusText:l.statusText,headers:l.headers})}catch(e){try{m?.(dL(e))}catch{}return dN(dj(i?.parsedBody))}});return{fetch:async(r,i)=>{if(p)throw Error("This MCP handler has been closed");try{return await async function(r,i){let n=i?.authInfo;if("POST"===r.method.toUpperCase()&&!uZ(r.headers.get("content-type")))return m(Error("Unsupported Media Type: Content-Type must be application/json")),dA(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let p=await async function(e,t,r=!0,i=4194304){let n,o=e.method.toUpperCase(),a=t,s=e,l=!1;if("POST"===o){if(void 0===a){let t;r&&(s=e.clone());try{let r=await dI(e,i);if(r.tooLarge)return{step:"body-too-large"};t=r.text}catch{return{step:"unreadable-body"}}try{n=0===t.length?void 0:JSON.parse(t)}catch{l=!0}l||void 0===n||(a=n)}else n=a;if(l||void 0===n)return{step:"no-json-body",forwardRequest:s}}return{step:"classified",outcome:function(e){if("POST"!==(e={...e,...void 0!==e.protocolVersionHeader&&{protocolVersionHeader:ul(e.protocolVersionHeader)},...void 0!==e.mcpMethodHeader&&{mcpMethodHeader:ul(e.mcpMethodHeader)},...void 0!==e.mcpNameHeader&&{mcpNameHeader:ul(e.mcpNameHeader)}}).httpMethod.toUpperCase())return{kind:"legacy",reason:"http-method"};let t=e.body;if(Array.isArray(t)){if(0===t.length)return uo("jsonrpc-shape","empty-batch",400,new cv(cy.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let e of t){if(cB(uc(e)?e.params:void 0))return uo("jsonrpc-shape","batch-with-modern-element",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(cY(e)||cX(e)||cQ(e)||c0(e)))return uo("jsonrpc-shape","batch-with-invalid-element",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}return cQ(t)||c0(t)?{kind:"legacy",reason:"response"}:uc(t)&&cY(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,o=void 0!==n&&n>=lX;if("initialize"===i&&!function(e){if(!cB(e))return!1;let t=cW(e);if(void 0===t||!(t>=lX))return!1;let r=cJ(e);return void 0!==r&&0===cG(r).length}(r)){if(o)return ua("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let e=uc(r)&&"string"==typeof r.protocolVersion?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==e&&{requestedVersion:e}}}if(cB(r)){let o=cJ(r),a=(void 0===o?[]:cG(o))[0];if(void 0!==a)return uo("envelope","envelope-invalid",400,new cv(cy.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${a.key}: ${a.problem}`,{envelope:a}),!0);let s=cW(r);return void 0!==n&&void 0!==s&&n!==s?ua("header-body-version-mismatch",n,`the body envelope names protocol version ${s} but the MCP-Protocol-Version header names ${n}`):void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?ua("method-header-mismatch",e.mcpMethodHeader,`the body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"request",message:t,classification:uu(s)}}if(o){let e=cJ(r),t=cG(e??{}).filter(e=>"missing"===e.problem).map(e=>e.key),i=void 0===e?["_meta"]:t.length>0?t:[oW];return uo("envelope","modern-header-without-claim",400,new cv(cy.InvalidParams,`Invalid params: the MCP-Protocol-Version header names protocol revision ${n}, but the request is missing the required per-request envelope key(s): ${i.join(", ")}`,{envelope:{missing:i}}),!0)}return{kind:"legacy",reason:"no-claim",...void 0!==n&&{requestedVersion:n}}}(e,t):uc(t)&&cX(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,o=void 0!==n&&n>=lX;if(cB(r)){let o=cW(r);if(void 0===o){let e=cJ(r),t=(void 0===e?[]:cG(e)).find(e=>e.key===oW)??{key:oW,problem:"expected a protocol version string"};return uo("envelope","notification-envelope-invalid",400,new cv(cy.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${t.key}: ${t.problem}`,{envelope:t}),!0)}if(void 0!==n&&n!==o)return ua("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${o} but the MCP-Protocol-Version header names ${n}`);let a=uu(o);return"modern"===a.era&&void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?ua("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:a}}return o?void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?ua("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:{era:"modern",revision:n}}:{kind:"legacy",reason:"notification",...void 0!==n&&{requestedVersion:n}}}(e,t):uo("jsonrpc-shape","invalid-json-rpc-body",400,new cv(cy.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}({httpMethod:o,...dZ(e),...void 0!==n&&{body:n}}),body:n,parsedBody:a,forwardRequest:s}}(r,i?.parsedBody,!0,a);if("unreadable-body"===p.step)return dA(400,-32700,"Parse error: the request body could not be read");if("body-too-large"===p.step)return dA(413,-32e3,dE(a));if("no-json-body"===p.step)return void 0!==y?y(p.forwardRequest,{...void 0!==n&&{authInfo:n}}):dA(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:h,body:f,parsedBody:v,forwardRequest:_}=p;try{switch(h.kind){case"reject":return m(Error(`Rejected inbound request (${h.cell}): ${h.message}`)),dz(h,dj(f));case"modern":return await async function(r,i,n){var a,p;let h=r.classification.revision;if(void 0===h||!lQ.includes(h)){let e=new cS({supported:[...lQ],requested:h??"unknown"});return m(e),dA(400,e.code,e.message,e.data,dj(r.message))}let f=function(e,t){if("request"!==t.messageKind)return;let r=t.message.method;if(void 0===e.protocolVersionHeader){let e=t.classification.revision;return ua("version-header-missing","(missing)",void 0===e?"the body carries a modern per-request envelope but the required MCP-Protocol-Version header is absent":`the body envelope names protocol version ${e} but the required MCP-Protocol-Version header is absent`,"standard-header-validation")}if(void 0===e.mcpMethodHeader)return ua("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let i=function(e,t){let r=Object.hasOwn(us,e)?us[e]:void 0;if(void 0===r)return;let i=uc(t)?t[r]:void 0;return{field:r,value:"string"==typeof i?i:void 0}}(r,t.message.params);if(void 0===i)return;let{field:n,value:o}=i;if(void 0===e.mcpNameHeader){if(void 0===o)return;return ua("name-header-missing","(missing)",`the body carries params.${n}="${o}" but the required Mcp-Name header is absent`,"standard-header-validation")}let a=ul(e.mcpNameHeader),s=ut(a);return void 0===s?ua("name-header-invalid-encoding",a,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==o&&s!==o?ua("name-header-mismatch",a,`the body carries params.${n}="${o}" but the Mcp-Name header names "${s}"`,"standard-header-validation"):void 0}({httpMethod:i.method,...dZ(i)},r);if(void 0!==f)return m(Error(`Rejected inbound request (${f.cell}): ${f.message}`)),dz(f,dj(r.message));let y="request"===r.messageKind?cJ(r.message.params):void 0,v=y?.[oY];if("request"===r.messageKind){let e=Object.hasOwn(lG,a=r.message.method)?lG[a]:void 0;if(void 0!==e){let t=lY(e,v);if(void 0!==t){let e=new cw({requiredCapabilities:t});return m(e),dA(un[e.code]??400,e.code,e.message,e.data,r.message.id)}}}let _=await e({era:"modern",...void 0!==n&&{authInfo:n},requestInfo:i}),b=_ instanceof dy?_.server:_;if(dM(b),"request"===r.messageKind&&"subscriptions/listen"===r.message.method){let e=b.getCapabilities(),t=d(b);return _.close().catch(m),g.serve(r.message,i.signal,e,t)}if("request"===r.messageKind&&"tools/call"===r.message.method&&_ instanceof dy){let e=r.message.params,t="string"==typeof e?.name?e.name:void 0,n=void 0===t?void 0:_.toolInputSchemaJson(t);if(void 0!==n){let t=c5(n);if(void 0!==t.declarations&&t.declarations.length>0){let n=function(e,t,r){for(let i of e){let e=`Mcp-Param-${i.headerName}`,n=r.get(e),o=function(e,t){let r=e;for(let e of t){if(null===r||"object"!=typeof r)return;r=r[e]}return r}(t,i.path);if(null==o)continue;let a=function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}(o);if(void 0===a)continue;if(null===n)return ur("param-header-missing",e,`the body carries ${c7(i.path)}=${JSON.stringify(o)} but the ${e} header is absent`);let s=ut(n);if(void 0===s)return ur("param-header-invalid-encoding",e,`the ${e} header carries an invalid Base64 sentinel value`);if(!(("integer"===i.type||"number"===i.type)&&ue.test(s)&&"number"==typeof o?Number(s)===o:s===a))return ur("param-header-mismatch",e,`the ${e} header decodes to ${JSON.stringify(s)} but the body carries ${c7(i.path)}=${JSON.stringify(o)}`)}}(t.declarations,e?.arguments,i.headers);if(void 0!==n)return _.close().catch(m),m(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),dz(n,r.message.id)}}}if("request"===r.messageKind&&_ instanceof dy)try{let e=await dc([r.message],n,e=>_.resolveScopeChallenge(e));if(void 0!==e)return _.close().catch(m),dd(e,du(n))}catch(e){return _.close().catch(m),m(dL(e)),dN(r.message.id)}dM(b),s(b,h),u(b,lQ),void 0!==y&&(p={clientInfo:y[oG],clientCapabilities:v},c(b,p));let S=b.onclose;l.add(b);let w=()=>{l.delete(b),b.onclose===w&&(b.onclose=S),S?.()};b.onclose=w;try{let e=await async function(e,t,r){let i=new da({classification:r.classification,...void 0!==r.responseMode&&{responseMode:r.responseMode},...void 0!==r.keepAliveMs&&{keepAliveMs:r.keepAliveMs}});return await e.connect(i),i.handleMessage(t,{...void 0!==r.request&&{request:r.request},...void 0!==r.authInfo&&{authInfo:r.authInfo}})}(_,r.message,{classification:r.classification,request:i,...void 0!==n&&{authInfo:n},...void 0!==o&&{responseMode:o},...void 0!==t.keepAliveMs&&{keepAliveMs:t.keepAliveMs}});return"notification"===r.messageKind&&queueMicrotask(()=>void b.close().catch(()=>{})),e}catch(e){if(e instanceof lW&&e.code===lB.ConnectionClosed)return new Response(null,{status:499});return await b.close().catch(()=>{}),l.delete(b),m(dL(e)),dN(dj(r.message))}}(h,r,n);case"legacy":return await async function(e,t,r,i){if(void 0!==y)return y(t,{...void 0!==r&&{authInfo:r},...void 0!==i&&{parsedBody:i}});let n=function(e,t){switch(e.reason){case"http-method":return uo("http-method","modern-only-method-not-allowed",405,new cv(-32e3,"Method not allowed."),!0);case"batch":return uo("jsonrpc-shape","modern-only-batch-not-supported",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return uo("jsonrpc-shape","modern-only-response-post",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return uo("era-classification","modern-only-missing-envelope",400,void 0===r?new cv(cy.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new cS({supported:[...t],requested:r}),!0)}}}(e,lQ);return void 0===n?new Response(null,{status:202}):(m(Error(`Rejected 2025-era request on a modern-only endpoint (${n.cell}): ${n.message}`)),dz(n,dj(i)))}(h,_,n,v)}}catch(e){return m(dL(e)),dN(dj(f))}}(r,i)}catch(e){return m(dL(e)),dN(dj(i?.parsedBody))}},notify:f,bus:h,close:async()=>{p=!0,g.closeAll();let e=[...l].map(e=>e.close().catch(()=>{}));l.clear(),await Promise.all(e)}}}(async function(){let{instructions:e,...t}=hm,r=new dy(t,{instructions:e}),i=async function(){let{toolModules:e,skippedTools:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw hs(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw hs(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default tool handler."}}:{skipped:!1,path:e,toolModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.toolModule)}return{toolModules:t,skippedTools:r}}(hc);return hl(t),e}(),n=async function(){let{promptModules:e,skippedPrompts:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw m6(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw m6(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default prompt handler."}}:{skipped:!1,path:e,promptModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.promptModule)}return{promptModules:t,skippedPrompts:r}}(hu);return m7(t),e}(),o=async function(){let{resourceModules:e,skippedResources:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw m8(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw m8(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default resource handler."}}:{skipped:!1,path:e,resourceModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.resourceModule)}return{resourceModules:t,skippedResources:r}}(hd);return he(t),e}(),[a,s,l]=await Promise.all([i,n,o]);return async function(e,t,r,i){let n=await INJECTED_MIDDLEWARE?.(),o=function(e){if(void 0===e)return[];let t=Array.isArray(e)?[...e]:[e];if(!t.every(e=>"function"==typeof e))throw Error("src/middleware.ts must export mcp as a function or an array of functions");return t}(n?.mcp),a="u">typeof OBSERVABILITY_CONFIG&&OBSERVABILITY_CONFIG.enabled?function(e=e=>console.error(e)){let t=new Map,r=[];function i(t){try{e(JSON.stringify({"@timestamp":new Date().toISOString(),...t}))}catch{}}return{middleware:async(e,n)=>{let o,a,s;if("tools/call"!==e.method&&"prompts/get"!==e.method&&"resources/read"!==e.method)return n();try{a=performance.now(),o={log:{level:"info"},...function(e){let t=e.http?.headers.traceparent;if("string"!=typeof t)return{};let r=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/.exec(t);return!r||"ff"===r[1]||/^0+$/.test(r[2])||/^0+$/.test(r[3])||"00"===r[1]&&void 0!==r[5]?{}:{trace:{id:r[2]},parent:{id:r[3]}}}(e),transaction:{id:crypto.randomUUID()},...e.http?{http:{request:{id:e.http.id}}}:{},xmcp:{method:e.method,component:"resources/read"===e.method?function(e){try{let i=new URL(e).href;return t.get(i)??r.find(({template:e})=>e.uriTemplate.match(i))?.name??"unknown"}catch{return"unknown"}}(e.params.uri):e.params.name}}}catch{return n()}i({...o,event:{kind:"event",category:["api"],type:["start"],action:"execution.start"}});let l="unknown";try{let t=await n();try{l=e.signal.aborted?"cancelled":c1(t)?"input_required":"isError"in t&&!0===t.isError?"failure":"success","failure"===l&&(s={message:"Operation returned an error result"})}catch{}return t}catch(t){throw s={message:"cancelled"==(l=e.signal.aborted?"cancelled":"failure")?"Operation cancelled":"Operation threw an exception"},t}finally{try{i({...o,log:{level:"failure"===l?"error":"info"},event:{kind:"event",category:["api"],type:["end"],action:"execution.end",duration:Math.round((performance.now()-a)*1e6),outcome:"success"===l?"success":"failure"===l?"failure":"unknown"},xmcp:{...o.xmcp,status:l},...s?{error:s}:{}})}catch{}}},registerResource(e,i){try{"string"==typeof i?t.set(new URL(i).href,e):r.push({name:e,template:i})}catch{}}}}():void 0;a&&o.unshift(a.middleware),dX.clear();let s="u"<typeof COMPONENTS_CONFIG?void 0:COMPONENTS_CONFIG;return!function(e,t,r){let i=e.server,n=i.setRequestHandler,o=pg(t);i.setRequestHandler=(e,...t)=>{if(py.has(e)&&1===t.length&&"function"==typeof t[0]){let e=t[0];t[0]=(t,r)=>o({method:t.method,params:t.params??{}},r,()=>e(t,r))}Reflect.apply(n,i,[e,...t])};try{r()}finally{i.setRequestHandler=n}}(e,o,()=>{var n,l;!function(e,t,r=[]){t.forEach((t,i)=>{var n,o;let a,s,l,c,u={name:m4(i),description:"No description provided"},{default:d,metadata:p,schema:m,outputSchema:h}=t;if("object"==typeof p&&null!==p&&Object.assign(u,p),!1===u.enabled)return;if("function"==typeof d&&"__x402"in d){let e=F.g.__XMCP_X402_REGISTRY;e&&e.set(u.name,d.__x402)}let f={};if(m9(m)?f=m:null!=m&&console.warn(`Invalid schema for tool "${u.name}" at ${i}. Expected Record<string, z.ZodType>`),null!=h)if(m9(h))a=h;else throw Error(`Invalid outputSchema for tool "${u.name}" at ${i}. Expected Record<string, z.ZodType>`);u.annotations={...u.annotations??{}},void 0===u.annotations.title&&(u.annotations.title=u.name),u._meta={...dY(u)._meta};let g=pv(i),y=!!(n=u._meta)&&"object"==typeof n&&"ui"in n&&"object"==typeof n.ui||g,v=u._meta;if(y){let e=`ui://app/${u.name}.html`;u._meta.ui||(u._meta.ui={}),u._meta.ui.resourceUri||(u._meta.ui.resourceUri=e);let t=function(e){let t={},r={};if(e.ui&&"object"==typeof e.ui){let i=e.ui,n={},o={};for(let[e,t]of Object.entries(i))m1.includes(e)?n[e]=t:m2.includes(e)?o[e]=t:n[e]=t;Object.keys(n).length>0&&(t.ui=n),Object.keys(o).length>0&&(r.ui=o)}for(let[r,i]of Object.entries(e))"ui"!==r&&(t[r]=i);return{toolMeta:t,resourceMeta:r}}(v);v=t.toolMeta;let r=t.resourceMeta;r.ui=r.ui||{},r.ui.csp=r.ui.csp||{},r.ui.csp.resourceDomains=r.ui.csp.resourceDomains||[],r.ui.csp.resourceDomains.includes("https://esm.sh")||r.ui.csp.resourceDomains.push("https://esm.sh"),dX.add(u.name,{name:u.name,uri:e,handler:d,mimeType:"text/html;profile=mcp-app",_meta:r,toolPath:g?i:void 0})}let _=m0(v),b=y?_:void 0;s=pv(i)&&y?async(e,t)=>({content:[{type:"text",text:""}],_meta:b,structuredContent:{args:e}}):function(e,t,r,i="unknown-tool"){return async(n,o)=>{let a,s,l=e(n,(a=pf(o),s=function(e){if(!e)return;let t={};return e.headers.forEach((e,r)=>{t[r]=e}),t}(o.http?.req),{signal:o.mcpReq.signal,authInfo:o.http?.authInfo,sessionId:o.sessionId,_meta:o.mcpReq._meta,requestId:o.mcpReq.id,requestInfo:s?{headers:s}:void 0,clientInfo:a,sendNotification:e=>o.mcpReq.notify(e),sendRequest:(e,t,r)=>o.mcpReq.send(e,t,r),elicit:(e,t)=>(async function(e,t,r){let i=function(e){let t=e.mode??"form";if("url"===t)return function(e){let t;pt(e,"Elicitation request must be a plain object."),pe(e,d9,"URL elicitation"),pr(e.message,"URL elicitation requires a string message."),pi(e.elicitationId,"URL elicitation requires a non-empty elicitationId."),pi(e.url,"URL elicitation requires a non-empty URL.");try{t=new URL(e.url)}catch{throw Error("URL elicitation requires a valid http or https URL.")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw Error("URL elicitation requires a valid http or https URL.")}(e),e;if("form"!==t)throw Error(`Unsupported elicitation mode "${String(e.mode)}". Expected "form" or "url".`);return function(e){pt(e,"Elicitation request must be a plain object."),pe(e,d2,"Form elicitation"),pr(e.message,"Form elicitation requires a string message.");let t=e.requestedSchema;if(pt(t,"Form elicitation requires a flat object schema."),pe(t,d4,"Form elicitation schema"),"object"!==t.type)throw Error('Form elicitation schema must use type "object".');for(let[e,r]of(pt(t.properties,"Form elicitation schema requires a properties object."),Object.entries(t.properties)))!function(e,t){if(pt(t,`Form elicitation field "${e}" must be a plain object.`),pn(t.title,`Form elicitation field "${e}" title must be a string.`),pn(t.description,`Form elicitation field "${e}" description must be a string.`),"string"===t.type&&"enum"in t){var r,i;if(pe(t,d3,`Form elicitation field "${e}"`),pa(t.enum,`Form elicitation field "${e}" enum values must be strings.`),r=t.enumNames,i=`Form elicitation field "${e}" enumNames must be strings.`,void 0!==r&&pa(r,i),void 0!==t.enumNames&&t.enumNames.length!==t.enum.length)throw Error(`Form elicitation field "${e}" enumNames length must match enum length.`);if(pn(t.default,`Form elicitation field "${e}" default must be a string.`),void 0!==t.default&&!t.enum.includes(t.default))throw Error(`Form elicitation field "${e}" default must be one of its enum values.`);return}if("string"===t.type&&!("enum"in t)){pe(t,d5,`Form elicitation field "${e}"`),po(t.minLength,`Form elicitation field "${e}" minLength must be a number.`),po(t.maxLength,`Form elicitation field "${e}" maxLength must be a number.`),pn(t.default,`Form elicitation field "${e}" default must be a string.`);let r=t.format;if(pn(r,`Form elicitation field "${e}" format must be a string.`),void 0!==r&&!d8.has(r))throw Error(`Form elicitation field "${e}" format must be one of: ${Array.from(d8).join(", ")}.`);return}if("boolean"===t.type){if(pe(t,d6,`Form elicitation field "${e}"`),void 0!==t.default&&"boolean"!=typeof t.default)throw Error(`Form elicitation field "${e}" default must be a boolean.`);return}if("number"===t.type||"integer"===t.type){pe(t,d7,`Form elicitation field "${e}"`),po(t.minimum,`Form elicitation field "${e}" minimum must be a number.`),po(t.maximum,`Form elicitation field "${e}" maximum must be a number.`),po(t.default,`Form elicitation field "${e}" default must be a number.`);return}throw Error(`Form elicitation field "${e}" uses unsupported type "${String(t.type)}". Supported types are string, boolean, number, integer, and string enums.`)}(e,r);if(void 0!==t.required){if(!Array.isArray(t.required)||t.required.some(e=>"string"!=typeof e))throw Error("Form elicitation schema required fields must be a string array.");for(let e of t.required)if(!(e in t.properties))throw Error(`Form elicitation schema required field "${e}" is not defined in properties.`)}}(e),{...e,mode:"form"}}(t);try{let t=await e.mcpReq.elicitInput(i,r);return{...t,content:t.content??void 0}}catch(e){if(e instanceof lW&&e.code===lB.MethodNotSupportedByProtocolVersion)throw Error("extra.elicit() is not available on protocol revision 2026-07-28: server-initiated elicitation was replaced by multi round-trip requests. Return inputRequired({ ... }) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}})(o,e,t),sample:(e,t)=>(async function(e,t,r){let i=function(e){pu(e,"Sampling request must be a plain object.");let t=Object.keys(e),r=t.filter(e=>pl.has(e));if(r.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${r.join(", ")}.`);let i=t.filter(e=>!ps.has(e));if(i.length>0)throw Error(`Sampling request includes unsupported key(s): ${i.join(", ")}.`);if(!Array.isArray(e.messages)||0===e.messages.length)throw Error("Sampling requires at least one message.");for(let[t,r]of e.messages.entries())!function(e,t){if(pu(t,`Sampling message at index ${e} must be a plain object.`),"user"!==t.role&&"assistant"!==t.role)throw Error(`Sampling message at index ${e} requires role "user" or "assistant".`);let r=t.content;pu(r,`Sampling message at index ${e} requires a content object.`);let i=r.type;if("string"!=typeof i||!pc.has(i))throw Error(`Sampling message at index ${e} uses unsupported content type "${String(i)}". Supported types are text, image, and audio.`);if("text"===i&&"string"!=typeof r.text)throw Error(`Sampling message at index ${e} requires string text content.`);if(("image"===i||"audio"===i)&&("string"!=typeof r.data||"string"!=typeof r.mimeType))throw Error(`Sampling message at index ${e} requires base64 data and a mimeType.`)}(t,r);if("number"!=typeof e.maxTokens)throw Error("Sampling requires a numeric maxTokens.");return e}(t);try{return await e.mcpReq.requestSampling(i,r)}catch(e){if(e instanceof lW&&e.code===lB.MethodNotSupportedByProtocolVersion)throw Error("extra.sample() is not available on protocol revision 2026-07-28: server-initiated sampling was replaced by multi round-trip requests. Return inputRequired({ ... }) with inputRequired.createMessage(...) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}})(o,e,t),inputResponses:o.mcpReq.inputResponses,requestState:o.mcpReq.requestState}));if(l instanceof Promise&&(l=await l),c1(l))return l;if("string"==typeof l||"number"==typeof l){if(r){let e=Object.entries(r);if(1===e.length){let[t,r]=e[0];try{return r.parse(l),{content:[{type:"text",text:"number"==typeof l?`${l}`:l}],structuredContent:{[t]:l}}}catch{}}}return ph(t)?{content:[{type:"text",text:""}],structuredContent:{args:n},_meta:t}:{content:[{type:"text",text:"number"==typeof l?`${l}`:l}]}}if(!r||!l||"object"!=typeof l||Array.isArray(l)||"structuredContent"in l||"content"in l&&Array.isArray(l.content)||"_meta"in l||"isError"in l||(pm(l,r,i,"returned data that does not match outputSchema"),l={structuredContent:l}),l&&"object"==typeof l&&"_meta"in l&&!("content"in l)&&!("structuredContent"in l)){let e=l._meta;if(ph(e))return{content:[{type:"text",text:""}],_meta:e}}if(!l||"object"!=typeof l){let e=null===l?"null":typeof l,t=void 0===l?"undefined":null===l?"null":"object"==typeof l?JSON.stringify(l,null,2):String(l);throw Error(`Tool handler must return a CallToolResult, string, or number. Got ${e}: ${t}
|
|
443
|
+
`),b=!0;try{u?.()}catch(e){r?.(e instanceof Error?e:Error(String(e)))}void 0!==d&&clearInterval(d),p?.(),o.delete(R);try{c.close()}catch{}}},k=new ReadableStream({start(e){c=e;let r=dP({method:"notifications/subscriptions/acknowledged",params:{notifications:y}},v);(w(r.method,r.params),0===Object.keys(y).length)?R(!0):(u=t.subscribe(e=>{if(b||!function(e,t){switch(t.kind){case"tools_list_changed":return!0===e.toolsListChanged;case"prompts_list_changed":return!0===e.promptsListChanged;case"resources_list_changed":return!0===e.resourcesListChanged;case"resource_updated":return void 0!==e.resourceSubscriptions&&e.resourceSubscriptions.includes(t.uri)}}(y,e))return;let t=dP(function(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed",...void 0!==e.params&&{params:e.params}};case"prompts_list_changed":return{method:"notifications/prompts/list_changed",...void 0!==e.params&&{params:e.params}};case"resources_list_changed":return{method:"notifications/resources/list_changed",...void 0!==e.params&&{params:e.params}};case"resource_updated":return{method:"notifications/resources/updated",params:{...e.params,uri:e.uri}}}}(e),v);w(t.method,t.params)}),d=dn(n,()=>S(": keepalive\n\n")),o.add(R))},cancel(){R(!1)}});if(void 0!==a)if(a.aborted)R(!1);else{let e=()=>R(!1);a.addEventListener("abort",e,{once:!0}),p=()=>a.removeEventListener("abort",e)}return new Response(k,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let e of o)e(!0)},get openCount(){return o.size}}}({bus:h,maxSubscriptions:t.maxSubscriptions??1024,keepAliveMs:t.keepAliveMs??15e3,onerror:m});"json"===o&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let y="reject"===i?void 0:(r=t.keepAliveMs,async(t,i)=>{if("POST"!==t.method.toUpperCase())return dA(405,-32e3,"Method not allowed.");try{let n=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:t}),o=new dq({sessionIdGenerator:void 0,...void 0!==r&&{keepAliveMs:r},...void 0!==a&&{maxRequestBodySize:a}});await n.connect(o);let s=()=>{o.close().catch(()=>{}),n.close().catch(()=>{})};t.signal?.addEventListener("abort",s,{once:!0});let l=await o.handleRequest(t,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(null===l.body||"text/event-stream"!==uM(l.headers.get("content-type")))return s(),l;let c=l.body.getReader(),u=!1,d=()=>{u||(u=!0,s())},p=new ReadableStream({pull:async e=>{try{let{done:t,value:r}=await c.read();if(t){d(),e.close();return}void 0!==r&&e.enqueue(r)}catch(t){d(),e.error(t)}},cancel:e=>(d(),c.cancel(e).catch(()=>{}))});return new Response(p,{status:l.status,statusText:l.statusText,headers:l.headers})}catch(e){try{m?.(dL(e))}catch{}return dN(dj(i?.parsedBody))}});return{fetch:async(r,i)=>{if(p)throw Error("This MCP handler has been closed");try{return await async function(r,i){let n=i?.authInfo;if("POST"===r.method.toUpperCase()&&!uZ(r.headers.get("content-type")))return m(Error("Unsupported Media Type: Content-Type must be application/json")),dA(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let p=await async function(e,t,r=!0,i=4194304){let n,o=e.method.toUpperCase(),a=t,s=e,l=!1;if("POST"===o){if(void 0===a){let t;r&&(s=e.clone());try{let r=await dI(e,i);if(r.tooLarge)return{step:"body-too-large"};t=r.text}catch{return{step:"unreadable-body"}}try{n=0===t.length?void 0:JSON.parse(t)}catch{l=!0}l||void 0===n||(a=n)}else n=a;if(l||void 0===n)return{step:"no-json-body",forwardRequest:s}}return{step:"classified",outcome:function(e){if("POST"!==(e={...e,...void 0!==e.protocolVersionHeader&&{protocolVersionHeader:ul(e.protocolVersionHeader)},...void 0!==e.mcpMethodHeader&&{mcpMethodHeader:ul(e.mcpMethodHeader)},...void 0!==e.mcpNameHeader&&{mcpNameHeader:ul(e.mcpNameHeader)}}).httpMethod.toUpperCase())return{kind:"legacy",reason:"http-method"};let t=e.body;if(Array.isArray(t)){if(0===t.length)return uo("jsonrpc-shape","empty-batch",400,new cv(cy.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let e of t){if(cB(uc(e)?e.params:void 0))return uo("jsonrpc-shape","batch-with-modern-element",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(cY(e)||cX(e)||cQ(e)||c0(e)))return uo("jsonrpc-shape","batch-with-invalid-element",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}return cQ(t)||c0(t)?{kind:"legacy",reason:"response"}:uc(t)&&cY(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,o=void 0!==n&&n>=lX;if("initialize"===i&&!function(e){if(!cB(e))return!1;let t=cW(e);if(void 0===t||!(t>=lX))return!1;let r=cJ(e);return void 0!==r&&0===cG(r).length}(r)){if(o)return ua("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let e=uc(r)&&"string"==typeof r.protocolVersion?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==e&&{requestedVersion:e}}}if(cB(r)){let o=cJ(r),a=(void 0===o?[]:cG(o))[0];if(void 0!==a)return uo("envelope","envelope-invalid",400,new cv(cy.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${a.key}: ${a.problem}`,{envelope:a}),!0);let s=cW(r);return void 0!==n&&void 0!==s&&n!==s?ua("header-body-version-mismatch",n,`the body envelope names protocol version ${s} but the MCP-Protocol-Version header names ${n}`):void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?ua("method-header-mismatch",e.mcpMethodHeader,`the body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"request",message:t,classification:uu(s)}}if(o){let e=cJ(r),t=cG(e??{}).filter(e=>"missing"===e.problem).map(e=>e.key),i=void 0===e?["_meta"]:t.length>0?t:[oW];return uo("envelope","modern-header-without-claim",400,new cv(cy.InvalidParams,`Invalid params: the MCP-Protocol-Version header names protocol revision ${n}, but the request is missing the required per-request envelope key(s): ${i.join(", ")}`,{envelope:{missing:i}}),!0)}return{kind:"legacy",reason:"no-claim",...void 0!==n&&{requestedVersion:n}}}(e,t):uc(t)&&cX(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,o=void 0!==n&&n>=lX;if(cB(r)){let o=cW(r);if(void 0===o){let e=cJ(r),t=(void 0===e?[]:cG(e)).find(e=>e.key===oW)??{key:oW,problem:"expected a protocol version string"};return uo("envelope","notification-envelope-invalid",400,new cv(cy.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${t.key}: ${t.problem}`,{envelope:t}),!0)}if(void 0!==n&&n!==o)return ua("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${o} but the MCP-Protocol-Version header names ${n}`);let a=uu(o);return"modern"===a.era&&void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?ua("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:a}}return o?void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?ua("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:{era:"modern",revision:n}}:{kind:"legacy",reason:"notification",...void 0!==n&&{requestedVersion:n}}}(e,t):uo("jsonrpc-shape","invalid-json-rpc-body",400,new cv(cy.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}({httpMethod:o,...dZ(e),...void 0!==n&&{body:n}}),body:n,parsedBody:a,forwardRequest:s}}(r,i?.parsedBody,!0,a);if("unreadable-body"===p.step)return dA(400,-32700,"Parse error: the request body could not be read");if("body-too-large"===p.step)return dA(413,-32e3,dO(a));if("no-json-body"===p.step)return void 0!==y?y(p.forwardRequest,{...void 0!==n&&{authInfo:n}}):dA(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:h,body:f,parsedBody:v,forwardRequest:_}=p;try{switch(h.kind){case"reject":return m(Error(`Rejected inbound request (${h.cell}): ${h.message}`)),dz(h,dj(f));case"modern":return await async function(r,i,n){var a,p;let h=r.classification.revision;if(void 0===h||!lQ.includes(h)){let e=new cS({supported:[...lQ],requested:h??"unknown"});return m(e),dA(400,e.code,e.message,e.data,dj(r.message))}let f=function(e,t){if("request"!==t.messageKind)return;let r=t.message.method;if(void 0===e.protocolVersionHeader){let e=t.classification.revision;return ua("version-header-missing","(missing)",void 0===e?"the body carries a modern per-request envelope but the required MCP-Protocol-Version header is absent":`the body envelope names protocol version ${e} but the required MCP-Protocol-Version header is absent`,"standard-header-validation")}if(void 0===e.mcpMethodHeader)return ua("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let i=function(e,t){let r=Object.hasOwn(us,e)?us[e]:void 0;if(void 0===r)return;let i=uc(t)?t[r]:void 0;return{field:r,value:"string"==typeof i?i:void 0}}(r,t.message.params);if(void 0===i)return;let{field:n,value:o}=i;if(void 0===e.mcpNameHeader){if(void 0===o)return;return ua("name-header-missing","(missing)",`the body carries params.${n}="${o}" but the required Mcp-Name header is absent`,"standard-header-validation")}let a=ul(e.mcpNameHeader),s=ut(a);return void 0===s?ua("name-header-invalid-encoding",a,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==o&&s!==o?ua("name-header-mismatch",a,`the body carries params.${n}="${o}" but the Mcp-Name header names "${s}"`,"standard-header-validation"):void 0}({httpMethod:i.method,...dZ(i)},r);if(void 0!==f)return m(Error(`Rejected inbound request (${f.cell}): ${f.message}`)),dz(f,dj(r.message));let y="request"===r.messageKind?cJ(r.message.params):void 0,v=y?.[oY];if("request"===r.messageKind){let e=Object.hasOwn(lG,a=r.message.method)?lG[a]:void 0;if(void 0!==e){let t=lY(e,v);if(void 0!==t){let e=new cw({requiredCapabilities:t});return m(e),dA(un[e.code]??400,e.code,e.message,e.data,r.message.id)}}}let _=await e({era:"modern",...void 0!==n&&{authInfo:n},requestInfo:i}),b=_ instanceof dy?_.server:_;if(dM(b),"request"===r.messageKind&&"subscriptions/listen"===r.message.method){let e=b.getCapabilities(),t=d(b);return _.close().catch(m),g.serve(r.message,i.signal,e,t)}if("request"===r.messageKind&&"tools/call"===r.message.method&&_ instanceof dy){let e=r.message.params,t="string"==typeof e?.name?e.name:void 0,n=void 0===t?void 0:_.toolInputSchemaJson(t);if(void 0!==n){let t=c5(n);if(void 0!==t.declarations&&t.declarations.length>0){let n=function(e,t,r){for(let i of e){let e=`Mcp-Param-${i.headerName}`,n=r.get(e),o=function(e,t){let r=e;for(let e of t){if(null===r||"object"!=typeof r)return;r=r[e]}return r}(t,i.path);if(null==o)continue;let a=function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}(o);if(void 0===a)continue;if(null===n)return ur("param-header-missing",e,`the body carries ${c7(i.path)}=${JSON.stringify(o)} but the ${e} header is absent`);let s=ut(n);if(void 0===s)return ur("param-header-invalid-encoding",e,`the ${e} header carries an invalid Base64 sentinel value`);if(!(("integer"===i.type||"number"===i.type)&&ue.test(s)&&"number"==typeof o?Number(s)===o:s===a))return ur("param-header-mismatch",e,`the ${e} header decodes to ${JSON.stringify(s)} but the body carries ${c7(i.path)}=${JSON.stringify(o)}`)}}(t.declarations,e?.arguments,i.headers);if(void 0!==n)return _.close().catch(m),m(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),dz(n,r.message.id)}}}if("request"===r.messageKind&&_ instanceof dy)try{let e=await dc([r.message],n,e=>_.resolveScopeChallenge(e));if(void 0!==e)return _.close().catch(m),dd(e,du(n))}catch(e){return _.close().catch(m),m(dL(e)),dN(r.message.id)}dM(b),s(b,h),u(b,lQ),void 0!==y&&(p={clientInfo:y[oG],clientCapabilities:v},c(b,p));let S=b.onclose;l.add(b);let w=()=>{l.delete(b),b.onclose===w&&(b.onclose=S),S?.()};b.onclose=w;try{let e=await async function(e,t,r){let i=new da({classification:r.classification,...void 0!==r.responseMode&&{responseMode:r.responseMode},...void 0!==r.keepAliveMs&&{keepAliveMs:r.keepAliveMs}});return await e.connect(i),i.handleMessage(t,{...void 0!==r.request&&{request:r.request},...void 0!==r.authInfo&&{authInfo:r.authInfo}})}(_,r.message,{classification:r.classification,request:i,...void 0!==n&&{authInfo:n},...void 0!==o&&{responseMode:o},...void 0!==t.keepAliveMs&&{keepAliveMs:t.keepAliveMs}});return"notification"===r.messageKind&&queueMicrotask(()=>void b.close().catch(()=>{})),e}catch(e){if(e instanceof lW&&e.code===lB.ConnectionClosed)return new Response(null,{status:499});return await b.close().catch(()=>{}),l.delete(b),m(dL(e)),dN(dj(r.message))}}(h,r,n);case"legacy":return await async function(e,t,r,i){if(void 0!==y)return y(t,{...void 0!==r&&{authInfo:r},...void 0!==i&&{parsedBody:i}});let n=function(e,t){switch(e.reason){case"http-method":return uo("http-method","modern-only-method-not-allowed",405,new cv(-32e3,"Method not allowed."),!0);case"batch":return uo("jsonrpc-shape","modern-only-batch-not-supported",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return uo("jsonrpc-shape","modern-only-response-post",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return uo("era-classification","modern-only-missing-envelope",400,void 0===r?new cv(cy.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new cS({supported:[...t],requested:r}),!0)}}}(e,lQ);return void 0===n?new Response(null,{status:202}):(m(Error(`Rejected 2025-era request on a modern-only endpoint (${n.cell}): ${n.message}`)),dz(n,dj(i)))}(h,_,n,v)}}catch(e){return m(dL(e)),dN(dj(f))}}(r,i)}catch(e){return m(dL(e)),dN(dj(i?.parsedBody))}},notify:f,bus:h,close:async()=>{p=!0,g.closeAll();let e=[...l].map(e=>e.close().catch(()=>{}));l.clear(),await Promise.all(e)}}}(async function(){let{instructions:e,...t}=hv,r=new dy(t,{instructions:e}),i=async function(){let{toolModules:e,skippedTools:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw hp(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw hp(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default tool handler."}}:{skipped:!1,path:e,toolModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.toolModule)}return{toolModules:t,skippedTools:r}}(hh);return hm(t),e}(),n=async function(){let{promptModules:e,skippedPrompts:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw hr(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw hr(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default prompt handler."}}:{skipped:!1,path:e,promptModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.promptModule)}return{promptModules:t,skippedPrompts:r}}(hf);return hi(t),e}(),o=async function(){let{resourceModules:e,skippedResources:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw hn(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw hn(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default resource handler."}}:{skipped:!1,path:e,resourceModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.resourceModule)}return{resourceModules:t,skippedResources:r}}(hg);return ho(t),e}(),[a,s,l]=await Promise.all([i,n,o]);return async function(e,t,r,i){let n=await INJECTED_MIDDLEWARE?.(),o=function(e){if(void 0===e)return[];let t=Array.isArray(e)?[...e]:[e];if(!t.every(e=>"function"==typeof e))throw Error("src/middleware.ts must export mcp as a function or an array of functions");return t}(n?.mcp),a=function(e){if(void 0!==e){if("function"!=typeof e)throw Error("src/middleware.ts must export authorize as a function");return e}}(n?.authorize),s="u">typeof OBSERVABILITY_CONFIG&&OBSERVABILITY_CONFIG.enabled?function(e=e=>console.error(e)){let t=new Map,r=[];function i(t){try{e(JSON.stringify({"@timestamp":new Date().toISOString(),...t}))}catch{}}return{middleware:async(e,n)=>{let o,a,s;if("tools/call"!==e.method&&"prompts/get"!==e.method&&"resources/read"!==e.method)return n();try{a=performance.now(),o={log:{level:"info"},...function(e){let t=e.http?.headers.traceparent;if("string"!=typeof t)return{};let r=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/.exec(t);return!r||"ff"===r[1]||/^0+$/.test(r[2])||/^0+$/.test(r[3])||"00"===r[1]&&void 0!==r[5]?{}:{trace:{id:r[2]},parent:{id:r[3]}}}(e),transaction:{id:crypto.randomUUID()},...e.http?{http:{request:{id:e.http.id}}}:{},xmcp:{method:e.method,component:"resources/read"===e.method?function(e){try{let i=new URL(e).href;return t.get(i)??r.find(({template:e})=>e.uriTemplate.match(i))?.name??"unknown"}catch{return"unknown"}}(e.params.uri):e.params.name}}}catch{return n()}i({...o,event:{kind:"event",category:["api"],type:["start"],action:"execution.start"}});let l="unknown";try{let t=await n();try{l=e.signal.aborted?"cancelled":c1(t)?"input_required":"isError"in t&&!0===t.isError?"failure":"success","failure"===l&&(s={message:"Operation returned an error result"})}catch{}return t}catch(t){throw s={message:"cancelled"==(l=e.signal.aborted?"cancelled":"failure")?"Operation cancelled":"Operation threw an exception"},t}finally{try{i({...o,log:{level:"failure"===l?"error":"info"},event:{kind:"event",category:["api"],type:["end"],action:"execution.end",duration:Math.round((performance.now()-a)*1e6),outcome:"success"===l?"success":"failure"===l?"failure":"unknown"},xmcp:{...o.xmcp,status:l},...s?{error:s}:{}})}catch{}}},registerResource(e,i){try{"string"==typeof i?t.set(new URL(i).href,e):r.push({name:e,template:i})}catch{}}}}():void 0;s&&o.unshift(s.middleware),dX.clear();let l="u"<typeof COMPONENTS_CONFIG?void 0:COMPONENTS_CONFIG;return!function(e,t,r,i){let n=e.server,o=n.setRequestHandler,a=i?{tools:new Map,prompts:new Map,resources:new Map,templates:new Map,uiOwners:new Map}:void 0,s=i&&a?function(e,t){let r=async(t,r,i)=>!r||await e(t,r,i)===!0;async function i(e,t,i){if(!Array.isArray(t))return t;let n=await Promise.all(t.map(t=>r(e,i(t),"list")));return t.filter((e,t)=>n[t])}return async(e,n)=>{switch(e.method){case"tools/call":{let{name:i}=e.params;if(!await r(e,t.tools.get(i),"call"))throw new cv(cy.InvalidParams,`Tool ${i} not found`);return n()}case"prompts/get":{let{name:i}=e.params;if(!await r(e,t.prompts.get(i),"get"))throw new cv(cy.InvalidParams,`Prompt ${i} not found`);return n()}case"resources/read":{let{uri:i}=e.params;if(!await r(e,d9(t,i),"read"))throw new c_(i);return n()}case"completion/complete":{let{ref:i}=e.params,o="ref/prompt"===i.type?t.prompts.get(i.name):[...t.templates.values()].find(({component:e})=>e.uriTemplate===i.uri)?.component??t.uiOwners.get(i.uri)??t.resources.get(i.uri);if(!await r(e,o,"complete"))throw new cv(cy.InvalidParams,"ref/prompt"===i.type?`Prompt ${i.name} not found`:`Resource template ${i.uri} not found`);return n()}case"tools/list":{let r=await n();return{...r,tools:await i(e,r.tools,e=>t.tools.get(e.name))}}case"prompts/list":{let r=await n();return{...r,prompts:await i(e,r.prompts,e=>t.prompts.get(e.name))}}case"resources/list":{let r=await n();return{...r,resources:await i(e,r.resources,e=>d9(t,e.uri,!0))}}case"resources/templates/list":{let r=await n();return{...r,resourceTemplates:await i(e,r.resourceTemplates,e=>t.templates.get(e.name)?.component)}}default:return n()}}}(i,a):void 0,l=pb(s?[s,...t]:t),c=s?pb([s]):void 0;n.setRequestHandler=(e,...t)=>{if(1===t.length&&"function"==typeof t[0]){let r=t[0];pw.has(e)?t[0]=(e,t)=>l({method:e.method,params:e.params??{}},t,()=>r(e,t)):"tools/call"===e&&c&&a&&(t[0]=(e,t)=>{let i=a.tools.get(e.params.name);return i?c({method:"tools/call",params:{name:e.params.name,arguments:e.params.arguments??{}},tool:{metadata:i.metadata}},t,()=>r(e,t)):r(e,t)})}Reflect.apply(o,n,[e,...t])};try{if(a){let t=async(e,t,r)=>{let n=a.resources.get(t);return!n||await i(e,n,r)===!0},n={registerTool:e.registerTool,registerPrompt:e.registerPrompt,registerResource:e.registerResource};e.registerTool=(t,r,...i)=>{let o=pS({name:t,description:r.description??"",annotations:r.annotations,icons:r.icons,tags:d2(r._meta),_meta:r._meta});return a.tools.set(t,Object.freeze({type:"tool",name:t,metadata:o})),Reflect.apply(n.registerTool,e,[t,r,...i])},e.registerPrompt=(t,r,...i)=>{let o=pS({name:t,title:r.title,description:r.description,icons:r.icons,tags:d2(r._meta),_meta:r._meta});return a.prompts.set(t,Object.freeze({type:"prompt",name:t,metadata:o})),Reflect.apply(n.registerPrompt,e,[t,r,...i])},e.registerResource=(t,r,i,...o)=>{let s=pS({name:t,title:i.title,description:i.description,icons:i.icons,mimeType:i.mimeType,tags:d2(i._meta),_meta:i._meta});if("string"==typeof r)a.resources.set(r,Object.freeze({type:"resource",name:t,uri:r,metadata:s}));else{let e=r.uriTemplate.toString();a.templates.set(t,{component:Object.freeze({type:"resourceTemplate",name:t,uriTemplate:e,metadata:s}),template:r})}return Reflect.apply(n.registerResource,e,[t,r,i,...o])};try{r(t)}finally{Object.assign(e,n)}for(let[e,t]of dX.getAll()){let r=a.tools.get(e);r&&a.uiOwners.set(t.uri,r)}}else r()}finally{n.setRequestHandler=o}}(e,o,n=>{var a,c;!function(e,t,r=[]){t.forEach((t,i)=>{var n,o;let a,s,l,c,u={name:m8(i),description:"No description provided"},{default:d,metadata:p,schema:m,outputSchema:h}=t;if("object"==typeof p&&null!==p&&Object.assign(u,p),!1===u.enabled)return;if("function"==typeof d&&"__x402"in d){let e=F.g.__XMCP_X402_REGISTRY;e&&e.set(u.name,d.__x402)}let f={};if(m7(m)?f=m:null!=m&&console.warn(`Invalid schema for tool "${u.name}" at ${i}. Expected Record<string, z.ZodType>`),null!=h)if(m7(h))a=h;else throw Error(`Invalid outputSchema for tool "${u.name}" at ${i}. Expected Record<string, z.ZodType>`);u.annotations={...u.annotations??{}},void 0===u.annotations.title&&(u.annotations.title=u.name),u._meta={...dY(u)._meta};let g=pR(i),y=!!(n=u._meta)&&"object"==typeof n&&"ui"in n&&"object"==typeof n.ui||g,v=u._meta;if(y){let e=`ui://app/${u.name}.html`;u._meta.ui||(u._meta.ui={}),u._meta.ui.resourceUri||(u._meta.ui.resourceUri=e);let t=function(e){let t={},r={};if(e.ui&&"object"==typeof e.ui){let i=e.ui,n={},o={};for(let[e,t]of Object.entries(i))m3.includes(e)?n[e]=t:m6.includes(e)?o[e]=t:n[e]=t;Object.keys(n).length>0&&(t.ui=n),Object.keys(o).length>0&&(r.ui=o)}for(let[r,i]of Object.entries(e))"ui"!==r&&(t[r]=i);return{toolMeta:t,resourceMeta:r}}(v);v=t.toolMeta;let r=t.resourceMeta;r.ui=r.ui||{},r.ui.csp=r.ui.csp||{},r.ui.csp.resourceDomains=r.ui.csp.resourceDomains||[],r.ui.csp.resourceDomains.includes("https://esm.sh")||r.ui.csp.resourceDomains.push("https://esm.sh"),dX.add(u.name,{name:u.name,uri:e,handler:d,mimeType:"text/html;profile=mcp-app",_meta:r,toolPath:g?i:void 0})}let _=m5(v),b=y?_:void 0;s=pR(i)&&y?async(e,t)=>({content:[{type:"text",text:""}],_meta:b,structuredContent:{args:e}}):function(e,t,r,i="unknown-tool"){return async(n,o)=>{let a,s,l=e(n,(a=p_(o),s=function(e){if(!e)return;let t={};return e.headers.forEach((e,r)=>{t[r]=e}),t}(o.http?.req),{signal:o.mcpReq.signal,authInfo:o.http?.authInfo,sessionId:o.sessionId,_meta:o.mcpReq._meta,requestId:o.mcpReq.id,requestInfo:s?{headers:s}:void 0,clientInfo:a,sendNotification:e=>o.mcpReq.notify(e),sendRequest:(e,t,r)=>o.mcpReq.send(e,t,r),elicit:(e,t)=>(async function(e,t,r){let i=function(e){let t=e.mode??"form";if("url"===t)return function(e){let t;po(e,"Elicitation request must be a plain object."),pn(e,d6,"URL elicitation"),pa(e.message,"URL elicitation requires a string message."),ps(e.elicitationId,"URL elicitation requires a non-empty elicitationId."),ps(e.url,"URL elicitation requires a non-empty URL.");try{t=new URL(e.url)}catch{throw Error("URL elicitation requires a valid http or https URL.")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw Error("URL elicitation requires a valid http or https URL.")}(e),e;if("form"!==t)throw Error(`Unsupported elicitation mode "${String(e.mode)}". Expected "form" or "url".`);return function(e){po(e,"Elicitation request must be a plain object."),pn(e,d3,"Form elicitation"),pa(e.message,"Form elicitation requires a string message.");let t=e.requestedSchema;if(po(t,"Form elicitation requires a flat object schema."),pn(t,d7,"Form elicitation schema"),"object"!==t.type)throw Error('Form elicitation schema must use type "object".');for(let[e,r]of(po(t.properties,"Form elicitation schema requires a properties object."),Object.entries(t.properties)))!function(e,t){if(po(t,`Form elicitation field "${e}" must be a plain object.`),pl(t.title,`Form elicitation field "${e}" title must be a string.`),pl(t.description,`Form elicitation field "${e}" description must be a string.`),"string"===t.type&&"enum"in t){var r,i;if(pn(t,pe,`Form elicitation field "${e}"`),pu(t.enum,`Form elicitation field "${e}" enum values must be strings.`),r=t.enumNames,i=`Form elicitation field "${e}" enumNames must be strings.`,void 0!==r&&pu(r,i),void 0!==t.enumNames&&t.enumNames.length!==t.enum.length)throw Error(`Form elicitation field "${e}" enumNames length must match enum length.`);if(pl(t.default,`Form elicitation field "${e}" default must be a string.`),void 0!==t.default&&!t.enum.includes(t.default))throw Error(`Form elicitation field "${e}" default must be one of its enum values.`);return}if("string"===t.type&&!("enum"in t)){pn(t,d8,`Form elicitation field "${e}"`),pc(t.minLength,`Form elicitation field "${e}" minLength must be a number.`),pc(t.maxLength,`Form elicitation field "${e}" maxLength must be a number.`),pl(t.default,`Form elicitation field "${e}" default must be a string.`);let r=t.format;if(pl(r,`Form elicitation field "${e}" format must be a string.`),void 0!==r&&!pi.has(r))throw Error(`Form elicitation field "${e}" format must be one of: ${Array.from(pi).join(", ")}.`);return}if("boolean"===t.type){if(pn(t,pt,`Form elicitation field "${e}"`),void 0!==t.default&&"boolean"!=typeof t.default)throw Error(`Form elicitation field "${e}" default must be a boolean.`);return}if("number"===t.type||"integer"===t.type){pn(t,pr,`Form elicitation field "${e}"`),pc(t.minimum,`Form elicitation field "${e}" minimum must be a number.`),pc(t.maximum,`Form elicitation field "${e}" maximum must be a number.`),pc(t.default,`Form elicitation field "${e}" default must be a number.`);return}throw Error(`Form elicitation field "${e}" uses unsupported type "${String(t.type)}". Supported types are string, boolean, number, integer, and string enums.`)}(e,r);if(void 0!==t.required){if(!Array.isArray(t.required)||t.required.some(e=>"string"!=typeof e))throw Error("Form elicitation schema required fields must be a string array.");for(let e of t.required)if(!(e in t.properties))throw Error(`Form elicitation schema required field "${e}" is not defined in properties.`)}}(e),{...e,mode:"form"}}(t);try{let t=await e.mcpReq.elicitInput(i,r);return{...t,content:t.content??void 0}}catch(e){if(e instanceof lW&&e.code===lB.MethodNotSupportedByProtocolVersion)throw Error("extra.elicit() is not available on protocol revision 2026-07-28: server-initiated elicitation was replaced by multi round-trip requests. Return inputRequired({ ... }) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}})(o,e,t),sample:(e,t)=>(async function(e,t,r){let i=function(e){ph(e,"Sampling request must be a plain object.");let t=Object.keys(e),r=t.filter(e=>pp.has(e));if(r.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${r.join(", ")}.`);let i=t.filter(e=>!pd.has(e));if(i.length>0)throw Error(`Sampling request includes unsupported key(s): ${i.join(", ")}.`);if(!Array.isArray(e.messages)||0===e.messages.length)throw Error("Sampling requires at least one message.");for(let[t,r]of e.messages.entries())!function(e,t){if(ph(t,`Sampling message at index ${e} must be a plain object.`),"user"!==t.role&&"assistant"!==t.role)throw Error(`Sampling message at index ${e} requires role "user" or "assistant".`);let r=t.content;ph(r,`Sampling message at index ${e} requires a content object.`);let i=r.type;if("string"!=typeof i||!pm.has(i))throw Error(`Sampling message at index ${e} uses unsupported content type "${String(i)}". Supported types are text, image, and audio.`);if("text"===i&&"string"!=typeof r.text)throw Error(`Sampling message at index ${e} requires string text content.`);if(("image"===i||"audio"===i)&&("string"!=typeof r.data||"string"!=typeof r.mimeType))throw Error(`Sampling message at index ${e} requires base64 data and a mimeType.`)}(t,r);if("number"!=typeof e.maxTokens)throw Error("Sampling requires a numeric maxTokens.");return e}(t);try{return await e.mcpReq.requestSampling(i,r)}catch(e){if(e instanceof lW&&e.code===lB.MethodNotSupportedByProtocolVersion)throw Error("extra.sample() is not available on protocol revision 2026-07-28: server-initiated sampling was replaced by multi round-trip requests. Return inputRequired({ ... }) with inputRequired.createMessage(...) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}})(o,e,t),inputResponses:o.mcpReq.inputResponses,requestState:o.mcpReq.requestState}));if(l instanceof Promise&&(l=await l),c1(l))return l;if("string"==typeof l||"number"==typeof l){if(r){let e=Object.entries(r);if(1===e.length){let[t,r]=e[0];try{return r.parse(l),{content:[{type:"text",text:"number"==typeof l?`${l}`:l}],structuredContent:{[t]:l}}}catch{}}}return pv(t)?{content:[{type:"text",text:""}],structuredContent:{args:n},_meta:t}:{content:[{type:"text",text:"number"==typeof l?`${l}`:l}]}}if(!r||!l||"object"!=typeof l||Array.isArray(l)||"structuredContent"in l||"content"in l&&Array.isArray(l.content)||"_meta"in l||"isError"in l||(py(l,r,i,"returned data that does not match outputSchema"),l={structuredContent:l}),l&&"object"==typeof l&&"_meta"in l&&!("content"in l)&&!("structuredContent"in l)){let e=l._meta;if(pv(e))return{content:[{type:"text",text:""}],_meta:e}}if(!l||"object"!=typeof l){let e=null===l?"null":typeof l,t=void 0===l?"undefined":null===l?"null":"object"==typeof l?JSON.stringify(l,null,2):String(l);throw Error(`Tool handler must return a CallToolResult, string, or number. Got ${e}: ${t}
|
|
444
444
|
|
|
445
445
|
Expected CallToolResult format:
|
|
446
446
|
{
|
|
@@ -490,7 +490,7 @@ Or both for backwards compatibility:
|
|
|
490
490
|
{
|
|
491
491
|
content: [{ type: "text", text: "fallback" }],
|
|
492
492
|
structuredContent: { your: "data" }
|
|
493
|
-
}`)}if(d&&!c&&!u){let{isError:e,...t}=l,r=Object.keys(t).length>0?`Tool execution failed: ${JSON.stringify(t)}`:"Tool execution failed";l.content=[{type:"text",text:r}],c=!0}if(r&&u&&!d&&
|
|
493
|
+
}`)}if(d&&!c&&!u){let{isError:e,...t}=l,r=Object.keys(t).length>0?`Tool execution failed: ${JSON.stringify(t)}`:"Tool execution failed";l.content=[{type:"text",text:r}],c=!0}if(r&&u&&!d&&py(l.structuredContent,r,i,"returned structuredContent that does not match outputSchema"),!c&&u&&(l.content=[{type:"text",text:JSON.stringify(l.structuredContent)}],c=!0),c)for(let e=0;e<l.content.length;e++){let t=l.content[e],r=pg(t);if(!r.valid)throw Error(`Invalid content item at index ${e}: ${r.error}
|
|
494
494
|
|
|
495
495
|
Content item: ${JSON.stringify(t,null,2)}
|
|
496
496
|
|
|
@@ -507,7 +507,7 @@ Expected format:
|
|
|
507
507
|
key: "value",
|
|
508
508
|
nested: { data: "here" }
|
|
509
509
|
}
|
|
510
|
-
}`)}}return l}}(d,b,a,u.name);let S={title:u.annotations?.title,description:u.description,inputSchema:
|
|
510
|
+
}`)}}return l}}(d,b,a,u.name);let S={title:u.annotations?.title,description:u.description,inputSchema:m4(f),outputSchema:a?m4(a,{strict:!0}):void 0,annotations:u.annotations,icons:u.icons,_meta:_};e.registerTool(u.name,S,(o={name:u.name,description:S.description,annotations:S.annotations,icons:S.icons,tags:u.tags,_meta:S._meta},l=pb(r,!0),c=Object.freeze({metadata:pS(o)}),(e,t)=>l({method:"tools/call",params:{name:c.metadata.name,arguments:e},tool:c},t,()=>s(e,t))))})}(e,ht(t,l),o),ht(r,l).forEach((t,r)=>{let i=m8(r),n={name:i,title:i,description:"No description provided"},o={},{default:a,metadata:s,schema:l}=t;if("object"==typeof s&&null!==s&&Object.assign(n,s),!1===n.enabled)return;let c=function(e,t="assistant"){return async(r,i)=>{let n,o=e(r,i);if(o instanceof Promise&&(o=await o),Array.isArray(o)||null!==o&&"object"==typeof o&&"messages"in o){let e=Array.isArray(o)?{messages:o}:o,t=await uT.GetPromptResult["~standard"].validate(e);if(t.issues){let e=t.issues.map(e=>{let t=e.path?.map(e=>"object"==typeof e?e.key:e).join(".");return`${t||"result"}: ${e.message}`});throw Error(`Invalid prompt result: ${e.join("; ")}`)}return e}if("string"==typeof o||"number"==typeof o)n={type:"text",text:"number"==typeof o?`${o}`:o};else{let e=pg(o);if(e.valid)n=o;else{let t=null===o?"null":typeof o,r=void 0===o?"undefined":null===o?"null":"object"==typeof o?JSON.stringify(o,null,2):String(o);throw Error(`Prompt handler must return a PromptContent object, string, number, PromptMessage[], or GetPromptResult. Got ${t}: ${r}
|
|
511
511
|
|
|
512
512
|
Validation error: ${e.error}
|
|
513
513
|
|
|
@@ -520,7 +520,7 @@ Expected formats:
|
|
|
520
520
|
- Image content: { type: "image", data: "base64data", mimeType: "image/jpeg" }
|
|
521
521
|
- Audio content: { type: "audio", data: "base64data", mimeType: "audio/mpeg" }
|
|
522
522
|
- Resource link: { type: "resource_link", name: "resource name", uri: "resource://uri" }
|
|
523
|
-
- All content types support an optional "_meta" object property`)}}if("user"!==t&&"assistant"!==t)throw Error(`Invalid role: ${t}`);return{messages:[{role:t,content:n}]}}}(a,n.role||"assistant");
|
|
523
|
+
- All content types support an optional "_meta" object property`)}}if("user"!==t&&"assistant"!==t)throw Error(`Invalid role: ${t}`);return{messages:[{role:t,content:n}]}}}(a,n.role||"assistant");m7(l)?Object.assign(o,l):null!=l&&console.warn(`Invalid schema for prompt "${n.name}" at ${r}. Expected Record<string, z.ZodType>`),e.registerPrompt(n.name,{title:n.title,description:n.description,icons:n.icons,_meta:dY(n)._meta,argsSchema:m4(o)},c)}),a=ht(i,l),c=s?.registerResource,[...dX.getAll()].forEach(([t,r])=>{let i=r.mimeType||"text/html;profile=mcp-app",n=r?._meta?m5(r._meta):void 0,o={name:r.name,description:`Auto-generated resource for ${r.name} tool`,mimeType:r.mimeType,_meta:n};c?.(r.name,r.uri),e.registerResource(r.name,r.uri,o,async(e,t)=>{if(r.mimeType&&r.toolPath)try{var n;let e,t,o=(n=r.toolPath,IS_CLOUDFLARE?function(e){let{normalizedPath:t,baseName:r}=ha(e),i=5381;for(let e=0;e<t.length;e++)i=Math.imul(i,33)+t.charCodeAt(e)>>>0;let n=i.toString(16).slice(0,6).padStart(6,"0");return`${r}_${n}`}(n):function(e){let{normalizedPath:t,baseName:r}=ha(e),i=F(Object(function(){var e=Error("Cannot find module 'crypto'");throw e.code="MODULE_NOT_FOUND",e}())).createHash("md5").update(t).digest("hex").slice(0,6);return`${r}_${i}`}(n)),a=function(e){if(INJECTED_CLIENT_BUNDLES)return INJECTED_CLIENT_BUNDLES[e]||null;if(!IS_CLOUDFLARE)try{let t=F(Object(function(){var e=Error("Cannot find module 'fs'");throw e.code="MODULE_NOT_FOUND",e}())),r=F(Object(function(){var e=Error("Cannot find module 'path'");throw e.code="MODULE_NOT_FOUND",e}()));for(let i of[r.join(process.cwd(),"dist","client"),r.join(process.cwd(),"client")]){let n=r.join(i,`${e}.bundle.js`),o=r.join(i,`${e}.bundle.css`);if(t.existsSync(n)){let e,r=t.readFileSync(n,"utf-8");return t.existsSync(o)&&(e=t.readFileSync(o,"utf-8")),{js:r,css:e}}}}catch{}return null}(o);if(!a)throw Error(`React client bundle not found for "${r.name}" (bundle: "${o}").
|
|
524
524
|
React tool bundles are generated automatically when you run "xmcp build" (or "xmcp dev").
|
|
525
525
|
Please re-run the build so the framework can regenerate the bundle.`);let s=a.js,l=a.css,c=(e=`
|
|
526
526
|
<script type="module">
|
|
@@ -575,7 +575,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let s=a.js
|
|
|
575
575
|
<div id="root"></div>
|
|
576
576
|
${e}
|
|
577
577
|
</body>
|
|
578
|
-
</html>`);return{contents:[{uri:r.uri,text:c,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let o=r.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:r.uri,text:o,mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}})}),
|
|
578
|
+
</html>`);return{contents:[{uri:r.uri,text:c,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let o=r.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:r.uri,text:o,mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}})}),a.forEach((t,r)=>{let i={name:m8(r),description:"No description provided"},{default:n,metadata:o,schema:a,complete:s}=t;if("object"==typeof o&&null!==o&&Object.assign(i,o),!1===i.enabled)return;let l={};m7(a)?l=a:null!=a&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let u=hs(r);if(!u)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let d=u.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(d=d.endsWith(".html")?d:`${d}.html`);let p=function(e,t,r={}){let i=hs(t);if(!i)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,n)=>{let o=e(function(e,t,r){let i={},n={};if(0===t.parameters.length)return n;let o=t.uriTemplate.split("://")[1]||"",a=e.split("://")[1]||"",s=o.split("/"),l=a.split("/");for(let e=0;e<s.length&&e<l.length;e++){let t=s[e],r=l[e],n=t.match(/^\{(.+)\}$/);n&&(i[n[1]]=r)}for(let e of t.parameters){let t=i[e],o=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!o){n[e]=t;continue}try{n[e]=o.parse(t)}catch(r){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return n}(t.href,i,r),n);if(o instanceof Promise&&(o=await o),c1(o))return o;if("string"==typeof o)return{contents:[{uri:t.href,text:o}]};if(!o||"object"!=typeof o||!Array.isArray(o.contents)){let e=null===o?"null":typeof o,t=void 0===o?"undefined":null===o?"null":"object"==typeof o?JSON.stringify(o,null,2):String(o);throw Error(`Resource handler must return a ReadResourceResult, InputRequiredResult, or string. Got ${e}: ${t}
|
|
579
579
|
|
|
580
580
|
Expected ReadResourceResult format:
|
|
581
581
|
{
|
|
@@ -584,7 +584,7 @@ Expected ReadResourceResult format:
|
|
|
584
584
|
{ uri: "resource://uri", mimeType: "application/json", text: "json content" },
|
|
585
585
|
{ uri: "resource://uri", blob: base64data }
|
|
586
586
|
]
|
|
587
|
-
}`)}return o.contents.forEach(e=>{e.uri||(e.uri=t.href)}),o}}(n,r,
|
|
587
|
+
}`)}return o.contents.forEach(e=>{e.uri||(e.uri=t.href)}),o}}(n,r,l);if("direct"===u.type)c?.(i.name,d),e.registerResource(i.name,d,dY(i),p);else{let t=Object.create(null);for(let e of u.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let r=new dv(d,{list:void 0,complete:t});c?.(i.name,r),e.registerResource(i.name,r,dY(i),async(e,t,r)=>{let i={};for(let e of u.parameters){let r=t[e],n=l[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);n?i[e]=n.parse(r):i[e]=r}let o=n(i,r);return o instanceof Promise&&(o=await o),"string"==typeof o?{contents:[{uri:e.href,text:o}]}:o})}}),function(e,t,r,i,n){let o=[...ht(new Map(t.map(e=>[e.uri,{metadata:{name:e.frontmatter.name},skill:e}])),r).values()].map(({skill:e})=>e);if(0===o.length)return;for(let{frontmatter:t,files:r}of o){let n=r[0].uri.slice(0,r[0].uri.lastIndexOf("/")+1);r.forEach(({uri:r,mimeType:o,text:a,blob:s},l)=>{let c=0===l?{mimeType:o,description:t.description}:{mimeType:o},u=0===l?t.name:`${t.name}/${decodeURIComponent(r.slice(n.length))}`,d=void 0!==a?{uri:r,mimeType:o,text:a}:{uri:r,mimeType:o,blob:s??""};i?.(u,r),e.registerResource(u,r,c,()=>({contents:[d]}))})}let a=o.map(hd),s=new Map(a.map(e=>[e.uri,e]));e.server.registerCapabilities({extensions:{"io.modelcontextprotocol/skills":{}}}),e.server.setRequestHandler("skills/list",{params:hc},(e,t)=>d1(t,p_(t),async()=>{let t=Object.freeze({...d0(),method:"skills/list",params:Object.freeze({...e})}),r=n?await Promise.all(a.map(e=>n(t,e.uri,"list"))):void 0,i=r?a.filter((e,t)=>r[t]):a,o=e?.cursor===void 0?0:function(e,t){let r=0/0;try{r=Number(atob(e))}catch{}if(!Number.isSafeInteger(r)||r<=0||r>=t)throw new cv(cy.InvalidParams,`Invalid cursor: ${e}`);return r}(e.cursor,i.length),s=o+50;return{skills:i.slice(o,s),...s<i.length?{nextCursor:btoa(String(s))}:{},...hl}})),e.server.setRequestHandler("skills/get",{params:hu},(e,t)=>d1(t,p_(t),async()=>{let{uri:t}=e,r=s.get(t),i=Object.freeze({...d0(),method:"skills/get",params:Object.freeze({...e})});if(!r||n&&!await n(i,t,"read"))throw new cv(cy.InvalidParams,`No skill is served at ${t}`);return{skill:r,...hl}}))}(e,hy,l,s?.registerResource,n)},a),e}(r,a,s,l)},{legacy:"stateless",responseMode:"json",maxSubscriptions:hx.maxSubscriptions,onerror:e=>hO("MCP handler error:",e)}),hI={async fetch(e,t,r){let i=new URL(e.url).pathname,n=e.headers.get("origin");if(hO(`${e.method} ${i}`),"OPTIONS"===e.method)return new Response(null,{status:204,headers:new Headers(hw(hR,n))});let o=hx.endpoint?.startsWith("/")?hx.endpoint:`/${hx.endpoint||"mcp"}`;if("/health"===i)return hk(new Response(JSON.stringify({status:"ok",transport:"cloudflare-workers",mode:"stateless",auth:"none"}),{status:200,headers:{"Content-Type":"application/json"}}),n);if("/"===i&&"GET"===e.method){var a,s;return hk(new Response((a=hC.name,s=hC.description,`
|
|
588
588
|
<!DOCTYPE html>
|
|
589
589
|
<html lang="en">
|
|
590
590
|
<head>
|
|
@@ -605,7 +605,7 @@ Expected ReadResourceResult format:
|
|
|
605
605
|
rel="stylesheet"
|
|
606
606
|
/>
|
|
607
607
|
<style>
|
|
608
|
-
${
|
|
608
|
+
${hS}
|
|
609
609
|
</style>
|
|
610
610
|
</head>
|
|
611
611
|
<body>
|
|
@@ -615,7 +615,7 @@ ${hg}
|
|
|
615
615
|
<div class="section-header">
|
|
616
616
|
<h2 id="server-name" class="display text-gradient">xmcp server</h2>
|
|
617
617
|
<p id="server-description" class="lead">
|
|
618
|
-
${s||
|
|
618
|
+
${s||h_}
|
|
619
619
|
</p>
|
|
620
620
|
</div>
|
|
621
621
|
</div>
|
|
@@ -722,7 +722,7 @@ ${`
|
|
|
722
722
|
(templateConfig.serverName && templateConfig.serverName.trim()) || "xmcp server";
|
|
723
723
|
const resolvedDescription =
|
|
724
724
|
(templateConfig.serverDescription && templateConfig.serverDescription.trim()) ||
|
|
725
|
-
"${
|
|
725
|
+
"${h_}";
|
|
726
726
|
const endpointPath =
|
|
727
727
|
(templateConfig.endpoint && templateConfig.endpoint.trim()) || "/";
|
|
728
728
|
const normalizedEndpoint = endpointPath.startsWith("/")
|
|
@@ -744,7 +744,7 @@ ${`
|
|
|
744
744
|
elements.description.textContent = resolvedDescription;
|
|
745
745
|
}
|
|
746
746
|
|
|
747
|
-
const icons = ${JSON.stringify(
|
|
747
|
+
const icons = ${JSON.stringify(hb)};
|
|
748
748
|
|
|
749
749
|
const connectionOptions = [
|
|
750
750
|
{
|
|
@@ -947,4 +947,4 @@ args = ["-y", "mcp-remote", "$\{serverUrl}"]\`,
|
|
|
947
947
|
<\/script>
|
|
948
948
|
</body>
|
|
949
949
|
</html>
|
|
950
|
-
`),{status:200,headers:{"Content-Type":"text/html"}}),n)}if(i===o)try{let{response:t,authInfo:r}=await async function(e){let t=await async function(){return
|
|
950
|
+
`),{status:200,headers:{"Content-Type":"text/html"}}),n)}if(i===o)try{let{response:t,authInfo:r}=await async function(e){let t=await async function(){return h$?(hT||(hT=(async()=>{try{var e;let t=await h$();return e=t?.default,Array.isArray(e)?e.filter(hP):hP(e)?[e]:e&&"object"==typeof e&&"middleware"in e&&"function"==typeof e.middleware?[e.middleware]:[]}catch(e){return console.error("[Cloudflare-MCP] Failed to load middleware:",e),[]}})()),hT):[]}();if(0===t.length)return{};let r={auth:void 0,setAuth:e=>{r.auth=e}};for(let i of t){let t=await i(e,r);if(t instanceof Response)return{response:t,authInfo:r.auth}}return{authInfo:r.auth}}(e);if(t)return hk(t,n);return async function(e,t,r){let i=crypto.randomUUID(),n=await e.clone().json().catch(()=>void 0),o=(e=>{for(let t of Array.isArray(e)?e:[e]){let e=dG(t);if(e)return e}})(n),a={};return e.headers.forEach((e,t)=>{a[t]=e}),dJ({id:i,headers:a,clientInfo:o},async()=>{try{let i=await hE.fetch(e,{authInfo:r,parsedBody:n});return hk(i,t)}catch(e){return console.error("[Cloudflare-MCP] Error handling MCP request:",e),hk(new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}}),t)}})}(e,n,r)}catch(e){return console.error("[Cloudflare-MCP] Middleware error:",e),hk(new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}}),n)}return hk(new Response(JSON.stringify({error:"Not found"}),{status:404,headers:{"Content-Type":"application/json"}}),n)}};var hq=H.A;export{hq as default};
|