@derushly/editor 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/NOTICE +15 -0
- package/README.md +6 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/server.d.ts +42 -0
- package/dist/server.js +756 -0
- package/package.json +56 -4
- package/ui-dist/THIRD_PARTY_NOTICES.md +2201 -0
- package/ui-dist/assets/dist-DDQ9WcrZ.js +58 -0
- package/ui-dist/assets/index-B1Lor06r.css +1 -0
- package/ui-dist/assets/index-BefJOHLE.js +852 -0
- package/ui-dist/assets/parent-audio-333CSKNZ-x-ixkhjk.js +500 -0
- package/ui-dist/assets/pausedVideoDecoder-3C25UMTR-DnYIc3M4.js +1 -0
- package/ui-dist/assets/previewOffCanvas-CTOQIFXK-DoXeJSRI.js +1 -0
- package/ui-dist/assets/runtime-inline-BT7nvEOP.js +1 -0
- package/ui-dist/assets/src-CYmap0el.js +36 -0
- package/ui-dist/hyperframe.runtime.iife.js +1146 -0
- package/ui-dist/index.html +13 -0
- package/ui-dist/third-party.json +1 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function e(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function t(e,t=`|`){return e.map(e=>ue(e)).join(t)}function n(e,t){return typeof t==`bigint`?t.toString():t}var r=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function i(e){return new r(e)}function a(e){return e==null}function o(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function s(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var c=Symbol(`evaluating`);function l(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==c)return r===void 0&&(r=c,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function u(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function d(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function f(e){return d(e._zod.def)??e._zod.def.shape}function p(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return u(this,t,e),e},enumerable:!0,configurable:!0})}function m(e,t,n){t in e?u(e,t,n):e[t]=n}function h(e,t,n,r){let i=f(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?p(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):m(e,a,r?r(n.value,a):n.value))}}function g(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?p(e,n,()=>t[n]):m(e,n,r.value))}}function _(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ee(e){return JSON.stringify(e)}function te(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var ne=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ie=i(()=>{if(E.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ae(e){if(re(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return re(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function oe(e){return ae(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var se=new Set([`string`,`number`,`symbol`]);function ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function le(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function v(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ue(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function de(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var fe={safeint:[-(2**53-1),2**53-1],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},pe={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function me(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return h(i,e,he(e,t)),le(e,_(n,{shape:i,checks:[]}))}function he(e,t){let n=f(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function ge(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(he(e,t)),a={};return h(a,e,Reflect.ownKeys(f(e)).filter(e=>!i.has(e))),le(e,_(n,{shape:a,checks:[]}))}function _e(e,t){if(!ae(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=f(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return le(e,_(e._zod.def,{shape:ve(e,t)}))}function ve(e,t){let n={};return h(n,e,Reflect.ownKeys(f(e))),g(n,t),n}function ye(e,t){if(!ae(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return le(e,_(e._zod.def,{shape:ve(e,t)}))}function be(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return h(n,e,Reflect.ownKeys(f(e))),h(n,t,Reflect.ownKeys(f(t))),le(e,_(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function xe(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(he(t,n)):void 0,o={};return h(o,t,Reflect.ownKeys(f(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),le(t,_(t._zod.def,{shape:o,checks:[]}))}function y(e,t,n){let r=n?new Set(he(t,n)):void 0,i={};return h(i,t,Reflect.ownKeys(f(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),le(t,_(t._zod.def,{shape:i}))}function b(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Se(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ce(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function we(e){return typeof e==`string`?e:e?.message}function Te(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function x(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function S(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:we(e.inst?._zod.def?.error?.(e))??we(a?.(e))??we(t?.error?.(e))??we(n.customError?.(e))??we(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Ee=/[\uD800-\uDBFF]/;function De(e){let t=e.length;if(!Ee.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Oe(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ke(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Ae(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function je(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Pe(e,n,r.value)}}function Me(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function C(e,t,n){return Me(e,t,n,!1)}function Ne(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Me(this,n,r(this))},set(e){Me(this,n,e)}})}return t}function Pe(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Me(this,t,n.bind(this))},set(e){Me(this,t,e)}})}function Fe(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Ie,Le=!1,Re={configurable:!0,get(){Le=!0}};function w(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Ie!==e._zod?Ie=void 0:(Ie=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Re);let e=Le;Le=!1;try{let r=n(this);return Le?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Le||=e,r}catch(n){throw delete this[t],Le||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function ze(e,t,n,r){let i=Fe(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Be=`~constantCatch`;function Ve(e){let t=()=>e;return t[Be]=!0,t}var He,Ue=Object.freeze({status:`aborted`}),We={value:void 0,enumerable:!1},Ge=`captureStackTrace`in Error?Error:null;function Ke(e){let t=Ge;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Ge=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function T(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){We.value=new a(r);try{Object.defineProperty(n,"_zod",We)}finally{We.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),je(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ke(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var qe=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Je=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(He=globalThis).__zod_globalConfig??(He.__zod_globalConfig={});var E=globalThis.__zod_globalConfig;function Ye(e){return e&&Object.assign(E,e),E}function Xe(){let e=this._zod;return e.message??=JSON.stringify(e.def,n,2),e.message}function Ze(e){this._zod.message=e}var Qe={get:Xe,set:Ze,enumerable:!0,configurable:!0},$e={value:void 0,enumerable:!1},et=new WeakSet([Object.prototype,Error.prototype]),tt=T(`$ZodError`,(e,t)=>{e.name=`$ZodError`,$e.value=t,Object.defineProperty(e,"issues",$e),$e.value=void 0,Object.defineProperty(e,"message",Qe);let n=Object.getPrototypeOf(e);et.has(n)||(et.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function nt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function rt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?nt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function it(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function at(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ot=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new qe;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>S(e,o,Ye())));throw ne(n,a?.callee??t),n}return s.value};return t},st=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>S(e,o,Ye())));throw ne(n,a?.callee??t),n}return s.value};return t},ct=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new qe;return a.issues.length?lt(e,a.issues,i):{success:!0,data:a.value}};function lt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>S(e,n,Ye()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var ut=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?lt(e,a.issues,i):{success:!0,data:a.value}},dt=Symbol.for(`zod.compile.invalid`),ft=Symbol.for(`zod.compile.fallback`),pt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==dt)return!0;if(r.definite===!0&&n===void 0)return!1}return mt(e,t,n)});function mt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[ft]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new qe;return a.issues.length===0}var ht=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},gt=e=>{let t=ot(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,at(n,a))};return n},_t=e=>{let t=ot(e),n=(e,r,i,a)=>t(e,r,i,at(n,a));return n},vt=e=>{let t=st(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,at(n,a))};return n},yt=e=>{let t=st(e),n=async(e,r,i,a)=>await t(e,r,i,at(n,a));return n},bt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ct(e)(t,n,i)},xt=e=>(t,n,r)=>ct(e)(t,n,r),St=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ut(e)(t,n,i)},Ct=e=>async(t,n,r)=>ut(e)(t,n,r),wt=/^[cC][0-9a-z]{6,}$/,Tt=/^[0-9a-z]+$/,Et=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Dt=/^[0-9a-vA-V]{20}$/,Ot=/^[A-Za-z0-9]{27}$/,kt=/^[a-zA-Z0-9_-]{21}$/;function At(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var jt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mt=/^([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})$/,Nt=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)$/,Pt=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ft=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function It(){return new RegExp(Ft,`u`)}var Lt=/^(?:(?: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])$/,Rt=/^(([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}|:))$/,zt=/^((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])$/,Bt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ht=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ut=/^https?$/,Wt=/^\+[1-9]\d{6,14}$/,Gt=`(?:(?:\\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])))`;function Kt(e){return RegExp(`^${e}$`)}var qt=Kt(Gt);function Jt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Yt(e){return RegExp(`^${Jt(e)}$`)}function Xt(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Jt({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Jt({precision:e.precision})}`:n;return RegExp(`^${Gt}T(?:${r})$`)}var Zt=/^[\s\S]{0,}$/,Qt=/^-?\d+$/,$t=/^-?\d+(?:\.\d+)?$/,en=/^(?:true|false)$/i,tn=/^null$/i,nn=/^[^A-Z]*$/,rn=/^[^a-z]*$/,D=T(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),an=e=>{let t=e.value;return!a(t)&&t.length!==void 0},on={number:`number`,bigint:`bigint`,object:`date`},sn=T(`$ZodCheckLessThan`,(e,t)=>{D.init(e,t);let n=on[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:on[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),cn=T(`$ZodCheckGreaterThan`,(e,t)=>{D.init(e,t);let n=on[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:on[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ln=T(`$ZodCheckMultipleOf`,(e,t)=>{D.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):s(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),un=T(`$ZodCheckNumberFormat`,(e,t)=>{D.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=fe[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,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})}}),dn=T(`$ZodCheckMaxLength`,(e,t)=>{var n;D.init(e,t),(n=e._zod.def).when??(n.when=an),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?De(r):i)<=t.maximum)return;let a=Oe(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fn=T(`$ZodCheckMinLength`,(e,t)=>{var n;D.init(e,t),(n=e._zod.def).when??(n.when=an),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?De(r):i)>=t.minimum)return;let a=Oe(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pn=T(`$ZodCheckLengthEquals`,(e,t)=>{var n;D.init(e,t),(n=e._zod.def).when??(n.when=an),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?De(r):i;if(a===t.length)return;let o=Oe(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),mn=T(`$ZodCheckStringFormat`,(e,t)=>{var n,r;D.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),hn=T(`$ZodCheckRegex`,(e,t)=>{mn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gn=T(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=nn,mn.init(e,t)}),_n=T(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=rn,mn.init(e,t)}),vn=T(`$ZodCheckIncludes`,(e,t)=>{D.init(e,t);let n=ce(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),yn=T(`$ZodCheckStartsWith`,(e,t)=>{D.init(e,t);let n=RegExp(`^${ce(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),bn=T(`$ZodCheckEndsWith`,(e,t)=>{D.init(e,t);let n=RegExp(`.*${ce(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),xn=T(`$ZodCheckOverwrite`,(e,t)=>{D.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Sn=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
2
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
3
|
+
`)}\n};`)(...Object.values(this.closed))}},Cn={major:4,minor:6,patch:7},O=T(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cn;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=b(t),a;for(let o of n){if(o._zod.def.when){if(Se(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new qe;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(x(t.issues,n,e),i||=b(t,n))});else{if(t.issues.length===n)continue;x(t.issues,n,e),i||=b(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(b(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new qe;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new qe;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return C(this,`~standard`,En(this))},set"~standard"(e){Me(this,`~standard`,e)}}),wn=(e,t)=>e.issues.length?{issues:e.issues.map(e=>S(e,t,Ye()))}:{value:e.value};async function Tn(e,t){let n={async:!0};return wn(await e._zod.run({value:t,issues:[]},n),n)}function En(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return wn(r,n)}catch{}return Tn(e,t)},vendor:`zod`,version:1}}var Dn=T(`$ZodString`,(e,t)=>{O.init(e,t),e._zod.pattern=t.pattern??Zt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),k=T(`$ZodStringFormat`,(e,t)=>{mn.init(e,t),Dn.init(e,t)}),On=T(`$ZodGUID`,(e,t)=>{t.pattern??=Mt,k.init(e,t)}),kn=T(`$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(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Nt(e)}else t.pattern??=Nt();k.init(e,t)}),An=T(`$ZodEmail`,(e,t)=>{t.pattern??=Pt,k.init(e,t)});function jn(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Mn(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?jn(e)||2:Nn(e,t)}function Nn(e,t){if(!t.normalize&&t.protocol?.source===Ut.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Pn=/[\t\n\r]/g;function Fn(e){return e.replace(Pn,``)}function In(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ln(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Rn=T(`$ZodURL`,(e,t)=>{k.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Mn(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Fn(r);return}t.hostname&&!In(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Ln(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Fn(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),zn=T(`$ZodEmoji`,(e,t)=>{t.pattern??=It(),k.init(e,t)}),Bn=T(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?kt:At(t.length),k.init(e,t)}),Vn=T(`$ZodCUID`,(e,t)=>{t.pattern??=wt,k.init(e,t)}),Hn=T(`$ZodCUID2`,(e,t)=>{t.pattern??=Tt,k.init(e,t)}),Un=T(`$ZodULID`,(e,t)=>{t.pattern??=Et,k.init(e,t)}),Wn=T(`$ZodXID`,(e,t)=>{t.pattern??=Dt,k.init(e,t)}),Gn=T(`$ZodKSUID`,(e,t)=>{t.pattern??=Ot,k.init(e,t)}),Kn=T(`$ZodISODateTime`,(e,t)=>{t.pattern??=Xt(t),k.init(e,t)}),qn=T(`$ZodISODate`,(e,t)=>{t.pattern??=qt,k.init(e,t)}),Jn=T(`$ZodISOTime`,(e,t)=>{t.pattern??=Yt(t),k.init(e,t)}),Yn=T(`$ZodISODuration`,(e,t)=>{t.pattern??=jt,k.init(e,t)}),Xn=T(`$ZodIPv4`,(e,t)=>{t.pattern??=Lt,k.init(e,t)}),Zn=/^[0-9a-fA-F:.]+$/;function Qn(e){return Zn.test(e)?jn(`http://[${e}]`):!1}var $n=T(`$ZodIPv6`,(e,t)=>{t.pattern??=Rt,k.init(e,t),e._zod.check=n=>{Qn(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),er=T(`$ZodCIDRv4`,(e,t)=>{t.pattern??=zt,k.init(e,t)});function tr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Qn(n)}var nr=T(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Bt,k.init(e,t),e._zod.check=n=>{tr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function rr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var ir=/^[0-9a-zA-Z+/]*={0,2}$/,ar=T(`$ZodBase64`,(e,t)=>{t.pattern??=ir,k.init(e,t),e._zod.check=n=>{rr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),or=/^[A-Za-z0-9_-]*$/;function sr(e){if(!or.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return rr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var cr=T(`$ZodBase64URL`,(e,t)=>{t.pattern??=or,k.init(e,t),e._zod.check=n=>{sr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),lr=T(`$ZodE164`,(e,t)=>{t.pattern??=Wt,k.init(e,t)});function ur(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var dr=T(`$ZodJWT`,(e,t)=>{k.init(e,t),e._zod.check=n=>{ur(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),fr=T(`$ZodNumber`,(e,t)=>{O.init(e,t),e._zod.pattern=$t,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),pr=T(`$ZodNumberFormat`,(e,t)=>{un.init(e,t),fr.init(e,t)}),mr=T(`$ZodBoolean`,(e,t)=>{O.init(e,t),e._zod.pattern=en,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),hr=T(`$ZodNull`,(e,t)=>{O.init(e,t),e._zod.pattern=tn,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),gr=T(`$ZodAny`,(e,t)=>{O.init(e,t),e._zod.parse=e=>e}),_r=T(`$ZodUnknown`,(e,t)=>{O.init(e,t),e._zod.parse=e=>e}),vr=T(`$ZodNever`,(e,t)=>{O.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function yr(e,t){let n=Te(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Te(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,x(n.issues,t,e),n}}return i(n,a)}}var br=e=>Array.isArray(e)?e.length:-1;function xr(e,t,n){e.issues.length&&t.issues.push(...Ce(n,e.issues)),t.value[n]=e.value}var Sr=T(`$ZodArray`,(e,t)=>{O.init(e,t);let n=E.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>xr(t,r,e)));else if(xr(c,r,e),s&&c.issues.length!==0&&b(c))break}return o.length?Promise.all(o).then(()=>r):r},yr(e,br)});function Cr(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Ce(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var wr=[];function Tr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:wr,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=de(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Er(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(b(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Cr(e,n,i,t,d,f))):Cr(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Dr=T(`$ZodObject`,(e,t)=>{O.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let a=i(()=>Tr(t));w(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||u(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let o=re,s=t.catchall,c,l=E.memoizer;l?.attach(e),e._zod.parse=(t,n)=>{c??=a.value;let r=t.value;if(!o(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=l?l.alloc(e,t,{},n):{};let i=[],u=c.shape,d=n?.abortEarly,f=t.issues.length;for(let e of c.allKeys){if(d&&t.issues.length!==f){if(b(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let a=u[e],o=a._zod.optin,s=a._zod.optout,c=a._zod.run({value:r[e],issues:[]},n);c instanceof Promise?i.push(c.then(n=>Cr(n,t,e,r,o,s))):Cr(c,t,e,r,o,s)}return s?Er(i,r,t,n,a.value,e,d===!0):i.length?Promise.all(i).then(()=>t):t}}),Or=T(`$ZodObjectJIT`,(e,t)=>{Dr.init(e,t);let n=e._zod.parse,r=i(()=>Tr(t)),a=E.memoizer,o=t=>{let n=r.value,i=n.symbolKeys,o=new Sn([`payload`,`ctx`],{shape:t,inst:e,memo:a,syms:i}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
4
|
+
let ${e}_ab = false;
|
|
5
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
6
|
+
const iss = ${e}.issues[i];
|
|
7
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
8
|
+
payload.issues.push(iss);
|
|
9
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
10
|
+
}
|
|
11
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
12
|
+
payload.value = newResult;
|
|
13
|
+
return payload;
|
|
14
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(a?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${i.indexOf(e)}]`:ee(e),a=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
15
|
+
const ${n}_present = ${a};
|
|
16
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
17
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (${e}) {
|
|
21
|
+
newResult[${r}] = ${n}.value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
`)}else f?(o.write(`
|
|
26
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
27
|
+
}
|
|
28
|
+
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
29
|
+
if (${n}.value !== undefined || ${a}) {
|
|
30
|
+
newResult[${r}] = ${n}.value;
|
|
31
|
+
}
|
|
32
|
+
`)):o.write(`
|
|
33
|
+
const ${n}_present = ${a};
|
|
34
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
35
|
+
}
|
|
36
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
37
|
+
payload.issues.push({
|
|
38
|
+
code: "invalid_type",
|
|
39
|
+
expected: "nonoptional",
|
|
40
|
+
input: undefined,
|
|
41
|
+
path: [${r}]
|
|
42
|
+
});
|
|
43
|
+
if (ctx && ctx.abortEarly) {
|
|
44
|
+
payload.value = newResult;
|
|
45
|
+
return payload;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (${n}_present) {
|
|
50
|
+
newResult[${r}] = ${n}.value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},s,c=re,l=!E.jitless,u=l&&ie.value,d=t.catchall,f;e._zod.parse=(i,a)=>{f??=r.value;let p=i.value;return c(p)?l&&u&&a?.async===!1&&a.jitless!==!0?(s||=o(t.shape),i=s(i,a),d?Er([],p,i,a,f,e,a?.abortEarly===!0):i):n(i,a):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function kr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!b(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>S(e,r,Ye())))}),t)}var Ar=T(`$ZodUnion`,(e,t)=>{O.init(e,t),w(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),w(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),w(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),w(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>o(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>kr(t,r,e,i)):kr(o,r,e,i)}});function jr(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Mr=T(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ar.init(e,t);let n=e._zod.parse;w(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||u(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=d(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=i(()=>jr(t));e._zod.parse=(i,a)=>{let o=i.value;if(!re(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Nr=T(`$ZodIntersection`,(e,t)=>{O.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Fr(e,t,n)):Fr(e,i,a)}});function Pr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ae(e)&&ae(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Pr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=Pr(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Fr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Pr(t.value,n.value);if(!c.valid){if(b(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ir=T(`$ZodRecord`,(e,t)=>{O.init(e,t);let n=E.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!ae(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>S(e,i,Ye())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Ce(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Ce(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&$t.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>S(e,i,Ye())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Ce(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Ce(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Lr=T(`$ZodEnum`,(t,n)=>{O.init(t,n);let r=e(n.entries),i=new Set(r);t._zod.values=i,w(t,`pattern`,t=>{let n=e(t.def.entries).filter(e=>se.has(typeof e));return RegExp(n.length?`^(${n.map(e=>ce(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),t._zod.parse=(e,n)=>{let a=e.value;return i.has(a)||e.issues.push({code:`invalid_value`,values:r,input:a,inst:t}),e}}),Rr=T(`$ZodLiteral`,(e,t)=>{O.init(e,t);let n=new Set(t.values);e._zod.values=n,w(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?ce(e):e?ce(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),zr=T(`$ZodTransform`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,E.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Je(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new qe;return n.value=i,n}});function Br(e,t){return e.value=t.issues.length?void 0:t.value,e}var Vr=T(`$ZodOptional`,(e,t)=>{O.init(e,t),w(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,w(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),w(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${o(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Br(e,t)):Br(e,r)}return t.innerType._zod.run(e,n)}}),Hr=T(`$ZodExactOptional`,(e,t)=>{Vr.init(e,t),w(e,`values`,e=>e.def.innerType._zod.values),w(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ur=T(`$ZodNullable`,(e,t)=>{O.init(e,t),w(e,`optin`,e=>e.def.innerType._zod.optin),w(e,`optout`,e=>e.def.innerType._zod.optout),w(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${o(t.source)}|null)$`):void 0}),w(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Wr=T(`$ZodDefault`,(e,t)=>{O.init(e,t),e._zod.optin=`defaulted`,w(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Gr(e,t)):Gr(r,t)}});function Gr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Kr=T(`$ZodPrefault`,(e,t)=>{O.init(e,t),e._zod.optin=`defaulted`,w(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),qr=T(`$ZodNonOptional`,(e,t)=>{O.init(e,t),w(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Jr(t,e)):Jr(i,e)}});function Jr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Yr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>S(e,r,Ye()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Xr=T(`$ZodCatch`,(e,t)=>{O.init(e,t),w(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),w(e,`optout`,e=>e.def.innerType._zod.optout),w(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Yr(e,r,t,n)):Yr(e,r,t,n)}}),Zr=T(`$ZodPipe`,(e,t)=>{O.init(e,t),w(e,`values`,e=>e.def.in._zod.values),w(e,`optin`,e=>e.def.in._zod.optin),w(e,`optout`,e=>e.def.out._zod.optout),w(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Qr(e,t.in,n)):Qr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Qr(e,t.out,n)):Qr(r,t.out,n)}});function Qr(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var $r=T(`$ZodPreprocess`,(e,t)=>{Zr.init(e,t)}),ei=T(`$ZodReadonly`,(e,t)=>{O.init(e,t),w(e,`propValues`,e=>e.def.innerType._zod.propValues),w(e,`values`,e=>e.def.innerType._zod.values),w(e,`optin`,e=>e.def.innerType?._zod?.optin),w(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ti):ti(r)}});function ti(e){return e.memo||(e.value=Object.freeze(e.value)),e}var ni=T(`$ZodLazy`,(e,t)=>{O.init(e,t),l(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),w(e,`pattern`,e=>e.innerType?._zod?.pattern),w(e,`propValues`,e=>e.innerType?._zod?.propValues),w(e,`optin`,e=>e.innerType?._zod?.optin??void 0),w(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),ri=T(`$ZodCustom`,(e,t)=>{D.init(e,t),O.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ii(t,n,r,e));ii(i,n,r,e)}});function ii(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ae(e))}}var ai=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},oi=`~memo`,si=[];function ci(e){return typeof e==`object`&&!!e}function li(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var ui=new WeakMap,di=0,fi=1,pi=2;function mi(e,t,n){let r=ui.get(e);if(r!==void 0)return r?pi:di;if(t.has(e))return pi;t.add(e);let i=di,a=e=>{if(i!==pi&&e?._zod){let r=mi(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=di;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?fi:o.value?._zod?mi(o.value,t,n):di;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=d(c);s(e?o(e,!0):fi),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?mi(r,t,!1):fi);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),hi(e,i)}function hi(e,t){return t!==fi&&ui.set(e,t===pi),t}function gi(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var _i,vi=[],yi={alloc(e,t,n){let r=_i;if(!r)return n;_i=void 0;let i={value:n,issues:null};return r.set(t.value,i),vi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&xi(n,e.value))throw new ai;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=mi(e,new Set,!1);if(i===di)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===pi||r?n=!0:r=!0}let l=s.value;if(!ci(l))return t(s,c);let u=c[oi];u||(u={buckets:new WeakMap,backEdges:void 0},c[oi]=u);let d;i===c?d=a:(d=gi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...li(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;_i=d;let p=vi.length,m=t(s,c);_i=void 0;let h=vi.length>p?vi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?li(e.issues):si),e)):(h&&(h.issues=m.issues.length?li(m.issues):si),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function bi(){return yi}function xi(e,t){let n=e[oi]?.backEdges;return n!==void 0&&ci(t)&&n.has(t)}var Si=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function n(t){return e[t]??null}let r={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},i={nan:`NaN`};function a(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):i[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${a(e.expected)}, received ${a(ke(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ue(e.values[0])}`:`Invalid option: expected one of ${t(e.values,`|`)}`;case`too_big`:{let t=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=n(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${t}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${t}${e.maximum.toString()}`}case`too_small`:{let t=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=n(e.origin);return r?`Too small: expected ${e.origin} to have ${t}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${t}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${r[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${t(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Ci(){return{localeError:Si()}}var wi,Ti=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ei(){return new Ti}(wi=globalThis).__zod_globalRegistry??(wi.__zod_globalRegistry=Ei());var Di=globalThis.__zod_globalRegistry;function Oi(e){return e.checks&&=[...e.checks],e}function ki(e,t){return new e(Oi({type:`string`,...v(t)}))}function Ai(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...v(t)})}function ji(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...v(t)})}function Mi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...v(t)})}function Ni(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...v(t)})}function Pi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...v(t)})}function Fi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...v(t)})}function Ii(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...v(t)})}function Li(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...v(t)})}function Ri(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...v(t)})}function zi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...v(t)})}function Bi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...v(t)})}function Vi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...v(t)})}function Hi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...v(t)})}function Ui(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...v(t)})}function Wi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...v(t)})}function Gi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...v(t)})}function Ki(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...v(t)})}function qi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...v(t)})}function Ji(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...v(t)})}function Yi(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...v(t)})}function Xi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...v(t)})}function Zi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...v(t)})}function Qi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...v(t)})}function $i(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...v(t)})}function ea(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...v(t)})}function ta(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...v(t)})}function na(e,t){return new e(Oi({type:`number`,checks:[],...v(t)}))}function ra(e,t){return new e(Oi({type:`number`,coerce:!0,checks:[],...v(t)}))}function ia(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...v(t)})}function aa(e,t){return new e({type:`boolean`,...v(t)})}function oa(e,t){return new e({type:`null`,...v(t)})}function sa(e){return new e({type:`any`})}function ca(e){return new e({type:`unknown`})}function la(e,t){return new e({type:`never`,...v(t)})}function ua(e,t){return new sn({check:`less_than`,...v(t),value:e,inclusive:!1})}function da(e,t){return new sn({check:`less_than`,...v(t),value:e,inclusive:!0})}function fa(e,t){return new cn({check:`greater_than`,...v(t),value:e,inclusive:!1})}function pa(e,t){return new cn({check:`greater_than`,...v(t),value:e,inclusive:!0})}function ma(e,t){return new ln({check:`multiple_of`,...v(t),value:e})}function ha(e,t){return new dn({check:`max_length`,...v(t),maximum:e})}function ga(e,t){return new fn({check:`min_length`,...v(t),minimum:e})}function _a(e,t){return new pn({check:`length_equals`,...v(t),length:e})}function va(e,t){return new hn({check:`string_format`,format:`regex`,...v(t),pattern:e})}function ya(e){return new gn({check:`string_format`,format:`lowercase`,...v(e)})}function ba(e){return new _n({check:`string_format`,format:`uppercase`,...v(e)})}function xa(e,t){return new vn({check:`string_format`,format:`includes`,...v(t),includes:e})}function Sa(e,t){return new yn({check:`string_format`,format:`starts_with`,...v(t),prefix:e})}function Ca(e,t){return new bn({check:`string_format`,format:`ends_with`,...v(t),suffix:e})}function wa(e){return new xn({check:`overwrite`,tx:e})}function Ta(e){return wa(t=>t.normalize(e))}function Ea(){return wa(e=>e.trim())}function Da(){return wa(e=>e.toLowerCase())}function Oa(){return wa(e=>e.toUpperCase())}function ka(){return wa(e=>te(e))}function Aa(e,t,n){return new e({type:`array`,element:t,...v(n)})}function ja(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...v(n)})}function Ma(e,t){let n=Na(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ae(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ae(r))}},e(t.value,t)),t);return n}function Na(e,t){let n=new D({check:`custom`,...v(t)});return n._zod.check=e,n}function Pa(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&u(e,t,n[t]);return e}function Fa(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Di,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function A(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function j(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,j(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Pa(o.schema,c),t.io===`input`&&Ga(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ia(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function La(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ia(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ia(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
54
|
+
|
|
55
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ra(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Ra(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var za=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ba=[`oneOf`,`anyOf`];function Va(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ha(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!za.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Va(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}u(n,r,e.length===1?e[0]:Ha(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Va(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Ua(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of za)if(t in e)return;let n=t.filter(e=>Ba.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ha(t);else{let e=n[0],i=Ba.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ha([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Pa(e,r))}function Wa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Pa(i,s),Pa(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Ra(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Ua(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Pa(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,u(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qa(t,`input`,e.processors),output:qa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ga(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ga(r.element,n);if(r.type===`set`)return Ga(r.valueType,n);if(r.type===`lazy`)return Ga(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Ga(r.innerType,n);if(r.type===`intersection`)return Ga(r.left,n)||Ga(r.right,n);if(r.type===`record`||r.type===`map`)return Ga(r.keyType,n)||Ga(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ga(r.in,n)||Ga(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ga(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ga(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ga(e,n))return!0;return!!(r.rest&&Ga(r.rest,n))}return!1}var Ka=(e,t={})=>n=>{let r=Fa({...n,processors:t});return j(e,r),La(r,e),Wa(r,e)},qa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Fa({...i??{},target:a,io:t,processors:n});return j(e,o),La(o,e),Wa(o,e)},Ja=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ya=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Xa=(e,t)=>{Ja(e,`minimum`,t),Ya(e,`maximum`,t)},Za=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Qa=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},$a=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},eo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},to=(e,t)=>Ja(e,`minimum`,t.minimum),no=(e,t)=>Ya(e,`maximum`,t.maximum),ro=e=>(t,n)=>{eo(t,n.format);let[r,i]=e[n.format];Ja(t,`minimum`,r),Ya(t,`maximum`,i)},io={greater_than:(e,t)=>Ja(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ya(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Za(e,t.value),number_format:ro(fe),bigint_format:ro(pe),min_length:to,max_length:no,length_equals:(e,t)=>Xa(e,t.length),min_size:to,max_size:no,size_equals:(e,t)=>Xa(e,t.size),string_format:(e,t)=>{eo(e,t.format),t.pattern&&Qa(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>$a(e,t.mime)};function ao(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)io[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ja(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ja(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ya(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ya(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Za(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&$a(t,i.mime);for(let e of i.patterns??[])Qa(t,e);return t}var oo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},so=new Map([[ir,Vt],[or,Ht]]),co=e=>so.get(e)??e,lo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=ao(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=oo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(co);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},uo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ao(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):A(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},fo=(e,t,n,r)=>{n.type=`boolean`},po=(e,t,n,r)=>{A(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{A(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},go=(e,t,n,r)=>{A(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},_o=(e,t,n,r)=>{A(e,t,n,r,`Void cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{n.not={}},yo=(e,t,n,r)=>{},bo=(e,t,n,r)=>{},xo=(e,t,n,r)=>{A(e,t,n,r,`Date cannot be represented in JSON Schema`)},So=(t,n,r,i)=>{let a=e(t._zod.def.entries);a.length===0?r.not={}:(a.every(e=>typeof e==`number`)&&(r.type=`number`),a.every(e=>typeof e==`string`)&&(r.type=`string`),r.enum=a)},Co=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(A(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(A(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},wo=(e,t,n,r)=>{A(e,t,n,r,`NaN cannot be represented in JSON Schema`)},To=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},Eo=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=ao(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},Do=(e,t,n,r)=>{n.type=`boolean`},Oo=(e,t,n,r)=>{A(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ko=(e,t,n,r)=>{A(e,t,n,r,`Function types cannot be represented in JSON Schema`)},Ao=(e,t,n,r)=>{A(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},jo=(e,t,n,r)=>{A(e,t,n,r,`Map cannot be represented in JSON Schema`)},Mo=(e,t,n,r)=>{A(e,t,n,r,`Set cannot be represented in JSON Schema`)},No=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=ao(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=j(a.element,t,{...r,path:[...r.path,`items`]})};function Po(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Po(t.out):t.type===`catch`?Po(t.innerType):e._zod.optin}var Fo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&A(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)u(i.properties,e,j(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Po(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=j(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Io=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>j(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Lo=(e,t,n,r)=>{let i=e._zod.def,a=j(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=j(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Ro=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>j(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?j(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?Po(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=ao(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function zo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=zo(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>zo(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?$t:Qt).source)),p}var Bo=new WeakMap;function Vo(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Bo.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=zo(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var Ho=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=ao(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=j(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)u(i.patternProperties,co(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=j(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Bo.get(t);n||(n=[],Bo.set(t,n),t.deferred.push(()=>Vo(t))),n.push(e)}i.additionalProperties=j(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Po(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Uo=(e,t,n,r)=>{let i=e._zod.def,a=j(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Wo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Go=Symbol();function Ko(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(A(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Go):JSON.parse(o)}var qo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Ko(i.defaultValue,e,t,n,r);o!==Go&&(n.default=o)},Jo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Ko(i.defaultValue,e,t,n,r);o!==Go&&(n._prefault=o)},Yo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{A(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Xo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;j(o,t,r);let s=t.seen.get(e);s.ref=o},Zo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Qo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},$o=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},es=(e,t,n,r)=>{let i=e._zod.innerType;j(i,t,r);let a=t.seen.get(e);a.ref=i},ts={string:lo,number:uo,boolean:fo,bigint:po,symbol:mo,null:ho,undefined:go,void:_o,never:vo,any:yo,unknown:bo,date:xo,enum:So,literal:Co,nan:wo,template_literal:To,file:Eo,success:Do,custom:Oo,function:ko,transform:Ao,map:jo,set:Mo,array:No,object:Fo,union:Io,intersection:Lo,tuple:Ro,record:Ho,nullable:Uo,nonoptional:Wo,default:qo,prefault:Jo,catch:Yo,pipe:Xo,readonly:Zo,promise:Qo,optional:$o,lazy:es};function ns(e,t){if(`_idmap`in e){let n=e,r=Fa({...t,processors:ts}),i={};for(let e of n._idmap.entries()){let[t,n]=e;j(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;La(r,n),u(a,t,Wa(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Fa({...t,processors:ts});return j(e,n),La(n,e),Wa(n,e)}var rs=new WeakSet([Object.prototype,Error.prototype]);function is(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var as=T(`ZodError`,(e,t)=>{tt.init(e,t),e.name=`ZodError`;let r=Object.getPrototypeOf(e);rs.has(r)||(rs.add(r),is(r,`format`,e=>t=>it(e,t)),is(r,`flatten`,e=>t=>rt(e,t)),is(r,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,n,2)}),is(r,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,n,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),os=ot(as),ss=st(as),cs=ct(as),ls=ut(as),us=gt(as),ds=_t(as),fs=vt(as),ps=yt(as),ms=bt(as),hs=xt(as),gs=St(as),_s=Ct(as);function vs(){E.localeError||Ye(Ci())}function ys(){E.memoizer||Ye({memoizer:bi()})}var M=T(`ZodType`,(e,t)=>(vs(),O.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(_(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return le(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Lc(e,t))},superRefine(e,t){return this.check(Rc(e,t))},overwrite(e){return this.check(wa(e))},optional(){return G(this)},exactOptional(){return vc(this)},nullable(){return bc(this)},nullish(){return G(bc(this))},nonoptional(e){return Ec(this,e)},array(){return R(this)},or(e){return V([this,e])},and(e){return uc(this,e)},transform(e){return Ac(this,hc(e))},default(e){return Sc(this,e)},prefault(e){return wc(this,e)},catch(e){return Oc(this,e)},pipe(e){return Ac(this,e)},readonly(){return Nc(this)},describe(e){let t=this.clone();return Di.add(t,{description:e}),t},meta(...e){if(e.length===0)return Di.get(this);let t=this.clone();return Di.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return C(this,`~standard`,{...En(this),jsonSchema:{input:qa(this,`input`),output:qa(this,`output`)}})},set"~standard"(e){Me(this,`~standard`,e)},parse:function e(t,n){return os(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ss(this,t,n,{callee:e})},safeParse(e,t){return cs(this,e,t)},async safeParseAsync(e,t){return ls(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Me(this,`spa`,e)},validate(e,t){return pt(this,e,t)},validateAsync(e,t){return ht(this,e,t)},encode:function e(t,n){return us(this,t,n,{callee:e})},decode:function e(t,n){return ds(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await fs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ps(this,t,n,{callee:e})},safeEncode(e,t){return ms(this,e,t)},safeDecode(e,t){return hs(this,e,t)},async safeEncodeAsync(e,t){return gs(this,e,t)},async safeDecodeAsync(e,t){return _s(this,e,t)},toJSONSchema(e){return Ka(this,{})(e)},get description(){return Di.get(this)?.description},get _def(){return this._zod.def}}),bs=T(`_ZodString`,(e,t)=>{Dn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)},Ne({format:e=>ao(e).format??null,minLength:e=>ao(e).minimum??null,maxLength:e=>ao(e).maximum??null},{regex(...e){return this.check(va(...e))},includes(...e){return this.check(xa(...e))},startsWith(...e){return this.check(Sa(...e))},endsWith(...e){return this.check(Ca(...e))},min(...e){return this.check(ga(...e))},max(...e){return this.check(ha(...e))},length(...e){return this.check(_a(...e))},nonempty(...e){return this.check(ga(1,...e))},lowercase(e){return this.check(ya(e))},uppercase(e){return this.check(ba(e))},trim(){return this.check(Ea())},normalize(...e){return this.check(Ta(...e))},toLowerCase(){return this.check(Da())},toUpperCase(){return this.check(Oa())},slugify(){return this.check(ka())}})),xs=T(`ZodString`,(e,t)=>{Dn.init(e,t),bs.init(e,t)},{email(e){return this.check(Ai(Es,e))},url(e){return this.check(Ii(As,e))},jwt(e){return this.check(Zi(Ks,e))},emoji(e){return this.check(Li(Ms,e))},guid(e){return this.check(ji(Os,e))},uuid(e){return this.check(Mi(ks,e))},uuidv4(e){return this.check(Ni(ks,e))},uuidv6(e){return this.check(Pi(ks,e))},uuidv7(e){return this.check(Fi(ks,e))},nanoid(e){return this.check(Ri(Ns,e))},cuid(e){return this.check(zi(Ps,e))},cuid2(e){return this.check(Bi(Fs,e))},ulid(e){return this.check(Vi(Is,e))},base64(e){return this.check(Ji(Us,e))},base64url(e){return this.check(Yi(Ws,e))},xid(e){return this.check(Hi(Ls,e))},ksuid(e){return this.check(Ui(Rs,e))},ipv4(e){return this.check(Wi(zs,e))},ipv6(e){return this.check(Gi(Bs,e))},cidrv4(e){return this.check(Ki(Vs,e))},cidrv6(e){return this.check(qi(Hs,e))},e164(e){return this.check(Xi(Gs,e))},datetime(e){return this.check(Qi(Ss,e))},date(e){return this.check($i(Cs,e))},time(e){return this.check(ea(ws,e))},duration(e){return this.check(ta(Ts,e))}});function N(e){return ki(xs,e)}var P=T(`ZodStringFormat`,(e,t)=>{k.init(e,t),bs.init(e,t)}),Ss=T(`ZodISODateTime`,(e,t)=>{Kn.init(e,t),P.init(e,t)}),Cs=T(`ZodISODate`,(e,t)=>{qn.init(e,t),P.init(e,t)}),ws=T(`ZodISOTime`,(e,t)=>{Jn.init(e,t),P.init(e,t)}),Ts=T(`ZodISODuration`,(e,t)=>{Yn.init(e,t),P.init(e,t)}),Es=T(`ZodEmail`,(e,t)=>{An.init(e,t),P.init(e,t)});function Ds(e){return Ai(Es,e)}var Os=T(`ZodGUID`,(e,t)=>{On.init(e,t),P.init(e,t)}),ks=T(`ZodUUID`,(e,t)=>{kn.init(e,t),P.init(e,t)}),As=T(`ZodURL`,(e,t)=>{Rn.init(e,t),P.init(e,t)});function js(e){return Ii(As,e)}var Ms=T(`ZodEmoji`,(e,t)=>{zn.init(e,t),P.init(e,t)}),Ns=T(`ZodNanoID`,(e,t)=>{Bn.init(e,t),P.init(e,t)}),Ps=T(`ZodCUID`,(e,t)=>{Vn.init(e,t),P.init(e,t)}),Fs=T(`ZodCUID2`,(e,t)=>{Hn.init(e,t),P.init(e,t)}),Is=T(`ZodULID`,(e,t)=>{Un.init(e,t),P.init(e,t)}),Ls=T(`ZodXID`,(e,t)=>{Wn.init(e,t),P.init(e,t)}),Rs=T(`ZodKSUID`,(e,t)=>{Gn.init(e,t),P.init(e,t)}),zs=T(`ZodIPv4`,(e,t)=>{Xn.init(e,t),P.init(e,t)}),Bs=T(`ZodIPv6`,(e,t)=>{$n.init(e,t),P.init(e,t)}),Vs=T(`ZodCIDRv4`,(e,t)=>{er.init(e,t),P.init(e,t)}),Hs=T(`ZodCIDRv6`,(e,t)=>{nr.init(e,t),P.init(e,t)}),Us=T(`ZodBase64`,(e,t)=>{ar.init(e,t),P.init(e,t)}),Ws=T(`ZodBase64URL`,(e,t)=>{cr.init(e,t),P.init(e,t)}),Gs=T(`ZodE164`,(e,t)=>{lr.init(e,t),P.init(e,t)}),Ks=T(`ZodJWT`,(e,t)=>{dr.init(e,t),P.init(e,t)}),qs=T(`ZodNumber`,(e,t)=>{fr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.isFinite=!0},Ne({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=ao(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=ao(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=ao(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ao(e).format??null},{gt(e,t){return this.check(fa(e,t))},gte(e,t){return this.check(pa(e,t))},min(e,t){return this.check(pa(e,t))},lt(e,t){return this.check(ua(e,t))},lte(e,t){return this.check(da(e,t))},max(e,t){return this.check(da(e,t))},int(e){return this.check(Ys(e))},safe(e){return this.check(Ys(e))},positive(e){return this.check(fa(0,e))},nonnegative(e){return this.check(pa(0,e))},negative(e){return this.check(ua(0,e))},nonpositive(e){return this.check(da(0,e))},multipleOf(e,t){return this.check(ma(e,t))},step(e,t){return this.check(ma(e,t))},finite(){return this}}));function F(e){return na(qs,e)}var Js=T(`ZodNumberFormat`,(e,t)=>{pr.init(e,t),qs.init(e,t)});function Ys(e){return ia(Js,e)}var Xs=T(`ZodBoolean`,(e,t)=>{mr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r)});function I(e){return aa(Xs,e)}var Zs=T(`ZodNull`,(e,t)=>{hr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r)});function Qs(e){return oa(Zs,e)}var $s=T(`ZodAny`,(e,t)=>{gr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ec(){return sa($s)}var tc=T(`ZodUnknown`,(e,t)=>{_r.init(e,t),M.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function L(){return ca(tc)}var nc=T(`ZodNever`,(e,t)=>{vr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function rc(e){return la(nc,e)}var ic=T(`ZodArray`,(e,t)=>{ys(),Sr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ga(e,t))},nonempty(e){return this.check(ga(1,e))},max(e,t){return this.check(ha(e,t))},length(e,t){return this.check(_a(e,t))},unwrap(){return this.element}});function R(e,t){return Aa(ic,e,t)}var ac=T(`ZodObject`,(e,t)=>{ys(),Or.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),ze(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return U(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(_(this._zod.def,{catchall:e}))},passthrough(){return this.clone(_(this._zod.def,{catchall:L()}))},loose(){return this.clone(_(this._zod.def,{catchall:L()}))},strict(){return this.clone(_(this._zod.def,{catchall:rc()}))},strip(){return this.clone(_(this._zod.def,{catchall:void 0}))},extend(e){return _e(this,e)},safeExtend(e){return ye(this,e)},merge(e){return be(this,e)},pick(e){return me(this,e)},omit(e){return ge(this,e)},partial(...e){return xe(gc,this,e[0])},exactPartial(...e){return xe(_c,this,e[0],`exactPartial`)},required(...e){return y(Tc,this,e[0])}});function z(e,t){return new ac({type:`object`,shape:e??{},...v(t)})}function B(e,t){return new ac({type:`object`,shape:e,catchall:L(),...v(t)})}var oc=T(`ZodUnion`,(e,t)=>{Ar.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.options=t.options});function V(e,t){return new oc({type:`union`,options:e,...v(t)})}var sc=T(`ZodDiscriminatedUnion`,(e,t)=>{oc.init(e,t),Mr.init(e,t)});function cc(e,t,n){return new sc({type:`union`,options:t,discriminator:e,...v(n)})}var lc=T(`ZodIntersection`,(e,t)=>{Nr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r)});function uc(e,t){return new lc({type:`intersection`,left:e,right:t})}var dc=T(`ZodRecord`,(e,t)=>{ys(),Ir.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function H(e,t,n){return!t||!t._zod?new dc({type:`record`,keyType:N(),valueType:e,...v(t)}):new dc({type:`record`,keyType:e,valueType:t,...v(n)})}var fc=T(`ZodEnum`,(e,t)=>{Lr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new fc({...t,checks:[],...v(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new fc({...t,checks:[],...v(r),entries:i})}});function U(e,t){return new fc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...v(t)})}var pc=T(`ZodLiteral`,(e,t)=>{Rr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),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 W(e,t){return new pc({type:`literal`,values:Array.isArray(e)?e:[e],...v(t)})}var mc=T(`ZodTransform`,(e,t)=>{ys(),zr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Je(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ae(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Ae(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function hc(e){return new mc({type:`transform`,transform:e})}var gc=T(`ZodOptional`,(e,t)=>{Vr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function G(e){return new gc({type:`optional`,innerType:e})}var _c=T(`ZodExactOptional`,(e,t)=>{Hr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new _c({type:`optional`,innerType:e})}var yc=T(`ZodNullable`,(e,t)=>{Ur.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new yc({type:`nullable`,innerType:e})}var xc=T(`ZodDefault`,(e,t)=>{Wr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sc(e,t){return new xc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}var Cc=T(`ZodPrefault`,(e,t)=>{Kr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wc(e,t){return new Cc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}var Tc=T(`ZodNonOptional`,(e,t)=>{qr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new Tc({type:`nonoptional`,innerType:e,...v(t)})}var Dc=T(`ZodCatch`,(e,t)=>{Xr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Oc(e,t){return new Dc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ve(t)})}var kc=T(`ZodPipe`,(e,t)=>{Zr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.in=t.in,e.out=t.out});function Ac(e,t){return new kc({type:`pipe`,in:e,out:t})}var jc=T(`ZodPreprocess`,(e,t)=>{kc.init(e,t),$r.init(e,t)}),Mc=T(`ZodReadonly`,(e,t)=>{ei.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nc(e){return new Mc({type:`readonly`,innerType:e})}var Pc=T(`ZodLazy`,(e,t)=>{ni.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Fc(e){return new Pc({type:`lazy`,getter:e})}var Ic=T(`ZodCustom`,(e,t)=>{ri.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r)});function Lc(e,t={}){return ja(Ic,e,t)}function Rc(e,t){return Ma(e,t)}function zc(e,t){return new jc({type:`pipe`,in:hc(e),out:t})}var Bc={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},Vc;Vc||={};function Hc(e){return Qi(Ss,e)}function Uc(e){return $i(Cs,e)}function Wc(e){return ra(qs,e)}var Gc=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Kc=`io.modelcontextprotocol/related-task`,qc=`io.modelcontextprotocol/protocolVersion`,Jc=`io.modelcontextprotocol/clientInfo`,Yc=`io.modelcontextprotocol/serverInfo`,Xc=`io.modelcontextprotocol/clientCapabilities`,Zc=`io.modelcontextprotocol/subscriptionId`,Qc=`io.modelcontextprotocol/logLevel`,$c=Fc(()=>V([N(),F(),I(),Qs(),H(N(),$c),R($c)])),K=H(N(),$c),el=R($c),tl=V([N(),F().int()]),nl=N(),rl=z({ttl:F().optional()}),il=z({taskId:N()}),al=B({progressToken:tl.optional(),[Kc]:il.optional()}),ol=z({_meta:al.optional()}),sl=ol.extend({task:rl.optional()}),q=z({method:N(),params:ol.loose().optional()}),cl=z({_meta:al.optional()}),ll=z({method:N(),params:cl.loose().optional()}),ul=B({get[Yc](){return wl.optional().catch(void 0)}}),J=B({_meta:ul.optional()}),dl=V([N(),F().int()]),fl=z({jsonrpc:W(`2.0`),id:dl,...q.shape}).strict(),pl=z({jsonrpc:W(`2.0`),...ll.shape}).strict(),ml=z({jsonrpc:W(`2.0`),id:dl,result:J}).strict(),hl=z({jsonrpc:W(`2.0`),id:dl.optional(),error:z({code:F().int(),message:N(),data:L().optional()})}).strict(),gl=V([fl,pl,ml,hl]),_l=V([ml,hl]),vl=J.strict(),yl=cl.extend({requestId:dl.optional(),reason:N().optional()}),bl=ll.extend({method:W(`notifications/cancelled`),params:yl}),xl=z({src:N(),mimeType:N().optional(),sizes:R(N()).optional(),theme:U([`light`,`dark`]).optional()}),Sl=z({icons:R(xl).optional()}),Cl=z({name:N(),title:N().optional()}),wl=Cl.extend({...Cl.shape,...Sl.shape,version:N(),websiteUrl:N().optional(),description:N().optional()}),Tl=zc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,uc(z({form:uc(z({applyDefaults:I().optional()}),K).optional(),url:K.optional()}),K.optional())),El=B({list:K.optional(),cancel:K.optional(),requests:B({sampling:B({createMessage:K.optional()}).optional(),elicitation:B({create:K.optional()}).optional()}).optional()}),Dl=B({list:K.optional(),cancel:K.optional(),requests:B({tools:B({call:K.optional()}).optional()}).optional()}),Ol=z({experimental:H(N(),K).optional(),sampling:z({context:K.optional(),tools:K.optional()}).optional(),elicitation:Tl.optional(),roots:z({listChanged:I().optional()}).optional(),tasks:El.optional(),extensions:H(N(),K).optional()}),kl=ol.extend({protocolVersion:N(),capabilities:Ol,clientInfo:wl}),Al=q.extend({method:W(`initialize`),params:kl}),jl=z({experimental:H(N(),K).optional(),logging:K.optional(),completions:K.optional(),prompts:z({listChanged:I().optional()}).optional(),resources:z({subscribe:I().optional(),listChanged:I().optional()}).optional(),tools:z({listChanged:I().optional()}).optional(),tasks:Dl.optional(),extensions:H(N(),K).optional()}),Ml=J.extend({protocolVersion:N(),capabilities:jl,serverInfo:wl,instructions:N().optional()}),Nl=ll.extend({method:W(`notifications/initialized`),params:cl.optional()}),Pl=q.extend({method:W(`server/discover`),params:ol.optional()}),Fl=J.extend({supportedVersions:R(N()),capabilities:jl,instructions:N().optional()}),Il=q.extend({method:W(`ping`),params:ol.optional()}),Ll=z({progress:F(),total:G(F()),message:G(N())}),Rl=z({...cl.shape,...Ll.shape,progressToken:tl}),zl=ll.extend({method:W(`notifications/progress`),params:Rl}),Bl=ol.extend({cursor:nl.optional()}),Vl=q.extend({params:Bl.optional()}),Hl=J.extend({nextCursor:nl.optional()}),Ul=z({uri:N(),mimeType:G(N()),_meta:H(N(),L()).optional()}),Wl=Ul.extend({text:N()}),Gl=N().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Kl=Ul.extend({blob:Gl}),ql=U([`user`,`assistant`]),Jl=z({audience:R(ql).optional(),priority:F().min(0).max(1).optional(),lastModified:Hc({offset:!0}).optional()}),Yl=z({...Cl.shape,...Sl.shape,uri:N(),description:G(N()),mimeType:G(N()),size:G(F()),annotations:Jl.optional(),_meta:G(B({}))}),Xl=z({...Cl.shape,...Sl.shape,uriTemplate:N(),description:G(N()),mimeType:G(N()),annotations:Jl.optional(),_meta:G(B({}))}),Zl=Vl.extend({method:W(`resources/list`)}),Ql=Hl.extend({resources:R(Yl)}),$l=Vl.extend({method:W(`resources/templates/list`)}),eu=Hl.extend({resourceTemplates:R(Xl)}),tu=ol.extend({uri:N()}),nu=tu,ru=q.extend({method:W(`resources/read`),params:nu}),iu=J.extend({contents:R(V([Wl,Kl]))}),au=ll.extend({method:W(`notifications/resources/list_changed`),params:cl.optional()}),ou=tu,su=q.extend({method:W(`resources/subscribe`),params:ou}),cu=tu,lu=q.extend({method:W(`resources/unsubscribe`),params:cu}),uu=z({toolsListChanged:I().optional(),promptsListChanged:I().optional(),resourcesListChanged:I().optional(),resourceSubscriptions:R(N()).optional()}),du=ol.extend({notifications:uu}),fu=q.extend({method:W(`subscriptions/listen`),params:du}),pu=cl.extend({notifications:uu}),mu=ll.extend({method:W(`notifications/subscriptions/acknowledged`),params:pu}),hu=ul.extend({[Zc]:dl}),gu=J.extend({_meta:hu}),_u=cl.extend({uri:N()}),vu=ll.extend({method:W(`notifications/resources/updated`),params:_u}),yu=z({name:N(),description:G(N()),required:G(I())}),bu=z({...Cl.shape,...Sl.shape,description:G(N()),arguments:G(R(yu)),_meta:G(B({}))}),xu=Vl.extend({method:W(`prompts/list`)}),Su=Hl.extend({prompts:R(bu)}),Cu=ol.extend({name:N(),arguments:H(N(),N()).optional()}),wu=q.extend({method:W(`prompts/get`),params:Cu}),Tu=z({type:W(`text`),text:N(),annotations:Jl.optional(),_meta:H(N(),L()).optional()}),Eu=z({type:W(`image`),data:Gl,mimeType:N(),annotations:Jl.optional(),_meta:H(N(),L()).optional()}),Du=z({type:W(`audio`),data:Gl,mimeType:N(),annotations:Jl.optional(),_meta:H(N(),L()).optional()}),Ou=z({type:W(`tool_use`),name:N(),id:N(),input:H(N(),L()),_meta:H(N(),L()).optional()}),ku=z({type:W(`resource`),resource:V([Wl,Kl]),annotations:Jl.optional(),_meta:H(N(),L()).optional()}),Au=Yl.extend({type:W(`resource_link`)}),ju=V([Tu,Eu,Du,Au,ku]),Mu=z({role:ql,content:ju}),Nu=J.extend({description:N().optional(),messages:R(Mu)}),Pu=ll.extend({method:W(`notifications/prompts/list_changed`),params:cl.optional()}),Fu=z({title:N().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),Iu=z({taskSupport:U([`required`,`optional`,`forbidden`]).optional()}),Lu=z({...Cl.shape,...Sl.shape,description:N().optional(),inputSchema:z({type:W(`object`),properties:H(N(),$c).optional(),required:R(N()).optional()}).catchall(L()),outputSchema:B({$schema:N().optional()}).optional(),annotations:Fu.optional(),execution:Iu.optional(),_meta:H(N(),L()).optional()}),Ru=Vl.extend({method:W(`tools/list`)}),zu=Hl.extend({tools:R(Lu)}),Bu=J.extend({content:R(ju).default([]),structuredContent:L().optional(),isError:I().optional()}),Vu=Bu.or(J.extend({toolResult:L()})),Hu=sl.extend({name:N(),arguments:H(N(),L()).optional()}),Uu=q.extend({method:W(`tools/call`),params:Hu}),Wu=ll.extend({method:W(`notifications/tools/list_changed`),params:cl.optional()}),Gu=z({autoRefresh:I().default(!0),debounceMs:F().int().nonnegative().default(300)}),Ku=U([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),qu=ol.extend({level:Ku}),Ju=q.extend({method:W(`logging/setLevel`),params:qu}),Yu=cl.extend({level:Ku,logger:N().optional(),data:L()}),Xu=ll.extend({method:W(`notifications/message`),params:Yu}),Zu=z({name:N().optional()}),Qu=z({hints:R(Zu).optional(),costPriority:F().min(0).max(1).optional(),speedPriority:F().min(0).max(1).optional(),intelligencePriority:F().min(0).max(1).optional()}),$u=z({mode:U([`auto`,`required`,`none`]).optional()}),ed=z({type:W(`tool_result`),toolUseId:N().describe(`The unique identifier for the corresponding tool call.`),content:R(ju),structuredContent:L().optional(),isError:I().optional(),_meta:H(N(),L()).optional()}),td=cc(`type`,[Tu,Eu,Du]),nd=cc(`type`,[Tu,Eu,Du,Ou,ed]),rd=z({role:ql,content:V([nd,R(nd)]),_meta:H(N(),L()).optional()}),id=sl.extend({messages:R(rd),modelPreferences:Qu.optional(),systemPrompt:N().optional(),includeContext:U([`none`,`thisServer`,`allServers`]).optional(),temperature:F().optional(),maxTokens:F().int(),stopSequences:R(N()).optional(),metadata:K.optional(),tools:R(Lu).optional(),toolChoice:$u.optional()}),ad=q.extend({method:W(`sampling/createMessage`),params:id}),od=J.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`]).or(N())),role:ql,content:td}),sd=J.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(N())),role:ql,content:V([nd,R(nd)])}),cd=z({type:W(`boolean`),title:N().optional(),description:N().optional(),default:I().optional()}),ld=z({type:W(`string`),title:N().optional(),description:N().optional(),minLength:F().optional(),maxLength:F().optional(),format:U([`email`,`uri`,`date`,`date-time`]).optional(),default:N().optional()}),ud=z({type:U([`number`,`integer`]),title:N().optional(),description:N().optional(),minimum:F().optional(),maximum:F().optional(),default:F().optional()}),dd=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),default:N().optional()}),fd=z({type:W(`string`),title:N().optional(),description:N().optional(),oneOf:R(z({const:N(),title:N()})),default:N().optional()}),pd=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),enumNames:R(N()).optional(),default:N().optional()}),md=V([dd,fd]),hd=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({type:W(`string`),enum:R(N())}),default:R(N()).optional()}),gd=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({anyOf:R(z({const:N(),title:N()}))}),default:R(N()).optional()}),_d=V([hd,gd]),vd=V([pd,md,_d]),yd=V([vd,cd,ld,ud]),bd=sl.extend({mode:W(`form`).optional(),message:N(),requestedSchema:z({type:W(`object`),properties:H(N(),yd),required:R(N()).optional()}).catchall(L())}),xd=sl.extend({mode:W(`url`),message:N(),elicitationId:N(),url:N().url()}),Sd=V([bd,xd]),Cd=q.extend({method:W(`elicitation/create`),params:Sd}),wd=cl.extend({elicitationId:N()}),Td=ll.extend({method:W(`notifications/elicitation/complete`),params:wd}),Ed=J.extend({action:U([`accept`,`decline`,`cancel`]),content:zc(e=>e===null?void 0:e,H(N(),V([N(),F(),I(),R(N())])).optional())}),Dd=z({type:W(`ref/resource`),uri:N()}),Od=z({type:W(`ref/prompt`),name:N()}),kd=ol.extend({ref:V([Od,Dd]),argument:z({name:N(),value:N()}),context:z({arguments:H(N(),N()).optional()}).optional()}),Ad=q.extend({method:W(`completion/complete`),params:kd}),jd=J.extend({completion:B({values:R(N()).max(100),total:G(F().int()),hasMore:G(I())})}),Md=z({uri:N().startsWith(`file://`),name:N().optional(),_meta:H(N(),L()).optional()}),Nd=q.extend({method:W(`roots/list`),params:ol.optional()}),Pd=J.extend({roots:R(Md)}),Fd=ll.extend({method:W(`notifications/roots/list_changed`),params:cl.optional()}),Id=B({ttl:F().optional(),pollInterval:F().optional()}),Ld=U([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Rd=z({taskId:N(),status:Ld,ttl:V([F(),Qs()]),createdAt:N(),lastUpdatedAt:N(),pollInterval:G(F()),statusMessage:G(N())}),zd=J.extend({task:Rd}),Bd=cl.merge(Rd),Vd=ll.extend({method:W(`notifications/tasks/status`),params:Bd}),Hd=q.extend({method:W(`tasks/get`),params:ol.extend({taskId:N()})}),Ud=J.merge(Rd),Wd=q.extend({method:W(`tasks/result`),params:ol.extend({taskId:N()})}),Gd=J.loose(),Kd=Vl.extend({method:W(`tasks/list`)}),qd=Hl.extend({tasks:R(Rd)}),Jd=q.extend({method:W(`tasks/cancel`),params:ol.extend({taskId:N()})}),Yd=J.merge(Rd),Xd=V([Il,Al,Pl,Ad,Ju,wu,xu,Zl,$l,ru,su,lu,fu,Uu,Ru]),Zd=V([bl,zl,Nl,Fd]),Qd=V([vl,od,sd,Ed,Pd]),$d=V([Il,ad,Cd,Nd]),ef=V([bl,zl,Xu,vu,au,Wu,Pu,mu,Td]),tf=V([vl,Ml,Fl,jd,Nu,Su,Ql,eu,iu,Bu,zu,gu]),nf=js().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Bc.custom,message:`URL must be parseable`,fatal:!0}),Ue}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),rf=B({resource:N().url(),authorization_servers:R(nf).optional(),jwks_uri:N().url().optional(),scopes_supported:R(N()).optional(),bearer_methods_supported:R(N()).optional(),resource_signing_alg_values_supported:R(N()).optional(),resource_name:N().optional(),resource_documentation:N().optional(),resource_policy_uri:N().url().optional(),resource_tos_uri:N().url().optional(),tls_client_certificate_bound_access_tokens:I().optional(),authorization_details_types_supported:R(N()).optional(),dpop_signing_alg_values_supported:R(N()).optional(),dpop_bound_access_tokens_required:I().optional()}),af=B({issuer:N(),authorization_endpoint:nf,token_endpoint:nf,registration_endpoint:nf.optional(),scopes_supported:R(N()).optional(),response_types_supported:R(N()),response_modes_supported:R(N()).optional(),grant_types_supported:R(N()).optional(),token_endpoint_auth_methods_supported:R(N()).optional(),token_endpoint_auth_signing_alg_values_supported:R(N()).optional(),service_documentation:nf.optional(),revocation_endpoint:nf.optional(),revocation_endpoint_auth_methods_supported:R(N()).optional(),revocation_endpoint_auth_signing_alg_values_supported:R(N()).optional(),introspection_endpoint:N().optional(),introspection_endpoint_auth_methods_supported:R(N()).optional(),introspection_endpoint_auth_signing_alg_values_supported:R(N()).optional(),code_challenge_methods_supported:R(N()).optional(),client_id_metadata_document_supported:I().optional(),authorization_response_iss_parameter_supported:I().optional().catch(void 0),dpop_signing_alg_values_supported:R(N()).optional()}),of=B({issuer:N(),authorization_endpoint:nf,token_endpoint:nf,userinfo_endpoint:nf.optional(),jwks_uri:nf,registration_endpoint:nf.optional(),scopes_supported:R(N()).optional(),response_types_supported:R(N()),response_modes_supported:R(N()).optional(),grant_types_supported:R(N()).optional(),acr_values_supported:R(N()).optional(),subject_types_supported:R(N()),id_token_signing_alg_values_supported:R(N()),id_token_encryption_alg_values_supported:R(N()).optional(),id_token_encryption_enc_values_supported:R(N()).optional(),userinfo_signing_alg_values_supported:R(N()).optional(),userinfo_encryption_alg_values_supported:R(N()).optional(),userinfo_encryption_enc_values_supported:R(N()).optional(),request_object_signing_alg_values_supported:R(N()).optional(),request_object_encryption_alg_values_supported:R(N()).optional(),request_object_encryption_enc_values_supported:R(N()).optional(),token_endpoint_auth_methods_supported:R(N()).optional(),token_endpoint_auth_signing_alg_values_supported:R(N()).optional(),display_values_supported:R(N()).optional(),claim_types_supported:R(N()).optional(),claims_supported:R(N()).optional(),service_documentation:N().optional(),claims_locales_supported:R(N()).optional(),ui_locales_supported:R(N()).optional(),claims_parameter_supported:I().optional(),request_parameter_supported:I().optional(),request_uri_parameter_supported:I().optional(),require_request_uri_registration:I().optional(),op_policy_uri:nf.optional(),op_tos_uri:nf.optional(),client_id_metadata_document_supported:I().optional(),authorization_response_iss_parameter_supported:I().optional().catch(void 0)}),sf=z({...of.shape,...af.pick({code_challenge_methods_supported:!0}).shape}),cf=z({access_token:N(),id_token:N().optional(),token_type:N(),expires_in:Wc().optional(),scope:N().optional(),refresh_token:N().optional(),issuer:N().optional().catch(void 0)}).strip(),lf=z({issued_token_type:W(`urn:ietf:params:oauth:token-type:id-jag`),access_token:N(),token_type:N().optional(),expires_in:F().optional(),scope:N().optional()}).strip(),uf=z({error:N(),error_description:N().optional(),error_uri:N().optional()}),df=nf.optional().or(W(``).transform(()=>void 0)),ff=z({redirect_uris:R(nf),token_endpoint_auth_method:N().optional(),grant_types:R(N()).optional(),response_types:R(N()).optional(),application_type:N().optional(),client_name:N().optional(),client_uri:nf.optional(),logo_uri:df,scope:N().optional(),contacts:R(N()).optional(),tos_uri:df,policy_uri:N().optional(),jwks_uri:nf.optional(),jwks:ec().optional(),software_id:N().optional(),software_version:N().optional(),software_statement:N().optional()}).strip(),pf=z({client_id:N(),client_secret:N().optional(),client_id_issued_at:F().optional(),client_secret_expires_at:F().optional(),issuer:N().optional().catch(void 0)}).strip(),mf=ff.merge(pf),hf=z({error:N(),error_description:N().optional()}).strip(),gf=z({token:N(),token_type_hint:N().optional()}).strip();function _f(e,t,n){return typeof e==`object`&&!!e&&`channel`in e&&e.channel===t&&`type`in e&&e.type===`mcp`&&`direction`in e&&e.direction===n&&`payload`in e}function vf(e,t,n,r,i){e.postMessage({channel:n,type:`mcp`,direction:r,payload:i},t)}var yf=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;onclientorigin;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-iframe`}get clientOrigin(){return this._clientOrigin}async start(){if(this._closed)throw Error(`IframeChildTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window.parent||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!_f(e.data,this._channelId,`client-to-server`))return;this._clientOrigin!==e.origin&&(this._clientOrigin=e.origin,this.onclientorigin?.(e.origin));let{payload:t}=e.data;if(t===`mcp-check-ready`)this._broadcastServerReady();else try{let e=gl.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this._broadcastServerReady()}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);this._clientOrigin?window.parent===window?console.debug(`[IframeChildTransport] Not running in an iframe, message not sent`):vf(window.parent,this._clientOrigin,this._channelId,`server-to-client`,e):console.debug(`[IframeChildTransport] No client connected, message not sent`)}async close(){this._closed||(this._closed=!0,this._started=!1,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._clientOrigin&&window.parent!==window&&vf(window.parent,this._clientOrigin,this._channelId,`server-to-client`,`mcp-server-stopped`),this.onclose?.())}_broadcastServerReady(){window.parent!==window&&vf(window.parent,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}},bf=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-default`}async start(){if(this._closed)throw Error(`TabServerTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!_f(e.data,this._channelId,`client-to-server`))return;let{payload:t}=e.data;if(t===`mcp-check-ready`)vf(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`);else try{let e=gl.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,vf(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);vf(window,`*`,this._channelId,`server-to-client`,e)}async close(){this._closed||(this._closed=!0,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._started&&vf(window,`*`,this._channelId,`server-to-client`,`mcp-server-stopped`),this._started=!1,this.onclose?.())}},xf=[`consequentialHint`,`debugging`,`readOnlyHint`,`untrustedContentHint`],Sf=`webmcp-polyfill`,Cf=500,wf=globalThis.DOMException,Tf=class{#e;#t;#n;#r=new Set;#i=new Set;#a=Promise.withResolvers();#o=new Map;#s=new Set;#c;#l=!1;constructor(e,t){this.#t=e,this.#e=e.document,this.#n=t,this.#t.addEventListener(`message`,e=>this.#d(e),!0),this.#t.addEventListener(`pagehide`,()=>{this.#l=!0;for(let e of this.#s)e.end()}),this.#t.addEventListener(`pageshow`,e=>{e.persisted&&(this.#l=!1,this.#x())});for(let e of this.#x())this.#i.add(e);this.#i.size===0?this.#a.resolve():setTimeout(()=>{this.#i.clear(),this.#a.resolve()},Cf)}async allowed(){return!this.#l&&this.#h(this.#e)}async getTools(e){await this.#a.promise;let t=this.#t.origin,n=[t,...e];return(await Promise.all(this.#b().map(async e=>{if(e===this.#t)return this.#n.getTools(t).map(e=>Mf(e,this.#t,t));try{let t=await this.#u(e,n,{kind:`getTools`});if(!Array.isArray(t.value))throw TypeError(`Expected a tool list from the frame`);return t.value.map(n=>Mf(Nf(n),e,t.origin))}catch(e){return e instanceof wf&&e.name===`UnknownError`||console.warn(`WebMCP: could not read tools from a frame.`,e),[]}}))).flat()}async execute(e,t,n,r,i){let a=await this.#u(e,[t],{kind:`execute`,name:n,input:r},i);if(typeof a.value!=`string`)throw Lf();return a.value}async notify(e){await this.#a.promise;let t=[this.#t.origin,...e];for(let e of this.#b())if(e===this.#t)await this.#n.changed();else try{await this.#u(e,t,{kind:`changed`})}catch{}}#u(e,t,n,r){return new Promise((i,a)=>{if(r?.throwIfAborted(),this.#l||!this.#v(e)){a(Lf());return}let o=crypto.randomUUID(),{port1:s,port2:c}=new MessageChannel,l,u=()=>{clearTimeout(h),g(),r?.removeEventListener(`abort`,f),this.#o.delete(o),s.close()},d=(e=Lf())=>{s.postMessage({kind:`cancel`}),u(),a(e)},f=()=>d(r?.reason),p=()=>{l===void 0&&this.#C(e),d()},m=r=>{r.source===e&&(this.#o.delete(o),t&&!t.includes(r.origin)?d():(l=r.origin,clearTimeout(h),n.kind!==`execute`&&n.kind!==`changed`&&(h=setTimeout(p,Cf)),s.postMessage(n)))},h=setTimeout(p,Cf),g=this.#w(e,d);s.onmessage=e=>{let t=Ff(e.data);t?.kind===`error`?d():t?.kind===`result`&&l!==void 0&&(u(),i({value:t.value,origin:l}))},s.onmessageerror=()=>d(),r?.addEventListener(`abort`,f,{once:!0}),this.#o.set(o,m);try{e.postMessage(`${Sf}:connect:${o}`,`*`,[c])}catch{c.close(),d()}})}#d(e){let t=Pf(e.data);if(!t)return;e.stopImmediatePropagation();let n=e.source;if(!e.isTrusted||!n||!If(n)||!this.#v(n)||e.origin===`null`||this.#l)return;if(t.kind===`announce`){let t=!this.#r.has(n);if(this.#S(n),n.postMessage(`${Sf}:present`,e.origin),!t||this.#t!==this.#t.top)return;for(let e of this.#r)e!==n&&e.postMessage(`${Sf}:refresh`,`*`);return}if(t.kind===`present`){this.#S(n);return}if(t.kind===`refresh`){n===this.#t.top&&this.#x();return}if(t.kind===`ready`){this.#o.get(t.id)?.(e);return}let[r]=e.ports;t.kind===`connect`&&t.id&&r&&e.ports.length===1&&(this.#S(n),this.#f(n,e.origin,t.id,r))}#f(e,t,n,r){let i=new AbortController,a=!1,o=()=>{clearTimeout(l),u(),r.close()},s=()=>{i.abort(),o()},c=()=>{r.postMessage({kind:`error`}),s()},l=setTimeout(c,Cf),u=this.#w(e,c);r.onmessageerror=c,r.onmessage=async n=>{let u=Ff(n.data);if(u?.kind===`cancel`)s();else if(!a){a=!0,clearTimeout(l);try{let n=await this.#p(e,t,u,i.signal);r.postMessage({kind:`result`,value:n}),o()}catch{c()}}},e.postMessage(`${Sf}:ready:${n}`,t)}async#p(e,t,n,r){if(!n||!this.#v(e))throw Lf();if(n.kind===`permission`){let{childIndex:e,childOrigin:t}=n;if(typeof e!=`number`||!Number.isInteger(e)||e<0||typeof t!=`string`)throw Lf();return this.#m(e,t)}if(!await this.allowed()||!await this.#g(e,t)||!this.#v(e))throw Lf();if(r.throwIfAborted(),n.kind===`getTools`)return this.#n.getTools(t);if(n.kind===`execute`&&typeof n.name==`string`&&typeof n.input==`string`)return this.#n.execute(t,n.name,n.input,r);if(n.kind===`changed`)await this.#n.changed();else throw Lf()}async#m(e,t){let n=this.#t[e];return n!==void 0&&await this.allowed()&&Ef(this.#e,n,t)}async#h(e){let t=Af(e);if(!t)return!1;let n=jf(e);if(n!==void 0)return n;if(t===t.parent)return!0;let r=t.location.ancestorOrigins?.[0],i=Df(t.parent,r===void 0||r===t.origin);return i?Ef(i,t,t.origin)&&await this.#h(i):this.#_(t,t.origin)}async#g(e,t){let n=Df(e,t===this.#t.origin);return n?this.#h(n):this.#_(e,t)}async#_(e,t){let n=e.parent;if(n===e)return!0;let r=-1;for(let t=0;t<n.length;t++)if(n[t]===e){r=t;break}if(r<0)return!1;if(n===this.#t)return await this.allowed()&&Ef(this.#e,e,t);if(await this.#a.promise,!this.#r.has(n))return!1;try{let e=await this.#u(n,void 0,{kind:`permission`,childIndex:r,childOrigin:t});return e.value===!0&&await this.#g(n,e.origin)}catch{return!1}}#v(e){try{return!e.closed&&e!==this.#t&&e.top===this.#t.top}catch{return!1}}#y(){if(this.#t.closed)return[];for(let e of this.#r)this.#v(e)||this.#r.delete(e);let e=[this.#t,...this.#r];for(let t=this.#t.parent;t!==t.parent;t=t.parent)e.push(t);let t=new Set,n=[this.#t.top];for(;n.length;){let r=n.pop();if(t.has(r))continue;t.add(r);let i=[];for(let e=0;e<r.length;e++){let t=r[e];t&&i.push(t)}for(let t of e)t!==r&&t.parent===r&&!i.includes(t)&&i.push(t);n.push(...i.reverse())}return Array.from(t).filter(e=>e===this.#t||this.#v(e))}#b(){return this.#y().filter(e=>e===this.#t||this.#r.has(e))}#x(){let e=this.#y().filter(e=>e!==this.#t);for(let t of e)t.postMessage(`${Sf}:announce`,`*`);return e}#S(e){this.#r.add(e),this.#i.delete(e),this.#i.size===0&&this.#a.resolve()}#C(e){this.#r.delete(e),this.#v(e)&&e.postMessage(`${Sf}:announce`,`*`)}#w(e,t){let n={peer:e,end:t};return this.#s.add(n),this.#c===void 0&&(this.#c=this.#t.setInterval(()=>{for(let e of this.#s)this.#v(e.peer)||e.end()},100)),()=>{this.#s.delete(n),this.#s.size===0&&(this.#t.clearInterval(this.#c),this.#c=void 0)}}};function Ef(e,t,n){let r=e.defaultView?.origin,i=Of(e,t,n===r);if(!i)return!1;let a=(i.getAttribute(`allow`)??``).split(`;`).map(e=>e.trim().split(/\s+/u)).find(([e])=>e===`tools`);if(!a)return n===r;let o=a.length===1?[`'src'`]:a.slice(1);if(o.includes(`'none'`))return!1;let s=i.hasAttribute(`srcdoc`)?null:i.getAttribute(`src`),c=s?URL.parse(s,e.baseURI):null,l=!s||c?.protocol===`about:`?r:c?.origin;return o.some(e=>e===`*`||e===`'self'`&&n===r||e===`'src'`&&n===l||e===n)}function Df(e,t){if(t)try{return e.document}catch{return}}function Of(e,t,n){if(n)try{let n=t.frameElement;if(n?.ownerDocument===e)return n}catch{}return kf(e,t)}function kf(e,t){let n=e.querySelectorAll(`iframe, frame`);for(let e of n)if(e.contentWindow===t)return e;for(let n of e.querySelectorAll(`*`)){if(!n.shadowRoot)continue;let e=kf(n.shadowRoot,t);if(e)return e}}function Af(e){let t=e.defaultView;return t&&!t.closed&&t.document===e?t:void 0}function jf(e){let t=e,n=Ff(t.permissionsPolicy??t.featurePolicy);if(typeof n?.features!=`function`||typeof n.allowsFeature!=`function`)return;let r=n.features();return Array.isArray(r)&&r.includes(`tools`)?!!n.allowsFeature(`tools`):void 0}function Mf(e,t,n){let r=e.serializedSchema===void 0?void 0:JSON.parse(e.serializedSchema);return{...e.annotations!==void 0&&{annotations:{...e.annotations}},description:e.description,...r!==void 0&&{inputSchema:r},name:e.name,origin:n,title:e.title,window:t}}function Nf(e){let t=Ff(e);if(!t||typeof t.name!=`string`||typeof t.title!=`string`||typeof t.description!=`string`||t.serializedSchema!==void 0&&typeof t.serializedSchema!=`string`)throw TypeError(`Invalid tool metadata from the frame`);let n={name:t.name,title:t.title,description:t.description,annotations:void 0,serializedSchema:t.serializedSchema};if(t.annotations===void 0)return n;let r=Ff(t.annotations);if(!r)throw TypeError(`Invalid tool annotations from the frame`);let i={};for(let e of xf){let t=r[e];if(t!==void 0){if(typeof t!=`boolean`)throw TypeError(`Invalid ${e} annotation from the frame`);i[e]=t}}return n.annotations=i,n}function Pf(e){if(typeof e!=`string`)return;let[t,n=``,r=``,i]=e.split(`:`);return t===Sf&&i===void 0?{kind:n,id:r}:void 0}function Ff(e){if(typeof e==`object`&&e&&!Array.isArray(e))return e}function If(e){try{return`postMessage`in e&&`window`in e}catch{return!1}}function Lf(){return new wf(`Tool execution failed`,`UnknownError`)}var Rf=globalThis.DOMException,zf=Object.getOwnPropertyDescriptor(globalThis,`window`)?.get,Bf=new WeakMap;function Vf(){if(typeof document>`u`||!globalThis.isSecureContext||`modelContext`in document)return;let e=Document.prototype,t=Object.getOwnPropertyDescriptor(e,`defaultView`).get,n=Object.getOwnPropertyDescriptor(globalThis,`ModelContext`);if(!Object.isExtensible(e)||n&&!n.configurable||!n&&!Object.isExtensible(globalThis))throw TypeError(`Cannot install WebMCP on this realm`);Object.defineProperty(globalThis,"ModelContext",{value:Wf,configurable:!0,writable:!0});let{getModelContext:r}={getModelContext(){t.call(this);let e=Bf.get(this);return e||(e=new Hf(this),Bf.set(this,e)),e}};Object.defineProperty(r,"name",{value:`get modelContext`}),Object.defineProperty(e,"modelContext",{configurable:!0,enumerable:!0,get:r}),document.modelContext}var Hf=class extends EventTarget{#e;#t=new Map;#n;#r=null;#i=e=>{let t=this.#r;typeof t==`function`&&Reflect.apply(t,this,[e])===!1&&Event.prototype.preventDefault.call(e)};constructor(e){super(),this.#e=e;let t=Af(e);t&&(this.#n=new Tf(t,{getTools:e=>this.#s(e),execute:(t,n,r,i)=>{let a=ap(e).origin;return this.#a(n,r,a,t,i)},changed:()=>this.#c()}))}get ontoolchange(){return this.#r}set ontoolchange(e){let t=Jf(e)?e:null;!this.#r&&t&&this.addEventListener(`toolchange`,this.#i),this.#r&&!t&&this.removeEventListener(`toolchange`,this.#i),this.#r=t}async registerTool(e,t={}){let n=this.#e,{name:r,title:i,description:a,annotations:o,inputSchema:s,execute:c}=Gf(e),l=Yf(t),u=np(l.exposedTo),d=tp(l.signal);ap(n);let f=()=>{if(this.#t.has(r))throw new Rf(`A tool named ${r} is already registered`,`InvalidStateError`)};if(f(),!/^[A-Za-z0-9_.-]{1,128}$/u.test(r))throw new Rf(`Tool names are 1 to 128 characters of ASCII alphanumerics, "_", "-" or ".": ${r}`,`InvalidStateError`);if(!a)throw new Rf(`A tool description cannot be empty`,`InvalidStateError`);let p=s===void 0?void 0:ep(s);d?.throwIfAborted();let m=rp(u),h={metadata:{name:r,title:i,description:a,annotations:o,serializedSchema:p},execute:c,exposedTo:m},g=await this.#o();return d?.throwIfAborted(),f(),new Promise((e,t)=>{d?.addEventListener(`abort`,()=>{this.#t.delete(r),g.notify(m),t(d.reason)},{once:!0}),this.#t.set(r,h),g.notify(m).then(e,t)})}async getTools(e={}){let t=this.#e,n=np(Yf(e).fromOrigins);ap(t);let r=await this.#o(),i=rp(n),a=await r.getTools(i);return a.sort((e,t)=>e.name===t.name?0:e.name<t.name?-1:1),new Promise(e=>{cp(()=>e(a))})}async executeTool(e,t={},n={}){let r=this.#e,i=Kf(e),a=tp(Yf(n).signal);ap(r);let o=URL.parse(i.origin)?.origin;if(!o||o===`null`)throw new Rf(`Invalid or opaque origin`,`NotSupportedError`);if(!Jf(t))throw TypeError(`inputObject must be an object`);let s=ep(t);a?.throwIfAborted();let c=await this.#o();a?.throwIfAborted();let l=ap(r);return i.window===l?this.#a(i.name,s,o,l.origin,a):c.execute(i.window,o,i.name,s,a)}#a(e,t,n,r,i){return new Promise((a,o)=>{i?.throwIfAborted();let s=new AbortController,c=!1,l=()=>{o(i.reason),cp(()=>{c||s.abort()})},u=()=>{c=!0,cp(()=>{i?.removeEventListener(`abort`,l),o(Lf())})},d=e=>{if(c=!0,!i?.aborted)try{let t=ep(e);cp(()=>{i?.removeEventListener(`abort`,l),a(t)})}catch{u()}};i?.addEventListener(`abort`,l,{once:!0}),cp(()=>{if(!i?.aborted)try{let i=ap(this.#e),a=this.#t.get(e);if(!a||n!==i.origin||!Uf(a,i.origin,r)){u();return}let o=JSON.parse(t);if(!Jf(o)){u();return}let c=(0,a.execute)(o,{signal:s.signal});Promise.resolve(c).then(d,u)}catch{u()}})})}async#o(){let e=this.#n;if(!e||!await e.allowed())throw new Rf(`WebMCP is disabled by Permissions Policy`,`NotAllowedError`);return ap(this.#e),e}#s(e){let t=ap(this.#e).origin,n=[];for(let r of this.#t.values())Uf(r,t,e)&&n.push(r.metadata);return n}#c(){return new Promise(e=>{cp(()=>{this.dispatchEvent(new Event(`toolchange`)),e()})})}};function Uf(e,t,n){return t===n||e.exposedTo.includes(n)}var Wf=function(){throw TypeError(`Illegal constructor`)};Object.defineProperty(Wf,"name",{value:`ModelContext`}),Object.defineProperty(Wf,"prototype",{value:Hf.prototype,writable:!1}),Object.setPrototypeOf(Wf,EventTarget),Object.defineProperties(Hf.prototype,{constructor:{value:Wf,configurable:!0,writable:!0},[Symbol.toStringTag]:{value:`ModelContext`,configurable:!0},registerTool:{enumerable:!0},getTools:{enumerable:!0},executeTool:{enumerable:!0},ontoolchange:{enumerable:!0}});function Gf(e){let t=Yf(e),n=Xf(t.annotations),r=Zf($f(t.description,`description`)),i=$f(t.execute,`execute`);if(typeof i!=`function`)throw TypeError(`execute must be a function`);let a=i,o=qf(t.inputSchema),s=Zf($f(t.name,`name`)),c=t.title;return{name:s,title:c===void 0?``:Qf(c),description:r,annotations:n,inputSchema:o,execute:a}}function Kf(e){let t=Yf(e);Xf(t.annotations),Zf($f(t.description,`description`)),qf(t.inputSchema);let n=Zf($f(t.name,`name`)),r=Qf($f(t.origin,`origin`)),i=t.title;i!==void 0&&Zf(i);let a=$f(t.window,`window`);if(!Jf(a))throw TypeError(`window must be a Window`);return zf.call(a),{name:n,origin:r,window:a}}function qf(e){if(e!==void 0&&!Jf(e))throw TypeError(`inputSchema must be an object`);return e}function Jf(e){return typeof e==`object`&&!!e||typeof e==`function`}function Yf(e){if(e==null)return{};if(!Jf(e))throw TypeError(`Expected a dictionary`);return e}function Xf(e){if(e===void 0)return;let t=Yf(e),n={};for(let e of xf)n[e]=!!t[e];return n}function Zf(e){if(typeof e==`symbol`)throw TypeError(`Cannot convert a Symbol to a string`);return String(e)}function Qf(e){return Zf(e).toWellFormed()}function $f(e,t){if(e===void 0)throw TypeError(`${t} is required`);return e}function ep(e){let t=JSON.stringify(e);if(t===void 0)throw TypeError(`Value is not JSON-serializable`);return t}function tp(e){if(e!==void 0)return AbortSignal.any([e])}function np(e){if(e===void 0)return[];if(!Jf(e))throw TypeError(`Origins must be a sequence`);let t=Yf(e)[Symbol.iterator];if(typeof t!=`function`)throw TypeError(`Origins must be a sequence`);let n={[Symbol.iterator](){let n=Reflect.apply(t,e,[]);if(!Jf(n))throw TypeError(`Iterator must be an object`);let r=Yf(n).next;if(typeof r!=`function`)throw TypeError(`Iterator next must be a function`);return{next(){return Reflect.apply(r,n,[])}}}};return Array.from(n,Qf)}function rp(e){return e.map(e=>{let t=URL.parse(e)?.origin;if(t===void 0)throw new Rf(`Invalid origin`,`SecurityError`);let n=URL.parse(t);if(!n||!ip(n))throw new Rf(`Origin is not potentially trustworthy`,`SecurityError`);return t})}function ip({protocol:e,hostname:t}){if([`https:`,`wss:`].includes(e))return!0;let n=t===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t),r=t===`localhost`||t===`localhost.`||t.endsWith(`.localhost`)||t.endsWith(`.localhost.`);return[`http:`,`ws:`].includes(e)&&(n||r)}function ap(e){let t=Af(e);if(!t)throw new Rf(`The document is not fully active`,`InvalidStateError`);if(jf(e)===!1)throw new Rf(`WebMCP is disabled by Permissions Policy`,`NotAllowedError`);return t}var op,sp=[];function cp(e){if(!op){let e=new MessageChannel;e.port1.onmessage=()=>sp.shift()?.(),op=e.port2}sp.push(e),op.postMessage(void 0)}var lp=new WeakSet,up=new WeakMap,dp=new WeakMap;function fp(e){return e.isTrusted&&(lp.has(e)||e.eventPhase!==Event.NONE&&e.target instanceof HTMLFormElement&&dp.has(e.target))}function pp(e,t){if(!fp(e))throw new DOMException(`respondWith() is only available during an agent-invoked submit event`,`InvalidStateError`);if(!e.defaultPrevented)throw new DOMException(`respondWith() requires preventDefault() during an agent-invoked submit event`,`InvalidStateError`);if(e.eventPhase===Event.NONE)throw new DOMException(`respondWith() is only available while the submit event is being dispatched`,`InvalidStateError`);lp.add(e);let n=Promise.resolve(t);up.set(e,n),e.target instanceof HTMLFormElement&&dp.get(e.target)?.respond(e)}var mp=new Set([`email`,`password`,`search`,`tel`,`text`,`url`]),hp=new Set([...mp,`date`,`datetime-local`,`month`,`number`,`time`,`week`]);function gp(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function _p(e){return Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`)?.get?.call(e)}function vp(e,t){return Element.prototype.getAttribute.call(e,t)}function yp(e,t){return Element.prototype.hasAttribute.call(e,t)}function bp(e){return Object.getOwnPropertyDescriptor(Node.prototype,`isConnected`)?.get?.call(e)}function xp(e){return Object.getOwnPropertyDescriptor(Element.prototype,`shadowRoot`)?.get?.call(e)}function Sp(e){return HTMLFormElement.prototype.checkValidity.call(e)}function Cp(e,t){HTMLFormElement.prototype.requestSubmit.call(e,t)}function wp(e){return[..._p(e)].filter(e=>gp(e)&&!e.matches(`:disabled`)&&!(`readOnly`in e&&e.readOnly&&(e instanceof HTMLTextAreaElement||hp.has(e.type))))}function Tp(e){let t=new Map;for(let n of wp(e)){let e=n.name.trim(),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Ep(e){return[...e.labels??[]].map(e=>{let t=e.cloneNode(!0);return t instanceof HTMLElement?(t.querySelectorAll(`button, input, meter, output, progress, select, textarea`).forEach(e=>e.remove()),t.textContent?.trim()??``):``}).filter(Boolean).join(`; `)}function Dp(e,t){for(let n=t[0]?.parentElement;n&&n!==e;n=n.parentElement)if(n instanceof HTMLFieldSetElement&&t.every(e=>n.contains(e)))return n}function Op(e,t){if(t.length===1){let e=t[0];return e&&(e.getAttribute(`toolparamdescription`)||Ep(e)||e.getAttribute(`aria-description`))||void 0}return Dp(e,t)?.getAttribute(`toolparamdescription`)||void 0}function kp(e,t,n,r){let i=Op(t,n),a=i&&r?`${i} (${r})`:i||r;return a?{...e,description:a}:e}function Ap(e,t){let n=e.getAttribute(t);if(n===null||n.trim()===``)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function jp(e,t){let n=Number(e.getAttribute(`step`));return Number.isFinite(n)&&n>0?n:t}function Mp(e,t){let n=e/t;return Math.abs(n-Math.round(n))<2**-52*16}function Np(e,t){let n=t.getAttribute(`pattern`);if(n===null)return e;try{new RegExp(n,`v`)}catch{return e}return{...e,pattern:n}}function Pp(e){let t={type:`number`},n=Ap(e,`min`),r=Ap(e,`max`);if(n!==void 0&&(t.minimum=n),r!==void 0&&(t.maximum=r),e.getAttribute(`step`)!==`any`){let r=jp(e,1),i=Number(e.getAttribute(`value`));Mp(n??(Number.isFinite(i)?i:0),r)&&(t.multipleOf=r)}return t}function Fp(e,t){let n=jp(e,60);return n<1?`${t}(:[0-5][0-9](\\.[0-9]{1,3})?)?$`:n<60?`${t}(:[0-5][0-9])?$`:`${t}$`}function Ip(e){return{anyOf:e.map(e=>({type:`string`,const:e.value,title:e.textContent??``})),enum:e.map(e=>e.value)}}function Lp(e){return{anyOf:e.map(e=>{let t=Ep(e),n={type:`string`,const:e.value};return t&&(n.title=t),n}),enum:e.map(e=>e.value)}}function Rp(e,t){return e instanceof HTMLInputElement&&e.type===t}function zp(e){if(mp.has(e.type))return Np({type:`string`},e);switch(e.type){case`hidden`:return e.getAttribute(`toolparamdescription`)?{type:`string`}:void 0;case`number`:return Np(Pp(e),e);case`range`:{let t=Pp(e);return t.minimum??=0,t.maximum??=100,t}case`checkbox`:return{type:`boolean`};case`date`:return{type:`string`,format:`date`};case`month`:return{type:`string`,format:`^[0-9]{4}-(0[1-9]|1[0-2])$`};case`week`:return{type:`string`,format:`^[0-9]{4}-W(0[1-9]|[1-4][0-9]|5[0-3])$`};case`time`:return{type:`string`,format:Fp(e,`^([01][0-9]|2[0-3]):[0-5][0-9]`)};case`datetime-local`:return{type:`string`,format:Fp(e,`^[0-9]{4}-(0[1-9]|1[0-2])-[0-9]{2}T([01][0-9]|2[0-3]):[0-5][0-9]`)};case`color`:return{type:`string`,format:`^#[0-9a-zA-Z]{6}$`};default:return}}function Bp(e,t){let[n]=t;if(!n)return;let r;if(t.every(e=>Rp(e,`radio`)))r={type:`string`,...Lp(t)};else if(t.length>1)t.every(e=>Rp(e,`checkbox`))&&(r={type:`array`,items:{type:`string`,...Lp(t)},uniqueItems:!0});else if(n instanceof HTMLTextAreaElement)r={type:`string`};else if(n instanceof HTMLSelectElement){let e=Ip([...n.options]);r=n.multiple?{type:`array`,items:{type:`string`,...e},uniqueItems:!0}:{type:`string`,...e}}else r=zp(n);let i=n.type===`date`?`Dates MUST be provided in 'YYYY-MM-DD' format.`:void 0;return r&&kp(r,e,t,i)}function Vp(e){let t={},n=[];for(let[r,i]of Tp(e)){if(!r)continue;let a=Bp(e,i);a&&(Object.defineProperty(t,r,{configurable:!0,enumerable:!0,value:a,writable:!0}),i.some(e=>e.required)&&n.push(r))}return{type:`object`,properties:t,required:n}}function Hp(e){return{name:vp(e,`toolname`)??``,title:vp(e,`tooltitle`)??``,description:vp(e,`tooldescription`)??``,inputSchema:Vp(e),autosubmit:yp(e,`toolautosubmit`)}}function Up(e){if(typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return String(e)}function Wp(e){if(typeof e==`boolean`)return e;if(typeof e==`number`&&Number.isInteger(e))return e!==0;if(typeof e==`string`){if(e===`1`||e.toLowerCase()===`true`)return!0;if(e===`0`||e.toLowerCase()===`false`)return!1}}function Gp(e,t){if(!Array.isArray(e))return!1;let n=new Set(t);for(let t of e){let e=Up(t);if(e===void 0||!n.delete(e))return!1}return!0}function Kp(e,t){if(t===``)return e.type!==`number`&&e.type!==`range`;let n=e.ownerDocument.createElement(`input`);return n.type=e.type,n.value=t,n.value!==``}function qp(e,t,n){let[r]=t;if(!r||!Bp(e,t))return!1;let i=Up(n);if(t.every(e=>Rp(e,`radio`)))return t.some(e=>e.value===i);if(t.length>1)return Gp(n,new Set(t.map(e=>e.value)));if(r instanceof HTMLSelectElement){let e=new Set([...r.options].map(e=>e.value));return r.multiple?Gp(n,e):i!==void 0&&e.has(i)}return r instanceof HTMLTextAreaElement?i!==void 0:r.type===`checkbox`?Wp(n)!==void 0:i!==void 0&&Kp(r,i)}function Jp(e){e.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function Yp(e,t){if(e.value===t)return;let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(n,`value`)?.set?.call(e,t),Jp(e)}function Xp(e,t){e.checked!==t&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`checked`)?.set?.call(e,t),Jp(e))}function Zp(e,t){let[n]=e,r=Up(t),i=new Set(Array.isArray(t)?t.map(Up):[]);if(e.every(e=>Rp(e,`radio`))){let t=e.find(e=>e.value===r);t&&Xp(t,!0)}else if(e.length>1)for(let t of e)t instanceof HTMLInputElement&&Xp(t,i.has(t.value));else if(n instanceof HTMLSelectElement){if(n.multiple){let e=!1;for(let t of n.options){let n=i.has(t.value);t.selected!==n&&(t.selected=n,e=!0)}e&&Jp(n)}else r!==void 0&&n.value!==r&&(n.value=r,Jp(n))}else if(n&&Rp(n,`checkbox`)){let e=Wp(t);e!==void 0&&Xp(n,e)}else n&&r!==void 0&&Yp(n,r)}function Qp(e,t){if(Array.isArray(t))throw em();let n=Tp(e),r=[];for(let[i,a]of Object.entries(t)){let t=n.get(i);if(!t||!qp(e,t,a))throw em();r.push({controls:t,value:a})}for(let{controls:e,value:t}of r)Zp(e,t)}function $p(e){return[..._p(e)].find(e=>!e.matches(`:disabled`)&&(e instanceof HTMLButtonElement&&e.type===`submit`||e instanceof HTMLInputElement&&[`image`,`submit`].includes(e.type)))}function em(){return new DOMException(`Tool execution failed`,`UnknownError`)}function tm(e,t){let n=new Event(e);return Object.defineProperty(n,"toolName",{enumerable:!0,value:t}),n}function nm(e,t,n,r,i){let{form:a}=t;return t.cancelPending?.(em()),new Promise((o,s)=>{let c=!1,l=()=>{EventTarget.prototype.removeEventListener.call(a,`invalid`,p,!0),i.removeEventListener(`abort`,m),dp.delete(a),t.cancelPending===d&&delete t.cancelPending},u=e=>{c||(c=!0,l(),e())},d=e=>u(()=>s(e)),f=e=>{t.cancelPending===d&&delete t.cancelPending,e.then(e=>u(()=>o(e??null)),e=>u(()=>s(e)))},p=e=>{e.isTrusted&&queueMicrotask(()=>{Sp(a)||d(em())})},m=()=>{u(()=>{e.dispatchEvent(tm(`toolcancel`,n.name)),s(i.reason)})};if(dp.set(a,{complete(e){setTimeout(()=>{let t=up.get(e);t?f(t):e.defaultPrevented?d(em()):u(()=>o(null))})},direct(){u(()=>o(null))},respond(e){queueMicrotask(()=>{let t=up.get(e);t&&f(t)})}}),t.cancelPending=d,EventTarget.prototype.addEventListener.call(a,`invalid`,p,!0),i.addEventListener(`abort`,m,{once:!0}),!n.autosubmit)r?.focus(),e.dispatchEvent(tm(`toolactivated`,n.name));else try{Cp(a,r),e.dispatchEvent(tm(`toolactivated`,n.name))}catch(e){d(e)}})}function rm(e){let t=SubmitEvent.prototype;if(`agentInvoked`in t&&`respondWith`in t)return;`agentInvoked`in t||Object.defineProperty(t,"agentInvoked",{configurable:!0,enumerable:!0,get(){return fp(this)}}),`respondWith`in t||Object.defineProperty(t,"respondWith",{configurable:!0,enumerable:!0,writable:!0,value(e){pp(this,e)}});let n=new Map,r=new Map,i=new Map,a=e=>{if(!(e instanceof SubmitEvent)||!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=dp.get(e.target);t&&(lp.add(e),t.complete(e))},o=e=>{if(!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=e.target;setTimeout(()=>{e.defaultPrevented||n.get(t)?.cancelPending?.(em())})};function s(e){i.get(e)?.disconnect(),i.delete(e),e.removeEventListener(`reset`,o,!0),e.removeEventListener(`submit`,a,!0)}function c(e){if(i.has(e))return;let t=new MutationObserver(l);i.set(e,t),t.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),e.addEventListener(`reset`,o,!0),e.addEventListener(`submit`,a,!0)}function l(){c(document);for(let e of i.keys())e instanceof ShadowRoot&&!e.host.isConnected&&s(e);let t=new Set,a=new Map,o=new Map;for(let e of i.keys())for(let i of e.querySelectorAll(`*`)){let e=xp(i);if(e&&c(e),!(i instanceof HTMLFormElement)||!yp(i,`toolname`)||!yp(i,`tooldescription`)||!bp(i))continue;let s=i;t.add(s);let l=Hp(s),u=JSON.stringify(l);if(r.get(s)===u)continue;r.delete(s);let d=o.get(l.name);if(d){let e=e=>n.get(e)?.name===l.name;if(!e(s)||e(d)){r.set(s,u);continue}let t=a.get(d);t&&r.set(d,t.fingerprint),a.delete(d)}o.set(l.name,s),a.set(s,{definition:l,fingerprint:u})}for(let e of r.keys())t.has(e)||r.delete(e);for(let[e,t]of n)a.get(e)?.fingerprint!==t.fingerprint&&(t.cancelPending?.(em()),t.controller.abort(),n.delete(e));for(let[t,{definition:r,fingerprint:i}]of a){if(n.has(t))continue;let a=new AbortController,o={controller:a,fingerprint:i,form:t,name:r.name};n.set(t,o),e.registerTool({name:r.name,title:r.title,description:r.description,inputSchema:r.inputSchema,execute(n,i){let a=$p(t);if(!r.autosubmit&&!a)throw em();return Qp(t,n),nm(e,o,r,a,i.signal)}},{signal:a.signal}).catch(e=>{a.abort(),e instanceof DOMException&&e.name===`AbortError`||console.error(`[webmcp] declarative form tool "${r.name}" was not registered:`,e)})}}let u=Object.getOwnPropertyDescriptor(Element.prototype,`attachShadow`);if(u?.configurable){let e=Element.prototype.attachShadow,t=function(t){let n=e.call(this,t);return n.mode===`open`&&Object.getOwnPropertyDescriptor(Node.prototype,`ownerDocument`)?.get?.call(this)===document&&bp(this)&&c(n),n};Object.defineProperty(Element.prototype,"attachShadow",{...u,value:t})}let d=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`submit`);if(d?.configurable){let e=HTMLFormElement.prototype.submit,t=function(){e.call(this),dp.get(this)?.direct()};Object.defineProperty(HTMLFormElement.prototype,"submit",{...d,value:t})}l()}function im(){if(typeof document>`u`||!globalThis.isSecureContext||typeof Promise.withResolvers!=`function`||typeof AbortSignal.any!=`function`||typeof String.prototype.toWellFormed!=`function`||typeof URL.parse!=`function`)return;Vf();let e=document.modelContext;e&&rm(e)}var am=/^[A-Za-z0-9_.-]{1,128}$/u;function om(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function sm(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function cm(e){if(typeof e==`symbol`)throw TypeError(`Symbol values cannot be converted to a DOMString`);return String(e)}function lm(e){let{name:t,description:n,title:r}=e;if(t===void 0)throw TypeError(`Tool "name" is required`);if(n===void 0)throw TypeError(`Tool "description" is required`);let{annotations:i,inputSchema:a,outputSchema:o,_meta:s,execute:c}=e,l=cm(t),u=r===void 0?void 0:cm(r).toWellFormed(),d={name:l,description:cm(n),execute:c};if(u!==void 0&&(d.title=u),a!==void 0&&(d.inputSchema=a),o!==void 0&&(d.outputSchema=o),s!==void 0){if(!om(s))throw TypeError(`Tool "_meta" must be an object`);d._meta=s}if(i!==void 0){let e=om(i)?i:{},t={readOnlyHint:!!e.readOnlyHint,untrustedContentHint:!!e.untrustedContentHint};e.title!==void 0&&(t.title=cm(e.title).toWellFormed());for(let n of[`destructiveHint`,`idempotentHint`,`openWorldHint`,`consequentialHint`,`debugging`]){let r=e[n];r!==void 0&&(t[n]=!!r)}d.annotations=t}return dm(d),d}function um(e){return new DOMException(e,`InvalidStateError`)}function dm(e){if(e.name===``)throw um(`Tool "name" must be a non-empty string`);if(!am.test(e.name))throw um(`Tool "name" must be 1–128 characters and contain only ASCII alphanumeric, underscore, hyphen, or period`);if(e.description.length===0)throw um(`Tool "description" must be a non-empty string`);if(typeof e.execute!=`function`)throw TypeError(`Tool "execute" must be a function`)}function fm(e){if(!sm(e))throw TypeError(`inputSchema must be an object`);let t=JSON.stringify(e);if(t===void 0)throw TypeError(`inputSchema must be JSON-serializable`);return t}var pm={type:`object`,properties:{}},mm=[`draft-2020-12`,`draft-07`];function hm(e){if(!om(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function gm(e,t=new WeakSet){if(e===null||typeof e==`string`||typeof e==`boolean`)return!0;if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`object`||t.has(e))return!1;t.add(e);try{return(Array.isArray(e)?e:hm(e)?Object.values(e):null)?.every(e=>gm(e,t))??!1}catch{return!1}finally{t.delete(e)}}function _m(e){if(!om(e))return!1;switch(e.type){case`text`:return typeof e.text==`string`;case`image`:case`audio`:return typeof e.data==`string`&&typeof e.mimeType==`string`;case`resource_link`:return typeof e.uri==`string`&&typeof e.name==`string`;case`resource`:{let t=e.resource;return om(t)&&typeof t.uri==`string`&&(typeof t.text==`string`||typeof t.blob==`string`)}default:return!1}}function vm(e){return om(e)&&gm(e)&&Array.isArray(e.content)&&e.content.every(_m)&&(e.isError===void 0||typeof e.isError==`boolean`)&&(e._meta===void 0||om(e._meta))}function ym(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function bm(e){if(vm(e))return e;let t={content:[{type:`text`,text:ym(e)}],isError:!1};return gm(e)&&(t.structuredContent=e),t}function xm(e){if(!om(e))return null;let t=e[`~standard`];return om(t)?t:null}function Sm(e){let t=xm(e);return!!(t&&t.version===1&&typeof t.validate==`function`)}function Cm(e){let t=xm(e);return!t||t.version!==1||!om(t.jsonSchema)?!1:typeof t.jsonSchema.input==`function`}function wm(e){let t=xm(e);return!!(t&&t.version===1&&typeof t.vendor==`string`&&typeof t.validate==`function`&&om(t.jsonSchema)&&typeof t.jsonSchema.input==`function`&&typeof t.jsonSchema.output==`function`)}function Tm(e){for(let t of mm)try{let n=e[`~standard`].jsonSchema.input({target:t}),r=JSON.parse(fm(n));if(om(r))return r}catch{}throw Error(`Failed to convert Standard JSON Schema inputSchema to a JSON Schema object`)}function Em(e){if(e===void 0)return{inputSchema:pm};if(Cm(e)){let t=Tm(e),n=fm(t);return Sm(e)&&Object.defineProperty(t,"~standard",{value:e[`~standard`]}),{inputSchema:t,registeredInputSchema:n}}if(Sm(e))throw Error(`Standard Schema inputSchema must provide ~standard.jsonSchema.input() for tool metadata`);let t=fm(e),n=JSON.parse(t);return!om(n)||Object.keys(n).length===0?{inputSchema:pm,registeredInputSchema:t}:{inputSchema:n.type===void 0?{type:`object`,...n}:n,registeredInputSchema:t}}var Dm=Object.defineProperty,Om=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),km=(e,t)=>{let n={};for(var r in e)Dm(n,r,{get:e[r],enumerable:!0});return t&&Dm(n,Symbol.toStringTag,{value:`Module`}),n},Am=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),jm=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),Mm=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),Nm=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function Pm(e){return typeof e==`string`&&jm.has(e.replace(/#$/,``))}function Fm(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(Am.has(n))return`2020-12`;if(jm.has(n))return`2019-09`;if(Mm.has(n)||Nm.has(n))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}`)}var Im=Symbol.for(`mcp.sdk.errorBrands`);function Lm(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Im,{value:n,enumerable:!1,configurable:!0})}function Rm(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Im)){let n=t[Im];if(n&&typeof n.has==`function`&&n.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 Rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Rm(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Lm(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)}});var Y=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),X=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Rm(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,Lm(this,new.target)}};(class extends X{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}});function zm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bm(e,t,n){return e===`elicitation`&&t===`form`&&n.form===void 0&&n.url===void 0}function Vm(e){switch(e.method){case`elicitation/create`:return e.params?.mode===`url`?{elicitation:{url:{}}}:{elicitation:{form:{}}};case`sampling/createMessage`:{let t=e.params;return t!==void 0&&(t.tools!==void 0||t.toolChoice!==void 0)?{sampling:{tools:{}}}:{sampling:{}}}case`roots/list`:return{roots:{}};default:return}}function Hm(e,t){let n={};for(let[r,i]of Object.entries(e)){if(i===void 0)continue;let e=t===void 0?void 0:t[r];if(e===void 0)n[r]=i;else if(zm(i)&&zm(e)){let t={};for(let[n,a]of Object.entries(i))a!==void 0&&e[n]===void 0&&!Bm(r,n,e)&&(t[n]=a);Object.keys(t).length>0&&(n[r]=t)}}return Object.keys(n).length>0?n:void 0}var Um=`2026-07-28`,Wm=[Um];function Gm(e){return e>=Um}function Km(e){return e.filter(e=>!Gm(e))}function qm(e){return e.filter(e=>Gm(e))}function Jm(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var Ym=[`task`,`inputRequests`,`requestState`];function Xm(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||Ym.some(t=>t in e)?e:{...e,content:[]}}function Zm(){let e=Fc(()=>V([N(),F(),I(),Qs(),H(N(),e),R(e)])),t=H(N(),e),n=V([N(),F().int()]),r=N(),i=z({ttl:F().optional()}),a=z({taskId:N()}),o=B({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=z({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=z({method:N(),params:s.loose().optional()}),u=z({_meta:o.optional()}),d=z({method:N(),params:u.loose().optional()}),f=B({_meta:o.optional()}),p=V([N(),F().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:N().optional()}),g=d.extend({method:W(`notifications/cancelled`),params:h}),_=z({src:N(),mimeType:N().optional(),sizes:R(N()).optional(),theme:U([`light`,`dark`]).optional()}),ee=z({icons:R(_).optional()}),te=z({name:N(),title:N().optional()}),ne=te.extend({...te.shape,...ee.shape,version:N(),websiteUrl:N().optional(),description:N().optional()}),re=zc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,uc(z({form:uc(z({applyDefaults:I().optional()}),t).optional(),url:t.optional()}),t.optional())),ie=B({list:t.optional(),cancel:t.optional(),requests:B({sampling:B({createMessage:t.optional()}).optional(),elicitation:B({create:t.optional()}).optional()}).optional()}),ae=B({list:t.optional(),cancel:t.optional(),requests:B({tools:B({call:t.optional()}).optional()}).optional()}),oe=z({experimental:H(N(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:re.optional(),roots:z({listChanged:I().optional()}).optional(),tasks:ie.optional(),extensions:H(N(),t).optional()}),se=s.extend({protocolVersion:N(),capabilities:oe,clientInfo:ne}),ce=l.extend({method:W(`initialize`),params:se}),le=z({experimental:H(N(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:I().optional()}).optional(),resources:z({subscribe:I().optional(),listChanged:I().optional()}).optional(),tools:z({listChanged:I().optional()}).optional(),tasks:ae.optional(),extensions:H(N(),t).optional()}),v=f.extend({protocolVersion:N(),capabilities:le,serverInfo:ne,instructions:N().optional()}),ue=d.extend({method:W(`notifications/initialized`),params:u.optional()}),de=l.extend({method:W(`ping`),params:s.optional()}),fe=z({progress:F(),total:G(F()),message:G(N())}),pe=z({...u.shape,...fe.shape,progressToken:n}),me=d.extend({method:W(`notifications/progress`),params:pe}),he=s.extend({cursor:r.optional()}),ge=l.extend({params:he.optional()}),_e=f.extend({nextCursor:r.optional()}),ve=z({uri:N(),mimeType:G(N()),_meta:H(N(),L()).optional()}),ye=ve.extend({text:N()}),be=N().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),xe=ve.extend({blob:be}),y=U([`user`,`assistant`]),b=z({audience:R(y).optional(),priority:F().min(0).max(1).optional(),lastModified:Hc({offset:!0}).optional()}),Se=z({...te.shape,...ee.shape,uri:N(),description:G(N()),mimeType:G(N()),size:G(F()),annotations:b.optional(),_meta:G(B({}))}),Ce=z({...te.shape,...ee.shape,uriTemplate:N(),description:G(N()),mimeType:G(N()),annotations:b.optional(),_meta:G(B({}))}),we=ge.extend({method:W(`resources/list`)}),Te=_e.extend({resources:R(Se)}),x=ge.extend({method:W(`resources/templates/list`)}),S=_e.extend({resourceTemplates:R(Ce)}),Ee=s.extend({uri:N()}),De=Ee,Oe=l.extend({method:W(`resources/read`),params:De}),ke=f.extend({contents:R(V([ye,xe]))}),Ae=d.extend({method:W(`notifications/resources/list_changed`),params:u.optional()}),je=Ee,Me=l.extend({method:W(`resources/subscribe`),params:je}),C=Ee,Ne=l.extend({method:W(`resources/unsubscribe`),params:C}),Pe=u.extend({uri:N()}),Fe=d.extend({method:W(`notifications/resources/updated`),params:Pe}),Ie=z({name:N(),description:G(N()),required:G(I())}),Le=z({...te.shape,...ee.shape,description:G(N()),arguments:G(R(Ie)),_meta:G(B({}))}),Re=ge.extend({method:W(`prompts/list`)}),w=_e.extend({prompts:R(Le)}),ze=s.extend({name:N(),arguments:H(N(),N()).optional()}),Be=l.extend({method:W(`prompts/get`),params:ze}),Ve=z({type:W(`text`),text:N(),annotations:b.optional(),_meta:H(N(),L()).optional()}),He=z({type:W(`image`),data:be,mimeType:N(),annotations:b.optional(),_meta:H(N(),L()).optional()}),Ue=z({type:W(`audio`),data:be,mimeType:N(),annotations:b.optional(),_meta:H(N(),L()).optional()}),We=z({type:W(`tool_use`),name:N(),id:N(),input:H(N(),L()),_meta:H(N(),L()).optional()}),Ge=z({type:W(`resource`),resource:V([ye,xe]),annotations:b.optional(),_meta:H(N(),L()).optional()}),Ke=Se.extend({type:W(`resource_link`)}),T=V([Ve,He,Ue,Ke,Ge]),qe=z({role:y,content:T}),Je=f.extend({description:N().optional(),messages:R(qe)}),E=d.extend({method:W(`notifications/prompts/list_changed`),params:u.optional()}),Ye=z({title:N().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),Xe=z({taskSupport:U([`required`,`optional`,`forbidden`]).optional()}),Ze=z({...te.shape,...ee.shape,description:N().optional(),inputSchema:z({type:W(`object`),properties:H(N(),e).optional(),required:R(N()).optional()}).catchall(L()),outputSchema:z({type:W(`object`),properties:H(N(),e).optional(),required:R(N()).optional()}).catchall(L()).optional(),annotations:Ye.optional(),execution:Xe.optional(),_meta:H(N(),L()).optional()}),Qe=ge.extend({method:W(`tools/list`)}),$e=_e.extend({tools:R(Ze)}),et=f.extend({content:R(T),structuredContent:H(N(),L()).optional(),isError:I().optional()}),tt=c.extend({name:N(),arguments:H(N(),L()).optional()}),nt=l.extend({method:W(`tools/call`),params:tt}),rt=d.extend({method:W(`notifications/tools/list_changed`),params:u.optional()}),it=U([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),at=s.extend({level:it}),ot=l.extend({method:W(`logging/setLevel`),params:at}),st=u.extend({level:it,logger:N().optional(),data:L()}),ct=d.extend({method:W(`notifications/message`),params:st}),lt=z({name:N().optional()}),ut=z({hints:R(lt).optional(),costPriority:F().min(0).max(1).optional(),speedPriority:F().min(0).max(1).optional(),intelligencePriority:F().min(0).max(1).optional()}),dt=z({mode:U([`auto`,`required`,`none`]).optional()}),ft=z({type:W(`tool_result`),toolUseId:N().describe(`The unique identifier for the corresponding tool call.`),content:R(T),structuredContent:z({}).loose().optional(),isError:I().optional(),_meta:H(N(),L()).optional()}),pt=cc(`type`,[Ve,He,Ue]),mt=cc(`type`,[Ve,He,Ue,We,ft]),ht=z({role:y,content:V([mt,R(mt)]),_meta:H(N(),L()).optional()}),gt=c.extend({messages:R(ht),modelPreferences:ut.optional(),systemPrompt:N().optional(),includeContext:U([`none`,`thisServer`,`allServers`]).optional(),temperature:F().optional(),maxTokens:F().int(),stopSequences:R(N()).optional(),metadata:t.optional(),tools:R(Ze).optional(),toolChoice:dt.optional()}),_t=l.extend({method:W(`sampling/createMessage`),params:gt}),vt=f.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`]).or(N())),role:y,content:pt}),yt=f.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(N())),role:y,content:V([mt,R(mt)])}),bt=z({type:W(`boolean`),title:N().optional(),description:N().optional(),default:I().optional()}),xt=z({type:W(`string`),title:N().optional(),description:N().optional(),minLength:F().optional(),maxLength:F().optional(),format:U([`email`,`uri`,`date`,`date-time`]).optional(),default:N().optional()}),St=z({type:U([`number`,`integer`]),title:N().optional(),description:N().optional(),minimum:F().optional(),maximum:F().optional(),default:F().optional()}),Ct=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),default:N().optional()}),wt=z({type:W(`string`),title:N().optional(),description:N().optional(),oneOf:R(z({const:N(),title:N()})),default:N().optional()}),Tt=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),enumNames:R(N()).optional(),default:N().optional()}),Et=V([Ct,wt]),Dt=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({type:W(`string`),enum:R(N())}),default:R(N()).optional()}),Ot=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({anyOf:R(z({const:N(),title:N()}))}),default:R(N()).optional()}),kt=V([Dt,Ot]),At=V([Tt,Et,kt]),jt=V([At,bt,xt,St]),Mt=c.extend({mode:W(`form`).optional(),message:N(),requestedSchema:z({type:W(`object`),properties:H(N(),jt),required:R(N()).optional()}).catchall(L())}),Nt=c.extend({mode:W(`url`),message:N(),elicitationId:N(),url:N().url()}),Pt=V([Mt,Nt]),Ft=l.extend({method:W(`elicitation/create`),params:Pt}),It=u.extend({elicitationId:N()}),Lt=d.extend({method:W(`notifications/elicitation/complete`),params:It}),Rt=f.extend({action:U([`accept`,`decline`,`cancel`]),content:zc(e=>e===null?void 0:e,H(N(),V([N(),F(),I(),R(N())])).optional())}),zt=z({type:W(`ref/resource`),uri:N()}),Bt=z({type:W(`ref/prompt`),name:N()}),Vt=s.extend({ref:V([Bt,zt]),argument:z({name:N(),value:N()}),context:z({arguments:H(N(),N()).optional()}).optional()}),Ht=l.extend({method:W(`completion/complete`),params:Vt}),Ut=f.extend({completion:B({values:R(N()).max(100),total:G(F().int()),hasMore:G(I())})}),Wt=z({uri:N().startsWith(`file://`),name:N().optional(),_meta:H(N(),L()).optional()}),Gt=l.extend({method:W(`roots/list`),params:s.optional()}),Kt=f.extend({roots:R(Wt)}),qt=d.extend({method:W(`notifications/roots/list_changed`),params:u.optional()}),Jt=B({ttl:F().optional(),pollInterval:F().optional()}),Yt=U([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Xt=z({taskId:N(),status:Yt,ttl:V([F(),Qs()]),createdAt:N(),lastUpdatedAt:N(),pollInterval:G(F()),statusMessage:G(N())}),Zt=f.extend({task:Xt}),Qt=u.merge(Xt),$t=d.extend({method:W(`notifications/tasks/status`),params:Qt}),en=l.extend({method:W(`tasks/get`),params:s.extend({taskId:N()})}),tn=f.merge(Xt),nn=l.extend({method:W(`tasks/result`),params:s.extend({taskId:N()})}),rn=f.loose(),D=ge.extend({method:W(`tasks/list`)}),an=_e.extend({tasks:R(Xt)}),on=l.extend({method:W(`tasks/cancel`),params:s.extend({taskId:N()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:m,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:_,IconsSchema:ee,BaseMetadataSchema:te,ImplementationSchema:ne,ClientTasksCapabilitySchema:ie,ServerTasksCapabilitySchema:ae,ClientCapabilitiesSchema:oe,InitializeRequestParamsSchema:se,InitializeRequestSchema:ce,ServerCapabilitiesSchema:le,InitializeResultSchema:v,InitializedNotificationSchema:ue,PingRequestSchema:de,ProgressSchema:fe,ProgressNotificationParamsSchema:pe,ProgressNotificationSchema:me,PaginatedRequestParamsSchema:he,PaginatedRequestSchema:ge,PaginatedResultSchema:_e,ResourceContentsSchema:ve,TextResourceContentsSchema:ye,BlobResourceContentsSchema:xe,RoleSchema:y,AnnotationsSchema:b,ResourceSchema:Se,ResourceTemplateSchema:Ce,ListResourcesRequestSchema:we,ListResourcesResultSchema:Te,ListResourceTemplatesRequestSchema:x,ListResourceTemplatesResultSchema:S,ResourceRequestParamsSchema:Ee,ReadResourceRequestParamsSchema:De,ReadResourceRequestSchema:Oe,ReadResourceResultSchema:ke,ResourceListChangedNotificationSchema:Ae,SubscribeRequestParamsSchema:je,SubscribeRequestSchema:Me,UnsubscribeRequestParamsSchema:C,UnsubscribeRequestSchema:Ne,ResourceUpdatedNotificationParamsSchema:Pe,ResourceUpdatedNotificationSchema:Fe,PromptArgumentSchema:Ie,PromptSchema:Le,ListPromptsRequestSchema:Re,ListPromptsResultSchema:w,GetPromptRequestParamsSchema:ze,GetPromptRequestSchema:Be,TextContentSchema:Ve,ImageContentSchema:He,AudioContentSchema:Ue,ToolUseContentSchema:We,EmbeddedResourceSchema:Ge,ResourceLinkSchema:Ke,ContentBlockSchema:T,PromptMessageSchema:qe,GetPromptResultSchema:Je,PromptListChangedNotificationSchema:E,ToolAnnotationsSchema:Ye,ToolExecutionSchema:Xe,ToolSchema:Ze,ListToolsRequestSchema:Qe,ListToolsResultSchema:$e,CallToolResultSchema:et,CallToolRequestParamsSchema:tt,CallToolRequestSchema:nt,ToolListChangedNotificationSchema:rt,LoggingLevelSchema:it,SetLevelRequestParamsSchema:at,SetLevelRequestSchema:ot,LoggingMessageNotificationParamsSchema:st,LoggingMessageNotificationSchema:ct,ModelHintSchema:lt,ModelPreferencesSchema:ut,ToolChoiceSchema:dt,ToolResultContentSchema:ft,SamplingContentSchema:pt,SamplingMessageContentBlockSchema:mt,SamplingMessageSchema:ht,CreateMessageRequestParamsSchema:gt,CreateMessageRequestSchema:_t,CreateMessageResultSchema:vt,CreateMessageResultWithToolsSchema:yt,BooleanSchemaSchema:bt,StringSchemaSchema:xt,NumberSchemaSchema:St,UntitledSingleSelectEnumSchemaSchema:Ct,TitledSingleSelectEnumSchemaSchema:wt,LegacyTitledEnumSchemaSchema:Tt,SingleSelectEnumSchemaSchema:Et,UntitledMultiSelectEnumSchemaSchema:Dt,TitledMultiSelectEnumSchemaSchema:Ot,MultiSelectEnumSchemaSchema:kt,EnumSchemaSchema:At,PrimitiveSchemaDefinitionSchema:jt,ElicitRequestFormParamsSchema:Mt,ElicitRequestURLParamsSchema:Nt,ElicitRequestParamsSchema:Pt,ElicitRequestSchema:Ft,ElicitationCompleteNotificationParamsSchema:It,ElicitationCompleteNotificationSchema:Lt,ElicitResultSchema:Rt,ResourceTemplateReferenceSchema:zt,PromptReferenceSchema:Bt,CompleteRequestParamsSchema:Vt,CompleteRequestSchema:Ht,CompleteResultSchema:Ut,RootSchema:Wt,ListRootsRequestSchema:Gt,ListRootsResultSchema:Kt,RootsListChangedNotificationSchema:qt,TaskCreationParamsSchema:Jt,TaskStatusSchema:Yt,TaskSchema:Xt,CreateTaskResultSchema:Zt,TaskStatusNotificationParamsSchema:Qt,TaskStatusNotificationSchema:$t,GetTaskRequestSchema:en,GetTaskResultSchema:tn,GetTaskPayloadRequestSchema:nn,GetTaskPayloadResultSchema:rn,ListTasksRequestSchema:D,ListTasksResultSchema:an,CancelTaskRequestSchema:on,CancelTaskResultSchema:f.merge(Xt),ClientRequestSchema:V([de,ce,Ht,ot,Be,Re,we,x,Oe,Me,Ne,nt,Qe,en,nn,D,on]),ClientNotificationSchema:V([g,me,ue,qt,$t]),ClientResultSchema:V([m,vt,yt,Rt,Kt,tn,an,Zt]),ServerRequestSchema:V([de,_t,Ft,Gt,en,nn,D,on]),ServerNotificationSchema:V([g,me,ct,Fe,Ae,rt,E,$t,Lt]),ServerResultSchema:V([m,v,Ut,Je,w,Te,S,ke,et,$e,tn,an,Zt]),CallToolResultWireSchema:L().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of Ym)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(Xm).pipe(et)}}var Qm;function $m(){return Qm??=Zm()}function eh(e){return e.type!==`object`}var th=new Set([`const`,`enum`,`default`,`examples`]),nh=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function rh(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function ih(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(rh(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=Pm(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&rh(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=th.has(o)?s:nh.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var ah={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},oh={"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},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,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},ch;function lh(){if(ch)return ch;let e=$m();return ch={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}},ch}function uh(e){return Object.prototype.hasOwnProperty.call(ah,e)}function dh(e){return Object.prototype.hasOwnProperty.call(oh,e)}function fh(e){return Object.prototype.hasOwnProperty.call(sh,e)}function ph(e){return fh(e)?lh().resultSchemas[e]:void 0}function mh(e){return uh(e)?lh().requestSchemas[e]:void 0}function hh(e){return dh(e)?lh().notificationSchemas[e]:void 0}Object.keys(ah),Object.keys(oh);function gh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _h(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var vh={ok:!1,reason:`not-in-era`};function yh(e){return gh(e)&&gh(e.outputSchema)&&eh(e.outputSchema)}function bh(e){return e}var xh={era:`2025-11-25`,hasRequestMethod:uh,hasNotificationMethod:dh,validateRequest:(e,t)=>_h(mh(e),t),validateResult:(e,t)=>_h(ph(e),t),validateNotification:(e,t)=>_h(hh(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>vh,validateInputResponse:()=>vh,samplingResultVariant:((e,t)=>{let n=$m();return _h(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=Jm(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&eh(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(gh(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:bh(e)}}return{kind:`complete`,result:bh(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>yh(e))?t:{...t,tools:n.map(e=>yh(e)?{...e,outputSchema:ih(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function Sh(){let e=Fc(()=>V([N(),F(),I(),Qs(),H(N(),e),R(e)])),t=H(N(),e),n=V([N(),F().int()]),r=N(),i=V([N(),F().int()]),a=U([`user`,`assistant`]),o=U([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=N().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=z({ttl:F().optional()}),l=z({taskId:N()}),u=B({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=z({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=z({_meta:u.optional()}),m=z({method:N(),params:p.loose().optional()}),h=z({src:N(),mimeType:N().optional(),sizes:R(N()).optional(),theme:U([`light`,`dark`]).optional()}),g=z({icons:R(h).optional()}),_=z({name:N(),title:N().optional()}),ee=_.extend({..._.shape,...g.shape,version:N(),websiteUrl:N().optional(),description:N().optional()}),te=zc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,uc(z({form:uc(z({applyDefaults:I().optional()}),t).optional(),url:t.optional()}),t.optional())),ne=B({list:t.optional(),cancel:t.optional(),requests:B({sampling:B({createMessage:t.optional()}).optional(),elicitation:B({create:t.optional()}).optional()}).optional()}),re=B({list:t.optional(),cancel:t.optional(),requests:B({tools:B({call:t.optional()}).optional()}).optional()}),ie=z({experimental:H(N(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:te.optional(),roots:z({listChanged:I().optional()}).optional(),tasks:ne.optional(),extensions:H(N(),t).optional()}),ae=z({experimental:H(N(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:I().optional()}).optional(),resources:z({subscribe:I().optional(),listChanged:I().optional()}).optional(),tools:z({listChanged:I().optional()}).optional(),tasks:re.optional(),extensions:H(N(),t).optional()}),oe=z({progress:F(),total:G(F()),message:G(N())}),se=z({...p.shape,...oe.shape,progressToken:n}),ce=m.extend({method:W(`notifications/progress`),params:se}),le=p.extend({level:o,logger:N().optional(),data:L()}),v=m.extend({method:W(`notifications/message`),params:le}),ue=z({uri:N(),mimeType:G(N()),_meta:H(N(),L()).optional()}),de=ue.extend({text:N()}),fe=ue.extend({blob:s}),pe=z({audience:R(a).optional(),priority:F().min(0).max(1).optional(),lastModified:Hc({offset:!0}).optional()}),me=z({..._.shape,...g.shape,uri:N(),description:G(N()),mimeType:G(N()),size:G(F()),annotations:pe.optional(),_meta:G(B({}))}),he=z({..._.shape,...g.shape,uriTemplate:N(),description:G(N()),mimeType:G(N()),annotations:pe.optional(),_meta:G(B({}))}),ge=m.extend({method:W(`notifications/resources/list_changed`),params:p.optional()}),_e=p.extend({uri:N()}),ve=m.extend({method:W(`notifications/resources/updated`),params:_e}),ye=z({name:N(),description:G(N()),required:G(I())}),be=z({..._.shape,...g.shape,description:G(N()),arguments:G(R(ye)),_meta:G(B({}))}),xe=m.extend({method:W(`notifications/prompts/list_changed`),params:p.optional()}),y=z({type:W(`text`),text:N(),annotations:pe.optional(),_meta:H(N(),L()).optional()}),b=z({type:W(`image`),data:s,mimeType:N(),annotations:pe.optional(),_meta:H(N(),L()).optional()}),Se=z({type:W(`audio`),data:s,mimeType:N(),annotations:pe.optional(),_meta:H(N(),L()).optional()}),Ce=z({type:W(`tool_use`),name:N(),id:N(),input:H(N(),L()),_meta:H(N(),L()).optional()}),we=z({type:W(`resource`),resource:V([de,fe]),annotations:pe.optional(),_meta:H(N(),L()).optional()}),Te=me.extend({type:W(`resource_link`)}),x=V([y,b,Se,Te,we]),S=z({role:a,content:x}),Ee=z({title:N().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),De=m.extend({method:W(`notifications/tools/list_changed`),params:p.optional()}),Oe=z({name:N().optional()}),ke=z({hints:R(Oe).optional(),costPriority:F().min(0).max(1).optional(),speedPriority:F().min(0).max(1).optional(),intelligencePriority:F().min(0).max(1).optional()}),Ae=z({mode:U([`auto`,`required`,`none`]).optional()}),je=z({type:W(`boolean`),title:N().optional(),description:N().optional(),default:I().optional()}),Me=z({type:W(`string`),title:N().optional(),description:N().optional(),minLength:F().optional(),maxLength:F().optional(),format:U([`email`,`uri`,`date`,`date-time`]).optional(),default:N().optional()}),C=z({type:U([`number`,`integer`]),title:N().optional(),description:N().optional(),minimum:F().optional(),maximum:F().optional(),default:F().optional()}),Ne=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),default:N().optional()}),Pe=z({type:W(`string`),title:N().optional(),description:N().optional(),oneOf:R(z({const:N(),title:N()})),default:N().optional()}),Fe=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),enumNames:R(N()).optional(),default:N().optional()}),Ie=V([Ne,Pe]),Le=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({type:W(`string`),enum:R(N())}),default:R(N()).optional()}),Re=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({anyOf:R(z({const:N(),title:N()}))}),default:R(N()).optional()}),w=V([Le,Re]),ze=V([Fe,Ie,w]),Be=V([ze,je,Me,C]),Ve=f.extend({mode:W(`form`).optional(),message:N(),requestedSchema:z({type:W(`object`),properties:H(N(),Be),required:R(N()).optional()}).catchall(L())}),He=z({type:W(`ref/resource`),uri:N()}),Ue=z({type:W(`ref/prompt`),name:N()}),We=z({uri:N().startsWith(`file://`),name:N().optional(),_meta:H(N(),L()).optional()}),Ge=ie.shape,Ke=z({experimental:Ge.experimental,sampling:Ge.sampling,elicitation:Ge.elicitation,roots:Ge.roots,extensions:Ge.extensions}),T=ae.shape,qe=z({experimental:T.experimental,logging:T.logging,completions:T.completions,prompts:T.prompts,resources:T.resources,tools:T.tools,extensions:T.extensions}),Je=B({progressToken:n.optional(),[qc]:N(),[Jc]:ee.optional(),[Xc]:Ke,[Qc]:o.optional()}),E=z({..._.shape,...g.shape,description:N().optional(),inputSchema:B({$schema:N().optional(),type:W(`object`)}),outputSchema:B({$schema:N().optional()}).optional(),annotations:Ee.optional(),_meta:H(N(),L()).optional()}),Ye=z({type:W(`tool_result`),toolUseId:N(),content:R(x),structuredContent:L().optional(),isError:I().optional(),_meta:H(N(),L()).optional()}),Xe=V([y,b,Se,Ce,Ye]),Ze=z({role:a,content:V([Xe,R(Xe)]),_meta:H(N(),L()).optional()}),Qe=N(),$e=B({[Yc]:ee.optional().catch(void 0)}),et=$e.optional();function tt(e){return B({_meta:et,resultType:Qe.default(`complete`),...e})}let nt=tt({}),rt=tt({nextCursor:r.optional()}),it=tt({content:R(x),structuredContent:L().optional(),isError:I().optional()}),at=tt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),tools:R(E),nextCursor:r.optional()}),ot=tt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),prompts:R(be),nextCursor:r.optional()}),st=tt({description:N().optional(),messages:R(S)}),ct=tt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resources:R(me),nextCursor:r.optional()}),lt=tt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resourceTemplates:R(he),nextCursor:r.optional()}),ut=tt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),contents:R(V([de,fe]))}),dt=tt({completion:z({values:R(N()).max(100),total:F().int().optional(),hasMore:I().optional()}).loose()}),ft=tt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`])}),pt=tt({ttlMs:F().int().min(0).catch(0),cacheScope:U([`public`,`private`]).catch(`private`),supportedVersions:R(N()),capabilities:qe,instructions:N().optional()}),mt=z({messages:R(Ze),modelPreferences:ke.optional(),systemPrompt:N().optional(),includeContext:U([`none`,`thisServer`,`allServers`]).optional(),temperature:F().optional(),maxTokens:F().int(),stopSequences:R(N()).optional(),metadata:t.optional(),tools:R(E).optional(),toolChoice:Ae.optional()}),ht=z({method:W(`sampling/createMessage`),params:mt}),gt=z({method:W(`roots/list`),params:z({_meta:H(N(),L()).optional()}).optional()}),_t=z({...Ze.shape,model:N(),stopReason:N().optional()}),vt=z({roots:R(We)}),yt=z({action:U([`accept`,`decline`,`cancel`]),content:H(N(),V([N(),F(),I(),R(N())])).optional()}),bt=z({mode:W(`url`),message:N(),url:N().url()}),xt=V([Ve,bt]),St=z({method:W(`elicitation/create`),params:xt}),Ct=V([ht,gt,St]),wt=V([_t,vt,yt]),Tt=H(N(),Ct),Et=H(N(),wt),Dt=tt({inputRequests:Tt.optional(),requestState:N().optional()}),Ot={inputResponses:Et.optional(),requestState:N().optional()},kt=z({_meta:Je,...Ot}),At=B({progressToken:n.optional()});function jt(e,t){return z({method:W(e),params:z({_meta:Je,...t})})}function Mt(e,t){return z({method:W(e),params:z({_meta:At.optional(),...t}).optional()})}let Nt={name:N(),arguments:H(N(),L()).optional(),...Ot},Pt={cursor:r.optional()},Ft=jt(`tools/call`,Nt),It=jt(`tools/list`,Pt),Lt=jt(`prompts/list`,Pt),Rt=jt(`prompts/get`,{name:N(),arguments:H(N(),N()).optional(),...Ot}),zt=jt(`resources/list`,Pt),Bt=jt(`resources/templates/list`,Pt),Vt=jt(`resources/read`,{uri:N(),...Ot}),Ht={ref:V([Ue,He]),argument:z({name:N(),value:N()}),context:z({arguments:H(N(),N()).optional()}).optional()},Ut=jt(`completion/complete`,Ht),Wt=jt(`server/discover`,{}),Gt=z({toolsListChanged:I().optional(),promptsListChanged:I().optional(),resourcesListChanged:I().optional(),resourceSubscriptions:R(N()).optional()}),Kt={notifications:Gt},qt=jt(`subscriptions/listen`,Kt),Jt=$e.extend({"io.modelcontextprotocol/subscriptionId":i}),Yt=B({_meta:Jt,resultType:Qe.default(`complete`)}),Xt={"tools/call":Mt(`tools/call`,Nt),"tools/list":Mt(`tools/list`,Pt),"prompts/get":Mt(`prompts/get`,{name:N(),arguments:H(N(),N()).optional()}),"prompts/list":Mt(`prompts/list`,Pt),"resources/list":Mt(`resources/list`,Pt),"resources/templates/list":Mt(`resources/templates/list`,Pt),"resources/read":Mt(`resources/read`,{uri:N()}),"completion/complete":Mt(`completion/complete`,Ht),"server/discover":Mt(`server/discover`,{}),"subscriptions/listen":Mt(`subscriptions/listen`,Kt)};function Zt(e){return B({_meta:et,...e})}let Qt={"tools/call":Zt({content:R(x),structuredContent:L().optional(),isError:I().optional()}),"tools/list":Zt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),tools:R(E),nextCursor:r.optional()}),"prompts/get":Zt({description:N().optional(),messages:R(S)}),"prompts/list":Zt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),prompts:R(be),nextCursor:r.optional()}),"resources/list":Zt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resources:R(me),nextCursor:r.optional()}),"resources/templates/list":Zt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resourceTemplates:R(he),nextCursor:r.optional()}),"resources/read":Zt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),contents:R(V([de,fe]))}),"completion/complete":Zt({completion:z({values:R(N()).max(100),total:F().int().optional(),hasMore:I().optional()}).loose()}),"server/discover":Zt({ttlMs:F().int().min(0).catch(0),cacheScope:U([`public`,`private`]).catch(`private`),supportedVersions:R(N()),capabilities:qe,instructions:N().optional()}),"subscriptions/listen":Zt({})},$t=B({"io.modelcontextprotocol/subscriptionId":i.optional()}),en=z({method:W(`notifications/subscriptions/acknowledged`),params:z({_meta:$t.optional(),notifications:Gt})}),tn=z({_meta:$t.optional(),requestId:i,reason:N().optional()}),nn=z({method:W(`notifications/cancelled`),params:tn}),rn={"notifications/cancelled":nn,"notifications/progress":ce,"notifications/message":v,"notifications/resources/updated":ve,"notifications/resources/list_changed":ge,"notifications/tools/list_changed":De,"notifications/prompts/list_changed":xe,"notifications/subscriptions/acknowledged":en},D=e=>z({jsonrpc:W(`2.0`),id:V([N(),F().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:p,NotificationSchema:m,IconSchema:h,IconsSchema:g,BaseMetadataSchema:_,ImplementationSchema:ee,ClientTasksCapabilitySchema:ne,ServerTasksCapabilitySchema:re,ClientCapabilitiesSchema:ie,ServerCapabilitiesSchema:ae,ProgressSchema:oe,ProgressNotificationParamsSchema:se,ProgressNotificationSchema:ce,LoggingMessageNotificationParamsSchema:le,LoggingMessageNotificationSchema:v,ResourceContentsSchema:ue,TextResourceContentsSchema:de,BlobResourceContentsSchema:fe,AnnotationsSchema:pe,ResourceSchema:me,ResourceTemplateSchema:he,ResourceListChangedNotificationSchema:ge,ResourceUpdatedNotificationParamsSchema:_e,ResourceUpdatedNotificationSchema:ve,PromptArgumentSchema:ye,PromptSchema:be,PromptListChangedNotificationSchema:xe,TextContentSchema:y,ImageContentSchema:b,AudioContentSchema:Se,ToolUseContentSchema:Ce,EmbeddedResourceSchema:we,ResourceLinkSchema:Te,ContentBlockSchema:x,PromptMessageSchema:S,ToolAnnotationsSchema:Ee,ToolListChangedNotificationSchema:De,ModelHintSchema:Oe,ModelPreferencesSchema:ke,ToolChoiceSchema:Ae,BooleanSchemaSchema:je,StringSchemaSchema:Me,NumberSchemaSchema:C,UntitledSingleSelectEnumSchemaSchema:Ne,TitledSingleSelectEnumSchemaSchema:Pe,LegacyTitledEnumSchemaSchema:Fe,SingleSelectEnumSchemaSchema:Ie,UntitledMultiSelectEnumSchemaSchema:Le,TitledMultiSelectEnumSchemaSchema:Re,MultiSelectEnumSchemaSchema:w,EnumSchemaSchema:ze,PrimitiveSchemaDefinitionSchema:Be,ElicitRequestFormParamsSchema:Ve,ResourceTemplateReferenceSchema:He,PromptReferenceSchema:Ue,RootSchema:We,ClientCapabilities2026Schema:Ke,ServerCapabilities2026Schema:qe,RequestMetaEnvelopeSchema:Je,ToolSchema:E,ToolResultContentSchema:Ye,SamplingMessageContentBlockSchema:Xe,SamplingMessageSchema:Ze,ResultTypeSchema:Qe,ResultMetaSchema:$e,ResultSchema:nt,PaginatedResultSchema:rt,CallToolResultSchema:it,ListToolsResultSchema:at,ListPromptsResultSchema:ot,GetPromptResultSchema:st,ListResourcesResultSchema:ct,ListResourceTemplatesResultSchema:lt,ReadResourceResultSchema:ut,CompleteResultSchema:dt,CacheableResultSchema:ft,DiscoverResultSchema:pt,CreateMessageRequestParamsSchema:mt,CreateMessageRequestSchema:ht,ListRootsRequestSchema:gt,CreateMessageResultSchema:_t,ListRootsResultSchema:vt,ElicitResultSchema:yt,ElicitRequestURLParamsSchema:bt,ElicitRequestParamsSchema:xt,ElicitRequestSchema:St,InputRequestSchema:Ct,InputResponseSchema:wt,InputRequestsSchema:Tt,InputResponsesSchema:Et,InputRequiredResultSchema:Dt,InputResponseRequestParamsSchema:kt,CallToolRequestSchema:Ft,ListToolsRequestSchema:It,ListPromptsRequestSchema:Lt,GetPromptRequestSchema:Rt,ListResourcesRequestSchema:zt,ListResourceTemplatesRequestSchema:Bt,ReadResourceRequestSchema:Vt,CompleteRequestSchema:Ut,DiscoverRequestSchema:Wt,SubscriptionFilterSchema:Gt,SubscriptionsListenRequestSchema:qt,SubscriptionsListenResultMetaSchema:Jt,SubscriptionsListenResultSchema:Yt,dispatchRequestSchemas:Xt,dispatchResultSchemas:Qt,NotificationMetaSchema:$t,SubscriptionsAcknowledgedNotificationSchema:en,CancelledNotificationParamsSchema:tn,CancelledNotificationSchema:nn,notificationSchemas2026:rn,JSONRPCResultResponseSchema:D(nt),CallToolResultResponseSchema:D(V([it,Dt])),ListToolsResultResponseSchema:D(at),ListPromptsResultResponseSchema:D(ot),GetPromptResultResponseSchema:D(V([st,Dt])),ListResourcesResultResponseSchema:D(ct),ListResourceTemplatesResultResponseSchema:D(lt),ReadResourceResultResponseSchema:D(V([ut,Dt])),CompleteResultResponseSchema:D(dt),DiscoverResultResponseSchema:D(pt),SubscriptionsListenResultResponseSchema:D(Yt)}}var Ch;function wh(){return Ch??=Sh()}var Th=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Eh(e){return Th.includes(e)}var Dh=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Oh(e,t){if(t===void 0)return e;let n=e[Dh];if(n===void 0)return{...e,[Dh]:t};let r={},i=n.ttlMs??t.ttlMs;i!==void 0&&(r.ttlMs=i);let a=n.cacheScope??t.cacheScope;return a!==void 0&&(r.cacheScope=a),{...e,[Dh]:r}}function kh(e){return e[Dh]}function Ah(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function jh(e){return e===`public`||e===`private`}function Mh(e,t){if(e.ttlMs!==void 0&&!Ah(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!jh(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}var Z=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Q=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Rm(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Lm(this,new.target)}static fromError(t,n,r){if(t===Z.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Ph(e.elicitations,n)}if(t===Z.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Fh({supported:e.supported,requested:e.requested},n)}if(t===Z.InvalidParams||t===Z.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===Z.ResourceNotFound||Object.keys(e).length===1))return new Nh(e.uri,n)}if(t===Z.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Ih({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Nh=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(Z.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Ph=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Z.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Fh=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Z.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Ih=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(Z.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Lh=0,Rh=`private`,zh=[`tools/call`,`prompts/get`,`resources/read`];function Bh(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||zh.includes(e))return t;throw new Q(Z.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Vh(e,t){let n=kh(t);if(t.resultType!==`complete`||!Eh(e))return n===void 0?t:Kh(t);let r=t,i=Ah(r.ttlMs)?r.ttlMs:Wh(n),a=jh(r.cacheScope)?r.cacheScope:Gh(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Dh],o}function Hh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Uh(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[Yc]:t}}:!Hh(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[Yc]:t}}}function Wh(e){return e!==void 0&&Ah(e.ttlMs)?e.ttlMs:Lh}function Gh(e){return e!==void 0&&jh(e.cacheScope)?e.cacheScope:Rh}function Kh(e){let t={...e};return delete t[Dh],t}var qh=[`elicitation/create`,`sampling/createMessage`,`roots/list`],Jh;function Yh(){if(Jh)return Jh;let e=wh();return Jh={request:{"elicitation/create":z({method:W(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":z({method:W(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":z({method:W(`roots/list`),params:B({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Jh}function Xh(e){return qh.includes(e)}function Zh(e){return Xh(e)?Yh().request[e]:void 0}function Qh(e){return Xh(e)?Yh().response[e]:void 0}var $h={"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},eg={"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 tg(e){return Object.prototype.hasOwnProperty.call($h,e)}function ng(e){return Object.prototype.hasOwnProperty.call(eg,e)}function rg(e){return Object.prototype.hasOwnProperty.call($h,e)}function ig(e){return tg(e)?wh().dispatchRequestSchemas[e]:void 0}function ag(e){return rg(e)?wh().dispatchResultSchemas[e]:void 0}function og(e){return ng(e)?wh().notificationSchemas2026[e]:void 0}Object.keys($h),Object.keys(eg);function sg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cg(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var lg={ok:!1,reason:`not-in-era`},ug=[qc,Xc];function dg(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>sg(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!sg(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(sg(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var fg={era:`2026-07-28`,hasRequestMethod:tg,hasNotificationMethod:ng,hasInputRequestMethod:e=>Zh(e)!==void 0,validateRequest:(e,t)=>cg(ig(e),t),validateResult:(e,t)=>cg(ag(e),t),validateNotification:(e,t)=>cg(og(e),t),validateInputRequest:(e,t)=>cg(Zh(e),t),validateInputResponse:(e,t)=>cg(Qh(e),t),samplingResultVariant:()=>lg,outboundEnvelope(e){return{[qc]:e.protocolVersion,[Jc]:e.clientInfo,[Xc]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of ug)n in e||t.push({key:n,problem:`missing`});let n=wh().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>Jm(e),inputRequestSchema:Zh,decodeResult(e,t){if(!sg(t))return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new X(Y.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(typeof n!=`string`)return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=sg(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:wh().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new X(Y.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:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new X(Y.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=mg(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return Uh(Vh(e,Bh(e,dg(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=wh().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(`; `)}`}},pg;function mg(){if(pg)return pg;let e=wh();return pg={"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},pg}var hg=`2026-07-28`;function gg(e){return e!==void 0&&Gm(e)?fg:xh}function _g(e){return e.revision===void 0?e.era===`modern`?fg.era:xh.era:gg(e.revision).era}function vg(e){return xg.some(t=>t.hasRequestMethod(e))}function yg(e){return xg.some(t=>t.hasNotificationMethod(e))}function bg(e){return e===`tasks/get`||e===`tasks/cancel`}var xg=[xh,fg],Sg=km({AnnotationsSchema:()=>Jl,AudioContentSchema:()=>Du,BaseMetadataSchema:()=>Cl,BaseRequestParamsSchema:()=>ol,BlobResourceContentsSchema:()=>Kl,BooleanSchemaSchema:()=>cd,CallToolRequestParamsSchema:()=>Hu,CallToolRequestSchema:()=>Uu,CallToolResultSchema:()=>Bu,CancelTaskRequestSchema:()=>Jd,CancelTaskResultSchema:()=>Yd,CancelledNotificationParamsSchema:()=>yl,CancelledNotificationSchema:()=>bl,ClientCapabilitiesSchema:()=>Ol,ClientNotificationSchema:()=>Zd,ClientRequestSchema:()=>Xd,ClientResultSchema:()=>Qd,ClientTasksCapabilitySchema:()=>El,CompatibilityCallToolResultSchema:()=>Vu,CompleteRequestParamsSchema:()=>kd,CompleteRequestSchema:()=>Ad,CompleteResultSchema:()=>jd,ContentBlockSchema:()=>ju,CreateMessageRequestParamsSchema:()=>id,CreateMessageRequestSchema:()=>ad,CreateMessageResultSchema:()=>od,CreateMessageResultWithToolsSchema:()=>sd,CreateTaskResultSchema:()=>zd,CursorSchema:()=>nl,DiscoverRequestSchema:()=>Pl,DiscoverResultSchema:()=>Fl,ElicitRequestFormParamsSchema:()=>bd,ElicitRequestParamsSchema:()=>Sd,ElicitRequestSchema:()=>Cd,ElicitRequestURLParamsSchema:()=>xd,ElicitResultSchema:()=>Ed,ElicitationCompleteNotificationParamsSchema:()=>wd,ElicitationCompleteNotificationSchema:()=>Td,EmbeddedResourceSchema:()=>ku,EmptyResultSchema:()=>vl,EnumSchemaSchema:()=>vd,GetPromptRequestParamsSchema:()=>Cu,GetPromptRequestSchema:()=>wu,GetPromptResultSchema:()=>Nu,GetTaskPayloadRequestSchema:()=>Wd,GetTaskPayloadResultSchema:()=>Gd,GetTaskRequestSchema:()=>Hd,GetTaskResultSchema:()=>Ud,IconSchema:()=>xl,IconsSchema:()=>Sl,ImageContentSchema:()=>Eu,ImplementationSchema:()=>wl,InitializeRequestParamsSchema:()=>kl,InitializeRequestSchema:()=>Al,InitializeResultSchema:()=>Ml,InitializedNotificationSchema:()=>Nl,JSONArraySchema:()=>el,JSONObjectSchema:()=>K,JSONRPCErrorResponseSchema:()=>hl,JSONRPCMessageSchema:()=>gl,JSONRPCNotificationSchema:()=>pl,JSONRPCRequestSchema:()=>fl,JSONRPCResponseSchema:()=>_l,JSONRPCResultResponseSchema:()=>ml,JSONValueSchema:()=>$c,LegacyTitledEnumSchemaSchema:()=>pd,ListChangedOptionsBaseSchema:()=>Gu,ListPromptsRequestSchema:()=>xu,ListPromptsResultSchema:()=>Su,ListResourceTemplatesRequestSchema:()=>$l,ListResourceTemplatesResultSchema:()=>eu,ListResourcesRequestSchema:()=>Zl,ListResourcesResultSchema:()=>Ql,ListRootsRequestSchema:()=>Nd,ListRootsResultSchema:()=>Pd,ListTasksRequestSchema:()=>Kd,ListTasksResultSchema:()=>qd,ListToolsRequestSchema:()=>Ru,ListToolsResultSchema:()=>zu,LoggingLevelSchema:()=>Ku,LoggingMessageNotificationParamsSchema:()=>Yu,LoggingMessageNotificationSchema:()=>Xu,ModelHintSchema:()=>Zu,ModelPreferencesSchema:()=>Qu,MultiSelectEnumSchemaSchema:()=>_d,NotificationSchema:()=>ll,NotificationsParamsSchema:()=>cl,NumberSchemaSchema:()=>ud,PaginatedRequestParamsSchema:()=>Bl,PaginatedRequestSchema:()=>Vl,PaginatedResultSchema:()=>Hl,PingRequestSchema:()=>Il,PrimitiveSchemaDefinitionSchema:()=>yd,ProgressNotificationParamsSchema:()=>Rl,ProgressNotificationSchema:()=>zl,ProgressSchema:()=>Ll,ProgressTokenSchema:()=>tl,PromptArgumentSchema:()=>yu,PromptListChangedNotificationSchema:()=>Pu,PromptMessageSchema:()=>Mu,PromptReferenceSchema:()=>Od,PromptSchema:()=>bu,ReadResourceRequestParamsSchema:()=>nu,ReadResourceRequestSchema:()=>ru,ReadResourceResultSchema:()=>iu,RelatedTaskMetadataSchema:()=>il,RequestIdSchema:()=>dl,RequestMetaSchema:()=>al,RequestSchema:()=>q,ResourceContentsSchema:()=>Ul,ResourceLinkSchema:()=>Au,ResourceListChangedNotificationSchema:()=>au,ResourceRequestParamsSchema:()=>tu,ResourceSchema:()=>Yl,ResourceTemplateReferenceSchema:()=>Dd,ResourceTemplateSchema:()=>Xl,ResourceUpdatedNotificationParamsSchema:()=>_u,ResourceUpdatedNotificationSchema:()=>vu,ResultMetaObjectSchema:()=>ul,ResultSchema:()=>J,RoleSchema:()=>ql,RootSchema:()=>Md,RootsListChangedNotificationSchema:()=>Fd,SamplingContentSchema:()=>td,SamplingMessageContentBlockSchema:()=>nd,SamplingMessageSchema:()=>rd,ServerCapabilitiesSchema:()=>jl,ServerNotificationSchema:()=>ef,ServerRequestSchema:()=>$d,ServerResultSchema:()=>tf,ServerTasksCapabilitySchema:()=>Dl,SetLevelRequestParamsSchema:()=>qu,SetLevelRequestSchema:()=>Ju,SingleSelectEnumSchemaSchema:()=>md,StringSchemaSchema:()=>ld,SubscribeRequestParamsSchema:()=>ou,SubscribeRequestSchema:()=>su,SubscriptionFilterSchema:()=>uu,SubscriptionsAcknowledgedNotificationParamsSchema:()=>pu,SubscriptionsAcknowledgedNotificationSchema:()=>mu,SubscriptionsListenRequestParamsSchema:()=>du,SubscriptionsListenRequestSchema:()=>fu,SubscriptionsListenResultMetaSchema:()=>hu,SubscriptionsListenResultSchema:()=>gu,TaskAugmentedRequestParamsSchema:()=>sl,TaskCreationParamsSchema:()=>Id,TaskMetadataSchema:()=>rl,TaskSchema:()=>Rd,TaskStatusNotificationParamsSchema:()=>Bd,TaskStatusNotificationSchema:()=>Vd,TaskStatusSchema:()=>Ld,TextContentSchema:()=>Tu,TextResourceContentsSchema:()=>Wl,TitledMultiSelectEnumSchemaSchema:()=>gd,TitledSingleSelectEnumSchemaSchema:()=>fd,ToolAnnotationsSchema:()=>Fu,ToolChoiceSchema:()=>$u,ToolExecutionSchema:()=>Iu,ToolListChangedNotificationSchema:()=>Wu,ToolResultContentSchema:()=>ed,ToolSchema:()=>Lu,ToolUseContentSchema:()=>Ou,UnsubscribeRequestParamsSchema:()=>cu,UnsubscribeRequestSchema:()=>lu,UntitledMultiSelectEnumSchemaSchema:()=>hd,UntitledSingleSelectEnumSchemaSchema:()=>dd}),Cg=e=>fl.safeParse(e).success,wg=e=>pl.safeParse(e).success,Tg=e=>ml.safeParse(e).success,Eg=e=>hl.safeParse(e).success,Dg=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`;function Og(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function kg(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var Ag=`x-mcp-header`,jg=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Mg=new Set([`string`,`integer`,`boolean`]);function Ng(e){let t=[],n=new Map,r,i=(e,a,o)=>{if(typeof e!=`object`||!e)return;let s=e;if(Ag in s){if(!o||a.length===0)return`${Ig(a)}: 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 e=s[Ag];if(typeof e!=`string`||e.length===0)return`${Ig(a)}: x-mcp-header MUST be a non-empty string`;if(!jg.test(e))return`${Ig(a)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let i=typeof s.type==`string`?s.type:void 0;if(i===void 0||!Mg.has(i)){let e=`${Ig(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${i??`<none>`}`;if(i!==`number`)return e;r??=e}let c=e.toLowerCase(),l=n.get(c);if(l!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${l}')`;n.set(c,e),t.push({path:a,headerName:e,type:i})}let c=s.properties;if(typeof c==`object`&&c)for(let[e,t]of Object.entries(c)){let n=i(t,[...a,e],o);if(n!==void 0)return n}for(let e of Pg){let t=s[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Fg.has(e)?Object.values(t):[t];for(let t of n){let n=i(t,[...a,`<${e}>`],!1);if(n!==void 0)return n}}},a=i(e,[],!0);return a===void 0?r===void 0?{valid:!0,declarations:t}:{valid:!1,reason:r,declarations:t}:{valid:!1,reason:r??a}}var Pg=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Fg=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Ig(e){return e.length===0?`<root>`:e.join(`.`)}var Lg=-32020;Z.InvalidRequest,Z.UnsupportedProtocolVersion,Z.InvalidParams,Z.MethodNotFound,Z.InvalidParams,Z.MissingRequiredClientCapability;var Rg={[Z.ParseError]:400,[Z.InvalidRequest]:400,[Z.MethodNotFound]:404,[Z.UnsupportedProtocolVersion]:400,[Z.MissingRequiredClientCapability]:400,[Lg]:400};function zg(e,t){return cs(e,t)}function Bg(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function Vg(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var Hg=!1,Ug=`draft-2020-12`;function Wg(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:Ug});else if(n.vendor===`zod`){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().`);Hg||(Hg=!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=ns(e,{target:Ug,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&Kg(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)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}}var Gg=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function Kg(e,t=e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;let n=typeof e.$ref==`string`&&Gg.exec(e.$ref);if(n&&t[n[1]]?.[n[2]]?.type===`object`)return!0;for(let n of[`oneOf`,`anyOf`,`allOf`]){let r=e[n];if(Array.isArray(r)&&r.length>0)return r.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||Kg(e,`$id`in e?{}:t)))}return!1}function qg(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function Jg(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>qg(e)).join(`, `)}:{success:!0,data:n.value}}function Yg(e){let t=ns(e,{target:Ug,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var Xg=/\\\.\\d\{(\d+)\}/;function Zg(e){let t=Xg.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>Hc({local:e,offset:t,precision:n}))))}function Qg(e,t){let n;switch(e){case`email`:n=[Ds()];break;case`uri`:n=[js()];break;case`date`:n=[Uc()];break;case`date-time`:n=Zg(t)}return new Set(n.map(e=>Yg(e)).filter(e=>e!==void 0))}function $g(e,t,n){return n!==`zod`||Qg(e,t).has(t)}function e_(e){let t=Wg(e,`input`),n=t.properties||{},r=t.required||[];return Object.entries(n).map(([e,t])=>({name:e,description:t?.description,required:r.includes(e)}))}function t_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function n_(e){try{return Wg(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Q(Z.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var r_=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function i_(e){return r_.has(e)||e.startsWith(`x-`)}var a_=new Set([`$schema`,...Object.keys(bd.shape.requestedSchema.shape)]),o_={string:Bg([ld,dd,fd,pd]),number:Bg([ud]),integer:Bg([ud]),boolean:Bg([cd]),array:Bg([hd,gd])},s_=new Set(ld.shape.format.unwrap().options);function c_(e,t,n,r){if(!t_(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(o_,e.type)?o_[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||i_(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?s_.has(e.format)?typeof s==`string`&&$g(e.format,s,n)||r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function l_(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&t_(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,c_(n,`properties.${e}`,t,r)])):a_.has(i)?n[i]=a:i_(i)||r.push(i);if(r.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function u_(e,t){if(!t_(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!zg(yd,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function d_(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>d_(e,t[r],`${n}[${r}]`)):!t_(e)||!t_(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?d_(r,t[e],i):i_(e)?[]:[i]})}function f_(e){if(!Vg(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=l_(n_(e.requestedSchema),t),r=zg(bd.shape.requestedSchema,n);if(!r.success)throw new Q(Z.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${u_(n,r.error.message)}`);let i=d_(n,r.data);if(i.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function p_(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)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`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(p_,{elicit(e){try{return{method:`elicitation/create`,params:f_(e)}}catch(e){throw e instanceof Q?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});function m_(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function h_(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof X?t.reason:new X(Y.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof X?t.reason:new X(Y.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function g_(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}var __=`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`.split(`.`),v_={IdJagTokenExchangeResponseSchema:lf,OAuthClientInformationFullSchema:mf,OAuthClientInformationSchema:pf,OAuthClientMetadataSchema:ff,OAuthClientRegistrationErrorSchema:hf,OAuthErrorResponseSchema:uf,OAuthMetadataSchema:af,OAuthProtectedResourceMetadataSchema:rf,OAuthTokenRevocationRequestSchema:gf,OAuthTokensSchema:cf,OpenIdProviderDiscoveryMetadataSchema:sf,OpenIdProviderMetadataSchema:of},y_={},b_={};function x_(e,t){let n=e.slice(0,-6);y_[n]=t,b_[n]=e=>t.safeParse(e).success}for(let e of __)x_(e,Sg[e]);for(let[e,t]of Object.entries(v_))x_(e,t);Object.freeze(y_),Object.freeze(b_);function S_(e){switch(e){case`initialize`:case`notifications/initialized`:return gg(void 0);case`server/discover`:return gg(hg);default:return}}var C_=[qc,Jc,Xc,Qc],w_=[`inputResponses`,`requestState`];function T_(e,t){let n=e.params;if(!j_(n))return{message:e,lifted:{}};let r=n._meta,i=j_(r)?C_.filter(e=>e in r):[],a=t===`request`?w_.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&j_(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function E_(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function D_(e){return()=>e}var O_=D_(void 0);function k_(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:D_(t)}}}var A_=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Gc,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(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new X(Y.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!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new X(Y.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});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 n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Tg(e)||Eg(e)?this._onresponse(e):Cg(e)?this._onrequest(e,t):wg(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;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new X(Y.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=T_(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=_g(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(yg(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=T_(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=_g(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(Z.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(vg(n.method)&&!i.hasRequestMethod(n.method)&&!(bg(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(Z.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Z.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(Z.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:P_(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?O_:D_(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Vg(t))return u(e,t,n);let i=E_(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(Z.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:Z.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);n===void 0?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),Tg(e)?n(e):n(Q.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(Vg(t))return bg(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=E_(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return gg(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=S_(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(vg(t)&&!e.hasRequestMethod(t))throw new X(Y.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof X?e:new X(Y.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),ee=!1,te=e=>{ee||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof X?e:new X(Y.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(ee=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(F_(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}Jg(n,a.result).then(e=>{e.success?d(e.data):f(new X(Y.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>te(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let ne=r?.timeout??6e4;this._setupTimeout(h,ne,r?.maxTotalTimeout,()=>te(new X(Y.RequestTimeout,`Request timed out`,{timeout:ne})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new X(Y.NotConnected,`Not connected`);if(yg(t.method)&&!e.hasNotificationMethod(t.method))throw new X(Y.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 r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))})}else await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!vg(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Q(Z.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await Jg(t.params,{...r.params});if(!a.success)throw new Q(Z.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!yg(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Q(Z.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))})}else{if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await Jg(t.params,{...r.params});if(!i.success)throw new Q(Z.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function j_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function M_(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=j_(a)&&j_(i)?{...a,...i}:i}return n}function N_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function P_(e){let t={},n=[];if(!N_(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e))!N_(i)||`method`in i||`result`in i?n.push(r):t[r]=i;return{accepted:t,droppedKeys:n}}function F_(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}Om((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))();var I_=/^[A-Za-z0-9._-]{1,128}$/;function L_(e){let t=[];if(e.length===0)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`),!I_.test(e)){let n=[...e].filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.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}}function R_(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);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.`)}}function z_(e){let t=L_(e);return R_(e,t.warnings),t.isValid}var B_=1e6,V_=1e6,H_=1e4,U_=1e6,W_=class e{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,n){if(e.length>t)throw Error(`${n} exceeds maximum length of ${t} characters (got ${e.length})`)}template;parts;get variableNames(){return this.parts.flatMap(e=>typeof e==`string`?[]:e.names)}constructor(t){e.validateLength(t,B_,`Template`),this.template=t,this.parts=this.parse(t)}toString(){return this.template}parse(t){let n=[],r=``,i=0,a=0;for(;i<t.length;)if(t[i]===`{`){r&&=(n.push(r),``);let o=t.indexOf(`}`,i);if(o===-1)throw Error(`Unclosed template expression`);if(a++,a>H_)throw Error(`Template contains too many expressions (max ${H_})`);let s=t.slice(i+1,o),c=this.getOperator(s),l=s.includes(`*`),u=this.getNames(s),d=u[0];for(let t of u)e.validateLength(t,V_,`Variable name`);n.push({name:d,operator:c,names:u,exploded:l}),i=o+1}else r+=t[i],i++;return r&&n.push(r),n}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,n){return e.validateLength(t,V_,`Variable value`),n===`+`||n===`#`?encodeURI(t):encodeURIComponent(t)}expandPart(e,t){if(e.operator===`?`||e.operator===`&`){let n=e.names.map(n=>{let r=t[n];return r===void 0?``:`${n}=${Array.isArray(r)?r.map(t=>this.encodeValue(t,e.operator)).join(`,`):this.encodeValue(r.toString(),e.operator)}`}).filter(e=>e.length>0);return n.length===0?``:(e.operator===`?`?`?`:`&`)+n.join(`&`)}if(e.names.length>1){let n=e.names.map(e=>t[e]).filter(e=>e!==void 0);return n.length===0?``:n.map(e=>Array.isArray(e)?e[0]:e).join(`,`)}let n=t[e.name];if(n===void 0)return``;let r=(Array.isArray(n)?n:[n]).map(t=>this.encodeValue(t,e.operator));switch(e.operator){case``:case`+`:return r.join(`,`);case`#`:return`#`+r.join(`,`);case`.`:return`.`+r.join(`.`);case`/`:return`/`+r.join(`/`);default:return r.join(`,`)}}expand(e){let t=``,n=!1;for(let r of this.parts){if(typeof r==`string`){t+=r;continue}let i=this.expandPart(r,e);i&&(t+=(r.operator===`?`||r.operator===`&`)&&n?i.replace(`?`,`&`):i,(r.operator===`?`||r.operator===`&`)&&(n=!0))}return t}escapeRegExp(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(t){let n=[];for(let n of t.names)e.validateLength(n,V_,`Variable name`);if(t.operator===`?`||t.operator===`&`){for(let e=0;e<t.names.length;e++){let r=t.names[e],i=e===0?`\\`+t.operator:`&`;n.push({pattern:i+this.escapeRegExp(r)+`=([^&]+)`,name:r})}return n}let r,i=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 n.push({pattern:r,name:i}),n}match(t){e.validateLength(t,B_,`URI`);let n=`^`,r=[];for(let e of this.parts)if(typeof e==`string`)n+=this.escapeRegExp(e);else{let t=this.partToRegExp(e);for(let{pattern:i,name:a}of t)n+=i,r.push({name:a,exploded:e.exploded})}n+=`$`,e.validateLength(n,U_,`Generated regex pattern`);let i=new RegExp(n),a=t.match(i);if(!a)return null;let o={};for(let[e,t]of r.entries()){let{name:n,exploded:r}=t,i=a[e+1],s=n.replace(`*`,``);o[s]=r&&i.includes(`,`)?i.split(`,`):i}return o}};function G_(e){return typeof e==`object`&&!!e&&`_zod`in e}function K_(e){return typeof e==`object`&&!!e&&!(`_zod`in e)&&`_def`in e&&typeof e._def?.typeName==`string`}function q_(e){if(typeof e!=`object`||!e||Vg(e))return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.values(e).every(e=>G_(e))}function J_(e){if(e!==void 0){if(q_(e))return z(e);if(typeof e==`object`&&e&&!Vg(e)&&Object.values(e).some(e=>K_(e)))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(!Vg(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 Y_(e,t){let n=t.getValidator(e);return{"~standard":{version:1,vendor:`mcp`,jsonSchema:{input:()=>e,output:()=>e},validate:e=>{let t=n(e);return t.valid?{value:t.data}:{issues:[{message:t.errorMessage}]}}}}}function X_(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!X_(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!X_(e[r],t[r]))return!1;return!0}return e===t}function Z_(e){return encodeURI(Q_(e))}function Q_(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}var $_={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},e1={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},t1={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},n1=typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);function r1(e,t=Object.create(null),n=n1,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:r1(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(t1[i])continue;let a=`${r}/${Z_(i)}`,o=e[i];if(Array.isArray(o)){if($_[i]){let e=o.length;for(let r=0;r<e;r++)r1(o[r],t,n,`${a}/${r}`)}}else if(e1[i])for(let e in o)r1(o[e],t,n,`${a}/${Z_(e)}`);else r1(o,t,n,a)}return t}var i1=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,a1=[0,31,28,31,30,31,30,31,31,30,31,30,31],o1=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,s1=/^(?=.{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,c1=/^(?:[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,l1=/^(?:(?:[^\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,u1=/^(?:(?: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,d1=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,f1=/^(?:\/(?:[^~/]|~0|~1)*)*$/,p1=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,m1=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,h1=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},g1=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,_1=/^((([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,v1=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));function y1(e){return e.test.bind(e)}var b1={date:S1,time:C1.bind(void 0,!1),"date-time":T1,duration:v1,uri:O1,"uri-reference":y1(c1),"uri-template":y1(l1),url:y1(u1),email:h1,hostname:y1(s1),ipv4:y1(g1),ipv6:y1(_1),regex:A1,uuid:y1(d1),"json-pointer":y1(f1),"json-pointer-uri-fragment":y1(p1),"relative-json-pointer":y1(m1)};function x1(e){return e%4==0&&(e%100!=0||e%400==0)}function S1(e){let t=e.match(i1);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&x1(n)?29:a1[r])}function C1(e,t){let n=t.match(o1);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var w1=/t|\s/i;function T1(e){let t=e.split(w1);return t.length==2&&S1(t[0])&&C1(!0,t[1])}var E1=/\/|:/,D1=/^(?:[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;function O1(e){return E1.test(e)&&D1.test(e)}var k1=/[^\\]\\Z/;function A1(e){if(k1.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function j1(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function $(e,t,n=`2019-09`,r=r1(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,u;switch(l){case`boolean`:case`number`:case`string`:u=l;break;case`object`:u=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:g,required:_,not:ee,anyOf:te,allOf:ne,oneOf:re,if:ie,then:ae,else:oe,format:se,properties:ce,patternProperties:le,additionalProperties:v,unevaluatedProperties:ue,minProperties:de,maxProperties:fe,propertyNames:pe,dependentRequired:me,dependentSchemas:he,dependencies:ge,prefixItems:_e,items:ve,additionalItems:ye,unevaluatedItems:be,contains:xe,minContains:y,maxContains:b,minItems:Se,maxItems:Ce,uniqueItems:we,minimum:Te,maximum:x,exclusiveMinimum:S,exclusiveMaximum:Ee,multipleOf:De,minLength:Oe,maxLength:ke,pattern:Ae,__absolute_ref__:je,__absolute_recursive_ref__:Me}=t,C=[];if(p===!0&&a===null&&(a=t),f===`#`){let l=a===null?r[Me]:a,u=`${s}/$recursiveRef`,d=$(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||C.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(d!==void 0){let t=r[je||d];if(t===void 0){let e=`Unresolved $ref "${d}".`;throw je&&je!==d&&(e+=` Absolute URI "${je}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
|
|
56
|
+
- `)}`,Error(e)}let l=`${s}/$ref`,u=$(e,t,n,r,i,a,o,l,c);if(u.valid||C.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:C.length===0,errors:C}}if(Array.isArray(m)){let t=m.length,n=!1;for(let r=0;r<t;r++)if(u===m[r]||m[r]===`integer`&&u===`number`&&e%1==0&&e===e){n=!0;break}n||C.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join(`", "`)}".`})}else m===`integer`?(u!==`number`||e%1||e!==e)&&C.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&C.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(h!==void 0&&(u===`object`||u===`array`?X_(e,h)||C.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&C.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),g!==void 0&&(u===`object`||u===`array`?g.some(t=>X_(e,t))||C.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(t=>e===t)||C.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),ee!==void 0){let t=`${s}/not`;$(e,ee,n,r,i,a,o,t).valid&&C.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let Ne=[];if(te!==void 0){let t=`${s}/anyOf`,l=C.length,u=!1;for(let s=0;s<te.length;s++){let l=te[s],d=Object.create(c),f=$(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);C.push(...f.errors),u||=f.valid,f.valid&&Ne.push(d)}u?C.length=l:C.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(ne!==void 0){let t=`${s}/allOf`,l=C.length,u=!0;for(let s=0;s<ne.length;s++){let l=ne[s],d=Object.create(c),f=$(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);C.push(...f.errors),u&&=f.valid,f.valid&&Ne.push(d)}u?C.length=l:C.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(re!==void 0){let t=`${s}/oneOf`,l=C.length,u=re.filter((s,l)=>{let u=Object.create(c),d=$(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return C.push(...d.errors),d.valid&&Ne.push(u),d.valid}).length;u===1?C.length=l:C.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...Ne),ie!==void 0){let t=`${s}/if`;if($(e,ie,n,r,i,a,o,t,c).valid){if(ae!==void 0){let l=$(e,ae,n,r,i,a,o,`${s}/then`,c);l.valid||C.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(oe!==void 0){let l=$(e,oe,n,r,i,a,o,`${s}/else`,c);l.valid||C.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(_!==void 0)for(let t of _)t in e||C.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(de!==void 0&&t.length<de&&C.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${de} properties.`}),fe!==void 0&&t.length>fe&&C.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${fe} properties.`}),pe!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${Z_(s)}`,c=$(s,pe,n,r,i,a,e,t);c.valid||C.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(me!==void 0){let t=`${s}/dependantRequired`;for(let n in me)if(n in e){let r=me[n];for(let i of r)i in e||C.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(he!==void 0)for(let t in he){let l=`${s}/dependentSchemas`;if(t in e){let s=$(e,he[t],n,r,i,a,o,`${l}/${Z_(t)}`,c);s.valid||C.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(ge!==void 0){let t=`${s}/dependencies`;for(let s in ge)if(s in e){let c=ge[s];if(Array.isArray(c))for(let n of c)n in e||C.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=$(e,c,n,r,i,a,o,`${t}/${Z_(s)}`);l.valid||C.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(ce!==void 0){let t=`${s}/properties`;for(let s in ce){if(!(s in e))continue;let d=`${o}/${Z_(s)}`,f=$(e[s],ce[s],n,r,i,a,d,`${t}/${Z_(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,C.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&le!==void 0){let t=`${s}/patternProperties`;for(let s in le){let d=new RegExp(s,`u`),f=le[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${Z_(p)}`,h=$(e[p],f,n,r,i,a,m,`${t}/${Z_(s)}`);h.valid?c[p]=l[p]=!0:(u=i,C.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...h.errors))}}}if(!u&&v!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${Z_(s)}`,f=$(e[s],v,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,C.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&ue!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${Z_(s)}`,u=$(e[s],ue,n,r,i,a,l,t);u.valid?c[s]=!0:C.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){Ce!==void 0&&e.length>Ce&&C.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${Ce}).`}),Se!==void 0&&e.length<Se&&C.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${Se}).`});let t=e.length,l=0,u=!1;if(_e!==void 0){let d=`${s}/prefixItems`,f=Math.min(_e.length,t);for(;l<f;l++){let t=$(e[l],_e[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,C.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}if(ve!==void 0){let d=`${s}/items`;if(Array.isArray(ve)){let s=Math.min(ve.length,t);for(;l<s;l++){let t=$(e[l],ve[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,C.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}else for(;l<t;l++){let t=$(e[l],ve,n,r,i,a,`${o}/${l}`,d);if(c[l]=!0,!t.valid&&(u=i,C.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}if(!u&&ye!==void 0){let d=`${s}/additionalItems`;for(;l<t;l++){let t=$(e[l],ye,n,r,i,a,`${o}/${l}`,d);c[l]=!0,t.valid||(u=i,C.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:d,error:`Items did not match additional items schema.`},...t.errors))}}}if(xe!==void 0){if(t===0&&y===void 0)C.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(y!==void 0&&t<y)C.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${y}).`});else{let l=`${s}/contains`,u=C.length,d=0;for(let s=0;s<t;s++){let t=$(e[s],xe,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):C.push(...t.errors)}d>=(y||0)&&(C.length=u),y===void 0&&b===void 0&&d===0?C.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):y!==void 0&&d<y?C.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${y} items matching schema. Only ${d} items were found.`}):b!==void 0&&d>b&&C.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${b} items matching schema. ${d} items were found.`})}}if(!u&&be!==void 0){let u=`${s}/unevaluatedItems`;for(;l<t;l++){if(c[l])continue;let t=$(e[l],be,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||C.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:u,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(we)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&X_(r,t))&&(C.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(u===`number`){if(n===`4`?(Te!==void 0&&(S===!0&&e<=Te||e<Te)&&C.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${S?`or equal to `:``} ${Te}.`}),x!==void 0&&(Ee===!0&&e>=x||e>x)&&C.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Ee?`or equal to `:``} ${x}.`})):(Te!==void 0&&e<Te&&C.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${Te}.`}),x!==void 0&&e>x&&C.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${x}.`}),S!==void 0&&e<=S&&C.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${S}.`}),Ee!==void 0&&e>=Ee&&C.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Ee}.`})),De!==void 0){let t=e%De;Math.abs(0-t)>=1.1920929e-7&&Math.abs(De-t)>=1.1920929e-7&&C.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${De}.`})}}else if(u===`string`){let t=Oe===void 0&&ke===void 0?0:j1(e);Oe!==void 0&&t<Oe&&C.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${Oe}).`}),ke!==void 0&&t>ke&&C.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${ke}).`}),Ae!==void 0&&!new RegExp(Ae,`u`).test(e)&&C.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),se!==void 0&&b1[se]&&!b1[se](e)&&C.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${se}".`})}return{valid:C.length===0,errors:C}}var M1=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=r1(e)}validate(e){return $(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),r1(e,this.lookup)}},N1=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=Fm(e,`pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.`);return t===`draft-7`?`7`:t}getValidator(e){let t=new M1(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let n=t.validate(e);return n.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:n.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join(`; `)}}}},P1=Symbol.for(`mcp.completable`);function F1(e){return!!e&&typeof e==`object`&&P1 in e}function I1(e){return e[P1]?.complete}var L1=2**31-1;function R1(e,t){if(!Number.isFinite(e)||e<1)return;let n=setInterval(t,Math.min(e,L1));return n.unref?.(),n}var z1,B1=class{static{z1=e=>e._classification}onclose;onerror;onmessage;_classification;_responseMode;_started=!1;_used=!1;_closed=!1;_terminalDelivered=!1;_dispatchWindowOpen=!1;_requestId;_deferredResponse;_sse;_abortCleanup;_keepAliveMs;constructor(e){this._classification=e.classification,this._responseMode=e.responseMode??`auto`,this._keepAliveMs=e.keepAliveMs??15e3}async start(){if(this._started)throw Error(`PerRequestHTTPServerTransport is already started`);this._started=!0}async handleMessage(e,t){if(this._used)throw Error(`PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request`);if(!this._started||this.onmessage===void 0)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 n=t?.request?.signal;if(n?.aborted)throw await this.close(),new X(Y.ConnectionClosed,`The request was aborted before it could be handled`);let r={classification:this._classification,...t?.request!==void 0&&{request:t.request},...t?.authInfo!==void 0&&{authInfo:t.authInfo}};if(Cg(e)){this._requestId=e.id;let t,i,a=new Promise((e,n)=>{t=e,i=n});if(this._deferredResponse={promise:a,resolve:t,reject:i,settled:!1},n!==void 0){let e=()=>void this.close();n.addEventListener(`abort`,e,{once:!0}),this._abortCleanup=()=>n.removeEventListener(`abort`,e)}this._dispatchWindowOpen=!0;try{this.onmessage(e,r)}finally{this._dispatchWindowOpen=!1}return this._responseMode===`sse`&&!this._closed&&!this._deferredResponse.settled&&this.upgradeToSse(),a}return this.onmessage(e,r),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let n=Tg(e)||Eg(e),r=n?e.id:t?.relatedRequestId;if(this._requestId===void 0||r===void 0||r!==this._requestId)n&&this.onerror?.(Error(`Received a response for an unknown request id: ${String(e.id)}`));else if(n){if(this._terminalDelivered)return;this._terminalDelivered=!0;let t=Eg(e)?e.error.code:void 0,n=t!==void 0&&(this._dispatchWindowOpen||t===Z.MissingRequiredClientCapability)?Rg[t]:void 0;if(n!==void 0&&this._sse===void 0){this.settleResponse(Response.json(e,{status:n,headers:{"Content-Type":`application/json`}})),queueMicrotask(()=>void this.close());return}if(this._sse!==void 0||this._responseMode===`sse`){this._sse===void 0&&this.upgradeToSse(),this.writeMessageFrame(e),this.finalizeStream();return}this.settleResponse(Response.json(e,{status:200,headers:{"Content-Type":`application/json`}})),queueMicrotask(()=>void this.close())}else this._responseMode!==`json`&&(this._sse===void 0&&this.upgradeToSse(),this.writeMessageFrame(e))}writeCommentFrame(e){if(this._closed||this._sse===void 0||this._sse.closed)return;let t=e.split(`
|
|
57
|
+
`).map(e=>`: ${e}`).join(`
|
|
58
|
+
`);this.writeFrame(`${t}\n\n`)}async close(){if(!this._closed){if(this._closed=!0,this._abortCleanup?.(),this._abortCleanup=void 0,this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),this._sse!==void 0&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}this._deferredResponse!==void 0&&!this._deferredResponse.settled&&(this._deferredResponse.settled=!0,this._deferredResponse.reject(new X(Y.ConnectionClosed,`Connection closed before a response was produced`))),this.onclose?.()}}settleResponse(e){this._deferredResponse===void 0||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=R1(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),this._sse!==void 0&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}queueMicrotask(()=>void this.close())}writeMessageFrame(e){this.writeFrame(`event: message\ndata: ${JSON.stringify(e)}\n\n`)}writeFrame(e){if(!(this._sse===void 0||this._sse.closed))try{this._sse.controller.enqueue(this._sse.encoder.encode(e))}catch(e){this.onerror?.(Error(`Failed to write to the response stream: ${e}`))}}};function V1(e){return e instanceof B1?z1(e):void 0}function H1(e){return typeof e==`object`&&!!e&&`setScopeChallengeResolver`in e&&typeof e.setScopeChallengeResolver==`function`}var U1=8,W1=6e5;function G1(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??U1,roundTimeoutMs:e?.roundTimeoutMs??W1,legacyShim:e?.legacyShim??!0}}function K1(e,t,n){if(typeof n!=`object`||!n||typeof n.method!=`string`)throw new Q(Z.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 r=n,i=Vm(r);if(i===void 0)throw new Q(Z.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 q1(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function J1(e,t){if(e===`tools/call`)return{content:[{type:`text`,text:t}],isError:!0};throw new Q(Z.InternalError,t)}var Y1=class{constructor(e){this._host=e}async fulfill(e,t,n,r,i){let{maxRounds:a,roundTimeoutMs:o}=this._host,s=r.mcpReq.signal,c=i,l=0;for(;;){if(l+=1,l>a)return J1(e,m_(e,a));let i=c.inputRequests,u=i!=null&&Object.keys(i).length>0,d=typeof c.requestState==`string`?c.requestState:void 0;if(!u&&d===void 0)throw new Q(Z.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);let f;if(u){let t=this._host.resolvedClientCapabilities(r),n=[];for(let[r,a]of Object.entries(i)){let{embedded:i,required:o}=K1(e,r,a);if(i.method!==`roots/list`&&i.params===void 0)throw new Q(Z.InternalError,`Handler for ${e} returned an input request '${r}' of kind '${i.method}' without params`);if(Hm(o,t)!==void 0)return J1(e,`Cannot request input '${r}' (${i.method}): the client on this 2025-era connection did not declare the required capability${t===void 0?` (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)`:``}`);n.push([r,i])}let a=g_(s);try{let e={relatedRequestId:r.mcpReq.id,timeout:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:a.signal},t=await Promise.all(n.map(async([t,n])=>{try{return[t,await this._dispatchLeg(n,e)]}catch(e){throw a.abort(e),e}}));f=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return J1(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{a.dispose()}}else await h_(250,s);let p={...r,mcpReq:{...r.mcpReq,inputResponses:f,droppedInputResponseKeys:void 0,requestState:D_(d)}};if(d!==void 0){let t=await this._host.verifyRequestState(d,p,e);t!==void 0&&(p=k_(p,t))}let m=await t(n,p);if(!Dg(m))return m;c=m}}async _dispatchLeg(e,t){switch(e.method){case`elicitation/create`:{let n=e.params;return n.mode===`url`&&n.elicitationId===void 0&&(n={...n,elicitationId:q1()}),await this._host.sendElicitation(n,t)}case`sampling/createMessage`:return await this._host.sendSampling(e.params,t);case`roots/list`:return await this._host.listRoots(e.params,t)}}},X1=new Set([`tools/call`,`prompts/get`,`resources/read`]),Z1=class extends A_{_clientCapabilities;_clientVersion;_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_boundFromTransport=!1;_legacyInputRequiredShim(){return this._legacyShim??=new Y1({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,n)=>this._verifyRequestState(e,t,n),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 N1,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=G1(t?.inputRequired),t?.cacheHints!==void 0){for(let[e,n]of Object.entries(t.cacheHints))n!==void 0&&Mh(n,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler(`initialize`,e=>this._oninitialize(e)),this.setNotificationHandler(`notifications/initialized`,()=>this.oninitialized?.()),qm(this._supportedProtocolVersions).length>0&&this.setRequestHandler(`server/discover`,()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}async connect(e){if(this.transport!==void 0)throw new X(Y.AlreadyConnected,`Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.`);this._boundFromTransport&&(this._boundFromTransport=!1,this._negotiatedProtocolVersion=void 0);let t=V1(e)?.revision;t!==void 0&&!this._servedModernEra()&&Wm.includes(t)&&qm(this._supportedProtocolVersions).includes(t)&&(this._negotiatedProtocolVersion=t,this._boundFromTransport=!0),await super.connect(e)}_registerLoggingHandler(){this.setRequestHandler(`logging/setLevel`,async(e,t)=>{let n=t.sessionId||t.http?.req?.headers.get(`mcp-session-id`)||void 0,{level:r}=e.params,i=zg(Ku,r);return i.success&&this._loggingLevels.set(n,i.data),{}})}buildContext(e,t){let n=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(t,n,r)=>{if(!this._capabilities.logging)return Promise.resolve();let i;if(this._servedModernEra()){if(i=e.mcpReq.envelope?.[Qc],i===void 0)return Promise.resolve()}else i=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return i!==void 0&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(i)?Promise.resolve():e.mcpReq.notify({method:`notifications/message`,params:{level:t,data:n,logger:r}})},elicitInput:(e,t)=>this.elicitInput(e,t),requestSampling:(e,t)=>this.createMessage(e,t)},http:n?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(Ku.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1};registerCapabilities(e){if(this.transport)throw new X(Y.AlreadyConnected,`Cannot register capabilities after connecting to transport`);let t=!!this._capabilities.logging;this._capabilities=M_(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if(e!==`tools/call`){let n=this._cacheHints?.[e],r=X1.has(e);return n===void 0&&!r?async(n,r)=>{let i=await t(n,r);if(Dg(i))throw new Q(Z.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 i}:async(i,a)=>{let o=r?await this._invokeInputRequiredCapableHandler(e,t,i,a):await t(i,a);if(Dg(o)){if(!r)throw new Q(Z.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 n===void 0?o:Oh(o,n)}}return async(e,n)=>{let r=gg(this._negotiatedProtocolVersion),i=r.validateRequest(`tools/call`,e);if(!i.ok)throw new Q(i.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,i.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call request: ${i.message}`);let a=await this._invokeInputRequiredCapableHandler(`tools/call`,t,e,n);if(Dg(a))return a;let o=Xm(a),s=r.validateResult(`tools/call`,o);if(!s.ok)throw new Q(s.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,s.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call result: ${s.message}`);return s.value}}_servedModernEra(){return this._negotiatedProtocolVersion!==void 0&&Gm(this._negotiatedProtocolVersion)}async _invokeInputRequiredCapableHandler(e,t,n,r){let i=this._servedModernEra(),a=r.mcpReq.requestState();if(a!==void 0&&typeof a!=`string`)throw new Q(Z.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`});let o=r;if(typeof a==`string`){let t=await this._verifyRequestState(a,r,e);t!==void 0&&(o=k_(r,t))}let s;try{s=await t(n,o)}catch(e){throw e instanceof Q&&e.code===Z.UrlElicitationRequired&&i?new Q(Z.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.`):e}if(!Dg(s))return s;if(!i){if(!this._inputRequiredServing.legacyShim)throw new Q(Z.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??`2025-11-25`}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,n,o,s)}let c=s.inputRequests,l=c!=null&&Object.keys(c).length>0,u=typeof s.requestState==`string`;if(!l&&!u)throw new Q(Z.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(l){let t=this._inputRequestCapabilityView(r);for(let[n,r]of Object.entries(c)){let{embedded:i,required:a}=K1(e,n,r),o=Hm(a,t);if(o!==void 0)throw new Ih({requiredCapabilities:o},`Cannot request input '${n}' (${i.method}): the request's client capabilities do not declare the required capability`)}}return s}async _verifyRequestState(e,t,n){if(this._requestStateVerify!==void 0)try{return await this._requestStateVerify(e,t)}catch(e){throw this.onerror?.(Error(`requestState verification rejected ${n}: ${e instanceof Error?e.message:String(e)}`)),new Q(Z.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[Xc]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new X(Y.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 X(Y.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw new X(Y.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw new X(Y.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw new X(Y.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 X(Y.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw new X(Y.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 X(Y.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 X(Y.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){switch(e){case`completion/complete`:if(!this._capabilities.completions)throw new X(Y.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw new X(Y.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw new X(Y.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 X(Y.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw new X(Y.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 n=Km(this._supportedProtocolVersions),r=n.includes(t)?t:n[0]??`2025-11-25`;return this._negotiatedProtocolVersion=r,this.transport?.setProtocolVersion?.(r),{protocolVersion:r,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:qm(this._supportedProtocolVersions),capabilities:Q1(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 X(Y.CapabilityNotSupported,`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages.at(-1),n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages.at(-2):void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw new Q(Z.InvalidParams,`The last message must contain only tool_result content if any is present`);if(!o)throw new Q(Z.InvalidParams,`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Q(Z.InvalidParams,`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}let n=!!(e.tools||e.toolChoice),r=await this.request({method:`sampling/createMessage`,params:e},t),i=this._wireCodec().samplingResultVariant(n,r);if(!i.ok)throw new X(Y.InvalidResult,`Invalid sampling/createMessage result: ${i.reason===`invalid`?i.message:i.reason}`);return i.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra(`elicitation/create`),e.mode??`form`){case`url`:if(!this._clientCapabilities?.elicitation?.url)throw new X(Y.CapabilityNotSupported,`Client does not support url elicitation.`);break;case`form`:if(!this._clientCapabilities?.elicitation?.form)throw new X(Y.CapabilityNotSupported,`Client does not support form elicitation.`)}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,n){let r=e.mode??`form`,i=n?.validateAcceptedContent??!0;switch(r){case`url`:{let n=e;return this.request({method:`elicitation/create`,params:n},t)}case`form`:{let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},t);if(i&&r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new Q(Z.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof Q?e:new Q(Z.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new X(Y.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`})}};function Q1(e){return{...e}}function $1(e,t){let n=0,r=[e];for(;r.length>0;){let e=r.pop();if(typeof e==`object`&&e){if(Array.isArray(e))for(let i of e){if(++n>t)return n;typeof i==`object`&&i&&r.push(i)}else for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;if(++n>t)return n;let a=e[i];typeof a==`object`&&a&&r.push(a)}}}return n}function e0(e){if(e!==void 0&&e!==1/0){if(typeof e!=`number`||Number.isNaN(e)||e<1)throw RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}var t0=class{server;_maxToolInputElements;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(t!==void 0&&t.enabled){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(t.inputSchema===void 0)return i0;try{let n=Wg(t.inputSchema,`input`);return this._toolInputSchemaJson[e]=n,n}catch{return}}}constructor(e,t){this.server=new Z1(e,t),this._maxToolInputElements=e0(t?.maxToolInputElements),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return H1(e)&&e.setScopeChallengeResolver(e=>this.resolveScopeChallenge(e)),await this.server.connect(e)}async close(){await this.server.close()}resolveScopeChallenge=e=>{switch(e.request.method){case`tools/call`:{let t=e.request.params?.name;if(typeof t!=`string`)return;let n=this._registeredTools[t];return n===void 0||!n.enabled?void 0:n.scopeChallenge?.(e)}case`resources/read`:{let t=e.request.params?.uri;if(typeof t!=`string`)return;let n;try{n=new URL(t)}catch{return}let r=this._registeredResources[n.toString()];if(r!==void 0)return r.enabled?r.scopeChallenge?.(e):void 0;for(let t of Object.values(this._registeredResourceTemplates))if(t.resourceTemplate.uriTemplate.match(n.toString()))return t.enabled?t.scopeChallenge?.(e):void 0;return}case`prompts/get`:{let t=e.request.params?.name;if(typeof t!=`string`)return;let n=this._registeredPrompts[t];return n===void 0||!n.enabled?void 0:n.scopeChallenge?.(e)}default:return}};_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||=(this.server.assertCanSetRequestHandler(`tools/list`),this.server.assertCanSetRequestHandler(`tools/call`),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler(`tools/list`,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?a0(e,t.inputSchema):i0,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(n.outputSchema=Wg(t.outputSchema,`output`)),n})})),this.server.setRequestHandler(`tools/call`,async(e,t)=>{let n=this._registeredTools[e.params.name];if(!n)throw new Q(Z.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new Q(Z.InvalidParams,`Tool ${e.params.name} disabled`);try{let r=await this.validateToolInput(n,e.params.arguments,e.params.name),i=await this.executeToolHandler(n,r,t);return await this.validateToolOutput(n,i,e.params.name),Dg(i)?i:this.server.projectCallToolResult(i,n.outputSchemaJson)}catch(e){if(e instanceof Q&&e.code===Z.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(this._maxToolInputElements!==void 0&&$1(t,this._maxToolInputElements)>this._maxToolInputElements)throw new Q(Z.InvalidParams,`Invalid arguments for tool ${n}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let r=await Jg(e.inputSchema,t??{});if(!r.success)throw new Q(Z.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${r.error}`);return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||Dg(t)||t.isError)return;if(t.structuredContent===void 0)throw new Q(Z.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await Jg(e.outputSchema,t.structuredContent);if(!r.success)throw new Q(Z.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${r.error}`)}async executeToolHandler(e,t,n){return e.executor(t,n)}_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`:return Og(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return kg(e),this.handleResourceCompletion(e,e.params.ref);default:throw new Q(Z.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new Q(Z.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new Q(Z.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return l0;let r=f0(u0(n.argsSchema)?.[e.params.argument.name]);if(!F1(r))return l0;let i=I1(r);return i?c0(await i(e.params.argument.value,e.params.context)):l0}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return l0;throw new Q(Z.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?c0(await r(e.params.argument.value,e.params.context)):l0}_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 n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),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 n;try{n=new URL(e.params.uri)}catch{throw new Q(Z.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:`invalid_uri`})}let r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new Q(Z.InvalidParams,`Resource ${n} disabled`);return Oh(await r.readCallback(n,t),r.cacheHint)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r){if(!e.enabled)throw new Q(Z.InvalidParams,`Resource template ${e.resourceTemplate.uriTemplate} disabled`);return Oh(await e.readCallback(n,r,t),e.cacheHint)}}throw new Nh(e.params.uri)}),!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])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?e_(t.argsSchema):void 0,icons:t.icons,_meta:t._meta}))})),this.server.setRequestHandler(`prompts/get`,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new Q(Z.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new Q(Z.InvalidParams,`Prompt ${e.params.name} disabled`);return n.handler(e.params.arguments,t)}),!0)}registerResource(e,t,n,r){let{cacheHint:i,scopeChallenge:a,...o}=n,s=o;if(i!==void 0&&Mh(i,`resource ${e}`),typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let o=this._createRegisteredResource(e,n.title,t,s,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,n.title,t,s,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,t,n,r,i,a){let o={name:e,title:t,metadata:r,readCallback:a,scopeChallenge:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=o)),e.name!==void 0&&(o.name=e.name),e.metadata!==void 0&&(o.metadata=e.metadata),e.title!==void 0&&(o.title=e.title,o.metadata={...o.metadata,title:e.title}),e.callback!==void 0&&(o.readCallback=e.callback),e.scopeChallenge!==void 0&&(o.scopeChallenge=e.scopeChallenge===null?void 0:e.scopeChallenge),e.enabled!==void 0&&(o.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=o,o}_createRegisteredResourceTemplate(e,t,n,r,i,a){let o={resourceTemplate:n,title:t,metadata:r,readCallback:a,scopeChallenge:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=o)),t.template!==void 0&&(o.resourceTemplate=t.template),t.metadata!==void 0&&(o.metadata=t.metadata),t.title!==void 0&&(o.title=t.title,o.metadata={...o.metadata,title:t.title}),t.callback!==void 0&&(o.readCallback=t.callback),t.scopeChallenge!==void 0&&(o.scopeChallenge=t.scopeChallenge===null?void 0:t.scopeChallenge),t.enabled!==void 0&&(o.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=o;let s=n.uriTemplate.variableNames;return Array.isArray(s)&&s.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(e,t,n,r,i,a,o,s){let c=r,l=i,u={title:t,description:n,argsSchema:r,icons:a,scopeChallenge:o,_meta:s,handler:s0(e,r,i),enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=u)),t.title!==void 0&&(u.title=t.title),t.description!==void 0&&(u.description=t.description),t.icons!==void 0&&(u.icons=t.icons),t.scopeChallenge!==void 0&&(u.scopeChallenge=t.scopeChallenge===null?void 0:t.scopeChallenge),t._meta!==void 0&&(u._meta=t._meta);let n=!1;t.argsSchema!==void 0&&(u.argsSchema=t.argsSchema,c=t.argsSchema,n=!0),t.callback!==void 0&&(l=t.callback,n=!0),n&&(u.handler=s0(e,c,l)),t.enabled!==void 0&&(u.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=u,r){let e=u0(r);e&&Object.values(e).some(e=>F1(f0(e)))&&this.setCompletionRequestHandler()}return u}_createRegisteredTool(e,t,n,r,i,a,o,s,c,l,u){z_(e);let d=u,f,p={title:t,description:n,inputSchema:r,outputSchema:i,get outputSchemaJson(){return f??=o0(p.outputSchema)},set outputSchemaJson(e){f=e},annotations:a,icons:o,execution:s,scopeChallenge:c,_meta:l,handler:u,executor:r0(r,u),enabled:!0,disable:()=>p.update({enabled:!1}),enable:()=>p.update({enabled:!0}),remove:()=>p.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&z_(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=p,e=t.name)),t.title!==void 0&&(p.title=t.title),t.description!==void 0&&(p.description=t.description);let n=!1;t.paramsSchema!==void 0&&(p.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],n=!0),t.callback!==void 0&&(p.handler=t.callback,d=t.callback,n=!0),n&&(p.executor=r0(p.inputSchema,d)),t.outputSchema!==void 0&&(p.outputSchema=t.outputSchema,p.outputSchemaJson=o0(t.outputSchema)),t.annotations!==void 0&&(p.annotations=t.annotations),t.icons!==void 0&&(p.icons=t.icons),t.scopeChallenge!==void 0&&(p.scopeChallenge=t.scopeChallenge===null?void 0:t.scopeChallenge),t._meta!==void 0&&(p._meta=t._meta),t.enabled!==void 0&&(p.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=p,this.setToolRequestHandlers(),this.sendToolListChanged(),p}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,icons:c,scopeChallenge:l,_meta:u}=t;return this._createRegisteredTool(e,r,i,J_(a),J_(o),s,c,void 0,l,u,n)}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a,icons:o,scopeChallenge:s,_meta:c}=t,l=this._createRegisteredPrompt(e,r,i,J_(a),n,o,s,c);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),l}isConnected(){return this.server.transport!==void 0}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()}},n0=class{_uriTemplate;constructor(e,t){this._callbacks=t,this._uriTemplate=typeof e==`string`?new W_(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}};function r0(e,t){if(e){let e=t;return async(t,n)=>e(t,n)}let n=t;return async(e,t)=>n(t)}var i0={type:`object`,properties:{}};function a0(e,t){let n=Wg(t,`input`),r=Ng(n);return 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}`),n}function o0(e){if(e!==void 0)try{return Wg(e,`output`)}catch{return}}function s0(e,t,n){if(t){let r=n;return async(n,i)=>{let a=await Jg(t,n??{});if(!a.success)throw new Q(Z.InvalidParams,`Invalid arguments for prompt ${e}: ${a.error}`);return r(a.data,i)}}{let e=n;return async(t,n)=>e(n)}}function c0(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}var l0={completion:{values:[],hasMore:!1}};function u0(e){let t=e;if(t.shape&&typeof t.shape==`object`)return t.shape}function d0(e){return e?.type===`optional`}function f0(e){return d0(e)?e.def?.innerType??e:e}var p0;function m0(e,t){return Y_(e,t??(p0??=new N1))}var h0=Em(void 0).inputSchema,g0=`__isBrowserMcpServer`;function _0(e){return typeof e==`object`&&!!e&&g0 in e&&e[g0]===!0}function v0(e){return`clientOrigin`in e&&(e.clientOrigin===void 0||typeof e.clientOrigin==`string`)&&(!(`onclientorigin`in e)||e.onclientorigin===void 0||typeof e.onclientorigin==`function`)}function y0(e){let t;try{t=JSON.parse(e)}catch{t=e}return om(t)?t:{content:[{type:`text`,text:typeof t==`string`?t:e}]}}function b0(e,t){return new Promise((n,r)=>{t.throwIfAborted();let i=()=>r(t.reason);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve().then(e).then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}function x0(e){return wm(e.inputSchema)?e.inputSchema:m0(e.inputSchema)}var S0=class extends EventTarget{[g0]=!0;mcpServer;native;ownerDocument;tools=new Map;peerOrigin;stopObservingPeerOrigin;registrations=new Set;nativeToolAbortControllers=new Map;nativeBackfilledTools=new Map;pendingTools=new Map;removingNativeTools=new Set;nativeSyncQueue=Promise.resolve();nativeToolChangeQueue=Promise.resolve();nativeToolChangeListener;closed=!1;closePromise;eventHandlers=new Map;eventHandlerListener=e=>{this.eventHandlers.get(e.type)?.call(this,e)};nativeLifecycleListener=e=>{if(this.closed)return;let t=new Event(e.type);`toolName`in e&&Object.defineProperty(t,"toolName",{enumerable:!0,value:e.toolName}),this.dispatchEvent(t)};constructor(e,t={}){super();let{native:n,...r}=t;!n&&!globalThis.document?.modelContext&&im(),this.mcpServer=new t0(e,{...r,capabilities:M_(r.capabilities??{},{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}})}),this.native=n??globalThis.document?.modelContext,this.ownerDocument=globalThis.document??null,this.nativeToolChangeListener=()=>{this.closed||(this.nativeToolChangeQueue=this.nativeToolChangeQueue.then(async()=>{try{await this.syncNativeTools()}catch(e){console.warn(`[BrowserMcpServer] Native WebMCP tool reconciliation failed:`,e)}await this.notifyProducerToolsChanged()}))},this.native?.addEventListener(`toolchange`,this.nativeToolChangeListener),this.native?.addEventListener(`toolactivated`,this.nativeLifecycleListener),this.native?.addEventListener(`toolcancel`,this.nativeLifecycleListener)}getEventHandler(e){return this.eventHandlers.get(e)??null}setEventHandler(e,t){typeof t==`function`?(this.eventHandlers.has(e)||super.addEventListener(e,this.eventHandlerListener),this.eventHandlers.set(e,t)):this.eventHandlers.delete(e)&&super.removeEventListener(e,this.eventHandlerListener)}get ontoolchange(){return this.getEventHandler(`toolchange`)}set ontoolchange(e){this.setEventHandler(`toolchange`,e)}get ontoolactivated(){return this.getEventHandler(`toolactivated`)}set ontoolactivated(e){this.setEventHandler(`toolactivated`,e)}get ontoolcancel(){return this.getEventHandler(`toolcancel`)}set ontoolcancel(e){this.setEventHandler(`toolcancel`,e)}async notifyProducerToolsChanged(){this.closed||(await new Promise(e=>setTimeout(e,0)),this.closed||this.dispatchEvent(new Event(`toolchange`)))}async registerNativeToolMirror(e,t,n,r,i){let a=this.native;if(!a)return;let o=n.signal?AbortSignal.any([n.signal,i.signal]):i.signal,s={name:e.name,description:e.description,execute:r};if(e.title!==void 0&&(s.title=e.title),t.registeredInputSchema!==void 0){let e=JSON.parse(t.registeredInputSchema);if(!om(e))throw TypeError(`inputSchema must be an object`);s.inputSchema=e}e.annotations&&(s.annotations=e.annotations),this.nativeToolAbortControllers.set(e.name,i);try{await a.registerTool(s,{...n,signal:o})}catch(t){if(i.abort(),this.nativeToolAbortControllers.get(e.name)===i&&this.nativeToolAbortControllers.delete(e.name),t instanceof DOMException&&t.name===`NotAllowedError`){console.warn(`[BrowserMcpServer] Tool "${e.name}" is available over MCP only: ${t.message}. Grant allow="tools" on the iframe to expose it to WebMCP.`);return}throw t}this.nativeToolAbortControllers.get(e.name)===i&&this.removingNativeTools.delete(e.name)}abortNativeToolMirror(e,t=this.nativeToolAbortControllers.get(e)){t&&this.nativeToolAbortControllers.get(e)===t&&(this.removingNativeTools.add(e),t.abort(),this.nativeToolAbortControllers.delete(e))}registerToolInMcp(e,t,n,r){let i={name:e.name,description:e.description,inputSchema:t.inputSchema};e.title!==void 0&&(i.title=e.title),e.outputSchema!==void 0&&(i.outputSchema=structuredClone(e.outputSchema)),e.annotations&&(i.annotations=e.annotations),e._meta!==void 0&&(i._meta=structuredClone(e._meta));let a={description:e.description};if(i.outputSchema!==void 0&&(a.outputSchema=m0(i.outputSchema)),i._meta!==void 0&&(a._meta=i._meta),e.title!==void 0&&(a.title=e.title),e.annotations){let{untrustedContentHint:t,...n}=e.annotations;a.annotations=n}let o;t.inputSchema.type===void 0||t.inputSchema.type===`object`?(a.inputSchema=x0(t),o=this.mcpServer.registerTool(e.name,a,async(t,r)=>{let i=await n(t,{signal:r.mcpReq.signal});if(Dg(i))throw Error(`WebMCP tool "${e.name}" returned input_required. Multi-round tool flows require BrowserMcpServer.mcpServer.registerTool().`);return bm(i)}),o.disable()):console.warn(`[BrowserMcpServer] Tool "${e.name}" remains available through WebMCP but cannot be exposed over MCP because MCP input schemas require an object root.`);let s={item:i,mcpHandle:o};return r?.length&&(s.exposedTo=r),s}registerTool=async(e,t={})=>{let{signal:n,exposedTo:r}=t??{},i={};if(n&&(i.signal=n),r&&(i.exposedTo=[...r]),this.closed)throw um(`BrowserMcpServer is closed`);if(!om(e))throw TypeError(`registerTool(tool) requires a tool object`);let a=lm(e);if(this.tools.has(a.name)&&!this.nativeBackfilledTools.has(a.name)||this.pendingTools.has(a.name))throw um(`Tool already registered: ${a.name}`);let o=Em(a.inputSchema);i.signal?.throwIfAborted();let s=a.execute,c=(e,t)=>b0(()=>s(e,t),t.signal),l=new AbortController,u=i.exposedTo?.map(e=>URL.parse(e)?.origin??e),d,f=()=>{this.pendingTools.get(a.name)===l&&this.pendingTools.delete(a.name),d&&this.tools.get(a.name)===d?this.removeTool(a.name):(d?.mcpHandle?.remove(),this.abortNativeToolMirror(a.name,l)),d=void 0};i.signal?.addEventListener(`abort`,f,{once:!0}),this.pendingTools.set(a.name,l);try{if(this.nativeBackfilledTools.has(a.name)||(d=this.registerToolInMcp(a,o,c,u)),i.signal?.throwIfAborted(),await this.registerNativeToolMirror(a,o,i,c,l),this.closed)throw um(`BrowserMcpServer is closed`);i.signal?.throwIfAborted(),this.removeTool(a.name,{skipNative:!0}),d??=this.registerToolInMcp(a,o,c,u),this.tools.set(a.name,d),this.applyToolExposure(),i.signal?.aborted&&(f(),i.signal.throwIfAborted())}catch(e){throw d?.mcpHandle?.remove(),this.abortNativeToolMirror(a.name,l),i.signal?.removeEventListener(`abort`,f),i.signal?.throwIfAborted(),e}finally{this.pendingTools.get(a.name)===l&&this.pendingTools.delete(a.name)}if(i.signal&&(d.abortSignal=i.signal,d.abortListener=f),this.tools.get(a.name)===d&&await this.nativeToolChangeQueue,this.closed)throw um(`BrowserMcpServer is closed`);i.signal?.throwIfAborted()};removeTool(e,t){let n=this.tools.get(e);n&&(n.abortSignal&&n.abortListener&&n.abortSignal.removeEventListener(`abort`,n.abortListener),this.tools.delete(e),this.nativeBackfilledTools.delete(e),n.mcpHandle?.remove()),t?.skipNative||this.abortNativeToolMirror(e)}syncNativeTools(){let e=this.native,t=this.nativeSyncQueue.then(async()=>{!this.closed&&e&&await this.backfillNativeStandardTools(e)});return this.nativeSyncQueue=t.then(()=>void 0,()=>void 0),t}async backfillNativeStandardTools(e){let t=this.ownerDocument?.defaultView,n=(await e.getTools()).filter(e=>{if(e.window===t)return!0;if(t?.parent!==t)return!1;let n=e.window;for(;n;){if(n===t)return!0;let e=n.parent;if(e===n)break;n=e}return!1});if(this.closed)return;for(let e of this.removingNativeTools)n.some(n=>n.name===e&&n.window===t)||this.removingNativeTools.delete(e);let r=new Map;for(let e of n){if(r.has(e.name)||this.pendingTools.has(e.name)||this.removingNativeTools.has(e.name))continue;let t;try{t=JSON.parse(fm(e.inputSchema??h0))}catch{}if(!om(t)){console.warn(`[BrowserMcpServer] Native tool "${e.name}" was not exposed over MCP because its input schema is malformed.`);continue}let n={name:e.name,description:e.description,inputSchema:t};e.title!==void 0&&(n.title=e.title),e.annotations&&(n.annotations=e.annotations),r.set(e.name,{source:e,item:n,fingerprint:JSON.stringify(n)})}for(let[e,t]of this.nativeBackfilledTools){let n=r.get(e);n?.fingerprint===t.fingerprint?this.nativeBackfilledTools.set(e,n):this.removeTool(e,{skipNative:!0})}for(let[t,n]of r){if(this.tools.has(t))continue;let r=async(n,r)=>{let i=this.nativeBackfilledTools.get(t)?.source;if(!i)throw Error(`Native tool not found: ${t}`);try{return y0(await e.executeTool(i,n,r))}catch(e){throw i.window.closed&&this.nativeToolChangeListener(),e}},i={...n.item,execute:r};try{let e=Em(i.inputSchema);this.tools.set(t,this.registerToolInMcp(i,e,r)),this.nativeBackfilledTools.set(t,n)}catch(e){console.warn(`[BrowserMcpServer] Native tool "${t}" was not exposed over MCP because its schema could not be compiled:`,e)}}this.applyToolExposure()}registerResource(e){if(this.closed)throw um(`BrowserMcpServer is closed`);let t={...e},n={};t.description!==void 0&&(n.description=t.description),t.mimeType!==void 0&&(n.mimeType=t.mimeType);let r=t.uri.includes(`{`)?new n0(t.uri,{list:void 0}):void 0,i=r?this.mcpServer.registerResource(t.name,r,n,async(e,n)=>t.read(e,n)):this.mcpServer.registerResource(t.name,t.uri,n,async e=>t.read(e));return this.registrations.add(i),{unregister:()=>{this.registrations.delete(i)&&i.remove()}}}registerPrompt(e){if(this.closed)throw um(`BrowserMcpServer is closed`);let t={...e};e.argsSchema!==void 0&&(t.argsSchema=structuredClone(e.argsSchema));let n=t.argsSchema===void 0?void 0:m0(t.argsSchema),r={};t.description!==void 0&&(r.description=t.description),n&&(r.argsSchema=n);let i=this.mcpServer.registerPrompt(t.name,r,async e=>t.get(e??{}));return this.registrations.add(i),{unregister:()=>{this.registrations.delete(i)&&i.remove()}}}listTools(){return structuredClone([...this.tools.values()].map(({item:e})=>e))}async getTools(e){if(this.closed)throw um(`BrowserMcpServer is closed`);if(!this.native)throw um(`BrowserMcpServer has no WebMCP context`);return this.native.getTools(e)}async executeTool(...e){if(this.closed)throw um(`BrowserMcpServer is closed`);if(!this.native)throw um(`BrowserMcpServer has no WebMCP context`);return this.native.executeTool(...e)}applyToolExposure(){for(let{exposedTo:e,mcpHandle:t}of this.tools.values()){if(!t)continue;let n=!e?.length||this.peerOrigin!==void 0&&this.peerOrigin!==`null`&&e.includes(this.peerOrigin);n!==t.enabled&&(n?t.enable():t.disable())}}observePeerOrigin(e){if(this.stopObservingPeerOrigin?.(),this.stopObservingPeerOrigin=void 0,this.peerOrigin=void 0,this.applyToolExposure(),!v0(e))return;let t=e;this.peerOrigin=t.clientOrigin,this.applyToolExposure();let n=t.onclientorigin,r=!0,i=e=>{n?.(e),r&&(this.peerOrigin=e,this.applyToolExposure())};t.onclientorigin=i,this.stopObservingPeerOrigin=()=>{r=!1,t.onclientorigin===i&&(t.onclientorigin=n)}}async connect(e){if(this.closed)throw um(`BrowserMcpServer is closed`);if(this.mcpServer.server.transport)throw um(`BrowserMcpServer is already connected`);this.observePeerOrigin(e);let t=this.stopObservingPeerOrigin;try{await this.mcpServer.connect(e)}catch(n){throw this.stopObservingPeerOrigin===t&&(t?.(),this.stopObservingPeerOrigin=void 0,this.peerOrigin=void 0,this.applyToolExposure()),this.mcpServer.server.transport===e&&await this.mcpServer.close(),n}}close(){return this.closePromise||=(this.closed=!0,this.stopObservingPeerOrigin?.(),this.stopObservingPeerOrigin=void 0,(async()=>{this.native?.removeEventListener(`toolchange`,this.nativeToolChangeListener),this.native?.removeEventListener(`toolactivated`,this.nativeLifecycleListener),this.native?.removeEventListener(`toolcancel`,this.nativeLifecycleListener);for(let e of this.nativeToolAbortControllers.keys())this.abortNativeToolMirror(e);for(let e of this.tools.keys())this.removeTool(e);for(let e of this.registrations)e.remove();this.registrations.clear(),this.nativeBackfilledTools.clear(),this.removingNativeTools.clear(),await this.mcpServer.close()})()),this.closePromise}},C0=null;function w0(e){if(window.parent!==window&&e?.iframeServer!==!1)return new yf(e?.iframeServer||{allowedOrigins:[`*`]});if(e?.tabServer===!1)throw Error(`tabServer transport is disabled and iframe transport was not selected`);return new bf(e?.tabServer||{allowedOrigins:[`*`]})}function T0(e){if(!globalThis.window||!globalThis.document||globalThis.isSecureContext===!1||C0||_0(document.modelContext))return;im();let t=document.modelContext;if(!t)throw Error(`modelContext is not available`);let n=Object.getOwnPropertyDescriptor(document,`modelContext`);if(n?!n.configurable:!Object.isExtensible(document))return;let r=w0(e?.transport),i=new S0({name:`${window.location.hostname||`localhost`}-webmcp`,version:`1.0.0`},{native:t});try{Object.defineProperty(document,"modelContext",{configurable:!0,enumerable:!0,writable:!1,value:i}),C0={server:i,transport:r,previousDescriptor:n}}catch(e){throw i.close(),r.close(),e}(async()=>{try{await i.syncNativeTools()}catch(e){console.warn(`[WebModelContext] Native WebMCP tool synchronization failed:`,e)}if(C0?.server===i)try{await i.connect(r)}catch(e){console.error(`[WebModelContext] Failed to connect MCP transport:`,e),C0?.server===i&&E0()}})()}function E0(){if(!C0)return;let{server:e,transport:t,previousDescriptor:n}=C0;C0=null,e.close(),t.close(),n?Object.defineProperty(document,"modelContext",n):Reflect.deleteProperty(document,`modelContext`)}var D0=globalThis.window?.__webModelContextOptions;if(D0?.autoInitialize!==!1)try{T0(D0)}catch(e){console.error(`[WebModelContext] Auto-initialization failed:`,e)}export{E0 as cleanupWebModelContext,T0 as initializeWebModelContext};
|