xmcp 1.1.3 → 1.3.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/cloudflare.d.ts +1 -0
- package/dist/cloudflare.js +2 -2
- package/dist/config/index.d.ts +35 -35
- package/dist/config/schemas/experimental/index.d.ts +4 -4
- package/dist/config.js +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +13 -13
- package/dist/node.d.ts +55 -0
- package/dist/node.js +1 -0
- package/dist/runtime/adapter-express.js +24 -22
- package/dist/runtime/adapter-fastify.js +24 -22
- package/dist/runtime/adapter-nestjs.js +24 -22
- package/dist/runtime/adapter-nextjs.js +24 -22
- package/dist/runtime/adapter-tanstack-cloudflare.js +240 -0
- package/dist/runtime/adapter-tanstack.js +244 -0
- package/dist/runtime/cloudflare-worker.js +32 -30
- package/dist/runtime/contexts/request-context.d.ts +24 -0
- package/dist/runtime/headers.js +1 -1
- package/dist/runtime/http.js +46 -44
- package/dist/runtime/stdio.js +19 -17
- package/dist/runtime/utils/content.d.ts +7 -0
- package/dist/runtime/utils/mcp-middleware.d.ts +14 -0
- package/dist/runtime/utils/server.d.ts +2 -1
- package/dist/runtime/utils/tools.d.ts +2 -1
- package/dist/runtime/utils/transformers/prompt.d.ts +7 -5
- package/dist/runtime/utils/transformers/tool.d.ts +1 -0
- package/dist/runtime/vercel.js +46 -44
- package/dist/types/declarations.d.ts +3 -0
- package/dist/types/mcp-middleware.d.ts +17 -0
- package/dist/types/prompt.d.ts +1 -0
- package/dist/types/resource.d.ts +3 -0
- package/dist/utils/context.d.ts +3 -1
- package/package.json +9 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let e,t,r,i,n,a,o,s,l,c,d,u,p,m;import{AsyncLocalStorage as h}from"async_hooks";var f,g,y,v,_,b,S,w,k,R,x,C,$,T={},E={};function P(e){var t=E[e];if(void 0!==t)return t.exports;var r=E[e]={exports:{}};return T[e](r,r.exports,P),r.exports}P.d=(e,t)=>{for(var r in t)P.o(t,r)&&!P.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},P.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),P.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var I={};P.d(I,{A:()=>me});var q=Object.create,O=Object.defineProperty,j=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyNames,L=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;let A=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),M=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Z=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),U=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]),H=Object.freeze({status:"aborted"});function F(e,t,r){function i(r,i){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:i,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,i);let n=o.prototype,a=Object.keys(n);for(let e=0;e<a.length;e++){let t=a[e];t in r||(r[t]=n[t].bind(r))}}let n=r?.Parent??Object;class a extends n{}function o(e){var t;let n=r?.Parent?new a:this;for(let r of(i(n,e),(t=n._zod).deferred??(t.deferred=[]),n._zod.deferred))r();return n}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class V extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class D extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(S=globalThis).__zod_globalConfig??(S.__zod_globalConfig={});let J=globalThis.__zod_globalConfig;function B(e){return e&&Object.assign(J,e),J}let W=/^[cC][0-9a-z]{6,}$/,G=/^[0-9a-z]+$/,K=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Y=/^[0-9a-vA-V]{20}$/,X=/^[A-Za-z0-9]{27}$/,Q=/^[a-zA-Z0-9_-]{21}$/,ee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,et=/^([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})$/,er=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)$/,ei=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,en=/^(?:(?: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])$/,ea=/^(([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}|:))$/,eo=/^((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])$/,es=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,el=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ec=/^[A-Za-z0-9_-]*$/,ed=/^https?$/,eu=/^\+[1-9]\d{6,14}$/,ep="(?:(?:\\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])))",em=RegExp(`^${ep}$`);function eh(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}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let ef=/^-?\d+$/,eg=/^-?\d+(?:\.\d+)?$/,ey=/^(?:true|false)$/i,ev=/^null$/i,e_=/^[^A-Z]*$/,eb=/^[^a-z]*$/;function eS(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 ew(e,t){return"bigint"==typeof t?t.toString():t}function ek(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function eR(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let ex=Symbol("evaluating");function eC(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==ex)return void 0===i&&(i=ex,i=r()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function e$(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function eT(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function eE(e){return JSON.stringify(e)}let eP="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function eI(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eq=ek(()=>{if(J.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function eO(e){if(!1===eI(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==eI(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ej(e){return eO(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let ez=new Set(["string","number","symbol"]);function eL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eN(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function eA(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}let eM={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]};function eZ(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 eU(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eH(e){return"string"==typeof e?e:e?.message}function eF(e,t,r){let i=e.message?e.message:eH(e.inst?._zod.def?.error?.(e))??eH(t?.error?.(e))??eH(r.customError?.(e))??eH(r.localeError?.(e))??"Invalid input",{inst:n,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=i,t?.reportInput&&(s.input=o),s}function eV(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eD(...e){let[t,r,i]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:i}:{...t}}let eJ=F("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),eB={number:"number",bigint:"bigint",object:"date"},eW=F("$ZodCheckLessThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin: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})}}),eG=F("$ZodCheckGreaterThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin: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})}}),eK=F("$ZodCheckMultipleOf",(e,t)=>{eJ.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{let i,n,a;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0==(n=Math.round(i=r.value/t.value),a=Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<a?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})}}),eY=F("$ZodCheckNumberFormat",(e,t)=>{eJ.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=eM[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=a,r&&(i.pattern=ef)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.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}):o.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&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),eX=F("$ZodCheckMaxLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;if(i.length<=t.maximum)return;let n=eV(i);r.issues.push({origin:n,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),eQ=F("$ZodCheckMinLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;if(i.length>=t.minimum)return;let n=eV(i);r.issues.push({origin:n,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),e0=F("$ZodCheckLengthEquals",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let i=r.value,n=i.length;if(n===t.length)return;let a=eV(i),o=n>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),e1=F("$ZodCheckStringFormat",(e,t)=>{var r,i;eJ.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),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=()=>{})}),e2=F("$ZodCheckRegex",(e,t)=>{e1.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})}}),e9=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=e_),e1.init(e,t)}),e4=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=eb),e1.init(e,t)}),e5=F("$ZodCheckIncludes",(e,t)=>{eJ.init(e,t);let r=eL(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(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})}}),e3=F("$ZodCheckStartsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`^${eL(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(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})}}),e6=F("$ZodCheckEndsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`.*${eL(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(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})}}),e7=F("$ZodCheckOverwrite",(e,t)=>{eJ.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class e8{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),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(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let te=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ew,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},tt=F("$ZodError",te),tr=F("$ZodError",te,{Parent:Error}),ti=e=>(t,r,i,n)=>{let a=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new V;if(o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},tn=e=>async(t,r,i,n)=>{let a=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},ta=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new V;return a.issues.length?{success:!1,error:new(e??tt)(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},to=ta(tr),ts=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},tl=ts(tr),tc={major:4,minor:4,patch:3},td=F("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tc;let i=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&i.unshift(e),i))for(let r of t._zod.onattach)r(e);if(0===i.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let i,n=eZ(e);for(let a of t){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}(e)||!a._zod.def.when(e))continue}else if(n)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&r?.async===!1)throw new V;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(n||(n=eZ(e,t)))});else{if(e.issues.length===t)continue;n||(n=eZ(e,t))}}return i?i.then(()=>e):e},r=(r,n,a)=>{if(eZ(r))return r.aborted=!0,r;let o=t(n,i,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(n,a)=>{if(a.skipChecks)return e._zod.parse(n,a);if("backward"===a.direction){let t=e._zod.parse({value:n.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,n,a)):r(t,n,a)}let o=e._zod.parse(n,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(e=>t(e,i,a))}return t(o,i,a)}}eC(e,"~standard",()=>({validate:t=>{try{let r=to(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return tl(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),tu=F("$ZodString",(e,t)=>{var r;let i;td.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(i=(r=e._zod.bag)?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*",RegExp(`^${i}$`)),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}}),tp=F("$ZodStringFormat",(e,t)=>{e1.init(e,t),tu.init(e,t)}),tm=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=et),tp.init(e,t)}),th=F("$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=er(e))}else t.pattern??(t.pattern=er());tp.init(e,t)}),tf=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ei),tp.init(e,t)}),tg=F("$ZodURL",(e,t)=>{tp.init(e,t),e._zod.check=r=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===ed.source&&!/^https?:\/\//i.test(i))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});let n=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.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&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=i;return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ty=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),tp.init(e,t)}),tv=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Q),tp.init(e,t)}),t_=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=W),tp.init(e,t)}),tb=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=G),tp.init(e,t)}),tS=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=K),tp.init(e,t)}),tw=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Y),tp.init(e,t)}),tk=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=X),tp.init(e,t)}),tR=F("$ZodISODateTime",(e,t)=>{let r,i,n;t.pattern??(r=eh({precision:t.precision}),i=["Z"],t.local&&i.push(""),t.offset&&i.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),n=`${r}(?:${i.join("|")})`,t.pattern=RegExp(`^${ep}T(?:${n})$`)),tp.init(e,t)}),tx=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=em),tp.init(e,t)}),tC=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${eh(t)}$`)),tp.init(e,t)}),t$=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ee),tp.init(e,t)}),tT=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=en),tp.init(e,t),e._zod.bag.format="ipv4"}),tE=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ea),tp.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),tP=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eo),tp.init(e,t)}),tI=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=es),tp.init(e,t),e._zod.check=r=>{let i=r.value.split("/");try{if(2!==i.length)throw Error();let[e,t]=i;if(!t)throw Error();let r=Number(t);if(`${r}`!==t||r<0||r>128)throw Error();new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function tq(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let tO=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=el),tp.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{tq(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),tj=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ec),tp.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!ec.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return tq(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})}}),tz=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=eu),tp.init(e,t)}),tL=F("$ZodJWT",(e,t)=>{tp.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})}}),tN=F("$ZodNumber",(e,t)=>{td.init(e,t),e._zod.pattern=e._zod.bag.pattern??eg,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 a="number"==typeof n?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...a?{received:a}:{}}),r}}),tA=F("$ZodNumberFormat",(e,t)=>{eY.init(e,t),tN.init(e,t)}),tM=F("$ZodBoolean",(e,t)=>{td.init(e,t),e._zod.pattern=ey,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}}),tZ=F("$ZodNull",(e,t)=>{td.init(e,t),e._zod.pattern=ev,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}}),tU=F("$ZodAny",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tH=F("$ZodUnknown",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tF=F("$ZodNever",(e,t)=>{td.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function tV(e,t,r){e.issues.length&&t.issues.push(...eU(r,e.issues)),t.value[r]=e.value}let tD=F("$ZodArray",(e,t)=>{td.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let a=[];for(let e=0;e<n.length;e++){let o=n[e],s=t.element._zod.run({value:o,issues:[]},i);s instanceof Promise?a.push(s.then(t=>tV(t,r,e))):tV(s,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function tJ(e,t,r,i,n,a){let o=r in i;if(e.issues.length){if(n&&a&&!o)return;t.issues.push(...eU(r,e.issues))}if(!o&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?o&&(t.value[r]=void 0):t.value[r]=e.value}function tB(e){var t;let r=Object.keys(e.shape);for(let t of r)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${t}": expected a Zod schema`);let i=Object.keys(t=e.shape).filter(e=>"optional"===t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,keys:r,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(i)}}function tW(e,t,r,i,n,a){let o=[],s=n.keySet,l=n.catchall._zod,c=l.def.type,d="optional"===l.optin,u="optional"===l.optout;for(let n in t){if("__proto__"===n||s.has(n))continue;if("never"===c){o.push(n);continue}let a=l.run({value:t[n],issues:[]},i);a instanceof Promise?e.push(a.then(e=>tJ(e,r,n,t,d,u))):tJ(a,r,n,t,d,u)}return(o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length)?Promise.all(e).then(()=>r):r}let tG=F("$ZodObject",(e,t)=>{let r;td.init(e,t);let i=Object.getOwnPropertyDescriptor(t,"shape");if(!i?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}let n=ek(()=>tB(t));eC(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let i=e[t]._zod;if(i.values)for(let e of(r[t]??(r[t]=new Set),i.values))r[t].add(e)}return r});let a=t.catchall;e._zod.parse=(t,i)=>{r??(r=n.value);let o=t.value;if(!eI(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};let s=[],l=r.shape;for(let e of r.keys){let r=l[e],n="optional"===r._zod.optin,a="optional"===r._zod.optout,c=r._zod.run({value:o[e],issues:[]},i);c instanceof Promise?s.push(c.then(r=>tJ(r,t,e,o,n,a))):tJ(c,t,e,o,n,a)}return a?tW(s,o,t,i,n.value,e):s.length?Promise.all(s).then(()=>t):t}}),tK=F("$ZodObjectJIT",(e,t)=>{let r,i;tG.init(e,t);let n=e._zod.parse,a=ek(()=>tB(t)),o=!J.jitless,s=o&&eq.value,l=t.catchall;e._zod.parse=(c,d)=>{i??(i=a.value);let u=c.value;return eI(u)?o&&s&&d?.async===!1&&!0!==d.jitless?(r||(r=(e=>{let t=new e8(["shape","payload","ctx"]),r=a.value,i=e=>{let t=eE(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let n=Object.create(null),o=0;for(let e of r.keys)n[e]=`key_${o++}`;for(let a of(t.write("const newResult = {};"),r.keys)){let r=n[a],o=eE(a),s=e[a],l=s?._zod?.optin==="optional",c=s?._zod?.optout==="optional";t.write(`const ${r} = ${i(a)};`),l&&c?t.write(`
|
|
1
|
+
let e,t,r,i,n,a,o,s,l,c,d,u,p,m;import{AsyncLocalStorage as h}from"async_hooks";var f,g,y,v,_,b,S,w,R,k,x,C,$,T={},E={};function P(e){var t=E[e];if(void 0!==t)return t.exports;var r=E[e]={exports:{}};return T[e](r,r.exports,P),r.exports}P.d=(e,t)=>{for(var r in t)P.o(t,r)&&!P.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},P.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),P.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var I={};P.d(I,{A:()=>ma});var q=Object.create,O=Object.defineProperty,j=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyNames,L=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;let A=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),M=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Z=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),U=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]),H=Object.freeze({status:"aborted"});function F(e,t,r){function i(r,i){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:i,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,i);let n=o.prototype,a=Object.keys(n);for(let e=0;e<a.length;e++){let t=a[e];t in r||(r[t]=n[t].bind(r))}}let n=r?.Parent??Object;class a extends n{}function o(e){var t;let n=r?.Parent?new a:this;for(let r of(i(n,e),(t=n._zod).deferred??(t.deferred=[]),n._zod.deferred))r();return n}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class V extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class D extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(S=globalThis).__zod_globalConfig??(S.__zod_globalConfig={});let J=globalThis.__zod_globalConfig;function B(e){return e&&Object.assign(J,e),J}let W=/^[cC][0-9a-z]{6,}$/,G=/^[0-9a-z]+$/,K=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Y=/^[0-9a-vA-V]{20}$/,X=/^[A-Za-z0-9]{27}$/,Q=/^[a-zA-Z0-9_-]{21}$/,ee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,et=/^([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})$/,er=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)$/,ei=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,en=/^(?:(?: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])$/,ea=/^(([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}|:))$/,eo=/^((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])$/,es=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,el=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ec=/^[A-Za-z0-9_-]*$/,ed=/^https?$/,eu=/^\+[1-9]\d{6,14}$/,ep="(?:(?:\\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])))",em=RegExp(`^${ep}$`);function eh(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}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let ef=/^-?\d+$/,eg=/^-?\d+(?:\.\d+)?$/,ey=/^(?:true|false)$/i,ev=/^null$/i,e_=/^[^A-Z]*$/,eb=/^[^a-z]*$/;function eS(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 ew(e,t){return"bigint"==typeof t?t.toString():t}function eR(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ek(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let ex=Symbol("evaluating");function eC(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==ex)return void 0===i&&(i=ex,i=r()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function e$(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function eT(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function eE(e){return JSON.stringify(e)}let eP="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function eI(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eq=eR(()=>{if(J.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function eO(e){if(!1===eI(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==eI(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ej(e){return eO(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let ez=new Set(["string","number","symbol"]);function eL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eN(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function eA(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}let eM={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]};function eZ(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 eU(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eH(e){return"string"==typeof e?e:e?.message}function eF(e,t,r){let i=e.message?e.message:eH(e.inst?._zod.def?.error?.(e))??eH(t?.error?.(e))??eH(r.customError?.(e))??eH(r.localeError?.(e))??"Invalid input",{inst:n,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=i,t?.reportInput&&(s.input=o),s}function eV(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eD(...e){let[t,r,i]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:i}:{...t}}let eJ=F("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),eB={number:"number",bigint:"bigint",object:"date"},eW=F("$ZodCheckLessThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin: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})}}),eG=F("$ZodCheckGreaterThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin: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})}}),eK=F("$ZodCheckMultipleOf",(e,t)=>{eJ.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{let i,n,a;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0==(n=Math.round(i=r.value/t.value),a=Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<a?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})}}),eY=F("$ZodCheckNumberFormat",(e,t)=>{eJ.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=eM[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=a,r&&(i.pattern=ef)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.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}):o.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&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),eX=F("$ZodCheckMaxLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;if(i.length<=t.maximum)return;let n=eV(i);r.issues.push({origin:n,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),eQ=F("$ZodCheckMinLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;if(i.length>=t.minimum)return;let n=eV(i);r.issues.push({origin:n,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),e0=F("$ZodCheckLengthEquals",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let i=r.value,n=i.length;if(n===t.length)return;let a=eV(i),o=n>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),e1=F("$ZodCheckStringFormat",(e,t)=>{var r,i;eJ.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),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=()=>{})}),e2=F("$ZodCheckRegex",(e,t)=>{e1.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})}}),e9=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=e_),e1.init(e,t)}),e4=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=eb),e1.init(e,t)}),e5=F("$ZodCheckIncludes",(e,t)=>{eJ.init(e,t);let r=eL(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(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})}}),e3=F("$ZodCheckStartsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`^${eL(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(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})}}),e6=F("$ZodCheckEndsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`.*${eL(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(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})}}),e7=F("$ZodCheckOverwrite",(e,t)=>{eJ.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class e8{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),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(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let te=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ew,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},tt=F("$ZodError",te),tr=F("$ZodError",te,{Parent:Error}),ti=e=>(t,r,i,n)=>{let a=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new V;if(o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},tn=e=>async(t,r,i,n)=>{let a=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},ta=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new V;return a.issues.length?{success:!1,error:new(e??tt)(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},to=ta(tr),ts=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},tl=ts(tr),tc={major:4,minor:4,patch:3},td=F("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tc;let i=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&i.unshift(e),i))for(let r of t._zod.onattach)r(e);if(0===i.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let i,n=eZ(e);for(let a of t){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}(e)||!a._zod.def.when(e))continue}else if(n)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&r?.async===!1)throw new V;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(n||(n=eZ(e,t)))});else{if(e.issues.length===t)continue;n||(n=eZ(e,t))}}return i?i.then(()=>e):e},r=(r,n,a)=>{if(eZ(r))return r.aborted=!0,r;let o=t(n,i,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(n,a)=>{if(a.skipChecks)return e._zod.parse(n,a);if("backward"===a.direction){let t=e._zod.parse({value:n.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,n,a)):r(t,n,a)}let o=e._zod.parse(n,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(e=>t(e,i,a))}return t(o,i,a)}}eC(e,"~standard",()=>({validate:t=>{try{let r=to(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return tl(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),tu=F("$ZodString",(e,t)=>{var r;let i;td.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(i=(r=e._zod.bag)?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*",RegExp(`^${i}$`)),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}}),tp=F("$ZodStringFormat",(e,t)=>{e1.init(e,t),tu.init(e,t)}),tm=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=et),tp.init(e,t)}),th=F("$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=er(e))}else t.pattern??(t.pattern=er());tp.init(e,t)}),tf=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ei),tp.init(e,t)}),tg=F("$ZodURL",(e,t)=>{tp.init(e,t),e._zod.check=r=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===ed.source&&!/^https?:\/\//i.test(i))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});let n=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.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&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=i;return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ty=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),tp.init(e,t)}),tv=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Q),tp.init(e,t)}),t_=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=W),tp.init(e,t)}),tb=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=G),tp.init(e,t)}),tS=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=K),tp.init(e,t)}),tw=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Y),tp.init(e,t)}),tR=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=X),tp.init(e,t)}),tk=F("$ZodISODateTime",(e,t)=>{let r,i,n;t.pattern??(r=eh({precision:t.precision}),i=["Z"],t.local&&i.push(""),t.offset&&i.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),n=`${r}(?:${i.join("|")})`,t.pattern=RegExp(`^${ep}T(?:${n})$`)),tp.init(e,t)}),tx=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=em),tp.init(e,t)}),tC=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${eh(t)}$`)),tp.init(e,t)}),t$=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ee),tp.init(e,t)}),tT=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=en),tp.init(e,t),e._zod.bag.format="ipv4"}),tE=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ea),tp.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),tP=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eo),tp.init(e,t)}),tI=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=es),tp.init(e,t),e._zod.check=r=>{let i=r.value.split("/");try{if(2!==i.length)throw Error();let[e,t]=i;if(!t)throw Error();let r=Number(t);if(`${r}`!==t||r<0||r>128)throw Error();new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function tq(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let tO=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=el),tp.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{tq(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),tj=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ec),tp.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!ec.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return tq(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})}}),tz=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=eu),tp.init(e,t)}),tL=F("$ZodJWT",(e,t)=>{tp.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})}}),tN=F("$ZodNumber",(e,t)=>{td.init(e,t),e._zod.pattern=e._zod.bag.pattern??eg,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 a="number"==typeof n?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...a?{received:a}:{}}),r}}),tA=F("$ZodNumberFormat",(e,t)=>{eY.init(e,t),tN.init(e,t)}),tM=F("$ZodBoolean",(e,t)=>{td.init(e,t),e._zod.pattern=ey,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}}),tZ=F("$ZodNull",(e,t)=>{td.init(e,t),e._zod.pattern=ev,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}}),tU=F("$ZodAny",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tH=F("$ZodUnknown",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tF=F("$ZodNever",(e,t)=>{td.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function tV(e,t,r){e.issues.length&&t.issues.push(...eU(r,e.issues)),t.value[r]=e.value}let tD=F("$ZodArray",(e,t)=>{td.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let a=[];for(let e=0;e<n.length;e++){let o=n[e],s=t.element._zod.run({value:o,issues:[]},i);s instanceof Promise?a.push(s.then(t=>tV(t,r,e))):tV(s,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function tJ(e,t,r,i,n,a){let o=r in i;if(e.issues.length){if(n&&a&&!o)return;t.issues.push(...eU(r,e.issues))}if(!o&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?o&&(t.value[r]=void 0):t.value[r]=e.value}function tB(e){var t;let r=Object.keys(e.shape);for(let t of r)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${t}": expected a Zod schema`);let i=Object.keys(t=e.shape).filter(e=>"optional"===t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,keys:r,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(i)}}function tW(e,t,r,i,n,a){let o=[],s=n.keySet,l=n.catchall._zod,c=l.def.type,d="optional"===l.optin,u="optional"===l.optout;for(let n in t){if("__proto__"===n||s.has(n))continue;if("never"===c){o.push(n);continue}let a=l.run({value:t[n],issues:[]},i);a instanceof Promise?e.push(a.then(e=>tJ(e,r,n,t,d,u))):tJ(a,r,n,t,d,u)}return(o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length)?Promise.all(e).then(()=>r):r}let tG=F("$ZodObject",(e,t)=>{let r;td.init(e,t);let i=Object.getOwnPropertyDescriptor(t,"shape");if(!i?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}let n=eR(()=>tB(t));eC(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let i=e[t]._zod;if(i.values)for(let e of(r[t]??(r[t]=new Set),i.values))r[t].add(e)}return r});let a=t.catchall;e._zod.parse=(t,i)=>{r??(r=n.value);let o=t.value;if(!eI(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};let s=[],l=r.shape;for(let e of r.keys){let r=l[e],n="optional"===r._zod.optin,a="optional"===r._zod.optout,c=r._zod.run({value:o[e],issues:[]},i);c instanceof Promise?s.push(c.then(r=>tJ(r,t,e,o,n,a))):tJ(c,t,e,o,n,a)}return a?tW(s,o,t,i,n.value,e):s.length?Promise.all(s).then(()=>t):t}}),tK=F("$ZodObjectJIT",(e,t)=>{let r,i;tG.init(e,t);let n=e._zod.parse,a=eR(()=>tB(t)),o=!J.jitless,s=o&&eq.value,l=t.catchall;e._zod.parse=(c,d)=>{i??(i=a.value);let u=c.value;return eI(u)?o&&s&&d?.async===!1&&!0!==d.jitless?(r||(r=(e=>{let t=new e8(["shape","payload","ctx"]),r=a.value,i=e=>{let t=eE(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let n=Object.create(null),o=0;for(let e of r.keys)n[e]=`key_${o++}`;for(let a of(t.write("const newResult = {};"),r.keys)){let r=n[a],o=eE(a),s=e[a],l=s?._zod?.optin==="optional",c=s?._zod?.optout==="optional";t.write(`const ${r} = ${i(a)};`),l&&c?t.write(`
|
|
2
2
|
if (${r}.issues.length) {
|
|
3
3
|
if (${o} in input) {
|
|
4
4
|
payload.issues = payload.issues.concat(${r}.issues.map(iss => ({
|
|
@@ -57,16 +57,16 @@ let e,t,r,i,n,a,o,s,l,c,d,u,p,m;import{AsyncLocalStorage as h}from"async_hooks";
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
`)}t.write("payload.value = newResult;"),t.write("return payload;");let s=t.compile();return(t,r)=>s(e,t,r)})(t.shape)),c=r(c,d),l)?tW([],u,c,d,i,e):c:n(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c)}});function tY(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=>!eZ(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=>eF(e,i,B())))}),t)}let tX=F("$ZodUnion",(e,t)=>{td.init(e,t),eC(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),eC(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),eC(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),eC(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>eR(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 a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},n);if(t instanceof Promise)o.push(t),a=!0;else{if(0===t.issues.length)return t;o.push(t)}}return a?Promise.all(o).then(t=>tY(t,i,e,n)):tY(o,i,e,n)}}),tQ=F("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,tX.init(e,t);let r=e._zod.parse;eC(e._zod,"propValues",()=>{let e={};for(let r of t.options){let i=r._zod.propValues;if(!i||0===Object.keys(i).length)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let[t,r]of Object.entries(i))for(let i of(e[t]||(e[t]=new Set),r))e[t].add(i)}return e});let i=ek(()=>{let e=t.options,r=new Map;for(let i of e){let e=i._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let t of e){if(r.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,i)}}return r});e._zod.parse=(n,a)=>{let o=n.value;if(!eI(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),n;let s=i.value.get(o?.[t.discriminator]);return s?s._zod.run(n,a):t.unionFallback||"backward"===a.direction?r(n,a):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:o,path:[t.discriminator],inst:e}),n)}}),t0=F("$ZodIntersection",(e,t)=>{td.init(e,t),e._zod.parse=(e,r)=>{let i=e.value,n=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return n instanceof Promise||a instanceof Promise?Promise.all([n,a]).then(([t,r])=>t1(e,t,r)):t1(e,n,a)}});function t1(e,t,r){let i,n=new Map;for(let r of t.issues)if("unrecognized_keys"===r.code)for(let e of(i??(i=r),r.keys))n.has(e)||n.set(e,{}),n.get(e).l=!0;else e.issues.push(r);for(let t of r.issues)if("unrecognized_keys"===t.code)for(let e of t.keys)n.has(e)||n.set(e,{}),n.get(e).r=!0;else e.issues.push(t);let a=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),eZ(e))return e;let o=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(eO(t)&&eO(r)){let i=Object.keys(r),n=Object.keys(t).filter(e=>-1!==i.indexOf(e)),a={...t,...r};for(let i of n){let n=e(t[i],r[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};a[i]=n.data}return{valid:!0,data:a}}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 a=e(t[n],r[n]);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};i.push(a.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let t2=F("$ZodRecord",(e,t)=>{td.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!eO(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let a=[],o=t.keyType._zod.values;if(o){let s;r.value={};let l=new Set;for(let s of o)if("string"==typeof s||"number"==typeof s||"symbol"==typeof s){l.add("number"==typeof s?s.toString():s);let o=t.keyType._zod.run({value:s,issues:[]},i);if(o instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(o.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map(e=>eF(e,i,B())),input:s,path:[s],inst:e});continue}let c=o.value,d=t.valueType._zod.run({value:n[s],issues:[]},i);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&r.issues.push(...eU(s,e.issues)),r.value[c]=e.value})):(d.issues.length&&r.issues.push(...eU(s,d.issues)),r.value[c]=d.value)}for(let e in n)l.has(e)||(s=s??[]).push(e);s&&s.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:s})}else for(let o of(r.value={},Reflect.ownKeys(n))){if("__proto__"===o||!Object.prototype.propertyIsEnumerable.call(n,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof o&&eg.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},i);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?r.value[o]=n[o]:r.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>eF(e,i,B())),input:o,path:[o],inst:e});continue}let l=t.valueType._zod.run({value:n[o],issues:[]},i);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&r.issues.push(...eU(o,e.issues)),r.value[s.value]=e.value})):(l.issues.length&&r.issues.push(...eU(o,l.issues)),r.value[s.value]=l.value)}return a.length?Promise.all(a).then(()=>r):r}}),t9=F("$ZodEnum",(e,t)=>{td.init(e,t);let r=eS(t.entries),i=new Set(r);e._zod.values=i,e._zod.pattern=RegExp(`^(${r.filter(e=>ez.has(typeof e)).map(e=>"string"==typeof e?eL(e):e.toString()).join("|")})$`),e._zod.parse=(t,n)=>{let a=t.value;return i.has(a)||t.issues.push({code:"invalid_value",values:r,input:a,inst:e}),t}}),t4=F("$ZodLiteral",(e,t)=>{if(td.init(e,t),0===t.values.length)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=RegExp(`^(${t.values.map(e=>"string"==typeof e?eL(e):e?eL(e.toString()):String(e)).join("|")})$`),e._zod.parse=(i,n)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),i}}),t5=F("$ZodTransform",(e,t)=>{td.init(e,t),e._zod.optin="optional",e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new D(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.fallback=!0,r));if(n instanceof Promise)throw new V;return r.value=n,r.fallback=!0,r}});function t3(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let t6=F("$ZodOptional",(e,t)=>{td.init(e,t),e._zod.optin="optional",e._zod.optout="optional",eC(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),eC(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${eR(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){let i=e.value,n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>t3(e,i)):t3(n,i)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),t7=F("$ZodExactOptional",(e,t)=>{t6.init(e,t),eC(e._zod,"values",()=>t.innerType._zod.values),eC(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),t8=F("$ZodNullable",(e,t)=>{td.init(e,t),eC(e._zod,"optin",()=>t.innerType._zod.optin),eC(e._zod,"optout",()=>t.innerType._zod.optout),eC(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${eR(e.source)}|null)$`):void 0}),eC(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),re=F("$ZodDefault",(e,t)=>{td.init(e,t),e._zod.optin="optional",eC(e._zod,"values",()=>t.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=>rt(e,t)):rt(i,t)}});function rt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let rr=F("$ZodPrefault",(e,t)=>{td.init(e,t),e._zod.optin="optional",eC(e._zod,"values",()=>t.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))}),ri=F("$ZodNonOptional",(e,t)=>{td.init(e,t),eC(e._zod,"values",()=>{let e=t.innerType._zod.values;return e?new Set([...e].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=>rn(t,e)):rn(n,e)}});function rn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}let ra=F("$ZodCatch",(e,t)=>{td.init(e,t),e._zod.optin="optional",eC(e._zod,"optout",()=>t.innerType._zod.optout),eC(e._zod,"values",()=>t.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(e,r);return i instanceof Promise?i.then(i=>(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>eF(e,r,B()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>eF(e,r,B()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ro=F("$ZodPipe",(e,t)=>{td.init(e,t),eC(e._zod,"values",()=>t.in._zod.values),eC(e._zod,"optin",()=>t.in._zod.optin),eC(e._zod,"optout",()=>t.out._zod.optout),eC(e._zod,"propValues",()=>t.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=>rs(e,t.in,r)):rs(i,t.in,r)}let i=t.in._zod.run(e,r);return i instanceof Promise?i.then(e=>rs(e,t.out,r)):rs(i,t.out,r)}});function rs(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}let rl=F("$ZodPreprocess",(e,t)=>{ro.init(e,t)}),rc=F("$ZodReadonly",(e,t)=>{td.init(e,t),eC(e._zod,"propValues",()=>t.innerType._zod.propValues),eC(e._zod,"values",()=>t.innerType._zod.values),eC(e._zod,"optin",()=>t.innerType?._zod?.optin),eC(e._zod,"optout",()=>t.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(rd):rd(i)}});function rd(e){return e.value=Object.freeze(e.value),e}let ru=F("$ZodLazy",(e,t)=>{td.init(e,t),eC(e._zod,"innerType",()=>(t._cachedInner||(t._cachedInner=t.getter()),t._cachedInner)),eC(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),eC(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),eC(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),eC(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),rp=F("$ZodCustom",(e,t)=>{eJ.init(e,t),td.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=>rm(t,r,i,e));rm(n,r,i,e)}});function rm(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(eD(e))}}Symbol("ZodOutput"),Symbol("ZodInput");(w=globalThis).__zod_globalRegistry??(w.__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 rh=globalThis.__zod_globalRegistry;function rf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...eA(t)})}function rg(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...eA(t)})}function ry(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...eA(t)})}function rv(e,t){return new eW({check:"less_than",...eA(t),value:e,inclusive:!1})}function r_(e,t){return new eW({check:"less_than",...eA(t),value:e,inclusive:!0})}function rb(e,t){return new eG({check:"greater_than",...eA(t),value:e,inclusive:!1})}function rS(e,t){return new eG({check:"greater_than",...eA(t),value:e,inclusive:!0})}function rw(e,t){return new eK({check:"multiple_of",...eA(t),value:e})}function rk(e,t){return new eX({check:"max_length",...eA(t),maximum:e})}function rR(e,t){return new eQ({check:"min_length",...eA(t),minimum:e})}function rx(e,t){return new e0({check:"length_equals",...eA(t),length:e})}function rC(e){return new e7({check:"overwrite",tx:e})}function r$(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??rh,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function rT(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let i={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,i);else{let r=o.schema,a=t.processors[n.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);a(e,t,r,i)}let a=e._zod.parent;a&&(o.ref||(o.ref=a),rT(a,t,i),t.seen.get(a).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&Object.assign(o.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)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 o.schema.examples,delete o.schema.default),"input"===t.io&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function rE(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");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:a}=(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 a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${n("__shared")}#/${i}/${a}`}}if(t[1]===r)return{ref:"#"};let n=`#/${i}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:n+a}})(t);i.def={...i.schema},a&&(i.defId=a);let o=i.schema;for(let e in o)delete o[e];o.$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>
|
|
60
|
+
`)}t.write("payload.value = newResult;"),t.write("return payload;");let s=t.compile();return(t,r)=>s(e,t,r)})(t.shape)),c=r(c,d),l)?tW([],u,c,d,i,e):c:n(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c)}});function tY(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=>!eZ(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=>eF(e,i,B())))}),t)}let tX=F("$ZodUnion",(e,t)=>{td.init(e,t),eC(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),eC(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),eC(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),eC(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ek(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 a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},n);if(t instanceof Promise)o.push(t),a=!0;else{if(0===t.issues.length)return t;o.push(t)}}return a?Promise.all(o).then(t=>tY(t,i,e,n)):tY(o,i,e,n)}}),tQ=F("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,tX.init(e,t);let r=e._zod.parse;eC(e._zod,"propValues",()=>{let e={};for(let r of t.options){let i=r._zod.propValues;if(!i||0===Object.keys(i).length)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let[t,r]of Object.entries(i))for(let i of(e[t]||(e[t]=new Set),r))e[t].add(i)}return e});let i=eR(()=>{let e=t.options,r=new Map;for(let i of e){let e=i._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let t of e){if(r.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,i)}}return r});e._zod.parse=(n,a)=>{let o=n.value;if(!eI(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),n;let s=i.value.get(o?.[t.discriminator]);return s?s._zod.run(n,a):t.unionFallback||"backward"===a.direction?r(n,a):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:o,path:[t.discriminator],inst:e}),n)}}),t0=F("$ZodIntersection",(e,t)=>{td.init(e,t),e._zod.parse=(e,r)=>{let i=e.value,n=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return n instanceof Promise||a instanceof Promise?Promise.all([n,a]).then(([t,r])=>t1(e,t,r)):t1(e,n,a)}});function t1(e,t,r){let i,n=new Map;for(let r of t.issues)if("unrecognized_keys"===r.code)for(let e of(i??(i=r),r.keys))n.has(e)||n.set(e,{}),n.get(e).l=!0;else e.issues.push(r);for(let t of r.issues)if("unrecognized_keys"===t.code)for(let e of t.keys)n.has(e)||n.set(e,{}),n.get(e).r=!0;else e.issues.push(t);let a=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),eZ(e))return e;let o=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(eO(t)&&eO(r)){let i=Object.keys(r),n=Object.keys(t).filter(e=>-1!==i.indexOf(e)),a={...t,...r};for(let i of n){let n=e(t[i],r[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};a[i]=n.data}return{valid:!0,data:a}}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 a=e(t[n],r[n]);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};i.push(a.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let t2=F("$ZodRecord",(e,t)=>{td.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!eO(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let a=[],o=t.keyType._zod.values;if(o){let s;r.value={};let l=new Set;for(let s of o)if("string"==typeof s||"number"==typeof s||"symbol"==typeof s){l.add("number"==typeof s?s.toString():s);let o=t.keyType._zod.run({value:s,issues:[]},i);if(o instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(o.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map(e=>eF(e,i,B())),input:s,path:[s],inst:e});continue}let c=o.value,d=t.valueType._zod.run({value:n[s],issues:[]},i);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&r.issues.push(...eU(s,e.issues)),r.value[c]=e.value})):(d.issues.length&&r.issues.push(...eU(s,d.issues)),r.value[c]=d.value)}for(let e in n)l.has(e)||(s=s??[]).push(e);s&&s.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:s})}else for(let o of(r.value={},Reflect.ownKeys(n))){if("__proto__"===o||!Object.prototype.propertyIsEnumerable.call(n,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof o&&eg.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},i);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?r.value[o]=n[o]:r.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>eF(e,i,B())),input:o,path:[o],inst:e});continue}let l=t.valueType._zod.run({value:n[o],issues:[]},i);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&r.issues.push(...eU(o,e.issues)),r.value[s.value]=e.value})):(l.issues.length&&r.issues.push(...eU(o,l.issues)),r.value[s.value]=l.value)}return a.length?Promise.all(a).then(()=>r):r}}),t9=F("$ZodEnum",(e,t)=>{td.init(e,t);let r=eS(t.entries),i=new Set(r);e._zod.values=i,e._zod.pattern=RegExp(`^(${r.filter(e=>ez.has(typeof e)).map(e=>"string"==typeof e?eL(e):e.toString()).join("|")})$`),e._zod.parse=(t,n)=>{let a=t.value;return i.has(a)||t.issues.push({code:"invalid_value",values:r,input:a,inst:e}),t}}),t4=F("$ZodLiteral",(e,t)=>{if(td.init(e,t),0===t.values.length)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=RegExp(`^(${t.values.map(e=>"string"==typeof e?eL(e):e?eL(e.toString()):String(e)).join("|")})$`),e._zod.parse=(i,n)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),i}}),t5=F("$ZodTransform",(e,t)=>{td.init(e,t),e._zod.optin="optional",e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new D(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.fallback=!0,r));if(n instanceof Promise)throw new V;return r.value=n,r.fallback=!0,r}});function t3(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let t6=F("$ZodOptional",(e,t)=>{td.init(e,t),e._zod.optin="optional",e._zod.optout="optional",eC(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),eC(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ek(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){let i=e.value,n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>t3(e,i)):t3(n,i)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),t7=F("$ZodExactOptional",(e,t)=>{t6.init(e,t),eC(e._zod,"values",()=>t.innerType._zod.values),eC(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),t8=F("$ZodNullable",(e,t)=>{td.init(e,t),eC(e._zod,"optin",()=>t.innerType._zod.optin),eC(e._zod,"optout",()=>t.innerType._zod.optout),eC(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ek(e.source)}|null)$`):void 0}),eC(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),re=F("$ZodDefault",(e,t)=>{td.init(e,t),e._zod.optin="optional",eC(e._zod,"values",()=>t.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=>rt(e,t)):rt(i,t)}});function rt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let rr=F("$ZodPrefault",(e,t)=>{td.init(e,t),e._zod.optin="optional",eC(e._zod,"values",()=>t.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))}),ri=F("$ZodNonOptional",(e,t)=>{td.init(e,t),eC(e._zod,"values",()=>{let e=t.innerType._zod.values;return e?new Set([...e].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=>rn(t,e)):rn(n,e)}});function rn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}let ra=F("$ZodCatch",(e,t)=>{td.init(e,t),e._zod.optin="optional",eC(e._zod,"optout",()=>t.innerType._zod.optout),eC(e._zod,"values",()=>t.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(e,r);return i instanceof Promise?i.then(i=>(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>eF(e,r,B()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>eF(e,r,B()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ro=F("$ZodPipe",(e,t)=>{td.init(e,t),eC(e._zod,"values",()=>t.in._zod.values),eC(e._zod,"optin",()=>t.in._zod.optin),eC(e._zod,"optout",()=>t.out._zod.optout),eC(e._zod,"propValues",()=>t.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=>rs(e,t.in,r)):rs(i,t.in,r)}let i=t.in._zod.run(e,r);return i instanceof Promise?i.then(e=>rs(e,t.out,r)):rs(i,t.out,r)}});function rs(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}let rl=F("$ZodPreprocess",(e,t)=>{ro.init(e,t)}),rc=F("$ZodReadonly",(e,t)=>{td.init(e,t),eC(e._zod,"propValues",()=>t.innerType._zod.propValues),eC(e._zod,"values",()=>t.innerType._zod.values),eC(e._zod,"optin",()=>t.innerType?._zod?.optin),eC(e._zod,"optout",()=>t.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(rd):rd(i)}});function rd(e){return e.value=Object.freeze(e.value),e}let ru=F("$ZodLazy",(e,t)=>{td.init(e,t),eC(e._zod,"innerType",()=>(t._cachedInner||(t._cachedInner=t.getter()),t._cachedInner)),eC(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),eC(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),eC(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),eC(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),rp=F("$ZodCustom",(e,t)=>{eJ.init(e,t),td.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=>rm(t,r,i,e));rm(n,r,i,e)}});function rm(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(eD(e))}}Symbol("ZodOutput"),Symbol("ZodInput");(w=globalThis).__zod_globalRegistry??(w.__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 rh=globalThis.__zod_globalRegistry;function rf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...eA(t)})}function rg(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...eA(t)})}function ry(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...eA(t)})}function rv(e,t){return new eW({check:"less_than",...eA(t),value:e,inclusive:!1})}function r_(e,t){return new eW({check:"less_than",...eA(t),value:e,inclusive:!0})}function rb(e,t){return new eG({check:"greater_than",...eA(t),value:e,inclusive:!1})}function rS(e,t){return new eG({check:"greater_than",...eA(t),value:e,inclusive:!0})}function rw(e,t){return new eK({check:"multiple_of",...eA(t),value:e})}function rR(e,t){return new eX({check:"max_length",...eA(t),maximum:e})}function rk(e,t){return new eQ({check:"min_length",...eA(t),minimum:e})}function rx(e,t){return new e0({check:"length_equals",...eA(t),length:e})}function rC(e){return new e7({check:"overwrite",tx:e})}function r$(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??rh,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function rT(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let i={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,i);else{let r=o.schema,a=t.processors[n.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);a(e,t,r,i)}let a=e._zod.parent;a&&(o.ref||(o.ref=a),rT(a,t,i),t.seen.get(a).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&Object.assign(o.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)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 o.schema.examples,delete o.schema.default),"input"===t.io&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function rE(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");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:a}=(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 a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${n("__shared")}#/${i}/${a}`}}if(t[1]===r)return{ref:"#"};let n=`#/${i}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:n+a}})(t);i.def={...i.schema},a&&(i.defId=a);let o=i.schema;for(let e in o)delete o[e];o.$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>
|
|
61
61
|
|
|
62
|
-
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||i.count>1&&"ref"===e.reused){n(r);continue}}}function rP(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,a={...n},o=r.ref;if(r.ref=null,o){i(o);let r=e.seen.get(o),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)):Object.assign(n,s),Object.assign(n,a),t._zod.parent===o)for(let e in n)"$ref"!==e&&"allOf"!==e&&(e in a||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!==o){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??[]})};for(let t of[...e.seen.entries()].reverse())i(t[0]);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)}Object.assign(n,r.def??r.schema);let a=e.metadataRegistry.get(t)?.id;void 0!==a&&n.id===a&&delete n.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?n.$defs=o:n.definitions=o);try{let r=JSON.parse(JSON.stringify(n));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:rI(t,"input",e.processors),output:rI(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let rI=(e,t,r={})=>i=>{let{libraryOptions:n,target:a}=i??{},o=r$({...n??{},target:a,io:t,processors:r});return rT(e,o),rE(o,e),rP(o,e)},rq={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},rO=(e,t,r,i)=>{r.type="string";let{minimum:n,maximum:a,format:o,patterns:s,contentEncoding:l}=e._zod.bag;if("number"==typeof n&&(r.minLength=n),"number"==typeof a&&(r.maxLength=a),o&&(r.format=rq[o]??o,""===r.format&&delete r.format,"time"===o&&delete r.format),l&&(r.contentEncoding=l),s&&s.size>0){let e=[...s];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}))])}},rj=(e,t,r,i)=>{let{minimum:n,maximum:a,format:o,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:c}=e._zod.bag;"string"==typeof o&&o.includes("int")?r.type="integer":r.type="number";let d="number"==typeof c&&c>=(n??-1/0),u="number"==typeof l&&l<=(a??1/0),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c:"number"==typeof n&&(r.minimum=n),u?p?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l:"number"==typeof a&&(r.maximum=a),"number"==typeof s&&(r.multipleOf=s)},rz=(e,t,r,i)=>{r.type="boolean"},rL=(e,t,r,i)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},rN=(e,t,r,i)=>{r.not={}},rA=(e,t,r,i)=>{},rM=(e,t,r,i)=>{},rZ=(e,t,r,i)=>{let n=eS(e._zod.def.entries);n.every(e=>"number"==typeof e)&&(r.type="number"),n.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=n},rU=(e,t,r,i)=>{let n=e._zod.def,a=[];for(let e of n.values)if(void 0===e){if("throw"===t.unrepresentable)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e)if("throw"===t.unrepresentable)throw Error("BigInt literals cannot be represented in JSON Schema");else a.push(Number(e));else a.push(e);if(0===a.length);else if(1===a.length){let e=a[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else a.every(e=>"number"==typeof e)&&(r.type="number"),a.every(e=>"string"==typeof e)&&(r.type="string"),a.every(e=>"boolean"==typeof e)&&(r.type="boolean"),a.every(e=>null===e)&&(r.type="null"),r.enum=a},rH=(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Custom types cannot be represented in JSON Schema")},rF=(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Transforms cannot be represented in JSON Schema")},rV=(e,t,r,i)=>{let n=e._zod.def,{minimum:a,maximum:o}=e._zod.bag;"number"==typeof a&&(r.minItems=a),"number"==typeof o&&(r.maxItems=o),r.type="array",r.items=rT(n.element,t,{...i,path:[...i.path,"items"]})},rD=(e,t,r,i)=>{let n=e._zod.def;r.type="object",r.properties={};let a=n.shape;for(let e in a)r.properties[e]=rT(a[e],t,{...i,path:[...i.path,"properties",e]});let o=new Set([...new Set(Object.keys(a))].filter(e=>{let r=n.shape[e]._zod;return"input"===t.io?void 0===r.optin:void 0===r.optout}));o.size>0&&(r.required=Array.from(o)),n.catchall?._zod.def.type==="never"?r.additionalProperties=!1:n.catchall?n.catchall&&(r.additionalProperties=rT(n.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)},rJ=(e,t,r,i)=>{let n=e._zod.def,a=!1===n.inclusive,o=n.options.map((e,r)=>rT(e,t,{...i,path:[...i.path,a?"oneOf":"anyOf",r]}));a?r.oneOf=o:r.anyOf=o},rB=(e,t,r,i)=>{let n=e._zod.def,a=rT(n.left,t,{...i,path:[...i.path,"allOf",0]}),o=rT(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;r.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},rW=(e,t,r,i)=>{let n=e._zod.def;r.type="object";let a=n.keyType,o=a._zod.bag,s=o?.patterns;if("loose"===n.mode&&s&&s.size>0){let e=rT(n.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});for(let t of(r.patternProperties={},s))r.patternProperties[t.source]=e}else("draft-07"===t.target||"draft-2020-12"===t.target)&&(r.propertyNames=rT(n.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=rT(n.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let l=a._zod.values;if(l){let e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(r.required=e)}},rG=(e,t,r,i)=>{let n=e._zod.def,a=rT(n.innerType,t,i),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},rK=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType},rY=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},rX=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},rQ=(e,t,r,i)=>{let n,a=e._zod.def;rT(a.innerType,t,i),t.seen.get(e).ref=a.innerType;try{n=a.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=n},r0=(e,t,r,i)=>{let n=e._zod.def,a=n.in._zod.traits.has("$ZodTransform"),o="input"===t.io?a?n.out:n.in:n.out;rT(o,t,i),t.seen.get(e).ref=o},r1=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType,r.readOnly=!0},r2=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType},r9=(e,t,r,i)=>{let n=e._zod.innerType;rT(n,t,i),t.seen.get(e).ref=n},r4={string:rO,number:rj,boolean:rz,bigint:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("BigInt cannot be represented in JSON Schema")},symbol:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Symbols cannot be represented in JSON Schema")},null:rL,undefined:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Undefined cannot be represented in JSON Schema")},void:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Void cannot be represented in JSON Schema")},never:rN,any:rA,unknown:rM,date:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Date cannot be represented in JSON Schema")},enum:rZ,literal:rU,nan:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("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)=>{let n={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:s}=e._zod.bag;void 0!==a&&(n.minLength=a),void 0!==o&&(n.maxLength=o),s?1===s.length?(n.contentMediaType=s[0],Object.assign(r,n)):(Object.assign(r,n),r.anyOf=s.map(e=>({contentMediaType:e}))):Object.assign(r,n)},success:(e,t,r,i)=>{r.type="boolean"},custom:rH,function:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Function types cannot be represented in JSON Schema")},transform:rF,map:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Map cannot be represented in JSON Schema")},set:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Set cannot be represented in JSON Schema")},array:rV,object:rD,union:rJ,intersection:rB,tuple:(e,t,r,i)=>{let n=e._zod.def;r.type="array";let a="draft-2020-12"===t.target?"prefixItems":"items",o="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",s=n.items.map((e,r)=>rT(e,t,{...i,path:[...i.path,a,r]})),l=n.rest?rT(n.rest,t,{...i,path:[...i.path,o,..."openapi-3.0"===t.target?[n.items.length]:[]]}):null;"draft-2020-12"===t.target?(r.prefixItems=s,l&&(r.items=l)):"openapi-3.0"===t.target?(r.items={anyOf:s},l&&r.items.anyOf.push(l),r.minItems=s.length,l||(r.maxItems=s.length)):(r.items=s,l&&(r.additionalItems=l));let{minimum:c,maximum:d}=e._zod.bag;"number"==typeof c&&(r.minItems=c),"number"==typeof d&&(r.maxItems=d)},record:rW,nullable:rG,nonoptional:rK,default:rY,prefault:rX,catch:rQ,pipe:r0,readonly:r1,promise:(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType},optional:r2,lazy:r9};function r5(e,t){if("_idmap"in e){let r=r$({...t,processors:r4}),i={};for(let t of e._idmap.entries()){let[e,i]=t;rT(i,r)}let n={};for(let a of(r.external={registry:e,uri:t?.uri,defs:i},e._idmap.entries())){let[e,t]=a;rE(r,t),n[e]=rP(r,t)}return Object.keys(i).length>0&&(n.__shared={["draft-2020-12"===r.target?"$defs":"definitions"]:i}),{schemas:n}}let r=r$({...t,processors:r4});return rT(e,r),rE(r,e),rP(r,e)}let r3=F("ZodISODateTime",(e,t)=>{tR.init(e,t),ik.init(e,t)});function r6(e){return new r3({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...eA(e)})}let r7=F("ZodISODate",(e,t)=>{tx.init(e,t),ik.init(e,t)});function r8(e){return new r7({type:"string",format:"date",check:"string_format",...eA(e)})}let ie=F("ZodISOTime",(e,t)=>{tC.init(e,t),ik.init(e,t)}),it=F("ZodISODuration",(e,t)=>{t$.init(e,t),ik.init(e,t)}),ir=F("ZodError",(e,t)=>{tt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>(function(e,t=e=>e.message){let r={_errors:[]},i=(e,n=[])=>{for(let a of e.issues)if("invalid_union"===a.code&&a.errors.length)a.errors.map(e=>i({issues:e},[...n,...a.path]));else if("invalid_key"===a.code)i({issues:a.issues},[...n,...a.path]);else if("invalid_element"===a.code)i({issues:a.issues},[...n,...a.path]);else{let e=[...n,...a.path];if(0===e.length)r._errors.push(t(a));else{let i=r,n=0;for(;n<e.length;){let r=e[n];n===e.length-1?(i[r]=i[r]||{_errors:[]},i[r]._errors.push(t(a))):i[r]=i[r]||{_errors:[]},i=i[r],n++}}}};return i(e),r})(e,t)},flatten:{value:t=>(function(e,t=e=>e.message){let r={},i=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):i.push(t(n));return{formErrors:i,fieldErrors:r}})(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ew,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ew,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),ii=ti(ir),ia=tn(ir),io=ta(ir),is=ts(ir),il=(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ti(ir)(e,t,i)},ic=(e,t,r)=>ti(ir)(e,t,r),id=async(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return tn(ir)(e,t,i)},iu=async(e,t,r)=>tn(ir)(e,t,r),ip=(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ta(ir)(e,t,i)},im=(e,t,r)=>ta(ir)(e,t,r),ih=async(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ts(ir)(e,t,i)},ig=async(e,t,r)=>ts(ir)(e,t,r),iy=new WeakMap;function iv(e,t,r){let i=Object.getPrototypeOf(e),n=iy.get(i);if(n||(n=new Set,iy.set(i,n)),!n.has(t))for(let e in n.add(t),r){let t=r[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,get(){let r=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:r}),r},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}let i_=F("ZodType",(e,t)=>(td.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:rI(e,"input"),output:rI(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{let i=r$({...r,processors:t});return rT(e,i),rE(i,e),rP(i,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,r)=>ii(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>io(e,t,r),e.parseAsync=async(t,r)=>ia(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>is(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>il(e,t,r),e.decode=(t,r)=>ic(e,t,r),e.encodeAsync=async(t,r)=>id(e,t,r),e.decodeAsync=async(t,r)=>iu(e,t,r),e.safeEncode=(t,r)=>ip(e,t,r),e.safeDecode=(t,r)=>im(e,t,r),e.safeEncodeAsync=async(t,r)=>ih(e,t,r),e.safeDecodeAsync=async(t,r)=>ig(e,t,r),iv(e,"ZodType",{check(...e){let t=this.def;return this.clone(eT(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 eN(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 nx({type:"custom",check:"custom",fn:e,...eA(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(eD(e,t.value,i._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),e.input??(e.input=t.value),e.inst??(e.inst=i),e.continue??(e.continue=!i._zod.def.abort),t.issues.push(eD(e)))},e(t.value,t)),(n=new eJ({check:"custom",...eA(t)}))._zod.check=r,i=n}(e,t))},overwrite(e){return this.check(rC(e))},optional(){return nu(this)},exactOptional(){var e;return e=this,new np({type:"optional",innerType:e})},nullable(){return nh(this)},nullish(){return nu(nh(this))},nonoptional(e){var t;return t=this,new ny({type:"nonoptional",innerType:t,...eA(e)})},array(){return i2(this)},or(e){return i6([this,e])},and(e){return nt(this,e)},transform(e){return nb(this,nc(e))},default(e){var t,r;return t=this,r=e,new nf({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():ej(r)}})},prefault(e){var t,r;return t=this,r=e,new ng({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():ej(r)}})},catch(e){var t,r;return t=this,new nv({type:"catch",innerType:t,catchValue:"function"==typeof(r=e)?r:()=>r})},pipe(e){return nb(this,e)},readonly(){var e;return e=this,new nw({type:"readonly",innerType:e})},describe(e){let t=this.clone();return rh.add(t,{description:e}),t},meta(...e){if(0===e.length)return rh.get(this);let t=this.clone();return rh.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>rh.get(e)?.description,configurable:!0}),e)),ib=F("_ZodString",(e,t)=>{tu.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rO(e,t,r,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,iv(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new e2({check:"string_format",format:"regex",...eA(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new e5({check:"string_format",format:"includes",...eA(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new e3({check:"string_format",format:"starts_with",...eA(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new e6({check:"string_format",format:"ends_with",...eA(t),suffix:e})}(...e))},min(...e){return this.check(rR(...e))},max(...e){return this.check(rk(...e))},length(...e){return this.check(rx(...e))},nonempty(...e){return this.check(rR(1,...e))},lowercase(e){return this.check(new e9({check:"string_format",format:"lowercase",...eA(e)}))},uppercase(e){return this.check(new e4({check:"string_format",format:"uppercase",...eA(e)}))},trim(){return this.check(rC(e=>e.trim()))},normalize(...e){return this.check(function(e){return rC(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(rC(e=>e.toLowerCase()))},toUpperCase(){return this.check(rC(e=>e.toUpperCase()))},slugify(){return this.check(rC(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})}),iS=F("ZodString",(e,t)=>{tu.init(e,t),ib.init(e,t),e.email=t=>e.check(rf(iR,t)),e.url=t=>e.check(ry(i$,t)),e.jwt=t=>e.check(new iH({type:"string",format:"jwt",check:"string_format",abort:!1,...eA(t)})),e.emoji=t=>e.check(new iT({type:"string",format:"emoji",check:"string_format",abort:!1,...eA(t)})),e.guid=t=>e.check(rg(ix,t)),e.uuid=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,...eA(t)})),e.uuidv4=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...eA(t)})),e.uuidv6=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...eA(t)})),e.uuidv7=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...eA(t)})),e.nanoid=t=>e.check(new iE({type:"string",format:"nanoid",check:"string_format",abort:!1,...eA(t)})),e.guid=t=>e.check(rg(ix,t)),e.cuid=t=>e.check(new iP({type:"string",format:"cuid",check:"string_format",abort:!1,...eA(t)})),e.cuid2=t=>e.check(new iI({type:"string",format:"cuid2",check:"string_format",abort:!1,...eA(t)})),e.ulid=t=>e.check(new iq({type:"string",format:"ulid",check:"string_format",abort:!1,...eA(t)})),e.base64=t=>e.check(new iM({type:"string",format:"base64",check:"string_format",abort:!1,...eA(t)})),e.base64url=t=>e.check(new iZ({type:"string",format:"base64url",check:"string_format",abort:!1,...eA(t)})),e.xid=t=>e.check(new iO({type:"string",format:"xid",check:"string_format",abort:!1,...eA(t)})),e.ksuid=t=>e.check(new ij({type:"string",format:"ksuid",check:"string_format",abort:!1,...eA(t)})),e.ipv4=t=>e.check(new iz({type:"string",format:"ipv4",check:"string_format",abort:!1,...eA(t)})),e.ipv6=t=>e.check(new iL({type:"string",format:"ipv6",check:"string_format",abort:!1,...eA(t)})),e.cidrv4=t=>e.check(new iN({type:"string",format:"cidrv4",check:"string_format",abort:!1,...eA(t)})),e.cidrv6=t=>e.check(new iA({type:"string",format:"cidrv6",check:"string_format",abort:!1,...eA(t)})),e.e164=t=>e.check(new iU({type:"string",format:"e164",check:"string_format",abort:!1,...eA(t)})),e.datetime=t=>e.check(r6(t)),e.date=t=>e.check(r8(t)),e.time=t=>e.check(new ie({type:"string",format:"time",check:"string_format",precision:null,...eA(t)})),e.duration=t=>e.check(new it({type:"string",format:"duration",check:"string_format",...eA(t)}))});function iw(e){return new iS({type:"string",...eA(e)})}let ik=F("ZodStringFormat",(e,t)=>{tp.init(e,t),ib.init(e,t)}),iR=F("ZodEmail",(e,t)=>{tf.init(e,t),ik.init(e,t)}),ix=F("ZodGUID",(e,t)=>{tm.init(e,t),ik.init(e,t)}),iC=F("ZodUUID",(e,t)=>{th.init(e,t),ik.init(e,t)}),i$=F("ZodURL",(e,t)=>{tg.init(e,t),ik.init(e,t)}),iT=F("ZodEmoji",(e,t)=>{ty.init(e,t),ik.init(e,t)}),iE=F("ZodNanoID",(e,t)=>{tv.init(e,t),ik.init(e,t)}),iP=F("ZodCUID",(e,t)=>{t_.init(e,t),ik.init(e,t)}),iI=F("ZodCUID2",(e,t)=>{tb.init(e,t),ik.init(e,t)}),iq=F("ZodULID",(e,t)=>{tS.init(e,t),ik.init(e,t)}),iO=F("ZodXID",(e,t)=>{tw.init(e,t),ik.init(e,t)}),ij=F("ZodKSUID",(e,t)=>{tk.init(e,t),ik.init(e,t)}),iz=F("ZodIPv4",(e,t)=>{tT.init(e,t),ik.init(e,t)}),iL=F("ZodIPv6",(e,t)=>{tE.init(e,t),ik.init(e,t)}),iN=F("ZodCIDRv4",(e,t)=>{tP.init(e,t),ik.init(e,t)}),iA=F("ZodCIDRv6",(e,t)=>{tI.init(e,t),ik.init(e,t)}),iM=F("ZodBase64",(e,t)=>{tO.init(e,t),ik.init(e,t)}),iZ=F("ZodBase64URL",(e,t)=>{tj.init(e,t),ik.init(e,t)}),iU=F("ZodE164",(e,t)=>{tz.init(e,t),ik.init(e,t)}),iH=F("ZodJWT",(e,t)=>{tL.init(e,t),ik.init(e,t)}),iF=F("ZodNumber",(e,t)=>{tN.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rj(e,t,r,i),iv(e,"ZodNumber",{gt(e,t){return this.check(rb(e,t))},gte(e,t){return this.check(rS(e,t))},min(e,t){return this.check(rS(e,t))},lt(e,t){return this.check(rv(e,t))},lte(e,t){return this.check(r_(e,t))},max(e,t){return this.check(r_(e,t))},int(e){return this.check(iJ(e))},safe(e){return this.check(iJ(e))},positive(e){return this.check(rb(0,e))},nonnegative(e){return this.check(rS(0,e))},negative(e){return this.check(rv(0,e))},nonpositive(e){return this.check(r_(0,e))},multipleOf(e,t){return this.check(rw(e,t))},step(e,t){return this.check(rw(e,t))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??-1/0,r.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(r.maximum??1/0,r.exclusiveMaximum??1/0)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function iV(e){return new iF({type:"number",checks:[],...eA(e)})}let iD=F("ZodNumberFormat",(e,t)=>{tA.init(e,t),iF.init(e,t)});function iJ(e){return new iD({type:"number",check:"number_format",abort:!1,format:"safeint",...eA(e)})}let iB=F("ZodBoolean",(e,t)=>{tM.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rz(e,t,r,i)});function iW(e){return new iB({type:"boolean",...eA(e)})}let iG=F("ZodNull",(e,t)=>{tZ.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rL(e,t,r,i)});function iK(e){return new iG({type:"null",...eA(e)})}let iY=F("ZodAny",(e,t)=>{tU.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rA(e,t,r,i)}),iX=F("ZodUnknown",(e,t)=>{tH.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rM(e,t,r,i)});function iQ(){return new iX({type:"unknown"})}let i0=F("ZodNever",(e,t)=>{tF.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rN(e,t,r,i)}),i1=F("ZodArray",(e,t)=>{tD.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rV(e,t,r,i),e.element=t.element,iv(e,"ZodArray",{min(e,t){return this.check(rR(e,t))},nonempty(e){return this.check(rR(1,e))},max(e,t){return this.check(rk(e,t))},length(e,t){return this.check(rx(e,t))},unwrap(){return this.element}})});function i2(e,t){return new i1({type:"array",element:e,...eA(t)})}let i9=F("ZodObject",(e,t)=>{tK.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rD(e,t,r,i),eC(e,"shape",()=>t.shape),iv(e,"ZodObject",{keyof(){return na(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:iQ()})},loose(){return this.clone({...this._zod.def,catchall:iQ()})},strict(){return this.clone({...this._zod.def,catchall:new i0({type:"never",...eA(void 0)})})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!eO(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let r=e._zod.def.shape;for(let e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=eT(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return e$(this,"shape",r),r}});return eN(e,i)}(this,e)},safeExtend(e){var t=this;if(!eO(e))throw Error("Invalid input to safeExtend: expected a plain object");let r=eT(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e};return e$(this,"shape",r),r}});return eN(t,r)},merge(e){var t=this;if(t._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=eT(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return e$(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return eN(t,r)},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=eT(e._zod.def,{get shape(){let e={};for(let i in t){if(!(i in r.shape))throw Error(`Unrecognized key: "${i}"`);t[i]&&(e[i]=r.shape[i])}return e$(this,"shape",e),e},checks:[]});return eN(e,n)}(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=eT(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete i[e]}return e$(this,"shape",i),i},checks:[]});return eN(e,n)}(this,e)},partial(...e){return function(e,t,r){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let n=eT(t._zod.def,{get shape(){let i=t._zod.def.shape,n={...i};if(r)for(let t in r){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);r[t]&&(n[t]=e?new e({type:"optional",innerType:i[t]}):i[t])}else for(let t in i)n[t]=e?new e({type:"optional",innerType:i[t]}):i[t];return e$(this,"shape",n),n},checks:[]});return eN(t,n)}(nd,this,e[0])},required(...e){var t,r;let i;return t=this,r=e[0],i=eT(t._zod.def,{get shape(){let e=t._zod.def.shape,i={...e};if(r)for(let t in r){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=new ny({type:"nonoptional",innerType:e[t]}))}else for(let t in e)i[t]=new ny({type:"nonoptional",innerType:e[t]});return e$(this,"shape",i),i}}),eN(t,i)}})});function i4(e,t){return new i9({type:"object",shape:e??{},...eA(t)})}function i5(e,t){return new i9({type:"object",shape:e,catchall:iQ(),...eA(t)})}let i3=F("ZodUnion",(e,t)=>{tX.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rJ(e,t,r,i),e.options=t.options});function i6(e,t){return new i3({type:"union",options:e,...eA(t)})}let i7=F("ZodDiscriminatedUnion",(e,t)=>{i3.init(e,t),tQ.init(e,t)});function i8(e,t,r){return new i7({type:"union",options:t,discriminator:e,...eA(r)})}let ne=F("ZodIntersection",(e,t)=>{t0.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rB(e,t,r,i)});function nt(e,t){return new ne({type:"intersection",left:e,right:t})}let nr=F("ZodRecord",(e,t)=>{t2.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rW(e,t,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function ni(e,t,r){return new nr(t&&t._zod?{type:"record",keyType:e,valueType:t,...eA(r)}:{type:"record",keyType:iw(),valueType:e,...eA(t)})}let nn=F("ZodEnum",(e,t)=>{t9.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rZ(e,t,r,i),e.enum=t.entries,e.options=Object.values(t.entries);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 nn({...t,checks:[],...eA(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 nn({...t,checks:[],...eA(i),entries:n})}});function na(e,t){return new nn({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...eA(t)})}let no=F("ZodLiteral",(e,t)=>{t4.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rU(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 ns(e,t){return new no({type:"literal",values:Array.isArray(e)?e:[e],...eA(t)})}let nl=F("ZodTransform",(e,t)=>{t5.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rF(e,t,r,i),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new D(e.constructor.name);r.addIssue=i=>{"string"==typeof i?r.issues.push(eD(i,r.value,t)):(i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(eD(i)))};let n=t.transform(r.value,r);return n instanceof Promise?n.then(e=>(r.value=e,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function nc(e){return new nl({type:"transform",transform:e})}let nd=F("ZodOptional",(e,t)=>{t6.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r2(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new nd({type:"optional",innerType:e})}let np=F("ZodExactOptional",(e,t)=>{t7.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r2(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),nm=F("ZodNullable",(e,t)=>{t8.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rG(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function nh(e){return new nm({type:"nullable",innerType:e})}let nf=F("ZodDefault",(e,t)=>{re.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rY(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),ng=F("ZodPrefault",(e,t)=>{rr.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rX(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),ny=F("ZodNonOptional",(e,t)=>{ri.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rK(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),nv=F("ZodCatch",(e,t)=>{ra.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rQ(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),n_=F("ZodPipe",(e,t)=>{ro.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r0(e,t,r,i),e.in=t.in,e.out=t.out});function nb(e,t){return new n_({type:"pipe",in:e,out:t})}let nS=F("ZodPreprocess",(e,t)=>{n_.init(e,t),rl.init(e,t)}),nw=F("ZodReadonly",(e,t)=>{rc.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r1(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),nk=F("ZodLazy",(e,t)=>{ru.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r9(e,t,r,i),e.unwrap=()=>e._zod.def.getter()});function nR(e){return new nk({type:"lazy",getter:e})}let nx=F("ZodCustom",(e,t)=>{rp.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rH(e,t,r,i)});function nC(e,t){return new nS({type:"pipe",in:nc(e),out:t})}k||(k={});let n$="2025-11-25",nT=[n$,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],nE="io.modelcontextprotocol/protocolVersion",nP="io.modelcontextprotocol/clientInfo",nI="io.modelcontextprotocol/serverInfo",nq="io.modelcontextprotocol/clientCapabilities",nO="io.modelcontextprotocol/subscriptionId",nj="io.modelcontextprotocol/logLevel",nz=nR(()=>i6([iw(),iV(),iW(),iK(),ni(iw(),nz),i2(nz)])),nL=ni(iw(),nz),nN=i2(nz),nA=i6([iw(),iV().int()]),nM=iw(),nZ=i4({ttl:iV().optional()}),nU=i4({taskId:iw()}),nH=i5({progressToken:nA.optional(),"io.modelcontextprotocol/related-task":nU.optional()}),nF=i4({_meta:nH.optional()}),nV=nF.extend({task:nZ.optional()}),nD=i4({method:iw(),params:nF.loose().optional()}),nJ=i4({_meta:nH.optional()}),nB=i4({method:iw(),params:nJ.loose().optional()}),nW=i5({get[nI](){return n8.optional().catch(void 0)}}),nG=i5({_meta:nW.optional()}),nK=i6([iw(),iV().int()]),nY=i4({jsonrpc:ns("2.0"),id:nK,...nD.shape}).strict(),nX=i4({jsonrpc:ns("2.0"),...nB.shape}).strict(),nQ=i4({jsonrpc:ns("2.0"),id:nK,result:nG}).strict(),n0=i4({jsonrpc:ns("2.0"),id:nK.optional(),error:i4({code:iV().int(),message:iw(),data:iQ().optional()})}).strict(),n1=i6([nY,nX,nQ,n0]),n2=i6([nQ,n0]),n9=nG.strict(),n4=nJ.extend({requestId:nK.optional(),reason:iw().optional()}),n5=nB.extend({method:ns("notifications/cancelled"),params:n4}),n3=i4({src:iw(),mimeType:iw().optional(),sizes:i2(iw()).optional(),theme:na(["light","dark"]).optional()}),n6=i4({icons:i2(n3).optional()}),n7=i4({name:iw(),title:iw().optional()}),n8=n7.extend({...n7.shape,...n6.shape,version:iw(),websiteUrl:iw().optional(),description:iw().optional()}),ae=nt(i4({applyDefaults:iW().optional()}),nL),at=nC(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,nt(i4({form:ae.optional(),url:nL.optional()}),nL.optional())),ar=i5({list:nL.optional(),cancel:nL.optional(),requests:i5({sampling:i5({createMessage:nL.optional()}).optional(),elicitation:i5({create:nL.optional()}).optional()}).optional()}),ai=i5({list:nL.optional(),cancel:nL.optional(),requests:i5({tools:i5({call:nL.optional()}).optional()}).optional()}),an=i4({experimental:ni(iw(),nL).optional(),sampling:i4({context:nL.optional(),tools:nL.optional()}).optional(),elicitation:at.optional(),roots:i4({listChanged:iW().optional()}).optional(),tasks:ar.optional(),extensions:ni(iw(),nL).optional()}),aa=nF.extend({protocolVersion:iw(),capabilities:an,clientInfo:n8}),ao=nD.extend({method:ns("initialize"),params:aa}),as=i4({experimental:ni(iw(),nL).optional(),logging:nL.optional(),completions:nL.optional(),prompts:i4({listChanged:iW().optional()}).optional(),resources:i4({subscribe:iW().optional(),listChanged:iW().optional()}).optional(),tools:i4({listChanged:iW().optional()}).optional(),tasks:ai.optional(),extensions:ni(iw(),nL).optional()}),al=nG.extend({protocolVersion:iw(),capabilities:as,serverInfo:n8,instructions:iw().optional()}),ac=nB.extend({method:ns("notifications/initialized"),params:nJ.optional()}),ad=nD.extend({method:ns("server/discover"),params:nF.optional()}),au=nG.extend({supportedVersions:i2(iw()),capabilities:as,instructions:iw().optional()}),ap=nD.extend({method:ns("ping"),params:nF.optional()}),am=i4({progress:iV(),total:nu(iV()),message:nu(iw())}),ah=i4({...nJ.shape,...am.shape,progressToken:nA}),af=nB.extend({method:ns("notifications/progress"),params:ah}),ag=nF.extend({cursor:nM.optional()}),ay=nD.extend({params:ag.optional()}),av=nG.extend({nextCursor:nM.optional()}),a_=i4({uri:iw(),mimeType:nu(iw()),_meta:ni(iw(),iQ()).optional()}),ab=a_.extend({text:iw()}),aS=iw().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),aw=a_.extend({blob:aS}),ak=na(["user","assistant"]),aR=i4({audience:i2(ak).optional(),priority:iV().min(0).max(1).optional(),lastModified:r6({offset:!0}).optional()}),ax=i4({...n7.shape,...n6.shape,uri:iw(),description:nu(iw()),mimeType:nu(iw()),size:nu(iV()),annotations:aR.optional(),_meta:nu(i5({}))}),aC=i4({...n7.shape,...n6.shape,uriTemplate:iw(),description:nu(iw()),mimeType:nu(iw()),annotations:aR.optional(),_meta:nu(i5({}))}),a$=ay.extend({method:ns("resources/list")}),aT=av.extend({resources:i2(ax)}),aE=ay.extend({method:ns("resources/templates/list")}),aP=av.extend({resourceTemplates:i2(aC)}),aI=nF.extend({uri:iw()}),aq=nD.extend({method:ns("resources/read"),params:aI}),aO=nG.extend({contents:i2(i6([ab,aw]))}),aj=nB.extend({method:ns("notifications/resources/list_changed"),params:nJ.optional()}),az=nD.extend({method:ns("resources/subscribe"),params:aI}),aL=nD.extend({method:ns("resources/unsubscribe"),params:aI}),aN=i4({toolsListChanged:iW().optional(),promptsListChanged:iW().optional(),resourcesListChanged:iW().optional(),resourceSubscriptions:i2(iw()).optional()}),aA=nF.extend({notifications:aN}),aM=nD.extend({method:ns("subscriptions/listen"),params:aA}),aZ=nJ.extend({notifications:aN}),aU=nB.extend({method:ns("notifications/subscriptions/acknowledged"),params:aZ}),aH=nW.extend({[nO]:nK}),aF=nG.extend({_meta:aH}),aV=nJ.extend({uri:iw()}),aD=nB.extend({method:ns("notifications/resources/updated"),params:aV}),aJ=i4({name:iw(),description:nu(iw()),required:nu(iW())}),aB=i4({...n7.shape,...n6.shape,description:nu(iw()),arguments:nu(i2(aJ)),_meta:nu(i5({}))}),aW=ay.extend({method:ns("prompts/list")}),aG=av.extend({prompts:i2(aB)}),aK=nF.extend({name:iw(),arguments:ni(iw(),iw()).optional()}),aY=nD.extend({method:ns("prompts/get"),params:aK}),aX=i4({type:ns("text"),text:iw(),annotations:aR.optional(),_meta:ni(iw(),iQ()).optional()}),aQ=i4({type:ns("image"),data:aS,mimeType:iw(),annotations:aR.optional(),_meta:ni(iw(),iQ()).optional()}),a0=i4({type:ns("audio"),data:aS,mimeType:iw(),annotations:aR.optional(),_meta:ni(iw(),iQ()).optional()}),a1=i4({type:ns("tool_use"),name:iw(),id:iw(),input:ni(iw(),iQ()),_meta:ni(iw(),iQ()).optional()}),a2=i4({type:ns("resource"),resource:i6([ab,aw]),annotations:aR.optional(),_meta:ni(iw(),iQ()).optional()}),a9=ax.extend({type:ns("resource_link")}),a4=i6([aX,aQ,a0,a9,a2]),a5=i4({role:ak,content:a4}),a3=nG.extend({description:iw().optional(),messages:i2(a5)}),a6=nB.extend({method:ns("notifications/prompts/list_changed"),params:nJ.optional()}),a7=i4({title:iw().optional(),readOnlyHint:iW().optional(),destructiveHint:iW().optional(),idempotentHint:iW().optional(),openWorldHint:iW().optional()}),a8=i4({taskSupport:na(["required","optional","forbidden"]).optional()}),oe=i4({...n7.shape,...n6.shape,description:iw().optional(),inputSchema:i4({type:ns("object"),properties:ni(iw(),nz).optional(),required:i2(iw()).optional()}).catchall(iQ()),outputSchema:i5({$schema:iw().optional()}).optional(),annotations:a7.optional(),execution:a8.optional(),_meta:ni(iw(),iQ()).optional()}),ot=ay.extend({method:ns("tools/list")}),or=av.extend({tools:i2(oe)}),oi=nG.extend({content:i2(a4).default([]),structuredContent:iQ().optional(),isError:iW().optional()}),on=oi.or(nG.extend({toolResult:iQ()})),oa=nV.extend({name:iw(),arguments:ni(iw(),iQ()).optional()}),oo=nD.extend({method:ns("tools/call"),params:oa}),os=nB.extend({method:ns("notifications/tools/list_changed"),params:nJ.optional()}),ol=i4({autoRefresh:iW().default(!0),debounceMs:iV().int().nonnegative().default(300)}),oc=na(["debug","info","notice","warning","error","critical","alert","emergency"]),od=nF.extend({level:oc}),ou=nD.extend({method:ns("logging/setLevel"),params:od}),op=nJ.extend({level:oc,logger:iw().optional(),data:iQ()}),om=nB.extend({method:ns("notifications/message"),params:op}),oh=i4({name:iw().optional()}),of=i4({hints:i2(oh).optional(),costPriority:iV().min(0).max(1).optional(),speedPriority:iV().min(0).max(1).optional(),intelligencePriority:iV().min(0).max(1).optional()}),og=i4({mode:na(["auto","required","none"]).optional()}),oy=i4({type:ns("tool_result"),toolUseId:iw().describe("The unique identifier for the corresponding tool call."),content:i2(a4),structuredContent:iQ().optional(),isError:iW().optional(),_meta:ni(iw(),iQ()).optional()}),ov=i8("type",[aX,aQ,a0]),o_=i8("type",[aX,aQ,a0,a1,oy]),ob=i4({role:ak,content:i6([o_,i2(o_)]),_meta:ni(iw(),iQ()).optional()}),oS=nV.extend({messages:i2(ob),modelPreferences:of.optional(),systemPrompt:iw().optional(),includeContext:na(["none","thisServer","allServers"]).optional(),temperature:iV().optional(),maxTokens:iV().int(),stopSequences:i2(iw()).optional(),metadata:nL.optional(),tools:i2(oe).optional(),toolChoice:og.optional()}),ow=nD.extend({method:ns("sampling/createMessage"),params:oS}),ok=nG.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens"]).or(iw())),role:ak,content:ov}),oR=nG.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens","toolUse"]).or(iw())),role:ak,content:i6([o_,i2(o_)])}),ox=i4({type:ns("boolean"),title:iw().optional(),description:iw().optional(),default:iW().optional()}),oC=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),minLength:iV().optional(),maxLength:iV().optional(),format:na(["email","uri","date","date-time"]).optional(),default:iw().optional()}),o$=i4({type:na(["number","integer"]),title:iw().optional(),description:iw().optional(),minimum:iV().optional(),maximum:iV().optional(),default:iV().optional()}),oT=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),default:iw().optional()}),oE=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),oneOf:i2(i4({const:iw(),title:iw()})),default:iw().optional()}),oP=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),enumNames:i2(iw()).optional(),default:iw().optional()}),oI=i6([oT,oE]),oq=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({type:ns("string"),enum:i2(iw())}),default:i2(iw()).optional()}),oO=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({anyOf:i2(i4({const:iw(),title:iw()}))}),default:i2(iw()).optional()}),oj=i6([oq,oO]),oz=i6([oP,oI,oj]),oL=i6([oz,ox,oC,o$]),oN=nV.extend({mode:ns("form").optional(),message:iw(),requestedSchema:i4({type:ns("object"),properties:ni(iw(),oL),required:i2(iw()).optional()}).catchall(iQ())}),oA=nV.extend({mode:ns("url"),message:iw(),elicitationId:iw(),url:iw().url()}),oM=i6([oN,oA]),oZ=nD.extend({method:ns("elicitation/create"),params:oM}),oU=nJ.extend({elicitationId:iw()}),oH=nB.extend({method:ns("notifications/elicitation/complete"),params:oU}),oF=nG.extend({action:na(["accept","decline","cancel"]),content:nC(e=>null===e?void 0:e,ni(iw(),i6([iw(),iV(),iW(),i2(iw())])).optional())}),oV=i4({type:ns("ref/resource"),uri:iw()}),oD=i4({type:ns("ref/prompt"),name:iw()}),oJ=nF.extend({ref:i6([oD,oV]),argument:i4({name:iw(),value:iw()}),context:i4({arguments:ni(iw(),iw()).optional()}).optional()}),oB=nD.extend({method:ns("completion/complete"),params:oJ}),oW=nG.extend({completion:i5({values:i2(iw()).max(100),total:nu(iV().int()),hasMore:nu(iW())})}),oG=i4({uri:iw().startsWith("file://"),name:iw().optional(),_meta:ni(iw(),iQ()).optional()}),oK=nD.extend({method:ns("roots/list"),params:nF.optional()}),oY=nG.extend({roots:i2(oG)}),oX=nB.extend({method:ns("notifications/roots/list_changed"),params:nJ.optional()}),oQ=i5({ttl:iV().optional(),pollInterval:iV().optional()}),o0=na(["working","input_required","completed","failed","cancelled"]),o1=i4({taskId:iw(),status:o0,ttl:i6([iV(),iK()]),createdAt:iw(),lastUpdatedAt:iw(),pollInterval:nu(iV()),statusMessage:nu(iw())}),o2=nG.extend({task:o1}),o9=nJ.merge(o1),o4=nB.extend({method:ns("notifications/tasks/status"),params:o9}),o5=nD.extend({method:ns("tasks/get"),params:nF.extend({taskId:iw()})}),o3=nG.merge(o1),o6=nD.extend({method:ns("tasks/result"),params:nF.extend({taskId:iw()})}),o7=nG.loose(),o8=ay.extend({method:ns("tasks/list")}),se=av.extend({tasks:i2(o1)}),st=nD.extend({method:ns("tasks/cancel"),params:nF.extend({taskId:iw()})}),sr=nG.merge(o1),si=i6([ap,ao,ad,oB,ou,aY,aW,a$,aE,aq,az,aL,aM,oo,ot]),sn=i6([n5,af,ac,oX]),sa=i6([n9,ok,oR,oF,oY]),so=i6([ap,ow,oZ,oK]),ss=i6([n5,af,om,aD,aj,os,a6,aU,oH]),sl=i6([n9,al,au,oW,a3,aG,aT,aP,aO,oi,or,aF]),sc=ry(i$,void 0).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),H}).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"}),sd=i5({resource:iw().url(),authorization_servers:i2(sc).optional(),jwks_uri:iw().url().optional(),scopes_supported:i2(iw()).optional(),bearer_methods_supported:i2(iw()).optional(),resource_signing_alg_values_supported:i2(iw()).optional(),resource_name:iw().optional(),resource_documentation:iw().optional(),resource_policy_uri:iw().url().optional(),resource_tos_uri:iw().url().optional(),tls_client_certificate_bound_access_tokens:iW().optional(),authorization_details_types_supported:i2(iw()).optional(),dpop_signing_alg_values_supported:i2(iw()).optional(),dpop_bound_access_tokens_required:iW().optional()}),su=i5({issuer:iw(),authorization_endpoint:sc,token_endpoint:sc,registration_endpoint:sc.optional(),scopes_supported:i2(iw()).optional(),response_types_supported:i2(iw()),response_modes_supported:i2(iw()).optional(),grant_types_supported:i2(iw()).optional(),token_endpoint_auth_methods_supported:i2(iw()).optional(),token_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),service_documentation:sc.optional(),revocation_endpoint:sc.optional(),revocation_endpoint_auth_methods_supported:i2(iw()).optional(),revocation_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),introspection_endpoint:iw().optional(),introspection_endpoint_auth_methods_supported:i2(iw()).optional(),introspection_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),code_challenge_methods_supported:i2(iw()).optional(),client_id_metadata_document_supported:iW().optional(),authorization_response_iss_parameter_supported:iW().optional().catch(void 0)}),sp=i5({issuer:iw(),authorization_endpoint:sc,token_endpoint:sc,userinfo_endpoint:sc.optional(),jwks_uri:sc,registration_endpoint:sc.optional(),scopes_supported:i2(iw()).optional(),response_types_supported:i2(iw()),response_modes_supported:i2(iw()).optional(),grant_types_supported:i2(iw()).optional(),acr_values_supported:i2(iw()).optional(),subject_types_supported:i2(iw()),id_token_signing_alg_values_supported:i2(iw()),id_token_encryption_alg_values_supported:i2(iw()).optional(),id_token_encryption_enc_values_supported:i2(iw()).optional(),userinfo_signing_alg_values_supported:i2(iw()).optional(),userinfo_encryption_alg_values_supported:i2(iw()).optional(),userinfo_encryption_enc_values_supported:i2(iw()).optional(),request_object_signing_alg_values_supported:i2(iw()).optional(),request_object_encryption_alg_values_supported:i2(iw()).optional(),request_object_encryption_enc_values_supported:i2(iw()).optional(),token_endpoint_auth_methods_supported:i2(iw()).optional(),token_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),display_values_supported:i2(iw()).optional(),claim_types_supported:i2(iw()).optional(),claims_supported:i2(iw()).optional(),service_documentation:iw().optional(),claims_locales_supported:i2(iw()).optional(),ui_locales_supported:i2(iw()).optional(),claims_parameter_supported:iW().optional(),request_parameter_supported:iW().optional(),request_uri_parameter_supported:iW().optional(),require_request_uri_registration:iW().optional(),op_policy_uri:sc.optional(),op_tos_uri:sc.optional(),client_id_metadata_document_supported:iW().optional(),authorization_response_iss_parameter_supported:iW().optional().catch(void 0)}),sm=i4({...sp.shape,...su.pick({code_challenge_methods_supported:!0}).shape}),sh=i4({access_token:iw(),id_token:iw().optional(),token_type:iw(),expires_in:new iF({type:"number",coerce:!0,checks:[],...eA(void 0)}).optional(),scope:iw().optional(),refresh_token:iw().optional()}).strip(),sf=i4({issued_token_type:ns("urn:ietf:params:oauth:token-type:id-jag"),access_token:iw(),token_type:iw().optional(),expires_in:iV().optional(),scope:iw().optional()}).strip(),sg=i4({error:iw(),error_description:iw().optional(),error_uri:iw().optional()}),sy=sc.optional().or(ns("").transform(()=>void 0)),sv=i4({redirect_uris:i2(sc),token_endpoint_auth_method:iw().optional(),grant_types:i2(iw()).optional(),response_types:i2(iw()).optional(),application_type:iw().optional(),client_name:iw().optional(),client_uri:sc.optional(),logo_uri:sy,scope:iw().optional(),contacts:i2(iw()).optional(),tos_uri:sy,policy_uri:iw().optional(),jwks_uri:sc.optional(),jwks:new iY({type:"any"}).optional(),software_id:iw().optional(),software_version:iw().optional(),software_statement:iw().optional()}).strip(),s_=i4({client_id:iw(),client_secret:iw().optional(),client_id_issued_at:iV().optional(),client_secret_expires_at:iV().optional()}).strip(),sb=sv.merge(s_),sS=i4({error:iw(),error_description:iw().optional()}).strip(),sw=i4({token:iw(),token_type_hint:iw().optional()}).strip(),sk=Symbol.for("mcp.sdk.errorBrands");function sR(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,sk,{value:r,enumerable:!1,configurable:!0})}function sx(e,t){try{if("object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&"string"==typeof e.mcpBrand&&Object.prototype.hasOwnProperty.call(t,sk)){let r=t[sk];if(r&&"function"==typeof r.has&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}(class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](e){return sx(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 sx(this,e)}constructor(e,t,r){super(t),this.code=e,this.errorUri=r,this.name="OAuthError",sR(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 sC=((f={}).NotConnected="NOT_CONNECTED",f.AlreadyConnected="ALREADY_CONNECTED",f.NotInitialized="NOT_INITIALIZED",f.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",f.RequestTimeout="REQUEST_TIMEOUT",f.ConnectionClosed="CONNECTION_CLOSED",f.SendFailed="SEND_FAILED",f.InvalidResult="INVALID_RESULT",f.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",f.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",f.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",f.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",f.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",f.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",f.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",f.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",f.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",f.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",f.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",f);var s$=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return sx(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 sx(this,e)}constructor(e,t,r){super(t),this.code=e,this.data=r,this.name="SdkError",sR(this,new.target)}};(class extends s${static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r){super(e,t,r),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let sT={};function sE(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function sP(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(sE(n)&&sE(e)){let t={};for(let[r,a]of Object.entries(n))void 0!==a&&void 0===e[r]&&("elicitation"!==i||"form"!==r||void 0!==e.form||void 0!==e.url)&&(t[r]=a);Object.keys(t).length>0&&(r[i]=t)}}return Object.keys(r).length>0?r:void 0}let sI="2026-07-28",sq=[sI];function sO(e){return e.filter(e=>e>=sI)}function sj(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 sz=["task","inputRequests","requestState"];function sL(e){return null===e||"object"!=typeof e||Array.isArray(e)||void 0!==e.content||sz.some(t=>t in e)?e:{...e,content:[]}}function sN(){let t,r,i,n,a,o,s,l,c,d,u,p,m,h,f,g,y,v,_,b,S,w,k,R,x,C,$,T,E,P,I,q,O,j,z,L,N,A,M,Z,U,H,F,V,D,J,B,W,G,K,Y,X,Q,ee,et,er,ei,en,ea,eo,es,el,ec,ed,eu,ep,em,eh,ef,eg,ey,ev,e_,eb,eS,ew,ek,eR,ex,eC,e$,eT,eE,eP,eI,eq,eO,ej,ez,eL,eN,eA,eM,eZ,eU,eH,eF,eV,eD,eJ,eB,eW,eG,eK,eY,eX,eQ,e0,e1,e2,e9,e4,e5,e3,e6,e7,e8,te,tt,tr,ti,tn,ta,to,ts,tl,tc,td,tu,tp,tm,th,tf,tg,ty,tv,t_,tb,tS,tw;return e??=(t=nR(()=>i6([iw(),iV(),iW(),iK(),ni(iw(),t),i2(t)])),r=ni(iw(),t),i=i6([iw(),iV().int()]),n=iw(),a=i4({ttl:iV().optional()}),o=i4({taskId:iw()}),c=(l=i4({_meta:(s=i5({progressToken:i.optional(),"io.modelcontextprotocol/related-task":o.optional()})).optional()})).extend({task:a.optional()}),d=i4({method:iw(),params:l.loose().optional()}),u=i4({_meta:s.optional()}),p=i4({method:iw(),params:u.loose().optional()}),m=i5({_meta:s.optional()}),h=i6([iw(),iV().int()]),f=m.strict(),g=u.extend({requestId:h.optional(),reason:iw().optional()}),y=p.extend({method:ns("notifications/cancelled"),params:g}),v=i4({src:iw(),mimeType:iw().optional(),sizes:i2(iw()).optional(),theme:na(["light","dark"]).optional()}),_=i4({icons:i2(v).optional()}),S=(b=i4({name:iw(),title:iw().optional()})).extend({...b.shape,..._.shape,version:iw(),websiteUrl:iw().optional(),description:iw().optional()}),w=nt(i4({applyDefaults:iW().optional()}),r),k=nC(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,nt(i4({form:w.optional(),url:r.optional()}),r.optional())),R=i5({list:r.optional(),cancel:r.optional(),requests:i5({sampling:i5({createMessage:r.optional()}).optional(),elicitation:i5({create:r.optional()}).optional()}).optional()}),x=i5({list:r.optional(),cancel:r.optional(),requests:i5({tools:i5({call:r.optional()}).optional()}).optional()}),C=i4({experimental:ni(iw(),r).optional(),sampling:i4({context:r.optional(),tools:r.optional()}).optional(),elicitation:k.optional(),roots:i4({listChanged:iW().optional()}).optional(),tasks:R.optional(),extensions:ni(iw(),r).optional()}),$=l.extend({protocolVersion:iw(),capabilities:C,clientInfo:S}),T=d.extend({method:ns("initialize"),params:$}),E=i4({experimental:ni(iw(),r).optional(),logging:r.optional(),completions:r.optional(),prompts:i4({listChanged:iW().optional()}).optional(),resources:i4({subscribe:iW().optional(),listChanged:iW().optional()}).optional(),tools:i4({listChanged:iW().optional()}).optional(),tasks:x.optional(),extensions:ni(iw(),r).optional()}),P=m.extend({protocolVersion:iw(),capabilities:E,serverInfo:S,instructions:iw().optional()}),I=p.extend({method:ns("notifications/initialized"),params:u.optional()}),q=d.extend({method:ns("ping"),params:l.optional()}),O=i4({progress:iV(),total:nu(iV()),message:nu(iw())}),j=i4({...u.shape,...O.shape,progressToken:i}),z=p.extend({method:ns("notifications/progress"),params:j}),L=l.extend({cursor:n.optional()}),N=d.extend({params:L.optional()}),A=m.extend({nextCursor:n.optional()}),Z=(M=i4({uri:iw(),mimeType:nu(iw()),_meta:ni(iw(),iQ()).optional()})).extend({text:iw()}),U=iw().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),H=M.extend({blob:U}),V=i4({audience:i2(F=na(["user","assistant"])).optional(),priority:iV().min(0).max(1).optional(),lastModified:r6({offset:!0}).optional()}),D=i4({...b.shape,..._.shape,uri:iw(),description:nu(iw()),mimeType:nu(iw()),size:nu(iV()),annotations:V.optional(),_meta:nu(i5({}))}),J=i4({...b.shape,..._.shape,uriTemplate:iw(),description:nu(iw()),mimeType:nu(iw()),annotations:V.optional(),_meta:nu(i5({}))}),B=N.extend({method:ns("resources/list")}),W=A.extend({resources:i2(D)}),G=N.extend({method:ns("resources/templates/list")}),K=A.extend({resourceTemplates:i2(J)}),Y=l.extend({uri:iw()}),X=d.extend({method:ns("resources/read"),params:Y}),Q=m.extend({contents:i2(i6([Z,H]))}),ee=p.extend({method:ns("notifications/resources/list_changed"),params:u.optional()}),et=d.extend({method:ns("resources/subscribe"),params:Y}),er=d.extend({method:ns("resources/unsubscribe"),params:Y}),ei=u.extend({uri:iw()}),en=p.extend({method:ns("notifications/resources/updated"),params:ei}),ea=i4({name:iw(),description:nu(iw()),required:nu(iW())}),eo=i4({...b.shape,..._.shape,description:nu(iw()),arguments:nu(i2(ea)),_meta:nu(i5({}))}),es=N.extend({method:ns("prompts/list")}),el=A.extend({prompts:i2(eo)}),ec=l.extend({name:iw(),arguments:ni(iw(),iw()).optional()}),ed=d.extend({method:ns("prompts/get"),params:ec}),eu=i4({type:ns("text"),text:iw(),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),ep=i4({type:ns("image"),data:U,mimeType:iw(),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),em=i4({type:ns("audio"),data:U,mimeType:iw(),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),eh=i4({type:ns("tool_use"),name:iw(),id:iw(),input:ni(iw(),iQ()),_meta:ni(iw(),iQ()).optional()}),ef=i4({type:ns("resource"),resource:i6([Z,H]),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),ev=i4({role:F,content:ey=i6([eu,ep,em,eg=D.extend({type:ns("resource_link")}),ef])}),e_=m.extend({description:iw().optional(),messages:i2(ev)}),eb=p.extend({method:ns("notifications/prompts/list_changed"),params:u.optional()}),eS=i4({title:iw().optional(),readOnlyHint:iW().optional(),destructiveHint:iW().optional(),idempotentHint:iW().optional(),openWorldHint:iW().optional()}),ew=i4({taskSupport:na(["required","optional","forbidden"]).optional()}),ek=i4({...b.shape,..._.shape,description:iw().optional(),inputSchema:i4({type:ns("object"),properties:ni(iw(),t).optional(),required:i2(iw()).optional()}).catchall(iQ()),outputSchema:i4({type:ns("object"),properties:ni(iw(),t).optional(),required:i2(iw()).optional()}).catchall(iQ()).optional(),annotations:eS.optional(),execution:ew.optional(),_meta:ni(iw(),iQ()).optional()}),eR=N.extend({method:ns("tools/list")}),ex=A.extend({tools:i2(ek)}),eC=m.extend({content:i2(ey),structuredContent:ni(iw(),iQ()).optional(),isError:iW().optional()}),e$=c.extend({name:iw(),arguments:ni(iw(),iQ()).optional()}),eT=d.extend({method:ns("tools/call"),params:e$}),eE=p.extend({method:ns("notifications/tools/list_changed"),params:u.optional()}),eP=na(["debug","info","notice","warning","error","critical","alert","emergency"]),eI=l.extend({level:eP}),eq=d.extend({method:ns("logging/setLevel"),params:eI}),eO=u.extend({level:eP,logger:iw().optional(),data:iQ()}),ej=p.extend({method:ns("notifications/message"),params:eO}),ez=i4({name:iw().optional()}),eL=i4({hints:i2(ez).optional(),costPriority:iV().min(0).max(1).optional(),speedPriority:iV().min(0).max(1).optional(),intelligencePriority:iV().min(0).max(1).optional()}),eN=i4({mode:na(["auto","required","none"]).optional()}),eA=i4({type:ns("tool_result"),toolUseId:iw().describe("The unique identifier for the corresponding tool call."),content:i2(ey),structuredContent:i4({}).loose().optional(),isError:iW().optional(),_meta:ni(iw(),iQ()).optional()}),eM=i8("type",[eu,ep,em]),eU=i4({role:F,content:i6([eZ=i8("type",[eu,ep,em,eh,eA]),i2(eZ)]),_meta:ni(iw(),iQ()).optional()}),eH=c.extend({messages:i2(eU),modelPreferences:eL.optional(),systemPrompt:iw().optional(),includeContext:na(["none","thisServer","allServers"]).optional(),temperature:iV().optional(),maxTokens:iV().int(),stopSequences:i2(iw()).optional(),metadata:r.optional(),tools:i2(ek).optional(),toolChoice:eN.optional()}),eF=d.extend({method:ns("sampling/createMessage"),params:eH}),eV=m.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens"]).or(iw())),role:F,content:eM}),eD=m.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens","toolUse"]).or(iw())),role:F,content:i6([eZ,i2(eZ)])}),eJ=i4({type:ns("boolean"),title:iw().optional(),description:iw().optional(),default:iW().optional()}),eB=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),minLength:iV().optional(),maxLength:iV().optional(),format:na(["email","uri","date","date-time"]).optional(),default:iw().optional()}),eW=i4({type:na(["number","integer"]),title:iw().optional(),description:iw().optional(),minimum:iV().optional(),maximum:iV().optional(),default:iV().optional()}),eG=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),default:iw().optional()}),eK=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),oneOf:i2(i4({const:iw(),title:iw()})),default:iw().optional()}),eY=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),enumNames:i2(iw()).optional(),default:iw().optional()}),eX=i6([eG,eK]),eQ=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({type:ns("string"),enum:i2(iw())}),default:i2(iw()).optional()}),e1=i6([eQ,e0=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({anyOf:i2(i4({const:iw(),title:iw()}))}),default:i2(iw()).optional()})]),e2=i6([eY,eX,e1]),e9=i6([e2,eJ,eB,eW]),e4=c.extend({mode:ns("form").optional(),message:iw(),requestedSchema:i4({type:ns("object"),properties:ni(iw(),e9),required:i2(iw()).optional()}).catchall(iQ())}),e3=i6([e4,e5=c.extend({mode:ns("url"),message:iw(),elicitationId:iw(),url:iw().url()})]),e6=d.extend({method:ns("elicitation/create"),params:e3}),e7=u.extend({elicitationId:iw()}),e8=p.extend({method:ns("notifications/elicitation/complete"),params:e7}),te=m.extend({action:na(["accept","decline","cancel"]),content:nC(e=>null===e?void 0:e,ni(iw(),i6([iw(),iV(),iW(),i2(iw())])).optional())}),tt=i4({type:ns("ref/resource"),uri:iw()}),tr=i4({type:ns("ref/prompt"),name:iw()}),ti=l.extend({ref:i6([tr,tt]),argument:i4({name:iw(),value:iw()}),context:i4({arguments:ni(iw(),iw()).optional()}).optional()}),tn=d.extend({method:ns("completion/complete"),params:ti}),ta=m.extend({completion:i5({values:i2(iw()).max(100),total:nu(iV().int()),hasMore:nu(iW())})}),to=i4({uri:iw().startsWith("file://"),name:iw().optional(),_meta:ni(iw(),iQ()).optional()}),ts=d.extend({method:ns("roots/list"),params:l.optional()}),tl=m.extend({roots:i2(to)}),tc=p.extend({method:ns("notifications/roots/list_changed"),params:u.optional()}),td=i5({ttl:iV().optional(),pollInterval:iV().optional()}),tu=na(["working","input_required","completed","failed","cancelled"]),tp=i4({taskId:iw(),status:tu,ttl:i6([iV(),iK()]),createdAt:iw(),lastUpdatedAt:iw(),pollInterval:nu(iV()),statusMessage:nu(iw())}),tm=m.extend({task:tp}),th=u.merge(tp),tf=p.extend({method:ns("notifications/tasks/status"),params:th}),tg=d.extend({method:ns("tasks/get"),params:l.extend({taskId:iw()})}),ty=m.merge(tp),tv=d.extend({method:ns("tasks/result"),params:l.extend({taskId:iw()})}),t_=m.loose(),tb=N.extend({method:ns("tasks/list")}),tS=A.extend({tasks:i2(tp)}),tw=d.extend({method:ns("tasks/cancel"),params:l.extend({taskId:iw()})}),{JSONValueSchema:t,JSONObjectSchema:r,ProgressTokenSchema:i,CursorSchema:n,TaskMetadataSchema:a,RelatedTaskMetadataSchema:o,RequestMetaSchema:s,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:c,RequestSchema:d,NotificationsParamsSchema:u,NotificationSchema:p,ResultSchema:m,RequestIdSchema:h,EmptyResultSchema:f,CancelledNotificationParamsSchema:g,CancelledNotificationSchema:y,IconSchema:v,IconsSchema:_,BaseMetadataSchema:b,ImplementationSchema:S,ClientTasksCapabilitySchema:R,ServerTasksCapabilitySchema:x,ClientCapabilitiesSchema:C,InitializeRequestParamsSchema:$,InitializeRequestSchema:T,ServerCapabilitiesSchema:E,InitializeResultSchema:P,InitializedNotificationSchema:I,PingRequestSchema:q,ProgressSchema:O,ProgressNotificationParamsSchema:j,ProgressNotificationSchema:z,PaginatedRequestParamsSchema:L,PaginatedRequestSchema:N,PaginatedResultSchema:A,ResourceContentsSchema:M,TextResourceContentsSchema:Z,BlobResourceContentsSchema:H,RoleSchema:F,AnnotationsSchema:V,ResourceSchema:D,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:ea,PromptSchema:eo,ListPromptsRequestSchema:es,ListPromptsResultSchema:el,GetPromptRequestParamsSchema:ec,GetPromptRequestSchema:ed,TextContentSchema:eu,ImageContentSchema:ep,AudioContentSchema:em,ToolUseContentSchema:eh,EmbeddedResourceSchema:ef,ResourceLinkSchema:eg,ContentBlockSchema:ey,PromptMessageSchema:ev,GetPromptResultSchema:e_,PromptListChangedNotificationSchema:eb,ToolAnnotationsSchema:eS,ToolExecutionSchema:ew,ToolSchema:ek,ListToolsRequestSchema:eR,ListToolsResultSchema:ex,CallToolResultSchema:eC,CallToolRequestParamsSchema:e$,CallToolRequestSchema:eT,ToolListChangedNotificationSchema:eE,LoggingLevelSchema:eP,SetLevelRequestParamsSchema:eI,SetLevelRequestSchema:eq,LoggingMessageNotificationParamsSchema:eO,LoggingMessageNotificationSchema:ej,ModelHintSchema:ez,ModelPreferencesSchema:eL,ToolChoiceSchema:eN,ToolResultContentSchema:eA,SamplingContentSchema:eM,SamplingMessageContentBlockSchema:eZ,SamplingMessageSchema:eU,CreateMessageRequestParamsSchema:eH,CreateMessageRequestSchema:eF,CreateMessageResultSchema:eV,CreateMessageResultWithToolsSchema:eD,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:ta,RootSchema:to,ListRootsRequestSchema:ts,ListRootsResultSchema:tl,RootsListChangedNotificationSchema:tc,TaskCreationParamsSchema:td,TaskStatusSchema:tu,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:i6([q,T,tn,eq,ed,es,B,G,X,et,er,eT,eR,tg,tv,tb,tw]),ClientNotificationSchema:i6([y,z,I,tc,tf]),ClientResultSchema:i6([f,eV,eD,te,tl,ty,tS,tm]),ServerRequestSchema:i6([q,eF,e6,ts,tg,tv,tb,tw]),ServerNotificationSchema:i6([y,z,ej,en,ee,eE,eb,tf,e8]),ServerResultSchema:i6([f,P,ta,e_,el,W,K,Q,eC,ex,ty,tS,tm]),CallToolResultWireSchema:iQ().superRefine((e,t)=>{if(!("object"!=typeof e||null===e||Array.isArray(e))&&void 0===e.content){for(let r of sz)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(sL).pipe(eC)})}function sA(e){return"object"!==e.type}let sM=new Set(["const","enum","default","examples"]),sZ=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function sU(e){return void 0!==e&&!("string"==typeof e&&e.startsWith("#"))}let sH={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},sF={"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},sV={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 sD(){if(t)return t;let e=sN();return t={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 sJ(e){return Object.prototype.hasOwnProperty.call(sH,e)}function sB(e){return Object.prototype.hasOwnProperty.call(sF,e)}function sW(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function sG(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(sH),Object.keys(sF);let sK={ok:!1,reason:"not-in-era"};function sY(e){return sW(e)&&sW(e.outputSchema)&&sA(e.outputSchema)}let sX={era:"2025-11-25",hasRequestMethod:sJ,hasNotificationMethod:sB,validateRequest:(e,t)=>sG(sJ(e)?sD().requestSchemas[e]:void 0,t),validateResult:(e,t)=>sG(Object.prototype.hasOwnProperty.call(sV,e)?sD().resultSchemas[e]:void 0,t),validateNotification:(e,t)=>sG(sB(e)?sD().notificationSchemas[e]:void 0,t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>sK,validateInputResponse:()=>sK,samplingResultVariant:(e,t)=>{let r=sN();return sG(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)},outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=sj(e),i=r.structuredContent;if(void 0===i)return r;let n="object"!=typeof i||null===i||Array.isArray(i),a=void 0!==t&&sA(t);return n||a?{...r,structuredContent:{result:i}}:r},decodeResult(e,t){if(sW(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=>sY(e))?{...t,tools:r.map(e=>sY(e)?{...e,outputSchema:function(e){var t;let r="string"==typeof e.$schema?e.$schema:void 0;if(sU(e.$id))return{...void 0!==r&&{$schema:r},type:"object",properties:{result:e},required:["result"]};let i="string"==typeof(t=e.$schema)&&M.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&&sU(e.$id))return e;let r={},a=!1;for(let[o,s]of Object.entries(e))t?r[o]=n(s,!1):("$ref"===o||"$dynamicRef"===o)&&"string"==typeof s?r[o]="#"===s?"#/properties/result":s.startsWith("#/")?`#/properties/result${s.slice(1)}`:s:"$recursiveRef"===o&&"#"===s&&i?a=!0:sM.has(o)?r[o]=s:sZ.has(o)?r[o]=n(s,!0):r[o]=n(s,!1);return a&&("$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 sQ(){return r??=function(){let e=nR(()=>i6([iw(),iV(),iW(),iK(),ni(iw(),e),i2(e)])),t=ni(iw(),e),r=i6([iw(),iV().int()]),i=iw(),n=i6([iw(),iV().int()]),a=na(["user","assistant"]),o=na(["debug","info","notice","warning","error","critical","alert","emergency"]),s=iw().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=i4({ttl:iV().optional()}),c=i4({taskId:iw()}),d=i5({progressToken:r.optional(),"io.modelcontextprotocol/related-task":c.optional()}),u=i4({_meta:d.optional()}),p=u.extend({task:l.optional()}),m=i4({_meta:d.optional()}),h=i4({method:iw(),params:m.loose().optional()}),f=i4({src:iw(),mimeType:iw().optional(),sizes:i2(iw()).optional(),theme:na(["light","dark"]).optional()}),g=i4({icons:i2(f).optional()}),y=i4({name:iw(),title:iw().optional()}),v=y.extend({...y.shape,...g.shape,version:iw(),websiteUrl:iw().optional(),description:iw().optional()}),_=nt(i4({applyDefaults:iW().optional()}),t),b=nC(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,nt(i4({form:_.optional(),url:t.optional()}),t.optional())),S=i5({list:t.optional(),cancel:t.optional(),requests:i5({sampling:i5({createMessage:t.optional()}).optional(),elicitation:i5({create:t.optional()}).optional()}).optional()}),w=i5({list:t.optional(),cancel:t.optional(),requests:i5({tools:i5({call:t.optional()}).optional()}).optional()}),k=i4({experimental:ni(iw(),t).optional(),sampling:i4({context:t.optional(),tools:t.optional()}).optional(),elicitation:b.optional(),roots:i4({listChanged:iW().optional()}).optional(),tasks:S.optional(),extensions:ni(iw(),t).optional()}),R=i4({experimental:ni(iw(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:i4({listChanged:iW().optional()}).optional(),resources:i4({subscribe:iW().optional(),listChanged:iW().optional()}).optional(),tools:i4({listChanged:iW().optional()}).optional(),tasks:w.optional(),extensions:ni(iw(),t).optional()}),x=i4({progress:iV(),total:nu(iV()),message:nu(iw())}),C=i4({...m.shape,...x.shape,progressToken:r}),$=h.extend({method:ns("notifications/progress"),params:C}),T=m.extend({level:o,logger:iw().optional(),data:iQ()}),E=h.extend({method:ns("notifications/message"),params:T}),P=i4({uri:iw(),mimeType:nu(iw()),_meta:ni(iw(),iQ()).optional()}),I=P.extend({text:iw()}),q=P.extend({blob:s}),O=i4({audience:i2(a).optional(),priority:iV().min(0).max(1).optional(),lastModified:r6({offset:!0}).optional()}),j=i4({...y.shape,...g.shape,uri:iw(),description:nu(iw()),mimeType:nu(iw()),size:nu(iV()),annotations:O.optional(),_meta:nu(i5({}))}),z=i4({...y.shape,...g.shape,uriTemplate:iw(),description:nu(iw()),mimeType:nu(iw()),annotations:O.optional(),_meta:nu(i5({}))}),L=h.extend({method:ns("notifications/resources/list_changed"),params:m.optional()}),N=m.extend({uri:iw()}),A=h.extend({method:ns("notifications/resources/updated"),params:N}),M=i4({name:iw(),description:nu(iw()),required:nu(iW())}),Z=i4({...y.shape,...g.shape,description:nu(iw()),arguments:nu(i2(M)),_meta:nu(i5({}))}),U=h.extend({method:ns("notifications/prompts/list_changed"),params:m.optional()}),H=i4({type:ns("text"),text:iw(),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),F=i4({type:ns("image"),data:s,mimeType:iw(),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),V=i4({type:ns("audio"),data:s,mimeType:iw(),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),D=i4({type:ns("tool_use"),name:iw(),id:iw(),input:ni(iw(),iQ()),_meta:ni(iw(),iQ()).optional()}),J=i4({type:ns("resource"),resource:i6([I,q]),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),B=j.extend({type:ns("resource_link")}),W=i6([H,F,V,B,J]),G=i4({role:a,content:W}),K=i4({title:iw().optional(),readOnlyHint:iW().optional(),destructiveHint:iW().optional(),idempotentHint:iW().optional(),openWorldHint:iW().optional()}),Y=h.extend({method:ns("notifications/tools/list_changed"),params:m.optional()}),X=i4({name:iw().optional()}),Q=i4({hints:i2(X).optional(),costPriority:iV().min(0).max(1).optional(),speedPriority:iV().min(0).max(1).optional(),intelligencePriority:iV().min(0).max(1).optional()}),ee=i4({mode:na(["auto","required","none"]).optional()}),et=i4({type:ns("boolean"),title:iw().optional(),description:iw().optional(),default:iW().optional()}),er=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),minLength:iV().optional(),maxLength:iV().optional(),format:na(["email","uri","date","date-time"]).optional(),default:iw().optional()}),ei=i4({type:na(["number","integer"]),title:iw().optional(),description:iw().optional(),minimum:iV().optional(),maximum:iV().optional(),default:iV().optional()}),en=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),default:iw().optional()}),ea=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),oneOf:i2(i4({const:iw(),title:iw()})),default:iw().optional()}),eo=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),enumNames:i2(iw()).optional(),default:iw().optional()}),es=i6([en,ea]),el=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({type:ns("string"),enum:i2(iw())}),default:i2(iw()).optional()}),ec=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({anyOf:i2(i4({const:iw(),title:iw()}))}),default:i2(iw()).optional()}),ed=i6([el,ec]),eu=i6([eo,es,ed]),ep=i6([eu,et,er,ei]),em=p.extend({mode:ns("form").optional(),message:iw(),requestedSchema:i4({type:ns("object"),properties:ni(iw(),ep),required:i2(iw()).optional()}).catchall(iQ())}),eh=i4({type:ns("ref/resource"),uri:iw()}),ef=i4({type:ns("ref/prompt"),name:iw()}),eg=i4({uri:iw().startsWith("file://"),name:iw().optional(),_meta:ni(iw(),iQ()).optional()}),ey=k.shape,ev=i4({experimental:ey.experimental,sampling:ey.sampling,elicitation:ey.elicitation,roots:ey.roots,extensions:ey.extensions}),e_=R.shape,eb=i4({experimental:e_.experimental,logging:e_.logging,completions:e_.completions,prompts:e_.prompts,resources:e_.resources,tools:e_.tools,extensions:e_.extensions}),eS=i5({progressToken:r.optional(),[nE]:iw(),[nP]:v.optional(),[nq]:ev,[nj]:o.optional()}),ew=i4({...y.shape,...g.shape,description:iw().optional(),inputSchema:i5({$schema:iw().optional(),type:ns("object")}),outputSchema:i5({$schema:iw().optional()}).optional(),annotations:K.optional(),_meta:ni(iw(),iQ()).optional()}),ek=i4({type:ns("tool_result"),toolUseId:iw(),content:i2(W),structuredContent:iQ().optional(),isError:iW().optional(),_meta:ni(iw(),iQ()).optional()}),eR=i6([H,F,V,D,ek]),ex=i4({role:a,content:i6([eR,i2(eR)]),_meta:ni(iw(),iQ()).optional()}),eC=iw(),e$=i5({[nI]:v.optional().catch(void 0)}),eT=e$.optional();function eE(e){return i5({_meta:eT,resultType:eC.default("complete"),...e})}let eP=eE({}),eI=eE({nextCursor:i.optional()}),eq=eE({content:i2(W),structuredContent:iQ().optional(),isError:iW().optional()}),eO=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),tools:i2(ew),nextCursor:i.optional()}),ej=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),prompts:i2(Z),nextCursor:i.optional()}),ez=eE({description:iw().optional(),messages:i2(G)}),eL=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resources:i2(j),nextCursor:i.optional()}),eN=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resourceTemplates:i2(z),nextCursor:i.optional()}),eA=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),contents:i2(i6([I,q]))}),eM=eE({completion:i4({values:i2(iw()).max(100),total:iV().int().optional(),hasMore:iW().optional()}).loose()}),eZ=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"])}),eU=eE({ttlMs:iV().int().min(0).catch(0),cacheScope:na(["public","private"]).catch("private"),supportedVersions:i2(iw()),capabilities:eb,instructions:iw().optional()}),eH=i4({messages:i2(ex),modelPreferences:Q.optional(),systemPrompt:iw().optional(),includeContext:na(["none","thisServer","allServers"]).optional(),temperature:iV().optional(),maxTokens:iV().int(),stopSequences:i2(iw()).optional(),metadata:t.optional(),tools:i2(ew).optional(),toolChoice:ee.optional()}),eF=i4({method:ns("sampling/createMessage"),params:eH}),eV=i4({method:ns("roots/list"),params:i4({_meta:ni(iw(),iQ()).optional()}).optional()}),eD=i4({...ex.shape,model:iw(),stopReason:iw().optional()}),eJ=i4({roots:i2(eg)}),eB=i4({action:na(["accept","decline","cancel"]),content:ni(iw(),i6([iw(),iV(),iW(),i2(iw())])).optional()}),eW=i4({mode:ns("url"),message:iw(),url:iw().url()}),eG=i6([em,eW]),eK=i4({method:ns("elicitation/create"),params:eG}),eY=i6([eF,eV,eK]),eX=i6([eD,eJ,eB]),eQ=ni(iw(),eY),e0=ni(iw(),eX),e1=eE({inputRequests:eQ.optional(),requestState:iw().optional()}),e2={inputResponses:e0.optional(),requestState:iw().optional()},e9=i4({_meta:eS,...e2}),e4=i5({progressToken:r.optional()});function e5(e,t){return i4({method:ns(e),params:i4({_meta:eS,...t})})}function e3(e,t){return i4({method:ns(e),params:i4({_meta:e4.optional(),...t}).optional()})}let e6={name:iw(),arguments:ni(iw(),iQ()).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:iw(),arguments:ni(iw(),iw()).optional(),...e2}),ti=e5("resources/list",e7),tn=e5("resources/templates/list",e7),ta=e5("resources/read",{uri:iw(),...e2}),to={ref:i6([ef,eh]),argument:i4({name:iw(),value:iw()}),context:i4({arguments:ni(iw(),iw()).optional()}).optional()},ts=e5("completion/complete",to),tl=e5("server/discover",{}),tc=i4({toolsListChanged:iW().optional(),promptsListChanged:iW().optional(),resourcesListChanged:iW().optional(),resourceSubscriptions:i2(iw()).optional()}),td={notifications:tc},tu=e5("subscriptions/listen",td),tp=e$.extend({"io.modelcontextprotocol/subscriptionId":n}),tm=i5({_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:iw(),arguments:ni(iw(),iw()).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:iw()}),"completion/complete":e3("completion/complete",to),"server/discover":e3("server/discover",{}),"subscriptions/listen":e3("subscriptions/listen",td)};function tf(e){return i5({_meta:eT,...e})}let tg={"tools/call":tf({content:i2(W),structuredContent:iQ().optional(),isError:iW().optional()}),"tools/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),tools:i2(ew),nextCursor:i.optional()}),"prompts/get":tf({description:iw().optional(),messages:i2(G)}),"prompts/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),prompts:i2(Z),nextCursor:i.optional()}),"resources/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resources:i2(j),nextCursor:i.optional()}),"resources/templates/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resourceTemplates:i2(z),nextCursor:i.optional()}),"resources/read":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),contents:i2(i6([I,q]))}),"completion/complete":tf({completion:i4({values:i2(iw()).max(100),total:iV().int().optional(),hasMore:iW().optional()}).loose()}),"server/discover":tf({ttlMs:iV().int().min(0).catch(0),cacheScope:na(["public","private"]).catch("private"),supportedVersions:i2(iw()),capabilities:eb,instructions:iw().optional()}),"subscriptions/listen":tf({})},ty=i5({"io.modelcontextprotocol/subscriptionId":n.optional()}),tv=i4({method:ns("notifications/subscriptions/acknowledged"),params:i4({_meta:ty.optional(),notifications:tc})}),t_=i4({_meta:ty.optional(),requestId:n,reason:iw().optional()}),tb=i4({method:ns("notifications/cancelled"),params:t_}),tS=e=>i4({jsonrpc:ns("2.0"),id:i6([iw(),iV().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:i,RequestIdSchema:n,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:l,RelatedTaskMetadataSchema:c,RequestMetaSchema:d,BaseRequestParamsSchema:u,TaskAugmentedRequestParamsSchema:p,NotificationsParamsSchema:m,NotificationSchema:h,IconSchema:f,IconsSchema:g,BaseMetadataSchema:y,ImplementationSchema:v,ClientTasksCapabilitySchema:S,ServerTasksCapabilitySchema:w,ClientCapabilitiesSchema:k,ServerCapabilitiesSchema:R,ProgressSchema:x,ProgressNotificationParamsSchema:C,ProgressNotificationSchema:$,LoggingMessageNotificationParamsSchema:T,LoggingMessageNotificationSchema:E,ResourceContentsSchema:P,TextResourceContentsSchema:I,BlobResourceContentsSchema:q,AnnotationsSchema:O,ResourceSchema:j,ResourceTemplateSchema:z,ResourceListChangedNotificationSchema:L,ResourceUpdatedNotificationParamsSchema:N,ResourceUpdatedNotificationSchema:A,PromptArgumentSchema:M,PromptSchema:Z,PromptListChangedNotificationSchema:U,TextContentSchema:H,ImageContentSchema:F,AudioContentSchema:V,ToolUseContentSchema:D,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:ea,LegacyTitledEnumSchemaSchema:eo,SingleSelectEnumSchemaSchema:es,UntitledMultiSelectEnumSchemaSchema:el,TitledMultiSelectEnumSchemaSchema:ec,MultiSelectEnumSchemaSchema:ed,EnumSchemaSchema:eu,PrimitiveSchemaDefinitionSchema:ep,ElicitRequestFormParamsSchema:em,ResourceTemplateReferenceSchema:eh,PromptReferenceSchema:ef,RootSchema:eg,ClientCapabilities2026Schema:ev,ServerCapabilities2026Schema:eb,RequestMetaEnvelopeSchema:eS,ToolSchema:ew,ToolResultContentSchema:ek,SamplingMessageContentBlockSchema:eR,SamplingMessageSchema:ex,ResultTypeSchema:eC,ResultMetaSchema:e$,ResultSchema:eP,PaginatedResultSchema:eI,CallToolResultSchema:eq,ListToolsResultSchema:eO,ListPromptsResultSchema:ej,GetPromptResultSchema:ez,ListResourcesResultSchema:eL,ListResourceTemplatesResultSchema:eN,ReadResourceResultSchema:eA,CompleteResultSchema:eM,CacheableResultSchema:eZ,DiscoverResultSchema:eU,CreateMessageRequestParamsSchema:eH,CreateMessageRequestSchema:eF,ListRootsRequestSchema:eV,CreateMessageResultSchema:eD,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:ta,CompleteRequestSchema:ts,DiscoverRequestSchema:tl,SubscriptionFilterSchema:tc,SubscriptionsListenRequestSchema:tu,SubscriptionsListenResultMetaSchema:tp,SubscriptionsListenResultSchema:tm,dispatchRequestSchemas:th,dispatchResultSchemas:tg,NotificationMetaSchema:ty,SubscriptionsAcknowledgedNotificationSchema:tv,CancelledNotificationParamsSchema:t_,CancelledNotificationSchema:tb,notificationSchemas2026:{"notifications/cancelled":tb,"notifications/progress":$,"notifications/message":E,"notifications/resources/updated":A,"notifications/resources/list_changed":L,"notifications/tools/list_changed":Y,"notifications/prompts/list_changed":U,"notifications/subscriptions/acknowledged":tv},JSONRPCResultResponseSchema:tS(eP),CallToolResultResponseSchema:tS(i6([eq,e1])),ListToolsResultResponseSchema:tS(eO),ListPromptsResultResponseSchema:tS(ej),GetPromptResultResponseSchema:tS(i6([ez,e1])),ListResourcesResultResponseSchema:tS(eL),ListResourceTemplatesResultResponseSchema:tS(eN),ReadResourceResultResponseSchema:tS(i6([eA,e1])),CompleteResultResponseSchema:tS(eM),DiscoverResultResponseSchema:tS(eU)}}()}let s0=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],s1=Symbol("modelcontextprotocol.resultCacheHintFallback");function s2(e,t){if(void 0===t)return e;let r=e[s1];if(void 0===r)return{...e,[s1]:t};let i={},n=r.ttlMs??t.ttlMs;void 0!==n&&(i.ttlMs=n);let a=r.cacheScope??t.cacheScope;return void 0!==a&&(i.cacheScope=a),{...e,[s1]:i}}function s9(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function s4(e){return"public"===e||"private"===e}function s5(e,t){if(void 0!==e.ttlMs&&!s9(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&&!s4(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}let s3=((g={})[g.ParseError=-32700]="ParseError",g[g.InvalidRequest=-32600]="InvalidRequest",g[g.MethodNotFound=-32601]="MethodNotFound",g[g.InvalidParams=-32602]="InvalidParams",g[g.InternalError=-32603]="InternalError",g[g.ResourceNotFound=-32002]="ResourceNotFound",g[g.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",g[g.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",g[g.UrlElicitationRequired=-32042]="UrlElicitationRequired",g);var s6=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](e){return sx(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 sx(this,e)}constructor(e,t,r){super(t),this.code=e,this.data=r,this.name="ProtocolError",sR(this,new.target)}static fromError(t,r,i){return t===s3.UrlElicitationRequired&&i&&i.elicitations?new s8(i.elicitations,r):t===s3.UnsupportedProtocolVersion&&i&&Array.isArray(i.supported)&&"string"==typeof i.requested?new le({supported:i.supported,requested:i.requested},r):(t===s3.InvalidParams||t===s3.ResourceNotFound)&&"string"==typeof i?.uri&&(t===s3.ResourceNotFound||1===Object.keys(i).length)?new s7(i.uri,r):t===s3.MissingRequiredClientCapability&&i&&null!==i.requiredCapabilities&&"object"==typeof i.requiredCapabilities&&!Array.isArray(i.requiredCapabilities)?new lt({requiredCapabilities:i.requiredCapabilities},r):new e(t,r,i)}},s7=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(s3.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},s8=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(s3.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},le=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(s3.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},lt=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(s3.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};let lr=["tools/call","prompts/get","resources/read"],li=["elicitation/create","sampling/createMessage","roots/list"];function ln(){if(i)return i;let e=sQ();return i={request:{"elicitation/create":i4({method:ns("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":i4({method:ns("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":i4({method:ns("roots/list"),params:i5({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}}}function la(e){return li.includes(e)}function lo(e){return la(e)?ln().request[e]:void 0}let ls={"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},ll={"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 lc(e){return Object.prototype.hasOwnProperty.call(ls,e)}function ld(e){return Object.prototype.hasOwnProperty.call(ll,e)}function lu(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lp(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(ls),Object.keys(ll);let lm={ok:!1,reason:"not-in-era"},lh=[nE,nq],lf={era:"2026-07-28",hasRequestMethod:lc,hasNotificationMethod:ld,hasInputRequestMethod:e=>void 0!==lo(e),validateRequest:(e,t)=>lp(lc(e)?sQ().dispatchRequestSchemas[e]:void 0,t),validateResult:(e,t)=>lp(Object.prototype.hasOwnProperty.call(ls,e)?sQ().dispatchResultSchemas[e]:void 0,t),validateNotification:(e,t)=>lp(ld(e)?sQ().notificationSchemas2026[e]:void 0,t),validateInputRequest:(e,t)=>lp(lo(e),t),validateInputResponse:(e,t)=>lp(la(e)?ln().response[e]:void 0,t),samplingResultVariant:()=>lm,outboundEnvelope:e=>({[nE]:e.protocolVersion,[nP]:e.clientInfo,[nq]:e.clientCapabilities,...void 0!==e.logLevel&&{[nj]:e.logLevel}}),validateEnvelopeMeta(e){let t=[];for(let r of lh)r in e||t.push({key:r,problem:"missing"});let r=sQ().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=>sj(e),inputRequestSchema:lo,decodeResult(e,t){if(!lu(t))return{kind:"invalid",error:new s$(sC.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(void 0===r)return{kind:"invalid",error:new s$(sC.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 s$(sC.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if("input_required"===r){let r=t.inputRequests,i=lu(r)?r:{},n=t.requestState;return 0===Object.keys(i).length&&"string"!=typeof n?{kind:"invalid",error:new s$(sC.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}}}if("complete"!==r)return{kind:"invalid",error:new s$(sC.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let i=lg(),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 s$(sC.InvalidResult,`Invalid result for ${e}: ${r.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:"complete",result:a}},encodeResult:(e,t,r)=>(function(e,t){if(void 0===t)return e;let r=e._meta;return void 0===r?{...e,_meta:{[nI]:t}}:null===r||"object"!=typeof r||Array.isArray(r)||void 0!==r[nI]?e:{...e,_meta:{...r,[nI]:t}}})(function(e,t){var r,i;let n=t[s1];if("complete"!==t.resultType||!s0.includes(e)){let e;return void 0===n?t:(e={...t},delete e[s1],e)}let a=s9(t.ttlMs)?t.ttlMs:void 0!==(r=n)&&s9(r.ttlMs)?r.ttlMs:0,o=s4(t.cacheScope)?t.cacheScope:void 0!==(i=n)&&s4(i.cacheScope)?i.cacheScope:"private",s={...t,ttlMs:a,cacheScope:o};return delete s[s1],s}(e,function(e,t){let r=t.resultType;if(void 0===r)return{...t,resultType:"complete"};if("complete"===r||lr.includes(e))return t;throw new s6(s3.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),a=t.tools;"tools/list"===e&&Array.isArray(a)&&a.some(e=>lu(e)&&"execution"in e)&&(n().tools=a.map(e=>{if(!lu(e)||!("execution"in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(lu(o)&&"tasks"in o){let e={...o};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=sQ().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 lg(){if(n)return n;let e=sQ();return n={"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 ly="2026-07-28";function lv(e){return void 0!==e&&e>=sI?lf:sX}function l_(e){return void 0!==e.revision?lv(e.revision).era:"modern"===e.era?lf.era:sX.era}function lb(e){return lw.some(t=>t.hasRequestMethod(e))}function lS(e){return lw.some(t=>t.hasNotificationMethod(e))}let lw=[sX,lf];function lk(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lR(e){if(!lk(e))return;let t=e._meta;return lk(t)?t:void 0}function lx(e){let t=lR(e);return void 0!==t&&nE in t}function lC(e){let t=lR(e)?.[nE];return"string"==typeof t?t:void 0}function l$(e){return lv(ly).validateEnvelopeMeta(e)}var lT=((e,t)=>{let r={};for(var i in e)O(r,i,{get:e[i],enumerable:!0});return t&&O(r,Symbol.toStringTag,{value:"Module"}),r})({AnnotationsSchema:()=>aR,AudioContentSchema:()=>a0,BaseMetadataSchema:()=>n7,BaseRequestParamsSchema:()=>nF,BlobResourceContentsSchema:()=>aw,BooleanSchemaSchema:()=>ox,CallToolRequestParamsSchema:()=>oa,CallToolRequestSchema:()=>oo,CallToolResultSchema:()=>oi,CancelTaskRequestSchema:()=>st,CancelTaskResultSchema:()=>sr,CancelledNotificationParamsSchema:()=>n4,CancelledNotificationSchema:()=>n5,ClientCapabilitiesSchema:()=>an,ClientNotificationSchema:()=>sn,ClientRequestSchema:()=>si,ClientResultSchema:()=>sa,ClientTasksCapabilitySchema:()=>ar,CompatibilityCallToolResultSchema:()=>on,CompleteRequestParamsSchema:()=>oJ,CompleteRequestSchema:()=>oB,CompleteResultSchema:()=>oW,ContentBlockSchema:()=>a4,CreateMessageRequestParamsSchema:()=>oS,CreateMessageRequestSchema:()=>ow,CreateMessageResultSchema:()=>ok,CreateMessageResultWithToolsSchema:()=>oR,CreateTaskResultSchema:()=>o2,CursorSchema:()=>nM,DiscoverRequestSchema:()=>ad,DiscoverResultSchema:()=>au,ElicitRequestFormParamsSchema:()=>oN,ElicitRequestParamsSchema:()=>oM,ElicitRequestSchema:()=>oZ,ElicitRequestURLParamsSchema:()=>oA,ElicitResultSchema:()=>oF,ElicitationCompleteNotificationParamsSchema:()=>oU,ElicitationCompleteNotificationSchema:()=>oH,EmbeddedResourceSchema:()=>a2,EmptyResultSchema:()=>n9,EnumSchemaSchema:()=>oz,GetPromptRequestParamsSchema:()=>aK,GetPromptRequestSchema:()=>aY,GetPromptResultSchema:()=>a3,GetTaskPayloadRequestSchema:()=>o6,GetTaskPayloadResultSchema:()=>o7,GetTaskRequestSchema:()=>o5,GetTaskResultSchema:()=>o3,IconSchema:()=>n3,IconsSchema:()=>n6,ImageContentSchema:()=>aQ,ImplementationSchema:()=>n8,InitializeRequestParamsSchema:()=>aa,InitializeRequestSchema:()=>ao,InitializeResultSchema:()=>al,InitializedNotificationSchema:()=>ac,JSONArraySchema:()=>nN,JSONObjectSchema:()=>nL,JSONRPCErrorResponseSchema:()=>n0,JSONRPCMessageSchema:()=>n1,JSONRPCNotificationSchema:()=>nX,JSONRPCRequestSchema:()=>nY,JSONRPCResponseSchema:()=>n2,JSONRPCResultResponseSchema:()=>nQ,JSONValueSchema:()=>nz,LegacyTitledEnumSchemaSchema:()=>oP,ListChangedOptionsBaseSchema:()=>ol,ListPromptsRequestSchema:()=>aW,ListPromptsResultSchema:()=>aG,ListResourceTemplatesRequestSchema:()=>aE,ListResourceTemplatesResultSchema:()=>aP,ListResourcesRequestSchema:()=>a$,ListResourcesResultSchema:()=>aT,ListRootsRequestSchema:()=>oK,ListRootsResultSchema:()=>oY,ListTasksRequestSchema:()=>o8,ListTasksResultSchema:()=>se,ListToolsRequestSchema:()=>ot,ListToolsResultSchema:()=>or,LoggingLevelSchema:()=>oc,LoggingMessageNotificationParamsSchema:()=>op,LoggingMessageNotificationSchema:()=>om,ModelHintSchema:()=>oh,ModelPreferencesSchema:()=>of,MultiSelectEnumSchemaSchema:()=>oj,NotificationSchema:()=>nB,NotificationsParamsSchema:()=>nJ,NumberSchemaSchema:()=>o$,PaginatedRequestParamsSchema:()=>ag,PaginatedRequestSchema:()=>ay,PaginatedResultSchema:()=>av,PingRequestSchema:()=>ap,PrimitiveSchemaDefinitionSchema:()=>oL,ProgressNotificationParamsSchema:()=>ah,ProgressNotificationSchema:()=>af,ProgressSchema:()=>am,ProgressTokenSchema:()=>nA,PromptArgumentSchema:()=>aJ,PromptListChangedNotificationSchema:()=>a6,PromptMessageSchema:()=>a5,PromptReferenceSchema:()=>oD,PromptSchema:()=>aB,ReadResourceRequestParamsSchema:()=>aI,ReadResourceRequestSchema:()=>aq,ReadResourceResultSchema:()=>aO,RelatedTaskMetadataSchema:()=>nU,RequestIdSchema:()=>nK,RequestMetaSchema:()=>nH,RequestSchema:()=>nD,ResourceContentsSchema:()=>a_,ResourceLinkSchema:()=>a9,ResourceListChangedNotificationSchema:()=>aj,ResourceRequestParamsSchema:()=>aI,ResourceSchema:()=>ax,ResourceTemplateReferenceSchema:()=>oV,ResourceTemplateSchema:()=>aC,ResourceUpdatedNotificationParamsSchema:()=>aV,ResourceUpdatedNotificationSchema:()=>aD,ResultMetaObjectSchema:()=>nW,ResultSchema:()=>nG,RoleSchema:()=>ak,RootSchema:()=>oG,RootsListChangedNotificationSchema:()=>oX,SamplingContentSchema:()=>ov,SamplingMessageContentBlockSchema:()=>o_,SamplingMessageSchema:()=>ob,ServerCapabilitiesSchema:()=>as,ServerNotificationSchema:()=>ss,ServerRequestSchema:()=>so,ServerResultSchema:()=>sl,ServerTasksCapabilitySchema:()=>ai,SetLevelRequestParamsSchema:()=>od,SetLevelRequestSchema:()=>ou,SingleSelectEnumSchemaSchema:()=>oI,StringSchemaSchema:()=>oC,SubscribeRequestParamsSchema:()=>aI,SubscribeRequestSchema:()=>az,SubscriptionFilterSchema:()=>aN,SubscriptionsAcknowledgedNotificationParamsSchema:()=>aZ,SubscriptionsAcknowledgedNotificationSchema:()=>aU,SubscriptionsListenRequestParamsSchema:()=>aA,SubscriptionsListenRequestSchema:()=>aM,SubscriptionsListenResultMetaSchema:()=>aH,SubscriptionsListenResultSchema:()=>aF,TaskAugmentedRequestParamsSchema:()=>nV,TaskCreationParamsSchema:()=>oQ,TaskMetadataSchema:()=>nZ,TaskSchema:()=>o1,TaskStatusNotificationParamsSchema:()=>o9,TaskStatusNotificationSchema:()=>o4,TaskStatusSchema:()=>o0,TextContentSchema:()=>aX,TextResourceContentsSchema:()=>ab,TitledMultiSelectEnumSchemaSchema:()=>oO,TitledSingleSelectEnumSchemaSchema:()=>oE,ToolAnnotationsSchema:()=>a7,ToolChoiceSchema:()=>og,ToolExecutionSchema:()=>a8,ToolListChangedNotificationSchema:()=>os,ToolResultContentSchema:()=>oy,ToolSchema:()=>oe,ToolUseContentSchema:()=>a1,UnsubscribeRequestParamsSchema:()=>aI,UnsubscribeRequestSchema:()=>aL,UntitledMultiSelectEnumSchemaSchema:()=>oq,UntitledSingleSelectEnumSchemaSchema:()=>oT});let lE=e=>nY.safeParse(e).success,lP=e=>nX.safeParse(e).success,lI=e=>nQ.safeParse(e).success,lq=e=>n0.safeParse(e).success,lO=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"input_required"===e.resultType,lj="x-mcp-header",lz=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,lL=new Set(["string","integer","boolean","number"]);function lN(e){let t=[],r=new Map,i=(e,n,a)=>{if(null===e||"object"!=typeof e)return;if(lj in e){if(!a||0===n.length)return`${lZ(n)}: 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 i=e[lj];if("string"!=typeof i||0===i.length)return`${lZ(n)}: x-mcp-header MUST be a non-empty string`;if(!lz.test(i))return`${lZ(n)}: x-mcp-header '${i}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let o="string"==typeof e.type?e.type:void 0;if(void 0===o||!lL.has(o))return`${lZ(n)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${o??"<none>"}`;let s=i.toLowerCase(),l=r.get(s);if(void 0!==l)return`x-mcp-header '${i}' is not case-insensitively unique (also declared as '${l}')`;r.set(s,i),t.push({path:n,headerName:i,type:o})}let o=e.properties;if(null!==o&&"object"==typeof o)for(let[e,t]of Object.entries(o)){let r=i(t,[...n,e],a);if(void 0!==r)return r}for(let t of lA){let r=e[t];if(void 0!==r)for(let e of Array.isArray(r)?r:null!==r&&"object"==typeof r&&lM.has(t)?Object.values(r):[r]){let r=i(e,[...n,`<${t}>`],!1);if(void 0!==r)return r}}},n=i(e,[],!0);return void 0===n?{valid:!0,declarations:t}:{valid:!1,reason:n}}let lA=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],lM=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function lZ(e){return 0===e.length?"<root>":e.join(".")}let lU=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,lH=/^-?\d+(\.\d+)?$/;function lF(e){if(!(e.startsWith("=?base64?")&&e.endsWith("?=")))return e;let t=e.slice(9,e.length-2);if(lU.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 lV(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:lD,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}let lD=-32020;s3.InvalidRequest,s3.UnsupportedProtocolVersion,s3.InvalidParams,s3.MethodNotFound,s3.InvalidParams,s3.MissingRequiredClientCapability;let lJ={[s3.ParseError]:400,[s3.InvalidRequest]:400,[s3.MethodNotFound]:404,[s3.UnsupportedProtocolVersion]:400,[s3.MissingRequiredClientCapability]:400,[lD]:400};function lB(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 lW(e,t,r,i="era-classification"){return lB(i,e,400,new s6(lD,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}let lG={"tools/call":"name","prompts/get":"name","resources/read":"uri"};function lK(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 lY(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lX(e){return void 0===e?{era:"modern"}:{era:e>=sI?"modern":"legacy",revision:e}}function lQ(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function l0(e){if(null==e)return!1;let t=typeof e;return("object"===t||"function"===t)&&"~standard"in e&&"function"==typeof e["~standard"]?.validate}let l1=!1,l2="draft-2020-12";function l9(e,t="input"){let r,i=e["~standard"];if(i.jsonSchema)r=i.jsonSchema[t]({target:l2});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().");l1||(l1=!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=r5(e,{target:l2,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){if("properties"in t||"patternProperties"in t||"additionalProperties"in t||"required"in t)return!0;for(let r of["oneOf","anyOf","allOf"]){let i=t[r];if(Array.isArray(i)&&i.length>0)return i.every(t=>null!==t&&"object"==typeof t&&("object"===t.type||e(t)))}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}}async function l4(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 l5=/\\\.\\d\{(\d+)\}/;function l3(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let l6=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function l7(e){return l6.has(e)||e.startsWith("x-")}let l8=new Set(["$schema",...Object.keys(oN.shape.requestedSchema.shape)]),ce={string:lQ([oC,oT,oE,oP]),number:lQ([o$]),integer:lQ([o$]),boolean:lQ([ox]),array:lQ([oq,oO])},ct=new Set(oC.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(!l0(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,a]of Object.entries(e))"properties"===n&&l3(a)?r[n]=Object.fromEntries(Object.entries(a).map(([e,r])=>[e,function(e,t,r,i){if(!l3(e))return e;let n="string"==typeof e.type&&Object.hasOwn(ce,e.type)?ce[e.type]:void 0;if(void 0===n)return e;let a={};for(let[s,l]of Object.entries(e))if(n.has(s)||l7(s))a[s]=l;else if("pattern"===s&&"string"===e.type&&"string"==typeof e.format)if(ct.has(e.format)){var o;"string"==typeof l&&(o=e.format,"zod"!==r||(function(e,t){let r;switch(e){case"email":r=[rf(iR,void 0)];break;case"uri":r=[ry(i$,void 0)];break;case"date":r=[r8()];break;case"date-time":let i,n;i=l5.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=>r6({local:e,offset:t,precision:r}))))}return new Set(r.map(e=>{let t;return t=r5(e,{target:l2,io:"input"}),"string"==typeof t.pattern?t.pattern:void 0}).filter(e=>void 0!==e))})(o,l).has(l))||i.push(`${t}.${s}`)}else a[s]=l;else i.push(`${t}.${s}`);return a}(r,`properties.${e}`,t,i)])):l8.has(n)?r[n]=a:l7(n)||i.push(n);if(i.length>0)throw new s6(s3.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(", ")}`);return r}(function(e){try{return l9(e,"input")}catch(t){let e=t instanceof Error?t.message:String(t);throw new s6(s3.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${e}`)}}(e.requestedSchema),r),n=(t=oN.shape.requestedSchema,io(t,i));if(!n.success)throw new s6(s3.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(e,t){if(!l3(e.properties))return t;let r=Object.entries(e.properties).filter(([,e])=>!io(oL,e).success).map(([e])=>`properties.${e}`);return r.length>0?r.join(", "):t}(i,n.error.message)}`);let a=function e(t,r,i=""){return Array.isArray(t)&&Array.isArray(r)?t.flatMap((t,n)=>e(t,r[n],`${i}[${n}]`)):l3(t)&&l3(r)?Object.entries(t).flatMap(([t,n])=>{let a=i?`${i}.${t}`:t;return Object.prototype.hasOwnProperty.call(r,t)?e(n,r[t],a):l7(t)?[]:[a]}):[]}(i,n.data);if(a.length>0)throw new s6(s3.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${a.join(", ")}`);let o=(n.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(n.data.properties,e));if(o.length>0)throw new s6(s3.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${o.join(", ")}`);return{...e,mode:"form",requestedSchema:n.data}}(e)}}catch(e){throw e instanceof s6?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 cr={},ci={};function cn(e,t){let r=e.slice(0,-6);cr[r]=t,ci[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"])cn(e,lT[e]);for(let[e,t]of Object.entries({IdJagTokenExchangeResponseSchema:sf,OAuthClientInformationFullSchema:sb,OAuthClientInformationSchema:s_,OAuthClientMetadataSchema:sv,OAuthClientRegistrationErrorSchema:sS,OAuthErrorResponseSchema:sg,OAuthMetadataSchema:su,OAuthProtectedResourceMetadataSchema:sd,OAuthTokenRevocationRequestSchema:sw,OAuthTokensSchema:sh,OpenIdProviderDiscoveryMetadataSchema:sm,OpenIdProviderMetadataSchema:sp}))cn(e,t);Object.freeze(cr),Object.freeze(ci);let ca=[nE,nP,nq,nj],co=["inputResponses","requestState"];function cs(e,t){let r=e.params;if(!cp(r))return{message:e,lifted:{}};let i=r._meta,n=cp(i)?ca.filter(e=>e in i):[],a="request"===t?co.filter(e=>e in r):[];if(0===n.length&&0===a.length)return{message:e,lifted:{}};let o={},s={...r};if(n.length>0&&cp(i)){let e={},t={...i};for(let r of n)e[r]=i[r],delete t[r];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)"inputResponses"===e&&(o.inputResponses=s[e]),"requestState"===e&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function cl(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 cc=(y=void 0,()=>y);function cd(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:()=>t}}}var cu=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{a=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??nT,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 s$(sC.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){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 s$(sC.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),lI(e)||lq(e)?this._onresponse(e):lE(e)?this._onrequest(e,t):lP(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 s$(sC.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}=cs(e,"notification"),i=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return;if(t?.classification!==void 0){let e=l_(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(lS(r.method)&&!i.hasNotificationMethod(r.method))return;let n=this._notificationHandlers.get(r.method),a=this.fallbackNotificationHandler;(void 0!==n||void 0!==a)&&Promise.resolve().then(()=>void 0===n?a(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}=cs(e,"request"),a=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 o=this._transport,s=(e,t,r)=>{let n={jsonrpc:"2.0",id:i.id,error:{code:e,message:t,...void 0!==r&&{data:r}}};o?.send(n).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=l_(t.classification);if(e!==a.era){this._onerror(Error(`Era mismatch on inbound request '${i.method}': classified as ${e} but this instance serves ${a.era}`));let r=t.classification.revision??e;s(s3.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(lb(i.method)&&!a.hasRequestMethod(i.method))return void s(s3.MethodNotFound,"Method not found");let l=this._requestHandlers.get(i.method)??this.fallbackRequestHandler;if(void 0===l)return void s(s3.MethodNotFound,"Method not found");let c=a.checkInboundEnvelope(n);if(void 0!==c)return void s(s3.InvalidParams,c);let d=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:i.id}),u=(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(!cm(e))return{accepted:t,droppedKeys:r};for(let[i,n]of Object.entries(e)){if(!cm(n)||"method"in n||"result"in n){r.push(i);continue}t[i]=n}return{accepted:t,droppedKeys:r}}(n.inputResponses),h={sessionId:o?.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?cc:(r=n.requestState,()=>r),signal:p.signal,send:(e,t,r)=>{let i=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(i,e.method),l0(t))return u(e,t,r);let n=cl(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 u(e,n,t)},notify:d},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=a.encodeResult(i.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${i.method}: ${e}`)),s(s3.InternalError,"Internal error");return}let r={result:t,jsonrpc:"2.0",id:i.id};await o?.send(r)},async e=>{if(p.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:s3.InternalError,r={jsonrpc:"2.0",id:i.id,error:{code:a.encodeErrorCode(t),message:e.message??"Internal error",...void 0!==e.data&&{data:e.data}}};await o?.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 a=this._responseHandlers.get(i),o=this._timeoutInfo.get(i);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(e){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),a(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(lI(e)?e:s6.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(this._assertOutboundRequestInEra(i,e.method),l0(t))return this._requestWithSchemaViaCodec(i,e,t,r);let n=cl(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 lv(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 lv(void 0);case"server/discover":return lv(ly);default:return}}(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(lb(t)&&!e.hasRequestMethod(t))throw new s$(sC.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,a,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:l,headers:c}=i??{},d=Date.now();return new Promise((u,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 s$?e:new s$(sC.RequestTimeout,String(e))}let h=e.era===ly&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,f=this._requestMessageId++;a=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?this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(e)}}),{relatedRequestId:o,resumptionToken:s,onresumptiontoken:l}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):h.abort(),p(e instanceof s$?e:new s$(sC.RequestTimeout,String(e))))};this._responseHandlers.set(f,n=>{let a;if(!i?.signal?.aborted){if(v=!0,n instanceof Error)return p(n);try{a=e.decodeResult(t.method,n.result)}catch(e){return p(e instanceof Error?e:Error(String(e)))}if("invalid"===a.kind)return p(a.error);if("input_required"===a.kind){var o;return i?.allowInputRequired===!0?u({resultType:"input_required",inputRequests:(o=a).inputRequests,...void 0!==o.requestState&&{requestState:o.requestState}}):u(this._resolveNonCompleteResult(a,{codec:e,request:t,resultSchema:r,options:i,flowStartedAt:d,retry:(i,n)=>this._requestWithSchemaViaCodec(e,void 0===i?{method:t.method}:{method:t.method,params:i},r,n)}))}l4(r,a.result).then(e=>{e.success?u(e.data):p(new s$(sC.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 s$(sC.RequestTimeout,"Request timed out",{timeout:b})),i?.resetTimeoutOnProgress??!1),this._transport.send(y,{relatedRequestId:o,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!==a&&(this._responseHandlers.delete(a),this._cleanupTimeout(a))})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new s$(sC.NotConnected,"Not connected");if(lS(t.method)&&!e.hasNotificationMethod(t.method))throw new s$(sC.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){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(!lb(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(),a=n.validateRequest(e,r);if(a.ok||"not-in-era"!==a.reason||(a=n.validateInputRequest(e,r)),!a.ok){if("not-in-era"===a.reason)throw new s6(s3.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(a.message)}return Promise.resolve(t(a.value,i))}}else if(r)i=async(i,n)=>{let a=await l4(t.params,{...i.params});if(!a.success)throw new s6(s3.InvalidParams,`Invalid params for ${e}: ${a.error}`);return r(a.data,n)};else throw TypeError("setRequestHandler: handler is required");this._requestHandlers.set(e,this._wrapHandler(e,i))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.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(!lS(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 s6(s3.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 l4(t.params,{...i.params});if(!n.success)throw new s6(s3.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,i)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function cp(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function cm(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var ch=((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var n,a=z(t),o=0,s=a.length;o<s;o++)n=a[o],N.call(e,n)||n===r||O(e,n,{get:(e=>t[e]).bind(null,n),enumerable:!(i=j(t,n))||i.enumerable});return e})(O(null!=(p=(d=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 a,o,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(";"),d=-1!==c?l.slice(0,c).trim():l.trim();if(!i.test(d))throw TypeError("invalid media type");var u=new n(d.toLowerCase());if(-1!==c){for(t.lastIndex=c;o=t.exec(l);){if(o.index!==c)throw TypeError("invalid parameter format");c+=o[0].length,a=o[1].toLowerCase(),34===(s=o[2]).charCodeAt(0)&&-1!==(s=s.slice(1,-1)).indexOf("\\")&&(s=s.replace(r,"$1")),u.parameters[a]=s}if(c!==l.length)throw TypeError("invalid parameter format")}return u}},()=>(u||d((u={exports:{}}).exports,u),u.exports))())?q(L(p)):{},"default",{value:p,enumerable:!0}),p);function cf(e){if(e)try{return ch.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();if(""===t||e.slice(t.length).includes(","))return;return t}}function cg(e){return"application/json"===e||"application/json"===cf(e)}let cy=/^[A-Za-z0-9._-]{1,128}$/;function cv(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"),!cy.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 c_=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,a=0;for(;n<t.length;)if("{"===t[n]){i&&(r.push(i),i="");let o=t.indexOf("}",n);if(-1===o)throw Error("Unclosed template expression");if(++a>1e4)throw Error("Template contains too many expressions (max 10000)");let s=t.slice(n+1,o),l=this.getOperator(s),c=s.includes("*"),d=this.getNames(s),u=d[0];for(let t of d)e.validateLength(t,1e6,"Variable name");r.push({name:u,operator:l,names:d,exploded:c}),n=o+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),a=t.match(n);if(!a)return null;let o={};for(let[e,t]of i.entries()){let{name:r,exploded:i}=t,n=a[e+1];o[r.replace("*","")]=i&&n.includes(",")?n.split(","):n}return o}};function cb(e){if(void 0!==e){if(function(e){if("object"!=typeof e||null===e||l0(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 i4(e);if("object"==typeof e&&null!==e&&!l0(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(!l0(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 cS(){sN(),sQ(),sD(),ln(),lg()}function cw(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(!cw(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(!cw(e[i],t[i]))return!1;return!0}return e===t}function ck(e){return encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1"))}let cR={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},cx={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},cC={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},c$="undefined"!=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 cT(e,t=Object.create(null),r=c$,i=""){if(e&&"object"==typeof e&&!Array.isArray(e)){let n=e.$id||e.id;if(n){let a=new URL(n,r.href);a.hash.length>1?t[a.href]=e:(a.hash="",""===i?r=a:cT(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(cC[n])continue;let a=`${i}/${ck(n)}`,o=e[n];if(Array.isArray(o)){if(cR[n]){let e=o.length;for(let i=0;i<e;i++)cT(o[i],t,r,`${a}/${i}`)}}else if(cx[n])for(let e in o)cT(o[e],t,r,`${a}/${ck(e)}`);else cT(o,t,r,a)}return t}let cE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,cP=[0,31,28,31,30,31,30,31,31,30,31,30,31],cI=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function cq(e){return e.test.bind(e)}let cO={date:cj,time:cz.bind(void 0,!1),"date-time":function(e){let t=e.split(cL);return 2==t.length&&cj(t[0])&&cz(!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 cN.test(e)&&cA.test(e)},"uri-reference":cq(/^(?:[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":cq(/^(?:(?:[^\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:cq(/^(?:(?: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:cq(/^(?=.{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:cq(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:cq(/^((([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(cM.test(e))return!1;try{return RegExp(e,"u"),!0}catch(e){return!1}},uuid:cq(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":cq(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":cq(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":cq(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function cj(e){var t;let r=e.match(cE);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3];return n>=1&&n<=12&&a>=1&&a<=(2==n&&(t=i)%4==0&&(t%100!=0||t%400==0)?29:cP[n])}function cz(e,t){let r=t.match(cI);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3],o=!!r[5];return(i<=23&&n<=59&&a<=59||23==i&&59==n&&60==a)&&(!e||o)}let cL=/t|\s/i,cN=/\/|:/,cA=/^(?:[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,cM=/[^\\]\\Z/;var cZ=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",r=!0){this.schema=e,this.draft=t,this.shortCircuit=r,this.lookup=cT(e)}validate(e){return function e(t,r,i="2019-09",n=cT(r),a=!0,o=null,s="#",l="#",c=Object.create(null)){let d;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 u=typeof t;switch(u){case"boolean":case"number":case"string":d=u;break;case"object":d=null===t?"null":Array.isArray(t)?"array":"object";break;default:throw Error(`Instances of "${u}" 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:k,then:R,else:x,format:C,properties:$,patternProperties:T,additionalProperties:E,unevaluatedProperties:P,minProperties:I,maxProperties:q,propertyNames:O,dependentRequired:j,dependentSchemas:z,dependencies:L,prefixItems:N,items:A,additionalItems:M,unevaluatedItems:Z,contains:U,minContains:H,maxContains:F,minItems:V,maxItems:D,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===o&&(o=r),"#"===m){let d=null===o?n[er]:o,u=`${l}/$recursiveRef`,p=e(t,null===o?r:o,i,n,a,d,s,u,c);p.valid||ei.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:u,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+=`
|
|
62
|
+
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||i.count>1&&"ref"===e.reused){n(r);continue}}}function rP(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,a={...n},o=r.ref;if(r.ref=null,o){i(o);let r=e.seen.get(o),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)):Object.assign(n,s),Object.assign(n,a),t._zod.parent===o)for(let e in n)"$ref"!==e&&"allOf"!==e&&(e in a||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!==o){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??[]})};for(let t of[...e.seen.entries()].reverse())i(t[0]);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)}Object.assign(n,r.def??r.schema);let a=e.metadataRegistry.get(t)?.id;void 0!==a&&n.id===a&&delete n.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?n.$defs=o:n.definitions=o);try{let r=JSON.parse(JSON.stringify(n));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:rI(t,"input",e.processors),output:rI(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let rI=(e,t,r={})=>i=>{let{libraryOptions:n,target:a}=i??{},o=r$({...n??{},target:a,io:t,processors:r});return rT(e,o),rE(o,e),rP(o,e)},rq={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},rO=(e,t,r,i)=>{r.type="string";let{minimum:n,maximum:a,format:o,patterns:s,contentEncoding:l}=e._zod.bag;if("number"==typeof n&&(r.minLength=n),"number"==typeof a&&(r.maxLength=a),o&&(r.format=rq[o]??o,""===r.format&&delete r.format,"time"===o&&delete r.format),l&&(r.contentEncoding=l),s&&s.size>0){let e=[...s];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}))])}},rj=(e,t,r,i)=>{let{minimum:n,maximum:a,format:o,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:c}=e._zod.bag;"string"==typeof o&&o.includes("int")?r.type="integer":r.type="number";let d="number"==typeof c&&c>=(n??-1/0),u="number"==typeof l&&l<=(a??1/0),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c:"number"==typeof n&&(r.minimum=n),u?p?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l:"number"==typeof a&&(r.maximum=a),"number"==typeof s&&(r.multipleOf=s)},rz=(e,t,r,i)=>{r.type="boolean"},rL=(e,t,r,i)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},rN=(e,t,r,i)=>{r.not={}},rA=(e,t,r,i)=>{},rM=(e,t,r,i)=>{},rZ=(e,t,r,i)=>{let n=eS(e._zod.def.entries);n.every(e=>"number"==typeof e)&&(r.type="number"),n.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=n},rU=(e,t,r,i)=>{let n=e._zod.def,a=[];for(let e of n.values)if(void 0===e){if("throw"===t.unrepresentable)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e)if("throw"===t.unrepresentable)throw Error("BigInt literals cannot be represented in JSON Schema");else a.push(Number(e));else a.push(e);if(0===a.length);else if(1===a.length){let e=a[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else a.every(e=>"number"==typeof e)&&(r.type="number"),a.every(e=>"string"==typeof e)&&(r.type="string"),a.every(e=>"boolean"==typeof e)&&(r.type="boolean"),a.every(e=>null===e)&&(r.type="null"),r.enum=a},rH=(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Custom types cannot be represented in JSON Schema")},rF=(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Transforms cannot be represented in JSON Schema")},rV=(e,t,r,i)=>{let n=e._zod.def,{minimum:a,maximum:o}=e._zod.bag;"number"==typeof a&&(r.minItems=a),"number"==typeof o&&(r.maxItems=o),r.type="array",r.items=rT(n.element,t,{...i,path:[...i.path,"items"]})},rD=(e,t,r,i)=>{let n=e._zod.def;r.type="object",r.properties={};let a=n.shape;for(let e in a)r.properties[e]=rT(a[e],t,{...i,path:[...i.path,"properties",e]});let o=new Set([...new Set(Object.keys(a))].filter(e=>{let r=n.shape[e]._zod;return"input"===t.io?void 0===r.optin:void 0===r.optout}));o.size>0&&(r.required=Array.from(o)),n.catchall?._zod.def.type==="never"?r.additionalProperties=!1:n.catchall?n.catchall&&(r.additionalProperties=rT(n.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)},rJ=(e,t,r,i)=>{let n=e._zod.def,a=!1===n.inclusive,o=n.options.map((e,r)=>rT(e,t,{...i,path:[...i.path,a?"oneOf":"anyOf",r]}));a?r.oneOf=o:r.anyOf=o},rB=(e,t,r,i)=>{let n=e._zod.def,a=rT(n.left,t,{...i,path:[...i.path,"allOf",0]}),o=rT(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length;r.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},rW=(e,t,r,i)=>{let n=e._zod.def;r.type="object";let a=n.keyType,o=a._zod.bag,s=o?.patterns;if("loose"===n.mode&&s&&s.size>0){let e=rT(n.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});for(let t of(r.patternProperties={},s))r.patternProperties[t.source]=e}else("draft-07"===t.target||"draft-2020-12"===t.target)&&(r.propertyNames=rT(n.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=rT(n.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let l=a._zod.values;if(l){let e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(r.required=e)}},rG=(e,t,r,i)=>{let n=e._zod.def,a=rT(n.innerType,t,i),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},rK=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType},rY=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},rX=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},rQ=(e,t,r,i)=>{let n,a=e._zod.def;rT(a.innerType,t,i),t.seen.get(e).ref=a.innerType;try{n=a.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=n},r0=(e,t,r,i)=>{let n=e._zod.def,a=n.in._zod.traits.has("$ZodTransform"),o="input"===t.io?a?n.out:n.in:n.out;rT(o,t,i),t.seen.get(e).ref=o},r1=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType,r.readOnly=!0},r2=(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType},r9=(e,t,r,i)=>{let n=e._zod.innerType;rT(n,t,i),t.seen.get(e).ref=n},r4={string:rO,number:rj,boolean:rz,bigint:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("BigInt cannot be represented in JSON Schema")},symbol:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Symbols cannot be represented in JSON Schema")},null:rL,undefined:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Undefined cannot be represented in JSON Schema")},void:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Void cannot be represented in JSON Schema")},never:rN,any:rA,unknown:rM,date:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Date cannot be represented in JSON Schema")},enum:rZ,literal:rU,nan:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("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)=>{let n={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:s}=e._zod.bag;void 0!==a&&(n.minLength=a),void 0!==o&&(n.maxLength=o),s?1===s.length?(n.contentMediaType=s[0],Object.assign(r,n)):(Object.assign(r,n),r.anyOf=s.map(e=>({contentMediaType:e}))):Object.assign(r,n)},success:(e,t,r,i)=>{r.type="boolean"},custom:rH,function:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Function types cannot be represented in JSON Schema")},transform:rF,map:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Map cannot be represented in JSON Schema")},set:(e,t,r,i)=>{if("throw"===t.unrepresentable)throw Error("Set cannot be represented in JSON Schema")},array:rV,object:rD,union:rJ,intersection:rB,tuple:(e,t,r,i)=>{let n=e._zod.def;r.type="array";let a="draft-2020-12"===t.target?"prefixItems":"items",o="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",s=n.items.map((e,r)=>rT(e,t,{...i,path:[...i.path,a,r]})),l=n.rest?rT(n.rest,t,{...i,path:[...i.path,o,..."openapi-3.0"===t.target?[n.items.length]:[]]}):null;"draft-2020-12"===t.target?(r.prefixItems=s,l&&(r.items=l)):"openapi-3.0"===t.target?(r.items={anyOf:s},l&&r.items.anyOf.push(l),r.minItems=s.length,l||(r.maxItems=s.length)):(r.items=s,l&&(r.additionalItems=l));let{minimum:c,maximum:d}=e._zod.bag;"number"==typeof c&&(r.minItems=c),"number"==typeof d&&(r.maxItems=d)},record:rW,nullable:rG,nonoptional:rK,default:rY,prefault:rX,catch:rQ,pipe:r0,readonly:r1,promise:(e,t,r,i)=>{let n=e._zod.def;rT(n.innerType,t,i),t.seen.get(e).ref=n.innerType},optional:r2,lazy:r9};function r5(e,t){if("_idmap"in e){let r=r$({...t,processors:r4}),i={};for(let t of e._idmap.entries()){let[e,i]=t;rT(i,r)}let n={};for(let a of(r.external={registry:e,uri:t?.uri,defs:i},e._idmap.entries())){let[e,t]=a;rE(r,t),n[e]=rP(r,t)}return Object.keys(i).length>0&&(n.__shared={["draft-2020-12"===r.target?"$defs":"definitions"]:i}),{schemas:n}}let r=r$({...t,processors:r4});return rT(e,r),rE(r,e),rP(r,e)}let r3=F("ZodISODateTime",(e,t)=>{tk.init(e,t),iR.init(e,t)});function r6(e){return new r3({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...eA(e)})}let r7=F("ZodISODate",(e,t)=>{tx.init(e,t),iR.init(e,t)});function r8(e){return new r7({type:"string",format:"date",check:"string_format",...eA(e)})}let ie=F("ZodISOTime",(e,t)=>{tC.init(e,t),iR.init(e,t)}),it=F("ZodISODuration",(e,t)=>{t$.init(e,t),iR.init(e,t)}),ir=F("ZodError",(e,t)=>{tt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>(function(e,t=e=>e.message){let r={_errors:[]},i=(e,n=[])=>{for(let a of e.issues)if("invalid_union"===a.code&&a.errors.length)a.errors.map(e=>i({issues:e},[...n,...a.path]));else if("invalid_key"===a.code)i({issues:a.issues},[...n,...a.path]);else if("invalid_element"===a.code)i({issues:a.issues},[...n,...a.path]);else{let e=[...n,...a.path];if(0===e.length)r._errors.push(t(a));else{let i=r,n=0;for(;n<e.length;){let r=e[n];n===e.length-1?(i[r]=i[r]||{_errors:[]},i[r]._errors.push(t(a))):i[r]=i[r]||{_errors:[]},i=i[r],n++}}}};return i(e),r})(e,t)},flatten:{value:t=>(function(e,t=e=>e.message){let r={},i=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):i.push(t(n));return{formErrors:i,fieldErrors:r}})(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ew,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ew,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),ii=ti(ir),ia=tn(ir),io=ta(ir),is=ts(ir),il=(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ti(ir)(e,t,i)},ic=(e,t,r)=>ti(ir)(e,t,r),id=async(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return tn(ir)(e,t,i)},iu=async(e,t,r)=>tn(ir)(e,t,r),ip=(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ta(ir)(e,t,i)},im=(e,t,r)=>ta(ir)(e,t,r),ih=async(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ts(ir)(e,t,i)},ig=async(e,t,r)=>ts(ir)(e,t,r),iy=new WeakMap;function iv(e,t,r){let i=Object.getPrototypeOf(e),n=iy.get(i);if(n||(n=new Set,iy.set(i,n)),!n.has(t))for(let e in n.add(t),r){let t=r[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,get(){let r=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:r}),r},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}let i_=F("ZodType",(e,t)=>(td.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:rI(e,"input"),output:rI(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{let i=r$({...r,processors:t});return rT(e,i),rE(i,e),rP(i,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,r)=>ii(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>io(e,t,r),e.parseAsync=async(t,r)=>ia(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>is(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>il(e,t,r),e.decode=(t,r)=>ic(e,t,r),e.encodeAsync=async(t,r)=>id(e,t,r),e.decodeAsync=async(t,r)=>iu(e,t,r),e.safeEncode=(t,r)=>ip(e,t,r),e.safeDecode=(t,r)=>im(e,t,r),e.safeEncodeAsync=async(t,r)=>ih(e,t,r),e.safeDecodeAsync=async(t,r)=>ig(e,t,r),iv(e,"ZodType",{check(...e){let t=this.def;return this.clone(eT(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 eN(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 nx({type:"custom",check:"custom",fn:e,...eA(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(eD(e,t.value,i._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),e.input??(e.input=t.value),e.inst??(e.inst=i),e.continue??(e.continue=!i._zod.def.abort),t.issues.push(eD(e)))},e(t.value,t)),(n=new eJ({check:"custom",...eA(t)}))._zod.check=r,i=n}(e,t))},overwrite(e){return this.check(rC(e))},optional(){return nu(this)},exactOptional(){var e;return e=this,new np({type:"optional",innerType:e})},nullable(){return nh(this)},nullish(){return nu(nh(this))},nonoptional(e){var t;return t=this,new ny({type:"nonoptional",innerType:t,...eA(e)})},array(){return i2(this)},or(e){return i6([this,e])},and(e){return nt(this,e)},transform(e){return nb(this,nc(e))},default(e){var t,r;return t=this,r=e,new nf({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():ej(r)}})},prefault(e){var t,r;return t=this,r=e,new ng({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():ej(r)}})},catch(e){var t,r;return t=this,new nv({type:"catch",innerType:t,catchValue:"function"==typeof(r=e)?r:()=>r})},pipe(e){return nb(this,e)},readonly(){var e;return e=this,new nw({type:"readonly",innerType:e})},describe(e){let t=this.clone();return rh.add(t,{description:e}),t},meta(...e){if(0===e.length)return rh.get(this);let t=this.clone();return rh.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>rh.get(e)?.description,configurable:!0}),e)),ib=F("_ZodString",(e,t)=>{tu.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rO(e,t,r,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,iv(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new e2({check:"string_format",format:"regex",...eA(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new e5({check:"string_format",format:"includes",...eA(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new e3({check:"string_format",format:"starts_with",...eA(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new e6({check:"string_format",format:"ends_with",...eA(t),suffix:e})}(...e))},min(...e){return this.check(rk(...e))},max(...e){return this.check(rR(...e))},length(...e){return this.check(rx(...e))},nonempty(...e){return this.check(rk(1,...e))},lowercase(e){return this.check(new e9({check:"string_format",format:"lowercase",...eA(e)}))},uppercase(e){return this.check(new e4({check:"string_format",format:"uppercase",...eA(e)}))},trim(){return this.check(rC(e=>e.trim()))},normalize(...e){return this.check(function(e){return rC(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(rC(e=>e.toLowerCase()))},toUpperCase(){return this.check(rC(e=>e.toUpperCase()))},slugify(){return this.check(rC(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})}),iS=F("ZodString",(e,t)=>{tu.init(e,t),ib.init(e,t),e.email=t=>e.check(rf(ik,t)),e.url=t=>e.check(ry(i$,t)),e.jwt=t=>e.check(new iH({type:"string",format:"jwt",check:"string_format",abort:!1,...eA(t)})),e.emoji=t=>e.check(new iT({type:"string",format:"emoji",check:"string_format",abort:!1,...eA(t)})),e.guid=t=>e.check(rg(ix,t)),e.uuid=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,...eA(t)})),e.uuidv4=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...eA(t)})),e.uuidv6=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...eA(t)})),e.uuidv7=t=>e.check(new iC({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...eA(t)})),e.nanoid=t=>e.check(new iE({type:"string",format:"nanoid",check:"string_format",abort:!1,...eA(t)})),e.guid=t=>e.check(rg(ix,t)),e.cuid=t=>e.check(new iP({type:"string",format:"cuid",check:"string_format",abort:!1,...eA(t)})),e.cuid2=t=>e.check(new iI({type:"string",format:"cuid2",check:"string_format",abort:!1,...eA(t)})),e.ulid=t=>e.check(new iq({type:"string",format:"ulid",check:"string_format",abort:!1,...eA(t)})),e.base64=t=>e.check(new iM({type:"string",format:"base64",check:"string_format",abort:!1,...eA(t)})),e.base64url=t=>e.check(new iZ({type:"string",format:"base64url",check:"string_format",abort:!1,...eA(t)})),e.xid=t=>e.check(new iO({type:"string",format:"xid",check:"string_format",abort:!1,...eA(t)})),e.ksuid=t=>e.check(new ij({type:"string",format:"ksuid",check:"string_format",abort:!1,...eA(t)})),e.ipv4=t=>e.check(new iz({type:"string",format:"ipv4",check:"string_format",abort:!1,...eA(t)})),e.ipv6=t=>e.check(new iL({type:"string",format:"ipv6",check:"string_format",abort:!1,...eA(t)})),e.cidrv4=t=>e.check(new iN({type:"string",format:"cidrv4",check:"string_format",abort:!1,...eA(t)})),e.cidrv6=t=>e.check(new iA({type:"string",format:"cidrv6",check:"string_format",abort:!1,...eA(t)})),e.e164=t=>e.check(new iU({type:"string",format:"e164",check:"string_format",abort:!1,...eA(t)})),e.datetime=t=>e.check(r6(t)),e.date=t=>e.check(r8(t)),e.time=t=>e.check(new ie({type:"string",format:"time",check:"string_format",precision:null,...eA(t)})),e.duration=t=>e.check(new it({type:"string",format:"duration",check:"string_format",...eA(t)}))});function iw(e){return new iS({type:"string",...eA(e)})}let iR=F("ZodStringFormat",(e,t)=>{tp.init(e,t),ib.init(e,t)}),ik=F("ZodEmail",(e,t)=>{tf.init(e,t),iR.init(e,t)}),ix=F("ZodGUID",(e,t)=>{tm.init(e,t),iR.init(e,t)}),iC=F("ZodUUID",(e,t)=>{th.init(e,t),iR.init(e,t)}),i$=F("ZodURL",(e,t)=>{tg.init(e,t),iR.init(e,t)}),iT=F("ZodEmoji",(e,t)=>{ty.init(e,t),iR.init(e,t)}),iE=F("ZodNanoID",(e,t)=>{tv.init(e,t),iR.init(e,t)}),iP=F("ZodCUID",(e,t)=>{t_.init(e,t),iR.init(e,t)}),iI=F("ZodCUID2",(e,t)=>{tb.init(e,t),iR.init(e,t)}),iq=F("ZodULID",(e,t)=>{tS.init(e,t),iR.init(e,t)}),iO=F("ZodXID",(e,t)=>{tw.init(e,t),iR.init(e,t)}),ij=F("ZodKSUID",(e,t)=>{tR.init(e,t),iR.init(e,t)}),iz=F("ZodIPv4",(e,t)=>{tT.init(e,t),iR.init(e,t)}),iL=F("ZodIPv6",(e,t)=>{tE.init(e,t),iR.init(e,t)}),iN=F("ZodCIDRv4",(e,t)=>{tP.init(e,t),iR.init(e,t)}),iA=F("ZodCIDRv6",(e,t)=>{tI.init(e,t),iR.init(e,t)}),iM=F("ZodBase64",(e,t)=>{tO.init(e,t),iR.init(e,t)}),iZ=F("ZodBase64URL",(e,t)=>{tj.init(e,t),iR.init(e,t)}),iU=F("ZodE164",(e,t)=>{tz.init(e,t),iR.init(e,t)}),iH=F("ZodJWT",(e,t)=>{tL.init(e,t),iR.init(e,t)}),iF=F("ZodNumber",(e,t)=>{tN.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rj(e,t,r,i),iv(e,"ZodNumber",{gt(e,t){return this.check(rb(e,t))},gte(e,t){return this.check(rS(e,t))},min(e,t){return this.check(rS(e,t))},lt(e,t){return this.check(rv(e,t))},lte(e,t){return this.check(r_(e,t))},max(e,t){return this.check(r_(e,t))},int(e){return this.check(iJ(e))},safe(e){return this.check(iJ(e))},positive(e){return this.check(rb(0,e))},nonnegative(e){return this.check(rS(0,e))},negative(e){return this.check(rv(0,e))},nonpositive(e){return this.check(r_(0,e))},multipleOf(e,t){return this.check(rw(e,t))},step(e,t){return this.check(rw(e,t))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??-1/0,r.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(r.maximum??1/0,r.exclusiveMaximum??1/0)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function iV(e){return new iF({type:"number",checks:[],...eA(e)})}let iD=F("ZodNumberFormat",(e,t)=>{tA.init(e,t),iF.init(e,t)});function iJ(e){return new iD({type:"number",check:"number_format",abort:!1,format:"safeint",...eA(e)})}let iB=F("ZodBoolean",(e,t)=>{tM.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rz(e,t,r,i)});function iW(e){return new iB({type:"boolean",...eA(e)})}let iG=F("ZodNull",(e,t)=>{tZ.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rL(e,t,r,i)});function iK(e){return new iG({type:"null",...eA(e)})}let iY=F("ZodAny",(e,t)=>{tU.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rA(e,t,r,i)}),iX=F("ZodUnknown",(e,t)=>{tH.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rM(e,t,r,i)});function iQ(){return new iX({type:"unknown"})}let i0=F("ZodNever",(e,t)=>{tF.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rN(e,t,r,i)}),i1=F("ZodArray",(e,t)=>{tD.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rV(e,t,r,i),e.element=t.element,iv(e,"ZodArray",{min(e,t){return this.check(rk(e,t))},nonempty(e){return this.check(rk(1,e))},max(e,t){return this.check(rR(e,t))},length(e,t){return this.check(rx(e,t))},unwrap(){return this.element}})});function i2(e,t){return new i1({type:"array",element:e,...eA(t)})}let i9=F("ZodObject",(e,t)=>{tK.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rD(e,t,r,i),eC(e,"shape",()=>t.shape),iv(e,"ZodObject",{keyof(){return na(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:iQ()})},loose(){return this.clone({...this._zod.def,catchall:iQ()})},strict(){return this.clone({...this._zod.def,catchall:new i0({type:"never",...eA(void 0)})})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!eO(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let r=e._zod.def.shape;for(let e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=eT(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return e$(this,"shape",r),r}});return eN(e,i)}(this,e)},safeExtend(e){var t=this;if(!eO(e))throw Error("Invalid input to safeExtend: expected a plain object");let r=eT(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e};return e$(this,"shape",r),r}});return eN(t,r)},merge(e){var t=this;if(t._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=eT(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return e$(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return eN(t,r)},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=eT(e._zod.def,{get shape(){let e={};for(let i in t){if(!(i in r.shape))throw Error(`Unrecognized key: "${i}"`);t[i]&&(e[i]=r.shape[i])}return e$(this,"shape",e),e},checks:[]});return eN(e,n)}(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=eT(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete i[e]}return e$(this,"shape",i),i},checks:[]});return eN(e,n)}(this,e)},partial(...e){return function(e,t,r){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let n=eT(t._zod.def,{get shape(){let i=t._zod.def.shape,n={...i};if(r)for(let t in r){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);r[t]&&(n[t]=e?new e({type:"optional",innerType:i[t]}):i[t])}else for(let t in i)n[t]=e?new e({type:"optional",innerType:i[t]}):i[t];return e$(this,"shape",n),n},checks:[]});return eN(t,n)}(nd,this,e[0])},required(...e){var t,r;let i;return t=this,r=e[0],i=eT(t._zod.def,{get shape(){let e=t._zod.def.shape,i={...e};if(r)for(let t in r){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=new ny({type:"nonoptional",innerType:e[t]}))}else for(let t in e)i[t]=new ny({type:"nonoptional",innerType:e[t]});return e$(this,"shape",i),i}}),eN(t,i)}})});function i4(e,t){return new i9({type:"object",shape:e??{},...eA(t)})}function i5(e,t){return new i9({type:"object",shape:e,catchall:iQ(),...eA(t)})}let i3=F("ZodUnion",(e,t)=>{tX.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rJ(e,t,r,i),e.options=t.options});function i6(e,t){return new i3({type:"union",options:e,...eA(t)})}let i7=F("ZodDiscriminatedUnion",(e,t)=>{i3.init(e,t),tQ.init(e,t)});function i8(e,t,r){return new i7({type:"union",options:t,discriminator:e,...eA(r)})}let ne=F("ZodIntersection",(e,t)=>{t0.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rB(e,t,r,i)});function nt(e,t){return new ne({type:"intersection",left:e,right:t})}let nr=F("ZodRecord",(e,t)=>{t2.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rW(e,t,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function ni(e,t,r){return new nr(t&&t._zod?{type:"record",keyType:e,valueType:t,...eA(r)}:{type:"record",keyType:iw(),valueType:e,...eA(t)})}let nn=F("ZodEnum",(e,t)=>{t9.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rZ(e,t,r,i),e.enum=t.entries,e.options=Object.values(t.entries);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 nn({...t,checks:[],...eA(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 nn({...t,checks:[],...eA(i),entries:n})}});function na(e,t){return new nn({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...eA(t)})}let no=F("ZodLiteral",(e,t)=>{t4.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rU(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 ns(e,t){return new no({type:"literal",values:Array.isArray(e)?e:[e],...eA(t)})}let nl=F("ZodTransform",(e,t)=>{t5.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rF(e,t,r,i),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new D(e.constructor.name);r.addIssue=i=>{"string"==typeof i?r.issues.push(eD(i,r.value,t)):(i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(eD(i)))};let n=t.transform(r.value,r);return n instanceof Promise?n.then(e=>(r.value=e,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function nc(e){return new nl({type:"transform",transform:e})}let nd=F("ZodOptional",(e,t)=>{t6.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r2(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new nd({type:"optional",innerType:e})}let np=F("ZodExactOptional",(e,t)=>{t7.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r2(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),nm=F("ZodNullable",(e,t)=>{t8.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rG(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function nh(e){return new nm({type:"nullable",innerType:e})}let nf=F("ZodDefault",(e,t)=>{re.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rY(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),ng=F("ZodPrefault",(e,t)=>{rr.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rX(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),ny=F("ZodNonOptional",(e,t)=>{ri.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rK(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),nv=F("ZodCatch",(e,t)=>{ra.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rQ(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),n_=F("ZodPipe",(e,t)=>{ro.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r0(e,t,r,i),e.in=t.in,e.out=t.out});function nb(e,t){return new n_({type:"pipe",in:e,out:t})}let nS=F("ZodPreprocess",(e,t)=>{n_.init(e,t),rl.init(e,t)}),nw=F("ZodReadonly",(e,t)=>{rc.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r1(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),nR=F("ZodLazy",(e,t)=>{ru.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>r9(e,t,r,i),e.unwrap=()=>e._zod.def.getter()});function nk(e){return new nR({type:"lazy",getter:e})}let nx=F("ZodCustom",(e,t)=>{rp.init(e,t),i_.init(e,t),e._zod.processJSONSchema=(t,r,i)=>rH(e,t,r,i)});function nC(e,t){return new nS({type:"pipe",in:nc(e),out:t})}R||(R={});let n$="2025-11-25",nT=[n$,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],nE="io.modelcontextprotocol/protocolVersion",nP="io.modelcontextprotocol/clientInfo",nI="io.modelcontextprotocol/serverInfo",nq="io.modelcontextprotocol/clientCapabilities",nO="io.modelcontextprotocol/subscriptionId",nj="io.modelcontextprotocol/logLevel",nz=nk(()=>i6([iw(),iV(),iW(),iK(),ni(iw(),nz),i2(nz)])),nL=ni(iw(),nz),nN=i2(nz),nA=i6([iw(),iV().int()]),nM=iw(),nZ=i4({ttl:iV().optional()}),nU=i4({taskId:iw()}),nH=i5({progressToken:nA.optional(),"io.modelcontextprotocol/related-task":nU.optional()}),nF=i4({_meta:nH.optional()}),nV=nF.extend({task:nZ.optional()}),nD=i4({method:iw(),params:nF.loose().optional()}),nJ=i4({_meta:nH.optional()}),nB=i4({method:iw(),params:nJ.loose().optional()}),nW=i5({get[nI](){return n8.optional().catch(void 0)}}),nG=i5({_meta:nW.optional()}),nK=i6([iw(),iV().int()]),nY=i4({jsonrpc:ns("2.0"),id:nK,...nD.shape}).strict(),nX=i4({jsonrpc:ns("2.0"),...nB.shape}).strict(),nQ=i4({jsonrpc:ns("2.0"),id:nK,result:nG}).strict(),n0=i4({jsonrpc:ns("2.0"),id:nK.optional(),error:i4({code:iV().int(),message:iw(),data:iQ().optional()})}).strict(),n1=i6([nY,nX,nQ,n0]),n2=i6([nQ,n0]),n9=nG.strict(),n4=nJ.extend({requestId:nK.optional(),reason:iw().optional()}),n5=nB.extend({method:ns("notifications/cancelled"),params:n4}),n3=i4({src:iw(),mimeType:iw().optional(),sizes:i2(iw()).optional(),theme:na(["light","dark"]).optional()}),n6=i4({icons:i2(n3).optional()}),n7=i4({name:iw(),title:iw().optional()}),n8=n7.extend({...n7.shape,...n6.shape,version:iw(),websiteUrl:iw().optional(),description:iw().optional()}),ae=nt(i4({applyDefaults:iW().optional()}),nL),at=nC(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,nt(i4({form:ae.optional(),url:nL.optional()}),nL.optional())),ar=i5({list:nL.optional(),cancel:nL.optional(),requests:i5({sampling:i5({createMessage:nL.optional()}).optional(),elicitation:i5({create:nL.optional()}).optional()}).optional()}),ai=i5({list:nL.optional(),cancel:nL.optional(),requests:i5({tools:i5({call:nL.optional()}).optional()}).optional()}),an=i4({experimental:ni(iw(),nL).optional(),sampling:i4({context:nL.optional(),tools:nL.optional()}).optional(),elicitation:at.optional(),roots:i4({listChanged:iW().optional()}).optional(),tasks:ar.optional(),extensions:ni(iw(),nL).optional()}),aa=nF.extend({protocolVersion:iw(),capabilities:an,clientInfo:n8}),ao=nD.extend({method:ns("initialize"),params:aa}),as=i4({experimental:ni(iw(),nL).optional(),logging:nL.optional(),completions:nL.optional(),prompts:i4({listChanged:iW().optional()}).optional(),resources:i4({subscribe:iW().optional(),listChanged:iW().optional()}).optional(),tools:i4({listChanged:iW().optional()}).optional(),tasks:ai.optional(),extensions:ni(iw(),nL).optional()}),al=nG.extend({protocolVersion:iw(),capabilities:as,serverInfo:n8,instructions:iw().optional()}),ac=nB.extend({method:ns("notifications/initialized"),params:nJ.optional()}),ad=nD.extend({method:ns("server/discover"),params:nF.optional()}),au=nG.extend({supportedVersions:i2(iw()),capabilities:as,instructions:iw().optional()}),ap=nD.extend({method:ns("ping"),params:nF.optional()}),am=i4({progress:iV(),total:nu(iV()),message:nu(iw())}),ah=i4({...nJ.shape,...am.shape,progressToken:nA}),af=nB.extend({method:ns("notifications/progress"),params:ah}),ag=nF.extend({cursor:nM.optional()}),ay=nD.extend({params:ag.optional()}),av=nG.extend({nextCursor:nM.optional()}),a_=i4({uri:iw(),mimeType:nu(iw()),_meta:ni(iw(),iQ()).optional()}),ab=a_.extend({text:iw()}),aS=iw().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),aw=a_.extend({blob:aS}),aR=na(["user","assistant"]),ak=i4({audience:i2(aR).optional(),priority:iV().min(0).max(1).optional(),lastModified:r6({offset:!0}).optional()}),ax=i4({...n7.shape,...n6.shape,uri:iw(),description:nu(iw()),mimeType:nu(iw()),size:nu(iV()),annotations:ak.optional(),_meta:nu(i5({}))}),aC=i4({...n7.shape,...n6.shape,uriTemplate:iw(),description:nu(iw()),mimeType:nu(iw()),annotations:ak.optional(),_meta:nu(i5({}))}),a$=ay.extend({method:ns("resources/list")}),aT=av.extend({resources:i2(ax)}),aE=ay.extend({method:ns("resources/templates/list")}),aP=av.extend({resourceTemplates:i2(aC)}),aI=nF.extend({uri:iw()}),aq=nD.extend({method:ns("resources/read"),params:aI}),aO=nG.extend({contents:i2(i6([ab,aw]))}),aj=nB.extend({method:ns("notifications/resources/list_changed"),params:nJ.optional()}),az=nD.extend({method:ns("resources/subscribe"),params:aI}),aL=nD.extend({method:ns("resources/unsubscribe"),params:aI}),aN=i4({toolsListChanged:iW().optional(),promptsListChanged:iW().optional(),resourcesListChanged:iW().optional(),resourceSubscriptions:i2(iw()).optional()}),aA=nF.extend({notifications:aN}),aM=nD.extend({method:ns("subscriptions/listen"),params:aA}),aZ=nJ.extend({notifications:aN}),aU=nB.extend({method:ns("notifications/subscriptions/acknowledged"),params:aZ}),aH=nW.extend({[nO]:nK}),aF=nG.extend({_meta:aH}),aV=nJ.extend({uri:iw()}),aD=nB.extend({method:ns("notifications/resources/updated"),params:aV}),aJ=i4({name:iw(),description:nu(iw()),required:nu(iW())}),aB=i4({...n7.shape,...n6.shape,description:nu(iw()),arguments:nu(i2(aJ)),_meta:nu(i5({}))}),aW=ay.extend({method:ns("prompts/list")}),aG=av.extend({prompts:i2(aB)}),aK=nF.extend({name:iw(),arguments:ni(iw(),iw()).optional()}),aY=nD.extend({method:ns("prompts/get"),params:aK}),aX=i4({type:ns("text"),text:iw(),annotations:ak.optional(),_meta:ni(iw(),iQ()).optional()}),aQ=i4({type:ns("image"),data:aS,mimeType:iw(),annotations:ak.optional(),_meta:ni(iw(),iQ()).optional()}),a0=i4({type:ns("audio"),data:aS,mimeType:iw(),annotations:ak.optional(),_meta:ni(iw(),iQ()).optional()}),a1=i4({type:ns("tool_use"),name:iw(),id:iw(),input:ni(iw(),iQ()),_meta:ni(iw(),iQ()).optional()}),a2=i4({type:ns("resource"),resource:i6([ab,aw]),annotations:ak.optional(),_meta:ni(iw(),iQ()).optional()}),a9=ax.extend({type:ns("resource_link")}),a4=i6([aX,aQ,a0,a9,a2]),a5=i4({role:aR,content:a4}),a3=nG.extend({description:iw().optional(),messages:i2(a5)}),a6=nB.extend({method:ns("notifications/prompts/list_changed"),params:nJ.optional()}),a7=i4({title:iw().optional(),readOnlyHint:iW().optional(),destructiveHint:iW().optional(),idempotentHint:iW().optional(),openWorldHint:iW().optional()}),a8=i4({taskSupport:na(["required","optional","forbidden"]).optional()}),oe=i4({...n7.shape,...n6.shape,description:iw().optional(),inputSchema:i4({type:ns("object"),properties:ni(iw(),nz).optional(),required:i2(iw()).optional()}).catchall(iQ()),outputSchema:i5({$schema:iw().optional()}).optional(),annotations:a7.optional(),execution:a8.optional(),_meta:ni(iw(),iQ()).optional()}),ot=ay.extend({method:ns("tools/list")}),or=av.extend({tools:i2(oe)}),oi=nG.extend({content:i2(a4).default([]),structuredContent:iQ().optional(),isError:iW().optional()}),on=oi.or(nG.extend({toolResult:iQ()})),oa=nV.extend({name:iw(),arguments:ni(iw(),iQ()).optional()}),oo=nD.extend({method:ns("tools/call"),params:oa}),os=nB.extend({method:ns("notifications/tools/list_changed"),params:nJ.optional()}),ol=i4({autoRefresh:iW().default(!0),debounceMs:iV().int().nonnegative().default(300)}),oc=na(["debug","info","notice","warning","error","critical","alert","emergency"]),od=nF.extend({level:oc}),ou=nD.extend({method:ns("logging/setLevel"),params:od}),op=nJ.extend({level:oc,logger:iw().optional(),data:iQ()}),om=nB.extend({method:ns("notifications/message"),params:op}),oh=i4({name:iw().optional()}),of=i4({hints:i2(oh).optional(),costPriority:iV().min(0).max(1).optional(),speedPriority:iV().min(0).max(1).optional(),intelligencePriority:iV().min(0).max(1).optional()}),og=i4({mode:na(["auto","required","none"]).optional()}),oy=i4({type:ns("tool_result"),toolUseId:iw().describe("The unique identifier for the corresponding tool call."),content:i2(a4),structuredContent:iQ().optional(),isError:iW().optional(),_meta:ni(iw(),iQ()).optional()}),ov=i8("type",[aX,aQ,a0]),o_=i8("type",[aX,aQ,a0,a1,oy]),ob=i4({role:aR,content:i6([o_,i2(o_)]),_meta:ni(iw(),iQ()).optional()}),oS=nV.extend({messages:i2(ob),modelPreferences:of.optional(),systemPrompt:iw().optional(),includeContext:na(["none","thisServer","allServers"]).optional(),temperature:iV().optional(),maxTokens:iV().int(),stopSequences:i2(iw()).optional(),metadata:nL.optional(),tools:i2(oe).optional(),toolChoice:og.optional()}),ow=nD.extend({method:ns("sampling/createMessage"),params:oS}),oR=nG.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens"]).or(iw())),role:aR,content:ov}),ok=nG.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens","toolUse"]).or(iw())),role:aR,content:i6([o_,i2(o_)])}),ox=i4({type:ns("boolean"),title:iw().optional(),description:iw().optional(),default:iW().optional()}),oC=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),minLength:iV().optional(),maxLength:iV().optional(),format:na(["email","uri","date","date-time"]).optional(),default:iw().optional()}),o$=i4({type:na(["number","integer"]),title:iw().optional(),description:iw().optional(),minimum:iV().optional(),maximum:iV().optional(),default:iV().optional()}),oT=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),default:iw().optional()}),oE=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),oneOf:i2(i4({const:iw(),title:iw()})),default:iw().optional()}),oP=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),enumNames:i2(iw()).optional(),default:iw().optional()}),oI=i6([oT,oE]),oq=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({type:ns("string"),enum:i2(iw())}),default:i2(iw()).optional()}),oO=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({anyOf:i2(i4({const:iw(),title:iw()}))}),default:i2(iw()).optional()}),oj=i6([oq,oO]),oz=i6([oP,oI,oj]),oL=i6([oz,ox,oC,o$]),oN=nV.extend({mode:ns("form").optional(),message:iw(),requestedSchema:i4({type:ns("object"),properties:ni(iw(),oL),required:i2(iw()).optional()}).catchall(iQ())}),oA=nV.extend({mode:ns("url"),message:iw(),elicitationId:iw(),url:iw().url()}),oM=i6([oN,oA]),oZ=nD.extend({method:ns("elicitation/create"),params:oM}),oU=nJ.extend({elicitationId:iw()}),oH=nB.extend({method:ns("notifications/elicitation/complete"),params:oU}),oF=nG.extend({action:na(["accept","decline","cancel"]),content:nC(e=>null===e?void 0:e,ni(iw(),i6([iw(),iV(),iW(),i2(iw())])).optional())}),oV=i4({type:ns("ref/resource"),uri:iw()}),oD=i4({type:ns("ref/prompt"),name:iw()}),oJ=nF.extend({ref:i6([oD,oV]),argument:i4({name:iw(),value:iw()}),context:i4({arguments:ni(iw(),iw()).optional()}).optional()}),oB=nD.extend({method:ns("completion/complete"),params:oJ}),oW=nG.extend({completion:i5({values:i2(iw()).max(100),total:nu(iV().int()),hasMore:nu(iW())})}),oG=i4({uri:iw().startsWith("file://"),name:iw().optional(),_meta:ni(iw(),iQ()).optional()}),oK=nD.extend({method:ns("roots/list"),params:nF.optional()}),oY=nG.extend({roots:i2(oG)}),oX=nB.extend({method:ns("notifications/roots/list_changed"),params:nJ.optional()}),oQ=i5({ttl:iV().optional(),pollInterval:iV().optional()}),o0=na(["working","input_required","completed","failed","cancelled"]),o1=i4({taskId:iw(),status:o0,ttl:i6([iV(),iK()]),createdAt:iw(),lastUpdatedAt:iw(),pollInterval:nu(iV()),statusMessage:nu(iw())}),o2=nG.extend({task:o1}),o9=nJ.merge(o1),o4=nB.extend({method:ns("notifications/tasks/status"),params:o9}),o5=nD.extend({method:ns("tasks/get"),params:nF.extend({taskId:iw()})}),o3=nG.merge(o1),o6=nD.extend({method:ns("tasks/result"),params:nF.extend({taskId:iw()})}),o7=nG.loose(),o8=ay.extend({method:ns("tasks/list")}),se=av.extend({tasks:i2(o1)}),st=nD.extend({method:ns("tasks/cancel"),params:nF.extend({taskId:iw()})}),sr=nG.merge(o1),si=i6([ap,ao,ad,oB,ou,aY,aW,a$,aE,aq,az,aL,aM,oo,ot]),sn=i6([n5,af,ac,oX]),sa=i6([n9,oR,ok,oF,oY]),so=i6([ap,ow,oZ,oK]),ss=i6([n5,af,om,aD,aj,os,a6,aU,oH]),sl=i6([n9,al,au,oW,a3,aG,aT,aP,aO,oi,or,aF]),sc=ry(i$,void 0).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),H}).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"}),sd=i5({resource:iw().url(),authorization_servers:i2(sc).optional(),jwks_uri:iw().url().optional(),scopes_supported:i2(iw()).optional(),bearer_methods_supported:i2(iw()).optional(),resource_signing_alg_values_supported:i2(iw()).optional(),resource_name:iw().optional(),resource_documentation:iw().optional(),resource_policy_uri:iw().url().optional(),resource_tos_uri:iw().url().optional(),tls_client_certificate_bound_access_tokens:iW().optional(),authorization_details_types_supported:i2(iw()).optional(),dpop_signing_alg_values_supported:i2(iw()).optional(),dpop_bound_access_tokens_required:iW().optional()}),su=i5({issuer:iw(),authorization_endpoint:sc,token_endpoint:sc,registration_endpoint:sc.optional(),scopes_supported:i2(iw()).optional(),response_types_supported:i2(iw()),response_modes_supported:i2(iw()).optional(),grant_types_supported:i2(iw()).optional(),token_endpoint_auth_methods_supported:i2(iw()).optional(),token_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),service_documentation:sc.optional(),revocation_endpoint:sc.optional(),revocation_endpoint_auth_methods_supported:i2(iw()).optional(),revocation_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),introspection_endpoint:iw().optional(),introspection_endpoint_auth_methods_supported:i2(iw()).optional(),introspection_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),code_challenge_methods_supported:i2(iw()).optional(),client_id_metadata_document_supported:iW().optional(),authorization_response_iss_parameter_supported:iW().optional().catch(void 0)}),sp=i5({issuer:iw(),authorization_endpoint:sc,token_endpoint:sc,userinfo_endpoint:sc.optional(),jwks_uri:sc,registration_endpoint:sc.optional(),scopes_supported:i2(iw()).optional(),response_types_supported:i2(iw()),response_modes_supported:i2(iw()).optional(),grant_types_supported:i2(iw()).optional(),acr_values_supported:i2(iw()).optional(),subject_types_supported:i2(iw()),id_token_signing_alg_values_supported:i2(iw()),id_token_encryption_alg_values_supported:i2(iw()).optional(),id_token_encryption_enc_values_supported:i2(iw()).optional(),userinfo_signing_alg_values_supported:i2(iw()).optional(),userinfo_encryption_alg_values_supported:i2(iw()).optional(),userinfo_encryption_enc_values_supported:i2(iw()).optional(),request_object_signing_alg_values_supported:i2(iw()).optional(),request_object_encryption_alg_values_supported:i2(iw()).optional(),request_object_encryption_enc_values_supported:i2(iw()).optional(),token_endpoint_auth_methods_supported:i2(iw()).optional(),token_endpoint_auth_signing_alg_values_supported:i2(iw()).optional(),display_values_supported:i2(iw()).optional(),claim_types_supported:i2(iw()).optional(),claims_supported:i2(iw()).optional(),service_documentation:iw().optional(),claims_locales_supported:i2(iw()).optional(),ui_locales_supported:i2(iw()).optional(),claims_parameter_supported:iW().optional(),request_parameter_supported:iW().optional(),request_uri_parameter_supported:iW().optional(),require_request_uri_registration:iW().optional(),op_policy_uri:sc.optional(),op_tos_uri:sc.optional(),client_id_metadata_document_supported:iW().optional(),authorization_response_iss_parameter_supported:iW().optional().catch(void 0)}),sm=i4({...sp.shape,...su.pick({code_challenge_methods_supported:!0}).shape}),sh=i4({access_token:iw(),id_token:iw().optional(),token_type:iw(),expires_in:new iF({type:"number",coerce:!0,checks:[],...eA(void 0)}).optional(),scope:iw().optional(),refresh_token:iw().optional()}).strip(),sf=i4({issued_token_type:ns("urn:ietf:params:oauth:token-type:id-jag"),access_token:iw(),token_type:iw().optional(),expires_in:iV().optional(),scope:iw().optional()}).strip(),sg=i4({error:iw(),error_description:iw().optional(),error_uri:iw().optional()}),sy=sc.optional().or(ns("").transform(()=>void 0)),sv=i4({redirect_uris:i2(sc),token_endpoint_auth_method:iw().optional(),grant_types:i2(iw()).optional(),response_types:i2(iw()).optional(),application_type:iw().optional(),client_name:iw().optional(),client_uri:sc.optional(),logo_uri:sy,scope:iw().optional(),contacts:i2(iw()).optional(),tos_uri:sy,policy_uri:iw().optional(),jwks_uri:sc.optional(),jwks:new iY({type:"any"}).optional(),software_id:iw().optional(),software_version:iw().optional(),software_statement:iw().optional()}).strip(),s_=i4({client_id:iw(),client_secret:iw().optional(),client_id_issued_at:iV().optional(),client_secret_expires_at:iV().optional()}).strip(),sb=sv.merge(s_),sS=i4({error:iw(),error_description:iw().optional()}).strip(),sw=i4({token:iw(),token_type_hint:iw().optional()}).strip(),sR=Symbol.for("mcp.sdk.errorBrands");function sk(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,sR,{value:r,enumerable:!1,configurable:!0})}function sx(e,t){try{if("object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&"string"==typeof e.mcpBrand&&Object.prototype.hasOwnProperty.call(t,sR)){let r=t[sR];if(r&&"function"==typeof r.has&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}(class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](e){return sx(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 sx(this,e)}constructor(e,t,r){super(t),this.code=e,this.errorUri=r,this.name="OAuthError",sk(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 sC=((f={}).NotConnected="NOT_CONNECTED",f.AlreadyConnected="ALREADY_CONNECTED",f.NotInitialized="NOT_INITIALIZED",f.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",f.RequestTimeout="REQUEST_TIMEOUT",f.ConnectionClosed="CONNECTION_CLOSED",f.SendFailed="SEND_FAILED",f.InvalidResult="INVALID_RESULT",f.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",f.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",f.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",f.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",f.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",f.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",f.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",f.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",f.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",f.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",f.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",f);var s$=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return sx(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 sx(this,e)}constructor(e,t,r){super(t),this.code=e,this.data=r,this.name="SdkError",sk(this,new.target)}};(class extends s${static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r){super(e,t,r),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let sT={};function sE(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function sP(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(sE(n)&&sE(e)){let t={};for(let[r,a]of Object.entries(n))void 0!==a&&void 0===e[r]&&("elicitation"!==i||"form"!==r||void 0!==e.form||void 0!==e.url)&&(t[r]=a);Object.keys(t).length>0&&(r[i]=t)}}return Object.keys(r).length>0?r:void 0}let sI="2026-07-28",sq=[sI];function sO(e){return e.filter(e=>e>=sI)}function sj(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 sz=["task","inputRequests","requestState"];function sL(e){return null===e||"object"!=typeof e||Array.isArray(e)||void 0!==e.content||sz.some(t=>t in e)?e:{...e,content:[]}}function sN(){let t,r,i,n,a,o,s,l,c,d,u,p,m,h,f,g,y,v,_,b,S,w,R,k,x,C,$,T,E,P,I,q,O,j,z,L,N,A,M,Z,U,H,F,V,D,J,B,W,G,K,Y,X,Q,ee,et,er,ei,en,ea,eo,es,el,ec,ed,eu,ep,em,eh,ef,eg,ey,ev,e_,eb,eS,ew,eR,ek,ex,eC,e$,eT,eE,eP,eI,eq,eO,ej,ez,eL,eN,eA,eM,eZ,eU,eH,eF,eV,eD,eJ,eB,eW,eG,eK,eY,eX,eQ,e0,e1,e2,e9,e4,e5,e3,e6,e7,e8,te,tt,tr,ti,tn,ta,to,ts,tl,tc,td,tu,tp,tm,th,tf,tg,ty,tv,t_,tb,tS,tw;return e??=(t=nk(()=>i6([iw(),iV(),iW(),iK(),ni(iw(),t),i2(t)])),r=ni(iw(),t),i=i6([iw(),iV().int()]),n=iw(),a=i4({ttl:iV().optional()}),o=i4({taskId:iw()}),c=(l=i4({_meta:(s=i5({progressToken:i.optional(),"io.modelcontextprotocol/related-task":o.optional()})).optional()})).extend({task:a.optional()}),d=i4({method:iw(),params:l.loose().optional()}),u=i4({_meta:s.optional()}),p=i4({method:iw(),params:u.loose().optional()}),m=i5({_meta:s.optional()}),h=i6([iw(),iV().int()]),f=m.strict(),g=u.extend({requestId:h.optional(),reason:iw().optional()}),y=p.extend({method:ns("notifications/cancelled"),params:g}),v=i4({src:iw(),mimeType:iw().optional(),sizes:i2(iw()).optional(),theme:na(["light","dark"]).optional()}),_=i4({icons:i2(v).optional()}),S=(b=i4({name:iw(),title:iw().optional()})).extend({...b.shape,..._.shape,version:iw(),websiteUrl:iw().optional(),description:iw().optional()}),w=nt(i4({applyDefaults:iW().optional()}),r),R=nC(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,nt(i4({form:w.optional(),url:r.optional()}),r.optional())),k=i5({list:r.optional(),cancel:r.optional(),requests:i5({sampling:i5({createMessage:r.optional()}).optional(),elicitation:i5({create:r.optional()}).optional()}).optional()}),x=i5({list:r.optional(),cancel:r.optional(),requests:i5({tools:i5({call:r.optional()}).optional()}).optional()}),C=i4({experimental:ni(iw(),r).optional(),sampling:i4({context:r.optional(),tools:r.optional()}).optional(),elicitation:R.optional(),roots:i4({listChanged:iW().optional()}).optional(),tasks:k.optional(),extensions:ni(iw(),r).optional()}),$=l.extend({protocolVersion:iw(),capabilities:C,clientInfo:S}),T=d.extend({method:ns("initialize"),params:$}),E=i4({experimental:ni(iw(),r).optional(),logging:r.optional(),completions:r.optional(),prompts:i4({listChanged:iW().optional()}).optional(),resources:i4({subscribe:iW().optional(),listChanged:iW().optional()}).optional(),tools:i4({listChanged:iW().optional()}).optional(),tasks:x.optional(),extensions:ni(iw(),r).optional()}),P=m.extend({protocolVersion:iw(),capabilities:E,serverInfo:S,instructions:iw().optional()}),I=p.extend({method:ns("notifications/initialized"),params:u.optional()}),q=d.extend({method:ns("ping"),params:l.optional()}),O=i4({progress:iV(),total:nu(iV()),message:nu(iw())}),j=i4({...u.shape,...O.shape,progressToken:i}),z=p.extend({method:ns("notifications/progress"),params:j}),L=l.extend({cursor:n.optional()}),N=d.extend({params:L.optional()}),A=m.extend({nextCursor:n.optional()}),Z=(M=i4({uri:iw(),mimeType:nu(iw()),_meta:ni(iw(),iQ()).optional()})).extend({text:iw()}),U=iw().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),H=M.extend({blob:U}),V=i4({audience:i2(F=na(["user","assistant"])).optional(),priority:iV().min(0).max(1).optional(),lastModified:r6({offset:!0}).optional()}),D=i4({...b.shape,..._.shape,uri:iw(),description:nu(iw()),mimeType:nu(iw()),size:nu(iV()),annotations:V.optional(),_meta:nu(i5({}))}),J=i4({...b.shape,..._.shape,uriTemplate:iw(),description:nu(iw()),mimeType:nu(iw()),annotations:V.optional(),_meta:nu(i5({}))}),B=N.extend({method:ns("resources/list")}),W=A.extend({resources:i2(D)}),G=N.extend({method:ns("resources/templates/list")}),K=A.extend({resourceTemplates:i2(J)}),Y=l.extend({uri:iw()}),X=d.extend({method:ns("resources/read"),params:Y}),Q=m.extend({contents:i2(i6([Z,H]))}),ee=p.extend({method:ns("notifications/resources/list_changed"),params:u.optional()}),et=d.extend({method:ns("resources/subscribe"),params:Y}),er=d.extend({method:ns("resources/unsubscribe"),params:Y}),ei=u.extend({uri:iw()}),en=p.extend({method:ns("notifications/resources/updated"),params:ei}),ea=i4({name:iw(),description:nu(iw()),required:nu(iW())}),eo=i4({...b.shape,..._.shape,description:nu(iw()),arguments:nu(i2(ea)),_meta:nu(i5({}))}),es=N.extend({method:ns("prompts/list")}),el=A.extend({prompts:i2(eo)}),ec=l.extend({name:iw(),arguments:ni(iw(),iw()).optional()}),ed=d.extend({method:ns("prompts/get"),params:ec}),eu=i4({type:ns("text"),text:iw(),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),ep=i4({type:ns("image"),data:U,mimeType:iw(),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),em=i4({type:ns("audio"),data:U,mimeType:iw(),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),eh=i4({type:ns("tool_use"),name:iw(),id:iw(),input:ni(iw(),iQ()),_meta:ni(iw(),iQ()).optional()}),ef=i4({type:ns("resource"),resource:i6([Z,H]),annotations:V.optional(),_meta:ni(iw(),iQ()).optional()}),ev=i4({role:F,content:ey=i6([eu,ep,em,eg=D.extend({type:ns("resource_link")}),ef])}),e_=m.extend({description:iw().optional(),messages:i2(ev)}),eb=p.extend({method:ns("notifications/prompts/list_changed"),params:u.optional()}),eS=i4({title:iw().optional(),readOnlyHint:iW().optional(),destructiveHint:iW().optional(),idempotentHint:iW().optional(),openWorldHint:iW().optional()}),ew=i4({taskSupport:na(["required","optional","forbidden"]).optional()}),eR=i4({...b.shape,..._.shape,description:iw().optional(),inputSchema:i4({type:ns("object"),properties:ni(iw(),t).optional(),required:i2(iw()).optional()}).catchall(iQ()),outputSchema:i4({type:ns("object"),properties:ni(iw(),t).optional(),required:i2(iw()).optional()}).catchall(iQ()).optional(),annotations:eS.optional(),execution:ew.optional(),_meta:ni(iw(),iQ()).optional()}),ek=N.extend({method:ns("tools/list")}),ex=A.extend({tools:i2(eR)}),eC=m.extend({content:i2(ey),structuredContent:ni(iw(),iQ()).optional(),isError:iW().optional()}),e$=c.extend({name:iw(),arguments:ni(iw(),iQ()).optional()}),eT=d.extend({method:ns("tools/call"),params:e$}),eE=p.extend({method:ns("notifications/tools/list_changed"),params:u.optional()}),eP=na(["debug","info","notice","warning","error","critical","alert","emergency"]),eI=l.extend({level:eP}),eq=d.extend({method:ns("logging/setLevel"),params:eI}),eO=u.extend({level:eP,logger:iw().optional(),data:iQ()}),ej=p.extend({method:ns("notifications/message"),params:eO}),ez=i4({name:iw().optional()}),eL=i4({hints:i2(ez).optional(),costPriority:iV().min(0).max(1).optional(),speedPriority:iV().min(0).max(1).optional(),intelligencePriority:iV().min(0).max(1).optional()}),eN=i4({mode:na(["auto","required","none"]).optional()}),eA=i4({type:ns("tool_result"),toolUseId:iw().describe("The unique identifier for the corresponding tool call."),content:i2(ey),structuredContent:i4({}).loose().optional(),isError:iW().optional(),_meta:ni(iw(),iQ()).optional()}),eM=i8("type",[eu,ep,em]),eU=i4({role:F,content:i6([eZ=i8("type",[eu,ep,em,eh,eA]),i2(eZ)]),_meta:ni(iw(),iQ()).optional()}),eH=c.extend({messages:i2(eU),modelPreferences:eL.optional(),systemPrompt:iw().optional(),includeContext:na(["none","thisServer","allServers"]).optional(),temperature:iV().optional(),maxTokens:iV().int(),stopSequences:i2(iw()).optional(),metadata:r.optional(),tools:i2(eR).optional(),toolChoice:eN.optional()}),eF=d.extend({method:ns("sampling/createMessage"),params:eH}),eV=m.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens"]).or(iw())),role:F,content:eM}),eD=m.extend({model:iw(),stopReason:nu(na(["endTurn","stopSequence","maxTokens","toolUse"]).or(iw())),role:F,content:i6([eZ,i2(eZ)])}),eJ=i4({type:ns("boolean"),title:iw().optional(),description:iw().optional(),default:iW().optional()}),eB=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),minLength:iV().optional(),maxLength:iV().optional(),format:na(["email","uri","date","date-time"]).optional(),default:iw().optional()}),eW=i4({type:na(["number","integer"]),title:iw().optional(),description:iw().optional(),minimum:iV().optional(),maximum:iV().optional(),default:iV().optional()}),eG=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),default:iw().optional()}),eK=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),oneOf:i2(i4({const:iw(),title:iw()})),default:iw().optional()}),eY=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),enumNames:i2(iw()).optional(),default:iw().optional()}),eX=i6([eG,eK]),eQ=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({type:ns("string"),enum:i2(iw())}),default:i2(iw()).optional()}),e1=i6([eQ,e0=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({anyOf:i2(i4({const:iw(),title:iw()}))}),default:i2(iw()).optional()})]),e2=i6([eY,eX,e1]),e9=i6([e2,eJ,eB,eW]),e4=c.extend({mode:ns("form").optional(),message:iw(),requestedSchema:i4({type:ns("object"),properties:ni(iw(),e9),required:i2(iw()).optional()}).catchall(iQ())}),e3=i6([e4,e5=c.extend({mode:ns("url"),message:iw(),elicitationId:iw(),url:iw().url()})]),e6=d.extend({method:ns("elicitation/create"),params:e3}),e7=u.extend({elicitationId:iw()}),e8=p.extend({method:ns("notifications/elicitation/complete"),params:e7}),te=m.extend({action:na(["accept","decline","cancel"]),content:nC(e=>null===e?void 0:e,ni(iw(),i6([iw(),iV(),iW(),i2(iw())])).optional())}),tt=i4({type:ns("ref/resource"),uri:iw()}),tr=i4({type:ns("ref/prompt"),name:iw()}),ti=l.extend({ref:i6([tr,tt]),argument:i4({name:iw(),value:iw()}),context:i4({arguments:ni(iw(),iw()).optional()}).optional()}),tn=d.extend({method:ns("completion/complete"),params:ti}),ta=m.extend({completion:i5({values:i2(iw()).max(100),total:nu(iV().int()),hasMore:nu(iW())})}),to=i4({uri:iw().startsWith("file://"),name:iw().optional(),_meta:ni(iw(),iQ()).optional()}),ts=d.extend({method:ns("roots/list"),params:l.optional()}),tl=m.extend({roots:i2(to)}),tc=p.extend({method:ns("notifications/roots/list_changed"),params:u.optional()}),td=i5({ttl:iV().optional(),pollInterval:iV().optional()}),tu=na(["working","input_required","completed","failed","cancelled"]),tp=i4({taskId:iw(),status:tu,ttl:i6([iV(),iK()]),createdAt:iw(),lastUpdatedAt:iw(),pollInterval:nu(iV()),statusMessage:nu(iw())}),tm=m.extend({task:tp}),th=u.merge(tp),tf=p.extend({method:ns("notifications/tasks/status"),params:th}),tg=d.extend({method:ns("tasks/get"),params:l.extend({taskId:iw()})}),ty=m.merge(tp),tv=d.extend({method:ns("tasks/result"),params:l.extend({taskId:iw()})}),t_=m.loose(),tb=N.extend({method:ns("tasks/list")}),tS=A.extend({tasks:i2(tp)}),tw=d.extend({method:ns("tasks/cancel"),params:l.extend({taskId:iw()})}),{JSONValueSchema:t,JSONObjectSchema:r,ProgressTokenSchema:i,CursorSchema:n,TaskMetadataSchema:a,RelatedTaskMetadataSchema:o,RequestMetaSchema:s,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:c,RequestSchema:d,NotificationsParamsSchema:u,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:E,InitializeResultSchema:P,InitializedNotificationSchema:I,PingRequestSchema:q,ProgressSchema:O,ProgressNotificationParamsSchema:j,ProgressNotificationSchema:z,PaginatedRequestParamsSchema:L,PaginatedRequestSchema:N,PaginatedResultSchema:A,ResourceContentsSchema:M,TextResourceContentsSchema:Z,BlobResourceContentsSchema:H,RoleSchema:F,AnnotationsSchema:V,ResourceSchema:D,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:ea,PromptSchema:eo,ListPromptsRequestSchema:es,ListPromptsResultSchema:el,GetPromptRequestParamsSchema:ec,GetPromptRequestSchema:ed,TextContentSchema:eu,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:eE,LoggingLevelSchema:eP,SetLevelRequestParamsSchema:eI,SetLevelRequestSchema:eq,LoggingMessageNotificationParamsSchema:eO,LoggingMessageNotificationSchema:ej,ModelHintSchema:ez,ModelPreferencesSchema:eL,ToolChoiceSchema:eN,ToolResultContentSchema:eA,SamplingContentSchema:eM,SamplingMessageContentBlockSchema:eZ,SamplingMessageSchema:eU,CreateMessageRequestParamsSchema:eH,CreateMessageRequestSchema:eF,CreateMessageResultSchema:eV,CreateMessageResultWithToolsSchema:eD,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:ta,RootSchema:to,ListRootsRequestSchema:ts,ListRootsResultSchema:tl,RootsListChangedNotificationSchema:tc,TaskCreationParamsSchema:td,TaskStatusSchema:tu,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:i6([q,T,tn,eq,ed,es,B,G,X,et,er,eT,ek,tg,tv,tb,tw]),ClientNotificationSchema:i6([y,z,I,tc,tf]),ClientResultSchema:i6([f,eV,eD,te,tl,ty,tS,tm]),ServerRequestSchema:i6([q,eF,e6,ts,tg,tv,tb,tw]),ServerNotificationSchema:i6([y,z,ej,en,ee,eE,eb,tf,e8]),ServerResultSchema:i6([f,P,ta,e_,el,W,K,Q,eC,ex,ty,tS,tm]),CallToolResultWireSchema:iQ().superRefine((e,t)=>{if(!("object"!=typeof e||null===e||Array.isArray(e))&&void 0===e.content){for(let r of sz)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(sL).pipe(eC)})}function sA(e){return"object"!==e.type}let sM=new Set(["const","enum","default","examples"]),sZ=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function sU(e){return void 0!==e&&!("string"==typeof e&&e.startsWith("#"))}let sH={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},sF={"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},sV={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 sD(){if(t)return t;let e=sN();return t={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 sJ(e){return Object.prototype.hasOwnProperty.call(sH,e)}function sB(e){return Object.prototype.hasOwnProperty.call(sF,e)}function sW(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function sG(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(sH),Object.keys(sF);let sK={ok:!1,reason:"not-in-era"};function sY(e){return sW(e)&&sW(e.outputSchema)&&sA(e.outputSchema)}let sX={era:"2025-11-25",hasRequestMethod:sJ,hasNotificationMethod:sB,validateRequest:(e,t)=>sG(sJ(e)?sD().requestSchemas[e]:void 0,t),validateResult:(e,t)=>sG(Object.prototype.hasOwnProperty.call(sV,e)?sD().resultSchemas[e]:void 0,t),validateNotification:(e,t)=>sG(sB(e)?sD().notificationSchemas[e]:void 0,t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>sK,validateInputResponse:()=>sK,samplingResultVariant:(e,t)=>{let r=sN();return sG(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)},outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=sj(e),i=r.structuredContent;if(void 0===i)return r;let n="object"!=typeof i||null===i||Array.isArray(i),a=void 0!==t&&sA(t);return n||a?{...r,structuredContent:{result:i}}:r},decodeResult(e,t){if(sW(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=>sY(e))?{...t,tools:r.map(e=>sY(e)?{...e,outputSchema:function(e){var t;let r="string"==typeof e.$schema?e.$schema:void 0;if(sU(e.$id))return{...void 0!==r&&{$schema:r},type:"object",properties:{result:e},required:["result"]};let i="string"==typeof(t=e.$schema)&&M.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&&sU(e.$id))return e;let r={},a=!1;for(let[o,s]of Object.entries(e))t?r[o]=n(s,!1):("$ref"===o||"$dynamicRef"===o)&&"string"==typeof s?r[o]="#"===s?"#/properties/result":s.startsWith("#/")?`#/properties/result${s.slice(1)}`:s:"$recursiveRef"===o&&"#"===s&&i?a=!0:sM.has(o)?r[o]=s:sZ.has(o)?r[o]=n(s,!0):r[o]=n(s,!1);return a&&("$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 sQ(){return r??=function(){let e=nk(()=>i6([iw(),iV(),iW(),iK(),ni(iw(),e),i2(e)])),t=ni(iw(),e),r=i6([iw(),iV().int()]),i=iw(),n=i6([iw(),iV().int()]),a=na(["user","assistant"]),o=na(["debug","info","notice","warning","error","critical","alert","emergency"]),s=iw().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=i4({ttl:iV().optional()}),c=i4({taskId:iw()}),d=i5({progressToken:r.optional(),"io.modelcontextprotocol/related-task":c.optional()}),u=i4({_meta:d.optional()}),p=u.extend({task:l.optional()}),m=i4({_meta:d.optional()}),h=i4({method:iw(),params:m.loose().optional()}),f=i4({src:iw(),mimeType:iw().optional(),sizes:i2(iw()).optional(),theme:na(["light","dark"]).optional()}),g=i4({icons:i2(f).optional()}),y=i4({name:iw(),title:iw().optional()}),v=y.extend({...y.shape,...g.shape,version:iw(),websiteUrl:iw().optional(),description:iw().optional()}),_=nt(i4({applyDefaults:iW().optional()}),t),b=nC(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,nt(i4({form:_.optional(),url:t.optional()}),t.optional())),S=i5({list:t.optional(),cancel:t.optional(),requests:i5({sampling:i5({createMessage:t.optional()}).optional(),elicitation:i5({create:t.optional()}).optional()}).optional()}),w=i5({list:t.optional(),cancel:t.optional(),requests:i5({tools:i5({call:t.optional()}).optional()}).optional()}),R=i4({experimental:ni(iw(),t).optional(),sampling:i4({context:t.optional(),tools:t.optional()}).optional(),elicitation:b.optional(),roots:i4({listChanged:iW().optional()}).optional(),tasks:S.optional(),extensions:ni(iw(),t).optional()}),k=i4({experimental:ni(iw(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:i4({listChanged:iW().optional()}).optional(),resources:i4({subscribe:iW().optional(),listChanged:iW().optional()}).optional(),tools:i4({listChanged:iW().optional()}).optional(),tasks:w.optional(),extensions:ni(iw(),t).optional()}),x=i4({progress:iV(),total:nu(iV()),message:nu(iw())}),C=i4({...m.shape,...x.shape,progressToken:r}),$=h.extend({method:ns("notifications/progress"),params:C}),T=m.extend({level:o,logger:iw().optional(),data:iQ()}),E=h.extend({method:ns("notifications/message"),params:T}),P=i4({uri:iw(),mimeType:nu(iw()),_meta:ni(iw(),iQ()).optional()}),I=P.extend({text:iw()}),q=P.extend({blob:s}),O=i4({audience:i2(a).optional(),priority:iV().min(0).max(1).optional(),lastModified:r6({offset:!0}).optional()}),j=i4({...y.shape,...g.shape,uri:iw(),description:nu(iw()),mimeType:nu(iw()),size:nu(iV()),annotations:O.optional(),_meta:nu(i5({}))}),z=i4({...y.shape,...g.shape,uriTemplate:iw(),description:nu(iw()),mimeType:nu(iw()),annotations:O.optional(),_meta:nu(i5({}))}),L=h.extend({method:ns("notifications/resources/list_changed"),params:m.optional()}),N=m.extend({uri:iw()}),A=h.extend({method:ns("notifications/resources/updated"),params:N}),M=i4({name:iw(),description:nu(iw()),required:nu(iW())}),Z=i4({...y.shape,...g.shape,description:nu(iw()),arguments:nu(i2(M)),_meta:nu(i5({}))}),U=h.extend({method:ns("notifications/prompts/list_changed"),params:m.optional()}),H=i4({type:ns("text"),text:iw(),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),F=i4({type:ns("image"),data:s,mimeType:iw(),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),V=i4({type:ns("audio"),data:s,mimeType:iw(),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),D=i4({type:ns("tool_use"),name:iw(),id:iw(),input:ni(iw(),iQ()),_meta:ni(iw(),iQ()).optional()}),J=i4({type:ns("resource"),resource:i6([I,q]),annotations:O.optional(),_meta:ni(iw(),iQ()).optional()}),B=j.extend({type:ns("resource_link")}),W=i6([H,F,V,B,J]),G=i4({role:a,content:W}),K=i4({title:iw().optional(),readOnlyHint:iW().optional(),destructiveHint:iW().optional(),idempotentHint:iW().optional(),openWorldHint:iW().optional()}),Y=h.extend({method:ns("notifications/tools/list_changed"),params:m.optional()}),X=i4({name:iw().optional()}),Q=i4({hints:i2(X).optional(),costPriority:iV().min(0).max(1).optional(),speedPriority:iV().min(0).max(1).optional(),intelligencePriority:iV().min(0).max(1).optional()}),ee=i4({mode:na(["auto","required","none"]).optional()}),et=i4({type:ns("boolean"),title:iw().optional(),description:iw().optional(),default:iW().optional()}),er=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),minLength:iV().optional(),maxLength:iV().optional(),format:na(["email","uri","date","date-time"]).optional(),default:iw().optional()}),ei=i4({type:na(["number","integer"]),title:iw().optional(),description:iw().optional(),minimum:iV().optional(),maximum:iV().optional(),default:iV().optional()}),en=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),default:iw().optional()}),ea=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),oneOf:i2(i4({const:iw(),title:iw()})),default:iw().optional()}),eo=i4({type:ns("string"),title:iw().optional(),description:iw().optional(),enum:i2(iw()),enumNames:i2(iw()).optional(),default:iw().optional()}),es=i6([en,ea]),el=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({type:ns("string"),enum:i2(iw())}),default:i2(iw()).optional()}),ec=i4({type:ns("array"),title:iw().optional(),description:iw().optional(),minItems:iV().optional(),maxItems:iV().optional(),items:i4({anyOf:i2(i4({const:iw(),title:iw()}))}),default:i2(iw()).optional()}),ed=i6([el,ec]),eu=i6([eo,es,ed]),ep=i6([eu,et,er,ei]),em=p.extend({mode:ns("form").optional(),message:iw(),requestedSchema:i4({type:ns("object"),properties:ni(iw(),ep),required:i2(iw()).optional()}).catchall(iQ())}),eh=i4({type:ns("ref/resource"),uri:iw()}),ef=i4({type:ns("ref/prompt"),name:iw()}),eg=i4({uri:iw().startsWith("file://"),name:iw().optional(),_meta:ni(iw(),iQ()).optional()}),ey=R.shape,ev=i4({experimental:ey.experimental,sampling:ey.sampling,elicitation:ey.elicitation,roots:ey.roots,extensions:ey.extensions}),e_=k.shape,eb=i4({experimental:e_.experimental,logging:e_.logging,completions:e_.completions,prompts:e_.prompts,resources:e_.resources,tools:e_.tools,extensions:e_.extensions}),eS=i5({progressToken:r.optional(),[nE]:iw(),[nP]:v.optional(),[nq]:ev,[nj]:o.optional()}),ew=i4({...y.shape,...g.shape,description:iw().optional(),inputSchema:i5({$schema:iw().optional(),type:ns("object")}),outputSchema:i5({$schema:iw().optional()}).optional(),annotations:K.optional(),_meta:ni(iw(),iQ()).optional()}),eR=i4({type:ns("tool_result"),toolUseId:iw(),content:i2(W),structuredContent:iQ().optional(),isError:iW().optional(),_meta:ni(iw(),iQ()).optional()}),ek=i6([H,F,V,D,eR]),ex=i4({role:a,content:i6([ek,i2(ek)]),_meta:ni(iw(),iQ()).optional()}),eC=iw(),e$=i5({[nI]:v.optional().catch(void 0)}),eT=e$.optional();function eE(e){return i5({_meta:eT,resultType:eC.default("complete"),...e})}let eP=eE({}),eI=eE({nextCursor:i.optional()}),eq=eE({content:i2(W),structuredContent:iQ().optional(),isError:iW().optional()}),eO=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),tools:i2(ew),nextCursor:i.optional()}),ej=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),prompts:i2(Z),nextCursor:i.optional()}),ez=eE({description:iw().optional(),messages:i2(G)}),eL=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resources:i2(j),nextCursor:i.optional()}),eN=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resourceTemplates:i2(z),nextCursor:i.optional()}),eA=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),contents:i2(i6([I,q]))}),eM=eE({completion:i4({values:i2(iw()).max(100),total:iV().int().optional(),hasMore:iW().optional()}).loose()}),eZ=eE({ttlMs:iV().int().min(0),cacheScope:na(["public","private"])}),eU=eE({ttlMs:iV().int().min(0).catch(0),cacheScope:na(["public","private"]).catch("private"),supportedVersions:i2(iw()),capabilities:eb,instructions:iw().optional()}),eH=i4({messages:i2(ex),modelPreferences:Q.optional(),systemPrompt:iw().optional(),includeContext:na(["none","thisServer","allServers"]).optional(),temperature:iV().optional(),maxTokens:iV().int(),stopSequences:i2(iw()).optional(),metadata:t.optional(),tools:i2(ew).optional(),toolChoice:ee.optional()}),eF=i4({method:ns("sampling/createMessage"),params:eH}),eV=i4({method:ns("roots/list"),params:i4({_meta:ni(iw(),iQ()).optional()}).optional()}),eD=i4({...ex.shape,model:iw(),stopReason:iw().optional()}),eJ=i4({roots:i2(eg)}),eB=i4({action:na(["accept","decline","cancel"]),content:ni(iw(),i6([iw(),iV(),iW(),i2(iw())])).optional()}),eW=i4({mode:ns("url"),message:iw(),url:iw().url()}),eG=i6([em,eW]),eK=i4({method:ns("elicitation/create"),params:eG}),eY=i6([eF,eV,eK]),eX=i6([eD,eJ,eB]),eQ=ni(iw(),eY),e0=ni(iw(),eX),e1=eE({inputRequests:eQ.optional(),requestState:iw().optional()}),e2={inputResponses:e0.optional(),requestState:iw().optional()},e9=i4({_meta:eS,...e2}),e4=i5({progressToken:r.optional()});function e5(e,t){return i4({method:ns(e),params:i4({_meta:eS,...t})})}function e3(e,t){return i4({method:ns(e),params:i4({_meta:e4.optional(),...t}).optional()})}let e6={name:iw(),arguments:ni(iw(),iQ()).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:iw(),arguments:ni(iw(),iw()).optional(),...e2}),ti=e5("resources/list",e7),tn=e5("resources/templates/list",e7),ta=e5("resources/read",{uri:iw(),...e2}),to={ref:i6([ef,eh]),argument:i4({name:iw(),value:iw()}),context:i4({arguments:ni(iw(),iw()).optional()}).optional()},ts=e5("completion/complete",to),tl=e5("server/discover",{}),tc=i4({toolsListChanged:iW().optional(),promptsListChanged:iW().optional(),resourcesListChanged:iW().optional(),resourceSubscriptions:i2(iw()).optional()}),td={notifications:tc},tu=e5("subscriptions/listen",td),tp=e$.extend({"io.modelcontextprotocol/subscriptionId":n}),tm=i5({_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:iw(),arguments:ni(iw(),iw()).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:iw()}),"completion/complete":e3("completion/complete",to),"server/discover":e3("server/discover",{}),"subscriptions/listen":e3("subscriptions/listen",td)};function tf(e){return i5({_meta:eT,...e})}let tg={"tools/call":tf({content:i2(W),structuredContent:iQ().optional(),isError:iW().optional()}),"tools/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),tools:i2(ew),nextCursor:i.optional()}),"prompts/get":tf({description:iw().optional(),messages:i2(G)}),"prompts/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),prompts:i2(Z),nextCursor:i.optional()}),"resources/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resources:i2(j),nextCursor:i.optional()}),"resources/templates/list":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),resourceTemplates:i2(z),nextCursor:i.optional()}),"resources/read":tf({ttlMs:iV().int().min(0),cacheScope:na(["public","private"]),contents:i2(i6([I,q]))}),"completion/complete":tf({completion:i4({values:i2(iw()).max(100),total:iV().int().optional(),hasMore:iW().optional()}).loose()}),"server/discover":tf({ttlMs:iV().int().min(0).catch(0),cacheScope:na(["public","private"]).catch("private"),supportedVersions:i2(iw()),capabilities:eb,instructions:iw().optional()}),"subscriptions/listen":tf({})},ty=i5({"io.modelcontextprotocol/subscriptionId":n.optional()}),tv=i4({method:ns("notifications/subscriptions/acknowledged"),params:i4({_meta:ty.optional(),notifications:tc})}),t_=i4({_meta:ty.optional(),requestId:n,reason:iw().optional()}),tb=i4({method:ns("notifications/cancelled"),params:t_}),tS=e=>i4({jsonrpc:ns("2.0"),id:i6([iw(),iV().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:i,RequestIdSchema:n,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:l,RelatedTaskMetadataSchema:c,RequestMetaSchema:d,BaseRequestParamsSchema:u,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:E,ResourceContentsSchema:P,TextResourceContentsSchema:I,BlobResourceContentsSchema:q,AnnotationsSchema:O,ResourceSchema:j,ResourceTemplateSchema:z,ResourceListChangedNotificationSchema:L,ResourceUpdatedNotificationParamsSchema:N,ResourceUpdatedNotificationSchema:A,PromptArgumentSchema:M,PromptSchema:Z,PromptListChangedNotificationSchema:U,TextContentSchema:H,ImageContentSchema:F,AudioContentSchema:V,ToolUseContentSchema:D,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:ea,LegacyTitledEnumSchemaSchema:eo,SingleSelectEnumSchemaSchema:es,UntitledMultiSelectEnumSchemaSchema:el,TitledMultiSelectEnumSchemaSchema:ec,MultiSelectEnumSchemaSchema:ed,EnumSchemaSchema:eu,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:eP,PaginatedResultSchema:eI,CallToolResultSchema:eq,ListToolsResultSchema:eO,ListPromptsResultSchema:ej,GetPromptResultSchema:ez,ListResourcesResultSchema:eL,ListResourceTemplatesResultSchema:eN,ReadResourceResultSchema:eA,CompleteResultSchema:eM,CacheableResultSchema:eZ,DiscoverResultSchema:eU,CreateMessageRequestParamsSchema:eH,CreateMessageRequestSchema:eF,ListRootsRequestSchema:eV,CreateMessageResultSchema:eD,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:ta,CompleteRequestSchema:ts,DiscoverRequestSchema:tl,SubscriptionFilterSchema:tc,SubscriptionsListenRequestSchema:tu,SubscriptionsListenResultMetaSchema:tp,SubscriptionsListenResultSchema:tm,dispatchRequestSchemas:th,dispatchResultSchemas:tg,NotificationMetaSchema:ty,SubscriptionsAcknowledgedNotificationSchema:tv,CancelledNotificationParamsSchema:t_,CancelledNotificationSchema:tb,notificationSchemas2026:{"notifications/cancelled":tb,"notifications/progress":$,"notifications/message":E,"notifications/resources/updated":A,"notifications/resources/list_changed":L,"notifications/tools/list_changed":Y,"notifications/prompts/list_changed":U,"notifications/subscriptions/acknowledged":tv},JSONRPCResultResponseSchema:tS(eP),CallToolResultResponseSchema:tS(i6([eq,e1])),ListToolsResultResponseSchema:tS(eO),ListPromptsResultResponseSchema:tS(ej),GetPromptResultResponseSchema:tS(i6([ez,e1])),ListResourcesResultResponseSchema:tS(eL),ListResourceTemplatesResultResponseSchema:tS(eN),ReadResourceResultResponseSchema:tS(i6([eA,e1])),CompleteResultResponseSchema:tS(eM),DiscoverResultResponseSchema:tS(eU)}}()}let s0=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],s1=Symbol("modelcontextprotocol.resultCacheHintFallback");function s2(e,t){if(void 0===t)return e;let r=e[s1];if(void 0===r)return{...e,[s1]:t};let i={},n=r.ttlMs??t.ttlMs;void 0!==n&&(i.ttlMs=n);let a=r.cacheScope??t.cacheScope;return void 0!==a&&(i.cacheScope=a),{...e,[s1]:i}}function s9(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function s4(e){return"public"===e||"private"===e}function s5(e,t){if(void 0!==e.ttlMs&&!s9(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&&!s4(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}let s3=((g={})[g.ParseError=-32700]="ParseError",g[g.InvalidRequest=-32600]="InvalidRequest",g[g.MethodNotFound=-32601]="MethodNotFound",g[g.InvalidParams=-32602]="InvalidParams",g[g.InternalError=-32603]="InternalError",g[g.ResourceNotFound=-32002]="ResourceNotFound",g[g.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",g[g.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",g[g.UrlElicitationRequired=-32042]="UrlElicitationRequired",g);var s6=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](e){return sx(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 sx(this,e)}constructor(e,t,r){super(t),this.code=e,this.data=r,this.name="ProtocolError",sk(this,new.target)}static fromError(t,r,i){return t===s3.UrlElicitationRequired&&i&&i.elicitations?new s8(i.elicitations,r):t===s3.UnsupportedProtocolVersion&&i&&Array.isArray(i.supported)&&"string"==typeof i.requested?new le({supported:i.supported,requested:i.requested},r):(t===s3.InvalidParams||t===s3.ResourceNotFound)&&"string"==typeof i?.uri&&(t===s3.ResourceNotFound||1===Object.keys(i).length)?new s7(i.uri,r):t===s3.MissingRequiredClientCapability&&i&&null!==i.requiredCapabilities&&"object"==typeof i.requiredCapabilities&&!Array.isArray(i.requiredCapabilities)?new lt({requiredCapabilities:i.requiredCapabilities},r):new e(t,r,i)}},s7=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(s3.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},s8=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(s3.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},le=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(s3.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},lt=class extends s6{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(s3.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};let lr=["tools/call","prompts/get","resources/read"],li=["elicitation/create","sampling/createMessage","roots/list"];function ln(){if(i)return i;let e=sQ();return i={request:{"elicitation/create":i4({method:ns("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":i4({method:ns("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":i4({method:ns("roots/list"),params:i5({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}}}function la(e){return li.includes(e)}function lo(e){return la(e)?ln().request[e]:void 0}let ls={"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},ll={"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 lc(e){return Object.prototype.hasOwnProperty.call(ls,e)}function ld(e){return Object.prototype.hasOwnProperty.call(ll,e)}function lu(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lp(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(ls),Object.keys(ll);let lm={ok:!1,reason:"not-in-era"},lh=[nE,nq],lf={era:"2026-07-28",hasRequestMethod:lc,hasNotificationMethod:ld,hasInputRequestMethod:e=>void 0!==lo(e),validateRequest:(e,t)=>lp(lc(e)?sQ().dispatchRequestSchemas[e]:void 0,t),validateResult:(e,t)=>lp(Object.prototype.hasOwnProperty.call(ls,e)?sQ().dispatchResultSchemas[e]:void 0,t),validateNotification:(e,t)=>lp(ld(e)?sQ().notificationSchemas2026[e]:void 0,t),validateInputRequest:(e,t)=>lp(lo(e),t),validateInputResponse:(e,t)=>lp(la(e)?ln().response[e]:void 0,t),samplingResultVariant:()=>lm,outboundEnvelope:e=>({[nE]:e.protocolVersion,[nP]:e.clientInfo,[nq]:e.clientCapabilities,...void 0!==e.logLevel&&{[nj]:e.logLevel}}),validateEnvelopeMeta(e){let t=[];for(let r of lh)r in e||t.push({key:r,problem:"missing"});let r=sQ().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=>sj(e),inputRequestSchema:lo,decodeResult(e,t){if(!lu(t))return{kind:"invalid",error:new s$(sC.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(void 0===r)return{kind:"invalid",error:new s$(sC.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 s$(sC.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if("input_required"===r){let r=t.inputRequests,i=lu(r)?r:{},n=t.requestState;return 0===Object.keys(i).length&&"string"!=typeof n?{kind:"invalid",error:new s$(sC.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}}}if("complete"!==r)return{kind:"invalid",error:new s$(sC.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let i=lg(),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 s$(sC.InvalidResult,`Invalid result for ${e}: ${r.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:"complete",result:a}},encodeResult:(e,t,r)=>(function(e,t){if(void 0===t)return e;let r=e._meta;return void 0===r?{...e,_meta:{[nI]:t}}:null===r||"object"!=typeof r||Array.isArray(r)||void 0!==r[nI]?e:{...e,_meta:{...r,[nI]:t}}})(function(e,t){var r,i;let n=t[s1];if("complete"!==t.resultType||!s0.includes(e)){let e;return void 0===n?t:(e={...t},delete e[s1],e)}let a=s9(t.ttlMs)?t.ttlMs:void 0!==(r=n)&&s9(r.ttlMs)?r.ttlMs:0,o=s4(t.cacheScope)?t.cacheScope:void 0!==(i=n)&&s4(i.cacheScope)?i.cacheScope:"private",s={...t,ttlMs:a,cacheScope:o};return delete s[s1],s}(e,function(e,t){let r=t.resultType;if(void 0===r)return{...t,resultType:"complete"};if("complete"===r||lr.includes(e))return t;throw new s6(s3.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),a=t.tools;"tools/list"===e&&Array.isArray(a)&&a.some(e=>lu(e)&&"execution"in e)&&(n().tools=a.map(e=>{if(!lu(e)||!("execution"in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(lu(o)&&"tasks"in o){let e={...o};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=sQ().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 lg(){if(n)return n;let e=sQ();return n={"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 ly="2026-07-28";function lv(e){return void 0!==e&&e>=sI?lf:sX}function l_(e){return void 0!==e.revision?lv(e.revision).era:"modern"===e.era?lf.era:sX.era}function lb(e){return lw.some(t=>t.hasRequestMethod(e))}function lS(e){return lw.some(t=>t.hasNotificationMethod(e))}let lw=[sX,lf];function lR(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lk(e){if(!lR(e))return;let t=e._meta;return lR(t)?t:void 0}function lx(e){let t=lk(e);return void 0!==t&&nE in t}function lC(e){let t=lk(e)?.[nE];return"string"==typeof t?t:void 0}function l$(e){return lv(ly).validateEnvelopeMeta(e)}var lT=((e,t)=>{let r={};for(var i in e)O(r,i,{get:e[i],enumerable:!0});return t&&O(r,Symbol.toStringTag,{value:"Module"}),r})({AnnotationsSchema:()=>ak,AudioContentSchema:()=>a0,BaseMetadataSchema:()=>n7,BaseRequestParamsSchema:()=>nF,BlobResourceContentsSchema:()=>aw,BooleanSchemaSchema:()=>ox,CallToolRequestParamsSchema:()=>oa,CallToolRequestSchema:()=>oo,CallToolResultSchema:()=>oi,CancelTaskRequestSchema:()=>st,CancelTaskResultSchema:()=>sr,CancelledNotificationParamsSchema:()=>n4,CancelledNotificationSchema:()=>n5,ClientCapabilitiesSchema:()=>an,ClientNotificationSchema:()=>sn,ClientRequestSchema:()=>si,ClientResultSchema:()=>sa,ClientTasksCapabilitySchema:()=>ar,CompatibilityCallToolResultSchema:()=>on,CompleteRequestParamsSchema:()=>oJ,CompleteRequestSchema:()=>oB,CompleteResultSchema:()=>oW,ContentBlockSchema:()=>a4,CreateMessageRequestParamsSchema:()=>oS,CreateMessageRequestSchema:()=>ow,CreateMessageResultSchema:()=>oR,CreateMessageResultWithToolsSchema:()=>ok,CreateTaskResultSchema:()=>o2,CursorSchema:()=>nM,DiscoverRequestSchema:()=>ad,DiscoverResultSchema:()=>au,ElicitRequestFormParamsSchema:()=>oN,ElicitRequestParamsSchema:()=>oM,ElicitRequestSchema:()=>oZ,ElicitRequestURLParamsSchema:()=>oA,ElicitResultSchema:()=>oF,ElicitationCompleteNotificationParamsSchema:()=>oU,ElicitationCompleteNotificationSchema:()=>oH,EmbeddedResourceSchema:()=>a2,EmptyResultSchema:()=>n9,EnumSchemaSchema:()=>oz,GetPromptRequestParamsSchema:()=>aK,GetPromptRequestSchema:()=>aY,GetPromptResultSchema:()=>a3,GetTaskPayloadRequestSchema:()=>o6,GetTaskPayloadResultSchema:()=>o7,GetTaskRequestSchema:()=>o5,GetTaskResultSchema:()=>o3,IconSchema:()=>n3,IconsSchema:()=>n6,ImageContentSchema:()=>aQ,ImplementationSchema:()=>n8,InitializeRequestParamsSchema:()=>aa,InitializeRequestSchema:()=>ao,InitializeResultSchema:()=>al,InitializedNotificationSchema:()=>ac,JSONArraySchema:()=>nN,JSONObjectSchema:()=>nL,JSONRPCErrorResponseSchema:()=>n0,JSONRPCMessageSchema:()=>n1,JSONRPCNotificationSchema:()=>nX,JSONRPCRequestSchema:()=>nY,JSONRPCResponseSchema:()=>n2,JSONRPCResultResponseSchema:()=>nQ,JSONValueSchema:()=>nz,LegacyTitledEnumSchemaSchema:()=>oP,ListChangedOptionsBaseSchema:()=>ol,ListPromptsRequestSchema:()=>aW,ListPromptsResultSchema:()=>aG,ListResourceTemplatesRequestSchema:()=>aE,ListResourceTemplatesResultSchema:()=>aP,ListResourcesRequestSchema:()=>a$,ListResourcesResultSchema:()=>aT,ListRootsRequestSchema:()=>oK,ListRootsResultSchema:()=>oY,ListTasksRequestSchema:()=>o8,ListTasksResultSchema:()=>se,ListToolsRequestSchema:()=>ot,ListToolsResultSchema:()=>or,LoggingLevelSchema:()=>oc,LoggingMessageNotificationParamsSchema:()=>op,LoggingMessageNotificationSchema:()=>om,ModelHintSchema:()=>oh,ModelPreferencesSchema:()=>of,MultiSelectEnumSchemaSchema:()=>oj,NotificationSchema:()=>nB,NotificationsParamsSchema:()=>nJ,NumberSchemaSchema:()=>o$,PaginatedRequestParamsSchema:()=>ag,PaginatedRequestSchema:()=>ay,PaginatedResultSchema:()=>av,PingRequestSchema:()=>ap,PrimitiveSchemaDefinitionSchema:()=>oL,ProgressNotificationParamsSchema:()=>ah,ProgressNotificationSchema:()=>af,ProgressSchema:()=>am,ProgressTokenSchema:()=>nA,PromptArgumentSchema:()=>aJ,PromptListChangedNotificationSchema:()=>a6,PromptMessageSchema:()=>a5,PromptReferenceSchema:()=>oD,PromptSchema:()=>aB,ReadResourceRequestParamsSchema:()=>aI,ReadResourceRequestSchema:()=>aq,ReadResourceResultSchema:()=>aO,RelatedTaskMetadataSchema:()=>nU,RequestIdSchema:()=>nK,RequestMetaSchema:()=>nH,RequestSchema:()=>nD,ResourceContentsSchema:()=>a_,ResourceLinkSchema:()=>a9,ResourceListChangedNotificationSchema:()=>aj,ResourceRequestParamsSchema:()=>aI,ResourceSchema:()=>ax,ResourceTemplateReferenceSchema:()=>oV,ResourceTemplateSchema:()=>aC,ResourceUpdatedNotificationParamsSchema:()=>aV,ResourceUpdatedNotificationSchema:()=>aD,ResultMetaObjectSchema:()=>nW,ResultSchema:()=>nG,RoleSchema:()=>aR,RootSchema:()=>oG,RootsListChangedNotificationSchema:()=>oX,SamplingContentSchema:()=>ov,SamplingMessageContentBlockSchema:()=>o_,SamplingMessageSchema:()=>ob,ServerCapabilitiesSchema:()=>as,ServerNotificationSchema:()=>ss,ServerRequestSchema:()=>so,ServerResultSchema:()=>sl,ServerTasksCapabilitySchema:()=>ai,SetLevelRequestParamsSchema:()=>od,SetLevelRequestSchema:()=>ou,SingleSelectEnumSchemaSchema:()=>oI,StringSchemaSchema:()=>oC,SubscribeRequestParamsSchema:()=>aI,SubscribeRequestSchema:()=>az,SubscriptionFilterSchema:()=>aN,SubscriptionsAcknowledgedNotificationParamsSchema:()=>aZ,SubscriptionsAcknowledgedNotificationSchema:()=>aU,SubscriptionsListenRequestParamsSchema:()=>aA,SubscriptionsListenRequestSchema:()=>aM,SubscriptionsListenResultMetaSchema:()=>aH,SubscriptionsListenResultSchema:()=>aF,TaskAugmentedRequestParamsSchema:()=>nV,TaskCreationParamsSchema:()=>oQ,TaskMetadataSchema:()=>nZ,TaskSchema:()=>o1,TaskStatusNotificationParamsSchema:()=>o9,TaskStatusNotificationSchema:()=>o4,TaskStatusSchema:()=>o0,TextContentSchema:()=>aX,TextResourceContentsSchema:()=>ab,TitledMultiSelectEnumSchemaSchema:()=>oO,TitledSingleSelectEnumSchemaSchema:()=>oE,ToolAnnotationsSchema:()=>a7,ToolChoiceSchema:()=>og,ToolExecutionSchema:()=>a8,ToolListChangedNotificationSchema:()=>os,ToolResultContentSchema:()=>oy,ToolSchema:()=>oe,ToolUseContentSchema:()=>a1,UnsubscribeRequestParamsSchema:()=>aI,UnsubscribeRequestSchema:()=>aL,UntitledMultiSelectEnumSchemaSchema:()=>oq,UntitledSingleSelectEnumSchemaSchema:()=>oT});let lE=e=>nY.safeParse(e).success,lP=e=>nX.safeParse(e).success,lI=e=>nQ.safeParse(e).success,lq=e=>n0.safeParse(e).success,lO=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"input_required"===e.resultType,lj="x-mcp-header",lz=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,lL=new Set(["string","integer","boolean","number"]);function lN(e){let t=[],r=new Map,i=(e,n,a)=>{if(null===e||"object"!=typeof e)return;if(lj in e){if(!a||0===n.length)return`${lZ(n)}: 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 i=e[lj];if("string"!=typeof i||0===i.length)return`${lZ(n)}: x-mcp-header MUST be a non-empty string`;if(!lz.test(i))return`${lZ(n)}: x-mcp-header '${i}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let o="string"==typeof e.type?e.type:void 0;if(void 0===o||!lL.has(o))return`${lZ(n)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${o??"<none>"}`;let s=i.toLowerCase(),l=r.get(s);if(void 0!==l)return`x-mcp-header '${i}' is not case-insensitively unique (also declared as '${l}')`;r.set(s,i),t.push({path:n,headerName:i,type:o})}let o=e.properties;if(null!==o&&"object"==typeof o)for(let[e,t]of Object.entries(o)){let r=i(t,[...n,e],a);if(void 0!==r)return r}for(let t of lA){let r=e[t];if(void 0!==r)for(let e of Array.isArray(r)?r:null!==r&&"object"==typeof r&&lM.has(t)?Object.values(r):[r]){let r=i(e,[...n,`<${t}>`],!1);if(void 0!==r)return r}}},n=i(e,[],!0);return void 0===n?{valid:!0,declarations:t}:{valid:!1,reason:n}}let lA=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],lM=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function lZ(e){return 0===e.length?"<root>":e.join(".")}let lU=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,lH=/^-?\d+(\.\d+)?$/;function lF(e){if(!(e.startsWith("=?base64?")&&e.endsWith("?=")))return e;let t=e.slice(9,e.length-2);if(lU.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 lV(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:lD,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}let lD=-32020;s3.InvalidRequest,s3.UnsupportedProtocolVersion,s3.InvalidParams,s3.MethodNotFound,s3.InvalidParams,s3.MissingRequiredClientCapability;let lJ={[s3.ParseError]:400,[s3.InvalidRequest]:400,[s3.MethodNotFound]:404,[s3.UnsupportedProtocolVersion]:400,[s3.MissingRequiredClientCapability]:400,[lD]:400};function lB(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 lW(e,t,r,i="era-classification"){return lB(i,e,400,new s6(lD,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}let lG={"tools/call":"name","prompts/get":"name","resources/read":"uri"};function lK(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 lY(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lX(e){return void 0===e?{era:"modern"}:{era:e>=sI?"modern":"legacy",revision:e}}function lQ(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function l0(e){if(null==e)return!1;let t=typeof e;return("object"===t||"function"===t)&&"~standard"in e&&"function"==typeof e["~standard"]?.validate}let l1=!1,l2="draft-2020-12";function l9(e,t="input"){let r,i=e["~standard"];if(i.jsonSchema)r=i.jsonSchema[t]({target:l2});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().");l1||(l1=!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=r5(e,{target:l2,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){if("properties"in t||"patternProperties"in t||"additionalProperties"in t||"required"in t)return!0;for(let r of["oneOf","anyOf","allOf"]){let i=t[r];if(Array.isArray(i)&&i.length>0)return i.every(t=>null!==t&&"object"==typeof t&&("object"===t.type||e(t)))}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}}async function l4(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 l5=/\\\.\\d\{(\d+)\}/;function l3(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let l6=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function l7(e){return l6.has(e)||e.startsWith("x-")}let l8=new Set(["$schema",...Object.keys(oN.shape.requestedSchema.shape)]),ce={string:lQ([oC,oT,oE,oP]),number:lQ([o$]),integer:lQ([o$]),boolean:lQ([ox]),array:lQ([oq,oO])},ct=new Set(oC.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(!l0(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,a]of Object.entries(e))"properties"===n&&l3(a)?r[n]=Object.fromEntries(Object.entries(a).map(([e,r])=>[e,function(e,t,r,i){if(!l3(e))return e;let n="string"==typeof e.type&&Object.hasOwn(ce,e.type)?ce[e.type]:void 0;if(void 0===n)return e;let a={};for(let[s,l]of Object.entries(e))if(n.has(s)||l7(s))a[s]=l;else if("pattern"===s&&"string"===e.type&&"string"==typeof e.format)if(ct.has(e.format)){var o;"string"==typeof l&&(o=e.format,"zod"!==r||(function(e,t){let r;switch(e){case"email":r=[rf(ik,void 0)];break;case"uri":r=[ry(i$,void 0)];break;case"date":r=[r8()];break;case"date-time":let i,n;i=l5.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=>r6({local:e,offset:t,precision:r}))))}return new Set(r.map(e=>{let t;return t=r5(e,{target:l2,io:"input"}),"string"==typeof t.pattern?t.pattern:void 0}).filter(e=>void 0!==e))})(o,l).has(l))||i.push(`${t}.${s}`)}else a[s]=l;else i.push(`${t}.${s}`);return a}(r,`properties.${e}`,t,i)])):l8.has(n)?r[n]=a:l7(n)||i.push(n);if(i.length>0)throw new s6(s3.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(", ")}`);return r}(function(e){try{return l9(e,"input")}catch(t){let e=t instanceof Error?t.message:String(t);throw new s6(s3.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${e}`)}}(e.requestedSchema),r),n=(t=oN.shape.requestedSchema,io(t,i));if(!n.success)throw new s6(s3.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(e,t){if(!l3(e.properties))return t;let r=Object.entries(e.properties).filter(([,e])=>!io(oL,e).success).map(([e])=>`properties.${e}`);return r.length>0?r.join(", "):t}(i,n.error.message)}`);let a=function e(t,r,i=""){return Array.isArray(t)&&Array.isArray(r)?t.flatMap((t,n)=>e(t,r[n],`${i}[${n}]`)):l3(t)&&l3(r)?Object.entries(t).flatMap(([t,n])=>{let a=i?`${i}.${t}`:t;return Object.prototype.hasOwnProperty.call(r,t)?e(n,r[t],a):l7(t)?[]:[a]}):[]}(i,n.data);if(a.length>0)throw new s6(s3.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${a.join(", ")}`);let o=(n.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(n.data.properties,e));if(o.length>0)throw new s6(s3.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${o.join(", ")}`);return{...e,mode:"form",requestedSchema:n.data}}(e)}}catch(e){throw e instanceof s6?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 cr={},ci={};function cn(e,t){let r=e.slice(0,-6);cr[r]=t,ci[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"])cn(e,lT[e]);for(let[e,t]of Object.entries({IdJagTokenExchangeResponseSchema:sf,OAuthClientInformationFullSchema:sb,OAuthClientInformationSchema:s_,OAuthClientMetadataSchema:sv,OAuthClientRegistrationErrorSchema:sS,OAuthErrorResponseSchema:sg,OAuthMetadataSchema:su,OAuthProtectedResourceMetadataSchema:sd,OAuthTokenRevocationRequestSchema:sw,OAuthTokensSchema:sh,OpenIdProviderDiscoveryMetadataSchema:sm,OpenIdProviderMetadataSchema:sp}))cn(e,t);let ca=Object.freeze(cr);Object.freeze(ci);let co=[nE,nP,nq,nj],cs=["inputResponses","requestState"];function cl(e,t){let r=e.params;if(!cm(r))return{message:e,lifted:{}};let i=r._meta,n=cm(i)?co.filter(e=>e in i):[],a="request"===t?cs.filter(e=>e in r):[];if(0===n.length&&0===a.length)return{message:e,lifted:{}};let o={},s={...r};if(n.length>0&&cm(i)){let e={},t={...i};for(let r of n)e[r]=i[r],delete t[r];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)"inputResponses"===e&&(o.inputResponses=s[e]),"requestState"===e&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function cc(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 cd=(y=void 0,()=>y);function cu(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:()=>t}}}var cp=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{a=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??nT,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 s$(sC.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){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 s$(sC.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),lI(e)||lq(e)?this._onresponse(e):lE(e)?this._onrequest(e,t):lP(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 s$(sC.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}=cl(e,"notification"),i=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return;if(t?.classification!==void 0){let e=l_(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(lS(r.method)&&!i.hasNotificationMethod(r.method))return;let n=this._notificationHandlers.get(r.method),a=this.fallbackNotificationHandler;(void 0!==n||void 0!==a)&&Promise.resolve().then(()=>void 0===n?a(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}=cl(e,"request"),a=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 o=this._transport,s=(e,t,r)=>{let n={jsonrpc:"2.0",id:i.id,error:{code:e,message:t,...void 0!==r&&{data:r}}};o?.send(n).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=l_(t.classification);if(e!==a.era){this._onerror(Error(`Era mismatch on inbound request '${i.method}': classified as ${e} but this instance serves ${a.era}`));let r=t.classification.revision??e;s(s3.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(lb(i.method)&&!a.hasRequestMethod(i.method))return void s(s3.MethodNotFound,"Method not found");let l=this._requestHandlers.get(i.method)??this.fallbackRequestHandler;if(void 0===l)return void s(s3.MethodNotFound,"Method not found");let c=a.checkInboundEnvelope(n);if(void 0!==c)return void s(s3.InvalidParams,c);let d=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:i.id}),u=(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(!ch(e))return{accepted:t,droppedKeys:r};for(let[i,n]of Object.entries(e)){if(!ch(n)||"method"in n||"result"in n){r.push(i);continue}t[i]=n}return{accepted:t,droppedKeys:r}}(n.inputResponses),h={sessionId:o?.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?cd:(r=n.requestState,()=>r),signal:p.signal,send:(e,t,r)=>{let i=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(i,e.method),l0(t))return u(e,t,r);let n=cc(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 u(e,n,t)},notify:d},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=a.encodeResult(i.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${i.method}: ${e}`)),s(s3.InternalError,"Internal error");return}let r={result:t,jsonrpc:"2.0",id:i.id};await o?.send(r)},async e=>{if(p.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:s3.InternalError,r={jsonrpc:"2.0",id:i.id,error:{code:a.encodeErrorCode(t),message:e.message??"Internal error",...void 0!==e.data&&{data:e.data}}};await o?.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 a=this._responseHandlers.get(i),o=this._timeoutInfo.get(i);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(e){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),a(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(lI(e)?e:s6.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(this._assertOutboundRequestInEra(i,e.method),l0(t))return this._requestWithSchemaViaCodec(i,e,t,r);let n=cc(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 lv(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 lv(void 0);case"server/discover":return lv(ly);default:return}}(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(lb(t)&&!e.hasRequestMethod(t))throw new s$(sC.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,a,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:l,headers:c}=i??{},d=Date.now();return new Promise((u,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 s$?e:new s$(sC.RequestTimeout,String(e))}let h=e.era===ly&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,f=this._requestMessageId++;a=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?this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(e)}}),{relatedRequestId:o,resumptionToken:s,onresumptiontoken:l}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):h.abort(),p(e instanceof s$?e:new s$(sC.RequestTimeout,String(e))))};this._responseHandlers.set(f,n=>{let a;if(!i?.signal?.aborted){if(v=!0,n instanceof Error)return p(n);try{a=e.decodeResult(t.method,n.result)}catch(e){return p(e instanceof Error?e:Error(String(e)))}if("invalid"===a.kind)return p(a.error);if("input_required"===a.kind){var o;return i?.allowInputRequired===!0?u({resultType:"input_required",inputRequests:(o=a).inputRequests,...void 0!==o.requestState&&{requestState:o.requestState}}):u(this._resolveNonCompleteResult(a,{codec:e,request:t,resultSchema:r,options:i,flowStartedAt:d,retry:(i,n)=>this._requestWithSchemaViaCodec(e,void 0===i?{method:t.method}:{method:t.method,params:i},r,n)}))}l4(r,a.result).then(e=>{e.success?u(e.data):p(new s$(sC.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 s$(sC.RequestTimeout,"Request timed out",{timeout:b})),i?.resetTimeoutOnProgress??!1),this._transport.send(y,{relatedRequestId:o,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!==a&&(this._responseHandlers.delete(a),this._cleanupTimeout(a))})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new s$(sC.NotConnected,"Not connected");if(lS(t.method)&&!e.hasNotificationMethod(t.method))throw new s$(sC.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){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(!lb(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(),a=n.validateRequest(e,r);if(a.ok||"not-in-era"!==a.reason||(a=n.validateInputRequest(e,r)),!a.ok){if("not-in-era"===a.reason)throw new s6(s3.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(a.message)}return Promise.resolve(t(a.value,i))}}else if(r)i=async(i,n)=>{let a=await l4(t.params,{...i.params});if(!a.success)throw new s6(s3.InvalidParams,`Invalid params for ${e}: ${a.error}`);return r(a.data,n)};else throw TypeError("setRequestHandler: handler is required");this._requestHandlers.set(e,this._wrapHandler(e,i))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.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(!lS(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 s6(s3.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 l4(t.params,{...i.params});if(!n.success)throw new s6(s3.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,i)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function cm(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function ch(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var cf=((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var n,a=z(t),o=0,s=a.length;o<s;o++)n=a[o],N.call(e,n)||n===r||O(e,n,{get:(e=>t[e]).bind(null,n),enumerable:!(i=j(t,n))||i.enumerable});return e})(O(null!=(p=(d=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 a,o,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(";"),d=-1!==c?l.slice(0,c).trim():l.trim();if(!i.test(d))throw TypeError("invalid media type");var u=new n(d.toLowerCase());if(-1!==c){for(t.lastIndex=c;o=t.exec(l);){if(o.index!==c)throw TypeError("invalid parameter format");c+=o[0].length,a=o[1].toLowerCase(),34===(s=o[2]).charCodeAt(0)&&-1!==(s=s.slice(1,-1)).indexOf("\\")&&(s=s.replace(r,"$1")),u.parameters[a]=s}if(c!==l.length)throw TypeError("invalid parameter format")}return u}},()=>(u||d((u={exports:{}}).exports,u),u.exports))())?q(L(p)):{},"default",{value:p,enumerable:!0}),p);function cg(e){if(e)try{return cf.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();if(""===t||e.slice(t.length).includes(","))return;return t}}function cy(e){return"application/json"===e||"application/json"===cg(e)}let cv=/^[A-Za-z0-9._-]{1,128}$/;function c_(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"),!cv.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 cb=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,a=0;for(;n<t.length;)if("{"===t[n]){i&&(r.push(i),i="");let o=t.indexOf("}",n);if(-1===o)throw Error("Unclosed template expression");if(++a>1e4)throw Error("Template contains too many expressions (max 10000)");let s=t.slice(n+1,o),l=this.getOperator(s),c=s.includes("*"),d=this.getNames(s),u=d[0];for(let t of d)e.validateLength(t,1e6,"Variable name");r.push({name:u,operator:l,names:d,exploded:c}),n=o+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),a=t.match(n);if(!a)return null;let o={};for(let[e,t]of i.entries()){let{name:r,exploded:i}=t,n=a[e+1];o[r.replace("*","")]=i&&n.includes(",")?n.split(","):n}return o}};function cS(e){if(void 0!==e){if(function(e){if("object"!=typeof e||null===e||l0(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 i4(e);if("object"==typeof e&&null!==e&&!l0(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(!l0(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 cw(){sN(),sQ(),sD(),ln(),lg()}function cR(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(!cR(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(!cR(e[i],t[i]))return!1;return!0}return e===t}function ck(e){return encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1"))}let cx={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},cC={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},c$={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},cT="undefined"!=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 cE(e,t=Object.create(null),r=cT,i=""){if(e&&"object"==typeof e&&!Array.isArray(e)){let n=e.$id||e.id;if(n){let a=new URL(n,r.href);a.hash.length>1?t[a.href]=e:(a.hash="",""===i?r=a:cE(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(c$[n])continue;let a=`${i}/${ck(n)}`,o=e[n];if(Array.isArray(o)){if(cx[n]){let e=o.length;for(let i=0;i<e;i++)cE(o[i],t,r,`${a}/${i}`)}}else if(cC[n])for(let e in o)cE(o[e],t,r,`${a}/${ck(e)}`);else cE(o,t,r,a)}return t}let cP=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,cI=[0,31,28,31,30,31,30,31,31,30,31,30,31],cq=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function cO(e){return e.test.bind(e)}let cj={date:cz,time:cL.bind(void 0,!1),"date-time":function(e){let t=e.split(cN);return 2==t.length&&cz(t[0])&&cL(!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 cA.test(e)&&cM.test(e)},"uri-reference":cO(/^(?:[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":cO(/^(?:(?:[^\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:cO(/^(?:(?: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:cO(/^(?=.{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:cO(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:cO(/^((([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(cZ.test(e))return!1;try{return RegExp(e,"u"),!0}catch(e){return!1}},uuid:cO(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":cO(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":cO(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":cO(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function cz(e){var t;let r=e.match(cP);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3];return n>=1&&n<=12&&a>=1&&a<=(2==n&&(t=i)%4==0&&(t%100!=0||t%400==0)?29:cI[n])}function cL(e,t){let r=t.match(cq);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3],o=!!r[5];return(i<=23&&n<=59&&a<=59||23==i&&59==n&&60==a)&&(!e||o)}let cN=/t|\s/i,cA=/\/|:/,cM=/^(?:[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,cZ=/[^\\]\\Z/;var cU=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",r=!0){this.schema=e,this.draft=t,this.shortCircuit=r,this.lookup=cE(e)}validate(e){return function e(t,r,i="2019-09",n=cE(r),a=!0,o=null,s="#",l="#",c=Object.create(null)){let d;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 u=typeof t;switch(u){case"boolean":case"number":case"string":d=u;break;case"object":d=null===t?"null":Array.isArray(t)?"array":"object";break;default:throw Error(`Instances of "${u}" 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:E,unevaluatedProperties:P,minProperties:I,maxProperties:q,propertyNames:O,dependentRequired:j,dependentSchemas:z,dependencies:L,prefixItems:N,items:A,additionalItems:M,unevaluatedItems:Z,contains:U,minContains:H,maxContains:F,minItems:V,maxItems:D,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===o&&(o=r),"#"===m){let d=null===o?n[er]:o,u=`${l}/$recursiveRef`,p=e(t,null===o?r:o,i,n,a,d,s,u,c);p.valid||ei.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:u,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+=`
|
|
63
63
|
Known schemas:
|
|
64
|
-
- ${Object.keys(n).join("\n- ")}`)}let d=`${l}/$ref`,u=e(t,r,i,n,a,o,s,d,c);if(u.valid||ei.push({instanceLocation:s,keyword:"$ref",keywordLocation:d,error:"A subschema had errors."},...u.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(d===f[i]||"integer"===f[i]&&"number"===d&&t%1==0&&t==t){r=!0;break}r||ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${f.join('", "')}".`})}else"integer"===f?("number"!==d||t%1||t!=t)&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`}):void 0!==f&&d!==f&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`});if(void 0!==g&&("object"===d||"array"===d?cw(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"===d||"array"===d?y.some(e=>cw(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,a,o,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`,d=ei.length,u=!1;for(let l=0;l<b.length;l++){let d=b[l],p=Object.create(c),m=e(t,d,i,n,a,!0===h?o:null,s,`${r}/${l}`,p);ei.push(...m.errors),u=u||m.valid,m.valid&&en.push(p)}u?ei.length=d:ei.splice(d,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:r,error:"Instance does not match any subschemas."})}if(void 0!==S){let r=`${l}/allOf`,d=ei.length,u=!0;for(let l=0;l<S.length;l++){let d=S[l],p=Object.create(c),m=e(t,d,i,n,a,!0===h?o:null,s,`${r}/${l}`,p);ei.push(...m.errors),u=u&&m.valid,m.valid&&en.push(p)}u?ei.length=d:ei.splice(d,0,{instanceLocation:s,keyword:"allOf",keywordLocation:r,error:"Instance does not match every subschema."})}if(void 0!==w){let r=`${l}/oneOf`,d=ei.length,u=w.filter((l,d)=>{let u=Object.create(c),p=e(t,l,i,n,a,!0===h?o:null,s,`${r}/${d}`,u);return ei.push(...p.errors),p.valid&&en.push(u),p.valid}).length;1===u?ei.length=d:ei.splice(d,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:r,error:`Instance does not match exactly one subschema (${u} matches).`})}if(("object"===d||"array"===d)&&Object.assign(c,...en),void 0!==k){let r=`${l}/if`;if(e(t,k,i,n,a,o,s,r,c).valid){if(void 0!==R){let d=e(t,R,i,n,a,o,s,`${l}/then`,c);d.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "then" schema.'},...d.errors)}}else if(void 0!==x){let d=e(t,x,i,n,a,o,s,`${l}/else`,c);d.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "else" schema.'},...d.errors)}}if("object"===d){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!==I&&r.length<I&&ei.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${I} properties.`}),void 0!==q&&r.length>q&&ei.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${q} properties.`}),void 0!==O){let r=`${l}/propertyNames`;for(let l in t){let t=`${s}/${ck(l)}`,c=e(l,O,i,n,a,o,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!==z)for(let r in z){let d=`${l}/dependentSchemas`;if(r in t){let l=e(t,z[r],i,n,a,o,s,`${d}/${ck(r)}`,c);l.valid||ei.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:d,error:`Instance has "${r}" but does not match dependant schema.`},...l.errors)}}if(void 0!==L){let r=`${l}/dependencies`;for(let l in L)if(l in t){let c=L[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 d=e(t,c,i,n,a,o,s,`${r}/${ck(l)}`);d.valid||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not match dependant schema.`},...d.errors)}}}let d=Object.create(null),u=!1;if(void 0!==$){let r=`${l}/properties`;for(let l in $){if(!(l in t))continue;let p=`${s}/${ck(l)}`,m=e(t[l],$[l],i,n,a,o,p,`${r}/${ck(l)}`);if(m.valid)c[l]=d[l]=!0;else if(u=a,ei.push({instanceLocation:s,keyword:"properties",keywordLocation:r,error:`Property "${l}" does not match schema.`},...m.errors),u)break}}if(!u&&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}/${ck(h)}`,g=e(t[h],m,i,n,a,o,f,`${r}/${ck(l)}`);g.valid?c[h]=d[h]=!0:(u=a,ei.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:r,error:`Property "${h}" matches pattern "${l}" but does not match associated schema.`},...g.errors))}}}if(u||void 0===E){if(!u&&void 0!==P){let r=`${l}/unevaluatedProperties`;for(let l in t)if(!c[l]){let d=`${s}/${ck(l)}`,u=e(t[l],P,i,n,a,o,d,r);u.valid?c[l]=!0:ei.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:r,error:`Property "${l}" does not match unevaluated properties schema.`},...u.errors)}}}else{let r=`${l}/additionalProperties`;for(let l in t){if(d[l])continue;let p=`${s}/${ck(l)}`,m=e(t[l],E,i,n,a,o,p,r);m.valid?c[l]=!0:(u=a,ei.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:r,error:`Property "${l}" does not match additional properties schema.`},...m.errors))}}}else if("array"===d){void 0!==D&&t.length>D&&ei.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${t.length} > ${D}).`}),void 0!==V&&t.length<V&&ei.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${t.length} < ${V}).`});let r=t.length,d=0,u=!1;if(void 0!==N){let p=`${l}/prefixItems`,m=Math.min(N.length,r);for(;d<m;d++){let r=e(t[d],N[d],i,n,a,o,`${s}/${d}`,`${p}/${d}`);if(c[d]=!0,!r.valid&&(u=a,ei.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:p,error:"Items did not match schema."},...r.errors),u))break}}if(void 0!==A){let p=`${l}/items`;if(Array.isArray(A)){let l=Math.min(A.length,r);for(;d<l;d++){let r=e(t[d],A[d],i,n,a,o,`${s}/${d}`,`${p}/${d}`);if(c[d]=!0,!r.valid&&(u=a,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),u))break}}else for(;d<r;d++){let r=e(t[d],A,i,n,a,o,`${s}/${d}`,p);if(c[d]=!0,!r.valid&&(u=a,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),u))break}if(!u&&void 0!==M){let p=`${l}/additionalItems`;for(;d<r;d++){let r=e(t[d],M,i,n,a,o,`${s}/${d}`,p);c[d]=!0,r.valid||(u=a,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===H)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!==H&&r<H)ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${r}) than minContains (${H}).`});else{let d=`${l}/contains`,u=ei.length,p=0;for(let l=0;l<r;l++){let r=e(t[l],U,i,n,a,o,`${s}/${l}`,d);r.valid?(c[l]=!0,p++):ei.push(...r.errors)}p>=(H||0)&&(ei.length=u),void 0===H&&void 0===F&&0===p?ei.splice(u,0,{instanceLocation:s,keyword:"contains",keywordLocation:d,error:"Array does not contain item matching schema."}):void 0!==H&&p<H?ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${H} items matching schema. Only ${p} items were found.`}):void 0!==F&&p>F&&ei.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${F} items matching schema. ${p} items were found.`})}if(!u&&void 0!==Z){let u=`${l}/unevaluatedItems`;for(;d<r;d++){if(c[d])continue;let r=e(t[d],Z,i,n,a,o,`${s}/${d}`,u);c[d]=!0,r.valid||ei.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:u,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 a=0;a<r;a++){if(e===a)continue;let r=t[a];(i===r||n&&"object"==typeof r&&null!==r&&cw(i,r))&&(ei.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${e} and ${a}.`}),e=Number.MAX_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER)}}}else if("number"===d){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"===d){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&&cO[C]&&!cO[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}),cT(e,this.lookup)}},cU=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(A.has(r))return"2020-12";if(M.has(r))return"2019-09";if(Z.has(r)||U.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 cZ(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("; ")}}}};cS();let cH=Symbol.for("mcp.completable");function cF(e){return!!e&&"object"==typeof e&&cH in e}let cV=0x80000000-1;function cD(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,cV));return r.unref?.(),r}var cJ=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 cB(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function cW(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[nO]:t}}}}function cG(e,t,r){if(null===r||"object"!=typeof r||"string"!=typeof r.method)throw new s6(s3.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 s6(s3.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 cK(e,t){if("tools/call"===e)return{content:[{type:"text",text:t}],isError:!0};throw new s6(s3.InternalError,t)}var cY=class{constructor(e){this._host=e}async fulfill(e,t,r,i,n){let{maxRounds:a,roundTimeoutMs:o}=this._host,s=i.mcpReq.signal,l=n,c=0;for(;;){let n;if((c+=1)>a)return cK(e,`Multi-round-trip request '${e}' still required input after ${a} rounds (inputRequired.maxRounds)`);let d=l.inputRequests,u=null!=d&&Object.keys(d).length>0,p="string"==typeof l.requestState?l.requestState:void 0;if(!u&&void 0===p)throw new s6(s3.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(u){let t=this._host.resolvedClientCapabilities(i),r=[];for(let[i,n]of Object.entries(d)){let{embedded:a,required:o}=cG(e,i,n);if("roots/list"!==a.method&&void 0===a.params)throw new s6(s3.InternalError,`Handler for ${e} returned an input request '${i}' of kind '${a.method}' without params`);if(void 0!==sP(o,t))return cK(e,`Cannot request input '${i}' (${a.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,a])}let a=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:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:a.signal},t=await Promise.all(r.map(async([t,r])=>{try{return[t,await this._dispatchLeg(r,e)]}catch(e){throw a.abort(e),e}}));n=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return cK(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{a.dispose()}}else await function(e,t){return new Promise((e,r)=>{if(t?.aborted)return void r(t.reason instanceof s$?t.reason:new s$(sC.RequestTimeout,String(t.reason)));let i=setTimeout(()=>{t?.removeEventListener("abort",n),e()},250),n=()=>{clearTimeout(i),r(t?.reason instanceof s$?t.reason:new s$(sC.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",n,{once:!0})})}(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=cd(m,t))}let h=await t(r,m);if(!lO(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 cX=new Set(["tools/call","prompts/get","resources/read"]);var cQ=class extends cu{_clientCapabilities;_clientVersion;static{o=(e,t)=>{void 0!==t.clientCapabilities&&(e._clientCapabilities=t.clientCapabilities),void 0!==t.clientInfo&&(e._clientVersion=t.clientInfo)},s=(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())},l=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_legacyInputRequiredShim(){return this._legacyShim??=new cY({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 cU,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&&s5(r,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",e=>this._oninitialize(e)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),sO(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}_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=io(oc,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?.[nj]))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(oc.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 s$(sC.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]=cp(n)&&cp(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=cX.has(e);return void 0!==r||i?async(n,a)=>{let o=i?await this._invokeInputRequiredCapableHandler(e,t,n,a):await t(n,a);if(lO(o)){if(!i)throw new s6(s3.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 o}return void 0===r?o:s2(o,r)}:async(r,i)=>{let n=await t(r,i);if(lO(n))throw new s6(s3.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=lv(this._negotiatedProtocolVersion),n=i.validateRequest("tools/call",e);if(!n.ok)throw new s6("not-in-era"===n.reason?s3.InternalError:s3.InvalidParams,"not-in-era"===n.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${n.message}`);let a=await this._invokeInputRequiredCapableHandler("tools/call",t,e,r);if(lO(a))return a;let o=sL(a),s=i.validateResult("tools/call",o);if(!s.ok)throw new s6("not-in-era"===s.reason?s3.InternalError:s3.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>=sI}async _invokeInputRequiredCapableHandler(e,t,r,i){let n,a=this._servedModernEra(),o=i.mcpReq.requestState();if(void 0!==o&&"string"!=typeof o)throw new s6(s3.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let s=i;if("string"==typeof o){let t=await this._verifyRequestState(o,i,e);void 0!==t&&(s=cd(i,t))}try{n=await t(r,s)}catch(e){if(e instanceof s6&&e.code===s3.UrlElicitationRequired){if(!a)throw e;throw new s6(s3.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(!lO(n))return n;if(!a){if(!this._inputRequiredServing.legacyShim)throw new s6(s3.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??n$}, 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,d="string"==typeof n.requestState;if(!c&&!d)throw new s6(s3.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:a}=cG(e,r,i),o=sP(a,t);if(void 0!==o)throw new lt({requiredCapabilities:o},`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 s6(s3.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[nq]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new s$(sC.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 s$(sC.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new s$(sC.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new s$(sC.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new s$(sC.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 s$(sC.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new s$(sC.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 s$(sC.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 s$(sC.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new s$(sC.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new s$(sC.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new s$(sC.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 s$(sC.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new s$(sC.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>=sI)),i=r.includes(t)?t:r[0]??n$;return this._negotiatedProtocolVersion=i,this.transport?.setProtocolVersion?.(i),{protocolVersion:i,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:sO(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 s$(sC.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,a=n?Array.isArray(n.content)?n.content:[n.content]:[],o=a.some(e=>"tool_use"===e.type);if(i){if(r.some(e=>"tool_result"!==e.type))throw new s6(s3.InvalidParams,"The last message must contain only tool_result content if any is present");if(!o)throw new s6(s3.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(o){let e=new Set(a.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 s6(s3.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 s$(sC.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 s$(sC.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new s$(sC.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 s6(s3.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof s6)throw e;throw new s6(s3.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return i}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new s$(sC.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"})}},c0=class{server;_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 c9;try{let r=l9(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new cQ(e,t),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}_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])=>{let r={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?l9(t.inputSchema,"input"):c9,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(r.outputSchema=l9(t.outputSchema,"output")),r})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new s6(s3.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new s6(s3.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),lO(n))return n;return this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(e){if(e instanceof s6&&e.code===s3.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(!e.inputSchema)return;let i=await l4(e.inputSchema,t??{});if(!i.success)throw new s6(s3.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${i.error}`);return i.data}async validateToolOutput(e,t,r){if(!e.outputSchema||lO(t)||t.isError)return;if(void 0===t.structuredContent)throw new s6(s3.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let i=await l4(e.outputSchema,t.structuredContent);if(!i.success)throw new s6(s3.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 s6(s3.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let r=this._registeredPrompts[t.name];if(!r)throw new s6(s3.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new s6(s3.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return c6;let i=c8(c7(r.argsSchema)?.[e.params.argument.name]);if(!cF(i))return c6;let n=i[cH]?.complete;return n?c3(await n(e.params.argument.value,e.params.context)):c6}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 c6;throw new s6(s3.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let i=r.resourceTemplate.completeCallback(e.params.argument.name);return i?c3(await i(e.params.argument.value,e.params.context)):c6}_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 s6(s3.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 s6(s3.InvalidParams,`Resource ${r} disabled`);return s2(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)return s2(await e.readCallback(r,i,t),e.cacheHint)}throw new s7(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=l9(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 s6(s3.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new s6(s3.InvalidParams,`Prompt ${e.params.name} disabled`);return r.handler(e.params.arguments,t)}),this._promptHandlersInitialized=!0)}registerResource(e,t,r,i){let n=r.cacheHint,a=r;if(void 0!==n){s5(n,`resource ${e}`);let t={...r};delete t.cacheHint,a=t}if("string"==typeof t){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let o=this._createRegisteredResource(e,r.title,t,a,i);return void 0!==n&&(o.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,r.title,t,a,i);return void 0!==n&&(o.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,t,r,i,n){let a={name:e,title:t,metadata:i,readCallback: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.title&&(a.title=e.title),void 0!==e.metadata&&(a.metadata=e.metadata),void 0!==e.callback&&(a.readCallback=e.callback),void 0!==e.enabled&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=a,a}_createRegisteredResourceTemplate(e,t,r,i,n){let a={resourceTemplate:r,title:t,metadata:i,readCallback: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.title&&(a.title=t.title),void 0!==t.template&&(a.resourceTemplate=t.template),void 0!==t.metadata&&(a.metadata=t.metadata),void 0!==t.callback&&(a.readCallback=t.callback),void 0!==t.enabled&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=r.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,r,i,n,a,o){let s=i,l=n,c={title:t,description:r,argsSchema:i,icons:a,_meta:o,handler:c5(e,i,n),enabled:!0,disable:()=>c.update({enabled:!1}),enable:()=>c.update({enabled:!0}),remove:()=>c.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=c)),void 0!==t.title&&(c.title=t.title),void 0!==t.description&&(c.description=t.description),void 0!==t.icons&&(c.icons=t.icons),void 0!==t._meta&&(c._meta=t._meta);let r=!1;void 0!==t.argsSchema&&(c.argsSchema=t.argsSchema,s=t.argsSchema,r=!0),void 0!==t.callback&&(l=t.callback,r=!0),r&&(c.handler=c5(e,s,l)),void 0!==t.enabled&&(c.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=c,i){let e=c7(i);e&&Object.values(e).some(e=>cF(c8(e)))&&this.setCompletionRequestHandler()}return c}_createRegisteredTool(e,t,r,i,n,a,o,s,l,c){if(cv(e),void 0!==i)try{let t=l9(i,"input");this._toolInputSchemaJson[e]=t;let r=lN(t);r.valid||console.warn(`[mcp-sdk] tool '${e}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${r.reason}`)}catch{}let d=c,u={title:t,description:r,inputSchema:i,outputSchema:n,outputSchemaJson:c4(n),annotations:a,icons:o,execution:s,_meta:l,handler:c,executor:c2(i,c),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&&("string"==typeof t.name&&cv(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=u,e=t.name)),void 0!==t.title&&(u.title=t.title),void 0!==t.description&&(u.description=t.description);let r=!1;void 0!==t.paramsSchema&&(u.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],r=!0),void 0!==t.callback&&(u.handler=t.callback,d=t.callback,r=!0),r&&(u.executor=c2(u.inputSchema,d)),void 0!==t.outputSchema&&(u.outputSchema=t.outputSchema,u.outputSchemaJson=c4(t.outputSchema)),void 0!==t.annotations&&(u.annotations=t.annotations),void 0!==t.icons&&(u.icons=t.icons),void 0!==t._meta&&(u._meta=t._meta),void 0!==t.enabled&&(u.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}registerTool(e,t,r){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:i,description:n,inputSchema:a,outputSchema:o,annotations:s,icons:l,_meta:c}=t;return this._createRegisteredTool(e,i,n,cb(a),cb(o),s,l,void 0,c,r)}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:i,description:n,argsSchema:a,icons:o,_meta:s}=t,l=this._createRegisteredPrompt(e,i,n,cb(a),r,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),l}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()}},c1=class{_uriTemplate;constructor(e,t){this._callbacks=t,this._uriTemplate="string"==typeof e?new c_(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}};function c2(e,t){return e?async(e,r)=>t(e,r):async(e,r)=>t(r)}let c9={type:"object",properties:{}};function c4(e){if(void 0!==e)try{return l9(e,"output")}catch{return}}function c5(e,t,r){return t?async(i,n)=>{let a=await l4(t,i);if(!a.success)throw new s6(s3.InvalidParams,`Invalid arguments for prompt ${e}: ${a.error}`);return r(a.data,n)}:async(e,t)=>r(t)}function c3(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}let c6={completion:{values:[],hasMore:!1}};function c7(e){if(e.shape&&"object"==typeof e.shape)return e.shape}function c8(e){return e?.type!=="optional"?e:e.def?.innerType??e}var de=class{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 s$(sC.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(lE(e)){let t,n;this._requestId=e.id;let a=new Promise((e,r)=>{t=e,n=r});if(this._deferredResponse={promise:a,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(),a}return this.onmessage(e,i),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let r=lI(e)||lq(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=lq(e)?e.error.code:void 0,r=void 0!==t&&(this._dispatchWindowOpen||t===s3.MissingRequiredClientCapability)?lJ[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}
|
|
64
|
+
- ${Object.keys(n).join("\n- ")}`)}let d=`${l}/$ref`,u=e(t,r,i,n,a,o,s,d,c);if(u.valid||ei.push({instanceLocation:s,keyword:"$ref",keywordLocation:d,error:"A subschema had errors."},...u.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(d===f[i]||"integer"===f[i]&&"number"===d&&t%1==0&&t==t){r=!0;break}r||ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${f.join('", "')}".`})}else"integer"===f?("number"!==d||t%1||t!=t)&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`}):void 0!==f&&d!==f&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`});if(void 0!==g&&("object"===d||"array"===d?cR(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"===d||"array"===d?y.some(e=>cR(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,a,o,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`,d=ei.length,u=!1;for(let l=0;l<b.length;l++){let d=b[l],p=Object.create(c),m=e(t,d,i,n,a,!0===h?o:null,s,`${r}/${l}`,p);ei.push(...m.errors),u=u||m.valid,m.valid&&en.push(p)}u?ei.length=d:ei.splice(d,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:r,error:"Instance does not match any subschemas."})}if(void 0!==S){let r=`${l}/allOf`,d=ei.length,u=!0;for(let l=0;l<S.length;l++){let d=S[l],p=Object.create(c),m=e(t,d,i,n,a,!0===h?o:null,s,`${r}/${l}`,p);ei.push(...m.errors),u=u&&m.valid,m.valid&&en.push(p)}u?ei.length=d:ei.splice(d,0,{instanceLocation:s,keyword:"allOf",keywordLocation:r,error:"Instance does not match every subschema."})}if(void 0!==w){let r=`${l}/oneOf`,d=ei.length,u=w.filter((l,d)=>{let u=Object.create(c),p=e(t,l,i,n,a,!0===h?o:null,s,`${r}/${d}`,u);return ei.push(...p.errors),p.valid&&en.push(u),p.valid}).length;1===u?ei.length=d:ei.splice(d,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:r,error:`Instance does not match exactly one subschema (${u} matches).`})}if(("object"===d||"array"===d)&&Object.assign(c,...en),void 0!==R){let r=`${l}/if`;if(e(t,R,i,n,a,o,s,r,c).valid){if(void 0!==k){let d=e(t,k,i,n,a,o,s,`${l}/then`,c);d.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "then" schema.'},...d.errors)}}else if(void 0!==x){let d=e(t,x,i,n,a,o,s,`${l}/else`,c);d.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "else" schema.'},...d.errors)}}if("object"===d){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!==I&&r.length<I&&ei.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${I} properties.`}),void 0!==q&&r.length>q&&ei.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${q} properties.`}),void 0!==O){let r=`${l}/propertyNames`;for(let l in t){let t=`${s}/${ck(l)}`,c=e(l,O,i,n,a,o,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!==z)for(let r in z){let d=`${l}/dependentSchemas`;if(r in t){let l=e(t,z[r],i,n,a,o,s,`${d}/${ck(r)}`,c);l.valid||ei.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:d,error:`Instance has "${r}" but does not match dependant schema.`},...l.errors)}}if(void 0!==L){let r=`${l}/dependencies`;for(let l in L)if(l in t){let c=L[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 d=e(t,c,i,n,a,o,s,`${r}/${ck(l)}`);d.valid||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not match dependant schema.`},...d.errors)}}}let d=Object.create(null),u=!1;if(void 0!==$){let r=`${l}/properties`;for(let l in $){if(!(l in t))continue;let p=`${s}/${ck(l)}`,m=e(t[l],$[l],i,n,a,o,p,`${r}/${ck(l)}`);if(m.valid)c[l]=d[l]=!0;else if(u=a,ei.push({instanceLocation:s,keyword:"properties",keywordLocation:r,error:`Property "${l}" does not match schema.`},...m.errors),u)break}}if(!u&&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}/${ck(h)}`,g=e(t[h],m,i,n,a,o,f,`${r}/${ck(l)}`);g.valid?c[h]=d[h]=!0:(u=a,ei.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:r,error:`Property "${h}" matches pattern "${l}" but does not match associated schema.`},...g.errors))}}}if(u||void 0===E){if(!u&&void 0!==P){let r=`${l}/unevaluatedProperties`;for(let l in t)if(!c[l]){let d=`${s}/${ck(l)}`,u=e(t[l],P,i,n,a,o,d,r);u.valid?c[l]=!0:ei.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:r,error:`Property "${l}" does not match unevaluated properties schema.`},...u.errors)}}}else{let r=`${l}/additionalProperties`;for(let l in t){if(d[l])continue;let p=`${s}/${ck(l)}`,m=e(t[l],E,i,n,a,o,p,r);m.valid?c[l]=!0:(u=a,ei.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:r,error:`Property "${l}" does not match additional properties schema.`},...m.errors))}}}else if("array"===d){void 0!==D&&t.length>D&&ei.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${t.length} > ${D}).`}),void 0!==V&&t.length<V&&ei.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${t.length} < ${V}).`});let r=t.length,d=0,u=!1;if(void 0!==N){let p=`${l}/prefixItems`,m=Math.min(N.length,r);for(;d<m;d++){let r=e(t[d],N[d],i,n,a,o,`${s}/${d}`,`${p}/${d}`);if(c[d]=!0,!r.valid&&(u=a,ei.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:p,error:"Items did not match schema."},...r.errors),u))break}}if(void 0!==A){let p=`${l}/items`;if(Array.isArray(A)){let l=Math.min(A.length,r);for(;d<l;d++){let r=e(t[d],A[d],i,n,a,o,`${s}/${d}`,`${p}/${d}`);if(c[d]=!0,!r.valid&&(u=a,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),u))break}}else for(;d<r;d++){let r=e(t[d],A,i,n,a,o,`${s}/${d}`,p);if(c[d]=!0,!r.valid&&(u=a,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),u))break}if(!u&&void 0!==M){let p=`${l}/additionalItems`;for(;d<r;d++){let r=e(t[d],M,i,n,a,o,`${s}/${d}`,p);c[d]=!0,r.valid||(u=a,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===H)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!==H&&r<H)ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${r}) than minContains (${H}).`});else{let d=`${l}/contains`,u=ei.length,p=0;for(let l=0;l<r;l++){let r=e(t[l],U,i,n,a,o,`${s}/${l}`,d);r.valid?(c[l]=!0,p++):ei.push(...r.errors)}p>=(H||0)&&(ei.length=u),void 0===H&&void 0===F&&0===p?ei.splice(u,0,{instanceLocation:s,keyword:"contains",keywordLocation:d,error:"Array does not contain item matching schema."}):void 0!==H&&p<H?ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${H} items matching schema. Only ${p} items were found.`}):void 0!==F&&p>F&&ei.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${F} items matching schema. ${p} items were found.`})}if(!u&&void 0!==Z){let u=`${l}/unevaluatedItems`;for(;d<r;d++){if(c[d])continue;let r=e(t[d],Z,i,n,a,o,`${s}/${d}`,u);c[d]=!0,r.valid||ei.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:u,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 a=0;a<r;a++){if(e===a)continue;let r=t[a];(i===r||n&&"object"==typeof r&&null!==r&&cR(i,r))&&(ei.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${e} and ${a}.`}),e=Number.MAX_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER)}}}else if("number"===d){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"===d){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&&cj[C]&&!cj[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}),cE(e,this.lookup)}},cH=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(A.has(r))return"2020-12";if(M.has(r))return"2019-09";if(Z.has(r)||U.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 cU(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("; ")}}}};cw();let cF=Symbol.for("mcp.completable");function cV(e){return!!e&&"object"==typeof e&&cF in e}let cD=0x80000000-1;function cJ(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,cD));return r.unref?.(),r}var cB=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 cW(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function cG(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[nO]:t}}}}function cK(e,t,r){if(null===r||"object"!=typeof r||"string"!=typeof r.method)throw new s6(s3.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 s6(s3.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 cY(e,t){if("tools/call"===e)return{content:[{type:"text",text:t}],isError:!0};throw new s6(s3.InternalError,t)}var cX=class{constructor(e){this._host=e}async fulfill(e,t,r,i,n){let{maxRounds:a,roundTimeoutMs:o}=this._host,s=i.mcpReq.signal,l=n,c=0;for(;;){let n;if((c+=1)>a)return cY(e,`Multi-round-trip request '${e}' still required input after ${a} rounds (inputRequired.maxRounds)`);let d=l.inputRequests,u=null!=d&&Object.keys(d).length>0,p="string"==typeof l.requestState?l.requestState:void 0;if(!u&&void 0===p)throw new s6(s3.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(u){let t=this._host.resolvedClientCapabilities(i),r=[];for(let[i,n]of Object.entries(d)){let{embedded:a,required:o}=cK(e,i,n);if("roots/list"!==a.method&&void 0===a.params)throw new s6(s3.InternalError,`Handler for ${e} returned an input request '${i}' of kind '${a.method}' without params`);if(void 0!==sP(o,t))return cY(e,`Cannot request input '${i}' (${a.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,a])}let a=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:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:a.signal},t=await Promise.all(r.map(async([t,r])=>{try{return[t,await this._dispatchLeg(r,e)]}catch(e){throw a.abort(e),e}}));n=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return cY(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{a.dispose()}}else await function(e,t){return new Promise((e,r)=>{if(t?.aborted)return void r(t.reason instanceof s$?t.reason:new s$(sC.RequestTimeout,String(t.reason)));let i=setTimeout(()=>{t?.removeEventListener("abort",n),e()},250),n=()=>{clearTimeout(i),r(t?.reason instanceof s$?t.reason:new s$(sC.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",n,{once:!0})})}(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=cu(m,t))}let h=await t(r,m);if(!lO(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 cQ=new Set(["tools/call","prompts/get","resources/read"]);var c0=class extends cp{_clientCapabilities;_clientVersion;static{o=(e,t)=>{void 0!==t.clientCapabilities&&(e._clientCapabilities=t.clientCapabilities),void 0!==t.clientInfo&&(e._clientVersion=t.clientInfo)},s=(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())},l=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_legacyInputRequiredShim(){return this._legacyShim??=new cX({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 cH,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&&s5(r,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",e=>this._oninitialize(e)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),sO(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}_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=io(oc,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?.[nj]))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(oc.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 s$(sC.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]=cm(n)&&cm(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=cQ.has(e);return void 0!==r||i?async(n,a)=>{let o=i?await this._invokeInputRequiredCapableHandler(e,t,n,a):await t(n,a);if(lO(o)){if(!i)throw new s6(s3.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 o}return void 0===r?o:s2(o,r)}:async(r,i)=>{let n=await t(r,i);if(lO(n))throw new s6(s3.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=lv(this._negotiatedProtocolVersion),n=i.validateRequest("tools/call",e);if(!n.ok)throw new s6("not-in-era"===n.reason?s3.InternalError:s3.InvalidParams,"not-in-era"===n.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${n.message}`);let a=await this._invokeInputRequiredCapableHandler("tools/call",t,e,r);if(lO(a))return a;let o=sL(a),s=i.validateResult("tools/call",o);if(!s.ok)throw new s6("not-in-era"===s.reason?s3.InternalError:s3.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>=sI}async _invokeInputRequiredCapableHandler(e,t,r,i){let n,a=this._servedModernEra(),o=i.mcpReq.requestState();if(void 0!==o&&"string"!=typeof o)throw new s6(s3.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let s=i;if("string"==typeof o){let t=await this._verifyRequestState(o,i,e);void 0!==t&&(s=cu(i,t))}try{n=await t(r,s)}catch(e){if(e instanceof s6&&e.code===s3.UrlElicitationRequired){if(!a)throw e;throw new s6(s3.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(!lO(n))return n;if(!a){if(!this._inputRequiredServing.legacyShim)throw new s6(s3.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??n$}, 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,d="string"==typeof n.requestState;if(!c&&!d)throw new s6(s3.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:a}=cK(e,r,i),o=sP(a,t);if(void 0!==o)throw new lt({requiredCapabilities:o},`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 s6(s3.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[nq]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new s$(sC.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 s$(sC.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new s$(sC.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new s$(sC.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new s$(sC.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 s$(sC.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new s$(sC.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 s$(sC.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 s$(sC.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new s$(sC.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new s$(sC.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new s$(sC.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 s$(sC.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new s$(sC.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>=sI)),i=r.includes(t)?t:r[0]??n$;return this._negotiatedProtocolVersion=i,this.transport?.setProtocolVersion?.(i),{protocolVersion:i,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:sO(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 s$(sC.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,a=n?Array.isArray(n.content)?n.content:[n.content]:[],o=a.some(e=>"tool_use"===e.type);if(i){if(r.some(e=>"tool_result"!==e.type))throw new s6(s3.InvalidParams,"The last message must contain only tool_result content if any is present");if(!o)throw new s6(s3.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(o){let e=new Set(a.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 s6(s3.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 s$(sC.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 s$(sC.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new s$(sC.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 s6(s3.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof s6)throw e;throw new s6(s3.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return i}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new s$(sC.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"})}},c1=class{server;_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 c4;try{let r=l9(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new c0(e,t),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}_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])=>{let r={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?l9(t.inputSchema,"input"):c4,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(r.outputSchema=l9(t.outputSchema,"output")),r})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new s6(s3.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new s6(s3.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),lO(n))return n;return this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(e){if(e instanceof s6&&e.code===s3.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(!e.inputSchema)return;let i=await l4(e.inputSchema,t??{});if(!i.success)throw new s6(s3.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${i.error}`);return i.data}async validateToolOutput(e,t,r){if(!e.outputSchema||lO(t)||t.isError)return;if(void 0===t.structuredContent)throw new s6(s3.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let i=await l4(e.outputSchema,t.structuredContent);if(!i.success)throw new s6(s3.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 s6(s3.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let r=this._registeredPrompts[t.name];if(!r)throw new s6(s3.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new s6(s3.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return c7;let i=de(c8(r.argsSchema)?.[e.params.argument.name]);if(!cV(i))return c7;let n=i[cF]?.complete;return n?c6(await n(e.params.argument.value,e.params.context)):c7}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 c7;throw new s6(s3.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let i=r.resourceTemplate.completeCallback(e.params.argument.name);return i?c6(await i(e.params.argument.value,e.params.context)):c7}_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 s6(s3.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 s6(s3.InvalidParams,`Resource ${r} disabled`);return s2(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)return s2(await e.readCallback(r,i,t),e.cacheHint)}throw new s7(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=l9(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 s6(s3.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new s6(s3.InvalidParams,`Prompt ${e.params.name} disabled`);return r.handler(e.params.arguments,t)}),this._promptHandlersInitialized=!0)}registerResource(e,t,r,i){let n=r.cacheHint,a=r;if(void 0!==n){s5(n,`resource ${e}`);let t={...r};delete t.cacheHint,a=t}if("string"==typeof t){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let o=this._createRegisteredResource(e,r.title,t,a,i);return void 0!==n&&(o.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,r.title,t,a,i);return void 0!==n&&(o.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,t,r,i,n){let a={name:e,title:t,metadata:i,readCallback: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.title&&(a.title=e.title),void 0!==e.metadata&&(a.metadata=e.metadata),void 0!==e.callback&&(a.readCallback=e.callback),void 0!==e.enabled&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=a,a}_createRegisteredResourceTemplate(e,t,r,i,n){let a={resourceTemplate:r,title:t,metadata:i,readCallback: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.title&&(a.title=t.title),void 0!==t.template&&(a.resourceTemplate=t.template),void 0!==t.metadata&&(a.metadata=t.metadata),void 0!==t.callback&&(a.readCallback=t.callback),void 0!==t.enabled&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=r.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,r,i,n,a,o){let s=i,l=n,c={title:t,description:r,argsSchema:i,icons:a,_meta:o,handler:c3(e,i,n),enabled:!0,disable:()=>c.update({enabled:!1}),enable:()=>c.update({enabled:!0}),remove:()=>c.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=c)),void 0!==t.title&&(c.title=t.title),void 0!==t.description&&(c.description=t.description),void 0!==t.icons&&(c.icons=t.icons),void 0!==t._meta&&(c._meta=t._meta);let r=!1;void 0!==t.argsSchema&&(c.argsSchema=t.argsSchema,s=t.argsSchema,r=!0),void 0!==t.callback&&(l=t.callback,r=!0),r&&(c.handler=c3(e,s,l)),void 0!==t.enabled&&(c.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=c,i){let e=c8(i);e&&Object.values(e).some(e=>cV(de(e)))&&this.setCompletionRequestHandler()}return c}_createRegisteredTool(e,t,r,i,n,a,o,s,l,c){if(c_(e),void 0!==i)try{let t=l9(i,"input");this._toolInputSchemaJson[e]=t;let r=lN(t);r.valid||console.warn(`[mcp-sdk] tool '${e}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${r.reason}`)}catch{}let d=c,u={title:t,description:r,inputSchema:i,outputSchema:n,outputSchemaJson:c5(n),annotations:a,icons:o,execution:s,_meta:l,handler:c,executor:c9(i,c),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&&("string"==typeof t.name&&c_(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=u,e=t.name)),void 0!==t.title&&(u.title=t.title),void 0!==t.description&&(u.description=t.description);let r=!1;void 0!==t.paramsSchema&&(u.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],r=!0),void 0!==t.callback&&(u.handler=t.callback,d=t.callback,r=!0),r&&(u.executor=c9(u.inputSchema,d)),void 0!==t.outputSchema&&(u.outputSchema=t.outputSchema,u.outputSchemaJson=c5(t.outputSchema)),void 0!==t.annotations&&(u.annotations=t.annotations),void 0!==t.icons&&(u.icons=t.icons),void 0!==t._meta&&(u._meta=t._meta),void 0!==t.enabled&&(u.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}registerTool(e,t,r){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:i,description:n,inputSchema:a,outputSchema:o,annotations:s,icons:l,_meta:c}=t;return this._createRegisteredTool(e,i,n,cS(a),cS(o),s,l,void 0,c,r)}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:i,description:n,argsSchema:a,icons:o,_meta:s}=t,l=this._createRegisteredPrompt(e,i,n,cS(a),r,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),l}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()}},c2=class{_uriTemplate;constructor(e,t){this._callbacks=t,this._uriTemplate="string"==typeof e?new cb(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}};function c9(e,t){return e?async(e,r)=>t(e,r):async(e,r)=>t(r)}let c4={type:"object",properties:{}};function c5(e){if(void 0!==e)try{return l9(e,"output")}catch{return}}function c3(e,t,r){return t?async(i,n)=>{let a=await l4(t,i);if(!a.success)throw new s6(s3.InvalidParams,`Invalid arguments for prompt ${e}: ${a.error}`);return r(a.data,n)}:async(e,t)=>r(t)}function c6(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}let c7={completion:{values:[],hasMore:!1}};function c8(e){if(e.shape&&"object"==typeof e.shape)return e.shape}function de(e){return e?.type!=="optional"?e:e.def?.innerType??e}var dt=class{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 s$(sC.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(lE(e)){let t,n;this._requestId=e.id;let a=new Promise((e,r)=>{t=e,n=r});if(this._deferredResponse={promise:a,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(),a}return this.onmessage(e,i),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let r=lI(e)||lq(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=lq(e)?e.error.code:void 0,r=void 0!==t&&(this._dispatchWindowOpen||t===s3.MissingRequiredClientCapability)?lJ[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}
|
|
65
65
|
|
|
66
|
-
`)}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 s$(sC.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=
|
|
66
|
+
`)}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 s$(sC.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=cJ(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
|
|
67
67
|
data: ${JSON.stringify(e)}
|
|
68
68
|
|
|
69
|
-
`)}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}`))}}};async function
|
|
69
|
+
`)}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}`))}}};async function dr(e,t,r){let i=new dt({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}})}var di=class{sessionIdGenerator;_started=!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;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??nT,this._keepAliveMs=e.keepAliveMs??15e3}startKeepAlive(e,t){if(this._closed)return;let r=cJ(this._keepAliveMs,()=>{try{e.enqueue(t.encode(": keepalive\n\n"))}catch{void 0!==r&&clearInterval(r)}});return r}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}})}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");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,{}),a=`id: ${n}
|
|
70
70
|
data:
|
|
71
71
|
|
|
72
72
|
`;void 0!==this._retryInterval&&(a=`id: ${n}
|
|
@@ -77,17 +77,17 @@ data:
|
|
|
77
77
|
`;return i&&(n+=`id: ${i}
|
|
78
78
|
`),n+=`data: ${JSON.stringify(r)}
|
|
79
79
|
|
|
80
|
-
`,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,a,o=e.headers.get("accept");if(!o?.includes("application/json")||!o.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(!cg(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{r=await e.json()}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else r=t.parsedBody;try{i=Array.isArray(r)?r.map(e=>n1.parse(e)):[n1.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 s=i.some(e=>ao.safeParse(e).success);if(s){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(!s){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");if(!i.some(e=>lE(e))){for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e});return new Response(null,{status:202})}let l=crypto.randomUUID(),c=i.find(e=>ao.safeParse(e).success),d=c?c.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(l,{resolveJson:r,cleanup:()=>{this._streamMapping.delete(l)}}),i))lE(e)&&this._requestToStreamMapping.set(e.id,l);for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e})});let u=new TextEncoder,p=new ReadableStream({start:e=>{n=e},cancel:()=>{void 0!==a&&clearInterval(a),this._streamMapping.get(l)?.controller===n&&this._streamMapping.delete(l)}}),m={"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&&(m["mcp-session-id"]=this.sessionId),i))lE(e)&&(this._streamMapping.set(l,{controller:n,encoder:u,cleanup:()=>{void 0!==a&&clearInterval(a),this._streamMapping.delete(l);try{n.close()}catch{}}}),this._requestToStreamMapping.set(e.id,l));for(let r of(await this.writePrimingEvent(n,u,l,d),i)){let i,n;lE(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(l)?.controller===n&&(a=this.startKeepAlive(n,u)),new Response(p,{status:200,headers:m})}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((lI(e)||lq(e))&&(r=e.id),void 0===r){let t;if(lI(e)||lq(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(lI(e)||lq(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 di(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 dn(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})}function da(e,t=null){return dn(e.httpStatus,e.code,e.message,e.data,t)}function ds(e){return e instanceof Error?e:Error(String(e))}function dl(e=null){return dn(500,-32603,"Internal server error",void 0,e)}async function dc(e,t,r=!0){let i,n=e.method.toUpperCase(),a=t,o=e,s=!1;if("POST"===n){if(void 0===a){let t;r&&(o=e.clone());try{t=await e.text()}catch{return{step:"unreadable-body"}}try{i=0===t.length?void 0:JSON.parse(t)}catch{s=!0}s||void 0===i||(a=i)}else i=a;if(s||void 0===i)return{step:"no-json-body",forwardRequest:o}}return{step:"classified",outcome:function(e){if("POST"!==(e={...e,...void 0!==e.protocolVersionHeader&&{protocolVersionHeader:lK(e.protocolVersionHeader)},...void 0!==e.mcpMethodHeader&&{mcpMethodHeader:lK(e.mcpMethodHeader)},...void 0!==e.mcpNameHeader&&{mcpNameHeader:lK(e.mcpNameHeader)}}).httpMethod.toUpperCase())return{kind:"legacy",reason:"http-method"};let t=e.body;if(Array.isArray(t)){if(0===t.length)return lB("jsonrpc-shape","empty-batch",400,new s6(s3.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let e of t){if(lx(lY(e)?e.params:void 0))return lB("jsonrpc-shape","batch-with-modern-element",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(lE(e)||lP(e)||lI(e)||lq(e)))return lB("jsonrpc-shape","batch-with-invalid-element",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}return lI(t)||lq(t)?{kind:"legacy",reason:"response"}:lY(t)&&lE(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,a=void 0!==n&&n>=sI;if("initialize"===i&&!function(e){if(!lx(e))return!1;let t=lC(e);if(void 0===t||!(t>=sI))return!1;let r=lR(e);return void 0!==r&&0===l$(r).length}(r)){if(a)return lW("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let e=lY(r)&&"string"==typeof r.protocolVersion?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==e&&{requestedVersion:e}}}if(lx(r)){let a=lR(r),o=(void 0===a?[]:l$(a))[0];if(void 0!==o)return lB("envelope","envelope-invalid",400,new s6(s3.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${o.key}: ${o.problem}`,{envelope:o}),!0);let s=lC(r);return void 0!==n&&void 0!==s&&n!==s?lW("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?lW("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:lX(s)}}if(a){let e=lR(r),t=l$(e??{}).filter(e=>"missing"===e.problem).map(e=>e.key),i=void 0===e?["_meta"]:t.length>0?t:[nE];return lB("envelope","modern-header-without-claim",400,new s6(s3.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):lY(t)&&lP(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,a=void 0!==n&&n>=sI;if(lx(r)){let a=lC(r);if(void 0===a){let e=lR(r),t=(void 0===e?[]:l$(e)).find(e=>e.key===nE)??{key:nE,problem:"expected a protocol version string"};return lB("envelope","notification-envelope-invalid",400,new s6(s3.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${t.key}: ${t.problem}`,{envelope:t}),!0)}if(void 0!==n&&n!==a)return lW("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${a} but the MCP-Protocol-Version header names ${n}`);let o=lX(a);return"modern"===o.era&&void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?lW("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:o}}return a?void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?lW("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):lB("jsonrpc-shape","invalid-json-rpc-body",400,new s6(s3.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}({httpMethod:n,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,...void 0!==i&&{body:i}}),body:i,parsedBody:a,forwardRequest:o}}let dd=Symbol("Let zodToJsonSchema decide on which parser to use"),du={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"};(v=R||(R={})).assertEqual=e=>{},v.assertIs=function(e){},v.assertNever=function(e){throw Error()},v.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},v.getValidEnumValues=e=>{let t=v.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let i of t)r[i]=e[i];return v.objectValues(r)},v.objectValues=e=>v.objectKeys(e).map(function(t){return e[t]}),v.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},v.find=(e,t)=>{for(let r of e)if(t(r))return r},v.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,v.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},v.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(x||(x={})).mergeShapes=(e,t)=>({...e,...t});let dp=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),dm=e=>{switch(typeof e){case"undefined":return dp.undefined;case"string":return dp.string;case"number":return Number.isNaN(e)?dp.nan:dp.number;case"boolean":return dp.boolean;case"function":return dp.function;case"bigint":return dp.bigint;case"symbol":return dp.symbol;case"object":if(Array.isArray(e))return dp.array;if(null===e)return dp.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return dp.promise;if("undefined"!=typeof Map&&e instanceof Map)return dp.map;if("undefined"!=typeof Set&&e instanceof Set)return dp.set;if("undefined"!=typeof Date&&e instanceof Date)return dp.date;return dp.object;default:return dp.unknown}},dh=R.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 df 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];i===n.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(n))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(this),r}static assert(e){if(!(e instanceof df))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.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()}}df.create=e=>new df(e);let dg=(e,t)=>{let r;switch(e.code){case dh.invalid_type:r=e.received===dp.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case dh.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,R.jsonStringifyReplacer)}`;break;case dh.unrecognized_keys:r=`Unrecognized key(s) in object: ${R.joinValues(e.keys,", ")}`;break;case dh.invalid_union:r="Invalid input";break;case dh.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${R.joinValues(e.options)}`;break;case dh.invalid_enum_value:r=`Invalid enum value. Expected ${R.joinValues(e.options)}, received '${e.received}'`;break;case dh.invalid_arguments:r="Invalid function arguments";break;case dh.invalid_return_type:r="Invalid function return type";break;case dh.invalid_date:r="Invalid date";break;case dh.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}"`:R.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case dh.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 dh.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 dh.custom:r="Invalid input";break;case dh.invalid_intersection_types:r="Intersection results could not be merged";break;case dh.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case dh.not_finite:r="Number must be finite";break;default:r=t.defaultError,R.assertNever(e)}return{message:r}};(_=C||(C={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},_.toString=e=>"string"==typeof e?e:e?.message;let dy=e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,a=[...r,...n.path||[]],o={...n,path:a};if(void 0!==n.message)return{...n,path:a,message:n.message};let s="";for(let e of i.filter(e=>!!e).slice().reverse())s=e(o,{data:t,defaultError:s}).message;return{...n,path:a,message:s}};function dv(e,t){let r=dy({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,dg,void 0].filter(e=>!!e)});e.common.issues.push(r)}class d_{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 db;"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 d_.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 db;"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 db=Object.freeze({status:"aborted"}),dS=e=>({status:"dirty",value:e}),dw=e=>({status:"valid",value:e}),dk=e=>"undefined"!=typeof Promise&&e instanceof Promise;class dR{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 dx=(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 df(e.common.issues);return this._error=t,this._error}}};function dC(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:a}=e;return"invalid_enum_value"===t.code?{message:a??n.defaultError}:void 0===n.data?{message:a??i??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:a??r??n.defaultError}},description:n}}class d${get description(){return this._def.description}_getType(e){return dm(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:dm(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new d_,ctx:{common:e.parent.common,data:e.data,parsedType:dm(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(dk(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:dm(e)},i=this._parseSync({data:e,path:r.path,parent:r});return dx(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dm(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:dm(e)},i=this._parse({data:e,path:r.path,parent:r});return dx(r,await (dk(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,i)=>{let n=e(r),a=()=>i.addIssue({code:dh.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"undefined"!=typeof Promise&&n instanceof Promise?n.then(e=>!!e||(a(),!1)):!!n||(a(),!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 ud({schema:this,typeName:$.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 uu.create(this,this._def)}nullable(){return up.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return d9.create(this)}promise(){return uc.create(this,this._def)}or(e){return d5.create([this,e],this._def)}and(e){return d7.create(this,e,this._def)}transform(e){return new ud({...dC(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new um({...dC(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:$.ZodDefault})}brand(){return new ug({typeName:$.ZodBranded,type:this,...dC(this._def)})}catch(e){return new uh({...dC(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:$.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return uy.create(this,e)}readonly(){return uv.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let dT=/^c[^\s-]{8,}$/i,dE=/^[0-9a-z]+$/,dP=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dI=/^[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,dq=/^[a-z0-9_-]{21}$/i,dO=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,dj=/^[-+]?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)?)??$/,dz=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,dL=/^(?:(?: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])$/,dN=/^(?:(?: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])$/,dA=/^(([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]))$/,dM=/^(([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])$/,dZ=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dU=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dH="((\\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])))",dF=RegExp(`^${dH}$`);function dV(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 dD extends d${_parse(e){var t,r,i,n;let a;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==dp.string){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.string,received:t.parsedType}),db}let o=new d_;for(let s of this._def.checks)if("min"===s.kind)e.data.length<s.value&&(dv(a=this._getOrReturnCtx(e,a),{code:dh.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if("max"===s.kind)e.data.length>s.value&&(dv(a=this._getOrReturnCtx(e,a),{code:dh.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if("length"===s.kind){let t=e.data.length>s.value,r=e.data.length<s.value;(t||r)&&(a=this._getOrReturnCtx(e,a),t?dv(a,{code:dh.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):r&&dv(a,{code:dh.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),o.dirty())}else if("email"===s.kind)dz.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"email",code:dh.invalid_string,message:s.message}),o.dirty());else if("emoji"===s.kind)c||(c=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),c.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"emoji",code:dh.invalid_string,message:s.message}),o.dirty());else if("uuid"===s.kind)dI.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"uuid",code:dh.invalid_string,message:s.message}),o.dirty());else if("nanoid"===s.kind)dq.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"nanoid",code:dh.invalid_string,message:s.message}),o.dirty());else if("cuid"===s.kind)dT.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"cuid",code:dh.invalid_string,message:s.message}),o.dirty());else if("cuid2"===s.kind)dE.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"cuid2",code:dh.invalid_string,message:s.message}),o.dirty());else if("ulid"===s.kind)dP.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"ulid",code:dh.invalid_string,message:s.message}),o.dirty());else if("url"===s.kind)try{new URL(e.data)}catch{dv(a=this._getOrReturnCtx(e,a),{validation:"url",code:dh.invalid_string,message:s.message}),o.dirty()}else"regex"===s.kind?(s.regex.lastIndex=0,s.regex.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"regex",code:dh.invalid_string,message:s.message}),o.dirty())):"trim"===s.kind?e.data=e.data.trim():"includes"===s.kind?e.data.includes(s.value,s.position)||(dv(a=this._getOrReturnCtx(e,a),{code:dh.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),o.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)||(dv(a=this._getOrReturnCtx(e,a),{code:dh.invalid_string,validation:{startsWith:s.value},message:s.message}),o.dirty()):"endsWith"===s.kind?e.data.endsWith(s.value)||(dv(a=this._getOrReturnCtx(e,a),{code:dh.invalid_string,validation:{endsWith:s.value},message:s.message}),o.dirty()):"datetime"===s.kind?(function(e){let t=`${dH}T${dV(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)||(dv(a=this._getOrReturnCtx(e,a),{code:dh.invalid_string,validation:"datetime",message:s.message}),o.dirty()):"date"===s.kind?dF.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{code:dh.invalid_string,validation:"date",message:s.message}),o.dirty()):"time"===s.kind?RegExp(`^${dV(s)}$`).test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{code:dh.invalid_string,validation:"time",message:s.message}),o.dirty()):"duration"===s.kind?dj.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"duration",code:dh.invalid_string,message:s.message}),o.dirty()):"ip"===s.kind?(t=e.data,!(("v4"===(r=s.version)||!r)&&dL.test(t)||("v6"===r||!r)&&dA.test(t))&&1&&(dv(a=this._getOrReturnCtx(e,a),{validation:"ip",code:dh.invalid_string,message:s.message}),o.dirty())):"jwt"===s.kind?!function(e,t){if(!dO.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)&&(dv(a=this._getOrReturnCtx(e,a),{validation:"jwt",code:dh.invalid_string,message:s.message}),o.dirty()):"cidr"===s.kind?(i=e.data,!(("v4"===(n=s.version)||!n)&&dN.test(i)||("v6"===n||!n)&&dM.test(i))&&1&&(dv(a=this._getOrReturnCtx(e,a),{validation:"cidr",code:dh.invalid_string,message:s.message}),o.dirty())):"base64"===s.kind?dZ.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"base64",code:dh.invalid_string,message:s.message}),o.dirty()):"base64url"===s.kind?dU.test(e.data)||(dv(a=this._getOrReturnCtx(e,a),{validation:"base64url",code:dh.invalid_string,message:s.message}),o.dirty()):R.assertNever(s);return{status:o.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:dh.invalid_string,...C.errToObj(r)})}_addCheck(e){return new dD({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...C.errToObj(e)})}url(e){return this._addCheck({kind:"url",...C.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...C.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...C.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...C.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...C.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...C.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...C.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...C.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...C.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...C.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...C.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,...C.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,...C.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...C.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...C.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...C.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...C.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...C.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...C.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...C.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...C.errToObj(t)})}nonempty(e){return this.min(1,C.errToObj(e))}trim(){return new dD({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new dD({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new dD({...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}}dD.create=e=>new dD({checks:[],typeName:$.ZodString,coerce:e?.coerce??!1,...dC(e)});class dJ extends d${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)!==dp.number){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.number,received:t.parsedType}),db}let r=new d_;for(let i of this._def.checks)"int"===i.kind?R.isInteger(e.data)||(dv(t=this._getOrReturnCtx(e,t),{code:dh.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.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)&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.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)&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(dv(t=this._getOrReturnCtx(e,t),{code:dh.not_finite,message:i.message}),r.dirty()):R.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,C.toString(t))}gt(e,t){return this.setLimit("min",e,!1,C.toString(t))}lte(e,t){return this.setLimit("max",e,!0,C.toString(t))}lt(e,t){return this.setLimit("max",e,!1,C.toString(t))}setLimit(e,t,r,i){return new dJ({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:C.toString(i)}]})}_addCheck(e){return new dJ({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:C.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:C.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.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&&R.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)}}dJ.create=e=>new dJ({checks:[],typeName:$.ZodNumber,coerce:e?.coerce||!1,...dC(e)});class dB extends d${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)!==dp.bigint)return this._getInvalidInput(e);let r=new d_;for(let i of this._def.checks)"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.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)&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):R.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.bigint,received:t.parsedType}),db}gte(e,t){return this.setLimit("min",e,!0,C.toString(t))}gt(e,t){return this.setLimit("min",e,!1,C.toString(t))}lte(e,t){return this.setLimit("max",e,!0,C.toString(t))}lt(e,t){return this.setLimit("max",e,!1,C.toString(t))}setLimit(e,t,r,i){return new dB({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:C.toString(i)}]})}_addCheck(e){return new dB({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:C.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}}dB.create=e=>new dB({checks:[],typeName:$.ZodBigInt,coerce:e?.coerce??!1,...dC(e)});class dW extends d${_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==dp.boolean){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.boolean,received:t.parsedType}),db}return dw(e.data)}}dW.create=e=>new dW({typeName:$.ZodBoolean,coerce:e?.coerce||!1,...dC(e)});class dG extends d${_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==dp.date){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.date,received:t.parsedType}),db}if(Number.isNaN(e.data.getTime()))return dv(this._getOrReturnCtx(e),{code:dh.invalid_date}),db;let r=new d_;for(let i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(dv(t=this._getOrReturnCtx(e,t),{code:dh.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):R.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new dG({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:C.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:C.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}}dG.create=e=>new dG({checks:[],coerce:e?.coerce||!1,typeName:$.ZodDate,...dC(e)});class dK extends d${_parse(e){if(this._getType(e)!==dp.symbol){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.symbol,received:t.parsedType}),db}return dw(e.data)}}dK.create=e=>new dK({typeName:$.ZodSymbol,...dC(e)});class dY extends d${_parse(e){if(this._getType(e)!==dp.undefined){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.undefined,received:t.parsedType}),db}return dw(e.data)}}dY.create=e=>new dY({typeName:$.ZodUndefined,...dC(e)});class dX extends d${_parse(e){if(this._getType(e)!==dp.null){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.null,received:t.parsedType}),db}return dw(e.data)}}dX.create=e=>new dX({typeName:$.ZodNull,...dC(e)});class dQ extends d${constructor(){super(...arguments),this._any=!0}_parse(e){return dw(e.data)}}dQ.create=e=>new dQ({typeName:$.ZodAny,...dC(e)});class d0 extends d${constructor(){super(...arguments),this._unknown=!0}_parse(e){return dw(e.data)}}d0.create=e=>new d0({typeName:$.ZodUnknown,...dC(e)});class d1 extends d${_parse(e){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.never,received:t.parsedType}),db}}d1.create=e=>new d1({typeName:$.ZodNever,...dC(e)});class d2 extends d${_parse(e){if(this._getType(e)!==dp.undefined){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.void,received:t.parsedType}),db}return dw(e.data)}}d2.create=e=>new d2({typeName:$.ZodVoid,...dC(e)});class d9 extends d${_parse(e){let{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==dp.array)return dv(t,{code:dh.invalid_type,expected:dp.array,received:t.parsedType}),db;if(null!==i.exactLength){let e=t.data.length>i.exactLength.value,n=t.data.length<i.exactLength.value;(e||n)&&(dv(t,{code:e?dh.too_big:dh.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&&(dv(t,{code:dh.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&&(dv(t,{code:dh.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 dR(t,e,t.path,r)))).then(e=>d_.mergeArray(r,e));let n=[...t.data].map((e,r)=>i.type._parseSync(new dR(t,e,t.path,r)));return d_.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new d9({...this._def,minLength:{value:e,message:C.toString(t)}})}max(e,t){return new d9({...this._def,maxLength:{value:e,message:C.toString(t)}})}length(e,t){return new d9({...this._def,exactLength:{value:e,message:C.toString(t)}})}nonempty(e){return this.min(1,e)}}d9.create=(e,t)=>new d9({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...dC(t)});class d4 extends d${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=R.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==dp.object){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.object,received:t.parsedType}),db}let{status:t,ctx:r}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),a=[];if(!(this._def.catchall instanceof d1&&"strip"===this._def.unknownKeys))for(let e in r.data)n.includes(e)||a.push(e);let o=[];for(let e of n){let t=i[e],n=r.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new dR(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof d1){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(dv(r,{code:dh.unrecognized_keys,keys:a}),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 a){let i=r.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new dR(r,i,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let r=await t.key,i=await t.value;e.push({key:r,value:i,alwaysSet:t.alwaysSet})}return e}).then(e=>d_.mergeObjectSync(t,e)):d_.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return C.errToObj,new d4({...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:C.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new d4({...this._def,unknownKeys:"strip"})}passthrough(){return new d4({...this._def,unknownKeys:"passthrough"})}extend(e){return new d4({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new d4({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new d4({...this._def,catchall:e})}pick(e){let t={};for(let r of R.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new d4({...this._def,shape:()=>t})}omit(e){let t={};for(let r of R.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new d4({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof d4){let r={};for(let i in t.shape){let n=t.shape[i];r[i]=uu.create(e(n))}return new d4({...t._def,shape:()=>r})}if(t instanceof d9)return new d9({...t._def,type:e(t.element)});if(t instanceof uu)return uu.create(e(t.unwrap()));if(t instanceof up)return up.create(e(t.unwrap()));if(t instanceof d8)return d8.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of R.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new d4({...this._def,shape:()=>t})}required(e){let t={};for(let r of R.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof uu;)e=e._def.innerType;t[r]=e}return new d4({...this._def,shape:()=>t})}keyof(){return uo(R.objectKeys(this.shape))}}d4.create=(e,t)=>new d4({shape:()=>e,unknownKeys:"strip",catchall:d1.create(),typeName:$.ZodObject,...dC(t)}),d4.strictCreate=(e,t)=>new d4({shape:()=>e,unknownKeys:"strict",catchall:d1.create(),typeName:$.ZodObject,...dC(t)}),d4.lazycreate=(e,t)=>new d4({shape:e,unknownKeys:"strip",catchall:d1.create(),typeName:$.ZodObject,...dC(t)});class d5 extends d${_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 df(e.ctx.common.issues));return dv(t,{code:dh.invalid_union,unionErrors:r}),db});{let e,i=[];for(let n of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=n._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,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 df(e));return dv(t,{code:dh.invalid_union,unionErrors:n}),db}}get options(){return this._def.options}}d5.create=(e,t)=>new d5({options:e,typeName:$.ZodUnion,...dC(t)});let d3=e=>{if(e instanceof un)return d3(e.schema);if(e instanceof ud)return d3(e.innerType());if(e instanceof ua)return[e.value];if(e instanceof us)return e.options;if(e instanceof ul)return R.objectValues(e.enum);else if(e instanceof um)return d3(e._def.innerType);else if(e instanceof dY)return[void 0];else if(e instanceof dX)return[null];else if(e instanceof uu)return[void 0,...d3(e.unwrap())];else if(e instanceof up)return[null,...d3(e.unwrap())];else if(e instanceof ug)return d3(e.unwrap());else if(e instanceof uv)return d3(e.unwrap());else if(e instanceof uh)return d3(e._def.innerType);else return[]};class d6 extends d${_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==dp.object)return dv(t,{code:dh.invalid_type,expected:dp.object,received:t.parsedType}),db;let r=this.discriminator,i=t.data[r],n=this.optionsMap.get(i);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(dv(t,{code:dh.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),db)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let i=new Map;for(let r of t){let t=d3(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let n of t){if(i.has(n))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);i.set(n,r)}}return new d6({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...dC(r)})}}class d7 extends d${_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=(e,i)=>{if("aborted"===e.status||"aborted"===i.status)return db;let n=function e(t,r){let i=dm(t),n=dm(r);if(t===r)return{valid:!0,data:t};if(i===dp.object&&n===dp.object){let i=R.objectKeys(r),n=R.objectKeys(t).filter(e=>-1!==i.indexOf(e)),a={...t,...r};for(let i of n){let n=e(t[i],r[i]);if(!n.valid)return{valid:!1};a[i]=n.data}return{valid:!0,data:a}}if(i===dp.array&&n===dp.array){if(t.length!==r.length)return{valid:!1};let i=[];for(let n=0;n<t.length;n++){let a=e(t[n],r[n]);if(!a.valid)return{valid:!1};i.push(a.data)}return{valid:!0,data:i}}if(i===dp.date&&n===dp.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}):(dv(r,{code:dh.invalid_intersection_types}),db)};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}))}}d7.create=(e,t,r)=>new d7({left:e,right:t,typeName:$.ZodIntersection,...dC(r)});class d8 extends d${_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==dp.array)return dv(r,{code:dh.invalid_type,expected:dp.array,received:r.parsedType}),db;if(r.data.length<this._def.items.length)return dv(r,{code:dh.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),db;!this._def.rest&&r.data.length>this._def.items.length&&(dv(r,{code:dh.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 dR(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(i).then(e=>d_.mergeArray(t,e)):d_.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new d8({...this._def,rest:e})}}d8.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new d8({items:e,typeName:$.ZodTuple,rest:null,...dC(t)})};class ue extends d${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!==dp.object)return dv(r,{code:dh.invalid_type,expected:dp.object,received:r.parsedType}),db;let i=[],n=this._def.keyType,a=this._def.valueType;for(let e in r.data)i.push({key:n._parse(new dR(r,e,r.path,e)),value:a._parse(new dR(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?d_.mergeObjectAsync(t,i):d_.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,r){return new ue(t instanceof d$?{keyType:e,valueType:t,typeName:$.ZodRecord,...dC(r)}:{keyType:dD.create(),valueType:e,typeName:$.ZodRecord,...dC(t)})}}class ut extends d${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!==dp.map)return dv(r,{code:dh.invalid_type,expected:dp.map,received:r.parsedType}),db;let i=this._def.keyType,n=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:i._parse(new dR(r,e,r.path,[a,"key"])),value:n._parse(new dR(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let i=await r.key,n=await r.value;if("aborted"===i.status||"aborted"===n.status)return db;("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 a){let i=r.key,n=r.value;if("aborted"===i.status||"aborted"===n.status)return db;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}}}}ut.create=(e,t,r)=>new ut({valueType:t,keyType:e,typeName:$.ZodMap,...dC(r)});class ur extends d${_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==dp.set)return dv(r,{code:dh.invalid_type,expected:dp.set,received:r.parsedType}),db;let i=this._def;null!==i.minSize&&r.data.size<i.minSize.value&&(dv(r,{code:dh.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&&(dv(r,{code:dh.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let n=this._def.valueType;function a(e){let r=new Set;for(let i of e){if("aborted"===i.status)return db;"dirty"===i.status&&t.dirty(),r.add(i.value)}return{status:t.value,value:r}}let o=[...r.data.values()].map((e,t)=>n._parse(new dR(r,e,r.path,t)));return r.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new ur({...this._def,minSize:{value:e,message:C.toString(t)}})}max(e,t){return new ur({...this._def,maxSize:{value:e,message:C.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ur.create=(e,t)=>new ur({valueType:e,minSize:null,maxSize:null,typeName:$.ZodSet,...dC(t)});class ui extends d${constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==dp.function)return dv(t,{code:dh.invalid_type,expected:dp.function,received:t.parsedType}),db;function r(e,r){return dy({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dg,dg].filter(e=>!!e),issueData:{code:dh.invalid_arguments,argumentsError:r}})}function i(e,r){return dy({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dg,dg].filter(e=>!!e),issueData:{code:dh.invalid_return_type,returnTypeError:r}})}let n={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof uc){let e=this;return dw(async function(...t){let o=new df([]),s=await e._def.args.parseAsync(t,n).catch(e=>{throw o.addIssue(r(t,e)),o}),l=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(l,n).catch(e=>{throw o.addIssue(i(l,e)),o})})}{let e=this;return dw(function(...t){let o=e._def.args.safeParse(t,n);if(!o.success)throw new df([r(t,o.error)]);let s=Reflect.apply(a,this,o.data),l=e._def.returns.safeParse(s,n);if(!l.success)throw new df([i(s,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ui({...this._def,args:d8.create(e).rest(d0.create())})}returns(e){return new ui({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ui({args:e||d8.create([]).rest(d0.create()),returns:t||d0.create(),typeName:$.ZodFunction,...dC(r)})}}class un extends d${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})}}un.create=(e,t)=>new un({getter:e,typeName:$.ZodLazy,...dC(t)});class ua extends d${_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return dv(t,{received:t.data,code:dh.invalid_literal,expected:this._def.value}),db}return{status:"valid",value:e.data}}get value(){return this._def.value}}function uo(e,t){return new us({values:e,typeName:$.ZodEnum,...dC(t)})}ua.create=(e,t)=>new ua({value:e,typeName:$.ZodLiteral,...dC(t)});class us extends d${_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return dv(t,{expected:R.joinValues(r),received:t.parsedType,code:dh.invalid_type}),db}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 dv(t,{received:t.data,code:dh.invalid_enum_value,options:r}),db}return dw(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 us.create(e,{...this._def,...t})}exclude(e,t=this._def){return us.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}us.create=uo;class ul extends d${_parse(e){let t=R.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==dp.string&&r.parsedType!==dp.number){let e=R.objectValues(t);return dv(r,{expected:R.joinValues(e),received:r.parsedType,code:dh.invalid_type}),db}if(this._cache||(this._cache=new Set(R.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=R.objectValues(t);return dv(r,{received:r.data,code:dh.invalid_enum_value,options:e}),db}return dw(e.data)}get enum(){return this._def.values}}ul.create=(e,t)=>new ul({values:e,typeName:$.ZodNativeEnum,...dC(t)});class uc extends d${unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==dp.promise&&!1===t.common.async?(dv(t,{code:dh.invalid_type,expected:dp.promise,received:t.parsedType}),db):dw((t.parsedType===dp.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}uc.create=(e,t)=>new uc({type:e,typeName:$.ZodPromise,...dC(t)});class ud extends d${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.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=>{dv(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 db;let i=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===i.status?db:"dirty"===i.status||"dirty"===t.value?dS(i.value):i});{if("aborted"===t.value)return db;let i=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===i.status?db:"dirty"===i.status||"dirty"===t.value?dS(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?db:("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?db:("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?db: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 db;let a=i.transform(e.value,n);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}R.assertNever(i)}}ud.create=(e,t,r)=>new ud({schema:e,typeName:$.ZodEffects,effect:t,...dC(r)}),ud.createWithPreprocess=(e,t,r)=>new ud({schema:t,effect:{type:"preprocess",transform:e},typeName:$.ZodEffects,...dC(r)});class uu extends d${_parse(e){return this._getType(e)===dp.undefined?dw(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}uu.create=(e,t)=>new uu({innerType:e,typeName:$.ZodOptional,...dC(t)});class up extends d${_parse(e){return this._getType(e)===dp.null?dw(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}up.create=(e,t)=>new up({innerType:e,typeName:$.ZodNullable,...dC(t)});class um extends d${_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===dp.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}um.create=(e,t)=>new um({innerType:e,typeName:$.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...dC(t)});class uh extends d${_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 dk(i)?i.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new df(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new df(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}uh.create=(e,t)=>new uh({innerType:e,typeName:$.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...dC(t)});class uf extends d${_parse(e){if(this._getType(e)!==dp.nan){let t=this._getOrReturnCtx(e);return dv(t,{code:dh.invalid_type,expected:dp.nan,received:t.parsedType}),db}return{status:"valid",value:e.data}}}uf.create=e=>new uf({typeName:$.ZodNaN,...dC(e)}),Symbol("zod_brand");class ug extends d${_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 uy extends d${_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?db:"dirty"===e.status?(t.dirty(),dS(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?db:"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 uy({in:e,out:t,typeName:$.ZodPipeline})}}class uv extends d${_parse(e){let t=this._def.innerType._parse(e),r=e=>("valid"===e.status&&(e.value=Object.freeze(e.value)),e);return dk(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}uv.create=(e,t)=>new uv({innerType:e,typeName:$.ZodReadonly,...dC(t)}),d4.lazycreate,(b=$||($={})).ZodString="ZodString",b.ZodNumber="ZodNumber",b.ZodNaN="ZodNaN",b.ZodBigInt="ZodBigInt",b.ZodBoolean="ZodBoolean",b.ZodDate="ZodDate",b.ZodSymbol="ZodSymbol",b.ZodUndefined="ZodUndefined",b.ZodNull="ZodNull",b.ZodAny="ZodAny",b.ZodUnknown="ZodUnknown",b.ZodNever="ZodNever",b.ZodVoid="ZodVoid",b.ZodArray="ZodArray",b.ZodObject="ZodObject",b.ZodUnion="ZodUnion",b.ZodDiscriminatedUnion="ZodDiscriminatedUnion",b.ZodIntersection="ZodIntersection",b.ZodTuple="ZodTuple",b.ZodRecord="ZodRecord",b.ZodMap="ZodMap",b.ZodSet="ZodSet",b.ZodFunction="ZodFunction",b.ZodLazy="ZodLazy",b.ZodLiteral="ZodLiteral",b.ZodEnum="ZodEnum",b.ZodEffects="ZodEffects",b.ZodNativeEnum="ZodNativeEnum",b.ZodOptional="ZodOptional",b.ZodNullable="ZodNullable",b.ZodDefault="ZodDefault",b.ZodCatch="ZodCatch",b.ZodPromise="ZodPromise",b.ZodBranded="ZodBranded",b.ZodPipeline="ZodPipeline",b.ZodReadonly="ZodReadonly",dD.create,dJ.create,uf.create,dB.create,dW.create,dG.create,dK.create,dY.create,dX.create,dQ.create,d0.create,d1.create,d2.create,d9.create,d4.create,d4.strictCreate,d5.create,d6.create,d7.create,d8.create,ue.create,ut.create,ur.create,ui.create,un.create,ua.create,us.create,ul.create,uc.create,ud.create,uu.create,up.create,ud.createWithPreprocess,uy.create;let u_=(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 ub(e){if("openAi"!==e.target)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?u_(t,e.currentPath):t.join("/")}}function uS(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function uw(e,t,r,i,n){e[t]=r,uS(e,t,i,n)}function uk(e,t){return uV(e.type._def,t)}let uR=/^[cC][^\s-]{8,}$/,ux=/^[0-9a-z]+$/,uC=/^[0-9A-HJKMNP-TV-Z]{26}$/,u$=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,uT=()=>(void 0===m&&(m=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),m),uE=/^(?:(?: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])$/,uP=/^(([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])$/,uI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,uq=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,uO=/^[a-zA-Z0-9_-]{21}$/,uj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function uz(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":uw(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":uw(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":uA(r,"email",i.message,t);break;case"format:idn-email":uA(r,"idn-email",i.message,t);break;case"pattern:zod":uM(r,u$,i.message,t)}break;case"url":uA(r,"uri",i.message,t);break;case"uuid":uA(r,"uuid",i.message,t);break;case"regex":uM(r,i.regex,i.message,t);break;case"cuid":uM(r,uR,i.message,t);break;case"cuid2":uM(r,ux,i.message,t);break;case"startsWith":uM(r,RegExp(`^${uL(i.value,t)}`),i.message,t);break;case"endsWith":uM(r,RegExp(`${uL(i.value,t)}$`),i.message,t);break;case"datetime":uA(r,"date-time",i.message,t);break;case"date":uA(r,"date",i.message,t);break;case"time":uA(r,"time",i.message,t);break;case"duration":uA(r,"duration",i.message,t);break;case"length":uw(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t),uw(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":uM(r,RegExp(uL(i.value,t)),i.message,t);break;case"ip":"v6"!==i.version&&uA(r,"ipv4",i.message,t),"v4"!==i.version&&uA(r,"ipv6",i.message,t);break;case"base64url":uM(r,uq,i.message,t);break;case"jwt":uM(r,uj,i.message,t);break;case"cidr":"v6"!==i.version&&uM(r,uE,i.message,t),"v4"!==i.version&&uM(r,uP,i.message,t);break;case"emoji":uM(r,uT(),i.message,t);break;case"ulid":uM(r,uC,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":uA(r,"binary",i.message,t);break;case"contentEncoding:base64":uw(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":uM(r,uI,i.message,t)}break;case"nanoid":uM(r,uO,i.message,t)}return r}function uL(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)uN.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}let uN=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function uA(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}}})):uw(e,"format",t,r,i)}function uM(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:uZ(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):uw(e,"pattern",uZ(t,i),r,i)}function uZ(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="",a=!1,o=!1,s=!1;for(let e=0;e<i.length;e++){if(a){n+=i[e],a=!1;continue}if(r.i){if(o){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
|
|
80
|
+
`,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,a,o=e.headers.get("accept");if(!o?.includes("application/json")||!o.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(!cy(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{r=await e.json()}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else r=t.parsedBody;try{i=Array.isArray(r)?r.map(e=>n1.parse(e)):[n1.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 s=i.some(e=>ao.safeParse(e).success);if(s){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(!s){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");if(!i.some(e=>lE(e))){for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e});return new Response(null,{status:202})}let l=crypto.randomUUID(),c=i.find(e=>ao.safeParse(e).success),d=c?c.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(l,{resolveJson:r,cleanup:()=>{this._streamMapping.delete(l)}}),i))lE(e)&&this._requestToStreamMapping.set(e.id,l);for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e})});let u=new TextEncoder,p=new ReadableStream({start:e=>{n=e},cancel:()=>{void 0!==a&&clearInterval(a),this._streamMapping.get(l)?.controller===n&&this._streamMapping.delete(l)}}),m={"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&&(m["mcp-session-id"]=this.sessionId),i))lE(e)&&(this._streamMapping.set(l,{controller:n,encoder:u,cleanup:()=>{void 0!==a&&clearInterval(a),this._streamMapping.delete(l);try{n.close()}catch{}}}),this._requestToStreamMapping.set(e.id,l));for(let r of(await this.writePrimingEvent(n,u,l,d),i)){let i,n;lE(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(l)?.controller===n&&(a=this.startKeepAlive(n,u)),new Response(p,{status:200,headers:m})}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((lI(e)||lq(e))&&(r=e.id),void 0===r){let t;if(lI(e)||lq(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(lI(e)||lq(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 dn(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})}function ds(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 dc(e=null){return da(500,-32603,"Internal server error",void 0,e)}async function dd(e,t,r=!0){let i,n=e.method.toUpperCase(),a=t,o=e,s=!1;if("POST"===n){if(void 0===a){let t;r&&(o=e.clone());try{t=await e.text()}catch{return{step:"unreadable-body"}}try{i=0===t.length?void 0:JSON.parse(t)}catch{s=!0}s||void 0===i||(a=i)}else i=a;if(s||void 0===i)return{step:"no-json-body",forwardRequest:o}}return{step:"classified",outcome:function(e){if("POST"!==(e={...e,...void 0!==e.protocolVersionHeader&&{protocolVersionHeader:lK(e.protocolVersionHeader)},...void 0!==e.mcpMethodHeader&&{mcpMethodHeader:lK(e.mcpMethodHeader)},...void 0!==e.mcpNameHeader&&{mcpNameHeader:lK(e.mcpNameHeader)}}).httpMethod.toUpperCase())return{kind:"legacy",reason:"http-method"};let t=e.body;if(Array.isArray(t)){if(0===t.length)return lB("jsonrpc-shape","empty-batch",400,new s6(s3.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let e of t){if(lx(lY(e)?e.params:void 0))return lB("jsonrpc-shape","batch-with-modern-element",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(lE(e)||lP(e)||lI(e)||lq(e)))return lB("jsonrpc-shape","batch-with-invalid-element",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}return lI(t)||lq(t)?{kind:"legacy",reason:"response"}:lY(t)&&lE(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,a=void 0!==n&&n>=sI;if("initialize"===i&&!function(e){if(!lx(e))return!1;let t=lC(e);if(void 0===t||!(t>=sI))return!1;let r=lk(e);return void 0!==r&&0===l$(r).length}(r)){if(a)return lW("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let e=lY(r)&&"string"==typeof r.protocolVersion?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==e&&{requestedVersion:e}}}if(lx(r)){let a=lk(r),o=(void 0===a?[]:l$(a))[0];if(void 0!==o)return lB("envelope","envelope-invalid",400,new s6(s3.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${o.key}: ${o.problem}`,{envelope:o}),!0);let s=lC(r);return void 0!==n&&void 0!==s&&n!==s?lW("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?lW("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:lX(s)}}if(a){let e=lk(r),t=l$(e??{}).filter(e=>"missing"===e.problem).map(e=>e.key),i=void 0===e?["_meta"]:t.length>0?t:[nE];return lB("envelope","modern-header-without-claim",400,new s6(s3.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):lY(t)&&lP(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,a=void 0!==n&&n>=sI;if(lx(r)){let a=lC(r);if(void 0===a){let e=lk(r),t=(void 0===e?[]:l$(e)).find(e=>e.key===nE)??{key:nE,problem:"expected a protocol version string"};return lB("envelope","notification-envelope-invalid",400,new s6(s3.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${t.key}: ${t.problem}`,{envelope:t}),!0)}if(void 0!==n&&n!==a)return lW("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${a} but the MCP-Protocol-Version header names ${n}`);let o=lX(a);return"modern"===o.era&&void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?lW("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:o}}return a?void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?lW("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):lB("jsonrpc-shape","invalid-json-rpc-body",400,new s6(s3.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}({httpMethod:n,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,...void 0!==i&&{body:i}}),body:i,parsedBody:a,forwardRequest:o}}let du=Symbol("Let zodToJsonSchema decide on which parser to use"),dp={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"};(v=k||(k={})).assertEqual=e=>{},v.assertIs=function(e){},v.assertNever=function(e){throw Error()},v.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},v.getValidEnumValues=e=>{let t=v.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let i of t)r[i]=e[i];return v.objectValues(r)},v.objectValues=e=>v.objectKeys(e).map(function(t){return e[t]}),v.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},v.find=(e,t)=>{for(let r of e)if(t(r))return r},v.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,v.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},v.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(x||(x={})).mergeShapes=(e,t)=>({...e,...t});let dm=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),dh=e=>{switch(typeof e){case"undefined":return dm.undefined;case"string":return dm.string;case"number":return Number.isNaN(e)?dm.nan:dm.number;case"boolean":return dm.boolean;case"function":return dm.function;case"bigint":return dm.bigint;case"symbol":return dm.symbol;case"object":if(Array.isArray(e))return dm.array;if(null===e)return dm.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return dm.promise;if("undefined"!=typeof Map&&e instanceof Map)return dm.map;if("undefined"!=typeof Set&&e instanceof Set)return dm.set;if("undefined"!=typeof Date&&e instanceof Date)return dm.date;return dm.object;default:return dm.unknown}},df=k.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 dg 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];i===n.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(n))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(this),r}static assert(e){if(!(e instanceof dg))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.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()}}dg.create=e=>new dg(e);let dy=(e,t)=>{let r;switch(e.code){case df.invalid_type:r=e.received===dm.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case df.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,k.jsonStringifyReplacer)}`;break;case df.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(e.keys,", ")}`;break;case df.invalid_union:r="Invalid input";break;case df.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(e.options)}`;break;case df.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(e.options)}, received '${e.received}'`;break;case df.invalid_arguments:r="Invalid function arguments";break;case df.invalid_return_type:r="Invalid function return type";break;case df.invalid_date:r="Invalid date";break;case df.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}"`:k.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case df.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 df.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 df.custom:r="Invalid input";break;case df.invalid_intersection_types:r="Intersection results could not be merged";break;case df.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case df.not_finite:r="Number must be finite";break;default:r=t.defaultError,k.assertNever(e)}return{message:r}};(_=C||(C={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},_.toString=e=>"string"==typeof e?e:e?.message;let dv=e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,a=[...r,...n.path||[]],o={...n,path:a};if(void 0!==n.message)return{...n,path:a,message:n.message};let s="";for(let e of i.filter(e=>!!e).slice().reverse())s=e(o,{data:t,defaultError:s}).message;return{...n,path:a,message:s}};function d_(e,t){let r=dv({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,dy,void 0].filter(e=>!!e)});e.common.issues.push(r)}class db{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 dS;"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 db.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 dS;"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 dS=Object.freeze({status:"aborted"}),dw=e=>({status:"dirty",value:e}),dR=e=>({status:"valid",value:e}),dk=e=>"undefined"!=typeof Promise&&e instanceof Promise;class dx{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 dC=(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 dg(e.common.issues);return this._error=t,this._error}}};function d$(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:a}=e;return"invalid_enum_value"===t.code?{message:a??n.defaultError}:void 0===n.data?{message:a??i??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:a??r??n.defaultError}},description:n}}class dT{get description(){return this._def.description}_getType(e){return dh(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:dh(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new db,ctx:{common:e.parent.common,data:e.data,parsedType:dh(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(dk(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:dh(e)},i=this._parseSync({data:e,path:r.path,parent:r});return dC(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dh(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:dh(e)},i=this._parse({data:e,path:r.path,parent:r});return dC(r,await (dk(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,i)=>{let n=e(r),a=()=>i.addIssue({code:df.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"undefined"!=typeof Promise&&n instanceof Promise?n.then(e=>!!e||(a(),!1)):!!n||(a(),!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 uu({schema:this,typeName:$.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 up.create(this,this._def)}nullable(){return um.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return d4.create(this)}promise(){return ud.create(this,this._def)}or(e){return d3.create([this,e],this._def)}and(e){return d8.create(this,e,this._def)}transform(e){return new uu({...d$(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new uh({...d$(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:$.ZodDefault})}brand(){return new uy({typeName:$.ZodBranded,type:this,...d$(this._def)})}catch(e){return new uf({...d$(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:$.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return uv.create(this,e)}readonly(){return u_.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let dE=/^c[^\s-]{8,}$/i,dP=/^[0-9a-z]+$/,dI=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dq=/^[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,dO=/^[a-z0-9_-]{21}$/i,dj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,dz=/^[-+]?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)?)??$/,dL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,dN=/^(?:(?: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])$/,dA=/^(?:(?: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])$/,dM=/^(([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]))$/,dZ=/^(([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])$/,dU=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dH=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dF="((\\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])))",dV=RegExp(`^${dF}$`);function dD(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 dJ extends dT{_parse(e){var t,r,i,n;let a;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==dm.string){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.string,received:t.parsedType}),dS}let o=new db;for(let s of this._def.checks)if("min"===s.kind)e.data.length<s.value&&(d_(a=this._getOrReturnCtx(e,a),{code:df.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if("max"===s.kind)e.data.length>s.value&&(d_(a=this._getOrReturnCtx(e,a),{code:df.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if("length"===s.kind){let t=e.data.length>s.value,r=e.data.length<s.value;(t||r)&&(a=this._getOrReturnCtx(e,a),t?d_(a,{code:df.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):r&&d_(a,{code:df.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),o.dirty())}else if("email"===s.kind)dL.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"email",code:df.invalid_string,message:s.message}),o.dirty());else if("emoji"===s.kind)c||(c=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),c.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"emoji",code:df.invalid_string,message:s.message}),o.dirty());else if("uuid"===s.kind)dq.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"uuid",code:df.invalid_string,message:s.message}),o.dirty());else if("nanoid"===s.kind)dO.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"nanoid",code:df.invalid_string,message:s.message}),o.dirty());else if("cuid"===s.kind)dE.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"cuid",code:df.invalid_string,message:s.message}),o.dirty());else if("cuid2"===s.kind)dP.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"cuid2",code:df.invalid_string,message:s.message}),o.dirty());else if("ulid"===s.kind)dI.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"ulid",code:df.invalid_string,message:s.message}),o.dirty());else if("url"===s.kind)try{new URL(e.data)}catch{d_(a=this._getOrReturnCtx(e,a),{validation:"url",code:df.invalid_string,message:s.message}),o.dirty()}else"regex"===s.kind?(s.regex.lastIndex=0,s.regex.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"regex",code:df.invalid_string,message:s.message}),o.dirty())):"trim"===s.kind?e.data=e.data.trim():"includes"===s.kind?e.data.includes(s.value,s.position)||(d_(a=this._getOrReturnCtx(e,a),{code:df.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),o.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)||(d_(a=this._getOrReturnCtx(e,a),{code:df.invalid_string,validation:{startsWith:s.value},message:s.message}),o.dirty()):"endsWith"===s.kind?e.data.endsWith(s.value)||(d_(a=this._getOrReturnCtx(e,a),{code:df.invalid_string,validation:{endsWith:s.value},message:s.message}),o.dirty()):"datetime"===s.kind?(function(e){let t=`${dF}T${dD(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)||(d_(a=this._getOrReturnCtx(e,a),{code:df.invalid_string,validation:"datetime",message:s.message}),o.dirty()):"date"===s.kind?dV.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{code:df.invalid_string,validation:"date",message:s.message}),o.dirty()):"time"===s.kind?RegExp(`^${dD(s)}$`).test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{code:df.invalid_string,validation:"time",message:s.message}),o.dirty()):"duration"===s.kind?dz.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"duration",code:df.invalid_string,message:s.message}),o.dirty()):"ip"===s.kind?(t=e.data,!(("v4"===(r=s.version)||!r)&&dN.test(t)||("v6"===r||!r)&&dM.test(t))&&1&&(d_(a=this._getOrReturnCtx(e,a),{validation:"ip",code:df.invalid_string,message:s.message}),o.dirty())):"jwt"===s.kind?!function(e,t){if(!dj.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)&&(d_(a=this._getOrReturnCtx(e,a),{validation:"jwt",code:df.invalid_string,message:s.message}),o.dirty()):"cidr"===s.kind?(i=e.data,!(("v4"===(n=s.version)||!n)&&dA.test(i)||("v6"===n||!n)&&dZ.test(i))&&1&&(d_(a=this._getOrReturnCtx(e,a),{validation:"cidr",code:df.invalid_string,message:s.message}),o.dirty())):"base64"===s.kind?dU.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"base64",code:df.invalid_string,message:s.message}),o.dirty()):"base64url"===s.kind?dH.test(e.data)||(d_(a=this._getOrReturnCtx(e,a),{validation:"base64url",code:df.invalid_string,message:s.message}),o.dirty()):k.assertNever(s);return{status:o.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:df.invalid_string,...C.errToObj(r)})}_addCheck(e){return new dJ({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...C.errToObj(e)})}url(e){return this._addCheck({kind:"url",...C.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...C.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...C.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...C.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...C.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...C.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...C.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...C.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...C.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...C.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...C.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,...C.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,...C.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...C.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...C.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...C.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...C.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...C.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...C.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...C.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...C.errToObj(t)})}nonempty(e){return this.min(1,C.errToObj(e))}trim(){return new dJ({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new dJ({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new dJ({...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}}dJ.create=e=>new dJ({checks:[],typeName:$.ZodString,coerce:e?.coerce??!1,...d$(e)});class dB extends dT{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)!==dm.number){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.number,received:t.parsedType}),dS}let r=new db;for(let i of this._def.checks)"int"===i.kind?k.isInteger(e.data)||(d_(t=this._getOrReturnCtx(e,t),{code:df.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(d_(t=this._getOrReturnCtx(e,t),{code:df.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)&&(d_(t=this._getOrReturnCtx(e,t),{code:df.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)&&(d_(t=this._getOrReturnCtx(e,t),{code:df.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(d_(t=this._getOrReturnCtx(e,t),{code:df.not_finite,message:i.message}),r.dirty()):k.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,C.toString(t))}gt(e,t){return this.setLimit("min",e,!1,C.toString(t))}lte(e,t){return this.setLimit("max",e,!0,C.toString(t))}lt(e,t){return this.setLimit("max",e,!1,C.toString(t))}setLimit(e,t,r,i){return new dB({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:C.toString(i)}]})}_addCheck(e){return new dB({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:C.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:C.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.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&&k.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)}}dB.create=e=>new dB({checks:[],typeName:$.ZodNumber,coerce:e?.coerce||!1,...d$(e)});class dW extends dT{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)!==dm.bigint)return this._getInvalidInput(e);let r=new db;for(let i of this._def.checks)"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(d_(t=this._getOrReturnCtx(e,t),{code:df.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)&&(d_(t=this._getOrReturnCtx(e,t),{code:df.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(d_(t=this._getOrReturnCtx(e,t),{code:df.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):k.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.bigint,received:t.parsedType}),dS}gte(e,t){return this.setLimit("min",e,!0,C.toString(t))}gt(e,t){return this.setLimit("min",e,!1,C.toString(t))}lte(e,t){return this.setLimit("max",e,!0,C.toString(t))}lt(e,t){return this.setLimit("max",e,!1,C.toString(t))}setLimit(e,t,r,i){return new dW({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:C.toString(i)}]})}_addCheck(e){return new dW({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:C.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}}dW.create=e=>new dW({checks:[],typeName:$.ZodBigInt,coerce:e?.coerce??!1,...d$(e)});class dG extends dT{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==dm.boolean){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.boolean,received:t.parsedType}),dS}return dR(e.data)}}dG.create=e=>new dG({typeName:$.ZodBoolean,coerce:e?.coerce||!1,...d$(e)});class dK extends dT{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==dm.date){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.date,received:t.parsedType}),dS}if(Number.isNaN(e.data.getTime()))return d_(this._getOrReturnCtx(e),{code:df.invalid_date}),dS;let r=new db;for(let i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(d_(t=this._getOrReturnCtx(e,t),{code:df.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(d_(t=this._getOrReturnCtx(e,t),{code:df.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):k.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new dK({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:C.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:C.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}}dK.create=e=>new dK({checks:[],coerce:e?.coerce||!1,typeName:$.ZodDate,...d$(e)});class dY extends dT{_parse(e){if(this._getType(e)!==dm.symbol){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.symbol,received:t.parsedType}),dS}return dR(e.data)}}dY.create=e=>new dY({typeName:$.ZodSymbol,...d$(e)});class dX extends dT{_parse(e){if(this._getType(e)!==dm.undefined){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.undefined,received:t.parsedType}),dS}return dR(e.data)}}dX.create=e=>new dX({typeName:$.ZodUndefined,...d$(e)});class dQ extends dT{_parse(e){if(this._getType(e)!==dm.null){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.null,received:t.parsedType}),dS}return dR(e.data)}}dQ.create=e=>new dQ({typeName:$.ZodNull,...d$(e)});class d0 extends dT{constructor(){super(...arguments),this._any=!0}_parse(e){return dR(e.data)}}d0.create=e=>new d0({typeName:$.ZodAny,...d$(e)});class d1 extends dT{constructor(){super(...arguments),this._unknown=!0}_parse(e){return dR(e.data)}}d1.create=e=>new d1({typeName:$.ZodUnknown,...d$(e)});class d2 extends dT{_parse(e){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.never,received:t.parsedType}),dS}}d2.create=e=>new d2({typeName:$.ZodNever,...d$(e)});class d9 extends dT{_parse(e){if(this._getType(e)!==dm.undefined){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.void,received:t.parsedType}),dS}return dR(e.data)}}d9.create=e=>new d9({typeName:$.ZodVoid,...d$(e)});class d4 extends dT{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==dm.array)return d_(t,{code:df.invalid_type,expected:dm.array,received:t.parsedType}),dS;if(null!==i.exactLength){let e=t.data.length>i.exactLength.value,n=t.data.length<i.exactLength.value;(e||n)&&(d_(t,{code:e?df.too_big:df.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&&(d_(t,{code:df.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&&(d_(t,{code:df.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 dx(t,e,t.path,r)))).then(e=>db.mergeArray(r,e));let n=[...t.data].map((e,r)=>i.type._parseSync(new dx(t,e,t.path,r)));return db.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new d4({...this._def,minLength:{value:e,message:C.toString(t)}})}max(e,t){return new d4({...this._def,maxLength:{value:e,message:C.toString(t)}})}length(e,t){return new d4({...this._def,exactLength:{value:e,message:C.toString(t)}})}nonempty(e){return this.min(1,e)}}d4.create=(e,t)=>new d4({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...d$(t)});class d5 extends dT{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=k.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==dm.object){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.object,received:t.parsedType}),dS}let{status:t,ctx:r}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),a=[];if(!(this._def.catchall instanceof d2&&"strip"===this._def.unknownKeys))for(let e in r.data)n.includes(e)||a.push(e);let o=[];for(let e of n){let t=i[e],n=r.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new dx(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof d2){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(d_(r,{code:df.unrecognized_keys,keys:a}),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 a){let i=r.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new dx(r,i,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let r=await t.key,i=await t.value;e.push({key:r,value:i,alwaysSet:t.alwaysSet})}return e}).then(e=>db.mergeObjectSync(t,e)):db.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return C.errToObj,new d5({...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:C.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new d5({...this._def,unknownKeys:"strip"})}passthrough(){return new d5({...this._def,unknownKeys:"passthrough"})}extend(e){return new d5({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new d5({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new d5({...this._def,catchall:e})}pick(e){let t={};for(let r of k.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new d5({...this._def,shape:()=>t})}omit(e){let t={};for(let r of k.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new d5({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof d5){let r={};for(let i in t.shape){let n=t.shape[i];r[i]=up.create(e(n))}return new d5({...t._def,shape:()=>r})}if(t instanceof d4)return new d4({...t._def,type:e(t.element)});if(t instanceof up)return up.create(e(t.unwrap()));if(t instanceof um)return um.create(e(t.unwrap()));if(t instanceof ue)return ue.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of k.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new d5({...this._def,shape:()=>t})}required(e){let t={};for(let r of k.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof up;)e=e._def.innerType;t[r]=e}return new d5({...this._def,shape:()=>t})}keyof(){return us(k.objectKeys(this.shape))}}d5.create=(e,t)=>new d5({shape:()=>e,unknownKeys:"strip",catchall:d2.create(),typeName:$.ZodObject,...d$(t)}),d5.strictCreate=(e,t)=>new d5({shape:()=>e,unknownKeys:"strict",catchall:d2.create(),typeName:$.ZodObject,...d$(t)}),d5.lazycreate=(e,t)=>new d5({shape:e,unknownKeys:"strip",catchall:d2.create(),typeName:$.ZodObject,...d$(t)});class d3 extends dT{_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 dg(e.ctx.common.issues));return d_(t,{code:df.invalid_union,unionErrors:r}),dS});{let e,i=[];for(let n of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=n._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,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 dg(e));return d_(t,{code:df.invalid_union,unionErrors:n}),dS}}get options(){return this._def.options}}d3.create=(e,t)=>new d3({options:e,typeName:$.ZodUnion,...d$(t)});let d6=e=>{if(e instanceof ua)return d6(e.schema);if(e instanceof uu)return d6(e.innerType());if(e instanceof uo)return[e.value];if(e instanceof ul)return e.options;if(e instanceof uc)return k.objectValues(e.enum);else if(e instanceof uh)return d6(e._def.innerType);else if(e instanceof dX)return[void 0];else if(e instanceof dQ)return[null];else if(e instanceof up)return[void 0,...d6(e.unwrap())];else if(e instanceof um)return[null,...d6(e.unwrap())];else if(e instanceof uy)return d6(e.unwrap());else if(e instanceof u_)return d6(e.unwrap());else if(e instanceof uf)return d6(e._def.innerType);else return[]};class d7 extends dT{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==dm.object)return d_(t,{code:df.invalid_type,expected:dm.object,received:t.parsedType}),dS;let r=this.discriminator,i=t.data[r],n=this.optionsMap.get(i);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(d_(t,{code:df.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),dS)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let i=new Map;for(let r of t){let t=d6(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let n of t){if(i.has(n))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);i.set(n,r)}}return new d7({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...d$(r)})}}class d8 extends dT{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=(e,i)=>{if("aborted"===e.status||"aborted"===i.status)return dS;let n=function e(t,r){let i=dh(t),n=dh(r);if(t===r)return{valid:!0,data:t};if(i===dm.object&&n===dm.object){let i=k.objectKeys(r),n=k.objectKeys(t).filter(e=>-1!==i.indexOf(e)),a={...t,...r};for(let i of n){let n=e(t[i],r[i]);if(!n.valid)return{valid:!1};a[i]=n.data}return{valid:!0,data:a}}if(i===dm.array&&n===dm.array){if(t.length!==r.length)return{valid:!1};let i=[];for(let n=0;n<t.length;n++){let a=e(t[n],r[n]);if(!a.valid)return{valid:!1};i.push(a.data)}return{valid:!0,data:i}}if(i===dm.date&&n===dm.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}):(d_(r,{code:df.invalid_intersection_types}),dS)};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}))}}d8.create=(e,t,r)=>new d8({left:e,right:t,typeName:$.ZodIntersection,...d$(r)});class ue extends dT{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==dm.array)return d_(r,{code:df.invalid_type,expected:dm.array,received:r.parsedType}),dS;if(r.data.length<this._def.items.length)return d_(r,{code:df.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),dS;!this._def.rest&&r.data.length>this._def.items.length&&(d_(r,{code:df.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 dx(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(i).then(e=>db.mergeArray(t,e)):db.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new ue({...this._def,rest:e})}}ue.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ue({items:e,typeName:$.ZodTuple,rest:null,...d$(t)})};class ut extends dT{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!==dm.object)return d_(r,{code:df.invalid_type,expected:dm.object,received:r.parsedType}),dS;let i=[],n=this._def.keyType,a=this._def.valueType;for(let e in r.data)i.push({key:n._parse(new dx(r,e,r.path,e)),value:a._parse(new dx(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?db.mergeObjectAsync(t,i):db.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,r){return new ut(t instanceof dT?{keyType:e,valueType:t,typeName:$.ZodRecord,...d$(r)}:{keyType:dJ.create(),valueType:e,typeName:$.ZodRecord,...d$(t)})}}class ur extends dT{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!==dm.map)return d_(r,{code:df.invalid_type,expected:dm.map,received:r.parsedType}),dS;let i=this._def.keyType,n=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:i._parse(new dx(r,e,r.path,[a,"key"])),value:n._parse(new dx(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let i=await r.key,n=await r.value;if("aborted"===i.status||"aborted"===n.status)return dS;("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 a){let i=r.key,n=r.value;if("aborted"===i.status||"aborted"===n.status)return dS;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}}}}ur.create=(e,t,r)=>new ur({valueType:t,keyType:e,typeName:$.ZodMap,...d$(r)});class ui extends dT{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==dm.set)return d_(r,{code:df.invalid_type,expected:dm.set,received:r.parsedType}),dS;let i=this._def;null!==i.minSize&&r.data.size<i.minSize.value&&(d_(r,{code:df.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&&(d_(r,{code:df.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let n=this._def.valueType;function a(e){let r=new Set;for(let i of e){if("aborted"===i.status)return dS;"dirty"===i.status&&t.dirty(),r.add(i.value)}return{status:t.value,value:r}}let o=[...r.data.values()].map((e,t)=>n._parse(new dx(r,e,r.path,t)));return r.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new ui({...this._def,minSize:{value:e,message:C.toString(t)}})}max(e,t){return new ui({...this._def,maxSize:{value:e,message:C.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ui.create=(e,t)=>new ui({valueType:e,minSize:null,maxSize:null,typeName:$.ZodSet,...d$(t)});class un extends dT{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==dm.function)return d_(t,{code:df.invalid_type,expected:dm.function,received:t.parsedType}),dS;function r(e,r){return dv({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dy,dy].filter(e=>!!e),issueData:{code:df.invalid_arguments,argumentsError:r}})}function i(e,r){return dv({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dy,dy].filter(e=>!!e),issueData:{code:df.invalid_return_type,returnTypeError:r}})}let n={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ud){let e=this;return dR(async function(...t){let o=new dg([]),s=await e._def.args.parseAsync(t,n).catch(e=>{throw o.addIssue(r(t,e)),o}),l=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(l,n).catch(e=>{throw o.addIssue(i(l,e)),o})})}{let e=this;return dR(function(...t){let o=e._def.args.safeParse(t,n);if(!o.success)throw new dg([r(t,o.error)]);let s=Reflect.apply(a,this,o.data),l=e._def.returns.safeParse(s,n);if(!l.success)throw new dg([i(s,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new un({...this._def,args:ue.create(e).rest(d1.create())})}returns(e){return new un({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new un({args:e||ue.create([]).rest(d1.create()),returns:t||d1.create(),typeName:$.ZodFunction,...d$(r)})}}class ua extends dT{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})}}ua.create=(e,t)=>new ua({getter:e,typeName:$.ZodLazy,...d$(t)});class uo extends dT{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return d_(t,{received:t.data,code:df.invalid_literal,expected:this._def.value}),dS}return{status:"valid",value:e.data}}get value(){return this._def.value}}function us(e,t){return new ul({values:e,typeName:$.ZodEnum,...d$(t)})}uo.create=(e,t)=>new uo({value:e,typeName:$.ZodLiteral,...d$(t)});class ul extends dT{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return d_(t,{expected:k.joinValues(r),received:t.parsedType,code:df.invalid_type}),dS}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 d_(t,{received:t.data,code:df.invalid_enum_value,options:r}),dS}return dR(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 ul.create(e,{...this._def,...t})}exclude(e,t=this._def){return ul.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}ul.create=us;class uc extends dT{_parse(e){let t=k.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==dm.string&&r.parsedType!==dm.number){let e=k.objectValues(t);return d_(r,{expected:k.joinValues(e),received:r.parsedType,code:df.invalid_type}),dS}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=k.objectValues(t);return d_(r,{received:r.data,code:df.invalid_enum_value,options:e}),dS}return dR(e.data)}get enum(){return this._def.values}}uc.create=(e,t)=>new uc({values:e,typeName:$.ZodNativeEnum,...d$(t)});class ud extends dT{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==dm.promise&&!1===t.common.async?(d_(t,{code:df.invalid_type,expected:dm.promise,received:t.parsedType}),dS):dR((t.parsedType===dm.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ud.create=(e,t)=>new ud({type:e,typeName:$.ZodPromise,...d$(t)});class uu extends dT{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.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=>{d_(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 dS;let i=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===i.status?dS:"dirty"===i.status||"dirty"===t.value?dw(i.value):i});{if("aborted"===t.value)return dS;let i=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===i.status?dS:"dirty"===i.status||"dirty"===t.value?dw(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?dS:("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?dS:("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?dS: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 dS;let a=i.transform(e.value,n);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}k.assertNever(i)}}uu.create=(e,t,r)=>new uu({schema:e,typeName:$.ZodEffects,effect:t,...d$(r)}),uu.createWithPreprocess=(e,t,r)=>new uu({schema:t,effect:{type:"preprocess",transform:e},typeName:$.ZodEffects,...d$(r)});class up extends dT{_parse(e){return this._getType(e)===dm.undefined?dR(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}up.create=(e,t)=>new up({innerType:e,typeName:$.ZodOptional,...d$(t)});class um extends dT{_parse(e){return this._getType(e)===dm.null?dR(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}um.create=(e,t)=>new um({innerType:e,typeName:$.ZodNullable,...d$(t)});class uh extends dT{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===dm.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}uh.create=(e,t)=>new uh({innerType:e,typeName:$.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...d$(t)});class uf extends dT{_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 dk(i)?i.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new dg(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new dg(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}uf.create=(e,t)=>new uf({innerType:e,typeName:$.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...d$(t)});class ug extends dT{_parse(e){if(this._getType(e)!==dm.nan){let t=this._getOrReturnCtx(e);return d_(t,{code:df.invalid_type,expected:dm.nan,received:t.parsedType}),dS}return{status:"valid",value:e.data}}}ug.create=e=>new ug({typeName:$.ZodNaN,...d$(e)}),Symbol("zod_brand");class uy extends dT{_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 uv extends dT{_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?dS:"dirty"===e.status?(t.dirty(),dw(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?dS:"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 uv({in:e,out:t,typeName:$.ZodPipeline})}}class u_ extends dT{_parse(e){let t=this._def.innerType._parse(e),r=e=>("valid"===e.status&&(e.value=Object.freeze(e.value)),e);return dk(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}u_.create=(e,t)=>new u_({innerType:e,typeName:$.ZodReadonly,...d$(t)}),d5.lazycreate,(b=$||($={})).ZodString="ZodString",b.ZodNumber="ZodNumber",b.ZodNaN="ZodNaN",b.ZodBigInt="ZodBigInt",b.ZodBoolean="ZodBoolean",b.ZodDate="ZodDate",b.ZodSymbol="ZodSymbol",b.ZodUndefined="ZodUndefined",b.ZodNull="ZodNull",b.ZodAny="ZodAny",b.ZodUnknown="ZodUnknown",b.ZodNever="ZodNever",b.ZodVoid="ZodVoid",b.ZodArray="ZodArray",b.ZodObject="ZodObject",b.ZodUnion="ZodUnion",b.ZodDiscriminatedUnion="ZodDiscriminatedUnion",b.ZodIntersection="ZodIntersection",b.ZodTuple="ZodTuple",b.ZodRecord="ZodRecord",b.ZodMap="ZodMap",b.ZodSet="ZodSet",b.ZodFunction="ZodFunction",b.ZodLazy="ZodLazy",b.ZodLiteral="ZodLiteral",b.ZodEnum="ZodEnum",b.ZodEffects="ZodEffects",b.ZodNativeEnum="ZodNativeEnum",b.ZodOptional="ZodOptional",b.ZodNullable="ZodNullable",b.ZodDefault="ZodDefault",b.ZodCatch="ZodCatch",b.ZodPromise="ZodPromise",b.ZodBranded="ZodBranded",b.ZodPipeline="ZodPipeline",b.ZodReadonly="ZodReadonly",dJ.create,dB.create,ug.create,dW.create,dG.create,dK.create,dY.create,dX.create,dQ.create,d0.create,d1.create,d2.create,d9.create,d4.create,d5.create,d5.strictCreate,d3.create,d7.create,d8.create,ue.create,ut.create,ur.create,ui.create,un.create,ua.create,uo.create,ul.create,uc.create,ud.create,uu.create,up.create,um.create,uu.createWithPreprocess,uv.create;let ub=(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 uS(e){if("openAi"!==e.target)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?ub(t,e.currentPath):t.join("/")}}function uw(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function uR(e,t,r,i,n){e[t]=r,uw(e,t,i,n)}function uk(e,t){return uD(e.type._def,t)}let ux=/^[cC][^\s-]{8,}$/,uC=/^[0-9a-z]+$/,u$=/^[0-9A-HJKMNP-TV-Z]{26}$/,uT=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,uE=()=>(void 0===m&&(m=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),m),uP=/^(?:(?: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])$/,uI=/^(([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])$/,uq=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,uO=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,uj=/^[a-zA-Z0-9_-]{21}$/,uz=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function uL(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":uR(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":uR(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":uM(r,"email",i.message,t);break;case"format:idn-email":uM(r,"idn-email",i.message,t);break;case"pattern:zod":uZ(r,uT,i.message,t)}break;case"url":uM(r,"uri",i.message,t);break;case"uuid":uM(r,"uuid",i.message,t);break;case"regex":uZ(r,i.regex,i.message,t);break;case"cuid":uZ(r,ux,i.message,t);break;case"cuid2":uZ(r,uC,i.message,t);break;case"startsWith":uZ(r,RegExp(`^${uN(i.value,t)}`),i.message,t);break;case"endsWith":uZ(r,RegExp(`${uN(i.value,t)}$`),i.message,t);break;case"datetime":uM(r,"date-time",i.message,t);break;case"date":uM(r,"date",i.message,t);break;case"time":uM(r,"time",i.message,t);break;case"duration":uM(r,"duration",i.message,t);break;case"length":uR(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t),uR(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":uZ(r,RegExp(uN(i.value,t)),i.message,t);break;case"ip":"v6"!==i.version&&uM(r,"ipv4",i.message,t),"v4"!==i.version&&uM(r,"ipv6",i.message,t);break;case"base64url":uZ(r,uO,i.message,t);break;case"jwt":uZ(r,uz,i.message,t);break;case"cidr":"v6"!==i.version&&uZ(r,uP,i.message,t),"v4"!==i.version&&uZ(r,uI,i.message,t);break;case"emoji":uZ(r,uE(),i.message,t);break;case"ulid":uZ(r,u$,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":uM(r,"binary",i.message,t);break;case"contentEncoding:base64":uR(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":uZ(r,uq,i.message,t)}break;case"nanoid":uZ(r,uj,i.message,t)}return r}function uN(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)uA.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}let uA=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function uM(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}}})):uR(e,"format",t,r,i)}function uZ(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:uU(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):uR(e,"pattern",uU(t,i),r,i)}function uU(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="",a=!1,o=!1,s=!1;for(let e=0;e<i.length;e++){if(a){n+=i[e],a=!1;continue}if(r.i){if(o){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
|
|
81
81
|
]))`;continue}else if("$"===i[e]){n+=`($|(?=[\r
|
|
82
82
|
]))`;continue}}if(r.s&&"."===i[e]){n+=o?`${i[e]}\r
|
|
83
83
|
`:`[${i[e]}\r
|
|
84
|
-
]`;continue}n+=i[e],"\\"===i[e]?a=!0:o&&"]"===i[e]?o=!1:o||"["!==i[e]||(o=!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 uU(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===$.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:uV(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??ub(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:uV(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===$.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=uz(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName===$.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===$.ZodBranded&&e.keyType._def.type._def.typeName===$.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=uk(e.keyType._def,t);return{...r,propertyNames:n}}return r}let uH={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},uF=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>uV(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 uV(e,t,r=!1){let i=t.seen.get(e);if(t.override){let n=t.override?.(e,t,i,r);if(n!==dd)return n}if(i&&!r){let e=uD(i,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=((e,t,r)=>{switch(t){case $.ZodString:return uz(e,r);case $.ZodNumber:let i={type:"number"};if(!e.checks)return i;for(let t of e.checks)switch(t.kind){case"int":i.type="integer",uS(i,"type",t.message,r);break;case"min":"jsonSchema7"===r.target?t.inclusive?uw(i,"minimum",t.value,t.message,r):uw(i,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(i.exclusiveMinimum=!0),uw(i,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uw(i,"maximum",t.value,t.message,r):uw(i,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(i.exclusiveMaximum=!0),uw(i,"maximum",t.value,t.message,r));break;case"multipleOf":uw(i,"multipleOf",t.value,t.message,r)}return i;case $.ZodObject:return function(e,t){let r="openAi"===t.target,i={type:"object",properties:{}},n=[],a=e.shape();for(let e in a){let o=a[e];if(void 0===o||void 0===o._def)continue;let s=function(e){try{return e.isOptional()}catch{return!0}}(o);s&&r&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let l=uV(o._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 o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return uV(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!==o&&(i.additionalProperties=o),i}(e,r);case $.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?uw(n,"minimum",t.value,t.message,r):uw(n,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(n.exclusiveMinimum=!0),uw(n,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uw(n,"maximum",t.value,t.message,r):uw(n,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(n.exclusiveMaximum=!0),uw(n,"maximum",t.value,t.message,r));break;case"multipleOf":uw(n,"multipleOf",t.value,t.message,r)}return n;case $.ZodBoolean:return{type:"boolean"};case $.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 a=t,o=r;let s={type:"integer",format:"unix-time"};if("openApi3"===o.target)return s;for(let e of a.checks)switch(e.kind){case"min":uw(s,"minimum",e.value,e.message,o);break;case"max":uw(s,"maximum",e.value,e.message,o)}return s}}(e,r);case $.ZodUndefined:return{not:ub(r)};case $.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case $.ZodArray:let a;return a={type:"array"},e.type?._def&&e.type?._def?.typeName!==$.ZodAny&&(a.items=uV(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&uw(a,"minItems",e.minLength.value,e.minLength.message,r),e.maxLength&&uw(a,"maxItems",e.maxLength.value,e.maxLength.message,r),e.exactLength&&(uw(a,"minItems",e.exactLength.value,e.exactLength.message,r),uw(a,"maxItems",e.exactLength.value,e.exactLength.message,r)),a;case $.ZodUnion:case $.ZodDiscriminatedUnion:if("openApi3"===r.target)return uF(e,r);let o=e.options instanceof Map?Array.from(e.options.values()):e.options;if(o.every(e=>e._def.typeName in uH&&(!e._def.checks||!e._def.checks.length))){let e=o.reduce((e,t)=>{let r=uH[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(o.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=o.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===o.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:o.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(o.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:o.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return uF(e,r);case $.ZodIntersection:let s,l,c;return s=[uV(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),uV(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 $.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>uV(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:uV(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>uV(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case $.ZodRecord:return uU(e,r);case $.ZodLiteral:let d;return"bigint"!=(d=typeof e.value)&&"number"!==d&&"boolean"!==d&&"string"!==d?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===r.target?{type:"bigint"===d?"integer":d,enum:[e.value]}:{type:"bigint"===d?"integer":d,const:e.value};case $.ZodEnum:return{type:"string",enum:Array.from(e.values)};case $.ZodNativeEnum:let u,p,m;return u=e.values,{type:1===(m=Array.from(new Set((p=Object.keys(e.values).filter(e=>"number"!=typeof u[u[e]]).map(e=>u[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:p};case $.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:uH[e.innerType._def.typeName],nullable:!0}:{type:[uH[e.innerType._def.typeName],"null"]};if("openApi3"===r.target){let t=uV(e.innerType._def,{...r,currentPath:[...r.currentPath]});return t&&"$ref"in t?{allOf:[t],nullable:!0}:t&&{...t,nullable:!0}}let h=uV(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return h&&{anyOf:[h,{type:"null"}]};case $.ZodOptional:if(r.currentPath.toString()===r.propertyPath?.toString())return uV(e.innerType._def,r);let f=uV(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return f?{anyOf:[{not:ub(r)},f]}:ub(r);case $.ZodMap:if("record"===r.mapStrategy)return uU(e,r);return{type:"array",maxItems:125,items:{type:"array",items:[uV(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||ub(r),uV(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||ub(r)],minItems:2,maxItems:2}};case $.ZodSet:let g;return g={type:"array",uniqueItems:!0,items:uV(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&uw(g,"minItems",e.minSize.value,e.minSize.message,r),e.maxSize&&uw(g,"maxItems",e.maxSize.value,e.maxSize.message,r),g;case $.ZodLazy:return()=>e.getter()._def;case $.ZodPromise:return uV(e.type._def,r);case $.ZodNaN:case $.ZodNever:return"openAi"===r.target?void 0:{not:ub({...r,currentPath:[...r.currentPath,"not"]})};case $.ZodEffects:return"input"===r.effectStrategy?uV(e.schema._def,r):ub(r);case $.ZodAny:case $.ZodUnknown:return ub(r);case $.ZodDefault:return{...uV(e.innerType._def,r),default:e.defaultValue()};case $.ZodBranded:return uk(e,r);case $.ZodReadonly:case $.ZodCatch:return uV(e.innerType._def,r);case $.ZodPipeline:if("input"===r.pipeStrategy)return uV(e.in._def,r);if("output"===r.pipeStrategy)return uV(e.out._def,r);let y=uV(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),v=uV(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",y?"1":"0"]});return{allOf:[y,v].filter(e=>void 0!==e)};case $.ZodFunction:case $.ZodVoid:case $.ZodSymbol:default:return}})(e,e.typeName,t),o="function"==typeof a?uV(a(),t):a;if(o&&uJ(e,t,o),t.postProcess){let r=t.postProcess(o,e,t);return n.jsonSchema=o,r}return n.jsonSchema=o,o}let uD=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:u_(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`),ub(t);return"seen"===t.$refStrategy?ub(t):void 0}},uJ=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function uB(e,t={}){let{strict:r=!1}=t,i=Object.entries(e),n=e=>({target:t})=>{let n={},a=[];for(let[r,o]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?{...du,name:t}:{...du,...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}]))}),a="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:uV(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??ub(n)}),{}):void 0,o="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=uV(e._def,void 0===o?n:{...n,currentPath:[...n.basePath,n.definitionPath,o]},!1)??ub(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&&(a||(a={}),a[n.openAiAnyTypeName]||(a[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===o?a?{...s,[n.definitionPath]:a}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,o].join("/"),[n.definitionPath]:{...a,[o]: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=r5(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".`)}(o,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}}(o,e)&&a.push(r);let o={type:"object",properties:n};return a.length>0&&(o.required=a),r&&(o.additionalProperties=!1),o},a=async t=>{if("object"!=typeof t||null===t||Array.isArray(t))return{issues:[{message:"Expected an object."}]};let n={},a=[];for(let[e,r]of i){let i=await r["~standard"].validate(t[e]);if(i.issues)for(let t of i.issues)a.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||a.push({message:`Unrecognized key: "${r}"`,path:[r]});return a.length>0?{issues:a}:{value:n}};return{shape:e,"~standard":{version:1,vendor:"xmcp",validate:a,jsonSchema:{input:n("input"),output:n("output")}}}}let uW=(e,t)=>{globalThis[e]=t},uG=e=>globalThis[e];function uK({name:e}){let t=Symbol.for(`xmcp-context-${e}`),r=Symbol.for(`xmcp-context-${e}-fallback-store`);if(uG(t))return uG(t);let i=new h,n=globalThis[r]??{current:null};uW(r,n);let a={provider:(e,t)=>(n.current=e,i.run(e,t)),getContext:()=>{let t=i.getStore();if(t)return t;if(n.current)return n.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:t=>{let r=i.getStore()??n.current;if(!r)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(r,t)}};return uW(t,a),a}let uY=uK({name:"http-request-context"});uY.setContext;let uX=uY.getContext,uQ=uY.provider,u0=uK({name:"client-info-context"});u0.setContext;let u1=u0.getContext;u0.provider;let u2=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),u9=e=>{if(!u2(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},u4=e=>{if(e&&"initialize"===e.method&&u2(e.params))return u9(e.params.clientInfo)},u5=(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}},u3=new Set(["message","mode","requestedSchema"]),u6=new Set(["elicitationId","message","mode","url"]),u7=new Set(["properties","required","type"]),u8=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"]);async function pn(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."),pa(e,u6,"URL elicitation"),ps(e.message,"URL elicitation requires a string message."),pl(e.elicitationId,"URL elicitation requires a non-empty elicitationId."),pl(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."),pa(e,u3,"Form elicitation"),ps(e.message,"Form elicitation requires a string message.");let t=e.requestedSchema;if(po(t,"Form elicitation requires a flat object schema."),pa(t,u7,"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.`),pc(t.title,`Form elicitation field "${e}" title must be a string.`),pc(t.description,`Form elicitation field "${e}" description must be a string.`),"string"===t.type&&"enum"in t){var r,i;if(pa(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(pc(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)){pa(t,u8,`Form elicitation field "${e}"`),pd(t.minLength,`Form elicitation field "${e}" minLength must be a number.`),pd(t.maxLength,`Form elicitation field "${e}" maxLength must be a number.`),pc(t.default,`Form elicitation field "${e}" default must be a string.`);let r=t.format;if(pc(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(pa(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){pa(t,pr,`Form elicitation field "${e}"`),pd(t.minimum,`Form elicitation field "${e}" minimum must be a number.`),pd(t.maximum,`Form elicitation field "${e}" maximum must be a number.`),pd(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 s$&&e.code===sC.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}}function pa(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 ps(e,t){if("string"!=typeof e)throw Error(t)}function pl(e,t){if("string"!=typeof e||0===e.trim().length)throw Error(t)}function pc(e,t){if(void 0!==e&&"string"!=typeof e)throw Error(t)}function pd(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 pp=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),pm=new Set(["task","toolChoice","tools"]),ph=new Set(["text","image","audio"]);async function pf(e,t,r){let i=function(e){pg(e,"Sampling request must be a plain object.");let t=Object.keys(e),r=t.filter(e=>pm.has(e));if(r.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${r.join(", ")}.`);let i=t.filter(e=>!pp.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(pg(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;pg(r,`Sampling message at index ${e} requires a content object.`);let i=r.type;if("string"!=typeof i||!ph.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 s$&&e.code===sC.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}}function pg(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}let py={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 pv(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=py[e.type];return t?t(e):{valid:!0}}function p_(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)),a=Object.keys(e).filter(e=>!n.has(e));if(a.length>0)throw Error(`Tool "${r}" ${i}: unrecognized key(s): ${a.join(", ")}`);for(let[n,a]of Object.entries(t))try{a.parse(e[n])}catch(e){throw Error(`Tool "${r}" ${i}: ${e?.message??`invalid field "${n}"`}`)}}function pb(e){return!!(e&&"object"==typeof e&&Object.keys(e).some(e=>e.startsWith("ui/")))}function pS(e){return e.endsWith(".tsx")}let pw=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}};function pk(e){let t={};return!function e(r,i=""){if(r&&"object"==typeof r)for(let[n,a]of Object.entries(r)){let r=i?`${i}/${n}`:n;!a||"object"!=typeof a||Array.isArray(a)||a instanceof Date||a instanceof RegExp?t[r]=a:e(a,r)}}(e),t}let pR=["ui/resourceUri","resourceUri","visibility"],px=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"];function pC(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 p$(e){return(e.split("/").pop()||e).replace(/\.[^/.]+$/,"")}function pT(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),a=t.slice(r+1),o=a[a.length-1];if(o&&o.includes(".")){let e=o.split(".")[0];"index"!==e?a[a.length-1]=e:a.pop()}let s=[],l=[],c=a.map(e=>{if(!e.match(/^\[.+\]$/))return l.push(e),e;{let t=e.slice(1,-1);return s.push(t),`{${t}}`}}),d=`${n}://${c.join("/")}`,u=s.length>0?"template":"direct";return{filePath:e,uriTemplate:d,scheme:n,parameters:s,pathSegments:l,type:u}}function pE(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 pP(e){return Error(`[xmcp] Invalid prompt file: ${e}
|
|
85
|
-
-> Default export must be a prompt handler function.`)}async function
|
|
86
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} prompt${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function
|
|
87
|
-
-> Default export must be a resource handler function.`)}async function
|
|
88
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} resource${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function
|
|
89
|
-
-> Default export must be a tool handler function.`)}async function
|
|
90
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} tool${1===n?"":"s"} skipped due to empty files or missing default exports`)}}(),
|
|
84
|
+
]`;continue}n+=i[e],"\\"===i[e]?a=!0:o&&"]"===i[e]?o=!1:o||"["!==i[e]||(o=!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 uH(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===$.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:uD(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??uS(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:uD(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===$.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=uL(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName===$.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===$.ZodBranded&&e.keyType._def.type._def.typeName===$.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=uk(e.keyType._def,t);return{...r,propertyNames:n}}return r}let uF={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},uV=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>uD(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 uD(e,t,r=!1){let i=t.seen.get(e);if(t.override){let n=t.override?.(e,t,i,r);if(n!==du)return n}if(i&&!r){let e=uJ(i,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=((e,t,r)=>{switch(t){case $.ZodString:return uL(e,r);case $.ZodNumber:let i={type:"number"};if(!e.checks)return i;for(let t of e.checks)switch(t.kind){case"int":i.type="integer",uw(i,"type",t.message,r);break;case"min":"jsonSchema7"===r.target?t.inclusive?uR(i,"minimum",t.value,t.message,r):uR(i,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(i.exclusiveMinimum=!0),uR(i,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uR(i,"maximum",t.value,t.message,r):uR(i,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(i.exclusiveMaximum=!0),uR(i,"maximum",t.value,t.message,r));break;case"multipleOf":uR(i,"multipleOf",t.value,t.message,r)}return i;case $.ZodObject:return function(e,t){let r="openAi"===t.target,i={type:"object",properties:{}},n=[],a=e.shape();for(let e in a){let o=a[e];if(void 0===o||void 0===o._def)continue;let s=function(e){try{return e.isOptional()}catch{return!0}}(o);s&&r&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let l=uD(o._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 o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return uD(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!==o&&(i.additionalProperties=o),i}(e,r);case $.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?uR(n,"minimum",t.value,t.message,r):uR(n,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(n.exclusiveMinimum=!0),uR(n,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uR(n,"maximum",t.value,t.message,r):uR(n,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(n.exclusiveMaximum=!0),uR(n,"maximum",t.value,t.message,r));break;case"multipleOf":uR(n,"multipleOf",t.value,t.message,r)}return n;case $.ZodBoolean:return{type:"boolean"};case $.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 a=t,o=r;let s={type:"integer",format:"unix-time"};if("openApi3"===o.target)return s;for(let e of a.checks)switch(e.kind){case"min":uR(s,"minimum",e.value,e.message,o);break;case"max":uR(s,"maximum",e.value,e.message,o)}return s}}(e,r);case $.ZodUndefined:return{not:uS(r)};case $.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case $.ZodArray:let a;return a={type:"array"},e.type?._def&&e.type?._def?.typeName!==$.ZodAny&&(a.items=uD(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&uR(a,"minItems",e.minLength.value,e.minLength.message,r),e.maxLength&&uR(a,"maxItems",e.maxLength.value,e.maxLength.message,r),e.exactLength&&(uR(a,"minItems",e.exactLength.value,e.exactLength.message,r),uR(a,"maxItems",e.exactLength.value,e.exactLength.message,r)),a;case $.ZodUnion:case $.ZodDiscriminatedUnion:if("openApi3"===r.target)return uV(e,r);let o=e.options instanceof Map?Array.from(e.options.values()):e.options;if(o.every(e=>e._def.typeName in uF&&(!e._def.checks||!e._def.checks.length))){let e=o.reduce((e,t)=>{let r=uF[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(o.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=o.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===o.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:o.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(o.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:o.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return uV(e,r);case $.ZodIntersection:let s,l,c;return s=[uD(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),uD(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 $.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>uD(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:uD(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>uD(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case $.ZodRecord:return uH(e,r);case $.ZodLiteral:let d;return"bigint"!=(d=typeof e.value)&&"number"!==d&&"boolean"!==d&&"string"!==d?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===r.target?{type:"bigint"===d?"integer":d,enum:[e.value]}:{type:"bigint"===d?"integer":d,const:e.value};case $.ZodEnum:return{type:"string",enum:Array.from(e.values)};case $.ZodNativeEnum:let u,p,m;return u=e.values,{type:1===(m=Array.from(new Set((p=Object.keys(e.values).filter(e=>"number"!=typeof u[u[e]]).map(e=>u[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:p};case $.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:uF[e.innerType._def.typeName],nullable:!0}:{type:[uF[e.innerType._def.typeName],"null"]};if("openApi3"===r.target){let t=uD(e.innerType._def,{...r,currentPath:[...r.currentPath]});return t&&"$ref"in t?{allOf:[t],nullable:!0}:t&&{...t,nullable:!0}}let h=uD(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return h&&{anyOf:[h,{type:"null"}]};case $.ZodOptional:if(r.currentPath.toString()===r.propertyPath?.toString())return uD(e.innerType._def,r);let f=uD(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return f?{anyOf:[{not:uS(r)},f]}:uS(r);case $.ZodMap:if("record"===r.mapStrategy)return uH(e,r);return{type:"array",maxItems:125,items:{type:"array",items:[uD(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||uS(r),uD(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||uS(r)],minItems:2,maxItems:2}};case $.ZodSet:let g;return g={type:"array",uniqueItems:!0,items:uD(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&uR(g,"minItems",e.minSize.value,e.minSize.message,r),e.maxSize&&uR(g,"maxItems",e.maxSize.value,e.maxSize.message,r),g;case $.ZodLazy:return()=>e.getter()._def;case $.ZodPromise:return uD(e.type._def,r);case $.ZodNaN:case $.ZodNever:return"openAi"===r.target?void 0:{not:uS({...r,currentPath:[...r.currentPath,"not"]})};case $.ZodEffects:return"input"===r.effectStrategy?uD(e.schema._def,r):uS(r);case $.ZodAny:case $.ZodUnknown:return uS(r);case $.ZodDefault:return{...uD(e.innerType._def,r),default:e.defaultValue()};case $.ZodBranded:return uk(e,r);case $.ZodReadonly:case $.ZodCatch:return uD(e.innerType._def,r);case $.ZodPipeline:if("input"===r.pipeStrategy)return uD(e.in._def,r);if("output"===r.pipeStrategy)return uD(e.out._def,r);let y=uD(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),v=uD(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",y?"1":"0"]});return{allOf:[y,v].filter(e=>void 0!==e)};case $.ZodFunction:case $.ZodVoid:case $.ZodSymbol:default:return}})(e,e.typeName,t),o="function"==typeof a?uD(a(),t):a;if(o&&uB(e,t,o),t.postProcess){let r=t.postProcess(o,e,t);return n.jsonSchema=o,r}return n.jsonSchema=o,o}let uJ=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:ub(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`),uS(t);return"seen"===t.$refStrategy?uS(t):void 0}},uB=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function uW(e,t={}){let{strict:r=!1}=t,i=Object.entries(e),n=e=>({target:t})=>{let n={},a=[];for(let[r,o]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?{...dp,name:t}:{...dp,...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}]))}),a="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:uD(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??uS(n)}),{}):void 0,o="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=uD(e._def,void 0===o?n:{...n,currentPath:[...n.basePath,n.definitionPath,o]},!1)??uS(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&&(a||(a={}),a[n.openAiAnyTypeName]||(a[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===o?a?{...s,[n.definitionPath]:a}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,o].join("/"),[n.definitionPath]:{...a,[o]: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=r5(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".`)}(o,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}}(o,e)&&a.push(r);let o={type:"object",properties:n};return a.length>0&&(o.required=a),r&&(o.additionalProperties=!1),o},a=async t=>{if("object"!=typeof t||null===t||Array.isArray(t))return{issues:[{message:"Expected an object."}]};let n={},a=[];for(let[e,r]of i){let i=await r["~standard"].validate(t[e]);if(i.issues)for(let t of i.issues)a.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||a.push({message:`Unrecognized key: "${r}"`,path:[r]});return a.length>0?{issues:a}:{value:n}};return{shape:e,"~standard":{version:1,vendor:"xmcp",validate:a,jsonSchema:{input:n("input"),output:n("output")}}}}let uG=(e,t)=>{globalThis[e]=t},uK=e=>globalThis[e];function uY({name:e,fallback:t=!0}){let r=Symbol.for(`xmcp-context-${e}`),i=Symbol.for(`xmcp-context-${e}-fallback-store`);if(uK(r))return uK(r);let n=new h,a=globalThis[i]??{current:null};uG(i,a);let o={provider:(e,r)=>(t&&(a.current=e),n.run(e,r)),getContext:()=>{let r=n.getStore();if(r)return r;if(t&&a.current)return a.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:r=>{let i=n.getStore()??(t?a.current:null);if(!i)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(i,r)}};return uG(r,o),o}let uX=uY({name:"http-request-context"});uX.setContext;let uQ=uX.getContext,u0=uX.provider,u1=uY({name:"client-info-context"});u1.setContext;let u2=u1.getContext;u1.provider;let u9=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),u4=e=>{if(!u9(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},u5=e=>{if(e&&"initialize"===e.method&&u9(e.params))return u4(e.params.clientInfo)},u3=(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}},u6=new Set(["message","mode","requestedSchema"]),u7=new Set(["elicitationId","message","mode","url"]),u8=new Set(["properties","required","type"]),pe=new Set(["default","description","format","maxLength","minLength","title","type"]),pt=new Set(["default","description","enum","enumNames","title","type"]),pr=new Set(["default","description","title","type"]),pi=new Set(["default","description","maximum","minimum","title","type"]),pn=new Set(["date","date-time","email","uri"]);async function pa(e,t,r){let i=function(e){let t=e.mode??"form";if("url"===t)return function(e){let t;ps(e,"Elicitation request must be a plain object."),po(e,u7,"URL elicitation"),pl(e.message,"URL elicitation requires a string message."),pc(e.elicitationId,"URL elicitation requires a non-empty elicitationId."),pc(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){ps(e,"Elicitation request must be a plain object."),po(e,u6,"Form elicitation"),pl(e.message,"Form elicitation requires a string message.");let t=e.requestedSchema;if(ps(t,"Form elicitation requires a flat object schema."),po(t,u8,"Form elicitation schema"),"object"!==t.type)throw Error('Form elicitation schema must use type "object".');for(let[e,r]of(ps(t.properties,"Form elicitation schema requires a properties object."),Object.entries(t.properties)))!function(e,t){if(ps(t,`Form elicitation field "${e}" must be a plain object.`),pd(t.title,`Form elicitation field "${e}" title must be a string.`),pd(t.description,`Form elicitation field "${e}" description must be a string.`),"string"===t.type&&"enum"in t){var r,i;if(po(t,pt,`Form elicitation field "${e}"`),pp(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&&pp(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(pd(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)){po(t,pe,`Form elicitation field "${e}"`),pu(t.minLength,`Form elicitation field "${e}" minLength must be a number.`),pu(t.maxLength,`Form elicitation field "${e}" maxLength must be a number.`),pd(t.default,`Form elicitation field "${e}" default must be a string.`);let r=t.format;if(pd(r,`Form elicitation field "${e}" format must be a string.`),void 0!==r&&!pn.has(r))throw Error(`Form elicitation field "${e}" format must be one of: ${Array.from(pn).join(", ")}.`);return}if("boolean"===t.type){if(po(t,pr,`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){po(t,pi,`Form elicitation field "${e}"`),pu(t.minimum,`Form elicitation field "${e}" minimum must be a number.`),pu(t.maximum,`Form elicitation field "${e}" maximum must be a number.`),pu(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 s$&&e.code===sC.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}}function po(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 ps(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}function pl(e,t){if("string"!=typeof e)throw Error(t)}function pc(e,t){if("string"!=typeof e||0===e.trim().length)throw Error(t)}function pd(e,t){if(void 0!==e&&"string"!=typeof e)throw Error(t)}function pu(e,t){if(void 0!==e&&"number"!=typeof e)throw Error(t)}function pp(e,t){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e))throw Error(t)}let pm=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),ph=new Set(["task","toolChoice","tools"]),pf=new Set(["text","image","audio"]);async function pg(e,t,r){let i=function(e){py(e,"Sampling request must be a plain object.");let t=Object.keys(e),r=t.filter(e=>ph.has(e));if(r.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${r.join(", ")}.`);let i=t.filter(e=>!pm.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(py(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;py(r,`Sampling message at index ${e} requires a content object.`);let i=r.type;if("string"!=typeof i||!pf.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 s$&&e.code===sC.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}}function py(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}let pv={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 p_(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=pv[e.type];return t?t(e):{valid:!0}}function pb(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)),a=Object.keys(e).filter(e=>!n.has(e));if(a.length>0)throw Error(`Tool "${r}" ${i}: unrecognized key(s): ${a.join(", ")}`);for(let[n,a]of Object.entries(t))try{a.parse(e[n])}catch(e){throw Error(`Tool "${r}" ${i}: ${e?.message??`invalid field "${n}"`}`)}}function pS(e){return!!(e&&"object"==typeof e&&Object.keys(e).some(e=>e.startsWith("ui/")))}function pw(e){let t=e.mcpReq.envelope,r=u4(t?.[nP]);if(!r)try{let e,t=uQ();r=t.clientInfo??(e=t.headers,u4({name:u3(e,"x-mcp-client-name"),version:u3(e,"x-mcp-client-version"),title:u3(e,"x-mcp-client-title"),websiteUrl:u3(e,"x-mcp-client-website-url"),description:u3(e,"x-mcp-client-description")}))}catch{}if(!r)try{r=u2().clientInfo}catch{}return r}function pR(e){return e.endsWith(".tsx")}let pk=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}};function px(e){let t={};return!function e(r,i=""){if(r&&"object"==typeof r)for(let[n,a]of Object.entries(r)){let r=i?`${i}/${n}`:n;!a||"object"!=typeof a||Array.isArray(a)||a instanceof Date||a instanceof RegExp?t[r]=a:e(a,r)}}(e),t}let pC=["ui/resourceUri","resourceUri","visibility"],p$=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"],pT=uY({name:"request-context",fallback:!1});function pE(e){let t=[...e];return(e,r,i)=>(function(e,t,r){let i,n=new Map;if(e.http){let e=uQ(),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 pT.provider(Object.freeze({clientInfo:t?Object.freeze({...t}):void 0,http:i,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,pw(r),async()=>{if(0===t.length)return i();let r=Object.freeze({...function(){try{return pT.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}(),method:e.method,params:Object.freeze({...e.params})}),n=-1,a=async e=>{if(e<=n)throw Error("MCP middleware next() can only be called once");n=e;let o=t[e];return o?o(r,()=>a(e+1)):i()};return a(0)})}let pP=new Set(["tools/list","prompts/get","prompts/list","resources/read","resources/list","resources/templates/list","completion/complete"]);function pI(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 pq(e){return(e.split("/").pop()||e).replace(/\.[^/.]+$/,"")}function pO(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),a=t.slice(r+1),o=a[a.length-1];if(o&&o.includes(".")){let e=o.split(".")[0];"index"!==e?a[a.length-1]=e:a.pop()}let s=[],l=[],c=a.map(e=>{if(!e.match(/^\[.+\]$/))return l.push(e),e;{let t=e.slice(1,-1);return s.push(t),`{${t}}`}}),d=`${n}://${c.join("/")}`,u=s.length>0?"template":"direct";return{filePath:e,uriTemplate:d,scheme:n,parameters:s,pathSegments:l,type:u}}function pj(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 pz(e){return Error(`[xmcp] Invalid prompt file: ${e}
|
|
85
|
+
-> Default export must be a prompt handler function.`)}async function pL(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 pz(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 pz(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}}let pN=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}
|
|
86
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} prompt${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function pA(e){return Error(`[xmcp] Invalid resource file: ${e}
|
|
87
|
+
-> Default export must be a resource handler function.`)}async function pM(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 pA(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 pA(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}}let pZ=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}
|
|
88
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} resource${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function pU(e){return Error(`[xmcp] Invalid tool file: ${e}
|
|
89
|
+
-> Default export must be a tool handler function.`)}async function pH(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 pU(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 pU(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}}let pF=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}
|
|
90
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} tool${1===n?"":"s"} skipped due to empty files or missing default exports`)}}(),pV=INJECTED_TOOLS,pD=INJECTED_PROMPTS,pJ=INJECTED_RESOURCES,pB=SERVER_INFO;async function pW(e,t,r,i){let n=await INJECTED_MIDDLEWARE?.(),a=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);return pk.clear(),!function(e,t,r){let i=e.server,n=i.setRequestHandler,a=pE(t);i.setRequestHandler=(e,...t)=>{if(pP.has(e)&&1===t.length&&"function"==typeof t[0]){let e=t[0];t[0]=(t,r)=>a({method:t.method,params:t.params??{}},r,()=>e(t,r))}Reflect.apply(n,i,[e,...t])};try{r()}finally{i.setRequestHandler=n}}(e,a,()=>{!function(e,t,r=[]){t.forEach((t,i)=>{var n,a;let o,s,l,c={name:pq(i),description:"No description provided"},{default:d,metadata:u,schema:p,outputSchema:m}=t;if("object"==typeof u&&null!==u&&Object.assign(c,u),"function"==typeof d&&"__x402"in d){let e=P.g.__XMCP_X402_REGISTRY;e&&e.set(c.name,d.__x402)}let h={};if(pI(p)?h=p:null!=p&&console.warn(`Invalid schema for tool "${c.name}" at ${i}. Expected Record<string, z.ZodType>`),null!=m)if(pI(m))o=m;else throw Error(`Invalid outputSchema for tool "${c.name}" at ${i}. Expected Record<string, z.ZodType>`);c.annotations={...c.annotations??{}},void 0===c.annotations.title&&(c.annotations.title=c.name),void 0===c._meta&&(c._meta={});let f=pR(i),g=!!(n=c._meta)&&"object"==typeof n&&"ui"in n&&"object"==typeof n.ui||f,y=c._meta;if(g){let e=`ui://app/${c.name}.html`;c._meta.ui||(c._meta.ui={}),c._meta.ui.resourceUri||(c._meta.ui.resourceUri=e);let t=function(e){let t={},r={};if(e.ui&&"object"==typeof e.ui){let i=e.ui,n={},a={};for(let[e,t]of Object.entries(i))pC.includes(e)?n[e]=t:p$.includes(e)?a[e]=t:n[e]=t;Object.keys(n).length>0&&(t.ui=n),Object.keys(a).length>0&&(r.ui=a)}for(let[r,i]of Object.entries(e))"ui"!==r&&(t[r]=i);return{toolMeta:t,resourceMeta:r}}(y);y=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"),pk.add(c.name,{name:c.name,uri:e,handler:d,mimeType:"text/html;profile=mcp-app",_meta:r,toolPath:f?i:void 0})}let v=px(y),_=g?v:void 0;s=pR(i)&&g?async(e,t)=>({content:[{type:"text",text:""}],_meta:_,structuredContent:{args:e}}):function(e,t,r,i="unknown-tool"){return async(n,a)=>{let o,s,l=e(n,(o=pw(a),s=function(e){if(!e)return;let t={};return e.headers.forEach((e,r)=>{t[r]=e}),t}(a.http?.req),{signal:a.mcpReq.signal,authInfo:a.http?.authInfo,sessionId:a.sessionId,_meta:a.mcpReq._meta,requestId:a.mcpReq.id,requestInfo:s?{headers:s}:void 0,clientInfo:o,sendNotification:e=>a.mcpReq.notify(e),sendRequest:(e,t,r)=>a.mcpReq.send(e,t,r),elicit:(e,t)=>pa(a,e,t),sample:(e,t)=>pg(a,e,t),inputResponses:a.mcpReq.inputResponses,requestState:a.mcpReq.requestState}));if(l instanceof Promise&&(l=await l),lO(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 pS(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||(pb(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(pS(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}
|
|
91
91
|
|
|
92
92
|
Expected CallToolResult format:
|
|
93
93
|
{
|
|
@@ -116,7 +116,7 @@ Or for widget metadata only:
|
|
|
116
116
|
_meta: {
|
|
117
117
|
"ui/...": ...
|
|
118
118
|
}
|
|
119
|
-
}`)}let
|
|
119
|
+
}`)}let c="content"in l&&Array.isArray(l.content),d="structuredContent"in l,u="isError"in l&&!0===l.isError;if(!c&&!d&&!u){let e=JSON.stringify(l,null,2);throw Error(`Tool handler must return at least 'content' or 'structuredContent'. Got: ${e}
|
|
120
120
|
|
|
121
121
|
Expected CallToolResult format:
|
|
122
122
|
{
|
|
@@ -137,7 +137,7 @@ Or both for backwards compatibility:
|
|
|
137
137
|
{
|
|
138
138
|
content: [{ type: "text", text: "fallback" }],
|
|
139
139
|
structuredContent: { your: "data" }
|
|
140
|
-
}`)}if(c&&!
|
|
140
|
+
}`)}if(u&&!c&&!d){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&&d&&!u&&pb(l.structuredContent,r,i,"returned structuredContent that does not match outputSchema"),!c&&d&&(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=p_(t);if(!r.valid)throw Error(`Invalid content item at index ${e}: ${r.error}
|
|
141
141
|
|
|
142
142
|
Content item: ${JSON.stringify(t,null,2)}
|
|
143
143
|
|
|
@@ -146,7 +146,7 @@ Expected content formats:
|
|
|
146
146
|
- Image: { type: "image", data: "base64data", mimeType: "image/jpeg" }
|
|
147
147
|
- Audio: { type: "audio", data: "base64data", mimeType: "audio/mpeg" }
|
|
148
148
|
- Resource: { type: "resource_link", name: "name", uri: "uri" }
|
|
149
|
-
All content types support an optional "_meta" object property`)}if(
|
|
149
|
+
All content types support an optional "_meta" object property`)}if(d){let e=l.structuredContent;if(null===e||"object"!=typeof e||Array.isArray(e)){let t=Array.isArray(e)?"array":typeof e;throw Error(`'structuredContent' must be a plain object (not an array or primitive). Got ${t}: ${JSON.stringify(e,null,2)}
|
|
150
150
|
|
|
151
151
|
Expected format:
|
|
152
152
|
{
|
|
@@ -154,18 +154,20 @@ Expected format:
|
|
|
154
154
|
key: "value",
|
|
155
155
|
nested: { data: "here" }
|
|
156
156
|
}
|
|
157
|
-
}`)}}return
|
|
157
|
+
}`)}}return l}}(d,_,o,c.name);let b={title:c.annotations?.title,description:c.description,inputSchema:uW(h),outputSchema:o?uW(o,{strict:!0}):void 0,annotations:c.annotations,_meta:v};e.registerTool(c.name,b,(a=c.name,l=pE(r),(e,t)=>l({method:"tools/call",params:{name:a,arguments:e}},t,()=>s(e,t))))})}(e,t,a),r.forEach((t,r)=>{let i=pq(r),n={name:i,title:i,description:"No description provided"},a={},{default:o,metadata:s,schema:l}=t;"object"==typeof s&&null!==s&&Object.assign(n,s);let c=function(e,t="assistant"){return async(r,i)=>{let n,a=e(r,i);if(a instanceof Promise&&(a=await a),Array.isArray(a)||null!==a&&"object"==typeof a&&"messages"in a){let e=Array.isArray(a)?{messages:a}:a,t=await ca.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 a||"number"==typeof a)n={type:"text",text:"number"==typeof a?`${a}`:a};else{let e=p_(a);if(e.valid)n=a;else{let t=null===a?"null":typeof a,r=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Prompt handler must return a PromptContent object, string, number, PromptMessage[], or GetPromptResult. Got ${t}: ${r}
|
|
158
158
|
|
|
159
159
|
Validation error: ${e.error}
|
|
160
160
|
|
|
161
161
|
Expected formats:
|
|
162
162
|
- String: "your text here"
|
|
163
163
|
- Number: 42
|
|
164
|
+
- Messages: [{ role: "user", content: { type: "text", text: "your text here" } }]
|
|
165
|
+
- Prompt result: { description: "optional description", messages: [...] }
|
|
164
166
|
- Text content: { type: "text", text: "your text here" }
|
|
165
167
|
- Image content: { type: "image", data: "base64data", mimeType: "image/jpeg" }
|
|
166
168
|
- Audio content: { type: "audio", data: "base64data", mimeType: "audio/mpeg" }
|
|
167
169
|
- Resource link: { type: "resource_link", name: "resource name", uri: "resource://uri" }
|
|
168
|
-
- 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}]}}}(o,n.role||"assistant");
|
|
170
|
+
- 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}]}}}(o,n.role||"assistant");pI(l)?Object.assign(a,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,argsSchema:uW(a)},c)}),[...pk.getAll()].forEach(([t,r])=>{let i=r.mimeType||"text/html;profile=mcp-app",n=r?._meta?px(r._meta):void 0,a={name:r.name,description:`Auto-generated resource for ${r.name} tool`,mimeType:r.mimeType,_meta:n},o=async(e,t)=>{if(r.mimeType&&r.toolPath)try{var n;let e,t,a=(n=r.toolPath,IS_CLOUDFLARE?function(e){let{normalizedPath:t,baseName:r}=pj(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}=pj(e),i=P(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)),o=function(e){if(INJECTED_CLIENT_BUNDLES)return INJECTED_CLIENT_BUNDLES[e]||null;if(!IS_CLOUDFLARE)try{let t=P(Object(function(){var e=Error("Cannot find module 'fs'");throw e.code="MODULE_NOT_FOUND",e}())),r=P(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`),a=r.join(i,`${e}.bundle.css`);if(t.existsSync(n)){let e,r=t.readFileSync(n,"utf-8");return t.existsSync(a)&&(e=t.readFileSync(a,"utf-8")),{js:r,css:e}}}}catch{}return null}(a);if(!o)throw Error(`React client bundle not found for "${r.name}" (bundle: "${a}").
|
|
169
171
|
React tool bundles are generated automatically when you run "xmcp build" (or "xmcp dev").
|
|
170
172
|
Please re-run the build so the framework can regenerate the bundle.`);let s=o.js,l=o.css,c=(e=`
|
|
171
173
|
<script type="module">
|
|
@@ -220,7 +222,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let s=o.js
|
|
|
220
222
|
<div id="root"></div>
|
|
221
223
|
${e}
|
|
222
224
|
</body>
|
|
223
|
-
</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 a=r.handler({},t);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:r.uri,text:a,mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"_meta"in a&&!("content"in a))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"content"in a&&Array.isArray(a.content)){let e=a.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}]}};e.registerResource(r.name,r.uri,a,o)}),i.forEach((t,r)=>{let i={name:
|
|
225
|
+
</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 a=r.handler({},t);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:r.uri,text:a,mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"_meta"in a&&!("content"in a))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"content"in a&&Array.isArray(a.content)){let e=a.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}]}};e.registerResource(r.name,r.uri,a,o)}),i.forEach((t,r)=>{let i={name:pq(r),description:"No description provided"},{default:n,metadata:a,schema:o,complete:s}=t;"object"==typeof a&&null!==a&&Object.assign(i,a);let l={};pI(o)?l=o:null!=o&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let c=pO(r);if(!c)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let d=c.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(d=d.endsWith(".html")?d:`${d}.html`);let u=function(e,t,r={}){let i=pO(t);if(!i)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,n)=>{let a=e(function(e,t,r){let i={},n={};if(0===t.parameters.length)return n;let a=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=a.split("/"),l=o.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],a=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!a){n[e]=t;continue}try{n[e]=a.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(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:t.href,text:a}]};if(!a||"object"!=typeof a||!Array.isArray(a.contents)){let e=null===a?"null":typeof a,t=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
|
|
224
226
|
|
|
225
227
|
Expected ReadResourceResult format:
|
|
226
228
|
{
|
|
@@ -229,7 +231,7 @@ Expected ReadResourceResult format:
|
|
|
229
231
|
{ uri: "resource://uri", mimeType: "application/json", text: "json content" },
|
|
230
232
|
{ uri: "resource://uri", blob: base64data }
|
|
231
233
|
]
|
|
232
|
-
}`)}return a.contents.forEach(e=>{e.uri||(e.uri=t.href)}),a}}(n,r,
|
|
234
|
+
}`)}return a.contents.forEach(e=>{e.uri||(e.uri=t.href)}),a}}(n,r,l);if("direct"===c.type)e.registerResource(i.name,d,i,u);else{let t=Object.create(null);for(let e of c.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let r=new c2(d,{list:void 0,complete:t}),a=async(e,t,r)=>{let i={};for(let e of c.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 a=n(i,r);return a instanceof Promise&&(a=await a),"string"==typeof a?{contents:[{uri:e.href,text:a}]}:a};e.registerResource(i.name,r,i,a)}})}),e}async function pG(){let{toolModules:e,skippedTools:t}=await pH(pV);return pF(t),e}async function pK(){let{promptModules:e,skippedPrompts:t}=await pL(pD);return pN(t),e}async function pY(){let{resourceModules:e,skippedResources:t}=await pM(pJ);return pZ(t),e}async function pX(){let{instructions:e,...t}=pB,r=new c1(t,{instructions:e}),i=pG(),n=pK(),a=pY(),[o,s,l]=await Promise.all([i,n,a]);return pW(r,o,s,l)}let pQ="This MCP server was bootstrapped with xmcp.",p0={cursor:`
|
|
233
235
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
234
236
|
<g clip-path="url(#cursor)">
|
|
235
237
|
<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" />
|
|
@@ -284,7 +286,7 @@ Expected ReadResourceResult format:
|
|
|
284
286
|
</clipPath>
|
|
285
287
|
</defs>
|
|
286
288
|
</svg>
|
|
287
|
-
`},
|
|
289
|
+
`},p1=String.raw`
|
|
288
290
|
:root {
|
|
289
291
|
color-scheme: dark;
|
|
290
292
|
--brand-white: #f7f7f7;
|
|
@@ -583,13 +585,13 @@ Expected ReadResourceResult format:
|
|
|
583
585
|
clip: rect(0, 0, 0, 0);
|
|
584
586
|
border: 0;
|
|
585
587
|
}
|
|
586
|
-
`;function
|
|
588
|
+
`;function p2(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 p9=HTTP_CORS_CONFIG;function p4(e,t){let r=new Headers(e.headers);for(let[e,i]of Object.entries(p2(p9,t)))r.set(e,i);return new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}let p5=HTTP_CONFIG,p3=TEMPLATE_CONFIG,p6=INJECTED_MIDDLEWARE,p7=null;async function p8(){return p6?(p7||(p7=(async()=>{try{var e;let t=await p6();return e=t?.default,Array.isArray(e)?e.filter(me):me(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),[]}})()),p7):[]}function me(e){return"function"==typeof e}async function mt(e){let t=await p8();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}}function mr(e,...t){p5.debug&&console.log(`[Cloudflare-MCP] ${e}`,...t)}cw();let mi=function(e,t={}){var r;let{legacy:i,onerror:n,responseMode:c}=t;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 d=new Set,u=!1,p=e=>{try{n?.(e)}catch{}},m=t.bus??new cB(p),h={toolsChanged:()=>m.publish({kind:"tools_list_changed"}),promptsChanged:()=>m.publish({kind:"prompts_list_changed"}),resourcesChanged:()=>m.publish({kind:"resources_list_changed"}),resourceUpdated:e=>m.publish({kind:"resource_updated",uri:e})},f=function(e){let{bus:t,onerror:r}=e,i=e.maxSubscriptions??1024,n=e.keepAliveMs??15e3,a=new Set;return{serve:function(e,o,s,l){var c,d,u;let p,m,h,f,g,y,v;if(a.size>=i)return r?.(Error(`subscriptions/listen refused: subscription limit reached (${i})`)),cW(e.id,-32603,"Subscription limit reached");let _=(c=e,(g=lv(ly).validateRequest("subscriptions/listen",c)).ok?g.value.params?.notifications:void 0);if(void 0===_)return cW(e.id,-32602,"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");let b=(d=_,u=s,y={},v=e=>void 0===u||!0===e,!0===d.toolsListChanged&&v(u?.tools?.listChanged)&&(y.toolsListChanged=!0),!0===d.promptsListChanged&&v(u?.prompts?.listChanged)&&(y.promptsListChanged=!0),!0===d.resourcesListChanged&&v(u?.resources?.listChanged)&&(y.resourcesListChanged=!0),void 0!==d.resourceSubscriptions&&d.resourceSubscriptions.length>0&&v(u?.resources?.subscribe)&&(y.resourceSubscriptions=[...d.resourceSubscriptions]),y),S=e.id,w=new TextEncoder,R=!1,k=e=>{if(!R)try{p.enqueue(w.encode(e))}catch(e){r?.(e instanceof Error?e:Error(String(e)))}},x=(e,t)=>{k(`event: message
|
|
587
589
|
data: ${JSON.stringify({jsonrpc:"2.0",method:e,params:t})}
|
|
588
590
|
|
|
589
|
-
`)},C=e=>{if(!
|
|
591
|
+
`)},C=e=>{if(!R){e&&k(`event: message
|
|
590
592
|
data: ${JSON.stringify({jsonrpc:"2.0",id:S,result:{resultType:"complete",_meta:{[nO]:S,[nI]:l}}})}
|
|
591
593
|
|
|
592
|
-
`),k=!0;try{m?.()}catch(e){r?.(e instanceof Error?e:Error(String(e)))}void 0!==h&&clearInterval(h),f?.(),a.delete(C);try{p.close()}catch{}}},$=new ReadableStream({start(e){p=e;let r=cW({method:"notifications/subscriptions/acknowledged",params:{notifications:b}},S);x(r.method,r.params),m=t.subscribe(e=>{if(k||!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)}}(b,e))return;let t=cW(function(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed"};case"prompts_list_changed":return{method:"notifications/prompts/list_changed"};case"resources_list_changed":return{method:"notifications/resources/list_changed"};case"resource_updated":return{method:"notifications/resources/updated",params:{uri:e.uri}}}}(e),S);x(t.method,t.params)}),h=cD(n,()=>R(": keepalive\n\n")),a.add(C)},cancel(){C(!1)}});if(void 0!==o)if(o.aborted)C(!1);else{let e=()=>C(!1);o.addEventListener("abort",e,{once:!0}),f=()=>o.removeEventListener("abort",e)}return new Response($,{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 a)e(!0)},get openCount(){return a.size}}}({bus:m,maxSubscriptions:t.maxSubscriptions??1024,keepAliveMs:t.keepAliveMs??15e3,onerror:p});"json"===c&&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 g="reject"===i?void 0:(r=t.keepAliveMs,async(t,i)=>{if("POST"!==t.method.toUpperCase())return dn(405,-32e3,"Method not allowed.");try{let n=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:t}),a=new dr({sessionIdGenerator:void 0,...void 0!==r&&{keepAliveMs:r}});await n.connect(a);let o=()=>{a.close().catch(()=>{}),n.close().catch(()=>{})};t.signal?.addEventListener("abort",o,{once:!0});let s=await a.handleRequest(t,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(null===s.body||"text/event-stream"!==cf(s.headers.get("content-type")))return o(),s;let l=s.body.getReader(),c=!1,d=()=>{c||(c=!0,o())},u=new ReadableStream({pull:async e=>{try{let{done:t,value:r}=await l.read();if(t){d(),e.close();return}void 0!==r&&e.enqueue(r)}catch(t){d(),e.error(t)}},cancel:e=>(d(),l.cancel(e).catch(()=>{}))});return new Response(u,{status:s.status,statusText:s.statusText,headers:s.headers})}catch(e){try{p?.(ds(e))}catch{}return dl(di(i?.parsedBody))}});async function y(r,i,n){var u,m;let h=r.classification.revision;if(void 0===h||!sq.includes(h)){let e=new le({supported:[...sq],requested:h??"unknown"});return p(e),dn(400,e.code,e.message,e.data,di(r.message))}let g=function(e,t){if("request"!==t.messageKind)return;let r=t.message.method;if(void 0===e.mcpMethodHeader)return lW("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let i=Object.hasOwn(lG,r)?lG[r]:void 0;if(void 0===i)return;let n=t.message.params?.[i],a="string"==typeof n?n:void 0;if(void 0===e.mcpNameHeader){if(void 0===a)return;return lW("name-header-missing","(missing)",`the body carries params.${i}="${a}" but the required Mcp-Name header is absent`,"standard-header-validation")}let o=lK(e.mcpNameHeader),s=lF(o);return void 0===s?lW("name-header-invalid-encoding",o,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==a&&s!==a?lW("name-header-mismatch",o,`the body carries params.${i}="${a}" but the Mcp-Name header names "${s}"`,"standard-header-validation"):void 0}({httpMethod:i.method,mcpMethodHeader:i.headers.get("mcp-method")??void 0,mcpNameHeader:i.headers.get("mcp-name")??void 0},r);if(void 0!==g)return p(Error(`Rejected inbound request (${g.cell}): ${g.message}`)),da(g,di(r.message));let y="request"===r.messageKind?lR(r.message.params):void 0,v=y?.[nq];if("request"===r.messageKind){let e=Object.hasOwn(sT,u=r.message.method)?sT[u]:void 0;if(void 0!==e){let t=sP(e,v);if(void 0!==t){let e=new lt({requiredCapabilities:t});return p(e),dn(lJ[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 c0?_.server:_;if("request"===r.messageKind&&"subscriptions/listen"===r.message.method){let e=b.getCapabilities(),t=l(b);return _.close().catch(p),f.serve(r.message,i.signal,e,t)}if("request"===r.messageKind&&"tools/call"===r.message.method&&_ instanceof c0){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=lN(n);if(t.valid&&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),a=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==a)continue;let o=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)}}(a);if(void 0===o)continue;if(null===n)return lV("param-header-missing",e,`the body carries ${lZ(i.path)}=${JSON.stringify(a)} but the ${e} header is absent`);let s=lF(n);if(void 0===s)return lV("param-header-invalid-encoding",e,`the ${e} header carries an invalid Base64 sentinel value`);if(!(("integer"===i.type||"number"===i.type)&&lH.test(s)&&"number"==typeof a?Number(s)===a:s===o))return lV("param-header-mismatch",e,`the ${e} header decodes to ${JSON.stringify(s)} but the body carries ${lZ(i.path)}=${JSON.stringify(a)}`)}}(t.declarations,e?.arguments,i.headers);if(void 0!==n)return _.close().catch(p),p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),da(n,r.message.id)}}}a(b,h),s(b,sq),void 0!==y&&(m={clientInfo:y[nP],clientCapabilities:v},o(b,m));let S=b.onclose;d.add(b),b.onclose=()=>{d.delete(b),S?.()};try{let e=await dt(_,r.message,{classification:r.classification,request:i,...void 0!==n&&{authInfo:n},...void 0!==c&&{responseMode:c},...void 0!==t.keepAliveMs&&{keepAliveMs:t.keepAliveMs}});return"notification"===r.messageKind&&queueMicrotask(()=>void b.close().catch(()=>{})),e}catch(e){if(e instanceof s$&&e.code===sC.ConnectionClosed)return new Response(null,{status:499});return await b.close().catch(()=>{}),d.delete(b),p(ds(e)),dl(di(r.message))}}async function v(e,t,r,i){if(void 0!==g)return g(t,{...void 0!==r&&{authInfo:r},...void 0!==i&&{parsedBody:i}});let n=function(e,t){switch(e.reason){case"http-method":return lB("http-method","modern-only-method-not-allowed",405,new s6(-32e3,"Method not allowed."),!0);case"batch":return lB("jsonrpc-shape","modern-only-batch-not-supported",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return lB("jsonrpc-shape","modern-only-response-post",400,new s6(s3.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 lB("era-classification","modern-only-missing-envelope",400,void 0===r?new s6(s3.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new le({supported:[...t],requested:r}),!0)}}}(e,sq);return void 0===n?new Response(null,{status:202}):(p(Error(`Rejected 2025-era request on a modern-only endpoint (${n.cell}): ${n.message}`)),da(n,di(i)))}async function _(e,t){let r=t?.authInfo;if("POST"===e.method.toUpperCase()&&!cg(e.headers.get("content-type")))return p(Error("Unsupported Media Type: Content-Type must be application/json")),dn(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let i=await dc(e,t?.parsedBody);if("unreadable-body"===i.step)return dn(400,-32700,"Parse error: the request body could not be read");if("no-json-body"===i.step)return void 0!==g?g(i.forwardRequest,{...void 0!==r&&{authInfo:r}}):dn(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:n,body:a,parsedBody:o,forwardRequest:s}=i;try{switch(n.kind){case"reject":return p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),da(n,di(a));case"modern":return await y(n,e,r);case"legacy":return await v(n,s,r,o)}}catch(e){return p(ds(e)),dl(di(a))}}return{fetch:async(e,t)=>{if(u)throw Error("This MCP handler has been closed");try{return await _(e,t)}catch(e){return p(ds(e)),dl(di(t?.parsedBody))}},notify:h,bus:m,close:async()=>{u=!0,f.closeAll();let e=[...d].map(e=>e.close().catch(()=>{}));d.clear(),await Promise.all(e)}}}(pB,{legacy:"stateless",responseMode:"json",onerror:e=>p6("MCP handler error:",e)});async function p8(e,t,r,i){let n=crypto.randomUUID(),a=await e.clone().json().catch(()=>void 0),o=(e=>{for(let t of Array.isArray(e)?e:[e]){let e=u4(t);if(e)return e}})(a),s={};return e.headers.forEach((e,t)=>{s[t]=e}),uQ({id:n,headers:s,clientInfo:o},async()=>{try{let r=await p7.fetch(e,{authInfo:i,parsedBody:a});return pQ(r,t)}catch(e){return console.error("[Cloudflare-MCP] Error handling MCP request:",e),pQ(new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}}),t)}})}let me={async fetch(e,t,r){let i=new URL(e.url).pathname,n=e.headers.get("origin");if(p6(`${e.method} ${i}`),"OPTIONS"===e.method)return new Response(null,{status:204,headers:new Headers(pY(pX,n))});let a=p0.endpoint?.startsWith("/")?p0.endpoint:`/${p0.endpoint||"mcp"}`;if("/health"===i)return pQ(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 o,s;return pQ(new Response((o=p1.name,s=p1.description,`
|
|
594
|
+
`),R=!0;try{m?.()}catch(e){r?.(e instanceof Error?e:Error(String(e)))}void 0!==h&&clearInterval(h),f?.(),a.delete(C);try{p.close()}catch{}}},$=new ReadableStream({start(e){p=e;let r=cG({method:"notifications/subscriptions/acknowledged",params:{notifications:b}},S);x(r.method,r.params),m=t.subscribe(e=>{if(R||!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)}}(b,e))return;let t=cG(function(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed"};case"prompts_list_changed":return{method:"notifications/prompts/list_changed"};case"resources_list_changed":return{method:"notifications/resources/list_changed"};case"resource_updated":return{method:"notifications/resources/updated",params:{uri:e.uri}}}}(e),S);x(t.method,t.params)}),h=cJ(n,()=>k(": keepalive\n\n")),a.add(C)},cancel(){C(!1)}});if(void 0!==o)if(o.aborted)C(!1);else{let e=()=>C(!1);o.addEventListener("abort",e,{once:!0}),f=()=>o.removeEventListener("abort",e)}return new Response($,{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 a)e(!0)},get openCount(){return a.size}}}({bus:m,maxSubscriptions:t.maxSubscriptions??1024,keepAliveMs:t.keepAliveMs??15e3,onerror:p});"json"===c&&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 g="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}),a=new di({sessionIdGenerator:void 0,...void 0!==r&&{keepAliveMs:r}});await n.connect(a);let o=()=>{a.close().catch(()=>{}),n.close().catch(()=>{})};t.signal?.addEventListener("abort",o,{once:!0});let s=await a.handleRequest(t,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(null===s.body||"text/event-stream"!==cg(s.headers.get("content-type")))return o(),s;let l=s.body.getReader(),c=!1,d=()=>{c||(c=!0,o())},u=new ReadableStream({pull:async e=>{try{let{done:t,value:r}=await l.read();if(t){d(),e.close();return}void 0!==r&&e.enqueue(r)}catch(t){d(),e.error(t)}},cancel:e=>(d(),l.cancel(e).catch(()=>{}))});return new Response(u,{status:s.status,statusText:s.statusText,headers:s.headers})}catch(e){try{p?.(dl(e))}catch{}return dc(dn(i?.parsedBody))}});async function y(r,i,n){var u,m;let h=r.classification.revision;if(void 0===h||!sq.includes(h)){let e=new le({supported:[...sq],requested:h??"unknown"});return p(e),da(400,e.code,e.message,e.data,dn(r.message))}let g=function(e,t){if("request"!==t.messageKind)return;let r=t.message.method;if(void 0===e.mcpMethodHeader)return lW("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let i=Object.hasOwn(lG,r)?lG[r]:void 0;if(void 0===i)return;let n=t.message.params?.[i],a="string"==typeof n?n:void 0;if(void 0===e.mcpNameHeader){if(void 0===a)return;return lW("name-header-missing","(missing)",`the body carries params.${i}="${a}" but the required Mcp-Name header is absent`,"standard-header-validation")}let o=lK(e.mcpNameHeader),s=lF(o);return void 0===s?lW("name-header-invalid-encoding",o,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==a&&s!==a?lW("name-header-mismatch",o,`the body carries params.${i}="${a}" but the Mcp-Name header names "${s}"`,"standard-header-validation"):void 0}({httpMethod:i.method,mcpMethodHeader:i.headers.get("mcp-method")??void 0,mcpNameHeader:i.headers.get("mcp-name")??void 0},r);if(void 0!==g)return p(Error(`Rejected inbound request (${g.cell}): ${g.message}`)),ds(g,dn(r.message));let y="request"===r.messageKind?lk(r.message.params):void 0,v=y?.[nq];if("request"===r.messageKind){let e=Object.hasOwn(sT,u=r.message.method)?sT[u]:void 0;if(void 0!==e){let t=sP(e,v);if(void 0!==t){let e=new lt({requiredCapabilities:t});return p(e),da(lJ[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 c1?_.server:_;if("request"===r.messageKind&&"subscriptions/listen"===r.message.method){let e=b.getCapabilities(),t=l(b);return _.close().catch(p),f.serve(r.message,i.signal,e,t)}if("request"===r.messageKind&&"tools/call"===r.message.method&&_ instanceof c1){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=lN(n);if(t.valid&&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),a=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==a)continue;let o=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)}}(a);if(void 0===o)continue;if(null===n)return lV("param-header-missing",e,`the body carries ${lZ(i.path)}=${JSON.stringify(a)} but the ${e} header is absent`);let s=lF(n);if(void 0===s)return lV("param-header-invalid-encoding",e,`the ${e} header carries an invalid Base64 sentinel value`);if(!(("integer"===i.type||"number"===i.type)&&lH.test(s)&&"number"==typeof a?Number(s)===a:s===o))return lV("param-header-mismatch",e,`the ${e} header decodes to ${JSON.stringify(s)} but the body carries ${lZ(i.path)}=${JSON.stringify(a)}`)}}(t.declarations,e?.arguments,i.headers);if(void 0!==n)return _.close().catch(p),p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),ds(n,r.message.id)}}}a(b,h),s(b,sq),void 0!==y&&(m={clientInfo:y[nP],clientCapabilities:v},o(b,m));let S=b.onclose;d.add(b),b.onclose=()=>{d.delete(b),S?.()};try{let e=await dr(_,r.message,{classification:r.classification,request:i,...void 0!==n&&{authInfo:n},...void 0!==c&&{responseMode:c},...void 0!==t.keepAliveMs&&{keepAliveMs:t.keepAliveMs}});return"notification"===r.messageKind&&queueMicrotask(()=>void b.close().catch(()=>{})),e}catch(e){if(e instanceof s$&&e.code===sC.ConnectionClosed)return new Response(null,{status:499});return await b.close().catch(()=>{}),d.delete(b),p(dl(e)),dc(dn(r.message))}}async function v(e,t,r,i){if(void 0!==g)return g(t,{...void 0!==r&&{authInfo:r},...void 0!==i&&{parsedBody:i}});let n=function(e,t){switch(e.reason){case"http-method":return lB("http-method","modern-only-method-not-allowed",405,new s6(-32e3,"Method not allowed."),!0);case"batch":return lB("jsonrpc-shape","modern-only-batch-not-supported",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return lB("jsonrpc-shape","modern-only-response-post",400,new s6(s3.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 lB("era-classification","modern-only-missing-envelope",400,void 0===r?new s6(s3.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new le({supported:[...t],requested:r}),!0)}}}(e,sq);return void 0===n?new Response(null,{status:202}):(p(Error(`Rejected 2025-era request on a modern-only endpoint (${n.cell}): ${n.message}`)),ds(n,dn(i)))}async function _(e,t){let r=t?.authInfo;if("POST"===e.method.toUpperCase()&&!cy(e.headers.get("content-type")))return p(Error("Unsupported Media Type: Content-Type must be application/json")),da(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let i=await dd(e,t?.parsedBody);if("unreadable-body"===i.step)return da(400,-32700,"Parse error: the request body could not be read");if("no-json-body"===i.step)return void 0!==g?g(i.forwardRequest,{...void 0!==r&&{authInfo:r}}):da(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:n,body:a,parsedBody:o,forwardRequest:s}=i;try{switch(n.kind){case"reject":return p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),ds(n,dn(a));case"modern":return await y(n,e,r);case"legacy":return await v(n,s,r,o)}}catch(e){return p(dl(e)),dc(dn(a))}}return{fetch:async(e,t)=>{if(u)throw Error("This MCP handler has been closed");try{return await _(e,t)}catch(e){return p(dl(e)),dc(dn(t?.parsedBody))}},notify:h,bus:m,close:async()=>{u=!0,f.closeAll();let e=[...d].map(e=>e.close().catch(()=>{}));d.clear(),await Promise.all(e)}}}(pX,{legacy:"stateless",responseMode:"json",onerror:e=>mr("MCP handler error:",e)});async function mn(e,t,r,i){let n=crypto.randomUUID(),a=await e.clone().json().catch(()=>void 0),o=(e=>{for(let t of Array.isArray(e)?e:[e]){let e=u5(t);if(e)return e}})(a),s={};return e.headers.forEach((e,t)=>{s[t]=e}),u0({id:n,headers:s,clientInfo:o},async()=>{try{let r=await mi.fetch(e,{authInfo:i,parsedBody:a});return p4(r,t)}catch(e){return console.error("[Cloudflare-MCP] Error handling MCP request:",e),p4(new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}}),t)}})}let ma={async fetch(e,t,r){let i=new URL(e.url).pathname,n=e.headers.get("origin");if(mr(`${e.method} ${i}`),"OPTIONS"===e.method)return new Response(null,{status:204,headers:new Headers(p2(p9,n))});let a=p5.endpoint?.startsWith("/")?p5.endpoint:`/${p5.endpoint||"mcp"}`;if("/health"===i)return p4(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 o,s;return p4(new Response((o=p3.name,s=p3.description,`
|
|
593
595
|
<!DOCTYPE html>
|
|
594
596
|
<html lang="en">
|
|
595
597
|
<head>
|
|
@@ -610,7 +612,7 @@ data: ${JSON.stringify({jsonrpc:"2.0",id:S,result:{resultType:"complete",_meta:{
|
|
|
610
612
|
rel="stylesheet"
|
|
611
613
|
/>
|
|
612
614
|
<style>
|
|
613
|
-
${
|
|
615
|
+
${p1}
|
|
614
616
|
</style>
|
|
615
617
|
</head>
|
|
616
618
|
<body>
|
|
@@ -620,7 +622,7 @@ ${pK}
|
|
|
620
622
|
<div class="section-header">
|
|
621
623
|
<h2 id="server-name" class="display text-gradient">xmcp server</h2>
|
|
622
624
|
<p id="server-description" class="lead">
|
|
623
|
-
${s||
|
|
625
|
+
${s||pQ}
|
|
624
626
|
</p>
|
|
625
627
|
</div>
|
|
626
628
|
</div>
|
|
@@ -727,7 +729,7 @@ ${`
|
|
|
727
729
|
(templateConfig.serverName && templateConfig.serverName.trim()) || "xmcp server";
|
|
728
730
|
const resolvedDescription =
|
|
729
731
|
(templateConfig.serverDescription && templateConfig.serverDescription.trim()) ||
|
|
730
|
-
"${
|
|
732
|
+
"${pQ}";
|
|
731
733
|
const endpointPath =
|
|
732
734
|
(templateConfig.endpoint && templateConfig.endpoint.trim()) || "/";
|
|
733
735
|
const normalizedEndpoint = endpointPath.startsWith("/")
|
|
@@ -749,7 +751,7 @@ ${`
|
|
|
749
751
|
elements.description.textContent = resolvedDescription;
|
|
750
752
|
}
|
|
751
753
|
|
|
752
|
-
const icons = ${JSON.stringify(
|
|
754
|
+
const icons = ${JSON.stringify(p0)};
|
|
753
755
|
|
|
754
756
|
const connectionOptions = [
|
|
755
757
|
{
|
|
@@ -952,4 +954,4 @@ args = ["-y", "mcp-remote", "\${serverUrl}"]\`,
|
|
|
952
954
|
</script>
|
|
953
955
|
</body>
|
|
954
956
|
</html>
|
|
955
|
-
`),{status:200,headers:{"Content-Type":"text/html"}}),n)}if(i===a)try{let{response:t,authInfo:i}=await
|
|
957
|
+
`),{status:200,headers:{"Content-Type":"text/html"}}),n)}if(i===a)try{let{response:t,authInfo:i}=await mt(e);if(t)return p4(t,n);return mn(e,n,r,i)}catch(e){return console.error("[Cloudflare-MCP] Middleware error:",e),p4(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 p4(new Response(JSON.stringify({error:"Not found"}),{status:404,headers:{"Content-Type":"application/json"}}),n)}};var mo=I.A;export{mo as default};
|