@onyxsecurity/mcp-gateway 2.1.54 → 2.1.56

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.
Files changed (28) hide show
  1. package/dist/bin/mcp-gateway.js +2 -2
  2. package/dist/{cli-DT-v3g0q.js → cli-Djg8Q492.js} +2 -2
  3. package/dist/{cli-DT-v3g0q.js.map → cli-Djg8Q492.js.map} +1 -1
  4. package/dist/{env-CXzYlaGo.js → env-BgasZcvb.js} +2 -2
  5. package/dist/{env-CXzYlaGo.js.map → env-BgasZcvb.js.map} +1 -1
  6. package/dist/{env-BxV2HUvJ.js → env-IH-ou_Qn.js} +1 -1
  7. package/dist/{helpers-C2Wt91RI.js → helpers-D_89Tzhc.js} +2 -2
  8. package/dist/{helpers-C2Wt91RI.js.map → helpers-D_89Tzhc.js.map} +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/{logger-D2D2A8cS.js → logger-BQ4h6bdx.js} +2 -2
  11. package/dist/{logger-D2D2A8cS.js.map → logger-BQ4h6bdx.js.map} +1 -1
  12. package/dist/{logger-SUJem08I.js → logger-C4yv4JYM.js} +1 -1
  13. package/dist/{main-BWclLffI.js → main-Dk_cm-rB.js} +2 -2
  14. package/dist/{main-BWclLffI.js.map → main-Dk_cm-rB.js.map} +1 -1
  15. package/dist/oauthProvidersClient-BNH7sHZm.js +1 -0
  16. package/dist/{oauthProvidersClient-DEIMpscP.js → oauthProvidersClient-D88rrBUI.js} +2 -2
  17. package/dist/{oauthProvidersClient-DEIMpscP.js.map → oauthProvidersClient-D88rrBUI.js.map} +1 -1
  18. package/dist/{providers-DEwCLySx.js → providers-CnxX5hRf.js} +2 -2
  19. package/dist/{providers-DEwCLySx.js.map → providers-CnxX5hRf.js.map} +1 -1
  20. package/dist/{proxyFetch-CGv-OIxy.js → proxyFetch-C3RS3xmp.js} +2 -2
  21. package/dist/{proxyFetch-CGv-OIxy.js.map → proxyFetch-C3RS3xmp.js.map} +1 -1
  22. package/dist/{transportDetection-iJJk0CkO.js → transportDetection-C-3F7JZT.js} +2 -2
  23. package/dist/{transportDetection-iJJk0CkO.js.map → transportDetection-C-3F7JZT.js.map} +1 -1
  24. package/dist/{upstreamNegotiation-C_Du8DxH.js → upstreamNegotiation-CWekWLVp.js} +10 -9
  25. package/dist/upstreamNegotiation-CWekWLVp.js.map +1 -0
  26. package/package.json +1 -1
  27. package/dist/oauthProvidersClient-BBhWRyBJ.js +0 -1
  28. package/dist/upstreamNegotiation-C_Du8DxH.js.map +0 -1
@@ -1,15 +1,16 @@
1
- import{proxiedFetch as e}from"./proxyFetch-CGv-OIxy.js";import{SESSION_ID as t,config as n}from"./env-CXzYlaGo.js";import{extractTraceIdFromHeaders as r,gatewayCorrelationId as i,logger as a,runWithTraceContextAsync as o}from"./logger-D2D2A8cS.js";import{AnnotationsSchema as s,AudioContentSchema as c,BaseMetadataSchema as l,BaseRequestParamsSchema as u,BlobResourceContentsSchema as d,BooleanSchemaSchema as f,CLIENT_CAPABILITIES_META_KEY as p,CLIENT_INFO_META_KEY as m,CallToolRequestParamsSchema as h,CallToolRequestSchema as g,CallToolResultSchema as _,CancelTaskRequestSchema as v,CancelTaskResultSchema as y,CancelledNotificationParamsSchema as b,CancelledNotificationSchema as x,ClientCapabilitiesSchema as S,ClientNotificationSchema as C,ClientRequestSchema as ee,ClientResultSchema as te,ClientTasksCapabilitySchema as ne,CompatibilityCallToolResultSchema as w,CompleteRequestParamsSchema as re,CompleteRequestSchema as T,CompleteResultSchema as ie,ContentBlockSchema as ae,CreateMessageRequestParamsSchema as oe,CreateMessageRequestSchema as se,CreateMessageResultSchema as ce,CreateMessageResultWithToolsSchema as le,CreateTaskResultSchema as E,CursorSchema as D,DEFAULT_NEGOTIATED_PROTOCOL_VERSION as ue,DiscoverRequestSchema as de,DiscoverResultSchema as fe,ElicitRequestFormParamsSchema as pe,ElicitRequestParamsSchema as O,ElicitRequestSchema as me,ElicitRequestURLParamsSchema as he,ElicitResultSchema as ge,ElicitationCompleteNotificationParamsSchema as _e,ElicitationCompleteNotificationSchema as ve,EmbeddedResourceSchema as ye,EmptyResultSchema as be,EnumSchemaSchema as xe,GetPromptRequestParamsSchema as Se,GetPromptRequestSchema as Ce,GetPromptResultSchema as we,GetTaskPayloadRequestSchema as Te,GetTaskPayloadResultSchema as Ee,GetTaskRequestSchema as De,GetTaskResultSchema as Oe,IconSchema as ke,IconsSchema as Ae,IdJagTokenExchangeResponseSchema as je,ImageContentSchema as Me,ImplementationSchema as Ne,InitializeRequestParamsSchema as Pe,InitializeRequestSchema as Fe,InitializeResultSchema as Ie,InitializedNotificationSchema as Le,JSONArraySchema as Re,JSONObjectSchema as ze,JSONRPCErrorResponseSchema as Be,JSONRPCMessageSchema as Ve,JSONRPCNotificationSchema as He,JSONRPCRequestSchema as Ue,JSONRPCResponseSchema as We,JSONRPCResultResponseSchema as Ge,JSONValueSchema as Ke,LATEST_PROTOCOL_VERSION as qe,LOG_LEVEL_META_KEY as Je,LegacyTitledEnumSchemaSchema as Ye,ListChangedOptionsBaseSchema as Xe,ListPromptsRequestSchema as Ze,ListPromptsResultSchema as Qe,ListResourceTemplatesRequestSchema as $e,ListResourceTemplatesResultSchema as et,ListResourcesRequestSchema as tt,ListResourcesResultSchema as nt,ListRootsRequestSchema as k,ListRootsResultSchema as rt,ListTasksRequestSchema as it,ListTasksResultSchema as at,ListToolsRequestSchema as ot,ListToolsResultSchema as st,LoggingLevelSchema as ct,LoggingMessageNotificationParamsSchema as lt,LoggingMessageNotificationSchema as ut,ModelHintSchema as dt,ModelPreferencesSchema as ft,MultiSelectEnumSchemaSchema as pt,NotificationSchema as mt,NotificationsParamsSchema as ht,NumberSchemaSchema as gt,OAuthClientInformationFullSchema as _t,OAuthClientInformationSchema as vt,OAuthClientMetadataSchema as yt,OAuthClientRegistrationErrorSchema as bt,OAuthErrorResponseSchema as xt,OAuthMetadataSchema as St,OAuthProtectedResourceMetadataSchema as Ct,OAuthTokenRevocationRequestSchema as wt,OAuthTokensSchema as Tt,OpenIdProviderDiscoveryMetadataSchema as Et,OpenIdProviderMetadataSchema as Dt,PROTOCOL_VERSION_META_KEY as Ot,PaginatedRequestParamsSchema as kt,PaginatedRequestSchema as At,PaginatedResultSchema as jt,PingRequestSchema as Mt,PrimitiveSchemaDefinitionSchema as A,ProgressNotificationParamsSchema as j,ProgressNotificationSchema as Nt,ProgressSchema as Pt,ProgressTokenSchema as Ft,PromptArgumentSchema as It,PromptListChangedNotificationSchema as Lt,PromptMessageSchema as Rt,PromptReferenceSchema as zt,PromptSchema as Bt,ReadResourceRequestParamsSchema as Vt,ReadResourceRequestSchema as Ht,ReadResourceResultSchema as Ut,RelatedTaskMetadataSchema as Wt,RequestIdSchema as Gt,RequestMetaSchema as Kt,RequestSchema as qt,ResourceContentsSchema as Jt,ResourceLinkSchema as Yt,ResourceListChangedNotificationSchema as Xt,ResourceRequestParamsSchema as M,ResourceSchema as Zt,ResourceTemplateReferenceSchema as Qt,ResourceTemplateSchema as $t,ResourceUpdatedNotificationParamsSchema as en,ResourceUpdatedNotificationSchema as tn,ResultMetaObjectSchema as nn,ResultSchema as rn,RoleSchema as an,RootSchema as on,RootsListChangedNotificationSchema as sn,SERVER_INFO_META_KEY as cn,SUBSCRIPTION_ID_META_KEY as ln,SUPPORTED_PROTOCOL_VERSIONS as un,SamplingContentSchema as dn,SamplingMessageContentBlockSchema as fn,SamplingMessageSchema as pn,ServerCapabilitiesSchema as mn,ServerNotificationSchema as hn,ServerRequestSchema as gn,ServerResultSchema as _n,ServerTasksCapabilitySchema as vn,SetLevelRequestParamsSchema as yn,SetLevelRequestSchema as bn,SingleSelectEnumSchemaSchema as xn,StringSchemaSchema as Sn,SubscribeRequestParamsSchema as Cn,SubscribeRequestSchema as wn,SubscriptionFilterSchema as Tn,SubscriptionsAcknowledgedNotificationParamsSchema as En,SubscriptionsAcknowledgedNotificationSchema as Dn,SubscriptionsListenRequestParamsSchema as On,SubscriptionsListenRequestSchema as kn,SubscriptionsListenResultMetaSchema as An,SubscriptionsListenResultSchema as jn,TaskAugmentedRequestParamsSchema as Mn,TaskCreationParamsSchema as Nn,TaskMetadataSchema as Pn,TaskSchema as Fn,TaskStatusNotificationParamsSchema as In,TaskStatusNotificationSchema as Ln,TaskStatusSchema as Rn,TextContentSchema as zn,TextResourceContentsSchema as Bn,TitledMultiSelectEnumSchemaSchema as Vn,TitledSingleSelectEnumSchemaSchema as Hn,ToolAnnotationsSchema as Un,ToolChoiceSchema as Wn,ToolExecutionSchema as Gn,ToolListChangedNotificationSchema as Kn,ToolResultContentSchema as qn,ToolSchema as Jn,ToolUseContentSchema as Yn,UnsubscribeRequestParamsSchema as Xn,UnsubscribeRequestSchema as Zn,UntitledMultiSelectEnumSchemaSchema as Qn,UntitledSingleSelectEnumSchemaSchema as $n,_enum as N,_null as er,array as P,boolean as F,date as tr,datetime as nr,discriminatedUnion as rr,email as ir,intersection as ar,lazy as or,literal as I,looseObject as L,number as R,object as z,optional as B,preprocess as sr,record as V,safeParse as cr,string as H,toJSONSchema as lr,union as U,unknown as W,url as ur}from"./normalizeUrl-DUUGubD4.js";import dr,{randomUUID as fr}from"crypto";import{homedir as pr,hostname as mr,userInfo as hr}from"node:os";import{join as gr}from"node:path";import{randomUUID as _r}from"node:crypto";import{existsSync as vr,readFileSync as yr}from"node:fs";import{Readable as br}from"stream";import xr from"ps-list";import{deflateSync as Sr}from"node:zlib";import Cr from"node:process";import{Http2ServerRequest as wr,constants as Tr}from"http2";import{URL as Er}from"node:url";import Dr from"node:http";var Or=class{counter=0;events=new Map;async replayEventsAfter(e,{send:t}){if(!e||!this.events.has(e))return``;let n=this.getStreamIdFromEventId(e);if(!n)return``;let r=!1,i=[...this.events.entries()].sort((e,t)=>e[0].localeCompare(t[0]));for(let[a,{message:o,streamId:s}]of i){if(s!==n)continue;if(a===e){r=!0;continue}r&&await t(a,o)}return n}async storeEvent(e,t){let n=this.generateEventId(e);return this.events.set(n,{message:t,streamId:e}),n}generateEventId(e){let t=(++this.counter).toString().padStart(12,`0`);return`${e}_${Date.now()}_${t}_${Math.random().toString(36).substring(2,10)}`}getStreamIdFromEventId(e){let t=e.split(`_`);return t.length<4?``:t.slice(0,-3).join(`_`)}},kr=class extends Error{extra;tags;constructor(e,t,n={},r={}){super(t),this.name=e,this.tags=n,this.extra=r}},Ar=class extends kr{constructor(e,t=`access_denied`,n={}){super(`AccessControlBlockError`,e,{feature:`access_control`,module:`security`,operation:`block`},{reason:t,...n}),this.reason=t}},jr=class extends kr{constructor(e,t,n={}){super(`ConfigurationError`,e,{feature:`configuration`,module:`cli`,operation:`validate`},{configKey:t,...n})}},Mr=class extends kr{constructor(e,t,n={}){super(`ProtocolEraMismatchError`,e,{feature:`protocol_era`,module:`proxy`,operation:`negotiate`},{url:t?(()=>{try{return new URL(t).origin}catch{return t}})():void 0,...n})}},Nr=class extends kr{constructor(e,t,n,r={},i){super(`ProxyConnectionError`,e,{feature:`connection`,module:`proxy`,operation:`connect`,transport:n||`unknown`},{url:t?(()=>{try{return new URL(t).origin}catch{return t}})():void 0,...r}),i!==void 0&&(this.cause=i)}};const Pr=n.clientAppName;let Fr=null;const Ir=async()=>(Fr||=await import(`systeminformation`),Fr);function Lr(e){return typeof e==`string`&&e!==``&&e.includes(`@`)}function Rr(){try{let e=Hr();if(!vr(e))return null;let t=yr(e,`utf-8`),n=!1;for(let e of t.split(`
2
- `)){let t=e.trim();if(t.startsWith(`#`)||t.startsWith(`;`))continue;if(t.startsWith(`[`)){n=t.toLowerCase()===`[user]`;continue}if(n){let e=t.match(/^email\s*=\s*(.+)/i);if(e)return e[1].replace(/\s+[#;].*$/,``).trim()||null}}return null}catch{return null}}function zr(){return gr(pr(),`.claude.json`)}function Br(){return gr(pr(),`.codex`,`auth.json`)}function Vr(){try{return mr()}catch{return`unknown-device`}}function Hr(){return gr(pr(),`.gitconfig`)}async function Ur(e){try{return(await xr()).find(t=>t.pid===e)?.name||`unknown`}catch{return`unknown`}}const Wr=new Map;async function Gr(e){let t=Wr.get(e);if(t)return t;let n=(async()=>{try{let{list:t}=await(await Ir()).processes(),n=t.find(t=>t.pid===e)?.started;if(n){let e=new Date(n);if(!Number.isNaN(e.getTime()))return e.toISOString()}return}catch{return}})();return Wr.set(e,n),n}function Kr(){return new Date(Date.now()-Math.round(process.uptime()*1e3)).toISOString()}async function qr(){try{let e=(await(await Ir()).system()).serial;return e&&e!==``&&e!==`0`&&!e.toLowerCase().includes(`to be filled`)?e:void 0}catch{return}}function Jr(){try{let e=Xr()?.oauthAccount?.emailAddress;if(Lr(e))return e;let t=Zr();if(Lr(t))return t;let n=Rr();return Lr(n)?n:void 0}catch{return}}function Yr(){try{let e=hr();if(e.username)return e.username;throw Error(`userInfo() returned empty username`)}catch{return process.env.USER||process.env.USERNAME||process.env.LOGNAME}}function Xr(){try{let e=zr();if(!vr(e))return null;let t=yr(e,`utf-8`);return JSON.parse(t)}catch{return null}}function Zr(){try{let e=Br();if(!vr(e))return null;let t=yr(e,`utf-8`),n=JSON.parse(t)?.tokens?.id_token;if(!n)return null;let r=n.split(`.`);if(r.length!==3)return null;let i=Buffer.from(r[1],`base64url`).toString(`utf-8`);return JSON.parse(i).email||null}catch{return null}}const Qr=()=>{if(!vr(`/.dockerenv`))return null;try{let e=yr(gr(pr(),`.onyx`,`container-context.json`),`utf8`),t=JSON.parse(e);return t.container_id?t:null}catch{return null}},$r=e=>{let t=process.env.ONYX_DOCKER_CONTAINER_ID,n=t?null:Qr(),r=t||n?.container_id;return r?{...e,containerRuntime:process.env.ONYX_CONTAINER_RUNTIME||void 0,deviceName:process.env.ONYX_HOST_DEVICE_NAME||n?.host_device_name||e.deviceName,dockerContainerId:r,dockerContainerName:process.env.ONYX_DOCKER_CONTAINER_NAME||n?.container_name||void 0,dockerImage:process.env.ONYX_DOCKER_IMAGE||n?.image||void 0,dockerImageId:process.env.ONYX_DOCKER_IMAGE_ID||n?.image_id||void 0,inDockerContainer:!0,systemSerialNumber:process.env.ONYX_HOST_SERIAL_NUMBER||n?.host_serial_number||e.systemSerialNumber}:e},ei=async()=>{let e=process.pid,t=process.ppid,r=Kr();try{let i=Vr(),[a,o,s]=await Promise.all([qr(),Ur(t),Gr(t)]),c=Jr(),l=Yr();return $r({clientAppName:Pr||`unknown`,deviceName:i,email:c,gatewayVersion:n.appVersion,parentProcessId:t,parentProcessName:o,parentProcessStartTime:s,processId:e,processStartTime:r,systemSerialNumber:a,username:l})}catch{return $r({clientAppName:Pr||`unknown`,deviceName:`unknown-device`,email:void 0,gatewayVersion:n.appVersion,parentProcessId:t,parentProcessName:`unknown`,processId:e,processStartTime:r,systemSerialNumber:void 0,username:void 0})}},ti=`[REDACTED]`,ni=new Set([`api_key`,`api-key`,`apikey`,`authorization`,`bearer`,`credential`,`credentials`,`header`,`headers`,`key`,`pass`,`passwd`,`password`,`pwd`,`secret`,`token`]);function ri(e){let t=[],n=!1;for(let r of e){if(n){t.push(ti),n=!1;continue}if(r.startsWith(`-H`)&&r.length>2&&!r.startsWith(`--`)&&r[2]!==`=`){t.push(`-H`+ti);continue}let e=ii(r);if(e!==null&&ai(e))if(r.includes(`=`)){let e=r.indexOf(`=`);t.push(r.slice(0,e+1)+ti)}else t.push(r),n=!0;else t.push(r)}return t}function ii(e){if(!e.startsWith(`-`))return null;let t=e.replace(/^-{1,2}/,``),n=t.indexOf(`=`);return n>=0?t.slice(0,n):t}function ai(e){return e===`H`?!0:ni.has(e.toLowerCase())}const oi=`onyx.security`;function si(e){if(!e)return e;let t;try{t=new URL(e)}catch{return e}if(!t.host||t.pathname===``||t.pathname===`/`)return e;let n=t.hostname.toLowerCase().replace(/\.$/,``);if(n!==oi&&!n.endsWith(`.${oi}`))return e;let r=t.pathname.split(`/`),i=r.findIndex(e=>e.length>0);if(i===-1)return e;r[i]=`[REDACTED]`;let a=r.join(`/`);return`${t.protocol}//${t.host}${a}${t.search}${t.hash}`}function ci(e){let t=Sr(JSON.stringify(e));return Buffer.from(t).toString(`base64url`)}var li=class{clientAppName;clientInfoBase64;sessionData;get scannerConfig(){return{apiKey:this.config.scanApiKey,enabled:this.config.scanEnabled,failOpen:this.config.scanFailOpen,headers:this.config.scanHeaders,timeoutMs:this.config.scanTimeoutMs,url:this.config.scanUrl}}config;constructor(e,t){this.config=e,this.sessionData=t,this.clientAppName=t.clientAppName||``,this.clientInfoBase64=this.getClientInfoBase64()}async evaluate(e){let t={action:`allow`};if(this.isScanEnabled())try{if(t=await this.scan({data:e.data,id:e.id,method:e.method,originalRequestId:e.originalRequestId,timestamp:e.timestamp,type:e.type}),a.info(`Scan result`,{action:t.action,id:e.id,method:e.method,originalRequestId:e.originalRequestId}),t.action===`block`)return a.warn(`Request blocked by security policy`),t}catch(t){if(a.error(`Scanning failed`,{error:t,method:e.method,requestType:e.type,scannerUrl:this.config.scanUrl}),!this.config.scanFailOpen)return a.warn(`Scanning service unavailable, blocking traffic (fail-closed)`),{action:`block`};a.warn(`Scanning service unavailable, allowing traffic (fail-open)`)}return t}isEnabled(){return this.isScanEnabled()}isScanEnabled(){return this.config.scanEnabled&&!!this.config.scanUrl}async scan(e){if(!this.isScanEnabled())return{action:`allow`};let t={data:e.data,id:e.id,metadata:this.buildEventMetadata(),method:e.method,originalRequestId:e.originalRequestId,type:e.type};a.info(`Scanning traffic`,{id:e.id,method:e.method,originalRequestId:e.originalRequestId,type:e.type});let n=await this.sendScanRequest(t);return a.info(`Scan result`,{action:n.action,blockReason:n.block_reason,hasModifiedData:!!n.modified_data,id:e.id,originalRequestId:e.originalRequestId}),n}updateConfig(e){this.config={...this.config,...e}}buildEventMetadata(){let e=this.config.spawnedServerInfoProvider?.();return{...this.sessionData,eventEndTime:new Date().toISOString(),...e?.pid===void 0?{}:{spawnedServerProcessId:e.pid},...e?.startedAtMs===void 0?{}:{spawnedServerProcessStartTime:new Date(e.startedAtMs).toISOString()}}}getClientInfoBase64(){return ci(this.sessionData)}async sendScanRequest(n){let r=new AbortController,i=setTimeout(()=>r.abort(),this.config.scanTimeoutMs);try{let i=`${this.config.scanUrl}/${this.config.scanApiKey}/mcp/${this.clientInfoBase64}`,a={data:n.data,id:n.id,metadata:n.metadata,method:n.method,sessionId:t,...n.originalRequestId&&{original_request_id:String(n.originalRequestId)},type:n.type},o=await e(i,{body:JSON.stringify(a),headers:{"Content-Type":`application/json`,...this.config.scanHeaders},method:`POST`,signal:r.signal});if(!o.ok)throw Error(`Sanitization service returned ${o.status}: ${o.statusText}`);let s=await o.json();if(!s.action||![`allow`,`block`,`modify`].includes(s.action))throw Error(`Invalid scan response format: action="${s.action}"`);return s}catch(e){throw e instanceof Error&&e.name===`AbortError`?Error(`Scan request timed out after ${this.config.scanTimeoutMs}ms`):e}finally{clearTimeout(i)}}};let ui=null;const di=async e=>{let t=await ei(),n=e.cliArgs.proxyType,r=n===`stdio`?{...e.cliArgs,args:ri(e.cliArgs.args)}:e.cliArgs,i={...t,fileContentHash:n===`stdio`?r.fileContentHash:void 0,proxyType:n,remoteCliArgs:n===`remote`?r:void 0,stdioCliArgs:n===`stdio`?r:void 0},o=n===`remote`?{...i,remoteCliArgs:{...r,url:si(r.url)}}:i;return a.setSessionData(o),ui=new li(e,i),ui},fi=()=>ui,pi=e=>{if(e.maxTotalTimeoutMs<0)throw Error(`maxTotalTimeoutMs must be >= 0 (0 disables the cap), got ${e.maxTotalTimeoutMs}`);let t={resetTimeoutOnProgress:e.resetTimeoutOnProgress,timeout:e.timeoutMs};return e.maxTotalTimeoutMs>0&&(t.maxTotalTimeout=e.maxTotalTimeoutMs),t},mi=new class{counts=new Map;lastLogTime=Date.now();logIntervalMs=6e4;increment(e){this.counts.set(e,(this.counts.get(e)||0)+1),this.maybeLog()}logAndReset(){if(this.counts.size===0)return;let e=(Array.from(this.counts.values()).reduce((e,t)=>e+t,0));a.info(`Requests intercepted`,{byMethod:Object.fromEntries(this.counts),eventType:`mcp_requests_intercepted`,totalCount:e}),this.counts.clear(),this.lastLogTime=Date.now()}maybeLog(){Date.now()-this.lastLogTime>=this.logIntervalMs&&this.logAndReset()}},hi=()=>{mi.logAndReset()},gi=e=>{if(e.length>1&&e[1]&&typeof e[1]==`object`&&`mcpReq`in e[1])return e[1].mcpReq?.id?.toString()},G=(e,t,n,r)=>async(...i)=>{mi.increment(e);let o=fi(),s=e,c=i[0],l=fr(),u=gi(i)?.toString();c&&typeof c==`object`&&`method`in c&&typeof c.method==`string`&&(s=c.method);let d=async(e,t,n)=>{try{if(!o?.isEnabled()&&!o?.isScanEnabled())return;let r;try{r=await o.evaluate({data:t,id:l,method:s,originalRequestId:u,timestamp:new Date().toISOString(),type:e})}catch(t){if(a.error(`${e} evaluation failed, applying fail-safe`,{error:t}),o?.isScanEnabled()&&!o.scannerConfig?.failOpen)throw Error(`Security scanning service unavailable`);return}if(a.info(`${e} scan result`,{action:r.action,id:l,method:s,...e===`request`&&{originalRequestId:u}}),r.action===`block`||r.action===`modify`){let t=r.action===`block`?`blocked`:`modified`,i=r.action===`block`&&e===`request`?`warn`:`log`;if(r.modified_data){if(r.action===`block`){let n=`${e} ${t} by security policy${e===`request`?`, returning error response`:``}`;return i===`warn`?a.warn(n):a.info(n),r.modified_data}if(n){let o=`${e} ${t} by security policy`;i===`warn`?a.warn(o):a.info(o),n(r.modified_data);return}return r.modified_data}a.warn(`${r.action} action without modified_data, allowing original ${e}`)}return}catch(t){if(a.error(`Unexpected error during ${e} processing`,{error:t}),e===`request`&&t instanceof Error&&t.message===`Security scanning service unavailable`)throw t;return}},f;try{f=await d(`request`,c,e=>{i[0]=e})}catch(n){if(n instanceof Error&&n.message===`Security scanning service unavailable`)throw a.error(`Security scanning unavailable (fail-closed)`,{error:n.message,handlerName:e,operation:t}),n;a.error(`Unexpected error during request processing, continuing`,{error:n,handlerName:e,operation:t})}if(f!==void 0)return f;if(r&&!await r.isAllowed()){let n=r.getBlockReason();throw a.warn(`MCP server blocked by access control`,{handlerName:e,operation:t,reason:n}),new Ar(n,`policy_block`)}try{let e=await n(...i);try{if(e){let t=await d(`response`,e);if(t!==void 0)return t}}catch(e){a.error(`Error during response processing, returning original result`,{error:e})}return e}catch(n){if(n instanceof Ar)throw a.info(`Request blocked by access control`,{error:n.message,handlerName:e,operation:t,reason:n.reason}),n;try{await d(`error`,{error:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:void 0})}catch(e){a.warn(`Failed to evaluate error`,{evalError:e})}throw a.error(`Handler error in ${e}`,{argsCount:i.length,errorMessage:n instanceof Error?n.message:String(n),operation:t}),n}},_i=async({authorizer:e,client:t,forwarding:r=n.toolCall,server:i,serverCapabilities:o})=>{let s=pi(r);o?.logging&&(i.setNotificationHandler(`notifications/message`,G(`notifications/message`,`server-to-client`,async e=>t.notification(e),e)),t.setNotificationHandler(`notifications/message`,G(`notifications/message`,`client-to-server`,async e=>i.notification(e),e))),o?.prompts&&(i.setRequestHandler(`prompts/get`,G(`prompts/get`,`get`,async e=>t.getPrompt(e.params,s),e)),i.setRequestHandler(`prompts/list`,G(`prompts/list`,`list`,async e=>t.listPrompts(e.params,s),e))),o?.resources&&(i.setRequestHandler(`resources/list`,G(`resources/list`,`list`,async e=>t.listResources(e.params,s),e)),i.setRequestHandler(`resources/templates/list`,G(`resources/templates/list`,`list`,async e=>t.listResourceTemplates(e.params,s),e)),i.setRequestHandler(`resources/read`,G(`resources/read`,`read`,async e=>t.readResource(e.params,s),e)),o?.resources.subscribe&&(i.setNotificationHandler(`notifications/resources/updated`,G(`notifications/resources/updated`,`notify`,async e=>t.notification(e),e)),i.setRequestHandler(`resources/subscribe`,G(`resources/subscribe`,`subscribe`,async e=>t.subscribeResource(e.params,s),e)),i.setRequestHandler(`resources/unsubscribe`,G(`resources/unsubscribe`,`unsubscribe`,async e=>t.unsubscribeResource(e.params,s),e)))),o?.tools&&(i.setRequestHandler(`tools/call`,G(`tools/call`,`call`,async(e,n)=>{let r=n.mcpReq._meta?.progressToken,i=r===void 0?void 0:e=>{n.mcpReq.notify({method:`notifications/progress`,params:{...e,progressToken:r}}).catch(e=>{a.warn(`Failed to forward progress notification to client`,{error:e})})};return t.callTool(e.params,{...s,onprogress:i})},e)),i.setRequestHandler(`tools/list`,G(`tools/list`,`list`,async e=>t.listTools(e.params,s),e))),o?.completions&&i.setRequestHandler(`completion/complete`,G(`completion/complete`,`complete`,async e=>t.complete(e.params,s),e))};var vi=Object.create,yi=Object.defineProperty,bi=Object.getOwnPropertyDescriptor,xi=Object.getOwnPropertyNames,Si=Object.getPrototypeOf,Ci=Object.prototype.hasOwnProperty,K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),wi=(e,t)=>{let n={};for(var r in e)yi(n,r,{get:e[r],enumerable:!0});return t&&yi(n,Symbol.toStringTag,{value:`Module`}),n},Ti=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xi(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ci.call(e,s)&&s!==n&&yi(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=bi(t,s))||r.enumerable});return e},Ei=(e,t,n)=>(n=e==null?{}:vi(Si(e)),Ti(t||!e||!e.__esModule?yi(n,`default`,{value:e,enumerable:!0}):n,e));const Di=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),Oi=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),ki=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),Ai=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function ji(e){return typeof e==`string`&&Oi.has(e.replace(/#$/,``))}function Mi(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(Di.has(n))return`2020-12`;if(Oi.has(n))return`2019-09`;if(ki.has(n)||Ai.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}const Ni=Symbol.for(`mcp.sdk.errorBrands`);function Pi(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Ni,{value:n,enumerable:!1,configurable:!0})}function Fi(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Ni)){let n=t[Ni];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}(class e extends Error{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return Fi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Fi(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Pi(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}});let q=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({});var J=class extends Error{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Fi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Fi(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`SdkError`,Pi(this,new.target)}};(class extends J{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.SdkHttpError`})}constructor(e,t,n){super(e,t,n),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}});function Ii(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Li(e,t,n){return e===`elicitation`&&t===`form`&&n.form===void 0&&n.url===void 0}function Ri(e){switch(e.method){case`elicitation/create`:return e.params?.mode===`url`?{elicitation:{url:{}}}:{elicitation:{form:{}}};case`sampling/createMessage`:{let t=e.params;return t!==void 0&&(t.tools!==void 0||t.toolChoice!==void 0)?{sampling:{tools:{}}}:{sampling:{}}}case`roots/list`:return{roots:{}};default:return}}function zi(e,t){let n={};for(let[r,i]of Object.entries(e)){if(i===void 0)continue;let e=t===void 0?void 0:t[r];if(e===void 0){n[r]=i;continue}if(Ii(i)&&Ii(e)){let t={};for(let[n,a]of Object.entries(i))a!==void 0&&e[n]===void 0&&!Li(r,n,e)&&(t[n]=a);Object.keys(t).length>0&&(n[r]=t)}}return Object.keys(n).length>0?n:void 0}const Bi=`2026-07-28`,Vi=[Bi];function Hi(e){return e>=Bi}function Ui(e){return e.filter(e=>!Hi(e))}function Wi(e){return e.filter(e=>Hi(e))}function Gi(e){let t=e.structuredContent;return t===void 0||!(typeof t!=`object`||!t||Array.isArray(t))||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}const Ki=[`task`,`inputRequests`,`requestState`];function qi(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||Ki.some(t=>t in e)?e:{...e,content:[]}}function Ji(){let e=or(()=>U([H(),R(),F(),er(),V(H(),e),P(e)])),t=V(H(),e),n=U([H(),R().int()]),r=H(),i=z({ttl:R().optional()}),a=z({taskId:H()}),o=L({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=z({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=z({method:H(),params:s.loose().optional()}),u=z({_meta:o.optional()}),d=z({method:H(),params:u.loose().optional()}),f=L({_meta:o.optional()}),p=U([H(),R().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:H().optional()}),g=d.extend({method:I(`notifications/cancelled`),params:h}),_=z({src:H(),mimeType:H().optional(),sizes:P(H()).optional(),theme:N([`light`,`dark`]).optional()}),v=z({icons:P(_).optional()}),y=z({name:H(),title:H().optional()}),b=y.extend({...y.shape,...v.shape,version:H(),websiteUrl:H().optional(),description:H().optional()}),x=ar(z({applyDefaults:F().optional()}),t),S=sr(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ar(z({form:x.optional(),url:t.optional()}),t.optional())),C=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),ee=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),te=z({experimental:V(H(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:S.optional(),roots:z({listChanged:F().optional()}).optional(),tasks:C.optional(),extensions:V(H(),t).optional()}),ne=s.extend({protocolVersion:H(),capabilities:te,clientInfo:b}),w=l.extend({method:I(`initialize`),params:ne}),re=z({experimental:V(H(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:F().optional()}).optional(),resources:z({subscribe:F().optional(),listChanged:F().optional()}).optional(),tools:z({listChanged:F().optional()}).optional(),tasks:ee.optional(),extensions:V(H(),t).optional()}),T=f.extend({protocolVersion:H(),capabilities:re,serverInfo:b,instructions:H().optional()}),ie=d.extend({method:I(`notifications/initialized`),params:u.optional()}),ae=l.extend({method:I(`ping`),params:s.optional()}),oe=z({progress:R(),total:B(R()),message:B(H())}),se=z({...u.shape,...oe.shape,progressToken:n}),ce=d.extend({method:I(`notifications/progress`),params:se}),le=s.extend({cursor:r.optional()}),E=l.extend({params:le.optional()}),D=f.extend({nextCursor:r.optional()}),ue=z({uri:H(),mimeType:B(H()),_meta:V(H(),W()).optional()}),de=ue.extend({text:H()}),fe=H().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),pe=ue.extend({blob:fe}),O=N([`user`,`assistant`]),me=z({audience:P(O).optional(),priority:R().min(0).max(1).optional(),lastModified:nr({offset:!0}).optional()}),he=z({...y.shape,...v.shape,uri:H(),description:B(H()),mimeType:B(H()),size:B(R()),annotations:me.optional(),_meta:B(L({}))}),ge=z({...y.shape,...v.shape,uriTemplate:H(),description:B(H()),mimeType:B(H()),annotations:me.optional(),_meta:B(L({}))}),_e=E.extend({method:I(`resources/list`)}),ve=D.extend({resources:P(he)}),ye=E.extend({method:I(`resources/templates/list`)}),be=D.extend({resourceTemplates:P(ge)}),xe=s.extend({uri:H()}),Se=xe,Ce=l.extend({method:I(`resources/read`),params:Se}),we=f.extend({contents:P(U([de,pe]))}),Te=d.extend({method:I(`notifications/resources/list_changed`),params:u.optional()}),Ee=xe,De=l.extend({method:I(`resources/subscribe`),params:Ee}),Oe=xe,ke=l.extend({method:I(`resources/unsubscribe`),params:Oe}),Ae=u.extend({uri:H()}),je=d.extend({method:I(`notifications/resources/updated`),params:Ae}),Me=z({name:H(),description:B(H()),required:B(F())}),Ne=z({...y.shape,...v.shape,description:B(H()),arguments:B(P(Me)),_meta:B(L({}))}),Pe=E.extend({method:I(`prompts/list`)}),Fe=D.extend({prompts:P(Ne)}),Ie=s.extend({name:H(),arguments:V(H(),H()).optional()}),Le=l.extend({method:I(`prompts/get`),params:Ie}),Re=z({type:I(`text`),text:H(),annotations:me.optional(),_meta:V(H(),W()).optional()}),ze=z({type:I(`image`),data:fe,mimeType:H(),annotations:me.optional(),_meta:V(H(),W()).optional()}),Be=z({type:I(`audio`),data:fe,mimeType:H(),annotations:me.optional(),_meta:V(H(),W()).optional()}),Ve=z({type:I(`tool_use`),name:H(),id:H(),input:V(H(),W()),_meta:V(H(),W()).optional()}),He=z({type:I(`resource`),resource:U([de,pe]),annotations:me.optional(),_meta:V(H(),W()).optional()}),Ue=he.extend({type:I(`resource_link`)}),We=U([Re,ze,Be,Ue,He]),Ge=z({role:O,content:We}),Ke=f.extend({description:H().optional(),messages:P(Ge)}),qe=d.extend({method:I(`notifications/prompts/list_changed`),params:u.optional()}),Je=z({title:H().optional(),readOnlyHint:F().optional(),destructiveHint:F().optional(),idempotentHint:F().optional(),openWorldHint:F().optional()}),Ye=z({taskSupport:N([`required`,`optional`,`forbidden`]).optional()}),Xe=z({...y.shape,...v.shape,description:H().optional(),inputSchema:z({type:I(`object`),properties:V(H(),e).optional(),required:P(H()).optional()}).catchall(W()),outputSchema:z({type:I(`object`),properties:V(H(),e).optional(),required:P(H()).optional()}).catchall(W()).optional(),annotations:Je.optional(),execution:Ye.optional(),_meta:V(H(),W()).optional()}),Ze=E.extend({method:I(`tools/list`)}),Qe=D.extend({tools:P(Xe)}),$e=f.extend({content:P(We),structuredContent:V(H(),W()).optional(),isError:F().optional()}),et=c.extend({name:H(),arguments:V(H(),W()).optional()}),tt=l.extend({method:I(`tools/call`),params:et}),nt=d.extend({method:I(`notifications/tools/list_changed`),params:u.optional()}),k=N([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),rt=s.extend({level:k}),it=l.extend({method:I(`logging/setLevel`),params:rt}),at=u.extend({level:k,logger:H().optional(),data:W()}),ot=d.extend({method:I(`notifications/message`),params:at}),st=z({name:H().optional()}),ct=z({hints:P(st).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),lt=z({mode:N([`auto`,`required`,`none`]).optional()}),ut=z({type:I(`tool_result`),toolUseId:H().describe(`The unique identifier for the corresponding tool call.`),content:P(We),structuredContent:z({}).loose().optional(),isError:F().optional(),_meta:V(H(),W()).optional()}),dt=rr(`type`,[Re,ze,Be]),ft=rr(`type`,[Re,ze,Be,Ve,ut]),pt=z({role:O,content:U([ft,P(ft)]),_meta:V(H(),W()).optional()}),mt=c.extend({messages:P(pt),modelPreferences:ct.optional(),systemPrompt:H().optional(),includeContext:N([`none`,`thisServer`,`allServers`]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:P(H()).optional(),metadata:t.optional(),tools:P(Xe).optional(),toolChoice:lt.optional()}),ht=l.extend({method:I(`sampling/createMessage`),params:mt}),gt=f.extend({model:H(),stopReason:B(N([`endTurn`,`stopSequence`,`maxTokens`]).or(H())),role:O,content:dt}),_t=f.extend({model:H(),stopReason:B(N([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(H())),role:O,content:U([ft,P(ft)])}),vt=z({type:I(`boolean`),title:H().optional(),description:H().optional(),default:F().optional()}),yt=z({type:I(`string`),title:H().optional(),description:H().optional(),minLength:R().optional(),maxLength:R().optional(),format:N([`email`,`uri`,`date`,`date-time`]).optional(),default:H().optional()}),bt=z({type:N([`number`,`integer`]),title:H().optional(),description:H().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),xt=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),default:H().optional()}),St=z({type:I(`string`),title:H().optional(),description:H().optional(),oneOf:P(z({const:H(),title:H()})),default:H().optional()}),Ct=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),enumNames:P(H()).optional(),default:H().optional()}),wt=U([xt,St]),Tt=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({type:I(`string`),enum:P(H())}),default:P(H()).optional()}),Et=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({anyOf:P(z({const:H(),title:H()}))}),default:P(H()).optional()}),Dt=U([Tt,Et]),Ot=U([Ct,wt,Dt]),kt=U([Ot,vt,yt,bt]),At=c.extend({mode:I(`form`).optional(),message:H(),requestedSchema:z({type:I(`object`),properties:V(H(),kt),required:P(H()).optional()}).catchall(W())}),jt=c.extend({mode:I(`url`),message:H(),elicitationId:H(),url:H().url()}),Mt=U([At,jt]),A=l.extend({method:I(`elicitation/create`),params:Mt}),j=u.extend({elicitationId:H()}),Nt=d.extend({method:I(`notifications/elicitation/complete`),params:j}),Pt=f.extend({action:N([`accept`,`decline`,`cancel`]),content:sr(e=>e===null?void 0:e,V(H(),U([H(),R(),F(),P(H())])).optional())}),Ft=z({type:I(`ref/resource`),uri:H()}),It=z({type:I(`ref/prompt`),name:H()}),Lt=s.extend({ref:U([It,Ft]),argument:z({name:H(),value:H()}),context:z({arguments:V(H(),H()).optional()}).optional()}),Rt=l.extend({method:I(`completion/complete`),params:Lt}),zt=f.extend({completion:L({values:P(H()).max(100),total:B(R().int()),hasMore:B(F())})}),Bt=z({uri:H().startsWith(`file://`),name:H().optional(),_meta:V(H(),W()).optional()}),Vt=l.extend({method:I(`roots/list`),params:s.optional()}),Ht=f.extend({roots:P(Bt)}),Ut=d.extend({method:I(`notifications/roots/list_changed`),params:u.optional()}),Wt=L({ttl:R().optional(),pollInterval:R().optional()}),Gt=N([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Kt=z({taskId:H(),status:Gt,ttl:U([R(),er()]),createdAt:H(),lastUpdatedAt:H(),pollInterval:B(R()),statusMessage:B(H())}),qt=f.extend({task:Kt}),Jt=u.merge(Kt),Yt=d.extend({method:I(`notifications/tasks/status`),params:Jt}),Xt=l.extend({method:I(`tasks/get`),params:s.extend({taskId:H()})}),M=f.merge(Kt),Zt=l.extend({method:I(`tasks/result`),params:s.extend({taskId:H()})}),Qt=f.loose(),$t=E.extend({method:I(`tasks/list`)}),en=D.extend({tasks:P(Kt)}),tn=l.extend({method:I(`tasks/cancel`),params:s.extend({taskId:H()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:m,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:b,ClientTasksCapabilitySchema:C,ServerTasksCapabilitySchema:ee,ClientCapabilitiesSchema:te,InitializeRequestParamsSchema:ne,InitializeRequestSchema:w,ServerCapabilitiesSchema:re,InitializeResultSchema:T,InitializedNotificationSchema:ie,PingRequestSchema:ae,ProgressSchema:oe,ProgressNotificationParamsSchema:se,ProgressNotificationSchema:ce,PaginatedRequestParamsSchema:le,PaginatedRequestSchema:E,PaginatedResultSchema:D,ResourceContentsSchema:ue,TextResourceContentsSchema:de,BlobResourceContentsSchema:pe,RoleSchema:O,AnnotationsSchema:me,ResourceSchema:he,ResourceTemplateSchema:ge,ListResourcesRequestSchema:_e,ListResourcesResultSchema:ve,ListResourceTemplatesRequestSchema:ye,ListResourceTemplatesResultSchema:be,ResourceRequestParamsSchema:xe,ReadResourceRequestParamsSchema:Se,ReadResourceRequestSchema:Ce,ReadResourceResultSchema:we,ResourceListChangedNotificationSchema:Te,SubscribeRequestParamsSchema:Ee,SubscribeRequestSchema:De,UnsubscribeRequestParamsSchema:Oe,UnsubscribeRequestSchema:ke,ResourceUpdatedNotificationParamsSchema:Ae,ResourceUpdatedNotificationSchema:je,PromptArgumentSchema:Me,PromptSchema:Ne,ListPromptsRequestSchema:Pe,ListPromptsResultSchema:Fe,GetPromptRequestParamsSchema:Ie,GetPromptRequestSchema:Le,TextContentSchema:Re,ImageContentSchema:ze,AudioContentSchema:Be,ToolUseContentSchema:Ve,EmbeddedResourceSchema:He,ResourceLinkSchema:Ue,ContentBlockSchema:We,PromptMessageSchema:Ge,GetPromptResultSchema:Ke,PromptListChangedNotificationSchema:qe,ToolAnnotationsSchema:Je,ToolExecutionSchema:Ye,ToolSchema:Xe,ListToolsRequestSchema:Ze,ListToolsResultSchema:Qe,CallToolResultSchema:$e,CallToolRequestParamsSchema:et,CallToolRequestSchema:tt,ToolListChangedNotificationSchema:nt,LoggingLevelSchema:k,SetLevelRequestParamsSchema:rt,SetLevelRequestSchema:it,LoggingMessageNotificationParamsSchema:at,LoggingMessageNotificationSchema:ot,ModelHintSchema:st,ModelPreferencesSchema:ct,ToolChoiceSchema:lt,ToolResultContentSchema:ut,SamplingContentSchema:dt,SamplingMessageContentBlockSchema:ft,SamplingMessageSchema:pt,CreateMessageRequestParamsSchema:mt,CreateMessageRequestSchema:ht,CreateMessageResultSchema:gt,CreateMessageResultWithToolsSchema:_t,BooleanSchemaSchema:vt,StringSchemaSchema:yt,NumberSchemaSchema:bt,UntitledSingleSelectEnumSchemaSchema:xt,TitledSingleSelectEnumSchemaSchema:St,LegacyTitledEnumSchemaSchema:Ct,SingleSelectEnumSchemaSchema:wt,UntitledMultiSelectEnumSchemaSchema:Tt,TitledMultiSelectEnumSchemaSchema:Et,MultiSelectEnumSchemaSchema:Dt,EnumSchemaSchema:Ot,PrimitiveSchemaDefinitionSchema:kt,ElicitRequestFormParamsSchema:At,ElicitRequestURLParamsSchema:jt,ElicitRequestParamsSchema:Mt,ElicitRequestSchema:A,ElicitationCompleteNotificationParamsSchema:j,ElicitationCompleteNotificationSchema:Nt,ElicitResultSchema:Pt,ResourceTemplateReferenceSchema:Ft,PromptReferenceSchema:It,CompleteRequestParamsSchema:Lt,CompleteRequestSchema:Rt,CompleteResultSchema:zt,RootSchema:Bt,ListRootsRequestSchema:Vt,ListRootsResultSchema:Ht,RootsListChangedNotificationSchema:Ut,TaskCreationParamsSchema:Wt,TaskStatusSchema:Gt,TaskSchema:Kt,CreateTaskResultSchema:qt,TaskStatusNotificationParamsSchema:Jt,TaskStatusNotificationSchema:Yt,GetTaskRequestSchema:Xt,GetTaskResultSchema:M,GetTaskPayloadRequestSchema:Zt,GetTaskPayloadResultSchema:Qt,ListTasksRequestSchema:$t,ListTasksResultSchema:en,CancelTaskRequestSchema:tn,CancelTaskResultSchema:f.merge(Kt),ClientRequestSchema:U([ae,w,Rt,it,Le,Pe,_e,ye,Ce,De,ke,tt,Ze,Xt,Zt,$t,tn]),ClientNotificationSchema:U([g,ce,ie,Ut,Yt]),ClientResultSchema:U([m,gt,_t,Pt,Ht,M,en,qt]),ServerRequestSchema:U([ae,ht,A,Vt,Xt,Zt,$t,tn]),ServerNotificationSchema:U([g,ce,ot,je,Te,nt,qe,Yt,Nt]),ServerResultSchema:U([m,T,zt,Ke,Fe,ve,be,we,$e,Qe,M,en,qt]),CallToolResultWireSchema:W().superRefine((e,t)=>{if(!(typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0)){for(let n of Ki)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(qi).pipe($e)}}let Yi;function Xi(){return Yi??=Ji()}function Zi(e){return e.type!==`object`}const Qi=new Set([`const`,`enum`,`default`,`examples`]),$i=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function ea(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function ta(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(ea(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=ji(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&ea(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:Qi.has(o)?i[o]=s:$i.has(o)?i[o]=r(s,!0):i[o]=r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}const na={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},ra={"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},ia={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};let aa;function oa(){if(aa)return aa;let e=Xi();return aa={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},aa}function sa(e){return Object.prototype.hasOwnProperty.call(na,e)}function ca(e){return Object.prototype.hasOwnProperty.call(ra,e)}function la(e){return Object.prototype.hasOwnProperty.call(ia,e)}function ua(e){return la(e)?oa().resultSchemas[e]:void 0}function da(e){return sa(e)?oa().requestSchemas[e]:void 0}function fa(e){return ca(e)?oa().notificationSchemas[e]:void 0}function pa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ma(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}const ha={ok:!1,reason:`not-in-era`};function ga(e){return pa(e)&&pa(e.outputSchema)&&Zi(e.outputSchema)}function _a(e){return e}const va={era:`2025-11-25`,hasRequestMethod:sa,hasNotificationMethod:ca,validateRequest:(e,t)=>ma(da(e),t),validateResult:(e,t)=>ma(ua(e),t),validateNotification:(e,t)=>ma(fa(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>ha,validateInputResponse:()=>ha,samplingResultVariant:((e,t)=>{let n=Xi();return ma(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=Gi(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&Zi(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(pa(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:_a(e)}}return{kind:`complete`,result:_a(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>ga(e))?t:{...t,tools:n.map(e=>ga(e)?{...e,outputSchema:ta(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function ya(){let e=or(()=>U([H(),R(),F(),er(),V(H(),e),P(e)])),t=V(H(),e),n=U([H(),R().int()]),r=H(),i=U([H(),R().int()]),a=N([`user`,`assistant`]),o=N([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=H().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=z({ttl:R().optional()}),l=z({taskId:H()}),u=L({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=z({_meta:u.optional()}),f=d.extend({task:c.optional()}),h=z({_meta:u.optional()}),g=z({method:H(),params:h.loose().optional()}),_=z({src:H(),mimeType:H().optional(),sizes:P(H()).optional(),theme:N([`light`,`dark`]).optional()}),v=z({icons:P(_).optional()}),y=z({name:H(),title:H().optional()}),b=y.extend({...y.shape,...v.shape,version:H(),websiteUrl:H().optional(),description:H().optional()}),x=ar(z({applyDefaults:F().optional()}),t),S=sr(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ar(z({form:x.optional(),url:t.optional()}),t.optional())),C=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),ee=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),te=z({experimental:V(H(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:S.optional(),roots:z({listChanged:F().optional()}).optional(),tasks:C.optional(),extensions:V(H(),t).optional()}),ne=z({experimental:V(H(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:F().optional()}).optional(),resources:z({subscribe:F().optional(),listChanged:F().optional()}).optional(),tools:z({listChanged:F().optional()}).optional(),tasks:ee.optional(),extensions:V(H(),t).optional()}),w=z({progress:R(),total:B(R()),message:B(H())}),re=z({...h.shape,...w.shape,progressToken:n}),T=g.extend({method:I(`notifications/progress`),params:re}),ie=h.extend({level:o,logger:H().optional(),data:W()}),ae=g.extend({method:I(`notifications/message`),params:ie}),oe=z({uri:H(),mimeType:B(H()),_meta:V(H(),W()).optional()}),se=oe.extend({text:H()}),ce=oe.extend({blob:s}),le=z({audience:P(a).optional(),priority:R().min(0).max(1).optional(),lastModified:nr({offset:!0}).optional()}),E=z({...y.shape,...v.shape,uri:H(),description:B(H()),mimeType:B(H()),size:B(R()),annotations:le.optional(),_meta:B(L({}))}),D=z({...y.shape,...v.shape,uriTemplate:H(),description:B(H()),mimeType:B(H()),annotations:le.optional(),_meta:B(L({}))}),ue=g.extend({method:I(`notifications/resources/list_changed`),params:h.optional()}),de=h.extend({uri:H()}),fe=g.extend({method:I(`notifications/resources/updated`),params:de}),pe=z({name:H(),description:B(H()),required:B(F())}),O=z({...y.shape,...v.shape,description:B(H()),arguments:B(P(pe)),_meta:B(L({}))}),me=g.extend({method:I(`notifications/prompts/list_changed`),params:h.optional()}),he=z({type:I(`text`),text:H(),annotations:le.optional(),_meta:V(H(),W()).optional()}),ge=z({type:I(`image`),data:s,mimeType:H(),annotations:le.optional(),_meta:V(H(),W()).optional()}),_e=z({type:I(`audio`),data:s,mimeType:H(),annotations:le.optional(),_meta:V(H(),W()).optional()}),ve=z({type:I(`tool_use`),name:H(),id:H(),input:V(H(),W()),_meta:V(H(),W()).optional()}),ye=z({type:I(`resource`),resource:U([se,ce]),annotations:le.optional(),_meta:V(H(),W()).optional()}),be=E.extend({type:I(`resource_link`)}),xe=U([he,ge,_e,be,ye]),Se=z({role:a,content:xe}),Ce=z({title:H().optional(),readOnlyHint:F().optional(),destructiveHint:F().optional(),idempotentHint:F().optional(),openWorldHint:F().optional()}),we=g.extend({method:I(`notifications/tools/list_changed`),params:h.optional()}),Te=z({name:H().optional()}),Ee=z({hints:P(Te).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),De=z({mode:N([`auto`,`required`,`none`]).optional()}),Oe=z({type:I(`boolean`),title:H().optional(),description:H().optional(),default:F().optional()}),ke=z({type:I(`string`),title:H().optional(),description:H().optional(),minLength:R().optional(),maxLength:R().optional(),format:N([`email`,`uri`,`date`,`date-time`]).optional(),default:H().optional()}),Ae=z({type:N([`number`,`integer`]),title:H().optional(),description:H().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),je=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),default:H().optional()}),Me=z({type:I(`string`),title:H().optional(),description:H().optional(),oneOf:P(z({const:H(),title:H()})),default:H().optional()}),Ne=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),enumNames:P(H()).optional(),default:H().optional()}),Pe=U([je,Me]),Fe=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({type:I(`string`),enum:P(H())}),default:P(H()).optional()}),Ie=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({anyOf:P(z({const:H(),title:H()}))}),default:P(H()).optional()}),Le=U([Fe,Ie]),Re=U([Ne,Pe,Le]),ze=U([Re,Oe,ke,Ae]),Be=f.extend({mode:I(`form`).optional(),message:H(),requestedSchema:z({type:I(`object`),properties:V(H(),ze),required:P(H()).optional()}).catchall(W())}),Ve=z({type:I(`ref/resource`),uri:H()}),He=z({type:I(`ref/prompt`),name:H()}),Ue=z({uri:H().startsWith(`file://`),name:H().optional(),_meta:V(H(),W()).optional()}),We=te.shape,Ge=z({experimental:We.experimental,sampling:We.sampling,elicitation:We.elicitation,roots:We.roots,extensions:We.extensions}),Ke=ne.shape,qe=z({experimental:Ke.experimental,logging:Ke.logging,completions:Ke.completions,prompts:Ke.prompts,resources:Ke.resources,tools:Ke.tools,extensions:Ke.extensions}),Ye=L({progressToken:n.optional(),[Ot]:H(),[m]:b.optional(),[p]:Ge,[Je]:o.optional()}),Xe=z({...y.shape,...v.shape,description:H().optional(),inputSchema:L({$schema:H().optional(),type:I(`object`)}),outputSchema:L({$schema:H().optional()}).optional(),annotations:Ce.optional(),_meta:V(H(),W()).optional()}),Ze=z({type:I(`tool_result`),toolUseId:H(),content:P(xe),structuredContent:W().optional(),isError:F().optional(),_meta:V(H(),W()).optional()}),Qe=U([he,ge,_e,ve,Ze]),$e=z({role:a,content:U([Qe,P(Qe)]),_meta:V(H(),W()).optional()}),et=H(),tt=L({[cn]:b.optional().catch(void 0)}),nt=tt.optional();function k(e){return L({_meta:nt,resultType:et.default(`complete`),...e})}let rt=k({}),it=k({nextCursor:r.optional()}),at=k({content:P(xe),structuredContent:W().optional(),isError:F().optional()}),ot=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),tools:P(Xe),nextCursor:r.optional()}),st=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),prompts:P(O),nextCursor:r.optional()}),ct=k({description:H().optional(),messages:P(Se)}),lt=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resources:P(E),nextCursor:r.optional()}),ut=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resourceTemplates:P(D),nextCursor:r.optional()}),dt=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),contents:P(U([se,ce]))}),ft=k({completion:z({values:P(H()).max(100),total:R().int().optional(),hasMore:F().optional()}).loose()}),pt=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`])}),mt=k({ttlMs:R().int().min(0).catch(0),cacheScope:N([`public`,`private`]).catch(`private`),supportedVersions:P(H()),capabilities:qe,instructions:H().optional()}),ht=z({messages:P($e),modelPreferences:Ee.optional(),systemPrompt:H().optional(),includeContext:N([`none`,`thisServer`,`allServers`]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:P(H()).optional(),metadata:t.optional(),tools:P(Xe).optional(),toolChoice:De.optional()}),gt=z({method:I(`sampling/createMessage`),params:ht}),_t=z({method:I(`roots/list`),params:z({_meta:V(H(),W()).optional()}).optional()}),vt=z({...$e.shape,model:H(),stopReason:H().optional()}),yt=z({roots:P(Ue)}),bt=z({action:N([`accept`,`decline`,`cancel`]),content:V(H(),U([H(),R(),F(),P(H())])).optional()}),xt=z({mode:I(`url`),message:H(),url:H().url()}),St=U([Be,xt]),Ct=z({method:I(`elicitation/create`),params:St}),wt=U([gt,_t,Ct]),Tt=U([vt,yt,bt]),Et=V(H(),wt),Dt=V(H(),Tt),kt=k({inputRequests:Et.optional(),requestState:H().optional()}),At={inputResponses:Dt.optional(),requestState:H().optional()},jt=z({_meta:Ye,...At}),Mt=L({progressToken:n.optional()});function A(e,t){return z({method:I(e),params:z({_meta:Ye,...t})})}function j(e,t){return z({method:I(e),params:z({_meta:Mt.optional(),...t}).optional()})}let Nt={name:H(),arguments:V(H(),W()).optional(),...At},Pt={cursor:r.optional()},Ft=A(`tools/call`,Nt),It=A(`tools/list`,Pt),Lt=A(`prompts/list`,Pt),Rt=A(`prompts/get`,{name:H(),arguments:V(H(),H()).optional(),...At}),zt=A(`resources/list`,Pt),Bt=A(`resources/templates/list`,Pt),Vt=A(`resources/read`,{uri:H(),...At}),Ht={ref:U([He,Ve]),argument:z({name:H(),value:H()}),context:z({arguments:V(H(),H()).optional()}).optional()},Ut=A(`completion/complete`,Ht),Wt=A(`server/discover`,{}),Gt=z({toolsListChanged:F().optional(),promptsListChanged:F().optional(),resourcesListChanged:F().optional(),resourceSubscriptions:P(H()).optional()}),Kt={notifications:Gt},qt=A(`subscriptions/listen`,Kt),Jt=tt.extend({"io.modelcontextprotocol/subscriptionId":i}),Yt=L({_meta:Jt,resultType:et.default(`complete`)}),Xt={"tools/call":j(`tools/call`,Nt),"tools/list":j(`tools/list`,Pt),"prompts/get":j(`prompts/get`,{name:H(),arguments:V(H(),H()).optional()}),"prompts/list":j(`prompts/list`,Pt),"resources/list":j(`resources/list`,Pt),"resources/templates/list":j(`resources/templates/list`,Pt),"resources/read":j(`resources/read`,{uri:H()}),"completion/complete":j(`completion/complete`,Ht),"server/discover":j(`server/discover`,{}),"subscriptions/listen":j(`subscriptions/listen`,Kt)};function M(e){return L({_meta:nt,...e})}let Zt={"tools/call":M({content:P(xe),structuredContent:W().optional(),isError:F().optional()}),"tools/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),tools:P(Xe),nextCursor:r.optional()}),"prompts/get":M({description:H().optional(),messages:P(Se)}),"prompts/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),prompts:P(O),nextCursor:r.optional()}),"resources/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resources:P(E),nextCursor:r.optional()}),"resources/templates/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resourceTemplates:P(D),nextCursor:r.optional()}),"resources/read":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),contents:P(U([se,ce]))}),"completion/complete":M({completion:z({values:P(H()).max(100),total:R().int().optional(),hasMore:F().optional()}).loose()}),"server/discover":M({ttlMs:R().int().min(0).catch(0),cacheScope:N([`public`,`private`]).catch(`private`),supportedVersions:P(H()),capabilities:qe,instructions:H().optional()}),"subscriptions/listen":M({})},Qt=L({"io.modelcontextprotocol/subscriptionId":i.optional()}),$t=z({method:I(`notifications/subscriptions/acknowledged`),params:z({_meta:Qt.optional(),notifications:Gt})}),en=z({_meta:Qt.optional(),requestId:i,reason:H().optional()}),tn=z({method:I(`notifications/cancelled`),params:en}),nn={"notifications/cancelled":tn,"notifications/progress":T,"notifications/message":ae,"notifications/resources/updated":fe,"notifications/resources/list_changed":ue,"notifications/tools/list_changed":we,"notifications/prompts/list_changed":me,"notifications/subscriptions/acknowledged":$t},rn=e=>z({jsonrpc:I(`2.0`),id:U([H(),R().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:h,NotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:b,ClientTasksCapabilitySchema:C,ServerTasksCapabilitySchema:ee,ClientCapabilitiesSchema:te,ServerCapabilitiesSchema:ne,ProgressSchema:w,ProgressNotificationParamsSchema:re,ProgressNotificationSchema:T,LoggingMessageNotificationParamsSchema:ie,LoggingMessageNotificationSchema:ae,ResourceContentsSchema:oe,TextResourceContentsSchema:se,BlobResourceContentsSchema:ce,AnnotationsSchema:le,ResourceSchema:E,ResourceTemplateSchema:D,ResourceListChangedNotificationSchema:ue,ResourceUpdatedNotificationParamsSchema:de,ResourceUpdatedNotificationSchema:fe,PromptArgumentSchema:pe,PromptSchema:O,PromptListChangedNotificationSchema:me,TextContentSchema:he,ImageContentSchema:ge,AudioContentSchema:_e,ToolUseContentSchema:ve,EmbeddedResourceSchema:ye,ResourceLinkSchema:be,ContentBlockSchema:xe,PromptMessageSchema:Se,ToolAnnotationsSchema:Ce,ToolListChangedNotificationSchema:we,ModelHintSchema:Te,ModelPreferencesSchema:Ee,ToolChoiceSchema:De,BooleanSchemaSchema:Oe,StringSchemaSchema:ke,NumberSchemaSchema:Ae,UntitledSingleSelectEnumSchemaSchema:je,TitledSingleSelectEnumSchemaSchema:Me,LegacyTitledEnumSchemaSchema:Ne,SingleSelectEnumSchemaSchema:Pe,UntitledMultiSelectEnumSchemaSchema:Fe,TitledMultiSelectEnumSchemaSchema:Ie,MultiSelectEnumSchemaSchema:Le,EnumSchemaSchema:Re,PrimitiveSchemaDefinitionSchema:ze,ElicitRequestFormParamsSchema:Be,ResourceTemplateReferenceSchema:Ve,PromptReferenceSchema:He,RootSchema:Ue,ClientCapabilities2026Schema:Ge,ServerCapabilities2026Schema:qe,RequestMetaEnvelopeSchema:Ye,ToolSchema:Xe,ToolResultContentSchema:Ze,SamplingMessageContentBlockSchema:Qe,SamplingMessageSchema:$e,ResultTypeSchema:et,ResultMetaSchema:tt,ResultSchema:rt,PaginatedResultSchema:it,CallToolResultSchema:at,ListToolsResultSchema:ot,ListPromptsResultSchema:st,GetPromptResultSchema:ct,ListResourcesResultSchema:lt,ListResourceTemplatesResultSchema:ut,ReadResourceResultSchema:dt,CompleteResultSchema:ft,CacheableResultSchema:pt,DiscoverResultSchema:mt,CreateMessageRequestParamsSchema:ht,CreateMessageRequestSchema:gt,ListRootsRequestSchema:_t,CreateMessageResultSchema:vt,ListRootsResultSchema:yt,ElicitResultSchema:bt,ElicitRequestURLParamsSchema:xt,ElicitRequestParamsSchema:St,ElicitRequestSchema:Ct,InputRequestSchema:wt,InputResponseSchema:Tt,InputRequestsSchema:Et,InputResponsesSchema:Dt,InputRequiredResultSchema:kt,InputResponseRequestParamsSchema:jt,CallToolRequestSchema:Ft,ListToolsRequestSchema:It,ListPromptsRequestSchema:Lt,GetPromptRequestSchema:Rt,ListResourcesRequestSchema:zt,ListResourceTemplatesRequestSchema:Bt,ReadResourceRequestSchema:Vt,CompleteRequestSchema:Ut,DiscoverRequestSchema:Wt,SubscriptionFilterSchema:Gt,SubscriptionsListenRequestSchema:qt,SubscriptionsListenResultMetaSchema:Jt,SubscriptionsListenResultSchema:Yt,dispatchRequestSchemas:Xt,dispatchResultSchemas:Zt,NotificationMetaSchema:Qt,SubscriptionsAcknowledgedNotificationSchema:$t,CancelledNotificationParamsSchema:en,CancelledNotificationSchema:tn,notificationSchemas2026:nn,JSONRPCResultResponseSchema:rn(rt),CallToolResultResponseSchema:rn(U([at,kt])),ListToolsResultResponseSchema:rn(ot),ListPromptsResultResponseSchema:rn(st),GetPromptResultResponseSchema:rn(U([ct,kt])),ListResourcesResultResponseSchema:rn(lt),ListResourceTemplatesResultResponseSchema:rn(ut),ReadResourceResultResponseSchema:rn(U([dt,kt])),CompleteResultResponseSchema:rn(ft),DiscoverResultResponseSchema:rn(mt)}}let ba;function xa(){return ba??=ya()}const Sa=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Ca(e){return Sa.includes(e)}const wa=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Ta(e,t){if(t===void 0)return e;let n=e[wa];if(n===void 0)return{...e,[wa]:t};let r={},i=n.ttlMs??t.ttlMs;i!==void 0&&(r.ttlMs=i);let a=n.cacheScope??t.cacheScope;return a!==void 0&&(r.cacheScope=a),{...e,[wa]:r}}function Ea(e){return e[wa]}function Da(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Oa(e){return e===`public`||e===`private`}function ka(e,t){if(e.ttlMs!==void 0&&!Da(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!Oa(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}let Y=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({});var X=class e extends Error{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Fi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Fi(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Pi(this,new.target)}static fromError(t,n,r){if(t===Y.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new ja(e.elicitations,n)}if(t===Y.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Ma({supported:e.supported,requested:e.requested},n)}if(t===Y.InvalidParams||t===Y.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===Y.ResourceNotFound||Object.keys(e).length===1))return new Aa(e.uri,n)}if(t===Y.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Na({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Aa=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(Y.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},ja=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Y.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Ma=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Y.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Na=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(Y.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};const Pa=[`tools/call`,`prompts/get`,`resources/read`];function Fa(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||Pa.includes(e))return t;throw new X(Y.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Ia(e,t){let n=Ea(t);if(t.resultType!==`complete`||!Ca(e))return n===void 0?t:Va(t);let r=t,i=Da(r.ttlMs)?r.ttlMs:za(n),a=Oa(r.cacheScope)?r.cacheScope:Ba(n),o={...r,ttlMs:i,cacheScope:a};return delete o[wa],o}function La(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ra(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[cn]:t}}:!La(n)||n[cn]!==void 0?e:{...e,_meta:{...n,[cn]:t}}}function za(e){return e!==void 0&&Da(e.ttlMs)?e.ttlMs:0}function Ba(e){return e!==void 0&&Oa(e.cacheScope)?e.cacheScope:`private`}function Va(e){let t={...e};return delete t[wa],t}const Ha=[`elicitation/create`,`sampling/createMessage`,`roots/list`];let Ua;function Wa(){if(Ua)return Ua;let e=xa();return Ua={request:{"elicitation/create":z({method:I(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":z({method:I(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":z({method:I(`roots/list`),params:L({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Ua}function Ga(e){return Ha.includes(e)}function Ka(e){return Ga(e)?Wa().request[e]:void 0}function qa(e){return Ga(e)?Wa().response[e]:void 0}const Ja={"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},Ya={"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 Xa(e){return Object.prototype.hasOwnProperty.call(Ja,e)}function Za(e){return Object.prototype.hasOwnProperty.call(Ya,e)}function Qa(e){return Object.prototype.hasOwnProperty.call(Ja,e)}function $a(e){return Xa(e)?xa().dispatchRequestSchemas[e]:void 0}function eo(e){return Qa(e)?xa().dispatchResultSchemas[e]:void 0}function to(e){return Za(e)?xa().notificationSchemas2026[e]:void 0}function no(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ro(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}const io={ok:!1,reason:`not-in-era`},ao=[Ot,p];function oo(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>no(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!no(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(no(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}const so={era:`2026-07-28`,hasRequestMethod:Xa,hasNotificationMethod:Za,hasInputRequestMethod:e=>Ka(e)!==void 0,validateRequest:(e,t)=>ro($a(e),t),validateResult:(e,t)=>ro(eo(e),t),validateNotification:(e,t)=>ro(to(e),t),validateInputRequest:(e,t)=>ro(Ka(e),t),validateInputResponse:(e,t)=>ro(qa(e),t),samplingResultVariant:()=>io,outboundEnvelope(e){return{[Ot]:e.protocolVersion,[m]:e.clientInfo,[p]:e.clientCapabilities,...e.logLevel!==void 0&&{[Je]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of ao)n in e||t.push({key:n,problem:`missing`});let n=xa().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;if(n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`))continue;t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>Gi(e),inputRequestSchema:Ka,decodeResult(e,t){if(!no(t))return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=no(n)?n:{},i=t.requestState;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i}}}if(n!==`complete`)return{kind:`invalid`,error:new J(q.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=lo(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return Ra(Ia(e,Fa(e,oo(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=xa().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}};let co;function lo(){if(co)return co;let e=xa();return co={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},co}const uo=`2026-07-28`;function fo(e){return e!==void 0&&Hi(e)?so:va}function po(e){return e.revision===void 0?e.era===`modern`?so.era:va.era:fo(e.revision).era}function mo(e){return go.some(t=>t.hasRequestMethod(e))}function ho(e){return go.some(t=>t.hasNotificationMethod(e))}const go=[va,so];function _o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vo(e){if(!_o(e))return;let t=e._meta;return _o(t)?t:void 0}function yo(e){let t=vo(e);return t!==void 0&&Ot in t}function bo(e){let t=vo(e)?.[Ot];return typeof t==`string`?t:void 0}function xo(e){return fo(uo).validateEnvelopeMeta(e)}var So=wi({AnnotationsSchema:()=>s,AudioContentSchema:()=>c,BaseMetadataSchema:()=>l,BaseRequestParamsSchema:()=>u,BlobResourceContentsSchema:()=>d,BooleanSchemaSchema:()=>f,CallToolRequestParamsSchema:()=>h,CallToolRequestSchema:()=>g,CallToolResultSchema:()=>_,CancelTaskRequestSchema:()=>v,CancelTaskResultSchema:()=>y,CancelledNotificationParamsSchema:()=>b,CancelledNotificationSchema:()=>x,ClientCapabilitiesSchema:()=>S,ClientNotificationSchema:()=>C,ClientRequestSchema:()=>ee,ClientResultSchema:()=>te,ClientTasksCapabilitySchema:()=>ne,CompatibilityCallToolResultSchema:()=>w,CompleteRequestParamsSchema:()=>re,CompleteRequestSchema:()=>T,CompleteResultSchema:()=>ie,ContentBlockSchema:()=>ae,CreateMessageRequestParamsSchema:()=>oe,CreateMessageRequestSchema:()=>se,CreateMessageResultSchema:()=>ce,CreateMessageResultWithToolsSchema:()=>le,CreateTaskResultSchema:()=>E,CursorSchema:()=>D,DiscoverRequestSchema:()=>de,DiscoverResultSchema:()=>fe,ElicitRequestFormParamsSchema:()=>pe,ElicitRequestParamsSchema:()=>O,ElicitRequestSchema:()=>me,ElicitRequestURLParamsSchema:()=>he,ElicitResultSchema:()=>ge,ElicitationCompleteNotificationParamsSchema:()=>_e,ElicitationCompleteNotificationSchema:()=>ve,EmbeddedResourceSchema:()=>ye,EmptyResultSchema:()=>be,EnumSchemaSchema:()=>xe,GetPromptRequestParamsSchema:()=>Se,GetPromptRequestSchema:()=>Ce,GetPromptResultSchema:()=>we,GetTaskPayloadRequestSchema:()=>Te,GetTaskPayloadResultSchema:()=>Ee,GetTaskRequestSchema:()=>De,GetTaskResultSchema:()=>Oe,IconSchema:()=>ke,IconsSchema:()=>Ae,ImageContentSchema:()=>Me,ImplementationSchema:()=>Ne,InitializeRequestParamsSchema:()=>Pe,InitializeRequestSchema:()=>Fe,InitializeResultSchema:()=>Ie,InitializedNotificationSchema:()=>Le,JSONArraySchema:()=>Re,JSONObjectSchema:()=>ze,JSONRPCErrorResponseSchema:()=>Be,JSONRPCMessageSchema:()=>Ve,JSONRPCNotificationSchema:()=>He,JSONRPCRequestSchema:()=>Ue,JSONRPCResponseSchema:()=>We,JSONRPCResultResponseSchema:()=>Ge,JSONValueSchema:()=>Ke,LegacyTitledEnumSchemaSchema:()=>Ye,ListChangedOptionsBaseSchema:()=>Xe,ListPromptsRequestSchema:()=>Ze,ListPromptsResultSchema:()=>Qe,ListResourceTemplatesRequestSchema:()=>$e,ListResourceTemplatesResultSchema:()=>et,ListResourcesRequestSchema:()=>tt,ListResourcesResultSchema:()=>nt,ListRootsRequestSchema:()=>k,ListRootsResultSchema:()=>rt,ListTasksRequestSchema:()=>it,ListTasksResultSchema:()=>at,ListToolsRequestSchema:()=>ot,ListToolsResultSchema:()=>st,LoggingLevelSchema:()=>ct,LoggingMessageNotificationParamsSchema:()=>lt,LoggingMessageNotificationSchema:()=>ut,ModelHintSchema:()=>dt,ModelPreferencesSchema:()=>ft,MultiSelectEnumSchemaSchema:()=>pt,NotificationSchema:()=>mt,NotificationsParamsSchema:()=>ht,NumberSchemaSchema:()=>gt,PaginatedRequestParamsSchema:()=>kt,PaginatedRequestSchema:()=>At,PaginatedResultSchema:()=>jt,PingRequestSchema:()=>Mt,PrimitiveSchemaDefinitionSchema:()=>A,ProgressNotificationParamsSchema:()=>j,ProgressNotificationSchema:()=>Nt,ProgressSchema:()=>Pt,ProgressTokenSchema:()=>Ft,PromptArgumentSchema:()=>It,PromptListChangedNotificationSchema:()=>Lt,PromptMessageSchema:()=>Rt,PromptReferenceSchema:()=>zt,PromptSchema:()=>Bt,ReadResourceRequestParamsSchema:()=>Vt,ReadResourceRequestSchema:()=>Ht,ReadResourceResultSchema:()=>Ut,RelatedTaskMetadataSchema:()=>Wt,RequestIdSchema:()=>Gt,RequestMetaSchema:()=>Kt,RequestSchema:()=>qt,ResourceContentsSchema:()=>Jt,ResourceLinkSchema:()=>Yt,ResourceListChangedNotificationSchema:()=>Xt,ResourceRequestParamsSchema:()=>M,ResourceSchema:()=>Zt,ResourceTemplateReferenceSchema:()=>Qt,ResourceTemplateSchema:()=>$t,ResourceUpdatedNotificationParamsSchema:()=>en,ResourceUpdatedNotificationSchema:()=>tn,ResultMetaObjectSchema:()=>nn,ResultSchema:()=>rn,RoleSchema:()=>an,RootSchema:()=>on,RootsListChangedNotificationSchema:()=>sn,SamplingContentSchema:()=>dn,SamplingMessageContentBlockSchema:()=>fn,SamplingMessageSchema:()=>pn,ServerCapabilitiesSchema:()=>mn,ServerNotificationSchema:()=>hn,ServerRequestSchema:()=>gn,ServerResultSchema:()=>_n,ServerTasksCapabilitySchema:()=>vn,SetLevelRequestParamsSchema:()=>yn,SetLevelRequestSchema:()=>bn,SingleSelectEnumSchemaSchema:()=>xn,StringSchemaSchema:()=>Sn,SubscribeRequestParamsSchema:()=>Cn,SubscribeRequestSchema:()=>wn,SubscriptionFilterSchema:()=>Tn,SubscriptionsAcknowledgedNotificationParamsSchema:()=>En,SubscriptionsAcknowledgedNotificationSchema:()=>Dn,SubscriptionsListenRequestParamsSchema:()=>On,SubscriptionsListenRequestSchema:()=>kn,SubscriptionsListenResultMetaSchema:()=>An,SubscriptionsListenResultSchema:()=>jn,TaskAugmentedRequestParamsSchema:()=>Mn,TaskCreationParamsSchema:()=>Nn,TaskMetadataSchema:()=>Pn,TaskSchema:()=>Fn,TaskStatusNotificationParamsSchema:()=>In,TaskStatusNotificationSchema:()=>Ln,TaskStatusSchema:()=>Rn,TextContentSchema:()=>zn,TextResourceContentsSchema:()=>Bn,TitledMultiSelectEnumSchemaSchema:()=>Vn,TitledSingleSelectEnumSchemaSchema:()=>Hn,ToolAnnotationsSchema:()=>Un,ToolChoiceSchema:()=>Wn,ToolExecutionSchema:()=>Gn,ToolListChangedNotificationSchema:()=>Kn,ToolResultContentSchema:()=>qn,ToolSchema:()=>Jn,ToolUseContentSchema:()=>Yn,UnsubscribeRequestParamsSchema:()=>Xn,UnsubscribeRequestSchema:()=>Zn,UntitledMultiSelectEnumSchemaSchema:()=>Qn,UntitledSingleSelectEnumSchemaSchema:()=>$n});const Z=e=>Ue.safeParse(e).success,Co=e=>He.safeParse(e).success,wo=e=>Ge.safeParse(e).success,To=e=>Be.safeParse(e).success,Eo=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`,Do=e=>Fe.safeParse(e).success;function Oo(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function ko(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}const Ao=`x-mcp-header`,jo=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Mo=new Set([`string`,`integer`,`boolean`,`number`]);function No(e){let t=[],n=new Map,r=(e,i,a)=>{if(typeof e!=`object`||!e)return;let o=e;if(Ao in o){if(!a||i.length===0)return`${Io(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let e=o[Ao];if(typeof e!=`string`||e.length===0)return`${Io(i)}: x-mcp-header MUST be a non-empty string`;if(!jo.test(e))return`${Io(i)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let r=typeof o.type==`string`?o.type:void 0;if(r===void 0||!Mo.has(r))return`${Io(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${r??`<none>`}`;let s=e.toLowerCase(),c=n.get(s);if(c!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${c}')`;n.set(s,e),t.push({path:i,headerName:e,type:r})}let s=o.properties;if(typeof s==`object`&&s)for(let[e,t]of Object.entries(s)){let n=r(t,[...i,e],a);if(n!==void 0)return n}for(let e of Po){let t=o[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Fo.has(e)?Object.values(t):[t];for(let t of n){let n=r(t,[...i,`<${e}>`],!1);if(n!==void 0)return n}}},i=r(e,[],!0);return i===void 0?{valid:!0,declarations:t}:{valid:!1,reason:i}}const Po=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Fo=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Io(e){return e.length===0?`<root>`:e.join(`.`)}Y.InvalidRequest,Y.UnsupportedProtocolVersion,Y.InvalidParams,Y.MethodNotFound,Y.InvalidParams,Y.MissingRequiredClientCapability,Y.ParseError,Y.InvalidRequest,Y.MethodNotFound,Y.UnsupportedProtocolVersion,Y.MissingRequiredClientCapability;function Lo(e,t,n,r,i){return{kind:`reject`,rung:e,cell:t,httpStatus:n,code:r.code,message:r.message,...r.data!==void 0&&{data:r.data},settled:i}}function Ro(e){if(!yo(e))return!1;let t=bo(e);if(t===void 0||!Hi(t))return!1;let n=vo(e);return n!==void 0&&xo(n).length===0}function zo(e,t){switch(e.reason){case`http-method`:return Lo(`http-method`,`modern-only-method-not-allowed`,405,new X(-32e3,`Method not allowed.`),!0);case`batch`:return Lo(`jsonrpc-shape`,`modern-only-batch-not-supported`,400,new X(Y.InvalidRequest,`Bad Request: JSON-RPC batches are not supported by this endpoint`),!0);case`response`:return Lo(`jsonrpc-shape`,`modern-only-response-post`,400,new X(Y.InvalidRequest,`Bad Request: JSON-RPC responses cannot be posted to this endpoint`),!0);case`notification`:return;case`initialize`:case`no-claim`:{let n=e.requestedVersion;return Lo(`era-classification`,`modern-only-missing-envelope`,400,n===void 0?new X(Y.UnsupportedProtocolVersion,`Unsupported protocol version: the request did not name a protocol version`,{supported:[...t]}):new Ma({supported:[...t],requested:n}),!0)}}}function Bo(e,t){return cr(e,t)}function Vo(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function Ho(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}let Uo=!1;const Wo=`draft-2020-12`;function Go(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:Wo});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);Uo||(Uo=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=lr(e,{target:Wo,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&Ko(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function Ko(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||Ko(e)))}return!1}function qo(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function Jo(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>qo(e)).join(`, `)}:{success:!0,data:n.value}}function Yo(e){let t=lr(e,{target:Wo,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}const Xo=/\\\.\\d\{(\d+)\}/;function Zo(e){let t=Xo.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>nr({local:e,offset:t,precision:n}))))}function Qo(e,t){let n;switch(e){case`email`:n=[ir()];break;case`uri`:n=[ur()];break;case`date`:n=[tr()];break;case`date-time`:n=Zo(t);break}return new Set(n.map(e=>Yo(e)).filter(e=>e!==void 0))}function $o(e,t,n){return n===`zod`?Qo(e,t).has(t):!0}function es(e){let t=Go(e,`input`),n=t.properties||{},r=t.required||[];return Object.entries(n).map(([e,t])=>({name:e,description:t?.description,required:r.includes(e)}))}function ts(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ns(e){try{return Go(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new X(Y.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}const rs=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function os(e){return rs.has(e)||e.startsWith(`x-`)}const ss=new Set([`$schema`,...Object.keys(pe.shape.requestedSchema.shape)]),cs={string:Vo([Sn,$n,Hn,Ye]),number:Vo([gt]),integer:Vo([gt]),boolean:Vo([f]),array:Vo([Qn,Vn])},ls=new Set(Sn.shape.format.unwrap().options);function us(e,t,n,r){if(!ts(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(cs,e.type)?cs[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||os(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?ls.has(e.format)?(typeof s!=`string`||!$o(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function ds(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&ts(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,us(n,`properties.${e}`,t,r)])):ss.has(i)?n[i]=a:os(i)||r.push(i);if(r.length>0)throw new X(Y.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function fs(e,t){if(!ts(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!Bo(A,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function ps(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>ps(e,t[r],`${n}[${r}]`)):!ts(e)||!ts(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?ps(r,t[e],i):os(e)?[]:[i]})}function ms(e){if(!Ho(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=ds(ns(e.requestedSchema),t),r=Bo(pe.shape.requestedSchema,n);if(!r.success)throw new X(Y.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${fs(n,r.error.message)}`);let i=ps(n,r.data);if(i.length>0)throw new X(Y.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new X(Y.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function hs(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(hs,{elicit(e){try{return{method:`elicitation/create`,params:ms(e)}}catch(e){throw e instanceof X?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});function gs(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function _s(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof J?t.reason:new J(q.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof J?t.reason:new J(q.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function vs(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}const ys=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),bs={IdJagTokenExchangeResponseSchema:je,OAuthClientInformationFullSchema:_t,OAuthClientInformationSchema:vt,OAuthClientMetadataSchema:yt,OAuthClientRegistrationErrorSchema:bt,OAuthErrorResponseSchema:xt,OAuthMetadataSchema:St,OAuthProtectedResourceMetadataSchema:Ct,OAuthTokenRevocationRequestSchema:wt,OAuthTokensSchema:Tt,OpenIdProviderDiscoveryMetadataSchema:Et,OpenIdProviderMetadataSchema:Dt},xs={},Ss={};function Cs(e,t){let n=e.slice(0,-6);xs[n]=t,Ss[n]=e=>t.safeParse(e).success}for(let e of ys)Cs(e,So[e]);for(let[e,t]of Object.entries(bs))Cs(e,t);Object.freeze(xs),Object.freeze(Ss);function ws(e){switch(e){case`initialize`:case`notifications/initialized`:return fo(void 0);case`server/discover`:return fo(uo);default:return}}const Ts=[Ot,m,p,Je],Es=[`inputResponses`,`requestState`];function Ds(e,t){let n=e.params;if(!Fs(n))return{message:e,lifted:{}};let r=n._meta,i=Fs(r)?Ts.filter(e=>e in r):[],a=t===`request`?Es.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&Fs(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function Os(e,t){let n=e.validateResult(t,void 0);if(!(!n.ok&&n.reason===`not-in-era`))return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function ks(e){return()=>e}const As=ks(void 0);function js(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:ks(t)}}}let Ms;function Ns(e,t){Ms(e,t)}var Ps=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{Ms=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??un,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new J(q.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new J(q.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),wo(e)||To(e)?this._onresponse(e):Z(e)?this._onrequest(e,t):Co(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new J(q.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=Ds(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=po(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(ho(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;i===void 0&&a===void 0||Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=Ds(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=po(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(Y.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(mo(n.method)&&!i.hasRequestMethod(n.method)){o(Y.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Y.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(Y.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:Rs(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?As:ks(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Ho(t))return u(e,t,n);let i=Os(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(Y.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:Y.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),wo(e)?n(e):n(X.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Ho(t))return this._requestWithSchemaViaCodec(r,e,t,n);let i=Os(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return fo(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=ws(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(mo(t)&&!e.hasRequestMethod(t))throw new J(q.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof J?e:new J(q.RequestTimeout,String(e))}let m=e.era===uo&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof J?e:new J(q.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(zs(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;Jo(n,o).then(e=>{e.success?d(e.data):f(new J(q.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new J(q.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new J(q.NotConnected,`Not connected`);if(ho(t.method)&&!e.hasNotificationMethod(t.method))throw new J(q.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!mo(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new X(Y.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await Jo(t.params,{...r.params});if(!a.success)throw new X(Y.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!ho(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new X(Y.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await Jo(t.params,{...r.params});if(!i.success)throw new X(Y.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Fs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Is(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=Fs(a)&&Fs(i)?{...a,...i}:i}return n}function Ls(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Rs(e){let t={},n=[];if(!Ls(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!Ls(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function zs(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState}}}var Bs=Ei(K((exports=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;exports.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),1);function Vs(e){if(e)try{return Bs.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function Hs(e){return e===`application/json`?!0:Vs(e)===`application/json`}var Us=class{_buffer;_maxBufferSize;constructor(e){this._maxBufferSize=e?.maxBufferSize??10485760}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){for(;this._buffer;){let e=this._buffer.indexOf(`
3
- `);if(e===-1)return null;let t=this._buffer.toString(`utf8`,0,e).replace(/\r$/,``);this._buffer=this._buffer.subarray(e+1);try{return Ws(t)}catch(e){if(e instanceof SyntaxError)continue;throw e}}return null}clear(){this._buffer=void 0}};function Ws(e){return Ve.parse(JSON.parse(e))}function Gs(e){return JSON.stringify(e)+`
4
- `}const Ks=/^[A-Za-z0-9._-]{1,128}$/;function qs(e){let t=[];if(e.length===0)return{isValid:!1,warnings:[`Tool name cannot be empty`]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(` `)&&t.push(`Tool name contains spaces, which may cause parsing issues`),e.includes(`,`)&&t.push(`Tool name contains commas, which may cause parsing issues`),(e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`Tool name starts or ends with a dash, which may cause parsing issues in some contexts`),(e.startsWith(`.`)||e.endsWith(`.`))&&t.push(`Tool name starts or ends with a dot, which may cause parsing issues in some contexts`),!Ks.test(e)){let n=[...e].filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.map(e=>`"${e}"`).join(`, `)}`,`Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)`),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function Js(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);console.warn(`Tool registration will proceed, but this may cause compatibility issues.`),console.warn(`Consider updating the tool name to conform to the MCP tool naming standard.`),console.warn(`See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.`)}}function Ys(e){let t=qs(e);return Js(e,t.warnings),t.isValid}function Xs(e){return typeof e==`object`&&!!e&&`_zod`in e}function Zs(e){return typeof e==`object`&&!!e&&!(`_zod`in e)&&`_def`in e&&typeof e._def?.typeName==`string`}function Qs(e){if(typeof e!=`object`||!e||Ho(e))return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.values(e).every(e=>Xs(e))}function $s(e){if(e!==void 0){if(Qs(e))return z(e);if(typeof e==`object`&&e&&!Ho(e)&&Object.values(e).some(e=>Zs(e)))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!Ho(e))throw TypeError(`inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).`);return e}}var ec=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.regexpCode=exports.getEsmExportName=exports.getProperty=exports.safeStringify=exports.stringify=exports.strConcat=exports.addCodeArg=exports.str=exports._=exports.nil=exports._Code=exports.Name=exports.IDENTIFIER=exports._CodeOrName=void 0;var t=class{};exports._CodeOrName=t,exports.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!exports.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};exports.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};exports._Code=r,exports.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}exports._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}exports.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}exports.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}exports.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}exports.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}exports.safeStringify=p;function m(t){return typeof t==`string`&&exports.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}exports.getProperty=m;function h(t){if(typeof t==`string`&&exports.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}exports.getEsmExportName=h;function g(e){return new r(e.toString())}exports.regexpCode=g})),tc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.ValueScope=exports.ValueScopeName=exports.Scope=exports.varKinds=exports.UsedValueState=void 0;let t=ec();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(exports.UsedValueState=r={})),exports.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};exports.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};exports.ValueScopeName=a;let o=(0,t._)`\n`;exports.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?exports.varKinds.var:exports.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Q=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.or=exports.and=exports.not=exports.CodeGen=exports.operators=exports.varKinds=exports.ValueScopeName=exports.ValueScope=exports.Scope=exports.Name=exports.regexpCode=exports.stringify=exports.getProperty=exports.nil=exports.strConcat=exports.str=exports._=void 0;let t=ec(),n=tc();var r=ec();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(exports,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(exports,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(exports,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=tc();Object.defineProperty(exports,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(exports,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(exports,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(exports,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),exports.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=T(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=T(this.rhs,e,n),this}get names(){return re(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=T(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(ie(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>w(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ae(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=T(this.condition,e,t),this}get names(){let e=super.names;return re(e,this.condition),this.else&&w(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=T(this.iteration,e,t),this}get names(){return w(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return re(re(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=T(this.iterable,e,t),this}get names(){return w(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var ee=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&w(e,this.catch.names),this.finally&&w(e,this.finally.names),e}},te=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};te.kind=`catch`;var ne=class extends m{render(e){return`finally`+super.render(e)}};ne.kind=`finally`,exports.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
5
- `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,exports.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new ee;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new te(e),t(e)}return n&&(this._currNode=r.finally=new ne,this.code(n)),this._endBlockNode(te,ne)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function w(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function re(e,n){return n instanceof t._CodeOrName?w(e,n.names):e}function T(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function ie(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ae(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${D(e)}`}exports.not=ae;let oe=E(exports.operators.AND);function se(...e){return e.reduce(oe)}exports.and=se;let ce=E(exports.operators.OR);function le(...e){return e.reduce(ce)}exports.or=le;function E(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${D(n)} ${e} ${D(r)}`}function D(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),$=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.checkStrictMode=exports.getErrorPath=exports.Type=exports.useFunc=exports.setEvaluated=exports.evaluatedPropsToName=exports.mergeEvaluated=exports.eachItem=exports.unescapeJsonPointer=exports.escapeJsonPointer=exports.escapeFragment=exports.unescapeFragment=exports.schemaRefOrVal=exports.schemaHasRulesButRef=exports.schemaHasRules=exports.checkUnknownRules=exports.alwaysValidSchema=exports.toHash=void 0;let t=Q(),n=ec();function r(e){let t={};for(let n of e)t[n]=!0;return t}exports.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}exports.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}exports.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}exports.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}exports.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}exports.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}exports.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}exports.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}exports.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}exports.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}exports.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}exports.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}exports.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}exports.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}exports.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(exports.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}exports.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}exports.checkStrictMode=x})),nc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),rc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.extendErrors=exports.resetErrorsCount=exports.reportExtraError=exports.reportError=exports.keyword$DataError=exports.keywordError=void 0;let t=Q(),n=$(),r=nc();exports.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},exports.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=exports.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}exports.reportError=i;function a(t,n=exports.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}exports.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}exports.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}exports.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),ic=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.boolOrEmptySchema=exports.topBoolOrEmptySchema=void 0;let t=rc(),n=Q(),r=nc(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}exports.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}exports.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),ac=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.getRules=exports.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}exports.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}exports.getRules=r})),oc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.shouldUseRule=exports.shouldUseGroup=exports.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}exports.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}exports.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}exports.shouldUseRule=r})),sc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.reportTypeError=exports.checkDataTypes=exports.checkDataType=exports.coerceAndCheckDataType=exports.getJSONTypes=exports.getSchemaTypes=exports.DataType=void 0;let t=ac(),n=oc(),r=rc(),i=Q(),a=$();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(exports.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}exports.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}exports.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}exports.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
1
+ import{proxiedFetch as e}from"./proxyFetch-C3RS3xmp.js";import{SESSION_ID as t,config as n}from"./env-BgasZcvb.js";import{extractTraceIdFromHeaders as r,gatewayCorrelationId as i,logger as a,runWithTraceContextAsync as o}from"./logger-BQ4h6bdx.js";import{AnnotationsSchema as s,AudioContentSchema as c,BaseMetadataSchema as l,BaseRequestParamsSchema as u,BlobResourceContentsSchema as d,BooleanSchemaSchema as f,CLIENT_CAPABILITIES_META_KEY as p,CLIENT_INFO_META_KEY as m,CallToolRequestParamsSchema as h,CallToolRequestSchema as g,CallToolResultSchema as _,CancelTaskRequestSchema as v,CancelTaskResultSchema as y,CancelledNotificationParamsSchema as b,CancelledNotificationSchema as x,ClientCapabilitiesSchema as S,ClientNotificationSchema as C,ClientRequestSchema as ee,ClientResultSchema as te,ClientTasksCapabilitySchema as ne,CompatibilityCallToolResultSchema as w,CompleteRequestParamsSchema as re,CompleteRequestSchema as T,CompleteResultSchema as ie,ContentBlockSchema as ae,CreateMessageRequestParamsSchema as oe,CreateMessageRequestSchema as se,CreateMessageResultSchema as ce,CreateMessageResultWithToolsSchema as le,CreateTaskResultSchema as E,CursorSchema as D,DEFAULT_NEGOTIATED_PROTOCOL_VERSION as ue,DiscoverRequestSchema as de,DiscoverResultSchema as fe,ElicitRequestFormParamsSchema as pe,ElicitRequestParamsSchema as O,ElicitRequestSchema as me,ElicitRequestURLParamsSchema as he,ElicitResultSchema as ge,ElicitationCompleteNotificationParamsSchema as _e,ElicitationCompleteNotificationSchema as ve,EmbeddedResourceSchema as ye,EmptyResultSchema as be,EnumSchemaSchema as xe,GetPromptRequestParamsSchema as Se,GetPromptRequestSchema as Ce,GetPromptResultSchema as we,GetTaskPayloadRequestSchema as Te,GetTaskPayloadResultSchema as Ee,GetTaskRequestSchema as De,GetTaskResultSchema as Oe,IconSchema as ke,IconsSchema as Ae,IdJagTokenExchangeResponseSchema as je,ImageContentSchema as Me,ImplementationSchema as Ne,InitializeRequestParamsSchema as Pe,InitializeRequestSchema as Fe,InitializeResultSchema as Ie,InitializedNotificationSchema as Le,JSONArraySchema as Re,JSONObjectSchema as ze,JSONRPCErrorResponseSchema as Be,JSONRPCMessageSchema as Ve,JSONRPCNotificationSchema as He,JSONRPCRequestSchema as Ue,JSONRPCResponseSchema as We,JSONRPCResultResponseSchema as Ge,JSONValueSchema as Ke,LATEST_PROTOCOL_VERSION as qe,LOG_LEVEL_META_KEY as Je,LegacyTitledEnumSchemaSchema as Ye,ListChangedOptionsBaseSchema as Xe,ListPromptsRequestSchema as Ze,ListPromptsResultSchema as Qe,ListResourceTemplatesRequestSchema as $e,ListResourceTemplatesResultSchema as et,ListResourcesRequestSchema as tt,ListResourcesResultSchema as nt,ListRootsRequestSchema as k,ListRootsResultSchema as rt,ListTasksRequestSchema as it,ListTasksResultSchema as at,ListToolsRequestSchema as ot,ListToolsResultSchema as st,LoggingLevelSchema as ct,LoggingMessageNotificationParamsSchema as lt,LoggingMessageNotificationSchema as ut,ModelHintSchema as dt,ModelPreferencesSchema as ft,MultiSelectEnumSchemaSchema as pt,NotificationSchema as mt,NotificationsParamsSchema as ht,NumberSchemaSchema as gt,OAuthClientInformationFullSchema as _t,OAuthClientInformationSchema as vt,OAuthClientMetadataSchema as yt,OAuthClientRegistrationErrorSchema as bt,OAuthErrorResponseSchema as xt,OAuthMetadataSchema as St,OAuthProtectedResourceMetadataSchema as Ct,OAuthTokenRevocationRequestSchema as wt,OAuthTokensSchema as Tt,OpenIdProviderDiscoveryMetadataSchema as Et,OpenIdProviderMetadataSchema as Dt,PROTOCOL_VERSION_META_KEY as Ot,PaginatedRequestParamsSchema as kt,PaginatedRequestSchema as At,PaginatedResultSchema as jt,PingRequestSchema as Mt,PrimitiveSchemaDefinitionSchema as A,ProgressNotificationParamsSchema as j,ProgressNotificationSchema as Nt,ProgressSchema as Pt,ProgressTokenSchema as Ft,PromptArgumentSchema as It,PromptListChangedNotificationSchema as Lt,PromptMessageSchema as Rt,PromptReferenceSchema as zt,PromptSchema as Bt,ReadResourceRequestParamsSchema as Vt,ReadResourceRequestSchema as Ht,ReadResourceResultSchema as Ut,RelatedTaskMetadataSchema as Wt,RequestIdSchema as Gt,RequestMetaSchema as Kt,RequestSchema as qt,ResourceContentsSchema as Jt,ResourceLinkSchema as Yt,ResourceListChangedNotificationSchema as Xt,ResourceRequestParamsSchema as M,ResourceSchema as Zt,ResourceTemplateReferenceSchema as Qt,ResourceTemplateSchema as $t,ResourceUpdatedNotificationParamsSchema as en,ResourceUpdatedNotificationSchema as tn,ResultMetaObjectSchema as nn,ResultSchema as rn,RoleSchema as an,RootSchema as on,RootsListChangedNotificationSchema as sn,SERVER_INFO_META_KEY as cn,SUBSCRIPTION_ID_META_KEY as ln,SUPPORTED_PROTOCOL_VERSIONS as un,SamplingContentSchema as dn,SamplingMessageContentBlockSchema as fn,SamplingMessageSchema as pn,ServerCapabilitiesSchema as mn,ServerNotificationSchema as hn,ServerRequestSchema as gn,ServerResultSchema as _n,ServerTasksCapabilitySchema as vn,SetLevelRequestParamsSchema as yn,SetLevelRequestSchema as bn,SingleSelectEnumSchemaSchema as xn,StringSchemaSchema as Sn,SubscribeRequestParamsSchema as Cn,SubscribeRequestSchema as wn,SubscriptionFilterSchema as Tn,SubscriptionsAcknowledgedNotificationParamsSchema as En,SubscriptionsAcknowledgedNotificationSchema as Dn,SubscriptionsListenRequestParamsSchema as On,SubscriptionsListenRequestSchema as kn,SubscriptionsListenResultMetaSchema as An,SubscriptionsListenResultSchema as jn,TaskAugmentedRequestParamsSchema as Mn,TaskCreationParamsSchema as Nn,TaskMetadataSchema as Pn,TaskSchema as Fn,TaskStatusNotificationParamsSchema as In,TaskStatusNotificationSchema as Ln,TaskStatusSchema as Rn,TextContentSchema as zn,TextResourceContentsSchema as Bn,TitledMultiSelectEnumSchemaSchema as Vn,TitledSingleSelectEnumSchemaSchema as Hn,ToolAnnotationsSchema as Un,ToolChoiceSchema as Wn,ToolExecutionSchema as Gn,ToolListChangedNotificationSchema as Kn,ToolResultContentSchema as qn,ToolSchema as Jn,ToolUseContentSchema as Yn,UnsubscribeRequestParamsSchema as Xn,UnsubscribeRequestSchema as Zn,UntitledMultiSelectEnumSchemaSchema as Qn,UntitledSingleSelectEnumSchemaSchema as $n,_enum as N,_null as er,array as P,boolean as F,date as tr,datetime as nr,discriminatedUnion as rr,email as ir,intersection as ar,lazy as or,literal as I,looseObject as L,number as R,object as z,optional as B,preprocess as sr,record as V,safeParse as cr,string as H,toJSONSchema as lr,union as U,unknown as W,url as ur}from"./normalizeUrl-DUUGubD4.js";import dr,{randomUUID as fr}from"crypto";import{homedir as pr,hostname as mr,userInfo as hr}from"node:os";import{join as gr}from"node:path";import{randomUUID as _r}from"node:crypto";import{existsSync as vr,readFileSync as yr}from"node:fs";import{Readable as br}from"stream";import xr from"ps-list";import{deflateSync as Sr}from"node:zlib";import Cr from"node:process";import{Http2ServerRequest as wr,constants as Tr}from"http2";import{URL as Er}from"node:url";import Dr from"node:http";var Or=class{counter=0;events=new Map;async replayEventsAfter(e,{send:t}){if(!e||!this.events.has(e))return``;let n=this.getStreamIdFromEventId(e);if(!n)return``;let r=!1,i=[...this.events.entries()].sort((e,t)=>e[0].localeCompare(t[0]));for(let[a,{message:o,streamId:s}]of i){if(s!==n)continue;if(a===e){r=!0;continue}r&&await t(a,o)}return n}async storeEvent(e,t){let n=this.generateEventId(e);return this.events.set(n,{message:t,streamId:e}),n}generateEventId(e){let t=(++this.counter).toString().padStart(12,`0`);return`${e}_${Date.now()}_${t}_${Math.random().toString(36).substring(2,10)}`}getStreamIdFromEventId(e){let t=e.split(`_`);return t.length<4?``:t.slice(0,-3).join(`_`)}},kr=class extends Error{extra;tags;constructor(e,t,n={},r={}){super(t),this.name=e,this.tags=n,this.extra=r}},Ar=class extends kr{constructor(e,t=`access_denied`,n={}){super(`AccessControlBlockError`,e,{feature:`access_control`,module:`security`,operation:`block`},{reason:t,...n}),this.reason=t}},jr=class extends kr{constructor(e,t,n={}){super(`ConfigurationError`,e,{feature:`configuration`,module:`cli`,operation:`validate`},{configKey:t,...n})}},Mr=class extends kr{constructor(e,t,n={}){super(`ProtocolEraMismatchError`,e,{feature:`protocol_era`,module:`proxy`,operation:`negotiate`},{url:t?(()=>{try{return new URL(t).origin}catch{return t}})():void 0,...n})}},Nr=class extends kr{constructor(e,t,n,r={},i){super(`ProxyConnectionError`,e,{feature:`connection`,module:`proxy`,operation:`connect`,transport:n||`unknown`},{url:t?(()=>{try{return new URL(t).origin}catch{return t}})():void 0,...r}),i!==void 0&&(this.cause=i)}};const Pr=n.clientAppName;let Fr=null;const Ir=async()=>(Fr||=await import(`systeminformation`),Fr);function Lr(e){return typeof e==`string`&&e!==``&&e.includes(`@`)}function Rr(){try{let e=Hr();if(!vr(e))return null;let t=yr(e,`utf-8`),n=!1;for(let e of t.split(`
2
+ `)){let t=e.trim();if(t.startsWith(`#`)||t.startsWith(`;`))continue;if(t.startsWith(`[`)){n=t.toLowerCase()===`[user]`;continue}if(n){let e=t.match(/^email\s*=\s*(.+)/i);if(e)return e[1].replace(/\s+[#;].*$/,``).trim()||null}}return null}catch{return null}}function zr(){return gr(pr(),`.claude.json`)}function Br(){return gr(pr(),`.codex`,`auth.json`)}function Vr(){try{return mr()}catch{return`unknown-device`}}function Hr(){return gr(pr(),`.gitconfig`)}async function Ur(e){try{return(await xr()).find(t=>t.pid===e)?.name||`unknown`}catch{return`unknown`}}const Wr=new Map;async function Gr(e){let t=Wr.get(e);if(t)return t;let n=(async()=>{try{let{list:t}=await(await Ir()).processes(),n=t.find(t=>t.pid===e)?.started;if(n){let e=new Date(n);if(!Number.isNaN(e.getTime()))return e.toISOString()}return}catch{return}})();return Wr.set(e,n),n}function Kr(){return new Date(Date.now()-Math.round(process.uptime()*1e3)).toISOString()}const qr=new Set([`-`,`0`,`00000000`,`00000000-0000-0000-0000-000000000000`,`11111111-1111-1111-1111-111111111111`,`Default string`,`None`,`Not Specified`,`System Serial Number`,`To Be Filled By O.E.M.`,`To be filled by O.E.M.`,`uninitialized`]);function Jr(e){if(!e)return!1;let t=e.trim();return t===``||qr.has(t)?!1:!t.toLowerCase().includes(`to be filled`)}const Yr=[`/etc/machine-id`,`/var/lib/dbus/machine-id`],Xr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function Zr(){try{return process.platform===`linux`?$r()??Qr()?.uid??oi():await ei()}catch{return}}function Qr(){if(process.env.KUBERNETES_SERVICE_HOST)try{let e=yr(`/var/run/secrets/kubernetes.io/serviceaccount/token`,`utf8`).trim().split(`.`);if(e.length!==3)return;let t=JSON.parse(Buffer.from(e[1]??``,`base64url`).toString(`utf8`))[`kubernetes.io`],n=t?.pod?.uid;return!n||!Xr.test(n)?void 0:{name:t?.pod?.name,namespace:t?.namespace,uid:n}}catch{return}}function $r(){for(let e of Yr){let t=ai(e);if(Jr(t))return t}}async function ei(){try{let{serial:e}=await(await Ir()).system();return Jr(e)?e.trim():void 0}catch{return}}function ti(){try{let e=ri()?.oauthAccount?.emailAddress;if(Lr(e))return e;let t=ii();if(Lr(t))return t;let n=Rr();return Lr(n)?n:void 0}catch{return}}function ni(){try{let e=hr();if(e.username)return e.username;throw Error(`userInfo() returned empty username`)}catch{return process.env.USER||process.env.USERNAME||process.env.LOGNAME}}function ri(){try{let e=zr();if(!vr(e))return null;let t=yr(e,`utf-8`);return JSON.parse(t)}catch{return null}}function ii(){try{let e=Br();if(!vr(e))return null;let t=yr(e,`utf-8`),n=JSON.parse(t)?.tokens?.id_token;if(!n)return null;let r=n.split(`.`);if(r.length!==3)return null;let i=Buffer.from(r[1],`base64url`).toString(`utf-8`);return JSON.parse(i).email||null}catch{return null}}function ai(e){try{return yr(e,`utf8`).split(`
3
+ `)[0]?.trim()}catch{return}}function oi(){let e=ai(`/sys/class/dmi/id/product_uuid`);return Jr(e)?e:void 0}const si=()=>{if(!vr(`/.dockerenv`))return null;try{let e=yr(gr(pr(),`.onyx`,`container-context.json`),`utf8`),t=JSON.parse(e);return t.container_id?t:null}catch{return null}},ci=e=>{let t=process.env.ONYX_DOCKER_CONTAINER_ID,n=t?null:si(),r=t||n?.container_id;return r?{...e,containerRuntime:process.env.ONYX_CONTAINER_RUNTIME||void 0,deviceName:process.env.ONYX_HOST_DEVICE_NAME||n?.host_device_name||e.deviceName,dockerContainerId:r,dockerContainerName:process.env.ONYX_DOCKER_CONTAINER_NAME||n?.container_name||void 0,dockerImage:process.env.ONYX_DOCKER_IMAGE||n?.image||void 0,dockerImageId:process.env.ONYX_DOCKER_IMAGE_ID||n?.image_id||void 0,inDockerContainer:!0,systemSerialNumber:process.env.ONYX_HOST_SERIAL_NUMBER||n?.host_serial_number||e.systemSerialNumber}:e},li=async()=>{let e=process.pid,t=process.ppid,r=Kr();try{let i=Vr(),[a,o,s]=await Promise.all([Zr(),Ur(t),Gr(t)]),c=ti(),l=ni();return ci({clientAppName:Pr||`unknown`,deviceName:i,email:c,gatewayVersion:n.appVersion,parentProcessId:t,parentProcessName:o,parentProcessStartTime:s,processId:e,processStartTime:r,systemSerialNumber:a,username:l})}catch{return ci({clientAppName:Pr||`unknown`,deviceName:`unknown-device`,email:void 0,gatewayVersion:n.appVersion,parentProcessId:t,parentProcessName:`unknown`,processId:e,processStartTime:r,systemSerialNumber:void 0,username:void 0})}},ui=`[REDACTED]`,di=new Set([`api_key`,`api-key`,`apikey`,`authorization`,`bearer`,`credential`,`credentials`,`header`,`headers`,`key`,`pass`,`passwd`,`password`,`pwd`,`secret`,`token`]);function fi(e){let t=[],n=!1;for(let r of e){if(n){t.push(ui),n=!1;continue}if(r.startsWith(`-H`)&&r.length>2&&!r.startsWith(`--`)&&r[2]!==`=`){t.push(`-H`+ui);continue}let e=pi(r);if(e!==null&&mi(e))if(r.includes(`=`)){let e=r.indexOf(`=`);t.push(r.slice(0,e+1)+ui)}else t.push(r),n=!0;else t.push(r)}return t}function pi(e){if(!e.startsWith(`-`))return null;let t=e.replace(/^-{1,2}/,``),n=t.indexOf(`=`);return n>=0?t.slice(0,n):t}function mi(e){return e===`H`?!0:di.has(e.toLowerCase())}const hi=`onyx.security`;function gi(e){if(!e)return e;let t;try{t=new URL(e)}catch{return e}if(!t.host||t.pathname===``||t.pathname===`/`)return e;let n=t.hostname.toLowerCase().replace(/\.$/,``);if(n!==hi&&!n.endsWith(`.${hi}`))return e;let r=t.pathname.split(`/`),i=r.findIndex(e=>e.length>0);if(i===-1)return e;r[i]=`[REDACTED]`;let a=r.join(`/`);return`${t.protocol}//${t.host}${a}${t.search}${t.hash}`}function _i(e){let t=Sr(JSON.stringify(e));return Buffer.from(t).toString(`base64url`)}var vi=class{clientAppName;clientInfoBase64;sessionData;get scannerConfig(){return{apiKey:this.config.scanApiKey,enabled:this.config.scanEnabled,failOpen:this.config.scanFailOpen,headers:this.config.scanHeaders,timeoutMs:this.config.scanTimeoutMs,url:this.config.scanUrl}}config;constructor(e,t){this.config=e,this.sessionData=t,this.clientAppName=t.clientAppName||``,this.clientInfoBase64=this.getClientInfoBase64()}async evaluate(e){let t={action:`allow`};if(this.isScanEnabled())try{if(t=await this.scan({data:e.data,id:e.id,method:e.method,originalRequestId:e.originalRequestId,timestamp:e.timestamp,type:e.type}),a.info(`Scan result`,{action:t.action,id:e.id,method:e.method,originalRequestId:e.originalRequestId}),t.action===`block`)return a.warn(`Request blocked by security policy`),t}catch(t){if(a.error(`Scanning failed`,{error:t,method:e.method,requestType:e.type,scannerUrl:this.config.scanUrl}),!this.config.scanFailOpen)return a.warn(`Scanning service unavailable, blocking traffic (fail-closed)`),{action:`block`};a.warn(`Scanning service unavailable, allowing traffic (fail-open)`)}return t}isEnabled(){return this.isScanEnabled()}isScanEnabled(){return this.config.scanEnabled&&!!this.config.scanUrl}async scan(e){if(!this.isScanEnabled())return{action:`allow`};let t={data:e.data,id:e.id,metadata:this.buildEventMetadata(),method:e.method,originalRequestId:e.originalRequestId,type:e.type};a.info(`Scanning traffic`,{id:e.id,method:e.method,originalRequestId:e.originalRequestId,type:e.type});let n=await this.sendScanRequest(t);return a.info(`Scan result`,{action:n.action,blockReason:n.block_reason,hasModifiedData:!!n.modified_data,id:e.id,originalRequestId:e.originalRequestId}),n}updateConfig(e){this.config={...this.config,...e}}buildEventMetadata(){let e=this.config.spawnedServerInfoProvider?.();return{...this.sessionData,eventEndTime:new Date().toISOString(),...e?.pid===void 0?{}:{spawnedServerProcessId:e.pid},...e?.startedAtMs===void 0?{}:{spawnedServerProcessStartTime:new Date(e.startedAtMs).toISOString()}}}getClientInfoBase64(){return _i(this.sessionData)}async sendScanRequest(n){let r=new AbortController,i=setTimeout(()=>r.abort(),this.config.scanTimeoutMs);try{let i=`${this.config.scanUrl}/${this.config.scanApiKey}/mcp/${this.clientInfoBase64}`,a={data:n.data,id:n.id,metadata:n.metadata,method:n.method,sessionId:t,...n.originalRequestId&&{original_request_id:String(n.originalRequestId)},type:n.type},o=await e(i,{body:JSON.stringify(a),headers:{"Content-Type":`application/json`,...this.config.scanHeaders},method:`POST`,signal:r.signal});if(!o.ok)throw Error(`Sanitization service returned ${o.status}: ${o.statusText}`);let s=await o.json();if(!s.action||![`allow`,`block`,`modify`].includes(s.action))throw Error(`Invalid scan response format: action="${s.action}"`);return s}catch(e){throw e instanceof Error&&e.name===`AbortError`?Error(`Scan request timed out after ${this.config.scanTimeoutMs}ms`):e}finally{clearTimeout(i)}}};let yi=null;const bi=async e=>{let t=await li(),n=e.cliArgs.proxyType,r=n===`stdio`?{...e.cliArgs,args:fi(e.cliArgs.args)}:e.cliArgs,i={...t,fileContentHash:n===`stdio`?r.fileContentHash:void 0,proxyType:n,remoteCliArgs:n===`remote`?r:void 0,stdioCliArgs:n===`stdio`?r:void 0},o=n===`remote`?{...i,remoteCliArgs:{...r,url:gi(r.url)}}:i;return a.setSessionData(o),yi=new vi(e,i),yi},xi=()=>yi,Si=e=>{if(e.maxTotalTimeoutMs<0)throw Error(`maxTotalTimeoutMs must be >= 0 (0 disables the cap), got ${e.maxTotalTimeoutMs}`);let t={resetTimeoutOnProgress:e.resetTimeoutOnProgress,timeout:e.timeoutMs};return e.maxTotalTimeoutMs>0&&(t.maxTotalTimeout=e.maxTotalTimeoutMs),t},Ci=new class{counts=new Map;lastLogTime=Date.now();logIntervalMs=6e4;increment(e){this.counts.set(e,(this.counts.get(e)||0)+1),this.maybeLog()}logAndReset(){if(this.counts.size===0)return;let e=(Array.from(this.counts.values()).reduce((e,t)=>e+t,0));a.info(`Requests intercepted`,{byMethod:Object.fromEntries(this.counts),eventType:`mcp_requests_intercepted`,totalCount:e}),this.counts.clear(),this.lastLogTime=Date.now()}maybeLog(){Date.now()-this.lastLogTime>=this.logIntervalMs&&this.logAndReset()}},wi=()=>{Ci.logAndReset()},Ti=e=>{if(e.length>1&&e[1]&&typeof e[1]==`object`&&`mcpReq`in e[1])return e[1].mcpReq?.id?.toString()},G=(e,t,n,r)=>async(...i)=>{Ci.increment(e);let o=xi(),s=e,c=i[0],l=fr(),u=Ti(i)?.toString();c&&typeof c==`object`&&`method`in c&&typeof c.method==`string`&&(s=c.method);let d=async(e,t,n)=>{try{if(!o?.isEnabled()&&!o?.isScanEnabled())return;let r;try{r=await o.evaluate({data:t,id:l,method:s,originalRequestId:u,timestamp:new Date().toISOString(),type:e})}catch(t){if(a.error(`${e} evaluation failed, applying fail-safe`,{error:t}),o?.isScanEnabled()&&!o.scannerConfig?.failOpen)throw Error(`Security scanning service unavailable`);return}if(a.info(`${e} scan result`,{action:r.action,id:l,method:s,...e===`request`&&{originalRequestId:u}}),r.action===`block`||r.action===`modify`){let t=r.action===`block`?`blocked`:`modified`,i=r.action===`block`&&e===`request`?`warn`:`log`;if(r.modified_data){if(r.action===`block`){let n=`${e} ${t} by security policy${e===`request`?`, returning error response`:``}`;return i===`warn`?a.warn(n):a.info(n),r.modified_data}if(n){let o=`${e} ${t} by security policy`;i===`warn`?a.warn(o):a.info(o),n(r.modified_data);return}return r.modified_data}a.warn(`${r.action} action without modified_data, allowing original ${e}`)}return}catch(t){if(a.error(`Unexpected error during ${e} processing`,{error:t}),e===`request`&&t instanceof Error&&t.message===`Security scanning service unavailable`)throw t;return}},f;try{f=await d(`request`,c,e=>{i[0]=e})}catch(n){if(n instanceof Error&&n.message===`Security scanning service unavailable`)throw a.error(`Security scanning unavailable (fail-closed)`,{error:n.message,handlerName:e,operation:t}),n;a.error(`Unexpected error during request processing, continuing`,{error:n,handlerName:e,operation:t})}if(f!==void 0)return f;if(r&&!await r.isAllowed()){let n=r.getBlockReason();throw a.warn(`MCP server blocked by access control`,{handlerName:e,operation:t,reason:n}),new Ar(n,`policy_block`)}try{let e=await n(...i);try{if(e){let t=await d(`response`,e);if(t!==void 0)return t}}catch(e){a.error(`Error during response processing, returning original result`,{error:e})}return e}catch(n){if(n instanceof Ar)throw a.info(`Request blocked by access control`,{error:n.message,handlerName:e,operation:t,reason:n.reason}),n;try{await d(`error`,{error:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:void 0})}catch(e){a.warn(`Failed to evaluate error`,{evalError:e})}throw a.error(`Handler error in ${e}`,{argsCount:i.length,errorMessage:n instanceof Error?n.message:String(n),operation:t}),n}},Ei=async({authorizer:e,client:t,forwarding:r=n.toolCall,server:i,serverCapabilities:o})=>{let s=Si(r);o?.logging&&(i.setNotificationHandler(`notifications/message`,G(`notifications/message`,`server-to-client`,async e=>t.notification(e),e)),t.setNotificationHandler(`notifications/message`,G(`notifications/message`,`client-to-server`,async e=>i.notification(e),e))),o?.prompts&&(i.setRequestHandler(`prompts/get`,G(`prompts/get`,`get`,async e=>t.getPrompt(e.params,s),e)),i.setRequestHandler(`prompts/list`,G(`prompts/list`,`list`,async e=>t.listPrompts(e.params,s),e))),o?.resources&&(i.setRequestHandler(`resources/list`,G(`resources/list`,`list`,async e=>t.listResources(e.params,s),e)),i.setRequestHandler(`resources/templates/list`,G(`resources/templates/list`,`list`,async e=>t.listResourceTemplates(e.params,s),e)),i.setRequestHandler(`resources/read`,G(`resources/read`,`read`,async e=>t.readResource(e.params,s),e)),o?.resources.subscribe&&(i.setNotificationHandler(`notifications/resources/updated`,G(`notifications/resources/updated`,`notify`,async e=>t.notification(e),e)),i.setRequestHandler(`resources/subscribe`,G(`resources/subscribe`,`subscribe`,async e=>t.subscribeResource(e.params,s),e)),i.setRequestHandler(`resources/unsubscribe`,G(`resources/unsubscribe`,`unsubscribe`,async e=>t.unsubscribeResource(e.params,s),e)))),o?.tools&&(i.setRequestHandler(`tools/call`,G(`tools/call`,`call`,async(e,n)=>{let r=n.mcpReq._meta?.progressToken,i=r===void 0?void 0:e=>{n.mcpReq.notify({method:`notifications/progress`,params:{...e,progressToken:r}}).catch(e=>{a.warn(`Failed to forward progress notification to client`,{error:e})})};return t.callTool(e.params,{...s,onprogress:i})},e)),i.setRequestHandler(`tools/list`,G(`tools/list`,`list`,async e=>t.listTools(e.params,s),e))),o?.completions&&i.setRequestHandler(`completion/complete`,G(`completion/complete`,`complete`,async e=>t.complete(e.params,s),e))};var Di=Object.create,Oi=Object.defineProperty,ki=Object.getOwnPropertyDescriptor,Ai=Object.getOwnPropertyNames,ji=Object.getPrototypeOf,Mi=Object.prototype.hasOwnProperty,K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ni=(e,t)=>{let n={};for(var r in e)Oi(n,r,{get:e[r],enumerable:!0});return t&&Oi(n,Symbol.toStringTag,{value:`Module`}),n},Pi=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ai(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Mi.call(e,s)&&s!==n&&Oi(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ki(t,s))||r.enumerable});return e},Fi=(e,t,n)=>(n=e==null?{}:Di(ji(e)),Pi(t||!e||!e.__esModule?Oi(n,`default`,{value:e,enumerable:!0}):n,e));const Ii=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),Li=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),Ri=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),zi=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function Bi(e){return typeof e==`string`&&Li.has(e.replace(/#$/,``))}function Vi(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(Ii.has(n))return`2020-12`;if(Li.has(n))return`2019-09`;if(Ri.has(n)||zi.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}const Hi=Symbol.for(`mcp.sdk.errorBrands`);function Ui(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Hi,{value:n,enumerable:!1,configurable:!0})}function Wi(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Hi)){let n=t[Hi];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}(class e extends Error{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return Wi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Wi(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Ui(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}});let q=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({});var J=class extends Error{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Wi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Wi(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`SdkError`,Ui(this,new.target)}};(class extends J{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.SdkHttpError`})}constructor(e,t,n){super(e,t,n),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}});function Gi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ki(e,t,n){return e===`elicitation`&&t===`form`&&n.form===void 0&&n.url===void 0}function qi(e){switch(e.method){case`elicitation/create`:return e.params?.mode===`url`?{elicitation:{url:{}}}:{elicitation:{form:{}}};case`sampling/createMessage`:{let t=e.params;return t!==void 0&&(t.tools!==void 0||t.toolChoice!==void 0)?{sampling:{tools:{}}}:{sampling:{}}}case`roots/list`:return{roots:{}};default:return}}function Ji(e,t){let n={};for(let[r,i]of Object.entries(e)){if(i===void 0)continue;let e=t===void 0?void 0:t[r];if(e===void 0){n[r]=i;continue}if(Gi(i)&&Gi(e)){let t={};for(let[n,a]of Object.entries(i))a!==void 0&&e[n]===void 0&&!Ki(r,n,e)&&(t[n]=a);Object.keys(t).length>0&&(n[r]=t)}}return Object.keys(n).length>0?n:void 0}const Yi=`2026-07-28`,Xi=[Yi];function Zi(e){return e>=Yi}function Qi(e){return e.filter(e=>!Zi(e))}function $i(e){return e.filter(e=>Zi(e))}function ea(e){let t=e.structuredContent;return t===void 0||!(typeof t!=`object`||!t||Array.isArray(t))||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}const ta=[`task`,`inputRequests`,`requestState`];function na(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||ta.some(t=>t in e)?e:{...e,content:[]}}function ra(){let e=or(()=>U([H(),R(),F(),er(),V(H(),e),P(e)])),t=V(H(),e),n=U([H(),R().int()]),r=H(),i=z({ttl:R().optional()}),a=z({taskId:H()}),o=L({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=z({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=z({method:H(),params:s.loose().optional()}),u=z({_meta:o.optional()}),d=z({method:H(),params:u.loose().optional()}),f=L({_meta:o.optional()}),p=U([H(),R().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:H().optional()}),g=d.extend({method:I(`notifications/cancelled`),params:h}),_=z({src:H(),mimeType:H().optional(),sizes:P(H()).optional(),theme:N([`light`,`dark`]).optional()}),v=z({icons:P(_).optional()}),y=z({name:H(),title:H().optional()}),b=y.extend({...y.shape,...v.shape,version:H(),websiteUrl:H().optional(),description:H().optional()}),x=ar(z({applyDefaults:F().optional()}),t),S=sr(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ar(z({form:x.optional(),url:t.optional()}),t.optional())),C=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),ee=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),te=z({experimental:V(H(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:S.optional(),roots:z({listChanged:F().optional()}).optional(),tasks:C.optional(),extensions:V(H(),t).optional()}),ne=s.extend({protocolVersion:H(),capabilities:te,clientInfo:b}),w=l.extend({method:I(`initialize`),params:ne}),re=z({experimental:V(H(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:F().optional()}).optional(),resources:z({subscribe:F().optional(),listChanged:F().optional()}).optional(),tools:z({listChanged:F().optional()}).optional(),tasks:ee.optional(),extensions:V(H(),t).optional()}),T=f.extend({protocolVersion:H(),capabilities:re,serverInfo:b,instructions:H().optional()}),ie=d.extend({method:I(`notifications/initialized`),params:u.optional()}),ae=l.extend({method:I(`ping`),params:s.optional()}),oe=z({progress:R(),total:B(R()),message:B(H())}),se=z({...u.shape,...oe.shape,progressToken:n}),ce=d.extend({method:I(`notifications/progress`),params:se}),le=s.extend({cursor:r.optional()}),E=l.extend({params:le.optional()}),D=f.extend({nextCursor:r.optional()}),ue=z({uri:H(),mimeType:B(H()),_meta:V(H(),W()).optional()}),de=ue.extend({text:H()}),fe=H().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),pe=ue.extend({blob:fe}),O=N([`user`,`assistant`]),me=z({audience:P(O).optional(),priority:R().min(0).max(1).optional(),lastModified:nr({offset:!0}).optional()}),he=z({...y.shape,...v.shape,uri:H(),description:B(H()),mimeType:B(H()),size:B(R()),annotations:me.optional(),_meta:B(L({}))}),ge=z({...y.shape,...v.shape,uriTemplate:H(),description:B(H()),mimeType:B(H()),annotations:me.optional(),_meta:B(L({}))}),_e=E.extend({method:I(`resources/list`)}),ve=D.extend({resources:P(he)}),ye=E.extend({method:I(`resources/templates/list`)}),be=D.extend({resourceTemplates:P(ge)}),xe=s.extend({uri:H()}),Se=xe,Ce=l.extend({method:I(`resources/read`),params:Se}),we=f.extend({contents:P(U([de,pe]))}),Te=d.extend({method:I(`notifications/resources/list_changed`),params:u.optional()}),Ee=xe,De=l.extend({method:I(`resources/subscribe`),params:Ee}),Oe=xe,ke=l.extend({method:I(`resources/unsubscribe`),params:Oe}),Ae=u.extend({uri:H()}),je=d.extend({method:I(`notifications/resources/updated`),params:Ae}),Me=z({name:H(),description:B(H()),required:B(F())}),Ne=z({...y.shape,...v.shape,description:B(H()),arguments:B(P(Me)),_meta:B(L({}))}),Pe=E.extend({method:I(`prompts/list`)}),Fe=D.extend({prompts:P(Ne)}),Ie=s.extend({name:H(),arguments:V(H(),H()).optional()}),Le=l.extend({method:I(`prompts/get`),params:Ie}),Re=z({type:I(`text`),text:H(),annotations:me.optional(),_meta:V(H(),W()).optional()}),ze=z({type:I(`image`),data:fe,mimeType:H(),annotations:me.optional(),_meta:V(H(),W()).optional()}),Be=z({type:I(`audio`),data:fe,mimeType:H(),annotations:me.optional(),_meta:V(H(),W()).optional()}),Ve=z({type:I(`tool_use`),name:H(),id:H(),input:V(H(),W()),_meta:V(H(),W()).optional()}),He=z({type:I(`resource`),resource:U([de,pe]),annotations:me.optional(),_meta:V(H(),W()).optional()}),Ue=he.extend({type:I(`resource_link`)}),We=U([Re,ze,Be,Ue,He]),Ge=z({role:O,content:We}),Ke=f.extend({description:H().optional(),messages:P(Ge)}),qe=d.extend({method:I(`notifications/prompts/list_changed`),params:u.optional()}),Je=z({title:H().optional(),readOnlyHint:F().optional(),destructiveHint:F().optional(),idempotentHint:F().optional(),openWorldHint:F().optional()}),Ye=z({taskSupport:N([`required`,`optional`,`forbidden`]).optional()}),Xe=z({...y.shape,...v.shape,description:H().optional(),inputSchema:z({type:I(`object`),properties:V(H(),e).optional(),required:P(H()).optional()}).catchall(W()),outputSchema:z({type:I(`object`),properties:V(H(),e).optional(),required:P(H()).optional()}).catchall(W()).optional(),annotations:Je.optional(),execution:Ye.optional(),_meta:V(H(),W()).optional()}),Ze=E.extend({method:I(`tools/list`)}),Qe=D.extend({tools:P(Xe)}),$e=f.extend({content:P(We),structuredContent:V(H(),W()).optional(),isError:F().optional()}),et=c.extend({name:H(),arguments:V(H(),W()).optional()}),tt=l.extend({method:I(`tools/call`),params:et}),nt=d.extend({method:I(`notifications/tools/list_changed`),params:u.optional()}),k=N([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),rt=s.extend({level:k}),it=l.extend({method:I(`logging/setLevel`),params:rt}),at=u.extend({level:k,logger:H().optional(),data:W()}),ot=d.extend({method:I(`notifications/message`),params:at}),st=z({name:H().optional()}),ct=z({hints:P(st).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),lt=z({mode:N([`auto`,`required`,`none`]).optional()}),ut=z({type:I(`tool_result`),toolUseId:H().describe(`The unique identifier for the corresponding tool call.`),content:P(We),structuredContent:z({}).loose().optional(),isError:F().optional(),_meta:V(H(),W()).optional()}),dt=rr(`type`,[Re,ze,Be]),ft=rr(`type`,[Re,ze,Be,Ve,ut]),pt=z({role:O,content:U([ft,P(ft)]),_meta:V(H(),W()).optional()}),mt=c.extend({messages:P(pt),modelPreferences:ct.optional(),systemPrompt:H().optional(),includeContext:N([`none`,`thisServer`,`allServers`]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:P(H()).optional(),metadata:t.optional(),tools:P(Xe).optional(),toolChoice:lt.optional()}),ht=l.extend({method:I(`sampling/createMessage`),params:mt}),gt=f.extend({model:H(),stopReason:B(N([`endTurn`,`stopSequence`,`maxTokens`]).or(H())),role:O,content:dt}),_t=f.extend({model:H(),stopReason:B(N([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(H())),role:O,content:U([ft,P(ft)])}),vt=z({type:I(`boolean`),title:H().optional(),description:H().optional(),default:F().optional()}),yt=z({type:I(`string`),title:H().optional(),description:H().optional(),minLength:R().optional(),maxLength:R().optional(),format:N([`email`,`uri`,`date`,`date-time`]).optional(),default:H().optional()}),bt=z({type:N([`number`,`integer`]),title:H().optional(),description:H().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),xt=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),default:H().optional()}),St=z({type:I(`string`),title:H().optional(),description:H().optional(),oneOf:P(z({const:H(),title:H()})),default:H().optional()}),Ct=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),enumNames:P(H()).optional(),default:H().optional()}),wt=U([xt,St]),Tt=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({type:I(`string`),enum:P(H())}),default:P(H()).optional()}),Et=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({anyOf:P(z({const:H(),title:H()}))}),default:P(H()).optional()}),Dt=U([Tt,Et]),Ot=U([Ct,wt,Dt]),kt=U([Ot,vt,yt,bt]),At=c.extend({mode:I(`form`).optional(),message:H(),requestedSchema:z({type:I(`object`),properties:V(H(),kt),required:P(H()).optional()}).catchall(W())}),jt=c.extend({mode:I(`url`),message:H(),elicitationId:H(),url:H().url()}),Mt=U([At,jt]),A=l.extend({method:I(`elicitation/create`),params:Mt}),j=u.extend({elicitationId:H()}),Nt=d.extend({method:I(`notifications/elicitation/complete`),params:j}),Pt=f.extend({action:N([`accept`,`decline`,`cancel`]),content:sr(e=>e===null?void 0:e,V(H(),U([H(),R(),F(),P(H())])).optional())}),Ft=z({type:I(`ref/resource`),uri:H()}),It=z({type:I(`ref/prompt`),name:H()}),Lt=s.extend({ref:U([It,Ft]),argument:z({name:H(),value:H()}),context:z({arguments:V(H(),H()).optional()}).optional()}),Rt=l.extend({method:I(`completion/complete`),params:Lt}),zt=f.extend({completion:L({values:P(H()).max(100),total:B(R().int()),hasMore:B(F())})}),Bt=z({uri:H().startsWith(`file://`),name:H().optional(),_meta:V(H(),W()).optional()}),Vt=l.extend({method:I(`roots/list`),params:s.optional()}),Ht=f.extend({roots:P(Bt)}),Ut=d.extend({method:I(`notifications/roots/list_changed`),params:u.optional()}),Wt=L({ttl:R().optional(),pollInterval:R().optional()}),Gt=N([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Kt=z({taskId:H(),status:Gt,ttl:U([R(),er()]),createdAt:H(),lastUpdatedAt:H(),pollInterval:B(R()),statusMessage:B(H())}),qt=f.extend({task:Kt}),Jt=u.merge(Kt),Yt=d.extend({method:I(`notifications/tasks/status`),params:Jt}),Xt=l.extend({method:I(`tasks/get`),params:s.extend({taskId:H()})}),M=f.merge(Kt),Zt=l.extend({method:I(`tasks/result`),params:s.extend({taskId:H()})}),Qt=f.loose(),$t=E.extend({method:I(`tasks/list`)}),en=D.extend({tasks:P(Kt)}),tn=l.extend({method:I(`tasks/cancel`),params:s.extend({taskId:H()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:m,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:b,ClientTasksCapabilitySchema:C,ServerTasksCapabilitySchema:ee,ClientCapabilitiesSchema:te,InitializeRequestParamsSchema:ne,InitializeRequestSchema:w,ServerCapabilitiesSchema:re,InitializeResultSchema:T,InitializedNotificationSchema:ie,PingRequestSchema:ae,ProgressSchema:oe,ProgressNotificationParamsSchema:se,ProgressNotificationSchema:ce,PaginatedRequestParamsSchema:le,PaginatedRequestSchema:E,PaginatedResultSchema:D,ResourceContentsSchema:ue,TextResourceContentsSchema:de,BlobResourceContentsSchema:pe,RoleSchema:O,AnnotationsSchema:me,ResourceSchema:he,ResourceTemplateSchema:ge,ListResourcesRequestSchema:_e,ListResourcesResultSchema:ve,ListResourceTemplatesRequestSchema:ye,ListResourceTemplatesResultSchema:be,ResourceRequestParamsSchema:xe,ReadResourceRequestParamsSchema:Se,ReadResourceRequestSchema:Ce,ReadResourceResultSchema:we,ResourceListChangedNotificationSchema:Te,SubscribeRequestParamsSchema:Ee,SubscribeRequestSchema:De,UnsubscribeRequestParamsSchema:Oe,UnsubscribeRequestSchema:ke,ResourceUpdatedNotificationParamsSchema:Ae,ResourceUpdatedNotificationSchema:je,PromptArgumentSchema:Me,PromptSchema:Ne,ListPromptsRequestSchema:Pe,ListPromptsResultSchema:Fe,GetPromptRequestParamsSchema:Ie,GetPromptRequestSchema:Le,TextContentSchema:Re,ImageContentSchema:ze,AudioContentSchema:Be,ToolUseContentSchema:Ve,EmbeddedResourceSchema:He,ResourceLinkSchema:Ue,ContentBlockSchema:We,PromptMessageSchema:Ge,GetPromptResultSchema:Ke,PromptListChangedNotificationSchema:qe,ToolAnnotationsSchema:Je,ToolExecutionSchema:Ye,ToolSchema:Xe,ListToolsRequestSchema:Ze,ListToolsResultSchema:Qe,CallToolResultSchema:$e,CallToolRequestParamsSchema:et,CallToolRequestSchema:tt,ToolListChangedNotificationSchema:nt,LoggingLevelSchema:k,SetLevelRequestParamsSchema:rt,SetLevelRequestSchema:it,LoggingMessageNotificationParamsSchema:at,LoggingMessageNotificationSchema:ot,ModelHintSchema:st,ModelPreferencesSchema:ct,ToolChoiceSchema:lt,ToolResultContentSchema:ut,SamplingContentSchema:dt,SamplingMessageContentBlockSchema:ft,SamplingMessageSchema:pt,CreateMessageRequestParamsSchema:mt,CreateMessageRequestSchema:ht,CreateMessageResultSchema:gt,CreateMessageResultWithToolsSchema:_t,BooleanSchemaSchema:vt,StringSchemaSchema:yt,NumberSchemaSchema:bt,UntitledSingleSelectEnumSchemaSchema:xt,TitledSingleSelectEnumSchemaSchema:St,LegacyTitledEnumSchemaSchema:Ct,SingleSelectEnumSchemaSchema:wt,UntitledMultiSelectEnumSchemaSchema:Tt,TitledMultiSelectEnumSchemaSchema:Et,MultiSelectEnumSchemaSchema:Dt,EnumSchemaSchema:Ot,PrimitiveSchemaDefinitionSchema:kt,ElicitRequestFormParamsSchema:At,ElicitRequestURLParamsSchema:jt,ElicitRequestParamsSchema:Mt,ElicitRequestSchema:A,ElicitationCompleteNotificationParamsSchema:j,ElicitationCompleteNotificationSchema:Nt,ElicitResultSchema:Pt,ResourceTemplateReferenceSchema:Ft,PromptReferenceSchema:It,CompleteRequestParamsSchema:Lt,CompleteRequestSchema:Rt,CompleteResultSchema:zt,RootSchema:Bt,ListRootsRequestSchema:Vt,ListRootsResultSchema:Ht,RootsListChangedNotificationSchema:Ut,TaskCreationParamsSchema:Wt,TaskStatusSchema:Gt,TaskSchema:Kt,CreateTaskResultSchema:qt,TaskStatusNotificationParamsSchema:Jt,TaskStatusNotificationSchema:Yt,GetTaskRequestSchema:Xt,GetTaskResultSchema:M,GetTaskPayloadRequestSchema:Zt,GetTaskPayloadResultSchema:Qt,ListTasksRequestSchema:$t,ListTasksResultSchema:en,CancelTaskRequestSchema:tn,CancelTaskResultSchema:f.merge(Kt),ClientRequestSchema:U([ae,w,Rt,it,Le,Pe,_e,ye,Ce,De,ke,tt,Ze,Xt,Zt,$t,tn]),ClientNotificationSchema:U([g,ce,ie,Ut,Yt]),ClientResultSchema:U([m,gt,_t,Pt,Ht,M,en,qt]),ServerRequestSchema:U([ae,ht,A,Vt,Xt,Zt,$t,tn]),ServerNotificationSchema:U([g,ce,ot,je,Te,nt,qe,Yt,Nt]),ServerResultSchema:U([m,T,zt,Ke,Fe,ve,be,we,$e,Qe,M,en,qt]),CallToolResultWireSchema:W().superRefine((e,t)=>{if(!(typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0)){for(let n of ta)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(na).pipe($e)}}let ia;function aa(){return ia??=ra()}function oa(e){return e.type!==`object`}const sa=new Set([`const`,`enum`,`default`,`examples`]),ca=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function la(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function ua(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(la(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=Bi(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&la(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:sa.has(o)?i[o]=s:ca.has(o)?i[o]=r(s,!0):i[o]=r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}const da={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},fa={"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},pa={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};let ma;function ha(){if(ma)return ma;let e=aa();return ma={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},ma}function ga(e){return Object.prototype.hasOwnProperty.call(da,e)}function _a(e){return Object.prototype.hasOwnProperty.call(fa,e)}function va(e){return Object.prototype.hasOwnProperty.call(pa,e)}function ya(e){return va(e)?ha().resultSchemas[e]:void 0}function ba(e){return ga(e)?ha().requestSchemas[e]:void 0}function xa(e){return _a(e)?ha().notificationSchemas[e]:void 0}function Sa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ca(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}const wa={ok:!1,reason:`not-in-era`};function Ta(e){return Sa(e)&&Sa(e.outputSchema)&&oa(e.outputSchema)}function Ea(e){return e}const Da={era:`2025-11-25`,hasRequestMethod:ga,hasNotificationMethod:_a,validateRequest:(e,t)=>Ca(ba(e),t),validateResult:(e,t)=>Ca(ya(e),t),validateNotification:(e,t)=>Ca(xa(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>wa,validateInputResponse:()=>wa,samplingResultVariant:((e,t)=>{let n=aa();return Ca(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=ea(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&oa(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(Sa(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Ea(e)}}return{kind:`complete`,result:Ea(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>Ta(e))?t:{...t,tools:n.map(e=>Ta(e)?{...e,outputSchema:ua(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function Oa(){let e=or(()=>U([H(),R(),F(),er(),V(H(),e),P(e)])),t=V(H(),e),n=U([H(),R().int()]),r=H(),i=U([H(),R().int()]),a=N([`user`,`assistant`]),o=N([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=H().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=z({ttl:R().optional()}),l=z({taskId:H()}),u=L({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=z({_meta:u.optional()}),f=d.extend({task:c.optional()}),h=z({_meta:u.optional()}),g=z({method:H(),params:h.loose().optional()}),_=z({src:H(),mimeType:H().optional(),sizes:P(H()).optional(),theme:N([`light`,`dark`]).optional()}),v=z({icons:P(_).optional()}),y=z({name:H(),title:H().optional()}),b=y.extend({...y.shape,...v.shape,version:H(),websiteUrl:H().optional(),description:H().optional()}),x=ar(z({applyDefaults:F().optional()}),t),S=sr(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ar(z({form:x.optional(),url:t.optional()}),t.optional())),C=L({list:t.optional(),cancel:t.optional(),requests:L({sampling:L({createMessage:t.optional()}).optional(),elicitation:L({create:t.optional()}).optional()}).optional()}),ee=L({list:t.optional(),cancel:t.optional(),requests:L({tools:L({call:t.optional()}).optional()}).optional()}),te=z({experimental:V(H(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:S.optional(),roots:z({listChanged:F().optional()}).optional(),tasks:C.optional(),extensions:V(H(),t).optional()}),ne=z({experimental:V(H(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:F().optional()}).optional(),resources:z({subscribe:F().optional(),listChanged:F().optional()}).optional(),tools:z({listChanged:F().optional()}).optional(),tasks:ee.optional(),extensions:V(H(),t).optional()}),w=z({progress:R(),total:B(R()),message:B(H())}),re=z({...h.shape,...w.shape,progressToken:n}),T=g.extend({method:I(`notifications/progress`),params:re}),ie=h.extend({level:o,logger:H().optional(),data:W()}),ae=g.extend({method:I(`notifications/message`),params:ie}),oe=z({uri:H(),mimeType:B(H()),_meta:V(H(),W()).optional()}),se=oe.extend({text:H()}),ce=oe.extend({blob:s}),le=z({audience:P(a).optional(),priority:R().min(0).max(1).optional(),lastModified:nr({offset:!0}).optional()}),E=z({...y.shape,...v.shape,uri:H(),description:B(H()),mimeType:B(H()),size:B(R()),annotations:le.optional(),_meta:B(L({}))}),D=z({...y.shape,...v.shape,uriTemplate:H(),description:B(H()),mimeType:B(H()),annotations:le.optional(),_meta:B(L({}))}),ue=g.extend({method:I(`notifications/resources/list_changed`),params:h.optional()}),de=h.extend({uri:H()}),fe=g.extend({method:I(`notifications/resources/updated`),params:de}),pe=z({name:H(),description:B(H()),required:B(F())}),O=z({...y.shape,...v.shape,description:B(H()),arguments:B(P(pe)),_meta:B(L({}))}),me=g.extend({method:I(`notifications/prompts/list_changed`),params:h.optional()}),he=z({type:I(`text`),text:H(),annotations:le.optional(),_meta:V(H(),W()).optional()}),ge=z({type:I(`image`),data:s,mimeType:H(),annotations:le.optional(),_meta:V(H(),W()).optional()}),_e=z({type:I(`audio`),data:s,mimeType:H(),annotations:le.optional(),_meta:V(H(),W()).optional()}),ve=z({type:I(`tool_use`),name:H(),id:H(),input:V(H(),W()),_meta:V(H(),W()).optional()}),ye=z({type:I(`resource`),resource:U([se,ce]),annotations:le.optional(),_meta:V(H(),W()).optional()}),be=E.extend({type:I(`resource_link`)}),xe=U([he,ge,_e,be,ye]),Se=z({role:a,content:xe}),Ce=z({title:H().optional(),readOnlyHint:F().optional(),destructiveHint:F().optional(),idempotentHint:F().optional(),openWorldHint:F().optional()}),we=g.extend({method:I(`notifications/tools/list_changed`),params:h.optional()}),Te=z({name:H().optional()}),Ee=z({hints:P(Te).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),De=z({mode:N([`auto`,`required`,`none`]).optional()}),Oe=z({type:I(`boolean`),title:H().optional(),description:H().optional(),default:F().optional()}),ke=z({type:I(`string`),title:H().optional(),description:H().optional(),minLength:R().optional(),maxLength:R().optional(),format:N([`email`,`uri`,`date`,`date-time`]).optional(),default:H().optional()}),Ae=z({type:N([`number`,`integer`]),title:H().optional(),description:H().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),je=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),default:H().optional()}),Me=z({type:I(`string`),title:H().optional(),description:H().optional(),oneOf:P(z({const:H(),title:H()})),default:H().optional()}),Ne=z({type:I(`string`),title:H().optional(),description:H().optional(),enum:P(H()),enumNames:P(H()).optional(),default:H().optional()}),Pe=U([je,Me]),Fe=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({type:I(`string`),enum:P(H())}),default:P(H()).optional()}),Ie=z({type:I(`array`),title:H().optional(),description:H().optional(),minItems:R().optional(),maxItems:R().optional(),items:z({anyOf:P(z({const:H(),title:H()}))}),default:P(H()).optional()}),Le=U([Fe,Ie]),Re=U([Ne,Pe,Le]),ze=U([Re,Oe,ke,Ae]),Be=f.extend({mode:I(`form`).optional(),message:H(),requestedSchema:z({type:I(`object`),properties:V(H(),ze),required:P(H()).optional()}).catchall(W())}),Ve=z({type:I(`ref/resource`),uri:H()}),He=z({type:I(`ref/prompt`),name:H()}),Ue=z({uri:H().startsWith(`file://`),name:H().optional(),_meta:V(H(),W()).optional()}),We=te.shape,Ge=z({experimental:We.experimental,sampling:We.sampling,elicitation:We.elicitation,roots:We.roots,extensions:We.extensions}),Ke=ne.shape,qe=z({experimental:Ke.experimental,logging:Ke.logging,completions:Ke.completions,prompts:Ke.prompts,resources:Ke.resources,tools:Ke.tools,extensions:Ke.extensions}),Ye=L({progressToken:n.optional(),[Ot]:H(),[m]:b.optional(),[p]:Ge,[Je]:o.optional()}),Xe=z({...y.shape,...v.shape,description:H().optional(),inputSchema:L({$schema:H().optional(),type:I(`object`)}),outputSchema:L({$schema:H().optional()}).optional(),annotations:Ce.optional(),_meta:V(H(),W()).optional()}),Ze=z({type:I(`tool_result`),toolUseId:H(),content:P(xe),structuredContent:W().optional(),isError:F().optional(),_meta:V(H(),W()).optional()}),Qe=U([he,ge,_e,ve,Ze]),$e=z({role:a,content:U([Qe,P(Qe)]),_meta:V(H(),W()).optional()}),et=H(),tt=L({[cn]:b.optional().catch(void 0)}),nt=tt.optional();function k(e){return L({_meta:nt,resultType:et.default(`complete`),...e})}let rt=k({}),it=k({nextCursor:r.optional()}),at=k({content:P(xe),structuredContent:W().optional(),isError:F().optional()}),ot=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),tools:P(Xe),nextCursor:r.optional()}),st=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),prompts:P(O),nextCursor:r.optional()}),ct=k({description:H().optional(),messages:P(Se)}),lt=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resources:P(E),nextCursor:r.optional()}),ut=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resourceTemplates:P(D),nextCursor:r.optional()}),dt=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),contents:P(U([se,ce]))}),ft=k({completion:z({values:P(H()).max(100),total:R().int().optional(),hasMore:F().optional()}).loose()}),pt=k({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`])}),mt=k({ttlMs:R().int().min(0).catch(0),cacheScope:N([`public`,`private`]).catch(`private`),supportedVersions:P(H()),capabilities:qe,instructions:H().optional()}),ht=z({messages:P($e),modelPreferences:Ee.optional(),systemPrompt:H().optional(),includeContext:N([`none`,`thisServer`,`allServers`]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:P(H()).optional(),metadata:t.optional(),tools:P(Xe).optional(),toolChoice:De.optional()}),gt=z({method:I(`sampling/createMessage`),params:ht}),_t=z({method:I(`roots/list`),params:z({_meta:V(H(),W()).optional()}).optional()}),vt=z({...$e.shape,model:H(),stopReason:H().optional()}),yt=z({roots:P(Ue)}),bt=z({action:N([`accept`,`decline`,`cancel`]),content:V(H(),U([H(),R(),F(),P(H())])).optional()}),xt=z({mode:I(`url`),message:H(),url:H().url()}),St=U([Be,xt]),Ct=z({method:I(`elicitation/create`),params:St}),wt=U([gt,_t,Ct]),Tt=U([vt,yt,bt]),Et=V(H(),wt),Dt=V(H(),Tt),kt=k({inputRequests:Et.optional(),requestState:H().optional()}),At={inputResponses:Dt.optional(),requestState:H().optional()},jt=z({_meta:Ye,...At}),Mt=L({progressToken:n.optional()});function A(e,t){return z({method:I(e),params:z({_meta:Ye,...t})})}function j(e,t){return z({method:I(e),params:z({_meta:Mt.optional(),...t}).optional()})}let Nt={name:H(),arguments:V(H(),W()).optional(),...At},Pt={cursor:r.optional()},Ft=A(`tools/call`,Nt),It=A(`tools/list`,Pt),Lt=A(`prompts/list`,Pt),Rt=A(`prompts/get`,{name:H(),arguments:V(H(),H()).optional(),...At}),zt=A(`resources/list`,Pt),Bt=A(`resources/templates/list`,Pt),Vt=A(`resources/read`,{uri:H(),...At}),Ht={ref:U([He,Ve]),argument:z({name:H(),value:H()}),context:z({arguments:V(H(),H()).optional()}).optional()},Ut=A(`completion/complete`,Ht),Wt=A(`server/discover`,{}),Gt=z({toolsListChanged:F().optional(),promptsListChanged:F().optional(),resourcesListChanged:F().optional(),resourceSubscriptions:P(H()).optional()}),Kt={notifications:Gt},qt=A(`subscriptions/listen`,Kt),Jt=tt.extend({"io.modelcontextprotocol/subscriptionId":i}),Yt=L({_meta:Jt,resultType:et.default(`complete`)}),Xt={"tools/call":j(`tools/call`,Nt),"tools/list":j(`tools/list`,Pt),"prompts/get":j(`prompts/get`,{name:H(),arguments:V(H(),H()).optional()}),"prompts/list":j(`prompts/list`,Pt),"resources/list":j(`resources/list`,Pt),"resources/templates/list":j(`resources/templates/list`,Pt),"resources/read":j(`resources/read`,{uri:H()}),"completion/complete":j(`completion/complete`,Ht),"server/discover":j(`server/discover`,{}),"subscriptions/listen":j(`subscriptions/listen`,Kt)};function M(e){return L({_meta:nt,...e})}let Zt={"tools/call":M({content:P(xe),structuredContent:W().optional(),isError:F().optional()}),"tools/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),tools:P(Xe),nextCursor:r.optional()}),"prompts/get":M({description:H().optional(),messages:P(Se)}),"prompts/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),prompts:P(O),nextCursor:r.optional()}),"resources/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resources:P(E),nextCursor:r.optional()}),"resources/templates/list":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),resourceTemplates:P(D),nextCursor:r.optional()}),"resources/read":M({ttlMs:R().int().min(0),cacheScope:N([`public`,`private`]),contents:P(U([se,ce]))}),"completion/complete":M({completion:z({values:P(H()).max(100),total:R().int().optional(),hasMore:F().optional()}).loose()}),"server/discover":M({ttlMs:R().int().min(0).catch(0),cacheScope:N([`public`,`private`]).catch(`private`),supportedVersions:P(H()),capabilities:qe,instructions:H().optional()}),"subscriptions/listen":M({})},Qt=L({"io.modelcontextprotocol/subscriptionId":i.optional()}),$t=z({method:I(`notifications/subscriptions/acknowledged`),params:z({_meta:Qt.optional(),notifications:Gt})}),en=z({_meta:Qt.optional(),requestId:i,reason:H().optional()}),tn=z({method:I(`notifications/cancelled`),params:en}),nn={"notifications/cancelled":tn,"notifications/progress":T,"notifications/message":ae,"notifications/resources/updated":fe,"notifications/resources/list_changed":ue,"notifications/tools/list_changed":we,"notifications/prompts/list_changed":me,"notifications/subscriptions/acknowledged":$t},rn=e=>z({jsonrpc:I(`2.0`),id:U([H(),R().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:h,NotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:b,ClientTasksCapabilitySchema:C,ServerTasksCapabilitySchema:ee,ClientCapabilitiesSchema:te,ServerCapabilitiesSchema:ne,ProgressSchema:w,ProgressNotificationParamsSchema:re,ProgressNotificationSchema:T,LoggingMessageNotificationParamsSchema:ie,LoggingMessageNotificationSchema:ae,ResourceContentsSchema:oe,TextResourceContentsSchema:se,BlobResourceContentsSchema:ce,AnnotationsSchema:le,ResourceSchema:E,ResourceTemplateSchema:D,ResourceListChangedNotificationSchema:ue,ResourceUpdatedNotificationParamsSchema:de,ResourceUpdatedNotificationSchema:fe,PromptArgumentSchema:pe,PromptSchema:O,PromptListChangedNotificationSchema:me,TextContentSchema:he,ImageContentSchema:ge,AudioContentSchema:_e,ToolUseContentSchema:ve,EmbeddedResourceSchema:ye,ResourceLinkSchema:be,ContentBlockSchema:xe,PromptMessageSchema:Se,ToolAnnotationsSchema:Ce,ToolListChangedNotificationSchema:we,ModelHintSchema:Te,ModelPreferencesSchema:Ee,ToolChoiceSchema:De,BooleanSchemaSchema:Oe,StringSchemaSchema:ke,NumberSchemaSchema:Ae,UntitledSingleSelectEnumSchemaSchema:je,TitledSingleSelectEnumSchemaSchema:Me,LegacyTitledEnumSchemaSchema:Ne,SingleSelectEnumSchemaSchema:Pe,UntitledMultiSelectEnumSchemaSchema:Fe,TitledMultiSelectEnumSchemaSchema:Ie,MultiSelectEnumSchemaSchema:Le,EnumSchemaSchema:Re,PrimitiveSchemaDefinitionSchema:ze,ElicitRequestFormParamsSchema:Be,ResourceTemplateReferenceSchema:Ve,PromptReferenceSchema:He,RootSchema:Ue,ClientCapabilities2026Schema:Ge,ServerCapabilities2026Schema:qe,RequestMetaEnvelopeSchema:Ye,ToolSchema:Xe,ToolResultContentSchema:Ze,SamplingMessageContentBlockSchema:Qe,SamplingMessageSchema:$e,ResultTypeSchema:et,ResultMetaSchema:tt,ResultSchema:rt,PaginatedResultSchema:it,CallToolResultSchema:at,ListToolsResultSchema:ot,ListPromptsResultSchema:st,GetPromptResultSchema:ct,ListResourcesResultSchema:lt,ListResourceTemplatesResultSchema:ut,ReadResourceResultSchema:dt,CompleteResultSchema:ft,CacheableResultSchema:pt,DiscoverResultSchema:mt,CreateMessageRequestParamsSchema:ht,CreateMessageRequestSchema:gt,ListRootsRequestSchema:_t,CreateMessageResultSchema:vt,ListRootsResultSchema:yt,ElicitResultSchema:bt,ElicitRequestURLParamsSchema:xt,ElicitRequestParamsSchema:St,ElicitRequestSchema:Ct,InputRequestSchema:wt,InputResponseSchema:Tt,InputRequestsSchema:Et,InputResponsesSchema:Dt,InputRequiredResultSchema:kt,InputResponseRequestParamsSchema:jt,CallToolRequestSchema:Ft,ListToolsRequestSchema:It,ListPromptsRequestSchema:Lt,GetPromptRequestSchema:Rt,ListResourcesRequestSchema:zt,ListResourceTemplatesRequestSchema:Bt,ReadResourceRequestSchema:Vt,CompleteRequestSchema:Ut,DiscoverRequestSchema:Wt,SubscriptionFilterSchema:Gt,SubscriptionsListenRequestSchema:qt,SubscriptionsListenResultMetaSchema:Jt,SubscriptionsListenResultSchema:Yt,dispatchRequestSchemas:Xt,dispatchResultSchemas:Zt,NotificationMetaSchema:Qt,SubscriptionsAcknowledgedNotificationSchema:$t,CancelledNotificationParamsSchema:en,CancelledNotificationSchema:tn,notificationSchemas2026:nn,JSONRPCResultResponseSchema:rn(rt),CallToolResultResponseSchema:rn(U([at,kt])),ListToolsResultResponseSchema:rn(ot),ListPromptsResultResponseSchema:rn(st),GetPromptResultResponseSchema:rn(U([ct,kt])),ListResourcesResultResponseSchema:rn(lt),ListResourceTemplatesResultResponseSchema:rn(ut),ReadResourceResultResponseSchema:rn(U([dt,kt])),CompleteResultResponseSchema:rn(ft),DiscoverResultResponseSchema:rn(mt)}}let ka;function Aa(){return ka??=Oa()}const ja=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Ma(e){return ja.includes(e)}const Na=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Pa(e,t){if(t===void 0)return e;let n=e[Na];if(n===void 0)return{...e,[Na]:t};let r={},i=n.ttlMs??t.ttlMs;i!==void 0&&(r.ttlMs=i);let a=n.cacheScope??t.cacheScope;return a!==void 0&&(r.cacheScope=a),{...e,[Na]:r}}function Fa(e){return e[Na]}function Ia(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function La(e){return e===`public`||e===`private`}function Ra(e,t){if(e.ttlMs!==void 0&&!Ia(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!La(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}let Y=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({});var X=class e extends Error{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Wi(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Wi(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Ui(this,new.target)}static fromError(t,n,r){if(t===Y.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Ba(e.elicitations,n)}if(t===Y.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Va({supported:e.supported,requested:e.requested},n)}if(t===Y.InvalidParams||t===Y.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===Y.ResourceNotFound||Object.keys(e).length===1))return new za(e.uri,n)}if(t===Y.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Ha({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},za=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(Y.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Ba=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Y.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Va=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Y.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Ha=class extends X{static{Object.defineProperty(this,`mcpBrand`,{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(Y.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};const Ua=[`tools/call`,`prompts/get`,`resources/read`];function Wa(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||Ua.includes(e))return t;throw new X(Y.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Ga(e,t){let n=Fa(t);if(t.resultType!==`complete`||!Ma(e))return n===void 0?t:Xa(t);let r=t,i=Ia(r.ttlMs)?r.ttlMs:Ja(n),a=La(r.cacheScope)?r.cacheScope:Ya(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Na],o}function Ka(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qa(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[cn]:t}}:!Ka(n)||n[cn]!==void 0?e:{...e,_meta:{...n,[cn]:t}}}function Ja(e){return e!==void 0&&Ia(e.ttlMs)?e.ttlMs:0}function Ya(e){return e!==void 0&&La(e.cacheScope)?e.cacheScope:`private`}function Xa(e){let t={...e};return delete t[Na],t}const Za=[`elicitation/create`,`sampling/createMessage`,`roots/list`];let Qa;function $a(){if(Qa)return Qa;let e=Aa();return Qa={request:{"elicitation/create":z({method:I(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":z({method:I(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":z({method:I(`roots/list`),params:L({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Qa}function eo(e){return Za.includes(e)}function to(e){return eo(e)?$a().request[e]:void 0}function no(e){return eo(e)?$a().response[e]:void 0}const ro={"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},io={"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 ao(e){return Object.prototype.hasOwnProperty.call(ro,e)}function oo(e){return Object.prototype.hasOwnProperty.call(io,e)}function so(e){return Object.prototype.hasOwnProperty.call(ro,e)}function co(e){return ao(e)?Aa().dispatchRequestSchemas[e]:void 0}function lo(e){return so(e)?Aa().dispatchResultSchemas[e]:void 0}function uo(e){return oo(e)?Aa().notificationSchemas2026[e]:void 0}function fo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function po(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}const mo={ok:!1,reason:`not-in-era`},ho=[Ot,p];function go(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>fo(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!fo(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(fo(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}const _o={era:`2026-07-28`,hasRequestMethod:ao,hasNotificationMethod:oo,hasInputRequestMethod:e=>to(e)!==void 0,validateRequest:(e,t)=>po(co(e),t),validateResult:(e,t)=>po(lo(e),t),validateNotification:(e,t)=>po(uo(e),t),validateInputRequest:(e,t)=>po(to(e),t),validateInputResponse:(e,t)=>po(no(e),t),samplingResultVariant:()=>mo,outboundEnvelope(e){return{[Ot]:e.protocolVersion,[m]:e.clientInfo,[p]:e.clientCapabilities,...e.logLevel!==void 0&&{[Je]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of ho)n in e||t.push({key:n,problem:`missing`});let n=Aa().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;if(n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`))continue;t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>ea(e),inputRequestSchema:to,decodeResult(e,t){if(!fo(t))return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=fo(n)?n:{},i=t.requestState;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i}}}if(n!==`complete`)return{kind:`invalid`,error:new J(q.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=yo(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new J(q.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return qa(Ga(e,Wa(e,go(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=Aa().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}};let vo;function yo(){if(vo)return vo;let e=Aa();return vo={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},vo}const bo=`2026-07-28`;function xo(e){return e!==void 0&&Zi(e)?_o:Da}function So(e){return e.revision===void 0?e.era===`modern`?_o.era:Da.era:xo(e.revision).era}function Co(e){return To.some(t=>t.hasRequestMethod(e))}function wo(e){return To.some(t=>t.hasNotificationMethod(e))}const To=[Da,_o];function Eo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Do(e){if(!Eo(e))return;let t=e._meta;return Eo(t)?t:void 0}function Oo(e){let t=Do(e);return t!==void 0&&Ot in t}function ko(e){let t=Do(e)?.[Ot];return typeof t==`string`?t:void 0}function Ao(e){return xo(bo).validateEnvelopeMeta(e)}var jo=Ni({AnnotationsSchema:()=>s,AudioContentSchema:()=>c,BaseMetadataSchema:()=>l,BaseRequestParamsSchema:()=>u,BlobResourceContentsSchema:()=>d,BooleanSchemaSchema:()=>f,CallToolRequestParamsSchema:()=>h,CallToolRequestSchema:()=>g,CallToolResultSchema:()=>_,CancelTaskRequestSchema:()=>v,CancelTaskResultSchema:()=>y,CancelledNotificationParamsSchema:()=>b,CancelledNotificationSchema:()=>x,ClientCapabilitiesSchema:()=>S,ClientNotificationSchema:()=>C,ClientRequestSchema:()=>ee,ClientResultSchema:()=>te,ClientTasksCapabilitySchema:()=>ne,CompatibilityCallToolResultSchema:()=>w,CompleteRequestParamsSchema:()=>re,CompleteRequestSchema:()=>T,CompleteResultSchema:()=>ie,ContentBlockSchema:()=>ae,CreateMessageRequestParamsSchema:()=>oe,CreateMessageRequestSchema:()=>se,CreateMessageResultSchema:()=>ce,CreateMessageResultWithToolsSchema:()=>le,CreateTaskResultSchema:()=>E,CursorSchema:()=>D,DiscoverRequestSchema:()=>de,DiscoverResultSchema:()=>fe,ElicitRequestFormParamsSchema:()=>pe,ElicitRequestParamsSchema:()=>O,ElicitRequestSchema:()=>me,ElicitRequestURLParamsSchema:()=>he,ElicitResultSchema:()=>ge,ElicitationCompleteNotificationParamsSchema:()=>_e,ElicitationCompleteNotificationSchema:()=>ve,EmbeddedResourceSchema:()=>ye,EmptyResultSchema:()=>be,EnumSchemaSchema:()=>xe,GetPromptRequestParamsSchema:()=>Se,GetPromptRequestSchema:()=>Ce,GetPromptResultSchema:()=>we,GetTaskPayloadRequestSchema:()=>Te,GetTaskPayloadResultSchema:()=>Ee,GetTaskRequestSchema:()=>De,GetTaskResultSchema:()=>Oe,IconSchema:()=>ke,IconsSchema:()=>Ae,ImageContentSchema:()=>Me,ImplementationSchema:()=>Ne,InitializeRequestParamsSchema:()=>Pe,InitializeRequestSchema:()=>Fe,InitializeResultSchema:()=>Ie,InitializedNotificationSchema:()=>Le,JSONArraySchema:()=>Re,JSONObjectSchema:()=>ze,JSONRPCErrorResponseSchema:()=>Be,JSONRPCMessageSchema:()=>Ve,JSONRPCNotificationSchema:()=>He,JSONRPCRequestSchema:()=>Ue,JSONRPCResponseSchema:()=>We,JSONRPCResultResponseSchema:()=>Ge,JSONValueSchema:()=>Ke,LegacyTitledEnumSchemaSchema:()=>Ye,ListChangedOptionsBaseSchema:()=>Xe,ListPromptsRequestSchema:()=>Ze,ListPromptsResultSchema:()=>Qe,ListResourceTemplatesRequestSchema:()=>$e,ListResourceTemplatesResultSchema:()=>et,ListResourcesRequestSchema:()=>tt,ListResourcesResultSchema:()=>nt,ListRootsRequestSchema:()=>k,ListRootsResultSchema:()=>rt,ListTasksRequestSchema:()=>it,ListTasksResultSchema:()=>at,ListToolsRequestSchema:()=>ot,ListToolsResultSchema:()=>st,LoggingLevelSchema:()=>ct,LoggingMessageNotificationParamsSchema:()=>lt,LoggingMessageNotificationSchema:()=>ut,ModelHintSchema:()=>dt,ModelPreferencesSchema:()=>ft,MultiSelectEnumSchemaSchema:()=>pt,NotificationSchema:()=>mt,NotificationsParamsSchema:()=>ht,NumberSchemaSchema:()=>gt,PaginatedRequestParamsSchema:()=>kt,PaginatedRequestSchema:()=>At,PaginatedResultSchema:()=>jt,PingRequestSchema:()=>Mt,PrimitiveSchemaDefinitionSchema:()=>A,ProgressNotificationParamsSchema:()=>j,ProgressNotificationSchema:()=>Nt,ProgressSchema:()=>Pt,ProgressTokenSchema:()=>Ft,PromptArgumentSchema:()=>It,PromptListChangedNotificationSchema:()=>Lt,PromptMessageSchema:()=>Rt,PromptReferenceSchema:()=>zt,PromptSchema:()=>Bt,ReadResourceRequestParamsSchema:()=>Vt,ReadResourceRequestSchema:()=>Ht,ReadResourceResultSchema:()=>Ut,RelatedTaskMetadataSchema:()=>Wt,RequestIdSchema:()=>Gt,RequestMetaSchema:()=>Kt,RequestSchema:()=>qt,ResourceContentsSchema:()=>Jt,ResourceLinkSchema:()=>Yt,ResourceListChangedNotificationSchema:()=>Xt,ResourceRequestParamsSchema:()=>M,ResourceSchema:()=>Zt,ResourceTemplateReferenceSchema:()=>Qt,ResourceTemplateSchema:()=>$t,ResourceUpdatedNotificationParamsSchema:()=>en,ResourceUpdatedNotificationSchema:()=>tn,ResultMetaObjectSchema:()=>nn,ResultSchema:()=>rn,RoleSchema:()=>an,RootSchema:()=>on,RootsListChangedNotificationSchema:()=>sn,SamplingContentSchema:()=>dn,SamplingMessageContentBlockSchema:()=>fn,SamplingMessageSchema:()=>pn,ServerCapabilitiesSchema:()=>mn,ServerNotificationSchema:()=>hn,ServerRequestSchema:()=>gn,ServerResultSchema:()=>_n,ServerTasksCapabilitySchema:()=>vn,SetLevelRequestParamsSchema:()=>yn,SetLevelRequestSchema:()=>bn,SingleSelectEnumSchemaSchema:()=>xn,StringSchemaSchema:()=>Sn,SubscribeRequestParamsSchema:()=>Cn,SubscribeRequestSchema:()=>wn,SubscriptionFilterSchema:()=>Tn,SubscriptionsAcknowledgedNotificationParamsSchema:()=>En,SubscriptionsAcknowledgedNotificationSchema:()=>Dn,SubscriptionsListenRequestParamsSchema:()=>On,SubscriptionsListenRequestSchema:()=>kn,SubscriptionsListenResultMetaSchema:()=>An,SubscriptionsListenResultSchema:()=>jn,TaskAugmentedRequestParamsSchema:()=>Mn,TaskCreationParamsSchema:()=>Nn,TaskMetadataSchema:()=>Pn,TaskSchema:()=>Fn,TaskStatusNotificationParamsSchema:()=>In,TaskStatusNotificationSchema:()=>Ln,TaskStatusSchema:()=>Rn,TextContentSchema:()=>zn,TextResourceContentsSchema:()=>Bn,TitledMultiSelectEnumSchemaSchema:()=>Vn,TitledSingleSelectEnumSchemaSchema:()=>Hn,ToolAnnotationsSchema:()=>Un,ToolChoiceSchema:()=>Wn,ToolExecutionSchema:()=>Gn,ToolListChangedNotificationSchema:()=>Kn,ToolResultContentSchema:()=>qn,ToolSchema:()=>Jn,ToolUseContentSchema:()=>Yn,UnsubscribeRequestParamsSchema:()=>Xn,UnsubscribeRequestSchema:()=>Zn,UntitledMultiSelectEnumSchemaSchema:()=>Qn,UntitledSingleSelectEnumSchemaSchema:()=>$n});const Z=e=>Ue.safeParse(e).success,Mo=e=>He.safeParse(e).success,No=e=>Ge.safeParse(e).success,Po=e=>Be.safeParse(e).success,Fo=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`,Io=e=>Fe.safeParse(e).success;function Lo(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function Ro(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}const zo=`x-mcp-header`,Bo=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Vo=new Set([`string`,`integer`,`boolean`,`number`]);function Ho(e){let t=[],n=new Map,r=(e,i,a)=>{if(typeof e!=`object`||!e)return;let o=e;if(zo in o){if(!a||i.length===0)return`${Go(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let e=o[zo];if(typeof e!=`string`||e.length===0)return`${Go(i)}: x-mcp-header MUST be a non-empty string`;if(!Bo.test(e))return`${Go(i)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let r=typeof o.type==`string`?o.type:void 0;if(r===void 0||!Vo.has(r))return`${Go(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${r??`<none>`}`;let s=e.toLowerCase(),c=n.get(s);if(c!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${c}')`;n.set(s,e),t.push({path:i,headerName:e,type:r})}let s=o.properties;if(typeof s==`object`&&s)for(let[e,t]of Object.entries(s)){let n=r(t,[...i,e],a);if(n!==void 0)return n}for(let e of Uo){let t=o[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Wo.has(e)?Object.values(t):[t];for(let t of n){let n=r(t,[...i,`<${e}>`],!1);if(n!==void 0)return n}}},i=r(e,[],!0);return i===void 0?{valid:!0,declarations:t}:{valid:!1,reason:i}}const Uo=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Wo=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Go(e){return e.length===0?`<root>`:e.join(`.`)}Y.InvalidRequest,Y.UnsupportedProtocolVersion,Y.InvalidParams,Y.MethodNotFound,Y.InvalidParams,Y.MissingRequiredClientCapability,Y.ParseError,Y.InvalidRequest,Y.MethodNotFound,Y.UnsupportedProtocolVersion,Y.MissingRequiredClientCapability;function Ko(e,t,n,r,i){return{kind:`reject`,rung:e,cell:t,httpStatus:n,code:r.code,message:r.message,...r.data!==void 0&&{data:r.data},settled:i}}function qo(e){if(!Oo(e))return!1;let t=ko(e);if(t===void 0||!Zi(t))return!1;let n=Do(e);return n!==void 0&&Ao(n).length===0}function Jo(e,t){switch(e.reason){case`http-method`:return Ko(`http-method`,`modern-only-method-not-allowed`,405,new X(-32e3,`Method not allowed.`),!0);case`batch`:return Ko(`jsonrpc-shape`,`modern-only-batch-not-supported`,400,new X(Y.InvalidRequest,`Bad Request: JSON-RPC batches are not supported by this endpoint`),!0);case`response`:return Ko(`jsonrpc-shape`,`modern-only-response-post`,400,new X(Y.InvalidRequest,`Bad Request: JSON-RPC responses cannot be posted to this endpoint`),!0);case`notification`:return;case`initialize`:case`no-claim`:{let n=e.requestedVersion;return Ko(`era-classification`,`modern-only-missing-envelope`,400,n===void 0?new X(Y.UnsupportedProtocolVersion,`Unsupported protocol version: the request did not name a protocol version`,{supported:[...t]}):new Va({supported:[...t],requested:n}),!0)}}}function Yo(e,t){return cr(e,t)}function Xo(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function Zo(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}let Qo=!1;const $o=`draft-2020-12`;function es(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:$o});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);Qo||(Qo=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=lr(e,{target:$o,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&ts(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function ts(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||ts(e)))}return!1}function ns(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function rs(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>ns(e)).join(`, `)}:{success:!0,data:n.value}}function os(e){let t=lr(e,{target:$o,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}const ss=/\\\.\\d\{(\d+)\}/;function cs(e){let t=ss.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>nr({local:e,offset:t,precision:n}))))}function ls(e,t){let n;switch(e){case`email`:n=[ir()];break;case`uri`:n=[ur()];break;case`date`:n=[tr()];break;case`date-time`:n=cs(t);break}return new Set(n.map(e=>os(e)).filter(e=>e!==void 0))}function us(e,t,n){return n===`zod`?ls(e,t).has(t):!0}function ds(e){let t=es(e,`input`),n=t.properties||{},r=t.required||[];return Object.entries(n).map(([e,t])=>({name:e,description:t?.description,required:r.includes(e)}))}function fs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ps(e){try{return es(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new X(Y.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}const ms=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function hs(e){return ms.has(e)||e.startsWith(`x-`)}const gs=new Set([`$schema`,...Object.keys(pe.shape.requestedSchema.shape)]),_s={string:Xo([Sn,$n,Hn,Ye]),number:Xo([gt]),integer:Xo([gt]),boolean:Xo([f]),array:Xo([Qn,Vn])},vs=new Set(Sn.shape.format.unwrap().options);function ys(e,t,n,r){if(!fs(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(_s,e.type)?_s[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||hs(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?vs.has(e.format)?(typeof s!=`string`||!us(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function bs(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&fs(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,ys(n,`properties.${e}`,t,r)])):gs.has(i)?n[i]=a:hs(i)||r.push(i);if(r.length>0)throw new X(Y.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function xs(e,t){if(!fs(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!Yo(A,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function Ss(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>Ss(e,t[r],`${n}[${r}]`)):!fs(e)||!fs(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?Ss(r,t[e],i):hs(e)?[]:[i]})}function Cs(e){if(!Zo(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=bs(ps(e.requestedSchema),t),r=Yo(pe.shape.requestedSchema,n);if(!r.success)throw new X(Y.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${xs(n,r.error.message)}`);let i=Ss(n,r.data);if(i.length>0)throw new X(Y.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new X(Y.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function ws(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(ws,{elicit(e){try{return{method:`elicitation/create`,params:Cs(e)}}catch(e){throw e instanceof X?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});function Ts(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Es(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof J?t.reason:new J(q.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof J?t.reason:new J(q.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function Ds(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}const Os=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),ks={IdJagTokenExchangeResponseSchema:je,OAuthClientInformationFullSchema:_t,OAuthClientInformationSchema:vt,OAuthClientMetadataSchema:yt,OAuthClientRegistrationErrorSchema:bt,OAuthErrorResponseSchema:xt,OAuthMetadataSchema:St,OAuthProtectedResourceMetadataSchema:Ct,OAuthTokenRevocationRequestSchema:wt,OAuthTokensSchema:Tt,OpenIdProviderDiscoveryMetadataSchema:Et,OpenIdProviderMetadataSchema:Dt},As={},js={};function Ms(e,t){let n=e.slice(0,-6);As[n]=t,js[n]=e=>t.safeParse(e).success}for(let e of Os)Ms(e,jo[e]);for(let[e,t]of Object.entries(ks))Ms(e,t);Object.freeze(As),Object.freeze(js);function Ns(e){switch(e){case`initialize`:case`notifications/initialized`:return xo(void 0);case`server/discover`:return xo(bo);default:return}}const Ps=[Ot,m,p,Je],Fs=[`inputResponses`,`requestState`];function Is(e,t){let n=e.params;if(!Ws(n))return{message:e,lifted:{}};let r=n._meta,i=Ws(r)?Ps.filter(e=>e in r):[],a=t===`request`?Fs.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&Ws(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function Ls(e,t){let n=e.validateResult(t,void 0);if(!(!n.ok&&n.reason===`not-in-era`))return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function Rs(e){return()=>e}const zs=Rs(void 0);function Bs(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:Rs(t)}}}let Vs;function Hs(e,t){Vs(e,t)}var Us=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{Vs=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??un,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new J(q.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new J(q.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),No(e)||Po(e)?this._onresponse(e):Z(e)?this._onrequest(e,t):Mo(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new J(q.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=Is(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=So(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(wo(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;i===void 0&&a===void 0||Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=Is(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=So(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(Y.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(Co(n.method)&&!i.hasRequestMethod(n.method)){o(Y.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Y.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(Y.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:qs(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?zs:Rs(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Zo(t))return u(e,t,n);let i=Ls(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(Y.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:Y.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),No(e)?n(e):n(X.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Zo(t))return this._requestWithSchemaViaCodec(r,e,t,n);let i=Ls(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return xo(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=Ns(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Co(t)&&!e.hasRequestMethod(t))throw new J(q.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof J?e:new J(q.RequestTimeout,String(e))}let m=e.era===bo&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof J?e:new J(q.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(Js(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;rs(n,o).then(e=>{e.success?d(e.data):f(new J(q.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new J(q.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new J(q.NotConnected,`Not connected`);if(wo(t.method)&&!e.hasNotificationMethod(t.method))throw new J(q.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!Co(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new X(Y.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await rs(t.params,{...r.params});if(!a.success)throw new X(Y.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!wo(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new X(Y.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await rs(t.params,{...r.params});if(!i.success)throw new X(Y.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Ws(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gs(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=Ws(a)&&Ws(i)?{...a,...i}:i}return n}function Ks(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qs(e){let t={},n=[];if(!Ks(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!Ks(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function Js(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState}}}var Ys=Fi(K((exports=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;exports.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),1);function Xs(e){if(e)try{return Ys.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function Zs(e){return e===`application/json`?!0:Xs(e)===`application/json`}var Qs=class{_buffer;_maxBufferSize;constructor(e){this._maxBufferSize=e?.maxBufferSize??10485760}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){for(;this._buffer;){let e=this._buffer.indexOf(`
4
+ `);if(e===-1)return null;let t=this._buffer.toString(`utf8`,0,e).replace(/\r$/,``);this._buffer=this._buffer.subarray(e+1);try{return $s(t)}catch(e){if(e instanceof SyntaxError)continue;throw e}}return null}clear(){this._buffer=void 0}};function $s(e){return Ve.parse(JSON.parse(e))}function ec(e){return JSON.stringify(e)+`
5
+ `}const tc=/^[A-Za-z0-9._-]{1,128}$/;function nc(e){let t=[];if(e.length===0)return{isValid:!1,warnings:[`Tool name cannot be empty`]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(` `)&&t.push(`Tool name contains spaces, which may cause parsing issues`),e.includes(`,`)&&t.push(`Tool name contains commas, which may cause parsing issues`),(e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`Tool name starts or ends with a dash, which may cause parsing issues in some contexts`),(e.startsWith(`.`)||e.endsWith(`.`))&&t.push(`Tool name starts or ends with a dot, which may cause parsing issues in some contexts`),!tc.test(e)){let n=[...e].filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.map(e=>`"${e}"`).join(`, `)}`,`Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)`),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function rc(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);console.warn(`Tool registration will proceed, but this may cause compatibility issues.`),console.warn(`Consider updating the tool name to conform to the MCP tool naming standard.`),console.warn(`See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.`)}}function ic(e){let t=nc(e);return rc(e,t.warnings),t.isValid}function ac(e){return typeof e==`object`&&!!e&&`_zod`in e}function oc(e){return typeof e==`object`&&!!e&&!(`_zod`in e)&&`_def`in e&&typeof e._def?.typeName==`string`}function sc(e){if(typeof e!=`object`||!e||Zo(e))return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.values(e).every(e=>ac(e))}function cc(e){if(e!==void 0){if(sc(e))return z(e);if(typeof e==`object`&&e&&!Zo(e)&&Object.values(e).some(e=>oc(e)))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!Zo(e))throw TypeError(`inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).`);return e}}var lc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.regexpCode=exports.getEsmExportName=exports.getProperty=exports.safeStringify=exports.stringify=exports.strConcat=exports.addCodeArg=exports.str=exports._=exports.nil=exports._Code=exports.Name=exports.IDENTIFIER=exports._CodeOrName=void 0;var t=class{};exports._CodeOrName=t,exports.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!exports.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};exports.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};exports._Code=r,exports.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}exports._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}exports.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}exports.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}exports.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}exports.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}exports.safeStringify=p;function m(t){return typeof t==`string`&&exports.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}exports.getProperty=m;function h(t){if(typeof t==`string`&&exports.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}exports.getEsmExportName=h;function g(e){return new r(e.toString())}exports.regexpCode=g})),uc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.ValueScope=exports.ValueScopeName=exports.Scope=exports.varKinds=exports.UsedValueState=void 0;let t=lc();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(exports.UsedValueState=r={})),exports.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};exports.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};exports.ValueScopeName=a;let o=(0,t._)`\n`;exports.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?exports.varKinds.var:exports.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Q=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.or=exports.and=exports.not=exports.CodeGen=exports.operators=exports.varKinds=exports.ValueScopeName=exports.ValueScope=exports.Scope=exports.Name=exports.regexpCode=exports.stringify=exports.getProperty=exports.nil=exports.strConcat=exports.str=exports._=void 0;let t=lc(),n=uc();var r=lc();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(exports,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(exports,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(exports,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=uc();Object.defineProperty(exports,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(exports,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(exports,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(exports,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),exports.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=T(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=T(this.rhs,e,n),this}get names(){return re(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=T(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(ie(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>w(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ae(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=T(this.condition,e,t),this}get names(){let e=super.names;return re(e,this.condition),this.else&&w(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=T(this.iteration,e,t),this}get names(){return w(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return re(re(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=T(this.iterable,e,t),this}get names(){return w(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var ee=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&w(e,this.catch.names),this.finally&&w(e,this.finally.names),e}},te=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};te.kind=`catch`;var ne=class extends m{render(e){return`finally`+super.render(e)}};ne.kind=`finally`,exports.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
6
+ `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,exports.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new ee;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new te(e),t(e)}return n&&(this._currNode=r.finally=new ne,this.code(n)),this._endBlockNode(te,ne)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function w(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function re(e,n){return n instanceof t._CodeOrName?w(e,n.names):e}function T(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function ie(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ae(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${D(e)}`}exports.not=ae;let oe=E(exports.operators.AND);function se(...e){return e.reduce(oe)}exports.and=se;let ce=E(exports.operators.OR);function le(...e){return e.reduce(ce)}exports.or=le;function E(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${D(n)} ${e} ${D(r)}`}function D(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),$=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.checkStrictMode=exports.getErrorPath=exports.Type=exports.useFunc=exports.setEvaluated=exports.evaluatedPropsToName=exports.mergeEvaluated=exports.eachItem=exports.unescapeJsonPointer=exports.escapeJsonPointer=exports.escapeFragment=exports.unescapeFragment=exports.schemaRefOrVal=exports.schemaHasRulesButRef=exports.schemaHasRules=exports.checkUnknownRules=exports.alwaysValidSchema=exports.toHash=void 0;let t=Q(),n=lc();function r(e){let t={};for(let n of e)t[n]=!0;return t}exports.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}exports.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}exports.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}exports.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}exports.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}exports.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}exports.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}exports.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}exports.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}exports.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}exports.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}exports.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}exports.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}exports.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}exports.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(exports.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}exports.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}exports.checkStrictMode=x})),dc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),fc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.extendErrors=exports.resetErrorsCount=exports.reportExtraError=exports.reportError=exports.keyword$DataError=exports.keywordError=void 0;let t=Q(),n=$(),r=dc();exports.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},exports.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=exports.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}exports.reportError=i;function a(t,n=exports.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}exports.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}exports.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}exports.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),pc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.boolOrEmptySchema=exports.topBoolOrEmptySchema=void 0;let t=fc(),n=Q(),r=dc(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}exports.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}exports.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),mc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.getRules=exports.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}exports.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}exports.getRules=r})),hc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.shouldUseRule=exports.shouldUseGroup=exports.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}exports.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}exports.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}exports.shouldUseRule=r})),gc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.reportTypeError=exports.checkDataTypes=exports.checkDataType=exports.coerceAndCheckDataType=exports.getJSONTypes=exports.getSchemaTypes=exports.DataType=void 0;let t=mc(),n=hc(),r=fc(),i=Q(),a=$();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(exports.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}exports.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}exports.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}exports.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
6
7
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
7
8
  || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
8
- || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}exports.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;for(let e in s.number&&delete s.integer,s)o=(0,i.and)(o,m(e,t,n,r));return o}exports.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}exports.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),cc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.assignDefaults=void 0;let t=Q(),n=$();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}exports.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),lc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateUnion=exports.validateArray=exports.usePattern=exports.callValidateCode=exports.schemaProperties=exports.allSchemaProperties=exports.noPropertyInData=exports.propertyInData=exports.isOwnProperty=exports.hasPropFunc=exports.reportMissingProp=exports.checkMissingProp=exports.checkReportMissingProp=void 0;let t=Q(),n=$(),r=nc(),i=$();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}exports.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}exports.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}exports.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}exports.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}exports.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}exports.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}exports.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}exports.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}exports.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}exports.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}exports.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}exports.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}exports.validateUnion=v})),uc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateKeywordUsage=exports.validSchemaType=exports.funcKeywordCode=exports.macroKeywordCode=void 0;let t=Q(),n=nc(),r=lc(),i=rc();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}exports.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}exports.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}exports.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}exports.validateKeywordUsage=f})),dc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.extendSubschemaMode=exports.extendSubschemaData=exports.getSubschema=void 0;let t=Q(),n=$();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}exports.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}exports.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}exports.extendSubschemaMode=a})),fc=K(((exports,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),pc=K(((exports,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),mc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.getSchemaRefs=exports.resolveUrl=exports.normalizeId=exports._getFullPath=exports.getFullPath=exports.inlineRef=void 0;let t=$(),n=fc(),r=pc(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}exports.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e){if(r===`$ref`)return 1/0;if(n++,i.has(r))continue;if(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)return 1/0}return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}exports.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}exports._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}exports.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}exports.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}exports.getSchemaRefs=h})),hc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.getData=exports.KeywordCxt=exports.validateFunctionCode=void 0;let t=ic(),n=sc(),r=oc(),i=sc(),a=cc(),o=uc(),s=dc(),c=Q(),l=nc(),u=mc(),d=$(),f=rc();function p(e){if(S(e)&&(ee(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}exports.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&ie(e),w(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),te(e),ae(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(ee(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&ie(e),re(e),T(e);let a=r.const(`_errs`,l.default.errors);te(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function ee(e){(0,d.checkUnknownRules)(e),ne(e)}function te(e,t){if(e.opts.jtd)return se(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);se(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function ne(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function w(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function re(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function T(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function ie({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ae(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&oe(e),t.return((0,c._)`${l.default.errors} === 0`))}function oe({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function se(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>he(e,`$ref`,h.all.$ref.definition));return}p.jtd||le(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),ce(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ce(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ce(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&he(e,n.keyword,n.definition,t.type)})}function le(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(E(e,t),e.opts.allowUnionTypes||D(e,t),ue(e,e.dataTypes))}function E(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{fe(e.dataTypes,t)||O(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),pe(e,t)}}function D(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&O(e,`use allowUnionTypes to allow union type keyword`)}function ue(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>de(t,e))&&O(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function de(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function fe(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function pe(e,t){let n=[];for(let r of e.dataTypes)fe(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function O(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var me=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,ve(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};exports.KeywordCxt=me;function he(e,t,n,r){let i=new me(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let ge=/^\/(?:[^~]|~0|~1)*$/,_e=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ve(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!ge.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=_e.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}exports.getData=ve})),gc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),_c=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=mc();exports.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),vc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.resolveSchema=exports.getCompilingSchema=exports.resolveRef=exports.compileSchema=exports.SchemaEnv=void 0;let t=Q(),n=gc(),r=nc(),i=mc(),a=$(),o=hc();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};exports.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}exports.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}exports.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}exports.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}exports.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),yc=K(((exports,t)=>{t.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}})),bc=K(((exports,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=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 i(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let a=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(e){return e.length=0,!0}function s(e,t,n){if(e.length){let r=i(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function c(e){let t=0,n={error:!1,address:``,zone:``},r=[],a=[],c=!1,l=!1,u=s;for(let i=0;i<e.length;i++){let s=e[i];if(!(s===`[`||s===`]`))if(s===`:`){if(c===!0&&(l=!0),!u(a,r,n))break;if(++t>7){n.error=!0;break}i>0&&e[i-1]===`:`&&(c=!0),r.push(`:`);continue}else if(s===`%`){if(!u(a,r,n))break;u=o}else{a.push(s);continue}}return a.length&&(u===o?n.zone=a.join(``):l?r.push(a.join(``)):r.push(i(a))),n.address=r.join(``),n}function l(e){if(u(e,`:`)<2)return{host:e,isIPV6:!1};let t=c(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function u(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function d(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}function f(e,t){let n=t===!0?unescape:escape;return e.scheme!==void 0&&(e.scheme=n(e.scheme)),e.userinfo!==void 0&&(e.userinfo=n(e.userinfo)),e.host!==void 0&&(e.host=n(e.host)),e.path!==void 0&&(e.path=n(e.path)),e.query!==void 0&&(e.query=n(e.query)),e.fragment!==void 0&&(e.fragment=n(e.fragment)),e}function p(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let t=l(n);n=t.isIPV6===!0?`[${t.escapedHost}]`:e.host}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:a,recomposeAuthority:p,normalizeComponentEncoding:f,removeDotSegments:d,isIPv4:r,isUUID:n,normalizeIPv6:l,stringArrayToHexStripped:i}})),xc=K(((exports,t)=>{let{isUUID:n}=bc(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=S(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=S(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},y={scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},b={scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0},x={http:h,https:g,ws:_,wss:v,urn:y,"urn:uuid":b};Object.setPrototypeOf(x,null);function S(e){return e&&(x[e]||x[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:x,isValidSchemeName:a,getSchemeHandler:S}})),Sc=K(((exports,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizeComponentEncoding:a,isIPv4:o,nonSimpleDomain:s}=bc(),{SCHEMES:c,getSchemeHandler:l}=xc();function u(e,t){return typeof e==`string`?e=m(g(e,t),t):typeof e==`object`&&(e=g(m(e,t),t)),e}function d(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=f(g(e,r),g(t,r),r,!0);return r.skipEscape=!0,m(i,r)}function f(e,t,n,i){let a={};return i||(e=g(m(e,n),n),t=g(m(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function p(e,t,n){return typeof e==`string`?(e=unescape(e),e=m(a(g(e,n),!0),{...n,skipEscape:!0})):typeof e==`object`&&(e=m(a(e,!0),{...n,skipEscape:!0})),typeof t==`string`?(t=unescape(t),t=m(a(g(t,n),!0),{...n,skipEscape:!0})):typeof t==`object`&&(t=m(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function m(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},a=Object.assign({},t),o=[],s=l(a.scheme||n.scheme);s&&s.serialize&&s.serialize(n,a),n.path!==void 0&&(a.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),a.reference!==`suffix`&&n.scheme&&o.push(n.scheme,`:`);let c=i(n);if(c!==void 0&&(a.reference!==`suffix`&&o.push(`//`),o.push(c),n.path&&n.path[0]!==`/`&&o.push(`/`)),n.path!==void 0){let e=n.path;!a.absolutePath&&(!s||!s.absolutePath)&&(e=r(e)),c===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),o.push(e)}return n.query!==void 0&&o.push(`?`,n.query),n.fragment!==void 0&&o.push(`#`,n.fragment),o.join(``)}let h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function g(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let c=e.match(h);if(c){if(i.scheme=c[1],i.userinfo=c[3],i.host=c[4],i.port=parseInt(c[5],10),i.path=c[6]||``,i.query=c[7],i.fragment=c[8],isNaN(i.port)&&(i.port=c[5]),i.host)if(o(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),a=e.isIPV6}else a=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let t=l(r.scheme||i.scheme);if(!r.unicodeSupport&&(!t||!t.unicodeSupport)&&i.host&&(r.domainHost||t&&t.domainHost)&&a===!1&&s(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}(!t||t&&!t.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=unescape(i.host))),i.path&&=escape(unescape(i.path)),i.fragment&&=encodeURI(decodeURIComponent(i.fragment))),t&&t.parse&&t.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return i}let _={SCHEMES:c,normalize:u,resolve:d,resolveComponent:f,equal:p,serialize:m,parse:g};t.exports=_,t.exports.default=_,t.exports.fastUri=_})),Cc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Sc();t.code=`require("ajv/dist/runtime/uri").default`,exports.default=t})),wc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=void 0;var t=hc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=gc(),i=_c(),a=ac(),o=vc(),s=Q(),c=mc(),l=sc(),u=$(),d=yc(),f=Cc(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={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.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=w(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=te.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&ee.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(T.call(this,n,t),!t)return(0,u.eachItem)(n,e=>ie.call(this,e)),this;oe.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>ie.call(this,e,r):e=>r.type.forEach(t=>ie.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=ce(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,exports.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function ee(e){if(Array.isArray(e)){this.addVocabulary(e);return}for(let t in this.logger.warn(`keywords option as map is deprecated, pass array`),e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function te(){let e={...this.opts};for(let t of m)delete e[t];return e}let ne={log(){},warn(){},error(){}};function w(e){if(e===!1)return ne;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let re=/^[a-z_$][a-z0-9_$:-]*$/i;function T(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!re.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function ie(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ae.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ae(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function oe(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ce(t)),e.validateSchema=this.compile(t,!0))}let se={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ce(e){return{anyOf:[e,se]}}})),Tc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Ec=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.callRef=exports.getValidate=void 0;let t=_c(),n=lc(),r=Q(),i=nc(),a=vc(),o=$(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}exports.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}exports.callRef=l,exports.default=s})),Dc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Tc(),n=Ec();exports.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Oc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};exports.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),kc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Ac=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}exports.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),jc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=Ac();exports.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Mc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=lc(),n=$(),r=Q();exports.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),Nc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Pc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=lc(),n=Q(),r=$();exports.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),Fc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),Ic=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=fc();t.code=`require("ajv/dist/runtime/equal").default`,exports.default=t})),Lc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=sc(),n=Q(),r=$(),i=Ic();exports.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),Rc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=Ic();exports.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),zc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=Ic();exports.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),Bc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Oc(),n=kc(),r=jc(),i=Mc(),a=Nc(),o=Pc(),s=Fc(),c=Lc(),l=Rc(),u=zc();exports.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),Vc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateAdditionalItems=void 0;let t=Q(),n=$(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}exports.validateAdditionalItems=i,exports.default=r})),Hc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateTuple=void 0;let t=Q(),n=$(),r=lc(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}exports.validateTuple=a,exports.default=i})),Uc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Hc();exports.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Wc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=lc(),i=Vc();exports.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),Gc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),Kc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateSchemaDeps=exports.validatePropertyDeps=exports.error=void 0;let t=Q(),n=$(),r=lc();exports.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
9
+ || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}exports.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;for(let e in s.number&&delete s.integer,s)o=(0,i.and)(o,m(e,t,n,r));return o}exports.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}exports.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),_c=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.assignDefaults=void 0;let t=Q(),n=$();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}exports.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),vc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateUnion=exports.validateArray=exports.usePattern=exports.callValidateCode=exports.schemaProperties=exports.allSchemaProperties=exports.noPropertyInData=exports.propertyInData=exports.isOwnProperty=exports.hasPropFunc=exports.reportMissingProp=exports.checkMissingProp=exports.checkReportMissingProp=void 0;let t=Q(),n=$(),r=dc(),i=$();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}exports.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}exports.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}exports.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}exports.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}exports.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}exports.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}exports.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}exports.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}exports.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}exports.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}exports.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}exports.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}exports.validateUnion=v})),yc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateKeywordUsage=exports.validSchemaType=exports.funcKeywordCode=exports.macroKeywordCode=void 0;let t=Q(),n=dc(),r=vc(),i=fc();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}exports.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}exports.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}exports.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}exports.validateKeywordUsage=f})),bc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.extendSubschemaMode=exports.extendSubschemaData=exports.getSubschema=void 0;let t=Q(),n=$();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}exports.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}exports.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}exports.extendSubschemaMode=a})),xc=K(((exports,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Sc=K(((exports,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Cc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.getSchemaRefs=exports.resolveUrl=exports.normalizeId=exports._getFullPath=exports.getFullPath=exports.inlineRef=void 0;let t=$(),n=xc(),r=Sc(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}exports.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e){if(r===`$ref`)return 1/0;if(n++,i.has(r))continue;if(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)return 1/0}return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}exports.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}exports._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}exports.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}exports.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}exports.getSchemaRefs=h})),wc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.getData=exports.KeywordCxt=exports.validateFunctionCode=void 0;let t=pc(),n=gc(),r=hc(),i=gc(),a=_c(),o=yc(),s=bc(),c=Q(),l=dc(),u=Cc(),d=$(),f=fc();function p(e){if(S(e)&&(ee(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}exports.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&ie(e),w(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),te(e),ae(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(ee(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&ie(e),re(e),T(e);let a=r.const(`_errs`,l.default.errors);te(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function ee(e){(0,d.checkUnknownRules)(e),ne(e)}function te(e,t){if(e.opts.jtd)return se(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);se(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function ne(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function w(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function re(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function T(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function ie({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ae(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&oe(e),t.return((0,c._)`${l.default.errors} === 0`))}function oe({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function se(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>he(e,`$ref`,h.all.$ref.definition));return}p.jtd||le(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),ce(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ce(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ce(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&he(e,n.keyword,n.definition,t.type)})}function le(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(E(e,t),e.opts.allowUnionTypes||D(e,t),ue(e,e.dataTypes))}function E(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{fe(e.dataTypes,t)||O(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),pe(e,t)}}function D(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&O(e,`use allowUnionTypes to allow union type keyword`)}function ue(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>de(t,e))&&O(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function de(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function fe(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function pe(e,t){let n=[];for(let r of e.dataTypes)fe(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function O(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var me=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,ve(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};exports.KeywordCxt=me;function he(e,t,n,r){let i=new me(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let ge=/^\/(?:[^~]|~0|~1)*$/,_e=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ve(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!ge.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=_e.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}exports.getData=ve})),Tc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Ec=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Cc();exports.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Dc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.resolveSchema=exports.getCompilingSchema=exports.resolveRef=exports.compileSchema=exports.SchemaEnv=void 0;let t=Q(),n=Tc(),r=dc(),i=Cc(),a=$(),o=wc();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};exports.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}exports.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}exports.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}exports.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}exports.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Oc=K(((exports,t)=>{t.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}})),kc=K(((exports,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=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 i(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let a=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(e){return e.length=0,!0}function s(e,t,n){if(e.length){let r=i(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function c(e){let t=0,n={error:!1,address:``,zone:``},r=[],a=[],c=!1,l=!1,u=s;for(let i=0;i<e.length;i++){let s=e[i];if(!(s===`[`||s===`]`))if(s===`:`){if(c===!0&&(l=!0),!u(a,r,n))break;if(++t>7){n.error=!0;break}i>0&&e[i-1]===`:`&&(c=!0),r.push(`:`);continue}else if(s===`%`){if(!u(a,r,n))break;u=o}else{a.push(s);continue}}return a.length&&(u===o?n.zone=a.join(``):l?r.push(a.join(``)):r.push(i(a))),n.address=r.join(``),n}function l(e){if(u(e,`:`)<2)return{host:e,isIPV6:!1};let t=c(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function u(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function d(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}function f(e,t){let n=t===!0?unescape:escape;return e.scheme!==void 0&&(e.scheme=n(e.scheme)),e.userinfo!==void 0&&(e.userinfo=n(e.userinfo)),e.host!==void 0&&(e.host=n(e.host)),e.path!==void 0&&(e.path=n(e.path)),e.query!==void 0&&(e.query=n(e.query)),e.fragment!==void 0&&(e.fragment=n(e.fragment)),e}function p(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let t=l(n);n=t.isIPV6===!0?`[${t.escapedHost}]`:e.host}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:a,recomposeAuthority:p,normalizeComponentEncoding:f,removeDotSegments:d,isIPv4:r,isUUID:n,normalizeIPv6:l,stringArrayToHexStripped:i}})),Ac=K(((exports,t)=>{let{isUUID:n}=kc(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=S(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=S(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},y={scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},b={scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0},x={http:h,https:g,ws:_,wss:v,urn:y,"urn:uuid":b};Object.setPrototypeOf(x,null);function S(e){return e&&(x[e]||x[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:x,isValidSchemeName:a,getSchemeHandler:S}})),jc=K(((exports,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizeComponentEncoding:a,isIPv4:o,nonSimpleDomain:s}=kc(),{SCHEMES:c,getSchemeHandler:l}=Ac();function u(e,t){return typeof e==`string`?e=m(g(e,t),t):typeof e==`object`&&(e=g(m(e,t),t)),e}function d(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=f(g(e,r),g(t,r),r,!0);return r.skipEscape=!0,m(i,r)}function f(e,t,n,i){let a={};return i||(e=g(m(e,n),n),t=g(m(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function p(e,t,n){return typeof e==`string`?(e=unescape(e),e=m(a(g(e,n),!0),{...n,skipEscape:!0})):typeof e==`object`&&(e=m(a(e,!0),{...n,skipEscape:!0})),typeof t==`string`?(t=unescape(t),t=m(a(g(t,n),!0),{...n,skipEscape:!0})):typeof t==`object`&&(t=m(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function m(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},a=Object.assign({},t),o=[],s=l(a.scheme||n.scheme);s&&s.serialize&&s.serialize(n,a),n.path!==void 0&&(a.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),a.reference!==`suffix`&&n.scheme&&o.push(n.scheme,`:`);let c=i(n);if(c!==void 0&&(a.reference!==`suffix`&&o.push(`//`),o.push(c),n.path&&n.path[0]!==`/`&&o.push(`/`)),n.path!==void 0){let e=n.path;!a.absolutePath&&(!s||!s.absolutePath)&&(e=r(e)),c===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),o.push(e)}return n.query!==void 0&&o.push(`?`,n.query),n.fragment!==void 0&&o.push(`#`,n.fragment),o.join(``)}let h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function g(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let c=e.match(h);if(c){if(i.scheme=c[1],i.userinfo=c[3],i.host=c[4],i.port=parseInt(c[5],10),i.path=c[6]||``,i.query=c[7],i.fragment=c[8],isNaN(i.port)&&(i.port=c[5]),i.host)if(o(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),a=e.isIPV6}else a=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let t=l(r.scheme||i.scheme);if(!r.unicodeSupport&&(!t||!t.unicodeSupport)&&i.host&&(r.domainHost||t&&t.domainHost)&&a===!1&&s(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}(!t||t&&!t.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=unescape(i.host))),i.path&&=escape(unescape(i.path)),i.fragment&&=encodeURI(decodeURIComponent(i.fragment))),t&&t.parse&&t.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return i}let _={SCHEMES:c,normalize:u,resolve:d,resolveComponent:f,equal:p,serialize:m,parse:g};t.exports=_,t.exports.default=_,t.exports.fastUri=_})),Mc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=jc();t.code=`require("ajv/dist/runtime/uri").default`,exports.default=t})),Nc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=void 0;var t=wc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=Tc(),i=Ec(),a=mc(),o=Dc(),s=Q(),c=Cc(),l=gc(),u=$(),d=Oc(),f=Mc(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={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.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=w(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=te.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&ee.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(T.call(this,n,t),!t)return(0,u.eachItem)(n,e=>ie.call(this,e)),this;oe.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>ie.call(this,e,r):e=>r.type.forEach(t=>ie.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=ce(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,exports.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function ee(e){if(Array.isArray(e)){this.addVocabulary(e);return}for(let t in this.logger.warn(`keywords option as map is deprecated, pass array`),e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function te(){let e={...this.opts};for(let t of m)delete e[t];return e}let ne={log(){},warn(){},error(){}};function w(e){if(e===!1)return ne;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let re=/^[a-z_$][a-z0-9_$:-]*$/i;function T(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!re.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function ie(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ae.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ae(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function oe(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ce(t)),e.validateSchema=this.compile(t,!0))}let se={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ce(e){return{anyOf:[e,se]}}})),Pc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Fc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.callRef=exports.getValidate=void 0;let t=Ec(),n=vc(),r=Q(),i=dc(),a=Dc(),o=$(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}exports.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}exports.callRef=l,exports.default=s})),Ic=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Pc(),n=Fc();exports.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Lc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};exports.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Rc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),zc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}exports.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),Bc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=zc();exports.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Vc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=vc(),n=$(),r=Q();exports.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),Hc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Uc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=vc(),n=Q(),r=$();exports.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),Wc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),Gc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=xc();t.code=`require("ajv/dist/runtime/equal").default`,exports.default=t})),Kc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=gc(),n=Q(),r=$(),i=Gc();exports.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),qc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=Gc();exports.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),Jc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=Gc();exports.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),Yc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Lc(),n=Rc(),r=Bc(),i=Vc(),a=Hc(),o=Uc(),s=Wc(),c=Kc(),l=qc(),u=Jc();exports.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),Xc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateAdditionalItems=void 0;let t=Q(),n=$(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}exports.validateAdditionalItems=i,exports.default=r})),Zc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateTuple=void 0;let t=Q(),n=$(),r=vc(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}exports.validateTuple=a,exports.default=i})),Qc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Zc();exports.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),$c=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=vc(),i=Xc();exports.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),el=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),tl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.validateSchemaDeps=exports.validatePropertyDeps=exports.error=void 0;let t=Q(),n=$(),r=vc();exports.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
9
10
  missingProperty: ${i},
10
11
  depsCount: ${n},
11
- deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:exports.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}exports.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t){if((0,n.alwaysValidSchema)(s,t[l]))continue;i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c)}}exports.validateSchemaDeps=s,exports.default=i})),qc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Jc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=lc(),n=Q(),r=nc(),i=$();exports.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),Yc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=hc(),n=lc(),r=$(),i=Jc();exports.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),Xc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=lc(),n=Q(),r=$(),i=$();exports.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),Zc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Qc=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:lc().validateUnion,error:{message:`must match a schema in anyOf`}}})),$c=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),el=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),tl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}exports.default=r})),nl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),rl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Vc(),n=Uc(),r=Hc(),i=Wc(),a=Gc(),o=Kc(),s=qc(),c=Jc(),l=Yc(),u=Xc(),d=Zc(),f=Qc(),p=$c(),m=el(),h=tl(),g=nl();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}exports.default=_})),il=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),al=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=[il().default]})),ol=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.contentVocabulary=exports.metadataVocabulary=void 0,exports.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],exports.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),sl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Dc(),n=Bc(),r=rl(),i=al(),a=ol();exports.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),cl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(exports.DiscrError=t={}))})),ll=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=cl(),r=vc(),i=_c(),a=$();exports.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();for(let e in o.if(!1),r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),ul=K(((exports,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),dl=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.MissingRefError=exports.ValidationError=exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=exports.Ajv=void 0;let n=wc(),r=sl(),i=ll(),a=ul(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};exports.Ajv=c,t.exports=exports=c,t.exports.Ajv=c,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=c;var l=hc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=gc();Object.defineProperty(exports,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=_c();Object.defineProperty(exports,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})})),fl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.dynamicAnchor=void 0;let t=Q(),n=nc(),r=vc(),i=Ec(),a={keyword:`$dynamicAnchor`,schemaType:`string`,code:e=>o(e,e.schema)};function o(e,r){let{gen:i,it:a}=e;a.schemaEnv.root.dynamicAnchors[r]=!0;let o=(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(r)}`,c=a.errSchemaPath===`#`?a.validateName:s(e);i.if((0,t._)`!${o}`,()=>i.assign(o,c))}exports.dynamicAnchor=o;function s(e){let{schemaEnv:t,schema:n,self:a}=e.it,{root:o,baseId:s,localRefs:c,meta:l}=t.root,{schemaId:u}=a.opts,d=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:s,localRefs:c,meta:l});return r.compileSchema.call(a,d),(0,i.getValidate)(e,d)}exports.default=a})),pl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.dynamicRef=void 0;let t=Q(),n=nc(),r=Ec(),i={keyword:`$dynamicRef`,schemaType:`string`,code:e=>a(e,e.schema)};function a(e,i){let{gen:a,keyword:o,it:s}=e;if(i[0]!==`#`)throw Error(`"${o}" only supports hash fragment reference`);let c=i.slice(1);if(s.allErrors)l();else{let t=a.let(`valid`,!1);l(t),e.ok(t)}function l(e){if(s.schemaEnv.root.dynamicAnchors[c]){let r=a.let(`_v`,(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(c)}`);a.if(r,u(r,e),u(s.validateName,e))}else u(s.validateName,e)()}function u(t,n){return n?()=>a.block(()=>{(0,r.callRef)(e,t),a.let(n,!0)}):()=>(0,r.callRef)(e,t)}}exports.dynamicRef=a,exports.default=i})),ml=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=fl(),n=$();exports.default={keyword:`$recursiveAnchor`,schemaType:`boolean`,code(e){e.schema?(0,t.dynamicAnchor)(e,``):(0,n.checkStrictMode)(e.it,`$recursiveAnchor: false is ignored`)}}})),hl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=pl();exports.default={keyword:`$recursiveRef`,schemaType:`string`,code:e=>(0,t.dynamicRef)(e,e.schema)}})),gl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=fl(),n=pl(),r=ml(),i=hl();exports.default=[t.default,n.default,r.default,i.default]})),_l=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Kc();exports.default={keyword:`dependentRequired`,type:`object`,schemaType:`object`,error:t.error,code:e=>(0,t.validatePropertyDeps)(e)}})),vl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Kc();exports.default={keyword:`dependentSchemas`,type:`object`,schemaType:`object`,code:e=>(0,t.validateSchemaDeps)(e)}})),yl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:[`maxContains`,`minContains`],type:`array`,schemaType:`number`,code({keyword:e,parentSchema:n,it:r}){n.contains===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "contains" is ignored`)}}})),bl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=_l(),n=vl(),r=yl();exports.default=[t.default,n.default,r.default]})),xl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=nc();exports.default={keyword:`unevaluatedProperties`,type:`object`,schemaType:[`boolean`,`object`],trackErrors:!0,error:{message:`must NOT have unevaluated properties`,params:({params:e})=>(0,t._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){let{gen:i,schema:a,data:o,errsCount:s,it:c}=e;if(!s)throw Error(`ajv implementation error`);let{allErrors:l,props:u}=c;u instanceof t.Name?i.if((0,t._)`${u} !== true`,()=>i.forIn(`key`,o,e=>i.if(f(u,e),()=>d(e)))):u!==!0&&i.forIn(`key`,o,e=>u===void 0?d(e):i.if(p(u,e),()=>d(e))),c.props=!0,e.ok((0,t._)`${s} === ${r.default.errors}`);function d(r){if(a===!1){e.setParams({unevaluatedProperty:r}),e.error(),l||i.break();return}if(!(0,n.alwaysValidSchema)(c,a)){let a=i.name(`valid`);e.subschema({keyword:`unevaluatedProperties`,dataProp:r,dataPropType:n.Type.Str},a),l||i.if((0,t.not)(a),()=>i.break())}}function f(e,n){return(0,t._)`!${e} || !${e}[${n}]`}function p(e,n){let r=[];for(let i in e)e[i]===!0&&r.push((0,t._)`${n} !== ${i}`);return(0,t.and)(...r)}}}})),Sl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`unevaluatedItems`,type:`array`,schemaType:[`boolean`,`object`],error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e,s=o.items||0;if(s===!0)return;let c=r.const(`len`,(0,t._)`${a}.length`);if(i===!1)e.setParams({len:s}),e.fail((0,t._)`${c} > ${s}`);else if(typeof i==`object`&&!(0,n.alwaysValidSchema)(o,i)){let n=r.var(`valid`,(0,t._)`${c} <= ${s}`);r.if((0,t.not)(n),()=>l(n,s)),e.ok(n)}o.items=!0;function l(i,a){r.forRange(`i`,a,c,a=>{e.subschema({keyword:`unevaluatedItems`,dataProp:a,dataPropType:n.Type.Num},i),o.allErrors||r.if((0,t.not)(i),()=>r.break())})}}}})),Cl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=xl(),n=Sl();exports.default=[t.default,n.default]})),wl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/schema`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:`Core and Validation specifications meta-schema`,allOf:[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format`},{$ref:`meta/content`}],type:[`object`,`boolean`],properties:{definitions:{$comment:`While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.`,type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},dependencies:{$comment:`"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"`,type:`object`,additionalProperties:{anyOf:[{$recursiveRef:`#`},{$ref:`meta/validation#/$defs/stringArray`}]}}}}})),Tl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/applicator`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:`Applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{additionalItems:{$recursiveRef:`#`},unevaluatedItems:{$recursiveRef:`#`},items:{anyOf:[{$recursiveRef:`#`},{$ref:`#/$defs/schemaArray`}]},contains:{$recursiveRef:`#`},additionalProperties:{$recursiveRef:`#`},unevaluatedProperties:{$recursiveRef:`#`},properties:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$recursiveRef:`#`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$recursiveRef:`#`}},propertyNames:{$recursiveRef:`#`},if:{$recursiveRef:`#`},then:{$recursiveRef:`#`},else:{$recursiveRef:`#`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$recursiveRef:`#`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$recursiveRef:`#`}}}}})),El=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/content`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:`Content vocabulary meta-schema`,type:[`object`,`boolean`],properties:{contentMediaType:{type:`string`},contentEncoding:{type:`string`},contentSchema:{$recursiveRef:`#`}}}})),Dl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/core`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:`Core vocabulary meta-schema`,type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{type:`string`,format:`uri`},$anchor:{type:`string`,pattern:`^[A-Za-z][-A-Za-z0-9.:_]*$`},$ref:{type:`string`,format:`uri-reference`},$recursiveRef:{type:`string`,format:`uri-reference`},$recursiveAnchor:{type:`boolean`,default:!1},$vocabulary:{type:`object`,propertyNames:{type:`string`,format:`uri`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}}}}})),Ol=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/format`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:`Format vocabulary meta-schema`,type:[`object`,`boolean`],properties:{format:{type:`string`}}}})),kl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/meta-data`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:`Meta-data vocabulary meta-schema`,type:[`object`,`boolean`],properties:{title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}}}})),Al=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/validation`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:`Validation vocabulary meta-schema`,type:[`object`,`boolean`],properties:{multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}},const:!0,enum:{type:`array`,items:!0},type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}}})),jl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=wl(),n=Tl(),r=El(),i=Dl(),a=Ol(),o=kl(),s=Al(),c=[`/properties`];function l(e){return[t,n,r,i,l(this,a),o,l(this,s)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function l(t,n){return e?t.$dataMetaSchema(n,c):n}}exports.default=l})),Ml=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.MissingRefError=exports.ValidationError=exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=exports.Ajv2019=void 0;let n=wc(),r=sl(),i=gl(),a=bl(),o=Cl(),s=ll(),c=jl(),l=`https://json-schema.org/draft/2019-09/schema`;var u=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(i.default),r.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(a.default),this.addVocabulary(o.default),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(c.default.call(this,e),this.refs[`http://json-schema.org/schema`]=l)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};exports.Ajv2019=u,t.exports=exports=u,t.exports.Ajv2019=u,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=u;var d=hc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return d.KeywordCxt}});var f=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return f._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return f.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return f.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return f.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return f.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return f.CodeGen}});var p=gc();Object.defineProperty(exports,`ValidationError`,{enumerable:!0,get:function(){return p.default}});var m=_c();Object.defineProperty(exports,`MissingRefError`,{enumerable:!0,get:function(){return m.default}})})),Nl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Dc(),n=Bc(),r=rl(),i=gl(),a=bl(),o=Cl(),s=al(),c=ol();exports.default=[i.default,t.default,n.default,(0,r.default)(!0),s.default,c.metadataVocabulary,c.contentVocabulary,a.default,o.default]})),Pl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/schema`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Core and Validation specifications meta-schema`,allOf:[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],type:[`object`,`boolean`],$comment:`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,properties:{definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}}}})),Fl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/applicator`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:`meta`,title:`Applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}}}})),Il=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/unevaluated`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:`meta`,title:`Unevaluated applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}}}})),Ll=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/content`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Content vocabulary meta-schema`,type:[`object`,`boolean`],properties:{contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}}}})),Rl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/core`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:`meta`,title:`Core vocabulary meta-schema`,type:[`object`,`boolean`],properties:{$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},$defs:{anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}}}})),zl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/format-annotation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:`meta`,title:`Format vocabulary meta-schema for annotation results`,type:[`object`,`boolean`],properties:{format:{type:`string`}}}})),Bl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/meta-data`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:`meta`,title:`Meta-data vocabulary meta-schema`,type:[`object`,`boolean`],properties:{title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}}}})),Vl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/validation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:`meta`,title:`Validation vocabulary meta-schema`,type:[`object`,`boolean`],properties:{type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},$defs:{nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}}})),Hl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Pl(),n=Fl(),r=Il(),i=Ll(),a=Rl(),o=zl(),s=Bl(),c=Vl(),l=[`/properties`];function u(e){return[t,n,r,i,a,u(this,o),s,u(this,c)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function u(t,n){return e?t.$dataMetaSchema(n,l):n}}exports.default=u})),Ul=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.MissingRefError=exports.ValidationError=exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=exports.Ajv2020=void 0;let n=wc(),r=Nl(),i=ll(),a=Hl(),o=`https://json-schema.org/draft/2020-12/schema`;var s=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(a.default.call(this,e),this.refs[`http://json-schema.org/schema`]=o)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}};exports.Ajv2020=s,t.exports=exports=s,t.exports.Ajv2020=s,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=s;var c=hc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return c.KeywordCxt}});var l=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return l._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return l.CodeGen}});var u=gc();Object.defineProperty(exports,`ValidationError`,{enumerable:!0,get:function(){return u.default}});var d=_c();Object.defineProperty(exports,`MissingRefError`,{enumerable:!0,get:function(){return d.default}})})),Wl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.formatNames=exports.fastFormats=exports.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}exports.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:ne,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:ee},double:{type:`number`,validate:ee},password:!0,binary:!0},exports.fastFormats={...exports.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},exports.formatNames=Object.keys(exports.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}let r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}let s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}let d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}let h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}let v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}let b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function ee(){return!0}let te=/[^\\]\\Z/;function ne(e){if(te.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),Gl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.formatLimitDefinition=void 0;let t=dl(),n=Q(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};exports.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},exports.default=t=>(t.addKeyword(exports.formatLimitDefinition),t)})),Kl=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0});let n=Wl(),r=Gl(),i=Q(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=exports=s,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=s})),ql=dl(),Jl=Ml(),Yl=Ul();const Xl=Ei(Kl(),1).default;function Zl(e){let t=new e({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Xl(t),t}var Ql=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor(e){this._userAjv=e!==void 0,this._ajv=e}get ajv(){return this._ajv??=Zl(Yl.Ajv2020)}_engineFor(e){if(this._userAjv)return this.ajv;let t=Mi(e,`pass a pre-configured Ajv instance to AjvJsonSchemaValidator(ajv) to validate other dialects.`);return t===`2020-12`?this.ajv:t===`2019-09`?this._ajv2019??=Zl(Jl.Ajv2019):this._ajvDraft7??=Zl(ql.Ajv)}getValidator(e){let t=this._engineFor(e),n=`$id`in e&&typeof e.$id==`string`?t.getSchema(e.$id)??t.compile(e):t.compile(e);return e=>n(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:t.errorsText(n.errors)}}};ql.Ajv;const $l=Symbol.for(`mcp.completable`);function eu(e){return!!e&&typeof e==`object`&&$l in e}function tu(e){return e[$l]?.complete}const nu=2**31-1;function ru(e,t){if(!Number.isFinite(e)||e<1)return;let n=setInterval(t,Math.min(e,nu));return n.unref?.(),n}function iu(e,t){switch(t.kind){case`tools_list_changed`:return e.toolsListChanged===!0;case`prompts_list_changed`:return e.promptsListChanged===!0;case`resources_list_changed`:return e.resourcesListChanged===!0;case`resource_updated`:return e.resourceSubscriptions!==void 0&&e.resourceSubscriptions.includes(t.uri)}}function au(e,t){let n={},r=e=>t===void 0||e===!0;return e.toolsListChanged===!0&&r(t?.tools?.listChanged)&&(n.toolsListChanged=!0),e.promptsListChanged===!0&&r(t?.prompts?.listChanged)&&(n.promptsListChanged=!0),e.resourcesListChanged===!0&&r(t?.resources?.listChanged)&&(n.resourcesListChanged=!0),e.resourceSubscriptions!==void 0&&e.resourceSubscriptions.length>0&&r(t?.resources?.subscribe)&&(n.resourceSubscriptions=[...e.resourceSubscriptions]),n}const ou=1024;function su(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[ln]:t}}}}function cu(e){let t=fo(uo).validateRequest(`subscriptions/listen`,e);return t.ok?t.value.params?.notifications:void 0}const lu=new Set([`notifications/tools/list_changed`,`notifications/prompts/list_changed`,`notifications/resources/list_changed`,`notifications/resources/updated`]);var uu=class{_subs=new Map;_serverCapabilities;_serverInfo;constructor(e=ou,t,n){this._maxSubscriptions=e,this._serverCapabilities=t,this._serverInfo=n}setServerCapabilities(e,t){this._serverCapabilities=e,t!==void 0&&(this._serverInfo=t)}has(e){return this._subs.has(e)}serve(e){if(this._serverCapabilities===void 0)throw Error(`StdioListenRouter.serve() called before setServerCapabilities(); refusing to honor a filter without capabilities`);if(this._subs.size>=this._maxSubscriptions)return{jsonrpc:`2.0`,id:e.id,error:{code:-32603,message:`Subscription limit reached`}};let t=cu(e);if(t===void 0)return{jsonrpc:`2.0`,id:e.id,error:{code:-32602,message:`Invalid params: 'notifications' is required and must be a valid SubscriptionFilter`}};let n=au(t,this._serverCapabilities);return this._subs.set(e.id,n),su({method:`notifications/subscriptions/acknowledged`,params:{notifications:n}},e.id)}cancel(e){return this._subs.delete(e)}routeOutbound(e){if(!lu.has(e.method))return`passthrough`;let t=e.params?.uri,n=typeof t==`string`?t:void 0,r=du(e.method,n),i=[];for(let[t,n]of this._subs)iu(n,r)&&i.push(su({method:e.method,params:e.params??{}},t));return i}teardownAll(){let e=[];for(let t of this._subs.keys())e.push({jsonrpc:`2.0`,id:t,result:{resultType:`complete`,_meta:{[ln]:t,...this._serverInfo!==void 0&&{[cn]:this._serverInfo}}}});return this._subs.clear(),e}};function du(e,t){switch(e){case`notifications/tools/list_changed`:return{kind:`tools_list_changed`};case`notifications/prompts/list_changed`:return{kind:`prompts_list_changed`};case`notifications/resources/list_changed`:return{kind:`resources_list_changed`};default:return{kind:`resource_updated`,uri:t??``}}}function fu(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??8,roundTimeoutMs:e?.roundTimeoutMs??6e5,legacyShim:e?.legacyShim??!0}}function pu(e,t,n){if(typeof n!=`object`||!n||typeof n.method!=`string`)throw new X(Y.InternalError,`Handler for ${e} returned an invalid input request '${t}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let r=n,i=Ri(r);if(i===void 0)throw new X(Y.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${r.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:r,required:i}}function mu(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function hu(e,t){if(e===`tools/call`)return{content:[{type:`text`,text:t}],isError:!0};throw new X(Y.InternalError,t)}var gu=class{constructor(e){this._host=e}async fulfill(e,t,n,r,i){let{maxRounds:a,roundTimeoutMs:o}=this._host,s=r.mcpReq.signal,c=i,l=0;for(;;){if(l+=1,l>a)return hu(e,gs(e,a));let i=c.inputRequests,u=i!=null&&Object.keys(i).length>0,d=typeof c.requestState==`string`?c.requestState:void 0;if(!u&&d===void 0)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);let f;if(u){let t=this._host.resolvedClientCapabilities(r),n=[];for(let[r,a]of Object.entries(i)){let{embedded:i,required:o}=pu(e,r,a);if(i.method!==`roots/list`&&i.params===void 0)throw new X(Y.InternalError,`Handler for ${e} returned an input request '${r}' of kind '${i.method}' without params`);if(zi(o,t)!==void 0)return hu(e,`Cannot request input '${r}' (${i.method}): the client on this 2025-era connection did not declare the required capability${t===void 0?` (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)`:``}`);n.push([r,i])}let a=vs(s);try{let e={relatedRequestId:r.mcpReq.id,timeout:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:a.signal},t=await Promise.all(n.map(async([t,n])=>{try{return[t,await this._dispatchLeg(n,e)]}catch(e){throw a.abort(e),e}}));f=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return hu(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{a.dispose()}}else await _s(250,s);let p={...r,mcpReq:{...r.mcpReq,inputResponses:f,droppedInputResponseKeys:void 0,requestState:ks(d)}};if(d!==void 0){let t=await this._host.verifyRequestState(d,p,e);t!==void 0&&(p=js(p,t))}let m=await t(n,p);if(!Eo(m))return m;c=m}}async _dispatchLeg(e,t){switch(e.method){case`elicitation/create`:{let n=e.params;return n.mode===`url`&&n.elicitationId===void 0&&(n={...n,elicitationId:mu()}),await this._host.sendElicitation(n,t)}case`sampling/createMessage`:return await this._host.sendSampling(e.params,t);case`roots/list`:return await this._host.listRoots(e.params,t)}}};const _u=new Set([`tools/call`,`prompts/get`,`resources/read`]);let vu,yu;function bu(e,t){vu(e,t)}function xu(e){return yu(e)}var Su=class extends Ps{_clientCapabilities;_clientVersion;static{vu=(e,t)=>{let n=t.filter(t=>!e._supportedProtocolVersions.includes(t));n.length>0&&(e._supportedProtocolVersions=[...e._supportedProtocolVersions,...n]),e.setRequestHandler(`server/discover`,()=>e._ondiscover())},yu=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_legacyInputRequiredShim(){return this._legacyShim??=new gu({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,n)=>this._verifyRequestState(e,t,n),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){if(super(t),this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new Ql,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=fu(t?.inputRequired),t?.cacheHints!==void 0){for(let[e,n]of Object.entries(t.cacheHints))n!==void 0&&ka(n,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler(`initialize`,e=>this._oninitialize(e)),this.setNotificationHandler(`notifications/initialized`,()=>this.oninitialized?.()),Wi(this._supportedProtocolVersions).length>0&&this.setRequestHandler(`server/discover`,()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}_registerLoggingHandler(){this.setRequestHandler(`logging/setLevel`,async(e,t)=>{let n=t.sessionId||t.http?.req?.headers.get(`mcp-session-id`)||void 0,{level:r}=e.params,i=Bo(ct,r);return i.success&&this._loggingLevels.set(n,i.data),{}})}buildContext(e,t){let n=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(t,n,r)=>{if(!this._capabilities.logging)return Promise.resolve();let i;if(this._servedModernEra()){if(i=e.mcpReq.envelope?.[Je],i===void 0)return Promise.resolve()}else i=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return i!==void 0&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(i)?Promise.resolve():e.mcpReq.notify({method:`notifications/message`,params:{level:t,data:n,logger:r}})},elicitInput:(e,t)=>this.elicitInput(e,t),requestSampling:(e,t)=>this.createMessage(e,t)},http:n?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(ct.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1};registerCapabilities(e){if(this.transport)throw new J(q.AlreadyConnected,`Cannot register capabilities after connecting to transport`);let t=!!this._capabilities.logging;this._capabilities=Is(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if(e!==`tools/call`){let n=this._cacheHints?.[e],r=_u.has(e);return n===void 0&&!r?async(n,r)=>{let i=await t(n,r);if(Eo(i))throw new X(Y.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return i}:async(i,a)=>{let o=r?await this._invokeInputRequiredCapableHandler(e,t,i,a):await t(i,a);if(Eo(o)){if(!r)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return o}return n===void 0?o:Ta(o,n)}}return async(e,n)=>{let r=fo(this._negotiatedProtocolVersion),i=r.validateRequest(`tools/call`,e);if(!i.ok)throw new X(i.reason===`not-in-era`?Y.InternalError:Y.InvalidParams,i.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call request: ${i.message}`);let a=await this._invokeInputRequiredCapableHandler(`tools/call`,t,e,n);if(Eo(a))return a;let o=qi(a),s=r.validateResult(`tools/call`,o);if(!s.ok)throw new X(s.reason===`not-in-era`?Y.InternalError:Y.InvalidParams,s.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call result: ${s.message}`);return s.value}}_servedModernEra(){return this._negotiatedProtocolVersion!==void 0&&Hi(this._negotiatedProtocolVersion)}async _invokeInputRequiredCapableHandler(e,t,n,r){let i=this._servedModernEra(),a=r.mcpReq.requestState();if(a!==void 0&&typeof a!=`string`)throw new X(Y.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`});let o=r;if(typeof a==`string`){let t=await this._verifyRequestState(a,r,e);t!==void 0&&(o=js(r,t))}let s;try{s=await t(n,o)}catch(e){throw e instanceof X&&e.code===Y.UrlElicitationRequired&&i?new X(Y.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`):e}if(!Eo(s))return s;if(!i){if(!this._inputRequiredServing.legacyShim)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??qe}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,n,o,s)}let c=s.inputRequests,l=c!=null&&Object.keys(c).length>0,u=typeof s.requestState==`string`;if(!l&&!u)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(l){let t=this._inputRequestCapabilityView(r);for(let[n,r]of Object.entries(c)){let{embedded:i,required:a}=pu(e,n,r),o=zi(a,t);if(o!==void 0)throw new Na({requiredCapabilities:o},`Cannot request input '${n}' (${i.method}): the request's client capabilities do not declare the required capability`)}}return s}async _verifyRequestState(e,t,n){if(this._requestStateVerify!==void 0)try{return await this._requestStateVerify(e,t)}catch(e){throw this.onerror?.(Error(`requestState verification rejected ${n}: ${e instanceof Error?e.message:String(e)}`)),new X(Y.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[p]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new J(q.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${e}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:e,era:`2026-07-28`})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw new J(q.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw new J(q.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw new J(q.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw new J(q.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw new J(q.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw new J(q.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw new J(q.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw new J(q.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){switch(e){case`completion/complete`:if(!this._capabilities.completions)throw new J(q.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw new J(q.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw new J(q.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw new J(q.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw new J(q.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case`ping`:case`initialize`:break}}async _oninitialize(e){let t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;let n=Ui(this._supportedProtocolVersions),r=n.includes(t)?t:n[0]??qe;return this._negotiatedProtocolVersion=r,this.transport?.setProtocolVersion?.(r),{protocolVersion:r,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:Wi(this._supportedProtocolVersions),capabilities:Cu(this.getCapabilities()),...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(e,t){return this._wireCodec().projectCallToolResult(e,t)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra(`ping`),this.request({method:`ping`})}async createMessage(e,t){if(this._assertPushApiInServedEra(`sampling/createMessage`),(e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new J(q.CapabilityNotSupported,`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages.at(-1),n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages.at(-2):void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw new X(Y.InvalidParams,`The last message must contain only tool_result content if any is present`);if(!o)throw new X(Y.InvalidParams,`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new X(Y.InvalidParams,`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}let n=!!(e.tools||e.toolChoice),r=await this.request({method:`sampling/createMessage`,params:e},t),i=this._wireCodec().samplingResultVariant(n,r);if(!i.ok)throw new J(q.InvalidResult,`Invalid sampling/createMessage result: ${i.reason===`invalid`?i.message:i.reason}`);return i.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra(`elicitation/create`),e.mode??`form`){case`url`:if(!this._clientCapabilities?.elicitation?.url)throw new J(q.CapabilityNotSupported,`Client does not support url elicitation.`);break;case`form`:if(!this._clientCapabilities?.elicitation?.form)throw new J(q.CapabilityNotSupported,`Client does not support form elicitation.`);break}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,n){let r=e.mode??`form`,i=n?.validateAcceptedContent??!0;switch(r){case`url`:{let n=e;return this.request({method:`elicitation/create`,params:n},t)}case`form`:{let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},t);if(i&&r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new X(Y.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof X?e:new X(Y.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new J(q.CapabilityNotSupported,`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this._assertPushApiInServedEra(`roots/list`),this.request({method:`roots/list`,params:e},t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};function Cu(e){return{...e}}var wu=class{server;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(!(t===void 0||!t.enabled)){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(t.inputSchema===void 0)return Eu;try{let n=Go(t.inputSchema,`input`);return this._toolInputSchemaJson[e]=n,n}catch{return}}}constructor(e,t){this.server=new Su(e,t),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||=(this.server.assertCanSetRequestHandler(`tools/list`),this.server.assertCanSetRequestHandler(`tools/call`),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler(`tools/list`,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?Go(t.inputSchema,`input`):Eu,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(n.outputSchema=Go(t.outputSchema,`output`)),n})})),this.server.setRequestHandler(`tools/call`,async(e,t)=>{let n=this._registeredTools[e.params.name];if(!n)throw new X(Y.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new X(Y.InvalidParams,`Tool ${e.params.name} disabled`);try{let r=await this.validateToolInput(n,e.params.arguments,e.params.name),i=await this.executeToolHandler(n,r,t);return await this.validateToolOutput(n,i,e.params.name),Eo(i)?i:this.server.projectCallToolResult(i,n.outputSchemaJson)}catch(e){if(e instanceof X&&e.code===Y.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(!e.inputSchema)return;let r=await Jo(e.inputSchema,t??{});if(!r.success)throw new X(Y.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${r.error}`);return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||Eo(t)||t.isError)return;if(t.structuredContent===void 0)throw new X(Y.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await Jo(e.outputSchema,t.structuredContent);if(!r.success)throw new X(Y.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${r.error}`)}async executeToolHandler(e,t,n){return e.executor(t,n)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||=(this.server.assertCanSetRequestHandler(`completion/complete`),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(`completion/complete`,async e=>{switch(e.params.ref.type){case`ref/prompt`:return Oo(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return ko(e),this.handleResourceCompletion(e,e.params.ref);default:throw new X(Y.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new X(Y.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new X(Y.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return Au;let r=Nu(ju(n.argsSchema)?.[e.params.argument.name]);if(!eu(r))return Au;let i=tu(r);return i?ku(await i(e.params.argument.value,e.params.context)):Au}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return Au;throw new X(Y.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?ku(await r(e.params.argument.value,e.params.context)):Au}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||=(this.server.assertCanSetRequestHandler(`resources/list`),this.server.assertCanSetRequestHandler(`resources/templates/list`),this.server.assertCanSetRequestHandler(`resources/read`),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler(`resources/list`,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),this.server.setRequestHandler(`resources/templates/list`,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(`resources/read`,async(e,t)=>{let n;try{n=new URL(e.params.uri)}catch{throw new X(Y.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:`invalid_uri`})}let r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new X(Y.InvalidParams,`Resource ${n} disabled`);return Ta(await r.readCallback(n,t),r.cacheHint)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r)return Ta(await e.readCallback(n,r,t),e.cacheHint)}throw new Aa(e.params.uri)}),!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||=(this.server.assertCanSetRequestHandler(`prompts/list`),this.server.assertCanSetRequestHandler(`prompts/get`),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler(`prompts/list`,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?es(t.argsSchema):void 0,icons:t.icons,_meta:t._meta}))})),this.server.setRequestHandler(`prompts/get`,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new X(Y.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new X(Y.InvalidParams,`Prompt ${e.params.name} disabled`);return n.handler(e.params.arguments,t)}),!0)}registerResource(e,t,n,r){let i=n.cacheHint,a=n;if(i!==void 0){ka(i,`resource ${e}`);let t={...n};delete t.cacheHint,a=t}if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let o=this._createRegisteredResource(e,n.title,t,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,n.title,t,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,t,n,r,i){let a={name:e,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=a)),e.name!==void 0&&(a.name=e.name),e.title!==void 0&&(a.title=e.title),e.metadata!==void 0&&(a.metadata=e.metadata),e.callback!==void 0&&(a.readCallback=e.callback),e.enabled!==void 0&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(e,t,n,r,i){let a={resourceTemplate:n,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.template!==void 0&&(a.resourceTemplate=t.template),t.metadata!==void 0&&(a.metadata=t.metadata),t.callback!==void 0&&(a.readCallback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,n,r,i,a,o){let s=r,c=i,l={title:t,description:n,argsSchema:r,icons:a,_meta:o,handler:Ou(e,r,i),enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=l)),t.title!==void 0&&(l.title=t.title),t.description!==void 0&&(l.description=t.description),t.icons!==void 0&&(l.icons=t.icons),t._meta!==void 0&&(l._meta=t._meta);let n=!1;t.argsSchema!==void 0&&(l.argsSchema=t.argsSchema,s=t.argsSchema,n=!0),t.callback!==void 0&&(c=t.callback,n=!0),n&&(l.handler=Ou(e,s,c)),t.enabled!==void 0&&(l.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=l,r){let e=ju(r);e&&Object.values(e).some(e=>eu(Nu(e)))&&this.setCompletionRequestHandler()}return l}_createRegisteredTool(e,t,n,r,i,a,o,s,c,l){if(Ys(e),r!==void 0)try{let t=Go(r,`input`);this._toolInputSchemaJson[e]=t;let n=No(t);n.valid||console.warn(`[mcp-sdk] tool '${e}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${n.reason}`)}catch{}let u=l,d={title:t,description:n,inputSchema:r,outputSchema:i,outputSchemaJson:Du(i),annotations:a,icons:o,execution:s,_meta:c,handler:l,executor:Tu(r,l),enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&Ys(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=d,e=t.name)),t.title!==void 0&&(d.title=t.title),t.description!==void 0&&(d.description=t.description);let n=!1;t.paramsSchema!==void 0&&(d.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],n=!0),t.callback!==void 0&&(d.handler=t.callback,u=t.callback,n=!0),n&&(d.executor=Tu(d.inputSchema,u)),t.outputSchema!==void 0&&(d.outputSchema=t.outputSchema,d.outputSchemaJson=Du(t.outputSchema)),t.annotations!==void 0&&(d.annotations=t.annotations),t.icons!==void 0&&(d.icons=t.icons),t._meta!==void 0&&(d._meta=t._meta),t.enabled!==void 0&&(d.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,icons:c,_meta:l}=t;return this._createRegisteredTool(e,r,i,$s(a),$s(o),s,c,void 0,l,n)}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a,icons:o,_meta:s}=t,c=this._createRegisteredPrompt(e,r,i,$s(a),n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};function Tu(e,t){if(e){let e=t;return async(t,n)=>e(t,n)}let n=t;return async(e,t)=>n(t)}const Eu={type:`object`,properties:{}};function Du(e){if(e!==void 0)try{return Go(e,`output`)}catch{return}}function Ou(e,t,n){if(t){let r=n;return async(n,i)=>{let a=await Jo(t,n);if(!a.success)throw new X(Y.InvalidParams,`Invalid arguments for prompt ${e}: ${a.error}`);return r(a.data,i)}}else{let e=n;return async(t,n)=>e(n)}}function ku(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}const Au={completion:{values:[],hasMore:!1}};function ju(e){let t=e;if(t.shape&&typeof t.shape==`object`)return t.shape}function Mu(e){return e?.type===`optional`}function Nu(e){return Mu(e)?e.def?.innerType??e:e}var Pu=class{sessionIdGenerator;_started=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId=`_GET_stream`;_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;sessionId;onclose;onerror;onmessage;constructor(e={}){this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval,this._supportedProtocolVersions=e.supportedProtocolVersions??un,this._keepAliveMs=e.keepAliveMs??15e3}startKeepAlive(e,t){if(this._closed)return;let n=ru(this._keepAliveMs,()=>{try{e.enqueue(t.encode(`: keepalive
12
+ deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:exports.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}exports.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t){if((0,n.alwaysValidSchema)(s,t[l]))continue;i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c)}}exports.validateSchemaDeps=s,exports.default=i})),nl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),rl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=vc(),n=Q(),r=dc(),i=$();exports.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),il=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=wc(),n=vc(),r=$(),i=rl();exports.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),al=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=vc(),n=Q(),r=$(),i=$();exports.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),ol=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),sl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:vc().validateUnion,error:{message:`must match a schema in anyOf`}}})),cl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),ll=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),ul=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}exports.default=r})),dl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),fl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Xc(),n=Qc(),r=Zc(),i=$c(),a=el(),o=tl(),s=nl(),c=rl(),l=il(),u=al(),d=ol(),f=sl(),p=cl(),m=ll(),h=ul(),g=dl();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}exports.default=_})),pl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q();exports.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),ml=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=[pl().default]})),hl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.contentVocabulary=exports.metadataVocabulary=void 0,exports.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],exports.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),gl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Ic(),n=Yc(),r=fl(),i=ml(),a=hl();exports.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),_l=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(exports.DiscrError=t={}))})),vl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=_l(),r=Dc(),i=Ec(),a=$();exports.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();for(let e in o.if(!1),r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),yl=K(((exports,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),bl=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.MissingRefError=exports.ValidationError=exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=exports.Ajv=void 0;let n=Nc(),r=gl(),i=vl(),a=yl(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};exports.Ajv=c,t.exports=exports=c,t.exports.Ajv=c,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=c;var l=wc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=Tc();Object.defineProperty(exports,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=Ec();Object.defineProperty(exports,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})})),xl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.dynamicAnchor=void 0;let t=Q(),n=dc(),r=Dc(),i=Fc(),a={keyword:`$dynamicAnchor`,schemaType:`string`,code:e=>o(e,e.schema)};function o(e,r){let{gen:i,it:a}=e;a.schemaEnv.root.dynamicAnchors[r]=!0;let o=(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(r)}`,c=a.errSchemaPath===`#`?a.validateName:s(e);i.if((0,t._)`!${o}`,()=>i.assign(o,c))}exports.dynamicAnchor=o;function s(e){let{schemaEnv:t,schema:n,self:a}=e.it,{root:o,baseId:s,localRefs:c,meta:l}=t.root,{schemaId:u}=a.opts,d=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:s,localRefs:c,meta:l});return r.compileSchema.call(a,d),(0,i.getValidate)(e,d)}exports.default=a})),Sl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.dynamicRef=void 0;let t=Q(),n=dc(),r=Fc(),i={keyword:`$dynamicRef`,schemaType:`string`,code:e=>a(e,e.schema)};function a(e,i){let{gen:a,keyword:o,it:s}=e;if(i[0]!==`#`)throw Error(`"${o}" only supports hash fragment reference`);let c=i.slice(1);if(s.allErrors)l();else{let t=a.let(`valid`,!1);l(t),e.ok(t)}function l(e){if(s.schemaEnv.root.dynamicAnchors[c]){let r=a.let(`_v`,(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(c)}`);a.if(r,u(r,e),u(s.validateName,e))}else u(s.validateName,e)()}function u(t,n){return n?()=>a.block(()=>{(0,r.callRef)(e,t),a.let(n,!0)}):()=>(0,r.callRef)(e,t)}}exports.dynamicRef=a,exports.default=i})),Cl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=xl(),n=$();exports.default={keyword:`$recursiveAnchor`,schemaType:`boolean`,code(e){e.schema?(0,t.dynamicAnchor)(e,``):(0,n.checkStrictMode)(e.it,`$recursiveAnchor: false is ignored`)}}})),wl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Sl();exports.default={keyword:`$recursiveRef`,schemaType:`string`,code:e=>(0,t.dynamicRef)(e,e.schema)}})),Tl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=xl(),n=Sl(),r=Cl(),i=wl();exports.default=[t.default,n.default,r.default,i.default]})),El=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=tl();exports.default={keyword:`dependentRequired`,type:`object`,schemaType:`object`,error:t.error,code:e=>(0,t.validatePropertyDeps)(e)}})),Dl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=tl();exports.default={keyword:`dependentSchemas`,type:`object`,schemaType:`object`,code:e=>(0,t.validateSchemaDeps)(e)}})),Ol=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=$();exports.default={keyword:[`maxContains`,`minContains`],type:`array`,schemaType:`number`,code({keyword:e,parentSchema:n,it:r}){n.contains===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "contains" is ignored`)}}})),kl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=El(),n=Dl(),r=Ol();exports.default=[t.default,n.default,r.default]})),Al=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$(),r=dc();exports.default={keyword:`unevaluatedProperties`,type:`object`,schemaType:[`boolean`,`object`],trackErrors:!0,error:{message:`must NOT have unevaluated properties`,params:({params:e})=>(0,t._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){let{gen:i,schema:a,data:o,errsCount:s,it:c}=e;if(!s)throw Error(`ajv implementation error`);let{allErrors:l,props:u}=c;u instanceof t.Name?i.if((0,t._)`${u} !== true`,()=>i.forIn(`key`,o,e=>i.if(f(u,e),()=>d(e)))):u!==!0&&i.forIn(`key`,o,e=>u===void 0?d(e):i.if(p(u,e),()=>d(e))),c.props=!0,e.ok((0,t._)`${s} === ${r.default.errors}`);function d(r){if(a===!1){e.setParams({unevaluatedProperty:r}),e.error(),l||i.break();return}if(!(0,n.alwaysValidSchema)(c,a)){let a=i.name(`valid`);e.subschema({keyword:`unevaluatedProperties`,dataProp:r,dataPropType:n.Type.Str},a),l||i.if((0,t.not)(a),()=>i.break())}}function f(e,n){return(0,t._)`!${e} || !${e}[${n}]`}function p(e,n){let r=[];for(let i in e)e[i]===!0&&r.push((0,t._)`${n} !== ${i}`);return(0,t.and)(...r)}}}})),jl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Q(),n=$();exports.default={keyword:`unevaluatedItems`,type:`array`,schemaType:[`boolean`,`object`],error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e,s=o.items||0;if(s===!0)return;let c=r.const(`len`,(0,t._)`${a}.length`);if(i===!1)e.setParams({len:s}),e.fail((0,t._)`${c} > ${s}`);else if(typeof i==`object`&&!(0,n.alwaysValidSchema)(o,i)){let n=r.var(`valid`,(0,t._)`${c} <= ${s}`);r.if((0,t.not)(n),()=>l(n,s)),e.ok(n)}o.items=!0;function l(i,a){r.forRange(`i`,a,c,a=>{e.subschema({keyword:`unevaluatedItems`,dataProp:a,dataPropType:n.Type.Num},i),o.allErrors||r.if((0,t.not)(i),()=>r.break())})}}}})),Ml=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Al(),n=jl();exports.default=[t.default,n.default]})),Nl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/schema`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:`Core and Validation specifications meta-schema`,allOf:[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format`},{$ref:`meta/content`}],type:[`object`,`boolean`],properties:{definitions:{$comment:`While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.`,type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},dependencies:{$comment:`"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"`,type:`object`,additionalProperties:{anyOf:[{$recursiveRef:`#`},{$ref:`meta/validation#/$defs/stringArray`}]}}}}})),Pl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/applicator`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:`Applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{additionalItems:{$recursiveRef:`#`},unevaluatedItems:{$recursiveRef:`#`},items:{anyOf:[{$recursiveRef:`#`},{$ref:`#/$defs/schemaArray`}]},contains:{$recursiveRef:`#`},additionalProperties:{$recursiveRef:`#`},unevaluatedProperties:{$recursiveRef:`#`},properties:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$recursiveRef:`#`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$recursiveRef:`#`}},propertyNames:{$recursiveRef:`#`},if:{$recursiveRef:`#`},then:{$recursiveRef:`#`},else:{$recursiveRef:`#`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$recursiveRef:`#`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$recursiveRef:`#`}}}}})),Fl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/content`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:`Content vocabulary meta-schema`,type:[`object`,`boolean`],properties:{contentMediaType:{type:`string`},contentEncoding:{type:`string`},contentSchema:{$recursiveRef:`#`}}}})),Il=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/core`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:`Core vocabulary meta-schema`,type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{type:`string`,format:`uri`},$anchor:{type:`string`,pattern:`^[A-Za-z][-A-Za-z0-9.:_]*$`},$ref:{type:`string`,format:`uri-reference`},$recursiveRef:{type:`string`,format:`uri-reference`},$recursiveAnchor:{type:`boolean`,default:!1},$vocabulary:{type:`object`,propertyNames:{type:`string`,format:`uri`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}}}}})),Ll=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/format`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:`Format vocabulary meta-schema`,type:[`object`,`boolean`],properties:{format:{type:`string`}}}})),Rl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/meta-data`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:`Meta-data vocabulary meta-schema`,type:[`object`,`boolean`],properties:{title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}}}})),zl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2019-09/schema`,$id:`https://json-schema.org/draft/2019-09/meta/validation`,$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:`Validation vocabulary meta-schema`,type:[`object`,`boolean`],properties:{multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}},const:!0,enum:{type:`array`,items:!0},type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}}})),Bl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Nl(),n=Pl(),r=Fl(),i=Il(),a=Ll(),o=Rl(),s=zl(),c=[`/properties`];function l(e){return[t,n,r,i,l(this,a),o,l(this,s)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function l(t,n){return e?t.$dataMetaSchema(n,c):n}}exports.default=l})),Vl=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.MissingRefError=exports.ValidationError=exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=exports.Ajv2019=void 0;let n=Nc(),r=gl(),i=Tl(),a=kl(),o=Ml(),s=vl(),c=Bl(),l=`https://json-schema.org/draft/2019-09/schema`;var u=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(i.default),r.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(a.default),this.addVocabulary(o.default),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(c.default.call(this,e),this.refs[`http://json-schema.org/schema`]=l)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};exports.Ajv2019=u,t.exports=exports=u,t.exports.Ajv2019=u,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=u;var d=wc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return d.KeywordCxt}});var f=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return f._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return f.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return f.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return f.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return f.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return f.CodeGen}});var p=Tc();Object.defineProperty(exports,`ValidationError`,{enumerable:!0,get:function(){return p.default}});var m=Ec();Object.defineProperty(exports,`MissingRefError`,{enumerable:!0,get:function(){return m.default}})})),Hl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Ic(),n=Yc(),r=fl(),i=Tl(),a=kl(),o=Ml(),s=ml(),c=hl();exports.default=[i.default,t.default,n.default,(0,r.default)(!0),s.default,c.metadataVocabulary,c.contentVocabulary,a.default,o.default]})),Ul=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/schema`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Core and Validation specifications meta-schema`,allOf:[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],type:[`object`,`boolean`],$comment:`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,properties:{definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}}}})),Wl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/applicator`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:`meta`,title:`Applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}}}})),Gl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/unevaluated`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:`meta`,title:`Unevaluated applicator vocabulary meta-schema`,type:[`object`,`boolean`],properties:{unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}}}})),Kl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/content`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:`meta`,title:`Content vocabulary meta-schema`,type:[`object`,`boolean`],properties:{contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}}}})),ql=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/core`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:`meta`,title:`Core vocabulary meta-schema`,type:[`object`,`boolean`],properties:{$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},$defs:{anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}}}})),Jl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/format-annotation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:`meta`,title:`Format vocabulary meta-schema for annotation results`,type:[`object`,`boolean`],properties:{format:{type:`string`}}}})),Yl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/meta-data`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:`meta`,title:`Meta-data vocabulary meta-schema`,type:[`object`,`boolean`],properties:{title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}}}})),Xl=K(((exports,t)=>{t.exports={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://json-schema.org/draft/2020-12/meta/validation`,$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:`meta`,title:`Validation vocabulary meta-schema`,type:[`object`,`boolean`],properties:{type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},$defs:{nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}}})),Zl=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0});let t=Ul(),n=Wl(),r=Gl(),i=Kl(),a=ql(),o=Jl(),s=Yl(),c=Xl(),l=[`/properties`];function u(e){return[t,n,r,i,a,u(this,o),s,u(this,c)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function u(t,n){return e?t.$dataMetaSchema(n,l):n}}exports.default=u})),Ql=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.MissingRefError=exports.ValidationError=exports.CodeGen=exports.Name=exports.nil=exports.stringify=exports.str=exports._=exports.KeywordCxt=exports.Ajv2020=void 0;let n=Nc(),r=Hl(),i=vl(),a=Zl(),o=`https://json-schema.org/draft/2020-12/schema`;var s=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(a.default.call(this,e),this.refs[`http://json-schema.org/schema`]=o)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}};exports.Ajv2020=s,t.exports=exports=s,t.exports.Ajv2020=s,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=s;var c=wc();Object.defineProperty(exports,`KeywordCxt`,{enumerable:!0,get:function(){return c.KeywordCxt}});var l=Q();Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return l._}}),Object.defineProperty(exports,`str`,{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(exports,`stringify`,{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(exports,`nil`,{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(exports,`Name`,{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(exports,`CodeGen`,{enumerable:!0,get:function(){return l.CodeGen}});var u=Tc();Object.defineProperty(exports,`ValidationError`,{enumerable:!0,get:function(){return u.default}});var d=Ec();Object.defineProperty(exports,`MissingRefError`,{enumerable:!0,get:function(){return d.default}})})),$l=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.formatNames=exports.fastFormats=exports.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}exports.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:ne,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:ee},double:{type:`number`,validate:ee},password:!0,binary:!0},exports.fastFormats={...exports.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},exports.formatNames=Object.keys(exports.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}let r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}let s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}let d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}let h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}let v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}let b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function ee(){return!0}let te=/[^\\]\\Z/;function ne(e){if(te.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),eu=K((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.formatLimitDefinition=void 0;let t=bl(),n=Q(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};exports.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},exports.default=t=>(t.addKeyword(exports.formatLimitDefinition),t)})),tu=K(((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0});let n=$l(),r=eu(),i=Q(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=exports=s,Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=s})),nu=bl(),ru=Vl(),iu=Ql();const au=Fi(tu(),1).default;function ou(e){let t=new e({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return au(t),t}var su=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor(e){this._userAjv=e!==void 0,this._ajv=e}get ajv(){return this._ajv??=ou(iu.Ajv2020)}_engineFor(e){if(this._userAjv)return this.ajv;let t=Vi(e,`pass a pre-configured Ajv instance to AjvJsonSchemaValidator(ajv) to validate other dialects.`);return t===`2020-12`?this.ajv:t===`2019-09`?this._ajv2019??=ou(ru.Ajv2019):this._ajvDraft7??=ou(nu.Ajv)}getValidator(e){let t=this._engineFor(e),n=`$id`in e&&typeof e.$id==`string`?t.getSchema(e.$id)??t.compile(e):t.compile(e);return e=>n(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:t.errorsText(n.errors)}}};nu.Ajv;const cu=Symbol.for(`mcp.completable`);function lu(e){return!!e&&typeof e==`object`&&cu in e}function uu(e){return e[cu]?.complete}const du=2**31-1;function fu(e,t){if(!Number.isFinite(e)||e<1)return;let n=setInterval(t,Math.min(e,du));return n.unref?.(),n}function pu(e,t){switch(t.kind){case`tools_list_changed`:return e.toolsListChanged===!0;case`prompts_list_changed`:return e.promptsListChanged===!0;case`resources_list_changed`:return e.resourcesListChanged===!0;case`resource_updated`:return e.resourceSubscriptions!==void 0&&e.resourceSubscriptions.includes(t.uri)}}function mu(e,t){let n={},r=e=>t===void 0||e===!0;return e.toolsListChanged===!0&&r(t?.tools?.listChanged)&&(n.toolsListChanged=!0),e.promptsListChanged===!0&&r(t?.prompts?.listChanged)&&(n.promptsListChanged=!0),e.resourcesListChanged===!0&&r(t?.resources?.listChanged)&&(n.resourcesListChanged=!0),e.resourceSubscriptions!==void 0&&e.resourceSubscriptions.length>0&&r(t?.resources?.subscribe)&&(n.resourceSubscriptions=[...e.resourceSubscriptions]),n}const hu=1024;function gu(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[ln]:t}}}}function _u(e){let t=xo(bo).validateRequest(`subscriptions/listen`,e);return t.ok?t.value.params?.notifications:void 0}const vu=new Set([`notifications/tools/list_changed`,`notifications/prompts/list_changed`,`notifications/resources/list_changed`,`notifications/resources/updated`]);var yu=class{_subs=new Map;_serverCapabilities;_serverInfo;constructor(e=hu,t,n){this._maxSubscriptions=e,this._serverCapabilities=t,this._serverInfo=n}setServerCapabilities(e,t){this._serverCapabilities=e,t!==void 0&&(this._serverInfo=t)}has(e){return this._subs.has(e)}serve(e){if(this._serverCapabilities===void 0)throw Error(`StdioListenRouter.serve() called before setServerCapabilities(); refusing to honor a filter without capabilities`);if(this._subs.size>=this._maxSubscriptions)return{jsonrpc:`2.0`,id:e.id,error:{code:-32603,message:`Subscription limit reached`}};let t=_u(e);if(t===void 0)return{jsonrpc:`2.0`,id:e.id,error:{code:-32602,message:`Invalid params: 'notifications' is required and must be a valid SubscriptionFilter`}};let n=mu(t,this._serverCapabilities);return this._subs.set(e.id,n),gu({method:`notifications/subscriptions/acknowledged`,params:{notifications:n}},e.id)}cancel(e){return this._subs.delete(e)}routeOutbound(e){if(!vu.has(e.method))return`passthrough`;let t=e.params?.uri,n=typeof t==`string`?t:void 0,r=bu(e.method,n),i=[];for(let[t,n]of this._subs)pu(n,r)&&i.push(gu({method:e.method,params:e.params??{}},t));return i}teardownAll(){let e=[];for(let t of this._subs.keys())e.push({jsonrpc:`2.0`,id:t,result:{resultType:`complete`,_meta:{[ln]:t,...this._serverInfo!==void 0&&{[cn]:this._serverInfo}}}});return this._subs.clear(),e}};function bu(e,t){switch(e){case`notifications/tools/list_changed`:return{kind:`tools_list_changed`};case`notifications/prompts/list_changed`:return{kind:`prompts_list_changed`};case`notifications/resources/list_changed`:return{kind:`resources_list_changed`};default:return{kind:`resource_updated`,uri:t??``}}}function xu(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??8,roundTimeoutMs:e?.roundTimeoutMs??6e5,legacyShim:e?.legacyShim??!0}}function Su(e,t,n){if(typeof n!=`object`||!n||typeof n.method!=`string`)throw new X(Y.InternalError,`Handler for ${e} returned an invalid input request '${t}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let r=n,i=qi(r);if(i===void 0)throw new X(Y.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${r.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:r,required:i}}function Cu(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function wu(e,t){if(e===`tools/call`)return{content:[{type:`text`,text:t}],isError:!0};throw new X(Y.InternalError,t)}var Tu=class{constructor(e){this._host=e}async fulfill(e,t,n,r,i){let{maxRounds:a,roundTimeoutMs:o}=this._host,s=r.mcpReq.signal,c=i,l=0;for(;;){if(l+=1,l>a)return wu(e,Ts(e,a));let i=c.inputRequests,u=i!=null&&Object.keys(i).length>0,d=typeof c.requestState==`string`?c.requestState:void 0;if(!u&&d===void 0)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);let f;if(u){let t=this._host.resolvedClientCapabilities(r),n=[];for(let[r,a]of Object.entries(i)){let{embedded:i,required:o}=Su(e,r,a);if(i.method!==`roots/list`&&i.params===void 0)throw new X(Y.InternalError,`Handler for ${e} returned an input request '${r}' of kind '${i.method}' without params`);if(Ji(o,t)!==void 0)return wu(e,`Cannot request input '${r}' (${i.method}): the client on this 2025-era connection did not declare the required capability${t===void 0?` (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)`:``}`);n.push([r,i])}let a=Ds(s);try{let e={relatedRequestId:r.mcpReq.id,timeout:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:a.signal},t=await Promise.all(n.map(async([t,n])=>{try{return[t,await this._dispatchLeg(n,e)]}catch(e){throw a.abort(e),e}}));f=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return wu(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{a.dispose()}}else await Es(250,s);let p={...r,mcpReq:{...r.mcpReq,inputResponses:f,droppedInputResponseKeys:void 0,requestState:Rs(d)}};if(d!==void 0){let t=await this._host.verifyRequestState(d,p,e);t!==void 0&&(p=Bs(p,t))}let m=await t(n,p);if(!Fo(m))return m;c=m}}async _dispatchLeg(e,t){switch(e.method){case`elicitation/create`:{let n=e.params;return n.mode===`url`&&n.elicitationId===void 0&&(n={...n,elicitationId:Cu()}),await this._host.sendElicitation(n,t)}case`sampling/createMessage`:return await this._host.sendSampling(e.params,t);case`roots/list`:return await this._host.listRoots(e.params,t)}}};const Eu=new Set([`tools/call`,`prompts/get`,`resources/read`]);let Du,Ou;function ku(e,t){Du(e,t)}function Au(e){return Ou(e)}var ju=class extends Us{_clientCapabilities;_clientVersion;static{Du=(e,t)=>{let n=t.filter(t=>!e._supportedProtocolVersions.includes(t));n.length>0&&(e._supportedProtocolVersions=[...e._supportedProtocolVersions,...n]),e.setRequestHandler(`server/discover`,()=>e._ondiscover())},Ou=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_legacyInputRequiredShim(){return this._legacyShim??=new Tu({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,n)=>this._verifyRequestState(e,t,n),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){if(super(t),this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new su,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=xu(t?.inputRequired),t?.cacheHints!==void 0){for(let[e,n]of Object.entries(t.cacheHints))n!==void 0&&Ra(n,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler(`initialize`,e=>this._oninitialize(e)),this.setNotificationHandler(`notifications/initialized`,()=>this.oninitialized?.()),$i(this._supportedProtocolVersions).length>0&&this.setRequestHandler(`server/discover`,()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}_registerLoggingHandler(){this.setRequestHandler(`logging/setLevel`,async(e,t)=>{let n=t.sessionId||t.http?.req?.headers.get(`mcp-session-id`)||void 0,{level:r}=e.params,i=Yo(ct,r);return i.success&&this._loggingLevels.set(n,i.data),{}})}buildContext(e,t){let n=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(t,n,r)=>{if(!this._capabilities.logging)return Promise.resolve();let i;if(this._servedModernEra()){if(i=e.mcpReq.envelope?.[Je],i===void 0)return Promise.resolve()}else i=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return i!==void 0&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(i)?Promise.resolve():e.mcpReq.notify({method:`notifications/message`,params:{level:t,data:n,logger:r}})},elicitInput:(e,t)=>this.elicitInput(e,t),requestSampling:(e,t)=>this.createMessage(e,t)},http:n?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(ct.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1};registerCapabilities(e){if(this.transport)throw new J(q.AlreadyConnected,`Cannot register capabilities after connecting to transport`);let t=!!this._capabilities.logging;this._capabilities=Gs(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if(e!==`tools/call`){let n=this._cacheHints?.[e],r=Eu.has(e);return n===void 0&&!r?async(n,r)=>{let i=await t(n,r);if(Fo(i))throw new X(Y.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return i}:async(i,a)=>{let o=r?await this._invokeInputRequiredCapableHandler(e,t,i,a):await t(i,a);if(Fo(o)){if(!r)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return o}return n===void 0?o:Pa(o,n)}}return async(e,n)=>{let r=xo(this._negotiatedProtocolVersion),i=r.validateRequest(`tools/call`,e);if(!i.ok)throw new X(i.reason===`not-in-era`?Y.InternalError:Y.InvalidParams,i.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call request: ${i.message}`);let a=await this._invokeInputRequiredCapableHandler(`tools/call`,t,e,n);if(Fo(a))return a;let o=na(a),s=r.validateResult(`tools/call`,o);if(!s.ok)throw new X(s.reason===`not-in-era`?Y.InternalError:Y.InvalidParams,s.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call result: ${s.message}`);return s.value}}_servedModernEra(){return this._negotiatedProtocolVersion!==void 0&&Zi(this._negotiatedProtocolVersion)}async _invokeInputRequiredCapableHandler(e,t,n,r){let i=this._servedModernEra(),a=r.mcpReq.requestState();if(a!==void 0&&typeof a!=`string`)throw new X(Y.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`});let o=r;if(typeof a==`string`){let t=await this._verifyRequestState(a,r,e);t!==void 0&&(o=Bs(r,t))}let s;try{s=await t(n,o)}catch(e){throw e instanceof X&&e.code===Y.UrlElicitationRequired&&i?new X(Y.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`):e}if(!Fo(s))return s;if(!i){if(!this._inputRequiredServing.legacyShim)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??qe}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,n,o,s)}let c=s.inputRequests,l=c!=null&&Object.keys(c).length>0,u=typeof s.requestState==`string`;if(!l&&!u)throw new X(Y.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(l){let t=this._inputRequestCapabilityView(r);for(let[n,r]of Object.entries(c)){let{embedded:i,required:a}=Su(e,n,r),o=Ji(a,t);if(o!==void 0)throw new Ha({requiredCapabilities:o},`Cannot request input '${n}' (${i.method}): the request's client capabilities do not declare the required capability`)}}return s}async _verifyRequestState(e,t,n){if(this._requestStateVerify!==void 0)try{return await this._requestStateVerify(e,t)}catch(e){throw this.onerror?.(Error(`requestState verification rejected ${n}: ${e instanceof Error?e.message:String(e)}`)),new X(Y.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[p]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new J(q.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${e}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:e,era:`2026-07-28`})}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw new J(q.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw new J(q.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw new J(q.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw new J(q.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw new J(q.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw new J(q.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw new J(q.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw new J(q.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){switch(e){case`completion/complete`:if(!this._capabilities.completions)throw new J(q.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw new J(q.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw new J(q.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw new J(q.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw new J(q.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case`ping`:case`initialize`:break}}async _oninitialize(e){let t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;let n=Qi(this._supportedProtocolVersions),r=n.includes(t)?t:n[0]??qe;return this._negotiatedProtocolVersion=r,this.transport?.setProtocolVersion?.(r),{protocolVersion:r,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:$i(this._supportedProtocolVersions),capabilities:Mu(this.getCapabilities()),...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(e,t){return this._wireCodec().projectCallToolResult(e,t)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra(`ping`),this.request({method:`ping`})}async createMessage(e,t){if(this._assertPushApiInServedEra(`sampling/createMessage`),(e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new J(q.CapabilityNotSupported,`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages.at(-1),n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages.at(-2):void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw new X(Y.InvalidParams,`The last message must contain only tool_result content if any is present`);if(!o)throw new X(Y.InvalidParams,`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new X(Y.InvalidParams,`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}let n=!!(e.tools||e.toolChoice),r=await this.request({method:`sampling/createMessage`,params:e},t),i=this._wireCodec().samplingResultVariant(n,r);if(!i.ok)throw new J(q.InvalidResult,`Invalid sampling/createMessage result: ${i.reason===`invalid`?i.message:i.reason}`);return i.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra(`elicitation/create`),e.mode??`form`){case`url`:if(!this._clientCapabilities?.elicitation?.url)throw new J(q.CapabilityNotSupported,`Client does not support url elicitation.`);break;case`form`:if(!this._clientCapabilities?.elicitation?.form)throw new J(q.CapabilityNotSupported,`Client does not support form elicitation.`);break}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,n){let r=e.mode??`form`,i=n?.validateAcceptedContent??!0;switch(r){case`url`:{let n=e;return this.request({method:`elicitation/create`,params:n},t)}case`form`:{let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},t);if(i&&r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new X(Y.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof X?e:new X(Y.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new J(q.CapabilityNotSupported,`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this._assertPushApiInServedEra(`roots/list`),this.request({method:`roots/list`,params:e},t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};function Mu(e){return{...e}}var Nu=class{server;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(!(t===void 0||!t.enabled)){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(t.inputSchema===void 0)return Fu;try{let n=es(t.inputSchema,`input`);return this._toolInputSchemaJson[e]=n,n}catch{return}}}constructor(e,t){this.server=new ju(e,t),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||=(this.server.assertCanSetRequestHandler(`tools/list`),this.server.assertCanSetRequestHandler(`tools/call`),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler(`tools/list`,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?es(t.inputSchema,`input`):Fu,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(n.outputSchema=es(t.outputSchema,`output`)),n})})),this.server.setRequestHandler(`tools/call`,async(e,t)=>{let n=this._registeredTools[e.params.name];if(!n)throw new X(Y.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new X(Y.InvalidParams,`Tool ${e.params.name} disabled`);try{let r=await this.validateToolInput(n,e.params.arguments,e.params.name),i=await this.executeToolHandler(n,r,t);return await this.validateToolOutput(n,i,e.params.name),Fo(i)?i:this.server.projectCallToolResult(i,n.outputSchemaJson)}catch(e){if(e instanceof X&&e.code===Y.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(!e.inputSchema)return;let r=await rs(e.inputSchema,t??{});if(!r.success)throw new X(Y.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${r.error}`);return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||Fo(t)||t.isError)return;if(t.structuredContent===void 0)throw new X(Y.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await rs(e.outputSchema,t.structuredContent);if(!r.success)throw new X(Y.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${r.error}`)}async executeToolHandler(e,t,n){return e.executor(t,n)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||=(this.server.assertCanSetRequestHandler(`completion/complete`),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(`completion/complete`,async e=>{switch(e.params.ref.type){case`ref/prompt`:return Lo(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return Ro(e),this.handleResourceCompletion(e,e.params.ref);default:throw new X(Y.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new X(Y.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new X(Y.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return zu;let r=Hu(Bu(n.argsSchema)?.[e.params.argument.name]);if(!lu(r))return zu;let i=uu(r);return i?Ru(await i(e.params.argument.value,e.params.context)):zu}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return zu;throw new X(Y.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?Ru(await r(e.params.argument.value,e.params.context)):zu}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||=(this.server.assertCanSetRequestHandler(`resources/list`),this.server.assertCanSetRequestHandler(`resources/templates/list`),this.server.assertCanSetRequestHandler(`resources/read`),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler(`resources/list`,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),this.server.setRequestHandler(`resources/templates/list`,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(`resources/read`,async(e,t)=>{let n;try{n=new URL(e.params.uri)}catch{throw new X(Y.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:`invalid_uri`})}let r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new X(Y.InvalidParams,`Resource ${n} disabled`);return Pa(await r.readCallback(n,t),r.cacheHint)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r)return Pa(await e.readCallback(n,r,t),e.cacheHint)}throw new za(e.params.uri)}),!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||=(this.server.assertCanSetRequestHandler(`prompts/list`),this.server.assertCanSetRequestHandler(`prompts/get`),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler(`prompts/list`,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?ds(t.argsSchema):void 0,icons:t.icons,_meta:t._meta}))})),this.server.setRequestHandler(`prompts/get`,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new X(Y.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new X(Y.InvalidParams,`Prompt ${e.params.name} disabled`);return n.handler(e.params.arguments,t)}),!0)}registerResource(e,t,n,r){let i=n.cacheHint,a=n;if(i!==void 0){Ra(i,`resource ${e}`);let t={...n};delete t.cacheHint,a=t}if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let o=this._createRegisteredResource(e,n.title,t,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,n.title,t,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,t,n,r,i){let a={name:e,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=a)),e.name!==void 0&&(a.name=e.name),e.title!==void 0&&(a.title=e.title),e.metadata!==void 0&&(a.metadata=e.metadata),e.callback!==void 0&&(a.readCallback=e.callback),e.enabled!==void 0&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(e,t,n,r,i){let a={resourceTemplate:n,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.template!==void 0&&(a.resourceTemplate=t.template),t.metadata!==void 0&&(a.metadata=t.metadata),t.callback!==void 0&&(a.readCallback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,n,r,i,a,o){let s=r,c=i,l={title:t,description:n,argsSchema:r,icons:a,_meta:o,handler:Lu(e,r,i),enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=l)),t.title!==void 0&&(l.title=t.title),t.description!==void 0&&(l.description=t.description),t.icons!==void 0&&(l.icons=t.icons),t._meta!==void 0&&(l._meta=t._meta);let n=!1;t.argsSchema!==void 0&&(l.argsSchema=t.argsSchema,s=t.argsSchema,n=!0),t.callback!==void 0&&(c=t.callback,n=!0),n&&(l.handler=Lu(e,s,c)),t.enabled!==void 0&&(l.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=l,r){let e=Bu(r);e&&Object.values(e).some(e=>lu(Hu(e)))&&this.setCompletionRequestHandler()}return l}_createRegisteredTool(e,t,n,r,i,a,o,s,c,l){if(ic(e),r!==void 0)try{let t=es(r,`input`);this._toolInputSchemaJson[e]=t;let n=Ho(t);n.valid||console.warn(`[mcp-sdk] tool '${e}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${n.reason}`)}catch{}let u=l,d={title:t,description:n,inputSchema:r,outputSchema:i,outputSchemaJson:Iu(i),annotations:a,icons:o,execution:s,_meta:c,handler:l,executor:Pu(r,l),enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&ic(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=d,e=t.name)),t.title!==void 0&&(d.title=t.title),t.description!==void 0&&(d.description=t.description);let n=!1;t.paramsSchema!==void 0&&(d.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],n=!0),t.callback!==void 0&&(d.handler=t.callback,u=t.callback,n=!0),n&&(d.executor=Pu(d.inputSchema,u)),t.outputSchema!==void 0&&(d.outputSchema=t.outputSchema,d.outputSchemaJson=Iu(t.outputSchema)),t.annotations!==void 0&&(d.annotations=t.annotations),t.icons!==void 0&&(d.icons=t.icons),t._meta!==void 0&&(d._meta=t._meta),t.enabled!==void 0&&(d.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,icons:c,_meta:l}=t;return this._createRegisteredTool(e,r,i,cc(a),cc(o),s,c,void 0,l,n)}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a,icons:o,_meta:s}=t,c=this._createRegisteredPrompt(e,r,i,cc(a),n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};function Pu(e,t){if(e){let e=t;return async(t,n)=>e(t,n)}let n=t;return async(e,t)=>n(t)}const Fu={type:`object`,properties:{}};function Iu(e){if(e!==void 0)try{return es(e,`output`)}catch{return}}function Lu(e,t,n){if(t){let r=n;return async(n,i)=>{let a=await rs(t,n);if(!a.success)throw new X(Y.InvalidParams,`Invalid arguments for prompt ${e}: ${a.error}`);return r(a.data,i)}}else{let e=n;return async(t,n)=>e(n)}}function Ru(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}const zu={completion:{values:[],hasMore:!1}};function Bu(e){let t=e;if(t.shape&&typeof t.shape==`object`)return t.shape}function Vu(e){return e?.type===`optional`}function Hu(e){return Vu(e)?e.def?.innerType??e:e}var Uu=class{sessionIdGenerator;_started=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId=`_GET_stream`;_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;sessionId;onclose;onerror;onmessage;constructor(e={}){this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval,this._supportedProtocolVersions=e.supportedProtocolVersions??un,this._keepAliveMs=e.keepAliveMs??15e3}startKeepAlive(e,t){if(this._closed)return;let n=fu(this._keepAliveMs,()=>{try{e.enqueue(t.encode(`: keepalive
12
13
 
13
14
  `))}catch{n!==void 0&&clearInterval(n)}});return n}async start(){if(this._started)throw Error(`Transport already started`);this._started=!0}setSupportedProtocolVersions(e){this._supportedProtocolVersions=e}createJsonErrorResponse(e,t,n,r){let i={code:t,message:n};return r?.data!==void 0&&(i.data=r.data),Response.json({jsonrpc:`2.0`,error:i,id:null},{status:e,headers:{"Content-Type":`application/json`,...r?.headers}})}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let t=e.headers.get(`host`);if(!t||!this._allowedHosts.includes(t)){let e=`Invalid Host header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let t=e.headers.get(`origin`);if(t&&!this._allowedOrigins.includes(t)){let e=`Invalid Origin header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}}}async handleRequest(e,t){if(this._closed)return this.createJsonErrorResponse(404,-32001,`Session not found`);let n=this.validateRequestHeaders(e);if(n)return n;switch(e.method){case`POST`:return this.handlePostRequest(e,t);case`GET`:return this.handleGetRequest(e);case`DELETE`:return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(e){return this._supportedProtocolVersions.includes(e)&&e>=`2025-11-25`}async writePrimingEvent(e,t,n,r){if(!this._eventStore||!this.supportsEmptySSEData(r))return;let i=await this._eventStore.storeEvent(n,{}),a=`id: ${i}\ndata: \n\n`;this._retryInterval!==void 0&&(a=`id: ${i}\nretry: ${this._retryInterval}\ndata: \n\n`),e.enqueue(t.encode(a))}async handleGetRequest(e){if(!e.headers.get(`accept`)?.includes(`text/event-stream`))return this.onerror?.(Error(`Not Acceptable: Client must accept text/event-stream`)),this.createJsonErrorResponse(406,-32e3,`Not Acceptable: Client must accept text/event-stream`);let t=this.validateSession(e);if(t)return t;let n=this.validateProtocolVersion(e);if(n)return n;if(this._eventStore){let t=e.headers.get(`last-event-id`);if(t)return this.replayEvents(t)}if(this._streamMapping.get(this._standaloneSseStreamId)!==void 0)return this.onerror?.(Error(`Conflict: Only one SSE stream is allowed per session`)),this.createJsonErrorResponse(409,-32e3,`Conflict: Only one SSE stream is allowed per session`);let r=new TextEncoder,i,a,o=new ReadableStream({start:e=>{i=e},cancel:()=>{a!==void 0&&clearInterval(a),this._streamMapping.get(this._standaloneSseStreamId)?.controller===i&&this._streamMapping.delete(this._standaloneSseStreamId)}}),s={"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`};return this.sessionId!==void 0&&(s[`mcp-session-id`]=this.sessionId),this._streamMapping.set(this._standaloneSseStreamId,{controller:i,encoder:r,cleanup:()=>{a!==void 0&&clearInterval(a),this._streamMapping.delete(this._standaloneSseStreamId);try{i.close()}catch{}}}),a=this.startKeepAlive(i,r),new Response(o,{headers:s})}async replayEvents(e){if(!this._eventStore)return this.onerror?.(Error(`Event store not configured`)),this.createJsonErrorResponse(400,-32e3,`Event store not configured`);try{let t;if(this._eventStore.getStreamIdForEventId){if(t=await this._eventStore.getStreamIdForEventId(e),!t)return this.onerror?.(Error(`Invalid event ID format`)),this.createJsonErrorResponse(400,-32e3,`Invalid event ID format`);if(this._streamMapping.get(t)!==void 0)return this.onerror?.(Error(`Conflict: Stream already has an active connection`)),this.createJsonErrorResponse(409,-32e3,`Conflict: Stream already has an active connection`)}let n={"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`};this.sessionId!==void 0&&(n[`mcp-session-id`]=this.sessionId);let r=new TextEncoder,i,a,o=!1,s,c=new ReadableStream({start:e=>{i=e},cancel:()=>{o=!0,a!==void 0&&clearInterval(a),s!==void 0&&this._streamMapping.get(s)?.controller===i&&this._streamMapping.delete(s)}}),l=new Set;if(s=await this._eventStore.replayEventsAfter(e,{send:async(e,t)=>{if(l.add(e),!this.writeSSEEvent(i,r,t,e))try{i.close()}catch{}}}),this._closed||o){try{i.close()}catch{}return this.createJsonErrorResponse(404,-32001,`Session not found`)}if(this._streamMapping.get(s)?.cleanup(),this._streamMapping.set(s,{controller:i,encoder:r,replayedEventIds:l,cleanup:()=>{a!==void 0&&clearInterval(a),this._streamMapping.delete(s);try{i.close()}catch{}}}),s!==this._standaloneSseStreamId&&![...this._requestToStreamMapping.values()].includes(s)){this._streamMapping.delete(s);try{i.close()}catch{}}return this._streamMapping.get(s)?.controller===i&&(a=this.startKeepAlive(i,r)),new Response(c,{headers:n})}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(500,-32e3,`Error replaying events`)}}writeSSEEvent(e,t,n,r){try{let i=`event: message
14
- `;return r&&(i+=`id: ${r}\n`),i+=`data: ${JSON.stringify(n)}\n\n`,e.enqueue(t.encode(i)),!0}catch(e){return this.onerror?.(e),!1}}handleUnsupportedRequest(){return this.onerror?.(Error(`Method not allowed.`)),Response.json({jsonrpc:`2.0`,error:{code:-32e3,message:`Method not allowed.`},id:null},{status:405,headers:{Allow:`GET, POST, DELETE`,"Content-Type":`application/json`}})}async handlePostRequest(e,t){try{let n=e.headers.get(`accept`);if(!n?.includes(`application/json`)||!n.includes(`text/event-stream`))return this.onerror?.(Error(`Not Acceptable: Client must accept both application/json and text/event-stream`)),this.createJsonErrorResponse(406,-32e3,`Not Acceptable: Client must accept both application/json and text/event-stream`);if(!Hs(e.headers.get(`content-type`)))return this.onerror?.(Error(`Unsupported Media Type: Content-Type must be application/json`)),this.createJsonErrorResponse(415,-32e3,`Unsupported Media Type: Content-Type must be application/json`);let r=e,i;if(t?.parsedBody===void 0)try{i=await e.json()}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,`Parse error: Invalid JSON`)}else i=t.parsedBody;let a;try{a=Array.isArray(i)?i.map(e=>Ve.parse(e)):[Ve.parse(i)]}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,`Parse error: Invalid JSON-RPC message`)}if(this._closed)return this.createJsonErrorResponse(404,-32001,`Session not found`);let o=a.some(e=>Do(e));if(o){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(Error(`Invalid Request: Server already initialized`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Server already initialized`);if(a.length>1)return this.onerror?.(Error(`Invalid Request: Only one initialization request is allowed`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Only one initialization request is allowed`);this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!o){let t=this.validateSession(e);if(t)return t;let n=this.validateProtocolVersion(e);if(n)return n}if(this._closed)return this.createJsonErrorResponse(404,-32001,`Session not found`);if(!a.some(e=>Z(e))){for(let e of a)this.onmessage?.(e,{authInfo:t?.authInfo,request:r});return new Response(null,{status:202})}let s=crypto.randomUUID(),c=a.find(e=>Do(e)),l=c?c.params.protocolVersion:e.headers.get(`mcp-protocol-version`)??ue;if(this._enableJsonResponse)return new Promise(e=>{this._streamMapping.set(s,{resolveJson:e,cleanup:()=>{this._streamMapping.delete(s)}});for(let e of a)Z(e)&&this._requestToStreamMapping.set(e.id,s);for(let e of a)this.onmessage?.(e,{authInfo:t?.authInfo,request:r})});let u=new TextEncoder,d,f,p=new ReadableStream({start:e=>{d=e},cancel:()=>{f!==void 0&&clearInterval(f),this._streamMapping.get(s)?.controller===d&&this._streamMapping.delete(s)}}),m={"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`};this.sessionId!==void 0&&(m[`mcp-session-id`]=this.sessionId);for(let e of a)Z(e)&&(this._streamMapping.set(s,{controller:d,encoder:u,cleanup:()=>{f!==void 0&&clearInterval(f),this._streamMapping.delete(s);try{d.close()}catch{}}}),this._requestToStreamMapping.set(e.id,s));await this.writePrimingEvent(d,u,s,l);for(let e of a){let n,i;Z(e)&&this._eventStore&&this.supportsEmptySSEData(l)&&(n=()=>{this.closeSSEStream(e.id)},i=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(e,{authInfo:t?.authInfo,request:r,closeSSEStream:n,closeStandaloneSSEStream:i})}return this._streamMapping.get(s)?.controller===d&&(f=this.startKeepAlive(d,u)),new Response(p,{status:200,headers:m})}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,`Parse error`,{data:String(e)})}}async handleDeleteRequest(e){let t=this.validateSession(e);if(t)return t;let n=this.validateProtocolVersion(e);if(n)return n;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(Error(`Bad Request: Server not initialized`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Server not initialized`);let t=e.headers.get(`mcp-session-id`);if(!t)return this.onerror?.(Error(`Bad Request: Mcp-Session-Id header is required`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Mcp-Session-Id header is required`);if(t!==this.sessionId)return this.onerror?.(Error(`Session not found`)),this.createJsonErrorResponse(404,-32001,`Session not found`)}validateProtocolVersion(e){let t=e.headers.get(`mcp-protocol-version`);if(t!==null&&!this._supportedProtocolVersions.includes(t)){let e=`Bad Request: Unsupported protocol version: ${t} (supported versions: ${this._supportedProtocolVersions.join(`, `)})`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(400,-32e3,e)}}async close(){if(!this._closed){this._closed=!0;for(let{cleanup:e}of this._streamMapping.values())e();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}}closeSSEStream(e){let t=this._requestToStreamMapping.get(e);if(!t)return;let n=this._streamMapping.get(t);n&&n.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,t){let n=t?.relatedRequestId;if((wo(e)||To(e))&&(n=e.id),n===void 0){if(wo(e)||To(e))throw Error(`Cannot send a response on a standalone SSE stream unless resuming a previous client request`);let t;this._eventStore&&(t=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let n=this._streamMapping.get(this._standaloneSseStreamId);if(n===void 0)return;n.controller&&n.encoder&&(t===void 0||!n.replayedEventIds?.has(t))&&this.writeSSEEvent(n.controller,n.encoder,e,t);return}let r=this._requestToStreamMapping.get(n);if(!r)throw Error(`No connection established for request ID: ${String(n)}`);let i=this._streamMapping.get(r);if(!this._enableJsonResponse){let t;this._eventStore&&(t=await this._eventStore.storeEvent(r,e),i=this._streamMapping.get(r)),i?.controller&&i?.encoder&&(t===void 0||!i.replayedEventIds?.has(t))&&this.writeSSEEvent(i.controller,i.encoder,e,t)}if(wo(e)||To(e)){this._requestResponseMap.set(n,e);let t=[...this._requestToStreamMapping.entries()].filter(([e,t])=>t===r).map(([e])=>e);if(t.every(e=>this._requestResponseMap.has(e))){if(!i){if(this._enableJsonResponse)throw Error(`No connection established for request ID: ${String(n)}`);if(!this._eventStore){this.onerror?.(Error(`Response for request ID ${String(n)} is undeliverable: per-request stream is disconnected and no eventStore is configured`));for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}if(this._enableJsonResponse&&i.resolveJson){let e={"Content-Type":`application/json`};this.sessionId!==void 0&&(e[`mcp-session-id`]=this.sessionId);let n=t.map(e=>this._requestResponseMap.get(e));n.length===1?i.resolveJson(Response.json(n[0],{status:200,headers:e})):i.resolveJson(Response.json(n,{status:200,headers:e})),i.cleanup()}else i.cleanup();for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e)}}}},Fu=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},Iu=e=>e instanceof Fu?e:new Fu(e.message,{cause:e}),Lu=global.Request,Ru=class extends Lu{constructor(e,t){typeof e==`object`&&Hu in e&&(e=e[Hu]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},zu=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},Bu=Symbol(`wrapBodyStream`),Vu=(e,t,n,r,i)=>{let a={method:e,headers:n,signal:i.signal};if(e===`TRACE`){a.method=`GET`;let e=new Ru(t,a);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)a.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[Bu]){let e;a.body=new ReadableStream({async pull(t){try{e||=br.toWeb(r).getReader();let{done:n,value:i}=await e.read();n?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else a.body=br.toWeb(r);return new Ru(t,a)},Hu=Symbol(`getRequestCache`),Uu=Symbol(`requestCache`),Wu=Symbol(`incomingKey`),Gu=Symbol(`urlKey`),Ku=Symbol(`headersKey`),qu=Symbol(`abortControllerKey`),Ju={get method(){return this[Wu].method||`GET`},get url(){return this[Gu]},get headers(){return this[Ku]||=zu(this[Wu])},[Symbol(`getAbortController`)](){return this[Hu](),this[qu]},[Hu](){return this[qu]||=new AbortController,this[Uu]||=Vu(this.method,this[Gu],this.headers,this[Wu],this[qu])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(Ju,e,{get(){return this[Hu]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(Ju,e,{value:function(){return this[Hu]()[e]()}})}),Object.defineProperty(Ju,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){let r={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[Uu]};return`Request (lightweight) ${n(r,{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(Ju,Ru.prototype);var Yu=(e,t)=>{let n=Object.create(Ju);n[Wu]=e;let r=e.url||``;if(r[0]!==`/`&&(r.startsWith(`http://`)||r.startsWith(`https://`))){if(e instanceof wr)throw new Fu(`Absolute URL for :path is not allowed in HTTP/2`);try{n[Gu]=new URL(r).href}catch(e){throw new Fu(`Invalid absolute URL`,{cause:e})}return n}let i=(e instanceof wr?e.authority:e.headers.host)||t;if(!i)throw new Fu(`Missing host header`);let a;if(e instanceof wr){if(a=e.scheme,!(a===`http`||a===`https`))throw new Fu(`Unsupported scheme`)}else a=e.socket&&e.socket.encrypted?`https`:`http`;let o=new URL(`${a}://${i}${r}`);if(o.hostname.length!==i.length&&o.hostname!==i.replace(/:\d+$/,``))throw new Fu(`Invalid host header`);return n[Gu]=o.href,n},Xu=Symbol(`responseCache`),Zu=Symbol(`getResponseCache`),Qu=Symbol(`cache`),$u=global.Response,ed=class e{#body;#init;[Zu](){return delete this[Qu],this[Xu]||=new $u(this.#body,this.#init)}constructor(t,n){let r;if(this.#body=t,n instanceof e){let e=n[Xu];if(e){this.#init=e,this[Zu]();return}else this.#init=n.#init,r=new Headers(n.#init.headers)}else this.#init=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[Qu]=[n?.status||200,t,r||n?.headers])}get headers(){let e=this[Qu];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":`text/plain; charset=UTF-8`})),e[2]):this[Zu]().headers}get status(){return this[Qu]?.[0]??this[Zu]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(ed.prototype,e,{get(){return this[Zu]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(ed.prototype,e,{value:function(){return this[Zu]()[e]()}})}),Object.defineProperty(ed.prototype,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){let r={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[Xu]};return`Response (lightweight) ${n(r,{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(ed,$u),Object.setPrototypeOf(ed.prototype,$u.prototype);async function td(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function nd(e,t,n){let r=t=>{e.cancel(t).catch(()=>{})};return t.on(`close`,r),t.on(`error`,r),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off(`close`,r),t.off(`error`,r)});function i(e){e&&t.destroy(e)}function a(){e.read().then(o,i)}function o({done:n,value:r}){try{if(n)t.end();else if(!t.write(r))t.once(`drain`,a);else return e.read().then(o,i)}catch(e){i(e)}}}function rd(e,t){if(e.locked)throw TypeError(`ReadableStream is locked.`);return t.destroyed?void 0:nd(e.getReader(),t)}var id=e=>{let t={};e instanceof Headers||(e=new Headers(e??void 0));let n=[];for(let[r,i]of e)r===`set-cookie`?n.push(i):t[r]=i;return n.length>0&&(t[`set-cookie`]=n),t[`content-type`]??=`text/plain; charset=UTF-8`,t},ad=`x-hono-already-sent`;global.crypto===void 0&&(global.crypto=dr);var od=Symbol(`outgoingEnded`),sd=Symbol(`incomingDraining`),cd=500,ld=64*1024*1024,ud=e=>{let t=e;if(e.destroyed||t[sd])return;if(t[sd]=!0,e instanceof wr){try{e.stream?.close?.(Tr.NGHTTP2_NO_ERROR)}catch{}return}let n=0,r=()=>{clearTimeout(a),e.off(`data`,o),e.off(`end`,r),e.off(`error`,r)},i=()=>{r();let t=e.socket;t&&!t.destroyed&&t.destroySoon()},a=setTimeout(i,cd);a.unref?.();let o=e=>{n+=e.length,n>ld&&i()};e.on(`data`,o),e.on(`end`,r),e.on(`error`,r),e.resume()},dd=()=>new Response(null,{status:400}),fd=e=>new Response(null,{status:e instanceof Error&&(e.name===`TimeoutError`||e.constructor.name===`TimeoutError`)?504:500}),pd=(e,t)=>{let n=e instanceof Error?e:Error(`unknown error`,{cause:e});n.code===`ERR_STREAM_PREMATURE_CLOSE`?console.info(`The user aborted a request.`):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":`text/plain`}),t.end(`Error: ${n.message}`),t.destroy(n))},md=e=>{`flushHeaders`in e&&e.writable&&e.flushHeaders()},hd=async(e,t)=>{let[n,r,i]=e[Qu],a=!1;if(!i)i={"content-type":`text/plain; charset=UTF-8`};else if(i instanceof Headers)a=i.has(`content-length`),i=id(i);else if(Array.isArray(i)){let e=new Headers(i);a=e.has(`content-length`),i=id(e)}else for(let e in i)if(e.length===14&&e.toLowerCase()===`content-length`){a=!0;break}a||(typeof r==`string`?i[`Content-Length`]=Buffer.byteLength(r):r instanceof Uint8Array?i[`Content-Length`]=r.byteLength:r instanceof Blob&&(i[`Content-Length`]=r.size)),t.writeHead(n,i),typeof r==`string`||r instanceof Uint8Array?t.end(r):r instanceof Blob?t.end(new Uint8Array(await r.arrayBuffer())):(md(t),await rd(r,t)?.catch(e=>pd(e,t))),t[od]?.()},gd=e=>typeof e.then==`function`,_d=async(e,t,n={})=>{if(gd(e))if(n.errorHandler)try{e=await e}catch(t){let r=await n.errorHandler(t);if(!r)return;e=r}else e=await e.catch(fd);if(Qu in e)return hd(e,t);let r=id(e.headers);if(e.body){let n=e.body.getReader(),i=[],a=!1,o;if(r[`transfer-encoding`]!==`chunked`){let e=2;for(let t=0;t<e;t++){o||=n.read();let r=await td(o).catch(e=>{console.error(e),a=!0});if(!r){if(t===1){await new Promise(e=>setTimeout(e)),e=3;continue}break}if(o=void 0,r.value&&i.push(r.value),r.done){a=!0;break}}a&&!(`content-length`in r)&&(r[`content-length`]=i.reduce((e,t)=>e+t.length,0))}t.writeHead(e.status,r),i.forEach(e=>{t.write(e)}),a?t.end():(i.length===0&&md(t),await nd(n,t,o))}else r[ad]||(t.writeHead(e.status,r),t.end());t[od]?.()},vd=(e,t={})=>{let n=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==Ru&&(Object.defineProperty(global,`Request`,{value:Ru}),Object.defineProperty(global,`Response`,{value:ed})),async(r,i)=>{let a,o;try{o=Yu(r,t.hostname);let s=!n||r.method===`GET`||r.method===`HEAD`;if(s||(r[Bu]=!0,r.on(`end`,()=>{s=!0}),r instanceof wr&&(i[od]=()=>{s||setTimeout(()=>{s||setTimeout(()=>{ud(r)})})}),i.on(`finish`,()=>{s||ud(r)})),i.on(`close`,()=>{o[qu]&&(r.errored?o[qu].abort(r.errored.toString()):i.writableFinished||o[qu].abort(`Client connection prematurely closed.`)),s||setTimeout(()=>{s||setTimeout(()=>{ud(r)})})}),a=e(o,{incoming:r,outgoing:i}),Qu in a)return hd(a,i)}catch(e){if(a)return pd(e,i);if(t.errorHandler){if(a=await t.errorHandler(o?e:Iu(e)),!a)return}else a=o?fd(e):dd()}try{return await _d(a,i,t)}catch(e){return pd(e,i)}}},yd=class{_webStandardTransport;_requestListener;_requestContext=new WeakMap;constructor(e={}){this._webStandardTransport=new Pu(e),this._requestListener=vd(async e=>{let t=this._requestContext.get(e);return this._webStandardTransport.handleRequest(e,{authInfo:t?.authInfo,parsedBody:t?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(e){this._webStandardTransport.onclose=e}get onclose(){return this._webStandardTransport.onclose}set onerror(e){this._webStandardTransport.onerror=e}get onerror(){return this._webStandardTransport.onerror}set onmessage(e){this._webStandardTransport.onmessage=e}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(e,t){return this._webStandardTransport.send(e,t)}setSupportedProtocolVersions(e){this._webStandardTransport.setSupportedProtocolVersions(e)}async handleRequest(e,t,n){let r=e.auth;await vd(async e=>this._webStandardTransport.handleRequest(e,{authInfo:r,parsedBody:n}),{overrideGlobalObjects:!1})(e,t)}closeSSEStream(e){this._webStandardTransport.closeSSEStream(e)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};const bd=(e,t)=>new Promise((n,r)=>{let i=[],a=0;e.on(`data`,n=>{if(a+=n.length,a>t){r(Error(`request entity too large (limit ${t} bytes)`)),e.destroy();return}i.push(n)}),e.on(`end`,()=>n(Buffer.concat(i).toString(`utf-8`))),e.on(`error`,r)});var xd=class{onclose;onerror;onmessage;get sessionId(){return this._sessionId}_sessionId;_sseResponse;constructor(e,t){this._endpoint=e,this.res=t,this._sessionId=_r()}async close(){this._sseResponse?.end(),this._sseResponse=void 0,this.onclose?.()}async handleMessage(e,t){let n;try{n=Ve.parse(e)}catch(e){throw this.onerror?.(e),e}this.onmessage?.(n,t)}async handlePostMessage(e,t,n){if(!this._sseResponse){let e=`SSE connection not established`;throw t.writeHead(500).end(e),Error(e)}let r=e.auth,i;try{let t=e.headers[`content-type`]??``;if(t.split(`;`)[0].trim().toLowerCase()!==`application/json`)throw Error(`Unsupported content-type: ${t}`);i=n??await bd(e,4194304)}catch(e){t.writeHead(400).end(String(e)),this.onerror?.(e);return}try{await this.handleMessage(typeof i==`string`?JSON.parse(i):i,{authInfo:r})}catch{t.writeHead(400).end(`Invalid message: ${i}`);return}t.writeHead(202).end(`Accepted`)}async send(e){if(!this._sseResponse)throw Error(`Not connected`);this._sseResponse.write(`event: message\ndata: ${JSON.stringify(e)}\n\n`)}async start(){if(this._sseResponse)throw Error(`SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this.res.writeHead(200,{"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"Content-Type":`text/event-stream`});let e=new Er(this._endpoint,`http://localhost`);e.searchParams.set(`sessionId`,this._sessionId);let t=e.pathname+e.search+e.hash;this.res.write(`event: endpoint\ndata: ${t}\n\n`),this._sseResponse=this.res,this.res.on(`close`,()=>{this._sseResponse=void 0,this.onclose?.()})}};const Sd=e=>new Promise(t=>{let n=[],r;e.on(`data`,e=>{n.push(e)}).on(`end`,()=>{r=Buffer.concat(n).toString();try{t(JSON.parse(r))}catch(n){a.error(`Error parsing body`,{bodyLength:r.length,bodyPreview:r.substring(0,100),contentType:e.headers[`content-type`],error:n}),t(null)}})}),Cd=(e,t)=>JSON.stringify({error:{code:e,message:t},id:null,jsonrpc:`2.0`}),wd=(e,t)=>{if(e instanceof Response){let n={};return e.headers.forEach((e,t)=>{n[t]?Array.isArray(n[t])?n[t].push(e):n[t]=[n[t],e]:n[t]=e}),t.writeHead(e.status,e.statusText,n).end(e.statusText),!0}return!1},Td=async(e,t)=>{t&&await t(e);try{await e.close()}catch(t){a.error(`Error closing server`,{error:t,serverType:typeof e})}},Ed=async({activeTransports:e,createServer:t,enableJsonResponse:n,endpoint:r,eventStore:i,onClose:o,onConnect:s,req:c,res:l,stateless:u})=>{if(c.method===`POST`&&new URL(c.url,`http://localhost`).pathname===r){try{let r=Array.isArray(c.headers[`mcp-session-id`])?c.headers[`mcp-session-id`][0]:c.headers[`mcp-session-id`],a,d,f=await Sd(c);if(r){let t=e[r];if(!t)return l.setHeader(`Content-Type`,`application/json`),l.writeHead(404).end(Cd(-32001,`Session not found`)),!0;a=t.transport,d=t.server}else if(!r&&Do(f)){a=new yd({enableJsonResponse:n,eventStore:i||new Or,onsessioninitialized:t=>{!u&&t&&(e[t]={server:d,transport:a})},sessionIdGenerator:u?void 0:_r});let r=!1;a.onclose=async()=>{let t=a.sessionId;r||(r=!0,!u&&t&&e[t]?(await Td(d,o),delete e[t]):u&&await Td(d,o))};try{d=await t(c)}catch(e){return wd(e,l)||l.writeHead(500).end(`Error creating server`),!0}return d.connect(a),s&&await s(d),await a.handleRequest(c,l,f),!0}else if(u&&!r&&!Do(f)){a=new yd({enableJsonResponse:n,eventStore:i||new Or,onsessioninitialized:()=>{},sessionIdGenerator:void 0});try{d=await t(c)}catch(e){return wd(e,l)||l.writeHead(500).end(`Error creating server`),!0}return d.connect(a),s&&await s(d),await a.handleRequest(c,l,f),!0}else return l.setHeader(`Content-Type`,`application/json`),l.writeHead(400).end(Cd(-32e3,`Bad Request: No valid session ID provided`)),!0;return await a.handleRequest(c,l,f),!0}catch(e){a.error(`Error handling request`,{error:e}),l.setHeader(`Content-Type`,`application/json`),l.writeHead(500).end(Cd(-32603,`Internal Server Error`))}return!0}if(c.method===`GET`&&new URL(c.url,`http://localhost`).pathname===r){let t=c.headers[`mcp-session-id`],n=t?e[t]:void 0;if(!t)return l.writeHead(400).end(`No sessionId`),!0;if(!n)return l.writeHead(400).end(`No active transport`),!0;let r=c.headers[`last-event-id`];return r?a.info(`Client reconnecting with Last-Event-ID for session`,{lastEventId:r,sessionId:t}):a.info(`Establishing new SSE stream for session`,{sessionId:t}),await n.transport.handleRequest(c,l),!0}if(c.method===`DELETE`&&new URL(c.url,`http://localhost`).pathname===r){a.info(`Received delete request`);let t=c.headers[`mcp-session-id`];if(!t)return l.writeHead(400).end(`Invalid or missing sessionId`),!0;a.info(`Received delete request for session`,{sessionId:t});let n=e[t];if(!n)return l.writeHead(400).end(`No active transport`),!0;try{await n.transport.handleRequest(c,l),await Td(n.server,o)}catch(e){a.error(`Error handling delete request`,{error:e}),l.writeHead(500).end(`Error handling delete request`)}return!0}return!1},Dd=async({activeTransports:e,createServer:t,endpoint:n,onClose:r,onConnect:i,req:o,res:s})=>{if(o.method===`GET`&&new URL(o.url,`http://localhost`).pathname===n){let n=new xd(`/messages`,s),c;try{c=await t(o)}catch(e){return wd(e,s)||s.writeHead(500).end(`Error creating server`),!0}e[n.sessionId]=n;let l=!1,u=!1;s.on(`close`,async()=>{l=!0,!u&&(u=!0,await Td(c,r),delete e[n.sessionId])});try{await c.connect(n),await n.send({jsonrpc:`2.0`,method:`sse/connection`,params:{message:`SSE Connection established`}}),i&&await i(c)}catch(e){l||(a.error(`Error connecting to server`,{error:e}),s.writeHead(500).end(`Error connecting to server`))}return!0}if(o.method===`POST`&&o.url?.startsWith(`/messages`)){let t=new URL(o.url,`https://example.com`).searchParams.get(`sessionId`);if(!t)return s.writeHead(400).end(`No sessionId`),!0;let n=e[t];return n?(await n.handlePostMessage(o,s),!0):(s.writeHead(400).end(`No active transport`),!0)}return!1},Od=async({createServer:e,enableJsonResponse:t,eventStore:n,host:s=`::`,onClose:c,onConnect:l,onUnhandledRequest:u,port:d,sseEndpoint:f=`/sse`,stateless:p,streamEndpoint:m=`/mcp`})=>{let h={},g={},_=Dr.createServer(async(s,d)=>{let _=r(s.headers)??i;await o(_,async()=>{if(s.headers.origin)try{let e=new URL(s.headers.origin);d.setHeader(`Access-Control-Allow-Origin`,e.origin),d.setHeader(`Access-Control-Allow-Credentials`,`true`),d.setHeader(`Access-Control-Allow-Methods`,`GET, POST, OPTIONS`),d.setHeader(`Access-Control-Allow-Headers`,`*`),d.setHeader(`Access-Control-Expose-Headers`,`mcp-session-id`)}catch(e){a.error(`Error parsing origin`,{error:e})}if(s.method===`OPTIONS`){d.writeHead(204),d.end();return}if(s.method===`GET`&&s.url===`/ping`){d.writeHead(200).end(`pong`);return}f&&await Dd({activeTransports:h,createServer:e,endpoint:f,onClose:c,onConnect:l,req:s,res:d})||m&&await Ed({activeTransports:g,createServer:e,enableJsonResponse:t,endpoint:m,eventStore:n,onClose:c,onConnect:l,req:s,res:d,stateless:p})||(u?await u(s,d):d.writeHead(404).end())})});return await new Promise(e=>{_.listen(d,s,()=>{e(void 0)})}),{close:async()=>{for(let e of Object.values(h))await e.close();for(let e of Object.values(g))await e.transport.close();return new Promise((e,t)=>{_.close(n=>{if(n){t(n);return}e()})})}}};var kd=class{_readBuffer;_started=!1;_closed=!1;constructor(e=Cr.stdin,t=Cr.stdout,n){this._stdin=e,this._stdout=t,this._readBuffer=new Us({maxBufferSize:n?.maxBufferSize})}onclose;onerror;onmessage;_ondata=e=>{try{this._readBuffer.append(e),this.processReadBuffer()}catch(e){this.onerror?.(e),this.close().catch(()=>{})}};_onerror=e=>{this.onerror?.(e)};_onstdouterror=e=>{this.onerror?.(e),this.close().catch(()=>{})};async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror),this._stdout.on(`error`,this._onstdouterror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._closed||(this._closed=!0,this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdout.off(`error`,this._onstdouterror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.())}send(e){return this._closed?Promise.reject(Error(`StdioServerTransport is closed`)):new Promise((t,n)=>{let r=Gs(e),i=!1,a=e=>{i||(i=!0,this._stdout.off(`error`,a),this._stdout.off(`drain`,o),n(e))},o=()=>{i||(i=!0,this._stdout.off(`error`,a),this._stdout.off(`drain`,o),t())};if(this._stdout.once(`error`,a),this._stdout.write(r)){if(i)return;i=!0,this._stdout.off(`error`,a),t()}else i||this._stdout.once(`drain`,o)})}};const Ad=3e3;var jd=class{onclose;onerror;onmessage;_closed=!1;_pendingRequests=new Set;_drainWaiters=[];constructor(e,t,n){this._wire=e,this._onInstanceClose=t,this._outboundIntercept=n}async start(){}async send(e,t){if(wo(e)||To(e)){let{id:t}=e;t!==void 0&&this._settle(t)}if(!this._closed&&this._outboundIntercept?.(e)!==`handled`)return this._wire.send(e,t)}setProtocolVersion=e=>{this._wire.setProtocolVersion?.(e)};deliver(e,t){if(!this._closed){if(Z(e))this._pendingRequests.add(e.id);else if(Co(e)&&e.method===`notifications/cancelled`){let t=e.params?.requestId;t!==void 0&&this._settle(t)}this.onmessage?.(e,t)}}async whenRequestsAnswered(e){return this._closed||this._pendingRequests.size===0?!0:await new Promise(t=>{let n=()=>{clearTimeout(r),t(!0)},r=setTimeout(()=>{this._drainWaiters=this._drainWaiters.filter(e=>e!==n),t(!1)},e);this._drainWaiters.push(n)})}async close(){if(!this._closed){this._closed=!0,this._pendingRequests.clear(),this._releaseDrainWaiters();try{this._onInstanceClose()}finally{this.onclose?.()}}}_settle(e){this._pendingRequests.delete(e),this._pendingRequests.size===0&&this._releaseDrainWaiters()}_releaseDrainWaiters(){let e=this._drainWaiters;this._drainWaiters=[];for(let t of e)t()}};function Md(e){let t=e.params;if(e.method===`initialize`&&!Ro(t)){let e=typeof t==`object`&&t&&typeof t.protocolVersion==`string`?t.protocolVersion:void 0;return{kind:`legacy`,reason:`initialize`,...e!==void 0&&{requestedVersion:e}}}if(!yo(t))return{kind:`legacy`,reason:`no-claim`};let n=vo(t),r=(n===void 0?[]:xo(n))[0];if(r!==void 0)return{kind:`invalid-envelope`,issue:r};let i=bo(t);return i===void 0||!Vi.includes(i)?{kind:`unsupported-revision`,requested:i??`unknown`}:{kind:`modern`,revision:i,classification:{era:`modern`,revision:i}}}function Nd(e,t={}){let n=t.legacy??`serve`,r=t.transport??new kd,i={phase:`opening`},a,o=!1,s=()=>o||i.phase===`closed`,c=e=>{try{t.onerror?.(e)}catch{}},l=(e,t,n,i)=>r.send({jsonrpc:`2.0`,id:e,error:{code:t,message:n,...i!==void 0&&{data:i}}}).catch(e=>c(Pd(e))),u=new uu(t.maxSubscriptions??ou),d=e=>{if(!Co(e))return;let t=u.routeOutbound(e);if(t!==`passthrough`){for(let e of t)r.send({jsonrpc:`2.0`,...e}).catch(e=>c(Pd(e)));return`handled`}},f=async e=>{if(Z(e)&&e.method===`subscriptions/listen`){let t=vo(e.params),n=yo(e.params)?(t===void 0?[]:xo(t))[0]:{key:`_meta`,problem:`the per-request envelope is required on protocol revision 2026-07-28`},i=bo(e.params),a;if(n!==void 0)a={jsonrpc:`2.0`,id:e.id,error:{code:-32602,message:`Invalid _meta envelope: ${n.key}: ${n.problem}`}};else if(i===void 0||!Vi.includes(i)){let t=new Ma({supported:[...Vi],requested:i??`unknown`});a={jsonrpc:`2.0`,id:e.id,error:{code:t.code,message:t.message,data:t.data}}}else a=u.serve(e);return await r.send(`error`in a?a:{jsonrpc:`2.0`,method:a.method,params:a.params}).catch(e=>c(Pd(e))),!0}if(Co(e)&&e.method===`notifications/cancelled`){let t=e.params?.requestId;if(t!==void 0&&u.cancel(t))return!0}return!1},p=(e,t,n)=>{let r=zo({kind:`legacy`,reason:t,...n!==void 0&&{requestedVersion:n}},Vi);return r===void 0?Promise.resolve():(c(Error(`Rejected 2025-era request on a modern-only stdio connection (${r.cell}): ${r.message}`)),l(e.id,r.code,r.message,r.data))},m=e=>{o||e===a||S()},h=async(t,n)=>{let i=await e({era:t}),a=i instanceof wu?i.server:i;t===`modern`&&(Ns(a,n),bu(a,Vi),u.setServerCapabilities(a.getCapabilities(),xu(a)));let o=new jd(r,()=>m(o),t===`modern`?d:void 0);return await i.connect(o),{product:i,channel:o}},g=e=>e.product.close().catch(e=>c(Pd(e))),_=async e=>{a=e.channel;try{await e.channel.whenRequestsAnswered(Ad)||c(Error(`Discarded the probe instance with requests still unanswered after ${Ad}ms; continuing with the fallback`)),await e.product.close()}catch(e){c(Pd(e))}finally{a=void 0}},v=async e=>{if(i.phase===`closed`)return;if(i.phase===`pinned`){if(i.era===`modern`&&Z(e)&&e.method===`initialize`&&!Ro(e.params)){await p(e,`initialize`,e.params!==null&&typeof e.params==`object`&&typeof e.params.protocolVersion==`string`?e.params.protocolVersion:void 0);return}if(i.era===`modern`&&await f(e))return;i.instance.channel.deliver(e);return}if(!Z(e)&&!Co(e)){c(Error(`Discarded a JSON-RPC response received before the connection negotiated an era`));return}let t=Md(e);switch(t.kind){case`invalid-envelope`:{let n=`Invalid _meta envelope for protocol revision 2026-07-28: ${t.issue.key}: ${t.issue.problem}`;Z(e)?await l(e.id,Y.InvalidParams,n,{envelope:t.issue}):c(Error(`Discarded a notification with a malformed envelope: ${n}`));return}case`unsupported-revision`:if(Z(e)){let n=new Ma({supported:[...Vi],requested:t.requested});c(n),await l(e.id,n.code,n.message,n.data)}else c(Error(`Discarded a notification claiming unsupported protocol revision ${t.requested}`));return;case`modern`:if(Z(e)&&e.method===`server/discover`){if(i.phase===`probe`){i.instance.channel.deliver(e,{classification:t.classification});return}let n=await h(`modern`,t.revision);if(s()){await g(n);return}i={phase:`probe`,instance:n},n.channel.deliver(e,{classification:t.classification});return}if(i.phase===`probe`){if(Co(e)){i.instance.channel.deliver(e,{classification:t.classification});return}i={phase:`pinned`,era:`modern`,instance:i.instance}}else{let e=await h(`modern`,t.revision);if(s()){await g(e);return}i={phase:`pinned`,era:`modern`,instance:e}}if(await f(e))return;i.instance.channel.deliver(e,{classification:t.classification});return;case`legacy`:{if(n===`reject`){Z(e)&&await p(e,t.reason,t.requestedVersion);return}if(i.phase===`probe`){if(await _(i.instance),s())return;i={phase:`opening`}}let r=await h(`legacy`);if(s()){await g(r);return}i={phase:`pinned`,era:`legacy`,instance:r},i.instance.channel.deliver(e);return}}},y=[],b=!1,x=async()=>{if(!b){b=!0;try{for(;y.length>0;){let e=y.shift();try{await v(e)}catch(t){Z(e)&&await l(e.id,Y.InternalError,`Internal server error`),c(Pd(t))}}}finally{b=!1}}},S=async()=>{if(o||i.phase===`closed`)return;o=!0;let e=i;i={phase:`closed`};for(let e of u.teardownAll())await r.send(e).catch(e=>c(Pd(e)));(e.phase===`probe`||e.phase===`pinned`)&&await e.instance.product.close().catch(e=>c(Pd(e))),await r.close().catch(e=>c(Pd(e)))};r.onmessage=e=>{y.push(e),x()},r.onerror=e=>{c(e),(i.phase===`probe`||i.phase===`pinned`)&&i.instance.channel.onerror?.(e)},r.onclose=()=>{if(o||i.phase===`closed`)return;o=!0;let e=i;i={phase:`closed`},(e.phase===`probe`||e.phase===`pinned`)&&e.instance.product.close().catch(e=>c(Pd(e)))};let C=r.start().catch(e=>{throw c(Pd(e)),e});return C.catch(()=>{}),{close:async()=>{await C.catch(()=>{}),await S()}}}function Pd(e){return e instanceof Error?e:Error(String(e))}const Fd=()=>n.supportNewMcpProtocol?{mode:`auto`}:void 0;export{Ar as AccessControlBlockError,jr as ConfigurationError,Or as InMemoryEventStore,Mr as ProtocolEraMismatchError,Nr as ProxyConnectionError,Su as Server,kd as StdioServerTransport,ci as compressClientInfo,ei as getSessionData,di as initializeTrafficMirror,hi as logRequestCounts,_i as proxyServer,ri as redactCliArgs,Nd as serveStdio,Od as startHTTPServer,Fd as upstreamVersionNegotiation};
15
- //# sourceMappingURL=upstreamNegotiation-C_Du8DxH.js.map
15
+ `;return r&&(i+=`id: ${r}\n`),i+=`data: ${JSON.stringify(n)}\n\n`,e.enqueue(t.encode(i)),!0}catch(e){return this.onerror?.(e),!1}}handleUnsupportedRequest(){return this.onerror?.(Error(`Method not allowed.`)),Response.json({jsonrpc:`2.0`,error:{code:-32e3,message:`Method not allowed.`},id:null},{status:405,headers:{Allow:`GET, POST, DELETE`,"Content-Type":`application/json`}})}async handlePostRequest(e,t){try{let n=e.headers.get(`accept`);if(!n?.includes(`application/json`)||!n.includes(`text/event-stream`))return this.onerror?.(Error(`Not Acceptable: Client must accept both application/json and text/event-stream`)),this.createJsonErrorResponse(406,-32e3,`Not Acceptable: Client must accept both application/json and text/event-stream`);if(!Zs(e.headers.get(`content-type`)))return this.onerror?.(Error(`Unsupported Media Type: Content-Type must be application/json`)),this.createJsonErrorResponse(415,-32e3,`Unsupported Media Type: Content-Type must be application/json`);let r=e,i;if(t?.parsedBody===void 0)try{i=await e.json()}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,`Parse error: Invalid JSON`)}else i=t.parsedBody;let a;try{a=Array.isArray(i)?i.map(e=>Ve.parse(e)):[Ve.parse(i)]}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,`Parse error: Invalid JSON-RPC message`)}if(this._closed)return this.createJsonErrorResponse(404,-32001,`Session not found`);let o=a.some(e=>Io(e));if(o){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(Error(`Invalid Request: Server already initialized`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Server already initialized`);if(a.length>1)return this.onerror?.(Error(`Invalid Request: Only one initialization request is allowed`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Only one initialization request is allowed`);this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!o){let t=this.validateSession(e);if(t)return t;let n=this.validateProtocolVersion(e);if(n)return n}if(this._closed)return this.createJsonErrorResponse(404,-32001,`Session not found`);if(!a.some(e=>Z(e))){for(let e of a)this.onmessage?.(e,{authInfo:t?.authInfo,request:r});return new Response(null,{status:202})}let s=crypto.randomUUID(),c=a.find(e=>Io(e)),l=c?c.params.protocolVersion:e.headers.get(`mcp-protocol-version`)??ue;if(this._enableJsonResponse)return new Promise(e=>{this._streamMapping.set(s,{resolveJson:e,cleanup:()=>{this._streamMapping.delete(s)}});for(let e of a)Z(e)&&this._requestToStreamMapping.set(e.id,s);for(let e of a)this.onmessage?.(e,{authInfo:t?.authInfo,request:r})});let u=new TextEncoder,d,f,p=new ReadableStream({start:e=>{d=e},cancel:()=>{f!==void 0&&clearInterval(f),this._streamMapping.get(s)?.controller===d&&this._streamMapping.delete(s)}}),m={"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`};this.sessionId!==void 0&&(m[`mcp-session-id`]=this.sessionId);for(let e of a)Z(e)&&(this._streamMapping.set(s,{controller:d,encoder:u,cleanup:()=>{f!==void 0&&clearInterval(f),this._streamMapping.delete(s);try{d.close()}catch{}}}),this._requestToStreamMapping.set(e.id,s));await this.writePrimingEvent(d,u,s,l);for(let e of a){let n,i;Z(e)&&this._eventStore&&this.supportsEmptySSEData(l)&&(n=()=>{this.closeSSEStream(e.id)},i=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(e,{authInfo:t?.authInfo,request:r,closeSSEStream:n,closeStandaloneSSEStream:i})}return this._streamMapping.get(s)?.controller===d&&(f=this.startKeepAlive(d,u)),new Response(p,{status:200,headers:m})}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,`Parse error`,{data:String(e)})}}async handleDeleteRequest(e){let t=this.validateSession(e);if(t)return t;let n=this.validateProtocolVersion(e);if(n)return n;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(Error(`Bad Request: Server not initialized`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Server not initialized`);let t=e.headers.get(`mcp-session-id`);if(!t)return this.onerror?.(Error(`Bad Request: Mcp-Session-Id header is required`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Mcp-Session-Id header is required`);if(t!==this.sessionId)return this.onerror?.(Error(`Session not found`)),this.createJsonErrorResponse(404,-32001,`Session not found`)}validateProtocolVersion(e){let t=e.headers.get(`mcp-protocol-version`);if(t!==null&&!this._supportedProtocolVersions.includes(t)){let e=`Bad Request: Unsupported protocol version: ${t} (supported versions: ${this._supportedProtocolVersions.join(`, `)})`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(400,-32e3,e)}}async close(){if(!this._closed){this._closed=!0;for(let{cleanup:e}of this._streamMapping.values())e();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}}closeSSEStream(e){let t=this._requestToStreamMapping.get(e);if(!t)return;let n=this._streamMapping.get(t);n&&n.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,t){let n=t?.relatedRequestId;if((No(e)||Po(e))&&(n=e.id),n===void 0){if(No(e)||Po(e))throw Error(`Cannot send a response on a standalone SSE stream unless resuming a previous client request`);let t;this._eventStore&&(t=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let n=this._streamMapping.get(this._standaloneSseStreamId);if(n===void 0)return;n.controller&&n.encoder&&(t===void 0||!n.replayedEventIds?.has(t))&&this.writeSSEEvent(n.controller,n.encoder,e,t);return}let r=this._requestToStreamMapping.get(n);if(!r)throw Error(`No connection established for request ID: ${String(n)}`);let i=this._streamMapping.get(r);if(!this._enableJsonResponse){let t;this._eventStore&&(t=await this._eventStore.storeEvent(r,e),i=this._streamMapping.get(r)),i?.controller&&i?.encoder&&(t===void 0||!i.replayedEventIds?.has(t))&&this.writeSSEEvent(i.controller,i.encoder,e,t)}if(No(e)||Po(e)){this._requestResponseMap.set(n,e);let t=[...this._requestToStreamMapping.entries()].filter(([e,t])=>t===r).map(([e])=>e);if(t.every(e=>this._requestResponseMap.has(e))){if(!i){if(this._enableJsonResponse)throw Error(`No connection established for request ID: ${String(n)}`);if(!this._eventStore){this.onerror?.(Error(`Response for request ID ${String(n)} is undeliverable: per-request stream is disconnected and no eventStore is configured`));for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}if(this._enableJsonResponse&&i.resolveJson){let e={"Content-Type":`application/json`};this.sessionId!==void 0&&(e[`mcp-session-id`]=this.sessionId);let n=t.map(e=>this._requestResponseMap.get(e));n.length===1?i.resolveJson(Response.json(n[0],{status:200,headers:e})):i.resolveJson(Response.json(n,{status:200,headers:e})),i.cleanup()}else i.cleanup();for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e)}}}},Wu=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},Gu=e=>e instanceof Wu?e:new Wu(e.message,{cause:e}),Ku=global.Request,qu=class extends Ku{constructor(e,t){typeof e==`object`&&Zu in e&&(e=e[Zu]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},Ju=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},Yu=Symbol(`wrapBodyStream`),Xu=(e,t,n,r,i)=>{let a={method:e,headers:n,signal:i.signal};if(e===`TRACE`){a.method=`GET`;let e=new qu(t,a);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)a.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[Yu]){let e;a.body=new ReadableStream({async pull(t){try{e||=br.toWeb(r).getReader();let{done:n,value:i}=await e.read();n?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else a.body=br.toWeb(r);return new qu(t,a)},Zu=Symbol(`getRequestCache`),Qu=Symbol(`requestCache`),$u=Symbol(`incomingKey`),ed=Symbol(`urlKey`),td=Symbol(`headersKey`),nd=Symbol(`abortControllerKey`),rd={get method(){return this[$u].method||`GET`},get url(){return this[ed]},get headers(){return this[td]||=Ju(this[$u])},[Symbol(`getAbortController`)](){return this[Zu](),this[nd]},[Zu](){return this[nd]||=new AbortController,this[Qu]||=Xu(this.method,this[ed],this.headers,this[$u],this[nd])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(rd,e,{get(){return this[Zu]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(rd,e,{value:function(){return this[Zu]()[e]()}})}),Object.defineProperty(rd,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){let r={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[Qu]};return`Request (lightweight) ${n(r,{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(rd,qu.prototype);var id=(e,t)=>{let n=Object.create(rd);n[$u]=e;let r=e.url||``;if(r[0]!==`/`&&(r.startsWith(`http://`)||r.startsWith(`https://`))){if(e instanceof wr)throw new Wu(`Absolute URL for :path is not allowed in HTTP/2`);try{n[ed]=new URL(r).href}catch(e){throw new Wu(`Invalid absolute URL`,{cause:e})}return n}let i=(e instanceof wr?e.authority:e.headers.host)||t;if(!i)throw new Wu(`Missing host header`);let a;if(e instanceof wr){if(a=e.scheme,!(a===`http`||a===`https`))throw new Wu(`Unsupported scheme`)}else a=e.socket&&e.socket.encrypted?`https`:`http`;let o=new URL(`${a}://${i}${r}`);if(o.hostname.length!==i.length&&o.hostname!==i.replace(/:\d+$/,``))throw new Wu(`Invalid host header`);return n[ed]=o.href,n},ad=Symbol(`responseCache`),od=Symbol(`getResponseCache`),sd=Symbol(`cache`),cd=global.Response,ld=class e{#body;#init;[od](){return delete this[sd],this[ad]||=new cd(this.#body,this.#init)}constructor(t,n){let r;if(this.#body=t,n instanceof e){let e=n[ad];if(e){this.#init=e,this[od]();return}else this.#init=n.#init,r=new Headers(n.#init.headers)}else this.#init=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[sd]=[n?.status||200,t,r||n?.headers])}get headers(){let e=this[sd];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":`text/plain; charset=UTF-8`})),e[2]):this[od]().headers}get status(){return this[sd]?.[0]??this[od]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(ld.prototype,e,{get(){return this[od]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(ld.prototype,e,{value:function(){return this[od]()[e]()}})}),Object.defineProperty(ld.prototype,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){let r={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[ad]};return`Response (lightweight) ${n(r,{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(ld,cd),Object.setPrototypeOf(ld.prototype,cd.prototype);async function ud(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function dd(e,t,n){let r=t=>{e.cancel(t).catch(()=>{})};return t.on(`close`,r),t.on(`error`,r),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off(`close`,r),t.off(`error`,r)});function i(e){e&&t.destroy(e)}function a(){e.read().then(o,i)}function o({done:n,value:r}){try{if(n)t.end();else if(!t.write(r))t.once(`drain`,a);else return e.read().then(o,i)}catch(e){i(e)}}}function fd(e,t){if(e.locked)throw TypeError(`ReadableStream is locked.`);return t.destroyed?void 0:dd(e.getReader(),t)}var pd=e=>{let t={};e instanceof Headers||(e=new Headers(e??void 0));let n=[];for(let[r,i]of e)r===`set-cookie`?n.push(i):t[r]=i;return n.length>0&&(t[`set-cookie`]=n),t[`content-type`]??=`text/plain; charset=UTF-8`,t},md=`x-hono-already-sent`;global.crypto===void 0&&(global.crypto=dr);var hd=Symbol(`outgoingEnded`),gd=Symbol(`incomingDraining`),_d=500,vd=64*1024*1024,yd=e=>{let t=e;if(e.destroyed||t[gd])return;if(t[gd]=!0,e instanceof wr){try{e.stream?.close?.(Tr.NGHTTP2_NO_ERROR)}catch{}return}let n=0,r=()=>{clearTimeout(a),e.off(`data`,o),e.off(`end`,r),e.off(`error`,r)},i=()=>{r();let t=e.socket;t&&!t.destroyed&&t.destroySoon()},a=setTimeout(i,_d);a.unref?.();let o=e=>{n+=e.length,n>vd&&i()};e.on(`data`,o),e.on(`end`,r),e.on(`error`,r),e.resume()},bd=()=>new Response(null,{status:400}),xd=e=>new Response(null,{status:e instanceof Error&&(e.name===`TimeoutError`||e.constructor.name===`TimeoutError`)?504:500}),Sd=(e,t)=>{let n=e instanceof Error?e:Error(`unknown error`,{cause:e});n.code===`ERR_STREAM_PREMATURE_CLOSE`?console.info(`The user aborted a request.`):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":`text/plain`}),t.end(`Error: ${n.message}`),t.destroy(n))},Cd=e=>{`flushHeaders`in e&&e.writable&&e.flushHeaders()},wd=async(e,t)=>{let[n,r,i]=e[sd],a=!1;if(!i)i={"content-type":`text/plain; charset=UTF-8`};else if(i instanceof Headers)a=i.has(`content-length`),i=pd(i);else if(Array.isArray(i)){let e=new Headers(i);a=e.has(`content-length`),i=pd(e)}else for(let e in i)if(e.length===14&&e.toLowerCase()===`content-length`){a=!0;break}a||(typeof r==`string`?i[`Content-Length`]=Buffer.byteLength(r):r instanceof Uint8Array?i[`Content-Length`]=r.byteLength:r instanceof Blob&&(i[`Content-Length`]=r.size)),t.writeHead(n,i),typeof r==`string`||r instanceof Uint8Array?t.end(r):r instanceof Blob?t.end(new Uint8Array(await r.arrayBuffer())):(Cd(t),await fd(r,t)?.catch(e=>Sd(e,t))),t[hd]?.()},Td=e=>typeof e.then==`function`,Ed=async(e,t,n={})=>{if(Td(e))if(n.errorHandler)try{e=await e}catch(t){let r=await n.errorHandler(t);if(!r)return;e=r}else e=await e.catch(xd);if(sd in e)return wd(e,t);let r=pd(e.headers);if(e.body){let n=e.body.getReader(),i=[],a=!1,o;if(r[`transfer-encoding`]!==`chunked`){let e=2;for(let t=0;t<e;t++){o||=n.read();let r=await ud(o).catch(e=>{console.error(e),a=!0});if(!r){if(t===1){await new Promise(e=>setTimeout(e)),e=3;continue}break}if(o=void 0,r.value&&i.push(r.value),r.done){a=!0;break}}a&&!(`content-length`in r)&&(r[`content-length`]=i.reduce((e,t)=>e+t.length,0))}t.writeHead(e.status,r),i.forEach(e=>{t.write(e)}),a?t.end():(i.length===0&&Cd(t),await dd(n,t,o))}else r[md]||(t.writeHead(e.status,r),t.end());t[hd]?.()},Dd=(e,t={})=>{let n=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==qu&&(Object.defineProperty(global,`Request`,{value:qu}),Object.defineProperty(global,`Response`,{value:ld})),async(r,i)=>{let a,o;try{o=id(r,t.hostname);let s=!n||r.method===`GET`||r.method===`HEAD`;if(s||(r[Yu]=!0,r.on(`end`,()=>{s=!0}),r instanceof wr&&(i[hd]=()=>{s||setTimeout(()=>{s||setTimeout(()=>{yd(r)})})}),i.on(`finish`,()=>{s||yd(r)})),i.on(`close`,()=>{o[nd]&&(r.errored?o[nd].abort(r.errored.toString()):i.writableFinished||o[nd].abort(`Client connection prematurely closed.`)),s||setTimeout(()=>{s||setTimeout(()=>{yd(r)})})}),a=e(o,{incoming:r,outgoing:i}),sd in a)return wd(a,i)}catch(e){if(a)return Sd(e,i);if(t.errorHandler){if(a=await t.errorHandler(o?e:Gu(e)),!a)return}else a=o?xd(e):bd()}try{return await Ed(a,i,t)}catch(e){return Sd(e,i)}}},Od=class{_webStandardTransport;_requestListener;_requestContext=new WeakMap;constructor(e={}){this._webStandardTransport=new Uu(e),this._requestListener=Dd(async e=>{let t=this._requestContext.get(e);return this._webStandardTransport.handleRequest(e,{authInfo:t?.authInfo,parsedBody:t?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(e){this._webStandardTransport.onclose=e}get onclose(){return this._webStandardTransport.onclose}set onerror(e){this._webStandardTransport.onerror=e}get onerror(){return this._webStandardTransport.onerror}set onmessage(e){this._webStandardTransport.onmessage=e}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(e,t){return this._webStandardTransport.send(e,t)}setSupportedProtocolVersions(e){this._webStandardTransport.setSupportedProtocolVersions(e)}async handleRequest(e,t,n){let r=e.auth;await Dd(async e=>this._webStandardTransport.handleRequest(e,{authInfo:r,parsedBody:n}),{overrideGlobalObjects:!1})(e,t)}closeSSEStream(e){this._webStandardTransport.closeSSEStream(e)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};const kd=(e,t)=>new Promise((n,r)=>{let i=[],a=0;e.on(`data`,n=>{if(a+=n.length,a>t){r(Error(`request entity too large (limit ${t} bytes)`)),e.destroy();return}i.push(n)}),e.on(`end`,()=>n(Buffer.concat(i).toString(`utf-8`))),e.on(`error`,r)});var Ad=class{onclose;onerror;onmessage;get sessionId(){return this._sessionId}_sessionId;_sseResponse;constructor(e,t){this._endpoint=e,this.res=t,this._sessionId=_r()}async close(){this._sseResponse?.end(),this._sseResponse=void 0,this.onclose?.()}async handleMessage(e,t){let n;try{n=Ve.parse(e)}catch(e){throw this.onerror?.(e),e}this.onmessage?.(n,t)}async handlePostMessage(e,t,n){if(!this._sseResponse){let e=`SSE connection not established`;throw t.writeHead(500).end(e),Error(e)}let r=e.auth,i;try{let t=e.headers[`content-type`]??``;if(t.split(`;`)[0].trim().toLowerCase()!==`application/json`)throw Error(`Unsupported content-type: ${t}`);i=n??await kd(e,4194304)}catch(e){t.writeHead(400).end(String(e)),this.onerror?.(e);return}try{await this.handleMessage(typeof i==`string`?JSON.parse(i):i,{authInfo:r})}catch{t.writeHead(400).end(`Invalid message: ${i}`);return}t.writeHead(202).end(`Accepted`)}async send(e){if(!this._sseResponse)throw Error(`Not connected`);this._sseResponse.write(`event: message\ndata: ${JSON.stringify(e)}\n\n`)}async start(){if(this._sseResponse)throw Error(`SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this.res.writeHead(200,{"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"Content-Type":`text/event-stream`});let e=new Er(this._endpoint,`http://localhost`);e.searchParams.set(`sessionId`,this._sessionId);let t=e.pathname+e.search+e.hash;this.res.write(`event: endpoint\ndata: ${t}\n\n`),this._sseResponse=this.res,this.res.on(`close`,()=>{this._sseResponse=void 0,this.onclose?.()})}};const jd=e=>new Promise(t=>{let n=[],r;e.on(`data`,e=>{n.push(e)}).on(`end`,()=>{r=Buffer.concat(n).toString();try{t(JSON.parse(r))}catch(n){a.error(`Error parsing body`,{bodyLength:r.length,bodyPreview:r.substring(0,100),contentType:e.headers[`content-type`],error:n}),t(null)}})}),Md=(e,t)=>JSON.stringify({error:{code:e,message:t},id:null,jsonrpc:`2.0`}),Nd=(e,t)=>{if(e instanceof Response){let n={};return e.headers.forEach((e,t)=>{n[t]?Array.isArray(n[t])?n[t].push(e):n[t]=[n[t],e]:n[t]=e}),t.writeHead(e.status,e.statusText,n).end(e.statusText),!0}return!1},Pd=async(e,t)=>{t&&await t(e);try{await e.close()}catch(t){a.error(`Error closing server`,{error:t,serverType:typeof e})}},Fd=async({activeTransports:e,createServer:t,enableJsonResponse:n,endpoint:r,eventStore:i,onClose:o,onConnect:s,req:c,res:l,stateless:u})=>{if(c.method===`POST`&&new URL(c.url,`http://localhost`).pathname===r){try{let r=Array.isArray(c.headers[`mcp-session-id`])?c.headers[`mcp-session-id`][0]:c.headers[`mcp-session-id`],a,d,f=await jd(c);if(r){let t=e[r];if(!t)return l.setHeader(`Content-Type`,`application/json`),l.writeHead(404).end(Md(-32001,`Session not found`)),!0;a=t.transport,d=t.server}else if(!r&&Io(f)){a=new Od({enableJsonResponse:n,eventStore:i||new Or,onsessioninitialized:t=>{!u&&t&&(e[t]={server:d,transport:a})},sessionIdGenerator:u?void 0:_r});let r=!1;a.onclose=async()=>{let t=a.sessionId;r||(r=!0,!u&&t&&e[t]?(await Pd(d,o),delete e[t]):u&&await Pd(d,o))};try{d=await t(c)}catch(e){return Nd(e,l)||l.writeHead(500).end(`Error creating server`),!0}return d.connect(a),s&&await s(d),await a.handleRequest(c,l,f),!0}else if(u&&!r&&!Io(f)){a=new Od({enableJsonResponse:n,eventStore:i||new Or,onsessioninitialized:()=>{},sessionIdGenerator:void 0});try{d=await t(c)}catch(e){return Nd(e,l)||l.writeHead(500).end(`Error creating server`),!0}return d.connect(a),s&&await s(d),await a.handleRequest(c,l,f),!0}else return l.setHeader(`Content-Type`,`application/json`),l.writeHead(400).end(Md(-32e3,`Bad Request: No valid session ID provided`)),!0;return await a.handleRequest(c,l,f),!0}catch(e){a.error(`Error handling request`,{error:e}),l.setHeader(`Content-Type`,`application/json`),l.writeHead(500).end(Md(-32603,`Internal Server Error`))}return!0}if(c.method===`GET`&&new URL(c.url,`http://localhost`).pathname===r){let t=c.headers[`mcp-session-id`],n=t?e[t]:void 0;if(!t)return l.writeHead(400).end(`No sessionId`),!0;if(!n)return l.writeHead(400).end(`No active transport`),!0;let r=c.headers[`last-event-id`];return r?a.info(`Client reconnecting with Last-Event-ID for session`,{lastEventId:r,sessionId:t}):a.info(`Establishing new SSE stream for session`,{sessionId:t}),await n.transport.handleRequest(c,l),!0}if(c.method===`DELETE`&&new URL(c.url,`http://localhost`).pathname===r){a.info(`Received delete request`);let t=c.headers[`mcp-session-id`];if(!t)return l.writeHead(400).end(`Invalid or missing sessionId`),!0;a.info(`Received delete request for session`,{sessionId:t});let n=e[t];if(!n)return l.writeHead(400).end(`No active transport`),!0;try{await n.transport.handleRequest(c,l),await Pd(n.server,o)}catch(e){a.error(`Error handling delete request`,{error:e}),l.writeHead(500).end(`Error handling delete request`)}return!0}return!1},Id=async({activeTransports:e,createServer:t,endpoint:n,onClose:r,onConnect:i,req:o,res:s})=>{if(o.method===`GET`&&new URL(o.url,`http://localhost`).pathname===n){let n=new Ad(`/messages`,s),c;try{c=await t(o)}catch(e){return Nd(e,s)||s.writeHead(500).end(`Error creating server`),!0}e[n.sessionId]=n;let l=!1,u=!1;s.on(`close`,async()=>{l=!0,!u&&(u=!0,await Pd(c,r),delete e[n.sessionId])});try{await c.connect(n),await n.send({jsonrpc:`2.0`,method:`sse/connection`,params:{message:`SSE Connection established`}}),i&&await i(c)}catch(e){l||(a.error(`Error connecting to server`,{error:e}),s.writeHead(500).end(`Error connecting to server`))}return!0}if(o.method===`POST`&&o.url?.startsWith(`/messages`)){let t=new URL(o.url,`https://example.com`).searchParams.get(`sessionId`);if(!t)return s.writeHead(400).end(`No sessionId`),!0;let n=e[t];return n?(await n.handlePostMessage(o,s),!0):(s.writeHead(400).end(`No active transport`),!0)}return!1},Ld=async({createServer:e,enableJsonResponse:t,eventStore:n,host:s=`::`,onClose:c,onConnect:l,onUnhandledRequest:u,port:d,sseEndpoint:f=`/sse`,stateless:p,streamEndpoint:m=`/mcp`})=>{let h={},g={},_=Dr.createServer(async(s,d)=>{let _=r(s.headers)??i;await o(_,async()=>{if(s.headers.origin)try{let e=new URL(s.headers.origin);d.setHeader(`Access-Control-Allow-Origin`,e.origin),d.setHeader(`Access-Control-Allow-Credentials`,`true`),d.setHeader(`Access-Control-Allow-Methods`,`GET, POST, OPTIONS`),d.setHeader(`Access-Control-Allow-Headers`,`*`),d.setHeader(`Access-Control-Expose-Headers`,`mcp-session-id`)}catch(e){a.error(`Error parsing origin`,{error:e})}if(s.method===`OPTIONS`){d.writeHead(204),d.end();return}if(s.method===`GET`&&s.url===`/ping`){d.writeHead(200).end(`pong`);return}f&&await Id({activeTransports:h,createServer:e,endpoint:f,onClose:c,onConnect:l,req:s,res:d})||m&&await Fd({activeTransports:g,createServer:e,enableJsonResponse:t,endpoint:m,eventStore:n,onClose:c,onConnect:l,req:s,res:d,stateless:p})||(u?await u(s,d):d.writeHead(404).end())})});return await new Promise(e=>{_.listen(d,s,()=>{e(void 0)})}),{close:async()=>{for(let e of Object.values(h))await e.close();for(let e of Object.values(g))await e.transport.close();return new Promise((e,t)=>{_.close(n=>{if(n){t(n);return}e()})})}}};var Rd=class{_readBuffer;_started=!1;_closed=!1;constructor(e=Cr.stdin,t=Cr.stdout,n){this._stdin=e,this._stdout=t,this._readBuffer=new Qs({maxBufferSize:n?.maxBufferSize})}onclose;onerror;onmessage;_ondata=e=>{try{this._readBuffer.append(e),this.processReadBuffer()}catch(e){this.onerror?.(e),this.close().catch(()=>{})}};_onerror=e=>{this.onerror?.(e)};_onstdouterror=e=>{this.onerror?.(e),this.close().catch(()=>{})};async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror),this._stdout.on(`error`,this._onstdouterror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._closed||(this._closed=!0,this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdout.off(`error`,this._onstdouterror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.())}send(e){return this._closed?Promise.reject(Error(`StdioServerTransport is closed`)):new Promise((t,n)=>{let r=ec(e),i=!1,a=e=>{i||(i=!0,this._stdout.off(`error`,a),this._stdout.off(`drain`,o),n(e))},o=()=>{i||(i=!0,this._stdout.off(`error`,a),this._stdout.off(`drain`,o),t())};if(this._stdout.once(`error`,a),this._stdout.write(r)){if(i)return;i=!0,this._stdout.off(`error`,a),t()}else i||this._stdout.once(`drain`,o)})}};const zd=3e3;var Bd=class{onclose;onerror;onmessage;_closed=!1;_pendingRequests=new Set;_drainWaiters=[];constructor(e,t,n){this._wire=e,this._onInstanceClose=t,this._outboundIntercept=n}async start(){}async send(e,t){if(No(e)||Po(e)){let{id:t}=e;t!==void 0&&this._settle(t)}if(!this._closed&&this._outboundIntercept?.(e)!==`handled`)return this._wire.send(e,t)}setProtocolVersion=e=>{this._wire.setProtocolVersion?.(e)};deliver(e,t){if(!this._closed){if(Z(e))this._pendingRequests.add(e.id);else if(Mo(e)&&e.method===`notifications/cancelled`){let t=e.params?.requestId;t!==void 0&&this._settle(t)}this.onmessage?.(e,t)}}async whenRequestsAnswered(e){return this._closed||this._pendingRequests.size===0?!0:await new Promise(t=>{let n=()=>{clearTimeout(r),t(!0)},r=setTimeout(()=>{this._drainWaiters=this._drainWaiters.filter(e=>e!==n),t(!1)},e);this._drainWaiters.push(n)})}async close(){if(!this._closed){this._closed=!0,this._pendingRequests.clear(),this._releaseDrainWaiters();try{this._onInstanceClose()}finally{this.onclose?.()}}}_settle(e){this._pendingRequests.delete(e),this._pendingRequests.size===0&&this._releaseDrainWaiters()}_releaseDrainWaiters(){let e=this._drainWaiters;this._drainWaiters=[];for(let t of e)t()}};function Vd(e){let t=e.params;if(e.method===`initialize`&&!qo(t)){let e=typeof t==`object`&&t&&typeof t.protocolVersion==`string`?t.protocolVersion:void 0;return{kind:`legacy`,reason:`initialize`,...e!==void 0&&{requestedVersion:e}}}if(!Oo(t))return{kind:`legacy`,reason:`no-claim`};let n=Do(t),r=(n===void 0?[]:Ao(n))[0];if(r!==void 0)return{kind:`invalid-envelope`,issue:r};let i=ko(t);return i===void 0||!Xi.includes(i)?{kind:`unsupported-revision`,requested:i??`unknown`}:{kind:`modern`,revision:i,classification:{era:`modern`,revision:i}}}function Hd(e,t={}){let n=t.legacy??`serve`,r=t.transport??new Rd,i={phase:`opening`},a,o=!1,s=()=>o||i.phase===`closed`,c=e=>{try{t.onerror?.(e)}catch{}},l=(e,t,n,i)=>r.send({jsonrpc:`2.0`,id:e,error:{code:t,message:n,...i!==void 0&&{data:i}}}).catch(e=>c(Ud(e))),u=new yu(t.maxSubscriptions??hu),d=e=>{if(!Mo(e))return;let t=u.routeOutbound(e);if(t!==`passthrough`){for(let e of t)r.send({jsonrpc:`2.0`,...e}).catch(e=>c(Ud(e)));return`handled`}},f=async e=>{if(Z(e)&&e.method===`subscriptions/listen`){let t=Do(e.params),n=Oo(e.params)?(t===void 0?[]:Ao(t))[0]:{key:`_meta`,problem:`the per-request envelope is required on protocol revision 2026-07-28`},i=ko(e.params),a;if(n!==void 0)a={jsonrpc:`2.0`,id:e.id,error:{code:-32602,message:`Invalid _meta envelope: ${n.key}: ${n.problem}`}};else if(i===void 0||!Xi.includes(i)){let t=new Va({supported:[...Xi],requested:i??`unknown`});a={jsonrpc:`2.0`,id:e.id,error:{code:t.code,message:t.message,data:t.data}}}else a=u.serve(e);return await r.send(`error`in a?a:{jsonrpc:`2.0`,method:a.method,params:a.params}).catch(e=>c(Ud(e))),!0}if(Mo(e)&&e.method===`notifications/cancelled`){let t=e.params?.requestId;if(t!==void 0&&u.cancel(t))return!0}return!1},p=(e,t,n)=>{let r=Jo({kind:`legacy`,reason:t,...n!==void 0&&{requestedVersion:n}},Xi);return r===void 0?Promise.resolve():(c(Error(`Rejected 2025-era request on a modern-only stdio connection (${r.cell}): ${r.message}`)),l(e.id,r.code,r.message,r.data))},m=e=>{o||e===a||S()},h=async(t,n)=>{let i=await e({era:t}),a=i instanceof Nu?i.server:i;t===`modern`&&(Hs(a,n),ku(a,Xi),u.setServerCapabilities(a.getCapabilities(),Au(a)));let o=new Bd(r,()=>m(o),t===`modern`?d:void 0);return await i.connect(o),{product:i,channel:o}},g=e=>e.product.close().catch(e=>c(Ud(e))),_=async e=>{a=e.channel;try{await e.channel.whenRequestsAnswered(zd)||c(Error(`Discarded the probe instance with requests still unanswered after ${zd}ms; continuing with the fallback`)),await e.product.close()}catch(e){c(Ud(e))}finally{a=void 0}},v=async e=>{if(i.phase===`closed`)return;if(i.phase===`pinned`){if(i.era===`modern`&&Z(e)&&e.method===`initialize`&&!qo(e.params)){await p(e,`initialize`,e.params!==null&&typeof e.params==`object`&&typeof e.params.protocolVersion==`string`?e.params.protocolVersion:void 0);return}if(i.era===`modern`&&await f(e))return;i.instance.channel.deliver(e);return}if(!Z(e)&&!Mo(e)){c(Error(`Discarded a JSON-RPC response received before the connection negotiated an era`));return}let t=Vd(e);switch(t.kind){case`invalid-envelope`:{let n=`Invalid _meta envelope for protocol revision 2026-07-28: ${t.issue.key}: ${t.issue.problem}`;Z(e)?await l(e.id,Y.InvalidParams,n,{envelope:t.issue}):c(Error(`Discarded a notification with a malformed envelope: ${n}`));return}case`unsupported-revision`:if(Z(e)){let n=new Va({supported:[...Xi],requested:t.requested});c(n),await l(e.id,n.code,n.message,n.data)}else c(Error(`Discarded a notification claiming unsupported protocol revision ${t.requested}`));return;case`modern`:if(Z(e)&&e.method===`server/discover`){if(i.phase===`probe`){i.instance.channel.deliver(e,{classification:t.classification});return}let n=await h(`modern`,t.revision);if(s()){await g(n);return}i={phase:`probe`,instance:n},n.channel.deliver(e,{classification:t.classification});return}if(i.phase===`probe`){if(Mo(e)){i.instance.channel.deliver(e,{classification:t.classification});return}i={phase:`pinned`,era:`modern`,instance:i.instance}}else{let e=await h(`modern`,t.revision);if(s()){await g(e);return}i={phase:`pinned`,era:`modern`,instance:e}}if(await f(e))return;i.instance.channel.deliver(e,{classification:t.classification});return;case`legacy`:{if(n===`reject`){Z(e)&&await p(e,t.reason,t.requestedVersion);return}if(i.phase===`probe`){if(await _(i.instance),s())return;i={phase:`opening`}}let r=await h(`legacy`);if(s()){await g(r);return}i={phase:`pinned`,era:`legacy`,instance:r},i.instance.channel.deliver(e);return}}},y=[],b=!1,x=async()=>{if(!b){b=!0;try{for(;y.length>0;){let e=y.shift();try{await v(e)}catch(t){Z(e)&&await l(e.id,Y.InternalError,`Internal server error`),c(Ud(t))}}}finally{b=!1}}},S=async()=>{if(o||i.phase===`closed`)return;o=!0;let e=i;i={phase:`closed`};for(let e of u.teardownAll())await r.send(e).catch(e=>c(Ud(e)));(e.phase===`probe`||e.phase===`pinned`)&&await e.instance.product.close().catch(e=>c(Ud(e))),await r.close().catch(e=>c(Ud(e)))};r.onmessage=e=>{y.push(e),x()},r.onerror=e=>{c(e),(i.phase===`probe`||i.phase===`pinned`)&&i.instance.channel.onerror?.(e)},r.onclose=()=>{if(o||i.phase===`closed`)return;o=!0;let e=i;i={phase:`closed`},(e.phase===`probe`||e.phase===`pinned`)&&e.instance.product.close().catch(e=>c(Ud(e)))};let C=r.start().catch(e=>{throw c(Ud(e)),e});return C.catch(()=>{}),{close:async()=>{await C.catch(()=>{}),await S()}}}function Ud(e){return e instanceof Error?e:Error(String(e))}const Wd=()=>n.supportNewMcpProtocol?{mode:`auto`}:void 0;export{Ar as AccessControlBlockError,jr as ConfigurationError,Or as InMemoryEventStore,Mr as ProtocolEraMismatchError,Nr as ProxyConnectionError,ju as Server,Rd as StdioServerTransport,_i as compressClientInfo,li as getSessionData,bi as initializeTrafficMirror,wi as logRequestCounts,Ei as proxyServer,fi as redactCliArgs,Hd as serveStdio,Ld as startHTTPServer,Wd as upstreamVersionNegotiation};
16
+ //# sourceMappingURL=upstreamNegotiation-CWekWLVp.js.map