@zlooks.cn/gateway-server 1.0.8 → 1.0.9
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/[pluginId]/[[...path]]/page.js +1 -1
- package/.next/server/app/[pluginId]/[[...path]]/page.js.nft.json +1 -1
- package/.next/server/app/[pluginId]/[[...path]]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/favicon.ico/route.js +1 -1
- package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next/server/app/page.js +65 -65
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/robots.txt/route.js +1 -1
- package/.next/server/app/robots.txt/route.js.nft.json +1 -1
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/{748.js → 111.js} +5 -5
- package/.next/server/chunks/276.js +1 -1
- package/.next/server/chunks/448.js +1 -1
- package/.next/server/chunks/47.js +1 -0
- package/.next/server/chunks/551.js +2 -0
- package/.next/server/chunks/{486.js → 733.js} +3 -3
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{269-8aa7eb951aba0024.js → 195-d082e7c7c29748e6.js} +1 -1
- package/.next/static/chunks/300-f710e304736538be.js +1 -0
- package/.next/static/chunks/app/[pluginId]/[[...path]]/page-43d50eeb765492ea.js +1 -0
- package/.next/static/chunks/app/{layout-f0b86ab9dd5accbc.js → layout-f0bed6be746ab51e.js} +1 -1
- package/.next/static/chunks/app/page-951d4daaa72eacbe.js +1 -0
- package/.next/static/css/124beab9989d874a.css +1 -0
- package/.next/trace +22 -22
- package/.next/trace-build +1 -1
- package/dist/command/index.js +2 -6
- package/dist/command/index.js.map +1 -1
- package/package.json +14 -14
- package/.next/server/chunks/793.js +0 -2
- package/.next/server/chunks/872.js +0 -1
- package/.next/static/chunks/275-bddb27d29e7e51af.js +0 -1
- package/.next/static/chunks/app/[pluginId]/[[...path]]/page-30ed03df8541cd76.js +0 -1
- package/.next/static/chunks/app/page-fa81d6b33c269d0c.js +0 -1
- package/.next/static/css/5e1fe404799cdc12.css +0 -1
- /package/.next/static/{rwKTkmXmP-fXOvY9TPxU4 → 49ul1kLYWLjp7R9hn91mE}/_buildManifest.js +0 -0
- /package/.next/static/{rwKTkmXmP-fXOvY9TPxU4 → 49ul1kLYWLjp7R9hn91mE}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
"use strict";exports.id=486,exports.ids=[486],exports.modules={7088:(a,b,c)=>{c.d(b,{u:()=>A});var d=c(60339);c(81630),c(73496);var e=c(27910),f=c(55511),g=global.Request,h=class extends g{constructor(a,b){"object"==typeof a&&j in a&&(a=a[j]()),void 0!==b?.body?.getReader&&(b.duplex??="half"),super(a,b)}},i=Symbol("wrapBodyStream"),j=Symbol("getRequestCache"),k=Symbol("requestCache"),l=Symbol("incomingKey"),m=Symbol("urlKey"),n=Symbol("headersKey"),o=Symbol("abortControllerKey"),p=Symbol("getAbortController"),q={get method(){return this[l].method||"GET"},get url(){return this[m]},get headers(){return this[n]||=(a=>{let b=[],c=a.rawHeaders;for(let a=0;a<c.length;a+=2){let{[a]:d,[a+1]:e}=c;58!==d.charCodeAt(0)&&b.push([d,e])}return new Headers(b)})(this[l])},[p](){return this[j](),this[o]},[j](){return this[o]||=new AbortController,this[k]||=((a,b,c,d,f)=>{let g={method:a,headers:c,signal:f.signal};if("TRACE"===a){g.method="GET";let a=new h(b,g);return Object.defineProperty(a,"method",{get:()=>"TRACE"}),a}if("GET"!==a&&"HEAD"!==a)if("rawBody"in d&&d.rawBody instanceof Buffer)g.body=new ReadableStream({start(a){a.enqueue(d.rawBody),a.close()}});else if(d[i]){let a;g.body=new ReadableStream({async pull(b){try{a||=e.Readable.toWeb(d).getReader();let{done:c,value:f}=await a.read();c?b.close():b.enqueue(f)}catch(a){b.error(a)}}})}else g.body=e.Readable.toWeb(d);return new h(b,g)})(this.method,this[m],this.headers,this[l],this[o])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(a=>{Object.defineProperty(q,a,{get(){return this[j]()[a]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(a=>{Object.defineProperty(q,a,{value:function(){return this[j]()[a]()}})}),Object.defineProperty(q,Symbol.for("nodejs.util.inspect.custom"),{value:function(a,b,c){let d={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[k]};return`Request (lightweight) ${c(d,{...b,depth:null==a?null:a-1})}`}}),Object.setPrototypeOf(q,h.prototype);var r=Symbol("responseCache"),s=Symbol("getResponseCache"),t=Symbol("cache"),u=global.Response,v=class a{#a;#b;[s](){return delete this[t],this[r]||=new u(this.#a,this.#b)}constructor(b,c){let d;if(this.#a=b,c instanceof a){const a=c[r];if(a){this.#b=a,this[s]();return}this.#b=c.#b,d=new Headers(c.#b.headers)}else this.#b=c;("string"==typeof b||void 0!==b?.getReader||b instanceof Blob||b instanceof Uint8Array)&&(this[t]=[c?.status||200,b,d||c?.headers])}get headers(){let a=this[t];return a?(a[2]instanceof Headers||(a[2]=new Headers(a[2]||{"content-type":"text/plain; charset=UTF-8"})),a[2]):this[s]().headers}get status(){return this[t]?.[0]??this[s]().status}get ok(){let a=this.status;return a>=200&&a<300}};function w(a){return Array.isArray(a)?a[0]:a}async function x(a,b,c){let d,e=(a.method??"GET").toUpperCase(),f=`http://${w(a.headers.host)??w(a.headers[":authority"])??"localhost"}${a.url??"/"}`,g=new Headers;for(let[b,c]of Object.entries(a.headers))if(!(void 0===c||b.startsWith(":")))if(Array.isArray(c))for(let a of c)g.append(b,a);else g.set(b,c);if("GET"!==e&&"HEAD"!==e)if(void 0===b){let b=new TextDecoder,c="";for await(let d of a)c+="string"==typeof d?d:b.decode(d,{stream:!0});(c+=b.decode()).length>0&&(d=c)}else{let a=JSON.stringify(b);g.delete("content-encoding"),g.delete("transfer-encoding"),void 0===a?g.delete("content-length"):(d=a,g.set("content-length",String(new TextEncoder().encode(a).byteLength)))}return new Request(f,{method:e,headers:g,...c?.signal!==void 0&&{signal:c.signal},...void 0!==d&&{body:d}})}["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(a=>{Object.defineProperty(v.prototype,a,{get(){return this[s]()[a]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(a=>{Object.defineProperty(v.prototype,a,{value:function(){return this[s]()[a]()}})}),Object.defineProperty(v.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(a,b,c){let d={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[r]};return`Response (lightweight) ${c(d,{...b,depth:null==a?null:a-1})}`}}),Object.setPrototypeOf(v,u),Object.setPrototypeOf(v.prototype,u.prototype),void 0===global.crypto&&(global.crypto=f),Symbol("outgoingEnded"),Symbol("incomingDraining");var y=c(52179),z=c(96022);function A(a,b){var c,e;let f;if(!b||"string"!=typeof b.path||!/^\/(?:[^/?#]+(?:\/[^/?#]+)*)?$/.test(b.path))throw TypeError("MCP endpoint path must be an absolute path without query, fragment, or empty segments");let g=b.security,h=a=>Array.isArray(a)&&a.length>0&&a.every(a=>"string"==typeof a&&a.length>0);if(!g||!h(g.allowedHostnames)||!h(g.allowedOriginHostnames))throw TypeError("MCP HTTP allowedHostnames and allowedOriginHostnames must be explicit and non-empty");if(!g.authentication||!["public","required","oauth"].includes(g.authentication.mode)||"required"===g.authentication.mode&&"function"!=typeof g.authentication.authenticate)throw TypeError("MCP HTTP authentication mode must be explicit");if("oauth"===g.authentication.mode){if("function"!=typeof g.authentication.verifier?.verifyAccessToken||!g.authentication.metadata)throw TypeError("MCP OAuth verifier and metadata must be provided");if(g.authentication.metadata.resourceServerUrl.pathname!==b.path)throw TypeError("MCP OAuth resourceServerUrl path must match the endpoint path");if(void 0!==g.authentication.requiredScopes&&(!Array.isArray(g.authentication.requiredScopes)||g.authentication.requiredScopes.some(a=>"string"!=typeof a||!a)))throw TypeError("MCP OAuth requiredScopes must contain non-empty strings")}if(void 0!==b.legacy&&!["stateless","reject"].includes(b.legacy))throw TypeError("Invalid MCP legacy mode");if(void 0!==b.onError&&"function"!=typeof b.onError)throw TypeError("MCP HTTP onError must be a function");if(void 0!==b.keepAliveMs&&(0,z.y)(b.keepAliveMs,"MCP keepAliveMs"),void 0!==b.maxSubscriptions&&(!Number.isSafeInteger(b.maxSubscriptions)||b.maxSubscriptions<=0))throw TypeError("MCP maxSubscriptions must be a positive integer");let i=[...g.allowedHostnames],j=[...g.allowedOriginHostnames],k=g.authentication.mode,l="required"===g.authentication.mode?g.authentication.authenticate:void 0,m="oauth"===g.authentication.mode?g.authentication:void 0,n=m?Object.freeze({...m.metadata,resourceServerUrl:new URL(m.metadata.resourceServerUrl),serviceDocumentationUrl:m.metadata.serviceDocumentationUrl?new URL(m.metadata.serviceDocumentationUrl):void 0,oauthMetadata:structuredClone(m.metadata.oauthMetadata),scopesSupported:m.metadata.scopesSupported?[...m.metadata.scopesSupported]:void 0}):void 0;n&&(0,d.hw)(n);let o=n?new URL((0,d.QK)(n.resourceServerUrl)).pathname:void 0,p=m?(0,d.PA)({verifier:m.verifier,requiredScopes:m.requiredScopes?[...m.requiredScopes]:void 0,resourceMetadataUrl:(0,d.QK)(n.resourceServerUrl)}):void 0,q=(0,d.p0)((0,y.O7)(a),{legacy:b.legacy,responseMode:b.responseMode,keepAliveMs:b.keepAliveMs,maxSubscriptions:b.maxSubscriptions,onerror:b.onError}),r=(0,y.Mi)(a,a=>{for(let b of(a.tools&&q.notify.toolsChanged(),a.resources&&q.notify.resourcesChanged(),a.prompts&&q.notify.promptsChanged(),a.resourceUpdates))q.notify.resourceUpdated(b)}),s=(c={async fetch(a){let b=(0,d.IK)(a,i)??(0,d.ld)(a,j);if(b)return b;let c=n?(0,d.yH)(a,n):void 0;if(c)return c;let e="required"===k?await l(a):"oauth"===k?await p(a):void 0;return e instanceof Response?e:q.fetch(a,{authInfo:e})}},e={onerror:b.onError},async(a,b,d)=>{let f,g;"function"==typeof d&&(d=void 0);let h=!1,i=new AbortController;b.on("close",()=>{h||i.abort()}),!0===b.destroyed&&i.abort();try{let b=await x(a,d,{signal:i.signal});f=await c.fetch(b,{...void 0!==a.auth&&{authInfo:a.auth},...void 0!==d&&{parsedBody:d}})}catch(a){var j;try{e?.onerror?.(a instanceof Error?a:Error(String(a)))}catch{}j=function(a){if(null===a||"object"!=typeof a||Array.isArray(a))return null;let{method:b,id:c}=a;return"string"!=typeof b?null:"string"==typeof c||"number"==typeof c?c:null}(d),f=Response.json({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:j},{status:500})}let k={};for(let[a,b]of f.headers)k[a]=b;if(b.writeHead(f.status,k),null===f.body){h=!0,b.end();return}b.on("drain",()=>{g?.(),g=void 0});let l=new Promise(a=>{i.signal.addEventListener("abort",()=>a(),{once:!0})});try{for await(let a of f.body){if(i.signal.aborted)break;!1===b.write(a)&&await Promise.race([new Promise(a=>{g=a}),l])}}catch{}h=!0,b.end()}),t=!0,u=!0,v=async()=>{let a=[];if(t)try{r(),t=!1}catch(b){a.push(b)}if(u)try{await q.close(),u=!1}catch(b){a.push(b)}if(a.length)throw AggregateError(a,"Failed to close MCP HTTP endpoint")};return{async middleware(a,c){if(a.path!==b.path&&a.path!==o&&!(m&&"/.well-known/oauth-authorization-server"===a.path))return c();a.respond=!1,await s(a.req,a.res)},close:()=>(f||(f=v().finally(()=>{f=void 0})),f)}}},8669:(a,b,c)=>{c.d(b,{N:()=>d});class d extends Error{code;constructor(a,b,c){super(b,c),this.code=a,this.name="HileMcpError"}}},16628:(a,b,c)=>{c.d(b,{nR:()=>z,iw:()=>n}),c(77598);let d="@hile/rsc",e="@hile/rsc/discovery/v1/",f=new TextEncoder;function g(a){return"trusted-internal"===a.scheme&&!("keyId"in a)}function h(a,b){let c=a[b];if("string"!=typeof c||0===c.length||f.encode(c).byteLength>4096)throw TypeError(`RSC discovery ${b} must not be empty or oversized`);return c}function i(a){if(null===a||"object"!=typeof a||Array.isArray(a))throw TypeError("RSC discovery announcement must be an object");if(1!==a.schemaVersion)throw TypeError("RSC discovery schemaVersion is unsupported");if(a.capability!==d)throw TypeError("RSC discovery capability is unsupported");if(1!==a.protocolVersion)throw TypeError("RSC discovery protocolVersion is unsupported");if(!Number.isSafeInteger(a.priority))throw TypeError("RSC discovery priority must be a safe integer");if(void 0!==a.generation&&(!Number.isSafeInteger(a.generation)||a.generation<0))throw TypeError("RSC discovery generation must be a non-negative safe integer");let b=h(a,"artifactOperation");if(!b.startsWith("/")||b.includes(".."))throw TypeError("RSC discovery artifactOperation must be an absolute safe operation");let c=a.runtime;if(null===c||"object"!=typeof c||Array.isArray(c))throw TypeError("RSC discovery runtime must be an object");let e=a.authentication;if(null===e||"object"!=typeof e||Array.isArray(e))throw TypeError("RSC discovery authentication must be an object");let f=h(e,"scheme");if("trusted-internal"===f&&(void 0!==e.keyId||void 0!==e.signature||void 0!==e.generationSignature))throw TypeError("RSC trusted-internal discovery authentication must not carry signing fields");return{schemaVersion:1,capability:d,instanceId:h(a,"instanceId"),pluginId:h(a,"pluginId"),buildId:h(a,"buildId"),namespace:h(a,"namespace"),priority:a.priority,...void 0===a.generation?{}:{generation:a.generation},protocolVersion:1,runtime:{react:h(c,"react"),reactDom:h(c,"reactDom"),rsc:h(c,"rsc")},artifactOperation:b,authentication:"trusted-internal"===f?{scheme:"trusted-internal"}:{scheme:f,keyId:h(e,"keyId"),signature:h(e,"signature"),...void 0===e.generationSignature?{}:{generationSignature:h(e,"generationSignature")}}}}function j(a){if(!a)throw TypeError("RSC discovery instanceId must not be empty");return`${e}${encodeURIComponent(a)}`}function k(a){return[...a].sort((a,b)=>b.priority-a.priority||(b.generation??0)-(a.generation??0)||b.buildId.localeCompare(a.buildId)||a.namespace.localeCompare(b.namespace)||a.instanceId.localeCompare(b.instanceId))[0]}let l=new WeakMap;class m{active=new Map;pendingRetirements=[];deploy;retire;replace;missingReconciliations;select;generationHighWater;generationHistorySize;generationStoreOwner=Symbol("RscDiscoveryManager");queue=Promise.resolve();closed=!1;closePromise;constructor(a){if(this.deploy=a.deploy,this.retire=a.retire,this.replace=a.replace,this.missingReconciliations=a.missingReconciliations??3,!Number.isSafeInteger(this.missingReconciliations)||this.missingReconciliations<1)throw TypeError("missingReconciliations must be a positive safe integer");if(this.select=a.select??k,this.generationHighWater=a.generationHighWater??new Map,this.generationHistorySize=a.generationHistorySize??4096,!Number.isSafeInteger(this.generationHistorySize)||this.generationHistorySize<1)throw TypeError("generationHistorySize must be a positive safe integer");if(this.generationHighWater.size>this.generationHistorySize)throw TypeError("generationHighWater exceeds generationHistorySize");if(l.has(this.generationHighWater))throw Error("generationHighWater is already in use by another discovery manager");l.set(this.generationHighWater,this.generationStoreOwner)}generationKey(a){return JSON.stringify([g(a.authentication)?a.authentication.scheme:a.authentication.keyId,a.pluginId,a.instanceId])}acceptedGeneration(a){return this.generationHighWater.get(this.generationKey(a))}generationFingerprint(a){return JSON.stringify(a)}recordGeneration(a){let b=this.generationKey(a),c=a.generation??0,d=this.generationHighWater.get(b);if(void 0!==d&&(d.generation>c||d.generation===c&&d.announcement===this.generationFingerprint(a))){this.generationHighWater.delete(b),this.generationHighWater.set(b,d);return}if(void 0===d&&this.generationHighWater.size>=this.generationHistorySize)throw Error("RSC discovery generation history capacity exhausted");this.generationHighWater.delete(b),this.generationHighWater.set(b,{generation:c,announcement:this.generationFingerprint(a),active:!0})}tombstoneGeneration(a){let b=this.generationKey(a),c=this.generationHighWater.get(b);c&&c.generation===(a.generation??0)&&c.announcement===this.generationFingerprint(a)&&this.generationHighWater.set(b,{...c,active:!1})}isLegacyPromotion(a,b){let c;if(g(a.authentication)||!b.active||0!==b.generation||0!==a.generation||void 0===a.authentication.generationSignature)return!1;try{c=JSON.parse(b.announcement)}catch{return!1}if(void 0!==c.generation)return!1;let{generation:d,authentication:e,...f}=a,{generationSignature:h,...i}=e;return JSON.stringify({...f,authentication:i})===b.announcement}reconcile(a){if(this.closed)return Promise.reject(Error("RSC discovery manager is closed"));let b=a.map(i),c=async()=>this.apply(b),d=this.queue.then(c,c);return this.queue=d.catch(()=>void 0),d}async apply(a){let b=[];if(this.pendingRetirements.length)for(let a of this.pendingRetirements.splice(0))try{await this.retire(a)}catch(c){this.pendingRetirements.push(a),b.push(c)}let c=new Set,d=new Map;for(let b of a){if(c.has(b.instanceId))throw TypeError(`Duplicate RSC discovery instanceId: ${b.instanceId}`);c.add(b.instanceId);let a=d.get(b.pluginId)??[];a.push(b),d.set(b.pluginId,a)}for(let a of[...new Set([...this.active.keys(),...d.keys()])].sort())try{let c,f=this.active.get(a),g=d.get(a);if(!g?.length){if(!f)continue;f.missing++,f.missing>=this.missingReconciliations&&(await this.retire(f.deployment),this.tombstoneGeneration(f.deployment.announcement),this.active.delete(a));continue}let h=[],j=g.filter(a=>{let b=this.acceptedGeneration(a);if(void 0===b&&this.generationHighWater.size>=this.generationHistorySize)return h.push(Error("RSC discovery generation history capacity exhausted")),!1;let c=a.generation??0;return!!(void 0===b||c>b.generation||this.isLegacyPromotion(a,b))||c===b.generation&&!!b.active&&this.generationFingerprint(a)===b.announcement||(h.push(Error(`RSC discovery generation rollback rejected: ${a.pluginId}/${a.instanceId} ${c} is not newer than accepted generation ${b.generation}`)),!1)});if(!j.length){b.push(...h),f&&(f.missing++,f.missing>=this.missingReconciliations&&(await this.retire(f.deployment),this.tombstoneGeneration(f.deployment.announcement),this.active.delete(a)));continue}let k=[];for(;j.length;){var e;let b=i(this.select(j.map(a=>structuredClone(a)))),d=j.findIndex(a=>a.instanceId===b.instanceId);if(b.pluginId!==a||d<0)throw TypeError("RSC discovery selection policy returned an unknown candidate");if(f&&(e=f.deployment.announcement,e.pluginId===b.pluginId&&e.buildId===b.buildId&&e.namespace===b.namespace)){let a=f.deployment.announcement;f.missing=0,f.deployment.announcement=structuredClone(b),this.recordGeneration(b),g.some(b=>this.generationFingerprint(b)===this.generationFingerprint(a))||this.tombstoneGeneration(a),c=f.deployment;break}if(f&&this.replace&&f.deployment.announcement.pluginId===b.pluginId&&f.deployment.announcement.buildId===b.buildId){c=await this.replace(f.deployment,b),this.recordGeneration(b);break}try{let a=await this.deploy(b);this.recordGeneration(b),c=a;break}catch(a){k.push(a),j.splice(d,1)}}if(!c)throw AggregateError(k,`No deployable RSC discovery candidate: ${a}`);if(f&&c===f.deployment)continue;if(this.active.set(a,{deployment:c,missing:0}),f&&!g.some(a=>this.generationFingerprint(a)===this.generationFingerprint(f.deployment.announcement))&&this.tombstoneGeneration(f.deployment.announcement),f&&f.deployment.announcement.buildId!==c.announcement.buildId)try{await this.retire(f.deployment)}catch(a){throw this.pendingRetirements.push(f.deployment),a}}catch(a){b.push(a)}if(b.length){let a=b.map(a=>a instanceof Error?a.message:String(a)).join("; ");throw AggregateError(b,`RSC discovery reconciliation failed: ${a}`)}}snapshot(){return[...this.active.values()].map(({deployment:a,missing:b})=>({pluginId:a.announcement.pluginId,buildId:a.announcement.buildId,namespace:a.announcement.namespace,instanceId:a.announcement.instanceId,priority:a.announcement.priority,...void 0===a.announcement.generation?{}:{generation:a.announcement.generation},state:b>0?"unavailable":"enabled",missingReconciliations:b})).sort((a,b)=>a.pluginId.localeCompare(b.pluginId))}async close(){if(this.closePromise)return this.closePromise;this.closed=!0;let a=(async()=>{await this.queue;let a=new Set([...this.pendingRetirements,...[...this.active.values()].reverse().map(({deployment:a})=>a)]),b=[];for(let c of a)try{await this.retire(c);let a=this.pendingRetirements.indexOf(c);a>=0&&this.pendingRetirements.splice(a,1);let b=this.active.get(c.announcement.pluginId);b?.deployment===c&&this.active.delete(c.announcement.pluginId)}catch(a){this.pendingRetirements.includes(c)||this.pendingRetirements.push(c),b.push(a)}if(b.length)throw AggregateError(b,"RSC discovery shutdown failed");l.get(this.generationHighWater)===this.generationStoreOwner&&l.delete(this.generationHighWater)})();return this.closePromise=a.catch(a=>{throw this.closePromise=void 0,a}),this.closePromise}}function n(){return a=>g(a.authentication)}var o=c(73024),p=c(51455),q=c(48161),r=c(76760),s=c(46466),t=c(18509),u=c(31343),v=c(26147);async function w(a,b,c){if(!c?.context)throw new t.gV("RSC artifact download");let d=(0,t.xe)(c.context),e=i(b),f=c.maxManifestBytes??1048576;if(!Number.isSafeInteger(f)||f<1)throw TypeError("maxManifestBytes must be positive");let g=c.maxFileBytes??0x4000000,h=c.maxTotalBytes??0x10000000;if(!Number.isSafeInteger(g)||g<1)throw TypeError("maxFileBytes must be positive");if(!Number.isSafeInteger(h)||h<1)throw TypeError("maxTotalBytes must be positive");let j=c.maxArtifactFiles??4096,k=c.maxPathBytes??1024,l=c.maxPathDepth??32;for(let[a,b]of Object.entries({maxArtifactFiles:j,maxPathBytes:k,maxPathDepth:l}))if(!Number.isSafeInteger(b)||b<1)throw TypeError(`${a} must be positive`);let m=await (0,p.mkdtemp)(r.join((0,q.tmpdir)(),"hile-rsc-discovered-"));try{let b,i=await a.stream(e.namespace,e.artifactOperation,{pluginId:e.pluginId,buildId:e.buildId,path:"plugin.json"},{context:d,signal:c.signal}),n=0,q=async function*(){for await(let a of i){if(!(a instanceof Uint8Array))throw TypeError("RSC artifact stream must yield Uint8Array chunks");if((n+=a.byteLength)>f)throw Error("RSC artifact manifest size limit exceeded");yield a}};await (0,s.pipeline)(q(),(0,o.createWriteStream)(r.join(m,"plugin.json"),{flags:"wx"}));try{b=JSON.parse(await (0,p.readFile)(r.join(m,"plugin.json"),"utf8"))}catch{throw TypeError("RSC artifact manifest must be valid JSON")}let t=(0,v.z_)(b,c.runtime);if(t.pluginId!==e.pluginId||t.buildId!==e.buildId)throw Error(`RSC discovery identity mismatch: announcement=${e.pluginId}@${e.buildId}, manifest=${t.pluginId}@${t.buildId}`);let w=[...(0,u.getRscPluginArtifactFiles)(t).keys()].sort();if(w.length>j)throw Error("RSC artifact file count limit exceeded");for(let a of w)if(Buffer.byteLength(a)>k||a.split("/").length>l)throw Error(`RSC artifact path complexity limit exceeded: ${a}`);let x=n;for(let b of w){let f=await a.stream(e.namespace,e.artifactOperation,{pluginId:t.pluginId,buildId:t.buildId,path:b},{context:d,signal:c.signal}),i=0,j=async function*(){for await(let a of f){if(!(a instanceof Uint8Array))throw TypeError("RSC artifact stream must yield Uint8Array chunks");if(i+=a.byteLength,x+=a.byteLength,i>g||x>h)throw Error(`RSC artifact size limit exceeded: ${b}`);yield a}},k=r.join(m,b);await (0,p.mkdir)(r.dirname(k),{recursive:!0}),await (0,s.pipeline)(j(),(0,o.createWriteStream)(k,{flags:"wx"}))}let y=await (0,u.verifyRscPluginArtifact)(m,c.runtime);return{artifactRoot:m,manifest:y.manifest,cleanup:()=>(0,p.rm)(m,{recursive:!0,force:!0})}}catch(a){throw await (0,p.rm)(m,{recursive:!0,force:!0}),a}}var x=c(75533);async function y(a,b={}){let c=b.concurrency??16;if(!Number.isSafeInteger(c)||c<1||c>64)throw TypeError("RSC discovery reader concurrency must be an integer between 1 and 64");b.signal?.throwIfAborted();let d=await a.listRegistryTopics(e,{signal:b.signal}),f=[],g=[],h=[...d].filter(({hasData:a})=>a).sort((a,b)=>a.topic.localeCompare(b.topic)),k=Array(h.length),l=0,m=async()=>{for(;l<h.length;){b.signal?.throwIfAborted();let c=l++,d=h[c];try{let e=await a.getRegistryTopic(d.topic,{signal:b.signal});if(!e?.hasData)continue;let f=i(e.payload);if(j(f.instanceId)!==d.topic)throw TypeError("RSC discovery topic does not match instanceId");k[c]=f}catch(a){k[c]={error:a}}}};for(let[a,d]of(await Promise.all(Array.from({length:Math.min(c,h.length)},()=>m())),b.signal?.throwIfAborted(),k.entries()))d&&("error"in d?g.push({topic:h[a].topic,error:d.error}):f.push(d));return{announcements:f,rejected:g}}class z{options;deployments;discovery;timer;refreshPromise;snapshotPromise;refreshController;startPromise;closePromise;closed=!1;reportError(a){try{this.options.onError?.(a)}catch{}}constructor(a){if(!a?.context)throw new t.gV("RSC discovery host");const b=(0,t.xe)(a.context);this.options={...a,context:b};const c=a.pollIntervalMs??500;if(!Number.isFinite(c)||c<25)throw TypeError("pollIntervalMs must be at least 25");if("function"!=typeof a.authorize)throw TypeError("RSC discovery authorize policy is required");const d=a.operationTimeoutMs??3e4;if(!Number.isFinite(d)||d<100)throw TypeError("operationTimeoutMs must be at least 100");this.deployments=new x.B({artifacts:a.artifacts,deployments:a.deployments,runtime:a.runtime,start:async()=>({deactivate:()=>void 0,drain:async()=>void 0,stop:async()=>void 0})}),this.discovery=new m({missingReconciliations:a.missingReconciliations,generationHighWater:a.generationHighWater,generationHistorySize:a.generationHistorySize,select:a.select,deploy:async c=>{let d=await w(a.application,c,{context:b,runtime:a.runtime,signal:this.refreshController?.signal,maxFileBytes:a.maxFileBytes,maxTotalBytes:a.maxTotalBytes,maxManifestBytes:a.maxManifestBytes,maxArtifactFiles:a.maxArtifactFiles,maxPathBytes:a.maxPathBytes,maxPathDepth:a.maxPathDepth});try{let b=await this.deployments.upgrade({artifactRoot:d.artifactRoot,namespace:c.namespace,expected:{pluginId:c.pluginId,buildId:c.buildId}});try{await a.onEnabled?.(structuredClone(c))}catch(a){this.reportError(a)}return{announcement:structuredClone(c),deployment:b}}finally{await d.cleanup()}},retire:({deployment:a})=>this.deployments.retire(a),replace:async(a,b)=>({announcement:structuredClone(b),deployment:await this.deployments.rebind(b,b.namespace)})})}async refresh(){if(this.closed)throw Error("Hile RSC discovery host is closed");if(this.refreshPromise)return this.refreshPromise;if(this.snapshotPromise)throw Error("Previous RSC discovery snapshot read is still settling");let a=new AbortController;this.refreshController=a;let b=setTimeout(()=>a.abort(Error("RSC discovery refresh timed out")),this.options.operationTimeoutMs??3e4);b.unref?.();let c=(async()=>{let b=y(this.options.application,{concurrency:this.options.snapshotConcurrency,signal:a.signal}).finally(()=>{this.snapshotPromise===b&&(this.snapshotPromise=void 0)});this.snapshotPromise=b;let c=await Promise.race([b,new Promise((b,c)=>a.signal.addEventListener("abort",()=>c(a.signal.reason),{once:!0}))]);for(let a of c.rejected)try{this.options.onRejected?.(a.topic,a.error)}catch(a){this.reportError(a)}let d=[];for(let a of c.announcements)try{if(!await this.options.authorize(structuredClone(a)))throw Error(`Unauthorized RSC discovery announcement: ${a.pluginId}`);if(Object.keys(this.options.runtime).some(b=>a.runtime[b]!==this.options.runtime[b]))throw Error(`Incompatible RSC discovery runtime: ${a.pluginId}@${a.buildId}`);d.push(a)}catch(c){let b=j(a.instanceId);try{this.options.onRejected?.(b,c)}catch(a){this.reportError(a)}}await this.discovery.reconcile(d)})().finally(()=>{clearTimeout(b),this.refreshController===a&&(this.refreshController=void 0),this.refreshPromise===c&&(this.refreshPromise=void 0)});return this.refreshPromise=c,this.refreshPromise}async start(){if(this.closed)throw Error("Hile RSC discovery host is closed");return this.startPromise||(this.startPromise=(async()=>{await this.refresh();let a=()=>{this.closed||(this.timer=setTimeout(async()=>{this.timer=void 0;try{await this.refresh()}catch(a){this.closed||this.reportError(a)}a()},this.options.pollIntervalMs??500),this.timer.unref?.())};a()})()),this.startPromise}snapshot(){return this.discovery.snapshot()}async close(){if(this.closePromise)return this.closePromise;this.closed=!0;let a=(async()=>{this.timer&&clearTimeout(this.timer),this.timer=void 0,this.refreshController?.abort(Error("Hile RSC discovery host is closing"));let a=[];try{await this.refreshPromise}catch{}try{await this.discovery.close()}catch(b){a.push(b)}try{await this.deployments.shutdown()}catch(b){a.push(b)}if(a.length)throw AggregateError(a,"Hile RSC discovery host cleanup failed")})();return this.closePromise=a.catch(a=>{throw this.closePromise=void 0,a}),this.closePromise}}c(41815)},26147:(a,b,c)=>{c.d(b,{tm:()=>d,fr:()=>e,z_:()=>y});let d="__hile_rsc_remote_client_boundary__",e=Object.freeze({react:"19.2.8",reactDom:"19.2.8",rsc:"19.2.8"}),f=Object.freeze({displayNameLength:120,descriptionLength:500,navigationItems:128,navigationIdLength:64,navigationLabelLength:120,navigationGroupLength:120,navigationOrderMagnitude:1e6}),g=/^\[([A-Za-z][A-Za-z0-9_]*)\]$/;function h(a){return"/"===a?[]:a.slice(1).split("/")}function i(a){return g.exec(a)?.[1]}let j=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;class k extends Error{code;constructor(a,b){super(b),this.name="RscProtocolError",this.code=a}}function l(a,b){throw new k(a,b)}function m(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function n(a,b){return("string"!=typeof a||0===a.length)&&l("ERR_RSC_INVALID_MANIFEST",`${b} must be a non-empty string`),a}function o(a,b){return Array.isArray(a)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be an array`),a}function p(a,b){return m(a)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be an object`),a}function q(a,b){let c=n(a,b),d=c.split("/");return(c.startsWith("/")||c.includes("\\")||c.includes(":")||c.includes("%")||c.includes("?")||c.includes("#")||/[\0-\x1F\x7F]/.test(c)||!/^[A-Za-z0-9@_./+-]+$/.test(c)||d.some(a=>""===a||"."===a||".."===a))&&l("ERR_RSC_UNSAFE_ARTIFACT_PATH",`${b} contains an unsafe artifact path`),c}function r(a,b){let c=n(a,b);return/^(?:default|[A-Za-z_$][A-Za-z0-9_$]*)$/.test(c)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be a JavaScript export name`),c}function s(a,b){let c=n(a,b);return/^sha256-[A-Za-z0-9+/]{43}=$/.test(c)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be a sha256 SRI value`),c}function t(a,b,c="ERR_RSC_INVALID_ROUTE"){("string"!=typeof a||0===a.length)&&l(c,`${b} must be a non-empty string`);let d=h(a);(!a.startsWith("/")||a.startsWith("//")||a.includes("?")||a.includes("#")||a.includes("\\")||a.includes("%")||/[\0-\x1F\x7F]/.test(a)||"/"!==a&&d.some(a=>""===a)||d.some(a=>"."===a||".."===a)||d.some(a=>""!==a&&!/^[A-Za-z0-9._~-]+$/.test(a)&&void 0===i(a)))&&l(c,`${b} must be a normalized absolute route path`);let e=d.map(i).filter(a=>void 0!==a);return new Set(e).size!==e.length&&l(c,`${b} must not repeat a route parameter name`),a}function u(a){return void 0!==i(a)}function v(a){return h(a).filter(a=>!u(a)).length}let w=/[\p{Cc}\p{Cs}\p{Zl}\p{Zp}\u061C\u200B\u200E\u200F\u202A-\u202E\u2060\u2066-\u2069]/u;function x(a,b,c){return("string"!=typeof a||0===a.length)&&l("ERR_RSC_INVALID_METADATA",`${b} must be a non-empty string`),(a!==a.trim()||function(a,b){let c=0;for(let d of a)if(++c>b)return!0;return!1}(a,c)||w.test(a))&&l("ERR_RSC_INVALID_METADATA",`${b} is not a bounded display string`),a}function y(a,b){var c;let d,e,g,i,k,w=p(a,"manifest");1!==w.protocolVersion&&l("ERR_RSC_PROTOCOL_VERSION",`unsupported RSC protocol version: ${String(w.protocolVersion)}`);let y=n(w.pluginId,"pluginId");j.test(y)||l("ERR_RSC_INVALID_MANIFEST","pluginId must be a lowercase identifier");let z=n(w.buildId,"buildId");/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(z)||l("ERR_RSC_INVALID_MANIFEST","buildId contains unsupported characters");let A=function(a,b){let c=p(a,"runtime"),d={react:n(c.react,"runtime.react"),reactDom:n(c.reactDom,"runtime.reactDom"),rsc:n(c.rsc,"runtime.rsc")};for(let a of["react","reactDom","rsc"])d[a]!==b[a]&&l("ERR_RSC_RUNTIME_MISMATCH",`${a} runtime mismatch: plugin=${d[a]}, host=${b[a]}`);return d}(w.runtime,b),B=p(w.server,"server"),C={entry:q(B.entry,"server.entry"),integrity:s(B.integrity,"server.integrity")},D=new Set,E=o(void 0===w.serverFunctions?[]:w.serverFunctions,"serverFunctions").map((a,b)=>{var c;let d,e,f=p(a,`serverFunctions[${b}]`),g=(d=n(f.id,c=`serverFunctions[${b}].id`),(!(e=/^([^/]+)\/[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9@_./+-]+#[A-Za-z_$][A-Za-z0-9_$]*$/.exec(d))||!j.test(e[1])||d.includes("..")||d.includes("//"))&&l("ERR_RSC_INVALID_MANIFEST",`${c} must identify a plugin build, module, and export`),d);return D.has(g)&&l("ERR_RSC_DUPLICATE_SERVER_FUNCTION_REFERENCE",`duplicate server function reference: ${g}`),D.add(g),{id:g,module:q(f.module,`serverFunctions[${b}].module`),exportName:r(f.exportName,`serverFunctions[${b}].exportName`),integrity:s(f.integrity,`serverFunctions[${b}].integrity`)}}),F=new Set,G=o(w.clients,"clients").map((a,b)=>{var c;let d,e=p(a,`clients[${b}]`),f=(d=n(e.id,c=`clients[${b}].id`),(!/^[A-Za-z0-9@_./+-]+#[A-Za-z_$][A-Za-z0-9_$]*$/.test(d)||d.includes(".."))&&l("ERR_RSC_INVALID_MANIFEST",`${c} must identify a module and export`),d);return F.has(f)&&l("ERR_RSC_DUPLICATE_CLIENT_REFERENCE",`duplicate client reference: ${f}`),F.add(f),{id:f,module:q(e.module,`clients[${b}].module`),ssrModule:q(e.ssrModule,`clients[${b}].ssrModule`),exportName:r(e.exportName,`clients[${b}].exportName`),chunks:o(e.chunks,`clients[${b}].chunks`).map((a,c)=>{let d=p(a,`clients[${b}].chunks[${c}]`);return{path:q(d.path,`clients[${b}].chunks[${c}].path`),integrity:s(d.integrity,`clients[${b}].chunks[${c}].integrity`)}}),ssrChunks:o(e.ssrChunks,`clients[${b}].ssrChunks`).map((a,c)=>{let d=p(a,`clients[${b}].ssrChunks[${c}]`);return{path:q(d.path,`clients[${b}].ssrChunks[${c}].path`),integrity:s(d.integrity,`clients[${b}].ssrChunks[${c}].integrity`)}}),integrity:s(e.integrity,`clients[${b}].integrity`),ssrIntegrity:s(e.ssrIntegrity,`clients[${b}].ssrIntegrity`)}}),H=new Set,I=o(w.styles,"styles").map((a,b)=>{let c=p(a,`styles[${b}]`),d=q(c.path,`styles[${b}].path`);return H.has(d)&&l("ERR_RSC_DUPLICATE_STYLE",`duplicate style artifact: ${d}`),H.add(d),{path:d,integrity:s(c.integrity,`styles[${b}].integrity`)}}),J=o(w.routes,"routes");0===J.length&&l("ERR_RSC_INVALID_ROUTE","routes must contain at least one route");let K=new Set,L=J.map((a,b)=>{var c;let d,e=p(a,`routes[${b}]`),f=t(e.path,`routes[${b}].path`);return K.has(f)&&l("ERR_RSC_DUPLICATE_ROUTE",`duplicate route path: ${f}`),K.add(f),{path:f,entry:(d=n(e.entry,c=`routes[${b}].entry`),/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(d)&&"."!==d&&".."!==d||l("ERR_RSC_INVALID_MANIFEST",`${c} must be a safe entry name`),d)}});for(let a=0;a<L.length;a++)for(let b=a+1;b<L.length;b++){let c=L[a].path,d=L[b].path;(function(a,b){let c=h(a),d=h(b);return c.length===d.length&&c.every((a,b)=>a===d[b]||u(a)||u(d[b]))})(c,d)&&v(c)===v(d)&&l("ERR_RSC_DUPLICATE_ROUTE",`ambiguous parameterized routes: ${c} and ${d}`)}let M=void 0===w.metadata?void 0:(c=w.metadata,m(c)||l("ERR_RSC_INVALID_METADATA","metadata must be an object"),d=x(c.displayName,"metadata.displayName",f.displayNameLength),e=void 0===c.description?void 0:x(c.description,"metadata.description",f.descriptionLength),(!Array.isArray(g=void 0===c.navigation?[]:c.navigation)||g.length>f.navigationItems)&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation must contain at most ${f.navigationItems} items`),i=new Set,k=g.map((a,b)=>{m(a)||l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}] must be an object`);let c="string"==typeof a.id?a.id:"";(c.length>f.navigationIdLength||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(c))&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}].id is invalid`),i.has(c)&&l("ERR_RSC_DUPLICATE_NAVIGATION",`duplicate navigation id: ${c}`),i.add(c);let d=t(a.path,`metadata.navigation[${b}].path`,"ERR_RSC_INVALID_METADATA");return(!K.has(d)||h(d).some(u))&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}].path must reference a declared static route`),void 0!==a.order&&(!Number.isSafeInteger(a.order)||Math.abs(a.order)>f.navigationOrderMagnitude)&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}].order is invalid`),{id:c,label:x(a.label,`metadata.navigation[${b}].label`,f.navigationLabelLength),path:d,...void 0===a.order?{}:{order:a.order},...void 0===a.group?{}:{group:x(a.group,`metadata.navigation[${b}].group`,f.navigationGroupLength)}}}),{displayName:d,...void 0===e?{}:{description:e},navigation:k});return{protocolVersion:1,pluginId:y,buildId:z,runtime:A,server:C,serverFunctions:E,clients:G,styles:I,routes:L,...void 0===M?{}:{metadata:M}}}},31343:(a,b,c)=>{c.r(b),c.d(b,{getRscPluginArtifactFiles:()=>l,inspectRscPluginArtifact:()=>k,resolveRscPluginArtifact:()=>o,resolveVerifiedRscPluginArtifact:()=>p,verifyRscPluginArtifact:()=>m});var d=c(51455),e=c(76760),f=c(77598),g=c(26147);async function h(a){let b=e.resolve(a),c=await (0,d.lstat)(b);if(c.isSymbolicLink())throw Error(`RSC artifact input must not be a symbolic link: ${b}`);if(c.isDirectory()){let a=e.join(b,"plugin.json"),c=await (0,d.lstat)(a);if(!c.isFile()||c.isSymbolicLink())throw Error(`RSC artifact manifest must be a regular file: ${a}`);return{root:b,manifestPath:a}}if(!c.isFile())throw Error(`RSC artifact manifest is not a file: ${b}`);return{root:e.dirname(b),manifestPath:b}}async function i(a,b){let c=a,f=b.split("/");for(let a=0;a<f.length;a++){let g;c=e.join(c,f[a]);try{g=await (0,d.lstat)(c)}catch{throw Error(`RSC artifact is missing: ${b}`)}if(g.isSymbolicLink())throw Error(`RSC artifact must not traverse a symbolic link: ${b}`);if(a<f.length-1&&!g.isDirectory())throw Error(`RSC artifact parent must be a directory: ${b}`);if(a===f.length-1&&!g.isFile())throw Error(`RSC artifact must be a regular file: ${b}`)}return c}async function j(a,b=a){let c=[];for(let f of(await (0,d.readdir)(b,{withFileTypes:!0}))){let d=e.join(b,f.name),g=e.relative(a,d).split(e.sep).join("/");if(f.isSymbolicLink())throw Error(`RSC artifact must not contain a symbolic link: ${g}`);if(f.isDirectory())c.push(...await j(a,d));else if(f.isFile())c.push(g);else throw Error(`RSC artifact contains an unsupported filesystem entry: ${g}`)}return c}async function k(a){let{manifestPath:b}=await h(a),c=JSON.parse(await (0,d.readFile)(b,"utf8"));if(!c.runtime)throw Error("RSC artifact manifest is missing runtime compatibility");return(0,g.z_)(c,c.runtime)}function l(a){let b=new Map,c=(a,c)=>{let d=b.get(a);if(d&&d!==c)throw Error(`RSC artifact declares conflicting integrity: ${a}`);b.set(a,c)};for(let b of(c(a.server.entry,a.server.integrity),a.serverFunctions))c(b.module,b.integrity);for(let b of a.clients){for(let a of(c(b.module,b.integrity),c(b.ssrModule,b.ssrIntegrity),b.chunks))c(a.path,a.integrity);for(let a of b.ssrChunks)c(a.path,a.integrity)}for(let b of a.styles)c(b.path,b.integrity);return b}async function m(a,b){let{root:c,manifestPath:k}=await h(a),m=JSON.parse(await (0,d.readFile)(k,"utf8")),n=(0,g.z_)(m,b),o=l(n);for(let[a,b]of o){let g=e.resolve(c,a);if(!g.startsWith(`${c}${e.sep}`))throw Error(`RSC artifact escapes its root: ${a}`);if(await i(c,a),`sha256-${(0,f.createHash)("sha256").update(await (0,d.readFile)(g)).digest("base64")}`!==b)throw Error(`RSC artifact integrity mismatch: ${a}`)}let p=new Set([e.relative(c,k).split(e.sep).join("/"),...o.keys()]);for(let a of(await j(c)))if(!p.has(a))throw Error(`RSC artifact contains an undeclared file: ${a}`);return{manifest:n,files:[...o.keys()].sort()}}async function n(a,b,c){let f,g,h=e.resolve(a);try{if(!(await (0,d.lstat)(h)).isDirectory())return{artifactRoot:h};return await (0,d.access)(e.join(h,"plugin.json")),{artifactRoot:h}}catch{}let i=function(a){let b=a?.trim();if(b){if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(b))throw TypeError("RSC buildId contains unsupported characters");return b}}(b.buildId);if(i)return{artifactRoot:e.join(h,i)};try{f=await (0,d.readdir)(h,{withFileTypes:!0})}catch{return{artifactRoot:h}}for(let a of(await Promise.all(f.filter(a=>a.isDirectory()&&!a.name.startsWith(".")&&"development"!==a.name).map(async a=>{let b=e.join(h,a.name),c=e.join(b,"plugin.json");try{let e=(await (0,d.stat)(c)).mtimeMs;try{let c=await k(b);return{path:b,name:a.name,mtime:e,manifest:c}}catch(c){return{path:b,name:a.name,mtime:e,error:c}}}catch{return}}))).filter(a=>void 0!==a).sort((a,b)=>b.mtime-a.mtime||b.name.localeCompare(a.name))){if("error"in a){g??=a.error;continue}try{let b=await m(a.path,c??a.manifest.runtime);return{artifactRoot:a.path,verification:b}}catch(a){g??=a}}if(void 0!==g)throw g;return{artifactRoot:h}}async function o(a,b={}){return(await n(a,b)).artifactRoot}async function p(a,b,c={}){let d=await n(a,c,b),e=d.verification??await m(d.artifactRoot,b);return{artifactRoot:d.artifactRoot,...e}}},39226:(a,b,c)=>{c.d(b,{cb:()=>g,vs:()=>i});var d=c(8669);c(60339);let e=/^[A-Za-z0-9._-]{1,128}$/,f=new WeakSet;function g(a){return!!a&&"object"==typeof a&&f.has(a)}function h(a,b,c){let e={...c};for(let[c,f]of Object.entries(e)){if(!g(f)||f.kind!==b)throw new d.N("INVALID_DEFINITION",`${a} ${b} "${c}" must be created with defineMcp*`);if(c!==f.config.name)throw new d.N("INVALID_DEFINITION",`${a} ${b} record key "${c}" must equal capability name "${f.config.name}"`)}return Object.freeze(e)}function i(a){var b=a.id;if("string"!=typeof b||!e.test(b))throw new d.N("INVALID_DEFINITION",`Provider name must match ${e}`);if(void 0!==a.displayName&&"string"!=typeof a.displayName)throw new d.N("INVALID_DEFINITION","Provider displayName must be a string");return Object.freeze({id:a.id,displayName:a.displayName,tools:h(a.id,"tool",a.tools),resources:h(a.id,"resource",a.resources),prompts:h(a.id,"prompt",a.prompts)})}},41815:(a,b,c)=>{c.d(b,{$C:()=>g,ur:()=>f});var d=c(18509);let e=Object.freeze({describe:"/-/rsc/describe",render:"/-/rsc/render",action:"/-/rsc/action",serverFunction:"/-/rsc/server-function"});function f(a,b){if(!a?.context)throw new d.gV(b);return Object.freeze({...a,context:(0,d.xe)(a.context)})}function g(a,b,c=e){if(!b)throw TypeError("RSC plugin namespace must not be empty");return{describe:d=>a.call(b,c.describe,{},f(d,"RSC plugin describe")),render:(d,e)=>a.stream(b,c.render,d,f(e,"RSC plugin render transport")),action:(d,e)=>a.call(b,c.action,d,f(e,"RSC plugin action transport")),serverFunction:(d,e)=>a.call(b,c.serverFunction,d,f(e,"RSC plugin server function transport"))}}new WeakMap,Object.freeze({snapshot:"/-/rsc/catalog/snapshot",active:"/-/rsc/catalog/active",install:"/-/rsc/catalog/install",activate:"/-/rsc/catalog/activate",deactivate:"/-/rsc/catalog/deactivate",remove:"/-/rsc/catalog/remove"})},51842:(a,b,c)=>{c.d(b,{n:()=>d});function d(a,b){return a<b?-1:+(a>b)}},52179:(a,b,c)=>{c.d(b,{Mi:()=>t,O7:()=>s,rW:()=>r});var d=c(18509),e=c(60339),f=c(8669),g=c(51842),h=c(93279),i=c(62202),j=c(57782);let k=Symbol("hile.mcp.gateway.runtime"),l=new WeakMap,m=new WeakMap;function n(a){if(a)return{subject:a.clientId,clientId:a.clientId,scopes:Object.freeze([...a.scopes??[]]),claims:a.extra?Object.freeze({...a.extra}):void 0}}function o(a){return a?.map(a=>({...a,sizes:a.sizes?[...a.sizes]:void 0}))}function p(a){return a?structuredClone(a):void 0}class q{options;instances=[];unsubscribe=()=>void 0;unsubscribeResourceUpdates=()=>void 0;closed=!1;closing;unsubscribePending=!0;unsubscribeResourceUpdatesPending=!0;sourceClosePending=!0;lifecycle=new AbortController;activeInvocations=new Set;liveProjections=new Set;catalogListeners=new Set;cursor=new Map;catalogState={groups:new Map,conflicts:new Map,tools:[],resources:[],prompts:[]};constructor(a){this.options=a}async start(){if(await this.options.source.start(),this.replaceInstances(this.options.source.snapshot()),"require-provider"===this.options.startup&&0===this.instances.length)throw new f.N("PROVIDER_UNAVAILABLE","MCP gateway requires at least one provider");this.unsubscribe=this.options.source.subscribe(a=>{this.replaceInstances(a)}),this.unsubscribeResourceUpdates=this.options.source.subscribeResourceUpdates(a=>{this.handleResourceUpdate(a)})}replaceInstances(a){let b=this.catalogState;for(let b of(this.instances=this.validInstances(a),this.catalogState=this.buildCatalog(),this.liveProjections))this.project(b,!0);let c=a=>a.map(a=>`${a.publicName}:${a.manifest.fingerprint}:${a.capability.name}`).join("\0"),d={tools:c(b.tools)!==c(this.catalogState.tools),resources:c(b.resources)!==c(this.catalogState.resources),prompts:c(b.prompts)!==c(this.catalogState.prompts),resourceUpdates:[]};if(d.tools||d.resources||d.prompts)for(let a of this.catalogListeners)try{a(d)}catch(a){this.report(a)}}handleResourceUpdate(a){let b=this.catalogState.resources.find(b=>b.providerId===a.providerId&&b.manifest.fingerprint===a.fingerprint&&(b.capability.uri===a.uri||!!b.resourceTemplate?.uriTemplate.match(a.uri)));if(!b||!this.catalogState.groups.get(a.providerId)?.some(b=>b.instanceId===a.instanceId&&b.fingerprint===a.fingerprint))return;for(let c of this.liveProjections)!c.http&&this.visible(b,c.principal)&&("modern"===c.era||c.resourceSubscriptions.has(a.uri))&&c.server.server.sendResourceUpdated({uri:a.uri}).catch(a=>this.report(a));let c={tools:!1,resources:!1,prompts:!1,resourceUpdates:[a.uri]};for(let a of this.catalogListeners)try{a(c)}catch(a){this.report(a)}}subscribeCatalogChanges(a){if(this.closed)throw new f.N("GATEWAY_CLOSED","MCP gateway is closed");return this.catalogListeners.add(a),()=>{this.catalogListeners.delete(a)}}report(a){try{this.options.onError?.(a)}catch{}}validInstances(a){return a.flatMap(a=>{let b=(0,i.Ky)(a);return b?[b]:[]})}groups(){let a=new Map;for(let b of this.instances){let c=a.get(b.providerId)??[];c.push(b),a.set(b.providerId,c)}for(let b of a.values())b.sort((a,b)=>(0,g.n)(a.instanceId,b.instanceId));return a}name(a,b){let c=this.options.naming?.aliases?.[a]??a,d=`${c}${this.options.naming?.separator??"."}${b}`;if(!/^[A-Za-z0-9._-]{1,128}$/.test(d))throw new f.N("CATALOG_CONFLICT",`Invalid public MCP name "${d}"`);return d}buildCatalog(){let a=this.groups(),b=new Map,c=(a,c)=>{let d=b.get(a)??new Set;d.add(c),b.set(a,d)},d=[],f=[],h=[];for(let[b,g]of a){if(1!==new Set(g.map(a=>a.fingerprint)).size){c(b,"instances publish different capability fingerprints");continue}let a=g[0],i=(d,f,g)=>{try{let c=this.name(b,f.name),h=f.scopes??[],i=Object.freeze({providerId:b,kind:d,localName:f.name,publicName:c,scopes:h});g.push({manifest:a,capability:f,providerId:b,kind:d,localName:f.name,publicName:c,scopes:h,view:i,inputSchema:"tool"===d||"prompt"===d?(0,e.e0)(f.inputSchema??{type:"object"}):void 0,outputSchema:"tool"===d&&f.outputSchema?(0,e.e0)(f.outputSchema):void 0,resourceTemplate:"resource"===d&&f.uriTemplate?new e.Zn(f.uriTemplate,{list:void 0}):void 0})}catch(a){c(b,a instanceof Error?a.message:"invalid public capability name")}};for(let b of a.capabilities.tools)i("tool",b,d);for(let b of a.capabilities.resources)i("resource",b,f);for(let b of a.capabilities.prompts)i("prompt",b,h)}let i=(a,b,d)=>{let e=new Map;for(let c of a){let a=e.get(b(c))??[];a.push(c.providerId),e.set(b(c),a)}for(let[a,b]of e)if(!(b.length<2))for(let e of new Set(b))c(e,`${d} conflict: ${a}`)};i(d,a=>a.publicName,"tool name"),i(f,a=>a.publicName,"resource name"),i(h,a=>a.publicName,"prompt name"),i(f,a=>a.capability.uri??a.capability.uriTemplate??"","resource URI");let j=(a,b)=>(0,g.n)(a.publicName,b.publicName),k=a=>!b.has(a.providerId);return{groups:a,conflicts:b,tools:d.filter(k).sort(j),resources:f.filter(k).sort(j),prompts:h.filter(k).sort(j)}}catalog(){return this.catalogState}inspect(){let a=this.catalog();return{providers:[...a.groups].sort(([a],[b])=>(0,g.n)(a,b)).map(([b,c])=>{let d=[...new Set(c.map(a=>a.fingerprint))].sort(),e=[...a.conflicts.get(b)??[]].sort();return{providerId:b,status:0===e.length?"ready":"conflict",instanceCount:c.length,fingerprints:d,conflicts:e}}),tools:a.tools.map(a=>a.publicName),resources:a.resources.map(a=>a.publicName),prompts:a.prompts.map(a=>a.publicName)}}select(a){let b=a.providerId,c=this.catalogState.groups.get(b)??[];if(!c.length)throw new f.N("PROVIDER_UNAVAILABLE",`MCP provider "${b}" is unavailable`);let d=new Set(c.map(a=>a.fingerprint));if(1!==d.size||!d.has(a.manifest.fingerprint))throw new f.N("CATALOG_CONFLICT",`MCP provider "${b}" changed during invocation`);let e=`${b}/${a.manifest.fingerprint}`,g=this.cursor.get(e)??0;return this.cursor.set(e,g+1),c[g%c.length]}visible(a,b){return!!(0,h.c)(b?.scopes,a.scopes)&&(this.options.isCapabilityExposed?.(a.view,b)??!0)}invoke(a,b,c,d,e){if(this.closed)return Promise.reject(new f.N("GATEWAY_CLOSED","MCP gateway is closed"));let g=this.invokeActive(a,b,c,d,e);return this.activeInvocations.add(g),g.finally(()=>{this.activeInvocations.delete(g)}).catch(()=>void 0),g}complete(a,b,c,d,e,g){if(this.closed)return Promise.reject(new f.N("GATEWAY_CLOSED","MCP gateway is closed"));let h=this.completeActive(a,b,c,d,e,g);return this.activeInvocations.add(h),h.finally(()=>{this.activeInvocations.delete(h)}).catch(()=>void 0),h}async completeActive(a,b,c,d,e,g){let h,i=this.lifecycle.signal;i.throwIfAborted();let k=this.select(a),l={argument:b,value:c,context:d},m={executionContext:g,providerId:a.providerId,instanceId:k.instanceId,fingerprint:a.manifest.fingerprint,kind:a.kind,name:a.capability.name,input:l},o={...m,input:l,principal:"trusted-internal"===this.options.invocationSecurity.mode?n(e):void 0,credential:"credential"===this.options.invocationSecurity.mode?await this.options.invocationSecurity.credentials.create(m,n(e),i):void 0},p=await this.options.source.stream(k,j.Aw.complete,o,{context:g,signal:i}),q=!1;for await(let b of p){if(b?.type!=="result"||q)throw new f.N("PROVIDER_UNAVAILABLE",`MCP completion for "${a.publicName}" emitted an invalid frame`);h=b.result,q=!0}if(!q||!Array.isArray(h)||h.some(a=>"string"!=typeof a))throw new f.N("PROVIDER_UNAVAILABLE",`MCP completion for "${a.publicName}" returned invalid suggestions`);return h}async invokeActive(a,b,c,d,e){let g=+(a.capability.execution?.retry==="idempotent-failover"),h=AbortSignal.any([d.mcpReq.signal,this.lifecycle.signal]),i={providerId:a.providerId,instanceId:void 0,fingerprint:a.manifest.fingerprint,credential:void 0,principal:"trusted-internal"===this.options.invocationSecurity.mode?n(c):void 0,kind:a.kind,name:a.capability.name,input:b,inputResponses:d.mcpReq.inputResponses,requestState:d.mcpReq.requestState()};for(let k=0;k<=g;k++){let l=!1;try{let g,k=this.select(a);for await(let m of(i.instanceId=k.instanceId,i.credential="credential"===this.options.invocationSecurity.mode?await this.options.invocationSecurity.credentials.create({executionContext:e,providerId:a.providerId,instanceId:k.instanceId,fingerprint:a.manifest.fingerprint,kind:a.kind,name:a.capability.name,input:b},n(c),h):void 0,await this.options.source.stream(k,j.Aw.invoke,i,{context:e,timeout:a.capability.execution?.timeoutMs,signal:h}))){if(l)throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted frames after its result`);if(m?.type==="progress"){if(!Number.isFinite(m.progress)||void 0!==m.total&&!Number.isFinite(m.total))throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted an invalid progress frame`);let b=d.mcpReq._meta?.progressToken;if(void 0!==b)try{await d.mcpReq.notify({method:"notifications/progress",params:{progressToken:b,progress:m.progress,total:m.total,message:m.message}})}catch(a){throw new f.N("PROVIDER_UNAVAILABLE","Failed to deliver MCP progress notification",{cause:a})}}else if(m?.type==="log"){if(!["debug","info","notice","warning","error"].includes(m.level))throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted an invalid log frame`);try{await d.mcpReq.log(m.level,m.data)}catch(a){throw new f.N("PROVIDER_UNAVAILABLE","Failed to deliver MCP log notification",{cause:a})}}else if(m?.type==="result")g=m.result,l=!0;else throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted an unknown frame`)}if(!l)throw Error(`MCP ${a.kind} "${a.publicName}" stream ended without a result`);return g}catch(a){if(h.aborted)throw h.reason??a;if(l||k===g||a instanceof f.N)throw a}}throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" failed without an error`)}[k](a){if(this.closed)throw new f.N("GATEWAY_CLOSED","MCP gateway is closed");let b=new e._k(this.options.info,{instructions:this.options.instructions,requestState:this.options.requestState,cacheHints:this.options.cacheHints,capabilities:{tools:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},prompts:{listChanged:!0}}}),c={server:b,executionContext:(0,d.xe)(this.options.executionContext(a)),authInfo:a.authInfo,principal:n(a.authInfo),era:a.era??"legacy",http:void 0!==a.requestInfo,resourceSubscriptions:new Set,handles:[],names:{tools:"",resources:"",prompts:""}};"legacy"===c.era&&(b.server.setRequestHandler("resources/subscribe",a=>(c.resourceSubscriptions.add(a.params.uri),{})),b.server.setRequestHandler("resources/unsubscribe",a=>(c.resourceSubscriptions.delete(a.params.uri),{}))),this.project(c,!1),this.liveProjections.add(c);let g=()=>{this.liveProjections.delete(c),c.resourceSubscriptions.clear()},h=b.server.onclose;b.server.onclose=()=>{g(),h?.()};let i=b.close.bind(b);return b.close=async()=>{g(),c.handles.length=0,await i()},b}project(a,b){let c,d,f,g,h=a.names;try{let b=this.catalog();c=b.tools.filter(b=>this.visible(b,a.principal)),d=b.resources.filter(b=>this.visible(b,a.principal)),f=b.prompts.filter(b=>this.visible(b,a.principal));let e=a=>a.map(a=>`${a.publicName}:${a.manifest.fingerprint}:${a.capability.name}`).join("\0");g={tools:e(c),resources:e(d),prompts:e(f)}}catch(a){this.report(a);return}if(h.tools===g.tools&&h.resources===g.resources&&h.prompts===g.prompts)return;let i={tools:a.server.sendToolListChanged,resources:a.server.sendResourceListChanged,prompts:a.server.sendPromptListChanged};for(let b of(a.server.sendToolListChanged=()=>void 0,a.server.sendResourceListChanged=()=>void 0,a.server.sendPromptListChanged=()=>void 0,a.handles.splice(0)))try{b.remove()}catch(a){this.report(a)}try{for(let b of c)a.handles.push(a.server.registerTool(b.publicName,{title:b.capability.title,description:b.capability.description,inputSchema:b.inputSchema,outputSchema:b.outputSchema,annotations:b.capability.annotations,icons:o(b.capability.icons),_meta:p(b.capability._meta)},(c,d)=>this.invoke(b,c,a.authInfo,d,a.executionContext)));for(let b of d){let c={title:b.capability.title,description:b.capability.description,mimeType:b.capability.mimeType,icons:o(b.capability.icons),size:b.capability.size,annotations:b.capability.annotations?structuredClone(b.capability.annotations):void 0,_meta:p(b.capability._meta),cacheHint:b.capability.cacheHint?{...b.capability.cacheHint}:void 0};if(b.capability.uri)a.handles.push(a.server.registerResource(b.publicName,b.capability.uri,c,(c,d)=>this.invoke(b,c.toString(),a.authInfo,d,a.executionContext)));else if(b.capability.uriTemplate){let d=b.capability.completionArguments??[],f=d.length?new e.Zn(b.capability.uriTemplate,{list:void 0,complete:Object.fromEntries(d.map(c=>[c,(d,e)=>this.complete(b,c,d,e,a.authInfo,a.executionContext)]))}):b.resourceTemplate;a.handles.push(a.server.registerResource(b.publicName,f,c,(c,d,e)=>this.invoke(b,d,a.authInfo,e,a.executionContext)))}}for(let b of f){let c=function(a,b,c){let d=(0,e.e0)(a);if(!b?.length)return d;let f=a.properties&&"object"==typeof a.properties&&!Array.isArray(a.properties)?a.properties:{},g=new Set(b),h=Object.fromEntries(Object.entries(f).map(([a,b])=>{let d=(0,e.e0)(b);return[a,g.has(a)?(0,e.JF)(d,(b,d)=>c(a,String(b),d)):d]}));return Object.assign(Object.create(d),{shape:h})}(b.capability.inputSchema??{type:"object"},b.capability.completionArguments,(c,d,e)=>this.complete(b,c,d,e,a.authInfo,a.executionContext));a.handles.push(a.server.registerPrompt(b.publicName,{title:b.capability.title,description:b.capability.description,argsSchema:c,icons:o(b.capability.icons),_meta:p(b.capability._meta)},(c,d)=>this.invoke(b,c,a.authInfo,d,a.executionContext)))}a.names=g}catch(b){for(let b of a.handles.splice(0))try{b.remove()}catch(a){this.report(a)}a.names={tools:"",resources:"",prompts:""},this.report(b)}finally{a.server.sendToolListChanged=i.tools,a.server.sendResourceListChanged=i.resources,a.server.sendPromptListChanged=i.prompts}if(b&&!a.http){let b=(a,b)=>{a&&b().catch(a=>this.report(a))};b(h.tools!==a.names.tools,()=>a.server.server.sendToolListChanged()),b(h.resources!==a.names.resources,()=>a.server.server.sendResourceListChanged()),b(h.prompts!==a.names.prompts,()=>a.server.server.sendPromptListChanged())}}close(){return this.closing||(this.closing=this.performClose().finally(()=>{this.closing=void 0})),this.closing}async performClose(){this.closed=!0,this.lifecycle.signal.aborted||this.lifecycle.abort(new f.N("GATEWAY_CLOSED","MCP gateway is closed"));let a=[];if(this.unsubscribePending)try{this.unsubscribe(),this.catalogListeners.clear(),this.unsubscribePending=!1}catch(b){a.push(b)}if(this.unsubscribeResourceUpdatesPending)try{this.unsubscribeResourceUpdates(),this.unsubscribeResourceUpdatesPending=!1}catch(b){a.push(b)}if(this.sourceClosePending){await Promise.allSettled([...this.activeInvocations]);try{await this.options.source.close(),this.sourceClosePending=!1}catch(b){a.push(b)}}if(a.length)throw AggregateError(a,"Failed to close MCP gateway")}}async function r(a){if(!a.info||e.aV.Implementation["~standard"].validate(a.info).issues||!a.info.name||!a.info.version)throw TypeError("MCP gateway info must follow the MCP Implementation schema with non-empty name and version");if(void 0!==a.instructions&&"string"!=typeof a.instructions)throw TypeError("MCP gateway instructions must be a string");if(void 0!==a.startup&&!["allow-empty","require-provider"].includes(a.startup))throw TypeError("Invalid MCP gateway startup mode");if(a.naming?.separator!==void 0&&![".","-","_"].includes(a.naming.separator))throw TypeError("Invalid MCP gateway name separator");if(a.naming?.aliases!==void 0&&(!a.naming.aliases||"object"!=typeof a.naming.aliases||Array.isArray(a.naming.aliases)))throw TypeError("MCP gateway aliases must be a record");if(void 0!==a.isCapabilityExposed&&"function"!=typeof a.isCapabilityExposed)throw TypeError("MCP isCapabilityExposed must be a function");if(void 0!==a.onError&&"function"!=typeof a.onError)throw TypeError("MCP gateway onError must be a function");if("function"!=typeof a.executionContext)throw TypeError("MCP gateway executionContext must be a function");let b=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"]);if(void 0!==a.cacheHints&&(!a.cacheHints||"object"!=typeof a.cacheHints||Object.entries(a.cacheHints).some(([a,c])=>!b.has(a)||!c||"object"!=typeof c||void 0!==c.ttlMs&&(!Number.isSafeInteger(c.ttlMs)||c.ttlMs<0)||void 0!==c.cacheScope&&!["public","private"].includes(c.cacheScope))))throw TypeError("MCP gateway cacheHints contain an invalid method or cache hint");if(!a.invocationSecurity||!["trusted-internal","credential"].includes(a.invocationSecurity.mode)||"credential"===a.invocationSecurity.mode&&"function"!=typeof a.invocationSecurity.credentials?.create)throw TypeError("MCP gateway invocationSecurity must be explicit");let c=Object.assign(Object.create(null),a.naming?.aliases??{});for(let[a,b]of Object.entries(c))if(!/^[A-Za-z0-9._-]{1,128}$/.test(a)||!/^[A-Za-z0-9._-]{1,128}$/.test(b))throw TypeError("MCP gateway aliases must contain legal provider and alias names");let d="credential"===a.invocationSecurity.mode?Object.freeze({mode:"credential",credentials:Object.freeze({create:a.invocationSecurity.credentials.create.bind(a.invocationSecurity.credentials)})}):Object.freeze({mode:"trusted-internal"}),f=new q({...a,info:Object.freeze({...a.info,icons:o(a.info.icons)}),cacheHints:a.cacheHints?Object.freeze(Object.fromEntries(Object.entries(a.cacheHints).map(([a,b])=>[a,Object.freeze({...b})]))):void 0,naming:a.naming?Object.freeze({separator:a.naming.separator,aliases:Object.freeze(c)}):void 0,requestState:a.requestState?Object.freeze({...a.requestState}):void 0,invocationSecurity:d});try{return await f.start(),l.set(f,a=>f[k](a)),m.set(f,a=>f.subscribeCatalogChanges(a)),f}catch(a){throw await f.close().catch(()=>void 0),a}}function s(a){let b=l.get(a);if(!b)throw TypeError("MCP gateway must be created by createMcpGateway");return b}function t(a,b){let c=m.get(a);if(!c)throw TypeError("MCP gateway must be created by createMcpGateway");return c(b)}},57278:(a,b,c)=>{c.d(b,{H_:()=>l}),c(77598),c(73136),c(60339),c(18509);var d=c(8669),e=c(38672);c(39226),e.aH;var f=c(62202),g=c(57782);new WeakMap;var h=c(57975),i=c(96022),j=c(51842);class k{application;pollIntervalMs;onError;instances=new Map;listeners=new Set;resourceUpdateListeners=new Set;seenResourceUpdates=new Set;resourceUnsubscribe;timer;starting;refreshPromise;closed=!1;lifecycle=new AbortController;closing;signature(a){return a.map(a=>`${a.providerId}/${a.instanceId}/${a.fingerprint}/${a.address.host}:${a.address.port}`).join("|")}constructor(a,b,c){this.application=a,this.pollIntervalMs=b,this.onError=c}start(){if(this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");return this.starting||(this.starting=this.performStart().finally(()=>{this.starting=void 0})),this.starting}async performStart(){if(!this.resourceUnsubscribe){let a=await this.application.subscribe(g.kn,a=>{let b=this.parseResourceUpdate(a);if(!(!b||this.seenResourceUpdates.has(b.eventId)))for(let a of(this.seenResourceUpdates.add(b.eventId),this.seenResourceUpdates.size>1024&&this.seenResourceUpdates.delete(this.seenResourceUpdates.values().next().value),this.resourceUpdateListeners))try{a(b)}catch(a){this.report(a)}});if(this.resourceUnsubscribe=a,this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed")}if(await this.refresh(),this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");this.timer||(this.timer=setInterval(()=>{this.refresh().catch(a=>this.report(a))},this.pollIntervalMs),this.timer.unref())}snapshot(){return[...this.instances.values()].sort((a,b)=>(0,j.n)(a.providerId,b.providerId)||(0,j.n)(a.instanceId,b.instanceId))}subscribe(a){if(this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");return this.listeners.add(a),()=>{this.listeners.delete(a)}}subscribeResourceUpdates(a){if(this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");return this.resourceUpdateListeners.add(a),()=>{this.resourceUpdateListeners.delete(a)}}parseResourceUpdate(a){if(!a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.eventId||!a.eventId||"string"!=typeof a.providerId||"string"!=typeof a.instanceId||"string"!=typeof a.fingerprint||"string"!=typeof a.uri)return;try{new URL(a.uri)}catch{return}let b=this.instances.get(`${a.providerId}/${a.instanceId}`);return b?.fingerprint===a.fingerprint?Object.freeze({eventId:a.eventId,providerId:a.providerId,instanceId:a.instanceId,fingerprint:a.fingerprint,uri:a.uri}):void 0}refresh(){if(this.refreshPromise)return this.refreshPromise;let a=(async()=>{let a=await this.application.listRegistryTopicSnapshots(g.k2,{signal:this.lifecycle.signal}),b=new Map;for(let{topic:c,payload:d,publishers:e}of a){let a=d&&"object"==typeof d&&!Array.isArray(d)?d:void 0,i="string"==typeof a?.providerId&&"string"==typeof a.instanceId?`${a.providerId}/${a.instanceId}`:void 0,j=i?this.instances.get(i):void 0,k=j&&c===`${g.k2}${j.providerId}/${j.instanceId}`&&(0,h.isDeepStrictEqual)(d,j)?j:(0,f.Ky)(d,c),l=1===e.length?e[0]:void 0;k&&l&&k.address.host===l.host&&k.address.port===l.port&&b.set(`${k.providerId}/${k.instanceId}`,k)}if(this.closed)return;let c=this.signature(this.snapshot());for(let[a,c]of(this.instances.clear(),b))this.instances.set(a,c);let d=this.snapshot();if(this.signature(d)!==c)for(let a of this.listeners)try{a(d)}catch(a){this.report(a)}})();return this.refreshPromise=a.finally(()=>{this.refreshPromise=void 0}),this.refreshPromise}stream(a,b,c,d){return this.application.streamPeer(a.address,b,c,d)}close(){return this.closing||(this.closing=this.performClose().finally(()=>{this.closing=void 0})),this.closing}async performClose(){this.closed||(this.closed=!0,this.lifecycle.abort(Error("MCP provider source closed")),this.timer&&clearInterval(this.timer),this.timer=void 0,this.listeners.clear(),this.resourceUpdateListeners.clear());try{await this.starting}catch{}try{await this.refreshPromise}catch(b){let a=b===this.lifecycle.signal.reason||!!b&&"object"==typeof b&&("ECONNABORTED"===b.status||"AbortError"===b.name);if(!this.lifecycle.signal.aborted||!a)throw b}if(this.resourceUnsubscribe){let a=this.resourceUnsubscribe;await a(),this.resourceUnsubscribe===a&&(this.resourceUnsubscribe=void 0)}}report(a){try{this.onError(a)}catch{}}}function l(a,b={}){let c=b.pollIntervalMs??2e3;if((0,i.y)(c,"pollIntervalMs",100),void 0!==b.onError&&"function"!=typeof b.onError)throw TypeError("MCP provider source onError must be a function");return new k(a,c,b.onError??(()=>void 0))}},57782:(a,b,c)=>{c.d(b,{Aw:()=>f,k2:()=>d,kn:()=>e});let d="@hile/mcp/providers/",e="@hile/mcp/resource-updates",f=Object.freeze({invoke:"/-/mcp/invoke",complete:"/-/mcp/complete"})},60339:(a,b,c)=>{let d,e,f,g,h,i,j,k,l,m;c.d(b,{_k:()=>gL,Zn:()=>gM,Hm:()=>eP,hw:()=>g8,JF:()=>gz,p0:()=>g2,e0:()=>hg,QK:()=>g9,IK:()=>g7,yH:()=>he,ld:()=>hf,PA:()=>g6,aV:()=>eA});var n,o,p,q,r,s=Object.create,t=Object.defineProperty,u=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,w=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,y=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),z=(a,b,c)=>(c=null!=a?s(w(a)):{},((a,b,c)=>{if(b&&"object"==typeof b||"function"==typeof b)for(var d,e=v(b),f=0,g=e.length;f<g;f++)d=e[f],x.call(a,d)||void 0===d||t(a,d,{get:(a=>b[a]).bind(null,d),enumerable:!(c=u(b,d))||c.enumerable});return a})(!b&&a&&a.__esModule?c:t(c,"default",{value:a,enumerable:!0}),a));let A=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),B=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),C=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),D=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);var E=c(62710),F=c(29951);r||(r={});var G=c(64586),H=c(35789);let I="2025-11-25",J=[I,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],K="io.modelcontextprotocol/protocolVersion",L="io.modelcontextprotocol/clientInfo",M="io.modelcontextprotocol/serverInfo",N="io.modelcontextprotocol/clientCapabilities",O="io.modelcontextprotocol/subscriptionId",P="io.modelcontextprotocol/logLevel",Q=E.RZ(()=>E.KC([E.Yj(),E.ai(),E.zM(),E.ch(),E.g1(E.Yj(),Q),E.YO(Q)])),R=E.g1(E.Yj(),Q),S=E.YO(Q),T=E.KC([E.Yj(),E.ai().int()]),U=E.Yj(),V=E.Ik({ttl:E.ai().optional()}),W=E.Ik({taskId:E.Yj()}),X=E._H({progressToken:T.optional(),"io.modelcontextprotocol/related-task":W.optional()}),Y=E.Ik({_meta:X.optional()}),Z=Y.extend({task:V.optional()}),$=E.Ik({method:E.Yj(),params:Y.loose().optional()}),_=E.Ik({_meta:X.optional()}),aa=E.Ik({method:E.Yj(),params:_.loose().optional()}),ab=E._H({get[M](){return aq.optional().catch(void 0)}}),ac=E._H({_meta:ab.optional()}),ad=E.KC([E.Yj(),E.ai().int()]),ae=E.Ik({jsonrpc:E.eu("2.0"),id:ad,...$.shape}).strict(),af=E.Ik({jsonrpc:E.eu("2.0"),...aa.shape}).strict(),ag=E.Ik({jsonrpc:E.eu("2.0"),id:ad,result:ac}).strict(),ah=E.Ik({jsonrpc:E.eu("2.0"),id:ad.optional(),error:E.Ik({code:E.ai().int(),message:E.Yj(),data:E.L5().optional()})}).strict(),ai=E.KC([ae,af,ag,ah]),aj=E.KC([ag,ah]),ak=ac.strict(),al=_.extend({requestId:ad.optional(),reason:E.Yj().optional()}),am=aa.extend({method:E.eu("notifications/cancelled"),params:al}),an=E.Ik({src:E.Yj(),mimeType:E.Yj().optional(),sizes:E.YO(E.Yj()).optional(),theme:E.k5(["light","dark"]).optional()}),ao=E.Ik({icons:E.YO(an).optional()}),ap=E.Ik({name:E.Yj(),title:E.Yj().optional()}),aq=ap.extend({...ap.shape,...ao.shape,version:E.Yj(),websiteUrl:E.Yj().optional(),description:E.Yj().optional()}),ar=E.E$(E.Ik({applyDefaults:E.zM().optional()}),R),as=E.vk(a=>a&&"object"==typeof a&&!Array.isArray(a)&&0===Object.keys(a).length?{form:{}}:a,E.E$(E.Ik({form:ar.optional(),url:R.optional()}),R.optional())),at=E._H({list:R.optional(),cancel:R.optional(),requests:E._H({sampling:E._H({createMessage:R.optional()}).optional(),elicitation:E._H({create:R.optional()}).optional()}).optional()}),au=E._H({list:R.optional(),cancel:R.optional(),requests:E._H({tools:E._H({call:R.optional()}).optional()}).optional()}),av=E.Ik({experimental:E.g1(E.Yj(),R).optional(),sampling:E.Ik({context:R.optional(),tools:R.optional()}).optional(),elicitation:as.optional(),roots:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:at.optional(),extensions:E.g1(E.Yj(),R).optional()}),aw=Y.extend({protocolVersion:E.Yj(),capabilities:av,clientInfo:aq}),ax=$.extend({method:E.eu("initialize"),params:aw}),ay=E.Ik({experimental:E.g1(E.Yj(),R).optional(),logging:R.optional(),completions:R.optional(),prompts:E.Ik({listChanged:E.zM().optional()}).optional(),resources:E.Ik({subscribe:E.zM().optional(),listChanged:E.zM().optional()}).optional(),tools:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:au.optional(),extensions:E.g1(E.Yj(),R).optional()}),az=ac.extend({protocolVersion:E.Yj(),capabilities:ay,serverInfo:aq,instructions:E.Yj().optional()}),aA=aa.extend({method:E.eu("notifications/initialized"),params:_.optional()}),aB=$.extend({method:E.eu("server/discover"),params:Y.optional()}),aC=ac.extend({supportedVersions:E.YO(E.Yj()),capabilities:ay,instructions:E.Yj().optional()}),aD=$.extend({method:E.eu("ping"),params:Y.optional()}),aE=E.Ik({progress:E.ai(),total:E.lq(E.ai()),message:E.lq(E.Yj())}),aF=E.Ik({..._.shape,...aE.shape,progressToken:T}),aG=aa.extend({method:E.eu("notifications/progress"),params:aF}),aH=Y.extend({cursor:U.optional()}),aI=$.extend({params:aH.optional()}),aJ=ac.extend({nextCursor:U.optional()}),aK=E.Ik({uri:E.Yj(),mimeType:E.lq(E.Yj()),_meta:E.g1(E.Yj(),E.L5()).optional()}),aL=aK.extend({text:E.Yj()}),aM=E.Yj().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),aN=aK.extend({blob:aM}),aO=E.k5(["user","assistant"]),aP=E.Ik({audience:E.YO(aO).optional(),priority:E.ai().min(0).max(1).optional(),lastModified:F.w$({offset:!0}).optional()}),aQ=E.Ik({...ap.shape,...ao.shape,uri:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),size:E.lq(E.ai()),annotations:aP.optional(),_meta:E.lq(E._H({}))}),aR=E.Ik({...ap.shape,...ao.shape,uriTemplate:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),annotations:aP.optional(),_meta:E.lq(E._H({}))}),aS=aI.extend({method:E.eu("resources/list")}),aT=aJ.extend({resources:E.YO(aQ)}),aU=aI.extend({method:E.eu("resources/templates/list")}),aV=aJ.extend({resourceTemplates:E.YO(aR)}),aW=Y.extend({uri:E.Yj()}),aX=$.extend({method:E.eu("resources/read"),params:aW}),aY=ac.extend({contents:E.YO(E.KC([aL,aN]))}),aZ=aa.extend({method:E.eu("notifications/resources/list_changed"),params:_.optional()}),a$=$.extend({method:E.eu("resources/subscribe"),params:aW}),a_=$.extend({method:E.eu("resources/unsubscribe"),params:aW}),a0=E.Ik({toolsListChanged:E.zM().optional(),promptsListChanged:E.zM().optional(),resourcesListChanged:E.zM().optional(),resourceSubscriptions:E.YO(E.Yj()).optional()}),a1=Y.extend({notifications:a0}),a2=$.extend({method:E.eu("subscriptions/listen"),params:a1}),a3=_.extend({notifications:a0}),a4=aa.extend({method:E.eu("notifications/subscriptions/acknowledged"),params:a3}),a5=ab.extend({[O]:ad}),a6=ac.extend({_meta:a5}),a7=_.extend({uri:E.Yj()}),a8=aa.extend({method:E.eu("notifications/resources/updated"),params:a7}),a9=E.Ik({name:E.Yj(),description:E.lq(E.Yj()),required:E.lq(E.zM())}),ba=E.Ik({...ap.shape,...ao.shape,description:E.lq(E.Yj()),arguments:E.lq(E.YO(a9)),_meta:E.lq(E._H({}))}),bb=aI.extend({method:E.eu("prompts/list")}),bc=aJ.extend({prompts:E.YO(ba)}),bd=Y.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional()}),be=$.extend({method:E.eu("prompts/get"),params:bd}),bf=E.Ik({type:E.eu("text"),text:E.Yj(),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bg=E.Ik({type:E.eu("image"),data:aM,mimeType:E.Yj(),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bh=E.Ik({type:E.eu("audio"),data:aM,mimeType:E.Yj(),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bi=E.Ik({type:E.eu("tool_use"),name:E.Yj(),id:E.Yj(),input:E.g1(E.Yj(),E.L5()),_meta:E.g1(E.Yj(),E.L5()).optional()}),bj=E.Ik({type:E.eu("resource"),resource:E.KC([aL,aN]),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bk=aQ.extend({type:E.eu("resource_link")}),bl=E.KC([bf,bg,bh,bk,bj]),bm=E.Ik({role:aO,content:bl}),bn=ac.extend({description:E.Yj().optional(),messages:E.YO(bm)}),bo=aa.extend({method:E.eu("notifications/prompts/list_changed"),params:_.optional()}),bp=E.Ik({title:E.Yj().optional(),readOnlyHint:E.zM().optional(),destructiveHint:E.zM().optional(),idempotentHint:E.zM().optional(),openWorldHint:E.zM().optional()}),bq=E.Ik({taskSupport:E.k5(["required","optional","forbidden"]).optional()}),br=E.Ik({...ap.shape,...ao.shape,description:E.Yj().optional(),inputSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),Q).optional(),required:E.YO(E.Yj()).optional()}).catchall(E.L5()),outputSchema:E._H({$schema:E.Yj().optional()}).optional(),annotations:bp.optional(),execution:bq.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bs=aI.extend({method:E.eu("tools/list")}),bt=aJ.extend({tools:E.YO(br)}),bu=ac.extend({content:E.YO(bl).default([]),structuredContent:E.L5().optional(),isError:E.zM().optional()}),bv=bu.or(ac.extend({toolResult:E.L5()})),bw=Z.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.L5()).optional()}),bx=$.extend({method:E.eu("tools/call"),params:bw}),by=aa.extend({method:E.eu("notifications/tools/list_changed"),params:_.optional()}),bz=E.Ik({autoRefresh:E.zM().default(!0),debounceMs:E.ai().int().nonnegative().default(300)}),bA=E.k5(["debug","info","notice","warning","error","critical","alert","emergency"]),bB=Y.extend({level:bA}),bC=$.extend({method:E.eu("logging/setLevel"),params:bB}),bD=_.extend({level:bA,logger:E.Yj().optional(),data:E.L5()}),bE=aa.extend({method:E.eu("notifications/message"),params:bD}),bF=E.Ik({name:E.Yj().optional()}),bG=E.Ik({hints:E.YO(bF).optional(),costPriority:E.ai().min(0).max(1).optional(),speedPriority:E.ai().min(0).max(1).optional(),intelligencePriority:E.ai().min(0).max(1).optional()}),bH=E.Ik({mode:E.k5(["auto","required","none"]).optional()}),bI=E.Ik({type:E.eu("tool_result"),toolUseId:E.Yj().describe("The unique identifier for the corresponding tool call."),content:E.YO(bl),structuredContent:E.L5().optional(),isError:E.zM().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bJ=E.gM("type",[bf,bg,bh]),bK=E.gM("type",[bf,bg,bh,bi,bI]),bL=E.Ik({role:aO,content:E.KC([bK,E.YO(bK)]),_meta:E.g1(E.Yj(),E.L5()).optional()}),bM=Z.extend({messages:E.YO(bL),modelPreferences:bG.optional(),systemPrompt:E.Yj().optional(),includeContext:E.k5(["none","thisServer","allServers"]).optional(),temperature:E.ai().optional(),maxTokens:E.ai().int(),stopSequences:E.YO(E.Yj()).optional(),metadata:R.optional(),tools:E.YO(br).optional(),toolChoice:bH.optional()}),bN=$.extend({method:E.eu("sampling/createMessage"),params:bM}),bO=ac.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens"]).or(E.Yj())),role:aO,content:bJ}),bP=ac.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens","toolUse"]).or(E.Yj())),role:aO,content:E.KC([bK,E.YO(bK)])}),bQ=E.Ik({type:E.eu("boolean"),title:E.Yj().optional(),description:E.Yj().optional(),default:E.zM().optional()}),bR=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),minLength:E.ai().optional(),maxLength:E.ai().optional(),format:E.k5(["email","uri","date","date-time"]).optional(),default:E.Yj().optional()}),bS=E.Ik({type:E.k5(["number","integer"]),title:E.Yj().optional(),description:E.Yj().optional(),minimum:E.ai().optional(),maximum:E.ai().optional(),default:E.ai().optional()}),bT=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),default:E.Yj().optional()}),bU=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),oneOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()})),default:E.Yj().optional()}),bV=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),enumNames:E.YO(E.Yj()).optional(),default:E.Yj().optional()}),bW=E.KC([bT,bU]),bX=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({type:E.eu("string"),enum:E.YO(E.Yj())}),default:E.YO(E.Yj()).optional()}),bY=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({anyOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()}))}),default:E.YO(E.Yj()).optional()}),bZ=E.KC([bX,bY]),b$=E.KC([bV,bW,bZ]),b_=E.KC([b$,bQ,bR,bS]),b0=Z.extend({mode:E.eu("form").optional(),message:E.Yj(),requestedSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),b_),required:E.YO(E.Yj()).optional()}).catchall(E.L5())}),b1=Z.extend({mode:E.eu("url"),message:E.Yj(),elicitationId:E.Yj(),url:E.Yj().url()}),b2=E.KC([b0,b1]),b3=$.extend({method:E.eu("elicitation/create"),params:b2}),b4=_.extend({elicitationId:E.Yj()}),b5=aa.extend({method:E.eu("notifications/elicitation/complete"),params:b4}),b6=ac.extend({action:E.k5(["accept","decline","cancel"]),content:E.vk(a=>null===a?void 0:a,E.g1(E.Yj(),E.KC([E.Yj(),E.ai(),E.zM(),E.YO(E.Yj())])).optional())}),b7=E.Ik({type:E.eu("ref/resource"),uri:E.Yj()}),b8=E.Ik({type:E.eu("ref/prompt"),name:E.Yj()}),b9=Y.extend({ref:E.KC([b8,b7]),argument:E.Ik({name:E.Yj(),value:E.Yj()}),context:E.Ik({arguments:E.g1(E.Yj(),E.Yj()).optional()}).optional()}),ca=$.extend({method:E.eu("completion/complete"),params:b9}),cb=ac.extend({completion:E._H({values:E.YO(E.Yj()).max(100),total:E.lq(E.ai().int()),hasMore:E.lq(E.zM())})}),cc=E.Ik({uri:E.Yj().startsWith("file://"),name:E.Yj().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),cd=$.extend({method:E.eu("roots/list"),params:Y.optional()}),ce=ac.extend({roots:E.YO(cc)}),cf=aa.extend({method:E.eu("notifications/roots/list_changed"),params:_.optional()}),cg=E._H({ttl:E.ai().optional(),pollInterval:E.ai().optional()}),ch=E.k5(["working","input_required","completed","failed","cancelled"]),ci=E.Ik({taskId:E.Yj(),status:ch,ttl:E.KC([E.ai(),E.ch()]),createdAt:E.Yj(),lastUpdatedAt:E.Yj(),pollInterval:E.lq(E.ai()),statusMessage:E.lq(E.Yj())}),cj=ac.extend({task:ci}),ck=_.merge(ci),cl=aa.extend({method:E.eu("notifications/tasks/status"),params:ck}),cm=$.extend({method:E.eu("tasks/get"),params:Y.extend({taskId:E.Yj()})}),cn=ac.merge(ci),co=$.extend({method:E.eu("tasks/result"),params:Y.extend({taskId:E.Yj()})}),cp=ac.loose(),cq=aI.extend({method:E.eu("tasks/list")}),cr=aJ.extend({tasks:E.YO(ci)}),cs=$.extend({method:E.eu("tasks/cancel"),params:Y.extend({taskId:E.Yj()})}),ct=ac.merge(ci),cu=E.KC([aD,ax,aB,ca,bC,be,bb,aS,aU,aX,a$,a_,a2,bx,bs]),cv=E.KC([am,aG,aA,cf]),cw=E.KC([ak,bO,bP,b6,ce]),cx=E.KC([aD,bN,b3,cd]),cy=E.KC([am,aG,bE,a8,aZ,by,bo,a4,b5]),cz=E.KC([ak,az,aC,cb,bn,bc,aT,aV,aY,bu,bt,a6]),cA=E.OZ().superRefine((a,b)=>{if(!URL.canParse(a))return b.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),G.tm}).refine(a=>{let b=new URL(a);return"javascript:"!==b.protocol&&"data:"!==b.protocol&&"vbscript:"!==b.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),cB=E._H({resource:E.Yj().url(),authorization_servers:E.YO(cA).optional(),jwks_uri:E.Yj().url().optional(),scopes_supported:E.YO(E.Yj()).optional(),bearer_methods_supported:E.YO(E.Yj()).optional(),resource_signing_alg_values_supported:E.YO(E.Yj()).optional(),resource_name:E.Yj().optional(),resource_documentation:E.Yj().optional(),resource_policy_uri:E.Yj().url().optional(),resource_tos_uri:E.Yj().url().optional(),tls_client_certificate_bound_access_tokens:E.zM().optional(),authorization_details_types_supported:E.YO(E.Yj()).optional(),dpop_signing_alg_values_supported:E.YO(E.Yj()).optional(),dpop_bound_access_tokens_required:E.zM().optional()}),cC=E._H({issuer:E.Yj(),authorization_endpoint:cA,token_endpoint:cA,registration_endpoint:cA.optional(),scopes_supported:E.YO(E.Yj()).optional(),response_types_supported:E.YO(E.Yj()),response_modes_supported:E.YO(E.Yj()).optional(),grant_types_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),service_documentation:cA.optional(),revocation_endpoint:cA.optional(),revocation_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),revocation_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),introspection_endpoint:E.Yj().optional(),introspection_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),introspection_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),code_challenge_methods_supported:E.YO(E.Yj()).optional(),client_id_metadata_document_supported:E.zM().optional(),authorization_response_iss_parameter_supported:E.zM().optional().catch(void 0)}),cD=E._H({issuer:E.Yj(),authorization_endpoint:cA,token_endpoint:cA,userinfo_endpoint:cA.optional(),jwks_uri:cA,registration_endpoint:cA.optional(),scopes_supported:E.YO(E.Yj()).optional(),response_types_supported:E.YO(E.Yj()),response_modes_supported:E.YO(E.Yj()).optional(),grant_types_supported:E.YO(E.Yj()).optional(),acr_values_supported:E.YO(E.Yj()).optional(),subject_types_supported:E.YO(E.Yj()),id_token_signing_alg_values_supported:E.YO(E.Yj()),id_token_encryption_alg_values_supported:E.YO(E.Yj()).optional(),id_token_encryption_enc_values_supported:E.YO(E.Yj()).optional(),userinfo_signing_alg_values_supported:E.YO(E.Yj()).optional(),userinfo_encryption_alg_values_supported:E.YO(E.Yj()).optional(),userinfo_encryption_enc_values_supported:E.YO(E.Yj()).optional(),request_object_signing_alg_values_supported:E.YO(E.Yj()).optional(),request_object_encryption_alg_values_supported:E.YO(E.Yj()).optional(),request_object_encryption_enc_values_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),display_values_supported:E.YO(E.Yj()).optional(),claim_types_supported:E.YO(E.Yj()).optional(),claims_supported:E.YO(E.Yj()).optional(),service_documentation:E.Yj().optional(),claims_locales_supported:E.YO(E.Yj()).optional(),ui_locales_supported:E.YO(E.Yj()).optional(),claims_parameter_supported:E.zM().optional(),request_parameter_supported:E.zM().optional(),request_uri_parameter_supported:E.zM().optional(),require_request_uri_registration:E.zM().optional(),op_policy_uri:cA.optional(),op_tos_uri:cA.optional(),client_id_metadata_document_supported:E.zM().optional(),authorization_response_iss_parameter_supported:E.zM().optional().catch(void 0)}),cE=E.Ik({...cD.shape,...cC.pick({code_challenge_methods_supported:!0}).shape}),cF=E.Ik({access_token:E.Yj(),id_token:E.Yj().optional(),token_type:E.Yj(),expires_in:H.ai().optional(),scope:E.Yj().optional(),refresh_token:E.Yj().optional()}).strip(),cG=E.Ik({issued_token_type:E.eu("urn:ietf:params:oauth:token-type:id-jag"),access_token:E.Yj(),token_type:E.Yj().optional(),expires_in:E.ai().optional(),scope:E.Yj().optional()}).strip(),cH=E.Ik({error:E.Yj(),error_description:E.Yj().optional(),error_uri:E.Yj().optional()}),cI=cA.optional().or(E.eu("").transform(()=>void 0)),cJ=E.Ik({redirect_uris:E.YO(cA),token_endpoint_auth_method:E.Yj().optional(),grant_types:E.YO(E.Yj()).optional(),response_types:E.YO(E.Yj()).optional(),application_type:E.Yj().optional(),client_name:E.Yj().optional(),client_uri:cA.optional(),logo_uri:cI,scope:E.Yj().optional(),contacts:E.YO(E.Yj()).optional(),tos_uri:cI,policy_uri:E.Yj().optional(),jwks_uri:cA.optional(),jwks:E.bz().optional(),software_id:E.Yj().optional(),software_version:E.Yj().optional(),software_statement:E.Yj().optional()}).strip(),cK=E.Ik({client_id:E.Yj(),client_secret:E.Yj().optional(),client_id_issued_at:E.ai().optional(),client_secret_expires_at:E.ai().optional()}).strip(),cL=cJ.merge(cK),cM=E.Ik({error:E.Yj(),error_description:E.Yj().optional()}).strip(),cN=E.Ik({token:E.Yj(),token_type_hint:E.Yj().optional()}).strip();var cO=c(49417),cP=c(28621);let cQ=Symbol.for("mcp.sdk.errorBrands");function cR(a,b){let c=new Set,d=b;for(;"function"==typeof d;){let a=d.mcpBrand;Object.prototype.hasOwnProperty.call(d,"mcpBrand")&&"string"==typeof a&&c.add(a),d=Object.getPrototypeOf(d)}0!==c.size&&Object.defineProperty(a,cQ,{value:c,enumerable:!1,configurable:!0})}function cS(a,b){try{if("object"==typeof b&&null!==b&&Object.prototype.hasOwnProperty.call(a,"mcpBrand")&&"string"==typeof a.mcpBrand&&Object.prototype.hasOwnProperty.call(b,cQ)){let c=b[cQ];if(c&&"function"==typeof c.has&&c.has(a.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(a,b)}let cT=((n={}).InvalidRequest="invalid_request",n.InvalidClient="invalid_client",n.InvalidGrant="invalid_grant",n.UnauthorizedClient="unauthorized_client",n.UnsupportedGrantType="unsupported_grant_type",n.InvalidScope="invalid_scope",n.AccessDenied="access_denied",n.ServerError="server_error",n.TemporarilyUnavailable="temporarily_unavailable",n.UnsupportedResponseType="unsupported_response_type",n.UnsupportedTokenType="unsupported_token_type",n.InvalidToken="invalid_token",n.MethodNotAllowed="method_not_allowed",n.TooManyRequests="too_many_requests",n.InvalidClientMetadata="invalid_client_metadata",n.InvalidRedirectUri="invalid_redirect_uri",n.InsufficientScope="insufficient_scope",n.InvalidTarget="invalid_target",n);var cU=class a extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](a){return cS(this,a)}static isInstance(a){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return cS(this,a)}constructor(a,b,c){super(b),this.code=a,this.errorUri=c,this.name="OAuthError",cR(this,new.target)}toResponseObject(){let a={error:this.code,error_description:this.message};return this.errorUri&&(a.error_uri=this.errorUri),a}static fromResponse(b){return new a(b.error,b.error_description??b.error,b.error_uri)}};let cV=((o={}).NotConnected="NOT_CONNECTED",o.AlreadyConnected="ALREADY_CONNECTED",o.NotInitialized="NOT_INITIALIZED",o.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",o.RequestTimeout="REQUEST_TIMEOUT",o.ConnectionClosed="CONNECTION_CLOSED",o.SendFailed="SEND_FAILED",o.InvalidResult="INVALID_RESULT",o.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",o.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",o.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",o.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",o.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",o.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",o.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",o.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",o.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",o.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",o.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",o);var cW=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](a){return cS(this,a)}static isInstance(a){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return cS(this,a)}constructor(a,b,c){super(b),this.code=a,this.data=c,this.name="SdkError",cR(this,new.target)}};(class extends cW{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(a,b,c){super(a,b,c),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let cX={};function cY(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function cZ(a,b){let c={};for(let[d,e]of Object.entries(a)){if(void 0===e)continue;let a=void 0===b?void 0:b[d];if(void 0===a){c[d]=e;continue}if(cY(e)&&cY(a)){let b={};for(let[c,f]of Object.entries(e))void 0!==f&&void 0===a[c]&&("elicitation"!==d||"form"!==c||void 0!==a.form||void 0!==a.url)&&(b[c]=f);Object.keys(b).length>0&&(c[d]=b)}}return Object.keys(c).length>0?c:void 0}let c$="2026-07-28",c_=[c$];function c0(a){return a.filter(a=>a>=c$)}function c1(a){let b=a.structuredContent;return void 0===b||!("object"!=typeof b||null===b||Array.isArray(b))||a.content?.some(a=>"text"===a.type)?a:{...a,content:[...a.content??[],{type:"text",text:JSON.stringify(b)}]}}let c2=["task","inputRequests","requestState"];function c3(a){return null===a||"object"!=typeof a||Array.isArray(a)||void 0!==a.content||c2.some(b=>b in a)?a:{...a,content:[]}}function c4(){let a,b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,aA,aB,aC,aD,aE,aF,aG,aH,aI,aJ,aK,aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,aX,aY,aZ,a$,a_,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,ba,bb,bc,bd,be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt,bu,bv,bw,bx,by;return d??=(a=E.RZ(()=>E.KC([E.Yj(),E.ai(),E.zM(),E.ch(),E.g1(E.Yj(),a),E.YO(a)])),b=E.g1(E.Yj(),a),c=E.KC([E.Yj(),E.ai().int()]),e=E.Yj(),f=E.Ik({ttl:E.ai().optional()}),g=E.Ik({taskId:E.Yj()}),h=E._H({progressToken:c.optional(),"io.modelcontextprotocol/related-task":g.optional()}),j=(i=E.Ik({_meta:h.optional()})).extend({task:f.optional()}),k=E.Ik({method:E.Yj(),params:i.loose().optional()}),l=E.Ik({_meta:h.optional()}),m=E.Ik({method:E.Yj(),params:l.loose().optional()}),n=E._H({_meta:h.optional()}),o=E.KC([E.Yj(),E.ai().int()]),p=n.strict(),q=l.extend({requestId:o.optional(),reason:E.Yj().optional()}),r=m.extend({method:E.eu("notifications/cancelled"),params:q}),s=E.Ik({src:E.Yj(),mimeType:E.Yj().optional(),sizes:E.YO(E.Yj()).optional(),theme:E.k5(["light","dark"]).optional()}),t=E.Ik({icons:E.YO(s).optional()}),v=(u=E.Ik({name:E.Yj(),title:E.Yj().optional()})).extend({...u.shape,...t.shape,version:E.Yj(),websiteUrl:E.Yj().optional(),description:E.Yj().optional()}),w=E.E$(E.Ik({applyDefaults:E.zM().optional()}),b),x=E.vk(a=>a&&"object"==typeof a&&!Array.isArray(a)&&0===Object.keys(a).length?{form:{}}:a,E.E$(E.Ik({form:w.optional(),url:b.optional()}),b.optional())),y=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({sampling:E._H({createMessage:b.optional()}).optional(),elicitation:E._H({create:b.optional()}).optional()}).optional()}),z=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({tools:E._H({call:b.optional()}).optional()}).optional()}),A=E.Ik({experimental:E.g1(E.Yj(),b).optional(),sampling:E.Ik({context:b.optional(),tools:b.optional()}).optional(),elicitation:x.optional(),roots:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:y.optional(),extensions:E.g1(E.Yj(),b).optional()}),B=i.extend({protocolVersion:E.Yj(),capabilities:A,clientInfo:v}),C=k.extend({method:E.eu("initialize"),params:B}),D=E.Ik({experimental:E.g1(E.Yj(),b).optional(),logging:b.optional(),completions:b.optional(),prompts:E.Ik({listChanged:E.zM().optional()}).optional(),resources:E.Ik({subscribe:E.zM().optional(),listChanged:E.zM().optional()}).optional(),tools:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:z.optional(),extensions:E.g1(E.Yj(),b).optional()}),G=n.extend({protocolVersion:E.Yj(),capabilities:D,serverInfo:v,instructions:E.Yj().optional()}),H=m.extend({method:E.eu("notifications/initialized"),params:l.optional()}),I=k.extend({method:E.eu("ping"),params:i.optional()}),J=E.Ik({progress:E.ai(),total:E.lq(E.ai()),message:E.lq(E.Yj())}),K=E.Ik({...l.shape,...J.shape,progressToken:c}),L=m.extend({method:E.eu("notifications/progress"),params:K}),M=i.extend({cursor:e.optional()}),N=k.extend({params:M.optional()}),O=n.extend({nextCursor:e.optional()}),Q=(P=E.Ik({uri:E.Yj(),mimeType:E.lq(E.Yj()),_meta:E.g1(E.Yj(),E.L5()).optional()})).extend({text:E.Yj()}),R=E.Yj().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),S=P.extend({blob:R}),T=E.k5(["user","assistant"]),U=E.Ik({audience:E.YO(T).optional(),priority:E.ai().min(0).max(1).optional(),lastModified:F.w$({offset:!0}).optional()}),V=E.Ik({...u.shape,...t.shape,uri:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),size:E.lq(E.ai()),annotations:U.optional(),_meta:E.lq(E._H({}))}),W=E.Ik({...u.shape,...t.shape,uriTemplate:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),annotations:U.optional(),_meta:E.lq(E._H({}))}),X=N.extend({method:E.eu("resources/list")}),Y=O.extend({resources:E.YO(V)}),Z=N.extend({method:E.eu("resources/templates/list")}),$=O.extend({resourceTemplates:E.YO(W)}),_=i.extend({uri:E.Yj()}),aa=k.extend({method:E.eu("resources/read"),params:_}),ab=n.extend({contents:E.YO(E.KC([Q,S]))}),ac=m.extend({method:E.eu("notifications/resources/list_changed"),params:l.optional()}),ad=k.extend({method:E.eu("resources/subscribe"),params:_}),ae=k.extend({method:E.eu("resources/unsubscribe"),params:_}),af=l.extend({uri:E.Yj()}),ag=m.extend({method:E.eu("notifications/resources/updated"),params:af}),ah=E.Ik({name:E.Yj(),description:E.lq(E.Yj()),required:E.lq(E.zM())}),ai=E.Ik({...u.shape,...t.shape,description:E.lq(E.Yj()),arguments:E.lq(E.YO(ah)),_meta:E.lq(E._H({}))}),aj=N.extend({method:E.eu("prompts/list")}),ak=O.extend({prompts:E.YO(ai)}),al=i.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional()}),am=k.extend({method:E.eu("prompts/get"),params:al}),an=E.Ik({type:E.eu("text"),text:E.Yj(),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),ao=E.Ik({type:E.eu("image"),data:R,mimeType:E.Yj(),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),ap=E.Ik({type:E.eu("audio"),data:R,mimeType:E.Yj(),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aq=E.Ik({type:E.eu("tool_use"),name:E.Yj(),id:E.Yj(),input:E.g1(E.Yj(),E.L5()),_meta:E.g1(E.Yj(),E.L5()).optional()}),ar=E.Ik({type:E.eu("resource"),resource:E.KC([Q,S]),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),as=V.extend({type:E.eu("resource_link")}),at=E.KC([an,ao,ap,as,ar]),au=E.Ik({role:T,content:at}),av=n.extend({description:E.Yj().optional(),messages:E.YO(au)}),aw=m.extend({method:E.eu("notifications/prompts/list_changed"),params:l.optional()}),ax=E.Ik({title:E.Yj().optional(),readOnlyHint:E.zM().optional(),destructiveHint:E.zM().optional(),idempotentHint:E.zM().optional(),openWorldHint:E.zM().optional()}),ay=E.Ik({taskSupport:E.k5(["required","optional","forbidden"]).optional()}),az=E.Ik({...u.shape,...t.shape,description:E.Yj().optional(),inputSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),a).optional(),required:E.YO(E.Yj()).optional()}).catchall(E.L5()),outputSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),a).optional(),required:E.YO(E.Yj()).optional()}).catchall(E.L5()).optional(),annotations:ax.optional(),execution:ay.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aA=N.extend({method:E.eu("tools/list")}),aB=O.extend({tools:E.YO(az)}),aC=n.extend({content:E.YO(at),structuredContent:E.g1(E.Yj(),E.L5()).optional(),isError:E.zM().optional()}),aD=j.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.L5()).optional()}),aE=k.extend({method:E.eu("tools/call"),params:aD}),aF=m.extend({method:E.eu("notifications/tools/list_changed"),params:l.optional()}),aG=E.k5(["debug","info","notice","warning","error","critical","alert","emergency"]),aH=i.extend({level:aG}),aI=k.extend({method:E.eu("logging/setLevel"),params:aH}),aJ=l.extend({level:aG,logger:E.Yj().optional(),data:E.L5()}),aK=m.extend({method:E.eu("notifications/message"),params:aJ}),aL=E.Ik({name:E.Yj().optional()}),aM=E.Ik({hints:E.YO(aL).optional(),costPriority:E.ai().min(0).max(1).optional(),speedPriority:E.ai().min(0).max(1).optional(),intelligencePriority:E.ai().min(0).max(1).optional()}),aN=E.Ik({mode:E.k5(["auto","required","none"]).optional()}),aO=E.Ik({type:E.eu("tool_result"),toolUseId:E.Yj().describe("The unique identifier for the corresponding tool call."),content:E.YO(at),structuredContent:E.Ik({}).loose().optional(),isError:E.zM().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aP=E.gM("type",[an,ao,ap]),aQ=E.gM("type",[an,ao,ap,aq,aO]),aR=E.Ik({role:T,content:E.KC([aQ,E.YO(aQ)]),_meta:E.g1(E.Yj(),E.L5()).optional()}),aS=j.extend({messages:E.YO(aR),modelPreferences:aM.optional(),systemPrompt:E.Yj().optional(),includeContext:E.k5(["none","thisServer","allServers"]).optional(),temperature:E.ai().optional(),maxTokens:E.ai().int(),stopSequences:E.YO(E.Yj()).optional(),metadata:b.optional(),tools:E.YO(az).optional(),toolChoice:aN.optional()}),aT=k.extend({method:E.eu("sampling/createMessage"),params:aS}),aU=n.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens"]).or(E.Yj())),role:T,content:aP}),aV=n.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens","toolUse"]).or(E.Yj())),role:T,content:E.KC([aQ,E.YO(aQ)])}),aW=E.Ik({type:E.eu("boolean"),title:E.Yj().optional(),description:E.Yj().optional(),default:E.zM().optional()}),aX=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),minLength:E.ai().optional(),maxLength:E.ai().optional(),format:E.k5(["email","uri","date","date-time"]).optional(),default:E.Yj().optional()}),aY=E.Ik({type:E.k5(["number","integer"]),title:E.Yj().optional(),description:E.Yj().optional(),minimum:E.ai().optional(),maximum:E.ai().optional(),default:E.ai().optional()}),aZ=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),default:E.Yj().optional()}),a$=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),oneOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()})),default:E.Yj().optional()}),a_=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),enumNames:E.YO(E.Yj()).optional(),default:E.Yj().optional()}),a0=E.KC([aZ,a$]),a1=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({type:E.eu("string"),enum:E.YO(E.Yj())}),default:E.YO(E.Yj()).optional()}),a2=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({anyOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()}))}),default:E.YO(E.Yj()).optional()}),a3=E.KC([a1,a2]),a4=E.KC([a_,a0,a3]),a5=E.KC([a4,aW,aX,aY]),a6=j.extend({mode:E.eu("form").optional(),message:E.Yj(),requestedSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),a5),required:E.YO(E.Yj()).optional()}).catchall(E.L5())}),a7=j.extend({mode:E.eu("url"),message:E.Yj(),elicitationId:E.Yj(),url:E.Yj().url()}),a8=E.KC([a6,a7]),a9=k.extend({method:E.eu("elicitation/create"),params:a8}),ba=l.extend({elicitationId:E.Yj()}),bb=m.extend({method:E.eu("notifications/elicitation/complete"),params:ba}),bc=n.extend({action:E.k5(["accept","decline","cancel"]),content:E.vk(a=>null===a?void 0:a,E.g1(E.Yj(),E.KC([E.Yj(),E.ai(),E.zM(),E.YO(E.Yj())])).optional())}),bd=E.Ik({type:E.eu("ref/resource"),uri:E.Yj()}),be=E.Ik({type:E.eu("ref/prompt"),name:E.Yj()}),bf=i.extend({ref:E.KC([be,bd]),argument:E.Ik({name:E.Yj(),value:E.Yj()}),context:E.Ik({arguments:E.g1(E.Yj(),E.Yj()).optional()}).optional()}),bg=k.extend({method:E.eu("completion/complete"),params:bf}),bh=n.extend({completion:E._H({values:E.YO(E.Yj()).max(100),total:E.lq(E.ai().int()),hasMore:E.lq(E.zM())})}),bi=E.Ik({uri:E.Yj().startsWith("file://"),name:E.Yj().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bj=k.extend({method:E.eu("roots/list"),params:i.optional()}),bk=n.extend({roots:E.YO(bi)}),bl=m.extend({method:E.eu("notifications/roots/list_changed"),params:l.optional()}),bm=E._H({ttl:E.ai().optional(),pollInterval:E.ai().optional()}),bn=E.k5(["working","input_required","completed","failed","cancelled"]),bo=E.Ik({taskId:E.Yj(),status:bn,ttl:E.KC([E.ai(),E.ch()]),createdAt:E.Yj(),lastUpdatedAt:E.Yj(),pollInterval:E.lq(E.ai()),statusMessage:E.lq(E.Yj())}),bp=n.extend({task:bo}),bq=l.merge(bo),br=m.extend({method:E.eu("notifications/tasks/status"),params:bq}),bs=k.extend({method:E.eu("tasks/get"),params:i.extend({taskId:E.Yj()})}),bt=n.merge(bo),bu=k.extend({method:E.eu("tasks/result"),params:i.extend({taskId:E.Yj()})}),bv=n.loose(),bw=N.extend({method:E.eu("tasks/list")}),bx=O.extend({tasks:E.YO(bo)}),by=k.extend({method:E.eu("tasks/cancel"),params:i.extend({taskId:E.Yj()})}),{JSONValueSchema:a,JSONObjectSchema:b,ProgressTokenSchema:c,CursorSchema:e,TaskMetadataSchema:f,RelatedTaskMetadataSchema:g,RequestMetaSchema:h,BaseRequestParamsSchema:i,TaskAugmentedRequestParamsSchema:j,RequestSchema:k,NotificationsParamsSchema:l,NotificationSchema:m,ResultSchema:n,RequestIdSchema:o,EmptyResultSchema:p,CancelledNotificationParamsSchema:q,CancelledNotificationSchema:r,IconSchema:s,IconsSchema:t,BaseMetadataSchema:u,ImplementationSchema:v,ClientTasksCapabilitySchema:y,ServerTasksCapabilitySchema:z,ClientCapabilitiesSchema:A,InitializeRequestParamsSchema:B,InitializeRequestSchema:C,ServerCapabilitiesSchema:D,InitializeResultSchema:G,InitializedNotificationSchema:H,PingRequestSchema:I,ProgressSchema:J,ProgressNotificationParamsSchema:K,ProgressNotificationSchema:L,PaginatedRequestParamsSchema:M,PaginatedRequestSchema:N,PaginatedResultSchema:O,ResourceContentsSchema:P,TextResourceContentsSchema:Q,BlobResourceContentsSchema:S,RoleSchema:T,AnnotationsSchema:U,ResourceSchema:V,ResourceTemplateSchema:W,ListResourcesRequestSchema:X,ListResourcesResultSchema:Y,ListResourceTemplatesRequestSchema:Z,ListResourceTemplatesResultSchema:$,ResourceRequestParamsSchema:_,ReadResourceRequestParamsSchema:_,ReadResourceRequestSchema:aa,ReadResourceResultSchema:ab,ResourceListChangedNotificationSchema:ac,SubscribeRequestParamsSchema:_,SubscribeRequestSchema:ad,UnsubscribeRequestParamsSchema:_,UnsubscribeRequestSchema:ae,ResourceUpdatedNotificationParamsSchema:af,ResourceUpdatedNotificationSchema:ag,PromptArgumentSchema:ah,PromptSchema:ai,ListPromptsRequestSchema:aj,ListPromptsResultSchema:ak,GetPromptRequestParamsSchema:al,GetPromptRequestSchema:am,TextContentSchema:an,ImageContentSchema:ao,AudioContentSchema:ap,ToolUseContentSchema:aq,EmbeddedResourceSchema:ar,ResourceLinkSchema:as,ContentBlockSchema:at,PromptMessageSchema:au,GetPromptResultSchema:av,PromptListChangedNotificationSchema:aw,ToolAnnotationsSchema:ax,ToolExecutionSchema:ay,ToolSchema:az,ListToolsRequestSchema:aA,ListToolsResultSchema:aB,CallToolResultSchema:aC,CallToolRequestParamsSchema:aD,CallToolRequestSchema:aE,ToolListChangedNotificationSchema:aF,LoggingLevelSchema:aG,SetLevelRequestParamsSchema:aH,SetLevelRequestSchema:aI,LoggingMessageNotificationParamsSchema:aJ,LoggingMessageNotificationSchema:aK,ModelHintSchema:aL,ModelPreferencesSchema:aM,ToolChoiceSchema:aN,ToolResultContentSchema:aO,SamplingContentSchema:aP,SamplingMessageContentBlockSchema:aQ,SamplingMessageSchema:aR,CreateMessageRequestParamsSchema:aS,CreateMessageRequestSchema:aT,CreateMessageResultSchema:aU,CreateMessageResultWithToolsSchema:aV,BooleanSchemaSchema:aW,StringSchemaSchema:aX,NumberSchemaSchema:aY,UntitledSingleSelectEnumSchemaSchema:aZ,TitledSingleSelectEnumSchemaSchema:a$,LegacyTitledEnumSchemaSchema:a_,SingleSelectEnumSchemaSchema:a0,UntitledMultiSelectEnumSchemaSchema:a1,TitledMultiSelectEnumSchemaSchema:a2,MultiSelectEnumSchemaSchema:a3,EnumSchemaSchema:a4,PrimitiveSchemaDefinitionSchema:a5,ElicitRequestFormParamsSchema:a6,ElicitRequestURLParamsSchema:a7,ElicitRequestParamsSchema:a8,ElicitRequestSchema:a9,ElicitationCompleteNotificationParamsSchema:ba,ElicitationCompleteNotificationSchema:bb,ElicitResultSchema:bc,ResourceTemplateReferenceSchema:bd,PromptReferenceSchema:be,CompleteRequestParamsSchema:bf,CompleteRequestSchema:bg,CompleteResultSchema:bh,RootSchema:bi,ListRootsRequestSchema:bj,ListRootsResultSchema:bk,RootsListChangedNotificationSchema:bl,TaskCreationParamsSchema:bm,TaskStatusSchema:bn,TaskSchema:bo,CreateTaskResultSchema:bp,TaskStatusNotificationParamsSchema:bq,TaskStatusNotificationSchema:br,GetTaskRequestSchema:bs,GetTaskResultSchema:bt,GetTaskPayloadRequestSchema:bu,GetTaskPayloadResultSchema:bv,ListTasksRequestSchema:bw,ListTasksResultSchema:bx,CancelTaskRequestSchema:by,CancelTaskResultSchema:n.merge(bo),ClientRequestSchema:E.KC([I,C,bg,aI,am,aj,X,Z,aa,ad,ae,aE,aA,bs,bu,bw,by]),ClientNotificationSchema:E.KC([r,L,H,bl,br]),ClientResultSchema:E.KC([p,aU,aV,bc,bk,bt,bx,bp]),ServerRequestSchema:E.KC([I,aT,a9,bj,bs,bu,bw,by]),ServerNotificationSchema:E.KC([r,L,aK,ag,ac,aF,aw,br,bb]),ServerResultSchema:E.KC([p,G,bh,av,ak,Y,$,ab,aC,aB,bt,bx,bp]),CallToolResultWireSchema:E.L5().superRefine((a,b)=>{if(!("object"!=typeof a||null===a||Array.isArray(a))&&void 0===a.content){for(let c of c2)if(c in a)return void b.addIssue({code:"custom",message:`content is required when the body carries '${c}' — another result family cannot default into an empty tools/call success`})}}).transform(c3).pipe(aC)})}function c5(a){return"object"!==a.type}let c6=new Set(["const","enum","default","examples"]),c7=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function c8(a){return void 0!==a&&!("string"==typeof a&&a.startsWith("#"))}let c9={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},da={"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},db={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function dc(){if(e)return e;let a=c4();return e={requestSchemas:{ping:a.PingRequestSchema,initialize:a.InitializeRequestSchema,"completion/complete":a.CompleteRequestSchema,"logging/setLevel":a.SetLevelRequestSchema,"prompts/get":a.GetPromptRequestSchema,"prompts/list":a.ListPromptsRequestSchema,"resources/list":a.ListResourcesRequestSchema,"resources/templates/list":a.ListResourceTemplatesRequestSchema,"resources/read":a.ReadResourceRequestSchema,"resources/subscribe":a.SubscribeRequestSchema,"resources/unsubscribe":a.UnsubscribeRequestSchema,"tools/call":a.CallToolRequestSchema,"tools/list":a.ListToolsRequestSchema,"tasks/get":a.GetTaskRequestSchema,"tasks/result":a.GetTaskPayloadRequestSchema,"tasks/list":a.ListTasksRequestSchema,"tasks/cancel":a.CancelTaskRequestSchema,"sampling/createMessage":a.CreateMessageRequestSchema,"elicitation/create":a.ElicitRequestSchema,"roots/list":a.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":a.CancelledNotificationSchema,"notifications/progress":a.ProgressNotificationSchema,"notifications/initialized":a.InitializedNotificationSchema,"notifications/roots/list_changed":a.RootsListChangedNotificationSchema,"notifications/tasks/status":a.TaskStatusNotificationSchema,"notifications/message":a.LoggingMessageNotificationSchema,"notifications/resources/updated":a.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":a.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":a.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":a.PromptListChangedNotificationSchema,"notifications/elicitation/complete":a.ElicitationCompleteNotificationSchema},resultSchemas:{ping:a.EmptyResultSchema,initialize:a.InitializeResultSchema,"completion/complete":a.CompleteResultSchema,"logging/setLevel":a.EmptyResultSchema,"prompts/get":a.GetPromptResultSchema,"prompts/list":a.ListPromptsResultSchema,"resources/list":a.ListResourcesResultSchema,"resources/templates/list":a.ListResourceTemplatesResultSchema,"resources/read":a.ReadResourceResultSchema,"resources/subscribe":a.EmptyResultSchema,"resources/unsubscribe":a.EmptyResultSchema,"tools/call":a.CallToolResultWireSchema,"tools/list":a.ListToolsResultSchema,"sampling/createMessage":a.CreateMessageResultWithToolsSchema,"elicitation/create":a.ElicitResultSchema,"roots/list":a.ListRootsResultSchema}}}function dd(a){return Object.prototype.hasOwnProperty.call(c9,a)}function de(a){return Object.prototype.hasOwnProperty.call(da,a)}function df(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function dg(a,b){if(void 0===a)return{ok:!1,reason:"not-in-era"};let c=a.safeParse(b);return c.success?{ok:!0,value:c.data}:{ok:!1,reason:"invalid",message:String(c.error)}}Object.keys(c9),Object.keys(da);let dh={ok:!1,reason:"not-in-era"};function di(a){return df(a)&&df(a.outputSchema)&&c5(a.outputSchema)}let dj={era:"2025-11-25",hasRequestMethod:dd,hasNotificationMethod:de,validateRequest:(a,b)=>dg(dd(a)?dc().requestSchemas[a]:void 0,b),validateResult:(a,b)=>dg(Object.prototype.hasOwnProperty.call(db,a)?dc().resultSchemas[a]:void 0,b),validateNotification:(a,b)=>dg(de(a)?dc().notificationSchemas[a]:void 0,b),hasInputRequestMethod:()=>!1,validateInputRequest:()=>dh,validateInputResponse:()=>dh,samplingResultVariant:(a,b)=>{let c=c4();return dg(a?c.CreateMessageResultWithToolsSchema:c.CreateMessageResultSchema,b)},outboundEnvelope:a=>void 0,validateEnvelopeMeta:a=>[],projectCallToolResult(a,b){let c=c1(a),d=c.structuredContent;if(void 0===d)return c;let e="object"!=typeof d||null===d||Array.isArray(d),f=void 0!==b&&c5(b);return e||f?{...c,structuredContent:{result:d}}:c},decodeResult(a,b){if(df(b)&&"resultType"in b){let a={...b};return delete a.resultType,{kind:"complete",result:a}}return{kind:"complete",result:b}},encodeResult(a,b){if("tools/list"!==a)return b;let c=b.tools;return Array.isArray(c)&&c.some(a=>di(a))?{...b,tools:c.map(a=>di(a)?{...a,outputSchema:function(a){var b;let c="string"==typeof a.$schema?a.$schema:void 0;if(c8(a.$id))return{...void 0!==c&&{$schema:c},type:"object",properties:{result:a},required:["result"]};let d="string"==typeof(b=a.$schema)&&B.has(b.replace(/#$/,""))&&!0!==a.$recursiveAnchor,e=(a,b)=>{if(Array.isArray(a))return a.map(a=>e(a,!1));if(null===a||"object"!=typeof a||!b&&c8(a.$id))return a;let c={},f=!1;for(let[g,h]of Object.entries(a))b?c[g]=e(h,!1):("$ref"===g||"$dynamicRef"===g)&&"string"==typeof h?c[g]="#"===h?"#/properties/result":h.startsWith("#/")?`#/properties/result${h.slice(1)}`:h:"$recursiveRef"===g&&"#"===h&&d?f=!0:c6.has(g)?c[g]=h:c7.has(g)?c[g]=e(h,!0):c[g]=e(h,!1);return f&&("$ref"in c?c.allOf=[...Array.isArray(c.allOf)?c.allOf:[],{$ref:"#/properties/result"}]:c.$ref="#/properties/result"),c};return{...void 0!==c&&{$schema:c},type:"object",properties:{result:e(a,!1)},required:["result"]}}(a.outputSchema)}:a)}:b},encodeErrorCode:a=>-32002===a?-32602:a,checkInboundEnvelope:a=>void 0};function dk(){return f??=function(){let a=E.RZ(()=>E.KC([E.Yj(),E.ai(),E.zM(),E.ch(),E.g1(E.Yj(),a),E.YO(a)])),b=E.g1(E.Yj(),a),c=E.KC([E.Yj(),E.ai().int()]),d=E.Yj(),e=E.KC([E.Yj(),E.ai().int()]),f=E.k5(["user","assistant"]),g=E.k5(["debug","info","notice","warning","error","critical","alert","emergency"]),h=E.Yj().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),i=E.Ik({ttl:E.ai().optional()}),j=E.Ik({taskId:E.Yj()}),k=E._H({progressToken:c.optional(),"io.modelcontextprotocol/related-task":j.optional()}),l=E.Ik({_meta:k.optional()}),m=l.extend({task:i.optional()}),n=E.Ik({_meta:k.optional()}),o=E.Ik({method:E.Yj(),params:n.loose().optional()}),p=E.Ik({src:E.Yj(),mimeType:E.Yj().optional(),sizes:E.YO(E.Yj()).optional(),theme:E.k5(["light","dark"]).optional()}),q=E.Ik({icons:E.YO(p).optional()}),r=E.Ik({name:E.Yj(),title:E.Yj().optional()}),s=r.extend({...r.shape,...q.shape,version:E.Yj(),websiteUrl:E.Yj().optional(),description:E.Yj().optional()}),t=E.E$(E.Ik({applyDefaults:E.zM().optional()}),b),u=E.vk(a=>a&&"object"==typeof a&&!Array.isArray(a)&&0===Object.keys(a).length?{form:{}}:a,E.E$(E.Ik({form:t.optional(),url:b.optional()}),b.optional())),v=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({sampling:E._H({createMessage:b.optional()}).optional(),elicitation:E._H({create:b.optional()}).optional()}).optional()}),w=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({tools:E._H({call:b.optional()}).optional()}).optional()}),x=E.Ik({experimental:E.g1(E.Yj(),b).optional(),sampling:E.Ik({context:b.optional(),tools:b.optional()}).optional(),elicitation:u.optional(),roots:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:v.optional(),extensions:E.g1(E.Yj(),b).optional()}),y=E.Ik({experimental:E.g1(E.Yj(),b).optional(),logging:b.optional(),completions:b.optional(),prompts:E.Ik({listChanged:E.zM().optional()}).optional(),resources:E.Ik({subscribe:E.zM().optional(),listChanged:E.zM().optional()}).optional(),tools:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:w.optional(),extensions:E.g1(E.Yj(),b).optional()}),z=E.Ik({progress:E.ai(),total:E.lq(E.ai()),message:E.lq(E.Yj())}),A=E.Ik({...n.shape,...z.shape,progressToken:c}),B=o.extend({method:E.eu("notifications/progress"),params:A}),C=n.extend({level:g,logger:E.Yj().optional(),data:E.L5()}),D=o.extend({method:E.eu("notifications/message"),params:C}),G=E.Ik({uri:E.Yj(),mimeType:E.lq(E.Yj()),_meta:E.g1(E.Yj(),E.L5()).optional()}),H=G.extend({text:E.Yj()}),I=G.extend({blob:h}),J=E.Ik({audience:E.YO(f).optional(),priority:E.ai().min(0).max(1).optional(),lastModified:F.w$({offset:!0}).optional()}),O=E.Ik({...r.shape,...q.shape,uri:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),size:E.lq(E.ai()),annotations:J.optional(),_meta:E.lq(E._H({}))}),Q=E.Ik({...r.shape,...q.shape,uriTemplate:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),annotations:J.optional(),_meta:E.lq(E._H({}))}),R=o.extend({method:E.eu("notifications/resources/list_changed"),params:n.optional()}),S=n.extend({uri:E.Yj()}),T=o.extend({method:E.eu("notifications/resources/updated"),params:S}),U=E.Ik({name:E.Yj(),description:E.lq(E.Yj()),required:E.lq(E.zM())}),V=E.Ik({...r.shape,...q.shape,description:E.lq(E.Yj()),arguments:E.lq(E.YO(U)),_meta:E.lq(E._H({}))}),W=o.extend({method:E.eu("notifications/prompts/list_changed"),params:n.optional()}),X=E.Ik({type:E.eu("text"),text:E.Yj(),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),Y=E.Ik({type:E.eu("image"),data:h,mimeType:E.Yj(),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),Z=E.Ik({type:E.eu("audio"),data:h,mimeType:E.Yj(),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),$=E.Ik({type:E.eu("tool_use"),name:E.Yj(),id:E.Yj(),input:E.g1(E.Yj(),E.L5()),_meta:E.g1(E.Yj(),E.L5()).optional()}),_=E.Ik({type:E.eu("resource"),resource:E.KC([H,I]),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aa=O.extend({type:E.eu("resource_link")}),ab=E.KC([X,Y,Z,aa,_]),ac=E.Ik({role:f,content:ab}),ad=E.Ik({title:E.Yj().optional(),readOnlyHint:E.zM().optional(),destructiveHint:E.zM().optional(),idempotentHint:E.zM().optional(),openWorldHint:E.zM().optional()}),ae=o.extend({method:E.eu("notifications/tools/list_changed"),params:n.optional()}),af=E.Ik({name:E.Yj().optional()}),ag=E.Ik({hints:E.YO(af).optional(),costPriority:E.ai().min(0).max(1).optional(),speedPriority:E.ai().min(0).max(1).optional(),intelligencePriority:E.ai().min(0).max(1).optional()}),ah=E.Ik({mode:E.k5(["auto","required","none"]).optional()}),ai=E.Ik({type:E.eu("boolean"),title:E.Yj().optional(),description:E.Yj().optional(),default:E.zM().optional()}),aj=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),minLength:E.ai().optional(),maxLength:E.ai().optional(),format:E.k5(["email","uri","date","date-time"]).optional(),default:E.Yj().optional()}),ak=E.Ik({type:E.k5(["number","integer"]),title:E.Yj().optional(),description:E.Yj().optional(),minimum:E.ai().optional(),maximum:E.ai().optional(),default:E.ai().optional()}),al=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),default:E.Yj().optional()}),am=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),oneOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()})),default:E.Yj().optional()}),an=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),enumNames:E.YO(E.Yj()).optional(),default:E.Yj().optional()}),ao=E.KC([al,am]),ap=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({type:E.eu("string"),enum:E.YO(E.Yj())}),default:E.YO(E.Yj()).optional()}),aq=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({anyOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()}))}),default:E.YO(E.Yj()).optional()}),ar=E.KC([ap,aq]),as=E.KC([an,ao,ar]),at=E.KC([as,ai,aj,ak]),au=m.extend({mode:E.eu("form").optional(),message:E.Yj(),requestedSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),at),required:E.YO(E.Yj()).optional()}).catchall(E.L5())}),av=E.Ik({type:E.eu("ref/resource"),uri:E.Yj()}),aw=E.Ik({type:E.eu("ref/prompt"),name:E.Yj()}),ax=E.Ik({uri:E.Yj().startsWith("file://"),name:E.Yj().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),ay=x.shape,az=E.Ik({experimental:ay.experimental,sampling:ay.sampling,elicitation:ay.elicitation,roots:ay.roots,extensions:ay.extensions}),aA=y.shape,aB=E.Ik({experimental:aA.experimental,logging:aA.logging,completions:aA.completions,prompts:aA.prompts,resources:aA.resources,tools:aA.tools,extensions:aA.extensions}),aC=E._H({progressToken:c.optional(),[K]:E.Yj(),[L]:s.optional(),[N]:az,[P]:g.optional()}),aD=E.Ik({...r.shape,...q.shape,description:E.Yj().optional(),inputSchema:E._H({$schema:E.Yj().optional(),type:E.eu("object")}),outputSchema:E._H({$schema:E.Yj().optional()}).optional(),annotations:ad.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aE=E.Ik({type:E.eu("tool_result"),toolUseId:E.Yj(),content:E.YO(ab),structuredContent:E.L5().optional(),isError:E.zM().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aF=E.KC([X,Y,Z,$,aE]),aG=E.Ik({role:f,content:E.KC([aF,E.YO(aF)]),_meta:E.g1(E.Yj(),E.L5()).optional()}),aH=E.Yj(),aI=E._H({[M]:s.optional().catch(void 0)}),aJ=aI.optional();function aK(a){return E._H({_meta:aJ,resultType:aH.default("complete"),...a})}let aL=aK({}),aM=aK({nextCursor:d.optional()}),aN=aK({content:E.YO(ab),structuredContent:E.L5().optional(),isError:E.zM().optional()}),aO=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),tools:E.YO(aD),nextCursor:d.optional()}),aP=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),prompts:E.YO(V),nextCursor:d.optional()}),aQ=aK({description:E.Yj().optional(),messages:E.YO(ac)}),aR=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resources:E.YO(O),nextCursor:d.optional()}),aS=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resourceTemplates:E.YO(Q),nextCursor:d.optional()}),aT=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),contents:E.YO(E.KC([H,I]))}),aU=aK({completion:E.Ik({values:E.YO(E.Yj()).max(100),total:E.ai().int().optional(),hasMore:E.zM().optional()}).loose()}),aV=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"])}),aW=aK({ttlMs:E.ai().int().min(0).catch(0),cacheScope:E.k5(["public","private"]).catch("private"),supportedVersions:E.YO(E.Yj()),capabilities:aB,instructions:E.Yj().optional()}),aX=E.Ik({messages:E.YO(aG),modelPreferences:ag.optional(),systemPrompt:E.Yj().optional(),includeContext:E.k5(["none","thisServer","allServers"]).optional(),temperature:E.ai().optional(),maxTokens:E.ai().int(),stopSequences:E.YO(E.Yj()).optional(),metadata:b.optional(),tools:E.YO(aD).optional(),toolChoice:ah.optional()}),aY=E.Ik({method:E.eu("sampling/createMessage"),params:aX}),aZ=E.Ik({method:E.eu("roots/list"),params:E.Ik({_meta:E.g1(E.Yj(),E.L5()).optional()}).optional()}),a$=E.Ik({...aG.shape,model:E.Yj(),stopReason:E.Yj().optional()}),a_=E.Ik({roots:E.YO(ax)}),a0=E.Ik({action:E.k5(["accept","decline","cancel"]),content:E.g1(E.Yj(),E.KC([E.Yj(),E.ai(),E.zM(),E.YO(E.Yj())])).optional()}),a1=E.Ik({mode:E.eu("url"),message:E.Yj(),url:E.Yj().url()}),a2=E.KC([au,a1]),a3=E.Ik({method:E.eu("elicitation/create"),params:a2}),a4=E.KC([aY,aZ,a3]),a5=E.KC([a$,a_,a0]),a6=E.g1(E.Yj(),a4),a7=E.g1(E.Yj(),a5),a8=aK({inputRequests:a6.optional(),requestState:E.Yj().optional()}),a9={inputResponses:a7.optional(),requestState:E.Yj().optional()},ba=E.Ik({_meta:aC,...a9}),bb=E._H({progressToken:c.optional()});function bc(a,b){return E.Ik({method:E.eu(a),params:E.Ik({_meta:aC,...b})})}function bd(a,b){return E.Ik({method:E.eu(a),params:E.Ik({_meta:bb.optional(),...b}).optional()})}let be={name:E.Yj(),arguments:E.g1(E.Yj(),E.L5()).optional(),...a9},bf={cursor:d.optional()},bg=bc("tools/call",be),bh=bc("tools/list",bf),bi=bc("prompts/list",bf),bj=bc("prompts/get",{name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional(),...a9}),bk=bc("resources/list",bf),bl=bc("resources/templates/list",bf),bm=bc("resources/read",{uri:E.Yj(),...a9}),bn={ref:E.KC([aw,av]),argument:E.Ik({name:E.Yj(),value:E.Yj()}),context:E.Ik({arguments:E.g1(E.Yj(),E.Yj()).optional()}).optional()},bo=bc("completion/complete",bn),bp=bc("server/discover",{}),bq=E.Ik({toolsListChanged:E.zM().optional(),promptsListChanged:E.zM().optional(),resourcesListChanged:E.zM().optional(),resourceSubscriptions:E.YO(E.Yj()).optional()}),br={notifications:bq},bs=bc("subscriptions/listen",br),bt=aI.extend({"io.modelcontextprotocol/subscriptionId":e}),bu=E._H({_meta:bt,resultType:aH.default("complete")}),bv={"tools/call":bd("tools/call",be),"tools/list":bd("tools/list",bf),"prompts/get":bd("prompts/get",{name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional()}),"prompts/list":bd("prompts/list",bf),"resources/list":bd("resources/list",bf),"resources/templates/list":bd("resources/templates/list",bf),"resources/read":bd("resources/read",{uri:E.Yj()}),"completion/complete":bd("completion/complete",bn),"server/discover":bd("server/discover",{}),"subscriptions/listen":bd("subscriptions/listen",br)};function bw(a){return E._H({_meta:aJ,...a})}let bx={"tools/call":bw({content:E.YO(ab),structuredContent:E.L5().optional(),isError:E.zM().optional()}),"tools/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),tools:E.YO(aD),nextCursor:d.optional()}),"prompts/get":bw({description:E.Yj().optional(),messages:E.YO(ac)}),"prompts/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),prompts:E.YO(V),nextCursor:d.optional()}),"resources/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resources:E.YO(O),nextCursor:d.optional()}),"resources/templates/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resourceTemplates:E.YO(Q),nextCursor:d.optional()}),"resources/read":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),contents:E.YO(E.KC([H,I]))}),"completion/complete":bw({completion:E.Ik({values:E.YO(E.Yj()).max(100),total:E.ai().int().optional(),hasMore:E.zM().optional()}).loose()}),"server/discover":bw({ttlMs:E.ai().int().min(0).catch(0),cacheScope:E.k5(["public","private"]).catch("private"),supportedVersions:E.YO(E.Yj()),capabilities:aB,instructions:E.Yj().optional()}),"subscriptions/listen":bw({})},by=E._H({"io.modelcontextprotocol/subscriptionId":e.optional()}),bz=E.Ik({method:E.eu("notifications/subscriptions/acknowledged"),params:E.Ik({_meta:by.optional(),notifications:bq})}),bA=E.Ik({_meta:by.optional(),requestId:e,reason:E.Yj().optional()}),bB=E.Ik({method:E.eu("notifications/cancelled"),params:bA}),bC=a=>E.Ik({jsonrpc:E.eu("2.0"),id:E.KC([E.Yj(),E.ai().int()]),result:a}).strict();return{JSONValueSchema:a,JSONObjectSchema:b,ProgressTokenSchema:c,CursorSchema:d,RequestIdSchema:e,RoleSchema:f,LoggingLevelSchema:g,TaskMetadataSchema:i,RelatedTaskMetadataSchema:j,RequestMetaSchema:k,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:m,NotificationsParamsSchema:n,NotificationSchema:o,IconSchema:p,IconsSchema:q,BaseMetadataSchema:r,ImplementationSchema:s,ClientTasksCapabilitySchema:v,ServerTasksCapabilitySchema:w,ClientCapabilitiesSchema:x,ServerCapabilitiesSchema:y,ProgressSchema:z,ProgressNotificationParamsSchema:A,ProgressNotificationSchema:B,LoggingMessageNotificationParamsSchema:C,LoggingMessageNotificationSchema:D,ResourceContentsSchema:G,TextResourceContentsSchema:H,BlobResourceContentsSchema:I,AnnotationsSchema:J,ResourceSchema:O,ResourceTemplateSchema:Q,ResourceListChangedNotificationSchema:R,ResourceUpdatedNotificationParamsSchema:S,ResourceUpdatedNotificationSchema:T,PromptArgumentSchema:U,PromptSchema:V,PromptListChangedNotificationSchema:W,TextContentSchema:X,ImageContentSchema:Y,AudioContentSchema:Z,ToolUseContentSchema:$,EmbeddedResourceSchema:_,ResourceLinkSchema:aa,ContentBlockSchema:ab,PromptMessageSchema:ac,ToolAnnotationsSchema:ad,ToolListChangedNotificationSchema:ae,ModelHintSchema:af,ModelPreferencesSchema:ag,ToolChoiceSchema:ah,BooleanSchemaSchema:ai,StringSchemaSchema:aj,NumberSchemaSchema:ak,UntitledSingleSelectEnumSchemaSchema:al,TitledSingleSelectEnumSchemaSchema:am,LegacyTitledEnumSchemaSchema:an,SingleSelectEnumSchemaSchema:ao,UntitledMultiSelectEnumSchemaSchema:ap,TitledMultiSelectEnumSchemaSchema:aq,MultiSelectEnumSchemaSchema:ar,EnumSchemaSchema:as,PrimitiveSchemaDefinitionSchema:at,ElicitRequestFormParamsSchema:au,ResourceTemplateReferenceSchema:av,PromptReferenceSchema:aw,RootSchema:ax,ClientCapabilities2026Schema:az,ServerCapabilities2026Schema:aB,RequestMetaEnvelopeSchema:aC,ToolSchema:aD,ToolResultContentSchema:aE,SamplingMessageContentBlockSchema:aF,SamplingMessageSchema:aG,ResultTypeSchema:aH,ResultMetaSchema:aI,ResultSchema:aL,PaginatedResultSchema:aM,CallToolResultSchema:aN,ListToolsResultSchema:aO,ListPromptsResultSchema:aP,GetPromptResultSchema:aQ,ListResourcesResultSchema:aR,ListResourceTemplatesResultSchema:aS,ReadResourceResultSchema:aT,CompleteResultSchema:aU,CacheableResultSchema:aV,DiscoverResultSchema:aW,CreateMessageRequestParamsSchema:aX,CreateMessageRequestSchema:aY,ListRootsRequestSchema:aZ,CreateMessageResultSchema:a$,ListRootsResultSchema:a_,ElicitResultSchema:a0,ElicitRequestURLParamsSchema:a1,ElicitRequestParamsSchema:a2,ElicitRequestSchema:a3,InputRequestSchema:a4,InputResponseSchema:a5,InputRequestsSchema:a6,InputResponsesSchema:a7,InputRequiredResultSchema:a8,InputResponseRequestParamsSchema:ba,CallToolRequestSchema:bg,ListToolsRequestSchema:bh,ListPromptsRequestSchema:bi,GetPromptRequestSchema:bj,ListResourcesRequestSchema:bk,ListResourceTemplatesRequestSchema:bl,ReadResourceRequestSchema:bm,CompleteRequestSchema:bo,DiscoverRequestSchema:bp,SubscriptionFilterSchema:bq,SubscriptionsListenRequestSchema:bs,SubscriptionsListenResultMetaSchema:bt,SubscriptionsListenResultSchema:bu,dispatchRequestSchemas:bv,dispatchResultSchemas:bx,NotificationMetaSchema:by,SubscriptionsAcknowledgedNotificationSchema:bz,CancelledNotificationParamsSchema:bA,CancelledNotificationSchema:bB,notificationSchemas2026:{"notifications/cancelled":bB,"notifications/progress":B,"notifications/message":D,"notifications/resources/updated":T,"notifications/resources/list_changed":R,"notifications/tools/list_changed":ae,"notifications/prompts/list_changed":W,"notifications/subscriptions/acknowledged":bz},JSONRPCResultResponseSchema:bC(aL),CallToolResultResponseSchema:bC(E.KC([aN,a8])),ListToolsResultResponseSchema:bC(aO),ListPromptsResultResponseSchema:bC(aP),GetPromptResultResponseSchema:bC(E.KC([aQ,a8])),ListResourcesResultResponseSchema:bC(aR),ListResourceTemplatesResultResponseSchema:bC(aS),ReadResourceResultResponseSchema:bC(E.KC([aT,a8])),CompleteResultResponseSchema:bC(aU),DiscoverResultResponseSchema:bC(aW)}}()}let dl=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],dm=Symbol("modelcontextprotocol.resultCacheHintFallback");function dn(a,b){if(void 0===b)return a;let c=a[dm];if(void 0===c)return{...a,[dm]:b};let d={},e=c.ttlMs??b.ttlMs;void 0!==e&&(d.ttlMs=e);let f=c.cacheScope??b.cacheScope;return void 0!==f&&(d.cacheScope=f),{...a,[dm]:d}}function dp(a){return"number"==typeof a&&Number.isSafeInteger(a)&&a>=0}function dq(a){return"public"===a||"private"===a}function dr(a,b){if(void 0!==a.ttlMs&&!dp(a.ttlMs))throw RangeError(`Invalid cache hint for ${b}: ttlMs must be a non-negative safe integer (got ${String(a.ttlMs)})`);if(void 0!==a.cacheScope&&!dq(a.cacheScope))throw RangeError(`Invalid cache hint for ${b}: cacheScope must be 'public' or 'private' (got ${String(a.cacheScope)})`)}let ds=((p={})[p.ParseError=-32700]="ParseError",p[p.InvalidRequest=-32600]="InvalidRequest",p[p.MethodNotFound=-32601]="MethodNotFound",p[p.InvalidParams=-32602]="InvalidParams",p[p.InternalError=-32603]="InternalError",p[p.ResourceNotFound=-32002]="ResourceNotFound",p[p.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",p[p.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",p[p.UrlElicitationRequired=-32042]="UrlElicitationRequired",p);var dt=class a extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](a){return cS(this,a)}static isInstance(a){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return cS(this,a)}constructor(a,b,c){super(b),this.code=a,this.data=c,this.name="ProtocolError",cR(this,new.target)}static fromError(b,c,d){return b===ds.UrlElicitationRequired&&d&&d.elicitations?new dv(d.elicitations,c):b===ds.UnsupportedProtocolVersion&&d&&Array.isArray(d.supported)&&"string"==typeof d.requested?new dw({supported:d.supported,requested:d.requested},c):(b===ds.InvalidParams||b===ds.ResourceNotFound)&&"string"==typeof d?.uri&&(b===ds.ResourceNotFound||1===Object.keys(d).length)?new du(d.uri,c):b===ds.MissingRequiredClientCapability&&d&&null!==d.requiredCapabilities&&"object"==typeof d.requiredCapabilities&&!Array.isArray(d.requiredCapabilities)?new dx({requiredCapabilities:d.requiredCapabilities},c):new a(b,c,d)}},du=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(a,b=`Resource not found: ${a}`){super(ds.InvalidParams,b,{uri:a})}get uri(){return this.data.uri}},dv=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(a,b=`URL elicitation${a.length>1?"s":""} required`){super(ds.UrlElicitationRequired,b,{elicitations:a})}get elicitations(){return this.data?.elicitations??[]}},dw=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(a,b=`Unsupported protocol version: ${a.requested}`){super(ds.UnsupportedProtocolVersion,b,a)}get supported(){return this.data.supported}get requested(){return this.data.requested}},dx=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(a,b=`Missing required client capabilities: ${Object.keys(a.requiredCapabilities).join(", ")}`){super(ds.MissingRequiredClientCapability,b,a)}get requiredCapabilities(){return this.data.requiredCapabilities}};let dy=["tools/call","prompts/get","resources/read"],dz=["elicitation/create","sampling/createMessage","roots/list"];function dA(){if(g)return g;let a=dk();return g={request:{"elicitation/create":E.Ik({method:E.eu("elicitation/create"),params:a.ElicitRequestParamsSchema}),"sampling/createMessage":E.Ik({method:E.eu("sampling/createMessage"),params:a.CreateMessageRequestParamsSchema}),"roots/list":E.Ik({method:E.eu("roots/list"),params:E._H({}).optional()})},response:{"elicitation/create":a.ElicitResultSchema,"sampling/createMessage":a.CreateMessageResultSchema,"roots/list":a.ListRootsResultSchema}}}function dB(a){return dz.includes(a)}function dC(a){return dB(a)?dA().request[a]:void 0}let dD={"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},dE={"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 dF(a){return Object.prototype.hasOwnProperty.call(dD,a)}function dG(a){return Object.prototype.hasOwnProperty.call(dE,a)}function dH(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function dI(a,b){if(void 0===a)return{ok:!1,reason:"not-in-era"};let c=a.safeParse(b);return c.success?{ok:!0,value:c.data}:{ok:!1,reason:"invalid",message:String(c.error)}}Object.keys(dD),Object.keys(dE);let dJ={ok:!1,reason:"not-in-era"},dK=[K,N],dL={era:"2026-07-28",hasRequestMethod:dF,hasNotificationMethod:dG,hasInputRequestMethod:a=>void 0!==dC(a),validateRequest:(a,b)=>dI(dF(a)?dk().dispatchRequestSchemas[a]:void 0,b),validateResult:(a,b)=>dI(Object.prototype.hasOwnProperty.call(dD,a)?dk().dispatchResultSchemas[a]:void 0,b),validateNotification:(a,b)=>dI(dG(a)?dk().notificationSchemas2026[a]:void 0,b),validateInputRequest:(a,b)=>dI(dC(a),b),validateInputResponse:(a,b)=>dI(dB(a)?dA().response[a]:void 0,b),samplingResultVariant:()=>dJ,outboundEnvelope:a=>({[K]:a.protocolVersion,[L]:a.clientInfo,[N]:a.clientCapabilities,...void 0!==a.logLevel&&{[P]:a.logLevel}}),validateEnvelopeMeta(a){let b=[];for(let c of dK)c in a||b.push({key:c,problem:"missing"});let c=dk().RequestMetaEnvelopeSchema.safeParse(a);if(!c.success)for(let a of c.error.issues){let c=a.path.map(String),d=c.length>0?c.join("."):"_meta";1===c.length&&b.some(a=>a.key===d&&"missing"===a.problem)||b.push({key:d,problem:a.message})}return b},projectCallToolResult:a=>c1(a),inputRequestSchema:dC,decodeResult(a,b){if(!dH(b))return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: not an object`,{method:a})};let c=b.resultType;if(void 0===c)return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: 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:a,violation:"missing-resultType"})};if("string"!=typeof c)return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: non-string resultType`,{method:a,resultType:c})};if("input_required"===c){let c=b.inputRequests,d=dH(c)?c:{},e=b.requestState;return 0===Object.keys(d).length&&"string"!=typeof e?{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:a,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:d,..."string"==typeof e&&{requestState:e}}}if("complete"!==c)return{kind:"invalid",error:new cW(cV.UnsupportedResultType,`Unsupported result type '${c}' for ${a}`,{resultType:c,method:a})};let d=function(){if(h)return h;let a=dk();return h={"tools/call":a.CallToolResultSchema,"tools/list":a.ListToolsResultSchema,"prompts/get":a.GetPromptResultSchema,"prompts/list":a.ListPromptsResultSchema,"resources/list":a.ListResourcesResultSchema,"resources/templates/list":a.ListResourceTemplatesResultSchema,"resources/read":a.ReadResourceResultSchema,"completion/complete":a.CompleteResultSchema,"server/discover":a.DiscoverResultSchema}}(),e=Object.hasOwn(d,a)?d[a]:void 0;if(void 0!==e){let c=e.safeParse(b);if(!c.success)return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: ${c.error}`,{method:a})}}let f={...b};return delete f.resultType,{kind:"complete",result:f}},encodeResult:(a,b,c)=>(function(a,b){if(void 0===b)return a;let c=a._meta;return void 0===c?{...a,_meta:{[M]:b}}:null===c||"object"!=typeof c||Array.isArray(c)||void 0!==c[M]?a:{...a,_meta:{...c,[M]:b}}})(function(a,b){var c,d;let e=b[dm];if("complete"!==b.resultType||!dl.includes(a)){let a;return void 0===e?b:(a={...b},delete a[dm],a)}let f=dp(b.ttlMs)?b.ttlMs:void 0!==(c=e)&&dp(c.ttlMs)?c.ttlMs:0,g=dq(b.cacheScope)?b.cacheScope:void 0!==(d=e)&&dq(d.cacheScope)?d.cacheScope:"private",h={...b,ttlMs:f,cacheScope:g};return delete h[dm],h}(a,function(a,b){let c=b.resultType;if(void 0===c)return{...b,resultType:"complete"};if("complete"===c||dy.includes(a))return b;throw new dt(ds.InternalError,`Handler for ${a} returned resultType '${String(c)}', but results of ${a} only support 'complete' on protocol revision 2026-07-28`)}(a,function(a,b){let c=b,d=!1,e=()=>(d||(c={...c},d=!0),c),f=b.tools;"tools/list"===a&&Array.isArray(f)&&f.some(a=>dH(a)&&"execution"in a)&&(e().tools=f.map(a=>{if(!dH(a)||!("execution"in a))return a;let b={...a};return delete b.execution,b}));let g=b.capabilities;if(dH(g)&&"tasks"in g){let a={...g};delete a.tasks,e().capabilities=a}return c}(a,b))),c),encodeErrorCode:a=>-32002===a?-32602:a,checkInboundEnvelope(a){if(void 0===a.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let b=dk().RequestMetaEnvelopeSchema.safeParse(a.envelope);if(!b.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${b.error.issues.map(a=>a.message).join("; ")}`}},dM="2026-07-28";function dN(a){return void 0!==a&&a>=c$?dL:dj}function dO(a){return void 0!==a.revision?dN(a.revision).era:"modern"===a.era?dL.era:dj.era}function dP(a){return dR.some(b=>b.hasRequestMethod(a))}function dQ(a){return dR.some(b=>b.hasNotificationMethod(a))}let dR=[dj,dL];function dS(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function dT(a){if(!dS(a))return;let b=a._meta;return dS(b)?b:void 0}function dU(a){let b=dT(a);return void 0!==b&&K in b}function dV(a){let b=dT(a)?.[K];return"string"==typeof b?b:void 0}function dW(a){return dN(dM).validateEnvelopeMeta(a)}var dX=(a=>{let b={};for(var c in a)t(b,c,{get:a[c],enumerable:!0});return b})({AnnotationsSchema:()=>aP,AudioContentSchema:()=>bh,BaseMetadataSchema:()=>ap,BaseRequestParamsSchema:()=>Y,BlobResourceContentsSchema:()=>aN,BooleanSchemaSchema:()=>bQ,CallToolRequestParamsSchema:()=>bw,CallToolRequestSchema:()=>bx,CallToolResultSchema:()=>bu,CancelTaskRequestSchema:()=>cs,CancelTaskResultSchema:()=>ct,CancelledNotificationParamsSchema:()=>al,CancelledNotificationSchema:()=>am,ClientCapabilitiesSchema:()=>av,ClientNotificationSchema:()=>cv,ClientRequestSchema:()=>cu,ClientResultSchema:()=>cw,ClientTasksCapabilitySchema:()=>at,CompatibilityCallToolResultSchema:()=>bv,CompleteRequestParamsSchema:()=>b9,CompleteRequestSchema:()=>ca,CompleteResultSchema:()=>cb,ContentBlockSchema:()=>bl,CreateMessageRequestParamsSchema:()=>bM,CreateMessageRequestSchema:()=>bN,CreateMessageResultSchema:()=>bO,CreateMessageResultWithToolsSchema:()=>bP,CreateTaskResultSchema:()=>cj,CursorSchema:()=>U,DiscoverRequestSchema:()=>aB,DiscoverResultSchema:()=>aC,ElicitRequestFormParamsSchema:()=>b0,ElicitRequestParamsSchema:()=>b2,ElicitRequestSchema:()=>b3,ElicitRequestURLParamsSchema:()=>b1,ElicitResultSchema:()=>b6,ElicitationCompleteNotificationParamsSchema:()=>b4,ElicitationCompleteNotificationSchema:()=>b5,EmbeddedResourceSchema:()=>bj,EmptyResultSchema:()=>ak,EnumSchemaSchema:()=>b$,GetPromptRequestParamsSchema:()=>bd,GetPromptRequestSchema:()=>be,GetPromptResultSchema:()=>bn,GetTaskPayloadRequestSchema:()=>co,GetTaskPayloadResultSchema:()=>cp,GetTaskRequestSchema:()=>cm,GetTaskResultSchema:()=>cn,IconSchema:()=>an,IconsSchema:()=>ao,ImageContentSchema:()=>bg,ImplementationSchema:()=>aq,InitializeRequestParamsSchema:()=>aw,InitializeRequestSchema:()=>ax,InitializeResultSchema:()=>az,InitializedNotificationSchema:()=>aA,JSONArraySchema:()=>S,JSONObjectSchema:()=>R,JSONRPCErrorResponseSchema:()=>ah,JSONRPCMessageSchema:()=>ai,JSONRPCNotificationSchema:()=>af,JSONRPCRequestSchema:()=>ae,JSONRPCResponseSchema:()=>aj,JSONRPCResultResponseSchema:()=>ag,JSONValueSchema:()=>Q,LegacyTitledEnumSchemaSchema:()=>bV,ListChangedOptionsBaseSchema:()=>bz,ListPromptsRequestSchema:()=>bb,ListPromptsResultSchema:()=>bc,ListResourceTemplatesRequestSchema:()=>aU,ListResourceTemplatesResultSchema:()=>aV,ListResourcesRequestSchema:()=>aS,ListResourcesResultSchema:()=>aT,ListRootsRequestSchema:()=>cd,ListRootsResultSchema:()=>ce,ListTasksRequestSchema:()=>cq,ListTasksResultSchema:()=>cr,ListToolsRequestSchema:()=>bs,ListToolsResultSchema:()=>bt,LoggingLevelSchema:()=>bA,LoggingMessageNotificationParamsSchema:()=>bD,LoggingMessageNotificationSchema:()=>bE,ModelHintSchema:()=>bF,ModelPreferencesSchema:()=>bG,MultiSelectEnumSchemaSchema:()=>bZ,NotificationSchema:()=>aa,NotificationsParamsSchema:()=>_,NumberSchemaSchema:()=>bS,PaginatedRequestParamsSchema:()=>aH,PaginatedRequestSchema:()=>aI,PaginatedResultSchema:()=>aJ,PingRequestSchema:()=>aD,PrimitiveSchemaDefinitionSchema:()=>b_,ProgressNotificationParamsSchema:()=>aF,ProgressNotificationSchema:()=>aG,ProgressSchema:()=>aE,ProgressTokenSchema:()=>T,PromptArgumentSchema:()=>a9,PromptListChangedNotificationSchema:()=>bo,PromptMessageSchema:()=>bm,PromptReferenceSchema:()=>b8,PromptSchema:()=>ba,ReadResourceRequestParamsSchema:()=>aW,ReadResourceRequestSchema:()=>aX,ReadResourceResultSchema:()=>aY,RelatedTaskMetadataSchema:()=>W,RequestIdSchema:()=>ad,RequestMetaSchema:()=>X,RequestSchema:()=>$,ResourceContentsSchema:()=>aK,ResourceLinkSchema:()=>bk,ResourceListChangedNotificationSchema:()=>aZ,ResourceRequestParamsSchema:()=>aW,ResourceSchema:()=>aQ,ResourceTemplateReferenceSchema:()=>b7,ResourceTemplateSchema:()=>aR,ResourceUpdatedNotificationParamsSchema:()=>a7,ResourceUpdatedNotificationSchema:()=>a8,ResultMetaObjectSchema:()=>ab,ResultSchema:()=>ac,RoleSchema:()=>aO,RootSchema:()=>cc,RootsListChangedNotificationSchema:()=>cf,SamplingContentSchema:()=>bJ,SamplingMessageContentBlockSchema:()=>bK,SamplingMessageSchema:()=>bL,ServerCapabilitiesSchema:()=>ay,ServerNotificationSchema:()=>cy,ServerRequestSchema:()=>cx,ServerResultSchema:()=>cz,ServerTasksCapabilitySchema:()=>au,SetLevelRequestParamsSchema:()=>bB,SetLevelRequestSchema:()=>bC,SingleSelectEnumSchemaSchema:()=>bW,StringSchemaSchema:()=>bR,SubscribeRequestParamsSchema:()=>aW,SubscribeRequestSchema:()=>a$,SubscriptionFilterSchema:()=>a0,SubscriptionsAcknowledgedNotificationParamsSchema:()=>a3,SubscriptionsAcknowledgedNotificationSchema:()=>a4,SubscriptionsListenRequestParamsSchema:()=>a1,SubscriptionsListenRequestSchema:()=>a2,SubscriptionsListenResultMetaSchema:()=>a5,SubscriptionsListenResultSchema:()=>a6,TaskAugmentedRequestParamsSchema:()=>Z,TaskCreationParamsSchema:()=>cg,TaskMetadataSchema:()=>V,TaskSchema:()=>ci,TaskStatusNotificationParamsSchema:()=>ck,TaskStatusNotificationSchema:()=>cl,TaskStatusSchema:()=>ch,TextContentSchema:()=>bf,TextResourceContentsSchema:()=>aL,TitledMultiSelectEnumSchemaSchema:()=>bY,TitledSingleSelectEnumSchemaSchema:()=>bU,ToolAnnotationsSchema:()=>bp,ToolChoiceSchema:()=>bH,ToolExecutionSchema:()=>bq,ToolListChangedNotificationSchema:()=>by,ToolResultContentSchema:()=>bI,ToolSchema:()=>br,ToolUseContentSchema:()=>bi,UnsubscribeRequestParamsSchema:()=>aW,UnsubscribeRequestSchema:()=>a_,UntitledMultiSelectEnumSchemaSchema:()=>bX,UntitledSingleSelectEnumSchemaSchema:()=>bT});let dY=a=>ae.safeParse(a).success,dZ=a=>af.safeParse(a).success,d$=a=>ag.safeParse(a).success,d_=a=>ah.safeParse(a).success,d0=a=>"object"==typeof a&&null!==a&&!Array.isArray(a)&&"input_required"===a.resultType,d1="x-mcp-header",d2=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,d3=new Set(["string","integer","boolean","number"]);function d4(a){let b=[],c=new Map,d=(a,e,f)=>{if(null===a||"object"!=typeof a)return;if(d1 in a){if(!f||0===e.length)return`${d7(e)}: 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 d=a[d1];if("string"!=typeof d||0===d.length)return`${d7(e)}: x-mcp-header MUST be a non-empty string`;if(!d2.test(d))return`${d7(e)}: x-mcp-header '${d}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let g="string"==typeof a.type?a.type:void 0;if(void 0===g||!d3.has(g))return`${d7(e)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${g??"<none>"}`;let h=d.toLowerCase(),i=c.get(h);if(void 0!==i)return`x-mcp-header '${d}' is not case-insensitively unique (also declared as '${i}')`;c.set(h,d),b.push({path:e,headerName:d,type:g})}let g=a.properties;if(null!==g&&"object"==typeof g)for(let[a,b]of Object.entries(g)){let c=d(b,[...e,a],f);if(void 0!==c)return c}for(let b of d5){let c=a[b];if(void 0!==c)for(let a of Array.isArray(c)?c:null!==c&&"object"==typeof c&&d6.has(b)?Object.values(c):[c]){let c=d(a,[...e,`<${b}>`],!1);if(void 0!==c)return c}}},e=d(a,[],!0);return void 0===e?{valid:!0,declarations:b}:{valid:!1,reason:e}}let d5=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],d6=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function d7(a){return 0===a.length?"<root>":a.join(".")}let d8=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,d9=/^-?\d+(\.\d+)?$/;function ea(a){if(!(a.startsWith("=?base64?")&&a.endsWith("?=")))return a;let b=a.slice(9,a.length-2);if(d8.test(b))try{let a=atob(b),c=new Uint8Array(a.length);for(let b=0;b<a.length;b++)c[b]=a.codePointAt(b);return new TextDecoder("utf-8",{fatal:!0}).decode(c)}catch{return}}function eb(a,b,c){return{kind:"reject",rung:"param-header-validation",cell:a,httpStatus:400,code:ec,message:`Bad Request: the request headers and body disagree: ${c}`,data:{mismatch:{header:b,body:c}},settled:!0}}let ec=-32020;ds.InvalidRequest,ds.UnsupportedProtocolVersion,ds.InvalidParams,ds.MethodNotFound,ds.InvalidParams,ds.MissingRequiredClientCapability;let ed={[ds.ParseError]:400,[ds.InvalidRequest]:400,[ds.MethodNotFound]:404,[ds.UnsupportedProtocolVersion]:400,[ds.MissingRequiredClientCapability]:400,[ec]:400};function ee(a,b,c,d,e){return{kind:"reject",rung:a,cell:b,httpStatus:c,code:d.code,message:d.message,...void 0!==d.data&&{data:d.data},settled:e}}function ef(a,b,c,d="era-classification"){return ee(d,a,400,new dt(ec,`Bad Request: the request headers and body disagree: ${c}`,{mismatch:{header:b,body:c}}),!0)}let eg={"tools/call":"name","prompts/get":"name","resources/read":"uri"};function eh(a){let b=0;for(;b<a.length;){let c=a.codePointAt(b);if(9!==c&&32!==c)break;b+=1}let c=a.length;for(;c>b;){let b=a.codePointAt(c-1);if(9!==b&&32!==b)break;c-=1}return 0===b&&c===a.length?a:a.slice(b,c)}function ei(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function ej(a){return void 0===a?{era:"modern"}:{era:a>=c$?"modern":"legacy",revision:a}}function ek(a){return new Set(a.flatMap(a=>Object.keys(a.shape)))}function el(a){if(null==a)return!1;let b=typeof a;return("object"===b||"function"===b)&&"~standard"in a&&"function"==typeof a["~standard"]?.validate}let em=!1,en="draft-2020-12";function eo(a,b="input"){let c,d=a["~standard"];if(d.jsonSchema)c=d.jsonSchema[b]({target:en});else if("zod"===d.vendor){if(!("_zod"in a))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().");em||(em=!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.")),c=cP.bl(a,{target:en,io:b})}else throw Error(`Schema library "${d.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===b)return void 0!==c.type||!function a(b){if("properties"in b||"patternProperties"in b||"additionalProperties"in b||"required"in b)return!0;for(let c of["oneOf","anyOf","allOf"]){let d=b[c];if(Array.isArray(d)&&d.length>0)return d.every(b=>null!==b&&"object"==typeof b&&("object"===b.type||a(b)))}return!1}(c)?c:{type:"object",...c};if(void 0!==c.type&&"object"!==c.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(c.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...c}}async function ep(a,b){let c=await a["~standard"].validate(b);return c.issues&&c.issues.length>0?{success:!1,error:c.issues.map(a=>a.path?.length?`${a.path.map(a=>String("object"==typeof a?a.key:a)).join(".")}: ${a.message}`:a.message).join(", ")}:{success:!0,data:c.value}}let eq=/\\\.\\d\{(\d+)\}/;function er(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}let es=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function et(a){return es.has(a)||a.startsWith("x-")}let eu=new Set(["$schema",...Object.keys(b0.shape.requestedSchema.shape)]),ev={string:ek([bR,bT,bU,bV]),number:ek([bS]),integer:ek([bS]),boolean:ek([bQ]),array:ek([bX,bY])},ew=new Set(bR.shape.format.unwrap().options);Object.assign(function(a){let b=void 0!==a.inputRequests&&Object.keys(a.inputRequests).length>0,c="string"==typeof a.requestState;if(!b&&!c)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==a.inputRequests&&{inputRequests:a.inputRequests},...void 0!==a.requestState&&{requestState:a.requestState}}},{elicit(a){try{return{method:"elicitation/create",params:function(a){var b;if(!el(a.requestedSchema))return{...a,mode:"form",requestedSchema:a.requestedSchema};let c=a.requestedSchema["~standard"].vendor,d=function(a,b){let c={},d=[];for(let[e,f]of Object.entries(a))"properties"===e&&er(f)?c[e]=Object.fromEntries(Object.entries(f).map(([a,c])=>[a,function(a,b,c,d){if(!er(a))return a;let e="string"==typeof a.type&&Object.hasOwn(ev,a.type)?ev[a.type]:void 0;if(void 0===e)return a;let f={};for(let[h,i]of Object.entries(a))if(e.has(h)||et(h))f[h]=i;else if("pattern"===h&&"string"===a.type&&"string"==typeof a.format)if(ew.has(a.format)){var g;"string"==typeof i&&(g=a.format,"zod"!==c||(function(a,b){let c;switch(a){case"email":c=[E.Rp()];break;case"uri":c=[E.OZ()];break;case"date":c=[F.p6()];break;case"date-time":let d,e;d=eq.exec(b),e=[void 0,-1,0],d&&e.push(Number(d[1])),c=[!1,!0].flatMap(a=>[!1,!0].flatMap(b=>e.map(c=>F.w$({local:a,offset:b,precision:c}))))}return new Set(c.map(a=>{let b;return b=cP.bl(a,{target:en,io:"input"}),"string"==typeof b.pattern?b.pattern:void 0}).filter(a=>void 0!==a))})(g,i).has(i))||d.push(`${b}.${h}`)}else f[h]=i;else d.push(`${b}.${h}`);return f}(c,`properties.${a}`,b,d)])):eu.has(e)?c[e]=f:et(e)||d.push(e);if(d.length>0)throw new dt(ds.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${d.join(", ")}`);return c}(function(a){try{return eo(a,"input")}catch(b){let a=b instanceof Error?b.message:String(b);throw new dt(ds.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${a}`)}}(a.requestedSchema),c),e=(b=b0.shape.requestedSchema,cO.xL(b,d));if(!e.success)throw new dt(ds.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(a,b){if(!er(a.properties))return b;let c=Object.entries(a.properties).filter(([,a])=>!cO.xL(b_,a).success).map(([a])=>`properties.${a}`);return c.length>0?c.join(", "):b}(d,e.error.message)}`);let f=function a(b,c,d=""){return Array.isArray(b)&&Array.isArray(c)?b.flatMap((b,e)=>a(b,c[e],`${d}[${e}]`)):er(b)&&er(c)?Object.entries(b).flatMap(([b,e])=>{let f=d?`${d}.${b}`:b;return Object.prototype.hasOwnProperty.call(c,b)?a(e,c[b],f):et(b)?[]:[f]}):[]}(d,e.data);if(f.length>0)throw new dt(ds.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${f.join(", ")}`);let g=(e.data.required??[]).filter(a=>!Object.prototype.hasOwnProperty.call(e.data.properties,a));if(g.length>0)throw new dt(ds.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${g.join(", ")}`);return{...a,mode:"form",requestedSchema:e.data}}(a)}}catch(a){throw a instanceof dt?TypeError(a.message,{cause:a}):a}},elicitUrl:a=>({method:"elicitation/create",params:{...a,mode:"url"}}),createMessage:a=>({method:"sampling/createMessage",params:a}),listRoots:()=>({method:"roots/list"})});let ex={},ey={};function ez(a,b){let c=a.slice(0,-6);ex[c]=b,ey[c]=a=>b.safeParse(a).success}for(let a of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])ez(a,dX[a]);for(let[a,b]of Object.entries({IdJagTokenExchangeResponseSchema:cG,OAuthClientInformationFullSchema:cL,OAuthClientInformationSchema:cK,OAuthClientMetadataSchema:cJ,OAuthClientRegistrationErrorSchema:cM,OAuthErrorResponseSchema:cH,OAuthMetadataSchema:cC,OAuthProtectedResourceMetadataSchema:cB,OAuthTokenRevocationRequestSchema:cN,OAuthTokensSchema:cF,OpenIdProviderDiscoveryMetadataSchema:cE,OpenIdProviderMetadataSchema:cD}))ez(a,b);let eA=Object.freeze(ex);Object.freeze(ey);let eB=[K,L,N,P],eC=["inputResponses","requestState"];function eD(a,b){let c=a.params;if(!eI(c))return{message:a,lifted:{}};let d=c._meta,e=eI(d)?eB.filter(a=>a in d):[],f="request"===b?eC.filter(a=>a in c):[];if(0===e.length&&0===f.length)return{message:a,lifted:{}};let g={},h={...c};if(e.length>0&&eI(d)){let a={},b={...d};for(let c of e)a[c]=d[c],delete b[c];g.envelope=a,Object.keys(b).length>0?h._meta=b:delete h._meta}for(let a of f)"inputResponses"===a&&(g.inputResponses=h[a]),"requestState"===a&&(g.requestState=h[a]),delete h[a];return{message:{...a,params:h},lifted:g}}function eE(a,b){let c=a.validateResult(b,void 0);if(c.ok||"not-in-era"!==c.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(c){let d=a.validateResult(b,c);return d.ok?{value:d.value}:{issues:[{message:"invalid"===d.reason?d.message:`not-in-era: ${b}`}]}}}}}let eF=(q=void 0,()=>q);function eG(a,b){return{...a,mcpReq:{...a.mcpReq,requestState:()=>b}}}var eH=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{i=(a,b)=>{a._negotiatedProtocolVersion=b}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(a){this._options=a,this._supportedProtocolVersions=a?.supportedProtocolVersions??J,this.setNotificationHandler("notifications/cancelled",a=>{this._oncancel(a)}),this.setNotificationHandler("notifications/progress",a=>{this._onprogress(a)}),this.setRequestHandler("ping",a=>({}))}_shouldDropInbound(a){}_outboundMetaEnvelope(){}_envelopeOutbound(a){let b=this._outboundMetaEnvelope();if(void 0===b)return a;let c=a.params??{};return{...a,params:{...c,_meta:{...b,...c._meta}}}}_resolveNonCompleteResult(a,b){return Promise.reject(new cW(cV.UnsupportedResultType,`Unsupported result type '${a.kind}' for ${b.request.method}`,{resultType:a.kind,method:b.request.method}))}_getRequestHandler(a){return this._requestHandlers.get(a)}async _oncancel(a){a.params.requestId&&this._requestHandlerAbortControllers.get(a.params.requestId)?.abort(a.params.reason)}_setupTimeout(a,b,c,d,e=!1){this._timeoutInfo.set(a,{timeoutId:setTimeout(d,b),startTime:Date.now(),timeout:b,maxTotalTimeout:c,resetTimeoutOnProgress:e,onTimeout:d})}_resetTimeout(a){let b=this._timeoutInfo.get(a);if(!b)return!1;let c=Date.now()-b.startTime;if(b.maxTotalTimeout&&c>=b.maxTotalTimeout)throw this._timeoutInfo.delete(a),new cW(cV.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:b.maxTotalTimeout,totalElapsed:c});return clearTimeout(b.timeoutId),b.timeoutId=setTimeout(b.onTimeout,b.timeout),!0}_cleanupTimeout(a){let b=this._timeoutInfo.get(a);b&&(clearTimeout(b.timeoutId),this._timeoutInfo.delete(a))}async connect(a){this._transport=a;let b=this.transport?.onclose;this._transport.onclose=()=>{try{b?.()}finally{this._onclose()}};let c=this.transport?.onerror;this._transport.onerror=a=>{c?.(a),this._onerror(a)};let d=this._transport?.onmessage;this._transport.onmessage=(a,b)=>{d?.(a,b),d$(a)||d_(a)?this._onresponse(a):dY(a)?this._onrequest(a,b):dZ(a)?this._onnotification(a,b):this._onerror(Error(`Unknown message type: ${JSON.stringify(a)}`))},a.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let a=this._responseHandlers;for(let a of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(a.timeoutId);this._timeoutInfo.clear();let b=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let c=new cW(cV.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let b of a.values())b(c);for(let a of b.values())a.abort(c)}}_onerror(a){this.onerror?.(a)}_onnotification(a,b){let{message:c}=eD(a,"notification"),d=this._negotiatedWireCodec();if(b?.classification===void 0&&"drop"===this._shouldDropInbound(a))return;if(b?.classification!==void 0){let a=dO(b.classification);if(a!==d.era)return void this._onerror(Error(`Era mismatch on inbound notification '${c.method}': classified as ${a} but this instance serves ${d.era}`))}if(dQ(c.method)&&!d.hasNotificationMethod(c.method))return;let e=this._notificationHandlers.get(c.method),f=this.fallbackNotificationHandler;(void 0!==e||void 0!==f)&&Promise.resolve().then(()=>void 0===e?f(c):e(c,d)).catch(a=>this._onerror(Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(a,b){var c;let{message:d,lifted:e}=eD(a,"request"),f=this._negotiatedWireCodec();if(b?.classification===void 0&&"drop"===this._shouldDropInbound(a))return void this._onerror(Error(`Dropped inbound request '${a.method}': not servable on this connection's protocol era`));let g=this._transport,h=(a,b,c)=>{let e={jsonrpc:"2.0",id:d.id,error:{code:a,message:b,...void 0!==c&&{data:c}}};g?.send(e).catch(a=>this._onerror(Error(`Failed to send an error response: ${a}`)))};if(b?.classification!==void 0){let a=dO(b.classification);if(a!==f.era){this._onerror(Error(`Era mismatch on inbound request '${d.method}': classified as ${a} but this instance serves ${f.era}`));let c=b.classification.revision??a;h(ds.UnsupportedProtocolVersion,`Unsupported protocol version: ${c}`,{supported:this._supportedProtocolVersions,requested:c});return}}if(dP(d.method)&&!f.hasRequestMethod(d.method))return void h(ds.MethodNotFound,"Method not found");let i=this._requestHandlers.get(d.method)??this.fallbackRequestHandler;if(void 0===i)return void h(ds.MethodNotFound,"Method not found");let j=f.checkInboundEnvelope(e);if(void 0!==j)return void h(ds.InvalidParams,j);let k=(a,b)=>this._notificationViaCodec(this._resolveOutboundCodec(a.method),a,{...b,relatedRequestId:d.id}),l=(a,b,c)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(a.method),a,b,{...c,relatedRequestId:d.id}),m=new AbortController;this._requestHandlerAbortControllers.set(d.id,m);let n=void 0===e.inputResponses?void 0:function(a){let b={},c=[];if(!eJ(a))return{accepted:b,droppedKeys:c};for(let[d,e]of Object.entries(a)){if(!eJ(e)||"method"in e||"result"in e){c.push(d);continue}b[d]=e}return{accepted:b,droppedKeys:c}}(e.inputResponses),o={sessionId:g?.sessionId,mcpReq:{id:d.id,method:d.method,_meta:d.params?._meta,...void 0!==e.envelope&&{envelope:e.envelope},...void 0!==n&&{inputResponses:n.accepted},...void 0!==n&&n.droppedKeys.length>0&&{droppedInputResponseKeys:n.droppedKeys},requestState:void 0===e.requestState?eF:(c=e.requestState,()=>c),signal:m.signal,send:(a,b,c)=>{let d=this._resolveOutboundCodec(a.method);if(this._assertOutboundRequestInEra(d,a.method),el(b))return l(a,b,c);let e=eE(d,a.method);if(void 0===e)throw TypeError(`'${a.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return l(a,e,b)},notify:k},http:b?.authInfo?{authInfo:b.authInfo}:void 0},p=this.buildContext(o,b);Promise.resolve().then(()=>i(d,p)).then(async a=>{let b;if(m.signal.aborted)return;try{b=f.encodeResult(d.method,a,this._outboundServerInfo())}catch(a){this._onerror(Error(`Failed to encode result for ${d.method}: ${a}`)),h(ds.InternalError,"Internal error");return}let c={result:b,jsonrpc:"2.0",id:d.id};await g?.send(c)},async a=>{if(m.signal.aborted)return;let b=Number.isSafeInteger(a.code)?a.code:ds.InternalError,c={jsonrpc:"2.0",id:d.id,error:{code:f.encodeErrorCode(b),message:a.message??"Internal error",...void 0!==a.data&&{data:a.data}}};await g?.send(c)}).catch(a=>this._onerror(Error(`Failed to send response: ${a}`))).finally(()=>{this._requestHandlerAbortControllers.get(d.id)===m&&this._requestHandlerAbortControllers.delete(d.id)})}_onprogress(a){let{progressToken:b,...c}=a.params,d=Number(b),e=this._progressHandlers.get(d);if(!e)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(a)}`));let f=this._responseHandlers.get(d),g=this._timeoutInfo.get(d);if(g&&f&&g.resetTimeoutOnProgress)try{this._resetTimeout(d)}catch(a){this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),f(a);return}e(c)}_onresponse(a){let b=Number(a.id),c=this._responseHandlers.get(b);void 0===c?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(a)}`)):(this._responseHandlers.delete(b),this._cleanupTimeout(b),this._progressHandlers.delete(b),c(d$(a)?a:dt.fromError(a.error.code,a.error.message,a.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(a,b,c){let d=this._resolveOutboundCodec(a.method);if(this._assertOutboundRequestInEra(d,a.method),el(b))return this._requestWithSchemaViaCodec(d,a,b,c);let e=eE(d,a.method);if(void 0===e)throw TypeError(`'${a.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(d,a,e,b)}_negotiatedWireCodec(){return dN(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(a){if(void 0===this._negotiatedProtocolVersion){let b=function(a){switch(a){case"initialize":case"notifications/initialized":return dN(void 0);case"server/discover":return dN(dM);default:return}}(a);if(b)return b}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(a,b){if(dP(b)&&!a.hasRequestMethod(b))throw new cW(cV.MethodNotSupportedByProtocolVersion,`Method '${b}' is not supported by the negotiated protocol version (wire era ${a.era})`,{method:b,era:a.era})}_requestWithSchema(a,b,c){let d=this._resolveOutboundCodec(a.method);return this._assertOutboundRequestInEra(d,a.method),this._requestWithSchemaViaCodec(d,a,b,c)}_requestWithSchemaViaCodec(a,b,c,d){let e,f,{relatedRequestId:g,resumptionToken:h,onresumptiontoken:i,headers:j}=d??{},k=Date.now();return new Promise((l,m)=>{let n=a=>{m(a)};if(!this._transport)return void n(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(b.method)}catch(a){n(a);return}if(d?.signal?.aborted){let a=d.signal.reason;throw a instanceof cW?a:new cW(cV.RequestTimeout,String(a))}let o=a.era===dM&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,p=this._requestMessageId++;f=p;let q={...b,jsonrpc:"2.0",id:p};d?.onprogress&&(this._progressHandlers.set(p,d.onprogress),q.params={...b.params,_meta:{...b.params?._meta,progressToken:p}});let r=this._envelopeOutbound(q),s=!1,t=a=>{s||(this._progressHandlers.delete(p),void 0===o?this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(a)}}),{relatedRequestId:g,resumptionToken:h,onresumptiontoken:i}).catch(a=>this._onerror(Error(`Failed to send cancellation: ${a}`))):o.abort(),m(a instanceof cW?a:new cW(cV.RequestTimeout,String(a))))};this._responseHandlers.set(p,e=>{let f;if(!d?.signal?.aborted){if(s=!0,e instanceof Error)return m(e);try{f=a.decodeResult(b.method,e.result)}catch(a){return m(a instanceof Error?a:Error(String(a)))}if("invalid"===f.kind)return m(f.error);if("input_required"===f.kind){var g;return d?.allowInputRequired===!0?l({resultType:"input_required",inputRequests:(g=f).inputRequests,...void 0!==g.requestState&&{requestState:g.requestState}}):l(this._resolveNonCompleteResult(f,{codec:a,request:b,resultSchema:c,options:d,flowStartedAt:k,retry:(d,e)=>this._requestWithSchemaViaCodec(a,void 0===d?{method:b.method}:{method:b.method,params:d},c,e)}))}ep(c,f.result).then(a=>{a.success?l(a.data):m(new cW(cV.InvalidResult,`Invalid result for ${b.method}: ${a.error}`))},m)}}),e=()=>t(d?.signal?.reason),d?.signal?.addEventListener("abort",e,{once:!0});let u=d?.timeout??6e4;this._setupTimeout(p,u,d?.maxTotalTimeout,()=>t(new cW(cV.RequestTimeout,"Request timed out",{timeout:u})),d?.resetTimeoutOnProgress??!1),this._transport.send(r,{relatedRequestId:g,resumptionToken:h,onresumptiontoken:i,headers:j,requestSignal:o?.signal}).catch(a=>{this._progressHandlers.delete(p),m(a)})}).finally(()=>{e&&d?.signal?.removeEventListener("abort",e),void 0!==f&&(this._responseHandlers.delete(f),this._cleanupTimeout(f))})}async notification(a,b){return this._notificationViaCodec(this._resolveOutboundCodec(a.method),a,b)}async _notificationViaCodec(a,b,c){if(!this._transport)throw new cW(cV.NotConnected,"Not connected");if(dQ(b.method)&&!a.hasNotificationMethod(b.method))throw new cW(cV.MethodNotSupportedByProtocolVersion,`Notification '${b.method}' is not supported by the negotiated protocol version (wire era ${a.era})`,{method:b.method,era:a.era});this.assertNotificationCapability(b.method);let d=this._envelopeOutbound({jsonrpc:"2.0",...b});if((this._options?.debouncedNotificationMethods??[]).includes(b.method)&&!b.params&&!c?.relatedRequestId){if(this._pendingDebouncedNotifications.has(b.method))return;this._pendingDebouncedNotifications.add(b.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(b.method),this._transport&&this._transport?.send(d,c).catch(a=>this._onerror(a))});return}await this._transport.send(d,c)}setRequestHandler(a,b,c){let d;if(this.assertRequestHandlerCapability(a),"function"==typeof b){if(!dP(a))throw TypeError(`'${a}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);d=(c,d)=>{let e=this._negotiatedWireCodec(),f=e.validateRequest(a,c);if(f.ok||"not-in-era"!==f.reason||(f=e.validateInputRequest(a,c)),!f.ok){if("not-in-era"===f.reason)throw new dt(ds.InternalError,`No wire schema for ${a} in the resolved era`);throw Error(f.message)}return Promise.resolve(b(f.value,d))}}else if(c)d=async(d,e)=>{let f=await ep(b.params,{...d.params});if(!f.success)throw new dt(ds.InvalidParams,`Invalid params for ${a}: ${f.error}`);return c(f.data,e)};else throw TypeError("setRequestHandler: handler is required");this._requestHandlers.set(a,this._wrapHandler(a,d))}_wrapHandler(a,b){return b}_outboundServerInfo(){}removeRequestHandler(a){this._requestHandlers.delete(a)}assertCanSetRequestHandler(a){if(this._requestHandlers.has(a))throw Error(`A request handler for ${a} already exists, which would be overridden`)}setNotificationHandler(a,b,c){if("function"==typeof b){if(!dQ(a))throw TypeError(`'${a}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(a,(c,d)=>{let e=d.validateNotification(a,c);if(!e.ok){if("not-in-era"===e.reason)throw new dt(ds.InternalError,`No wire schema for ${a} in the resolved era`);throw Error(e.message)}return Promise.resolve(b(e.value))});return}if(!c)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(a,async d=>{let e=await ep(b.params,{...d.params});if(!e.success)throw new dt(ds.InvalidParams,`Invalid params for notification ${a}: ${e.error}`);await c(e.data,d)})}removeNotificationHandler(a){this._notificationHandlers.delete(a)}};function eI(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function eJ(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}var eK=z(y(a=>{var b=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,c=/\\([\u000b\u0020-\u00ff])/g,d=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function e(a){this.parameters=Object.create(null),this.type=a}a.parse=function(a){if(!a)throw TypeError("argument string is required");var f,g,h,i="object"==typeof a?function(a){var b;if("function"==typeof a.getHeader?b=a.getHeader("content-type"):"object"==typeof a.headers&&(b=a.headers&&a.headers["content-type"]),"string"!=typeof b)throw TypeError("content-type header is missing from object");return b}(a):a;if("string"!=typeof i)throw TypeError("argument string is required to be a string");var j=i.indexOf(";"),k=-1!==j?i.slice(0,j).trim():i.trim();if(!d.test(k))throw TypeError("invalid media type");var l=new e(k.toLowerCase());if(-1!==j){for(b.lastIndex=j;g=b.exec(i);){if(g.index!==j)throw TypeError("invalid parameter format");j+=g[0].length,f=g[1].toLowerCase(),34===(h=g[2]).charCodeAt(0)&&-1!==(h=h.slice(1,-1)).indexOf("\\")&&(h=h.replace(c,"$1")),l.parameters[f]=h}if(j!==i.length)throw TypeError("invalid parameter format")}return l}})(),1);function eL(a){if(a)try{return eK.parse(a).type}catch{let b=(a.split(";",1)[0]??"").trim().toLowerCase();if(""===b||a.slice(b.length).includes(","))return;return b}}function eM(a){return"application/json"===a||"application/json"===eL(a)}let eN=/^[A-Za-z0-9._-]{1,128}$/;function eO(a){let b=function(a){let b=[];if(0===a.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(a.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${a.length})`]};if(a.includes(" ")&&b.push("Tool name contains spaces, which may cause parsing issues"),a.includes(",")&&b.push("Tool name contains commas, which may cause parsing issues"),(a.startsWith("-")||a.endsWith("-"))&&b.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(a.startsWith(".")||a.endsWith("."))&&b.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!eN.test(a)){let c=[...a].filter(a=>!/[A-Za-z0-9._-]/.test(a)).filter((a,b,c)=>c.indexOf(a)===b);return b.push(`Tool name contains invalid characters: ${c.map(a=>`"${a}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:b}}return{isValid:!0,warnings:b}}(a);var c=b.warnings;if(c.length>0){for(let b of(console.warn(`Tool name validation warning for "${a}":`),c))console.warn(` - ${b}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}return b.isValid}var eP=class a{static isTemplate(a){return/\{[^}\s]+\}/.test(a)}static validateLength(a,b,c){if(a.length>b)throw Error(`${c} exceeds maximum length of ${b} characters (got ${a.length})`)}template;parts;get variableNames(){return this.parts.flatMap(a=>"string"==typeof a?[]:a.names)}constructor(b){a.validateLength(b,1e6,"Template"),this.template=b,this.parts=this.parse(b)}toString(){return this.template}parse(b){let c=[],d="",e=0,f=0;for(;e<b.length;)if("{"===b[e]){d&&(c.push(d),d="");let g=b.indexOf("}",e);if(-1===g)throw Error("Unclosed template expression");if(++f>1e4)throw Error("Template contains too many expressions (max 10000)");let h=b.slice(e+1,g),i=this.getOperator(h),j=h.includes("*"),k=this.getNames(h),l=k[0];for(let b of k)a.validateLength(b,1e6,"Variable name");c.push({name:l,operator:i,names:k,exploded:j}),e=g+1}else d+=b[e],e++;return d&&c.push(d),c}getOperator(a){return["+","#",".","/","?","&"].find(b=>a.startsWith(b))||""}getNames(a){let b=this.getOperator(a);return a.slice(b.length).split(",").map(a=>a.replace("*","").trim()).filter(a=>a.length>0)}encodeValue(b,c){return(a.validateLength(b,1e6,"Variable value"),"+"===c||"#"===c)?encodeURI(b):encodeURIComponent(b)}expandPart(a,b){if("?"===a.operator||"&"===a.operator){let c=a.names.map(c=>{let d=b[c];return void 0===d?"":`${c}=${Array.isArray(d)?d.map(b=>this.encodeValue(b,a.operator)).join(","):this.encodeValue(d.toString(),a.operator)}`}).filter(a=>a.length>0);return 0===c.length?"":("?"===a.operator?"?":"&")+c.join("&")}if(a.names.length>1){let c=a.names.map(a=>b[a]).filter(a=>void 0!==a);return 0===c.length?"":c.map(a=>Array.isArray(a)?a[0]:a).join(",")}let c=b[a.name];if(void 0===c)return"";let d=(Array.isArray(c)?c:[c]).map(b=>this.encodeValue(b,a.operator));switch(a.operator){case"":case"+":default:return d.join(",");case"#":return"#"+d.join(",");case".":return"."+d.join(".");case"/":return"/"+d.join("/")}}expand(a){let b="",c=!1;for(let d of this.parts){if("string"==typeof d){b+=d;continue}let e=this.expandPart(d,a);e&&(b+=("?"===d.operator||"&"===d.operator)&&c?e.replace("?","&"):e,("?"===d.operator||"&"===d.operator)&&(c=!0))}return b}escapeRegExp(a){return a.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(b){let c,d=[];for(let c of b.names)a.validateLength(c,1e6,"Variable name");if("?"===b.operator||"&"===b.operator){for(let a=0;a<b.names.length;a++){let c=b.names[a],e=0===a?"\\"+b.operator:"&";d.push({pattern:e+this.escapeRegExp(c)+"=([^&]+)",name:c})}return d}let e=b.name;switch(b.operator){case"":c=b.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":c="(.+)";break;case".":c=String.raw`\.([^/,]+)`;break;case"/":c="/"+(b.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:c="([^/]+)"}return d.push({pattern:c,name:e}),d}match(b){a.validateLength(b,1e6,"URI");let c="^",d=[];for(let a of this.parts)if("string"==typeof a)c+=this.escapeRegExp(a);else for(let{pattern:b,name:e}of this.partToRegExp(a))c+=b,d.push({name:e,exploded:a.exploded});c+="$",a.validateLength(c,1e6,"Generated regex pattern");let e=new RegExp(c),f=b.match(e);if(!f)return null;let g={};for(let[a,b]of d.entries()){let{name:c,exploded:d}=b,e=f[a+1];g[c.replace("*","")]=d&&e.includes(",")?e.split(","):e}return g}};function eQ(a){if(void 0!==a){if(function(a){if("object"!=typeof a||null===a||el(a))return!1;let b=Object.getPrototypeOf(a);return(b===Object.prototype||null===b)&&Object.values(a).every(a=>"object"==typeof a&&null!==a&&"_zod"in a)}(a))return E.Ik(a);if("object"==typeof a&&null!==a&&!el(a)&&Object.values(a).some(a=>"object"==typeof a&&null!==a&&!("_zod"in a)&&"_def"in a&&"string"==typeof a._def?.typeName))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!el(a))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return a}}var eR=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.regexpCode=a.getEsmExportName=a.getProperty=a.safeStringify=a.stringify=a.strConcat=a.addCodeArg=a.str=a._=a.nil=a._Code=a.Name=a.IDENTIFIER=a._CodeOrName=void 0;var b=class{};a._CodeOrName=b,a.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var c=class extends b{constructor(b){if(super(),!a.IDENTIFIER.test(b))throw Error("CodeGen: name must be a valid identifier");this.str=b}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};a.Name=c;var d=class extends b{constructor(a){super(),this._items="string"==typeof a?[a]:a}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let a=this._items[0];return""===a||'""'===a}get str(){var a;return null!=(a=this._str)?a:this._str=this._items.reduce((a,b)=>`${a}${b}`,"")}get names(){var a;return null!=(a=this._names)?a:this._names=this._items.reduce((a,b)=>(b instanceof c&&(a[b.str]=(a[b.str]||0)+1),a),{})}};function e(a,...b){let c=[a[0]],f=0;for(;f<b.length;)h(c,b[f]),c.push(a[++f]);return new d(c)}a._Code=d,a.nil=new d(""),a._=e;let f=new d("+");function g(a,...b){let e=[i(a[0])],j=0;for(;j<b.length;)e.push(f),h(e,b[j]),e.push(f,i(a[++j]));return function(a){let b=1;for(;b<a.length-1;){if(a[b]===f){var d,e;let f=(d=a[b-1],'""'===(e=a[b+1])?d:'""'===d?e:"string"==typeof d?e instanceof c||'"'!==d[d.length-1]?void 0:"string"!=typeof e?`${d.slice(0,-1)}${e}"`:'"'===e[0]?d.slice(0,-1)+e.slice(1):void 0:"string"!=typeof e||'"'!==e[0]||d instanceof c?void 0:`"${d}${e.slice(1)}`);if(void 0!==f){a.splice(b-1,3,f);continue}a[b++]="+"}b++}}(e),new d(e)}function h(a,b){var e;b instanceof d?a.push(...b._items):b instanceof c?a.push(b):a.push("number"==typeof(e=b)||"boolean"==typeof e||null===e?e:i(Array.isArray(e)?e.join(","):e))}function i(a){return JSON.stringify(a).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}a.str=g,a.addCodeArg=h,a.strConcat=function(a,b){return b.emptyStr()?a:a.emptyStr()?b:g`${a}${b}`},a.stringify=function(a){return new d(i(a))},a.safeStringify=i,a.getProperty=function(b){return"string"==typeof b&&a.IDENTIFIER.test(b)?new d(`.${b}`):e`[${b}]`},a.getEsmExportName=function(b){if("string"==typeof b&&a.IDENTIFIER.test(b))return new d(`${b}`);throw Error(`CodeGen: invalid export name: ${b}, use explicit $id name mapping`)},a.regexpCode=function(a){return new d(a.toString())}}),eS=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ValueScope=a.ValueScopeName=a.Scope=a.varKinds=a.UsedValueState=void 0;let b=eR();var c,d,e=class extends Error{constructor(a){super(`CodeGen: "code" for ${a} not defined`),this.value=a.value}};(c=d||(a.UsedValueState=d={}))[c.Started=0]="Started",c[c.Completed=1]="Completed",a.varKinds={const:new b.Name("const"),let:new b.Name("let"),var:new b.Name("var")};var f=class{constructor({prefixes:a,parent:b}={}){this._names={},this._prefixes=a,this._parent=b}toName(a){return a instanceof b.Name?a:this.name(a)}name(a){return new b.Name(this._newName(a))}_newName(a){let b=this._names[a]||this._nameGroup(a);return`${a}${b.index++}`}_nameGroup(a){var b,c;if((null==(c=null==(b=this._parent)?void 0:b._prefixes)?void 0:c.has(a))||this._prefixes&&!this._prefixes.has(a))throw Error(`CodeGen: prefix "${a}" is not allowed in this scope`);return this._names[a]={prefix:a,index:0}}};a.Scope=f;var g=class extends b.Name{constructor(a,b){super(b),this.prefix=a}setValue(a,{property:c,itemIndex:d}){this.value=a,this.scopePath=(0,b._)`.${new b.Name(c)}[${d}]`}};a.ValueScopeName=g;let h=(0,b._)`\n`;var i=class extends f{constructor(a){super(a),this._values={},this._scope=a.scope,this.opts={...a,_n:a.lines?h:b.nil}}get(){return this._scope}name(a){return new g(a,this._newName(a))}value(a,b){var c;if(void 0===b.ref)throw Error("CodeGen: ref must be passed in value");let d=this.toName(a),{prefix:e}=d,f=null!=(c=b.key)?c:b.ref,g=this._values[e];if(g){let a=g.get(f);if(a)return a}else g=this._values[e]=new Map;g.set(f,d);let h=this._scope[e]||(this._scope[e]=[]),i=h.length;return h[i]=b.ref,d.setValue(b,{property:e,itemIndex:i}),d}getValue(a,b){let c=this._values[a];if(c)return c.get(b)}scopeRefs(a,c=this._values){return this._reduceValues(c,c=>{if(void 0===c.scopePath)throw Error(`CodeGen: name "${c}" has no value`);return(0,b._)`${a}${c.scopePath}`})}scopeCode(a=this._values,b,c){return this._reduceValues(a,a=>{if(void 0===a.value)throw Error(`CodeGen: name "${a}" has no value`);return a.value.code},b,c)}_reduceValues(c,f,g={},h){let i=b.nil;for(let j in c){let k=c[j];if(!k)continue;let l=g[j]=g[j]||new Map;k.forEach(c=>{if(l.has(c))return;l.set(c,d.Started);let g=f(c);if(g){let d=this.opts.es5?a.varKinds.var:a.varKinds.const;i=(0,b._)`${i}${d} ${c} = ${g};${this.opts._n}`}else if(g=null==h?void 0:h(c))i=(0,b._)`${i}${g}${this.opts._n}`;else throw new e(c);l.set(c,d.Completed)})}return i}};a.ValueScope=i}),eT=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.or=a.and=a.not=a.CodeGen=a.operators=a.varKinds=a.ValueScopeName=a.ValueScope=a.Scope=a.Name=a.regexpCode=a.stringify=a.getProperty=a.nil=a.strConcat=a.str=a._=void 0;let b=eR(),c=eS();var d=eR();Object.defineProperty(a,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(a,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(a,"strConcat",{enumerable:!0,get:function(){return d.strConcat}}),Object.defineProperty(a,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(a,"getProperty",{enumerable:!0,get:function(){return d.getProperty}}),Object.defineProperty(a,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(a,"regexpCode",{enumerable:!0,get:function(){return d.regexpCode}}),Object.defineProperty(a,"Name",{enumerable:!0,get:function(){return d.Name}});var e=eS();Object.defineProperty(a,"Scope",{enumerable:!0,get:function(){return e.Scope}}),Object.defineProperty(a,"ValueScope",{enumerable:!0,get:function(){return e.ValueScope}}),Object.defineProperty(a,"ValueScopeName",{enumerable:!0,get:function(){return e.ValueScopeName}}),Object.defineProperty(a,"varKinds",{enumerable:!0,get:function(){return e.varKinds}}),a.operators={GT:new b._Code(">"),GTE:new b._Code(">="),LT:new b._Code("<"),LTE:new b._Code("<="),EQ:new b._Code("==="),NEQ:new b._Code("!=="),NOT:new b._Code("!"),OR:new b._Code("||"),AND:new b._Code("&&"),ADD:new b._Code("+")};var f=class{optimizeNodes(){return this}optimizeNames(a,b){return this}},g=class extends f{constructor(a,b,c){super(),this.varKind=a,this.name=b,this.rhs=c}render({es5:a,_n:b}){let d=a?c.varKinds.var:this.varKind,e=void 0===this.rhs?"":` = ${this.rhs}`;return`${d} ${this.name}${e};`+b}optimizeNames(a,b){if(a[this.name.str])return this.rhs&&(this.rhs=E(this.rhs,a,b)),this}get names(){return this.rhs instanceof b._CodeOrName?this.rhs.names:{}}},h=class extends f{constructor(a,b,c){super(),this.lhs=a,this.rhs=b,this.sideEffects=c}render({_n:a}){return`${this.lhs} = ${this.rhs};`+a}optimizeNames(a,c){if(!(this.lhs instanceof b.Name)||a[this.lhs.str]||this.sideEffects)return this.rhs=E(this.rhs,a,c),this}get names(){return D(this.lhs instanceof b.Name?{}:{...this.lhs.names},this.rhs)}},i=class extends h{constructor(a,b,c,d){super(a,c,d),this.op=b}render({_n:a}){return`${this.lhs} ${this.op}= ${this.rhs};`+a}},j=class extends f{constructor(a){super(),this.label=a,this.names={}}render({_n:a}){return`${this.label}:`+a}},k=class extends f{constructor(a){super(),this.label=a,this.names={}}render({_n:a}){return`break${this.label?` ${this.label}`:""};`+a}},l=class extends f{constructor(a){super(),this.error=a}render({_n:a}){return`throw ${this.error};`+a}get names(){return this.error.names}},m=class extends f{constructor(a){super(),this.code=a}render({_n:a}){return`${this.code};`+a}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(a,b){return this.code=E(this.code,a,b),this}get names(){return this.code instanceof b._CodeOrName?this.code.names:{}}},n=class extends f{constructor(a=[]){super(),this.nodes=a}render(a){return this.nodes.reduce((b,c)=>b+c.render(a),"")}optimizeNodes(){let{nodes:a}=this,b=a.length;for(;b--;){let c=a[b].optimizeNodes();Array.isArray(c)?a.splice(b,1,...c):c?a[b]=c:a.splice(b,1)}return a.length>0?this:void 0}optimizeNames(a,b){let{nodes:c}=this,d=c.length;for(;d--;){let e=c[d];e.optimizeNames(a,b)||(function(a,b){for(let c in b)a[c]=(a[c]||0)-(b[c]||0)}(a,e.names),c.splice(d,1))}return c.length>0?this:void 0}get names(){return this.nodes.reduce((a,b)=>C(a,b.names),{})}},o=class extends n{render(a){return"{"+a._n+super.render(a)+"}"+a._n}},p=class extends n{},q=class extends o{};q.kind="else";var r=class a extends o{constructor(a,b){super(b),this.condition=a}render(a){let b=`if(${this.condition})`+super.render(a);return this.else&&(b+="else "+this.else.render(a)),b}optimizeNodes(){super.optimizeNodes();let b=this.condition;if(!0===b)return this.nodes;let c=this.else;if(c){let a=c.optimizeNodes();c=this.else=Array.isArray(a)?new q(a):a}return c?!1===b?c instanceof a?c:c.nodes:this.nodes.length?this:new a(F(b),c instanceof a?[c]:c.nodes):!1!==b&&this.nodes.length?this:void 0}optimizeNames(a,b){var c;if(this.else=null==(c=this.else)?void 0:c.optimizeNames(a,b),super.optimizeNames(a,b)||this.else)return this.condition=E(this.condition,a,b),this}get names(){let a=super.names;return D(a,this.condition),this.else&&C(a,this.else.names),a}};r.kind="if";var s=class extends o{};s.kind="for";var t=class extends s{constructor(a){super(),this.iteration=a}render(a){return`for(${this.iteration})`+super.render(a)}optimizeNames(a,b){if(super.optimizeNames(a,b))return this.iteration=E(this.iteration,a,b),this}get names(){return C(super.names,this.iteration.names)}},u=class extends s{constructor(a,b,c,d){super(),this.varKind=a,this.name=b,this.from=c,this.to=d}render(a){let b=a.es5?c.varKinds.var:this.varKind,{name:d,from:e,to:f}=this;return`for(${b} ${d}=${e}; ${d}<${f}; ${d}++)`+super.render(a)}get names(){return D(D(super.names,this.from),this.to)}},v=class extends s{constructor(a,b,c,d){super(),this.loop=a,this.varKind=b,this.name=c,this.iterable=d}render(a){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(a)}optimizeNames(a,b){if(super.optimizeNames(a,b))return this.iterable=E(this.iterable,a,b),this}get names(){return C(super.names,this.iterable.names)}},w=class extends o{constructor(a,b,c){super(),this.name=a,this.args=b,this.async=c}render(a){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(a)}};w.kind="func";var x=class extends n{render(a){return"return "+super.render(a)}};x.kind="return";var y=class extends o{render(a){let b="try"+super.render(a);return this.catch&&(b+=this.catch.render(a)),this.finally&&(b+=this.finally.render(a)),b}optimizeNodes(){var a,b;return super.optimizeNodes(),null==(a=this.catch)||a.optimizeNodes(),null==(b=this.finally)||b.optimizeNodes(),this}optimizeNames(a,b){var c,d;return super.optimizeNames(a,b),null==(c=this.catch)||c.optimizeNames(a,b),null==(d=this.finally)||d.optimizeNames(a,b),this}get names(){let a=super.names;return this.catch&&C(a,this.catch.names),this.finally&&C(a,this.finally.names),a}},z=class extends o{constructor(a){super(),this.error=a}render(a){return`catch(${this.error})`+super.render(a)}};z.kind="catch";var A=class extends o{render(a){return"finally"+super.render(a)}};A.kind="finally";var B=class{constructor(a,b={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...b,_n:b.lines?"\n":""},this._extScope=a,this._scope=new c.Scope({parent:a}),this._nodes=[new p]}toString(){return this._root.render(this.opts)}name(a){return this._scope.name(a)}scopeName(a){return this._extScope.name(a)}scopeValue(a,b){let c=this._extScope.value(a,b);return(this._values[c.prefix]||(this._values[c.prefix]=new Set)).add(c),c}getScopeValue(a,b){return this._extScope.getValue(a,b)}scopeRefs(a){return this._extScope.scopeRefs(a,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(a,b,c,d){let e=this._scope.toName(b);return void 0!==c&&d&&(this._constants[e.str]=c),this._leafNode(new g(a,e,c)),e}const(a,b,d){return this._def(c.varKinds.const,a,b,d)}let(a,b,d){return this._def(c.varKinds.let,a,b,d)}var(a,b,d){return this._def(c.varKinds.var,a,b,d)}assign(a,b,c){return this._leafNode(new h(a,b,c))}add(b,c){return this._leafNode(new i(b,a.operators.ADD,c))}code(a){return"function"==typeof a?a():a!==b.nil&&this._leafNode(new m(a)),this}object(...a){let c=["{"];for(let[d,e]of a)c.length>1&&c.push(","),c.push(d),(d!==e||this.opts.es5)&&(c.push(":"),(0,b.addCodeArg)(c,e));return c.push("}"),new b._Code(c)}if(a,b,c){if(this._blockNode(new r(a)),b&&c)this.code(b).else().code(c).endIf();else if(b)this.code(b).endIf();else if(c)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(a){return this._elseNode(new r(a))}else(){return this._elseNode(new q)}endIf(){return this._endBlockNode(r,q)}_for(a,b){return this._blockNode(a),b&&this.code(b).endFor(),this}for(a,b){return this._for(new t(a),b)}forRange(a,b,d,e,f=this.opts.es5?c.varKinds.var:c.varKinds.let){let g=this._scope.toName(a);return this._for(new u(f,g,b,d),()=>e(g))}forOf(a,d,e,f=c.varKinds.const){let g=this._scope.toName(a);if(this.opts.es5){let a=d instanceof b.Name?d:this.var("_arr",d);return this.forRange("_i",0,(0,b._)`${a}.length`,c=>{this.var(g,(0,b._)`${a}[${c}]`),e(g)})}return this._for(new v("of",f,g,d),()=>e(g))}forIn(a,d,e,f=this.opts.es5?c.varKinds.var:c.varKinds.const){if(this.opts.ownProperties)return this.forOf(a,(0,b._)`Object.keys(${d})`,e);let g=this._scope.toName(a);return this._for(new v("in",f,g,d),()=>e(g))}endFor(){return this._endBlockNode(s)}label(a){return this._leafNode(new j(a))}break(a){return this._leafNode(new k(a))}return(a){let b=new x;if(this._blockNode(b),this.code(a),1!==b.nodes.length)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(a,b,c){if(!b&&!c)throw Error('CodeGen: "try" without "catch" and "finally"');let d=new y;if(this._blockNode(d),this.code(a),b){let a=this.name("e");this._currNode=d.catch=new z(a),b(a)}return c&&(this._currNode=d.finally=new A,this.code(c)),this._endBlockNode(z,A)}throw(a){return this._leafNode(new l(a))}block(a,b){return this._blockStarts.push(this._nodes.length),a&&this.code(a).endBlock(b),this}endBlock(a){let b=this._blockStarts.pop();if(void 0===b)throw Error("CodeGen: not in self-balancing block");let c=this._nodes.length-b;if(c<0||void 0!==a&&c!==a)throw Error(`CodeGen: wrong number of nodes: ${c} vs ${a} expected`);return this._nodes.length=b,this}func(a,c=b.nil,d,e){return this._blockNode(new w(a,c,d)),e&&this.code(e).endFunc(),this}endFunc(){return this._endBlockNode(w)}optimize(a=1){for(;a-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(a){return this._currNode.nodes.push(a),this}_blockNode(a){this._currNode.nodes.push(a),this._nodes.push(a)}_endBlockNode(a,b){let c=this._currNode;if(c instanceof a||b&&c instanceof b)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${b?`${a.kind}/${b.kind}`:a.kind}"`)}_elseNode(a){let b=this._currNode;if(!(b instanceof r))throw Error('CodeGen: "else" without "if"');return this._currNode=b.else=a,this}get _root(){return this._nodes[0]}get _currNode(){let a=this._nodes;return a[a.length-1]}set _currNode(a){let b=this._nodes;b[b.length-1]=a}};function C(a,b){for(let c in b)a[c]=(a[c]||0)+(b[c]||0);return a}function D(a,c){return c instanceof b._CodeOrName?C(a,c.names):a}function E(a,c,d){var e;if(a instanceof b.Name)return f(a);if(!((e=a)instanceof b._Code&&e._items.some(a=>a instanceof b.Name&&1===c[a.str]&&void 0!==d[a.str])))return a;return new b._Code(a._items.reduce((a,c)=>(c instanceof b.Name&&(c=f(c)),c instanceof b._Code?a.push(...c._items):a.push(c),a),[]));function f(a){let b=d[a.str];return void 0===b||1!==c[a.str]?a:(delete c[a.str],b)}}function F(a){return"boolean"==typeof a||"number"==typeof a||null===a?!a:(0,b._)`!${J(a)}`}a.CodeGen=B,a.not=F;let G=I(a.operators.AND);a.and=function(...a){return a.reduce(G)};let H=I(a.operators.OR);function I(a){return(c,d)=>c===b.nil?d:d===b.nil?c:(0,b._)`${J(c)} ${a} ${J(d)}`}function J(a){return a instanceof b.Name?a:(0,b._)`(${a})`}a.or=function(...a){return a.reduce(H)}}),eU=y(a=>{var b,c;Object.defineProperty(a,"__esModule",{value:!0}),a.checkStrictMode=a.getErrorPath=a.Type=a.useFunc=a.setEvaluated=a.evaluatedPropsToName=a.mergeEvaluated=a.eachItem=a.unescapeJsonPointer=a.escapeJsonPointer=a.escapeFragment=a.unescapeFragment=a.schemaRefOrVal=a.schemaHasRulesButRef=a.schemaHasRules=a.checkUnknownRules=a.alwaysValidSchema=a.toHash=void 0;let d=eT(),e=eR();function f(a,b=a.schema){let{opts:c,self:d}=a;if(!c.strictSchema||"boolean"==typeof b)return;let e=d.RULES.keywords;for(let c in b)e[c]||n(a,`unknown keyword: "${c}"`)}function g(a,b){if("boolean"==typeof a)return!a;for(let c in a)if(b[c])return!0;return!1}function h(a){return"number"==typeof a?`${a}`:a.replace(/~/g,"~0").replace(/\//g,"~1")}function i(a){return a.replace(/~1/g,"/").replace(/~0/g,"~")}function j({mergeNames:a,mergeToName:b,mergeValues:c,resultToName:e}){return(f,g,h,i)=>{let j=void 0===h?g:h instanceof d.Name?(g instanceof d.Name?a(f,g,h):b(f,g,h),h):g instanceof d.Name?(b(f,h,g),g):c(g,h);return i!==d.Name||j instanceof d.Name?j:e(f,j)}}function k(a,b){if(!0===b)return a.var("props",!0);let c=a.var("props",(0,d._)`{}`);return void 0!==b&&l(a,c,b),c}function l(a,b,c){Object.keys(c).forEach(c=>a.assign((0,d._)`${b}${(0,d.getProperty)(c)}`,!0))}a.toHash=function(a){let b={};for(let c of a)b[c]=!0;return b},a.alwaysValidSchema=function(a,b){return"boolean"==typeof b?b:0===Object.keys(b).length||(f(a,b),!g(b,a.self.RULES.all))},a.checkUnknownRules=f,a.schemaHasRules=g,a.schemaHasRulesButRef=function(a,b){if("boolean"==typeof a)return!a;for(let c in a)if("$ref"!==c&&b.all[c])return!0;return!1},a.schemaRefOrVal=function({topSchemaRef:a,schemaPath:b},c,e,f){if(!f){if("number"==typeof c||"boolean"==typeof c)return c;if("string"==typeof c)return(0,d._)`${c}`}return(0,d._)`${a}${b}${(0,d.getProperty)(e)}`},a.unescapeFragment=function(a){return i(decodeURIComponent(a))},a.escapeFragment=function(a){return encodeURIComponent(h(a))},a.escapeJsonPointer=h,a.unescapeJsonPointer=i,a.eachItem=function(a,b){if(Array.isArray(a))for(let c of a)b(c);else b(a)},a.mergeEvaluated={props:j({mergeNames:(a,b,c)=>a.if((0,d._)`${c} !== true && ${b} !== undefined`,()=>{a.if((0,d._)`${b} === true`,()=>a.assign(c,!0),()=>a.assign(c,(0,d._)`${c} || {}`).code((0,d._)`Object.assign(${c}, ${b})`))}),mergeToName:(a,b,c)=>a.if((0,d._)`${c} !== true`,()=>{!0===b?a.assign(c,!0):(a.assign(c,(0,d._)`${c} || {}`),l(a,c,b))}),mergeValues:(a,b)=>!0===a||{...a,...b},resultToName:k}),items:j({mergeNames:(a,b,c)=>a.if((0,d._)`${c} !== true && ${b} !== undefined`,()=>a.assign(c,(0,d._)`${b} === true ? true : ${c} > ${b} ? ${c} : ${b}`)),mergeToName:(a,b,c)=>a.if((0,d._)`${c} !== true`,()=>a.assign(c,!0===b||(0,d._)`${c} > ${b} ? ${c} : ${b}`)),mergeValues:(a,b)=>!0===a||Math.max(a,b),resultToName:(a,b)=>a.var("items",b)})},a.evaluatedPropsToName=k,a.setEvaluated=l;let m={};function n(a,b,c=a.opts.strictSchema){if(c){if(b=`strict mode: ${b}`,!0===c)throw Error(b);a.self.logger.warn(b)}}a.useFunc=function(a,b){return a.scopeValue("func",{ref:b,code:m[b.code]||(m[b.code]=new e._Code(b.code))})},(c=b||(a.Type=b={}))[c.Num=0]="Num",c[c.Str=1]="Str",a.getErrorPath=function(a,c,e){if(a instanceof d.Name){let f=c===b.Num;return e?f?(0,d._)`"[" + ${a} + "]"`:(0,d._)`"['" + ${a} + "']"`:f?(0,d._)`"/" + ${a}`:(0,d._)`"/" + ${a}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return e?(0,d.getProperty)(a).toString():"/"+h(a)},a.checkStrictMode=n}),eV=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT();a.default={data:new b.Name("data"),valCxt:new b.Name("valCxt"),instancePath:new b.Name("instancePath"),parentData:new b.Name("parentData"),parentDataProperty:new b.Name("parentDataProperty"),rootData:new b.Name("rootData"),dynamicAnchors:new b.Name("dynamicAnchors"),vErrors:new b.Name("vErrors"),errors:new b.Name("errors"),this:new b.Name("this"),self:new b.Name("self"),scope:new b.Name("scope"),json:new b.Name("json"),jsonPos:new b.Name("jsonPos"),jsonLen:new b.Name("jsonLen"),jsonPart:new b.Name("jsonPart")}}),eW=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.extendErrors=a.resetErrorsCount=a.reportExtraError=a.reportError=a.keyword$DataError=a.keywordError=void 0;let b=eT(),c=eU(),d=eV();function e(a,c){let e=a.const("err",c);a.if((0,b._)`${d.default.vErrors} === null`,()=>a.assign(d.default.vErrors,(0,b._)`[${e}]`),(0,b._)`${d.default.vErrors}.push(${e})`),a.code((0,b._)`${d.default.errors}++`)}function f(a,c){let{gen:d,validateName:e,schemaEnv:f}=a;f.$async?d.throw((0,b._)`new ${a.ValidationError}(${c})`):(d.assign((0,b._)`${e}.errors`,c),d.return(!1))}a.keywordError={message:({keyword:a})=>(0,b.str)`must pass "${a}" keyword validation`},a.keyword$DataError={message:({keyword:a,schemaType:c})=>c?(0,b.str)`"${a}" keyword must be ${c} ($data)`:(0,b.str)`"${a}" keyword is invalid ($data)`},a.reportError=function(c,d=a.keywordError,g,i){let{it:j}=c,{gen:k,compositeRule:l,allErrors:m}=j,n=h(c,d,g);(null!=i?i:l||m)?e(k,n):f(j,(0,b._)`[${n}]`)},a.reportExtraError=function(b,c=a.keywordError,g){let{it:i}=b,{gen:j,compositeRule:k,allErrors:l}=i;e(j,h(b,c,g)),k||l||f(i,d.default.vErrors)},a.resetErrorsCount=function(a,c){a.assign(d.default.errors,c),a.if((0,b._)`${d.default.vErrors} !== null`,()=>a.if(c,()=>a.assign((0,b._)`${d.default.vErrors}.length`,c),()=>a.assign(d.default.vErrors,null)))},a.extendErrors=function({gen:a,keyword:c,schemaValue:e,data:f,errsCount:g,it:h}){if(void 0===g)throw Error("ajv implementation error");let i=a.name("err");a.forRange("i",g,d.default.errors,g=>{a.const(i,(0,b._)`${d.default.vErrors}[${g}]`),a.if((0,b._)`${i}.instancePath === undefined`,()=>a.assign((0,b._)`${i}.instancePath`,(0,b.strConcat)(d.default.instancePath,h.errorPath))),a.assign((0,b._)`${i}.schemaPath`,(0,b.str)`${h.errSchemaPath}/${c}`),h.opts.verbose&&(a.assign((0,b._)`${i}.schema`,e),a.assign((0,b._)`${i}.data`,f))})};let g={keyword:new b.Name("keyword"),schemaPath:new b.Name("schemaPath"),params:new b.Name("params"),propertyName:new b.Name("propertyName"),message:new b.Name("message"),schema:new b.Name("schema"),parentSchema:new b.Name("parentSchema")};function h(a,e,f){let{createErrors:h}=a.it;return!1===h?(0,b._)`{}`:function(a,e,f={}){let{gen:h,it:i}=a,j=[function({errorPath:a},{instancePath:e}){let f=e?(0,b.str)`${a}${(0,c.getErrorPath)(e,c.Type.Str)}`:a;return[d.default.instancePath,(0,b.strConcat)(d.default.instancePath,f)]}(i,f),function({keyword:a,it:{errSchemaPath:d}},{schemaPath:e,parentSchema:f}){let h=f?d:(0,b.str)`${d}/${a}`;return e&&(h=(0,b.str)`${h}${(0,c.getErrorPath)(e,c.Type.Str)}`),[g.schemaPath,h]}(a,f)];return function(a,{params:c,message:e},f){let{keyword:h,data:i,schemaValue:j,it:k}=a,{opts:l,propertyName:m,topSchemaRef:n,schemaPath:o}=k;f.push([g.keyword,h],[g.params,"function"==typeof c?c(a):c||(0,b._)`{}`]),l.messages&&f.push([g.message,"function"==typeof e?e(a):e]),l.verbose&&f.push([g.schema,j],[g.parentSchema,(0,b._)`${n}${o}`],[d.default.data,i]),m&&f.push([g.propertyName,m])}(a,e,j),h.object(...j)}(a,e,f)}}),eX=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.boolOrEmptySchema=a.topBoolOrEmptySchema=void 0;let b=eW(),c=eT(),d=eV(),e={message:"boolean schema is false"};function f(a,c){let{gen:d,data:f}=a;(0,b.reportError)({gen:d,keyword:"false schema",data:f,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:a},e,void 0,c)}a.topBoolOrEmptySchema=function(a){let{gen:b,schema:e,validateName:g}=a;!1===e?f(a,!1):"object"==typeof e&&!0===e.$async?b.return(d.default.data):(b.assign((0,c._)`${g}.errors`,null),b.return(!0))},a.boolOrEmptySchema=function(a,b){let{gen:c,schema:d}=a;!1===d?(c.var(b,!1),f(a)):c.var(b,!0)}}),eY=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getRules=a.isJSONType=void 0;let b=new Set(["string","number","integer","boolean","null","object","array"]);a.isJSONType=function(a){return"string"==typeof a&&b.has(a)},a.getRules=function(){let a={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...a,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},a.number,a.string,a.array,a.object],post:{rules:[]},all:{},keywords:{}}}}),eZ=y(a=>{function b(a,b){return b.rules.some(b=>c(a,b))}function c(a,b){var c;return void 0!==a[b.keyword]||(null==(c=b.definition.implements)?void 0:c.some(b=>void 0!==a[b]))}Object.defineProperty(a,"__esModule",{value:!0}),a.shouldUseRule=a.shouldUseGroup=a.schemaHasRulesForType=void 0,a.schemaHasRulesForType=function({schema:a,self:c},d){let e=c.RULES.types[d];return e&&!0!==e&&b(a,e)},a.shouldUseGroup=b,a.shouldUseRule=c}),e$=y(a=>{var b,c;Object.defineProperty(a,"__esModule",{value:!0}),a.reportTypeError=a.checkDataTypes=a.checkDataType=a.coerceAndCheckDataType=a.getJSONTypes=a.getSchemaTypes=a.DataType=void 0;let d=eY(),e=eZ(),f=eW(),g=eT(),h=eU();function i(a){let b=Array.isArray(a)?a:a?[a]:[];if(b.every(d.isJSONType))return b;throw Error("type must be JSONType or JSONType[]: "+b.join(","))}(c=b||(a.DataType=b={}))[c.Correct=0]="Correct",c[c.Wrong=1]="Wrong",a.getSchemaTypes=function(a){let b=i(a.type);if(b.includes("null")){if(!1===a.nullable)throw Error("type: null contradicts nullable: false")}else{if(!b.length&&void 0!==a.nullable)throw Error('"nullable" cannot be used without "type"');!0===a.nullable&&b.push("null")}return b},a.getJSONTypes=i,a.coerceAndCheckDataType=function(a,c){var d,f;let{gen:h,data:i,opts:k}=a,m=(d=c,(f=k.coerceTypes)?d.filter(a=>j.has(a)||"array"===f&&"array"===a):[]),o=c.length>0&&!(0===m.length&&1===c.length&&(0,e.schemaHasRulesForType)(a,c[0]));if(o){let d=l(c,i,k.strictNumbers,b.Wrong);h.if(d,()=>{m.length?function(a,b,c){let{gen:d,data:e,opts:f}=a,h=d.let("dataType",(0,g._)`typeof ${e}`),i=d.let("coerced",(0,g._)`undefined`);for(let a of("array"===f.coerceTypes&&d.if((0,g._)`${h} == 'object' && Array.isArray(${e}) && ${e}.length == 1`,()=>d.assign(e,(0,g._)`${e}[0]`).assign(h,(0,g._)`typeof ${e}`).if(l(b,e,f.strictNumbers),()=>d.assign(i,e))),d.if((0,g._)`${i} !== undefined`),c))(j.has(a)||"array"===a&&"array"===f.coerceTypes)&&function(a){switch(a){case"string":d.elseIf((0,g._)`${h} == "number" || ${h} == "boolean"`).assign(i,(0,g._)`"" + ${e}`).elseIf((0,g._)`${e} === null`).assign(i,(0,g._)`""`);return;case"number":d.elseIf((0,g._)`${h} == "boolean" || ${e} === null
|
|
1
|
+
"use strict";exports.id=733,exports.ids=[733],exports.modules={7088:(a,b,c)=>{c.d(b,{u:()=>A});var d=c(60339);c(81630),c(73496);var e=c(27910),f=c(55511),g=global.Request,h=class extends g{constructor(a,b){"object"==typeof a&&j in a&&(a=a[j]()),void 0!==b?.body?.getReader&&(b.duplex??="half"),super(a,b)}},i=Symbol("wrapBodyStream"),j=Symbol("getRequestCache"),k=Symbol("requestCache"),l=Symbol("incomingKey"),m=Symbol("urlKey"),n=Symbol("headersKey"),o=Symbol("abortControllerKey"),p=Symbol("getAbortController"),q={get method(){return this[l].method||"GET"},get url(){return this[m]},get headers(){return this[n]||=(a=>{let b=[],c=a.rawHeaders;for(let a=0;a<c.length;a+=2){let{[a]:d,[a+1]:e}=c;58!==d.charCodeAt(0)&&b.push([d,e])}return new Headers(b)})(this[l])},[p](){return this[j](),this[o]},[j](){return this[o]||=new AbortController,this[k]||=((a,b,c,d,f)=>{let g={method:a,headers:c,signal:f.signal};if("TRACE"===a){g.method="GET";let a=new h(b,g);return Object.defineProperty(a,"method",{get:()=>"TRACE"}),a}if("GET"!==a&&"HEAD"!==a)if("rawBody"in d&&d.rawBody instanceof Buffer)g.body=new ReadableStream({start(a){a.enqueue(d.rawBody),a.close()}});else if(d[i]){let a;g.body=new ReadableStream({async pull(b){try{a||=e.Readable.toWeb(d).getReader();let{done:c,value:f}=await a.read();c?b.close():b.enqueue(f)}catch(a){b.error(a)}}})}else g.body=e.Readable.toWeb(d);return new h(b,g)})(this.method,this[m],this.headers,this[l],this[o])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(a=>{Object.defineProperty(q,a,{get(){return this[j]()[a]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(a=>{Object.defineProperty(q,a,{value:function(){return this[j]()[a]()}})}),Object.defineProperty(q,Symbol.for("nodejs.util.inspect.custom"),{value:function(a,b,c){let d={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[k]};return`Request (lightweight) ${c(d,{...b,depth:null==a?null:a-1})}`}}),Object.setPrototypeOf(q,h.prototype);var r=Symbol("responseCache"),s=Symbol("getResponseCache"),t=Symbol("cache"),u=global.Response,v=class a{#a;#b;[s](){return delete this[t],this[r]||=new u(this.#a,this.#b)}constructor(b,c){let d;if(this.#a=b,c instanceof a){const a=c[r];if(a){this.#b=a,this[s]();return}this.#b=c.#b,d=new Headers(c.#b.headers)}else this.#b=c;("string"==typeof b||void 0!==b?.getReader||b instanceof Blob||b instanceof Uint8Array)&&(this[t]=[c?.status||200,b,d||c?.headers])}get headers(){let a=this[t];return a?(a[2]instanceof Headers||(a[2]=new Headers(a[2]||{"content-type":"text/plain; charset=UTF-8"})),a[2]):this[s]().headers}get status(){return this[t]?.[0]??this[s]().status}get ok(){let a=this.status;return a>=200&&a<300}};function w(a){return Array.isArray(a)?a[0]:a}async function x(a,b,c){let d,e=(a.method??"GET").toUpperCase(),f=`http://${w(a.headers.host)??w(a.headers[":authority"])??"localhost"}${a.url??"/"}`,g=new Headers;for(let[b,c]of Object.entries(a.headers))if(!(void 0===c||b.startsWith(":")))if(Array.isArray(c))for(let a of c)g.append(b,a);else g.set(b,c);if("GET"!==e&&"HEAD"!==e)if(void 0===b){let b=new TextDecoder,c="";for await(let d of a)c+="string"==typeof d?d:b.decode(d,{stream:!0});(c+=b.decode()).length>0&&(d=c)}else{let a=JSON.stringify(b);g.delete("content-encoding"),g.delete("transfer-encoding"),void 0===a?g.delete("content-length"):(d=a,g.set("content-length",String(new TextEncoder().encode(a).byteLength)))}return new Request(f,{method:e,headers:g,...c?.signal!==void 0&&{signal:c.signal},...void 0!==d&&{body:d}})}["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(a=>{Object.defineProperty(v.prototype,a,{get(){return this[s]()[a]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(a=>{Object.defineProperty(v.prototype,a,{value:function(){return this[s]()[a]()}})}),Object.defineProperty(v.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(a,b,c){let d={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[r]};return`Response (lightweight) ${c(d,{...b,depth:null==a?null:a-1})}`}}),Object.setPrototypeOf(v,u),Object.setPrototypeOf(v.prototype,u.prototype),void 0===global.crypto&&(global.crypto=f),Symbol("outgoingEnded"),Symbol("incomingDraining");var y=c(52179),z=c(96022);function A(a,b){var c,e;let f;if(!b||"string"!=typeof b.path||!/^\/(?:[^/?#]+(?:\/[^/?#]+)*)?$/.test(b.path))throw TypeError("MCP endpoint path must be an absolute path without query, fragment, or empty segments");let g=b.security,h=a=>Array.isArray(a)&&a.length>0&&a.every(a=>"string"==typeof a&&a.length>0);if(!g||!h(g.allowedHostnames)||!h(g.allowedOriginHostnames))throw TypeError("MCP HTTP allowedHostnames and allowedOriginHostnames must be explicit and non-empty");if(!g.authentication||!["public","required","oauth"].includes(g.authentication.mode)||"required"===g.authentication.mode&&"function"!=typeof g.authentication.authenticate)throw TypeError("MCP HTTP authentication mode must be explicit");if("oauth"===g.authentication.mode){if("function"!=typeof g.authentication.verifier?.verifyAccessToken||!g.authentication.metadata)throw TypeError("MCP OAuth verifier and metadata must be provided");if(g.authentication.metadata.resourceServerUrl.pathname!==b.path)throw TypeError("MCP OAuth resourceServerUrl path must match the endpoint path");if(void 0!==g.authentication.requiredScopes&&(!Array.isArray(g.authentication.requiredScopes)||g.authentication.requiredScopes.some(a=>"string"!=typeof a||!a)))throw TypeError("MCP OAuth requiredScopes must contain non-empty strings")}if(void 0!==b.legacy&&!["stateless","reject"].includes(b.legacy))throw TypeError("Invalid MCP legacy mode");if(void 0!==b.onError&&"function"!=typeof b.onError)throw TypeError("MCP HTTP onError must be a function");if(void 0!==b.keepAliveMs&&(0,z.y)(b.keepAliveMs,"MCP keepAliveMs"),void 0!==b.maxSubscriptions&&(!Number.isSafeInteger(b.maxSubscriptions)||b.maxSubscriptions<=0))throw TypeError("MCP maxSubscriptions must be a positive integer");let i=[...g.allowedHostnames],j=[...g.allowedOriginHostnames],k=g.authentication.mode,l="required"===g.authentication.mode?g.authentication.authenticate:void 0,m="oauth"===g.authentication.mode?g.authentication:void 0,n=m?Object.freeze({...m.metadata,resourceServerUrl:new URL(m.metadata.resourceServerUrl),serviceDocumentationUrl:m.metadata.serviceDocumentationUrl?new URL(m.metadata.serviceDocumentationUrl):void 0,oauthMetadata:structuredClone(m.metadata.oauthMetadata),scopesSupported:m.metadata.scopesSupported?[...m.metadata.scopesSupported]:void 0}):void 0;n&&(0,d.hw)(n);let o=n?new URL((0,d.QK)(n.resourceServerUrl)).pathname:void 0,p=m?(0,d.PA)({verifier:m.verifier,requiredScopes:m.requiredScopes?[...m.requiredScopes]:void 0,resourceMetadataUrl:(0,d.QK)(n.resourceServerUrl)}):void 0,q=(0,d.p0)((0,y.O7)(a),{legacy:b.legacy,responseMode:b.responseMode,keepAliveMs:b.keepAliveMs,maxSubscriptions:b.maxSubscriptions,onerror:b.onError}),r=(0,y.Mi)(a,a=>{for(let b of(a.tools&&q.notify.toolsChanged(),a.resources&&q.notify.resourcesChanged(),a.prompts&&q.notify.promptsChanged(),a.resourceUpdates))q.notify.resourceUpdated(b)}),s=(c={async fetch(a){let b=(0,d.IK)(a,i)??(0,d.ld)(a,j);if(b)return b;let c=n?(0,d.yH)(a,n):void 0;if(c)return c;let e="required"===k?await l(a):"oauth"===k?await p(a):void 0;return e instanceof Response?e:q.fetch(a,{authInfo:e})}},e={onerror:b.onError},async(a,b,d)=>{let f,g;"function"==typeof d&&(d=void 0);let h=!1,i=new AbortController;b.on("close",()=>{h||i.abort()}),!0===b.destroyed&&i.abort();try{let b=await x(a,d,{signal:i.signal});f=await c.fetch(b,{...void 0!==a.auth&&{authInfo:a.auth},...void 0!==d&&{parsedBody:d}})}catch(a){var j;try{e?.onerror?.(a instanceof Error?a:Error(String(a)))}catch{}j=function(a){if(null===a||"object"!=typeof a||Array.isArray(a))return null;let{method:b,id:c}=a;return"string"!=typeof b?null:"string"==typeof c||"number"==typeof c?c:null}(d),f=Response.json({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:j},{status:500})}let k={};for(let[a,b]of f.headers)k[a]=b;if(b.writeHead(f.status,k),null===f.body){h=!0,b.end();return}b.on("drain",()=>{g?.(),g=void 0});let l=new Promise(a=>{i.signal.addEventListener("abort",()=>a(),{once:!0})});try{for await(let a of f.body){if(i.signal.aborted)break;!1===b.write(a)&&await Promise.race([new Promise(a=>{g=a}),l])}}catch{}h=!0,b.end()}),t=!0,u=!0,v=async()=>{let a=[];if(t)try{r(),t=!1}catch(b){a.push(b)}if(u)try{await q.close(),u=!1}catch(b){a.push(b)}if(a.length)throw AggregateError(a,"Failed to close MCP HTTP endpoint")};return{async middleware(a,c){if(a.path!==b.path&&a.path!==o&&!(m&&"/.well-known/oauth-authorization-server"===a.path))return c();a.respond=!1,await s(a.req,a.res)},close:()=>(f||(f=v().finally(()=>{f=void 0})),f)}}},8669:(a,b,c)=>{c.d(b,{N:()=>d});class d extends Error{code;constructor(a,b,c){super(b,c),this.code=a,this.name="HileMcpError"}}},25636:(a,b,c)=>{c.d(b,{B:()=>k});var d=c(93678),e=c(51455),f=c(48161),g=c(76760);async function h(a,b,c){let h=g.resolve(a),i=(await (0,e.lstat)(h)).isDirectory()?h:g.dirname(h),j=await (0,e.mkdtemp)(g.join((0,f.tmpdir)(),"hile-rsc-managed-artifact-"));try{for(let a of(await (0,e.writeFile)(g.join(j,"plugin.json"),`${JSON.stringify(b.manifest,null,2)}
|
|
2
|
+
`),b.files)){let b=g.resolve(i,a),c=g.resolve(j,a),d=g.relative(i,b),f=g.relative(j,c);if(d.startsWith("..")||g.isAbsolute(d)||f.startsWith("..")||g.isAbsolute(f))throw Error(`RSC staged artifact path escapes its root: ${a}`);await (0,e.mkdir)(g.dirname(c),{recursive:!0}),await (0,e.copyFile)(b,c)}let a=await (0,d.verifyRscPluginArtifact)(j,c);return{artifactRoot:j,verification:a,cleanup:()=>(0,e.rm)(j,{recursive:!0,force:!0})}}catch(a){throw await (0,e.rm)(j,{recursive:!0,force:!0}),a}}function i(a){return`${a.pluginId}\0${a.buildId}`}async function j(a){let b=[];for(let c of[()=>a.deactivate(),()=>a.drain(),()=>a.stop()])try{await c()}catch(a){b.push(a)}if(b.length>0)throw AggregateError(b,"RSC managed runtime cleanup failed")}class k{artifacts;deployments;runtimeCompatibility;verify;start;stage;managed=new Map;shutdownPromise;shuttingDown=!1;lifecycle=new Map;pendingInstalls=new Set;constructor(a){this.artifacts=a.artifacts,this.deployments=a.deployments,this.runtimeCompatibility={...a.runtime},this.verify=a.verify??d.verifyRscPluginArtifact,this.stage=a.stage??h,this.start=a.start}async install(a){let b;if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");let c=new Promise(a=>{b=a});this.pendingInstalls.add(c);try{let b=await this.verify(a.artifactRoot,this.runtimeCompatibility),{manifest:c}=b;if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");if(a.expected&&(a.expected.pluginId!==c.pluginId||a.expected.buildId!==c.buildId))throw Error(`RSC deployment identity mismatch: expected=${a.expected.pluginId}@${a.expected.buildId}, artifact=${c.pluginId}@${c.buildId}`);let d={pluginId:c.pluginId,buildId:c.buildId,namespace:a.namespace};return await this.enqueue(d,async()=>{let e,f,g=i(d);if(this.managed.has(g))throw Error(`RSC deployment is already managed: ${c.pluginId}@${c.buildId}`);let h=await this.stage(a.artifactRoot,b,this.runtimeCompatibility),k=h.verification.manifest;if(k.pluginId!==c.pluginId||k.buildId!==c.buildId)throw await h.cleanup(),Error("RSC staged artifact identity changed during installation");let l=!1;try{if(e=this.artifacts.register(h.artifactRoot,k),f=await this.start({artifactRoot:h.artifactRoot,manifest:k,deployment:d}),this.shuttingDown)throw Error("RSC deployment manager is shutting down");return this.deployments.install(d,{activate:a.activate}),l=!0,this.managed.set(g,{deployment:d,runtime:f,unregisterArtifacts:e,cleanupArtifacts:h.cleanup}),{...d}}catch(b){l&&this.deployments.remove(d);let a=[];if(f)try{await j(f)}catch(b){a.push(b)}if(e)try{e()}catch(b){a.push(b)}try{await h.cleanup()}catch(b){a.push(b)}if(a.length>0)throw AggregateError([b,...a],`RSC installation failed and cleanup reported errors: ${b instanceof Error?b.message:String(b)}`);throw b}})}finally{this.pendingInstalls.delete(c),b()}}upgrade(a){return this.install({...a,activate:!0})}activate(a){if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");if(this.lifecycle.has(i(a)))throw Error("RSC deployment is retiring");this.deployments.activate(a)}rebind(a,b){return this.enqueue(a,async()=>{let c=this.managed.get(i(a));if(!c)throw Error(`RSC deployment is not managed: ${a.pluginId}@${a.buildId}`);let d=this.deployments.rebind(a,b);return c.deployment=d,{...d}})}async deactivate(a){if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");if(this.lifecycle.has(i(a)))throw Error("RSC deployment is retiring");this.deployments.deactivate(a)}enqueue(a,b){let c=i(a),d=(this.lifecycle.get(c)??Promise.resolve()).catch(()=>void 0).then(b);return this.lifecycle.set(c,d),d.finally(()=>{this.lifecycle.get(c)===d&&this.lifecycle.delete(c)}).catch(()=>void 0),d}retire(a,b={}){return this.enqueue(a,async()=>{let c=i(a),d=this.managed.get(c);if(!d)return;let e=this.deployments.snapshot().find(b=>b.pluginId===a.pluginId&&b.buildId===a.buildId),f=[];if(e?.state==="active")try{this.deployments.deactivate(a)}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(e)try{await this.deployments.drain(a)}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(d.runtime)try{await j(d.runtime),d.runtime=void 0}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(e)try{this.deployments.remove(a)}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(b.removeArtifacts??!0){if(d.unregisterArtifacts)try{d.unregisterArtifacts(),d.unregisterArtifacts=void 0}catch(a){f.push(a)}if(d.cleanupArtifacts)try{await d.cleanupArtifacts(),d.cleanupArtifacts=void 0}catch(a){f.push(a)}d.unregisterArtifacts||d.cleanupArtifacts||this.managed.delete(c)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed")})}async removeArtifacts(a){let b=i(a),c=this.managed.get(b);return!!c&&!c.runtime&&(c.unregisterArtifacts?.(),await c.cleanupArtifacts?.(),this.managed.delete(b),!0)}shutdown(){if(this.shutdownPromise)return this.shutdownPromise;this.shuttingDown=!0;let a=(async()=>{await Promise.all([...this.pendingInstalls]);let a=[];for(let b of[...this.managed.values()])try{await this.retire(b.deployment,{removeArtifacts:!0})}catch(b){a.push(b)}if(a.length)throw AggregateError(a,"RSC deployment shutdown failed")})();return this.shutdownPromise=a.catch(a=>{throw this.shutdownPromise=void 0,a}),this.shutdownPromise}}},27402:(a,b,c)=>{c.d(b,{nR:()=>z,iw:()=>n}),c(77598);let d="@hile/rsc",e="@hile/rsc/discovery/v1/",f=new TextEncoder;function g(a){return"trusted-internal"===a.scheme&&!("keyId"in a)}function h(a,b){let c=a[b];if("string"!=typeof c||0===c.length||f.encode(c).byteLength>4096)throw TypeError(`RSC discovery ${b} must not be empty or oversized`);return c}function i(a){if(null===a||"object"!=typeof a||Array.isArray(a))throw TypeError("RSC discovery announcement must be an object");if(1!==a.schemaVersion)throw TypeError("RSC discovery schemaVersion is unsupported");if(a.capability!==d)throw TypeError("RSC discovery capability is unsupported");if(1!==a.protocolVersion)throw TypeError("RSC discovery protocolVersion is unsupported");if(!Number.isSafeInteger(a.priority))throw TypeError("RSC discovery priority must be a safe integer");if(void 0!==a.generation&&(!Number.isSafeInteger(a.generation)||a.generation<0))throw TypeError("RSC discovery generation must be a non-negative safe integer");let b=h(a,"artifactOperation");if(!b.startsWith("/")||b.includes(".."))throw TypeError("RSC discovery artifactOperation must be an absolute safe operation");let c=a.runtime;if(null===c||"object"!=typeof c||Array.isArray(c))throw TypeError("RSC discovery runtime must be an object");let e=a.authentication;if(null===e||"object"!=typeof e||Array.isArray(e))throw TypeError("RSC discovery authentication must be an object");let f=h(e,"scheme");if("trusted-internal"===f&&(void 0!==e.keyId||void 0!==e.signature||void 0!==e.generationSignature))throw TypeError("RSC trusted-internal discovery authentication must not carry signing fields");return{schemaVersion:1,capability:d,instanceId:h(a,"instanceId"),pluginId:h(a,"pluginId"),buildId:h(a,"buildId"),namespace:h(a,"namespace"),priority:a.priority,...void 0===a.generation?{}:{generation:a.generation},protocolVersion:1,runtime:{react:h(c,"react"),reactDom:h(c,"reactDom"),rsc:h(c,"rsc")},artifactOperation:b,authentication:"trusted-internal"===f?{scheme:"trusted-internal"}:{scheme:f,keyId:h(e,"keyId"),signature:h(e,"signature"),...void 0===e.generationSignature?{}:{generationSignature:h(e,"generationSignature")}}}}function j(a){if(!a)throw TypeError("RSC discovery instanceId must not be empty");return`${e}${encodeURIComponent(a)}`}function k(a){return[...a].sort((a,b)=>b.priority-a.priority||(b.generation??0)-(a.generation??0)||b.buildId.localeCompare(a.buildId)||a.namespace.localeCompare(b.namespace)||a.instanceId.localeCompare(b.instanceId))[0]}let l=new WeakMap;class m{active=new Map;pendingRetirements=[];deploy;retire;replace;missingReconciliations;select;generationHighWater;generationHistorySize;generationStoreOwner=Symbol("RscDiscoveryManager");queue=Promise.resolve();closed=!1;closePromise;constructor(a){if(this.deploy=a.deploy,this.retire=a.retire,this.replace=a.replace,this.missingReconciliations=a.missingReconciliations??3,!Number.isSafeInteger(this.missingReconciliations)||this.missingReconciliations<1)throw TypeError("missingReconciliations must be a positive safe integer");if(this.select=a.select??k,this.generationHighWater=a.generationHighWater??new Map,this.generationHistorySize=a.generationHistorySize??4096,!Number.isSafeInteger(this.generationHistorySize)||this.generationHistorySize<1)throw TypeError("generationHistorySize must be a positive safe integer");if(this.generationHighWater.size>this.generationHistorySize)throw TypeError("generationHighWater exceeds generationHistorySize");if(l.has(this.generationHighWater))throw Error("generationHighWater is already in use by another discovery manager");l.set(this.generationHighWater,this.generationStoreOwner)}generationKey(a){return JSON.stringify([g(a.authentication)?a.authentication.scheme:a.authentication.keyId,a.pluginId,a.instanceId])}acceptedGeneration(a){return this.generationHighWater.get(this.generationKey(a))}generationFingerprint(a){return JSON.stringify(a)}recordGeneration(a){let b=this.generationKey(a),c=a.generation??0,d=this.generationHighWater.get(b);if(void 0!==d&&(d.generation>c||d.generation===c&&d.announcement===this.generationFingerprint(a))){this.generationHighWater.delete(b),this.generationHighWater.set(b,d);return}if(void 0===d&&this.generationHighWater.size>=this.generationHistorySize)throw Error("RSC discovery generation history capacity exhausted");this.generationHighWater.delete(b),this.generationHighWater.set(b,{generation:c,announcement:this.generationFingerprint(a),active:!0})}tombstoneGeneration(a){let b=this.generationKey(a),c=this.generationHighWater.get(b);c&&c.generation===(a.generation??0)&&c.announcement===this.generationFingerprint(a)&&this.generationHighWater.set(b,{...c,active:!1})}isLegacyPromotion(a,b){let c;if(g(a.authentication)||!b.active||0!==b.generation||0!==a.generation||void 0===a.authentication.generationSignature)return!1;try{c=JSON.parse(b.announcement)}catch{return!1}if(void 0!==c.generation)return!1;let{generation:d,authentication:e,...f}=a,{generationSignature:h,...i}=e;return JSON.stringify({...f,authentication:i})===b.announcement}reconcile(a){if(this.closed)return Promise.reject(Error("RSC discovery manager is closed"));let b=a.map(i),c=async()=>this.apply(b),d=this.queue.then(c,c);return this.queue=d.catch(()=>void 0),d}async apply(a){let b=[];if(this.pendingRetirements.length)for(let a of this.pendingRetirements.splice(0))try{await this.retire(a)}catch(c){this.pendingRetirements.push(a),b.push(c)}let c=new Set,d=new Map;for(let b of a){if(c.has(b.instanceId))throw TypeError(`Duplicate RSC discovery instanceId: ${b.instanceId}`);c.add(b.instanceId);let a=d.get(b.pluginId)??[];a.push(b),d.set(b.pluginId,a)}for(let a of[...new Set([...this.active.keys(),...d.keys()])].sort())try{let c,f=this.active.get(a),g=d.get(a);if(!g?.length){if(!f)continue;f.missing++,f.missing>=this.missingReconciliations&&(await this.retire(f.deployment),this.tombstoneGeneration(f.deployment.announcement),this.active.delete(a));continue}let h=[],j=g.filter(a=>{let b=this.acceptedGeneration(a);if(void 0===b&&this.generationHighWater.size>=this.generationHistorySize)return h.push(Error("RSC discovery generation history capacity exhausted")),!1;let c=a.generation??0;return!!(void 0===b||c>b.generation||this.isLegacyPromotion(a,b))||c===b.generation&&!!b.active&&this.generationFingerprint(a)===b.announcement||(h.push(Error(`RSC discovery generation rollback rejected: ${a.pluginId}/${a.instanceId} ${c} is not newer than accepted generation ${b.generation}`)),!1)});if(!j.length){b.push(...h),f&&(f.missing++,f.missing>=this.missingReconciliations&&(await this.retire(f.deployment),this.tombstoneGeneration(f.deployment.announcement),this.active.delete(a)));continue}let k=[];for(;j.length;){var e;let b=i(this.select(j.map(a=>structuredClone(a)))),d=j.findIndex(a=>a.instanceId===b.instanceId);if(b.pluginId!==a||d<0)throw TypeError("RSC discovery selection policy returned an unknown candidate");if(f&&(e=f.deployment.announcement,e.pluginId===b.pluginId&&e.buildId===b.buildId&&e.namespace===b.namespace)){let a=f.deployment.announcement;f.missing=0,f.deployment.announcement=structuredClone(b),this.recordGeneration(b),g.some(b=>this.generationFingerprint(b)===this.generationFingerprint(a))||this.tombstoneGeneration(a),c=f.deployment;break}if(f&&this.replace&&f.deployment.announcement.pluginId===b.pluginId&&f.deployment.announcement.buildId===b.buildId){c=await this.replace(f.deployment,b),this.recordGeneration(b);break}try{let a=await this.deploy(b);this.recordGeneration(b),c=a;break}catch(a){k.push(a),j.splice(d,1)}}if(!c)throw AggregateError(k,`No deployable RSC discovery candidate: ${a}`);if(f&&c===f.deployment)continue;if(this.active.set(a,{deployment:c,missing:0}),f&&!g.some(a=>this.generationFingerprint(a)===this.generationFingerprint(f.deployment.announcement))&&this.tombstoneGeneration(f.deployment.announcement),f&&f.deployment.announcement.buildId!==c.announcement.buildId)try{await this.retire(f.deployment)}catch(a){throw this.pendingRetirements.push(f.deployment),a}}catch(a){b.push(a)}if(b.length){let a=b.map(a=>a instanceof Error?a.message:String(a)).join("; ");throw AggregateError(b,`RSC discovery reconciliation failed: ${a}`)}}snapshot(){return[...this.active.values()].map(({deployment:a,missing:b})=>({pluginId:a.announcement.pluginId,buildId:a.announcement.buildId,namespace:a.announcement.namespace,instanceId:a.announcement.instanceId,priority:a.announcement.priority,...void 0===a.announcement.generation?{}:{generation:a.announcement.generation},state:b>0?"unavailable":"enabled",missingReconciliations:b})).sort((a,b)=>a.pluginId.localeCompare(b.pluginId))}async close(){if(this.closePromise)return this.closePromise;this.closed=!0;let a=(async()=>{await this.queue;let a=new Set([...this.pendingRetirements,...[...this.active.values()].reverse().map(({deployment:a})=>a)]),b=[];for(let c of a)try{await this.retire(c);let a=this.pendingRetirements.indexOf(c);a>=0&&this.pendingRetirements.splice(a,1);let b=this.active.get(c.announcement.pluginId);b?.deployment===c&&this.active.delete(c.announcement.pluginId)}catch(a){this.pendingRetirements.includes(c)||this.pendingRetirements.push(c),b.push(a)}if(b.length)throw AggregateError(b,"RSC discovery shutdown failed");l.get(this.generationHighWater)===this.generationStoreOwner&&l.delete(this.generationHighWater)})();return this.closePromise=a.catch(a=>{throw this.closePromise=void 0,a}),this.closePromise}}function n(){return a=>g(a.authentication)}var o=c(73024),p=c(51455),q=c(48161),r=c(76760),s=c(46466),t=c(18509),u=c(93678),v=c(81866);async function w(a,b,c){if(!c?.context)throw new t.gV("RSC artifact download");let d=(0,t.xe)(c.context),e=i(b),f=c.maxManifestBytes??1048576;if(!Number.isSafeInteger(f)||f<1)throw TypeError("maxManifestBytes must be positive");let g=c.maxFileBytes??0x4000000,h=c.maxTotalBytes??0x10000000;if(!Number.isSafeInteger(g)||g<1)throw TypeError("maxFileBytes must be positive");if(!Number.isSafeInteger(h)||h<1)throw TypeError("maxTotalBytes must be positive");let j=c.maxArtifactFiles??4096,k=c.maxPathBytes??1024,l=c.maxPathDepth??32;for(let[a,b]of Object.entries({maxArtifactFiles:j,maxPathBytes:k,maxPathDepth:l}))if(!Number.isSafeInteger(b)||b<1)throw TypeError(`${a} must be positive`);let m=await (0,p.mkdtemp)(r.join((0,q.tmpdir)(),"hile-rsc-discovered-"));try{let b,i=await a.stream(e.namespace,e.artifactOperation,{pluginId:e.pluginId,buildId:e.buildId,path:"plugin.json"},{context:d,signal:c.signal}),n=0,q=async function*(){for await(let a of i){if(!(a instanceof Uint8Array))throw TypeError("RSC artifact stream must yield Uint8Array chunks");if((n+=a.byteLength)>f)throw Error("RSC artifact manifest size limit exceeded");yield a}};await (0,s.pipeline)(q(),(0,o.createWriteStream)(r.join(m,"plugin.json"),{flags:"wx"}));try{b=JSON.parse(await (0,p.readFile)(r.join(m,"plugin.json"),"utf8"))}catch{throw TypeError("RSC artifact manifest must be valid JSON")}let t=(0,v.z_)(b,c.runtime);if(t.pluginId!==e.pluginId||t.buildId!==e.buildId)throw Error(`RSC discovery identity mismatch: announcement=${e.pluginId}@${e.buildId}, manifest=${t.pluginId}@${t.buildId}`);let w=[...(0,u.getRscPluginArtifactFiles)(t).keys()].sort();if(w.length>j)throw Error("RSC artifact file count limit exceeded");for(let a of w)if(Buffer.byteLength(a)>k||a.split("/").length>l)throw Error(`RSC artifact path complexity limit exceeded: ${a}`);let x=n;for(let b of w){let f=await a.stream(e.namespace,e.artifactOperation,{pluginId:t.pluginId,buildId:t.buildId,path:b},{context:d,signal:c.signal}),i=0,j=async function*(){for await(let a of f){if(!(a instanceof Uint8Array))throw TypeError("RSC artifact stream must yield Uint8Array chunks");if(i+=a.byteLength,x+=a.byteLength,i>g||x>h)throw Error(`RSC artifact size limit exceeded: ${b}`);yield a}},k=r.join(m,b);await (0,p.mkdir)(r.dirname(k),{recursive:!0}),await (0,s.pipeline)(j(),(0,o.createWriteStream)(k,{flags:"wx"}))}let y=await (0,u.verifyRscPluginArtifact)(m,c.runtime);return{artifactRoot:m,manifest:y.manifest,cleanup:()=>(0,p.rm)(m,{recursive:!0,force:!0})}}catch(a){throw await (0,p.rm)(m,{recursive:!0,force:!0}),a}}var x=c(25636);async function y(a,b={}){let c=b.concurrency??16;if(!Number.isSafeInteger(c)||c<1||c>64)throw TypeError("RSC discovery reader concurrency must be an integer between 1 and 64");b.signal?.throwIfAborted();let d=await a.listRegistryTopics(e,{signal:b.signal}),f=[],g=[],h=[...d].filter(({hasData:a})=>a).sort((a,b)=>a.topic.localeCompare(b.topic)),k=Array(h.length),l=0,m=async()=>{for(;l<h.length;){b.signal?.throwIfAborted();let c=l++,d=h[c];try{let e=await a.getRegistryTopic(d.topic,{signal:b.signal});if(!e?.hasData)continue;let f=i(e.payload);if(j(f.instanceId)!==d.topic)throw TypeError("RSC discovery topic does not match instanceId");k[c]=f}catch(a){k[c]={error:a}}}};for(let[a,d]of(await Promise.all(Array.from({length:Math.min(c,h.length)},()=>m())),b.signal?.throwIfAborted(),k.entries()))d&&("error"in d?g.push({topic:h[a].topic,error:d.error}):f.push(d));return{announcements:f,rejected:g}}class z{options;deployments;discovery;timer;refreshPromise;snapshotPromise;refreshController;startPromise;closePromise;closed=!1;reportError(a){try{this.options.onError?.(a)}catch{}}constructor(a){if(!a?.context)throw new t.gV("RSC discovery host");const b=(0,t.xe)(a.context);this.options={...a,context:b};const c=a.pollIntervalMs??500;if(!Number.isFinite(c)||c<25)throw TypeError("pollIntervalMs must be at least 25");if("function"!=typeof a.authorize)throw TypeError("RSC discovery authorize policy is required");const d=a.operationTimeoutMs??3e4;if(!Number.isFinite(d)||d<100)throw TypeError("operationTimeoutMs must be at least 100");this.deployments=new x.B({artifacts:a.artifacts,deployments:a.deployments,runtime:a.runtime,start:async()=>({deactivate:()=>void 0,drain:async()=>void 0,stop:async()=>void 0})}),this.discovery=new m({missingReconciliations:a.missingReconciliations,generationHighWater:a.generationHighWater,generationHistorySize:a.generationHistorySize,select:a.select,deploy:async c=>{let d=await w(a.application,c,{context:b,runtime:a.runtime,signal:this.refreshController?.signal,maxFileBytes:a.maxFileBytes,maxTotalBytes:a.maxTotalBytes,maxManifestBytes:a.maxManifestBytes,maxArtifactFiles:a.maxArtifactFiles,maxPathBytes:a.maxPathBytes,maxPathDepth:a.maxPathDepth});try{let b=await this.deployments.upgrade({artifactRoot:d.artifactRoot,namespace:c.namespace,expected:{pluginId:c.pluginId,buildId:c.buildId}});try{await a.onEnabled?.(structuredClone(c))}catch(a){this.reportError(a)}return{announcement:structuredClone(c),deployment:b}}finally{await d.cleanup()}},retire:({deployment:a})=>this.deployments.retire(a),replace:async(a,b)=>({announcement:structuredClone(b),deployment:await this.deployments.rebind(b,b.namespace)})})}async refresh(){if(this.closed)throw Error("Hile RSC discovery host is closed");if(this.refreshPromise)return this.refreshPromise;if(this.snapshotPromise)throw Error("Previous RSC discovery snapshot read is still settling");let a=new AbortController;this.refreshController=a;let b=setTimeout(()=>a.abort(Error("RSC discovery refresh timed out")),this.options.operationTimeoutMs??3e4);b.unref?.();let c=(async()=>{let b=y(this.options.application,{concurrency:this.options.snapshotConcurrency,signal:a.signal}).finally(()=>{this.snapshotPromise===b&&(this.snapshotPromise=void 0)});this.snapshotPromise=b;let c=await Promise.race([b,new Promise((b,c)=>a.signal.addEventListener("abort",()=>c(a.signal.reason),{once:!0}))]);for(let a of c.rejected)try{this.options.onRejected?.(a.topic,a.error)}catch(a){this.reportError(a)}let d=[];for(let a of c.announcements)try{if(!await this.options.authorize(structuredClone(a)))throw Error(`Unauthorized RSC discovery announcement: ${a.pluginId}`);if(Object.keys(this.options.runtime).some(b=>a.runtime[b]!==this.options.runtime[b]))throw Error(`Incompatible RSC discovery runtime: ${a.pluginId}@${a.buildId}`);d.push(a)}catch(c){let b=j(a.instanceId);try{this.options.onRejected?.(b,c)}catch(a){this.reportError(a)}}await this.discovery.reconcile(d)})().finally(()=>{clearTimeout(b),this.refreshController===a&&(this.refreshController=void 0),this.refreshPromise===c&&(this.refreshPromise=void 0)});return this.refreshPromise=c,this.refreshPromise}async start(){if(this.closed)throw Error("Hile RSC discovery host is closed");return this.startPromise||(this.startPromise=(async()=>{await this.refresh();let a=()=>{this.closed||(this.timer=setTimeout(async()=>{this.timer=void 0;try{await this.refresh()}catch(a){this.closed||this.reportError(a)}a()},this.options.pollIntervalMs??500),this.timer.unref?.())};a()})()),this.startPromise}snapshot(){return this.discovery.snapshot()}async close(){if(this.closePromise)return this.closePromise;this.closed=!0;let a=(async()=>{this.timer&&clearTimeout(this.timer),this.timer=void 0,this.refreshController?.abort(Error("Hile RSC discovery host is closing"));let a=[];try{await this.refreshPromise}catch{}try{await this.discovery.close()}catch(b){a.push(b)}try{await this.deployments.shutdown()}catch(b){a.push(b)}if(a.length)throw AggregateError(a,"Hile RSC discovery host cleanup failed")})();return this.closePromise=a.catch(a=>{throw this.closePromise=void 0,a}),this.closePromise}}c(93932)},37904:(a,b,c)=>{c.d(b,{ui:()=>i,hv:()=>z,ku:()=>s,d5:()=>A,AG:()=>k,XH:()=>n,V9:()=>h,W4:()=>u,_U:()=>q,Vh:()=>l,Kq:()=>B,$:()=>j});var d=c(73024),e=c(76760),f=c(73136);let g=Symbol.for("@hile/rsc/remote-client-resolvers");function h(a="/_hile/rsc/assets"){let b=function(a){if(!a.startsWith("/"))throw TypeError("RSC asset mount path must be absolute");let b=a.replace(/\/+$/,"");if(!b)throw TypeError("RSC asset mount path must not be the root path");return b}(a),c=(a,c)=>`${b}/${encodeURIComponent(a)}/${encodeURIComponent(c)}`;return{manifest:(a,b)=>`${c(a,b)}/plugin.json`,file:(a,b,d)=>`${c(a,b)}/file/${d.split("/").map(encodeURIComponent).join("/")}`}}class i{artifacts=new Map;nextRegistration=1;register(a,b){var c,d;let f=(c=b.pluginId,d=b.buildId,`${c}\0${d}`);if(this.artifacts.has(f))throw Error(`RSC artifacts already registered: ${b.pluginId}@${b.buildId}`);this.artifacts.set(f,{root:e.resolve(a),manifest:structuredClone(b),registration:this.nextRegistration++});let g=!1;return()=>{g||(g=!0,this.artifacts.delete(f))}}get(a,b){let c=this.artifacts.get(`${a}\0${b}`);if(c)return{root:c.root,manifest:structuredClone(c.manifest),registration:c.registration}}}function j(a,b,c,d=h()){let e=a.get(b,c);if(!e)throw Error(`RSC plugin artifacts are not registered: ${b}@${c}`);return e.manifest.styles.map(a=>({href:d.file(b,c,a.path),integrity:a.integrity}))}function k(a,b=h()){return(c,d)=>{let g=a.get(c.pluginId,c.buildId);if(!g)throw Error(`RSC plugin artifacts are not registered: ${c.pluginId}@${c.buildId}`);let h=g.manifest.clients.find(({id:a})=>a===c.referenceId);if(!h||h.exportName!==c.exportName)throw Error(`RSC client reference is not registered: ${c.referenceId}`);return{moduleUrl:"ssr"===d?(0,f.pathToFileURL)(e.join(g.root,h.ssrModule)).href:b.file(c.pluginId,c.buildId,h.module),styles:g.manifest.styles.map(a=>({href:b.file(c.pluginId,c.buildId,a.path),integrity:a.integrity}))}}}function l(a){let b,c=(b=globalThis,b[g]??={base:globalThis.__HILE_RSC_RESOLVE_CLIENT__,entries:[]});0===c.entries.length&&(c.base=globalThis.__HILE_RSC_RESOLVE_CLIENT__);let d=Symbol("hile-rsc-resolver");c.entries.push({token:d,resolver:a}),globalThis.__HILE_RSC_RESOLVE_CLIENT__=a;let e=!1;return()=>{if(e)return;e=!0;let a=c.entries.findIndex(a=>a.token===d);a>=0&&c.entries.splice(a,1);let b=c.entries.at(-1)?.resolver??c.base;b?globalThis.__HILE_RSC_RESOLVE_CLIENT__=b:delete globalThis.__HILE_RSC_RESOLVE_CLIENT__}}let m=new i;function n(a={}){let b=a.catalog??m,c=`${function(a){if(!a.startsWith("/"))throw TypeError("RSC asset mount path must be absolute");let b=a.replace(/\/+$/,"");if(!b)throw TypeError("RSC asset mount path must not be the root path");return b}(a.mountPath??"/_hile/rsc/assets")}/`,f=a.metadataCacheSize??256;if(!Number.isSafeInteger(f)||f<1)throw TypeError("RSC asset metadata cache size must be a positive safe integer");let g=new Map;return async(a,h)=>{let i,j;if(!a.path.startsWith(c))return h();let k=a.path.slice(c.length).split("/");if(k.length<3){a.status=404;return}try{i=decodeURIComponent(k.shift()),j=decodeURIComponent(k.shift())}catch{a.status=400;return}let l=b.get(i,j);if(!l){g.delete(`${i}\0${j}`),a.status=404;return}let m=`${i}\0${j}`,n=void 0!==l.registration,o=`${l.root}\0${l.registration??""}`,p=n?g.get(m):void 0;if(p?.source!==o&&(g.delete(m),p=void 0),p)g.delete(m),g.set(m,p);else if((p=function(a){let b=new Set,c=a.clients;for(let a of c)for(let c of(b.add(a.module),a.chunks))b.add(c.path);for(let c of a.styles)b.add(c.path);return{source:"",files:b,manifest:function(a,b=a.clients){return{protocolVersion:a.protocolVersion,pluginId:a.pluginId,buildId:a.buildId,clients:b.map(({id:a,module:b,exportName:c,chunks:d,integrity:e})=>({id:a,module:b,exportName:c,chunks:d,integrity:e})),styles:a.styles}}(a,c)}}(l.manifest)).source=o,n)for(g.set(m,p);g.size>f;)g.delete(g.keys().next().value);if(1===k.length&&"plugin.json"===k[0]){a.status=200,a.type="application/json; charset=utf-8",a.set("Cache-Control","public, max-age=31536000, immutable"),a.set("X-Content-Type-Options","nosniff"),a.body=p.manifest;return}if("file"!==k.shift()){a.status=404;return}let q=function(a){try{let b=a.split("/").map(decodeURIComponent);if(b.some(a=>!a||"."===a||".."===a||a.includes("\\")))return;return b.join("/")}catch{return}}(k.join("/"));if(!q||!p.files.has(q)){a.status=404;return}let r=e.resolve(l.root,q);if(!r.startsWith(`${l.root}${e.sep}`)){a.status=404;return}a.status=200,a.type=q.endsWith(".js")?"text/javascript; charset=utf-8":q.endsWith(".css")?"text/css; charset=utf-8":q.endsWith(".json")?"application/json; charset=utf-8":"application/octet-stream",a.set("Cache-Control","public, max-age=31536000, immutable"),a.set("X-Content-Type-Options","nosniff"),a.set("Cross-Origin-Resource-Policy","same-origin"),a.body=(0,d.createReadStream)(r)}}var o=c(18509);function p(a){if(a)try{return new URL(a).origin}catch{return}}function q(a){return async(b,c)=>{let d,e,f=p("function"==typeof a.expectedOrigin?await a.expectedOrigin(c,b):a.expectedOrigin),g=p((d=Object.entries(c.headers??{}).find(([a])=>"origin"===a.toLowerCase()),Array.isArray(e=d?.[1])?e[0]:e));if(!f||!g||f!==g)return!1;let h=await a.readToken(c,b);return!!h&&a.verifyToken(h,b,c)}}class r extends Error{code;constructor(a,b){super(b),this.code=a,this.name="RscServerFunctionGatewayError"}}class s{options;constructor(a){this.options=a}async invoke(a,b){if(!b?.context)throw new o.gV("RSC Server Function gateway");b={...b,context:(0,o.xe)(b.context)};let c=function(a){if(null===a||"object"!=typeof a||Array.isArray(a))throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function request must be an object");let{referenceId:b,args:c}=a;if("string"!=typeof b||!b)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function referenceId must not be empty");let d=/^([^/]+)\/([^/]+)\/(.+)#([^#]+)$/.exec(b);if(!d)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function referenceId is malformed");if(void 0===c)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function args are required");return{pluginId:d[1],buildId:d[2],referenceId:b,args:c}}(a);if(!await this.options.authorize(c,b))throw new r("ERR_RSC_SERVER_FUNCTION_FORBIDDEN","RSC Server Function request was denied");let d=await this.options.locator.resolve({pluginId:c.pluginId,buildId:c.buildId},{context:b.context,signal:b.signal});try{return await d.client.serverFunction({buildId:c.buildId,referenceId:c.referenceId,args:c.args},{context:b.context,signal:b.signal})}finally{await d.release()}}}async function t(a,b){if(!a.req)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","HTTP request body is unavailable");let c=[],d=0;for await(let e of a.req){let a=Buffer.isBuffer(e)?e:Buffer.from(e);if((d+=a.byteLength)>b)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function body is too large");c.push(a)}try{return JSON.parse(Buffer.concat(c).toString("utf8"))}catch{throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function body must be valid JSON")}}function u(a){let b=function(a){if(!a.startsWith("/"))throw TypeError("RSC Server Function mount path must be absolute");let b=a.replace(/\/+$/,"");if(!b)throw TypeError("RSC Server Function mount path must not be root");return b}(a.mountPath??"/_hile/rsc/server-functions"),c=a.bodyLimit??1048576;if(!Number.isSafeInteger(c)||c<1)throw TypeError("RSC Server Function body limit must be positive");let d=a.readJson??t;return async(e,f)=>{if(e.path!==b)return f();if("POST"!==e.method.toUpperCase()){e.status=405,e.set("Allow","POST");return}try{if(!e.requestContext?.context)throw new o.gV("RSC Server Function HTTP ingress");let b=await a.gateway.invoke(await d(e,c),{...e.requestContext,signal:e.signal??e.requestContext.signal});e.status=200,e.type="application/json; charset=utf-8",e.body={value:b}}catch(a){if(a instanceof r){e.status="ERR_RSC_SERVER_FUNCTION_FORBIDDEN"===a.code?403:400,e.type="application/json; charset=utf-8",e.body={code:a.code,message:a.message};return}e.status=500,e.type="application/json; charset=utf-8",e.body={code:"ERR_RSC_SERVER_FUNCTION_FAILED",message:"RSC Server Function execution failed"}}}}var v=c(93932);class w extends Error{code;constructor(a,b){super(b),this.code=a,this.name="RscDeploymentCatalogError"}}function x(a){return`${a.pluginId}\0${a.buildId}`}function y(a){return{pluginId:a.pluginId,buildId:a.buildId,namespace:a.namespace}}class z{records=new Map;activeBuilds=new Map;install(a,b={}){for(let[b,c]of Object.entries(a))if("string"!=typeof c||0===c.length)throw TypeError(`RSC deployment ${b} must not be empty`);let c=x(a);if(this.records.has(c))throw new w("ERR_RSC_DEPLOYMENT_ALREADY_INSTALLED",`RSC deployment is already installed: ${a.pluginId}@${a.buildId}`);return this.records.set(c,{deployment:y(a),state:"inactive",references:0,drainWaiters:new Set}),b.activate&&this.activate(a),()=>this.remove(a)}required(a){let b=this.records.get(x(a));if(!b)throw new w("ERR_RSC_DEPLOYMENT_NOT_INSTALLED",`RSC deployment is not installed: ${a.pluginId}@${a.buildId}`);return b}activate(a){let b=this.required(a),c=this.activeBuilds.get(a.pluginId);c&&c!==a.buildId&&(this.required({pluginId:a.pluginId,buildId:c}).state="draining"),b.state="active",this.activeBuilds.set(a.pluginId,a.buildId)}rebind(a,b){if("string"!=typeof b||0===b.length)throw TypeError("RSC deployment namespace must not be empty");let c=this.required(a);return c.deployment={...c.deployment,namespace:b},y(c.deployment)}deactivate(a){this.required(a).state="inactive",this.activeBuilds.get(a.pluginId)===a.buildId&&this.activeBuilds.delete(a.pluginId)}getActive(a){let b=this.activeBuilds.get(a);if(b)return y(this.required({pluginId:a,buildId:b}).deployment)}acquire(a){let b=this.required(a);if("active"!==b.state)throw new w("ERR_RSC_DEPLOYMENT_INACTIVE",`RSC deployment is not active: ${a.pluginId}@${a.buildId}`);b.references++;let c=!1;return{deployment:y(b.deployment),release:()=>{if(!c&&(c=!0,b.references--,0===b.references)){for(let a of b.drainWaiters)a();b.drainWaiters.clear()}}}}async drain(a){let b=this.required(a);0!==b.references&&await new Promise(a=>b.drainWaiters.add(a))}remove(a){let b=x(a),c=this.records.get(b);if(!c)return!1;if(c.references>0)throw new w("ERR_RSC_DEPLOYMENT_REFERENCED",`RSC deployment is still referenced: ${a.pluginId}@${a.buildId}`);return this.activeBuilds.get(a.pluginId)===a.buildId&&this.activeBuilds.delete(a.pluginId),this.records.delete(b),!0}snapshot(){return[...this.records.values()].map(({deployment:a,state:b,references:c})=>({...y(a),state:b,references:c}))}}function A(a,b){return{async resolve(c,d){d=(0,v.ur)(d,"RSC catalog plugin resolution");let e=a.acquire(c);try{return{client:await b(e.deployment,d),release:e.release}}catch(a){throw e.release(),a}}}}function B(a,b){for(let c of(b.asset&&a.use(b.asset),b.action&&a.use(b.action),b.serverFunction&&a.use(b.serverFunction),b.middleware??[]))a.use(c);return a}c(25636),c(43561)},39226:(a,b,c)=>{c.d(b,{cb:()=>g,vs:()=>i});var d=c(8669);c(60339);let e=/^[A-Za-z0-9._-]{1,128}$/,f=new WeakSet;function g(a){return!!a&&"object"==typeof a&&f.has(a)}function h(a,b,c){let e={...c};for(let[c,f]of Object.entries(e)){if(!g(f)||f.kind!==b)throw new d.N("INVALID_DEFINITION",`${a} ${b} "${c}" must be created with defineMcp*`);if(c!==f.config.name)throw new d.N("INVALID_DEFINITION",`${a} ${b} record key "${c}" must equal capability name "${f.config.name}"`)}return Object.freeze(e)}function i(a){var b=a.id;if("string"!=typeof b||!e.test(b))throw new d.N("INVALID_DEFINITION",`Provider name must match ${e}`);if(void 0!==a.displayName&&"string"!=typeof a.displayName)throw new d.N("INVALID_DEFINITION","Provider displayName must be a string");return Object.freeze({id:a.id,displayName:a.displayName,tools:h(a.id,"tool",a.tools),resources:h(a.id,"resource",a.resources),prompts:h(a.id,"prompt",a.prompts)})}},43561:(a,b,c)=>{c.d(b,{T:()=>g});var d=c(18509);function e(a,b,c){for(let[c,d]of[["timeout",a],["idleTimeout",b]])if(void 0!==d&&(!Number.isSafeInteger(d)||d<1||d>0x7fffffff))throw TypeError(`RSC ${c} must be an integer between 1 and 2147483647`);if(void 0!==c&&(!Number.isSafeInteger(c)||c<1||c>64))throw TypeError("RSC stream window must be an integer between 1 and 64")}function f(a,b){return b?.aborted===!0||a instanceof Error&&"AbortError"===a.name}class g{locator;decoder;verifyManifest;verificationCache;verificationCacheSize;verificationTimeout;observe;constructor(a){if(this.locator=a.locator,this.decoder=a.decoder,this.verifyManifest=a.verifyManifest??!0,this.verificationCache=a.verificationCache??new Map,this.verificationCacheSize=a.verificationCacheSize??256,!Number.isSafeInteger(this.verificationCacheSize)||this.verificationCacheSize<1)throw TypeError("RSC verification cache size must be a positive safe integer");this.verificationTimeout=a.verificationTimeout??3e4,e(this.verificationTimeout),this.observe=a.observe}async verify(a,b,c,d){let e=async()=>{let e,f,g,h=await this.locator.resolve({pluginId:a,buildId:b},{context:d,timeout:this.verificationTimeout});try{if(h.verificationKey!==c)throw Error("RSC plugin endpoint changed during manifest verification");if((e=await h.client.describe({context:d,timeout:this.verificationTimeout})).pluginId!==a)throw Error(`RSC plugin identity mismatch: requested=${a}, resolved=${e.pluginId}`);if(e.buildId!==b)throw Error(`RSC plugin build mismatch: requested=${b}, resolved=${e.buildId}`)}catch(a){f=a}try{await h.release()}catch(a){g=a}if(void 0!==f&&void 0!==g)throw AggregateError([f,g],"RSC manifest verification and lease cleanup failed");if(void 0!==f)throw f;if(void 0!==g)throw g};if(void 0===c)return void await e();let f=JSON.stringify([a,b,c,d]),g=this.verificationCache.get(f);if(g&&(this.verificationCache.delete(f),this.verificationCache.set(f,g)),!g)for(g=e().catch(a=>{throw this.verificationCache.get(f)===g&&this.verificationCache.delete(f),a}),this.verificationCache.set(f,g);this.verificationCache.size>this.verificationCacheSize;)this.verificationCache.delete(this.verificationCache.keys().next().value);await g}async waitForVerification(a,b,c){let d,e;if(!b&&void 0===c)return a;b?.throwIfAborted();let f=new Promise((a,f)=>{b&&(e=()=>f(b.reason??new DOMException("Aborted","AbortError")),b.addEventListener("abort",e,{once:!0})),void 0!==c&&(d=setTimeout(()=>f(Error("RSC manifest verification timed out")),c),d.unref?.())});try{await Promise.race([a,f])}finally{d&&clearTimeout(d),e&&b?.removeEventListener("abort",e)}}async render({pluginId:a,request:b,context:c,signal:g,timeout:h,idleTimeout:i,window:j}){let k,l,m=performance.now(),n=0,o=!1,p=(c,d)=>{if(!o){o=!0;try{this.observe?.({operation:"render",pluginId:a,buildId:b.buildId,outcome:c,durationMs:performance.now()-m,bytes:n,...void 0===d?{}:{error:d}})}catch{}}};try{if(!c)throw new d.gV("RSC host render");c=(0,d.xe)(c),e(h,i,j),g?.throwIfAborted()}catch(a){throw p(f(a,g)?"cancelled":"error",a),a}try{k=await this.locator.resolve({pluginId:a,buildId:b.buildId},{context:c,signal:g})}catch(a){throw p(f(a,g)?"cancelled":"error",a),a}let q=()=>l??=Promise.resolve().then(()=>k.release());try{let d;if(this.verifyManifest){let d=this.verify(a,b.buildId,k.verificationKey,c);await this.waitForVerification(d,g,h)}let e=await k.client.render(b,{context:c,signal:g,timeout:h,idleTimeout:i,window:j}),l=!1,m=!1,o=!1,r=()=>{o&&m&&(void 0!==d?p(f(d,g)?"cancelled":"error",d):p(l?"cancelled":"success"))},s=async a=>{void 0!==a&&(d=a);try{await q()}catch(a){throw d=void 0===d||d===a?a:AggregateError([d,a],"RSC Flight stream and lease cleanup failed"),m=!0,r(),d}m=!0,r()},t={[Symbol.asyncIterator](){let a=e[Symbol.asyncIterator]();return{async next(){try{let b=await a.next();return b.done?await s():n+=b.value.byteLength,b}catch(a){throw m||await s(a),a}},async return(b){let c;try{c=a.return?await a.return(b):{done:!0,value:b}}catch(a){throw await s(a),a}return c.done?(l=!0,await s()):n+=c.value.byteLength,c},async throw(b){let c;if(!a.throw)throw await s(b),b;try{c=await a.throw(b)}catch(a){throw await s(a),a}return c.done?await s():n+=c.value.byteLength,c}}}},u=await this.decoder.decode(t,{pluginId:a,buildId:b.buildId,signal:g});if(o=!0,r(),void 0!==d)throw d;return u}catch(b){let a=b;try{await q()}catch(c){c===b||b instanceof AggregateError&&b.errors.includes(c)||(a=AggregateError([b,c],"RSC render and lease cleanup failed"))}throw p(f(b,g)?"cancelled":"error",a),a}}}},51842:(a,b,c)=>{c.d(b,{n:()=>d});function d(a,b){return a<b?-1:+(a>b)}},52179:(a,b,c)=>{c.d(b,{Mi:()=>t,O7:()=>s,rW:()=>r});var d=c(18509),e=c(60339),f=c(8669),g=c(51842),h=c(93279),i=c(62202),j=c(57782);let k=Symbol("hile.mcp.gateway.runtime"),l=new WeakMap,m=new WeakMap;function n(a){if(a)return{subject:a.clientId,clientId:a.clientId,scopes:Object.freeze([...a.scopes??[]]),claims:a.extra?Object.freeze({...a.extra}):void 0}}function o(a){return a?.map(a=>({...a,sizes:a.sizes?[...a.sizes]:void 0}))}function p(a){return a?structuredClone(a):void 0}class q{options;instances=[];unsubscribe=()=>void 0;unsubscribeResourceUpdates=()=>void 0;closed=!1;closing;unsubscribePending=!0;unsubscribeResourceUpdatesPending=!0;sourceClosePending=!0;lifecycle=new AbortController;activeInvocations=new Set;liveProjections=new Set;catalogListeners=new Set;cursor=new Map;catalogState={groups:new Map,conflicts:new Map,tools:[],resources:[],prompts:[]};constructor(a){this.options=a}async start(){if(await this.options.source.start(),this.replaceInstances(this.options.source.snapshot()),"require-provider"===this.options.startup&&0===this.instances.length)throw new f.N("PROVIDER_UNAVAILABLE","MCP gateway requires at least one provider");this.unsubscribe=this.options.source.subscribe(a=>{this.replaceInstances(a)}),this.unsubscribeResourceUpdates=this.options.source.subscribeResourceUpdates(a=>{this.handleResourceUpdate(a)})}replaceInstances(a){let b=this.catalogState;for(let b of(this.instances=this.validInstances(a),this.catalogState=this.buildCatalog(),this.liveProjections))this.project(b,!0);let c=a=>a.map(a=>`${a.publicName}:${a.manifest.fingerprint}:${a.capability.name}`).join("\0"),d={tools:c(b.tools)!==c(this.catalogState.tools),resources:c(b.resources)!==c(this.catalogState.resources),prompts:c(b.prompts)!==c(this.catalogState.prompts),resourceUpdates:[]};if(d.tools||d.resources||d.prompts)for(let a of this.catalogListeners)try{a(d)}catch(a){this.report(a)}}handleResourceUpdate(a){let b=this.catalogState.resources.find(b=>b.providerId===a.providerId&&b.manifest.fingerprint===a.fingerprint&&(b.capability.uri===a.uri||!!b.resourceTemplate?.uriTemplate.match(a.uri)));if(!b||!this.catalogState.groups.get(a.providerId)?.some(b=>b.instanceId===a.instanceId&&b.fingerprint===a.fingerprint))return;for(let c of this.liveProjections)!c.http&&this.visible(b,c.principal)&&("modern"===c.era||c.resourceSubscriptions.has(a.uri))&&c.server.server.sendResourceUpdated({uri:a.uri}).catch(a=>this.report(a));let c={tools:!1,resources:!1,prompts:!1,resourceUpdates:[a.uri]};for(let a of this.catalogListeners)try{a(c)}catch(a){this.report(a)}}subscribeCatalogChanges(a){if(this.closed)throw new f.N("GATEWAY_CLOSED","MCP gateway is closed");return this.catalogListeners.add(a),()=>{this.catalogListeners.delete(a)}}report(a){try{this.options.onError?.(a)}catch{}}validInstances(a){return a.flatMap(a=>{let b=(0,i.Ky)(a);return b?[b]:[]})}groups(){let a=new Map;for(let b of this.instances){let c=a.get(b.providerId)??[];c.push(b),a.set(b.providerId,c)}for(let b of a.values())b.sort((a,b)=>(0,g.n)(a.instanceId,b.instanceId));return a}name(a,b){let c=this.options.naming?.aliases?.[a]??a,d=`${c}${this.options.naming?.separator??"."}${b}`;if(!/^[A-Za-z0-9._-]{1,128}$/.test(d))throw new f.N("CATALOG_CONFLICT",`Invalid public MCP name "${d}"`);return d}buildCatalog(){let a=this.groups(),b=new Map,c=(a,c)=>{let d=b.get(a)??new Set;d.add(c),b.set(a,d)},d=[],f=[],h=[];for(let[b,g]of a){if(1!==new Set(g.map(a=>a.fingerprint)).size){c(b,"instances publish different capability fingerprints");continue}let a=g[0],i=(d,f,g)=>{try{let c=this.name(b,f.name),h=f.scopes??[],i=Object.freeze({providerId:b,kind:d,localName:f.name,publicName:c,scopes:h});g.push({manifest:a,capability:f,providerId:b,kind:d,localName:f.name,publicName:c,scopes:h,view:i,inputSchema:"tool"===d||"prompt"===d?(0,e.e0)(f.inputSchema??{type:"object"}):void 0,outputSchema:"tool"===d&&f.outputSchema?(0,e.e0)(f.outputSchema):void 0,resourceTemplate:"resource"===d&&f.uriTemplate?new e.Zn(f.uriTemplate,{list:void 0}):void 0})}catch(a){c(b,a instanceof Error?a.message:"invalid public capability name")}};for(let b of a.capabilities.tools)i("tool",b,d);for(let b of a.capabilities.resources)i("resource",b,f);for(let b of a.capabilities.prompts)i("prompt",b,h)}let i=(a,b,d)=>{let e=new Map;for(let c of a){let a=e.get(b(c))??[];a.push(c.providerId),e.set(b(c),a)}for(let[a,b]of e)if(!(b.length<2))for(let e of new Set(b))c(e,`${d} conflict: ${a}`)};i(d,a=>a.publicName,"tool name"),i(f,a=>a.publicName,"resource name"),i(h,a=>a.publicName,"prompt name"),i(f,a=>a.capability.uri??a.capability.uriTemplate??"","resource URI");let j=(a,b)=>(0,g.n)(a.publicName,b.publicName),k=a=>!b.has(a.providerId);return{groups:a,conflicts:b,tools:d.filter(k).sort(j),resources:f.filter(k).sort(j),prompts:h.filter(k).sort(j)}}catalog(){return this.catalogState}inspect(){let a=this.catalog();return{providers:[...a.groups].sort(([a],[b])=>(0,g.n)(a,b)).map(([b,c])=>{let d=[...new Set(c.map(a=>a.fingerprint))].sort(),e=[...a.conflicts.get(b)??[]].sort();return{providerId:b,status:0===e.length?"ready":"conflict",instanceCount:c.length,fingerprints:d,conflicts:e}}),tools:a.tools.map(a=>a.publicName),resources:a.resources.map(a=>a.publicName),prompts:a.prompts.map(a=>a.publicName)}}select(a){let b=a.providerId,c=this.catalogState.groups.get(b)??[];if(!c.length)throw new f.N("PROVIDER_UNAVAILABLE",`MCP provider "${b}" is unavailable`);let d=new Set(c.map(a=>a.fingerprint));if(1!==d.size||!d.has(a.manifest.fingerprint))throw new f.N("CATALOG_CONFLICT",`MCP provider "${b}" changed during invocation`);let e=`${b}/${a.manifest.fingerprint}`,g=this.cursor.get(e)??0;return this.cursor.set(e,g+1),c[g%c.length]}visible(a,b){return!!(0,h.c)(b?.scopes,a.scopes)&&(this.options.isCapabilityExposed?.(a.view,b)??!0)}invoke(a,b,c,d,e){if(this.closed)return Promise.reject(new f.N("GATEWAY_CLOSED","MCP gateway is closed"));let g=this.invokeActive(a,b,c,d,e);return this.activeInvocations.add(g),g.finally(()=>{this.activeInvocations.delete(g)}).catch(()=>void 0),g}complete(a,b,c,d,e,g){if(this.closed)return Promise.reject(new f.N("GATEWAY_CLOSED","MCP gateway is closed"));let h=this.completeActive(a,b,c,d,e,g);return this.activeInvocations.add(h),h.finally(()=>{this.activeInvocations.delete(h)}).catch(()=>void 0),h}async completeActive(a,b,c,d,e,g){let h,i=this.lifecycle.signal;i.throwIfAborted();let k=this.select(a),l={argument:b,value:c,context:d},m={executionContext:g,providerId:a.providerId,instanceId:k.instanceId,fingerprint:a.manifest.fingerprint,kind:a.kind,name:a.capability.name,input:l},o={...m,input:l,principal:"trusted-internal"===this.options.invocationSecurity.mode?n(e):void 0,credential:"credential"===this.options.invocationSecurity.mode?await this.options.invocationSecurity.credentials.create(m,n(e),i):void 0},p=await this.options.source.stream(k,j.Aw.complete,o,{context:g,signal:i}),q=!1;for await(let b of p){if(b?.type!=="result"||q)throw new f.N("PROVIDER_UNAVAILABLE",`MCP completion for "${a.publicName}" emitted an invalid frame`);h=b.result,q=!0}if(!q||!Array.isArray(h)||h.some(a=>"string"!=typeof a))throw new f.N("PROVIDER_UNAVAILABLE",`MCP completion for "${a.publicName}" returned invalid suggestions`);return h}async invokeActive(a,b,c,d,e){let g=+(a.capability.execution?.retry==="idempotent-failover"),h=AbortSignal.any([d.mcpReq.signal,this.lifecycle.signal]),i={providerId:a.providerId,instanceId:void 0,fingerprint:a.manifest.fingerprint,credential:void 0,principal:"trusted-internal"===this.options.invocationSecurity.mode?n(c):void 0,kind:a.kind,name:a.capability.name,input:b,inputResponses:d.mcpReq.inputResponses,requestState:d.mcpReq.requestState()};for(let k=0;k<=g;k++){let l=!1;try{let g,k=this.select(a);for await(let m of(i.instanceId=k.instanceId,i.credential="credential"===this.options.invocationSecurity.mode?await this.options.invocationSecurity.credentials.create({executionContext:e,providerId:a.providerId,instanceId:k.instanceId,fingerprint:a.manifest.fingerprint,kind:a.kind,name:a.capability.name,input:b},n(c),h):void 0,await this.options.source.stream(k,j.Aw.invoke,i,{context:e,timeout:a.capability.execution?.timeoutMs,signal:h}))){if(l)throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted frames after its result`);if(m?.type==="progress"){if(!Number.isFinite(m.progress)||void 0!==m.total&&!Number.isFinite(m.total))throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted an invalid progress frame`);let b=d.mcpReq._meta?.progressToken;if(void 0!==b)try{await d.mcpReq.notify({method:"notifications/progress",params:{progressToken:b,progress:m.progress,total:m.total,message:m.message}})}catch(a){throw new f.N("PROVIDER_UNAVAILABLE","Failed to deliver MCP progress notification",{cause:a})}}else if(m?.type==="log"){if(!["debug","info","notice","warning","error"].includes(m.level))throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted an invalid log frame`);try{await d.mcpReq.log(m.level,m.data)}catch(a){throw new f.N("PROVIDER_UNAVAILABLE","Failed to deliver MCP log notification",{cause:a})}}else if(m?.type==="result")g=m.result,l=!0;else throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" emitted an unknown frame`)}if(!l)throw Error(`MCP ${a.kind} "${a.publicName}" stream ended without a result`);return g}catch(a){if(h.aborted)throw h.reason??a;if(l||k===g||a instanceof f.N)throw a}}throw new f.N("PROVIDER_UNAVAILABLE",`MCP ${a.kind} "${a.publicName}" failed without an error`)}[k](a){if(this.closed)throw new f.N("GATEWAY_CLOSED","MCP gateway is closed");let b=new e._k(this.options.info,{instructions:this.options.instructions,requestState:this.options.requestState,cacheHints:this.options.cacheHints,capabilities:{tools:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},prompts:{listChanged:!0}}}),c={server:b,executionContext:(0,d.xe)(this.options.executionContext(a)),authInfo:a.authInfo,principal:n(a.authInfo),era:a.era??"legacy",http:void 0!==a.requestInfo,resourceSubscriptions:new Set,handles:[],names:{tools:"",resources:"",prompts:""}};"legacy"===c.era&&(b.server.setRequestHandler("resources/subscribe",a=>(c.resourceSubscriptions.add(a.params.uri),{})),b.server.setRequestHandler("resources/unsubscribe",a=>(c.resourceSubscriptions.delete(a.params.uri),{}))),this.project(c,!1),this.liveProjections.add(c);let g=()=>{this.liveProjections.delete(c),c.resourceSubscriptions.clear()},h=b.server.onclose;b.server.onclose=()=>{g(),h?.()};let i=b.close.bind(b);return b.close=async()=>{g(),c.handles.length=0,await i()},b}project(a,b){let c,d,f,g,h=a.names;try{let b=this.catalog();c=b.tools.filter(b=>this.visible(b,a.principal)),d=b.resources.filter(b=>this.visible(b,a.principal)),f=b.prompts.filter(b=>this.visible(b,a.principal));let e=a=>a.map(a=>`${a.publicName}:${a.manifest.fingerprint}:${a.capability.name}`).join("\0");g={tools:e(c),resources:e(d),prompts:e(f)}}catch(a){this.report(a);return}if(h.tools===g.tools&&h.resources===g.resources&&h.prompts===g.prompts)return;let i={tools:a.server.sendToolListChanged,resources:a.server.sendResourceListChanged,prompts:a.server.sendPromptListChanged};for(let b of(a.server.sendToolListChanged=()=>void 0,a.server.sendResourceListChanged=()=>void 0,a.server.sendPromptListChanged=()=>void 0,a.handles.splice(0)))try{b.remove()}catch(a){this.report(a)}try{for(let b of c)a.handles.push(a.server.registerTool(b.publicName,{title:b.capability.title,description:b.capability.description,inputSchema:b.inputSchema,outputSchema:b.outputSchema,annotations:b.capability.annotations,icons:o(b.capability.icons),_meta:p(b.capability._meta)},(c,d)=>this.invoke(b,c,a.authInfo,d,a.executionContext)));for(let b of d){let c={title:b.capability.title,description:b.capability.description,mimeType:b.capability.mimeType,icons:o(b.capability.icons),size:b.capability.size,annotations:b.capability.annotations?structuredClone(b.capability.annotations):void 0,_meta:p(b.capability._meta),cacheHint:b.capability.cacheHint?{...b.capability.cacheHint}:void 0};if(b.capability.uri)a.handles.push(a.server.registerResource(b.publicName,b.capability.uri,c,(c,d)=>this.invoke(b,c.toString(),a.authInfo,d,a.executionContext)));else if(b.capability.uriTemplate){let d=b.capability.completionArguments??[],f=d.length?new e.Zn(b.capability.uriTemplate,{list:void 0,complete:Object.fromEntries(d.map(c=>[c,(d,e)=>this.complete(b,c,d,e,a.authInfo,a.executionContext)]))}):b.resourceTemplate;a.handles.push(a.server.registerResource(b.publicName,f,c,(c,d,e)=>this.invoke(b,d,a.authInfo,e,a.executionContext)))}}for(let b of f){let c=function(a,b,c){let d=(0,e.e0)(a);if(!b?.length)return d;let f=a.properties&&"object"==typeof a.properties&&!Array.isArray(a.properties)?a.properties:{},g=new Set(b),h=Object.fromEntries(Object.entries(f).map(([a,b])=>{let d=(0,e.e0)(b);return[a,g.has(a)?(0,e.JF)(d,(b,d)=>c(a,String(b),d)):d]}));return Object.assign(Object.create(d),{shape:h})}(b.capability.inputSchema??{type:"object"},b.capability.completionArguments,(c,d,e)=>this.complete(b,c,d,e,a.authInfo,a.executionContext));a.handles.push(a.server.registerPrompt(b.publicName,{title:b.capability.title,description:b.capability.description,argsSchema:c,icons:o(b.capability.icons),_meta:p(b.capability._meta)},(c,d)=>this.invoke(b,c,a.authInfo,d,a.executionContext)))}a.names=g}catch(b){for(let b of a.handles.splice(0))try{b.remove()}catch(a){this.report(a)}a.names={tools:"",resources:"",prompts:""},this.report(b)}finally{a.server.sendToolListChanged=i.tools,a.server.sendResourceListChanged=i.resources,a.server.sendPromptListChanged=i.prompts}if(b&&!a.http){let b=(a,b)=>{a&&b().catch(a=>this.report(a))};b(h.tools!==a.names.tools,()=>a.server.server.sendToolListChanged()),b(h.resources!==a.names.resources,()=>a.server.server.sendResourceListChanged()),b(h.prompts!==a.names.prompts,()=>a.server.server.sendPromptListChanged())}}close(){return this.closing||(this.closing=this.performClose().finally(()=>{this.closing=void 0})),this.closing}async performClose(){this.closed=!0,this.lifecycle.signal.aborted||this.lifecycle.abort(new f.N("GATEWAY_CLOSED","MCP gateway is closed"));let a=[];if(this.unsubscribePending)try{this.unsubscribe(),this.catalogListeners.clear(),this.unsubscribePending=!1}catch(b){a.push(b)}if(this.unsubscribeResourceUpdatesPending)try{this.unsubscribeResourceUpdates(),this.unsubscribeResourceUpdatesPending=!1}catch(b){a.push(b)}if(this.sourceClosePending){await Promise.allSettled([...this.activeInvocations]);try{await this.options.source.close(),this.sourceClosePending=!1}catch(b){a.push(b)}}if(a.length)throw AggregateError(a,"Failed to close MCP gateway")}}async function r(a){if(!a.info||e.aV.Implementation["~standard"].validate(a.info).issues||!a.info.name||!a.info.version)throw TypeError("MCP gateway info must follow the MCP Implementation schema with non-empty name and version");if(void 0!==a.instructions&&"string"!=typeof a.instructions)throw TypeError("MCP gateway instructions must be a string");if(void 0!==a.startup&&!["allow-empty","require-provider"].includes(a.startup))throw TypeError("Invalid MCP gateway startup mode");if(a.naming?.separator!==void 0&&![".","-","_"].includes(a.naming.separator))throw TypeError("Invalid MCP gateway name separator");if(a.naming?.aliases!==void 0&&(!a.naming.aliases||"object"!=typeof a.naming.aliases||Array.isArray(a.naming.aliases)))throw TypeError("MCP gateway aliases must be a record");if(void 0!==a.isCapabilityExposed&&"function"!=typeof a.isCapabilityExposed)throw TypeError("MCP isCapabilityExposed must be a function");if(void 0!==a.onError&&"function"!=typeof a.onError)throw TypeError("MCP gateway onError must be a function");if("function"!=typeof a.executionContext)throw TypeError("MCP gateway executionContext must be a function");let b=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"]);if(void 0!==a.cacheHints&&(!a.cacheHints||"object"!=typeof a.cacheHints||Object.entries(a.cacheHints).some(([a,c])=>!b.has(a)||!c||"object"!=typeof c||void 0!==c.ttlMs&&(!Number.isSafeInteger(c.ttlMs)||c.ttlMs<0)||void 0!==c.cacheScope&&!["public","private"].includes(c.cacheScope))))throw TypeError("MCP gateway cacheHints contain an invalid method or cache hint");if(!a.invocationSecurity||!["trusted-internal","credential"].includes(a.invocationSecurity.mode)||"credential"===a.invocationSecurity.mode&&"function"!=typeof a.invocationSecurity.credentials?.create)throw TypeError("MCP gateway invocationSecurity must be explicit");let c=Object.assign(Object.create(null),a.naming?.aliases??{});for(let[a,b]of Object.entries(c))if(!/^[A-Za-z0-9._-]{1,128}$/.test(a)||!/^[A-Za-z0-9._-]{1,128}$/.test(b))throw TypeError("MCP gateway aliases must contain legal provider and alias names");let d="credential"===a.invocationSecurity.mode?Object.freeze({mode:"credential",credentials:Object.freeze({create:a.invocationSecurity.credentials.create.bind(a.invocationSecurity.credentials)})}):Object.freeze({mode:"trusted-internal"}),f=new q({...a,info:Object.freeze({...a.info,icons:o(a.info.icons)}),cacheHints:a.cacheHints?Object.freeze(Object.fromEntries(Object.entries(a.cacheHints).map(([a,b])=>[a,Object.freeze({...b})]))):void 0,naming:a.naming?Object.freeze({separator:a.naming.separator,aliases:Object.freeze(c)}):void 0,requestState:a.requestState?Object.freeze({...a.requestState}):void 0,invocationSecurity:d});try{return await f.start(),l.set(f,a=>f[k](a)),m.set(f,a=>f.subscribeCatalogChanges(a)),f}catch(a){throw await f.close().catch(()=>void 0),a}}function s(a){let b=l.get(a);if(!b)throw TypeError("MCP gateway must be created by createMcpGateway");return b}function t(a,b){let c=m.get(a);if(!c)throw TypeError("MCP gateway must be created by createMcpGateway");return c(b)}},57278:(a,b,c)=>{c.d(b,{H_:()=>l}),c(77598),c(73136),c(60339),c(18509);var d=c(8669),e=c(38672);c(39226),e.aH;var f=c(62202),g=c(57782);new WeakMap;var h=c(57975),i=c(96022),j=c(51842);class k{application;pollIntervalMs;onError;instances=new Map;listeners=new Set;resourceUpdateListeners=new Set;seenResourceUpdates=new Set;resourceUnsubscribe;timer;starting;refreshPromise;closed=!1;lifecycle=new AbortController;closing;signature(a){return a.map(a=>`${a.providerId}/${a.instanceId}/${a.fingerprint}/${a.address.host}:${a.address.port}`).join("|")}constructor(a,b,c){this.application=a,this.pollIntervalMs=b,this.onError=c}start(){if(this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");return this.starting||(this.starting=this.performStart().finally(()=>{this.starting=void 0})),this.starting}async performStart(){if(!this.resourceUnsubscribe){let a=await this.application.subscribe(g.kn,a=>{let b=this.parseResourceUpdate(a);if(!(!b||this.seenResourceUpdates.has(b.eventId)))for(let a of(this.seenResourceUpdates.add(b.eventId),this.seenResourceUpdates.size>1024&&this.seenResourceUpdates.delete(this.seenResourceUpdates.values().next().value),this.resourceUpdateListeners))try{a(b)}catch(a){this.report(a)}});if(this.resourceUnsubscribe=a,this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed")}if(await this.refresh(),this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");this.timer||(this.timer=setInterval(()=>{this.refresh().catch(a=>this.report(a))},this.pollIntervalMs),this.timer.unref())}snapshot(){return[...this.instances.values()].sort((a,b)=>(0,j.n)(a.providerId,b.providerId)||(0,j.n)(a.instanceId,b.instanceId))}subscribe(a){if(this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");return this.listeners.add(a),()=>{this.listeners.delete(a)}}subscribeResourceUpdates(a){if(this.closed)throw new d.N("PROVIDER_UNAVAILABLE","MCP provider source is closed");return this.resourceUpdateListeners.add(a),()=>{this.resourceUpdateListeners.delete(a)}}parseResourceUpdate(a){if(!a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.eventId||!a.eventId||"string"!=typeof a.providerId||"string"!=typeof a.instanceId||"string"!=typeof a.fingerprint||"string"!=typeof a.uri)return;try{new URL(a.uri)}catch{return}let b=this.instances.get(`${a.providerId}/${a.instanceId}`);return b?.fingerprint===a.fingerprint?Object.freeze({eventId:a.eventId,providerId:a.providerId,instanceId:a.instanceId,fingerprint:a.fingerprint,uri:a.uri}):void 0}refresh(){if(this.refreshPromise)return this.refreshPromise;let a=(async()=>{let a=await this.application.listRegistryTopicSnapshots(g.k2,{signal:this.lifecycle.signal}),b=new Map;for(let{topic:c,payload:d,publishers:e}of a){let a=d&&"object"==typeof d&&!Array.isArray(d)?d:void 0,i="string"==typeof a?.providerId&&"string"==typeof a.instanceId?`${a.providerId}/${a.instanceId}`:void 0,j=i?this.instances.get(i):void 0,k=j&&c===`${g.k2}${j.providerId}/${j.instanceId}`&&(0,h.isDeepStrictEqual)(d,j)?j:(0,f.Ky)(d,c),l=1===e.length?e[0]:void 0;k&&l&&k.address.host===l.host&&k.address.port===l.port&&b.set(`${k.providerId}/${k.instanceId}`,k)}if(this.closed)return;let c=this.signature(this.snapshot());for(let[a,c]of(this.instances.clear(),b))this.instances.set(a,c);let d=this.snapshot();if(this.signature(d)!==c)for(let a of this.listeners)try{a(d)}catch(a){this.report(a)}})();return this.refreshPromise=a.finally(()=>{this.refreshPromise=void 0}),this.refreshPromise}stream(a,b,c,d){return this.application.streamPeer(a.address,b,c,d)}close(){return this.closing||(this.closing=this.performClose().finally(()=>{this.closing=void 0})),this.closing}async performClose(){this.closed||(this.closed=!0,this.lifecycle.abort(Error("MCP provider source closed")),this.timer&&clearInterval(this.timer),this.timer=void 0,this.listeners.clear(),this.resourceUpdateListeners.clear());try{await this.starting}catch{}try{await this.refreshPromise}catch(b){let a=b===this.lifecycle.signal.reason||!!b&&"object"==typeof b&&("ECONNABORTED"===b.status||"AbortError"===b.name);if(!this.lifecycle.signal.aborted||!a)throw b}if(this.resourceUnsubscribe){let a=this.resourceUnsubscribe;await a(),this.resourceUnsubscribe===a&&(this.resourceUnsubscribe=void 0)}}report(a){try{this.onError(a)}catch{}}}function l(a,b={}){let c=b.pollIntervalMs??2e3;if((0,i.y)(c,"pollIntervalMs",100),void 0!==b.onError&&"function"!=typeof b.onError)throw TypeError("MCP provider source onError must be a function");return new k(a,c,b.onError??(()=>void 0))}},57782:(a,b,c)=>{c.d(b,{Aw:()=>f,k2:()=>d,kn:()=>e});let d="@hile/mcp/providers/",e="@hile/mcp/resource-updates",f=Object.freeze({invoke:"/-/mcp/invoke",complete:"/-/mcp/complete"})},60339:(a,b,c)=>{let d,e,f,g,h,i,j,k,l,m;c.d(b,{_k:()=>gL,Zn:()=>gM,Hm:()=>eP,hw:()=>g8,JF:()=>gz,p0:()=>g2,e0:()=>hg,QK:()=>g9,IK:()=>g7,yH:()=>he,ld:()=>hf,PA:()=>g6,aV:()=>eA});var n,o,p,q,r,s=Object.create,t=Object.defineProperty,u=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,w=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,y=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),z=(a,b,c)=>(c=null!=a?s(w(a)):{},((a,b,c)=>{if(b&&"object"==typeof b||"function"==typeof b)for(var d,e=v(b),f=0,g=e.length;f<g;f++)d=e[f],x.call(a,d)||void 0===d||t(a,d,{get:(a=>b[a]).bind(null,d),enumerable:!(c=u(b,d))||c.enumerable});return a})(!b&&a&&a.__esModule?c:t(c,"default",{value:a,enumerable:!0}),a));let A=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),B=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),C=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),D=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);var E=c(62710),F=c(29951);r||(r={});var G=c(64586),H=c(35789);let I="2025-11-25",J=[I,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],K="io.modelcontextprotocol/protocolVersion",L="io.modelcontextprotocol/clientInfo",M="io.modelcontextprotocol/serverInfo",N="io.modelcontextprotocol/clientCapabilities",O="io.modelcontextprotocol/subscriptionId",P="io.modelcontextprotocol/logLevel",Q=E.RZ(()=>E.KC([E.Yj(),E.ai(),E.zM(),E.ch(),E.g1(E.Yj(),Q),E.YO(Q)])),R=E.g1(E.Yj(),Q),S=E.YO(Q),T=E.KC([E.Yj(),E.ai().int()]),U=E.Yj(),V=E.Ik({ttl:E.ai().optional()}),W=E.Ik({taskId:E.Yj()}),X=E._H({progressToken:T.optional(),"io.modelcontextprotocol/related-task":W.optional()}),Y=E.Ik({_meta:X.optional()}),Z=Y.extend({task:V.optional()}),$=E.Ik({method:E.Yj(),params:Y.loose().optional()}),_=E.Ik({_meta:X.optional()}),aa=E.Ik({method:E.Yj(),params:_.loose().optional()}),ab=E._H({get[M](){return aq.optional().catch(void 0)}}),ac=E._H({_meta:ab.optional()}),ad=E.KC([E.Yj(),E.ai().int()]),ae=E.Ik({jsonrpc:E.eu("2.0"),id:ad,...$.shape}).strict(),af=E.Ik({jsonrpc:E.eu("2.0"),...aa.shape}).strict(),ag=E.Ik({jsonrpc:E.eu("2.0"),id:ad,result:ac}).strict(),ah=E.Ik({jsonrpc:E.eu("2.0"),id:ad.optional(),error:E.Ik({code:E.ai().int(),message:E.Yj(),data:E.L5().optional()})}).strict(),ai=E.KC([ae,af,ag,ah]),aj=E.KC([ag,ah]),ak=ac.strict(),al=_.extend({requestId:ad.optional(),reason:E.Yj().optional()}),am=aa.extend({method:E.eu("notifications/cancelled"),params:al}),an=E.Ik({src:E.Yj(),mimeType:E.Yj().optional(),sizes:E.YO(E.Yj()).optional(),theme:E.k5(["light","dark"]).optional()}),ao=E.Ik({icons:E.YO(an).optional()}),ap=E.Ik({name:E.Yj(),title:E.Yj().optional()}),aq=ap.extend({...ap.shape,...ao.shape,version:E.Yj(),websiteUrl:E.Yj().optional(),description:E.Yj().optional()}),ar=E.E$(E.Ik({applyDefaults:E.zM().optional()}),R),as=E.vk(a=>a&&"object"==typeof a&&!Array.isArray(a)&&0===Object.keys(a).length?{form:{}}:a,E.E$(E.Ik({form:ar.optional(),url:R.optional()}),R.optional())),at=E._H({list:R.optional(),cancel:R.optional(),requests:E._H({sampling:E._H({createMessage:R.optional()}).optional(),elicitation:E._H({create:R.optional()}).optional()}).optional()}),au=E._H({list:R.optional(),cancel:R.optional(),requests:E._H({tools:E._H({call:R.optional()}).optional()}).optional()}),av=E.Ik({experimental:E.g1(E.Yj(),R).optional(),sampling:E.Ik({context:R.optional(),tools:R.optional()}).optional(),elicitation:as.optional(),roots:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:at.optional(),extensions:E.g1(E.Yj(),R).optional()}),aw=Y.extend({protocolVersion:E.Yj(),capabilities:av,clientInfo:aq}),ax=$.extend({method:E.eu("initialize"),params:aw}),ay=E.Ik({experimental:E.g1(E.Yj(),R).optional(),logging:R.optional(),completions:R.optional(),prompts:E.Ik({listChanged:E.zM().optional()}).optional(),resources:E.Ik({subscribe:E.zM().optional(),listChanged:E.zM().optional()}).optional(),tools:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:au.optional(),extensions:E.g1(E.Yj(),R).optional()}),az=ac.extend({protocolVersion:E.Yj(),capabilities:ay,serverInfo:aq,instructions:E.Yj().optional()}),aA=aa.extend({method:E.eu("notifications/initialized"),params:_.optional()}),aB=$.extend({method:E.eu("server/discover"),params:Y.optional()}),aC=ac.extend({supportedVersions:E.YO(E.Yj()),capabilities:ay,instructions:E.Yj().optional()}),aD=$.extend({method:E.eu("ping"),params:Y.optional()}),aE=E.Ik({progress:E.ai(),total:E.lq(E.ai()),message:E.lq(E.Yj())}),aF=E.Ik({..._.shape,...aE.shape,progressToken:T}),aG=aa.extend({method:E.eu("notifications/progress"),params:aF}),aH=Y.extend({cursor:U.optional()}),aI=$.extend({params:aH.optional()}),aJ=ac.extend({nextCursor:U.optional()}),aK=E.Ik({uri:E.Yj(),mimeType:E.lq(E.Yj()),_meta:E.g1(E.Yj(),E.L5()).optional()}),aL=aK.extend({text:E.Yj()}),aM=E.Yj().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),aN=aK.extend({blob:aM}),aO=E.k5(["user","assistant"]),aP=E.Ik({audience:E.YO(aO).optional(),priority:E.ai().min(0).max(1).optional(),lastModified:F.w$({offset:!0}).optional()}),aQ=E.Ik({...ap.shape,...ao.shape,uri:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),size:E.lq(E.ai()),annotations:aP.optional(),_meta:E.lq(E._H({}))}),aR=E.Ik({...ap.shape,...ao.shape,uriTemplate:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),annotations:aP.optional(),_meta:E.lq(E._H({}))}),aS=aI.extend({method:E.eu("resources/list")}),aT=aJ.extend({resources:E.YO(aQ)}),aU=aI.extend({method:E.eu("resources/templates/list")}),aV=aJ.extend({resourceTemplates:E.YO(aR)}),aW=Y.extend({uri:E.Yj()}),aX=$.extend({method:E.eu("resources/read"),params:aW}),aY=ac.extend({contents:E.YO(E.KC([aL,aN]))}),aZ=aa.extend({method:E.eu("notifications/resources/list_changed"),params:_.optional()}),a$=$.extend({method:E.eu("resources/subscribe"),params:aW}),a_=$.extend({method:E.eu("resources/unsubscribe"),params:aW}),a0=E.Ik({toolsListChanged:E.zM().optional(),promptsListChanged:E.zM().optional(),resourcesListChanged:E.zM().optional(),resourceSubscriptions:E.YO(E.Yj()).optional()}),a1=Y.extend({notifications:a0}),a2=$.extend({method:E.eu("subscriptions/listen"),params:a1}),a3=_.extend({notifications:a0}),a4=aa.extend({method:E.eu("notifications/subscriptions/acknowledged"),params:a3}),a5=ab.extend({[O]:ad}),a6=ac.extend({_meta:a5}),a7=_.extend({uri:E.Yj()}),a8=aa.extend({method:E.eu("notifications/resources/updated"),params:a7}),a9=E.Ik({name:E.Yj(),description:E.lq(E.Yj()),required:E.lq(E.zM())}),ba=E.Ik({...ap.shape,...ao.shape,description:E.lq(E.Yj()),arguments:E.lq(E.YO(a9)),_meta:E.lq(E._H({}))}),bb=aI.extend({method:E.eu("prompts/list")}),bc=aJ.extend({prompts:E.YO(ba)}),bd=Y.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional()}),be=$.extend({method:E.eu("prompts/get"),params:bd}),bf=E.Ik({type:E.eu("text"),text:E.Yj(),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bg=E.Ik({type:E.eu("image"),data:aM,mimeType:E.Yj(),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bh=E.Ik({type:E.eu("audio"),data:aM,mimeType:E.Yj(),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bi=E.Ik({type:E.eu("tool_use"),name:E.Yj(),id:E.Yj(),input:E.g1(E.Yj(),E.L5()),_meta:E.g1(E.Yj(),E.L5()).optional()}),bj=E.Ik({type:E.eu("resource"),resource:E.KC([aL,aN]),annotations:aP.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bk=aQ.extend({type:E.eu("resource_link")}),bl=E.KC([bf,bg,bh,bk,bj]),bm=E.Ik({role:aO,content:bl}),bn=ac.extend({description:E.Yj().optional(),messages:E.YO(bm)}),bo=aa.extend({method:E.eu("notifications/prompts/list_changed"),params:_.optional()}),bp=E.Ik({title:E.Yj().optional(),readOnlyHint:E.zM().optional(),destructiveHint:E.zM().optional(),idempotentHint:E.zM().optional(),openWorldHint:E.zM().optional()}),bq=E.Ik({taskSupport:E.k5(["required","optional","forbidden"]).optional()}),br=E.Ik({...ap.shape,...ao.shape,description:E.Yj().optional(),inputSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),Q).optional(),required:E.YO(E.Yj()).optional()}).catchall(E.L5()),outputSchema:E._H({$schema:E.Yj().optional()}).optional(),annotations:bp.optional(),execution:bq.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bs=aI.extend({method:E.eu("tools/list")}),bt=aJ.extend({tools:E.YO(br)}),bu=ac.extend({content:E.YO(bl).default([]),structuredContent:E.L5().optional(),isError:E.zM().optional()}),bv=bu.or(ac.extend({toolResult:E.L5()})),bw=Z.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.L5()).optional()}),bx=$.extend({method:E.eu("tools/call"),params:bw}),by=aa.extend({method:E.eu("notifications/tools/list_changed"),params:_.optional()}),bz=E.Ik({autoRefresh:E.zM().default(!0),debounceMs:E.ai().int().nonnegative().default(300)}),bA=E.k5(["debug","info","notice","warning","error","critical","alert","emergency"]),bB=Y.extend({level:bA}),bC=$.extend({method:E.eu("logging/setLevel"),params:bB}),bD=_.extend({level:bA,logger:E.Yj().optional(),data:E.L5()}),bE=aa.extend({method:E.eu("notifications/message"),params:bD}),bF=E.Ik({name:E.Yj().optional()}),bG=E.Ik({hints:E.YO(bF).optional(),costPriority:E.ai().min(0).max(1).optional(),speedPriority:E.ai().min(0).max(1).optional(),intelligencePriority:E.ai().min(0).max(1).optional()}),bH=E.Ik({mode:E.k5(["auto","required","none"]).optional()}),bI=E.Ik({type:E.eu("tool_result"),toolUseId:E.Yj().describe("The unique identifier for the corresponding tool call."),content:E.YO(bl),structuredContent:E.L5().optional(),isError:E.zM().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bJ=E.gM("type",[bf,bg,bh]),bK=E.gM("type",[bf,bg,bh,bi,bI]),bL=E.Ik({role:aO,content:E.KC([bK,E.YO(bK)]),_meta:E.g1(E.Yj(),E.L5()).optional()}),bM=Z.extend({messages:E.YO(bL),modelPreferences:bG.optional(),systemPrompt:E.Yj().optional(),includeContext:E.k5(["none","thisServer","allServers"]).optional(),temperature:E.ai().optional(),maxTokens:E.ai().int(),stopSequences:E.YO(E.Yj()).optional(),metadata:R.optional(),tools:E.YO(br).optional(),toolChoice:bH.optional()}),bN=$.extend({method:E.eu("sampling/createMessage"),params:bM}),bO=ac.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens"]).or(E.Yj())),role:aO,content:bJ}),bP=ac.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens","toolUse"]).or(E.Yj())),role:aO,content:E.KC([bK,E.YO(bK)])}),bQ=E.Ik({type:E.eu("boolean"),title:E.Yj().optional(),description:E.Yj().optional(),default:E.zM().optional()}),bR=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),minLength:E.ai().optional(),maxLength:E.ai().optional(),format:E.k5(["email","uri","date","date-time"]).optional(),default:E.Yj().optional()}),bS=E.Ik({type:E.k5(["number","integer"]),title:E.Yj().optional(),description:E.Yj().optional(),minimum:E.ai().optional(),maximum:E.ai().optional(),default:E.ai().optional()}),bT=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),default:E.Yj().optional()}),bU=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),oneOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()})),default:E.Yj().optional()}),bV=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),enumNames:E.YO(E.Yj()).optional(),default:E.Yj().optional()}),bW=E.KC([bT,bU]),bX=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({type:E.eu("string"),enum:E.YO(E.Yj())}),default:E.YO(E.Yj()).optional()}),bY=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({anyOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()}))}),default:E.YO(E.Yj()).optional()}),bZ=E.KC([bX,bY]),b$=E.KC([bV,bW,bZ]),b_=E.KC([b$,bQ,bR,bS]),b0=Z.extend({mode:E.eu("form").optional(),message:E.Yj(),requestedSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),b_),required:E.YO(E.Yj()).optional()}).catchall(E.L5())}),b1=Z.extend({mode:E.eu("url"),message:E.Yj(),elicitationId:E.Yj(),url:E.Yj().url()}),b2=E.KC([b0,b1]),b3=$.extend({method:E.eu("elicitation/create"),params:b2}),b4=_.extend({elicitationId:E.Yj()}),b5=aa.extend({method:E.eu("notifications/elicitation/complete"),params:b4}),b6=ac.extend({action:E.k5(["accept","decline","cancel"]),content:E.vk(a=>null===a?void 0:a,E.g1(E.Yj(),E.KC([E.Yj(),E.ai(),E.zM(),E.YO(E.Yj())])).optional())}),b7=E.Ik({type:E.eu("ref/resource"),uri:E.Yj()}),b8=E.Ik({type:E.eu("ref/prompt"),name:E.Yj()}),b9=Y.extend({ref:E.KC([b8,b7]),argument:E.Ik({name:E.Yj(),value:E.Yj()}),context:E.Ik({arguments:E.g1(E.Yj(),E.Yj()).optional()}).optional()}),ca=$.extend({method:E.eu("completion/complete"),params:b9}),cb=ac.extend({completion:E._H({values:E.YO(E.Yj()).max(100),total:E.lq(E.ai().int()),hasMore:E.lq(E.zM())})}),cc=E.Ik({uri:E.Yj().startsWith("file://"),name:E.Yj().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),cd=$.extend({method:E.eu("roots/list"),params:Y.optional()}),ce=ac.extend({roots:E.YO(cc)}),cf=aa.extend({method:E.eu("notifications/roots/list_changed"),params:_.optional()}),cg=E._H({ttl:E.ai().optional(),pollInterval:E.ai().optional()}),ch=E.k5(["working","input_required","completed","failed","cancelled"]),ci=E.Ik({taskId:E.Yj(),status:ch,ttl:E.KC([E.ai(),E.ch()]),createdAt:E.Yj(),lastUpdatedAt:E.Yj(),pollInterval:E.lq(E.ai()),statusMessage:E.lq(E.Yj())}),cj=ac.extend({task:ci}),ck=_.merge(ci),cl=aa.extend({method:E.eu("notifications/tasks/status"),params:ck}),cm=$.extend({method:E.eu("tasks/get"),params:Y.extend({taskId:E.Yj()})}),cn=ac.merge(ci),co=$.extend({method:E.eu("tasks/result"),params:Y.extend({taskId:E.Yj()})}),cp=ac.loose(),cq=aI.extend({method:E.eu("tasks/list")}),cr=aJ.extend({tasks:E.YO(ci)}),cs=$.extend({method:E.eu("tasks/cancel"),params:Y.extend({taskId:E.Yj()})}),ct=ac.merge(ci),cu=E.KC([aD,ax,aB,ca,bC,be,bb,aS,aU,aX,a$,a_,a2,bx,bs]),cv=E.KC([am,aG,aA,cf]),cw=E.KC([ak,bO,bP,b6,ce]),cx=E.KC([aD,bN,b3,cd]),cy=E.KC([am,aG,bE,a8,aZ,by,bo,a4,b5]),cz=E.KC([ak,az,aC,cb,bn,bc,aT,aV,aY,bu,bt,a6]),cA=E.OZ().superRefine((a,b)=>{if(!URL.canParse(a))return b.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),G.tm}).refine(a=>{let b=new URL(a);return"javascript:"!==b.protocol&&"data:"!==b.protocol&&"vbscript:"!==b.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),cB=E._H({resource:E.Yj().url(),authorization_servers:E.YO(cA).optional(),jwks_uri:E.Yj().url().optional(),scopes_supported:E.YO(E.Yj()).optional(),bearer_methods_supported:E.YO(E.Yj()).optional(),resource_signing_alg_values_supported:E.YO(E.Yj()).optional(),resource_name:E.Yj().optional(),resource_documentation:E.Yj().optional(),resource_policy_uri:E.Yj().url().optional(),resource_tos_uri:E.Yj().url().optional(),tls_client_certificate_bound_access_tokens:E.zM().optional(),authorization_details_types_supported:E.YO(E.Yj()).optional(),dpop_signing_alg_values_supported:E.YO(E.Yj()).optional(),dpop_bound_access_tokens_required:E.zM().optional()}),cC=E._H({issuer:E.Yj(),authorization_endpoint:cA,token_endpoint:cA,registration_endpoint:cA.optional(),scopes_supported:E.YO(E.Yj()).optional(),response_types_supported:E.YO(E.Yj()),response_modes_supported:E.YO(E.Yj()).optional(),grant_types_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),service_documentation:cA.optional(),revocation_endpoint:cA.optional(),revocation_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),revocation_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),introspection_endpoint:E.Yj().optional(),introspection_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),introspection_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),code_challenge_methods_supported:E.YO(E.Yj()).optional(),client_id_metadata_document_supported:E.zM().optional(),authorization_response_iss_parameter_supported:E.zM().optional().catch(void 0)}),cD=E._H({issuer:E.Yj(),authorization_endpoint:cA,token_endpoint:cA,userinfo_endpoint:cA.optional(),jwks_uri:cA,registration_endpoint:cA.optional(),scopes_supported:E.YO(E.Yj()).optional(),response_types_supported:E.YO(E.Yj()),response_modes_supported:E.YO(E.Yj()).optional(),grant_types_supported:E.YO(E.Yj()).optional(),acr_values_supported:E.YO(E.Yj()).optional(),subject_types_supported:E.YO(E.Yj()),id_token_signing_alg_values_supported:E.YO(E.Yj()),id_token_encryption_alg_values_supported:E.YO(E.Yj()).optional(),id_token_encryption_enc_values_supported:E.YO(E.Yj()).optional(),userinfo_signing_alg_values_supported:E.YO(E.Yj()).optional(),userinfo_encryption_alg_values_supported:E.YO(E.Yj()).optional(),userinfo_encryption_enc_values_supported:E.YO(E.Yj()).optional(),request_object_signing_alg_values_supported:E.YO(E.Yj()).optional(),request_object_encryption_alg_values_supported:E.YO(E.Yj()).optional(),request_object_encryption_enc_values_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_methods_supported:E.YO(E.Yj()).optional(),token_endpoint_auth_signing_alg_values_supported:E.YO(E.Yj()).optional(),display_values_supported:E.YO(E.Yj()).optional(),claim_types_supported:E.YO(E.Yj()).optional(),claims_supported:E.YO(E.Yj()).optional(),service_documentation:E.Yj().optional(),claims_locales_supported:E.YO(E.Yj()).optional(),ui_locales_supported:E.YO(E.Yj()).optional(),claims_parameter_supported:E.zM().optional(),request_parameter_supported:E.zM().optional(),request_uri_parameter_supported:E.zM().optional(),require_request_uri_registration:E.zM().optional(),op_policy_uri:cA.optional(),op_tos_uri:cA.optional(),client_id_metadata_document_supported:E.zM().optional(),authorization_response_iss_parameter_supported:E.zM().optional().catch(void 0)}),cE=E.Ik({...cD.shape,...cC.pick({code_challenge_methods_supported:!0}).shape}),cF=E.Ik({access_token:E.Yj(),id_token:E.Yj().optional(),token_type:E.Yj(),expires_in:H.ai().optional(),scope:E.Yj().optional(),refresh_token:E.Yj().optional()}).strip(),cG=E.Ik({issued_token_type:E.eu("urn:ietf:params:oauth:token-type:id-jag"),access_token:E.Yj(),token_type:E.Yj().optional(),expires_in:E.ai().optional(),scope:E.Yj().optional()}).strip(),cH=E.Ik({error:E.Yj(),error_description:E.Yj().optional(),error_uri:E.Yj().optional()}),cI=cA.optional().or(E.eu("").transform(()=>void 0)),cJ=E.Ik({redirect_uris:E.YO(cA),token_endpoint_auth_method:E.Yj().optional(),grant_types:E.YO(E.Yj()).optional(),response_types:E.YO(E.Yj()).optional(),application_type:E.Yj().optional(),client_name:E.Yj().optional(),client_uri:cA.optional(),logo_uri:cI,scope:E.Yj().optional(),contacts:E.YO(E.Yj()).optional(),tos_uri:cI,policy_uri:E.Yj().optional(),jwks_uri:cA.optional(),jwks:E.bz().optional(),software_id:E.Yj().optional(),software_version:E.Yj().optional(),software_statement:E.Yj().optional()}).strip(),cK=E.Ik({client_id:E.Yj(),client_secret:E.Yj().optional(),client_id_issued_at:E.ai().optional(),client_secret_expires_at:E.ai().optional()}).strip(),cL=cJ.merge(cK),cM=E.Ik({error:E.Yj(),error_description:E.Yj().optional()}).strip(),cN=E.Ik({token:E.Yj(),token_type_hint:E.Yj().optional()}).strip();var cO=c(49417),cP=c(28621);let cQ=Symbol.for("mcp.sdk.errorBrands");function cR(a,b){let c=new Set,d=b;for(;"function"==typeof d;){let a=d.mcpBrand;Object.prototype.hasOwnProperty.call(d,"mcpBrand")&&"string"==typeof a&&c.add(a),d=Object.getPrototypeOf(d)}0!==c.size&&Object.defineProperty(a,cQ,{value:c,enumerable:!1,configurable:!0})}function cS(a,b){try{if("object"==typeof b&&null!==b&&Object.prototype.hasOwnProperty.call(a,"mcpBrand")&&"string"==typeof a.mcpBrand&&Object.prototype.hasOwnProperty.call(b,cQ)){let c=b[cQ];if(c&&"function"==typeof c.has&&c.has(a.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(a,b)}let cT=((n={}).InvalidRequest="invalid_request",n.InvalidClient="invalid_client",n.InvalidGrant="invalid_grant",n.UnauthorizedClient="unauthorized_client",n.UnsupportedGrantType="unsupported_grant_type",n.InvalidScope="invalid_scope",n.AccessDenied="access_denied",n.ServerError="server_error",n.TemporarilyUnavailable="temporarily_unavailable",n.UnsupportedResponseType="unsupported_response_type",n.UnsupportedTokenType="unsupported_token_type",n.InvalidToken="invalid_token",n.MethodNotAllowed="method_not_allowed",n.TooManyRequests="too_many_requests",n.InvalidClientMetadata="invalid_client_metadata",n.InvalidRedirectUri="invalid_redirect_uri",n.InsufficientScope="insufficient_scope",n.InvalidTarget="invalid_target",n);var cU=class a extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](a){return cS(this,a)}static isInstance(a){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return cS(this,a)}constructor(a,b,c){super(b),this.code=a,this.errorUri=c,this.name="OAuthError",cR(this,new.target)}toResponseObject(){let a={error:this.code,error_description:this.message};return this.errorUri&&(a.error_uri=this.errorUri),a}static fromResponse(b){return new a(b.error,b.error_description??b.error,b.error_uri)}};let cV=((o={}).NotConnected="NOT_CONNECTED",o.AlreadyConnected="ALREADY_CONNECTED",o.NotInitialized="NOT_INITIALIZED",o.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",o.RequestTimeout="REQUEST_TIMEOUT",o.ConnectionClosed="CONNECTION_CLOSED",o.SendFailed="SEND_FAILED",o.InvalidResult="INVALID_RESULT",o.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",o.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",o.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",o.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",o.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",o.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",o.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",o.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",o.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",o.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",o.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",o);var cW=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](a){return cS(this,a)}static isInstance(a){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return cS(this,a)}constructor(a,b,c){super(b),this.code=a,this.data=c,this.name="SdkError",cR(this,new.target)}};(class extends cW{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(a,b,c){super(a,b,c),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let cX={};function cY(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function cZ(a,b){let c={};for(let[d,e]of Object.entries(a)){if(void 0===e)continue;let a=void 0===b?void 0:b[d];if(void 0===a){c[d]=e;continue}if(cY(e)&&cY(a)){let b={};for(let[c,f]of Object.entries(e))void 0!==f&&void 0===a[c]&&("elicitation"!==d||"form"!==c||void 0!==a.form||void 0!==a.url)&&(b[c]=f);Object.keys(b).length>0&&(c[d]=b)}}return Object.keys(c).length>0?c:void 0}let c$="2026-07-28",c_=[c$];function c0(a){return a.filter(a=>a>=c$)}function c1(a){let b=a.structuredContent;return void 0===b||!("object"!=typeof b||null===b||Array.isArray(b))||a.content?.some(a=>"text"===a.type)?a:{...a,content:[...a.content??[],{type:"text",text:JSON.stringify(b)}]}}let c2=["task","inputRequests","requestState"];function c3(a){return null===a||"object"!=typeof a||Array.isArray(a)||void 0!==a.content||c2.some(b=>b in a)?a:{...a,content:[]}}function c4(){let a,b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,aA,aB,aC,aD,aE,aF,aG,aH,aI,aJ,aK,aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,aX,aY,aZ,a$,a_,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,ba,bb,bc,bd,be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt,bu,bv,bw,bx,by;return d??=(a=E.RZ(()=>E.KC([E.Yj(),E.ai(),E.zM(),E.ch(),E.g1(E.Yj(),a),E.YO(a)])),b=E.g1(E.Yj(),a),c=E.KC([E.Yj(),E.ai().int()]),e=E.Yj(),f=E.Ik({ttl:E.ai().optional()}),g=E.Ik({taskId:E.Yj()}),h=E._H({progressToken:c.optional(),"io.modelcontextprotocol/related-task":g.optional()}),j=(i=E.Ik({_meta:h.optional()})).extend({task:f.optional()}),k=E.Ik({method:E.Yj(),params:i.loose().optional()}),l=E.Ik({_meta:h.optional()}),m=E.Ik({method:E.Yj(),params:l.loose().optional()}),n=E._H({_meta:h.optional()}),o=E.KC([E.Yj(),E.ai().int()]),p=n.strict(),q=l.extend({requestId:o.optional(),reason:E.Yj().optional()}),r=m.extend({method:E.eu("notifications/cancelled"),params:q}),s=E.Ik({src:E.Yj(),mimeType:E.Yj().optional(),sizes:E.YO(E.Yj()).optional(),theme:E.k5(["light","dark"]).optional()}),t=E.Ik({icons:E.YO(s).optional()}),v=(u=E.Ik({name:E.Yj(),title:E.Yj().optional()})).extend({...u.shape,...t.shape,version:E.Yj(),websiteUrl:E.Yj().optional(),description:E.Yj().optional()}),w=E.E$(E.Ik({applyDefaults:E.zM().optional()}),b),x=E.vk(a=>a&&"object"==typeof a&&!Array.isArray(a)&&0===Object.keys(a).length?{form:{}}:a,E.E$(E.Ik({form:w.optional(),url:b.optional()}),b.optional())),y=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({sampling:E._H({createMessage:b.optional()}).optional(),elicitation:E._H({create:b.optional()}).optional()}).optional()}),z=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({tools:E._H({call:b.optional()}).optional()}).optional()}),A=E.Ik({experimental:E.g1(E.Yj(),b).optional(),sampling:E.Ik({context:b.optional(),tools:b.optional()}).optional(),elicitation:x.optional(),roots:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:y.optional(),extensions:E.g1(E.Yj(),b).optional()}),B=i.extend({protocolVersion:E.Yj(),capabilities:A,clientInfo:v}),C=k.extend({method:E.eu("initialize"),params:B}),D=E.Ik({experimental:E.g1(E.Yj(),b).optional(),logging:b.optional(),completions:b.optional(),prompts:E.Ik({listChanged:E.zM().optional()}).optional(),resources:E.Ik({subscribe:E.zM().optional(),listChanged:E.zM().optional()}).optional(),tools:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:z.optional(),extensions:E.g1(E.Yj(),b).optional()}),G=n.extend({protocolVersion:E.Yj(),capabilities:D,serverInfo:v,instructions:E.Yj().optional()}),H=m.extend({method:E.eu("notifications/initialized"),params:l.optional()}),I=k.extend({method:E.eu("ping"),params:i.optional()}),J=E.Ik({progress:E.ai(),total:E.lq(E.ai()),message:E.lq(E.Yj())}),K=E.Ik({...l.shape,...J.shape,progressToken:c}),L=m.extend({method:E.eu("notifications/progress"),params:K}),M=i.extend({cursor:e.optional()}),N=k.extend({params:M.optional()}),O=n.extend({nextCursor:e.optional()}),Q=(P=E.Ik({uri:E.Yj(),mimeType:E.lq(E.Yj()),_meta:E.g1(E.Yj(),E.L5()).optional()})).extend({text:E.Yj()}),R=E.Yj().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),S=P.extend({blob:R}),T=E.k5(["user","assistant"]),U=E.Ik({audience:E.YO(T).optional(),priority:E.ai().min(0).max(1).optional(),lastModified:F.w$({offset:!0}).optional()}),V=E.Ik({...u.shape,...t.shape,uri:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),size:E.lq(E.ai()),annotations:U.optional(),_meta:E.lq(E._H({}))}),W=E.Ik({...u.shape,...t.shape,uriTemplate:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),annotations:U.optional(),_meta:E.lq(E._H({}))}),X=N.extend({method:E.eu("resources/list")}),Y=O.extend({resources:E.YO(V)}),Z=N.extend({method:E.eu("resources/templates/list")}),$=O.extend({resourceTemplates:E.YO(W)}),_=i.extend({uri:E.Yj()}),aa=k.extend({method:E.eu("resources/read"),params:_}),ab=n.extend({contents:E.YO(E.KC([Q,S]))}),ac=m.extend({method:E.eu("notifications/resources/list_changed"),params:l.optional()}),ad=k.extend({method:E.eu("resources/subscribe"),params:_}),ae=k.extend({method:E.eu("resources/unsubscribe"),params:_}),af=l.extend({uri:E.Yj()}),ag=m.extend({method:E.eu("notifications/resources/updated"),params:af}),ah=E.Ik({name:E.Yj(),description:E.lq(E.Yj()),required:E.lq(E.zM())}),ai=E.Ik({...u.shape,...t.shape,description:E.lq(E.Yj()),arguments:E.lq(E.YO(ah)),_meta:E.lq(E._H({}))}),aj=N.extend({method:E.eu("prompts/list")}),ak=O.extend({prompts:E.YO(ai)}),al=i.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional()}),am=k.extend({method:E.eu("prompts/get"),params:al}),an=E.Ik({type:E.eu("text"),text:E.Yj(),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),ao=E.Ik({type:E.eu("image"),data:R,mimeType:E.Yj(),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),ap=E.Ik({type:E.eu("audio"),data:R,mimeType:E.Yj(),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aq=E.Ik({type:E.eu("tool_use"),name:E.Yj(),id:E.Yj(),input:E.g1(E.Yj(),E.L5()),_meta:E.g1(E.Yj(),E.L5()).optional()}),ar=E.Ik({type:E.eu("resource"),resource:E.KC([Q,S]),annotations:U.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),as=V.extend({type:E.eu("resource_link")}),at=E.KC([an,ao,ap,as,ar]),au=E.Ik({role:T,content:at}),av=n.extend({description:E.Yj().optional(),messages:E.YO(au)}),aw=m.extend({method:E.eu("notifications/prompts/list_changed"),params:l.optional()}),ax=E.Ik({title:E.Yj().optional(),readOnlyHint:E.zM().optional(),destructiveHint:E.zM().optional(),idempotentHint:E.zM().optional(),openWorldHint:E.zM().optional()}),ay=E.Ik({taskSupport:E.k5(["required","optional","forbidden"]).optional()}),az=E.Ik({...u.shape,...t.shape,description:E.Yj().optional(),inputSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),a).optional(),required:E.YO(E.Yj()).optional()}).catchall(E.L5()),outputSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),a).optional(),required:E.YO(E.Yj()).optional()}).catchall(E.L5()).optional(),annotations:ax.optional(),execution:ay.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aA=N.extend({method:E.eu("tools/list")}),aB=O.extend({tools:E.YO(az)}),aC=n.extend({content:E.YO(at),structuredContent:E.g1(E.Yj(),E.L5()).optional(),isError:E.zM().optional()}),aD=j.extend({name:E.Yj(),arguments:E.g1(E.Yj(),E.L5()).optional()}),aE=k.extend({method:E.eu("tools/call"),params:aD}),aF=m.extend({method:E.eu("notifications/tools/list_changed"),params:l.optional()}),aG=E.k5(["debug","info","notice","warning","error","critical","alert","emergency"]),aH=i.extend({level:aG}),aI=k.extend({method:E.eu("logging/setLevel"),params:aH}),aJ=l.extend({level:aG,logger:E.Yj().optional(),data:E.L5()}),aK=m.extend({method:E.eu("notifications/message"),params:aJ}),aL=E.Ik({name:E.Yj().optional()}),aM=E.Ik({hints:E.YO(aL).optional(),costPriority:E.ai().min(0).max(1).optional(),speedPriority:E.ai().min(0).max(1).optional(),intelligencePriority:E.ai().min(0).max(1).optional()}),aN=E.Ik({mode:E.k5(["auto","required","none"]).optional()}),aO=E.Ik({type:E.eu("tool_result"),toolUseId:E.Yj().describe("The unique identifier for the corresponding tool call."),content:E.YO(at),structuredContent:E.Ik({}).loose().optional(),isError:E.zM().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aP=E.gM("type",[an,ao,ap]),aQ=E.gM("type",[an,ao,ap,aq,aO]),aR=E.Ik({role:T,content:E.KC([aQ,E.YO(aQ)]),_meta:E.g1(E.Yj(),E.L5()).optional()}),aS=j.extend({messages:E.YO(aR),modelPreferences:aM.optional(),systemPrompt:E.Yj().optional(),includeContext:E.k5(["none","thisServer","allServers"]).optional(),temperature:E.ai().optional(),maxTokens:E.ai().int(),stopSequences:E.YO(E.Yj()).optional(),metadata:b.optional(),tools:E.YO(az).optional(),toolChoice:aN.optional()}),aT=k.extend({method:E.eu("sampling/createMessage"),params:aS}),aU=n.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens"]).or(E.Yj())),role:T,content:aP}),aV=n.extend({model:E.Yj(),stopReason:E.lq(E.k5(["endTurn","stopSequence","maxTokens","toolUse"]).or(E.Yj())),role:T,content:E.KC([aQ,E.YO(aQ)])}),aW=E.Ik({type:E.eu("boolean"),title:E.Yj().optional(),description:E.Yj().optional(),default:E.zM().optional()}),aX=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),minLength:E.ai().optional(),maxLength:E.ai().optional(),format:E.k5(["email","uri","date","date-time"]).optional(),default:E.Yj().optional()}),aY=E.Ik({type:E.k5(["number","integer"]),title:E.Yj().optional(),description:E.Yj().optional(),minimum:E.ai().optional(),maximum:E.ai().optional(),default:E.ai().optional()}),aZ=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),default:E.Yj().optional()}),a$=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),oneOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()})),default:E.Yj().optional()}),a_=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),enumNames:E.YO(E.Yj()).optional(),default:E.Yj().optional()}),a0=E.KC([aZ,a$]),a1=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({type:E.eu("string"),enum:E.YO(E.Yj())}),default:E.YO(E.Yj()).optional()}),a2=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({anyOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()}))}),default:E.YO(E.Yj()).optional()}),a3=E.KC([a1,a2]),a4=E.KC([a_,a0,a3]),a5=E.KC([a4,aW,aX,aY]),a6=j.extend({mode:E.eu("form").optional(),message:E.Yj(),requestedSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),a5),required:E.YO(E.Yj()).optional()}).catchall(E.L5())}),a7=j.extend({mode:E.eu("url"),message:E.Yj(),elicitationId:E.Yj(),url:E.Yj().url()}),a8=E.KC([a6,a7]),a9=k.extend({method:E.eu("elicitation/create"),params:a8}),ba=l.extend({elicitationId:E.Yj()}),bb=m.extend({method:E.eu("notifications/elicitation/complete"),params:ba}),bc=n.extend({action:E.k5(["accept","decline","cancel"]),content:E.vk(a=>null===a?void 0:a,E.g1(E.Yj(),E.KC([E.Yj(),E.ai(),E.zM(),E.YO(E.Yj())])).optional())}),bd=E.Ik({type:E.eu("ref/resource"),uri:E.Yj()}),be=E.Ik({type:E.eu("ref/prompt"),name:E.Yj()}),bf=i.extend({ref:E.KC([be,bd]),argument:E.Ik({name:E.Yj(),value:E.Yj()}),context:E.Ik({arguments:E.g1(E.Yj(),E.Yj()).optional()}).optional()}),bg=k.extend({method:E.eu("completion/complete"),params:bf}),bh=n.extend({completion:E._H({values:E.YO(E.Yj()).max(100),total:E.lq(E.ai().int()),hasMore:E.lq(E.zM())})}),bi=E.Ik({uri:E.Yj().startsWith("file://"),name:E.Yj().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),bj=k.extend({method:E.eu("roots/list"),params:i.optional()}),bk=n.extend({roots:E.YO(bi)}),bl=m.extend({method:E.eu("notifications/roots/list_changed"),params:l.optional()}),bm=E._H({ttl:E.ai().optional(),pollInterval:E.ai().optional()}),bn=E.k5(["working","input_required","completed","failed","cancelled"]),bo=E.Ik({taskId:E.Yj(),status:bn,ttl:E.KC([E.ai(),E.ch()]),createdAt:E.Yj(),lastUpdatedAt:E.Yj(),pollInterval:E.lq(E.ai()),statusMessage:E.lq(E.Yj())}),bp=n.extend({task:bo}),bq=l.merge(bo),br=m.extend({method:E.eu("notifications/tasks/status"),params:bq}),bs=k.extend({method:E.eu("tasks/get"),params:i.extend({taskId:E.Yj()})}),bt=n.merge(bo),bu=k.extend({method:E.eu("tasks/result"),params:i.extend({taskId:E.Yj()})}),bv=n.loose(),bw=N.extend({method:E.eu("tasks/list")}),bx=O.extend({tasks:E.YO(bo)}),by=k.extend({method:E.eu("tasks/cancel"),params:i.extend({taskId:E.Yj()})}),{JSONValueSchema:a,JSONObjectSchema:b,ProgressTokenSchema:c,CursorSchema:e,TaskMetadataSchema:f,RelatedTaskMetadataSchema:g,RequestMetaSchema:h,BaseRequestParamsSchema:i,TaskAugmentedRequestParamsSchema:j,RequestSchema:k,NotificationsParamsSchema:l,NotificationSchema:m,ResultSchema:n,RequestIdSchema:o,EmptyResultSchema:p,CancelledNotificationParamsSchema:q,CancelledNotificationSchema:r,IconSchema:s,IconsSchema:t,BaseMetadataSchema:u,ImplementationSchema:v,ClientTasksCapabilitySchema:y,ServerTasksCapabilitySchema:z,ClientCapabilitiesSchema:A,InitializeRequestParamsSchema:B,InitializeRequestSchema:C,ServerCapabilitiesSchema:D,InitializeResultSchema:G,InitializedNotificationSchema:H,PingRequestSchema:I,ProgressSchema:J,ProgressNotificationParamsSchema:K,ProgressNotificationSchema:L,PaginatedRequestParamsSchema:M,PaginatedRequestSchema:N,PaginatedResultSchema:O,ResourceContentsSchema:P,TextResourceContentsSchema:Q,BlobResourceContentsSchema:S,RoleSchema:T,AnnotationsSchema:U,ResourceSchema:V,ResourceTemplateSchema:W,ListResourcesRequestSchema:X,ListResourcesResultSchema:Y,ListResourceTemplatesRequestSchema:Z,ListResourceTemplatesResultSchema:$,ResourceRequestParamsSchema:_,ReadResourceRequestParamsSchema:_,ReadResourceRequestSchema:aa,ReadResourceResultSchema:ab,ResourceListChangedNotificationSchema:ac,SubscribeRequestParamsSchema:_,SubscribeRequestSchema:ad,UnsubscribeRequestParamsSchema:_,UnsubscribeRequestSchema:ae,ResourceUpdatedNotificationParamsSchema:af,ResourceUpdatedNotificationSchema:ag,PromptArgumentSchema:ah,PromptSchema:ai,ListPromptsRequestSchema:aj,ListPromptsResultSchema:ak,GetPromptRequestParamsSchema:al,GetPromptRequestSchema:am,TextContentSchema:an,ImageContentSchema:ao,AudioContentSchema:ap,ToolUseContentSchema:aq,EmbeddedResourceSchema:ar,ResourceLinkSchema:as,ContentBlockSchema:at,PromptMessageSchema:au,GetPromptResultSchema:av,PromptListChangedNotificationSchema:aw,ToolAnnotationsSchema:ax,ToolExecutionSchema:ay,ToolSchema:az,ListToolsRequestSchema:aA,ListToolsResultSchema:aB,CallToolResultSchema:aC,CallToolRequestParamsSchema:aD,CallToolRequestSchema:aE,ToolListChangedNotificationSchema:aF,LoggingLevelSchema:aG,SetLevelRequestParamsSchema:aH,SetLevelRequestSchema:aI,LoggingMessageNotificationParamsSchema:aJ,LoggingMessageNotificationSchema:aK,ModelHintSchema:aL,ModelPreferencesSchema:aM,ToolChoiceSchema:aN,ToolResultContentSchema:aO,SamplingContentSchema:aP,SamplingMessageContentBlockSchema:aQ,SamplingMessageSchema:aR,CreateMessageRequestParamsSchema:aS,CreateMessageRequestSchema:aT,CreateMessageResultSchema:aU,CreateMessageResultWithToolsSchema:aV,BooleanSchemaSchema:aW,StringSchemaSchema:aX,NumberSchemaSchema:aY,UntitledSingleSelectEnumSchemaSchema:aZ,TitledSingleSelectEnumSchemaSchema:a$,LegacyTitledEnumSchemaSchema:a_,SingleSelectEnumSchemaSchema:a0,UntitledMultiSelectEnumSchemaSchema:a1,TitledMultiSelectEnumSchemaSchema:a2,MultiSelectEnumSchemaSchema:a3,EnumSchemaSchema:a4,PrimitiveSchemaDefinitionSchema:a5,ElicitRequestFormParamsSchema:a6,ElicitRequestURLParamsSchema:a7,ElicitRequestParamsSchema:a8,ElicitRequestSchema:a9,ElicitationCompleteNotificationParamsSchema:ba,ElicitationCompleteNotificationSchema:bb,ElicitResultSchema:bc,ResourceTemplateReferenceSchema:bd,PromptReferenceSchema:be,CompleteRequestParamsSchema:bf,CompleteRequestSchema:bg,CompleteResultSchema:bh,RootSchema:bi,ListRootsRequestSchema:bj,ListRootsResultSchema:bk,RootsListChangedNotificationSchema:bl,TaskCreationParamsSchema:bm,TaskStatusSchema:bn,TaskSchema:bo,CreateTaskResultSchema:bp,TaskStatusNotificationParamsSchema:bq,TaskStatusNotificationSchema:br,GetTaskRequestSchema:bs,GetTaskResultSchema:bt,GetTaskPayloadRequestSchema:bu,GetTaskPayloadResultSchema:bv,ListTasksRequestSchema:bw,ListTasksResultSchema:bx,CancelTaskRequestSchema:by,CancelTaskResultSchema:n.merge(bo),ClientRequestSchema:E.KC([I,C,bg,aI,am,aj,X,Z,aa,ad,ae,aE,aA,bs,bu,bw,by]),ClientNotificationSchema:E.KC([r,L,H,bl,br]),ClientResultSchema:E.KC([p,aU,aV,bc,bk,bt,bx,bp]),ServerRequestSchema:E.KC([I,aT,a9,bj,bs,bu,bw,by]),ServerNotificationSchema:E.KC([r,L,aK,ag,ac,aF,aw,br,bb]),ServerResultSchema:E.KC([p,G,bh,av,ak,Y,$,ab,aC,aB,bt,bx,bp]),CallToolResultWireSchema:E.L5().superRefine((a,b)=>{if(!("object"!=typeof a||null===a||Array.isArray(a))&&void 0===a.content){for(let c of c2)if(c in a)return void b.addIssue({code:"custom",message:`content is required when the body carries '${c}' — another result family cannot default into an empty tools/call success`})}}).transform(c3).pipe(aC)})}function c5(a){return"object"!==a.type}let c6=new Set(["const","enum","default","examples"]),c7=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function c8(a){return void 0!==a&&!("string"==typeof a&&a.startsWith("#"))}let c9={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},da={"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},db={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function dc(){if(e)return e;let a=c4();return e={requestSchemas:{ping:a.PingRequestSchema,initialize:a.InitializeRequestSchema,"completion/complete":a.CompleteRequestSchema,"logging/setLevel":a.SetLevelRequestSchema,"prompts/get":a.GetPromptRequestSchema,"prompts/list":a.ListPromptsRequestSchema,"resources/list":a.ListResourcesRequestSchema,"resources/templates/list":a.ListResourceTemplatesRequestSchema,"resources/read":a.ReadResourceRequestSchema,"resources/subscribe":a.SubscribeRequestSchema,"resources/unsubscribe":a.UnsubscribeRequestSchema,"tools/call":a.CallToolRequestSchema,"tools/list":a.ListToolsRequestSchema,"tasks/get":a.GetTaskRequestSchema,"tasks/result":a.GetTaskPayloadRequestSchema,"tasks/list":a.ListTasksRequestSchema,"tasks/cancel":a.CancelTaskRequestSchema,"sampling/createMessage":a.CreateMessageRequestSchema,"elicitation/create":a.ElicitRequestSchema,"roots/list":a.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":a.CancelledNotificationSchema,"notifications/progress":a.ProgressNotificationSchema,"notifications/initialized":a.InitializedNotificationSchema,"notifications/roots/list_changed":a.RootsListChangedNotificationSchema,"notifications/tasks/status":a.TaskStatusNotificationSchema,"notifications/message":a.LoggingMessageNotificationSchema,"notifications/resources/updated":a.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":a.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":a.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":a.PromptListChangedNotificationSchema,"notifications/elicitation/complete":a.ElicitationCompleteNotificationSchema},resultSchemas:{ping:a.EmptyResultSchema,initialize:a.InitializeResultSchema,"completion/complete":a.CompleteResultSchema,"logging/setLevel":a.EmptyResultSchema,"prompts/get":a.GetPromptResultSchema,"prompts/list":a.ListPromptsResultSchema,"resources/list":a.ListResourcesResultSchema,"resources/templates/list":a.ListResourceTemplatesResultSchema,"resources/read":a.ReadResourceResultSchema,"resources/subscribe":a.EmptyResultSchema,"resources/unsubscribe":a.EmptyResultSchema,"tools/call":a.CallToolResultWireSchema,"tools/list":a.ListToolsResultSchema,"sampling/createMessage":a.CreateMessageResultWithToolsSchema,"elicitation/create":a.ElicitResultSchema,"roots/list":a.ListRootsResultSchema}}}function dd(a){return Object.prototype.hasOwnProperty.call(c9,a)}function de(a){return Object.prototype.hasOwnProperty.call(da,a)}function df(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function dg(a,b){if(void 0===a)return{ok:!1,reason:"not-in-era"};let c=a.safeParse(b);return c.success?{ok:!0,value:c.data}:{ok:!1,reason:"invalid",message:String(c.error)}}Object.keys(c9),Object.keys(da);let dh={ok:!1,reason:"not-in-era"};function di(a){return df(a)&&df(a.outputSchema)&&c5(a.outputSchema)}let dj={era:"2025-11-25",hasRequestMethod:dd,hasNotificationMethod:de,validateRequest:(a,b)=>dg(dd(a)?dc().requestSchemas[a]:void 0,b),validateResult:(a,b)=>dg(Object.prototype.hasOwnProperty.call(db,a)?dc().resultSchemas[a]:void 0,b),validateNotification:(a,b)=>dg(de(a)?dc().notificationSchemas[a]:void 0,b),hasInputRequestMethod:()=>!1,validateInputRequest:()=>dh,validateInputResponse:()=>dh,samplingResultVariant:(a,b)=>{let c=c4();return dg(a?c.CreateMessageResultWithToolsSchema:c.CreateMessageResultSchema,b)},outboundEnvelope:a=>void 0,validateEnvelopeMeta:a=>[],projectCallToolResult(a,b){let c=c1(a),d=c.structuredContent;if(void 0===d)return c;let e="object"!=typeof d||null===d||Array.isArray(d),f=void 0!==b&&c5(b);return e||f?{...c,structuredContent:{result:d}}:c},decodeResult(a,b){if(df(b)&&"resultType"in b){let a={...b};return delete a.resultType,{kind:"complete",result:a}}return{kind:"complete",result:b}},encodeResult(a,b){if("tools/list"!==a)return b;let c=b.tools;return Array.isArray(c)&&c.some(a=>di(a))?{...b,tools:c.map(a=>di(a)?{...a,outputSchema:function(a){var b;let c="string"==typeof a.$schema?a.$schema:void 0;if(c8(a.$id))return{...void 0!==c&&{$schema:c},type:"object",properties:{result:a},required:["result"]};let d="string"==typeof(b=a.$schema)&&B.has(b.replace(/#$/,""))&&!0!==a.$recursiveAnchor,e=(a,b)=>{if(Array.isArray(a))return a.map(a=>e(a,!1));if(null===a||"object"!=typeof a||!b&&c8(a.$id))return a;let c={},f=!1;for(let[g,h]of Object.entries(a))b?c[g]=e(h,!1):("$ref"===g||"$dynamicRef"===g)&&"string"==typeof h?c[g]="#"===h?"#/properties/result":h.startsWith("#/")?`#/properties/result${h.slice(1)}`:h:"$recursiveRef"===g&&"#"===h&&d?f=!0:c6.has(g)?c[g]=h:c7.has(g)?c[g]=e(h,!0):c[g]=e(h,!1);return f&&("$ref"in c?c.allOf=[...Array.isArray(c.allOf)?c.allOf:[],{$ref:"#/properties/result"}]:c.$ref="#/properties/result"),c};return{...void 0!==c&&{$schema:c},type:"object",properties:{result:e(a,!1)},required:["result"]}}(a.outputSchema)}:a)}:b},encodeErrorCode:a=>-32002===a?-32602:a,checkInboundEnvelope:a=>void 0};function dk(){return f??=function(){let a=E.RZ(()=>E.KC([E.Yj(),E.ai(),E.zM(),E.ch(),E.g1(E.Yj(),a),E.YO(a)])),b=E.g1(E.Yj(),a),c=E.KC([E.Yj(),E.ai().int()]),d=E.Yj(),e=E.KC([E.Yj(),E.ai().int()]),f=E.k5(["user","assistant"]),g=E.k5(["debug","info","notice","warning","error","critical","alert","emergency"]),h=E.Yj().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),i=E.Ik({ttl:E.ai().optional()}),j=E.Ik({taskId:E.Yj()}),k=E._H({progressToken:c.optional(),"io.modelcontextprotocol/related-task":j.optional()}),l=E.Ik({_meta:k.optional()}),m=l.extend({task:i.optional()}),n=E.Ik({_meta:k.optional()}),o=E.Ik({method:E.Yj(),params:n.loose().optional()}),p=E.Ik({src:E.Yj(),mimeType:E.Yj().optional(),sizes:E.YO(E.Yj()).optional(),theme:E.k5(["light","dark"]).optional()}),q=E.Ik({icons:E.YO(p).optional()}),r=E.Ik({name:E.Yj(),title:E.Yj().optional()}),s=r.extend({...r.shape,...q.shape,version:E.Yj(),websiteUrl:E.Yj().optional(),description:E.Yj().optional()}),t=E.E$(E.Ik({applyDefaults:E.zM().optional()}),b),u=E.vk(a=>a&&"object"==typeof a&&!Array.isArray(a)&&0===Object.keys(a).length?{form:{}}:a,E.E$(E.Ik({form:t.optional(),url:b.optional()}),b.optional())),v=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({sampling:E._H({createMessage:b.optional()}).optional(),elicitation:E._H({create:b.optional()}).optional()}).optional()}),w=E._H({list:b.optional(),cancel:b.optional(),requests:E._H({tools:E._H({call:b.optional()}).optional()}).optional()}),x=E.Ik({experimental:E.g1(E.Yj(),b).optional(),sampling:E.Ik({context:b.optional(),tools:b.optional()}).optional(),elicitation:u.optional(),roots:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:v.optional(),extensions:E.g1(E.Yj(),b).optional()}),y=E.Ik({experimental:E.g1(E.Yj(),b).optional(),logging:b.optional(),completions:b.optional(),prompts:E.Ik({listChanged:E.zM().optional()}).optional(),resources:E.Ik({subscribe:E.zM().optional(),listChanged:E.zM().optional()}).optional(),tools:E.Ik({listChanged:E.zM().optional()}).optional(),tasks:w.optional(),extensions:E.g1(E.Yj(),b).optional()}),z=E.Ik({progress:E.ai(),total:E.lq(E.ai()),message:E.lq(E.Yj())}),A=E.Ik({...n.shape,...z.shape,progressToken:c}),B=o.extend({method:E.eu("notifications/progress"),params:A}),C=n.extend({level:g,logger:E.Yj().optional(),data:E.L5()}),D=o.extend({method:E.eu("notifications/message"),params:C}),G=E.Ik({uri:E.Yj(),mimeType:E.lq(E.Yj()),_meta:E.g1(E.Yj(),E.L5()).optional()}),H=G.extend({text:E.Yj()}),I=G.extend({blob:h}),J=E.Ik({audience:E.YO(f).optional(),priority:E.ai().min(0).max(1).optional(),lastModified:F.w$({offset:!0}).optional()}),O=E.Ik({...r.shape,...q.shape,uri:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),size:E.lq(E.ai()),annotations:J.optional(),_meta:E.lq(E._H({}))}),Q=E.Ik({...r.shape,...q.shape,uriTemplate:E.Yj(),description:E.lq(E.Yj()),mimeType:E.lq(E.Yj()),annotations:J.optional(),_meta:E.lq(E._H({}))}),R=o.extend({method:E.eu("notifications/resources/list_changed"),params:n.optional()}),S=n.extend({uri:E.Yj()}),T=o.extend({method:E.eu("notifications/resources/updated"),params:S}),U=E.Ik({name:E.Yj(),description:E.lq(E.Yj()),required:E.lq(E.zM())}),V=E.Ik({...r.shape,...q.shape,description:E.lq(E.Yj()),arguments:E.lq(E.YO(U)),_meta:E.lq(E._H({}))}),W=o.extend({method:E.eu("notifications/prompts/list_changed"),params:n.optional()}),X=E.Ik({type:E.eu("text"),text:E.Yj(),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),Y=E.Ik({type:E.eu("image"),data:h,mimeType:E.Yj(),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),Z=E.Ik({type:E.eu("audio"),data:h,mimeType:E.Yj(),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),$=E.Ik({type:E.eu("tool_use"),name:E.Yj(),id:E.Yj(),input:E.g1(E.Yj(),E.L5()),_meta:E.g1(E.Yj(),E.L5()).optional()}),_=E.Ik({type:E.eu("resource"),resource:E.KC([H,I]),annotations:J.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aa=O.extend({type:E.eu("resource_link")}),ab=E.KC([X,Y,Z,aa,_]),ac=E.Ik({role:f,content:ab}),ad=E.Ik({title:E.Yj().optional(),readOnlyHint:E.zM().optional(),destructiveHint:E.zM().optional(),idempotentHint:E.zM().optional(),openWorldHint:E.zM().optional()}),ae=o.extend({method:E.eu("notifications/tools/list_changed"),params:n.optional()}),af=E.Ik({name:E.Yj().optional()}),ag=E.Ik({hints:E.YO(af).optional(),costPriority:E.ai().min(0).max(1).optional(),speedPriority:E.ai().min(0).max(1).optional(),intelligencePriority:E.ai().min(0).max(1).optional()}),ah=E.Ik({mode:E.k5(["auto","required","none"]).optional()}),ai=E.Ik({type:E.eu("boolean"),title:E.Yj().optional(),description:E.Yj().optional(),default:E.zM().optional()}),aj=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),minLength:E.ai().optional(),maxLength:E.ai().optional(),format:E.k5(["email","uri","date","date-time"]).optional(),default:E.Yj().optional()}),ak=E.Ik({type:E.k5(["number","integer"]),title:E.Yj().optional(),description:E.Yj().optional(),minimum:E.ai().optional(),maximum:E.ai().optional(),default:E.ai().optional()}),al=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),default:E.Yj().optional()}),am=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),oneOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()})),default:E.Yj().optional()}),an=E.Ik({type:E.eu("string"),title:E.Yj().optional(),description:E.Yj().optional(),enum:E.YO(E.Yj()),enumNames:E.YO(E.Yj()).optional(),default:E.Yj().optional()}),ao=E.KC([al,am]),ap=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({type:E.eu("string"),enum:E.YO(E.Yj())}),default:E.YO(E.Yj()).optional()}),aq=E.Ik({type:E.eu("array"),title:E.Yj().optional(),description:E.Yj().optional(),minItems:E.ai().optional(),maxItems:E.ai().optional(),items:E.Ik({anyOf:E.YO(E.Ik({const:E.Yj(),title:E.Yj()}))}),default:E.YO(E.Yj()).optional()}),ar=E.KC([ap,aq]),as=E.KC([an,ao,ar]),at=E.KC([as,ai,aj,ak]),au=m.extend({mode:E.eu("form").optional(),message:E.Yj(),requestedSchema:E.Ik({type:E.eu("object"),properties:E.g1(E.Yj(),at),required:E.YO(E.Yj()).optional()}).catchall(E.L5())}),av=E.Ik({type:E.eu("ref/resource"),uri:E.Yj()}),aw=E.Ik({type:E.eu("ref/prompt"),name:E.Yj()}),ax=E.Ik({uri:E.Yj().startsWith("file://"),name:E.Yj().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),ay=x.shape,az=E.Ik({experimental:ay.experimental,sampling:ay.sampling,elicitation:ay.elicitation,roots:ay.roots,extensions:ay.extensions}),aA=y.shape,aB=E.Ik({experimental:aA.experimental,logging:aA.logging,completions:aA.completions,prompts:aA.prompts,resources:aA.resources,tools:aA.tools,extensions:aA.extensions}),aC=E._H({progressToken:c.optional(),[K]:E.Yj(),[L]:s.optional(),[N]:az,[P]:g.optional()}),aD=E.Ik({...r.shape,...q.shape,description:E.Yj().optional(),inputSchema:E._H({$schema:E.Yj().optional(),type:E.eu("object")}),outputSchema:E._H({$schema:E.Yj().optional()}).optional(),annotations:ad.optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aE=E.Ik({type:E.eu("tool_result"),toolUseId:E.Yj(),content:E.YO(ab),structuredContent:E.L5().optional(),isError:E.zM().optional(),_meta:E.g1(E.Yj(),E.L5()).optional()}),aF=E.KC([X,Y,Z,$,aE]),aG=E.Ik({role:f,content:E.KC([aF,E.YO(aF)]),_meta:E.g1(E.Yj(),E.L5()).optional()}),aH=E.Yj(),aI=E._H({[M]:s.optional().catch(void 0)}),aJ=aI.optional();function aK(a){return E._H({_meta:aJ,resultType:aH.default("complete"),...a})}let aL=aK({}),aM=aK({nextCursor:d.optional()}),aN=aK({content:E.YO(ab),structuredContent:E.L5().optional(),isError:E.zM().optional()}),aO=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),tools:E.YO(aD),nextCursor:d.optional()}),aP=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),prompts:E.YO(V),nextCursor:d.optional()}),aQ=aK({description:E.Yj().optional(),messages:E.YO(ac)}),aR=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resources:E.YO(O),nextCursor:d.optional()}),aS=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resourceTemplates:E.YO(Q),nextCursor:d.optional()}),aT=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),contents:E.YO(E.KC([H,I]))}),aU=aK({completion:E.Ik({values:E.YO(E.Yj()).max(100),total:E.ai().int().optional(),hasMore:E.zM().optional()}).loose()}),aV=aK({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"])}),aW=aK({ttlMs:E.ai().int().min(0).catch(0),cacheScope:E.k5(["public","private"]).catch("private"),supportedVersions:E.YO(E.Yj()),capabilities:aB,instructions:E.Yj().optional()}),aX=E.Ik({messages:E.YO(aG),modelPreferences:ag.optional(),systemPrompt:E.Yj().optional(),includeContext:E.k5(["none","thisServer","allServers"]).optional(),temperature:E.ai().optional(),maxTokens:E.ai().int(),stopSequences:E.YO(E.Yj()).optional(),metadata:b.optional(),tools:E.YO(aD).optional(),toolChoice:ah.optional()}),aY=E.Ik({method:E.eu("sampling/createMessage"),params:aX}),aZ=E.Ik({method:E.eu("roots/list"),params:E.Ik({_meta:E.g1(E.Yj(),E.L5()).optional()}).optional()}),a$=E.Ik({...aG.shape,model:E.Yj(),stopReason:E.Yj().optional()}),a_=E.Ik({roots:E.YO(ax)}),a0=E.Ik({action:E.k5(["accept","decline","cancel"]),content:E.g1(E.Yj(),E.KC([E.Yj(),E.ai(),E.zM(),E.YO(E.Yj())])).optional()}),a1=E.Ik({mode:E.eu("url"),message:E.Yj(),url:E.Yj().url()}),a2=E.KC([au,a1]),a3=E.Ik({method:E.eu("elicitation/create"),params:a2}),a4=E.KC([aY,aZ,a3]),a5=E.KC([a$,a_,a0]),a6=E.g1(E.Yj(),a4),a7=E.g1(E.Yj(),a5),a8=aK({inputRequests:a6.optional(),requestState:E.Yj().optional()}),a9={inputResponses:a7.optional(),requestState:E.Yj().optional()},ba=E.Ik({_meta:aC,...a9}),bb=E._H({progressToken:c.optional()});function bc(a,b){return E.Ik({method:E.eu(a),params:E.Ik({_meta:aC,...b})})}function bd(a,b){return E.Ik({method:E.eu(a),params:E.Ik({_meta:bb.optional(),...b}).optional()})}let be={name:E.Yj(),arguments:E.g1(E.Yj(),E.L5()).optional(),...a9},bf={cursor:d.optional()},bg=bc("tools/call",be),bh=bc("tools/list",bf),bi=bc("prompts/list",bf),bj=bc("prompts/get",{name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional(),...a9}),bk=bc("resources/list",bf),bl=bc("resources/templates/list",bf),bm=bc("resources/read",{uri:E.Yj(),...a9}),bn={ref:E.KC([aw,av]),argument:E.Ik({name:E.Yj(),value:E.Yj()}),context:E.Ik({arguments:E.g1(E.Yj(),E.Yj()).optional()}).optional()},bo=bc("completion/complete",bn),bp=bc("server/discover",{}),bq=E.Ik({toolsListChanged:E.zM().optional(),promptsListChanged:E.zM().optional(),resourcesListChanged:E.zM().optional(),resourceSubscriptions:E.YO(E.Yj()).optional()}),br={notifications:bq},bs=bc("subscriptions/listen",br),bt=aI.extend({"io.modelcontextprotocol/subscriptionId":e}),bu=E._H({_meta:bt,resultType:aH.default("complete")}),bv={"tools/call":bd("tools/call",be),"tools/list":bd("tools/list",bf),"prompts/get":bd("prompts/get",{name:E.Yj(),arguments:E.g1(E.Yj(),E.Yj()).optional()}),"prompts/list":bd("prompts/list",bf),"resources/list":bd("resources/list",bf),"resources/templates/list":bd("resources/templates/list",bf),"resources/read":bd("resources/read",{uri:E.Yj()}),"completion/complete":bd("completion/complete",bn),"server/discover":bd("server/discover",{}),"subscriptions/listen":bd("subscriptions/listen",br)};function bw(a){return E._H({_meta:aJ,...a})}let bx={"tools/call":bw({content:E.YO(ab),structuredContent:E.L5().optional(),isError:E.zM().optional()}),"tools/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),tools:E.YO(aD),nextCursor:d.optional()}),"prompts/get":bw({description:E.Yj().optional(),messages:E.YO(ac)}),"prompts/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),prompts:E.YO(V),nextCursor:d.optional()}),"resources/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resources:E.YO(O),nextCursor:d.optional()}),"resources/templates/list":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),resourceTemplates:E.YO(Q),nextCursor:d.optional()}),"resources/read":bw({ttlMs:E.ai().int().min(0),cacheScope:E.k5(["public","private"]),contents:E.YO(E.KC([H,I]))}),"completion/complete":bw({completion:E.Ik({values:E.YO(E.Yj()).max(100),total:E.ai().int().optional(),hasMore:E.zM().optional()}).loose()}),"server/discover":bw({ttlMs:E.ai().int().min(0).catch(0),cacheScope:E.k5(["public","private"]).catch("private"),supportedVersions:E.YO(E.Yj()),capabilities:aB,instructions:E.Yj().optional()}),"subscriptions/listen":bw({})},by=E._H({"io.modelcontextprotocol/subscriptionId":e.optional()}),bz=E.Ik({method:E.eu("notifications/subscriptions/acknowledged"),params:E.Ik({_meta:by.optional(),notifications:bq})}),bA=E.Ik({_meta:by.optional(),requestId:e,reason:E.Yj().optional()}),bB=E.Ik({method:E.eu("notifications/cancelled"),params:bA}),bC=a=>E.Ik({jsonrpc:E.eu("2.0"),id:E.KC([E.Yj(),E.ai().int()]),result:a}).strict();return{JSONValueSchema:a,JSONObjectSchema:b,ProgressTokenSchema:c,CursorSchema:d,RequestIdSchema:e,RoleSchema:f,LoggingLevelSchema:g,TaskMetadataSchema:i,RelatedTaskMetadataSchema:j,RequestMetaSchema:k,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:m,NotificationsParamsSchema:n,NotificationSchema:o,IconSchema:p,IconsSchema:q,BaseMetadataSchema:r,ImplementationSchema:s,ClientTasksCapabilitySchema:v,ServerTasksCapabilitySchema:w,ClientCapabilitiesSchema:x,ServerCapabilitiesSchema:y,ProgressSchema:z,ProgressNotificationParamsSchema:A,ProgressNotificationSchema:B,LoggingMessageNotificationParamsSchema:C,LoggingMessageNotificationSchema:D,ResourceContentsSchema:G,TextResourceContentsSchema:H,BlobResourceContentsSchema:I,AnnotationsSchema:J,ResourceSchema:O,ResourceTemplateSchema:Q,ResourceListChangedNotificationSchema:R,ResourceUpdatedNotificationParamsSchema:S,ResourceUpdatedNotificationSchema:T,PromptArgumentSchema:U,PromptSchema:V,PromptListChangedNotificationSchema:W,TextContentSchema:X,ImageContentSchema:Y,AudioContentSchema:Z,ToolUseContentSchema:$,EmbeddedResourceSchema:_,ResourceLinkSchema:aa,ContentBlockSchema:ab,PromptMessageSchema:ac,ToolAnnotationsSchema:ad,ToolListChangedNotificationSchema:ae,ModelHintSchema:af,ModelPreferencesSchema:ag,ToolChoiceSchema:ah,BooleanSchemaSchema:ai,StringSchemaSchema:aj,NumberSchemaSchema:ak,UntitledSingleSelectEnumSchemaSchema:al,TitledSingleSelectEnumSchemaSchema:am,LegacyTitledEnumSchemaSchema:an,SingleSelectEnumSchemaSchema:ao,UntitledMultiSelectEnumSchemaSchema:ap,TitledMultiSelectEnumSchemaSchema:aq,MultiSelectEnumSchemaSchema:ar,EnumSchemaSchema:as,PrimitiveSchemaDefinitionSchema:at,ElicitRequestFormParamsSchema:au,ResourceTemplateReferenceSchema:av,PromptReferenceSchema:aw,RootSchema:ax,ClientCapabilities2026Schema:az,ServerCapabilities2026Schema:aB,RequestMetaEnvelopeSchema:aC,ToolSchema:aD,ToolResultContentSchema:aE,SamplingMessageContentBlockSchema:aF,SamplingMessageSchema:aG,ResultTypeSchema:aH,ResultMetaSchema:aI,ResultSchema:aL,PaginatedResultSchema:aM,CallToolResultSchema:aN,ListToolsResultSchema:aO,ListPromptsResultSchema:aP,GetPromptResultSchema:aQ,ListResourcesResultSchema:aR,ListResourceTemplatesResultSchema:aS,ReadResourceResultSchema:aT,CompleteResultSchema:aU,CacheableResultSchema:aV,DiscoverResultSchema:aW,CreateMessageRequestParamsSchema:aX,CreateMessageRequestSchema:aY,ListRootsRequestSchema:aZ,CreateMessageResultSchema:a$,ListRootsResultSchema:a_,ElicitResultSchema:a0,ElicitRequestURLParamsSchema:a1,ElicitRequestParamsSchema:a2,ElicitRequestSchema:a3,InputRequestSchema:a4,InputResponseSchema:a5,InputRequestsSchema:a6,InputResponsesSchema:a7,InputRequiredResultSchema:a8,InputResponseRequestParamsSchema:ba,CallToolRequestSchema:bg,ListToolsRequestSchema:bh,ListPromptsRequestSchema:bi,GetPromptRequestSchema:bj,ListResourcesRequestSchema:bk,ListResourceTemplatesRequestSchema:bl,ReadResourceRequestSchema:bm,CompleteRequestSchema:bo,DiscoverRequestSchema:bp,SubscriptionFilterSchema:bq,SubscriptionsListenRequestSchema:bs,SubscriptionsListenResultMetaSchema:bt,SubscriptionsListenResultSchema:bu,dispatchRequestSchemas:bv,dispatchResultSchemas:bx,NotificationMetaSchema:by,SubscriptionsAcknowledgedNotificationSchema:bz,CancelledNotificationParamsSchema:bA,CancelledNotificationSchema:bB,notificationSchemas2026:{"notifications/cancelled":bB,"notifications/progress":B,"notifications/message":D,"notifications/resources/updated":T,"notifications/resources/list_changed":R,"notifications/tools/list_changed":ae,"notifications/prompts/list_changed":W,"notifications/subscriptions/acknowledged":bz},JSONRPCResultResponseSchema:bC(aL),CallToolResultResponseSchema:bC(E.KC([aN,a8])),ListToolsResultResponseSchema:bC(aO),ListPromptsResultResponseSchema:bC(aP),GetPromptResultResponseSchema:bC(E.KC([aQ,a8])),ListResourcesResultResponseSchema:bC(aR),ListResourceTemplatesResultResponseSchema:bC(aS),ReadResourceResultResponseSchema:bC(E.KC([aT,a8])),CompleteResultResponseSchema:bC(aU),DiscoverResultResponseSchema:bC(aW)}}()}let dl=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],dm=Symbol("modelcontextprotocol.resultCacheHintFallback");function dn(a,b){if(void 0===b)return a;let c=a[dm];if(void 0===c)return{...a,[dm]:b};let d={},e=c.ttlMs??b.ttlMs;void 0!==e&&(d.ttlMs=e);let f=c.cacheScope??b.cacheScope;return void 0!==f&&(d.cacheScope=f),{...a,[dm]:d}}function dp(a){return"number"==typeof a&&Number.isSafeInteger(a)&&a>=0}function dq(a){return"public"===a||"private"===a}function dr(a,b){if(void 0!==a.ttlMs&&!dp(a.ttlMs))throw RangeError(`Invalid cache hint for ${b}: ttlMs must be a non-negative safe integer (got ${String(a.ttlMs)})`);if(void 0!==a.cacheScope&&!dq(a.cacheScope))throw RangeError(`Invalid cache hint for ${b}: cacheScope must be 'public' or 'private' (got ${String(a.cacheScope)})`)}let ds=((p={})[p.ParseError=-32700]="ParseError",p[p.InvalidRequest=-32600]="InvalidRequest",p[p.MethodNotFound=-32601]="MethodNotFound",p[p.InvalidParams=-32602]="InvalidParams",p[p.InternalError=-32603]="InternalError",p[p.ResourceNotFound=-32002]="ResourceNotFound",p[p.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",p[p.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",p[p.UrlElicitationRequired=-32042]="UrlElicitationRequired",p);var dt=class a extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](a){return cS(this,a)}static isInstance(a){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return cS(this,a)}constructor(a,b,c){super(b),this.code=a,this.data=c,this.name="ProtocolError",cR(this,new.target)}static fromError(b,c,d){return b===ds.UrlElicitationRequired&&d&&d.elicitations?new dv(d.elicitations,c):b===ds.UnsupportedProtocolVersion&&d&&Array.isArray(d.supported)&&"string"==typeof d.requested?new dw({supported:d.supported,requested:d.requested},c):(b===ds.InvalidParams||b===ds.ResourceNotFound)&&"string"==typeof d?.uri&&(b===ds.ResourceNotFound||1===Object.keys(d).length)?new du(d.uri,c):b===ds.MissingRequiredClientCapability&&d&&null!==d.requiredCapabilities&&"object"==typeof d.requiredCapabilities&&!Array.isArray(d.requiredCapabilities)?new dx({requiredCapabilities:d.requiredCapabilities},c):new a(b,c,d)}},du=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(a,b=`Resource not found: ${a}`){super(ds.InvalidParams,b,{uri:a})}get uri(){return this.data.uri}},dv=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(a,b=`URL elicitation${a.length>1?"s":""} required`){super(ds.UrlElicitationRequired,b,{elicitations:a})}get elicitations(){return this.data?.elicitations??[]}},dw=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(a,b=`Unsupported protocol version: ${a.requested}`){super(ds.UnsupportedProtocolVersion,b,a)}get supported(){return this.data.supported}get requested(){return this.data.requested}},dx=class extends dt{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(a,b=`Missing required client capabilities: ${Object.keys(a.requiredCapabilities).join(", ")}`){super(ds.MissingRequiredClientCapability,b,a)}get requiredCapabilities(){return this.data.requiredCapabilities}};let dy=["tools/call","prompts/get","resources/read"],dz=["elicitation/create","sampling/createMessage","roots/list"];function dA(){if(g)return g;let a=dk();return g={request:{"elicitation/create":E.Ik({method:E.eu("elicitation/create"),params:a.ElicitRequestParamsSchema}),"sampling/createMessage":E.Ik({method:E.eu("sampling/createMessage"),params:a.CreateMessageRequestParamsSchema}),"roots/list":E.Ik({method:E.eu("roots/list"),params:E._H({}).optional()})},response:{"elicitation/create":a.ElicitResultSchema,"sampling/createMessage":a.CreateMessageResultSchema,"roots/list":a.ListRootsResultSchema}}}function dB(a){return dz.includes(a)}function dC(a){return dB(a)?dA().request[a]:void 0}let dD={"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},dE={"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 dF(a){return Object.prototype.hasOwnProperty.call(dD,a)}function dG(a){return Object.prototype.hasOwnProperty.call(dE,a)}function dH(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function dI(a,b){if(void 0===a)return{ok:!1,reason:"not-in-era"};let c=a.safeParse(b);return c.success?{ok:!0,value:c.data}:{ok:!1,reason:"invalid",message:String(c.error)}}Object.keys(dD),Object.keys(dE);let dJ={ok:!1,reason:"not-in-era"},dK=[K,N],dL={era:"2026-07-28",hasRequestMethod:dF,hasNotificationMethod:dG,hasInputRequestMethod:a=>void 0!==dC(a),validateRequest:(a,b)=>dI(dF(a)?dk().dispatchRequestSchemas[a]:void 0,b),validateResult:(a,b)=>dI(Object.prototype.hasOwnProperty.call(dD,a)?dk().dispatchResultSchemas[a]:void 0,b),validateNotification:(a,b)=>dI(dG(a)?dk().notificationSchemas2026[a]:void 0,b),validateInputRequest:(a,b)=>dI(dC(a),b),validateInputResponse:(a,b)=>dI(dB(a)?dA().response[a]:void 0,b),samplingResultVariant:()=>dJ,outboundEnvelope:a=>({[K]:a.protocolVersion,[L]:a.clientInfo,[N]:a.clientCapabilities,...void 0!==a.logLevel&&{[P]:a.logLevel}}),validateEnvelopeMeta(a){let b=[];for(let c of dK)c in a||b.push({key:c,problem:"missing"});let c=dk().RequestMetaEnvelopeSchema.safeParse(a);if(!c.success)for(let a of c.error.issues){let c=a.path.map(String),d=c.length>0?c.join("."):"_meta";1===c.length&&b.some(a=>a.key===d&&"missing"===a.problem)||b.push({key:d,problem:a.message})}return b},projectCallToolResult:a=>c1(a),inputRequestSchema:dC,decodeResult(a,b){if(!dH(b))return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: not an object`,{method:a})};let c=b.resultType;if(void 0===c)return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: 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:a,violation:"missing-resultType"})};if("string"!=typeof c)return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: non-string resultType`,{method:a,resultType:c})};if("input_required"===c){let c=b.inputRequests,d=dH(c)?c:{},e=b.requestState;return 0===Object.keys(d).length&&"string"!=typeof e?{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:a,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:d,..."string"==typeof e&&{requestState:e}}}if("complete"!==c)return{kind:"invalid",error:new cW(cV.UnsupportedResultType,`Unsupported result type '${c}' for ${a}`,{resultType:c,method:a})};let d=function(){if(h)return h;let a=dk();return h={"tools/call":a.CallToolResultSchema,"tools/list":a.ListToolsResultSchema,"prompts/get":a.GetPromptResultSchema,"prompts/list":a.ListPromptsResultSchema,"resources/list":a.ListResourcesResultSchema,"resources/templates/list":a.ListResourceTemplatesResultSchema,"resources/read":a.ReadResourceResultSchema,"completion/complete":a.CompleteResultSchema,"server/discover":a.DiscoverResultSchema}}(),e=Object.hasOwn(d,a)?d[a]:void 0;if(void 0!==e){let c=e.safeParse(b);if(!c.success)return{kind:"invalid",error:new cW(cV.InvalidResult,`Invalid result for ${a}: ${c.error}`,{method:a})}}let f={...b};return delete f.resultType,{kind:"complete",result:f}},encodeResult:(a,b,c)=>(function(a,b){if(void 0===b)return a;let c=a._meta;return void 0===c?{...a,_meta:{[M]:b}}:null===c||"object"!=typeof c||Array.isArray(c)||void 0!==c[M]?a:{...a,_meta:{...c,[M]:b}}})(function(a,b){var c,d;let e=b[dm];if("complete"!==b.resultType||!dl.includes(a)){let a;return void 0===e?b:(a={...b},delete a[dm],a)}let f=dp(b.ttlMs)?b.ttlMs:void 0!==(c=e)&&dp(c.ttlMs)?c.ttlMs:0,g=dq(b.cacheScope)?b.cacheScope:void 0!==(d=e)&&dq(d.cacheScope)?d.cacheScope:"private",h={...b,ttlMs:f,cacheScope:g};return delete h[dm],h}(a,function(a,b){let c=b.resultType;if(void 0===c)return{...b,resultType:"complete"};if("complete"===c||dy.includes(a))return b;throw new dt(ds.InternalError,`Handler for ${a} returned resultType '${String(c)}', but results of ${a} only support 'complete' on protocol revision 2026-07-28`)}(a,function(a,b){let c=b,d=!1,e=()=>(d||(c={...c},d=!0),c),f=b.tools;"tools/list"===a&&Array.isArray(f)&&f.some(a=>dH(a)&&"execution"in a)&&(e().tools=f.map(a=>{if(!dH(a)||!("execution"in a))return a;let b={...a};return delete b.execution,b}));let g=b.capabilities;if(dH(g)&&"tasks"in g){let a={...g};delete a.tasks,e().capabilities=a}return c}(a,b))),c),encodeErrorCode:a=>-32002===a?-32602:a,checkInboundEnvelope(a){if(void 0===a.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let b=dk().RequestMetaEnvelopeSchema.safeParse(a.envelope);if(!b.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${b.error.issues.map(a=>a.message).join("; ")}`}},dM="2026-07-28";function dN(a){return void 0!==a&&a>=c$?dL:dj}function dO(a){return void 0!==a.revision?dN(a.revision).era:"modern"===a.era?dL.era:dj.era}function dP(a){return dR.some(b=>b.hasRequestMethod(a))}function dQ(a){return dR.some(b=>b.hasNotificationMethod(a))}let dR=[dj,dL];function dS(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function dT(a){if(!dS(a))return;let b=a._meta;return dS(b)?b:void 0}function dU(a){let b=dT(a);return void 0!==b&&K in b}function dV(a){let b=dT(a)?.[K];return"string"==typeof b?b:void 0}function dW(a){return dN(dM).validateEnvelopeMeta(a)}var dX=(a=>{let b={};for(var c in a)t(b,c,{get:a[c],enumerable:!0});return b})({AnnotationsSchema:()=>aP,AudioContentSchema:()=>bh,BaseMetadataSchema:()=>ap,BaseRequestParamsSchema:()=>Y,BlobResourceContentsSchema:()=>aN,BooleanSchemaSchema:()=>bQ,CallToolRequestParamsSchema:()=>bw,CallToolRequestSchema:()=>bx,CallToolResultSchema:()=>bu,CancelTaskRequestSchema:()=>cs,CancelTaskResultSchema:()=>ct,CancelledNotificationParamsSchema:()=>al,CancelledNotificationSchema:()=>am,ClientCapabilitiesSchema:()=>av,ClientNotificationSchema:()=>cv,ClientRequestSchema:()=>cu,ClientResultSchema:()=>cw,ClientTasksCapabilitySchema:()=>at,CompatibilityCallToolResultSchema:()=>bv,CompleteRequestParamsSchema:()=>b9,CompleteRequestSchema:()=>ca,CompleteResultSchema:()=>cb,ContentBlockSchema:()=>bl,CreateMessageRequestParamsSchema:()=>bM,CreateMessageRequestSchema:()=>bN,CreateMessageResultSchema:()=>bO,CreateMessageResultWithToolsSchema:()=>bP,CreateTaskResultSchema:()=>cj,CursorSchema:()=>U,DiscoverRequestSchema:()=>aB,DiscoverResultSchema:()=>aC,ElicitRequestFormParamsSchema:()=>b0,ElicitRequestParamsSchema:()=>b2,ElicitRequestSchema:()=>b3,ElicitRequestURLParamsSchema:()=>b1,ElicitResultSchema:()=>b6,ElicitationCompleteNotificationParamsSchema:()=>b4,ElicitationCompleteNotificationSchema:()=>b5,EmbeddedResourceSchema:()=>bj,EmptyResultSchema:()=>ak,EnumSchemaSchema:()=>b$,GetPromptRequestParamsSchema:()=>bd,GetPromptRequestSchema:()=>be,GetPromptResultSchema:()=>bn,GetTaskPayloadRequestSchema:()=>co,GetTaskPayloadResultSchema:()=>cp,GetTaskRequestSchema:()=>cm,GetTaskResultSchema:()=>cn,IconSchema:()=>an,IconsSchema:()=>ao,ImageContentSchema:()=>bg,ImplementationSchema:()=>aq,InitializeRequestParamsSchema:()=>aw,InitializeRequestSchema:()=>ax,InitializeResultSchema:()=>az,InitializedNotificationSchema:()=>aA,JSONArraySchema:()=>S,JSONObjectSchema:()=>R,JSONRPCErrorResponseSchema:()=>ah,JSONRPCMessageSchema:()=>ai,JSONRPCNotificationSchema:()=>af,JSONRPCRequestSchema:()=>ae,JSONRPCResponseSchema:()=>aj,JSONRPCResultResponseSchema:()=>ag,JSONValueSchema:()=>Q,LegacyTitledEnumSchemaSchema:()=>bV,ListChangedOptionsBaseSchema:()=>bz,ListPromptsRequestSchema:()=>bb,ListPromptsResultSchema:()=>bc,ListResourceTemplatesRequestSchema:()=>aU,ListResourceTemplatesResultSchema:()=>aV,ListResourcesRequestSchema:()=>aS,ListResourcesResultSchema:()=>aT,ListRootsRequestSchema:()=>cd,ListRootsResultSchema:()=>ce,ListTasksRequestSchema:()=>cq,ListTasksResultSchema:()=>cr,ListToolsRequestSchema:()=>bs,ListToolsResultSchema:()=>bt,LoggingLevelSchema:()=>bA,LoggingMessageNotificationParamsSchema:()=>bD,LoggingMessageNotificationSchema:()=>bE,ModelHintSchema:()=>bF,ModelPreferencesSchema:()=>bG,MultiSelectEnumSchemaSchema:()=>bZ,NotificationSchema:()=>aa,NotificationsParamsSchema:()=>_,NumberSchemaSchema:()=>bS,PaginatedRequestParamsSchema:()=>aH,PaginatedRequestSchema:()=>aI,PaginatedResultSchema:()=>aJ,PingRequestSchema:()=>aD,PrimitiveSchemaDefinitionSchema:()=>b_,ProgressNotificationParamsSchema:()=>aF,ProgressNotificationSchema:()=>aG,ProgressSchema:()=>aE,ProgressTokenSchema:()=>T,PromptArgumentSchema:()=>a9,PromptListChangedNotificationSchema:()=>bo,PromptMessageSchema:()=>bm,PromptReferenceSchema:()=>b8,PromptSchema:()=>ba,ReadResourceRequestParamsSchema:()=>aW,ReadResourceRequestSchema:()=>aX,ReadResourceResultSchema:()=>aY,RelatedTaskMetadataSchema:()=>W,RequestIdSchema:()=>ad,RequestMetaSchema:()=>X,RequestSchema:()=>$,ResourceContentsSchema:()=>aK,ResourceLinkSchema:()=>bk,ResourceListChangedNotificationSchema:()=>aZ,ResourceRequestParamsSchema:()=>aW,ResourceSchema:()=>aQ,ResourceTemplateReferenceSchema:()=>b7,ResourceTemplateSchema:()=>aR,ResourceUpdatedNotificationParamsSchema:()=>a7,ResourceUpdatedNotificationSchema:()=>a8,ResultMetaObjectSchema:()=>ab,ResultSchema:()=>ac,RoleSchema:()=>aO,RootSchema:()=>cc,RootsListChangedNotificationSchema:()=>cf,SamplingContentSchema:()=>bJ,SamplingMessageContentBlockSchema:()=>bK,SamplingMessageSchema:()=>bL,ServerCapabilitiesSchema:()=>ay,ServerNotificationSchema:()=>cy,ServerRequestSchema:()=>cx,ServerResultSchema:()=>cz,ServerTasksCapabilitySchema:()=>au,SetLevelRequestParamsSchema:()=>bB,SetLevelRequestSchema:()=>bC,SingleSelectEnumSchemaSchema:()=>bW,StringSchemaSchema:()=>bR,SubscribeRequestParamsSchema:()=>aW,SubscribeRequestSchema:()=>a$,SubscriptionFilterSchema:()=>a0,SubscriptionsAcknowledgedNotificationParamsSchema:()=>a3,SubscriptionsAcknowledgedNotificationSchema:()=>a4,SubscriptionsListenRequestParamsSchema:()=>a1,SubscriptionsListenRequestSchema:()=>a2,SubscriptionsListenResultMetaSchema:()=>a5,SubscriptionsListenResultSchema:()=>a6,TaskAugmentedRequestParamsSchema:()=>Z,TaskCreationParamsSchema:()=>cg,TaskMetadataSchema:()=>V,TaskSchema:()=>ci,TaskStatusNotificationParamsSchema:()=>ck,TaskStatusNotificationSchema:()=>cl,TaskStatusSchema:()=>ch,TextContentSchema:()=>bf,TextResourceContentsSchema:()=>aL,TitledMultiSelectEnumSchemaSchema:()=>bY,TitledSingleSelectEnumSchemaSchema:()=>bU,ToolAnnotationsSchema:()=>bp,ToolChoiceSchema:()=>bH,ToolExecutionSchema:()=>bq,ToolListChangedNotificationSchema:()=>by,ToolResultContentSchema:()=>bI,ToolSchema:()=>br,ToolUseContentSchema:()=>bi,UnsubscribeRequestParamsSchema:()=>aW,UnsubscribeRequestSchema:()=>a_,UntitledMultiSelectEnumSchemaSchema:()=>bX,UntitledSingleSelectEnumSchemaSchema:()=>bT});let dY=a=>ae.safeParse(a).success,dZ=a=>af.safeParse(a).success,d$=a=>ag.safeParse(a).success,d_=a=>ah.safeParse(a).success,d0=a=>"object"==typeof a&&null!==a&&!Array.isArray(a)&&"input_required"===a.resultType,d1="x-mcp-header",d2=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,d3=new Set(["string","integer","boolean","number"]);function d4(a){let b=[],c=new Map,d=(a,e,f)=>{if(null===a||"object"!=typeof a)return;if(d1 in a){if(!f||0===e.length)return`${d7(e)}: 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 d=a[d1];if("string"!=typeof d||0===d.length)return`${d7(e)}: x-mcp-header MUST be a non-empty string`;if(!d2.test(d))return`${d7(e)}: x-mcp-header '${d}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let g="string"==typeof a.type?a.type:void 0;if(void 0===g||!d3.has(g))return`${d7(e)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${g??"<none>"}`;let h=d.toLowerCase(),i=c.get(h);if(void 0!==i)return`x-mcp-header '${d}' is not case-insensitively unique (also declared as '${i}')`;c.set(h,d),b.push({path:e,headerName:d,type:g})}let g=a.properties;if(null!==g&&"object"==typeof g)for(let[a,b]of Object.entries(g)){let c=d(b,[...e,a],f);if(void 0!==c)return c}for(let b of d5){let c=a[b];if(void 0!==c)for(let a of Array.isArray(c)?c:null!==c&&"object"==typeof c&&d6.has(b)?Object.values(c):[c]){let c=d(a,[...e,`<${b}>`],!1);if(void 0!==c)return c}}},e=d(a,[],!0);return void 0===e?{valid:!0,declarations:b}:{valid:!1,reason:e}}let d5=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],d6=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function d7(a){return 0===a.length?"<root>":a.join(".")}let d8=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,d9=/^-?\d+(\.\d+)?$/;function ea(a){if(!(a.startsWith("=?base64?")&&a.endsWith("?=")))return a;let b=a.slice(9,a.length-2);if(d8.test(b))try{let a=atob(b),c=new Uint8Array(a.length);for(let b=0;b<a.length;b++)c[b]=a.codePointAt(b);return new TextDecoder("utf-8",{fatal:!0}).decode(c)}catch{return}}function eb(a,b,c){return{kind:"reject",rung:"param-header-validation",cell:a,httpStatus:400,code:ec,message:`Bad Request: the request headers and body disagree: ${c}`,data:{mismatch:{header:b,body:c}},settled:!0}}let ec=-32020;ds.InvalidRequest,ds.UnsupportedProtocolVersion,ds.InvalidParams,ds.MethodNotFound,ds.InvalidParams,ds.MissingRequiredClientCapability;let ed={[ds.ParseError]:400,[ds.InvalidRequest]:400,[ds.MethodNotFound]:404,[ds.UnsupportedProtocolVersion]:400,[ds.MissingRequiredClientCapability]:400,[ec]:400};function ee(a,b,c,d,e){return{kind:"reject",rung:a,cell:b,httpStatus:c,code:d.code,message:d.message,...void 0!==d.data&&{data:d.data},settled:e}}function ef(a,b,c,d="era-classification"){return ee(d,a,400,new dt(ec,`Bad Request: the request headers and body disagree: ${c}`,{mismatch:{header:b,body:c}}),!0)}let eg={"tools/call":"name","prompts/get":"name","resources/read":"uri"};function eh(a){let b=0;for(;b<a.length;){let c=a.codePointAt(b);if(9!==c&&32!==c)break;b+=1}let c=a.length;for(;c>b;){let b=a.codePointAt(c-1);if(9!==b&&32!==b)break;c-=1}return 0===b&&c===a.length?a:a.slice(b,c)}function ei(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function ej(a){return void 0===a?{era:"modern"}:{era:a>=c$?"modern":"legacy",revision:a}}function ek(a){return new Set(a.flatMap(a=>Object.keys(a.shape)))}function el(a){if(null==a)return!1;let b=typeof a;return("object"===b||"function"===b)&&"~standard"in a&&"function"==typeof a["~standard"]?.validate}let em=!1,en="draft-2020-12";function eo(a,b="input"){let c,d=a["~standard"];if(d.jsonSchema)c=d.jsonSchema[b]({target:en});else if("zod"===d.vendor){if(!("_zod"in a))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().");em||(em=!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.")),c=cP.bl(a,{target:en,io:b})}else throw Error(`Schema library "${d.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===b)return void 0!==c.type||!function a(b){if("properties"in b||"patternProperties"in b||"additionalProperties"in b||"required"in b)return!0;for(let c of["oneOf","anyOf","allOf"]){let d=b[c];if(Array.isArray(d)&&d.length>0)return d.every(b=>null!==b&&"object"==typeof b&&("object"===b.type||a(b)))}return!1}(c)?c:{type:"object",...c};if(void 0!==c.type&&"object"!==c.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(c.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...c}}async function ep(a,b){let c=await a["~standard"].validate(b);return c.issues&&c.issues.length>0?{success:!1,error:c.issues.map(a=>a.path?.length?`${a.path.map(a=>String("object"==typeof a?a.key:a)).join(".")}: ${a.message}`:a.message).join(", ")}:{success:!0,data:c.value}}let eq=/\\\.\\d\{(\d+)\}/;function er(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}let es=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function et(a){return es.has(a)||a.startsWith("x-")}let eu=new Set(["$schema",...Object.keys(b0.shape.requestedSchema.shape)]),ev={string:ek([bR,bT,bU,bV]),number:ek([bS]),integer:ek([bS]),boolean:ek([bQ]),array:ek([bX,bY])},ew=new Set(bR.shape.format.unwrap().options);Object.assign(function(a){let b=void 0!==a.inputRequests&&Object.keys(a.inputRequests).length>0,c="string"==typeof a.requestState;if(!b&&!c)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==a.inputRequests&&{inputRequests:a.inputRequests},...void 0!==a.requestState&&{requestState:a.requestState}}},{elicit(a){try{return{method:"elicitation/create",params:function(a){var b;if(!el(a.requestedSchema))return{...a,mode:"form",requestedSchema:a.requestedSchema};let c=a.requestedSchema["~standard"].vendor,d=function(a,b){let c={},d=[];for(let[e,f]of Object.entries(a))"properties"===e&&er(f)?c[e]=Object.fromEntries(Object.entries(f).map(([a,c])=>[a,function(a,b,c,d){if(!er(a))return a;let e="string"==typeof a.type&&Object.hasOwn(ev,a.type)?ev[a.type]:void 0;if(void 0===e)return a;let f={};for(let[h,i]of Object.entries(a))if(e.has(h)||et(h))f[h]=i;else if("pattern"===h&&"string"===a.type&&"string"==typeof a.format)if(ew.has(a.format)){var g;"string"==typeof i&&(g=a.format,"zod"!==c||(function(a,b){let c;switch(a){case"email":c=[E.Rp()];break;case"uri":c=[E.OZ()];break;case"date":c=[F.p6()];break;case"date-time":let d,e;d=eq.exec(b),e=[void 0,-1,0],d&&e.push(Number(d[1])),c=[!1,!0].flatMap(a=>[!1,!0].flatMap(b=>e.map(c=>F.w$({local:a,offset:b,precision:c}))))}return new Set(c.map(a=>{let b;return b=cP.bl(a,{target:en,io:"input"}),"string"==typeof b.pattern?b.pattern:void 0}).filter(a=>void 0!==a))})(g,i).has(i))||d.push(`${b}.${h}`)}else f[h]=i;else d.push(`${b}.${h}`);return f}(c,`properties.${a}`,b,d)])):eu.has(e)?c[e]=f:et(e)||d.push(e);if(d.length>0)throw new dt(ds.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${d.join(", ")}`);return c}(function(a){try{return eo(a,"input")}catch(b){let a=b instanceof Error?b.message:String(b);throw new dt(ds.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${a}`)}}(a.requestedSchema),c),e=(b=b0.shape.requestedSchema,cO.xL(b,d));if(!e.success)throw new dt(ds.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(a,b){if(!er(a.properties))return b;let c=Object.entries(a.properties).filter(([,a])=>!cO.xL(b_,a).success).map(([a])=>`properties.${a}`);return c.length>0?c.join(", "):b}(d,e.error.message)}`);let f=function a(b,c,d=""){return Array.isArray(b)&&Array.isArray(c)?b.flatMap((b,e)=>a(b,c[e],`${d}[${e}]`)):er(b)&&er(c)?Object.entries(b).flatMap(([b,e])=>{let f=d?`${d}.${b}`:b;return Object.prototype.hasOwnProperty.call(c,b)?a(e,c[b],f):et(b)?[]:[f]}):[]}(d,e.data);if(f.length>0)throw new dt(ds.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${f.join(", ")}`);let g=(e.data.required??[]).filter(a=>!Object.prototype.hasOwnProperty.call(e.data.properties,a));if(g.length>0)throw new dt(ds.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${g.join(", ")}`);return{...a,mode:"form",requestedSchema:e.data}}(a)}}catch(a){throw a instanceof dt?TypeError(a.message,{cause:a}):a}},elicitUrl:a=>({method:"elicitation/create",params:{...a,mode:"url"}}),createMessage:a=>({method:"sampling/createMessage",params:a}),listRoots:()=>({method:"roots/list"})});let ex={},ey={};function ez(a,b){let c=a.slice(0,-6);ex[c]=b,ey[c]=a=>b.safeParse(a).success}for(let a of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])ez(a,dX[a]);for(let[a,b]of Object.entries({IdJagTokenExchangeResponseSchema:cG,OAuthClientInformationFullSchema:cL,OAuthClientInformationSchema:cK,OAuthClientMetadataSchema:cJ,OAuthClientRegistrationErrorSchema:cM,OAuthErrorResponseSchema:cH,OAuthMetadataSchema:cC,OAuthProtectedResourceMetadataSchema:cB,OAuthTokenRevocationRequestSchema:cN,OAuthTokensSchema:cF,OpenIdProviderDiscoveryMetadataSchema:cE,OpenIdProviderMetadataSchema:cD}))ez(a,b);let eA=Object.freeze(ex);Object.freeze(ey);let eB=[K,L,N,P],eC=["inputResponses","requestState"];function eD(a,b){let c=a.params;if(!eI(c))return{message:a,lifted:{}};let d=c._meta,e=eI(d)?eB.filter(a=>a in d):[],f="request"===b?eC.filter(a=>a in c):[];if(0===e.length&&0===f.length)return{message:a,lifted:{}};let g={},h={...c};if(e.length>0&&eI(d)){let a={},b={...d};for(let c of e)a[c]=d[c],delete b[c];g.envelope=a,Object.keys(b).length>0?h._meta=b:delete h._meta}for(let a of f)"inputResponses"===a&&(g.inputResponses=h[a]),"requestState"===a&&(g.requestState=h[a]),delete h[a];return{message:{...a,params:h},lifted:g}}function eE(a,b){let c=a.validateResult(b,void 0);if(c.ok||"not-in-era"!==c.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(c){let d=a.validateResult(b,c);return d.ok?{value:d.value}:{issues:[{message:"invalid"===d.reason?d.message:`not-in-era: ${b}`}]}}}}}let eF=(q=void 0,()=>q);function eG(a,b){return{...a,mcpReq:{...a.mcpReq,requestState:()=>b}}}var eH=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{i=(a,b)=>{a._negotiatedProtocolVersion=b}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(a){this._options=a,this._supportedProtocolVersions=a?.supportedProtocolVersions??J,this.setNotificationHandler("notifications/cancelled",a=>{this._oncancel(a)}),this.setNotificationHandler("notifications/progress",a=>{this._onprogress(a)}),this.setRequestHandler("ping",a=>({}))}_shouldDropInbound(a){}_outboundMetaEnvelope(){}_envelopeOutbound(a){let b=this._outboundMetaEnvelope();if(void 0===b)return a;let c=a.params??{};return{...a,params:{...c,_meta:{...b,...c._meta}}}}_resolveNonCompleteResult(a,b){return Promise.reject(new cW(cV.UnsupportedResultType,`Unsupported result type '${a.kind}' for ${b.request.method}`,{resultType:a.kind,method:b.request.method}))}_getRequestHandler(a){return this._requestHandlers.get(a)}async _oncancel(a){a.params.requestId&&this._requestHandlerAbortControllers.get(a.params.requestId)?.abort(a.params.reason)}_setupTimeout(a,b,c,d,e=!1){this._timeoutInfo.set(a,{timeoutId:setTimeout(d,b),startTime:Date.now(),timeout:b,maxTotalTimeout:c,resetTimeoutOnProgress:e,onTimeout:d})}_resetTimeout(a){let b=this._timeoutInfo.get(a);if(!b)return!1;let c=Date.now()-b.startTime;if(b.maxTotalTimeout&&c>=b.maxTotalTimeout)throw this._timeoutInfo.delete(a),new cW(cV.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:b.maxTotalTimeout,totalElapsed:c});return clearTimeout(b.timeoutId),b.timeoutId=setTimeout(b.onTimeout,b.timeout),!0}_cleanupTimeout(a){let b=this._timeoutInfo.get(a);b&&(clearTimeout(b.timeoutId),this._timeoutInfo.delete(a))}async connect(a){this._transport=a;let b=this.transport?.onclose;this._transport.onclose=()=>{try{b?.()}finally{this._onclose()}};let c=this.transport?.onerror;this._transport.onerror=a=>{c?.(a),this._onerror(a)};let d=this._transport?.onmessage;this._transport.onmessage=(a,b)=>{d?.(a,b),d$(a)||d_(a)?this._onresponse(a):dY(a)?this._onrequest(a,b):dZ(a)?this._onnotification(a,b):this._onerror(Error(`Unknown message type: ${JSON.stringify(a)}`))},a.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let a=this._responseHandlers;for(let a of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(a.timeoutId);this._timeoutInfo.clear();let b=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let c=new cW(cV.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let b of a.values())b(c);for(let a of b.values())a.abort(c)}}_onerror(a){this.onerror?.(a)}_onnotification(a,b){let{message:c}=eD(a,"notification"),d=this._negotiatedWireCodec();if(b?.classification===void 0&&"drop"===this._shouldDropInbound(a))return;if(b?.classification!==void 0){let a=dO(b.classification);if(a!==d.era)return void this._onerror(Error(`Era mismatch on inbound notification '${c.method}': classified as ${a} but this instance serves ${d.era}`))}if(dQ(c.method)&&!d.hasNotificationMethod(c.method))return;let e=this._notificationHandlers.get(c.method),f=this.fallbackNotificationHandler;(void 0!==e||void 0!==f)&&Promise.resolve().then(()=>void 0===e?f(c):e(c,d)).catch(a=>this._onerror(Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(a,b){var c;let{message:d,lifted:e}=eD(a,"request"),f=this._negotiatedWireCodec();if(b?.classification===void 0&&"drop"===this._shouldDropInbound(a))return void this._onerror(Error(`Dropped inbound request '${a.method}': not servable on this connection's protocol era`));let g=this._transport,h=(a,b,c)=>{let e={jsonrpc:"2.0",id:d.id,error:{code:a,message:b,...void 0!==c&&{data:c}}};g?.send(e).catch(a=>this._onerror(Error(`Failed to send an error response: ${a}`)))};if(b?.classification!==void 0){let a=dO(b.classification);if(a!==f.era){this._onerror(Error(`Era mismatch on inbound request '${d.method}': classified as ${a} but this instance serves ${f.era}`));let c=b.classification.revision??a;h(ds.UnsupportedProtocolVersion,`Unsupported protocol version: ${c}`,{supported:this._supportedProtocolVersions,requested:c});return}}if(dP(d.method)&&!f.hasRequestMethod(d.method))return void h(ds.MethodNotFound,"Method not found");let i=this._requestHandlers.get(d.method)??this.fallbackRequestHandler;if(void 0===i)return void h(ds.MethodNotFound,"Method not found");let j=f.checkInboundEnvelope(e);if(void 0!==j)return void h(ds.InvalidParams,j);let k=(a,b)=>this._notificationViaCodec(this._resolveOutboundCodec(a.method),a,{...b,relatedRequestId:d.id}),l=(a,b,c)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(a.method),a,b,{...c,relatedRequestId:d.id}),m=new AbortController;this._requestHandlerAbortControllers.set(d.id,m);let n=void 0===e.inputResponses?void 0:function(a){let b={},c=[];if(!eJ(a))return{accepted:b,droppedKeys:c};for(let[d,e]of Object.entries(a)){if(!eJ(e)||"method"in e||"result"in e){c.push(d);continue}b[d]=e}return{accepted:b,droppedKeys:c}}(e.inputResponses),o={sessionId:g?.sessionId,mcpReq:{id:d.id,method:d.method,_meta:d.params?._meta,...void 0!==e.envelope&&{envelope:e.envelope},...void 0!==n&&{inputResponses:n.accepted},...void 0!==n&&n.droppedKeys.length>0&&{droppedInputResponseKeys:n.droppedKeys},requestState:void 0===e.requestState?eF:(c=e.requestState,()=>c),signal:m.signal,send:(a,b,c)=>{let d=this._resolveOutboundCodec(a.method);if(this._assertOutboundRequestInEra(d,a.method),el(b))return l(a,b,c);let e=eE(d,a.method);if(void 0===e)throw TypeError(`'${a.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return l(a,e,b)},notify:k},http:b?.authInfo?{authInfo:b.authInfo}:void 0},p=this.buildContext(o,b);Promise.resolve().then(()=>i(d,p)).then(async a=>{let b;if(m.signal.aborted)return;try{b=f.encodeResult(d.method,a,this._outboundServerInfo())}catch(a){this._onerror(Error(`Failed to encode result for ${d.method}: ${a}`)),h(ds.InternalError,"Internal error");return}let c={result:b,jsonrpc:"2.0",id:d.id};await g?.send(c)},async a=>{if(m.signal.aborted)return;let b=Number.isSafeInteger(a.code)?a.code:ds.InternalError,c={jsonrpc:"2.0",id:d.id,error:{code:f.encodeErrorCode(b),message:a.message??"Internal error",...void 0!==a.data&&{data:a.data}}};await g?.send(c)}).catch(a=>this._onerror(Error(`Failed to send response: ${a}`))).finally(()=>{this._requestHandlerAbortControllers.get(d.id)===m&&this._requestHandlerAbortControllers.delete(d.id)})}_onprogress(a){let{progressToken:b,...c}=a.params,d=Number(b),e=this._progressHandlers.get(d);if(!e)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(a)}`));let f=this._responseHandlers.get(d),g=this._timeoutInfo.get(d);if(g&&f&&g.resetTimeoutOnProgress)try{this._resetTimeout(d)}catch(a){this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),f(a);return}e(c)}_onresponse(a){let b=Number(a.id),c=this._responseHandlers.get(b);void 0===c?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(a)}`)):(this._responseHandlers.delete(b),this._cleanupTimeout(b),this._progressHandlers.delete(b),c(d$(a)?a:dt.fromError(a.error.code,a.error.message,a.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(a,b,c){let d=this._resolveOutboundCodec(a.method);if(this._assertOutboundRequestInEra(d,a.method),el(b))return this._requestWithSchemaViaCodec(d,a,b,c);let e=eE(d,a.method);if(void 0===e)throw TypeError(`'${a.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(d,a,e,b)}_negotiatedWireCodec(){return dN(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(a){if(void 0===this._negotiatedProtocolVersion){let b=function(a){switch(a){case"initialize":case"notifications/initialized":return dN(void 0);case"server/discover":return dN(dM);default:return}}(a);if(b)return b}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(a,b){if(dP(b)&&!a.hasRequestMethod(b))throw new cW(cV.MethodNotSupportedByProtocolVersion,`Method '${b}' is not supported by the negotiated protocol version (wire era ${a.era})`,{method:b,era:a.era})}_requestWithSchema(a,b,c){let d=this._resolveOutboundCodec(a.method);return this._assertOutboundRequestInEra(d,a.method),this._requestWithSchemaViaCodec(d,a,b,c)}_requestWithSchemaViaCodec(a,b,c,d){let e,f,{relatedRequestId:g,resumptionToken:h,onresumptiontoken:i,headers:j}=d??{},k=Date.now();return new Promise((l,m)=>{let n=a=>{m(a)};if(!this._transport)return void n(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(b.method)}catch(a){n(a);return}if(d?.signal?.aborted){let a=d.signal.reason;throw a instanceof cW?a:new cW(cV.RequestTimeout,String(a))}let o=a.era===dM&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,p=this._requestMessageId++;f=p;let q={...b,jsonrpc:"2.0",id:p};d?.onprogress&&(this._progressHandlers.set(p,d.onprogress),q.params={...b.params,_meta:{...b.params?._meta,progressToken:p}});let r=this._envelopeOutbound(q),s=!1,t=a=>{s||(this._progressHandlers.delete(p),void 0===o?this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(a)}}),{relatedRequestId:g,resumptionToken:h,onresumptiontoken:i}).catch(a=>this._onerror(Error(`Failed to send cancellation: ${a}`))):o.abort(),m(a instanceof cW?a:new cW(cV.RequestTimeout,String(a))))};this._responseHandlers.set(p,e=>{let f;if(!d?.signal?.aborted){if(s=!0,e instanceof Error)return m(e);try{f=a.decodeResult(b.method,e.result)}catch(a){return m(a instanceof Error?a:Error(String(a)))}if("invalid"===f.kind)return m(f.error);if("input_required"===f.kind){var g;return d?.allowInputRequired===!0?l({resultType:"input_required",inputRequests:(g=f).inputRequests,...void 0!==g.requestState&&{requestState:g.requestState}}):l(this._resolveNonCompleteResult(f,{codec:a,request:b,resultSchema:c,options:d,flowStartedAt:k,retry:(d,e)=>this._requestWithSchemaViaCodec(a,void 0===d?{method:b.method}:{method:b.method,params:d},c,e)}))}ep(c,f.result).then(a=>{a.success?l(a.data):m(new cW(cV.InvalidResult,`Invalid result for ${b.method}: ${a.error}`))},m)}}),e=()=>t(d?.signal?.reason),d?.signal?.addEventListener("abort",e,{once:!0});let u=d?.timeout??6e4;this._setupTimeout(p,u,d?.maxTotalTimeout,()=>t(new cW(cV.RequestTimeout,"Request timed out",{timeout:u})),d?.resetTimeoutOnProgress??!1),this._transport.send(r,{relatedRequestId:g,resumptionToken:h,onresumptiontoken:i,headers:j,requestSignal:o?.signal}).catch(a=>{this._progressHandlers.delete(p),m(a)})}).finally(()=>{e&&d?.signal?.removeEventListener("abort",e),void 0!==f&&(this._responseHandlers.delete(f),this._cleanupTimeout(f))})}async notification(a,b){return this._notificationViaCodec(this._resolveOutboundCodec(a.method),a,b)}async _notificationViaCodec(a,b,c){if(!this._transport)throw new cW(cV.NotConnected,"Not connected");if(dQ(b.method)&&!a.hasNotificationMethod(b.method))throw new cW(cV.MethodNotSupportedByProtocolVersion,`Notification '${b.method}' is not supported by the negotiated protocol version (wire era ${a.era})`,{method:b.method,era:a.era});this.assertNotificationCapability(b.method);let d=this._envelopeOutbound({jsonrpc:"2.0",...b});if((this._options?.debouncedNotificationMethods??[]).includes(b.method)&&!b.params&&!c?.relatedRequestId){if(this._pendingDebouncedNotifications.has(b.method))return;this._pendingDebouncedNotifications.add(b.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(b.method),this._transport&&this._transport?.send(d,c).catch(a=>this._onerror(a))});return}await this._transport.send(d,c)}setRequestHandler(a,b,c){let d;if(this.assertRequestHandlerCapability(a),"function"==typeof b){if(!dP(a))throw TypeError(`'${a}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);d=(c,d)=>{let e=this._negotiatedWireCodec(),f=e.validateRequest(a,c);if(f.ok||"not-in-era"!==f.reason||(f=e.validateInputRequest(a,c)),!f.ok){if("not-in-era"===f.reason)throw new dt(ds.InternalError,`No wire schema for ${a} in the resolved era`);throw Error(f.message)}return Promise.resolve(b(f.value,d))}}else if(c)d=async(d,e)=>{let f=await ep(b.params,{...d.params});if(!f.success)throw new dt(ds.InvalidParams,`Invalid params for ${a}: ${f.error}`);return c(f.data,e)};else throw TypeError("setRequestHandler: handler is required");this._requestHandlers.set(a,this._wrapHandler(a,d))}_wrapHandler(a,b){return b}_outboundServerInfo(){}removeRequestHandler(a){this._requestHandlers.delete(a)}assertCanSetRequestHandler(a){if(this._requestHandlers.has(a))throw Error(`A request handler for ${a} already exists, which would be overridden`)}setNotificationHandler(a,b,c){if("function"==typeof b){if(!dQ(a))throw TypeError(`'${a}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(a,(c,d)=>{let e=d.validateNotification(a,c);if(!e.ok){if("not-in-era"===e.reason)throw new dt(ds.InternalError,`No wire schema for ${a} in the resolved era`);throw Error(e.message)}return Promise.resolve(b(e.value))});return}if(!c)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(a,async d=>{let e=await ep(b.params,{...d.params});if(!e.success)throw new dt(ds.InvalidParams,`Invalid params for notification ${a}: ${e.error}`);await c(e.data,d)})}removeNotificationHandler(a){this._notificationHandlers.delete(a)}};function eI(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function eJ(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}var eK=z(y(a=>{var b=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,c=/\\([\u000b\u0020-\u00ff])/g,d=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function e(a){this.parameters=Object.create(null),this.type=a}a.parse=function(a){if(!a)throw TypeError("argument string is required");var f,g,h,i="object"==typeof a?function(a){var b;if("function"==typeof a.getHeader?b=a.getHeader("content-type"):"object"==typeof a.headers&&(b=a.headers&&a.headers["content-type"]),"string"!=typeof b)throw TypeError("content-type header is missing from object");return b}(a):a;if("string"!=typeof i)throw TypeError("argument string is required to be a string");var j=i.indexOf(";"),k=-1!==j?i.slice(0,j).trim():i.trim();if(!d.test(k))throw TypeError("invalid media type");var l=new e(k.toLowerCase());if(-1!==j){for(b.lastIndex=j;g=b.exec(i);){if(g.index!==j)throw TypeError("invalid parameter format");j+=g[0].length,f=g[1].toLowerCase(),34===(h=g[2]).charCodeAt(0)&&-1!==(h=h.slice(1,-1)).indexOf("\\")&&(h=h.replace(c,"$1")),l.parameters[f]=h}if(j!==i.length)throw TypeError("invalid parameter format")}return l}})(),1);function eL(a){if(a)try{return eK.parse(a).type}catch{let b=(a.split(";",1)[0]??"").trim().toLowerCase();if(""===b||a.slice(b.length).includes(","))return;return b}}function eM(a){return"application/json"===a||"application/json"===eL(a)}let eN=/^[A-Za-z0-9._-]{1,128}$/;function eO(a){let b=function(a){let b=[];if(0===a.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(a.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${a.length})`]};if(a.includes(" ")&&b.push("Tool name contains spaces, which may cause parsing issues"),a.includes(",")&&b.push("Tool name contains commas, which may cause parsing issues"),(a.startsWith("-")||a.endsWith("-"))&&b.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(a.startsWith(".")||a.endsWith("."))&&b.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!eN.test(a)){let c=[...a].filter(a=>!/[A-Za-z0-9._-]/.test(a)).filter((a,b,c)=>c.indexOf(a)===b);return b.push(`Tool name contains invalid characters: ${c.map(a=>`"${a}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:b}}return{isValid:!0,warnings:b}}(a);var c=b.warnings;if(c.length>0){for(let b of(console.warn(`Tool name validation warning for "${a}":`),c))console.warn(` - ${b}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}return b.isValid}var eP=class a{static isTemplate(a){return/\{[^}\s]+\}/.test(a)}static validateLength(a,b,c){if(a.length>b)throw Error(`${c} exceeds maximum length of ${b} characters (got ${a.length})`)}template;parts;get variableNames(){return this.parts.flatMap(a=>"string"==typeof a?[]:a.names)}constructor(b){a.validateLength(b,1e6,"Template"),this.template=b,this.parts=this.parse(b)}toString(){return this.template}parse(b){let c=[],d="",e=0,f=0;for(;e<b.length;)if("{"===b[e]){d&&(c.push(d),d="");let g=b.indexOf("}",e);if(-1===g)throw Error("Unclosed template expression");if(++f>1e4)throw Error("Template contains too many expressions (max 10000)");let h=b.slice(e+1,g),i=this.getOperator(h),j=h.includes("*"),k=this.getNames(h),l=k[0];for(let b of k)a.validateLength(b,1e6,"Variable name");c.push({name:l,operator:i,names:k,exploded:j}),e=g+1}else d+=b[e],e++;return d&&c.push(d),c}getOperator(a){return["+","#",".","/","?","&"].find(b=>a.startsWith(b))||""}getNames(a){let b=this.getOperator(a);return a.slice(b.length).split(",").map(a=>a.replace("*","").trim()).filter(a=>a.length>0)}encodeValue(b,c){return(a.validateLength(b,1e6,"Variable value"),"+"===c||"#"===c)?encodeURI(b):encodeURIComponent(b)}expandPart(a,b){if("?"===a.operator||"&"===a.operator){let c=a.names.map(c=>{let d=b[c];return void 0===d?"":`${c}=${Array.isArray(d)?d.map(b=>this.encodeValue(b,a.operator)).join(","):this.encodeValue(d.toString(),a.operator)}`}).filter(a=>a.length>0);return 0===c.length?"":("?"===a.operator?"?":"&")+c.join("&")}if(a.names.length>1){let c=a.names.map(a=>b[a]).filter(a=>void 0!==a);return 0===c.length?"":c.map(a=>Array.isArray(a)?a[0]:a).join(",")}let c=b[a.name];if(void 0===c)return"";let d=(Array.isArray(c)?c:[c]).map(b=>this.encodeValue(b,a.operator));switch(a.operator){case"":case"+":default:return d.join(",");case"#":return"#"+d.join(",");case".":return"."+d.join(".");case"/":return"/"+d.join("/")}}expand(a){let b="",c=!1;for(let d of this.parts){if("string"==typeof d){b+=d;continue}let e=this.expandPart(d,a);e&&(b+=("?"===d.operator||"&"===d.operator)&&c?e.replace("?","&"):e,("?"===d.operator||"&"===d.operator)&&(c=!0))}return b}escapeRegExp(a){return a.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(b){let c,d=[];for(let c of b.names)a.validateLength(c,1e6,"Variable name");if("?"===b.operator||"&"===b.operator){for(let a=0;a<b.names.length;a++){let c=b.names[a],e=0===a?"\\"+b.operator:"&";d.push({pattern:e+this.escapeRegExp(c)+"=([^&]+)",name:c})}return d}let e=b.name;switch(b.operator){case"":c=b.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":c="(.+)";break;case".":c=String.raw`\.([^/,]+)`;break;case"/":c="/"+(b.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:c="([^/]+)"}return d.push({pattern:c,name:e}),d}match(b){a.validateLength(b,1e6,"URI");let c="^",d=[];for(let a of this.parts)if("string"==typeof a)c+=this.escapeRegExp(a);else for(let{pattern:b,name:e}of this.partToRegExp(a))c+=b,d.push({name:e,exploded:a.exploded});c+="$",a.validateLength(c,1e6,"Generated regex pattern");let e=new RegExp(c),f=b.match(e);if(!f)return null;let g={};for(let[a,b]of d.entries()){let{name:c,exploded:d}=b,e=f[a+1];g[c.replace("*","")]=d&&e.includes(",")?e.split(","):e}return g}};function eQ(a){if(void 0!==a){if(function(a){if("object"!=typeof a||null===a||el(a))return!1;let b=Object.getPrototypeOf(a);return(b===Object.prototype||null===b)&&Object.values(a).every(a=>"object"==typeof a&&null!==a&&"_zod"in a)}(a))return E.Ik(a);if("object"==typeof a&&null!==a&&!el(a)&&Object.values(a).some(a=>"object"==typeof a&&null!==a&&!("_zod"in a)&&"_def"in a&&"string"==typeof a._def?.typeName))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!el(a))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return a}}var eR=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.regexpCode=a.getEsmExportName=a.getProperty=a.safeStringify=a.stringify=a.strConcat=a.addCodeArg=a.str=a._=a.nil=a._Code=a.Name=a.IDENTIFIER=a._CodeOrName=void 0;var b=class{};a._CodeOrName=b,a.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var c=class extends b{constructor(b){if(super(),!a.IDENTIFIER.test(b))throw Error("CodeGen: name must be a valid identifier");this.str=b}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};a.Name=c;var d=class extends b{constructor(a){super(),this._items="string"==typeof a?[a]:a}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let a=this._items[0];return""===a||'""'===a}get str(){var a;return null!=(a=this._str)?a:this._str=this._items.reduce((a,b)=>`${a}${b}`,"")}get names(){var a;return null!=(a=this._names)?a:this._names=this._items.reduce((a,b)=>(b instanceof c&&(a[b.str]=(a[b.str]||0)+1),a),{})}};function e(a,...b){let c=[a[0]],f=0;for(;f<b.length;)h(c,b[f]),c.push(a[++f]);return new d(c)}a._Code=d,a.nil=new d(""),a._=e;let f=new d("+");function g(a,...b){let e=[i(a[0])],j=0;for(;j<b.length;)e.push(f),h(e,b[j]),e.push(f,i(a[++j]));return function(a){let b=1;for(;b<a.length-1;){if(a[b]===f){var d,e;let f=(d=a[b-1],'""'===(e=a[b+1])?d:'""'===d?e:"string"==typeof d?e instanceof c||'"'!==d[d.length-1]?void 0:"string"!=typeof e?`${d.slice(0,-1)}${e}"`:'"'===e[0]?d.slice(0,-1)+e.slice(1):void 0:"string"!=typeof e||'"'!==e[0]||d instanceof c?void 0:`"${d}${e.slice(1)}`);if(void 0!==f){a.splice(b-1,3,f);continue}a[b++]="+"}b++}}(e),new d(e)}function h(a,b){var e;b instanceof d?a.push(...b._items):b instanceof c?a.push(b):a.push("number"==typeof(e=b)||"boolean"==typeof e||null===e?e:i(Array.isArray(e)?e.join(","):e))}function i(a){return JSON.stringify(a).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}a.str=g,a.addCodeArg=h,a.strConcat=function(a,b){return b.emptyStr()?a:a.emptyStr()?b:g`${a}${b}`},a.stringify=function(a){return new d(i(a))},a.safeStringify=i,a.getProperty=function(b){return"string"==typeof b&&a.IDENTIFIER.test(b)?new d(`.${b}`):e`[${b}]`},a.getEsmExportName=function(b){if("string"==typeof b&&a.IDENTIFIER.test(b))return new d(`${b}`);throw Error(`CodeGen: invalid export name: ${b}, use explicit $id name mapping`)},a.regexpCode=function(a){return new d(a.toString())}}),eS=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ValueScope=a.ValueScopeName=a.Scope=a.varKinds=a.UsedValueState=void 0;let b=eR();var c,d,e=class extends Error{constructor(a){super(`CodeGen: "code" for ${a} not defined`),this.value=a.value}};(c=d||(a.UsedValueState=d={}))[c.Started=0]="Started",c[c.Completed=1]="Completed",a.varKinds={const:new b.Name("const"),let:new b.Name("let"),var:new b.Name("var")};var f=class{constructor({prefixes:a,parent:b}={}){this._names={},this._prefixes=a,this._parent=b}toName(a){return a instanceof b.Name?a:this.name(a)}name(a){return new b.Name(this._newName(a))}_newName(a){let b=this._names[a]||this._nameGroup(a);return`${a}${b.index++}`}_nameGroup(a){var b,c;if((null==(c=null==(b=this._parent)?void 0:b._prefixes)?void 0:c.has(a))||this._prefixes&&!this._prefixes.has(a))throw Error(`CodeGen: prefix "${a}" is not allowed in this scope`);return this._names[a]={prefix:a,index:0}}};a.Scope=f;var g=class extends b.Name{constructor(a,b){super(b),this.prefix=a}setValue(a,{property:c,itemIndex:d}){this.value=a,this.scopePath=(0,b._)`.${new b.Name(c)}[${d}]`}};a.ValueScopeName=g;let h=(0,b._)`\n`;var i=class extends f{constructor(a){super(a),this._values={},this._scope=a.scope,this.opts={...a,_n:a.lines?h:b.nil}}get(){return this._scope}name(a){return new g(a,this._newName(a))}value(a,b){var c;if(void 0===b.ref)throw Error("CodeGen: ref must be passed in value");let d=this.toName(a),{prefix:e}=d,f=null!=(c=b.key)?c:b.ref,g=this._values[e];if(g){let a=g.get(f);if(a)return a}else g=this._values[e]=new Map;g.set(f,d);let h=this._scope[e]||(this._scope[e]=[]),i=h.length;return h[i]=b.ref,d.setValue(b,{property:e,itemIndex:i}),d}getValue(a,b){let c=this._values[a];if(c)return c.get(b)}scopeRefs(a,c=this._values){return this._reduceValues(c,c=>{if(void 0===c.scopePath)throw Error(`CodeGen: name "${c}" has no value`);return(0,b._)`${a}${c.scopePath}`})}scopeCode(a=this._values,b,c){return this._reduceValues(a,a=>{if(void 0===a.value)throw Error(`CodeGen: name "${a}" has no value`);return a.value.code},b,c)}_reduceValues(c,f,g={},h){let i=b.nil;for(let j in c){let k=c[j];if(!k)continue;let l=g[j]=g[j]||new Map;k.forEach(c=>{if(l.has(c))return;l.set(c,d.Started);let g=f(c);if(g){let d=this.opts.es5?a.varKinds.var:a.varKinds.const;i=(0,b._)`${i}${d} ${c} = ${g};${this.opts._n}`}else if(g=null==h?void 0:h(c))i=(0,b._)`${i}${g}${this.opts._n}`;else throw new e(c);l.set(c,d.Completed)})}return i}};a.ValueScope=i}),eT=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.or=a.and=a.not=a.CodeGen=a.operators=a.varKinds=a.ValueScopeName=a.ValueScope=a.Scope=a.Name=a.regexpCode=a.stringify=a.getProperty=a.nil=a.strConcat=a.str=a._=void 0;let b=eR(),c=eS();var d=eR();Object.defineProperty(a,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(a,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(a,"strConcat",{enumerable:!0,get:function(){return d.strConcat}}),Object.defineProperty(a,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(a,"getProperty",{enumerable:!0,get:function(){return d.getProperty}}),Object.defineProperty(a,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(a,"regexpCode",{enumerable:!0,get:function(){return d.regexpCode}}),Object.defineProperty(a,"Name",{enumerable:!0,get:function(){return d.Name}});var e=eS();Object.defineProperty(a,"Scope",{enumerable:!0,get:function(){return e.Scope}}),Object.defineProperty(a,"ValueScope",{enumerable:!0,get:function(){return e.ValueScope}}),Object.defineProperty(a,"ValueScopeName",{enumerable:!0,get:function(){return e.ValueScopeName}}),Object.defineProperty(a,"varKinds",{enumerable:!0,get:function(){return e.varKinds}}),a.operators={GT:new b._Code(">"),GTE:new b._Code(">="),LT:new b._Code("<"),LTE:new b._Code("<="),EQ:new b._Code("==="),NEQ:new b._Code("!=="),NOT:new b._Code("!"),OR:new b._Code("||"),AND:new b._Code("&&"),ADD:new b._Code("+")};var f=class{optimizeNodes(){return this}optimizeNames(a,b){return this}},g=class extends f{constructor(a,b,c){super(),this.varKind=a,this.name=b,this.rhs=c}render({es5:a,_n:b}){let d=a?c.varKinds.var:this.varKind,e=void 0===this.rhs?"":` = ${this.rhs}`;return`${d} ${this.name}${e};`+b}optimizeNames(a,b){if(a[this.name.str])return this.rhs&&(this.rhs=E(this.rhs,a,b)),this}get names(){return this.rhs instanceof b._CodeOrName?this.rhs.names:{}}},h=class extends f{constructor(a,b,c){super(),this.lhs=a,this.rhs=b,this.sideEffects=c}render({_n:a}){return`${this.lhs} = ${this.rhs};`+a}optimizeNames(a,c){if(!(this.lhs instanceof b.Name)||a[this.lhs.str]||this.sideEffects)return this.rhs=E(this.rhs,a,c),this}get names(){return D(this.lhs instanceof b.Name?{}:{...this.lhs.names},this.rhs)}},i=class extends h{constructor(a,b,c,d){super(a,c,d),this.op=b}render({_n:a}){return`${this.lhs} ${this.op}= ${this.rhs};`+a}},j=class extends f{constructor(a){super(),this.label=a,this.names={}}render({_n:a}){return`${this.label}:`+a}},k=class extends f{constructor(a){super(),this.label=a,this.names={}}render({_n:a}){return`break${this.label?` ${this.label}`:""};`+a}},l=class extends f{constructor(a){super(),this.error=a}render({_n:a}){return`throw ${this.error};`+a}get names(){return this.error.names}},m=class extends f{constructor(a){super(),this.code=a}render({_n:a}){return`${this.code};`+a}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(a,b){return this.code=E(this.code,a,b),this}get names(){return this.code instanceof b._CodeOrName?this.code.names:{}}},n=class extends f{constructor(a=[]){super(),this.nodes=a}render(a){return this.nodes.reduce((b,c)=>b+c.render(a),"")}optimizeNodes(){let{nodes:a}=this,b=a.length;for(;b--;){let c=a[b].optimizeNodes();Array.isArray(c)?a.splice(b,1,...c):c?a[b]=c:a.splice(b,1)}return a.length>0?this:void 0}optimizeNames(a,b){let{nodes:c}=this,d=c.length;for(;d--;){let e=c[d];e.optimizeNames(a,b)||(function(a,b){for(let c in b)a[c]=(a[c]||0)-(b[c]||0)}(a,e.names),c.splice(d,1))}return c.length>0?this:void 0}get names(){return this.nodes.reduce((a,b)=>C(a,b.names),{})}},o=class extends n{render(a){return"{"+a._n+super.render(a)+"}"+a._n}},p=class extends n{},q=class extends o{};q.kind="else";var r=class a extends o{constructor(a,b){super(b),this.condition=a}render(a){let b=`if(${this.condition})`+super.render(a);return this.else&&(b+="else "+this.else.render(a)),b}optimizeNodes(){super.optimizeNodes();let b=this.condition;if(!0===b)return this.nodes;let c=this.else;if(c){let a=c.optimizeNodes();c=this.else=Array.isArray(a)?new q(a):a}return c?!1===b?c instanceof a?c:c.nodes:this.nodes.length?this:new a(F(b),c instanceof a?[c]:c.nodes):!1!==b&&this.nodes.length?this:void 0}optimizeNames(a,b){var c;if(this.else=null==(c=this.else)?void 0:c.optimizeNames(a,b),super.optimizeNames(a,b)||this.else)return this.condition=E(this.condition,a,b),this}get names(){let a=super.names;return D(a,this.condition),this.else&&C(a,this.else.names),a}};r.kind="if";var s=class extends o{};s.kind="for";var t=class extends s{constructor(a){super(),this.iteration=a}render(a){return`for(${this.iteration})`+super.render(a)}optimizeNames(a,b){if(super.optimizeNames(a,b))return this.iteration=E(this.iteration,a,b),this}get names(){return C(super.names,this.iteration.names)}},u=class extends s{constructor(a,b,c,d){super(),this.varKind=a,this.name=b,this.from=c,this.to=d}render(a){let b=a.es5?c.varKinds.var:this.varKind,{name:d,from:e,to:f}=this;return`for(${b} ${d}=${e}; ${d}<${f}; ${d}++)`+super.render(a)}get names(){return D(D(super.names,this.from),this.to)}},v=class extends s{constructor(a,b,c,d){super(),this.loop=a,this.varKind=b,this.name=c,this.iterable=d}render(a){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(a)}optimizeNames(a,b){if(super.optimizeNames(a,b))return this.iterable=E(this.iterable,a,b),this}get names(){return C(super.names,this.iterable.names)}},w=class extends o{constructor(a,b,c){super(),this.name=a,this.args=b,this.async=c}render(a){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(a)}};w.kind="func";var x=class extends n{render(a){return"return "+super.render(a)}};x.kind="return";var y=class extends o{render(a){let b="try"+super.render(a);return this.catch&&(b+=this.catch.render(a)),this.finally&&(b+=this.finally.render(a)),b}optimizeNodes(){var a,b;return super.optimizeNodes(),null==(a=this.catch)||a.optimizeNodes(),null==(b=this.finally)||b.optimizeNodes(),this}optimizeNames(a,b){var c,d;return super.optimizeNames(a,b),null==(c=this.catch)||c.optimizeNames(a,b),null==(d=this.finally)||d.optimizeNames(a,b),this}get names(){let a=super.names;return this.catch&&C(a,this.catch.names),this.finally&&C(a,this.finally.names),a}},z=class extends o{constructor(a){super(),this.error=a}render(a){return`catch(${this.error})`+super.render(a)}};z.kind="catch";var A=class extends o{render(a){return"finally"+super.render(a)}};A.kind="finally";var B=class{constructor(a,b={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...b,_n:b.lines?"\n":""},this._extScope=a,this._scope=new c.Scope({parent:a}),this._nodes=[new p]}toString(){return this._root.render(this.opts)}name(a){return this._scope.name(a)}scopeName(a){return this._extScope.name(a)}scopeValue(a,b){let c=this._extScope.value(a,b);return(this._values[c.prefix]||(this._values[c.prefix]=new Set)).add(c),c}getScopeValue(a,b){return this._extScope.getValue(a,b)}scopeRefs(a){return this._extScope.scopeRefs(a,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(a,b,c,d){let e=this._scope.toName(b);return void 0!==c&&d&&(this._constants[e.str]=c),this._leafNode(new g(a,e,c)),e}const(a,b,d){return this._def(c.varKinds.const,a,b,d)}let(a,b,d){return this._def(c.varKinds.let,a,b,d)}var(a,b,d){return this._def(c.varKinds.var,a,b,d)}assign(a,b,c){return this._leafNode(new h(a,b,c))}add(b,c){return this._leafNode(new i(b,a.operators.ADD,c))}code(a){return"function"==typeof a?a():a!==b.nil&&this._leafNode(new m(a)),this}object(...a){let c=["{"];for(let[d,e]of a)c.length>1&&c.push(","),c.push(d),(d!==e||this.opts.es5)&&(c.push(":"),(0,b.addCodeArg)(c,e));return c.push("}"),new b._Code(c)}if(a,b,c){if(this._blockNode(new r(a)),b&&c)this.code(b).else().code(c).endIf();else if(b)this.code(b).endIf();else if(c)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(a){return this._elseNode(new r(a))}else(){return this._elseNode(new q)}endIf(){return this._endBlockNode(r,q)}_for(a,b){return this._blockNode(a),b&&this.code(b).endFor(),this}for(a,b){return this._for(new t(a),b)}forRange(a,b,d,e,f=this.opts.es5?c.varKinds.var:c.varKinds.let){let g=this._scope.toName(a);return this._for(new u(f,g,b,d),()=>e(g))}forOf(a,d,e,f=c.varKinds.const){let g=this._scope.toName(a);if(this.opts.es5){let a=d instanceof b.Name?d:this.var("_arr",d);return this.forRange("_i",0,(0,b._)`${a}.length`,c=>{this.var(g,(0,b._)`${a}[${c}]`),e(g)})}return this._for(new v("of",f,g,d),()=>e(g))}forIn(a,d,e,f=this.opts.es5?c.varKinds.var:c.varKinds.const){if(this.opts.ownProperties)return this.forOf(a,(0,b._)`Object.keys(${d})`,e);let g=this._scope.toName(a);return this._for(new v("in",f,g,d),()=>e(g))}endFor(){return this._endBlockNode(s)}label(a){return this._leafNode(new j(a))}break(a){return this._leafNode(new k(a))}return(a){let b=new x;if(this._blockNode(b),this.code(a),1!==b.nodes.length)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(a,b,c){if(!b&&!c)throw Error('CodeGen: "try" without "catch" and "finally"');let d=new y;if(this._blockNode(d),this.code(a),b){let a=this.name("e");this._currNode=d.catch=new z(a),b(a)}return c&&(this._currNode=d.finally=new A,this.code(c)),this._endBlockNode(z,A)}throw(a){return this._leafNode(new l(a))}block(a,b){return this._blockStarts.push(this._nodes.length),a&&this.code(a).endBlock(b),this}endBlock(a){let b=this._blockStarts.pop();if(void 0===b)throw Error("CodeGen: not in self-balancing block");let c=this._nodes.length-b;if(c<0||void 0!==a&&c!==a)throw Error(`CodeGen: wrong number of nodes: ${c} vs ${a} expected`);return this._nodes.length=b,this}func(a,c=b.nil,d,e){return this._blockNode(new w(a,c,d)),e&&this.code(e).endFunc(),this}endFunc(){return this._endBlockNode(w)}optimize(a=1){for(;a-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(a){return this._currNode.nodes.push(a),this}_blockNode(a){this._currNode.nodes.push(a),this._nodes.push(a)}_endBlockNode(a,b){let c=this._currNode;if(c instanceof a||b&&c instanceof b)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${b?`${a.kind}/${b.kind}`:a.kind}"`)}_elseNode(a){let b=this._currNode;if(!(b instanceof r))throw Error('CodeGen: "else" without "if"');return this._currNode=b.else=a,this}get _root(){return this._nodes[0]}get _currNode(){let a=this._nodes;return a[a.length-1]}set _currNode(a){let b=this._nodes;b[b.length-1]=a}};function C(a,b){for(let c in b)a[c]=(a[c]||0)+(b[c]||0);return a}function D(a,c){return c instanceof b._CodeOrName?C(a,c.names):a}function E(a,c,d){var e;if(a instanceof b.Name)return f(a);if(!((e=a)instanceof b._Code&&e._items.some(a=>a instanceof b.Name&&1===c[a.str]&&void 0!==d[a.str])))return a;return new b._Code(a._items.reduce((a,c)=>(c instanceof b.Name&&(c=f(c)),c instanceof b._Code?a.push(...c._items):a.push(c),a),[]));function f(a){let b=d[a.str];return void 0===b||1!==c[a.str]?a:(delete c[a.str],b)}}function F(a){return"boolean"==typeof a||"number"==typeof a||null===a?!a:(0,b._)`!${J(a)}`}a.CodeGen=B,a.not=F;let G=I(a.operators.AND);a.and=function(...a){return a.reduce(G)};let H=I(a.operators.OR);function I(a){return(c,d)=>c===b.nil?d:d===b.nil?c:(0,b._)`${J(c)} ${a} ${J(d)}`}function J(a){return a instanceof b.Name?a:(0,b._)`(${a})`}a.or=function(...a){return a.reduce(H)}}),eU=y(a=>{var b,c;Object.defineProperty(a,"__esModule",{value:!0}),a.checkStrictMode=a.getErrorPath=a.Type=a.useFunc=a.setEvaluated=a.evaluatedPropsToName=a.mergeEvaluated=a.eachItem=a.unescapeJsonPointer=a.escapeJsonPointer=a.escapeFragment=a.unescapeFragment=a.schemaRefOrVal=a.schemaHasRulesButRef=a.schemaHasRules=a.checkUnknownRules=a.alwaysValidSchema=a.toHash=void 0;let d=eT(),e=eR();function f(a,b=a.schema){let{opts:c,self:d}=a;if(!c.strictSchema||"boolean"==typeof b)return;let e=d.RULES.keywords;for(let c in b)e[c]||n(a,`unknown keyword: "${c}"`)}function g(a,b){if("boolean"==typeof a)return!a;for(let c in a)if(b[c])return!0;return!1}function h(a){return"number"==typeof a?`${a}`:a.replace(/~/g,"~0").replace(/\//g,"~1")}function i(a){return a.replace(/~1/g,"/").replace(/~0/g,"~")}function j({mergeNames:a,mergeToName:b,mergeValues:c,resultToName:e}){return(f,g,h,i)=>{let j=void 0===h?g:h instanceof d.Name?(g instanceof d.Name?a(f,g,h):b(f,g,h),h):g instanceof d.Name?(b(f,h,g),g):c(g,h);return i!==d.Name||j instanceof d.Name?j:e(f,j)}}function k(a,b){if(!0===b)return a.var("props",!0);let c=a.var("props",(0,d._)`{}`);return void 0!==b&&l(a,c,b),c}function l(a,b,c){Object.keys(c).forEach(c=>a.assign((0,d._)`${b}${(0,d.getProperty)(c)}`,!0))}a.toHash=function(a){let b={};for(let c of a)b[c]=!0;return b},a.alwaysValidSchema=function(a,b){return"boolean"==typeof b?b:0===Object.keys(b).length||(f(a,b),!g(b,a.self.RULES.all))},a.checkUnknownRules=f,a.schemaHasRules=g,a.schemaHasRulesButRef=function(a,b){if("boolean"==typeof a)return!a;for(let c in a)if("$ref"!==c&&b.all[c])return!0;return!1},a.schemaRefOrVal=function({topSchemaRef:a,schemaPath:b},c,e,f){if(!f){if("number"==typeof c||"boolean"==typeof c)return c;if("string"==typeof c)return(0,d._)`${c}`}return(0,d._)`${a}${b}${(0,d.getProperty)(e)}`},a.unescapeFragment=function(a){return i(decodeURIComponent(a))},a.escapeFragment=function(a){return encodeURIComponent(h(a))},a.escapeJsonPointer=h,a.unescapeJsonPointer=i,a.eachItem=function(a,b){if(Array.isArray(a))for(let c of a)b(c);else b(a)},a.mergeEvaluated={props:j({mergeNames:(a,b,c)=>a.if((0,d._)`${c} !== true && ${b} !== undefined`,()=>{a.if((0,d._)`${b} === true`,()=>a.assign(c,!0),()=>a.assign(c,(0,d._)`${c} || {}`).code((0,d._)`Object.assign(${c}, ${b})`))}),mergeToName:(a,b,c)=>a.if((0,d._)`${c} !== true`,()=>{!0===b?a.assign(c,!0):(a.assign(c,(0,d._)`${c} || {}`),l(a,c,b))}),mergeValues:(a,b)=>!0===a||{...a,...b},resultToName:k}),items:j({mergeNames:(a,b,c)=>a.if((0,d._)`${c} !== true && ${b} !== undefined`,()=>a.assign(c,(0,d._)`${b} === true ? true : ${c} > ${b} ? ${c} : ${b}`)),mergeToName:(a,b,c)=>a.if((0,d._)`${c} !== true`,()=>a.assign(c,!0===b||(0,d._)`${c} > ${b} ? ${c} : ${b}`)),mergeValues:(a,b)=>!0===a||Math.max(a,b),resultToName:(a,b)=>a.var("items",b)})},a.evaluatedPropsToName=k,a.setEvaluated=l;let m={};function n(a,b,c=a.opts.strictSchema){if(c){if(b=`strict mode: ${b}`,!0===c)throw Error(b);a.self.logger.warn(b)}}a.useFunc=function(a,b){return a.scopeValue("func",{ref:b,code:m[b.code]||(m[b.code]=new e._Code(b.code))})},(c=b||(a.Type=b={}))[c.Num=0]="Num",c[c.Str=1]="Str",a.getErrorPath=function(a,c,e){if(a instanceof d.Name){let f=c===b.Num;return e?f?(0,d._)`"[" + ${a} + "]"`:(0,d._)`"['" + ${a} + "']"`:f?(0,d._)`"/" + ${a}`:(0,d._)`"/" + ${a}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return e?(0,d.getProperty)(a).toString():"/"+h(a)},a.checkStrictMode=n}),eV=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT();a.default={data:new b.Name("data"),valCxt:new b.Name("valCxt"),instancePath:new b.Name("instancePath"),parentData:new b.Name("parentData"),parentDataProperty:new b.Name("parentDataProperty"),rootData:new b.Name("rootData"),dynamicAnchors:new b.Name("dynamicAnchors"),vErrors:new b.Name("vErrors"),errors:new b.Name("errors"),this:new b.Name("this"),self:new b.Name("self"),scope:new b.Name("scope"),json:new b.Name("json"),jsonPos:new b.Name("jsonPos"),jsonLen:new b.Name("jsonLen"),jsonPart:new b.Name("jsonPart")}}),eW=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.extendErrors=a.resetErrorsCount=a.reportExtraError=a.reportError=a.keyword$DataError=a.keywordError=void 0;let b=eT(),c=eU(),d=eV();function e(a,c){let e=a.const("err",c);a.if((0,b._)`${d.default.vErrors} === null`,()=>a.assign(d.default.vErrors,(0,b._)`[${e}]`),(0,b._)`${d.default.vErrors}.push(${e})`),a.code((0,b._)`${d.default.errors}++`)}function f(a,c){let{gen:d,validateName:e,schemaEnv:f}=a;f.$async?d.throw((0,b._)`new ${a.ValidationError}(${c})`):(d.assign((0,b._)`${e}.errors`,c),d.return(!1))}a.keywordError={message:({keyword:a})=>(0,b.str)`must pass "${a}" keyword validation`},a.keyword$DataError={message:({keyword:a,schemaType:c})=>c?(0,b.str)`"${a}" keyword must be ${c} ($data)`:(0,b.str)`"${a}" keyword is invalid ($data)`},a.reportError=function(c,d=a.keywordError,g,i){let{it:j}=c,{gen:k,compositeRule:l,allErrors:m}=j,n=h(c,d,g);(null!=i?i:l||m)?e(k,n):f(j,(0,b._)`[${n}]`)},a.reportExtraError=function(b,c=a.keywordError,g){let{it:i}=b,{gen:j,compositeRule:k,allErrors:l}=i;e(j,h(b,c,g)),k||l||f(i,d.default.vErrors)},a.resetErrorsCount=function(a,c){a.assign(d.default.errors,c),a.if((0,b._)`${d.default.vErrors} !== null`,()=>a.if(c,()=>a.assign((0,b._)`${d.default.vErrors}.length`,c),()=>a.assign(d.default.vErrors,null)))},a.extendErrors=function({gen:a,keyword:c,schemaValue:e,data:f,errsCount:g,it:h}){if(void 0===g)throw Error("ajv implementation error");let i=a.name("err");a.forRange("i",g,d.default.errors,g=>{a.const(i,(0,b._)`${d.default.vErrors}[${g}]`),a.if((0,b._)`${i}.instancePath === undefined`,()=>a.assign((0,b._)`${i}.instancePath`,(0,b.strConcat)(d.default.instancePath,h.errorPath))),a.assign((0,b._)`${i}.schemaPath`,(0,b.str)`${h.errSchemaPath}/${c}`),h.opts.verbose&&(a.assign((0,b._)`${i}.schema`,e),a.assign((0,b._)`${i}.data`,f))})};let g={keyword:new b.Name("keyword"),schemaPath:new b.Name("schemaPath"),params:new b.Name("params"),propertyName:new b.Name("propertyName"),message:new b.Name("message"),schema:new b.Name("schema"),parentSchema:new b.Name("parentSchema")};function h(a,e,f){let{createErrors:h}=a.it;return!1===h?(0,b._)`{}`:function(a,e,f={}){let{gen:h,it:i}=a,j=[function({errorPath:a},{instancePath:e}){let f=e?(0,b.str)`${a}${(0,c.getErrorPath)(e,c.Type.Str)}`:a;return[d.default.instancePath,(0,b.strConcat)(d.default.instancePath,f)]}(i,f),function({keyword:a,it:{errSchemaPath:d}},{schemaPath:e,parentSchema:f}){let h=f?d:(0,b.str)`${d}/${a}`;return e&&(h=(0,b.str)`${h}${(0,c.getErrorPath)(e,c.Type.Str)}`),[g.schemaPath,h]}(a,f)];return function(a,{params:c,message:e},f){let{keyword:h,data:i,schemaValue:j,it:k}=a,{opts:l,propertyName:m,topSchemaRef:n,schemaPath:o}=k;f.push([g.keyword,h],[g.params,"function"==typeof c?c(a):c||(0,b._)`{}`]),l.messages&&f.push([g.message,"function"==typeof e?e(a):e]),l.verbose&&f.push([g.schema,j],[g.parentSchema,(0,b._)`${n}${o}`],[d.default.data,i]),m&&f.push([g.propertyName,m])}(a,e,j),h.object(...j)}(a,e,f)}}),eX=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.boolOrEmptySchema=a.topBoolOrEmptySchema=void 0;let b=eW(),c=eT(),d=eV(),e={message:"boolean schema is false"};function f(a,c){let{gen:d,data:f}=a;(0,b.reportError)({gen:d,keyword:"false schema",data:f,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:a},e,void 0,c)}a.topBoolOrEmptySchema=function(a){let{gen:b,schema:e,validateName:g}=a;!1===e?f(a,!1):"object"==typeof e&&!0===e.$async?b.return(d.default.data):(b.assign((0,c._)`${g}.errors`,null),b.return(!0))},a.boolOrEmptySchema=function(a,b){let{gen:c,schema:d}=a;!1===d?(c.var(b,!1),f(a)):c.var(b,!0)}}),eY=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getRules=a.isJSONType=void 0;let b=new Set(["string","number","integer","boolean","null","object","array"]);a.isJSONType=function(a){return"string"==typeof a&&b.has(a)},a.getRules=function(){let a={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...a,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},a.number,a.string,a.array,a.object],post:{rules:[]},all:{},keywords:{}}}}),eZ=y(a=>{function b(a,b){return b.rules.some(b=>c(a,b))}function c(a,b){var c;return void 0!==a[b.keyword]||(null==(c=b.definition.implements)?void 0:c.some(b=>void 0!==a[b]))}Object.defineProperty(a,"__esModule",{value:!0}),a.shouldUseRule=a.shouldUseGroup=a.schemaHasRulesForType=void 0,a.schemaHasRulesForType=function({schema:a,self:c},d){let e=c.RULES.types[d];return e&&!0!==e&&b(a,e)},a.shouldUseGroup=b,a.shouldUseRule=c}),e$=y(a=>{var b,c;Object.defineProperty(a,"__esModule",{value:!0}),a.reportTypeError=a.checkDataTypes=a.checkDataType=a.coerceAndCheckDataType=a.getJSONTypes=a.getSchemaTypes=a.DataType=void 0;let d=eY(),e=eZ(),f=eW(),g=eT(),h=eU();function i(a){let b=Array.isArray(a)?a:a?[a]:[];if(b.every(d.isJSONType))return b;throw Error("type must be JSONType or JSONType[]: "+b.join(","))}(c=b||(a.DataType=b={}))[c.Correct=0]="Correct",c[c.Wrong=1]="Wrong",a.getSchemaTypes=function(a){let b=i(a.type);if(b.includes("null")){if(!1===a.nullable)throw Error("type: null contradicts nullable: false")}else{if(!b.length&&void 0!==a.nullable)throw Error('"nullable" cannot be used without "type"');!0===a.nullable&&b.push("null")}return b},a.getJSONTypes=i,a.coerceAndCheckDataType=function(a,c){var d,f;let{gen:h,data:i,opts:k}=a,m=(d=c,(f=k.coerceTypes)?d.filter(a=>j.has(a)||"array"===f&&"array"===a):[]),o=c.length>0&&!(0===m.length&&1===c.length&&(0,e.schemaHasRulesForType)(a,c[0]));if(o){let d=l(c,i,k.strictNumbers,b.Wrong);h.if(d,()=>{m.length?function(a,b,c){let{gen:d,data:e,opts:f}=a,h=d.let("dataType",(0,g._)`typeof ${e}`),i=d.let("coerced",(0,g._)`undefined`);for(let a of("array"===f.coerceTypes&&d.if((0,g._)`${h} == 'object' && Array.isArray(${e}) && ${e}.length == 1`,()=>d.assign(e,(0,g._)`${e}[0]`).assign(h,(0,g._)`typeof ${e}`).if(l(b,e,f.strictNumbers),()=>d.assign(i,e))),d.if((0,g._)`${i} !== undefined`),c))(j.has(a)||"array"===a&&"array"===f.coerceTypes)&&function(a){switch(a){case"string":d.elseIf((0,g._)`${h} == "number" || ${h} == "boolean"`).assign(i,(0,g._)`"" + ${e}`).elseIf((0,g._)`${e} === null`).assign(i,(0,g._)`""`);return;case"number":d.elseIf((0,g._)`${h} == "boolean" || ${e} === null
|
|
2
3
|
|| (${h} == "string" && ${e} && ${e} == +${e})`).assign(i,(0,g._)`+${e}`);return;case"integer":d.elseIf((0,g._)`${h} === "boolean" || ${e} === null
|
|
3
4
|
|| (${h} === "string" && ${e} && ${e} == +${e} && !(${e} % 1))`).assign(i,(0,g._)`+${e}`);return;case"boolean":d.elseIf((0,g._)`${e} === "false" || ${e} === 0 || ${e} === null`).assign(i,!1).elseIf((0,g._)`${e} === "true" || ${e} === 1`).assign(i,!0);return;case"null":d.elseIf((0,g._)`${e} === "" || ${e} === 0 || ${e} === false`),d.assign(i,null);return;case"array":d.elseIf((0,g._)`${h} === "string" || ${h} === "number"
|
|
4
5
|
|| ${h} === "boolean" || ${e} === null`).assign(i,(0,g._)`[${e}]`)}}(a);d.else(),n(a),d.endIf(),d.if((0,g._)`${i} !== undefined`,()=>{d.assign(e,i),function({gen:a,parentData:b,parentDataProperty:c},d){a.if((0,g._)`${b} !== undefined`,()=>a.assign((0,g._)`${b}[${c}]`,d))}(a,i)})}(a,c,m):n(a)})}return o};let j=new Set(["string","number","integer","boolean","null"]);function k(a,c,d,e=b.Correct){let f,h=e===b.Correct?g.operators.EQ:g.operators.NEQ;switch(a){case"null":return(0,g._)`${c} ${h} null`;case"array":f=(0,g._)`Array.isArray(${c})`;break;case"object":f=(0,g._)`${c} && typeof ${c} == "object" && !Array.isArray(${c})`;break;case"integer":f=i((0,g._)`!(${c} % 1) && !isNaN(${c})`);break;case"number":f=i();break;default:return(0,g._)`typeof ${c} ${h} ${a}`}return e===b.Correct?f:(0,g.not)(f);function i(a=g.nil){return(0,g.and)((0,g._)`typeof ${c} == "number"`,a,d?(0,g._)`isFinite(${c})`:g.nil)}}function l(a,b,c,d){let e;if(1===a.length)return k(a[0],b,c,d);let f=(0,h.toHash)(a);if(f.array&&f.object){let a=(0,g._)`typeof ${b} != "object"`;e=f.null?a:(0,g._)`!${b} || ${a}`,delete f.null,delete f.array,delete f.object}else e=g.nil;for(let a in f.number&&delete f.integer,f)e=(0,g.and)(e,k(a,b,c,d));return e}a.checkDataType=k,a.checkDataTypes=l;let m={message:({schema:a})=>`must be ${a}`,params:({schema:a,schemaValue:b})=>"string"==typeof a?(0,g._)`{type: ${a}}`:(0,g._)`{type: ${b}}`};function n(a){let b=function(a){let{gen:b,data:c,schema:d}=a,e=(0,h.schemaRefOrVal)(a,d,"type");return{gen:b,keyword:"type",data:c,schema:d.type,schemaCode:e,schemaValue:e,parentSchema:d,params:{},it:a}}(a);(0,f.reportError)(b,m)}a.reportTypeError=n}),e_=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.assignDefaults=void 0;let b=eT(),c=eU();function d(a,d,e){let{gen:f,compositeRule:g,data:h,opts:i}=a;if(void 0===e)return;let j=(0,b._)`${h}${(0,b.getProperty)(d)}`;if(g)return void(0,c.checkStrictMode)(a,`default is ignored for: ${j}`);let k=(0,b._)`${j} === undefined`;"empty"===i.useDefaults&&(k=(0,b._)`${k} || ${j} === null || ${j} === ""`),f.if(k,(0,b._)`${j} = ${(0,b.stringify)(e)}`)}a.assignDefaults=function(a,b){let{properties:c,items:e}=a.schema;if("object"===b&&c)for(let b in c)d(a,b,c[b].default);else"array"===b&&Array.isArray(e)&&e.forEach((b,c)=>d(a,c,b.default))}}),e0=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.validateUnion=a.validateArray=a.usePattern=a.callValidateCode=a.schemaProperties=a.allSchemaProperties=a.noPropertyInData=a.propertyInData=a.isOwnProperty=a.hasPropFunc=a.reportMissingProp=a.checkMissingProp=a.checkReportMissingProp=void 0;let b=eT(),c=eU(),d=eV(),e=eU();function f(a){return a.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,b._)`Object.prototype.hasOwnProperty`})}function g(a,c,d){return(0,b._)`${f(a)}.call(${c}, ${d})`}function h(a,c,d,e){let f=(0,b._)`${c}${(0,b.getProperty)(d)} === undefined`;return e?(0,b.or)(f,(0,b.not)(g(a,c,d))):f}function i(a){return a?Object.keys(a).filter(a=>"__proto__"!==a):[]}a.checkReportMissingProp=function(a,c){let{gen:d,data:e,it:f}=a;d.if(h(d,e,c,f.opts.ownProperties),()=>{a.setParams({missingProperty:(0,b._)`${c}`},!0),a.error()})},a.checkMissingProp=function({gen:a,data:c,it:{opts:d}},e,f){return(0,b.or)(...e.map(e=>(0,b.and)(h(a,c,e,d.ownProperties),(0,b._)`${f} = ${e}`)))},a.reportMissingProp=function(a,b){a.setParams({missingProperty:b},!0),a.error()},a.hasPropFunc=f,a.isOwnProperty=g,a.propertyInData=function(a,c,d,e){let f=(0,b._)`${c}${(0,b.getProperty)(d)} !== undefined`;return e?(0,b._)`${f} && ${g(a,c,d)}`:f},a.noPropertyInData=h,a.allSchemaProperties=i,a.schemaProperties=function(a,b){return i(b).filter(d=>!(0,c.alwaysValidSchema)(a,b[d]))},a.callValidateCode=function({schemaCode:a,data:c,it:{gen:e,topSchemaRef:f,schemaPath:g,errorPath:h},it:i},j,k,l){let m=l?(0,b._)`${a}, ${c}, ${f}${g}`:c,n=[[d.default.instancePath,(0,b.strConcat)(d.default.instancePath,h)],[d.default.parentData,i.parentData],[d.default.parentDataProperty,i.parentDataProperty],[d.default.rootData,d.default.rootData]];i.opts.dynamicRef&&n.push([d.default.dynamicAnchors,d.default.dynamicAnchors]);let o=(0,b._)`${m}, ${e.object(...n)}`;return k!==b.nil?(0,b._)`${j}.call(${k}, ${o})`:(0,b._)`${j}(${o})`};let j=(0,b._)`new RegExp`;a.usePattern=function({gen:a,it:{opts:c}},d){let f=c.unicodeRegExp?"u":"",{regExp:g}=c.code,h=g(d,f);return a.scopeValue("pattern",{key:h.toString(),ref:h,code:(0,b._)`${"new RegExp"===g.code?j:(0,e.useFunc)(a,g)}(${d}, ${f})`})},a.validateArray=function(a){let{gen:d,data:e,keyword:f,it:g}=a,h=d.name("valid");if(g.allErrors){let a=d.let("valid",!0);return i(()=>d.assign(a,!1)),a}return d.var(h,!0),i(()=>d.break()),h;function i(g){let i=d.const("len",(0,b._)`${e}.length`);d.forRange("i",0,i,e=>{a.subschema({keyword:f,dataProp:e,dataPropType:c.Type.Num},h),d.if((0,b.not)(h),g)})}},a.validateUnion=function(a){let{gen:d,schema:e,keyword:f,it:g}=a;if(!Array.isArray(e))throw Error("ajv implementation error");if(e.some(a=>(0,c.alwaysValidSchema)(g,a))&&!g.opts.unevaluated)return;let h=d.let("valid",!1),i=d.name("_valid");d.block(()=>e.forEach((c,e)=>{let g=a.subschema({keyword:f,schemaProp:e,compositeRule:!0},i);d.assign(h,(0,b._)`${h} || ${i}`),a.mergeValidEvaluated(g,i)||d.if((0,b.not)(h))})),a.result(h,()=>a.reset(),()=>a.error(!0))}}),e1=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.validateKeywordUsage=a.validSchemaType=a.funcKeywordCode=a.macroKeywordCode=void 0;let b=eT(),c=eV(),d=e0(),e=eW();function f(a){let{gen:c,data:d,it:e}=a;c.if(e.parentData,()=>c.assign(d,(0,b._)`${e.parentData}[${e.parentDataProperty}]`))}function g(a,c,d){if(void 0===d)throw Error(`keyword "${c}" failed to compile`);return a.scopeValue("keyword","function"==typeof d?{ref:d}:{ref:d,code:(0,b.stringify)(d)})}a.macroKeywordCode=function(a,c){let{gen:d,keyword:e,schema:f,parentSchema:h,it:i}=a,j=c.macro.call(i.self,f,h,i),k=g(d,e,j);!1!==i.opts.validateSchema&&i.self.validateSchema(j,!0);let l=d.name("valid");a.subschema({schema:j,schemaPath:b.nil,errSchemaPath:`${i.errSchemaPath}/${e}`,topSchemaRef:k,compositeRule:!0},l),a.pass(l,()=>a.error(!0))},a.funcKeywordCode=function(a,h){var i;let{gen:j,keyword:k,schema:l,parentSchema:m,$data:n,it:o}=a;!function({schemaEnv:a},b){if(b.async&&!a.$async)throw Error("async keyword in sync schema")}(o,h);let p=g(j,k,!n&&h.compile?h.compile.call(o.self,l,m,o):h.validate),q=j.let("valid");function r(e=h.async?(0,b._)`await `:b.nil){let f=o.opts.passContext?c.default.this:c.default.self,g=!("compile"in h&&!n||!1===h.schema);j.assign(q,(0,b._)`${e}${(0,d.callValidateCode)(a,p,f,g)}`,h.modifying)}function s(a){var c;j.if((0,b.not)(null!=(c=h.valid)?c:q),a)}a.block$data(q,function(){if(!1===h.errors)r(),h.modifying&&f(a),s(()=>a.error());else{let d,g,i=h.async?(d=j.let("ruleErrs",null),j.try(()=>r((0,b._)`await `),a=>j.assign(q,!1).if((0,b._)`${a} instanceof ${o.ValidationError}`,()=>j.assign(d,(0,b._)`${a}.errors`),()=>j.throw(a))),d):(g=(0,b._)`${p}.errors`,j.assign(g,null),r(b.nil),g);h.modifying&&f(a),s(()=>(function(a,d){let{gen:f}=a;f.if((0,b._)`Array.isArray(${d})`,()=>{f.assign(c.default.vErrors,(0,b._)`${c.default.vErrors} === null ? ${d} : ${c.default.vErrors}.concat(${d})`).assign(c.default.errors,(0,b._)`${c.default.vErrors}.length`),(0,e.extendErrors)(a)},()=>a.error())})(a,i))}}),a.ok(null!=(i=h.valid)?i:q)},a.validSchemaType=function(a,b,c=!1){return!b.length||b.some(b=>"array"===b?Array.isArray(a):"object"===b?a&&"object"==typeof a&&!Array.isArray(a):typeof a==b||c&&void 0===a)},a.validateKeywordUsage=function({schema:a,opts:b,self:c,errSchemaPath:d},e,f){if(Array.isArray(e.keyword)?!e.keyword.includes(f):e.keyword!==f)throw Error("ajv implementation error");let g=e.dependencies;if(null==g?void 0:g.some(b=>!Object.prototype.hasOwnProperty.call(a,b)))throw Error(`parent schema must have dependencies of ${f}: ${g.join(",")}`);if(e.validateSchema&&!e.validateSchema(a[f])){let a=`keyword "${f}" value is invalid at path "${d}": `+c.errorsText(e.validateSchema.errors);if("log"===b.validateSchema)c.logger.error(a);else throw Error(a)}}}),e2=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.extendSubschemaMode=a.extendSubschemaData=a.getSubschema=void 0;let b=eT(),c=eU();a.getSubschema=function(a,{keyword:d,schemaProp:e,schema:f,schemaPath:g,errSchemaPath:h,topSchemaRef:i}){if(void 0!==d&&void 0!==f)throw Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==d){let f=a.schema[d];return void 0===e?{schema:f,schemaPath:(0,b._)`${a.schemaPath}${(0,b.getProperty)(d)}`,errSchemaPath:`${a.errSchemaPath}/${d}`}:{schema:f[e],schemaPath:(0,b._)`${a.schemaPath}${(0,b.getProperty)(d)}${(0,b.getProperty)(e)}`,errSchemaPath:`${a.errSchemaPath}/${d}/${(0,c.escapeFragment)(e)}`}}if(void 0!==f){if(void 0===g||void 0===h||void 0===i)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:f,schemaPath:g,topSchemaRef:i,errSchemaPath:h}}throw Error('either "keyword" or "schema" must be passed')},a.extendSubschemaData=function(a,d,{dataProp:e,dataPropType:f,data:g,dataTypes:h,propertyName:i}){if(void 0!==g&&void 0!==e)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:j}=d;if(void 0!==e){let{errorPath:g,dataPathArr:h,opts:i}=d;k(j.let("data",(0,b._)`${d.data}${(0,b.getProperty)(e)}`,!0)),a.errorPath=(0,b.str)`${g}${(0,c.getErrorPath)(e,f,i.jsPropertySyntax)}`,a.parentDataProperty=(0,b._)`${e}`,a.dataPathArr=[...h,a.parentDataProperty]}function k(b){a.data=b,a.dataLevel=d.dataLevel+1,a.dataTypes=[],d.definedProperties=new Set,a.parentData=d.data,a.dataNames=[...d.dataNames,b]}void 0!==g&&(k(g instanceof b.Name?g:j.let("data",g,!0)),void 0!==i&&(a.propertyName=i)),h&&(a.dataTypes=h)},a.extendSubschemaMode=function(a,{jtdDiscriminator:b,jtdMetadata:c,compositeRule:d,createErrors:e,allErrors:f}){void 0!==d&&(a.compositeRule=d),void 0!==e&&(a.createErrors=e),void 0!==f&&(a.allErrors=f),a.jtdDiscriminator=b,a.jtdMetadata=c}}),e3=y((a,b)=>{b.exports=function a(b,c){if(b===c)return!0;if(b&&c&&"object"==typeof b&&"object"==typeof c){if(b.constructor!==c.constructor)return!1;if(Array.isArray(b)){if((d=b.length)!=c.length)return!1;for(e=d;0!=e--;)if(!a(b[e],c[e]))return!1;return!0}if(b.constructor===RegExp)return b.source===c.source&&b.flags===c.flags;if(b.valueOf!==Object.prototype.valueOf)return b.valueOf()===c.valueOf();if(b.toString!==Object.prototype.toString)return b.toString()===c.toString();if((d=(f=Object.keys(b)).length)!==Object.keys(c).length)return!1;for(e=d;0!=e--;)if(!Object.prototype.hasOwnProperty.call(c,f[e]))return!1;for(e=d;0!=e--;){var d,e,f,g=f[e];if(!a(b[g],c[g]))return!1}return!0}return b!=b&&c!=c}}),e4=y((a,b)=>{var c=b.exports=function(a,b,d){"function"==typeof b&&(d=b,b={});var e="function"==typeof(d=b.cb||d)?d:d.pre||function(){};!function a(b,d,e,f,g,h,i,j,k,l){if(f&&"object"==typeof f&&!Array.isArray(f)){for(var m in d(f,g,h,i,j,k,l),f){var n=f[m];if(Array.isArray(n)){if(m in c.arrayKeywords)for(var o=0;o<n.length;o++)a(b,d,e,n[o],g+"/"+m+"/"+o,h,g,m,f,o)}else if(m in c.propsKeywords){if(n&&"object"==typeof n)for(var p in n)a(b,d,e,n[p],g+"/"+m+"/"+p.replace(/~/g,"~0").replace(/\//g,"~1"),h,g,m,f,p)}else(m in c.keywords||b.allKeys&&!(m in c.skipKeywords))&&a(b,d,e,n,g+"/"+m,h,g,m,f)}e(f,g,h,i,j,k,l)}}(b,e,d.post||function(){},a,"",a)};c.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},c.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},c.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},c.skipKeywords={default:!0,enum:!0,const:!0,required:!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}}),e5=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getSchemaRefs=a.resolveUrl=a.normalizeId=a._getFullPath=a.getFullPath=a.inlineRef=void 0;let b=eU(),c=e3(),d=e4(),e=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);a.inlineRef=function(a,c=!0){return"boolean"==typeof a||(!0===c?!function a(b){for(let c in b){if(f.has(c))return!0;let d=b[c];if(Array.isArray(d)&&d.some(a)||"object"==typeof d&&a(d))return!0}return!1}(a):!!c&&function a(c){let d=0;for(let f in c)if("$ref"===f||(d++,!e.has(f)&&("object"==typeof c[f]&&(0,b.eachItem)(c[f],b=>d+=a(b)),d===1/0)))return 1/0;return d}(a)<=c)};let f=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function g(a,b="",c){return!1!==c&&(b=j(b)),h(a,a.parse(b))}function h(a,b){return a.serialize(b).split("#")[0]+"#"}a.getFullPath=g,a._getFullPath=h;let i=/#\/?$/;function j(a){return a?a.replace(i,""):""}a.normalizeId=j,a.resolveUrl=function(a,b,c){return c=j(c),a.resolve(b,c)};let k=/^[a-z_][-a-z0-9._]*$/i;a.getSchemaRefs=function(a,b){if("boolean"==typeof a)return{};let{schemaId:e,uriResolver:f}=this.opts,h=j(a[e]||b),i={"":h},l=g(f,h,!1),m={},n=new Set;return d(a,{allKeys:!0},(a,b,c,d)=>{if(void 0===d)return;let f=l+b,g=i[d];function h(b){let c=this.opts.uriResolver.resolve;if(b=j(g?c(g,b):b),n.has(b))throw p(b);n.add(b);let d=this.refs[b];return"string"==typeof d&&(d=this.refs[d]),"object"==typeof d?o(a,d.schema,b):b!==j(f)&&("#"===b[0]?(o(a,m[b],b),m[b]=a):this.refs[b]=f),b}function q(a){if("string"==typeof a){if(!k.test(a))throw Error(`invalid anchor "${a}"`);h.call(this,`#${a}`)}}"string"==typeof a[e]&&(g=h.call(this,a[e])),q.call(this,a.$anchor),q.call(this,a.$dynamicAnchor),i[b]=g}),m;function o(a,b,d){if(void 0!==b&&!c(a,b))throw p(d)}function p(a){return Error(`reference "${a}" resolves to more than one schema`)}}}),e6=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getData=a.KeywordCxt=a.validateFunctionCode=void 0;let b=eX(),c=e$(),d=eZ(),e=e$(),f=e_(),g=e1(),h=e2(),i=eT(),j=eV(),k=e5(),l=eU(),m=eW();function n({gen:a,validateName:b,schema:c,schemaEnv:d,opts:e},f){var g;e.code.es5?a.func(b,(0,i._)`${j.default.data}, ${j.default.valCxt}`,d.$async,()=>{var b,d;a.code((0,i._)`"use strict"; ${o(c,e)}`),b=a,d=e,b.if(j.default.valCxt,()=>{b.var(j.default.instancePath,(0,i._)`${j.default.valCxt}.${j.default.instancePath}`),b.var(j.default.parentData,(0,i._)`${j.default.valCxt}.${j.default.parentData}`),b.var(j.default.parentDataProperty,(0,i._)`${j.default.valCxt}.${j.default.parentDataProperty}`),b.var(j.default.rootData,(0,i._)`${j.default.valCxt}.${j.default.rootData}`),d.dynamicRef&&b.var(j.default.dynamicAnchors,(0,i._)`${j.default.valCxt}.${j.default.dynamicAnchors}`)},()=>{b.var(j.default.instancePath,(0,i._)`""`),b.var(j.default.parentData,(0,i._)`undefined`),b.var(j.default.parentDataProperty,(0,i._)`undefined`),b.var(j.default.rootData,j.default.data),d.dynamicRef&&b.var(j.default.dynamicAnchors,(0,i._)`{}`)}),a.code(f)}):a.func(b,(0,i._)`${j.default.data}, ${(g=e,(0,i._)`{${j.default.instancePath}="", ${j.default.parentData}, ${j.default.parentDataProperty}, ${j.default.rootData}=${j.default.data}${g.dynamicRef?(0,i._)`, ${j.default.dynamicAnchors}={}`:i.nil}}={}`)}`,d.$async,()=>a.code(o(c,e)).code(f))}function o(a,b){let c="object"==typeof a&&a[b.schemaId];return c&&(b.code.source||b.code.process)?(0,i._)`/*# sourceURL=${c} */`:i.nil}function p({schema:a,self:b}){if("boolean"==typeof a)return!a;for(let c in a)if(b.RULES.all[c])return!0;return!1}function q(a){return"boolean"!=typeof a.schema}function r(a){(0,l.checkUnknownRules)(a),function(a){let{schema:b,errSchemaPath:c,opts:d,self:e}=a;b.$ref&&d.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(b,e.RULES)&&e.logger.warn(`$ref: keywords ignored in schema at path "${c}"`)}(a)}function s(a,b){if(a.opts.jtd)return u(a,[],!1,b);let d=(0,c.getSchemaTypes)(a.schema);u(a,d,!(0,c.coerceAndCheckDataType)(a,d),b)}function t({gen:a,schemaEnv:b,schema:c,errSchemaPath:d,opts:e}){let f=c.$comment;if(!0===e.$comment)a.code((0,i._)`${j.default.self}.logger.log(${f})`);else if("function"==typeof e.$comment){let c=(0,i.str)`${d}/$comment`,e=a.scopeValue("root",{ref:b.root});a.code((0,i._)`${j.default.self}.opts.$comment(${f}, ${c}, ${e}.schema)`)}}function u(a,b,c,f){var g,h,k,m;let{gen:n,schema:o,data:p,allErrors:q,opts:r,self:s}=a,{RULES:t}=s;if(o.$ref&&(r.ignoreKeywordsWithRef||!(0,l.schemaHasRulesButRef)(o,t)))return void n.block(()=>z(a,"$ref",t.all.$ref.definition));function u(g){(0,d.shouldUseGroup)(o,g)&&(g.type?(n.if((0,e.checkDataType)(g.type,p,r.strictNumbers)),v(a,g),1===b.length&&b[0]===g.type&&c&&(n.else(),(0,e.reportTypeError)(a)),n.endIf()):v(a,g),q||n.if((0,i._)`${j.default.errors} === ${f||0}`))}r.jtd||(g=a,h=b,!g.schemaEnv.meta&&g.opts.strictTypes&&(function(a,b){if(b.length){if(!a.dataTypes.length){a.dataTypes=b;return}b.forEach(b=>{w(a.dataTypes,b)||x(a,`type "${b}" not allowed by context "${a.dataTypes.join(",")}"`)}),function(a,b){let c=[];for(let d of a.dataTypes)w(b,d)?c.push(d):b.includes("integer")&&"number"===d&&c.push("integer");a.dataTypes=c}(a,b)}}(g,h),g.opts.allowUnionTypes||(k=g,(m=h).length>1&&!(2===m.length&&m.includes("null"))&&x(k,"use allowUnionTypes to allow union type keyword")),function(a,b){let c=a.self.RULES.all;for(let e in c){let f=c[e];if("object"==typeof f&&(0,d.shouldUseRule)(a.schema,f)){let{type:c}=f.definition;c.length&&!c.some(a=>{var c,d;return c=b,d=a,c.includes(d)||"number"===d&&c.includes("integer")})&&x(a,`missing type "${c.join(",")}" for keyword "${e}"`)}}}(g,g.dataTypes))),n.block(()=>{for(let a of t.rules)u(a);u(t.post)})}function v(a,b){let{gen:c,schema:e,opts:{useDefaults:g}}=a;g&&(0,f.assignDefaults)(a,b.type),c.block(()=>{for(let c of b.rules)(0,d.shouldUseRule)(e,c)&&z(a,c.keyword,c.definition,b.type)})}function w(a,b){return a.includes(b)||"integer"===b&&a.includes("number")}function x(a,b){let c=a.schemaEnv.baseId+a.errSchemaPath;b+=` at "${c}" (strictTypes)`,(0,l.checkStrictMode)(a,b,a.opts.strictTypes)}a.validateFunctionCode=function(a){q(a)&&(r(a),p(a))?function(a){let{schema:b,opts:c,gen:d}=a;n(a,()=>{c.$comment&&b.$comment&&t(a),function(a){let{schema:b,opts:c}=a;void 0!==b.default&&c.useDefaults&&c.strictSchema&&(0,l.checkStrictMode)(a,"default is ignored in the schema root")}(a),d.let(j.default.vErrors,null),d.let(j.default.errors,0),c.unevaluated&&function(a){let{gen:b,validateName:c}=a;a.evaluated=b.const("evaluated",(0,i._)`${c}.evaluated`),b.if((0,i._)`${a.evaluated}.dynamicProps`,()=>b.assign((0,i._)`${a.evaluated}.props`,(0,i._)`undefined`)),b.if((0,i._)`${a.evaluated}.dynamicItems`,()=>b.assign((0,i._)`${a.evaluated}.items`,(0,i._)`undefined`))}(a),s(a),function(a){let{gen:b,schemaEnv:c,validateName:d,ValidationError:e,opts:f}=a;c.$async?b.if((0,i._)`${j.default.errors} === 0`,()=>b.return(j.default.data),()=>b.throw((0,i._)`new ${e}(${j.default.vErrors})`)):(b.assign((0,i._)`${d}.errors`,j.default.vErrors),f.unevaluated&&function({gen:a,evaluated:b,props:c,items:d}){c instanceof i.Name&&a.assign((0,i._)`${b}.props`,c),d instanceof i.Name&&a.assign((0,i._)`${b}.items`,d)}(a),b.return((0,i._)`${j.default.errors} === 0`))}(a)})}(a):n(a,()=>(0,b.topBoolOrEmptySchema)(a))};var y=class{constructor(a,b,c){if((0,g.validateKeywordUsage)(a,b,c),this.gen=a.gen,this.allErrors=a.allErrors,this.keyword=c,this.data=a.data,this.schema=a.schema[c],this.$data=b.$data&&a.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(a,this.schema,c,this.$data),this.schemaType=b.schemaType,this.parentSchema=a.schema,this.params={},this.it=a,this.def=b,this.$data)this.schemaCode=a.gen.const("vSchema",C(this.$data,a));else if(this.schemaCode=this.schemaValue,!(0,g.validSchemaType)(this.schema,b.schemaType,b.allowUndefined))throw Error(`${c} value must be ${JSON.stringify(b.schemaType)}`);("code"in b?b.trackErrors:!1!==b.errors)&&(this.errsCount=a.gen.const("_errs",j.default.errors))}result(a,b,c){this.failResult((0,i.not)(a),b,c)}failResult(a,b,c){this.gen.if(a),c?c():this.error(),b?(this.gen.else(),b(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(a,b){this.failResult((0,i.not)(a),void 0,b)}fail(a){if(void 0===a){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(a),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(a){if(!this.$data)return this.fail(a);let{schemaCode:b}=this;this.fail((0,i._)`${b} !== undefined && (${(0,i.or)(this.invalid$data(),a)})`)}error(a,b,c){if(b){this.setParams(b),this._error(a,c),this.setParams({});return}this._error(a,c)}_error(a,b){(a?m.reportExtraError:m.reportError)(this,this.def.error,b)}$dataError(){(0,m.reportError)(this,this.def.$dataError||m.keyword$DataError)}reset(){if(void 0===this.errsCount)throw Error('add "trackErrors" to keyword definition');(0,m.resetErrorsCount)(this.gen,this.errsCount)}ok(a){this.allErrors||this.gen.if(a)}setParams(a,b){b?Object.assign(this.params,a):this.params=a}block$data(a,b,c=i.nil){this.gen.block(()=>{this.check$data(a,c),b()})}check$data(a=i.nil,b=i.nil){if(!this.$data)return;let{gen:c,schemaCode:d,schemaType:e,def:f}=this;c.if((0,i.or)((0,i._)`${d} === undefined`,b)),a!==i.nil&&c.assign(a,!0),(e.length||f.validateSchema)&&(c.elseIf(this.invalid$data()),this.$dataError(),a!==i.nil&&c.assign(a,!1)),c.else()}invalid$data(){let{gen:a,schemaCode:b,schemaType:c,def:d,it:f}=this;return(0,i.or)(function(){if(c.length){if(!(b instanceof i.Name))throw Error("ajv implementation error");let a=Array.isArray(c)?c:[c];return(0,i._)`${(0,e.checkDataTypes)(a,b,f.opts.strictNumbers,e.DataType.Wrong)}`}return i.nil}(),function(){if(d.validateSchema){let c=a.scopeValue("validate$data",{ref:d.validateSchema});return(0,i._)`!${c}(${b})`}return i.nil}())}subschema(a,c){let d=(0,h.getSubschema)(this.it,a);(0,h.extendSubschemaData)(d,this.it,a),(0,h.extendSubschemaMode)(d,a);let e={...this.it,...d,items:void 0,props:void 0};return!function(a,c){if(q(a)&&(r(a),p(a)))return function(a,b){var c;let d,{schema:e,gen:f,opts:g}=a;g.$comment&&e.$comment&&t(a),(d=(c=a).schema[c.opts.schemaId])&&(c.baseId=(0,k.resolveUrl)(c.opts.uriResolver,c.baseId,d)),function(a){if(a.schema.$async&&!a.schemaEnv.$async)throw Error("async schema in sync schema")}(a);let h=f.const("_errs",j.default.errors);s(a,h),f.var(b,(0,i._)`${h} === ${j.default.errors}`)}(a,c);(0,b.boolOrEmptySchema)(a,c)}(e,c),e}mergeEvaluated(a,b){let{it:c,gen:d}=this;c.opts.unevaluated&&(!0!==c.props&&void 0!==a.props&&(c.props=l.mergeEvaluated.props(d,a.props,c.props,b)),!0!==c.items&&void 0!==a.items&&(c.items=l.mergeEvaluated.items(d,a.items,c.items,b)))}mergeValidEvaluated(a,b){let{it:c,gen:d}=this;if(c.opts.unevaluated&&(!0!==c.props||!0!==c.items))return d.if(b,()=>this.mergeEvaluated(a,i.Name)),!0}};function z(a,b,c,d){let e=new y(a,c,b);"code"in c?c.code(e,d):e.$data&&c.validate?(0,g.funcKeywordCode)(e,c):"macro"in c?(0,g.macroKeywordCode)(e,c):(c.compile||c.validate)&&(0,g.funcKeywordCode)(e,c)}a.KeywordCxt=y;let A=/^\/(?:[^~]|~0|~1)*$/,B=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function C(a,{dataLevel:b,dataNames:c,dataPathArr:d}){let e,f;if(""===a)return j.default.rootData;if("/"===a[0]){if(!A.test(a))throw Error(`Invalid JSON-pointer: ${a}`);e=a,f=j.default.rootData}else{let g=B.exec(a);if(!g)throw Error(`Invalid JSON-pointer: ${a}`);let i=+g[1];if("#"===(e=g[2])){if(i>=b)throw Error(h("property/index",i));return d[b-i]}if(i>b)throw Error(h("data",i));if(f=c[b-i],!e)return f}let g=f;for(let a of e.split("/"))a&&(f=(0,i._)`${f}${(0,i.getProperty)((0,l.unescapeJsonPointer)(a))}`,g=(0,i._)`${g} && ${f}`);return g;function h(a,c){return`Cannot access ${a} ${c} levels up, current level is ${b}`}}a.getData=C}),e7=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default=class extends Error{constructor(a){super("validation failed"),this.errors=a,this.ajv=this.validation=!0}}}),e8=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=e5();a.default=class extends Error{constructor(a,c,d,e){super(e||`can't resolve reference ${d} from id ${c}`),this.missingRef=(0,b.resolveUrl)(a,c,d),this.missingSchema=(0,b.normalizeId)((0,b.getFullPath)(a,this.missingRef))}}}),e9=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.resolveSchema=a.getCompilingSchema=a.resolveRef=a.compileSchema=a.SchemaEnv=void 0;let b=eT(),c=e7(),d=eV(),e=e5(),f=eU(),g=e6();var h=class{constructor(a){var b;let c;this.refs={},this.dynamicAnchors={},"object"==typeof a.schema&&(c=a.schema),this.schema=a.schema,this.schemaId=a.schemaId,this.root=a.root||this,this.baseId=null!=(b=a.baseId)?b:(0,e.normalizeId)(null==c?void 0:c[a.schemaId||"$id"]),this.schemaPath=a.schemaPath,this.localRefs=a.localRefs,this.meta=a.meta,this.$async=null==c?void 0:c.$async,this.refs={}}};function i(a){let f,h,i=k.call(this,a);if(i)return i;let j=(0,e.getFullPath)(this.opts.uriResolver,a.root.baseId),{es5:l,lines:m}=this.opts.code,{ownProperties:n}=this.opts,o=new b.CodeGen(this.scope,{es5:l,lines:m,ownProperties:n});a.$async&&(f=o.scopeValue("Error",{ref:c.default,code:(0,b._)`require("ajv/dist/runtime/validation_error").default`}));let p=o.scopeName("validate");a.validateName=p;let q={gen:o,allErrors:this.opts.allErrors,data:d.default.data,parentData:d.default.parentData,parentDataProperty:d.default.parentDataProperty,dataNames:[d.default.data],dataPathArr:[b.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",!0===this.opts.code.source?{ref:a.schema,code:(0,b.stringify)(a.schema)}:{ref:a.schema}),validateName:p,ValidationError:f,schema:a.schema,schemaEnv:a,rootId:j,baseId:a.baseId||j,schemaPath:b.nil,errSchemaPath:a.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,b._)`""`,opts:this.opts,self:this};try{this._compilations.add(a),(0,g.validateFunctionCode)(q),o.optimize(this.opts.code.optimize);let c=o.toString();h=`${o.scopeRefs(d.default.scope)}return ${c}`,this.opts.code.process&&(h=this.opts.code.process(h,a));let e=Function(`${d.default.self}`,`${d.default.scope}`,h)(this,this.scope.get());if(this.scope.value(p,{ref:e}),e.errors=null,e.schema=a.schema,e.schemaEnv=a,a.$async&&(e.$async=!0),!0===this.opts.code.source&&(e.source={validateName:p,validateCode:c,scopeValues:o._values}),this.opts.unevaluated){let{props:a,items:c}=q;e.evaluated={props:a instanceof b.Name?void 0:a,items:c instanceof b.Name?void 0:c,dynamicProps:a instanceof b.Name,dynamicItems:c instanceof b.Name},e.source&&(e.source.evaluated=(0,b.stringify)(e.evaluated))}return a.validate=e,a}catch(b){throw delete a.validate,delete a.validateName,h&&this.logger.error("Error compiling schema, function code:",h),b}finally{this._compilations.delete(a)}}function j(a){return(0,e.inlineRef)(a.schema,this.opts.inlineRefs)?a.schema:a.validate?a:i.call(this,a)}function k(a){for(let d of this._compilations){var b,c;if(b=d,c=a,b.schema===c.schema&&b.root===c.root&&b.baseId===c.baseId)return d}}function l(a,b){let c;for(;"string"==typeof(c=this.refs[b]);)b=c;return c||this.schemas[b]||m.call(this,a,b)}function m(a,b){let c=this.opts.uriResolver.parse(b),d=(0,e._getFullPath)(this.opts.uriResolver,c),f=(0,e.getFullPath)(this.opts.uriResolver,a.baseId,void 0);if(Object.keys(a.schema).length>0&&d===f)return o.call(this,c,a);let g=(0,e.normalizeId)(d),j=this.refs[g]||this.schemas[g];if("string"==typeof j){let b=m.call(this,a,j);if("object"!=typeof(null==b?void 0:b.schema))return;return o.call(this,c,b)}if("object"==typeof(null==j?void 0:j.schema)){if(j.validate||i.call(this,j),g===(0,e.normalizeId)(b)){let{schema:b}=j,{schemaId:c}=this.opts,d=b[c];return d&&(f=(0,e.resolveUrl)(this.opts.uriResolver,f,d)),new h({schema:b,schemaId:c,root:a,baseId:f})}return o.call(this,c,j)}}a.SchemaEnv=h,a.compileSchema=i,a.resolveRef=function(a,b,c){var d;c=(0,e.resolveUrl)(this.opts.uriResolver,b,c);let f=a.refs[c];if(f)return f;let g=l.call(this,a,c);if(void 0===g){let e=null==(d=a.localRefs)?void 0:d[c],{schemaId:f}=this.opts;e&&(g=new h({schema:e,schemaId:f,root:a,baseId:b}))}if(void 0!==g)return a.refs[c]=j.call(this,g)},a.getCompilingSchema=k,a.resolveSchema=m;let n=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function o(a,{baseId:b,schema:c,root:d}){var g;let i;if((null==(g=a.fragment)?void 0:g[0])!=="/")return;for(let d of a.fragment.slice(1).split("/")){if("boolean"==typeof c)return;let a=c[(0,f.unescapeFragment)(d)];if(void 0===a)return;let g="object"==typeof(c=a)&&c[this.opts.schemaId];!n.has(d)&&g&&(b=(0,e.resolveUrl)(this.opts.uriResolver,b,g))}if("boolean"!=typeof c&&c.$ref&&!(0,f.schemaHasRulesButRef)(c,this.RULES)){let a=(0,e.resolveUrl)(this.opts.uriResolver,b,c.$ref);i=m.call(this,d,a)}let{schemaId:j}=this.opts;if((i=i||new h({schema:c,schemaId:j,root:d,baseId:b})).schema!==i.root.schema)return i}}),fa=y((a,b)=>{b.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}}),fb=y((a,b)=>{let c=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),d=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function e(a){let b="",c=0,d=0;for(d=0;d<a.length;d++)if(48!==(c=a[d].charCodeAt(0))){if(!(c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102))return"";b+=a[d];break}for(d+=1;d<a.length;d++){if(!((c=a[d].charCodeAt(0))>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102))return"";b+=a[d]}return b}function f(a){return a.length=0,!0}function g(a,b,c){if(a.length){let d=e(a);if(""===d)return c.error=!0,!1;b.push(d),a.length=0}return!0}function h(a){if(2>function(a){let b=0;for(let c=0;c<a.length;c++)":"===a[c]&&b++;return b}(a))return{host:a,isIPV6:!1};let b=function(a){let b=0,c={error:!1,address:"",zone:""},d=[],h=[],i=!1,j=!1,k=g;for(let e=0;e<a.length;e++){let g=a[e];if("["!==g&&"]"!==g)if(":"===g){if(!0===i&&(j=!0),!k(h,d,c))break;if(++b>7){c.error=!0;break}e>0&&":"===a[e-1]&&(i=!0),d.push(":");continue}else if("%"===g){if(!k(h,d,c))break;k=f}else{h.push(g);continue}}return h.length&&(k===f?c.zone=h.join(""):j?d.push(h.join("")):d.push(e(h))),c.address=d.join(""),c}(a);if(b.error)return{host:a,isIPV6:!1};{let a=b.address,c=b.address;return b.zone&&(a+="%"+b.zone,c+="%25"+b.zone),{host:a,isIPV6:!0,escapedHost:c}}}b.exports={nonSimpleDomain:RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u),recomposeAuthority:function(a){let b=[];if(void 0!==a.userinfo&&(b.push(a.userinfo),b.push("@")),void 0!==a.host){let c=unescape(a.host);if(!d(c)){let b=h(c);c=!0===b.isIPV6?`[${b.escapedHost}]`:a.host}b.push(c)}return("number"==typeof a.port||"string"==typeof a.port)&&(b.push(":"),b.push(String(a.port))),b.length?b.join(""):void 0},normalizeComponentEncoding:function(a,b){let c=!0!==b?escape:unescape;return void 0!==a.scheme&&(a.scheme=c(a.scheme)),void 0!==a.userinfo&&(a.userinfo=c(a.userinfo)),void 0!==a.host&&(a.host=c(a.host)),void 0!==a.path&&(a.path=c(a.path)),void 0!==a.query&&(a.query=c(a.query)),void 0!==a.fragment&&(a.fragment=c(a.fragment)),a},removeDotSegments:function(a){let b=a,c=[],d=-1,e=0;for(;e=b.length;){if(1===e)if("."===b)break;else if("/"===b){c.push("/");break}else{c.push(b);break}if(2===e){if("."===b[0]){if("."===b[1])break;else if("/"===b[1]){b=b.slice(2);continue}}else if("/"===b[0]&&("."===b[1]||"/"===b[1])){c.push("/");break}}else if(3===e&&"/.."===b){0!==c.length&&c.pop(),c.push("/");break}if("."===b[0]){if("."===b[1]){if("/"===b[2]){b=b.slice(3);continue}}else if("/"===b[1]){b=b.slice(2);continue}}else if("/"===b[0]&&"."===b[1]){if("/"===b[2]){b=b.slice(2);continue}else if("."===b[2]&&"/"===b[3]){b=b.slice(3),0!==c.length&&c.pop();continue}}if(-1===(d=b.indexOf("/",1))){c.push(b);break}c.push(b.slice(0,d)),b=b.slice(d)}return c.join("")},isIPv4:d,isUUID:c,normalizeIPv6:h,stringArrayToHexStripped:e}}),fc=y((a,b)=>{let{isUUID:c}=fb(),d=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,e=["http","https","ws","wss","urn","urn:uuid"];function f(a){return!0===a.secure||!1!==a.secure&&!!a.scheme&&3===a.scheme.length&&("w"===a.scheme[0]||"W"===a.scheme[0])&&("s"===a.scheme[1]||"S"===a.scheme[1])&&("s"===a.scheme[2]||"S"===a.scheme[2])}function g(a){return a.host||(a.error=a.error||"HTTP URIs must have a host."),a}function h(a){let b="https"===String(a.scheme).toLowerCase();return(a.port===(b?443:80)||""===a.port)&&(a.port=void 0),a.path||(a.path="/"),a}let i={scheme:"http",domainHost:!0,parse:g,serialize:h},j={scheme:"https",domainHost:i.domainHost,parse:g,serialize:h},k={scheme:"ws",domainHost:!0,parse:function(a){return a.secure=f(a),a.resourceName=(a.path||"/")+(a.query?"?"+a.query:""),a.path=void 0,a.query=void 0,a},serialize:function(a){if((a.port===(f(a)?443:80)||""===a.port)&&(a.port=void 0),"boolean"==typeof a.secure&&(a.scheme=a.secure?"wss":"ws",a.secure=void 0),a.resourceName){let[b,c]=a.resourceName.split("?");a.path=b&&"/"!==b?b:void 0,a.query=c,a.resourceName=void 0}return a.fragment=void 0,a}},l={scheme:"wss",domainHost:k.domainHost,parse:k.parse,serialize:k.serialize},m={http:i,https:j,ws:k,wss:l,urn:{scheme:"urn",parse:function(a,b){if(!a.path)return a.error="URN can not be parsed",a;let c=a.path.match(d);if(c){let d=b.scheme||a.scheme||"urn";a.nid=c[1].toLowerCase(),a.nss=c[2];let e=n(`${d}:${b.nid||a.nid}`);a.path=void 0,e&&(a=e.parse(a,b))}else a.error=a.error||"URN can not be parsed.";return a},serialize:function(a,b){if(void 0===a.nid)throw Error("URN without nid cannot be serialized");let c=b.scheme||a.scheme||"urn",d=a.nid.toLowerCase(),e=n(`${c}:${b.nid||d}`);e&&(a=e.serialize(a,b));let f=a,g=a.nss;return f.path=`${d||b.nid}:${g}`,b.skipEscape=!0,f},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(a,b){return a.uuid=a.nss,a.nss=void 0,b.tolerant||a.uuid&&c(a.uuid)||(a.error=a.error||"UUID is not valid."),a},serialize:function(a){return a.nss=(a.uuid||"").toLowerCase(),a},skipNormalize:!0}};function n(a){return a&&(m[a]||m[a.toLowerCase()])||void 0}Object.setPrototypeOf(m,null),b.exports={wsIsSecure:f,SCHEMES:m,isValidSchemeName:function(a){return -1!==e.indexOf(a)},getSchemeHandler:n}}),fd=y((a,b)=>{let{normalizeIPv6:c,removeDotSegments:d,recomposeAuthority:e,normalizeComponentEncoding:f,isIPv4:g,nonSimpleDomain:h}=fb(),{SCHEMES:i,getSchemeHandler:j}=fc();function k(a,b,c,e){let f={};return e||(a=n(l(a,c),c),b=n(l(b,c),c)),!(c=c||{}).tolerant&&b.scheme?(f.scheme=b.scheme,f.userinfo=b.userinfo,f.host=b.host,f.port=b.port,f.path=d(b.path||""),f.query=b.query):(void 0!==b.userinfo||void 0!==b.host||void 0!==b.port?(f.userinfo=b.userinfo,f.host=b.host,f.port=b.port,f.path=d(b.path||""),f.query=b.query):(b.path?("/"===b.path[0]?f.path=d(b.path):(void 0===a.userinfo&&void 0===a.host&&void 0===a.port||a.path?a.path?f.path=a.path.slice(0,a.path.lastIndexOf("/")+1)+b.path:f.path=b.path:f.path="/"+b.path,f.path=d(f.path)),f.query=b.query):(f.path=a.path,void 0!==b.query?f.query=b.query:f.query=a.query),f.userinfo=a.userinfo,f.host=a.host,f.port=a.port),f.scheme=a.scheme),f.fragment=b.fragment,f}function l(a,b){let c={host:a.host,scheme:a.scheme,userinfo:a.userinfo,port:a.port,path:a.path,query:a.query,nid:a.nid,nss:a.nss,uuid:a.uuid,fragment:a.fragment,reference:a.reference,resourceName:a.resourceName,secure:a.secure,error:""},f=Object.assign({},b),g=[],h=j(f.scheme||c.scheme);h&&h.serialize&&h.serialize(c,f),void 0!==c.path&&(f.skipEscape?c.path=unescape(c.path):(c.path=escape(c.path),void 0!==c.scheme&&(c.path=c.path.split("%3A").join(":")))),"suffix"!==f.reference&&c.scheme&&g.push(c.scheme,":");let i=e(c);if(void 0!==i&&("suffix"!==f.reference&&g.push("//"),g.push(i),c.path&&"/"!==c.path[0]&&g.push("/")),void 0!==c.path){let a=c.path;f.absolutePath||h&&h.absolutePath||(a=d(a)),void 0===i&&"/"===a[0]&&"/"===a[1]&&(a="/%2F"+a.slice(2)),g.push(a)}return void 0!==c.query&&g.push("?",c.query),void 0!==c.fragment&&g.push("#",c.fragment),g.join("")}let m=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function n(a,b){let d=Object.assign({},b),e={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},f=!1;"suffix"===d.reference&&(a=d.scheme?d.scheme+":"+a:"//"+a);let i=a.match(m);if(i){if(e.scheme=i[1],e.userinfo=i[3],e.host=i[4],e.port=parseInt(i[5],10),e.path=i[6]||"",e.query=i[7],e.fragment=i[8],isNaN(e.port)&&(e.port=i[5]),e.host)if(!1===g(e.host)){let a=c(e.host);e.host=a.host.toLowerCase(),f=a.isIPV6}else f=!0;void 0!==e.scheme||void 0!==e.userinfo||void 0!==e.host||void 0!==e.port||void 0!==e.query||e.path?void 0===e.scheme?e.reference="relative":void 0===e.fragment?e.reference="absolute":e.reference="uri":e.reference="same-document",d.reference&&"suffix"!==d.reference&&d.reference!==e.reference&&(e.error=e.error||"URI is not a "+d.reference+" reference.");let b=j(d.scheme||e.scheme);if(!d.unicodeSupport&&(!b||!b.unicodeSupport)&&e.host&&(d.domainHost||b&&b.domainHost)&&!1===f&&h(e.host))try{e.host=URL.domainToASCII(e.host.toLowerCase())}catch(a){e.error=e.error||"Host's domain name can not be converted to ASCII: "+a}(!b||b&&!b.skipNormalize)&&(-1!==a.indexOf("%")&&(void 0!==e.scheme&&(e.scheme=unescape(e.scheme)),void 0!==e.host&&(e.host=unescape(e.host))),e.path&&(e.path=escape(unescape(e.path))),e.fragment&&(e.fragment=encodeURI(decodeURIComponent(e.fragment)))),b&&b.parse&&b.parse(e,d)}else e.error=e.error||"URI can not be parsed.";return e}let o={SCHEMES:i,normalize:function(a,b){return"string"==typeof a?a=l(n(a,b),b):"object"==typeof a&&(a=n(l(a,b),b)),a},resolve:function(a,b,c){let d=c?Object.assign({scheme:"null"},c):{scheme:"null"},e=k(n(a,d),n(b,d),d,!0);return d.skipEscape=!0,l(e,d)},resolveComponent:k,equal:function(a,b,c){return"string"==typeof a?a=l(f(n(a=unescape(a),c),!0),{...c,skipEscape:!0}):"object"==typeof a&&(a=l(f(a,!0),{...c,skipEscape:!0})),"string"==typeof b?b=l(f(n(b=unescape(b),c),!0),{...c,skipEscape:!0}):"object"==typeof b&&(b=l(f(b,!0),{...c,skipEscape:!0})),a.toLowerCase()===b.toLowerCase()},serialize:l,parse:n};b.exports=o,b.exports.default=o,b.exports.fastUri=o}),fe=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=fd();b.code='require("ajv/dist/runtime/uri").default',a.default=b}),ff=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CodeGen=a.Name=a.nil=a.stringify=a.str=a._=a.KeywordCxt=void 0;var b=e6();Object.defineProperty(a,"KeywordCxt",{enumerable:!0,get:function(){return b.KeywordCxt}});var c=eT();Object.defineProperty(a,"_",{enumerable:!0,get:function(){return c._}}),Object.defineProperty(a,"str",{enumerable:!0,get:function(){return c.str}}),Object.defineProperty(a,"stringify",{enumerable:!0,get:function(){return c.stringify}}),Object.defineProperty(a,"nil",{enumerable:!0,get:function(){return c.nil}}),Object.defineProperty(a,"Name",{enumerable:!0,get:function(){return c.Name}}),Object.defineProperty(a,"CodeGen",{enumerable:!0,get:function(){return c.CodeGen}});let d=e7(),e=e8(),f=eY(),g=e9(),h=eT(),i=e5(),j=e$(),k=eU(),l=fa(),m=fe(),n=(a,b)=>new RegExp(a,b);n.code="new RegExp";let o=["removeAdditional","useDefaults","coerceTypes"],p=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),q={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},r={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};var s=class{constructor(a={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,a=this.opts={...a,...function(a){var b,c,d,e,f,g,h,i,j,k,l,o,p,q,r,s,t,u,v,w,x,y,z,A,B;let C=a.strict,D=null==(b=a.code)?void 0:b.optimize,E=!0===D||void 0===D?1:D||0,F=null!=(d=null==(c=a.code)?void 0:c.regExp)?d:n,G=null!=(e=a.uriResolver)?e:m.default;return{strictSchema:null==(g=null!=(f=a.strictSchema)?f:C)||g,strictNumbers:null==(i=null!=(h=a.strictNumbers)?h:C)||i,strictTypes:null!=(k=null!=(j=a.strictTypes)?j:C)?k:"log",strictTuples:null!=(o=null!=(l=a.strictTuples)?l:C)?o:"log",strictRequired:null!=(q=null!=(p=a.strictRequired)?p:C)&&q,code:a.code?{...a.code,optimize:E,regExp:F}:{optimize:E,regExp:F},loopRequired:null!=(r=a.loopRequired)?r:200,loopEnum:null!=(s=a.loopEnum)?s:200,meta:null==(t=a.meta)||t,messages:null==(u=a.messages)||u,inlineRefs:null==(v=a.inlineRefs)||v,schemaId:null!=(w=a.schemaId)?w:"$id",addUsedSchema:null==(x=a.addUsedSchema)||x,validateSchema:null==(y=a.validateSchema)||y,validateFormats:null==(z=a.validateFormats)||z,unicodeRegExp:null==(A=a.unicodeRegExp)||A,int32range:null==(B=a.int32range)||B,uriResolver:G}}(a)};const{es5:b,lines:c}=this.opts.code;this.scope=new h.ValueScope({scope:{},prefixes:p,es5:b,lines:c}),this.logger=function(a){if(!1===a)return z;if(void 0===a)return console;if(a.log&&a.warn&&a.error)return a;throw Error("logger must implement log, warn and error methods")}(a.logger);const d=a.validateFormats;a.validateFormats=!1,this.RULES=(0,f.getRules)(),t.call(this,q,a,"NOT SUPPORTED"),t.call(this,r,a,"DEPRECATED","warn"),this._metaOpts=y.call(this),a.formats&&w.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),a.keywords&&x.call(this,a.keywords),"object"==typeof a.meta&&this.addMetaSchema(a.meta),v.call(this),a.validateFormats=d}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:a,meta:b,schemaId:c}=this.opts,d=l;"id"===c&&((d={...l}).id=d.$id,delete d.$id),b&&a&&this.addMetaSchema(d,d[c],!1)}defaultMeta(){let{meta:a,schemaId:b}=this.opts;return this.opts.defaultMeta="object"==typeof a?a[b]||a:void 0}validate(a,b){let c;if("string"==typeof a){if(!(c=this.getSchema(a)))throw Error(`no schema with key or ref "${a}"`)}else c=this.compile(a);let d=c(b);return"$async"in c||(this.errors=c.errors),d}compile(a,b){let c=this._addSchema(a,b);return c.validate||this._compileSchemaEnv(c)}compileAsync(a,b){if("function"!=typeof this.opts.loadSchema)throw Error("options.loadSchema should be a function");let{loadSchema:c}=this.opts;return d.call(this,a,b);async function d(a,b){await f.call(this,a.$schema);let c=this._addSchema(a,b);return c.validate||g.call(this,c)}async function f(a){a&&!this.getSchema(a)&&await d.call(this,{$ref:a},!0)}async function g(a){try{return this._compileSchemaEnv(a)}catch(b){if(!(b instanceof e.default))throw b;return h.call(this,b),await i.call(this,b.missingSchema),g.call(this,a)}}function h({missingSchema:a,missingRef:b}){if(this.refs[a])throw Error(`AnySchema ${a} is loaded but ${b} cannot be resolved`)}async function i(a){let c=await j.call(this,a);this.refs[a]||await f.call(this,c.$schema),this.refs[a]||this.addSchema(c,a,b)}async function j(a){let b=this._loading[a];if(b)return b;try{return await (this._loading[a]=c(a))}finally{delete this._loading[a]}}}addSchema(a,b,c,d=this.opts.validateSchema){let e;if(Array.isArray(a)){for(let b of a)this.addSchema(b,void 0,c,d);return this}if("object"==typeof a){let{schemaId:b}=this.opts;if(void 0!==(e=a[b])&&"string"!=typeof e)throw Error(`schema ${b} must be string`)}return b=(0,i.normalizeId)(b||e),this._checkUnique(b),this.schemas[b]=this._addSchema(a,c,b,d,!0),this}addMetaSchema(a,b,c=this.opts.validateSchema){return this.addSchema(a,b,!0,c),this}validateSchema(a,b){let c;if("boolean"==typeof a)return!0;if(void 0!==(c=a.$schema)&&"string"!=typeof c)throw Error("$schema must be a string");if(!(c=c||this.opts.defaultMeta||this.defaultMeta()))return this.logger.warn("meta-schema not available"),this.errors=null,!0;let d=this.validate(c,a);if(!d&&b){let a="schema is invalid: "+this.errorsText();if("log"===this.opts.validateSchema)this.logger.error(a);else throw Error(a)}return d}getSchema(a){let b;for(;"string"==typeof(b=u.call(this,a));)a=b;if(void 0===b){let{schemaId:c}=this.opts,d=new g.SchemaEnv({schema:{},schemaId:c});if(!(b=g.resolveSchema.call(this,d,a)))return;this.refs[a]=b}return b.validate||this._compileSchemaEnv(b)}removeSchema(a){if(a instanceof RegExp)return this._removeAllSchemas(this.schemas,a),this._removeAllSchemas(this.refs,a),this;switch(typeof a){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let b=u.call(this,a);return"object"==typeof b&&this._cache.delete(b.schema),delete this.schemas[a],delete this.refs[a],this}case"object":{this._cache.delete(a);let b=a[this.opts.schemaId];return b&&(b=(0,i.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(a){for(let b of a)this.addKeyword(b);return this}addKeyword(a,b){let c;if("string"==typeof a)c=a,"object"==typeof b&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),b.keyword=c);else if("object"==typeof a&&void 0===b){if(Array.isArray(c=(b=a).keyword)&&!c.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(B.call(this,c,b),!b)return(0,k.eachItem)(c,a=>C.call(this,a)),this;E.call(this,b);let d={...b,type:(0,j.getJSONTypes)(b.type),schemaType:(0,j.getJSONTypes)(b.schemaType)};return(0,k.eachItem)(c,0===d.type.length?a=>C.call(this,a,d):a=>d.type.forEach(b=>C.call(this,a,d,b))),this}getKeyword(a){let b=this.RULES.all[a];return"object"==typeof b?b.definition:!!b}removeKeyword(a){let{RULES:b}=this;for(let c of(delete b.keywords[a],delete b.all[a],b.rules)){let b=c.rules.findIndex(b=>b.keyword===a);b>=0&&c.rules.splice(b,1)}return this}addFormat(a,b){return"string"==typeof b&&(b=new RegExp(b)),this.formats[a]=b,this}errorsText(a=this.errors,{separator:b=", ",dataVar:c="data"}={}){return a&&0!==a.length?a.map(a=>`${c}${a.instancePath} ${a.message}`).reduce((a,c)=>a+b+c):"No errors"}$dataMetaSchema(a,b){let c=this.RULES.all;for(let d of(a=JSON.parse(JSON.stringify(a)),b)){let b=d.split("/").slice(1),e=a;for(let a of b)e=e[a];for(let a in c){let b=c[a];if("object"!=typeof b)continue;let{$data:d}=b.definition,f=e[a];d&&f&&(e[a]=G(f))}}return a}_removeAllSchemas(a,b){for(let c in a){let d=a[c];(!b||b.test(c))&&("string"==typeof d?delete a[c]:d&&!d.meta&&(this._cache.delete(d.schema),delete a[c]))}}_addSchema(a,b,c,d=this.opts.validateSchema,e=this.opts.addUsedSchema){let f,{schemaId:h}=this.opts;if("object"==typeof a)f=a[h];else if(this.opts.jtd)throw Error("schema must be object");else if("boolean"!=typeof a)throw Error("schema must be object or boolean");let j=this._cache.get(a);if(void 0!==j)return j;c=(0,i.normalizeId)(f||c);let k=i.getSchemaRefs.call(this,a,c);return j=new g.SchemaEnv({schema:a,schemaId:h,meta:b,baseId:c,localRefs:k}),this._cache.set(j.schema,j),e&&!c.startsWith("#")&&(c&&this._checkUnique(c),this.refs[c]=j),d&&this.validateSchema(a,!0),j}_checkUnique(a){if(this.schemas[a]||this.refs[a])throw Error(`schema with key or id "${a}" already exists`)}_compileSchemaEnv(a){if(a.meta?this._compileMetaSchema(a):g.compileSchema.call(this,a),!a.validate)throw Error("ajv implementation error");return a.validate}_compileMetaSchema(a){let b=this.opts;this.opts=this._metaOpts;try{g.compileSchema.call(this,a)}finally{this.opts=b}}};function t(a,b,c,d="error"){for(let e in a)e in b&&this.logger[d](`${c}: option ${e}. ${a[e]}`)}function u(a){return a=(0,i.normalizeId)(a),this.schemas[a]||this.refs[a]}function v(){let a=this.opts.schemas;if(a)if(Array.isArray(a))this.addSchema(a);else for(let b in a)this.addSchema(a[b],b)}function w(){for(let a in this.opts.formats){let b=this.opts.formats[a];b&&this.addFormat(a,b)}}function x(a){if(Array.isArray(a))return void this.addVocabulary(a);for(let b in this.logger.warn("keywords option as map is deprecated, pass array"),a){let c=a[b];c.keyword||(c.keyword=b),this.addKeyword(c)}}function y(){let a={...this.opts};for(let b of o)delete a[b];return a}s.ValidationError=d.default,s.MissingRefError=e.default,a.default=s;let z={log(){},warn(){},error(){}},A=/^[a-z_$][a-z0-9_$:-]*$/i;function B(a,b){let{RULES:c}=this;if((0,k.eachItem)(a,a=>{if(c.keywords[a])throw Error(`Keyword ${a} is already defined`);if(!A.test(a))throw Error(`Keyword ${a} has invalid name`)}),b&&b.$data&&!("code"in b||"validate"in b))throw Error('$data keyword must have "code" or "validate" function')}function C(a,b,c){var d;let e=null==b?void 0:b.post;if(c&&e)throw Error('keyword with "post" flag cannot have "type"');let{RULES:f}=this,g=e?f.post:f.rules.find(({type:a})=>a===c);if(g||(g={type:c,rules:[]},f.rules.push(g)),f.keywords[a]=!0,!b)return;let h={keyword:a,definition:{...b,type:(0,j.getJSONTypes)(b.type),schemaType:(0,j.getJSONTypes)(b.schemaType)}};b.before?D.call(this,g,h,b.before):g.rules.push(h),f.all[a]=h,null==(d=b.implements)||d.forEach(a=>this.addKeyword(a))}function D(a,b,c){let d=a.rules.findIndex(a=>a.keyword===c);d>=0?a.rules.splice(d,0,b):(a.rules.push(b),this.logger.warn(`rule ${c} is not defined`))}function E(a){let{metaSchema:b}=a;void 0!==b&&(a.$data&&this.opts.$data&&(b=G(b)),a.validateSchema=this.compile(b,!0))}let F={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function G(a){return{anyOf:[a,F]}}}),fg=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}}}),fh=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.callRef=a.getValidate=void 0;let b=e8(),c=e0(),d=eT(),e=eV(),f=e9(),g=eU();function h(a,b){let{gen:c}=a;return b.validate?c.scopeValue("validate",{ref:b.validate}):(0,d._)`${c.scopeValue("wrapper",{ref:b})}.validate`}function i(a,b,f,h){let{gen:i,it:j}=a,{allErrors:k,schemaEnv:l,opts:m}=j,n=m.passContext?e.default.this:d.nil;function o(a){let b=(0,d._)`${a}.errors`;i.assign(e.default.vErrors,(0,d._)`${e.default.vErrors} === null ? ${b} : ${e.default.vErrors}.concat(${b})`),i.assign(e.default.errors,(0,d._)`${e.default.vErrors}.length`)}function p(a){var b;if(!j.opts.unevaluated)return;let c=null==(b=null==f?void 0:f.validate)?void 0:b.evaluated;if(!0!==j.props)if(c&&!c.dynamicProps)void 0!==c.props&&(j.props=g.mergeEvaluated.props(i,c.props,j.props));else{let b=i.var("props",(0,d._)`${a}.evaluated.props`);j.props=g.mergeEvaluated.props(i,b,j.props,d.Name)}if(!0!==j.items)if(c&&!c.dynamicItems)void 0!==c.items&&(j.items=g.mergeEvaluated.items(i,c.items,j.items));else{let b=i.var("items",(0,d._)`${a}.evaluated.items`);j.items=g.mergeEvaluated.items(i,b,j.items,d.Name)}}h?function(){if(!l.$async)throw Error("async schema referenced by sync schema");let e=i.let("valid");i.try(()=>{i.code((0,d._)`await ${(0,c.callValidateCode)(a,b,n)}`),p(b),k||i.assign(e,!0)},a=>{i.if((0,d._)`!(${a} instanceof ${j.ValidationError})`,()=>i.throw(a)),o(a),k||i.assign(e,!1)}),a.ok(e)}():a.result((0,c.callValidateCode)(a,b,n),()=>p(b),()=>o(b))}a.getValidate=h,a.callRef=i,a.default={keyword:"$ref",schemaType:"string",code(a){var c,e;let g,j,k,{gen:l,schema:m,it:n}=a,{baseId:o,schemaEnv:p,validateName:q,opts:r,self:s}=n,{root:t}=p;if(("#"===m||"#/"===m)&&o===t.baseId){if(p===t)return i(a,q,p,p.$async);let b=l.scopeValue("root",{ref:t});return i(a,(0,d._)`${b}.validate`,t,t.$async)}let u=f.resolveRef.call(s,t,o,m);if(void 0===u)throw new b.default(n.opts.uriResolver,o,m);return u instanceof f.SchemaEnv?void i(a,h(a,c=u),c,c.$async):(e=u,g=l.scopeValue("schema",!0===r.code.source?{ref:e,code:(0,d.stringify)(e)}:{ref:e}),j=l.name("valid"),k=a.subschema({schema:e,dataTypes:[],schemaPath:d.nil,topSchemaRef:g,errSchemaPath:m},j),void(a.mergeEvaluated(k),a.ok(j)))}}}),fi=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=fg(),c=fh();a.default=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",b.default,c.default]}),fj=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT(),c=b.operators,d={maximum:{okStr:"<=",ok:c.LTE,fail:c.GT},minimum:{okStr:">=",ok:c.GTE,fail:c.LT},exclusiveMaximum:{okStr:"<",ok:c.LT,fail:c.GTE},exclusiveMinimum:{okStr:">",ok:c.GT,fail:c.LTE}};a.default={keyword:Object.keys(d),type:"number",schemaType:"number",$data:!0,error:{message:({keyword:a,schemaCode:c})=>(0,b.str)`must be ${d[a].okStr} ${c}`,params:({keyword:a,schemaCode:c})=>(0,b._)`{comparison: ${d[a].okStr}, limit: ${c}}`},code(a){let{keyword:c,data:e,schemaCode:f}=a;a.fail$data((0,b._)`${e} ${d[c].fail} ${f} || isNaN(${e})`)}}}),fk=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT();a.default={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:a})=>(0,b.str)`must be multiple of ${a}`,params:({schemaCode:a})=>(0,b._)`{multipleOf: ${a}}`},code(a){let{gen:c,data:d,schemaCode:e,it:f}=a,g=f.opts.multipleOfPrecision,h=c.let("res"),i=g?(0,b._)`Math.abs(Math.round(${h}) - ${h}) > 1e-${g}`:(0,b._)`${h} !== parseInt(${h})`;a.fail$data((0,b._)`(${e} === 0 || (${h} = ${d}/${e}, ${i}))`)}}}),fl=y(a=>{function b(a){let b,c=a.length,d=0,e=0;for(;e<c;)d++,(b=a.charCodeAt(e++))>=55296&&b<=56319&&e<c&&(64512&(b=a.charCodeAt(e)))==56320&&e++;return d}Object.defineProperty(a,"__esModule",{value:!0}),a.default=b,b.code='require("ajv/dist/runtime/ucs2length").default'}),fm=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT(),c=eU(),d=fl();a.default={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message:({keyword:a,schemaCode:c})=>(0,b.str)`must NOT have ${"maxLength"===a?"more":"fewer"} than ${c} characters`,params:({schemaCode:a})=>(0,b._)`{limit: ${a}}`},code(a){let{keyword:e,data:f,schemaCode:g,it:h}=a,i="maxLength"===e?b.operators.GT:b.operators.LT,j=!1===h.opts.unicode?(0,b._)`${f}.length`:(0,b._)`${(0,c.useFunc)(a.gen,d.default)}(${f})`;a.fail$data((0,b._)`${j} ${i} ${g}`)}}}),fn=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=e0(),c=eU(),d=eT();a.default={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:a})=>(0,d.str)`must match pattern "${a}"`,params:({schemaCode:a})=>(0,d._)`{pattern: ${a}}`},code(a){let{gen:e,data:f,$data:g,schema:h,schemaCode:i,it:j}=a,k=j.opts.unicodeRegExp?"u":"";if(g){let{regExp:b}=j.opts.code,g="new RegExp"===b.code?(0,d._)`new RegExp`:(0,c.useFunc)(e,b),h=e.let("valid");e.try(()=>e.assign(h,(0,d._)`${g}(${i}, ${k}).test(${f})`),()=>e.assign(h,!1)),a.fail$data((0,d._)`!${h}`)}else{let c=(0,b.usePattern)(a,h);a.fail$data((0,d._)`!${c}.test(${f})`)}}}}),fo=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT();a.default={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message:({keyword:a,schemaCode:c})=>(0,b.str)`must NOT have ${"maxProperties"===a?"more":"fewer"} than ${c} properties`,params:({schemaCode:a})=>(0,b._)`{limit: ${a}}`},code(a){let{keyword:c,data:d,schemaCode:e}=a,f="maxProperties"===c?b.operators.GT:b.operators.LT;a.fail$data((0,b._)`Object.keys(${d}).length ${f} ${e}`)}}}),fp=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=e0(),c=eT(),d=eU();a.default={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:a}})=>(0,c.str)`must have required property '${a}'`,params:({params:{missingProperty:a}})=>(0,c._)`{missingProperty: ${a}}`},code(a){let{gen:e,schema:f,schemaCode:g,data:h,$data:i,it:j}=a,{opts:k}=j;if(!i&&0===f.length)return;let l=f.length>=k.loopRequired;if(j.allErrors?function(){if(l||i)a.block$data(c.nil,m);else for(let c of f)(0,b.checkReportMissingProp)(a,c)}():function(){let d=e.let("missing");if(l||i){let f=e.let("valid",!0);a.block$data(f,()=>{var i,j;return i=d,j=f,void(a.setParams({missingProperty:i}),e.forOf(i,g,()=>{e.assign(j,(0,b.propertyInData)(e,h,i,k.ownProperties)),e.if((0,c.not)(j),()=>{a.error(),e.break()})},c.nil))}),a.ok(f)}else e.if((0,b.checkMissingProp)(a,f,d)),(0,b.reportMissingProp)(a,d),e.else()}(),k.strictRequired){let b=a.parentSchema.properties,{definedProperties:c}=a.it;for(let a of f)if((null==b?void 0:b[a])===void 0&&!c.has(a)){let b=`required property "${a}" is not defined at "${j.schemaEnv.baseId+j.errSchemaPath}" (strictRequired)`;(0,d.checkStrictMode)(j,b,j.opts.strictRequired)}}function m(){e.forOf("prop",g,c=>{a.setParams({missingProperty:c}),e.if((0,b.noPropertyInData)(e,h,c,k.ownProperties),()=>a.error())})}}}}),fq=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT();a.default={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message:({keyword:a,schemaCode:c})=>(0,b.str)`must NOT have ${"maxItems"===a?"more":"fewer"} than ${c} items`,params:({schemaCode:a})=>(0,b._)`{limit: ${a}}`},code(a){let{keyword:c,data:d,schemaCode:e}=a,f="maxItems"===c?b.operators.GT:b.operators.LT;a.fail$data((0,b._)`${d}.length ${f} ${e}`)}}}),fr=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=e3();b.code='require("ajv/dist/runtime/equal").default',a.default=b}),fs=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=e$(),c=eT(),d=eU(),e=fr();a.default={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:a,j:b}})=>(0,c.str)`must NOT have duplicate items (items ## ${b} and ${a} are identical)`,params:({params:{i:a,j:b}})=>(0,c._)`{i: ${a}, j: ${b}}`},code(a){let{gen:f,data:g,$data:h,schema:i,parentSchema:j,schemaCode:k,it:l}=a;if(!h&&!i)return;let m=f.let("valid"),n=j.items?(0,b.getSchemaTypes)(j.items):[];a.block$data(m,function(){let h=f.let("i",(0,c._)`${g}.length`),i=f.let("j");a.setParams({i:h,j:i}),f.assign(m,!0),f.if((0,c._)`${h} > 1`,()=>(n.length>0&&!n.some(a=>"object"===a||"array"===a)?function(d,e){let h=f.name("item"),i=(0,b.checkDataTypes)(n,h,l.opts.strictNumbers,b.DataType.Wrong),j=f.const("indices",(0,c._)`{}`);f.for((0,c._)`;${d}--;`,()=>{f.let(h,(0,c._)`${g}[${d}]`),f.if(i,(0,c._)`continue`),n.length>1&&f.if((0,c._)`typeof ${h} == "string"`,(0,c._)`${h} += "_"`),f.if((0,c._)`typeof ${j}[${h}] == "number"`,()=>{f.assign(e,(0,c._)`${j}[${h}]`),a.error(),f.assign(m,!1).break()}).code((0,c._)`${j}[${h}] = ${d}`)})}:function(b,h){let i=(0,d.useFunc)(f,e.default),j=f.name("outer");f.label(j).for((0,c._)`;${b}--;`,()=>f.for((0,c._)`${h} = ${b}; ${h}--;`,()=>f.if((0,c._)`${i}(${g}[${b}], ${g}[${h}])`,()=>{a.error(),f.assign(m,!1).break(j)})))})(h,i))},(0,c._)`${k} === false`),a.ok(m)}}}),ft=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT(),c=eU(),d=fr();a.default={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:a})=>(0,b._)`{allowedValue: ${a}}`},code(a){let{gen:e,data:f,$data:g,schemaCode:h,schema:i}=a;g||i&&"object"==typeof i?a.fail$data((0,b._)`!${(0,c.useFunc)(e,d.default)}(${f}, ${h})`):a.fail((0,b._)`${i} !== ${f}`)}}}),fu=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT(),c=eU(),d=fr();a.default={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:a})=>(0,b._)`{allowedValues: ${a}}`},code(a){let e,f,{gen:g,data:h,$data:i,schema:j,schemaCode:k,it:l}=a;if(!i&&0===j.length)throw Error("enum must have non-empty array");let m=j.length>=l.opts.loopEnum,n=()=>null!=e?e:e=(0,c.useFunc)(g,d.default);if(m||i)f=g.let("valid"),a.block$data(f,function(){g.assign(f,!1),g.forOf("v",k,a=>g.if((0,b._)`${n()}(${h}, ${a})`,()=>g.assign(f,!0).break()))});else{if(!Array.isArray(j))throw Error("ajv implementation error");let a=g.const("vSchema",k);f=(0,b.or)(...j.map((c,d)=>{var e,f;let g;return e=a,"object"==typeof(g=j[f=d])&&null!==g?(0,b._)`${n()}(${h}, ${e}[${f}])`:(0,b._)`${h} === ${g}`}))}a.pass(f)}}}),fv=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=fj(),c=fk(),d=fm(),e=fn(),f=fo(),g=fp(),h=fq(),i=fs(),j=ft(),k=fu();a.default=[b.default,c.default,d.default,e.default,f.default,g.default,h.default,i.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},j.default,k.default]}),fw=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.validateAdditionalItems=void 0;let b=eT(),c=eU();function d(a,d){let{gen:e,schema:f,data:g,keyword:h,it:i}=a;i.items=!0;let j=e.const("len",(0,b._)`${g}.length`);if(!1===f)a.setParams({len:d.length}),a.pass((0,b._)`${j} <= ${d.length}`);else if("object"==typeof f&&!(0,c.alwaysValidSchema)(i,f)){let f=e.var("valid",(0,b._)`${j} <= ${d.length}`);e.if((0,b.not)(f),()=>{var g;return g=f,void e.forRange("i",d.length,j,d=>{a.subschema({keyword:h,dataProp:d,dataPropType:c.Type.Num},g),i.allErrors||e.if((0,b.not)(g),()=>e.break())})}),a.ok(f)}}a.validateAdditionalItems=d,a.default={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:a}})=>(0,b.str)`must NOT have more than ${a} items`,params:({params:{len:a}})=>(0,b._)`{limit: ${a}}`},code(a){let{parentSchema:b,it:e}=a,{items:f}=b;Array.isArray(f)?d(a,f):(0,c.checkStrictMode)(e,'"additionalItems" is ignored when "items" is not an array of schemas')}}}),fx=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.validateTuple=void 0;let b=eT(),c=eU(),d=e0();function e(a,d,f=a.schema){let{gen:g,parentSchema:h,data:i,keyword:j,it:k}=a;(function(a){let{opts:b,errSchemaPath:e}=k,g=f.length,h=g===a.minItems&&(g===a.maxItems||!1===a[d]);if(b.strictTuples&&!h){let a=`"${j}" is ${g}-tuple, but minItems or maxItems/${d} are not specified or different at path "${e}"`;(0,c.checkStrictMode)(k,a,b.strictTuples)}})(h),k.opts.unevaluated&&f.length&&!0!==k.items&&(k.items=c.mergeEvaluated.items(g,f.length,k.items));let l=g.name("valid"),m=g.const("len",(0,b._)`${i}.length`);f.forEach((d,e)=>{(0,c.alwaysValidSchema)(k,d)||(g.if((0,b._)`${m} > ${e}`,()=>a.subschema({keyword:j,schemaProp:e,dataProp:e},l)),a.ok(l))})}a.validateTuple=e,a.default={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(a){let{schema:b,it:f}=a;if(Array.isArray(b))return e(a,"additionalItems",b);f.items=!0,(0,c.alwaysValidSchema)(f,b)||a.ok((0,d.validateArray)(a))}}}),fy=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=fx();a.default={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:a=>(0,b.validateTuple)(a,"items")}}),fz=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT(),c=eU(),d=e0(),e=fw();a.default={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:a}})=>(0,b.str)`must NOT have more than ${a} items`,params:({params:{len:a}})=>(0,b._)`{limit: ${a}}`},code(a){let{schema:b,parentSchema:f,it:g}=a,{prefixItems:h}=f;g.items=!0,(0,c.alwaysValidSchema)(g,b)||(h?(0,e.validateAdditionalItems)(a,h):a.ok((0,d.validateArray)(a)))}}}),fA=y(a=>{Object.defineProperty(a,"__esModule",{value:!0});let b=eT(),c=eU();a.default={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:a,max:c}})=>void 0===c?(0,b.str)`must contain at least ${a} valid item(s)`:(0,b.str)`must contain at least ${a} and no more than ${c} valid item(s)`,params:({params:{min:a,max:c}})=>void 0===c?(0,b._)`{minContains: ${a}}`:(0,b._)`{minContains: ${a}, maxContains: ${c}}`},code(a){let d,e,{gen:f,schema:g,parentSchema:h,data:i,it:j}=a,{minContains:k,maxContains:l}=h;j.opts.next?(d=void 0===k?1:k,e=l):d=1;let m=f.const("len",(0,b._)`${i}.length`);if(a.setParams({min:d,max:e}),void 0===e&&0===d)return void(0,c.checkStrictMode)(j,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==e&&d>e){(0,c.checkStrictMode)(j,'"minContains" > "maxContains" is always invalid'),a.fail();return}if((0,c.alwaysValidSchema)(j,g)){let c=(0,b._)`${m} >= ${d}`;void 0!==e&&(c=(0,b._)`${c} && ${m} <= ${e}`),a.pass(c);return}j.items=!0;let n=f.name("valid");function o(){let a=f.name("_valid"),c=f.let("count",0);p(a,()=>f.if(a,()=>{var a;return a=c,void(f.code((0,b._)`${a}++`),void 0===e?f.if((0,b._)`${a} >= ${d}`,()=>f.assign(n,!0).break()):(f.if((0,b._)`${a} > ${e}`,()=>f.assign(n,!1).break()),1===d?f.assign(n,!0):f.if((0,b._)`${a} >= ${d}`,()=>f.assign(n,!0))))}))}function p(b,d){f.forRange("i",0,m,e=>{a.subschema({keyword:"contains",dataProp:e,dataPropType:c.Type.Num,compositeRule:!0},b),d()})}void 0===e&&1===d?p(n,()=>f.if(n,()=>f.break())):0===d?(f.let(n,!0),void 0!==e&&f.if((0,b._)`${i}.length > 0`,o)):(f.let(n,!1),o()),a.result(n,()=>a.reset())}}}),fB=y(a=>{Object.defineProperty(a,"__esModule",{value:!0}),a.validateSchemaDeps=a.validatePropertyDeps=a.error=void 0;let b=eT(),c=eU(),d=e0();a.error={message:({params:{property:a,depsCount:c,deps:d}})=>(0,b.str)`must have ${1===c?"property":"properties"} ${d} when property ${a} is present`,params:({params:{property:a,depsCount:c,deps:d,missingProperty:e}})=>(0,b._)`{property: ${a},
|
|
@@ -26,5 +27,4 @@ data: ${JSON.stringify({jsonrpc:"2.0",method:a,params:b})}
|
|
|
26
27
|
`)},A=a=>{if(!x){a&&y(`event: message
|
|
27
28
|
data: ${JSON.stringify({jsonrpc:"2.0",id:v,result:{resultType:"complete",_meta:{[O]:v,[M]:i}}})}
|
|
28
29
|
|
|
29
|
-
`),x=!0;try{n?.()}catch(a){c?.(a instanceof Error?a:Error(String(a)))}void 0!==o&&clearInterval(o),p?.(),f.delete(A);try{m.close()}catch{}}},B=new ReadableStream({start(a){m=a;let c=gF({method:"notifications/subscriptions/acknowledged",params:{notifications:u}},v);z(c.method,c.params),n=b.subscribe(a=>{if(x||!function(a,b){switch(b.kind){case"tools_list_changed":return!0===a.toolsListChanged;case"prompts_list_changed":return!0===a.promptsListChanged;case"resources_list_changed":return!0===a.resourcesListChanged;case"resource_updated":return void 0!==a.resourceSubscriptions&&a.resourceSubscriptions.includes(b.uri)}}(u,a))return;let b=gF(function(a){switch(a.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed"};case"prompts_list_changed":return{method:"notifications/prompts/list_changed"};case"resources_list_changed":return{method:"notifications/resources/list_changed"};case"resource_updated":return{method:"notifications/resources/updated",params:{uri:a.uri}}}}(a),v);z(b.method,b.params)}),o=gC(e,()=>y(": keepalive\n\n")),f.add(A)},cancel(){A(!1)}});if(void 0!==g)if(g.aborted)A(!1);else{let a=()=>A(!1);g.addEventListener("abort",a,{once:!0}),p=()=>g.removeEventListener("abort",a)}return new Response(B,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let a of f)a(!0)},get openCount(){return f.size}}}({bus:n,maxSubscriptions:b.maxSubscriptions??1024,keepAliveMs:b.keepAliveMs??15e3,onerror:m});"json"===f&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let q="reject"===d?void 0:(c=b.keepAliveMs,async(b,d)=>{if("POST"!==b.method.toUpperCase())return gZ(405,-32e3,"Method not allowed.");try{let e=await a({era:"legacy",...d?.authInfo!==void 0&&{authInfo:d.authInfo},requestInfo:b}),f=new gX({sessionIdGenerator:void 0,...void 0!==c&&{keepAliveMs:c}});await e.connect(f);let g=()=>{f.close().catch(()=>{}),e.close().catch(()=>{})};b.signal?.addEventListener("abort",g,{once:!0});let h=await f.handleRequest(b,{...d?.authInfo!==void 0&&{authInfo:d.authInfo},...d?.parsedBody!==void 0&&{parsedBody:d.parsedBody}});if(null===h.body||"text/event-stream"!==eL(h.headers.get("content-type")))return g(),h;let i=h.body.getReader(),j=!1,k=()=>{j||(j=!0,g())},l=new ReadableStream({pull:async a=>{try{let{done:b,value:c}=await i.read();if(b){k(),a.close();return}void 0!==c&&a.enqueue(c)}catch(b){k(),a.error(b)}},cancel:a=>(k(),i.cancel(a).catch(()=>{}))});return new Response(l,{status:h.status,statusText:h.statusText,headers:h.headers})}catch(a){try{m?.(g_(a))}catch{}return g0(gY(d?.parsedBody))}});async function r(c,d,e){var h,n;let o=c.classification.revision;if(void 0===o||!c_.includes(o)){let a=new dw({supported:[...c_],requested:o??"unknown"});return m(a),gZ(400,a.code,a.message,a.data,gY(c.message))}let q=function(a,b){if("request"!==b.messageKind)return;let c=b.message.method;if(void 0===a.mcpMethodHeader)return ef("method-header-missing","(missing)",`the body names method ${c} but the required Mcp-Method header is absent`,"standard-header-validation");let d=Object.hasOwn(eg,c)?eg[c]:void 0;if(void 0===d)return;let e=b.message.params?.[d],f="string"==typeof e?e:void 0;if(void 0===a.mcpNameHeader){if(void 0===f)return;return ef("name-header-missing","(missing)",`the body carries params.${d}="${f}" but the required Mcp-Name header is absent`,"standard-header-validation")}let g=eh(a.mcpNameHeader),h=ea(g);return void 0===h?ef("name-header-invalid-encoding",g,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==f&&h!==f?ef("name-header-mismatch",g,`the body carries params.${d}="${f}" but the Mcp-Name header names "${h}"`,"standard-header-validation"):void 0}({httpMethod:d.method,mcpMethodHeader:d.headers.get("mcp-method")??void 0,mcpNameHeader:d.headers.get("mcp-name")??void 0},c);if(void 0!==q)return m(Error(`Rejected inbound request (${q.cell}): ${q.message}`)),g$(q,gY(c.message));let r="request"===c.messageKind?dT(c.message.params):void 0,s=r?.[N];if("request"===c.messageKind){let a=Object.hasOwn(cX,h=c.message.method)?cX[h]:void 0;if(void 0!==a){let b=cZ(a,s);if(void 0!==b){let a=new dx({requiredCapabilities:b});return m(a),gZ(ed[a.code]??400,a.code,a.message,a.data,c.message.id)}}}let t=await a({era:"modern",...void 0!==e&&{authInfo:e},requestInfo:d}),u=t instanceof gL?t.server:t;if("request"===c.messageKind&&"subscriptions/listen"===c.message.method){let a=u.getCapabilities(),b=l(u);return t.close().catch(m),p.serve(c.message,d.signal,a,b)}if("request"===c.messageKind&&"tools/call"===c.message.method&&t instanceof gL){let a=c.message.params,b="string"==typeof a?.name?a.name:void 0,e=void 0===b?void 0:t.toolInputSchemaJson(b);if(void 0!==e){let b=d4(e);if(b.valid&&b.declarations.length>0){let e=function(a,b,c){for(let d of a){let a=`Mcp-Param-${d.headerName}`,e=c.get(a),f=function(a,b){let c=a;for(let a of b){if(null===c||"object"!=typeof c)return;c=c[a]}return c}(b,d.path);if(null==f)continue;let g=function(a){if("string"==typeof a)return a;if("boolean"==typeof a)return a?"true":"false";if("number"==typeof a){if(!Number.isFinite(a)||Number.isInteger(a)&&!Number.isSafeInteger(a))return;return String(a)}}(f);if(void 0===g)continue;if(null===e)return eb("param-header-missing",a,`the body carries ${d7(d.path)}=${JSON.stringify(f)} but the ${a} header is absent`);let h=ea(e);if(void 0===h)return eb("param-header-invalid-encoding",a,`the ${a} header carries an invalid Base64 sentinel value`);if(!(("integer"===d.type||"number"===d.type)&&d9.test(h)&&"number"==typeof f?Number(h)===f:h===g))return eb("param-header-mismatch",a,`the ${a} header decodes to ${JSON.stringify(h)} but the body carries ${d7(d.path)}=${JSON.stringify(f)}`)}}(b.declarations,a?.arguments,d.headers);if(void 0!==e)return t.close().catch(m),m(Error(`Rejected inbound request (${e.cell}): ${e.message}`)),g$(e,c.message.id)}}}i(u,o),k(u,c_),void 0!==r&&(n={clientInfo:r[L],clientCapabilities:s},j(u,n));let v=u.onclose;g.add(u),u.onclose=()=>{g.delete(u),v?.()};try{let a=await gW(t,c.message,{classification:c.classification,request:d,...void 0!==e&&{authInfo:e},...void 0!==f&&{responseMode:f},...void 0!==b.keepAliveMs&&{keepAliveMs:b.keepAliveMs}});return"notification"===c.messageKind&&queueMicrotask(()=>void u.close().catch(()=>{})),a}catch(a){if(a instanceof cW&&a.code===cV.ConnectionClosed)return new Response(null,{status:499});return await u.close().catch(()=>{}),g.delete(u),m(g_(a)),g0(gY(c.message))}}async function s(a,b,c,d){if(void 0!==q)return q(b,{...void 0!==c&&{authInfo:c},...void 0!==d&&{parsedBody:d}});let e=function(a,b){switch(a.reason){case"http-method":return ee("http-method","modern-only-method-not-allowed",405,new dt(-32e3,"Method not allowed."),!0);case"batch":return ee("jsonrpc-shape","modern-only-batch-not-supported",400,new dt(ds.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return ee("jsonrpc-shape","modern-only-response-post",400,new dt(ds.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let c=a.requestedVersion;return ee("era-classification","modern-only-missing-envelope",400,void 0===c?new dt(ds.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...b]}):new dw({supported:[...b],requested:c}),!0)}}}(a,c_);return void 0===e?new Response(null,{status:202}):(m(Error(`Rejected 2025-era request on a modern-only endpoint (${e.cell}): ${e.message}`)),g$(e,gY(d)))}async function t(a,b){let c=b?.authInfo;if("POST"===a.method.toUpperCase()&&!eM(a.headers.get("content-type")))return m(Error("Unsupported Media Type: Content-Type must be application/json")),gZ(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let d=await g1(a,b?.parsedBody);if("unreadable-body"===d.step)return gZ(400,-32700,"Parse error: the request body could not be read");if("no-json-body"===d.step)return void 0!==q?q(d.forwardRequest,{...void 0!==c&&{authInfo:c}}):gZ(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:e,body:f,parsedBody:g,forwardRequest:h}=d;try{switch(e.kind){case"reject":return m(Error(`Rejected inbound request (${e.cell}): ${e.message}`)),g$(e,gY(f));case"modern":return await r(e,a,c);case"legacy":return await s(e,h,c,g)}}catch(a){return m(g_(a)),g0(gY(f))}}return{fetch:async(a,b)=>{if(h)throw Error("This MCP handler has been closed");try{return await t(a,b)}catch(a){return m(g_(a)),g0(gY(b?.parsedBody))}},notify:o,bus:n,close:async()=>{h=!0,p.closeAll();let a=[...g].map(a=>a.close().catch(()=>{}));g.clear(),await Promise.all(a)}}}function g3(a){return a.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function g4(a,b,c,d){let e=`Bearer error="${g3(a)}", error_description="${g3(b)}"`;return c.length>0&&(e+=`, scope="${c.join(" ")}"`),d&&(e+=`, resource_metadata="${d}"`),e}async function g5(a,b){let{verifier:c,requiredScopes:d=[]}=b;if(!a)throw new cU(cT.InvalidToken,"Missing Authorization header");let[e,f]=a.split(" ");if(e?.toLowerCase()!=="bearer"||!f)throw new cU(cT.InvalidToken,"Invalid Authorization header format, expected 'Bearer TOKEN'");let g=await c.verifyAccessToken(f);if(d.length>0&&!d.every(a=>g.scopes.includes(a)))throw new cU(cT.InsufficientScope,"Insufficient scope");if("number"!=typeof g.expiresAt||Number.isNaN(g.expiresAt))throw new cU(cT.InvalidToken,"Token has no expiration time");if(g.expiresAt<Date.now()/1e3)throw new cU(cT.InvalidToken,"Token has expired");return g}function g6(a){let{verifier:b,requiredScopes:c=[],resourceMetadataUrl:d}=a,e={verifier:b,requiredScopes:c,resourceMetadataUrl:d};return async a=>{let[b]=(a.headers.get("authorization")??"").split(",");try{return await g5(b||void 0,e)}catch(a){return function(a,b){let{requiredScopes:c=[],resourceMetadataUrl:d}=b??{};if(!(a instanceof cU)){let a=new cU(cT.ServerError,"Internal Server Error");return Response.json(a.toResponseObject(),{status:500})}switch(a.code){case cT.InvalidToken:{let b=g4(a.code,a.message,c,d);return Response.json(a.toResponseObject(),{status:401,headers:{"WWW-Authenticate":b}})}case cT.InsufficientScope:{let b=g4(a.code,a.message,c,d);return Response.json(a.toResponseObject(),{status:403,headers:{"WWW-Authenticate":b}})}case cT.ServerError:return Response.json(a.toResponseObject(),{status:500});default:return Response.json(a.toResponseObject(),{status:400})}}(a,e)}}}function g7(a,b){let c=function(a,b){let c;if(!a)return{ok:!1,errorCode:"missing_host",message:"Missing Host header"};try{c=new URL(`http://${a}`).hostname}catch{return{ok:!1,errorCode:"invalid_host_header",message:`Invalid Host header: ${a}`,hostHeader:a}}return b.includes(c)?{ok:!0,hostname:c}:{ok:!1,errorCode:"invalid_host",message:`Invalid Host: ${c}`,hostHeader:a,hostname:c}}(a.headers.get("host"),b);if(!c.ok)return Response.json({jsonrpc:"2.0",error:{code:-32e3,message:c.message},id:null},{status:403,headers:{"Content-Type":"application/json"}})}function g8(a){var b=new URL(a.oauthMetadata.issuer),c=a.dangerouslyAllowInsecureIssuerUrl;if("https:"!==b.protocol&&"localhost"!==b.hostname&&"127.0.0.1"!==b.hostname&&!c)throw Error("Issuer URL must be HTTPS");if(b.hash)throw Error(`Issuer URL must not have a fragment: ${b}`);if(b.search)throw Error(`Issuer URL must not have a query string: ${b}`);return{resource:a.resourceServerUrl.href,authorization_servers:[a.oauthMetadata.issuer],scopes_supported:a.scopesSupported,resource_name:a.resourceName,resource_documentation:a.serviceDocumentationUrl?.href}}function g9(a){return new URL(ha(a),a).href}function ha(a){let b=hb(a.pathname);return`/.well-known/oauth-protected-resource${"/"===b?"":b}`}function hb(a){return a.length>1&&a.endsWith("/")?a.slice(0,-1):a}let hc="GET, HEAD, OPTIONS";function hd(a,b){if("OPTIONS"===a.method){let b=a.headers.get("access-control-request-headers");return new Response(null,{status:204,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":hc,...null===b?{}:{"Access-Control-Allow-Headers":b,Vary:"Access-Control-Request-Headers"}}})}if("GET"!==a.method&&"HEAD"!==a.method){let b=new cU(cT.MethodNotAllowed,`The method ${a.method} is not allowed for this endpoint`);return Response.json(b.toResponseObject(),{status:405,headers:{Allow:hc,"Access-Control-Allow-Origin":"*"}})}let c=Response.json(b,{headers:{"Access-Control-Allow-Origin":"*"}});return"HEAD"===a.method?new Response(null,{status:c.status,headers:c.headers}):c}function he(a,b){let c=hb(new URL(a.url).pathname);return c===ha(b.resourceServerUrl)?hd(a,g8(b)):"/.well-known/oauth-authorization-server"===c?(g8(b),hd(a,b.oauthMetadata)):void 0}function hf(a,b){let c=function(a,b){let c;if(null==a||""===a)return{ok:!0};try{c=new URL(a).hostname}catch{return{ok:!1,errorCode:"invalid_origin_header",message:`Invalid Origin header: ${a}`,originHeader:a}}return""===c?{ok:!1,errorCode:"invalid_origin_header",message:`Invalid Origin header: ${a}`,originHeader:a}:b.includes(c)?{ok:!0,origin:a,hostname:c}:{ok:!1,errorCode:"invalid_origin",message:`Invalid Origin: ${c}`,originHeader:a,hostname:c}}(a.headers.get("origin"),b);if(!c.ok)return Response.json({jsonrpc:"2.0",error:{code:-32e3,message:c.message},id:null},{status:403,headers:{"Content-Type":"application/json"}})}function hg(a,b){let c;return c=(b??(m??=new gx)).getValidator(a),{"~standard":{version:1,vendor:"mcp",jsonSchema:{input:()=>a,output:()=>a},validate:a=>{let b=c(a);return b.valid?{value:b.data}:{issues:[{message:b.errorMessage}]}}}}}},62202:(a,b,c)=>{c.d(b,{Ky:()=>k});var d=c(77598),e=c(60339);c(8669);var f=c(96022),g=c(57782);let h=/^[A-Za-z0-9._-]{1,128}$/;function i(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}function j(a){return!(!i(a)||"string"!=typeof a.name||!h.test(a.name)||void 0!==a.title&&"string"!=typeof a.title||void 0!==a.description&&"string"!=typeof a.description||void 0!==a.mimeType&&"string"!=typeof a.mimeType||void 0!==a.annotations&&!i(a.annotations)||void 0!==a.icons&&(!Array.isArray(a.icons)||a.icons.some(a=>!!e.aV.Icon["~standard"].validate(a).issues))||void 0!==a._meta&&!i(a._meta)||void 0!==a.completionArguments&&(!Array.isArray(a.completionArguments)||a.completionArguments.some(a=>"string"!=typeof a||!a)||new Set(a.completionArguments).size!==a.completionArguments.length)||void 0!==a.scopes&&(!Array.isArray(a.scopes)||a.scopes.some(a=>"string"!=typeof a||!/^[\x21\x23-\x5B\x5D-\x7E]+$/.test(a))))}function k(a,b){var c;let k;if(!(!i(a)||1!==a.protocol||"string"!=typeof a.providerId||!h.test(a.providerId)||"string"!=typeof a.instanceId||!h.test(a.instanceId)||"string"!=typeof a.namespace||0===a.namespace.length||!i(a.address)||"string"!=typeof a.address.host||0===a.address.host.length||!Number.isSafeInteger(a.address.port)||1>Number(a.address.port)||Number(a.address.port)>65535)&&"string"==typeof a.fingerprint&&/^[a-f0-9]{64}$/.test(a.fingerprint)&&(void 0===a.displayName||"string"==typeof a.displayName)&&function(a){if(!i(a)||!Array.isArray(a.tools)||!Array.isArray(a.resources)||!Array.isArray(a.prompts)||![a.tools,a.resources,a.prompts].every(a=>new Set(a.map(a=>a?.name)).size===a.length)||!a.tools.every(a=>{var b;if(!j(a)||!(void 0===(b=a.annotations)||i(b)&&(void 0===b.title||"string"==typeof b.title)&&["readOnlyHint","destructiveHint","idempotentHint","openWorldHint"].every(a=>void 0===b[a]||"boolean"==typeof b[a]))||!i(a.inputSchema)||void 0!==a.outputSchema&&!i(a.outputSchema)||void 0!==a.execution&&(!i(a.execution)||!["never","idempotent-failover"].includes(String(a.execution.retry))||void 0!==a.execution.timeoutMs&&(!Number.isSafeInteger(a.execution.timeoutMs)||0>=Number(a.execution.timeoutMs)||Number(a.execution.timeoutMs)>f._)||"idempotent-failover"===a.execution.retry&&(a.annotations?.readOnlyHint!==!0||a.annotations?.idempotentHint!==!0)))return!1;try{(0,e.e0)(a.inputSchema),void 0!==a.outputSchema&&(0,e.e0)(a.outputSchema)}catch{return!1}return!0})||!a.prompts.every(a=>{if(!j(a)||!i(a.inputSchema)||a.completionArguments?.some(b=>!i(a.inputSchema.properties)||!(b in a.inputSchema.properties)))return!1;try{return(0,e.e0)(a.inputSchema),!0}catch{return!1}})||!a.resources.every(a=>{if(!j(a))return!1;let b="string"==typeof a.uri;if(b===("string"==typeof a.uriTemplate)||void 0!==a.size&&(!Number.isSafeInteger(a.size)||0>Number(a.size))||void 0!==a.annotations&&e.aV.Annotations["~standard"].validate(a.annotations).issues||void 0!==a.cacheHint&&(!i(a.cacheHint)||void 0!==a.cacheHint.ttlMs&&(!Number.isSafeInteger(a.cacheHint.ttlMs)||0>Number(a.cacheHint.ttlMs))||void 0!==a.cacheHint.cacheScope&&!["public","private"].includes(String(a.cacheHint.cacheScope))))return!1;try{if(b)new URL(a.uri);else{let b=new e.Hm(a.uriTemplate);if(a.completionArguments?.some(a=>!b.variableNames.includes(a)))return!1}return!0}catch{return!1}}))return!1;let b=a.resources.map(a=>a.uri??a.uriTemplate);return new Set(b).size===b.length}(a.capabilities)){try{k=structuredClone(a)}catch{return}if(void 0===b||b===`${g.k2}${k.providerId}/${k.instanceId}`)return(c={providerId:k.providerId,displayName:k.displayName,capabilities:k.capabilities},(0,d.createHash)("sha256").update(function a(b){return Array.isArray(b)?`[${b.map(a).join(",")}]`:b&&"object"==typeof b?`{${Object.entries(b).filter(([,a])=>void 0!==a).sort(([a],[b])=>a<b?-1:+(a>b)).map(([b,c])=>`${JSON.stringify(b)}:${a(c)}`).join(",")}}`:JSON.stringify(b)}(c)).digest("hex")===k.fingerprint)?function a(b){if(!b||"object"!=typeof b||Object.isFrozen(b))return b;for(let c of Object.values(b))a(c);return Object.freeze(b)}(k):void 0}}},68333:(a,b,c)=>{c.d(b,{r:()=>d.rW});var d=c(52179)},75533:(a,b,c)=>{c.d(b,{B:()=>k});var d=c(31343),e=c(51455),f=c(48161),g=c(76760);async function h(a,b,c){let h=g.resolve(a),i=(await (0,e.lstat)(h)).isDirectory()?h:g.dirname(h),j=await (0,e.mkdtemp)(g.join((0,f.tmpdir)(),"hile-rsc-managed-artifact-"));try{for(let a of(await (0,e.writeFile)(g.join(j,"plugin.json"),`${JSON.stringify(b.manifest,null,2)}
|
|
30
|
-
`),b.files)){let b=g.resolve(i,a),c=g.resolve(j,a),d=g.relative(i,b),f=g.relative(j,c);if(d.startsWith("..")||g.isAbsolute(d)||f.startsWith("..")||g.isAbsolute(f))throw Error(`RSC staged artifact path escapes its root: ${a}`);await (0,e.mkdir)(g.dirname(c),{recursive:!0}),await (0,e.copyFile)(b,c)}let a=await (0,d.verifyRscPluginArtifact)(j,c);return{artifactRoot:j,verification:a,cleanup:()=>(0,e.rm)(j,{recursive:!0,force:!0})}}catch(a){throw await (0,e.rm)(j,{recursive:!0,force:!0}),a}}function i(a){return`${a.pluginId}\0${a.buildId}`}async function j(a){let b=[];for(let c of[()=>a.deactivate(),()=>a.drain(),()=>a.stop()])try{await c()}catch(a){b.push(a)}if(b.length>0)throw AggregateError(b,"RSC managed runtime cleanup failed")}class k{artifacts;deployments;runtimeCompatibility;verify;start;stage;managed=new Map;shutdownPromise;shuttingDown=!1;lifecycle=new Map;pendingInstalls=new Set;constructor(a){this.artifacts=a.artifacts,this.deployments=a.deployments,this.runtimeCompatibility={...a.runtime},this.verify=a.verify??d.verifyRscPluginArtifact,this.stage=a.stage??h,this.start=a.start}async install(a){let b;if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");let c=new Promise(a=>{b=a});this.pendingInstalls.add(c);try{let b=await this.verify(a.artifactRoot,this.runtimeCompatibility),{manifest:c}=b;if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");if(a.expected&&(a.expected.pluginId!==c.pluginId||a.expected.buildId!==c.buildId))throw Error(`RSC deployment identity mismatch: expected=${a.expected.pluginId}@${a.expected.buildId}, artifact=${c.pluginId}@${c.buildId}`);let d={pluginId:c.pluginId,buildId:c.buildId,namespace:a.namespace};return await this.enqueue(d,async()=>{let e,f,g=i(d);if(this.managed.has(g))throw Error(`RSC deployment is already managed: ${c.pluginId}@${c.buildId}`);let h=await this.stage(a.artifactRoot,b,this.runtimeCompatibility),k=h.verification.manifest;if(k.pluginId!==c.pluginId||k.buildId!==c.buildId)throw await h.cleanup(),Error("RSC staged artifact identity changed during installation");let l=!1;try{if(e=this.artifacts.register(h.artifactRoot,k),f=await this.start({artifactRoot:h.artifactRoot,manifest:k,deployment:d}),this.shuttingDown)throw Error("RSC deployment manager is shutting down");return this.deployments.install(d,{activate:a.activate}),l=!0,this.managed.set(g,{deployment:d,runtime:f,unregisterArtifacts:e,cleanupArtifacts:h.cleanup}),{...d}}catch(b){l&&this.deployments.remove(d);let a=[];if(f)try{await j(f)}catch(b){a.push(b)}if(e)try{e()}catch(b){a.push(b)}try{await h.cleanup()}catch(b){a.push(b)}if(a.length>0)throw AggregateError([b,...a],`RSC installation failed and cleanup reported errors: ${b instanceof Error?b.message:String(b)}`);throw b}})}finally{this.pendingInstalls.delete(c),b()}}upgrade(a){return this.install({...a,activate:!0})}activate(a){if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");if(this.lifecycle.has(i(a)))throw Error("RSC deployment is retiring");this.deployments.activate(a)}rebind(a,b){return this.enqueue(a,async()=>{let c=this.managed.get(i(a));if(!c)throw Error(`RSC deployment is not managed: ${a.pluginId}@${a.buildId}`);let d=this.deployments.rebind(a,b);return c.deployment=d,{...d}})}async deactivate(a){if(this.shuttingDown)throw Error("RSC deployment manager is shutting down");if(this.lifecycle.has(i(a)))throw Error("RSC deployment is retiring");this.deployments.deactivate(a)}enqueue(a,b){let c=i(a),d=(this.lifecycle.get(c)??Promise.resolve()).catch(()=>void 0).then(b);return this.lifecycle.set(c,d),d.finally(()=>{this.lifecycle.get(c)===d&&this.lifecycle.delete(c)}).catch(()=>void 0),d}retire(a,b={}){return this.enqueue(a,async()=>{let c=i(a),d=this.managed.get(c);if(!d)return;let e=this.deployments.snapshot().find(b=>b.pluginId===a.pluginId&&b.buildId===a.buildId),f=[];if(e?.state==="active")try{this.deployments.deactivate(a)}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(e)try{await this.deployments.drain(a)}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(d.runtime)try{await j(d.runtime),d.runtime=void 0}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(e)try{this.deployments.remove(a)}catch(a){f.push(a)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed");if(b.removeArtifacts??!0){if(d.unregisterArtifacts)try{d.unregisterArtifacts(),d.unregisterArtifacts=void 0}catch(a){f.push(a)}if(d.cleanupArtifacts)try{await d.cleanupArtifacts(),d.cleanupArtifacts=void 0}catch(a){f.push(a)}d.unregisterArtifacts||d.cleanupArtifacts||this.managed.delete(c)}if(f.length)throw AggregateError(f,"RSC deployment retirement failed")})}async removeArtifacts(a){let b=i(a),c=this.managed.get(b);return!!c&&!c.runtime&&(c.unregisterArtifacts?.(),await c.cleanupArtifacts?.(),this.managed.delete(b),!0)}shutdown(){if(this.shutdownPromise)return this.shutdownPromise;this.shuttingDown=!0;let a=(async()=>{await Promise.all([...this.pendingInstalls]);let a=[];for(let b of[...this.managed.values()])try{await this.retire(b.deployment,{removeArtifacts:!0})}catch(b){a.push(b)}if(a.length)throw AggregateError(a,"RSC deployment shutdown failed")})();return this.shutdownPromise=a.catch(a=>{throw this.shutdownPromise=void 0,a}),this.shutdownPromise}}},80385:(a,b,c)=>{c.d(b,{ui:()=>i,hv:()=>z,ku:()=>s,d5:()=>A,AG:()=>k,XH:()=>n,V9:()=>h,W4:()=>u,_U:()=>q,Vh:()=>l,Kq:()=>B,$:()=>j});var d=c(73024),e=c(76760),f=c(73136);let g=Symbol.for("@hile/rsc/remote-client-resolvers");function h(a="/_hile/rsc/assets"){let b=function(a){if(!a.startsWith("/"))throw TypeError("RSC asset mount path must be absolute");let b=a.replace(/\/+$/,"");if(!b)throw TypeError("RSC asset mount path must not be the root path");return b}(a),c=(a,c)=>`${b}/${encodeURIComponent(a)}/${encodeURIComponent(c)}`;return{manifest:(a,b)=>`${c(a,b)}/plugin.json`,file:(a,b,d)=>`${c(a,b)}/file/${d.split("/").map(encodeURIComponent).join("/")}`}}class i{artifacts=new Map;nextRegistration=1;register(a,b){var c,d;let f=(c=b.pluginId,d=b.buildId,`${c}\0${d}`);if(this.artifacts.has(f))throw Error(`RSC artifacts already registered: ${b.pluginId}@${b.buildId}`);this.artifacts.set(f,{root:e.resolve(a),manifest:structuredClone(b),registration:this.nextRegistration++});let g=!1;return()=>{g||(g=!0,this.artifacts.delete(f))}}get(a,b){let c=this.artifacts.get(`${a}\0${b}`);if(c)return{root:c.root,manifest:structuredClone(c.manifest),registration:c.registration}}}function j(a,b,c,d=h()){let e=a.get(b,c);if(!e)throw Error(`RSC plugin artifacts are not registered: ${b}@${c}`);return e.manifest.styles.map(a=>({href:d.file(b,c,a.path),integrity:a.integrity}))}function k(a,b=h()){return(c,d)=>{let g=a.get(c.pluginId,c.buildId);if(!g)throw Error(`RSC plugin artifacts are not registered: ${c.pluginId}@${c.buildId}`);let h=g.manifest.clients.find(({id:a})=>a===c.referenceId);if(!h||h.exportName!==c.exportName)throw Error(`RSC client reference is not registered: ${c.referenceId}`);return{moduleUrl:"ssr"===d?(0,f.pathToFileURL)(e.join(g.root,h.ssrModule)).href:b.file(c.pluginId,c.buildId,h.module),styles:g.manifest.styles.map(a=>({href:b.file(c.pluginId,c.buildId,a.path),integrity:a.integrity}))}}}function l(a){let b,c=(b=globalThis,b[g]??={base:globalThis.__HILE_RSC_RESOLVE_CLIENT__,entries:[]});0===c.entries.length&&(c.base=globalThis.__HILE_RSC_RESOLVE_CLIENT__);let d=Symbol("hile-rsc-resolver");c.entries.push({token:d,resolver:a}),globalThis.__HILE_RSC_RESOLVE_CLIENT__=a;let e=!1;return()=>{if(e)return;e=!0;let a=c.entries.findIndex(a=>a.token===d);a>=0&&c.entries.splice(a,1);let b=c.entries.at(-1)?.resolver??c.base;b?globalThis.__HILE_RSC_RESOLVE_CLIENT__=b:delete globalThis.__HILE_RSC_RESOLVE_CLIENT__}}let m=new i;function n(a={}){let b=a.catalog??m,c=`${function(a){if(!a.startsWith("/"))throw TypeError("RSC asset mount path must be absolute");let b=a.replace(/\/+$/,"");if(!b)throw TypeError("RSC asset mount path must not be the root path");return b}(a.mountPath??"/_hile/rsc/assets")}/`,f=a.metadataCacheSize??256;if(!Number.isSafeInteger(f)||f<1)throw TypeError("RSC asset metadata cache size must be a positive safe integer");let g=new Map;return async(a,h)=>{let i,j;if(!a.path.startsWith(c))return h();let k=a.path.slice(c.length).split("/");if(k.length<3){a.status=404;return}try{i=decodeURIComponent(k.shift()),j=decodeURIComponent(k.shift())}catch{a.status=400;return}let l=b.get(i,j);if(!l){g.delete(`${i}\0${j}`),a.status=404;return}let m=`${i}\0${j}`,n=void 0!==l.registration,o=`${l.root}\0${l.registration??""}`,p=n?g.get(m):void 0;if(p?.source!==o&&(g.delete(m),p=void 0),p)g.delete(m),g.set(m,p);else if((p=function(a){let b=new Set,c=a.clients;for(let a of c)for(let c of(b.add(a.module),a.chunks))b.add(c.path);for(let c of a.styles)b.add(c.path);return{source:"",files:b,manifest:function(a,b=a.clients){return{protocolVersion:a.protocolVersion,pluginId:a.pluginId,buildId:a.buildId,clients:b.map(({id:a,module:b,exportName:c,chunks:d,integrity:e})=>({id:a,module:b,exportName:c,chunks:d,integrity:e})),styles:a.styles}}(a,c)}}(l.manifest)).source=o,n)for(g.set(m,p);g.size>f;)g.delete(g.keys().next().value);if(1===k.length&&"plugin.json"===k[0]){a.status=200,a.type="application/json; charset=utf-8",a.set("Cache-Control","public, max-age=31536000, immutable"),a.set("X-Content-Type-Options","nosniff"),a.body=p.manifest;return}if("file"!==k.shift()){a.status=404;return}let q=function(a){try{let b=a.split("/").map(decodeURIComponent);if(b.some(a=>!a||"."===a||".."===a||a.includes("\\")))return;return b.join("/")}catch{return}}(k.join("/"));if(!q||!p.files.has(q)){a.status=404;return}let r=e.resolve(l.root,q);if(!r.startsWith(`${l.root}${e.sep}`)){a.status=404;return}a.status=200,a.type=q.endsWith(".js")?"text/javascript; charset=utf-8":q.endsWith(".css")?"text/css; charset=utf-8":q.endsWith(".json")?"application/json; charset=utf-8":"application/octet-stream",a.set("Cache-Control","public, max-age=31536000, immutable"),a.set("X-Content-Type-Options","nosniff"),a.set("Cross-Origin-Resource-Policy","same-origin"),a.body=(0,d.createReadStream)(r)}}var o=c(18509);function p(a){if(a)try{return new URL(a).origin}catch{return}}function q(a){return async(b,c)=>{let d,e,f=p("function"==typeof a.expectedOrigin?await a.expectedOrigin(c,b):a.expectedOrigin),g=p((d=Object.entries(c.headers??{}).find(([a])=>"origin"===a.toLowerCase()),Array.isArray(e=d?.[1])?e[0]:e));if(!f||!g||f!==g)return!1;let h=await a.readToken(c,b);return!!h&&a.verifyToken(h,b,c)}}class r extends Error{code;constructor(a,b){super(b),this.code=a,this.name="RscServerFunctionGatewayError"}}class s{options;constructor(a){this.options=a}async invoke(a,b){if(!b?.context)throw new o.gV("RSC Server Function gateway");b={...b,context:(0,o.xe)(b.context)};let c=function(a){if(null===a||"object"!=typeof a||Array.isArray(a))throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function request must be an object");let{referenceId:b,args:c}=a;if("string"!=typeof b||!b)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function referenceId must not be empty");let d=/^([^/]+)\/([^/]+)\/(.+)#([^#]+)$/.exec(b);if(!d)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function referenceId is malformed");if(void 0===c)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function args are required");return{pluginId:d[1],buildId:d[2],referenceId:b,args:c}}(a);if(!await this.options.authorize(c,b))throw new r("ERR_RSC_SERVER_FUNCTION_FORBIDDEN","RSC Server Function request was denied");let d=await this.options.locator.resolve({pluginId:c.pluginId,buildId:c.buildId},{context:b.context,signal:b.signal});try{return await d.client.serverFunction({buildId:c.buildId,referenceId:c.referenceId,args:c.args},{context:b.context,signal:b.signal})}finally{await d.release()}}}async function t(a,b){if(!a.req)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","HTTP request body is unavailable");let c=[],d=0;for await(let e of a.req){let a=Buffer.isBuffer(e)?e:Buffer.from(e);if((d+=a.byteLength)>b)throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function body is too large");c.push(a)}try{return JSON.parse(Buffer.concat(c).toString("utf8"))}catch{throw new r("ERR_RSC_SERVER_FUNCTION_INVALID_REQUEST","RSC Server Function body must be valid JSON")}}function u(a){let b=function(a){if(!a.startsWith("/"))throw TypeError("RSC Server Function mount path must be absolute");let b=a.replace(/\/+$/,"");if(!b)throw TypeError("RSC Server Function mount path must not be root");return b}(a.mountPath??"/_hile/rsc/server-functions"),c=a.bodyLimit??1048576;if(!Number.isSafeInteger(c)||c<1)throw TypeError("RSC Server Function body limit must be positive");let d=a.readJson??t;return async(e,f)=>{if(e.path!==b)return f();if("POST"!==e.method.toUpperCase()){e.status=405,e.set("Allow","POST");return}try{if(!e.requestContext?.context)throw new o.gV("RSC Server Function HTTP ingress");let b=await a.gateway.invoke(await d(e,c),{...e.requestContext,signal:e.signal??e.requestContext.signal});e.status=200,e.type="application/json; charset=utf-8",e.body={value:b}}catch(a){if(a instanceof r){e.status="ERR_RSC_SERVER_FUNCTION_FORBIDDEN"===a.code?403:400,e.type="application/json; charset=utf-8",e.body={code:a.code,message:a.message};return}e.status=500,e.type="application/json; charset=utf-8",e.body={code:"ERR_RSC_SERVER_FUNCTION_FAILED",message:"RSC Server Function execution failed"}}}}var v=c(41815);class w extends Error{code;constructor(a,b){super(b),this.code=a,this.name="RscDeploymentCatalogError"}}function x(a){return`${a.pluginId}\0${a.buildId}`}function y(a){return{pluginId:a.pluginId,buildId:a.buildId,namespace:a.namespace}}class z{records=new Map;activeBuilds=new Map;install(a,b={}){for(let[b,c]of Object.entries(a))if("string"!=typeof c||0===c.length)throw TypeError(`RSC deployment ${b} must not be empty`);let c=x(a);if(this.records.has(c))throw new w("ERR_RSC_DEPLOYMENT_ALREADY_INSTALLED",`RSC deployment is already installed: ${a.pluginId}@${a.buildId}`);return this.records.set(c,{deployment:y(a),state:"inactive",references:0,drainWaiters:new Set}),b.activate&&this.activate(a),()=>this.remove(a)}required(a){let b=this.records.get(x(a));if(!b)throw new w("ERR_RSC_DEPLOYMENT_NOT_INSTALLED",`RSC deployment is not installed: ${a.pluginId}@${a.buildId}`);return b}activate(a){let b=this.required(a),c=this.activeBuilds.get(a.pluginId);c&&c!==a.buildId&&(this.required({pluginId:a.pluginId,buildId:c}).state="draining"),b.state="active",this.activeBuilds.set(a.pluginId,a.buildId)}rebind(a,b){if("string"!=typeof b||0===b.length)throw TypeError("RSC deployment namespace must not be empty");let c=this.required(a);return c.deployment={...c.deployment,namespace:b},y(c.deployment)}deactivate(a){this.required(a).state="inactive",this.activeBuilds.get(a.pluginId)===a.buildId&&this.activeBuilds.delete(a.pluginId)}getActive(a){let b=this.activeBuilds.get(a);if(b)return y(this.required({pluginId:a,buildId:b}).deployment)}acquire(a){let b=this.required(a);if("active"!==b.state)throw new w("ERR_RSC_DEPLOYMENT_INACTIVE",`RSC deployment is not active: ${a.pluginId}@${a.buildId}`);b.references++;let c=!1;return{deployment:y(b.deployment),release:()=>{if(!c&&(c=!0,b.references--,0===b.references)){for(let a of b.drainWaiters)a();b.drainWaiters.clear()}}}}async drain(a){let b=this.required(a);0!==b.references&&await new Promise(a=>b.drainWaiters.add(a))}remove(a){let b=x(a),c=this.records.get(b);if(!c)return!1;if(c.references>0)throw new w("ERR_RSC_DEPLOYMENT_REFERENCED",`RSC deployment is still referenced: ${a.pluginId}@${a.buildId}`);return this.activeBuilds.get(a.pluginId)===a.buildId&&this.activeBuilds.delete(a.pluginId),this.records.delete(b),!0}snapshot(){return[...this.records.values()].map(({deployment:a,state:b,references:c})=>({...y(a),state:b,references:c}))}}function A(a,b){return{async resolve(c,d){d=(0,v.ur)(d,"RSC catalog plugin resolution");let e=a.acquire(c);try{return{client:await b(e.deployment,d),release:e.release}}catch(a){throw e.release(),a}}}}function B(a,b){for(let c of(b.asset&&a.use(b.asset),b.action&&a.use(b.action),b.serverFunction&&a.use(b.serverFunction),b.middleware??[]))a.use(c);return a}c(75533),c(96418)},93279:(a,b,c)=>{c.d(b,{S:()=>d,c:()=>e});let d="*";function e(a,b){if(!b?.length)return!0;let c=new Set(a??[]);return c.has(d)||b.every(a=>c.has(a))}},96022:(a,b,c)=>{c.d(b,{_:()=>d,y:()=>e});let d=0x7fffffff;function e(a,b,c=1){if(!Number.isSafeInteger(a)||a<c||a>d)throw RangeError(`${b} must be an integer between ${c} and ${d}`)}},96418:(a,b,c)=>{c.d(b,{T:()=>g});var d=c(18509);function e(a,b,c){for(let[c,d]of[["timeout",a],["idleTimeout",b]])if(void 0!==d&&(!Number.isSafeInteger(d)||d<1||d>0x7fffffff))throw TypeError(`RSC ${c} must be an integer between 1 and 2147483647`);if(void 0!==c&&(!Number.isSafeInteger(c)||c<1||c>64))throw TypeError("RSC stream window must be an integer between 1 and 64")}function f(a,b){return b?.aborted===!0||a instanceof Error&&"AbortError"===a.name}class g{locator;decoder;verifyManifest;verificationCache;verificationCacheSize;verificationTimeout;observe;constructor(a){if(this.locator=a.locator,this.decoder=a.decoder,this.verifyManifest=a.verifyManifest??!0,this.verificationCache=a.verificationCache??new Map,this.verificationCacheSize=a.verificationCacheSize??256,!Number.isSafeInteger(this.verificationCacheSize)||this.verificationCacheSize<1)throw TypeError("RSC verification cache size must be a positive safe integer");this.verificationTimeout=a.verificationTimeout??3e4,e(this.verificationTimeout),this.observe=a.observe}async verify(a,b,c,d){let e=async()=>{let e,f,g,h=await this.locator.resolve({pluginId:a,buildId:b},{context:d,timeout:this.verificationTimeout});try{if(h.verificationKey!==c)throw Error("RSC plugin endpoint changed during manifest verification");if((e=await h.client.describe({context:d,timeout:this.verificationTimeout})).pluginId!==a)throw Error(`RSC plugin identity mismatch: requested=${a}, resolved=${e.pluginId}`);if(e.buildId!==b)throw Error(`RSC plugin build mismatch: requested=${b}, resolved=${e.buildId}`)}catch(a){f=a}try{await h.release()}catch(a){g=a}if(void 0!==f&&void 0!==g)throw AggregateError([f,g],"RSC manifest verification and lease cleanup failed");if(void 0!==f)throw f;if(void 0!==g)throw g};if(void 0===c)return void await e();let f=JSON.stringify([a,b,c,d]),g=this.verificationCache.get(f);if(g&&(this.verificationCache.delete(f),this.verificationCache.set(f,g)),!g)for(g=e().catch(a=>{throw this.verificationCache.get(f)===g&&this.verificationCache.delete(f),a}),this.verificationCache.set(f,g);this.verificationCache.size>this.verificationCacheSize;)this.verificationCache.delete(this.verificationCache.keys().next().value);await g}async waitForVerification(a,b,c){let d,e;if(!b&&void 0===c)return a;b?.throwIfAborted();let f=new Promise((a,f)=>{b&&(e=()=>f(b.reason??new DOMException("Aborted","AbortError")),b.addEventListener("abort",e,{once:!0})),void 0!==c&&(d=setTimeout(()=>f(Error("RSC manifest verification timed out")),c),d.unref?.())});try{await Promise.race([a,f])}finally{d&&clearTimeout(d),e&&b?.removeEventListener("abort",e)}}async render({pluginId:a,request:b,context:c,signal:g,timeout:h,idleTimeout:i,window:j}){let k,l,m=performance.now(),n=0,o=!1,p=(c,d)=>{if(!o){o=!0;try{this.observe?.({operation:"render",pluginId:a,buildId:b.buildId,outcome:c,durationMs:performance.now()-m,bytes:n,...void 0===d?{}:{error:d}})}catch{}}};try{if(!c)throw new d.gV("RSC host render");c=(0,d.xe)(c),e(h,i,j),g?.throwIfAborted()}catch(a){throw p(f(a,g)?"cancelled":"error",a),a}try{k=await this.locator.resolve({pluginId:a,buildId:b.buildId},{context:c,signal:g})}catch(a){throw p(f(a,g)?"cancelled":"error",a),a}let q=()=>l??=Promise.resolve().then(()=>k.release());try{let d;if(this.verifyManifest){let d=this.verify(a,b.buildId,k.verificationKey,c);await this.waitForVerification(d,g,h)}let e=await k.client.render(b,{context:c,signal:g,timeout:h,idleTimeout:i,window:j}),l=!1,m=!1,o=!1,r=()=>{o&&m&&(void 0!==d?p(f(d,g)?"cancelled":"error",d):p(l?"cancelled":"success"))},s=async a=>{void 0!==a&&(d=a);try{await q()}catch(a){throw d=void 0===d||d===a?a:AggregateError([d,a],"RSC Flight stream and lease cleanup failed"),m=!0,r(),d}m=!0,r()},t={[Symbol.asyncIterator](){let a=e[Symbol.asyncIterator]();return{async next(){try{let b=await a.next();return b.done?await s():n+=b.value.byteLength,b}catch(a){throw m||await s(a),a}},async return(b){let c;try{c=a.return?await a.return(b):{done:!0,value:b}}catch(a){throw await s(a),a}return c.done?(l=!0,await s()):n+=c.value.byteLength,c},async throw(b){let c;if(!a.throw)throw await s(b),b;try{c=await a.throw(b)}catch(a){throw await s(a),a}return c.done?await s():n+=c.value.byteLength,c}}}},u=await this.decoder.decode(t,{pluginId:a,buildId:b.buildId,signal:g});if(o=!0,r(),void 0!==d)throw d;return u}catch(b){let a=b;try{await q()}catch(c){c===b||b instanceof AggregateError&&b.errors.includes(c)||(a=AggregateError([b,c],"RSC render and lease cleanup failed"))}throw p(f(b,g)?"cancelled":"error",a),a}}}},99079:(a,b,c)=>{c.d(b,{SS:()=>d.S}),c(8669),c(39226);var d=c(93279);c(77598)}};
|
|
30
|
+
`),x=!0;try{n?.()}catch(a){c?.(a instanceof Error?a:Error(String(a)))}void 0!==o&&clearInterval(o),p?.(),f.delete(A);try{m.close()}catch{}}},B=new ReadableStream({start(a){m=a;let c=gF({method:"notifications/subscriptions/acknowledged",params:{notifications:u}},v);z(c.method,c.params),n=b.subscribe(a=>{if(x||!function(a,b){switch(b.kind){case"tools_list_changed":return!0===a.toolsListChanged;case"prompts_list_changed":return!0===a.promptsListChanged;case"resources_list_changed":return!0===a.resourcesListChanged;case"resource_updated":return void 0!==a.resourceSubscriptions&&a.resourceSubscriptions.includes(b.uri)}}(u,a))return;let b=gF(function(a){switch(a.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed"};case"prompts_list_changed":return{method:"notifications/prompts/list_changed"};case"resources_list_changed":return{method:"notifications/resources/list_changed"};case"resource_updated":return{method:"notifications/resources/updated",params:{uri:a.uri}}}}(a),v);z(b.method,b.params)}),o=gC(e,()=>y(": keepalive\n\n")),f.add(A)},cancel(){A(!1)}});if(void 0!==g)if(g.aborted)A(!1);else{let a=()=>A(!1);g.addEventListener("abort",a,{once:!0}),p=()=>g.removeEventListener("abort",a)}return new Response(B,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let a of f)a(!0)},get openCount(){return f.size}}}({bus:n,maxSubscriptions:b.maxSubscriptions??1024,keepAliveMs:b.keepAliveMs??15e3,onerror:m});"json"===f&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let q="reject"===d?void 0:(c=b.keepAliveMs,async(b,d)=>{if("POST"!==b.method.toUpperCase())return gZ(405,-32e3,"Method not allowed.");try{let e=await a({era:"legacy",...d?.authInfo!==void 0&&{authInfo:d.authInfo},requestInfo:b}),f=new gX({sessionIdGenerator:void 0,...void 0!==c&&{keepAliveMs:c}});await e.connect(f);let g=()=>{f.close().catch(()=>{}),e.close().catch(()=>{})};b.signal?.addEventListener("abort",g,{once:!0});let h=await f.handleRequest(b,{...d?.authInfo!==void 0&&{authInfo:d.authInfo},...d?.parsedBody!==void 0&&{parsedBody:d.parsedBody}});if(null===h.body||"text/event-stream"!==eL(h.headers.get("content-type")))return g(),h;let i=h.body.getReader(),j=!1,k=()=>{j||(j=!0,g())},l=new ReadableStream({pull:async a=>{try{let{done:b,value:c}=await i.read();if(b){k(),a.close();return}void 0!==c&&a.enqueue(c)}catch(b){k(),a.error(b)}},cancel:a=>(k(),i.cancel(a).catch(()=>{}))});return new Response(l,{status:h.status,statusText:h.statusText,headers:h.headers})}catch(a){try{m?.(g_(a))}catch{}return g0(gY(d?.parsedBody))}});async function r(c,d,e){var h,n;let o=c.classification.revision;if(void 0===o||!c_.includes(o)){let a=new dw({supported:[...c_],requested:o??"unknown"});return m(a),gZ(400,a.code,a.message,a.data,gY(c.message))}let q=function(a,b){if("request"!==b.messageKind)return;let c=b.message.method;if(void 0===a.mcpMethodHeader)return ef("method-header-missing","(missing)",`the body names method ${c} but the required Mcp-Method header is absent`,"standard-header-validation");let d=Object.hasOwn(eg,c)?eg[c]:void 0;if(void 0===d)return;let e=b.message.params?.[d],f="string"==typeof e?e:void 0;if(void 0===a.mcpNameHeader){if(void 0===f)return;return ef("name-header-missing","(missing)",`the body carries params.${d}="${f}" but the required Mcp-Name header is absent`,"standard-header-validation")}let g=eh(a.mcpNameHeader),h=ea(g);return void 0===h?ef("name-header-invalid-encoding",g,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==f&&h!==f?ef("name-header-mismatch",g,`the body carries params.${d}="${f}" but the Mcp-Name header names "${h}"`,"standard-header-validation"):void 0}({httpMethod:d.method,mcpMethodHeader:d.headers.get("mcp-method")??void 0,mcpNameHeader:d.headers.get("mcp-name")??void 0},c);if(void 0!==q)return m(Error(`Rejected inbound request (${q.cell}): ${q.message}`)),g$(q,gY(c.message));let r="request"===c.messageKind?dT(c.message.params):void 0,s=r?.[N];if("request"===c.messageKind){let a=Object.hasOwn(cX,h=c.message.method)?cX[h]:void 0;if(void 0!==a){let b=cZ(a,s);if(void 0!==b){let a=new dx({requiredCapabilities:b});return m(a),gZ(ed[a.code]??400,a.code,a.message,a.data,c.message.id)}}}let t=await a({era:"modern",...void 0!==e&&{authInfo:e},requestInfo:d}),u=t instanceof gL?t.server:t;if("request"===c.messageKind&&"subscriptions/listen"===c.message.method){let a=u.getCapabilities(),b=l(u);return t.close().catch(m),p.serve(c.message,d.signal,a,b)}if("request"===c.messageKind&&"tools/call"===c.message.method&&t instanceof gL){let a=c.message.params,b="string"==typeof a?.name?a.name:void 0,e=void 0===b?void 0:t.toolInputSchemaJson(b);if(void 0!==e){let b=d4(e);if(b.valid&&b.declarations.length>0){let e=function(a,b,c){for(let d of a){let a=`Mcp-Param-${d.headerName}`,e=c.get(a),f=function(a,b){let c=a;for(let a of b){if(null===c||"object"!=typeof c)return;c=c[a]}return c}(b,d.path);if(null==f)continue;let g=function(a){if("string"==typeof a)return a;if("boolean"==typeof a)return a?"true":"false";if("number"==typeof a){if(!Number.isFinite(a)||Number.isInteger(a)&&!Number.isSafeInteger(a))return;return String(a)}}(f);if(void 0===g)continue;if(null===e)return eb("param-header-missing",a,`the body carries ${d7(d.path)}=${JSON.stringify(f)} but the ${a} header is absent`);let h=ea(e);if(void 0===h)return eb("param-header-invalid-encoding",a,`the ${a} header carries an invalid Base64 sentinel value`);if(!(("integer"===d.type||"number"===d.type)&&d9.test(h)&&"number"==typeof f?Number(h)===f:h===g))return eb("param-header-mismatch",a,`the ${a} header decodes to ${JSON.stringify(h)} but the body carries ${d7(d.path)}=${JSON.stringify(f)}`)}}(b.declarations,a?.arguments,d.headers);if(void 0!==e)return t.close().catch(m),m(Error(`Rejected inbound request (${e.cell}): ${e.message}`)),g$(e,c.message.id)}}}i(u,o),k(u,c_),void 0!==r&&(n={clientInfo:r[L],clientCapabilities:s},j(u,n));let v=u.onclose;g.add(u),u.onclose=()=>{g.delete(u),v?.()};try{let a=await gW(t,c.message,{classification:c.classification,request:d,...void 0!==e&&{authInfo:e},...void 0!==f&&{responseMode:f},...void 0!==b.keepAliveMs&&{keepAliveMs:b.keepAliveMs}});return"notification"===c.messageKind&&queueMicrotask(()=>void u.close().catch(()=>{})),a}catch(a){if(a instanceof cW&&a.code===cV.ConnectionClosed)return new Response(null,{status:499});return await u.close().catch(()=>{}),g.delete(u),m(g_(a)),g0(gY(c.message))}}async function s(a,b,c,d){if(void 0!==q)return q(b,{...void 0!==c&&{authInfo:c},...void 0!==d&&{parsedBody:d}});let e=function(a,b){switch(a.reason){case"http-method":return ee("http-method","modern-only-method-not-allowed",405,new dt(-32e3,"Method not allowed."),!0);case"batch":return ee("jsonrpc-shape","modern-only-batch-not-supported",400,new dt(ds.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return ee("jsonrpc-shape","modern-only-response-post",400,new dt(ds.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let c=a.requestedVersion;return ee("era-classification","modern-only-missing-envelope",400,void 0===c?new dt(ds.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...b]}):new dw({supported:[...b],requested:c}),!0)}}}(a,c_);return void 0===e?new Response(null,{status:202}):(m(Error(`Rejected 2025-era request on a modern-only endpoint (${e.cell}): ${e.message}`)),g$(e,gY(d)))}async function t(a,b){let c=b?.authInfo;if("POST"===a.method.toUpperCase()&&!eM(a.headers.get("content-type")))return m(Error("Unsupported Media Type: Content-Type must be application/json")),gZ(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let d=await g1(a,b?.parsedBody);if("unreadable-body"===d.step)return gZ(400,-32700,"Parse error: the request body could not be read");if("no-json-body"===d.step)return void 0!==q?q(d.forwardRequest,{...void 0!==c&&{authInfo:c}}):gZ(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:e,body:f,parsedBody:g,forwardRequest:h}=d;try{switch(e.kind){case"reject":return m(Error(`Rejected inbound request (${e.cell}): ${e.message}`)),g$(e,gY(f));case"modern":return await r(e,a,c);case"legacy":return await s(e,h,c,g)}}catch(a){return m(g_(a)),g0(gY(f))}}return{fetch:async(a,b)=>{if(h)throw Error("This MCP handler has been closed");try{return await t(a,b)}catch(a){return m(g_(a)),g0(gY(b?.parsedBody))}},notify:o,bus:n,close:async()=>{h=!0,p.closeAll();let a=[...g].map(a=>a.close().catch(()=>{}));g.clear(),await Promise.all(a)}}}function g3(a){return a.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function g4(a,b,c,d){let e=`Bearer error="${g3(a)}", error_description="${g3(b)}"`;return c.length>0&&(e+=`, scope="${c.join(" ")}"`),d&&(e+=`, resource_metadata="${d}"`),e}async function g5(a,b){let{verifier:c,requiredScopes:d=[]}=b;if(!a)throw new cU(cT.InvalidToken,"Missing Authorization header");let[e,f]=a.split(" ");if(e?.toLowerCase()!=="bearer"||!f)throw new cU(cT.InvalidToken,"Invalid Authorization header format, expected 'Bearer TOKEN'");let g=await c.verifyAccessToken(f);if(d.length>0&&!d.every(a=>g.scopes.includes(a)))throw new cU(cT.InsufficientScope,"Insufficient scope");if("number"!=typeof g.expiresAt||Number.isNaN(g.expiresAt))throw new cU(cT.InvalidToken,"Token has no expiration time");if(g.expiresAt<Date.now()/1e3)throw new cU(cT.InvalidToken,"Token has expired");return g}function g6(a){let{verifier:b,requiredScopes:c=[],resourceMetadataUrl:d}=a,e={verifier:b,requiredScopes:c,resourceMetadataUrl:d};return async a=>{let[b]=(a.headers.get("authorization")??"").split(",");try{return await g5(b||void 0,e)}catch(a){return function(a,b){let{requiredScopes:c=[],resourceMetadataUrl:d}=b??{};if(!(a instanceof cU)){let a=new cU(cT.ServerError,"Internal Server Error");return Response.json(a.toResponseObject(),{status:500})}switch(a.code){case cT.InvalidToken:{let b=g4(a.code,a.message,c,d);return Response.json(a.toResponseObject(),{status:401,headers:{"WWW-Authenticate":b}})}case cT.InsufficientScope:{let b=g4(a.code,a.message,c,d);return Response.json(a.toResponseObject(),{status:403,headers:{"WWW-Authenticate":b}})}case cT.ServerError:return Response.json(a.toResponseObject(),{status:500});default:return Response.json(a.toResponseObject(),{status:400})}}(a,e)}}}function g7(a,b){let c=function(a,b){let c;if(!a)return{ok:!1,errorCode:"missing_host",message:"Missing Host header"};try{c=new URL(`http://${a}`).hostname}catch{return{ok:!1,errorCode:"invalid_host_header",message:`Invalid Host header: ${a}`,hostHeader:a}}return b.includes(c)?{ok:!0,hostname:c}:{ok:!1,errorCode:"invalid_host",message:`Invalid Host: ${c}`,hostHeader:a,hostname:c}}(a.headers.get("host"),b);if(!c.ok)return Response.json({jsonrpc:"2.0",error:{code:-32e3,message:c.message},id:null},{status:403,headers:{"Content-Type":"application/json"}})}function g8(a){var b=new URL(a.oauthMetadata.issuer),c=a.dangerouslyAllowInsecureIssuerUrl;if("https:"!==b.protocol&&"localhost"!==b.hostname&&"127.0.0.1"!==b.hostname&&!c)throw Error("Issuer URL must be HTTPS");if(b.hash)throw Error(`Issuer URL must not have a fragment: ${b}`);if(b.search)throw Error(`Issuer URL must not have a query string: ${b}`);return{resource:a.resourceServerUrl.href,authorization_servers:[a.oauthMetadata.issuer],scopes_supported:a.scopesSupported,resource_name:a.resourceName,resource_documentation:a.serviceDocumentationUrl?.href}}function g9(a){return new URL(ha(a),a).href}function ha(a){let b=hb(a.pathname);return`/.well-known/oauth-protected-resource${"/"===b?"":b}`}function hb(a){return a.length>1&&a.endsWith("/")?a.slice(0,-1):a}let hc="GET, HEAD, OPTIONS";function hd(a,b){if("OPTIONS"===a.method){let b=a.headers.get("access-control-request-headers");return new Response(null,{status:204,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":hc,...null===b?{}:{"Access-Control-Allow-Headers":b,Vary:"Access-Control-Request-Headers"}}})}if("GET"!==a.method&&"HEAD"!==a.method){let b=new cU(cT.MethodNotAllowed,`The method ${a.method} is not allowed for this endpoint`);return Response.json(b.toResponseObject(),{status:405,headers:{Allow:hc,"Access-Control-Allow-Origin":"*"}})}let c=Response.json(b,{headers:{"Access-Control-Allow-Origin":"*"}});return"HEAD"===a.method?new Response(null,{status:c.status,headers:c.headers}):c}function he(a,b){let c=hb(new URL(a.url).pathname);return c===ha(b.resourceServerUrl)?hd(a,g8(b)):"/.well-known/oauth-authorization-server"===c?(g8(b),hd(a,b.oauthMetadata)):void 0}function hf(a,b){let c=function(a,b){let c;if(null==a||""===a)return{ok:!0};try{c=new URL(a).hostname}catch{return{ok:!1,errorCode:"invalid_origin_header",message:`Invalid Origin header: ${a}`,originHeader:a}}return""===c?{ok:!1,errorCode:"invalid_origin_header",message:`Invalid Origin header: ${a}`,originHeader:a}:b.includes(c)?{ok:!0,origin:a,hostname:c}:{ok:!1,errorCode:"invalid_origin",message:`Invalid Origin: ${c}`,originHeader:a,hostname:c}}(a.headers.get("origin"),b);if(!c.ok)return Response.json({jsonrpc:"2.0",error:{code:-32e3,message:c.message},id:null},{status:403,headers:{"Content-Type":"application/json"}})}function hg(a,b){let c;return c=(b??(m??=new gx)).getValidator(a),{"~standard":{version:1,vendor:"mcp",jsonSchema:{input:()=>a,output:()=>a},validate:a=>{let b=c(a);return b.valid?{value:b.data}:{issues:[{message:b.errorMessage}]}}}}}},62202:(a,b,c)=>{c.d(b,{Ky:()=>k});var d=c(77598),e=c(60339);c(8669);var f=c(96022),g=c(57782);let h=/^[A-Za-z0-9._-]{1,128}$/;function i(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}function j(a){return!(!i(a)||"string"!=typeof a.name||!h.test(a.name)||void 0!==a.title&&"string"!=typeof a.title||void 0!==a.description&&"string"!=typeof a.description||void 0!==a.mimeType&&"string"!=typeof a.mimeType||void 0!==a.annotations&&!i(a.annotations)||void 0!==a.icons&&(!Array.isArray(a.icons)||a.icons.some(a=>!!e.aV.Icon["~standard"].validate(a).issues))||void 0!==a._meta&&!i(a._meta)||void 0!==a.completionArguments&&(!Array.isArray(a.completionArguments)||a.completionArguments.some(a=>"string"!=typeof a||!a)||new Set(a.completionArguments).size!==a.completionArguments.length)||void 0!==a.scopes&&(!Array.isArray(a.scopes)||a.scopes.some(a=>"string"!=typeof a||!/^[\x21\x23-\x5B\x5D-\x7E]+$/.test(a))))}function k(a,b){var c;let k;if(!(!i(a)||1!==a.protocol||"string"!=typeof a.providerId||!h.test(a.providerId)||"string"!=typeof a.instanceId||!h.test(a.instanceId)||"string"!=typeof a.namespace||0===a.namespace.length||!i(a.address)||"string"!=typeof a.address.host||0===a.address.host.length||!Number.isSafeInteger(a.address.port)||1>Number(a.address.port)||Number(a.address.port)>65535)&&"string"==typeof a.fingerprint&&/^[a-f0-9]{64}$/.test(a.fingerprint)&&(void 0===a.displayName||"string"==typeof a.displayName)&&function(a){if(!i(a)||!Array.isArray(a.tools)||!Array.isArray(a.resources)||!Array.isArray(a.prompts)||![a.tools,a.resources,a.prompts].every(a=>new Set(a.map(a=>a?.name)).size===a.length)||!a.tools.every(a=>{var b;if(!j(a)||!(void 0===(b=a.annotations)||i(b)&&(void 0===b.title||"string"==typeof b.title)&&["readOnlyHint","destructiveHint","idempotentHint","openWorldHint"].every(a=>void 0===b[a]||"boolean"==typeof b[a]))||!i(a.inputSchema)||void 0!==a.outputSchema&&!i(a.outputSchema)||void 0!==a.execution&&(!i(a.execution)||!["never","idempotent-failover"].includes(String(a.execution.retry))||void 0!==a.execution.timeoutMs&&(!Number.isSafeInteger(a.execution.timeoutMs)||0>=Number(a.execution.timeoutMs)||Number(a.execution.timeoutMs)>f._)||"idempotent-failover"===a.execution.retry&&(a.annotations?.readOnlyHint!==!0||a.annotations?.idempotentHint!==!0)))return!1;try{(0,e.e0)(a.inputSchema),void 0!==a.outputSchema&&(0,e.e0)(a.outputSchema)}catch{return!1}return!0})||!a.prompts.every(a=>{if(!j(a)||!i(a.inputSchema)||a.completionArguments?.some(b=>!i(a.inputSchema.properties)||!(b in a.inputSchema.properties)))return!1;try{return(0,e.e0)(a.inputSchema),!0}catch{return!1}})||!a.resources.every(a=>{if(!j(a))return!1;let b="string"==typeof a.uri;if(b===("string"==typeof a.uriTemplate)||void 0!==a.size&&(!Number.isSafeInteger(a.size)||0>Number(a.size))||void 0!==a.annotations&&e.aV.Annotations["~standard"].validate(a.annotations).issues||void 0!==a.cacheHint&&(!i(a.cacheHint)||void 0!==a.cacheHint.ttlMs&&(!Number.isSafeInteger(a.cacheHint.ttlMs)||0>Number(a.cacheHint.ttlMs))||void 0!==a.cacheHint.cacheScope&&!["public","private"].includes(String(a.cacheHint.cacheScope))))return!1;try{if(b)new URL(a.uri);else{let b=new e.Hm(a.uriTemplate);if(a.completionArguments?.some(a=>!b.variableNames.includes(a)))return!1}return!0}catch{return!1}}))return!1;let b=a.resources.map(a=>a.uri??a.uriTemplate);return new Set(b).size===b.length}(a.capabilities)){try{k=structuredClone(a)}catch{return}if(void 0===b||b===`${g.k2}${k.providerId}/${k.instanceId}`)return(c={providerId:k.providerId,displayName:k.displayName,capabilities:k.capabilities},(0,d.createHash)("sha256").update(function a(b){return Array.isArray(b)?`[${b.map(a).join(",")}]`:b&&"object"==typeof b?`{${Object.entries(b).filter(([,a])=>void 0!==a).sort(([a],[b])=>a<b?-1:+(a>b)).map(([b,c])=>`${JSON.stringify(b)}:${a(c)}`).join(",")}}`:JSON.stringify(b)}(c)).digest("hex")===k.fingerprint)?function a(b){if(!b||"object"!=typeof b||Object.isFrozen(b))return b;for(let c of Object.values(b))a(c);return Object.freeze(b)}(k):void 0}}},68333:(a,b,c)=>{c.d(b,{r:()=>d.rW});var d=c(52179)},81866:(a,b,c)=>{c.d(b,{tm:()=>d,fr:()=>e,z_:()=>y});let d="__hile_rsc_remote_client_boundary__",e=Object.freeze({react:"19.2.8",reactDom:"19.2.8",rsc:"19.2.8"}),f=Object.freeze({displayNameLength:120,descriptionLength:500,navigationItems:128,navigationIdLength:64,navigationLabelLength:120,navigationGroupLength:120,navigationOrderMagnitude:1e6}),g=/^\[([A-Za-z][A-Za-z0-9_]*)\]$/;function h(a){return"/"===a?[]:a.slice(1).split("/")}function i(a){return g.exec(a)?.[1]}let j=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;class k extends Error{code;constructor(a,b){super(b),this.name="RscProtocolError",this.code=a}}function l(a,b){throw new k(a,b)}function m(a){return null!==a&&"object"==typeof a&&!Array.isArray(a)}function n(a,b){return("string"!=typeof a||0===a.length)&&l("ERR_RSC_INVALID_MANIFEST",`${b} must be a non-empty string`),a}function o(a,b){return Array.isArray(a)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be an array`),a}function p(a,b){return m(a)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be an object`),a}function q(a,b){let c=n(a,b),d=c.split("/");return(c.startsWith("/")||c.includes("\\")||c.includes(":")||c.includes("%")||c.includes("?")||c.includes("#")||/[\0-\x1F\x7F]/.test(c)||!/^[A-Za-z0-9@_./+-]+$/.test(c)||d.some(a=>""===a||"."===a||".."===a))&&l("ERR_RSC_UNSAFE_ARTIFACT_PATH",`${b} contains an unsafe artifact path`),c}function r(a,b){let c=n(a,b);return/^(?:default|[A-Za-z_$][A-Za-z0-9_$]*)$/.test(c)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be a JavaScript export name`),c}function s(a,b){let c=n(a,b);return/^sha256-[A-Za-z0-9+/]{43}=$/.test(c)||l("ERR_RSC_INVALID_MANIFEST",`${b} must be a sha256 SRI value`),c}function t(a,b,c="ERR_RSC_INVALID_ROUTE"){("string"!=typeof a||0===a.length)&&l(c,`${b} must be a non-empty string`);let d=h(a);(!a.startsWith("/")||a.startsWith("//")||a.includes("?")||a.includes("#")||a.includes("\\")||a.includes("%")||/[\0-\x1F\x7F]/.test(a)||"/"!==a&&d.some(a=>""===a)||d.some(a=>"."===a||".."===a)||d.some(a=>""!==a&&!/^[A-Za-z0-9._~-]+$/.test(a)&&void 0===i(a)))&&l(c,`${b} must be a normalized absolute route path`);let e=d.map(i).filter(a=>void 0!==a);return new Set(e).size!==e.length&&l(c,`${b} must not repeat a route parameter name`),a}function u(a){return void 0!==i(a)}function v(a){return h(a).filter(a=>!u(a)).length}let w=/[\p{Cc}\p{Cs}\p{Zl}\p{Zp}\u061C\u200B\u200E\u200F\u202A-\u202E\u2060\u2066-\u2069]/u;function x(a,b,c){return("string"!=typeof a||0===a.length)&&l("ERR_RSC_INVALID_METADATA",`${b} must be a non-empty string`),(a!==a.trim()||function(a,b){let c=0;for(let d of a)if(++c>b)return!0;return!1}(a,c)||w.test(a))&&l("ERR_RSC_INVALID_METADATA",`${b} is not a bounded display string`),a}function y(a,b){var c;let d,e,g,i,k,w=p(a,"manifest");1!==w.protocolVersion&&l("ERR_RSC_PROTOCOL_VERSION",`unsupported RSC protocol version: ${String(w.protocolVersion)}`);let y=n(w.pluginId,"pluginId");j.test(y)||l("ERR_RSC_INVALID_MANIFEST","pluginId must be a lowercase identifier");let z=n(w.buildId,"buildId");/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(z)||l("ERR_RSC_INVALID_MANIFEST","buildId contains unsupported characters");let A=function(a,b){let c=p(a,"runtime"),d={react:n(c.react,"runtime.react"),reactDom:n(c.reactDom,"runtime.reactDom"),rsc:n(c.rsc,"runtime.rsc")};for(let a of["react","reactDom","rsc"])d[a]!==b[a]&&l("ERR_RSC_RUNTIME_MISMATCH",`${a} runtime mismatch: plugin=${d[a]}, host=${b[a]}`);return d}(w.runtime,b),B=p(w.server,"server"),C={entry:q(B.entry,"server.entry"),integrity:s(B.integrity,"server.integrity")},D=new Set,E=o(void 0===w.serverFunctions?[]:w.serverFunctions,"serverFunctions").map((a,b)=>{var c;let d,e,f=p(a,`serverFunctions[${b}]`),g=(d=n(f.id,c=`serverFunctions[${b}].id`),(!(e=/^([^/]+)\/[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9@_./+-]+#[A-Za-z_$][A-Za-z0-9_$]*$/.exec(d))||!j.test(e[1])||d.includes("..")||d.includes("//"))&&l("ERR_RSC_INVALID_MANIFEST",`${c} must identify a plugin build, module, and export`),d);return D.has(g)&&l("ERR_RSC_DUPLICATE_SERVER_FUNCTION_REFERENCE",`duplicate server function reference: ${g}`),D.add(g),{id:g,module:q(f.module,`serverFunctions[${b}].module`),exportName:r(f.exportName,`serverFunctions[${b}].exportName`),integrity:s(f.integrity,`serverFunctions[${b}].integrity`)}}),F=new Set,G=o(w.clients,"clients").map((a,b)=>{var c;let d,e=p(a,`clients[${b}]`),f=(d=n(e.id,c=`clients[${b}].id`),(!/^[A-Za-z0-9@_./+-]+#[A-Za-z_$][A-Za-z0-9_$]*$/.test(d)||d.includes(".."))&&l("ERR_RSC_INVALID_MANIFEST",`${c} must identify a module and export`),d);return F.has(f)&&l("ERR_RSC_DUPLICATE_CLIENT_REFERENCE",`duplicate client reference: ${f}`),F.add(f),{id:f,module:q(e.module,`clients[${b}].module`),ssrModule:q(e.ssrModule,`clients[${b}].ssrModule`),exportName:r(e.exportName,`clients[${b}].exportName`),chunks:o(e.chunks,`clients[${b}].chunks`).map((a,c)=>{let d=p(a,`clients[${b}].chunks[${c}]`);return{path:q(d.path,`clients[${b}].chunks[${c}].path`),integrity:s(d.integrity,`clients[${b}].chunks[${c}].integrity`)}}),ssrChunks:o(e.ssrChunks,`clients[${b}].ssrChunks`).map((a,c)=>{let d=p(a,`clients[${b}].ssrChunks[${c}]`);return{path:q(d.path,`clients[${b}].ssrChunks[${c}].path`),integrity:s(d.integrity,`clients[${b}].ssrChunks[${c}].integrity`)}}),integrity:s(e.integrity,`clients[${b}].integrity`),ssrIntegrity:s(e.ssrIntegrity,`clients[${b}].ssrIntegrity`)}}),H=new Set,I=o(w.styles,"styles").map((a,b)=>{let c=p(a,`styles[${b}]`),d=q(c.path,`styles[${b}].path`);return H.has(d)&&l("ERR_RSC_DUPLICATE_STYLE",`duplicate style artifact: ${d}`),H.add(d),{path:d,integrity:s(c.integrity,`styles[${b}].integrity`)}}),J=o(w.routes,"routes");0===J.length&&l("ERR_RSC_INVALID_ROUTE","routes must contain at least one route");let K=new Set,L=J.map((a,b)=>{var c;let d,e=p(a,`routes[${b}]`),f=t(e.path,`routes[${b}].path`);return K.has(f)&&l("ERR_RSC_DUPLICATE_ROUTE",`duplicate route path: ${f}`),K.add(f),{path:f,entry:(d=n(e.entry,c=`routes[${b}].entry`),/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(d)&&"."!==d&&".."!==d||l("ERR_RSC_INVALID_MANIFEST",`${c} must be a safe entry name`),d)}});for(let a=0;a<L.length;a++)for(let b=a+1;b<L.length;b++){let c=L[a].path,d=L[b].path;(function(a,b){let c=h(a),d=h(b);return c.length===d.length&&c.every((a,b)=>a===d[b]||u(a)||u(d[b]))})(c,d)&&v(c)===v(d)&&l("ERR_RSC_DUPLICATE_ROUTE",`ambiguous parameterized routes: ${c} and ${d}`)}let M=void 0===w.metadata?void 0:(c=w.metadata,m(c)||l("ERR_RSC_INVALID_METADATA","metadata must be an object"),d=x(c.displayName,"metadata.displayName",f.displayNameLength),e=void 0===c.description?void 0:x(c.description,"metadata.description",f.descriptionLength),(!Array.isArray(g=void 0===c.navigation?[]:c.navigation)||g.length>f.navigationItems)&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation must contain at most ${f.navigationItems} items`),i=new Set,k=g.map((a,b)=>{m(a)||l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}] must be an object`);let c="string"==typeof a.id?a.id:"";(c.length>f.navigationIdLength||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(c))&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}].id is invalid`),i.has(c)&&l("ERR_RSC_DUPLICATE_NAVIGATION",`duplicate navigation id: ${c}`),i.add(c);let d=t(a.path,`metadata.navigation[${b}].path`,"ERR_RSC_INVALID_METADATA");return(!K.has(d)||h(d).some(u))&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}].path must reference a declared static route`),void 0!==a.order&&(!Number.isSafeInteger(a.order)||Math.abs(a.order)>f.navigationOrderMagnitude)&&l("ERR_RSC_INVALID_METADATA",`metadata.navigation[${b}].order is invalid`),{id:c,label:x(a.label,`metadata.navigation[${b}].label`,f.navigationLabelLength),path:d,...void 0===a.order?{}:{order:a.order},...void 0===a.group?{}:{group:x(a.group,`metadata.navigation[${b}].group`,f.navigationGroupLength)}}}),{displayName:d,...void 0===e?{}:{description:e},navigation:k});return{protocolVersion:1,pluginId:y,buildId:z,runtime:A,server:C,serverFunctions:E,clients:G,styles:I,routes:L,...void 0===M?{}:{metadata:M}}}},93279:(a,b,c)=>{c.d(b,{S:()=>d,c:()=>e});let d="*";function e(a,b){if(!b?.length)return!0;let c=new Set(a??[]);return c.has(d)||b.every(a=>c.has(a))}},93678:(a,b,c)=>{c.r(b),c.d(b,{getRscPluginArtifactFiles:()=>l,inspectRscPluginArtifact:()=>k,resolveRscPluginArtifact:()=>o,resolveVerifiedRscPluginArtifact:()=>p,verifyRscPluginArtifact:()=>m});var d=c(51455),e=c(76760),f=c(77598),g=c(81866);async function h(a){let b=e.resolve(a),c=await (0,d.lstat)(b);if(c.isSymbolicLink())throw Error(`RSC artifact input must not be a symbolic link: ${b}`);if(c.isDirectory()){let a=e.join(b,"plugin.json"),c=await (0,d.lstat)(a);if(!c.isFile()||c.isSymbolicLink())throw Error(`RSC artifact manifest must be a regular file: ${a}`);return{root:b,manifestPath:a}}if(!c.isFile())throw Error(`RSC artifact manifest is not a file: ${b}`);return{root:e.dirname(b),manifestPath:b}}async function i(a,b){let c=a,f=b.split("/");for(let a=0;a<f.length;a++){let g;c=e.join(c,f[a]);try{g=await (0,d.lstat)(c)}catch{throw Error(`RSC artifact is missing: ${b}`)}if(g.isSymbolicLink())throw Error(`RSC artifact must not traverse a symbolic link: ${b}`);if(a<f.length-1&&!g.isDirectory())throw Error(`RSC artifact parent must be a directory: ${b}`);if(a===f.length-1&&!g.isFile())throw Error(`RSC artifact must be a regular file: ${b}`)}return c}async function j(a,b=a){let c=[];for(let f of(await (0,d.readdir)(b,{withFileTypes:!0}))){let d=e.join(b,f.name),g=e.relative(a,d).split(e.sep).join("/");if(f.isSymbolicLink())throw Error(`RSC artifact must not contain a symbolic link: ${g}`);if(f.isDirectory())c.push(...await j(a,d));else if(f.isFile())c.push(g);else throw Error(`RSC artifact contains an unsupported filesystem entry: ${g}`)}return c}async function k(a){let{manifestPath:b}=await h(a),c=JSON.parse(await (0,d.readFile)(b,"utf8"));if(!c.runtime)throw Error("RSC artifact manifest is missing runtime compatibility");return(0,g.z_)(c,c.runtime)}function l(a){let b=new Map,c=(a,c)=>{let d=b.get(a);if(d&&d!==c)throw Error(`RSC artifact declares conflicting integrity: ${a}`);b.set(a,c)};for(let b of(c(a.server.entry,a.server.integrity),a.serverFunctions))c(b.module,b.integrity);for(let b of a.clients){for(let a of(c(b.module,b.integrity),c(b.ssrModule,b.ssrIntegrity),b.chunks))c(a.path,a.integrity);for(let a of b.ssrChunks)c(a.path,a.integrity)}for(let b of a.styles)c(b.path,b.integrity);return b}async function m(a,b){let{root:c,manifestPath:k}=await h(a),m=JSON.parse(await (0,d.readFile)(k,"utf8")),n=(0,g.z_)(m,b),o=l(n);for(let[a,b]of o){let g=e.resolve(c,a);if(!g.startsWith(`${c}${e.sep}`))throw Error(`RSC artifact escapes its root: ${a}`);if(await i(c,a),`sha256-${(0,f.createHash)("sha256").update(await (0,d.readFile)(g)).digest("base64")}`!==b)throw Error(`RSC artifact integrity mismatch: ${a}`)}let p=new Set([e.relative(c,k).split(e.sep).join("/"),...o.keys()]);for(let a of(await j(c)))if(!p.has(a))throw Error(`RSC artifact contains an undeclared file: ${a}`);return{manifest:n,files:[...o.keys()].sort()}}async function n(a,b,c){let f,g,h=e.resolve(a);try{if(!(await (0,d.lstat)(h)).isDirectory())return{artifactRoot:h};return await (0,d.access)(e.join(h,"plugin.json")),{artifactRoot:h}}catch{}let i=function(a){let b=a?.trim();if(b){if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(b))throw TypeError("RSC buildId contains unsupported characters");return b}}(b.buildId);if(i)return{artifactRoot:e.join(h,i)};try{f=await (0,d.readdir)(h,{withFileTypes:!0})}catch{return{artifactRoot:h}}for(let a of(await Promise.all(f.filter(a=>a.isDirectory()&&!a.name.startsWith(".")&&"development"!==a.name).map(async a=>{let b=e.join(h,a.name),c=e.join(b,"plugin.json");try{let e=(await (0,d.stat)(c)).mtimeMs;try{let c=await k(b);return{path:b,name:a.name,mtime:e,manifest:c}}catch(c){return{path:b,name:a.name,mtime:e,error:c}}}catch{return}}))).filter(a=>void 0!==a).sort((a,b)=>b.mtime-a.mtime||b.name.localeCompare(a.name))){if("error"in a){g??=a.error;continue}try{let b=await m(a.path,c??a.manifest.runtime);return{artifactRoot:a.path,verification:b}}catch(a){g??=a}}if(void 0!==g)throw g;return{artifactRoot:h}}async function o(a,b={}){return(await n(a,b)).artifactRoot}async function p(a,b,c={}){let d=await n(a,c,b),e=d.verification??await m(d.artifactRoot,b);return{artifactRoot:d.artifactRoot,...e}}},93932:(a,b,c)=>{c.d(b,{$C:()=>g,ur:()=>f});var d=c(18509);let e=Object.freeze({describe:"/-/rsc/describe",render:"/-/rsc/render",action:"/-/rsc/action",serverFunction:"/-/rsc/server-function"});function f(a,b){if(!a?.context)throw new d.gV(b);return Object.freeze({...a,context:(0,d.xe)(a.context)})}function g(a,b,c=e){if(!b)throw TypeError("RSC plugin namespace must not be empty");return{describe:d=>a.call(b,c.describe,{},f(d,"RSC plugin describe")),render:(d,e)=>a.stream(b,c.render,d,f(e,"RSC plugin render transport")),action:(d,e)=>a.call(b,c.action,d,f(e,"RSC plugin action transport")),serverFunction:(d,e)=>a.call(b,c.serverFunction,d,f(e,"RSC plugin server function transport"))}}new WeakMap,Object.freeze({snapshot:"/-/rsc/catalog/snapshot",active:"/-/rsc/catalog/active",install:"/-/rsc/catalog/install",activate:"/-/rsc/catalog/activate",deactivate:"/-/rsc/catalog/deactivate",remove:"/-/rsc/catalog/remove"})},96022:(a,b,c)=>{c.d(b,{_:()=>d,y:()=>e});let d=0x7fffffff;function e(a,b,c=1){if(!Number.isSafeInteger(a)||a<c||a>d)throw RangeError(`${b} must be an integer between ${c} and ${d}`)}},99079:(a,b,c)=>{c.d(b,{SS:()=>d.S}),c(8669),c(39226);var d=c(93279);c(77598)}};
|