everyapp 0.3.0-rc.2 → 0.3.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/access-YWM4BSBD.js +1 -0
- package/dist/activity-RTCAUMQS.js +14 -0
- package/dist/ai-UOYQFTAX.js +5 -0
- package/dist/apps-PEOBCDNU.js +14 -0
- package/dist/chunk-26KS6TD6.js +1 -0
- package/dist/chunk-3EADVHFN.js +15 -0
- package/dist/chunk-4LKLQOM7.js +7 -0
- package/dist/{chunk-PNLU5U3P.js → chunk-5IC3ZN52.js} +1 -1
- package/dist/{chunk-H7PDL3X5.js → chunk-AMCNAKYU.js} +1 -1
- package/dist/{chunk-23HJ5I2A.js → chunk-ASCNE7GS.js} +1 -1
- package/dist/{chunk-6OGVO7QK.js → chunk-BCTEWNN4.js} +1 -1
- package/dist/{chunk-W3JCQHHU.js → chunk-BK4NK34C.js} +1 -1
- package/dist/chunk-BWNZ6F4F.js +2 -0
- package/dist/chunk-DCFHBCCW.js +9 -0
- package/dist/{chunk-2Y5Q6A5K.js → chunk-DWTJ4OLZ.js} +1 -1
- package/dist/chunk-EP3IQ354.js +20 -0
- package/dist/{chunk-OP4DYXYI.js → chunk-EP4HRYXP.js} +1 -1
- package/dist/{chunk-HOUHG236.js → chunk-EQLY5I46.js} +1 -1
- package/dist/{chunk-YHJZMJYZ.js → chunk-F5XK23HV.js} +1 -1
- package/dist/{chunk-5PTNYZK6.js → chunk-FB2OC32C.js} +3 -3
- package/dist/chunk-FQ2A7YAP.js +57 -0
- package/dist/{chunk-OM2HDWVP.js → chunk-GAPQSINH.js} +1 -1
- package/dist/chunk-GJK6GAWO.js +1 -0
- package/dist/chunk-H4EZTXIK.js +1 -0
- package/dist/chunk-HJGZGZFE.js +32 -0
- package/dist/{chunk-CCWBPAKH.js → chunk-I7FNTTUY.js} +3 -3
- package/dist/chunk-KOBKGQ27.js +91 -0
- package/dist/{chunk-PS7S74DG.js → chunk-KQM6ZUX5.js} +1 -1
- package/dist/chunk-KVCL64LI.js +1 -0
- package/dist/{chunk-4JRIS6S6.js → chunk-LEEUODYR.js} +1 -1
- package/dist/{chunk-6PGUCTJ6.js → chunk-LI3YLKLC.js} +1 -1
- package/dist/chunk-MEIWV7FJ.js +20 -0
- package/dist/{configure-F7UZCJUG.js → chunk-MLTNW3AM.js} +2 -2
- package/dist/chunk-NDOEON54.js +4 -0
- package/dist/chunk-NW7SJPSP.js +37 -0
- package/dist/chunk-O64FPLGX.js +1 -0
- package/dist/chunk-ORGV2NNT.js +8 -0
- package/dist/chunk-PDPUGYJW.js +47 -0
- package/dist/chunk-QFTBDXLF.js +146 -0
- package/dist/{chunk-E3EPK27P.js → chunk-QJRZFIYC.js} +2 -2
- package/dist/chunk-QKHLRLK3.js +15 -0
- package/dist/{chunk-CZXHKPRZ.js → chunk-R2DF3ENZ.js} +1 -1
- package/dist/{chunk-IUOBIB5M.js → chunk-R7JOHK7Y.js} +2 -2
- package/dist/chunk-RL72BUT4.js +1 -0
- package/dist/chunk-RQBSTNL7.js +1 -0
- package/dist/{chunk-H6QQMY7B.js → chunk-S2G4G73L.js} +1 -1
- package/dist/{chunk-LXYMDZER.js → chunk-SGRGD7L4.js} +1 -1
- package/dist/{chunk-T2GD7RHS.js → chunk-TIYSZWP5.js} +1 -1
- package/dist/chunk-TUXKBLLJ.js +10 -0
- package/dist/chunk-U4ATZJEU.js +6 -0
- package/dist/chunk-V7BWZOSZ.js +26 -0
- package/dist/{chunk-J35DDCNU.js → chunk-VVKQJSF3.js} +1 -1
- package/dist/chunk-WVHJIYQ3.js +14 -0
- package/dist/{chunk-ZEXVHB22.js → chunk-XBD7PQN5.js} +1 -1
- package/dist/{chunk-N5GQLGEC.js → chunk-YAZHTVUV.js} +1 -1
- package/dist/configure-CAWCTPYY.js +1 -0
- package/dist/{create-2E5HVWYK.js → create-3ZWJQXPK.js} +2 -2
- package/dist/{db-HEQVTDTM.js → db-B7KO37SV.js} +1 -1
- package/dist/delete-CB3EPOU4.js +3 -0
- package/dist/deploy-5O7LV5OX.js +1 -0
- package/dist/dev-4JYCVVOZ.js +86 -0
- package/dist/{email-RLZFUFUN.js → email-SWJQXEUR.js} +1 -1
- package/dist/{events-2V5VRBWP.js → events-GJV2KVIU.js} +13 -13
- package/dist/{groups-HDG5DVFY.js → groups-NNTLSXMK.js} +1 -1
- package/dist/index.js +104 -95
- package/dist/install-UAG3CNYW.js +1 -0
- package/dist/{login-KHJBC64Z.js → login-QEKMLMUB.js} +1 -1
- package/dist/mcp-AFGVOM5D.js +1 -0
- package/dist/provider-622VM7UZ.js +29 -0
- package/dist/release-CXEX6O7F.js +1 -0
- package/dist/{restore-FFGYV7NO.js → restore-PGIVEA5P.js} +1 -1
- package/dist/secret-3LUDEDUW.js +1 -0
- package/dist/setup-PUD375AM.js +1 -0
- package/dist/{signin-AP3D4XM4.js → signin-EP5JLAT5.js} +2 -2
- package/dist/status-LK6DNLCI.js +5 -0
- package/dist/teardown-6RURRSME.js +22 -0
- package/dist/update-YJFTOZEV.js +1 -0
- package/dist/{workspace-CJC5I66L.js → workspace-VW7ZZRFP.js} +3 -3
- package/package.json +5 -5
- package/skills/build-every-app/SKILL.md +22 -13
- package/skills/build-every-app/patterns.md +16 -3
- package/skills/everyapp/SKILL.md +33 -18
- package/skills/everyapp/mcp.md +22 -8
- package/skills/everyapp/security-review.md +1 -1
- package/skills/everyapp/setup/README.md +18 -1
- package/skills/everyapp/setup/access.md +11 -7
- package/skills/everyapp/setup/ai-gateway.md +117 -0
- package/skills/everyapp/setup/ai.md +139 -0
- package/skills/everyapp/setup/context.md +2 -2
- package/skills/everyapp/setup/dataforseo.md +3 -3
- package/skills/everyapp/setup/email.md +1 -1
- package/skills/everyapp/setup/gateway.md +3 -3
- package/skills/everyapp/setup/google.md +8 -6
- package/skills/everyapp/setup/microsoft-365.md +4 -2
- package/skills/everyapp/setup/providers.md +27 -9
- package/skills/everyapp/setup/remote-mcp.md +1 -1
- package/skills/everyapp/setup/signin-apple.md +3 -3
- package/skills/everyapp/setup/signin-cloudflare.md +1 -1
- package/skills/everyapp/setup/signin-github.md +1 -1
- package/skills/everyapp/setup/signin-google.md +2 -2
- package/skills/everyapp/setup/signin-microsoft.md +1 -1
- package/skills/everyapp/setup/slack.md +2 -0
- package/dist/access-LGEN3ABJ.js +0 -1
- package/dist/activity-RSD4D66F.js +0 -12
- package/dist/apps-4RCFXT74.js +0 -13
- package/dist/chunk-AGTCKFRB.js +0 -22
- package/dist/chunk-BHMRY53V.js +0 -2
- package/dist/chunk-CB4U7H2G.js +0 -4
- package/dist/chunk-CZTEDWZ2.js +0 -22
- package/dist/chunk-EGEWRFVY.js +0 -1
- package/dist/chunk-ELK7QZ2M.js +0 -1
- package/dist/chunk-FJJSSVET.js +0 -33
- package/dist/chunk-GKBPYVP3.js +0 -25
- package/dist/chunk-IFCPALVC.js +0 -46
- package/dist/chunk-J455FAEN.js +0 -7
- package/dist/chunk-JYKRUS5C.js +0 -1
- package/dist/chunk-LYNBZ7RV.js +0 -57
- package/dist/chunk-M2QQ2UD7.js +0 -132
- package/dist/chunk-NFU4YFXB.js +0 -1
- package/dist/chunk-ONLNJXVQ.js +0 -32
- package/dist/chunk-RMF4YGD6.js +0 -98
- package/dist/chunk-TLRM3P7V.js +0 -15
- package/dist/chunk-WOVS3GV5.js +0 -10
- package/dist/chunk-ZECBN24L.js +0 -15
- package/dist/chunk-ZFCUH5PK.js +0 -7
- package/dist/delete-XCSIQIRS.js +0 -3
- package/dist/deploy-3QOZEZHC.js +0 -1
- package/dist/dev-JL3ZP5BT.js +0 -86
- package/dist/install-Z5FYXUYM.js +0 -1
- package/dist/mcp-EFDUKJ5V.js +0 -1
- package/dist/provider-EOI5PTFH.js +0 -13
- package/dist/release-74J5ZIL3.js +0 -1
- package/dist/secret-7FKKTLHB.js +0 -1
- package/dist/setup-PAKRCAFO.js +0 -1
- package/dist/status-RMWNHOEK.js +0 -4
- package/dist/teardown-E4JNKAZJ.js +0 -22
- package/dist/update-DWVZFNPS.js +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import{b as Qu}from"./chunk-BWNZ6F4F.js";import{a as Wu,b as Yu}from"./chunk-VVKQJSF3.js";import{a as Xu,b as Zu}from"./chunk-SGRGD7L4.js";import{a as Gu,c as Ju,e as Ku}from"./chunk-R2DF3ENZ.js";import{a as Wt,b as Yt}from"./chunk-HJGZGZFE.js";import{c as Ui,d as Vi}from"./chunk-RL72BUT4.js";import{a as Fu}from"./chunk-AMCNAKYU.js";import"./chunk-RQBSTNL7.js";import{$a as qi,A as yu,B as Su,C as vu,Cb as Mu,Cc as Hu,F as Xn,Fa as Tu,G as Ni,Ga as $u,Gb as Nu,L as _u,M as bu,Mb as qu,Qc as Uu,S as Ru,Wa as zu,Wc as Vu,Xc as Bu,_a as Pu,ab as ji,bc as De,c as Po,d as Kn,db as Cu,eb as ko,fc as Tr,hb as ku,kc as ju,m as Kt,n as Tt,na as wu,nc as xi,o as wr,oa as Eu,oc as Hi,p as uu,pc as Lu,q as du,qc as Du,r as Er,s as Wn,t as pu,tc as Zn,u as mu,ub as Iu,uc as xu,v as hu,vb as Au,w as fu,wb as Ou,x as Co,xb as Li,y as Yn,yb as Di,z as gu,zb as Io}from"./chunk-FQ2A7YAP.js";import Bb from"node:http";import xf from"node:http";import _d from"node:net";import{Readable as ts}from"node:stream";import{pipeline as Hf}from"node:stream/promises";function Xt(e){if(!e)return null;let t=e.trim().toLowerCase();if(t.length===0)return null;let r=t.indexOf(".");return r<=0?{appLabel:"",baseHost:t,host:t}:{appLabel:t.slice(0,r),baseHost:t.slice(r+1),host:t}}var Bi="Your browser sent more than one EveryApp session cookie, which another site on this domain can cause. Clear this site's cookies and sign in again.";function sf(e,t){let r=e.get("cookie");if(!r)return 0;let o=0;for(let n of r.split(/[;,]/)){let a=n.indexOf("=");a!==-1&&t.includes(n.slice(0,a).trim())&&o++}return o}function Fi(e,t){return t.length>0&&sf(e,t)>1}function ed(e){let t=e?.scopes??[];return t.length>0&&t.every(r=>r.startsWith("mcp:"))}var af=new Set(["GET","HEAD","OPTIONS"]);function Gi(e,t,r,o){if(af.has(e.toUpperCase()))return{allowed:!0,reason:"safe method"};if(o!==null)return o==="same-origin"?{allowed:!0,reason:"sec-fetch-site same-origin"}:{allowed:!1,reason:`sec-fetch-site ${o}`};if(r===null)return{allowed:!1,reason:"no origin and no sec-fetch-site"};let n;try{n=new URL(r).host}catch{return{allowed:!1,reason:"malformed origin"}}return n===t?{allowed:!0,reason:"origin matches app host"}:{allowed:!1,reason:`origin ${n} != ${t}`}}function Ji(e){return e.get("upgrade")?.trim().toLowerCase()==="websocket"}function Ki(e,t){if(t===null)return{allowed:!1,reason:"websocket upgrade without origin"};let r;try{r=new URL(t).host}catch{return{allowed:!1,reason:"malformed origin"}}return r===e?{allowed:!0,reason:"websocket origin matches app host"}:{allowed:!1,reason:`websocket origin ${r} != ${e}`}}var cf="/_serverFn";function lf(e){try{return decodeURIComponent(e)}catch{return e.replace(/%[0-9a-f]{2}/gi,t=>{try{return decodeURIComponent(t)}catch{return t}})}}function Wi(e,t=cf){let r=lf(e),o;try{o=new URL(r.replace(/^[/\\]+/,"/"),"https://x.invalid").pathname}catch{o=r}let n=o.toLowerCase(),a=t.toLowerCase().replace(/\/+$/,"");return n===a||n.startsWith(`${a}/`)}function uf(e){let t=e.get("sec-fetch-mode"),r=e.get("sec-fetch-dest");return t==="navigate"||t==="nested-navigate"||r==="document"||r==="iframe"||r==="frame"?!0:!(t!==null||e.get("sec-fetch-site")!==null)&&(e.get("accept")??"").toLowerCase().includes("text/html")}function df(e){return e.get("x-tsr-serverfn")?.trim().toLowerCase()==="true"||e.get("x-tsr-redirect")?.trim().toLowerCase()==="manual"}function Yi(e){if(uf(e))return{allowed:!1,reason:"server function navigation"};let t=e.get("sec-fetch-site");return t!==null&&t!=="same-origin"?{allowed:!1,reason:`sec-fetch-site ${t}`}:df(e)?{allowed:!0,reason:"same-origin server function call"}:{allowed:!1,reason:"missing server function client header"}}var rd="[redacted]",pf=new Set(["cookie","authorization","set-cookie"]),mf=/token|secret|password|code/i,td=4;function hf(e){return pf.has(e.toLowerCase())||mf.test(e)}function Qn(e,t=0){return Array.isArray(e)?t>=td?"[truncated]":e.map(r=>Qn(r,t+1)):!e||typeof e!="object"?e:t>=td?"[truncated]":Object.fromEntries(Object.entries(e).map(([r,o])=>[r,hf(r)?rd:Qn(o,t+1)]))}function $r(e,t={},r="log"){console[r](JSON.stringify({evt:e,...Qn(t)}))}var od="x-everyapp-",ff="cf-access-",nd="cloudflare-workers-version-overrides";function sd(e){let t=new Headers(e);t.delete("cookie"),t.delete("authorization"),t.delete(nd);for(let r of[...t.keys()]){let o=r.toLowerCase();(o.startsWith(od)||o.startsWith(ff))&&t.delete(r)}return t}function Xi(e){let t=es(e);return t?.startsWith("epat_")?t:null}var gf=/^[A-Za-z0-9_-]{16}$/,yf=/^[A-Za-z0-9_-]{32}$/;function Sf(e){let t=e.split(":");return t.length<3?!1:t.slice(0,-2).join(":").length>0&&gf.test(t[t.length-2])&&yf.test(t[t.length-1])}function es(e){let t=e.get("authorization");if(!t)return null;let[r,...o]=t.trim().split(/\s+/);if(r?.toLowerCase()!=="bearer")return null;let n=o.join(" ").trim();return n||null}function ad(e){let t=es(e);return t!==null&&(t.startsWith("epat_")||Sf(t))}function Zi(e){return es(e)!==null}function Ao(e,t,r=!1){let o=sd(e);if(t&&!r){let n=e.get("authorization");n&&o.set("authorization",n)}return o}var vf=["frame-ancestors 'none'","base-uri 'self'","object-src 'none'"].join("; "),_f={"frame-ancestors":{floor:"'none'",allowed:["'none'","'self'"]},"base-uri":{floor:"'self'",allowed:["'none'","'self'"]},"object-src":{floor:"'none'",allowed:["'none'"]}};function id(e){let t=new Map;for(let r of e.split(";")){let o=r.trim();if(!o)continue;let n=o.indexOf(" "),a=(n===-1?o:o.slice(0,n)).toLowerCase(),i=n===-1?"":o.slice(n+1).trim();t.set(a,i)}for(let[r,{floor:o,allowed:n}]of Object.entries(_f)){let a=t.get(r)?.toLowerCase();t.set(r,a&&n.includes(a)?a:o)}return[...t.entries()].map(([r,o])=>o?`${r} ${o}`:r).join("; ")}function Qi(e){let t=e.getSetCookie();if(t.length!==0){e.delete("set-cookie");for(let r of t)e.append("set-cookie",bf(r))}}function bf(e){let[t,...r]=e.split(";"),o=r.filter(n=>{let a=n.indexOf("=");return(a===-1?n:n.slice(0,a)).trim().toLowerCase()!=="domain"});return[t,...o].join(";")}var Rf="max-age=63072000; includeSubDomains; preload";function $t(e,t={}){let o=(e.headers.get("content-type")??"").includes("text/html"),n=new Headers(e.headers);if(t.stripCookieDomains!==!1&&Qi(n),n.set("Strict-Transport-Security",t.hsts??Rf),n.set("X-Content-Type-Options","nosniff"),n.set("X-Frame-Options","DENY"),n.set("X-Robots-Tag","noindex, nofollow"),n.set("Referrer-Policy",t.referrerPolicy??"strict-origin-when-cross-origin"),t.noStore&&n.set("Cache-Control","no-store"),o){let a=n.get("content-security-policy"),i=a?id(a):vf;n.set("Content-Security-Policy",i),/(^|;\s*)frame-ancestors 'self'(;|$)/.test(i)&&n.set("X-Frame-Options","SAMEORIGIN")}return new Response(e.body,{status:e.status,statusText:e.statusText,headers:n})}var ot=class extends Error{constructor(r,o="no_binding"){super(r);this.reason=o;this.name="AppUnreachableError"}},cd="DISPATCHER",ud="everyapp",wf=Object.freeze({cpuMs:5e3,subrequests:200});function Ef(e){return`APP__${e}`}function Tf(e){return typeof e=="object"&&e!==null&&typeof e.get=="function"}var $f=/^[a-z0-9]{1,12}$/;function zf(e){let t="every-",r=`-${e.appId}`;if(!e.workerName.startsWith(t)||!e.workerName.endsWith(r)||e.workerName.length<=t.length+r.length)return!1;let o=e.workerName.slice(t.length,e.workerName.length-r.length);return $f.test(o)&&qu({appId:e.appId,orgKey:o,workerName:e.workerName})}function ld(e,t){return e instanceof Error&&e.message.startsWith("Worker not found")?new ot(`The dispatch namespace has no Worker "${t}".`,"worker_not_found"):e}function Pf(e,t){let r=e[cd];if(!Tf(r))throw new ot(`No dispatch namespace binding "${cd}" for worker "${t.workerName}". Only a hosted gateway with a Workers for Platforms namespace reaches dispatch apps.`,"no_dispatcher");if(!zf(t))throw new ot(`Worker "${t.workerName}" is not app "${t.appId}"'s registry Worker; refusing to dispatch to it.`,"invalid_worker_name");let o=t.limits??wf,n={appId:t.appId,organizationId:t.organizationId,workerName:t.workerName,egress:[...t.egress??[]]},a;try{a=r.get(t.workerName,{},{limits:{cpuMs:o.cpuMs,subRequests:o.subrequests},outbound:{[ud]:n}})}catch(i){throw ld(i,t.workerName)}return{async fetch(i){try{return await a.fetch(i)}catch(l){throw ld(l,t.workerName)}}}}function Oo(e,t){if(t.tier==="service_binding"){let r=Ef(t.workerName),o=e[r];if(!o||typeof o.fetch!="function")throw new ot(`No service binding "${r}" for worker "${t.workerName}". The gateway must be redeployed with bindings reconstructed from the registry.`);return o}if(t.tier==="dispatch")return Pf(e,t);throw new ot(`Tier "${String(t.tier)}" is not a way to reach an app.`)}var Cf=24*60*60,kf=10*60,If="__host-everyapp_";var h0=new TextEncoder;function dd(e){return e.trimStart().toLowerCase().startsWith(If)}function ec(e){let t=new Headers(e.headers);t.delete("access-control-allow-credentials");let r=t.getSetCookie();if(r.some(dd)){t.delete("set-cookie");for(let o of r)dd(o)||t.append("set-cookie",o)}if(e.status===101){Qi(t);let{webSocket:o}=e;return new Response(null,{status:101,statusText:e.statusText,webSocket:o,headers:t})}return new Response(e.body,{status:e.status,statusText:e.statusText,headers:t})}var Af=/^\/assets\/[^/]+-([A-Za-z0-9_-]{8})\.(?:m?js|css|json|wasm|woff2?|ttf|otf|eot|png|jpe?g|gif|webp|avif|svg|ico)(?:\.map)?$/,Of=/^(?:[a-z]{8}|[A-Z]{8})$/,Mf="public, max-age=0, must-revalidate",md="private, max-age=31536000, immutable";function hd(e){let t=Af.exec(e);return t!==null&&!Of.test(t[1])}function pd(e){return e.toLowerCase().replace(/\s+/g,"")}function tc(e,t,r){if(e!=="GET"&&e!=="HEAD"||r.status!==200&&r.status!==304||!hd(t)||(r.headers.get("content-type")??"").includes("text/html"))return r;let n=r.headers.get("cache-control");if(n===null||pd(n)!==pd(Mf))return r;let a=new Headers(r.headers);return a.set("cache-control",md),new Response(r.body,{status:r.status,statusText:r.statusText,headers:a})}var Nf=du*1e3/2,fd=new Map;function Me(e,t){return $t(new Response(JSON.stringify(t),{status:e,headers:{"content-type":"application/json"}}))}function Sd(e){return $r("app.unroutable",{app:e.appId,message:e.message},"error"),Me(503,{error:"app_unavailable",app:e.appId})}function qf(e,t){return t?`Bearer realm="every-app", error="invalid_token", error_description="Use a personal access token here, or connect ${`${e.replace(/\/$/,"")}/mcp`.replace(/["\\]/g,"")}"`:'Bearer realm="every-app"'}function gd(e,t,r,o){return $t(new Response(JSON.stringify(t),{status:e,headers:{"content-type":"application/json","www-authenticate":qf(r,o)}}))}function yd(e){return(e.headers.get("accept")??"").includes("text/html")}function vd(e,t){return e.audienceFor?e.audienceFor(t):t.workerName}async function jf(e,t){let r=e.now??Date.now(),o=vd(e,t),n=`${o}\0${e.issuer}`,a=fd.get(n);if(a&&r-a.mintedAtMs<Nf)return a.marker;let i=await Wn(e.privateKeyPem,{audience:o,issuer:e.issuer,keyId:e.keyId,now:r});return fd.set(n,{marker:i,mintedAtMs:r}),i}function rc(e){$r("proxy",{app:e.app.appId,method:e.method,status:e.status,ms:Date.now()-e.startedAtMs,gatewayMs:e.startedAtMs-e.receivedAtMs,mode:e.mode})}function Lf(e,t,r){return`gw;dur=${t-e}, app;dur=${r-t}`}async function Df(e,t){if(!e.activate)return!1;try{return await e.activate(t)}catch(r){return $r("app.activate_failed",{app:t.appId,message:r instanceof Error?r.message:String(r)},"warn"),!1}}async function oc(e,t){let r=Date.now(),o=new URL(e.url),n=Xt(e.headers.get("host")??o.host);if(!n)return Me(400,{error:"missing_host"});let a;try{a=await t.resolveApp(n,t.registry)}catch(T){if(!(T instanceof Ui))throw T;return Sd(T)}if(!a)return Me(404,{error:"no_app_for_host",host:n.host});if(a.status==="disabled")return Me(503,{error:"app_unavailable",status:a.status});if(a.status==="binding"&&await Df(t,a)&&(a={...a,status:"active"}),a.status!=="active"){let T=Me(503,{error:"app_deploying",status:a.status});return T.headers.set("retry-after","5"),T}let i=Io(a.manifest.public,e.method,o.pathname);if(t.needsSetup){let T=await t.needsSetup({app:a,request:e,publicRoute:i.public});if(T)return T}if(Li(o.pathname))return Me(404,{error:"not_found"});if(Di(o.pathname))return Me(404,{error:"not_found"});if(a.manifest.serverFnGuard!==!1&&Wi(o.pathname,a.manifest.serverFnBase)){let T=Yi(e.headers);if(!T.allowed)return Me(403,{error:"server_fn_denied",reason:T.reason})}if(Fi(e.headers,t.authenticator.sessionCookieNames))return $r("session.duplicate_cookie",{app:a.appId},"warn"),Me(401,{error:"unauthenticated",reason:"duplicate_session_cookie",message:Bi});let l=Zi(e.headers),c=ad(e.headers),u=e.headers.has("cookie"),m=Ji(e.headers)&&u&&!l?Ki(n.host,e.headers.get("origin")):Gi(e.method,n.host,e.headers.get("origin"),e.headers.get("sec-fetch-site"));if(!l&&!m.allowed&&!i.public&&u)return Me(403,{error:"csrf_denied",reason:m.reason});let f=i.public?"public":"user",y=null;if(m.allowed||l)try{y=await t.authenticator.authenticate(e)}catch(T){if(!i.public)throw T;console.error(`authentication failed for public app "${a.appId}"; continuing anonymously:`,T instanceof Error?T.stack??T.message:T)}let R=y?await t.authenticator.hasAppAccess(y,a):!1,S=R!==!1;y&&typeof R=="object"&&(y=R);let P=y?.credential?.kind==="pat"||y?.credential?.kind==="oauth",b=Ao(e.headers,i.public,c||P);if(y&&S){let T=a.manifest.mcp?.by,_=T==="gateway"&&o.pathname==="/mcp"&&!i.public,C=_||T==="app"&&o.pathname==="/mcp";if(ed(y.credential)&&!C)return Me(403,{error:"forbidden",reason:"token_scope"});if(_){let U=t.interceptMcp?await t.interceptMcp({request:e,app:a,session:y}):null;return U?$t(U):Me(503,{error:"mcp_unavailable",app:a.appId})}let M=await Er(t.privateKeyPem,{subject:{sub:y.sub,email:y.email,orgId:y.orgId,orgRole:y.orgRole},audience:vd(t,a),issuer:t.issuer,channel:y.credential?.channel??"web",actor:y.credential?.actor?{sub:y.credential.actor}:void 0,scopes:y.credential?.scopes,keyId:t.keyId,now:t.now});b.set(Tt,M)}else{if(c||P||l&&!i.public)return y?Me(403,{error:"forbidden",reason:"no_app_access"}):gd(401,{error:"unauthenticated"},t.issuer,l);if(i.public){let T=await jf(t,a);b.set(wr,T)}else return y?Me(403,{error:"forbidden",reason:"no_app_access"}):yd(e)&&t.thirdParty?$t(await t.thirdParty.startSession(e)):yd(e)&&t.loginUrl?$t(new Response(null,{status:302,headers:{location:`${t.loginUrl}?return_to=${encodeURIComponent(o.toString())}`}})):gd(401,{error:"unauthenticated"},t.issuer,l)}let h=new Request(e.url,{method:e.method,headers:b,body:e.body,redirect:"manual",cf:e.cf,...e.body?{duplex:"half"}:{}}),$,v=Date.now();try{$=await(t.fetcherFor??Oo)(t.env,a).fetch(h)}catch(T){return T instanceof ot?(console.error(`app unreachable: ${T.message}`),rc({app:a,method:e.method,status:503,receivedAtMs:r,startedAtMs:v,mode:f}),Me(503,{error:"app_unreachable",app:a.appId})):(console.error(`app "${a.appId}" threw:`,T instanceof Error?T.stack??T.message:T),rc({app:a,method:e.method,status:502,receivedAtMs:r,startedAtMs:v,mode:f}),Me(502,{error:"app_error",app:a.appId}))}let z=Date.now();if(rc({app:a,method:e.method,status:$.status,receivedAtMs:r,startedAtMs:v,mode:f}),$.status===101)return t.thirdParty?ec($):$;let I=$t(tc(e.method,o.pathname,t.thirdParty?ec($):$));return I.headers.append("server-timing",Lf(r,v,z)),I}var rs=new Set(["connection","keep-alive","transfer-encoding","te","trailer","proxy-authenticate","proxy-authorization"]);function nc(e){let r=`http://${e.headers.host??"localhost"}${e.url??"/"}`,o=new Headers;for(let i=0;i<e.rawHeaders.length;i+=2){let l=e.rawHeaders[i];rs.has(l.toLowerCase())||o.append(l,e.rawHeaders[i+1])}let n=e.method??"GET",a=n!=="GET"&&n!=="HEAD";return new Request(r,{method:n,headers:o,...a?{body:ts.toWeb(e),duplex:"half"}:{}})}async function os(e,t){let r={};t.headers.forEach((n,a)=>{a==="set-cookie"||rs.has(a)||(r[a]=n)});let o=t.headers.getSetCookie();o.length>0&&(r["set-cookie"]=o),e.writeHead(t.status,r),t.body?await Hf(ts.fromWeb(t.body),e):e.end()}function sc(e,t="127.0.0.1"){return{fetch(r){let o=new URL(r.url),n={};return r.headers.forEach((a,i)=>{rs.has(i)||(n[i]=a)}),n.host=o.host,new Promise((a,i)=>{let l=xf.request({host:t,port:e,method:r.method,path:o.pathname+o.search,headers:n},c=>{let u=new Headers;for(let y=0;y<c.rawHeaders.length;y+=2){let R=c.rawHeaders[y];rs.has(R.toLowerCase())||u.append(R,c.rawHeaders[y+1])}let m=c.statusCode??502,f=m!==204&&m!==304&&r.method!=="HEAD";a(new Response(f?ts.toWeb(c):null,{status:m,headers:u}))});l.on("error",i),r.body?ts.fromWeb(r.body).pipe(l):l.end()})}}}function Uf(e){let t=e.headers.host??"localhost",r=new Headers;for(let o=0;o<e.rawHeaders.length;o+=2)r.append(e.rawHeaders[o],e.rawHeaders[o+1]);return new Request(`http://${t}${e.url??"/"}`,{method:e.method??"GET",headers:r})}async function bd(e,t,r,o){try{if(o.parseAppLabel(e.headers.host??null)!==o.appId){t.end(`HTTP/1.1 404 Not Found\r
|
|
2
|
+
connection: close\r
|
|
3
|
+
\r
|
|
4
|
+
`);return}let a=Uf(e),i=Io(o.publicRoutes,a.method,new URL(a.url).pathname),l=await o.mintIdentity(a);if(!l&&!i.public){t.end(`HTTP/1.1 401 Unauthorized\r
|
|
5
|
+
connection: close\r
|
|
6
|
+
\r
|
|
7
|
+
`);return}let c=Ao(a.headers,i.public);l?c.set(Tt,l):c.set(wr,await o.mintPublicMarker()),ac(e,t,r,o.appPort,{outboundHeaders:c})}catch{t.destroy()}}function ac(e,t,r,o,n={}){let a=[`${e.method??"GET"} ${e.url??"/"} HTTP/1.1`];if(n.outboundHeaders)n.outboundHeaders.forEach((c,u)=>{a.push(`${u}: ${c}`)});else for(let c=0;c<e.rawHeaders.length;c+=2)a.push(`${e.rawHeaders[c]}: ${e.rawHeaders[c+1]}`);let i=_d.connect(o,n.targetHost??"127.0.0.1",()=>{i.write(a.join(`\r
|
|
8
|
+
`)+`\r
|
|
9
|
+
\r
|
|
10
|
+
`),r.length>0&&i.write(r),t.pipe(i),i.pipe(t)}),l=()=>{t.destroy(),i.destroy()};i.on("error",l),t.on("error",l)}function Rd(){return new Promise((e,t)=>{let r=_d.createServer();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let o=r.address();if(o&&typeof o=="object"){let n=o.port;r.close(()=>e(n))}else r.close(()=>t(new Error("could not allocate a port")))})})}function wd(e,t=9e4){return ic(`http://127.0.0.1:${e}/`,t)}async function ic(e,t=9e4){let r=Date.now()+t,o;for(;Date.now()<r;)try{await fetch(e,{method:"HEAD"});return}catch(n){o=n,await new Promise(a=>setTimeout(a,300))}throw new Error(`nothing answered at ${e} within ${t}ms: ${String(o)}`)}import Vf from"node:net";function ns(e,t,r=process.argv.slice(2)){let o=e.slice(2).replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),n=new Set([e,`--${o}`]),a=[];for(let i=0;i<r.length;i++){let l=r[i];if(n.has(l)){i++;continue}[...n].some(c=>l.startsWith(`${c}=`))||a.push(l)}return Kn([],{argv:[...a,e,t]})}var Mo=(r=>(r.Stub="stub",r.Mirror="mirror",r))(Mo||{}),lc="EVERYAPP_DEV_MODE",Zt="everyapp.localhost";function Ed(e,t){let r=e??t??"stub",o=Object.values(Mo).find(n=>n===r.toLowerCase());if(o)return o;throw new De("INVALID_DEV_MODE",[`${e===void 0?lc:"--mode"} must be stub or mirror, not "${r}"`,"stub signs you in as a seeded dev user; mirror uses real login through a local Gateway."].join(`
|
|
11
|
+
`))}function Bf(e){let t=e.split(":")[0]??e;return t.length===0?0:t.split(".").filter(r=>r.length>0).length}function Td(e){if(!(Bf(e)>=2))throw new De("MIRROR_BASE_HOST",[`Mirror mode needs a two-label base host, like ${Zt}`,`The session cookie must cross from the Gateway to the app's subdomain; "${e}" has one label.`,`Open apps at http://<app>.${Zt}:<port> through portless or an /etc/hosts entry.`].join(`
|
|
12
|
+
`),{rerun:ns("--base-host",Zt),data:{baseHost:e,fix:`on the local Gateway, set EVERYAPP_DEV_COOKIE_DOMAIN=${Zt} and GATEWAY_URL=http://${Zt}:<port>`}})}var cc=e=>e.split(":")[0]??e;function uc(e,t){let r=cc(e).toLowerCase(),o=cc(t).toLowerCase();if(r===o)return{kind:"launcher"};if(r.endsWith(`.${o}`)){let n=r.slice(0,-(o.length+1));if(n.length>0&&!n.includes("."))return{kind:"app",appLabel:n}}return{kind:"invalid"}}function dc(e,t){let r;try{r=new URL(`http://${e.trim().toLowerCase()}`).hostname}catch{return!1}if(!r)return!1;if(r==="localhost"||r.endsWith(".localhost")||Vf.isIP(r.replace(/^\[|\]$/g,"")))return!0;if(t){let o=cc(t).trim().toLowerCase();if(o&&(r===o||r.endsWith(`.${o}`)))return!0}return!1}function $d(e){return e.origin!==void 0||e.referer!==void 0||e["sec-fetch-mode"]!==void 0||e["sec-fetch-site"]!==void 0}function zd(e){let t=e.fetchImpl??fetch,r=new URL("/api/dev/identity",e.gatewayUrl).toString(),o=new Set;function n(i){switch(i){case"no_session":return`No Gateway session yet: log in at ${e.loginUrl}, then reload`;case"no_active_organization":return"No active organization: create or pick one in the Gateway, then reload";case"expired":return"Your Gateway session expired: log in again, then reload";default:return`The Gateway rejected the session (${i})`}}function a(i){!i||o.has(i)||(o.add(i),e.onHint?.(n(i)))}return{sessionCookieNames:[],async authenticate(i){let l=i.headers.get("cookie"),c=Xi(i.headers);if(!l&&!c)return a("no_session"),null;let u=c?{authorization:`Bearer ${c}`}:{cookie:l},m;try{m=await t(r,{headers:u})}catch(y){return e.onHint?.([`Can't reach the local Gateway at ${e.gatewayUrl}`,`${Tr(y)}. Is pnpm dev running in apps/every-app-gateway?`].join(`
|
|
13
|
+
`)),null}if(!m.ok)return null;let f=await m.json();return f.session?f.session:(a(f.reason),null)},async hasAppAccess(){return!0}}}var No="dev.migrations";async function Pd({cwd:e,manifest:t,cf:r,out:o,skip:n}){if(await Xu(e,o),n){o.emit({type:"step",step:No,status:"skip",data:{reason:"flag"}});return}let a=await Gu(e,t);if(a.status==="skipped"){o.emit({type:"step",step:No,status:"skip",data:{reason:a.reason}});return}o.emit({type:"step",step:No,status:"start",message:"Applying local migrations..."});let i;try{i=await Ju({cwd:e,manifest:t,cf:r,...a})}catch(l){let c=Tr(l);throw o.emit({type:"step",step:No,status:"fail",data:{message:c}}),new De("MIGRATIONS_FAILED",["A local migration failed",c,"Or start with --skip-migrations if the local database is already usable."].join(`
|
|
14
|
+
`),{data:{fix:`correct the migration, then run ${Kn()} again`}})}Zu(o,No,i)}async function Cd({cwd:e,manifest:t,cf:r,port:o}){return t.dev?ju({command:t.dev,args:[],cwd:e,env:{...process.env,PORT:String(o),NODE_OPTIONS:Du(process.env.NODE_OPTIONS)},shell:!0,hold:!0}):r.start({args:["dev"],cwd:e,env:{PORT:String(o),...Ku(e)},holdOutput:!0})}import Xh from"node:net";var zt={sub:"dev-user",email:"dev@everyapp.localhost",orgId:"dev-org",orgRole:"owner"},Ff="x-everyapp-dev-anon",Gf=/(?:^|;\s*)everyapp_dev_anon=1(?:;|$)/;function Jf(){return{sessionCookieNames:[],authenticate:async e=>e.headers.get(Ff)==="1"||Gf.test(e.headers.get("cookie")??"")?null:zt,hasAppAccess:async()=>!0}}function kd(e){let t=new Vi(e.apps.map(o=>o.manifest.mcp?o:{...o,manifest:{...o.manifest,mcp:{by:"gateway",why:"everyapp dev serves it locally."}}})),r={env:e.env,registry:t,authenticator:e.authenticator??Jf(),privateKeyPem:Yt,issuer:Wt,keyId:Kt,resolveApp:async(o,n)=>o.appLabel?n.findByAppId(o.appLabel):null,fetcherFor:e.fetcherFor??Oo,audienceFor:o=>o.appId,interceptMcp:e.interceptMcp};return o=>oc(o,r)}async function pc(e,t=zt){return Er(Yt,{subject:t,audience:e,issuer:Wt,channel:"web",keyId:Kt})}async function Id(e){return Wn(Yt,{audience:e,issuer:Wt,keyId:Kt})}function Se(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var qo=class extends Error{constructor(r){super(`timed out after ${r}ms`);this.ms=r;this.name="TimeoutError"}};async function ss(e,t){let r=new AbortController,o,n=new Promise((a,i)=>{o=setTimeout(()=>{r.abort(),i(new qo(e))},e)});try{return await Promise.race([t(r.signal),n])}finally{clearTimeout(o)}}async function as(e,t,r){let o=Number(e.headers.get("content-length"));if(Number.isFinite(o)&&o>t)return await e.body?.cancel().catch(()=>{}),{ok:!1,bytes:o};if(!e.body)return{ok:!0,text:"",bytes:0};let n=e.body.getReader(),a=()=>void n.cancel().catch(()=>{});r?.aborted&&a(),r?.addEventListener("abort",a,{once:!0});let i=new TextDecoder,l="",c=0;try{for(;;){let{done:u,value:m}=await n.read();if(u)break;if(c+=m.byteLength,c>t)return await n.cancel().catch(()=>{}),{ok:!1,bytes:c};l+=i.decode(m,{stream:!0})}}finally{r?.removeEventListener("abort",a)}return{ok:!0,text:l+i.decode(),bytes:c}}function jo(e){return e.length>128?`${e.slice(0,128)}\u2026`:e}function nt(e,t){return`${e}_${t}`}function is(e){let t=e.indexOf("_");return t<=0||t===e.length-1?null:{appId:e.slice(0,t),localName:e.slice(t+1)}}function Ad(e,t,r){return e.surface==="app"?r.name:nt(t.appId,r.name)}function Od(e,t){let r,o=t;if(e.surface==="gateway"){let i=is(t);if(!i)return null;({appId:r,localName:o}=i)}let n=e.surface==="app"?e.apps[0]:e.apps.find(i=>i.appId===r),a=n?.tools.find(i=>i.name===o);return n&&a?{app:n,tool:a}:null}var Kf=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Md=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Wf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Yf=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Nd(e){return typeof e=="string"&&Md.has(e.replace(/#$/,""))}function cs(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(Kf.has(r))return"2020-12";if(Md.has(r))return"2019-09";if(Wf.has(r)||Yf.has(r))return"draft-7";throw new 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}`)}function Lo(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let o=e.length;if(o!==t.length)return!1;for(let n=0;n<o;n++)if(!Lo(e[n],t[n]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let o=Object.keys(e),n=Object.keys(t);if(o.length!==n.length)return!1;for(let a of o)if(!Lo(e[a],t[a]))return!1;return!0}return e===t}function Ye(e){return encodeURI(Xf(e))}function Xf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var Zf={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},Qf={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},eg={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},tg=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function Qt(e,t=Object.create(null),r=tg,o=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let a=e.$id||e.id;if(a){let i=new URL(a,r.href);i.hash.length>1?t[i.href]=e:(i.hash="",o===""?r=i:Qt(e,t,r))}}else if(e!==!0&&e!==!1)return t;let n=r.href+(o?"#"+o:"");if(t[n]!==void 0)throw new Error(`Duplicate schema URI "${n}".`);if(t[n]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&e.__absolute_ref__===void 0){let a=new URL(e.$ref,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:a.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let a=new URL(e.$recursiveRef,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:a.href})}if(e.$anchor){let a=new URL("#"+e.$anchor,r.href);t[a.href]=e}for(let a in e){if(eg[a])continue;let i=`${o}/${Ye(a)}`,l=e[a];if(Array.isArray(l)){if(Zf[a]){let c=l.length;for(let u=0;u<c;u++)Qt(l[u],t,r,`${i}/${u}`)}}else if(Qf[a])for(let c in l)Qt(l[c],t,r,`${i}/${Ye(c)}`);else Qt(l,t,r,i)}return t}var rg=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,og=[0,31,28,31,30,31,30,31,31,30,31,30,31],ng=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,sg=/^(?=.{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,ag=/^(?:[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,ig=/^(?:(?:[^\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,cg=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,lg=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,ug=/^(?:\/(?:[^~/]|~0|~1)*)*$/,dg=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,pg=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,mg=e=>{if(e[0]==='"')return!1;let[t,r,...o]=e.split("@");return!t||!r||o.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(n=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},hg=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,fg=/^((([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,gg=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function st(e){return e.test.bind(e)}var qd={date:jd,time:Ld.bind(void 0,!1),"date-time":vg,duration:gg,uri:Rg,"uri-reference":st(ag),"uri-template":st(ig),url:st(cg),email:mg,hostname:st(sg),ipv4:st(hg),ipv6:st(fg),regex:Eg,uuid:st(lg),"json-pointer":st(ug),"json-pointer-uri-fragment":st(dg),"relative-json-pointer":st(pg)};function yg(e){return e%4===0&&(e%100!==0||e%400===0)}function jd(e){let t=e.match(rg);if(!t)return!1;let r=+t[1],o=+t[2],n=+t[3];return o>=1&&o<=12&&n>=1&&n<=(o==2&&yg(r)?29:og[o])}function Ld(e,t){let r=t.match(ng);if(!r)return!1;let o=+r[1],n=+r[2],a=+r[3],i=!!r[5];return(o<=23&&n<=59&&a<=59||o==23&&n==59&&a==60)&&(!e||i)}var Sg=/t|\s/i;function vg(e){let t=e.split(Sg);return t.length==2&&jd(t[0])&&Ld(!0,t[1])}var _g=/\/|:/,bg=/^(?:[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 Rg(e){return _g.test(e)&&bg.test(e)}var wg=/[^\\]\\Z/;function Eg(e){if(wg.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}function Tg(e){let t=0,r=e.length,o=0,n;for(;o<r;)t++,n=e.charCodeAt(o++),n>=55296&&n<=56319&&o<r&&(n=e.charCodeAt(o),(n&64512)==56320&&o++);return t}function Te(e,t,r="2019-09",o=Qt(t),n=!0,a=null,i="#",l="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:i,keyword:"false",keywordLocation:i,error:"False boolean schema."}]};let u=typeof e,m;switch(u){case"boolean":case"number":case"string":m=u;break;case"object":e===null?m="null":Array.isArray(e)?m="array":m="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:f,$recursiveRef:y,$recursiveAnchor:R,type:S,const:P,enum:b,required:h,not:$,anyOf:v,allOf:z,oneOf:I,if:T,then:_,else:C,format:M,properties:U,patternProperties:q,additionalProperties:D,unevaluatedProperties:W,minProperties:F,maxProperties:ie,propertyNames:he,dependentRequired:ge,dependentSchemas:_e,dependencies:ue,prefixItems:O,items:j,additionalItems:E,unevaluatedItems:p,contains:g,minContains:w,maxContains:A,minItems:x,maxItems:J,uniqueItems:K,minimum:ce,maximum:fe,exclusiveMinimum:k,exclusiveMaximum:L,multipleOf:H,minLength:Q,maxLength:re,pattern:oe,__absolute_ref__:me,__absolute_recursive_ref__:Re}=t,B=[];if(R===!0&&a===null&&(a=t),y==="#"){let X=a===null?o[Re]:a,ee=`${l}/$recursiveRef`,ne=Te(e,a===null?t:a,r,o,n,X,i,ee,c);ne.valid||B.push({instanceLocation:i,keyword:"$recursiveRef",keywordLocation:ee,error:"A subschema had errors."},...ne.errors)}if(f!==void 0){let X=o[me||f];if(X===void 0){let Z=`Unresolved $ref "${f}".`;throw me&&me!==f&&(Z+=` Absolute URI "${me}".`),Z+=`
|
|
15
|
+
Known schemas:
|
|
16
|
+
- ${Object.keys(o).join(`
|
|
17
|
+
- `)}`,new Error(Z)}let ee=`${l}/$ref`,ne=Te(e,X,r,o,n,a,i,ee,c);if(ne.valid||B.push({instanceLocation:i,keyword:"$ref",keywordLocation:ee,error:"A subschema had errors."},...ne.errors),r==="4"||r==="7")return{valid:B.length===0,errors:B}}if(Array.isArray(S)){let X=S.length,ee=!1;for(let ne=0;ne<X;ne++)if(m===S[ne]||S[ne]==="integer"&&m==="number"&&e%1===0&&e===e){ee=!0;break}ee||B.push({instanceLocation:i,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${m}" is invalid. Expected "${S.join('", "')}".`})}else S==="integer"?(m!=="number"||e%1||e!==e)&&B.push({instanceLocation:i,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${m}" is invalid. Expected "${S}".`}):S!==void 0&&m!==S&&B.push({instanceLocation:i,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${m}" is invalid. Expected "${S}".`});if(P!==void 0&&(m==="object"||m==="array"?Lo(e,P)||B.push({instanceLocation:i,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(P)}.`}):e!==P&&B.push({instanceLocation:i,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(P)}.`})),b!==void 0&&(m==="object"||m==="array"?b.some(X=>Lo(e,X))||B.push({instanceLocation:i,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(b)}.`}):b.some(X=>e===X)||B.push({instanceLocation:i,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(b)}.`})),$!==void 0){let X=`${l}/not`;Te(e,$,r,o,n,a,i,X).valid&&B.push({instanceLocation:i,keyword:"not",keywordLocation:X,error:'Instance matched "not" schema.'})}let be=[];if(v!==void 0){let X=`${l}/anyOf`,ee=B.length,ne=!1;for(let Z=0;Z<v.length;Z++){let Y=v[Z],se=Object.create(c),ae=Te(e,Y,r,o,n,R===!0?a:null,i,`${X}/${Z}`,se);B.push(...ae.errors),ne=ne||ae.valid,ae.valid&&be.push(se)}ne?B.length=ee:B.splice(ee,0,{instanceLocation:i,keyword:"anyOf",keywordLocation:X,error:"Instance does not match any subschemas."})}if(z!==void 0){let X=`${l}/allOf`,ee=B.length,ne=!0;for(let Z=0;Z<z.length;Z++){let Y=z[Z],se=Object.create(c),ae=Te(e,Y,r,o,n,R===!0?a:null,i,`${X}/${Z}`,se);B.push(...ae.errors),ne=ne&&ae.valid,ae.valid&&be.push(se)}ne?B.length=ee:B.splice(ee,0,{instanceLocation:i,keyword:"allOf",keywordLocation:X,error:"Instance does not match every subschema."})}if(I!==void 0){let X=`${l}/oneOf`,ee=B.length,ne=I.filter((Z,Y)=>{let se=Object.create(c),ae=Te(e,Z,r,o,n,R===!0?a:null,i,`${X}/${Y}`,se);return B.push(...ae.errors),ae.valid&&be.push(se),ae.valid}).length;ne===1?B.length=ee:B.splice(ee,0,{instanceLocation:i,keyword:"oneOf",keywordLocation:X,error:`Instance does not match exactly one subschema (${ne} matches).`})}if((m==="object"||m==="array")&&Object.assign(c,...be),T!==void 0){let X=`${l}/if`;if(Te(e,T,r,o,n,a,i,X,c).valid){if(_!==void 0){let ee=Te(e,_,r,o,n,a,i,`${l}/then`,c);ee.valid||B.push({instanceLocation:i,keyword:"if",keywordLocation:X,error:'Instance does not match "then" schema.'},...ee.errors)}}else if(C!==void 0){let ee=Te(e,C,r,o,n,a,i,`${l}/else`,c);ee.valid||B.push({instanceLocation:i,keyword:"if",keywordLocation:X,error:'Instance does not match "else" schema.'},...ee.errors)}}if(m==="object"){if(h!==void 0)for(let Z of h)Z in e||B.push({instanceLocation:i,keyword:"required",keywordLocation:`${l}/required`,error:`Instance does not have required property "${Z}".`});let X=Object.keys(e);if(F!==void 0&&X.length<F&&B.push({instanceLocation:i,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${F} properties.`}),ie!==void 0&&X.length>ie&&B.push({instanceLocation:i,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${ie} properties.`}),he!==void 0){let Z=`${l}/propertyNames`;for(let Y in e){let se=`${i}/${Ye(Y)}`,ae=Te(Y,he,r,o,n,a,se,Z);ae.valid||B.push({instanceLocation:i,keyword:"propertyNames",keywordLocation:Z,error:`Property name "${Y}" does not match schema.`},...ae.errors)}}if(ge!==void 0){let Z=`${l}/dependantRequired`;for(let Y in ge)if(Y in e){let se=ge[Y];for(let ae of se)ae in e||B.push({instanceLocation:i,keyword:"dependentRequired",keywordLocation:Z,error:`Instance has "${Y}" but does not have "${ae}".`})}}if(_e!==void 0)for(let Z in _e){let Y=`${l}/dependentSchemas`;if(Z in e){let se=Te(e,_e[Z],r,o,n,a,i,`${Y}/${Ye(Z)}`,c);se.valid||B.push({instanceLocation:i,keyword:"dependentSchemas",keywordLocation:Y,error:`Instance has "${Z}" but does not match dependant schema.`},...se.errors)}}if(ue!==void 0){let Z=`${l}/dependencies`;for(let Y in ue)if(Y in e){let se=ue[Y];if(Array.isArray(se))for(let ae of se)ae in e||B.push({instanceLocation:i,keyword:"dependencies",keywordLocation:Z,error:`Instance has "${Y}" but does not have "${ae}".`});else{let ae=Te(e,se,r,o,n,a,i,`${Z}/${Ye(Y)}`);ae.valid||B.push({instanceLocation:i,keyword:"dependencies",keywordLocation:Z,error:`Instance has "${Y}" but does not match dependant schema.`},...ae.errors)}}}let ee=Object.create(null),ne=!1;if(U!==void 0){let Z=`${l}/properties`;for(let Y in U){if(!(Y in e))continue;let se=`${i}/${Ye(Y)}`,ae=Te(e[Y],U[Y],r,o,n,a,se,`${Z}/${Ye(Y)}`);if(ae.valid)c[Y]=ee[Y]=!0;else if(ne=n,B.push({instanceLocation:i,keyword:"properties",keywordLocation:Z,error:`Property "${Y}" does not match schema.`},...ae.errors),ne)break}}if(!ne&&q!==void 0){let Z=`${l}/patternProperties`;for(let Y in q){let se=new RegExp(Y,"u"),ae=q[Y];for(let Ee in e){if(!se.test(Ee))continue;let pt=`${i}/${Ye(Ee)}`,rt=Te(e[Ee],ae,r,o,n,a,pt,`${Z}/${Ye(Y)}`);rt.valid?c[Ee]=ee[Ee]=!0:(ne=n,B.push({instanceLocation:i,keyword:"patternProperties",keywordLocation:Z,error:`Property "${Ee}" matches pattern "${Y}" but does not match associated schema.`},...rt.errors))}}}if(!ne&&D!==void 0){let Z=`${l}/additionalProperties`;for(let Y in e){if(ee[Y])continue;let se=`${i}/${Ye(Y)}`,ae=Te(e[Y],D,r,o,n,a,se,Z);ae.valid?c[Y]=!0:(ne=n,B.push({instanceLocation:i,keyword:"additionalProperties",keywordLocation:Z,error:`Property "${Y}" does not match additional properties schema.`},...ae.errors))}}else if(!ne&&W!==void 0){let Z=`${l}/unevaluatedProperties`;for(let Y in e)if(!c[Y]){let se=`${i}/${Ye(Y)}`,ae=Te(e[Y],W,r,o,n,a,se,Z);ae.valid?c[Y]=!0:B.push({instanceLocation:i,keyword:"unevaluatedProperties",keywordLocation:Z,error:`Property "${Y}" does not match unevaluated properties schema.`},...ae.errors)}}}else if(m==="array"){J!==void 0&&e.length>J&&B.push({instanceLocation:i,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${e.length} > ${J}).`}),x!==void 0&&e.length<x&&B.push({instanceLocation:i,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${e.length} < ${x}).`});let X=e.length,ee=0,ne=!1;if(O!==void 0){let Z=`${l}/prefixItems`,Y=Math.min(O.length,X);for(;ee<Y;ee++){let se=Te(e[ee],O[ee],r,o,n,a,`${i}/${ee}`,`${Z}/${ee}`);if(c[ee]=!0,!se.valid&&(ne=n,B.push({instanceLocation:i,keyword:"prefixItems",keywordLocation:Z,error:"Items did not match schema."},...se.errors),ne))break}}if(j!==void 0){let Z=`${l}/items`;if(Array.isArray(j)){let Y=Math.min(j.length,X);for(;ee<Y;ee++){let se=Te(e[ee],j[ee],r,o,n,a,`${i}/${ee}`,`${Z}/${ee}`);if(c[ee]=!0,!se.valid&&(ne=n,B.push({instanceLocation:i,keyword:"items",keywordLocation:Z,error:"Items did not match schema."},...se.errors),ne))break}}else for(;ee<X;ee++){let Y=Te(e[ee],j,r,o,n,a,`${i}/${ee}`,Z);if(c[ee]=!0,!Y.valid&&(ne=n,B.push({instanceLocation:i,keyword:"items",keywordLocation:Z,error:"Items did not match schema."},...Y.errors),ne))break}if(!ne&&E!==void 0){let Y=`${l}/additionalItems`;for(;ee<X;ee++){let se=Te(e[ee],E,r,o,n,a,`${i}/${ee}`,Y);c[ee]=!0,se.valid||(ne=n,B.push({instanceLocation:i,keyword:"additionalItems",keywordLocation:Y,error:"Items did not match additional items schema."},...se.errors))}}}if(g!==void 0)if(X===0&&w===void 0)B.push({instanceLocation:i,keyword:"contains",keywordLocation:`${l}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(w!==void 0&&X<w)B.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${X}) than minContains (${w}).`});else{let Z=`${l}/contains`,Y=B.length,se=0;for(let ae=0;ae<X;ae++){let Ee=Te(e[ae],g,r,o,n,a,`${i}/${ae}`,Z);Ee.valid?(c[ae]=!0,se++):B.push(...Ee.errors)}se>=(w||0)&&(B.length=Y),w===void 0&&A===void 0&&se===0?B.splice(Y,0,{instanceLocation:i,keyword:"contains",keywordLocation:Z,error:"Array does not contain item matching schema."}):w!==void 0&&se<w?B.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${w} items matching schema. Only ${se} items were found.`}):A!==void 0&&se>A&&B.push({instanceLocation:i,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${A} items matching schema. ${se} items were found.`})}if(!ne&&p!==void 0){let Z=`${l}/unevaluatedItems`;for(;ee<X;ee++){if(c[ee])continue;let Y=Te(e[ee],p,r,o,n,a,`${i}/${ee}`,Z);c[ee]=!0,Y.valid||B.push({instanceLocation:i,keyword:"unevaluatedItems",keywordLocation:Z,error:"Items did not match unevaluated items schema."},...Y.errors)}}if(K)for(let Z=0;Z<X;Z++){let Y=e[Z],se=typeof Y=="object"&&Y!==null;for(let ae=0;ae<X;ae++){if(Z===ae)continue;let Ee=e[ae];(Y===Ee||se&&typeof Ee=="object"&&Ee!==null&&Lo(Y,Ee))&&(B.push({instanceLocation:i,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${Z} and ${ae}.`}),Z=Number.MAX_SAFE_INTEGER,ae=Number.MAX_SAFE_INTEGER)}}}else if(m==="number"){if(r==="4"?(ce!==void 0&&(k===!0&&e<=ce||e<ce)&&B.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${e} is less than ${k?"or equal to ":""} ${ce}.`}),fe!==void 0&&(L===!0&&e>=fe||e>fe)&&B.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${e} is greater than ${L?"or equal to ":""} ${fe}.`})):(ce!==void 0&&e<ce&&B.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${e} is less than ${ce}.`}),fe!==void 0&&e>fe&&B.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${e} is greater than ${fe}.`}),k!==void 0&&e<=k&&B.push({instanceLocation:i,keyword:"exclusiveMinimum",keywordLocation:`${l}/exclusiveMinimum`,error:`${e} is less than ${k}.`}),L!==void 0&&e>=L&&B.push({instanceLocation:i,keyword:"exclusiveMaximum",keywordLocation:`${l}/exclusiveMaximum`,error:`${e} is greater than or equal to ${L}.`})),H!==void 0){let X=e%H;Math.abs(0-X)>=11920929e-14&&Math.abs(H-X)>=11920929e-14&&B.push({instanceLocation:i,keyword:"multipleOf",keywordLocation:`${l}/multipleOf`,error:`${e} is not a multiple of ${H}.`})}}else if(m==="string"){let X=Q===void 0&&re===void 0?0:Tg(e);Q!==void 0&&X<Q&&B.push({instanceLocation:i,keyword:"minLength",keywordLocation:`${l}/minLength`,error:`String is too short (${X} < ${Q}).`}),re!==void 0&&X>re&&B.push({instanceLocation:i,keyword:"maxLength",keywordLocation:`${l}/maxLength`,error:`String is too long (${X} > ${re}).`}),oe!==void 0&&!new RegExp(oe,"u").test(e)&&B.push({instanceLocation:i,keyword:"pattern",keywordLocation:`${l}/pattern`,error:"String does not match pattern."}),M!==void 0&&qd[M]&&!qd[M](e)&&B.push({instanceLocation:i,keyword:"format",keywordLocation:`${l}/format`,error:`String does not match format "${M}".`})}return{valid:B.length===0,errors:B}}var $g=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",r=!0){this.schema=e,this.draft=t,this.shortCircuit=r,this.lookup=Qt(e)}validate(e){return Te(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),Qt(e,this.lookup)}},mc=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=cs(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new $g(e,this.draft??this._draftFor(e),this.shortcircuit);return r=>{let o=t.validate(r);return o.valid?{valid:!0,data:r,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:o.errors.map(n=>`${n.instanceLocation}: ${n.error}`).join("; ")}}}};var ls=new mc,Hd=1e3,zg=256,zr=new Map;function Ud(e,t){let r=JSON.stringify(t),o=zr.get(e);if(o?.schema===r)return o.check;let n=Mg(t),a=n?ls.getValidator(n):null;if(zr.delete(e),zr.size>=zg){let i=zr.keys().next().value;i!==void 0&&zr.delete(i)}return zr.set(e,{schema:r,check:a}),a}function Vd(e){let t=Ng(e);if(t)return`$ref "${t}" does not resolve in the schema`;try{return ls.getValidator(e)({}),null}catch(r){return r instanceof Error?r.message:String(r)}}var Dd=new Set(["pattern","patternProperties"]),Pg=new Set(["$ref","$dynamicRef","$recursiveRef"]),Cg=new Set(["unevaluatedProperties","unevaluatedItems"]),kg=new Set(["not","if","oneOf","contains"]),Ig=new Set(["additionalItems","additionalProperties","contains","contentSchema","else","if","items","not","propertyNames","then","unevaluatedItems","unevaluatedProperties"]),Ag=new Set(["allOf","anyOf","oneOf","prefixItems"]),Og=new Set(["$defs","definitions","dependencies","dependentSchemas","patternProperties","properties"]);function xd(e,t,r){return Ig.has(e)?Array.isArray(t)?t.map(r):r(t):Ag.has(e)?Array.isArray(t)?t.map(r):t:Og.has(e)&&Se(t)?Object.fromEntries(Object.entries(t).map(([o,n])=>[o,r(n)])):t}function Mg(e){let t={regex:!1,regexWhereExact:!1,reference:!1},r=!1,o=(a,i)=>{if(!Se(a))return a;for(let[l,c]of Object.entries(a))Pg.has(l)&&(t.reference=!0),Cg.has(l)&&(r=!0),Dd.has(l)&&(t.regex=!0,i&&(t.regexWhereExact=!0)),xd(l,c,u=>o(u,i||kg.has(l)));return a};if(o(e,!1),t.reference||t.regexWhereExact)return null;if(!t.regex)return e;if(r)return null;let n=a=>{if(!Se(a))return a;let i={};for(let[l,c]of Object.entries(a))Dd.has(l)||l==="additionalProperties"&&"patternProperties"in a||(i[l]=xd(l,c,n));return i};return n(e)}function Ng(e){let t=new Set,r=[],o=n=>{if(Array.isArray(n))return n.forEach(o);if(!n||typeof n!="object")return;let a=n;typeof a.$anchor=="string"&&t.add(a.$anchor),typeof a.$ref=="string"&&r.push(a.$ref),Object.values(a).forEach(o)};return o(e),r.find(n=>{if(!n.startsWith("#"))return!0;let a=n.slice(1);if(a==="")return!1;if(!a.startsWith("/"))return!t.has(a);let i=e;for(let l of a.slice(1).split("/")){let c;try{c=decodeURIComponent(l).replace(/~1/g,"/").replace(/~0/g,"~")}catch{return!0}if(!i||typeof i!="object"||!(c in i))return!0;i=i[c]}return!1})??null}function Bd(e,t){let r=0,o=[[e,0]];for(let n=o.pop();n;n=o.pop()){let[a,i]=n;if(r+=1,!(a===null||typeof a!="object")){if(i+1>t)return{tooDeep:!0};for(let l of Array.isArray(a)?a:Object.values(a))o.push([l,i+1])}}return{tooDeep:!1,values:r}}var Ve={schemaBytes:20*1024,descriptionChars:2048,titleChars:100,instructionsChars:2048,warningChars:500,warningsMax:100,responseBytes:5*1024*1024},qg=15e3,jg=/^sha256:[0-9a-f]{64}$/,Lg="x-mcp-header";function Dg(e,t){if(!Se(t)||t.v!==1)return{status:"error",error:`expected a v${1} tools catalog`};let{hash:r,sdk:o,tools:n}=t;if(typeof r!="string"||!jg.test(r))return{status:"error",error:"the catalog has no valid hash"};if(typeof o!="string"||o.length>32)return{status:"error",error:"the catalog has no SDK version"};if(!Array.isArray(n))return{status:"error",error:"the catalog has no tools list"};let a=Array.isArray(t.warnings)?t.warnings.filter(u=>typeof u=="string").slice(0,Ve.warningsMax).map(u=>u.slice(0,Ve.warningChars)):[],i;typeof t.instructions=="string"&&t.instructions&&(i=t.instructions,i.length>Ve.instructionsChars&&(i=i.slice(0,Ve.instructionsChars),a.push(`instructions trimmed to ${Ve.instructionsChars} characters`)));let l=[],c=new Set;for(let u of n){let m=xg(e,u);if(typeof m=="string"){a.push(m);continue}if(c.has(m.name)){a.push(`${m.name}: skipped, duplicate name`);continue}c.add(m.name),l.push(m)}return{status:l.length>0?"ok":"empty",hash:r,sdkVersion:o,...i?{instructions:i}:{},tools:l,warnings:a}}function xg(e,t){if(!Se(t)||typeof t.name!="string")return"skipped a tool without a name";let r=t.name,o=y=>`${r}: skipped, ${y}`;if(!gu.test(r))return o("names must be lowercase snake_case, at most 48 characters");let n=nt(e,r);if(n.length>64)return o(`"${n}" is longer than ${64} characters`);let a=t.description;if(typeof a!="string"||!a.trim())return o("no description");if(a.length>Ve.descriptionChars)return o(`description longer than ${Ve.descriptionChars} characters`);let i=t.title;if(i!==void 0&&typeof i!="string")return o("title is not a string");if(typeof i=="string"&&i.length>Ve.titleChars)return o(`title longer than ${Ve.titleChars} characters`);let l=t.risk??"write";if(!yu(l))return o(`unknown risk "${String(l)}"`);let c=Gd(t.inputSchema);if(typeof c=="string")return o(`inputSchema ${c}`);let u;if(t.outputSchema!==void 0){let y=Gd(t.outputSchema);if(typeof y=="string")return o(`outputSchema ${y}`);u=y}let m={},f=t.annotations;if(Se(f))for(let y of["idempotentHint","openWorldHint"])typeof f[y]=="boolean"&&(m[y]=f[y]);return{name:r,...i?{title:i}:{},description:a,risk:l,inputSchema:c,...u?{outputSchema:u}:{},...Object.keys(m).length>0?{annotations:m}:{}}}function Gd(e){if(!Se(e)||e.type!=="object")return'must be a JSON Schema with type "object"';let t=hc(e);if(new TextEncoder().encode(JSON.stringify(t)).byteLength>Ve.schemaBytes)return`is larger than ${Ve.schemaBytes/1024} KB`;let o=Vd(t);return o?`is not a usable JSON Schema (${o})`:t}function hc(e){if(Array.isArray(e))return e.map(hc);if(!Se(e))return e;let t={};for(let[r,o]of Object.entries(e))r!==Lg&&(t[r]=hc(o));return t}async function Jd(e,t){let r=await pu(t.signing.privateKeyPem,{audience:e.audience,issuer:t.signing.issuer,purpose:"tools.list",keyId:t.signing.keyId}),{response:o,read:n}=await ss(t.timeoutMs??qg,async l=>{let c=await t.invoke(new Request(new URL(mu,e.baseUrl),{method:"POST",headers:{"content-type":"application/json",[uu]:r},body:JSON.stringify({v:1}),signal:l})),u=await as(c,Ve.responseBytes,l);return{response:c,read:u}});if(!n.ok)return{status:"error",error:`the catalog is larger than ${Ve.responseBytes/1024/1024} MB`};let a;try{a=JSON.parse(n.text)}catch{a=void 0}if(o.ok)return Dg(e.appId,a);let i=Se(a)?a.error:void 0;return Se(a)&&a.v===1&&Se(i)?{status:"error",error:`the app refused the catalog request (${String(i.code)}): ${String(i.message)}`}:[401,403,404,405].includes(o.status)?{status:"unsupported",error:`the app answered ${o.status}; it does not serve agent tools (EveryApp SDK 0.3 or later)`}:{status:"error",error:`the app answered ${o.status}`}}var Hg=Object.create,us=Object.defineProperty,Ug=Object.getOwnPropertyDescriptor,Vg=Object.getOwnPropertyNames,Bg=Object.getPrototypeOf,Fg=Object.prototype.hasOwnProperty,V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Kd=(e,t)=>{let r={};for(var o in e)us(r,o,{get:e[o],enumerable:!0});return t&&us(r,Symbol.toStringTag,{value:"Module"}),r},Gg=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(var n=Vg(t),a=0,i=n.length,l;a<i;a++)l=n[a],!Fg.call(e,l)&&l!==r&&us(e,l,{get:(c=>t[c]).bind(null,l),enumerable:!(o=Ug(t,l))||o.enumerable});return e},ds=(e,t,r)=>(r=e!=null?Hg(Bg(e)):{},Gg(t||!e||!e.__esModule?us(r,"default",{value:e,enumerable:!0}):r,e));import*as d from"zod/v4";var rr="2025-11-25",ps="2025-03-26",Do=[rr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ms="io.modelcontextprotocol/related-task",Fe="io.modelcontextprotocol/protocolVersion",or="io.modelcontextprotocol/clientInfo",at="io.modelcontextprotocol/serverInfo",it="io.modelcontextprotocol/clientCapabilities",nr="io.modelcontextprotocol/subscriptionId",Ct="io.modelcontextprotocol/logLevel";var sr="2.0";var Pt=d.lazy(()=>d.union([d.string(),d.number(),d.boolean(),d.null(),d.record(d.string(),Pt),d.array(Pt)])),$e=d.record(d.string(),Pt),fc=d.array(Pt),xo=d.union([d.string(),d.number().int()]),Ho=d.string(),hs=d.object({ttl:d.number().optional()}),fs=d.object({taskId:d.string()}),Uo=d.looseObject({progressToken:xo.optional(),[ms]:fs.optional()}),ke=d.object({_meta:Uo.optional()}),ar=ke.extend({task:hs.optional()}),ze=d.object({method:d.string(),params:ke.loose().optional()}),Ne=d.object({_meta:Uo.optional()}),qe=d.object({method:d.string(),params:Ne.loose().optional()}),Vo=d.looseObject({get[at](){return Ir.optional().catch(void 0)}}),Pe=d.looseObject({_meta:Vo.optional()}),kt=d.union([d.string(),d.number().int()]),Bo=d.object({jsonrpc:d.literal(sr),id:kt,...ze.shape}).strict(),Fo=d.object({jsonrpc:d.literal(sr),...qe.shape}).strict(),Pr=d.object({jsonrpc:d.literal(sr),id:kt,result:Pe}).strict(),Cr=d.object({jsonrpc:d.literal(sr),id:kt.optional(),error:d.object({code:d.number().int(),message:d.string(),data:d.unknown().optional()})}).strict(),kr=d.union([Bo,Fo,Pr,Cr]),gc=d.union([Pr,Cr]),Go=Pe.strict(),gs=Ne.extend({requestId:kt.optional(),reason:d.string().optional()}),Jo=qe.extend({method:d.literal("notifications/cancelled"),params:gs}),ys=d.object({src:d.string(),mimeType:d.string().optional(),sizes:d.array(d.string()).optional(),theme:d.enum(["light","dark"]).optional()}),It=d.object({icons:d.array(ys).optional()}),mt=d.object({name:d.string(),title:d.string().optional()}),Ir=mt.extend({...mt.shape,...It.shape,version:d.string(),websiteUrl:d.string().optional(),description:d.string().optional()}),Jg=d.intersection(d.object({applyDefaults:d.boolean().optional()}),$e),Kg=d.preprocess(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,d.intersection(d.object({form:Jg.optional(),url:$e.optional()}),$e.optional())),Ss=d.looseObject({list:$e.optional(),cancel:$e.optional(),requests:d.looseObject({sampling:d.looseObject({createMessage:$e.optional()}).optional(),elicitation:d.looseObject({create:$e.optional()}).optional()}).optional()}),vs=d.looseObject({list:$e.optional(),cancel:$e.optional(),requests:d.looseObject({tools:d.looseObject({call:$e.optional()}).optional()}).optional()}),_s=d.object({experimental:d.record(d.string(),$e).optional(),sampling:d.object({context:$e.optional(),tools:$e.optional()}).optional(),elicitation:Kg.optional(),roots:d.object({listChanged:d.boolean().optional()}).optional(),tasks:Ss.optional(),extensions:d.record(d.string(),$e).optional()}),bs=ke.extend({protocolVersion:d.string(),capabilities:_s,clientInfo:Ir}),Ko=ze.extend({method:d.literal("initialize"),params:bs}),Wo=d.object({experimental:d.record(d.string(),$e).optional(),logging:$e.optional(),completions:$e.optional(),prompts:d.object({listChanged:d.boolean().optional()}).optional(),resources:d.object({subscribe:d.boolean().optional(),listChanged:d.boolean().optional()}).optional(),tools:d.object({listChanged:d.boolean().optional()}).optional(),tasks:vs.optional(),extensions:d.record(d.string(),$e).optional()}),Rs=Pe.extend({protocolVersion:d.string(),capabilities:Wo,serverInfo:Ir,instructions:d.string().optional()}),ws=qe.extend({method:d.literal("notifications/initialized"),params:Ne.optional()}),Es=ze.extend({method:d.literal("server/discover"),params:ke.optional()}),Ts=Pe.extend({supportedVersions:d.array(d.string()),capabilities:Wo,instructions:d.string().optional()}),Yo=ze.extend({method:d.literal("ping"),params:ke.optional()}),$s=d.object({progress:d.number(),total:d.optional(d.number()),message:d.optional(d.string())}),zs=d.object({...Ne.shape,...$s.shape,progressToken:xo}),Xo=qe.extend({method:d.literal("notifications/progress"),params:zs}),Ps=ke.extend({cursor:Ho.optional()}),At=ze.extend({params:Ps.optional()}),Ot=Pe.extend({nextCursor:Ho.optional()}),Zo=d.object({uri:d.string(),mimeType:d.optional(d.string()),_meta:d.record(d.string(),d.unknown()).optional()}),Qo=Zo.extend({text:d.string()}),yc=d.string().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),en=Zo.extend({blob:yc}),Mt=d.enum(["user","assistant"]),ht=d.object({audience:d.array(Mt).optional(),priority:d.number().min(0).max(1).optional(),lastModified:d.iso.datetime({offset:!0}).optional()}),tn=d.object({...mt.shape,...It.shape,uri:d.string(),description:d.optional(d.string()),mimeType:d.optional(d.string()),size:d.optional(d.number()),annotations:ht.optional(),_meta:d.optional(d.looseObject({}))}),Cs=d.object({...mt.shape,...It.shape,uriTemplate:d.string(),description:d.optional(d.string()),mimeType:d.optional(d.string()),annotations:ht.optional(),_meta:d.optional(d.looseObject({}))}),ks=At.extend({method:d.literal("resources/list")}),Is=Ot.extend({resources:d.array(tn)}),As=At.extend({method:d.literal("resources/templates/list")}),Os=Ot.extend({resourceTemplates:d.array(Cs)}),Ar=ke.extend({uri:d.string()}),Ms=Ar,Ns=ze.extend({method:d.literal("resources/read"),params:Ms}),qs=Pe.extend({contents:d.array(d.union([Qo,en]))}),js=qe.extend({method:d.literal("notifications/resources/list_changed"),params:Ne.optional()}),Ls=Ar,Ds=ze.extend({method:d.literal("resources/subscribe"),params:Ls}),xs=Ar,Hs=ze.extend({method:d.literal("resources/unsubscribe"),params:xs}),rn=d.object({toolsListChanged:d.boolean().optional(),promptsListChanged:d.boolean().optional(),resourcesListChanged:d.boolean().optional(),resourceSubscriptions:d.array(d.string()).optional()}),Us=ke.extend({notifications:rn}),Vs=ze.extend({method:d.literal("subscriptions/listen"),params:Us}),Bs=Ne.extend({notifications:rn}),Fs=qe.extend({method:d.literal("notifications/subscriptions/acknowledged"),params:Bs}),Gs=Vo.extend({[nr]:kt}),Js=Pe.extend({_meta:Gs}),Ks=Ne.extend({uri:d.string()}),Ws=qe.extend({method:d.literal("notifications/resources/updated"),params:Ks}),Ys=d.object({name:d.string(),description:d.optional(d.string()),required:d.optional(d.boolean())}),Xs=d.object({...mt.shape,...It.shape,description:d.optional(d.string()),arguments:d.optional(d.array(Ys)),_meta:d.optional(d.looseObject({}))}),Zs=At.extend({method:d.literal("prompts/list")}),Qs=Ot.extend({prompts:d.array(Xs)}),ea=ke.extend({name:d.string(),arguments:d.record(d.string(),d.string()).optional()}),ta=ze.extend({method:d.literal("prompts/get"),params:ea}),Or=d.object({type:d.literal("text"),text:d.string(),annotations:ht.optional(),_meta:d.record(d.string(),d.unknown()).optional()}),Mr=d.object({type:d.literal("image"),data:yc,mimeType:d.string(),annotations:ht.optional(),_meta:d.record(d.string(),d.unknown()).optional()}),Nr=d.object({type:d.literal("audio"),data:yc,mimeType:d.string(),annotations:ht.optional(),_meta:d.record(d.string(),d.unknown()).optional()}),ra=d.object({type:d.literal("tool_use"),name:d.string(),id:d.string(),input:d.record(d.string(),d.unknown()),_meta:d.record(d.string(),d.unknown()).optional()}),oa=d.object({type:d.literal("resource"),resource:d.union([Qo,en]),annotations:ht.optional(),_meta:d.record(d.string(),d.unknown()).optional()}),na=tn.extend({type:d.literal("resource_link")}),qr=d.union([Or,Mr,Nr,na,oa]),sa=d.object({role:Mt,content:qr}),aa=Pe.extend({description:d.string().optional(),messages:d.array(sa)}),ia=qe.extend({method:d.literal("notifications/prompts/list_changed"),params:Ne.optional()}),ca=d.object({title:d.string().optional(),readOnlyHint:d.boolean().optional(),destructiveHint:d.boolean().optional(),idempotentHint:d.boolean().optional(),openWorldHint:d.boolean().optional()}),la=d.object({taskSupport:d.enum(["required","optional","forbidden"]).optional()}),on=d.object({...mt.shape,...It.shape,description:d.string().optional(),inputSchema:d.object({type:d.literal("object"),properties:d.record(d.string(),Pt).optional(),required:d.array(d.string()).optional()}).catchall(d.unknown()),outputSchema:d.looseObject({$schema:d.string().optional()}).optional(),annotations:ca.optional(),execution:la.optional(),_meta:d.record(d.string(),d.unknown()).optional()}),ua=At.extend({method:d.literal("tools/list")}),da=Ot.extend({tools:d.array(on)}),nn=Pe.extend({content:d.array(qr).default([]),structuredContent:d.unknown().optional(),isError:d.boolean().optional()}),Sc=nn.or(Pe.extend({toolResult:d.unknown()})),pa=ar.extend({name:d.string(),arguments:d.record(d.string(),d.unknown()).optional()}),ma=ze.extend({method:d.literal("tools/call"),params:pa}),ha=qe.extend({method:d.literal("notifications/tools/list_changed"),params:Ne.optional()}),vc=d.object({autoRefresh:d.boolean().default(!0),debounceMs:d.number().int().nonnegative().default(300)}),Nt=d.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),fa=ke.extend({level:Nt}),ga=ze.extend({method:d.literal("logging/setLevel"),params:fa}),ya=Ne.extend({level:Nt,logger:d.string().optional(),data:d.unknown()}),Sa=qe.extend({method:d.literal("notifications/message"),params:ya}),va=d.object({name:d.string().optional()}),_a=d.object({hints:d.array(va).optional(),costPriority:d.number().min(0).max(1).optional(),speedPriority:d.number().min(0).max(1).optional(),intelligencePriority:d.number().min(0).max(1).optional()}),ba=d.object({mode:d.enum(["auto","required","none"]).optional()}),Ra=d.object({type:d.literal("tool_result"),toolUseId:d.string().describe("The unique identifier for the corresponding tool call."),content:d.array(qr),structuredContent:d.unknown().optional(),isError:d.boolean().optional(),_meta:d.record(d.string(),d.unknown()).optional()}),wa=d.discriminatedUnion("type",[Or,Mr,Nr]),tr=d.discriminatedUnion("type",[Or,Mr,Nr,ra,Ra]),Ea=d.object({role:Mt,content:d.union([tr,d.array(tr)]),_meta:d.record(d.string(),d.unknown()).optional()}),Ta=ar.extend({messages:d.array(Ea),modelPreferences:_a.optional(),systemPrompt:d.string().optional(),includeContext:d.enum(["none","thisServer","allServers"]).optional(),temperature:d.number().optional(),maxTokens:d.number().int(),stopSequences:d.array(d.string()).optional(),metadata:$e.optional(),tools:d.array(on).optional(),toolChoice:ba.optional()}),$a=ze.extend({method:d.literal("sampling/createMessage"),params:Ta}),za=Pe.extend({model:d.string(),stopReason:d.optional(d.enum(["endTurn","stopSequence","maxTokens"]).or(d.string())),role:Mt,content:wa}),Pa=Pe.extend({model:d.string(),stopReason:d.optional(d.enum(["endTurn","stopSequence","maxTokens","toolUse"]).or(d.string())),role:Mt,content:d.union([tr,d.array(tr)])}),sn=d.object({type:d.literal("boolean"),title:d.string().optional(),description:d.string().optional(),default:d.boolean().optional()}),jr=d.object({type:d.literal("string"),title:d.string().optional(),description:d.string().optional(),minLength:d.number().optional(),maxLength:d.number().optional(),format:d.enum(["email","uri","date","date-time"]).optional(),default:d.string().optional()}),Lr=d.object({type:d.enum(["number","integer"]),title:d.string().optional(),description:d.string().optional(),minimum:d.number().optional(),maximum:d.number().optional(),default:d.number().optional()}),an=d.object({type:d.literal("string"),title:d.string().optional(),description:d.string().optional(),enum:d.array(d.string()),default:d.string().optional()}),cn=d.object({type:d.literal("string"),title:d.string().optional(),description:d.string().optional(),oneOf:d.array(d.object({const:d.string(),title:d.string()})),default:d.string().optional()}),ln=d.object({type:d.literal("string"),title:d.string().optional(),description:d.string().optional(),enum:d.array(d.string()),enumNames:d.array(d.string()).optional(),default:d.string().optional()}),Ca=d.union([an,cn]),un=d.object({type:d.literal("array"),title:d.string().optional(),description:d.string().optional(),minItems:d.number().optional(),maxItems:d.number().optional(),items:d.object({type:d.literal("string"),enum:d.array(d.string())}),default:d.array(d.string()).optional()}),dn=d.object({type:d.literal("array"),title:d.string().optional(),description:d.string().optional(),minItems:d.number().optional(),maxItems:d.number().optional(),items:d.object({anyOf:d.array(d.object({const:d.string(),title:d.string()}))}),default:d.array(d.string()).optional()}),ka=d.union([un,dn]),Ia=d.union([ln,Ca,ka]),pn=d.union([Ia,sn,jr,Lr]),Dr=ar.extend({mode:d.literal("form").optional(),message:d.string(),requestedSchema:d.object({type:d.literal("object"),properties:d.record(d.string(),pn),required:d.array(d.string()).optional()}).catchall(d.unknown())}),Aa=ar.extend({mode:d.literal("url"),message:d.string(),elicitationId:d.string(),url:d.string().url()}),Oa=d.union([Dr,Aa]),Ma=ze.extend({method:d.literal("elicitation/create"),params:Oa}),Na=Ne.extend({elicitationId:d.string()}),qa=qe.extend({method:d.literal("notifications/elicitation/complete"),params:Na}),ja=Pe.extend({action:d.enum(["accept","decline","cancel"]),content:d.preprocess(e=>e===null?void 0:e,d.record(d.string(),d.union([d.string(),d.number(),d.boolean(),d.array(d.string())])).optional())}),La=d.object({type:d.literal("ref/resource"),uri:d.string()}),Da=d.object({type:d.literal("ref/prompt"),name:d.string()}),xa=ke.extend({ref:d.union([Da,La]),argument:d.object({name:d.string(),value:d.string()}),context:d.object({arguments:d.record(d.string(),d.string()).optional()}).optional()}),Ha=ze.extend({method:d.literal("completion/complete"),params:xa}),Ua=Pe.extend({completion:d.looseObject({values:d.array(d.string()).max(100),total:d.optional(d.number().int()),hasMore:d.optional(d.boolean())})}),Va=d.object({uri:d.string().startsWith("file://"),name:d.string().optional(),_meta:d.record(d.string(),d.unknown()).optional()}),Ba=ze.extend({method:d.literal("roots/list"),params:ke.optional()}),Fa=Pe.extend({roots:d.array(Va)}),Ga=qe.extend({method:d.literal("notifications/roots/list_changed"),params:Ne.optional()}),_c=d.looseObject({ttl:d.number().optional(),pollInterval:d.number().optional()}),Ja=d.enum(["working","input_required","completed","failed","cancelled"]),qt=d.object({taskId:d.string(),status:Ja,ttl:d.union([d.number(),d.null()]),createdAt:d.string(),lastUpdatedAt:d.string(),pollInterval:d.optional(d.number()),statusMessage:d.optional(d.string())}),bc=Pe.extend({task:qt}),Ka=Ne.merge(qt),Rc=qe.extend({method:d.literal("notifications/tasks/status"),params:Ka}),wc=ze.extend({method:d.literal("tasks/get"),params:ke.extend({taskId:d.string()})}),Ec=Pe.merge(qt),Tc=ze.extend({method:d.literal("tasks/result"),params:ke.extend({taskId:d.string()})}),$c=Pe.loose(),zc=At.extend({method:d.literal("tasks/list")}),Pc=Ot.extend({tasks:d.array(qt)}),Cc=ze.extend({method:d.literal("tasks/cancel"),params:ke.extend({taskId:d.string()})}),kc=Pe.merge(qt),Ic=d.union([Yo,Ko,Es,Ha,ga,ta,Zs,ks,As,Ns,Ds,Hs,Vs,ma,ua]),Ac=d.union([Jo,Xo,ws,Ga]),Oc=d.union([Go,za,Pa,ja,Fa]),Mc=d.union([Yo,$a,Ma,Ba]),Nc=d.union([Jo,Xo,Sa,Ws,js,ha,ia,Fs,qa]),qc=d.union([Go,Rs,Ts,Ua,aa,Qs,Is,Os,qs,nn,da,Js]);import*as N from"zod/v4";var Ie=N.url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:N.ZodIssueCode.custom,message:"URL must be parseable",fatal:!0}),N.NEVER}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Lc=N.looseObject({resource:N.string().url(),authorization_servers:N.array(Ie).optional(),jwks_uri:N.string().url().optional(),scopes_supported:N.array(N.string()).optional(),bearer_methods_supported:N.array(N.string()).optional(),resource_signing_alg_values_supported:N.array(N.string()).optional(),resource_name:N.string().optional(),resource_documentation:N.string().optional(),resource_policy_uri:N.string().url().optional(),resource_tos_uri:N.string().url().optional(),tls_client_certificate_bound_access_tokens:N.boolean().optional(),authorization_details_types_supported:N.array(N.string()).optional(),dpop_signing_alg_values_supported:N.array(N.string()).optional(),dpop_bound_access_tokens_required:N.boolean().optional()}),Wa=N.looseObject({issuer:N.string(),authorization_endpoint:Ie,token_endpoint:Ie,registration_endpoint:Ie.optional(),scopes_supported:N.array(N.string()).optional(),response_types_supported:N.array(N.string()),response_modes_supported:N.array(N.string()).optional(),grant_types_supported:N.array(N.string()).optional(),token_endpoint_auth_methods_supported:N.array(N.string()).optional(),token_endpoint_auth_signing_alg_values_supported:N.array(N.string()).optional(),service_documentation:Ie.optional(),revocation_endpoint:Ie.optional(),revocation_endpoint_auth_methods_supported:N.array(N.string()).optional(),revocation_endpoint_auth_signing_alg_values_supported:N.array(N.string()).optional(),introspection_endpoint:N.string().optional(),introspection_endpoint_auth_methods_supported:N.array(N.string()).optional(),introspection_endpoint_auth_signing_alg_values_supported:N.array(N.string()).optional(),code_challenge_methods_supported:N.array(N.string()).optional(),client_id_metadata_document_supported:N.boolean().optional(),authorization_response_iss_parameter_supported:N.boolean().optional().catch(void 0),dpop_signing_alg_values_supported:N.array(N.string()).optional()}),Ya=N.looseObject({issuer:N.string(),authorization_endpoint:Ie,token_endpoint:Ie,userinfo_endpoint:Ie.optional(),jwks_uri:Ie,registration_endpoint:Ie.optional(),scopes_supported:N.array(N.string()).optional(),response_types_supported:N.array(N.string()),response_modes_supported:N.array(N.string()).optional(),grant_types_supported:N.array(N.string()).optional(),acr_values_supported:N.array(N.string()).optional(),subject_types_supported:N.array(N.string()),id_token_signing_alg_values_supported:N.array(N.string()),id_token_encryption_alg_values_supported:N.array(N.string()).optional(),id_token_encryption_enc_values_supported:N.array(N.string()).optional(),userinfo_signing_alg_values_supported:N.array(N.string()).optional(),userinfo_encryption_alg_values_supported:N.array(N.string()).optional(),userinfo_encryption_enc_values_supported:N.array(N.string()).optional(),request_object_signing_alg_values_supported:N.array(N.string()).optional(),request_object_encryption_alg_values_supported:N.array(N.string()).optional(),request_object_encryption_enc_values_supported:N.array(N.string()).optional(),token_endpoint_auth_methods_supported:N.array(N.string()).optional(),token_endpoint_auth_signing_alg_values_supported:N.array(N.string()).optional(),display_values_supported:N.array(N.string()).optional(),claim_types_supported:N.array(N.string()).optional(),claims_supported:N.array(N.string()).optional(),service_documentation:N.string().optional(),claims_locales_supported:N.array(N.string()).optional(),ui_locales_supported:N.array(N.string()).optional(),claims_parameter_supported:N.boolean().optional(),request_parameter_supported:N.boolean().optional(),request_uri_parameter_supported:N.boolean().optional(),require_request_uri_registration:N.boolean().optional(),op_policy_uri:Ie.optional(),op_tos_uri:Ie.optional(),client_id_metadata_document_supported:N.boolean().optional(),authorization_response_iss_parameter_supported:N.boolean().optional().catch(void 0)}),Dc=N.object({...Ya.shape,...Wa.pick({code_challenge_methods_supported:!0}).shape}),xc=N.object({access_token:N.string(),id_token:N.string().optional(),token_type:N.string(),expires_in:N.coerce.number().optional(),scope:N.string().optional(),refresh_token:N.string().optional(),issuer:N.string().optional().catch(void 0)}).strip(),Hc=N.object({issued_token_type:N.literal("urn:ietf:params:oauth:token-type:id-jag"),access_token:N.string(),token_type:N.string().optional(),expires_in:N.number().optional(),scope:N.string().optional()}).strip(),Uc=N.object({error:N.string(),error_description:N.string().optional(),error_uri:N.string().optional()}),jc=Ie.optional().or(N.literal("").transform(()=>{})),Xa=N.object({redirect_uris:N.array(Ie),token_endpoint_auth_method:N.string().optional(),grant_types:N.array(N.string()).optional(),response_types:N.array(N.string()).optional(),application_type:N.string().optional(),client_name:N.string().optional(),client_uri:Ie.optional(),logo_uri:jc,scope:N.string().optional(),contacts:N.array(N.string()).optional(),tos_uri:jc,policy_uri:N.string().optional(),jwks_uri:Ie.optional(),jwks:N.any().optional(),software_id:N.string().optional(),software_version:N.string().optional(),software_statement:N.string().optional()}).strip(),Za=N.object({client_id:N.string(),client_secret:N.string().optional(),client_id_issued_at:N.number().optional(),client_secret_expires_at:N.number().optional(),issuer:N.string().optional().catch(void 0)}).strip(),Vc=Xa.merge(Za),Bc=N.object({error:N.string(),error_description:N.string().optional()}).strip(),Fc=N.object({token:N.string(),token_type_hint:N.string().optional()}).strip();import*as s from"zod/v4";var Yc=Symbol.for("mcp.sdk.errorBrands");function el(e,t){let r=new Set,o=t;for(;typeof o=="function";){let n=o.mcpBrand;Object.prototype.hasOwnProperty.call(o,"mcpBrand")&&typeof n=="string"&&r.add(n),o=Object.getPrototypeOf(o)}r.size!==0&&Object.defineProperty(e,Yc,{value:r,enumerable:!1,configurable:!0})}function Vr(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,Yc)){let r=t[Yc];if(r&&typeof r.has=="function"&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var cr=function(e){return e.InvalidRequest="invalid_request",e.InvalidClient="invalid_client",e.InvalidGrant="invalid_grant",e.UnauthorizedClient="unauthorized_client",e.UnsupportedGrantType="unsupported_grant_type",e.InvalidScope="invalid_scope",e.AccessDenied="access_denied",e.ServerError="server_error",e.TemporarilyUnavailable="temporarily_unavailable",e.UnsupportedResponseType="unsupported_response_type",e.UnsupportedTokenType="unsupported_token_type",e.InvalidToken="invalid_token",e.MethodNotAllowed="method_not_allowed",e.TooManyRequests="too_many_requests",e.InvalidClientMetadata="invalid_client_metadata",e.InvalidRedirectUri="invalid_redirect_uri",e.InsufficientScope="insufficient_scope",e.InvalidTarget="invalid_target",e.InvalidDpopProof="invalid_dpop_proof",e.UseDpopNonce="use_dpop_nonce",e}({}),vn=class Sp extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return Vr(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Vr(this,t)}constructor(t,r,o){super(r),this.code=t,this.errorUri=o,this.name="OAuthError",el(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(t){return new Sp(t.error,t.error_description??t.error,t.error_uri)}},pe=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}({}),le=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return Vr(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Vr(this,e)}constructor(e,t,r,o){super(t,o),this.code=e,this.data=r,this.name="SdkError",el(this,new.target)}},Wg=class extends le{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,o){super(e,t,r,o),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};var op={};function vp(e){return Object.hasOwn(op,e)?op[e]:void 0}function np(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Yg(e,t,r){return e==="elicitation"&&t==="form"&&r.form===void 0&&r.url===void 0}function _p(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 _n(e,t){let r={};for(let[o,n]of Object.entries(e)){if(n===void 0)continue;let a=t===void 0?void 0:t[o];if(a===void 0){r[o]=n;continue}if(np(n)&&np(a)){let i={};for(let[l,c]of Object.entries(n))c!==void 0&&a[l]===void 0&&!Yg(o,l,a)&&(i[l]=c);Object.keys(i).length>0&&(r[o]=i)}}return Object.keys(r).length>0?r:void 0}var bp="2026-07-28",lr=[bp];function gt(e){return e>=bp}function Rp(e){return e.filter(t=>!gt(t))}function si(e){return e.filter(t=>gt(t))}function wp(e){let t=e.structuredContent;return t===void 0||!(typeof t!="object"||t===null||Array.isArray(t))||(e.content?.some(r=>r.type==="text")??!1)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var Ep=["task","inputRequests","requestState"];function tl(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||Ep.some(t=>t in e)?e:{...e,content:[]}}function Xg(){let e=s.lazy(()=>s.union([s.string(),s.number(),s.boolean(),s.null(),s.record(s.string(),e),s.array(e)])),t=s.record(s.string(),e),r=s.union([s.string(),s.number().int()]),o=s.string(),n=s.object({ttl:s.number().optional()}),a=s.object({taskId:s.string()}),i=s.looseObject({progressToken:r.optional(),"io.modelcontextprotocol/related-task":a.optional()}),l=s.object({_meta:i.optional()}),c=l.extend({task:n.optional()}),u=s.object({method:s.string(),params:l.loose().optional()}),m=s.object({_meta:i.optional()}),f=s.object({method:s.string(),params:m.loose().optional()}),y=s.looseObject({_meta:i.optional()}),R=s.union([s.string(),s.number().int()]),S=y.strict(),P=m.extend({requestId:R.optional(),reason:s.string().optional()}),b=f.extend({method:s.literal("notifications/cancelled"),params:P}),h=s.object({src:s.string(),mimeType:s.string().optional(),sizes:s.array(s.string()).optional(),theme:s.enum(["light","dark"]).optional()}),$=s.object({icons:s.array(h).optional()}),v=s.object({name:s.string(),title:s.string().optional()}),z=v.extend({...v.shape,...$.shape,version:s.string(),websiteUrl:s.string().optional(),description:s.string().optional()}),I=s.intersection(s.object({applyDefaults:s.boolean().optional()}),t),T=s.preprocess(Oe=>Oe&&typeof Oe=="object"&&!Array.isArray(Oe)&&Object.keys(Oe).length===0?{form:{}}:Oe,s.intersection(s.object({form:I.optional(),url:t.optional()}),t.optional())),_=s.looseObject({list:t.optional(),cancel:t.optional(),requests:s.looseObject({sampling:s.looseObject({createMessage:t.optional()}).optional(),elicitation:s.looseObject({create:t.optional()}).optional()}).optional()}),C=s.looseObject({list:t.optional(),cancel:t.optional(),requests:s.looseObject({tools:s.looseObject({call:t.optional()}).optional()}).optional()}),M=s.object({experimental:s.record(s.string(),t).optional(),sampling:s.object({context:t.optional(),tools:t.optional()}).optional(),elicitation:T.optional(),roots:s.object({listChanged:s.boolean().optional()}).optional(),tasks:_.optional(),extensions:s.record(s.string(),t).optional()}),U=l.extend({protocolVersion:s.string(),capabilities:M,clientInfo:z}),q=u.extend({method:s.literal("initialize"),params:U}),D=s.object({experimental:s.record(s.string(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:s.object({listChanged:s.boolean().optional()}).optional(),resources:s.object({subscribe:s.boolean().optional(),listChanged:s.boolean().optional()}).optional(),tools:s.object({listChanged:s.boolean().optional()}).optional(),tasks:C.optional(),extensions:s.record(s.string(),t).optional()}),W=y.extend({protocolVersion:s.string(),capabilities:D,serverInfo:z,instructions:s.string().optional()}),F=f.extend({method:s.literal("notifications/initialized"),params:m.optional()}),ie=u.extend({method:s.literal("ping"),params:l.optional()}),he=s.object({progress:s.number(),total:s.optional(s.number()),message:s.optional(s.string())}),ge=s.object({...m.shape,...he.shape,progressToken:r}),_e=f.extend({method:s.literal("notifications/progress"),params:ge}),ue=l.extend({cursor:o.optional()}),O=u.extend({params:ue.optional()}),j=y.extend({nextCursor:o.optional()}),E=s.object({uri:s.string(),mimeType:s.optional(s.string()),_meta:s.record(s.string(),s.unknown()).optional()}),p=E.extend({text:s.string()}),g=s.string().refine(Oe=>{try{return atob(Oe),!0}catch{return!1}},{message:"Invalid Base64 string"}),w=E.extend({blob:g}),A=s.enum(["user","assistant"]),x=s.object({audience:s.array(A).optional(),priority:s.number().min(0).max(1).optional(),lastModified:s.iso.datetime({offset:!0}).optional()}),J=s.object({...v.shape,...$.shape,uri:s.string(),description:s.optional(s.string()),mimeType:s.optional(s.string()),size:s.optional(s.number()),annotations:x.optional(),_meta:s.optional(s.looseObject({}))}),K=s.object({...v.shape,...$.shape,uriTemplate:s.string(),description:s.optional(s.string()),mimeType:s.optional(s.string()),annotations:x.optional(),_meta:s.optional(s.looseObject({}))}),ce=O.extend({method:s.literal("resources/list")}),fe=j.extend({resources:s.array(J)}),k=O.extend({method:s.literal("resources/templates/list")}),L=j.extend({resourceTemplates:s.array(K)}),H=l.extend({uri:s.string()}),Q=H,re=u.extend({method:s.literal("resources/read"),params:Q}),oe=y.extend({contents:s.array(s.union([p,w]))}),me=f.extend({method:s.literal("notifications/resources/list_changed"),params:m.optional()}),Re=H,B=u.extend({method:s.literal("resources/subscribe"),params:Re}),be=H,X=u.extend({method:s.literal("resources/unsubscribe"),params:be}),ee=m.extend({uri:s.string()}),ne=f.extend({method:s.literal("notifications/resources/updated"),params:ee}),Z=s.object({name:s.string(),description:s.optional(s.string()),required:s.optional(s.boolean())}),Y=s.object({...v.shape,...$.shape,description:s.optional(s.string()),arguments:s.optional(s.array(Z)),_meta:s.optional(s.looseObject({}))}),se=O.extend({method:s.literal("prompts/list")}),ae=j.extend({prompts:s.array(Y)}),Ee=l.extend({name:s.string(),arguments:s.record(s.string(),s.string()).optional()}),pt=u.extend({method:s.literal("prompts/get"),params:Ee}),rt=s.object({type:s.literal("text"),text:s.string(),annotations:x.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),xt=s.object({type:s.literal("image"),data:g,mimeType:s.string(),annotations:x.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),Ht=s.object({type:s.literal("audio"),data:g,mimeType:s.string(),annotations:x.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),Qr=s.object({type:s.literal("tool_use"),name:s.string(),id:s.string(),input:s.record(s.string(),s.unknown()),_meta:s.record(s.string(),s.unknown()).optional()}),Rt=s.object({type:s.literal("resource"),resource:s.union([p,w]),annotations:x.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),eo=J.extend({type:s.literal("resource_link")}),Be=s.union([rt,xt,Ht,eo,Rt]),pr=s.object({role:A,content:Be}),mr=y.extend({description:s.string().optional(),messages:s.array(pr)}),Ut=f.extend({method:s.literal("notifications/prompts/list_changed"),params:m.optional()}),to=s.object({title:s.string().optional(),readOnlyHint:s.boolean().optional(),destructiveHint:s.boolean().optional(),idempotentHint:s.boolean().optional(),openWorldHint:s.boolean().optional()}),hr=s.object({taskSupport:s.enum(["required","optional","forbidden"]).optional()}),Vt=s.object({...v.shape,...$.shape,description:s.string().optional(),inputSchema:s.object({type:s.literal("object"),properties:s.record(s.string(),e).optional(),required:s.array(s.string()).optional()}).catchall(s.unknown()),outputSchema:s.object({type:s.literal("object"),properties:s.record(s.string(),e).optional(),required:s.array(s.string()).optional()}).catchall(s.unknown()).optional(),annotations:to.optional(),execution:hr.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),fr=O.extend({method:s.literal("tools/list")}),gr=j.extend({tools:s.array(Vt)}),yr=y.extend({content:s.array(Be),structuredContent:s.record(s.string(),s.unknown()).optional(),isError:s.boolean().optional()}),Ae=c.extend({name:s.string(),arguments:s.record(s.string(),s.unknown()).optional()}),ro=u.extend({method:s.literal("tools/call"),params:Ae}),An=f.extend({method:s.literal("notifications/tools/list_changed"),params:m.optional()}),Sr=s.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),oo=l.extend({level:Sr}),no=u.extend({method:s.literal("logging/setLevel"),params:oo}),so=m.extend({level:Sr,logger:s.string().optional(),data:s.unknown()}),ao=f.extend({method:s.literal("notifications/message"),params:so}),io=s.object({name:s.string().optional()}),co=s.object({hints:s.array(io).optional(),costPriority:s.number().min(0).max(1).optional(),speedPriority:s.number().min(0).max(1).optional(),intelligencePriority:s.number().min(0).max(1).optional()}),lo=s.object({mode:s.enum(["auto","required","none"]).optional()}),On=s.object({type:s.literal("tool_result"),toolUseId:s.string().describe("The unique identifier for the corresponding tool call."),content:s.array(Be),structuredContent:s.object({}).loose().optional(),isError:s.boolean().optional(),_meta:s.record(s.string(),s.unknown()).optional()}),uo=s.discriminatedUnion("type",[rt,xt,Ht]),wt=s.discriminatedUnion("type",[rt,xt,Ht,Qr,On]),po=s.object({role:A,content:s.union([wt,s.array(wt)]),_meta:s.record(s.string(),s.unknown()).optional()}),mo=c.extend({messages:s.array(po),modelPreferences:co.optional(),systemPrompt:s.string().optional(),includeContext:s.enum(["none","thisServer","allServers"]).optional(),temperature:s.number().optional(),maxTokens:s.number().int(),stopSequences:s.array(s.string()).optional(),metadata:t.optional(),tools:s.array(Vt).optional(),toolChoice:lo.optional()}),ho=u.extend({method:s.literal("sampling/createMessage"),params:mo}),fo=y.extend({model:s.string(),stopReason:s.optional(s.enum(["endTurn","stopSequence","maxTokens"]).or(s.string())),role:A,content:uo}),go=y.extend({model:s.string(),stopReason:s.optional(s.enum(["endTurn","stopSequence","maxTokens","toolUse"]).or(s.string())),role:A,content:s.union([wt,s.array(wt)])}),yo=s.object({type:s.literal("boolean"),title:s.string().optional(),description:s.string().optional(),default:s.boolean().optional()}),So=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),minLength:s.number().optional(),maxLength:s.number().optional(),format:s.enum(["email","uri","date","date-time"]).optional(),default:s.string().optional()}),vo=s.object({type:s.enum(["number","integer"]),title:s.string().optional(),description:s.string().optional(),minimum:s.number().optional(),maximum:s.number().optional(),default:s.number().optional()}),_o=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),enum:s.array(s.string()),default:s.string().optional()}),bo=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),oneOf:s.array(s.object({const:s.string(),title:s.string()})),default:s.string().optional()}),Ro=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),enum:s.array(s.string()),enumNames:s.array(s.string()).optional(),default:s.string().optional()}),wo=s.union([_o,bo]),Bt=s.object({type:s.literal("array"),title:s.string().optional(),description:s.string().optional(),minItems:s.number().optional(),maxItems:s.number().optional(),items:s.object({type:s.literal("string"),enum:s.array(s.string())}),default:s.array(s.string()).optional()}),Ft=s.object({type:s.literal("array"),title:s.string().optional(),description:s.string().optional(),minItems:s.number().optional(),maxItems:s.number().optional(),items:s.object({anyOf:s.array(s.object({const:s.string(),title:s.string()}))}),default:s.array(s.string()).optional()}),Mn=s.union([Bt,Ft]),Nn=s.union([Ro,wo,Mn]),He=s.union([Nn,yo,So,vo]),Ue=c.extend({mode:s.literal("form").optional(),message:s.string(),requestedSchema:s.object({type:s.literal("object"),properties:s.record(s.string(),He),required:s.array(s.string()).optional()}).catchall(s.unknown())}),Eo=c.extend({mode:s.literal("url"),message:s.string(),elicitationId:s.string(),url:s.string().url()}),We=s.union([Ue,Eo]),qn=u.extend({method:s.literal("elicitation/create"),params:We}),jn=m.extend({elicitationId:s.string()}),Ln=f.extend({method:s.literal("notifications/elicitation/complete"),params:jn}),Dn=y.extend({action:s.enum(["accept","decline","cancel"]),content:s.preprocess(Oe=>Oe===null?void 0:Oe,s.record(s.string(),s.union([s.string(),s.number(),s.boolean(),s.array(s.string())])).optional())}),xn=s.object({type:s.literal("ref/resource"),uri:s.string()}),Hn=s.object({type:s.literal("ref/prompt"),name:s.string()}),Un=l.extend({ref:s.union([Hn,xn]),argument:s.object({name:s.string(),value:s.string()}),context:s.object({arguments:s.record(s.string(),s.string()).optional()}).optional()}),To=u.extend({method:s.literal("completion/complete"),params:Un}),Vn=y.extend({completion:s.looseObject({values:s.array(s.string()).max(100),total:s.optional(s.number().int()),hasMore:s.optional(s.boolean())})}),Bn=s.object({uri:s.string().startsWith("file://"),name:s.string().optional(),_meta:s.record(s.string(),s.unknown()).optional()}),vr=u.extend({method:s.literal("roots/list"),params:l.optional()}),$o=y.extend({roots:s.array(Bn)}),Fn=f.extend({method:s.literal("notifications/roots/list_changed"),params:m.optional()}),Gn=s.looseObject({ttl:s.number().optional(),pollInterval:s.number().optional()}),zo=s.enum(["working","input_required","completed","failed","cancelled"]),Et=s.object({taskId:s.string(),status:zo,ttl:s.union([s.number(),s.null()]),createdAt:s.string(),lastUpdatedAt:s.string(),pollInterval:s.optional(s.number()),statusMessage:s.optional(s.string())}),Le=y.extend({task:Et}),Jn=m.merge(Et),Gt=f.extend({method:s.literal("notifications/tasks/status"),params:Jn}),_r=u.extend({method:s.literal("tasks/get"),params:l.extend({taskId:s.string()})}),br=y.merge(Et),Rr=u.extend({method:s.literal("tasks/result"),params:l.extend({taskId:s.string()})}),Mi=y.loose(),je=O.extend({method:s.literal("tasks/list")}),Ce=j.extend({tasks:s.array(Et)}),Jt=u.extend({method:s.literal("tasks/cancel"),params:l.extend({taskId:s.string()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,TaskMetadataSchema:n,RelatedTaskMetadataSchema:a,RequestMetaSchema:i,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:c,RequestSchema:u,NotificationsParamsSchema:m,NotificationSchema:f,ResultSchema:y,RequestIdSchema:R,EmptyResultSchema:S,CancelledNotificationParamsSchema:P,CancelledNotificationSchema:b,IconSchema:h,IconsSchema:$,BaseMetadataSchema:v,ImplementationSchema:z,ClientTasksCapabilitySchema:_,ServerTasksCapabilitySchema:C,ClientCapabilitiesSchema:M,InitializeRequestParamsSchema:U,InitializeRequestSchema:q,ServerCapabilitiesSchema:D,InitializeResultSchema:W,InitializedNotificationSchema:F,PingRequestSchema:ie,ProgressSchema:he,ProgressNotificationParamsSchema:ge,ProgressNotificationSchema:_e,PaginatedRequestParamsSchema:ue,PaginatedRequestSchema:O,PaginatedResultSchema:j,ResourceContentsSchema:E,TextResourceContentsSchema:p,BlobResourceContentsSchema:w,RoleSchema:A,AnnotationsSchema:x,ResourceSchema:J,ResourceTemplateSchema:K,ListResourcesRequestSchema:ce,ListResourcesResultSchema:fe,ListResourceTemplatesRequestSchema:k,ListResourceTemplatesResultSchema:L,ResourceRequestParamsSchema:H,ReadResourceRequestParamsSchema:Q,ReadResourceRequestSchema:re,ReadResourceResultSchema:oe,ResourceListChangedNotificationSchema:me,SubscribeRequestParamsSchema:Re,SubscribeRequestSchema:B,UnsubscribeRequestParamsSchema:be,UnsubscribeRequestSchema:X,ResourceUpdatedNotificationParamsSchema:ee,ResourceUpdatedNotificationSchema:ne,PromptArgumentSchema:Z,PromptSchema:Y,ListPromptsRequestSchema:se,ListPromptsResultSchema:ae,GetPromptRequestParamsSchema:Ee,GetPromptRequestSchema:pt,TextContentSchema:rt,ImageContentSchema:xt,AudioContentSchema:Ht,ToolUseContentSchema:Qr,EmbeddedResourceSchema:Rt,ResourceLinkSchema:eo,ContentBlockSchema:Be,PromptMessageSchema:pr,GetPromptResultSchema:mr,PromptListChangedNotificationSchema:Ut,ToolAnnotationsSchema:to,ToolExecutionSchema:hr,ToolSchema:Vt,ListToolsRequestSchema:fr,ListToolsResultSchema:gr,CallToolResultSchema:yr,CallToolRequestParamsSchema:Ae,CallToolRequestSchema:ro,ToolListChangedNotificationSchema:An,LoggingLevelSchema:Sr,SetLevelRequestParamsSchema:oo,SetLevelRequestSchema:no,LoggingMessageNotificationParamsSchema:so,LoggingMessageNotificationSchema:ao,ModelHintSchema:io,ModelPreferencesSchema:co,ToolChoiceSchema:lo,ToolResultContentSchema:On,SamplingContentSchema:uo,SamplingMessageContentBlockSchema:wt,SamplingMessageSchema:po,CreateMessageRequestParamsSchema:mo,CreateMessageRequestSchema:ho,CreateMessageResultSchema:fo,CreateMessageResultWithToolsSchema:go,BooleanSchemaSchema:yo,StringSchemaSchema:So,NumberSchemaSchema:vo,UntitledSingleSelectEnumSchemaSchema:_o,TitledSingleSelectEnumSchemaSchema:bo,LegacyTitledEnumSchemaSchema:Ro,SingleSelectEnumSchemaSchema:wo,UntitledMultiSelectEnumSchemaSchema:Bt,TitledMultiSelectEnumSchemaSchema:Ft,MultiSelectEnumSchemaSchema:Mn,EnumSchemaSchema:Nn,PrimitiveSchemaDefinitionSchema:He,ElicitRequestFormParamsSchema:Ue,ElicitRequestURLParamsSchema:Eo,ElicitRequestParamsSchema:We,ElicitRequestSchema:qn,ElicitationCompleteNotificationParamsSchema:jn,ElicitationCompleteNotificationSchema:Ln,ElicitResultSchema:Dn,ResourceTemplateReferenceSchema:xn,PromptReferenceSchema:Hn,CompleteRequestParamsSchema:Un,CompleteRequestSchema:To,CompleteResultSchema:Vn,RootSchema:Bn,ListRootsRequestSchema:vr,ListRootsResultSchema:$o,RootsListChangedNotificationSchema:Fn,TaskCreationParamsSchema:Gn,TaskStatusSchema:zo,TaskSchema:Et,CreateTaskResultSchema:Le,TaskStatusNotificationParamsSchema:Jn,TaskStatusNotificationSchema:Gt,GetTaskRequestSchema:_r,GetTaskResultSchema:br,GetTaskPayloadRequestSchema:Rr,GetTaskPayloadResultSchema:Mi,ListTasksRequestSchema:je,ListTasksResultSchema:Ce,CancelTaskRequestSchema:Jt,CancelTaskResultSchema:y.merge(Et),ClientRequestSchema:s.union([ie,q,To,no,pt,se,ce,k,re,B,X,ro,fr,_r,Rr,je,Jt]),ClientNotificationSchema:s.union([b,_e,F,Fn,Gt]),ClientResultSchema:s.union([S,fo,go,Dn,$o,br,Ce,Le]),ServerRequestSchema:s.union([ie,ho,qn,vr,_r,Rr,je,Jt]),ServerNotificationSchema:s.union([b,_e,ao,ne,me,An,Ut,Gt,Ln]),ServerResultSchema:s.union([S,W,Vn,mr,ae,fe,L,oe,yr,gr,br,Ce,Le]),CallToolResultWireSchema:s.unknown().superRefine((Oe,nf)=>{if(!(typeof Oe!="object"||Oe===null||Array.isArray(Oe)||Oe.content!==void 0)){for(let lu of Ep)if(lu in Oe){nf.addIssue({code:"custom",message:`content is required when the body carries '${lu}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(tl).pipe(yr)}}var Zg;function Tp(){return Zg??=Xg()}function $p(e){return e.type!=="object"}var Qg=new Set(["const","enum","default","examples"]),ey=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function sp(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}function ty(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(sp(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let r=Nd(e.$schema)&&e.$recursiveAnchor!==!0,o=(n,a)=>{if(Array.isArray(n))return n.map(c=>o(c,!1));if(n===null||typeof n!="object"||!a&&sp(n.$id))return n;let i={},l=!1;for(let[c,u]of Object.entries(n))a?i[c]=o(u,!1):(c==="$ref"||c==="$dynamicRef")&&typeof u=="string"?i[c]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u:c==="$recursiveRef"&&u==="#"&&r?l=!0:Qg.has(c)?i[c]=u:ey.has(c)?i[c]=o(u,!0):i[c]=o(u,!1);return l&&("$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:o(e,!1)},required:["result"]}}var zp={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},Pp={"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},ry={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},Qa;function rl(){if(Qa)return Qa;let e=Tp();return Qa={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}},Qa}function Cp(e){return Object.prototype.hasOwnProperty.call(zp,e)}function kp(e){return Object.prototype.hasOwnProperty.call(Pp,e)}function oy(e){return Object.prototype.hasOwnProperty.call(ry,e)}function ny(e){return oy(e)?rl().resultSchemas[e]:void 0}function sy(e){return Cp(e)?rl().requestSchemas[e]:void 0}function ay(e){return kp(e)?rl().notificationSchemas[e]:void 0}var Rw=Object.keys(zp),ww=Object.keys(Pp);function Xc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ei(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}var ap={ok:!1,reason:"not-in-era"};function ip(e){return Xc(e)&&Xc(e.outputSchema)&&$p(e.outputSchema)}var ol={era:"2025-11-25",hasRequestMethod:Cp,hasNotificationMethod:kp,validateRequest:(e,t)=>ei(sy(e),t),validateResult:(e,t)=>ei(ny(e),t),validateNotification:(e,t)=>ei(ay(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>ap,validateInputResponse:()=>ap,samplingResultVariant:(e,t)=>{let r=Tp();return ei(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)},outboundEnvelope:e=>{},validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=wp(e),o=r.structuredContent;if(o===void 0)return r;let n=typeof o!="object"||o===null||Array.isArray(o),a=t!==void 0&&$p(t);return!n&&!a?r:{...r,structuredContent:{result:o}}},decodeResult(e,t){if(Xc(t)&&"resultType"in t){let r={...t};return delete r.resultType,{kind:"complete",result:r}}return{kind:"complete",result:t}},encodeResult(e,t){if(e!=="tools/list")return t;let r=t.tools;return!Array.isArray(r)||!r.some(o=>ip(o))?t:{...t,tools:r.map(o=>ip(o)?{...o,outputSchema:ty(o.outputSchema)}:o)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>{}};function iy(){let e=s.lazy(()=>s.union([s.string(),s.number(),s.boolean(),s.null(),s.record(s.string(),e),s.array(e)])),t=s.record(s.string(),e),r=s.union([s.string(),s.number().int()]),o=s.string(),n=s.union([s.string(),s.number().int()]),a=s.enum(["user","assistant"]),i=s.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),l=s.string().refine(Ce=>{try{return atob(Ce),!0}catch{return!1}},{message:"Invalid Base64 string"}),c=s.object({ttl:s.number().optional()}),u=s.object({taskId:s.string()}),m=s.looseObject({progressToken:r.optional(),"io.modelcontextprotocol/related-task":u.optional()}),f=s.object({_meta:m.optional()}),y=f.extend({task:c.optional()}),R=s.object({_meta:m.optional()}),S=s.object({method:s.string(),params:R.loose().optional()}),P=s.object({src:s.string(),mimeType:s.string().optional(),sizes:s.array(s.string()).optional(),theme:s.enum(["light","dark"]).optional()}),b=s.object({icons:s.array(P).optional()}),h=s.object({name:s.string(),title:s.string().optional()}),$=h.extend({...h.shape,...b.shape,version:s.string(),websiteUrl:s.string().optional(),description:s.string().optional()}),v=s.intersection(s.object({applyDefaults:s.boolean().optional()}),t),z=s.preprocess(Ce=>Ce&&typeof Ce=="object"&&!Array.isArray(Ce)&&Object.keys(Ce).length===0?{form:{}}:Ce,s.intersection(s.object({form:v.optional(),url:t.optional()}),t.optional())),I=s.looseObject({list:t.optional(),cancel:t.optional(),requests:s.looseObject({sampling:s.looseObject({createMessage:t.optional()}).optional(),elicitation:s.looseObject({create:t.optional()}).optional()}).optional()}),T=s.looseObject({list:t.optional(),cancel:t.optional(),requests:s.looseObject({tools:s.looseObject({call:t.optional()}).optional()}).optional()}),_=s.object({experimental:s.record(s.string(),t).optional(),sampling:s.object({context:t.optional(),tools:t.optional()}).optional(),elicitation:z.optional(),roots:s.object({listChanged:s.boolean().optional()}).optional(),tasks:I.optional(),extensions:s.record(s.string(),t).optional()}),C=s.object({experimental:s.record(s.string(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:s.object({listChanged:s.boolean().optional()}).optional(),resources:s.object({subscribe:s.boolean().optional(),listChanged:s.boolean().optional()}).optional(),tools:s.object({listChanged:s.boolean().optional()}).optional(),tasks:T.optional(),extensions:s.record(s.string(),t).optional()}),M=s.object({progress:s.number(),total:s.optional(s.number()),message:s.optional(s.string())}),U=s.object({...R.shape,...M.shape,progressToken:r}),q=S.extend({method:s.literal("notifications/progress"),params:U}),D=R.extend({level:i,logger:s.string().optional(),data:s.unknown()}),W=S.extend({method:s.literal("notifications/message"),params:D}),F=s.object({uri:s.string(),mimeType:s.optional(s.string()),_meta:s.record(s.string(),s.unknown()).optional()}),ie=F.extend({text:s.string()}),he=F.extend({blob:l}),ge=s.object({audience:s.array(a).optional(),priority:s.number().min(0).max(1).optional(),lastModified:s.iso.datetime({offset:!0}).optional()}),_e=s.object({...h.shape,...b.shape,uri:s.string(),description:s.optional(s.string()),mimeType:s.optional(s.string()),size:s.optional(s.number()),annotations:ge.optional(),_meta:s.optional(s.looseObject({}))}),ue=s.object({...h.shape,...b.shape,uriTemplate:s.string(),description:s.optional(s.string()),mimeType:s.optional(s.string()),annotations:ge.optional(),_meta:s.optional(s.looseObject({}))}),O=S.extend({method:s.literal("notifications/resources/list_changed"),params:R.optional()}),j=R.extend({uri:s.string()}),E=S.extend({method:s.literal("notifications/resources/updated"),params:j}),p=s.object({name:s.string(),description:s.optional(s.string()),required:s.optional(s.boolean())}),g=s.object({...h.shape,...b.shape,description:s.optional(s.string()),arguments:s.optional(s.array(p)),_meta:s.optional(s.looseObject({}))}),w=S.extend({method:s.literal("notifications/prompts/list_changed"),params:R.optional()}),A=s.object({type:s.literal("text"),text:s.string(),annotations:ge.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),x=s.object({type:s.literal("image"),data:l,mimeType:s.string(),annotations:ge.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),J=s.object({type:s.literal("audio"),data:l,mimeType:s.string(),annotations:ge.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),K=s.object({type:s.literal("tool_use"),name:s.string(),id:s.string(),input:s.record(s.string(),s.unknown()),_meta:s.record(s.string(),s.unknown()).optional()}),ce=s.object({type:s.literal("resource"),resource:s.union([ie,he]),annotations:ge.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),fe=_e.extend({type:s.literal("resource_link")}),k=s.union([A,x,J,fe,ce]),L=s.object({role:a,content:k}),H=s.object({title:s.string().optional(),readOnlyHint:s.boolean().optional(),destructiveHint:s.boolean().optional(),idempotentHint:s.boolean().optional(),openWorldHint:s.boolean().optional()}),Q=S.extend({method:s.literal("notifications/tools/list_changed"),params:R.optional()}),re=s.object({name:s.string().optional()}),oe=s.object({hints:s.array(re).optional(),costPriority:s.number().min(0).max(1).optional(),speedPriority:s.number().min(0).max(1).optional(),intelligencePriority:s.number().min(0).max(1).optional()}),me=s.object({mode:s.enum(["auto","required","none"]).optional()}),Re=s.object({type:s.literal("boolean"),title:s.string().optional(),description:s.string().optional(),default:s.boolean().optional()}),B=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),minLength:s.number().optional(),maxLength:s.number().optional(),format:s.enum(["email","uri","date","date-time"]).optional(),default:s.string().optional()}),be=s.object({type:s.enum(["number","integer"]),title:s.string().optional(),description:s.string().optional(),minimum:s.number().optional(),maximum:s.number().optional(),default:s.number().optional()}),X=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),enum:s.array(s.string()),default:s.string().optional()}),ee=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),oneOf:s.array(s.object({const:s.string(),title:s.string()})),default:s.string().optional()}),ne=s.object({type:s.literal("string"),title:s.string().optional(),description:s.string().optional(),enum:s.array(s.string()),enumNames:s.array(s.string()).optional(),default:s.string().optional()}),Z=s.union([X,ee]),Y=s.object({type:s.literal("array"),title:s.string().optional(),description:s.string().optional(),minItems:s.number().optional(),maxItems:s.number().optional(),items:s.object({type:s.literal("string"),enum:s.array(s.string())}),default:s.array(s.string()).optional()}),se=s.object({type:s.literal("array"),title:s.string().optional(),description:s.string().optional(),minItems:s.number().optional(),maxItems:s.number().optional(),items:s.object({anyOf:s.array(s.object({const:s.string(),title:s.string()}))}),default:s.array(s.string()).optional()}),ae=s.union([Y,se]),Ee=s.union([ne,Z,ae]),pt=s.union([Ee,Re,B,be]),rt=y.extend({mode:s.literal("form").optional(),message:s.string(),requestedSchema:s.object({type:s.literal("object"),properties:s.record(s.string(),pt),required:s.array(s.string()).optional()}).catchall(s.unknown())}),xt=s.object({type:s.literal("ref/resource"),uri:s.string()}),Ht=s.object({type:s.literal("ref/prompt"),name:s.string()}),Qr=s.object({uri:s.string().startsWith("file://"),name:s.string().optional(),_meta:s.record(s.string(),s.unknown()).optional()}),Rt=_.shape,eo=s.object({experimental:Rt.experimental,sampling:Rt.sampling,elicitation:Rt.elicitation,roots:Rt.roots,extensions:Rt.extensions}),Be=C.shape,pr=s.object({experimental:Be.experimental,logging:Be.logging,completions:Be.completions,prompts:Be.prompts,resources:Be.resources,tools:Be.tools,extensions:Be.extensions}),mr=s.looseObject({progressToken:r.optional(),[Fe]:s.string(),[or]:$.optional(),[it]:eo,[Ct]:i.optional()}),Ut=s.object({...h.shape,...b.shape,description:s.string().optional(),inputSchema:s.looseObject({$schema:s.string().optional(),type:s.literal("object")}),outputSchema:s.looseObject({$schema:s.string().optional()}).optional(),annotations:H.optional(),_meta:s.record(s.string(),s.unknown()).optional()}),to=s.object({type:s.literal("tool_result"),toolUseId:s.string(),content:s.array(k),structuredContent:s.unknown().optional(),isError:s.boolean().optional(),_meta:s.record(s.string(),s.unknown()).optional()}),hr=s.union([A,x,J,K,to]),Vt=s.object({role:a,content:s.union([hr,s.array(hr)]),_meta:s.record(s.string(),s.unknown()).optional()}),fr=s.string(),gr=s.looseObject({[at]:$.optional().catch(void 0)}),yr=gr.optional();function Ae(Ce){return s.looseObject({_meta:yr,resultType:fr.default("complete"),...Ce})}let ro=Ae({}),An=Ae({nextCursor:o.optional()}),Sr=Ae({content:s.array(k),structuredContent:s.unknown().optional(),isError:s.boolean().optional()}),oo=Ae({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),tools:s.array(Ut),nextCursor:o.optional()}),no=Ae({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),prompts:s.array(g),nextCursor:o.optional()}),so=Ae({description:s.string().optional(),messages:s.array(L)}),ao=Ae({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),resources:s.array(_e),nextCursor:o.optional()}),io=Ae({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),resourceTemplates:s.array(ue),nextCursor:o.optional()}),co=Ae({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),contents:s.array(s.union([ie,he]))}),lo=Ae({completion:s.object({values:s.array(s.string()).max(100),total:s.number().int().optional(),hasMore:s.boolean().optional()}).loose()}),On=Ae({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"])}),uo=Ae({ttlMs:s.number().int().min(0).catch(0),cacheScope:s.enum(["public","private"]).catch("private"),supportedVersions:s.array(s.string()),capabilities:pr,instructions:s.string().optional()}),wt=s.object({messages:s.array(Vt),modelPreferences:oe.optional(),systemPrompt:s.string().optional(),includeContext:s.enum(["none","thisServer","allServers"]).optional(),temperature:s.number().optional(),maxTokens:s.number().int(),stopSequences:s.array(s.string()).optional(),metadata:t.optional(),tools:s.array(Ut).optional(),toolChoice:me.optional()}),po=s.object({method:s.literal("sampling/createMessage"),params:wt}),mo=s.object({method:s.literal("roots/list"),params:s.object({_meta:s.record(s.string(),s.unknown()).optional()}).optional()}),ho=s.object({...Vt.shape,model:s.string(),stopReason:s.string().optional()}),fo=s.object({roots:s.array(Qr)}),go=s.object({action:s.enum(["accept","decline","cancel"]),content:s.record(s.string(),s.union([s.string(),s.number(),s.boolean(),s.array(s.string())])).optional()}),yo=s.object({mode:s.literal("url"),message:s.string(),url:s.string().url()}),So=s.union([rt,yo]),vo=s.object({method:s.literal("elicitation/create"),params:So}),_o=s.union([po,mo,vo]),bo=s.union([ho,fo,go]),Ro=s.record(s.string(),_o),wo=s.record(s.string(),bo),Bt=Ae({inputRequests:Ro.optional(),requestState:s.string().optional()}),Ft={inputResponses:wo.optional(),requestState:s.string().optional()},Mn=s.object({_meta:mr,...Ft}),Nn=s.looseObject({progressToken:r.optional()});function He(Ce,Jt){return s.object({method:s.literal(Ce),params:s.object({_meta:mr,...Jt})})}function Ue(Ce,Jt){return s.object({method:s.literal(Ce),params:s.object({_meta:Nn.optional(),...Jt}).optional()})}let Eo={name:s.string(),arguments:s.record(s.string(),s.unknown()).optional(),...Ft},We={cursor:o.optional()},qn=He("tools/call",Eo),jn=He("tools/list",We),Ln=He("prompts/list",We),Dn=He("prompts/get",{name:s.string(),arguments:s.record(s.string(),s.string()).optional(),...Ft}),xn=He("resources/list",We),Hn=He("resources/templates/list",We),Un=He("resources/read",{uri:s.string(),...Ft}),To={ref:s.union([Ht,xt]),argument:s.object({name:s.string(),value:s.string()}),context:s.object({arguments:s.record(s.string(),s.string()).optional()}).optional()},Vn=He("completion/complete",To),Bn=He("server/discover",{}),vr=s.object({toolsListChanged:s.boolean().optional(),promptsListChanged:s.boolean().optional(),resourcesListChanged:s.boolean().optional(),resourceSubscriptions:s.array(s.string()).optional()}),$o={notifications:vr},Fn=He("subscriptions/listen",$o),Gn=gr.extend({"io.modelcontextprotocol/subscriptionId":n}),zo=s.looseObject({_meta:Gn,resultType:fr.default("complete")}),Et={"tools/call":Ue("tools/call",Eo),"tools/list":Ue("tools/list",We),"prompts/get":Ue("prompts/get",{name:s.string(),arguments:s.record(s.string(),s.string()).optional()}),"prompts/list":Ue("prompts/list",We),"resources/list":Ue("resources/list",We),"resources/templates/list":Ue("resources/templates/list",We),"resources/read":Ue("resources/read",{uri:s.string()}),"completion/complete":Ue("completion/complete",To),"server/discover":Ue("server/discover",{}),"subscriptions/listen":Ue("subscriptions/listen",$o)};function Le(Ce){return s.looseObject({_meta:yr,...Ce})}let Jn={"tools/call":Le({content:s.array(k),structuredContent:s.unknown().optional(),isError:s.boolean().optional()}),"tools/list":Le({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),tools:s.array(Ut),nextCursor:o.optional()}),"prompts/get":Le({description:s.string().optional(),messages:s.array(L)}),"prompts/list":Le({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),prompts:s.array(g),nextCursor:o.optional()}),"resources/list":Le({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),resources:s.array(_e),nextCursor:o.optional()}),"resources/templates/list":Le({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),resourceTemplates:s.array(ue),nextCursor:o.optional()}),"resources/read":Le({ttlMs:s.number().int().min(0),cacheScope:s.enum(["public","private"]),contents:s.array(s.union([ie,he]))}),"completion/complete":Le({completion:s.object({values:s.array(s.string()).max(100),total:s.number().int().optional(),hasMore:s.boolean().optional()}).loose()}),"server/discover":Le({ttlMs:s.number().int().min(0).catch(0),cacheScope:s.enum(["public","private"]).catch("private"),supportedVersions:s.array(s.string()),capabilities:pr,instructions:s.string().optional()}),"subscriptions/listen":Le({})},Gt=s.looseObject({"io.modelcontextprotocol/subscriptionId":n.optional()}),_r=s.object({method:s.literal("notifications/subscriptions/acknowledged"),params:s.object({_meta:Gt.optional(),notifications:vr})}),br=s.object({_meta:Gt.optional(),requestId:n,reason:s.string().optional()}),Rr=s.object({method:s.literal("notifications/cancelled"),params:br}),Mi={"notifications/cancelled":Rr,"notifications/progress":q,"notifications/message":W,"notifications/resources/updated":E,"notifications/resources/list_changed":O,"notifications/tools/list_changed":Q,"notifications/prompts/list_changed":w,"notifications/subscriptions/acknowledged":_r},je=Ce=>s.object({jsonrpc:s.literal("2.0"),id:s.union([s.string(),s.number().int()]),result:Ce}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,RequestIdSchema:n,RoleSchema:a,LoggingLevelSchema:i,TaskMetadataSchema:c,RelatedTaskMetadataSchema:u,RequestMetaSchema:m,BaseRequestParamsSchema:f,TaskAugmentedRequestParamsSchema:y,NotificationsParamsSchema:R,NotificationSchema:S,IconSchema:P,IconsSchema:b,BaseMetadataSchema:h,ImplementationSchema:$,ClientTasksCapabilitySchema:I,ServerTasksCapabilitySchema:T,ClientCapabilitiesSchema:_,ServerCapabilitiesSchema:C,ProgressSchema:M,ProgressNotificationParamsSchema:U,ProgressNotificationSchema:q,LoggingMessageNotificationParamsSchema:D,LoggingMessageNotificationSchema:W,ResourceContentsSchema:F,TextResourceContentsSchema:ie,BlobResourceContentsSchema:he,AnnotationsSchema:ge,ResourceSchema:_e,ResourceTemplateSchema:ue,ResourceListChangedNotificationSchema:O,ResourceUpdatedNotificationParamsSchema:j,ResourceUpdatedNotificationSchema:E,PromptArgumentSchema:p,PromptSchema:g,PromptListChangedNotificationSchema:w,TextContentSchema:A,ImageContentSchema:x,AudioContentSchema:J,ToolUseContentSchema:K,EmbeddedResourceSchema:ce,ResourceLinkSchema:fe,ContentBlockSchema:k,PromptMessageSchema:L,ToolAnnotationsSchema:H,ToolListChangedNotificationSchema:Q,ModelHintSchema:re,ModelPreferencesSchema:oe,ToolChoiceSchema:me,BooleanSchemaSchema:Re,StringSchemaSchema:B,NumberSchemaSchema:be,UntitledSingleSelectEnumSchemaSchema:X,TitledSingleSelectEnumSchemaSchema:ee,LegacyTitledEnumSchemaSchema:ne,SingleSelectEnumSchemaSchema:Z,UntitledMultiSelectEnumSchemaSchema:Y,TitledMultiSelectEnumSchemaSchema:se,MultiSelectEnumSchemaSchema:ae,EnumSchemaSchema:Ee,PrimitiveSchemaDefinitionSchema:pt,ElicitRequestFormParamsSchema:rt,ResourceTemplateReferenceSchema:xt,PromptReferenceSchema:Ht,RootSchema:Qr,ClientCapabilities2026Schema:eo,ServerCapabilities2026Schema:pr,RequestMetaEnvelopeSchema:mr,ToolSchema:Ut,ToolResultContentSchema:to,SamplingMessageContentBlockSchema:hr,SamplingMessageSchema:Vt,ResultTypeSchema:fr,ResultMetaSchema:gr,ResultSchema:ro,PaginatedResultSchema:An,CallToolResultSchema:Sr,ListToolsResultSchema:oo,ListPromptsResultSchema:no,GetPromptResultSchema:so,ListResourcesResultSchema:ao,ListResourceTemplatesResultSchema:io,ReadResourceResultSchema:co,CompleteResultSchema:lo,CacheableResultSchema:On,DiscoverResultSchema:uo,CreateMessageRequestParamsSchema:wt,CreateMessageRequestSchema:po,ListRootsRequestSchema:mo,CreateMessageResultSchema:ho,ListRootsResultSchema:fo,ElicitResultSchema:go,ElicitRequestURLParamsSchema:yo,ElicitRequestParamsSchema:So,ElicitRequestSchema:vo,InputRequestSchema:_o,InputResponseSchema:bo,InputRequestsSchema:Ro,InputResponsesSchema:wo,InputRequiredResultSchema:Bt,InputResponseRequestParamsSchema:Mn,CallToolRequestSchema:qn,ListToolsRequestSchema:jn,ListPromptsRequestSchema:Ln,GetPromptRequestSchema:Dn,ListResourcesRequestSchema:xn,ListResourceTemplatesRequestSchema:Hn,ReadResourceRequestSchema:Un,CompleteRequestSchema:Vn,DiscoverRequestSchema:Bn,SubscriptionFilterSchema:vr,SubscriptionsListenRequestSchema:Fn,SubscriptionsListenResultMetaSchema:Gn,SubscriptionsListenResultSchema:zo,dispatchRequestSchemas:Et,dispatchResultSchemas:Jn,NotificationMetaSchema:Gt,SubscriptionsAcknowledgedNotificationSchema:_r,CancelledNotificationParamsSchema:br,CancelledNotificationSchema:Rr,notificationSchemas2026:Mi,JSONRPCResultResponseSchema:je(ro),CallToolResultResponseSchema:je(s.union([Sr,Bt])),ListToolsResultResponseSchema:je(oo),ListPromptsResultResponseSchema:je(no),GetPromptResultResponseSchema:je(s.union([so,Bt])),ListResourcesResultResponseSchema:je(ao),ListResourceTemplatesResultResponseSchema:je(io),ReadResourceResultResponseSchema:je(s.union([co,Bt])),CompleteResultResponseSchema:je(lo),DiscoverResultResponseSchema:je(uo),SubscriptionsListenResultResponseSchema:je(zo)}}var cy;function jt(){return cy??=iy()}var ly=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function uy(e){return ly.includes(e)}var Hr=Symbol("modelcontextprotocol.resultCacheHintFallback");function ai(e,t){if(t===void 0)return e;let r=e[Hr];if(r===void 0)return{...e,[Hr]:t};let o={},n=r.ttlMs??t.ttlMs;n!==void 0&&(o.ttlMs=n);let a=r.cacheScope??t.cacheScope;return a!==void 0&&(o.cacheScope=a),{...e,[Hr]:o}}function dy(e){return e[Hr]}function nl(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function sl(e){return e==="public"||e==="private"}function al(e,t){if(e.ttlMs!==void 0&&!nl(e.ttlMs))throw new RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!sl(e.cacheScope))throw new RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}var G=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}({}),te=class Ip extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return Vr(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Vr(this,t)}constructor(t,r,o){super(r),this.code=t,this.data=o,this.name="ProtocolError",el(this,new.target)}static fromError(t,r,o){if(t===G.UrlElicitationRequired&&o){let n=o;if(n.elicitations)return new Ap(n.elicitations,r)}if(t===G.UnsupportedProtocolVersion&&o){let n=o;if(Array.isArray(n.supported)&&typeof n.requested=="string")return new ci({supported:n.supported,requested:n.requested},r)}if(t===G.InvalidParams||t===G.ResourceNotFound){let n=o;if(typeof n?.uri=="string"&&(t===G.ResourceNotFound||Object.keys(n).length===1))return new ii(n.uri,r)}if(t===G.MissingRequiredClientCapability&&o){let n=o;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities=="object"&&!Array.isArray(n.requiredCapabilities))return new bn({requiredCapabilities:n.requiredCapabilities},r)}return new Ip(t,r,o)}},ii=class extends te{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(G.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Ap=class extends te{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(G.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},ci=class extends te{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(G.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},bn=class extends te{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(G.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},py=0,my="private",hy=["tools/call","prompts/get","resources/read"];function fy(e,t){let r=t.resultType;if(r===void 0)return{...t,resultType:"complete"};if(r==="complete"||hy.includes(e))return t;throw new te(G.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function gy(e,t){let r=dy(t);if(t.resultType!=="complete"||!uy(e))return r===void 0?t:by(t);let o=t,n=nl(o.ttlMs)?o.ttlMs:vy(r),a=sl(o.cacheScope)?o.cacheScope:_y(r),i={...o,ttlMs:n,cacheScope:a};return delete i[Hr],i}function yy(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Sy(e,t){if(t===void 0)return e;let r=e._meta;return r===void 0?{...e,_meta:{[at]:t}}:!yy(r)||r[at]!==void 0?e:{...e,_meta:{...r,[at]:t}}}function vy(e){return e!==void 0&&nl(e.ttlMs)?e.ttlMs:py}function _y(e){return e!==void 0&&sl(e.cacheScope)?e.cacheScope:my}function by(e){let t={...e};return delete t[Hr],t}var Ry=["elicitation/create","sampling/createMessage","roots/list"],ti;function Op(){if(ti)return ti;let e=jt();return ti={request:{"elicitation/create":s.object({method:s.literal("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":s.object({method:s.literal("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":s.object({method:s.literal("roots/list"),params:s.looseObject({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},ti}function Mp(e){return Ry.includes(e)}function Gc(e){return Mp(e)?Op().request[e]:void 0}function wy(e){return Mp(e)?Op().response[e]:void 0}var il={"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},Np={"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 qp(e){return Object.prototype.hasOwnProperty.call(il,e)}function jp(e){return Object.prototype.hasOwnProperty.call(Np,e)}function Ey(e){return Object.prototype.hasOwnProperty.call(il,e)}function Ty(e){return qp(e)?jt().dispatchRequestSchemas[e]:void 0}function $y(e){return Ey(e)?jt().dispatchResultSchemas[e]:void 0}function zy(e){return jp(e)?jt().notificationSchemas2026[e]:void 0}var Ew=Object.keys(il),Tw=Object.keys(Np);function fn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mn(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}var Py={ok:!1,reason:"not-in-era"},Cy=[Fe,it];function ky(e,t){let r=t,o=!1,n=()=>(o||(r={...r},o=!0),r),a=t.tools;e==="tools/list"&&Array.isArray(a)&&a.some(l=>fn(l)&&"execution"in l)&&(n().tools=a.map(l=>{if(!fn(l)||!("execution"in l))return l;let c={...l};return delete c.execution,c}));let i=t.capabilities;if(fn(i)&&"tasks"in i){let l={...i};delete l.tasks,n().capabilities=l}return r}var cl={era:"2026-07-28",hasRequestMethod:qp,hasNotificationMethod:jp,hasInputRequestMethod:e=>Gc(e)!==void 0,validateRequest:(e,t)=>mn(Ty(e),t),validateResult:(e,t)=>mn($y(e),t),validateNotification:(e,t)=>mn(zy(e),t),validateInputRequest:(e,t)=>mn(Gc(e),t),validateInputResponse:(e,t)=>mn(wy(e),t),samplingResultVariant:()=>Py,outboundEnvelope(e){return{[Fe]:e.protocolVersion,[or]:e.clientInfo,[it]:e.clientCapabilities,...e.logLevel!==void 0&&{[Ct]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let o of Cy)o in e||t.push({key:o,problem:"missing"});let r=jt().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let o of r.error.issues){let n=o.path.map(String),a=n.length>0?n.join("."):"_meta";n.length===1&&t.some(i=>i.key===a&&i.problem==="missing")||t.push({key:a,problem:o.message})}return t},projectCallToolResult:e=>wp(e),inputRequestSchema:Gc,decodeResult(e,t){if(!fn(t))return{kind:"invalid",error:new le(pe.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(r===void 0)return{kind:"invalid",error:new le(pe.InvalidResult,`Invalid result for ${e}: missing required resultType \u2014 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 r!="string")return{kind:"invalid",error:new le(pe.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if(r==="input_required"){let i=t.inputRequests,l=fn(i)?i:{},c=t.requestState,u=t._meta===void 0?void 0:jt().ResultMetaSchema.safeParse(t._meta),m=u?.success?u.data:void 0;return Object.keys(l).length===0&&typeof c!="string"?{kind:"invalid",error:new le(pe.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:l,...typeof c=="string"&&{requestState:c},...m!==void 0&&{_meta:m}}}if(r!=="complete")return{kind:"invalid",error:new le(pe.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let o=Iy(),n=Object.hasOwn(o,e)?o[e]:void 0;if(n!==void 0){let i=n.safeParse(t);if(!i.success)return{kind:"invalid",error:new le(pe.InvalidResult,`Invalid result for ${e}: ${i.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:"complete",result:a}},encodeResult(e,t,r){return Sy(gy(e,fy(e,ky(e,t))),r)},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=jt().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(r=>r.message).join("; ")}`}},ri;function Iy(){if(ri)return ri;let e=jt();return ri={"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},ri}var Rn="2026-07-28";function ft(e){return e!==void 0&>(e)?cl:ol}function cp(e){return e.revision!==void 0?ft(e.revision).era:e.era==="modern"?cl.era:ol.era}function Jc(e){return Lp.some(t=>t.hasRequestMethod(e))}function Kc(e){return Lp.some(t=>t.hasNotificationMethod(e))}function lp(e){return e==="tasks/get"||e==="tasks/cancel"}var Lp=[ol,cl];function up(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Lt(e){if(!up(e))return;let t=e._meta;return up(t)?t:void 0}function li(e){let t=Lt(e);return t!==void 0&&Fe in t}function ll(e){let t=Lt(e)?.[Fe];return typeof t=="string"?t:void 0}function ni(e){return ft(Rn).validateEnvelopeMeta(e)}var Ay=Kd({AnnotationsSchema:()=>ht,AudioContentSchema:()=>Nr,BaseMetadataSchema:()=>mt,BaseRequestParamsSchema:()=>ke,BlobResourceContentsSchema:()=>en,BooleanSchemaSchema:()=>sn,CallToolRequestParamsSchema:()=>pa,CallToolRequestSchema:()=>ma,CallToolResultSchema:()=>nn,CancelTaskRequestSchema:()=>Cc,CancelTaskResultSchema:()=>kc,CancelledNotificationParamsSchema:()=>gs,CancelledNotificationSchema:()=>Jo,ClientCapabilitiesSchema:()=>_s,ClientNotificationSchema:()=>Ac,ClientRequestSchema:()=>Ic,ClientResultSchema:()=>Oc,ClientTasksCapabilitySchema:()=>Ss,CompatibilityCallToolResultSchema:()=>Sc,CompleteRequestParamsSchema:()=>xa,CompleteRequestSchema:()=>Ha,CompleteResultSchema:()=>Ua,ContentBlockSchema:()=>qr,CreateMessageRequestParamsSchema:()=>Ta,CreateMessageRequestSchema:()=>$a,CreateMessageResultSchema:()=>za,CreateMessageResultWithToolsSchema:()=>Pa,CreateTaskResultSchema:()=>bc,CursorSchema:()=>Ho,DiscoverRequestSchema:()=>Es,DiscoverResultSchema:()=>Ts,ElicitRequestFormParamsSchema:()=>Dr,ElicitRequestParamsSchema:()=>Oa,ElicitRequestSchema:()=>Ma,ElicitRequestURLParamsSchema:()=>Aa,ElicitResultSchema:()=>ja,ElicitationCompleteNotificationParamsSchema:()=>Na,ElicitationCompleteNotificationSchema:()=>qa,EmbeddedResourceSchema:()=>oa,EmptyResultSchema:()=>Go,EnumSchemaSchema:()=>Ia,GetPromptRequestParamsSchema:()=>ea,GetPromptRequestSchema:()=>ta,GetPromptResultSchema:()=>aa,GetTaskPayloadRequestSchema:()=>Tc,GetTaskPayloadResultSchema:()=>$c,GetTaskRequestSchema:()=>wc,GetTaskResultSchema:()=>Ec,IconSchema:()=>ys,IconsSchema:()=>It,ImageContentSchema:()=>Mr,ImplementationSchema:()=>Ir,InitializeRequestParamsSchema:()=>bs,InitializeRequestSchema:()=>Ko,InitializeResultSchema:()=>Rs,InitializedNotificationSchema:()=>ws,JSONArraySchema:()=>fc,JSONObjectSchema:()=>$e,JSONRPCErrorResponseSchema:()=>Cr,JSONRPCMessageSchema:()=>kr,JSONRPCNotificationSchema:()=>Fo,JSONRPCRequestSchema:()=>Bo,JSONRPCResponseSchema:()=>gc,JSONRPCResultResponseSchema:()=>Pr,JSONValueSchema:()=>Pt,LegacyTitledEnumSchemaSchema:()=>ln,ListChangedOptionsBaseSchema:()=>vc,ListPromptsRequestSchema:()=>Zs,ListPromptsResultSchema:()=>Qs,ListResourceTemplatesRequestSchema:()=>As,ListResourceTemplatesResultSchema:()=>Os,ListResourcesRequestSchema:()=>ks,ListResourcesResultSchema:()=>Is,ListRootsRequestSchema:()=>Ba,ListRootsResultSchema:()=>Fa,ListTasksRequestSchema:()=>zc,ListTasksResultSchema:()=>Pc,ListToolsRequestSchema:()=>ua,ListToolsResultSchema:()=>da,LoggingLevelSchema:()=>Nt,LoggingMessageNotificationParamsSchema:()=>ya,LoggingMessageNotificationSchema:()=>Sa,ModelHintSchema:()=>va,ModelPreferencesSchema:()=>_a,MultiSelectEnumSchemaSchema:()=>ka,NotificationSchema:()=>qe,NotificationsParamsSchema:()=>Ne,NumberSchemaSchema:()=>Lr,PaginatedRequestParamsSchema:()=>Ps,PaginatedRequestSchema:()=>At,PaginatedResultSchema:()=>Ot,PingRequestSchema:()=>Yo,PrimitiveSchemaDefinitionSchema:()=>pn,ProgressNotificationParamsSchema:()=>zs,ProgressNotificationSchema:()=>Xo,ProgressSchema:()=>$s,ProgressTokenSchema:()=>xo,PromptArgumentSchema:()=>Ys,PromptListChangedNotificationSchema:()=>ia,PromptMessageSchema:()=>sa,PromptReferenceSchema:()=>Da,PromptSchema:()=>Xs,ReadResourceRequestParamsSchema:()=>Ms,ReadResourceRequestSchema:()=>Ns,ReadResourceResultSchema:()=>qs,RelatedTaskMetadataSchema:()=>fs,RequestIdSchema:()=>kt,RequestMetaSchema:()=>Uo,RequestSchema:()=>ze,ResourceContentsSchema:()=>Zo,ResourceLinkSchema:()=>na,ResourceListChangedNotificationSchema:()=>js,ResourceRequestParamsSchema:()=>Ar,ResourceSchema:()=>tn,ResourceTemplateReferenceSchema:()=>La,ResourceTemplateSchema:()=>Cs,ResourceUpdatedNotificationParamsSchema:()=>Ks,ResourceUpdatedNotificationSchema:()=>Ws,ResultMetaObjectSchema:()=>Vo,ResultSchema:()=>Pe,RoleSchema:()=>Mt,RootSchema:()=>Va,RootsListChangedNotificationSchema:()=>Ga,SamplingContentSchema:()=>wa,SamplingMessageContentBlockSchema:()=>tr,SamplingMessageSchema:()=>Ea,ServerCapabilitiesSchema:()=>Wo,ServerNotificationSchema:()=>Nc,ServerRequestSchema:()=>Mc,ServerResultSchema:()=>qc,ServerTasksCapabilitySchema:()=>vs,SetLevelRequestParamsSchema:()=>fa,SetLevelRequestSchema:()=>ga,SingleSelectEnumSchemaSchema:()=>Ca,StringSchemaSchema:()=>jr,SubscribeRequestParamsSchema:()=>Ls,SubscribeRequestSchema:()=>Ds,SubscriptionFilterSchema:()=>rn,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Bs,SubscriptionsAcknowledgedNotificationSchema:()=>Fs,SubscriptionsListenRequestParamsSchema:()=>Us,SubscriptionsListenRequestSchema:()=>Vs,SubscriptionsListenResultMetaSchema:()=>Gs,SubscriptionsListenResultSchema:()=>Js,TaskAugmentedRequestParamsSchema:()=>ar,TaskCreationParamsSchema:()=>_c,TaskMetadataSchema:()=>hs,TaskSchema:()=>qt,TaskStatusNotificationParamsSchema:()=>Ka,TaskStatusNotificationSchema:()=>Rc,TaskStatusSchema:()=>Ja,TextContentSchema:()=>Or,TextResourceContentsSchema:()=>Qo,TitledMultiSelectEnumSchemaSchema:()=>dn,TitledSingleSelectEnumSchemaSchema:()=>cn,ToolAnnotationsSchema:()=>ca,ToolChoiceSchema:()=>ba,ToolExecutionSchema:()=>la,ToolListChangedNotificationSchema:()=>ha,ToolResultContentSchema:()=>Ra,ToolSchema:()=>on,ToolUseContentSchema:()=>ra,UnsubscribeRequestParamsSchema:()=>xs,UnsubscribeRequestSchema:()=>Hs,UntitledMultiSelectEnumSchemaSchema:()=>un,UntitledSingleSelectEnumSchemaSchema:()=>an});var Ze=e=>Bo.safeParse(e).success,ui=e=>Fo.safeParse(e).success,ct=e=>Pr.safeParse(e).success,lt=e=>Cr.safeParse(e).success;var yt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var ul=e=>Ko.safeParse(e).success;function dl(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function pl(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var Oy="Mcp-Param-",dp="x-mcp-header",My=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Ny=new Set(["string","integer","boolean"]);function di(e){let t=[],r=new Map,o,n=(i,l,c)=>{if(i===null||typeof i!="object")return;let u=i;if(dp in u){if(!c||l.length===0)return`${xr(l)}: 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 f=u[dp];if(typeof f!="string"||f.length===0)return`${xr(l)}: x-mcp-header MUST be a non-empty string`;if(!My.test(f))return`${xr(l)}: x-mcp-header '${f}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let y=typeof u.type=="string"?u.type:void 0;if(y===void 0||!Ny.has(y)){let P=`${xr(l)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${y??"<none>"}`;if(y!=="number")return P;o??=P}let R=f.toLowerCase(),S=r.get(R);if(S!==void 0)return`x-mcp-header '${f}' is not case-insensitively unique (also declared as '${S}')`;r.set(R,f),t.push({path:l,headerName:f,type:y})}let m=u.properties;if(m!==null&&typeof m=="object")for(let[f,y]of Object.entries(m)){let R=n(y,[...l,f],c);if(R!==void 0)return R}for(let f of qy){let y=u[f];if(y===void 0)continue;let R=Array.isArray(y)?y:y!==null&&typeof y=="object"&&jy.has(f)?Object.values(y):[y];for(let S of R){let P=n(S,[...l,`<${f}>`],!1);if(P!==void 0)return P}}},a=n(e,[],!0);return a!==void 0?{valid:!1,reason:o??a}:o===void 0?{valid:!0,declarations:t}:{valid:!1,reason:o,declarations:t}}var qy=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],jy=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function xr(e){return e.length===0?"<root>":e.join(".")}var Ly="=?base64?",Dy="?=",xy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Hy=/^-?\d+(\.\d+)?$/;function Uy(e){if(typeof e=="string")return e;if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function Vy(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.codePointAt(o);return new TextDecoder("utf-8",{fatal:!0}).decode(r)}function Dp(e){if(!(e.startsWith(Ly)&&e.endsWith(Dy)))return e;let t=e.slice(9,e.length-2);if(xy.test(t))try{return Vy(t)}catch{return}}function By(e,t){let r=e;for(let o of t){if(r===null||typeof r!="object")return;r=r[o]}return r}function xp(e,t,r){for(let o of e){let n=`${Oy}${o.headerName}`,a=r.get(n),i=By(t,o.path);if(i==null)continue;let l=Uy(i);if(l===void 0)continue;if(a===null)return Wc("param-header-missing",n,`the body carries ${xr(o.path)}=${JSON.stringify(i)} but the ${n} header is absent`);let c=Dp(a);if(c===void 0)return Wc("param-header-invalid-encoding",n,`the ${n} header carries an invalid Base64 sentinel value`);if(!((o.type==="integer"||o.type==="number")&&Hy.test(c)&&typeof i=="number"?Number(c)===i:c===l))return Wc("param-header-mismatch",n,`the ${n} header decodes to ${JSON.stringify(c)} but the body carries ${xr(o.path)}=${JSON.stringify(i)}`)}}function Wc(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:Ur,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}var Ur=-32020,$w=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32e3],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[G.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[Ur,G.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[G.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope \u2014 and a missing envelope on a request whose protocol-version header names a modern revision \u2014 is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[G.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision\u2019s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[G.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[Ur],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[G.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced \u2014 pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[Ur],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool\u2019s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],ml={[G.ParseError]:400,[G.InvalidRequest]:400,[G.MethodNotFound]:404,[G.UnsupportedProtocolVersion]:400,[G.MissingRequiredClientCapability]:400,[Ur]:400};function Hp(e,t){return t==="in-band"?e===G.MissingRequiredClientCapability?400:200:ml[e]??400}function Ge(e,t,r,o,n){return{kind:"reject",rung:e,cell:t,httpStatus:r,code:o.code,message:o.message,...o.data!==void 0&&{data:o.data},settled:n}}function Xe(e,t,r,o="era-classification"){return Ge(o,e,400,new te(Ur,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}var pp={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function Fy(e,t){let r=Object.hasOwn(pp,e)?pp[e]:void 0;if(r===void 0)return;let o=yn(t)?t[r]:void 0;return{field:r,value:typeof o=="string"?o:void 0}}function oi(e){let t=0;for(;t<e.length;){let o=e.codePointAt(t);if(o!==9&&o!==32)break;t+=1}let r=e.length;for(;r>t;){let o=e.codePointAt(r-1);if(o!==9&&o!==32)break;r-=1}return t===0&&r===e.length?e:e.slice(t,r)}function Up(e,t){if(t.messageKind!=="request")return;let r=t.message.method;if(e.protocolVersionHeader===void 0){let c=t.classification.revision;return Xe("version-header-missing","(missing)",c===void 0?"the body carries a modern per-request envelope but the required MCP-Protocol-Version header is absent":`the body envelope names protocol version ${c} but the required MCP-Protocol-Version header is absent`,"standard-header-validation")}if(e.mcpMethodHeader===void 0)return Xe("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let o=Fy(r,t.message.params);if(o===void 0)return;let{field:n,value:a}=o;if(e.mcpNameHeader===void 0)return a===void 0?void 0:Xe("name-header-missing","(missing)",`the body carries params.${n}="${a}" but the required Mcp-Name header is absent`,"standard-header-validation");let i=oi(e.mcpNameHeader),l=Dp(i);if(l===void 0)return Xe("name-header-invalid-encoding",i,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation");if(a!==void 0&&l!==a)return Xe("name-header-mismatch",i,`the body carries params.${n}="${a}" but the Mcp-Name header names "${l}"`,"standard-header-validation")}function yn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Vp(e){return e===void 0?{era:"modern"}:{era:gt(e)?"modern":"legacy",revision:e}}function Gy(e){if(!li(e))return!1;let t=ll(e);if(t===void 0||!gt(t))return!1;let r=Lt(e);return r!==void 0&&ni(r).length===0}function Jy(e){if(e.length===0)return Ge("jsonrpc-shape","empty-batch",400,new te(G.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let t of e){if(li(yn(t)?t.params:void 0))return Ge("jsonrpc-shape","batch-with-modern-element",400,new te(G.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(Ze(t)||ui(t)||ct(t)||lt(t)))return Ge("jsonrpc-shape","batch-with-invalid-element",400,new te(G.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}function Ky(e,t){let r=t.params,o=t.method,n=e.protocolVersionHeader,a=n!==void 0&>(n);if(o==="initialize"&&!Gy(r)){if(a)return Xe("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let i=yn(r)&&typeof r.protocolVersion=="string"?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...i!==void 0&&{requestedVersion:i}}}if(li(r)){let i=Lt(r),l=(i===void 0?[]:ni(i))[0];if(l!==void 0)return Ge("envelope","envelope-invalid",400,new te(G.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${l.key}: ${l.problem}`,{envelope:l}),!0);let c=ll(r);return n!==void 0&&c!==void 0&&n!==c?Xe("header-body-version-mismatch",n,`the body envelope names protocol version ${c} but the MCP-Protocol-Version header names ${n}`):e.mcpMethodHeader!==void 0&&e.mcpMethodHeader!==o?Xe("method-header-mismatch",e.mcpMethodHeader,`the body names method ${o} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"request",message:t,classification:Vp(c)}}if(a){let i=Lt(r),l=ni(i??{}).filter(u=>u.problem==="missing").map(u=>u.key),c=i===void 0?["_meta"]:l.length>0?l:[Fe];return Ge("envelope","modern-header-without-claim",400,new te(G.InvalidParams,`Invalid params: the MCP-Protocol-Version header names protocol revision ${n}, but the request is missing the required per-request envelope key(s): ${c.join(", ")}`,{envelope:{missing:c}}),!0)}return{kind:"legacy",reason:"no-claim",...n!==void 0&&{requestedVersion:n}}}function Wy(e,t){let r=t.params,o=t.method,n=e.protocolVersionHeader,a=n!==void 0&>(n);if(li(r)){let i=ll(r);if(i===void 0){let c=Lt(r),u=(c===void 0?[]:ni(c)).find(m=>m.key===Fe)??{key:Fe,problem:"expected a protocol version string"};return Ge("envelope","notification-envelope-invalid",400,new te(G.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${u.key}: ${u.problem}`,{envelope:u}),!0)}if(n!==void 0&&n!==i)return Xe("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${i} but the MCP-Protocol-Version header names ${n}`);let l=Vp(i);return l.era==="modern"&&e.mcpMethodHeader!==void 0&&e.mcpMethodHeader!==o?Xe("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${o} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:l}}return a?e.mcpMethodHeader!==void 0&&e.mcpMethodHeader!==o?Xe("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${o} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:{era:"modern",revision:n}}:{kind:"legacy",reason:"notification",...n!==void 0&&{requestedVersion:n}}}function pi(e){if(e={...e,...e.protocolVersionHeader!==void 0&&{protocolVersionHeader:oi(e.protocolVersionHeader)},...e.mcpMethodHeader!==void 0&&{mcpMethodHeader:oi(e.mcpMethodHeader)},...e.mcpNameHeader!==void 0&&{mcpNameHeader:oi(e.mcpNameHeader)}},e.httpMethod.toUpperCase()!=="POST")return{kind:"legacy",reason:"http-method"};let t=e.body;return Array.isArray(t)?Jy(t):ct(t)||lt(t)?{kind:"legacy",reason:"response"}:yn(t)&&Ze(t)?Ky(e,t):yn(t)&&ui(t)?Wy(e,t):Ge("jsonrpc-shape","invalid-json-rpc-body",400,new te(G.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}function Bp(e,t){switch(e.reason){case"http-method":return Ge("http-method","modern-only-method-not-allowed",405,new te(-32e3,"Method not allowed."),!0);case"batch":return Ge("jsonrpc-shape","modern-only-batch-not-supported",400,new te(G.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return Ge("jsonrpc-shape","modern-only-response-post",400,new te(G.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return Ge("era-classification","modern-only-missing-envelope",400,r===void 0?new te(G.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new ci({supported:[...t],requested:r}),!0)}}}function mi(e,t){return s.safeParse(e,t)}function hn(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}function Br(e){if(e==null)return!1;let t=typeof e;return t!=="object"&&t!=="function"||!("~standard"in e)?!1:typeof e["~standard"]?.validate=="function"}var mp=!1,Zc="draft-2020-12";function ur(e,t="input"){let r=e["~standard"],o;if(r.jsonSchema)o=r.jsonSchema[t]({target:Zc});else if(r.vendor==="zod"){if(!("_zod"in e))throw new 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().");mp||(mp=!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.")),o=s.toJSONSchema(e,{target:Zc,io:t})}else throw new Error(`Schema library "${r.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output")return o.type!==void 0?o:Fp(o)?{type:"object",...o}:o;if(o.type!==void 0&&o.type!=="object")throw new Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(o.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...o}}var Yy=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function Fp(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let r=typeof e.$ref=="string"&&Yy.exec(e.$ref);if(r&&t[r[1]]?.[r[2]]?.type==="object")return!0;for(let o of["oneOf","anyOf","allOf"]){let n=e[o];if(Array.isArray(n)&&n.length>0)return n.every(a=>a!==null&&typeof a=="object"&&(a.type==="object"||Fp(a,"$id"in a?{}:t)))}return!1}function Xy(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}async function ir(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(o=>Xy(o)).join(", ")}:{success:!0,data:r.value}}function Zy(e){let t=s.toJSONSchema(e,{target:Zc,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}var Qy=/\\\.\\d\{(\d+)\}/;function eS(e){let t=Qy.exec(e),r=[void 0,-1,0];return t&&r.push(Number(t[1])),[!1,!0].flatMap(o=>[!1,!0].flatMap(n=>r.map(a=>s.iso.datetime({local:o,offset:n,precision:a}))))}function tS(e,t){let r;switch(e){case"email":r=[s.email()];break;case"uri":r=[s.url()];break;case"date":r=[s.iso.date()];break;case"date-time":r=eS(t);break}return new Set(r.map(o=>Zy(o)).filter(o=>o!==void 0))}function rS(e,t,r){return r!=="zod"?!0:tS(e,t).has(t)}function Gp(e){let t=ur(e,"input"),r=t.properties||{},o=t.required||[];return Object.entries(r).map(([n,a])=>({name:n,description:a?.description,required:o.includes(n)}))}function Sn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oS(e){try{return ur(e,"input")}catch(t){let r=t instanceof Error?t.message:String(t);throw new te(G.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${r}`)}}var nS=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function hl(e){return nS.has(e)||e.startsWith("x-")}var sS=new Set(["$schema",...Object.keys(Dr.shape.requestedSchema.shape)]),hp={string:hn([jr,an,cn,ln]),number:hn([Lr]),integer:hn([Lr]),boolean:hn([sn]),array:hn([un,dn])},aS=new Set(jr.shape.format.unwrap().options);function iS(e,t,r,o){if(!Sn(e))return e;let n=typeof e.type=="string"&&Object.hasOwn(hp,e.type)?hp[e.type]:void 0;if(n===void 0)return e;let a={};for(let[i,l]of Object.entries(e))n.has(i)||hl(i)?a[i]=l:i==="pattern"&&e.type==="string"&&typeof e.format=="string"?aS.has(e.format)?(typeof l!="string"||!rS(e.format,l,r))&&o.push(`${t}.${i}`):a[i]=l:o.push(`${t}.${i}`);return a}function cS(e,t){let r={},o=[];for(let[n,a]of Object.entries(e))n==="properties"&&Sn(a)?r[n]=Object.fromEntries(Object.entries(a).map(([i,l])=>[i,iS(l,`properties.${i}`,t,o)])):sS.has(n)?r[n]=a:hl(n)||o.push(n);if(o.length>0)throw new te(G.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);return r}function lS(e,t){if(!Sn(e.properties))return t;let r=Object.entries(e.properties).filter(([,o])=>!mi(pn,o).success).map(([o])=>`properties.${o}`);return r.length>0?r.join(", "):t}function Qc(e,t,r=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((o,n)=>Qc(o,t[n],`${r}[${n}]`)):!Sn(e)||!Sn(t)?[]:Object.entries(e).flatMap(([o,n])=>{let a=r?`${r}.${o}`:o;return Object.prototype.hasOwnProperty.call(t,o)?Qc(n,t[o],a):hl(o)?[]:[a]})}function uS(e){if(!Br(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,r=cS(oS(e.requestedSchema),t),o=mi(Dr.shape.requestedSchema,r);if(!o.success)throw new te(G.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${lS(r,o.error.message)}`);let n=Qc(r,o.data);if(n.length>0)throw new te(G.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);let a=(o.data.required??[]).filter(i=>!Object.prototype.hasOwnProperty.call(o.data.properties,i));if(a.length>0)throw new te(G.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(", ")}`);return{...e,mode:"form",requestedSchema:o.data}}function dS(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,r=typeof e.requestState=="string";if(!t&&!r)throw new 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}}}var pS=Object.assign(dS,{elicit(e){try{return{method:"elicitation/create",params:uS(e)}}catch(t){throw t instanceof te?new TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var Jp=250;function Kp(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Wp(e,t){return new Promise((r,o)=>{if(t?.aborted){o(t.reason instanceof le?t.reason:new le(pe.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",a),r()},e),a=()=>{clearTimeout(n),o(t?.reason instanceof le?t.reason:new le(pe.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",a,{once:!0})})}function Yp(e){let t=new AbortController,r=()=>t.abort(e?.reason);return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:o=>t.abort(o),dispose:()=>e?.removeEventListener("abort",r)}}var mS=["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"],hS={IdJagTokenExchangeResponseSchema:Hc,OAuthClientInformationFullSchema:Vc,OAuthClientInformationSchema:Za,OAuthClientMetadataSchema:Xa,OAuthClientRegistrationErrorSchema:Bc,OAuthErrorResponseSchema:Uc,OAuthMetadataSchema:Wa,OAuthProtectedResourceMetadataSchema:Lc,OAuthTokenRevocationRequestSchema:Fc,OAuthTokensSchema:xc,OpenIdProviderDiscoveryMetadataSchema:Dc,OpenIdProviderMetadataSchema:Ya},Xp={},Zp={};function Qp(e,t){let r=e.slice(0,-6);Xp[r]=t,Zp[r]=o=>t.safeParse(o).success}for(let e of mS)Qp(e,Ay[e]);for(let[e,t]of Object.entries(hS))Qp(e,t);var fS=Object.freeze(Xp),gS=Object.freeze(Zp);function yS(e){switch(e){case"initialize":case"notifications/initialized":return ft(void 0);case"server/discover":return ft(Rn);default:return}}var em=6e4,SS=[Fe,or,it,Ct],vS=["inputResponses","requestState"];function fp(e,t){let r=e.params;if(!gn(r))return{message:e,lifted:{}};let o=r._meta,n=gn(o)?SS.filter(c=>c in o):[],a=t==="request"?vS.filter(c=>c in r):[];if(n.length===0&&a.length===0)return{message:e,lifted:{}};let i={},l={...r};if(n.length>0&&gn(o)){let c={},u={...o};for(let m of n)c[m]=o[m],delete u[m];i.envelope=c,Object.keys(u).length>0?l._meta=u:delete l._meta}for(let c of a)c==="inputResponses"&&(i.inputResponses=l[c]),c==="requestState"&&(i.requestState=l[c]),delete l[c];return{message:{...e,params:l},lifted:i}}function gp(e,t){let r=e.validateResult(t,void 0);if(!(!r.ok&&r.reason==="not-in-era"))return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(o){let n=e.validateResult(t,o);return n.ok?{value:n.value}:{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function wn(e){return()=>e}var _S=wn(void 0);function fl(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:wn(t)}}}var tm;function rm(e,t){tm(e,t)}var gl=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{tm=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Do,this.setNotificationHandler("notifications/cancelled",t=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",t=>{this._onprogress(t)}),this.setRequestHandler("ping",t=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new le(pe.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,o,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:n,onTimeout:o})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new le(pe.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=n=>{r?.(n),this._onerror(n)};let o=this._transport?.onmessage;this._transport.onmessage=(n,a)=>{o?.(n,a),ct(n)||lt(n)?this._onresponse(n):Ze(n)?this._onrequest(n,a):ui(n)?this._onnotification(n,a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},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 o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new le(pe.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let o of e.values())o(r);for(let o of t.values())o.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=fp(e,"notification"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let i=cp(t.classification);if(i!==o.era){this._onerror(new Error(`Era mismatch on inbound notification '${r.method}': classified as ${i} but this instance serves ${o.era}`));return}}if(Kc(r.method)&&!o.hasNotificationMethod(r.method))return;let n=this._notificationHandlers.get(r.method),a=this.fallbackNotificationHandler;n===void 0&&a===void 0||Promise.resolve().then(()=>n===void 0?a(r):n(r,o)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,t){let{message:r,lifted:o}=fp(e,"request"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(new Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,i=(P,b,h)=>{let $={jsonrpc:"2.0",id:r.id,error:{code:P,message:b,...h!==void 0&&{data:h}}};a?.send($).catch(v=>this._onerror(new Error(`Failed to send an error response: ${v}`)))};if(t?.classification!==void 0){let P=cp(t.classification);if(P!==n.era){this._onerror(new Error(`Era mismatch on inbound request '${r.method}': classified as ${P} but this instance serves ${n.era}`));let b=t.classification.revision??P;i(G.UnsupportedProtocolVersion,`Unsupported protocol version: ${b}`,{supported:this._supportedProtocolVersions,requested:b});return}}if(Jc(r.method)&&!n.hasRequestMethod(r.method)&&!(lp(r.method)&&this._customSchemaRequestMethods.has(r.method))){i(G.MethodNotFound,"Method not found");return}let l=this._requestHandlers.get(r.method)??this.fallbackRequestHandler;if(l===void 0){i(G.MethodNotFound,"Method not found");return}let c=n.checkInboundEnvelope(o);if(c!==void 0){i(G.InvalidParams,c);return}let u=(P,b)=>this._notificationViaCodec(this._resolveOutboundCodec(P.method),P,{...b,relatedRequestId:r.id}),m=(P,b,h)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(P.method),P,b,{...h,relatedRequestId:r.id}),f=new AbortController;this._requestHandlerAbortControllers.set(r.id,f);let y=o.inputResponses===void 0?void 0:bS(o.inputResponses),R={sessionId:a?.sessionId,mcpReq:{id:r.id,method:r.method,_meta:r.params?._meta,...o.envelope!==void 0&&{envelope:o.envelope},...y!==void 0&&{inputResponses:y.accepted},...y!==void 0&&y.droppedKeys.length>0&&{droppedInputResponseKeys:y.droppedKeys},requestState:o.requestState===void 0?_S:wn(o.requestState),signal:f.signal,send:(P,b,h)=>{let $=this._resolveOutboundCodec(P.method);if(this._assertOutboundRequestInEra($,P.method),Br(b))return m(P,b,h);let v=gp($,P.method);if(v===void 0)throw new TypeError(`'${P.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return m(P,v,b)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},S=this.buildContext(R,t);Promise.resolve().then(()=>l(r,S)).then(async P=>{if(f.signal.aborted)return;let b;try{b=n.encodeResult(r.method,P,this._outboundServerInfo())}catch($){this._onerror(new Error(`Failed to encode result for ${r.method}: ${$}`)),i(G.InternalError,"Internal error");return}let h={result:b,jsonrpc:"2.0",id:r.id};await a?.send(h)},async P=>{if(f.signal.aborted)return;let b=Number.isSafeInteger(P.code)?P.code:G.InternalError,h={jsonrpc:"2.0",id:r.id,error:{code:n.encodeErrorCode(b),message:P.message??"Internal error",...P.data!==void 0&&{data:P.data}}};await a?.send(h)}).catch(P=>this._onerror(new Error(`Failed to send response: ${P}`))).finally(()=>{this._requestHandlerAbortControllers.get(r.id)===f&&this._requestHandlerAbortControllers.delete(r.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,o=Number(t),n=this._progressHandlers.get(o);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(o),i=this._timeoutInfo.get(o);if(i&&a&&i.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(l){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),a(l);return}n(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),ct(e)?r(e):r(te.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let o=this._resolveOutboundCodec(e.method);if(Br(t))return lp(e.method)||this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r);this._assertOutboundRequestInEra(o,e.method);let n=gp(o,e.method);if(n===void 0)throw new TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(o,e,n,t)}_negotiatedWireCodec(){return ft(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=yS(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Jc(t)&&!e.hasRequestMethod(t))throw new le(pe.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let o=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r)}_requestWithSchemaViaCodec(e,t,r,o){let{relatedRequestId:n,resumptionToken:a,onresumptiontoken:i,headers:l}=o??{},c=Date.now(),u,m;return new Promise((f,y)=>{let R=T=>{y(T)};if(!this._transport){R(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(T){R(T);return}if(o?.signal?.aborted){let T=o.signal.reason;throw T instanceof le?T:new le(pe.RequestTimeout,String(T))}let S=e.era===Rn&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,P=this._requestMessageId++;m=P;let b={...t,jsonrpc:"2.0",id:P};o?.onprogress&&(this._progressHandlers.set(P,o.onprogress),b.params={...t.params,_meta:{...t.params?._meta,progressToken:P}});let h=this._envelopeOutbound(b),$=!1,v=T=>{$||(this._progressHandlers.delete(P),S===void 0?t.method!=="initialize"&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:P,reason:String(T)}}),{relatedRequestId:n,resumptionToken:a,onresumptiontoken:i}).catch(_=>this._onerror(new Error(`Failed to send cancellation: ${_}`))):S.abort(),y(T instanceof le?T:new le(pe.RequestTimeout,String(T))))};this._responseHandlers.set(P,T=>{if(o?.signal?.aborted)return;if($=!0,T instanceof Error)return y(T);let _;try{_=e.decodeResult(t.method,T.result)}catch(M){return y(M instanceof Error?M:new Error(String(M)))}if(_.kind==="invalid")return y(_.error);if(_.kind==="input_required"){if(o?.allowInputRequired===!0)return f(RS(_));let M={codec:e,request:t,resultSchema:r,options:o,flowStartedAt:c,retry:(U,q)=>this._requestWithSchemaViaCodec(e,U===void 0?{method:t.method}:{method:t.method,params:U},r,q)};return f(this._resolveNonCompleteResult(_,M))}let C=_.result;ir(r,C).then(M=>{M.success?f(M.data):y(new le(pe.InvalidResult,`Invalid result for ${t.method}: ${M.error}`))},y)}),u=()=>v(o?.signal?.reason),o?.signal?.addEventListener("abort",u,{once:!0});let z=o?.timeout??em,I=()=>v(new le(pe.RequestTimeout,"Request timed out",{timeout:z}));this._setupTimeout(P,z,o?.maxTotalTimeout,I,o?.resetTimeoutOnProgress??!1),this._transport.send(h,{relatedRequestId:n,resumptionToken:a,onresumptiontoken:i,headers:l,requestSignal:S?.signal}).catch(T=>{this._progressHandlers.delete(P),y(T)})}).finally(()=>{u&&o?.signal?.removeEventListener("abort",u),m!==void 0&&(this._responseHandlers.delete(m),this._cleanupTimeout(m))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new le(pe.NotConnected,"Not connected");if(Kc(t.method)&&!e.hasNotificationMethod(t.method))throw new le(pe.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 o=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(o,r).catch(n=>this._onerror(n))});return}await this._transport.send(o,r)}setRequestHandler(e,t,r){this.assertRequestHandlerCapability(e);let o;if(typeof t=="function"){if(!Jc(e))throw new TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);o=(n,a)=>{let i=this._negotiatedWireCodec(),l=i.validateRequest(e,n);if(!l.ok&&l.reason==="not-in-era"&&(l=i.validateInputRequest(e,n)),!l.ok)throw l.reason==="not-in-era"?new te(G.InternalError,`No wire schema for ${e} in the resolved era`):new Error(l.message);return Promise.resolve(t(l.value,a))}}else if(r)o=async(n,a)=>{let i=await ir(t.params,{...n.params});if(!i.success)throw new te(G.InvalidParams,`Invalid params for ${e}: ${i.error}`);return r(i.data,a)};else throw new TypeError("setRequestHandler: handler is required");typeof t=="function"?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,o))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if(typeof t=="function"){if(!Kc(e))throw new TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(o,n)=>{let a=n.validateNotification(e,o);if(!a.ok)throw a.reason==="not-in-era"?new te(G.InternalError,`No wire schema for ${e} in the resolved era`):new Error(a.message);return Promise.resolve(t(a.value))});return}if(!r)throw new TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async o=>{let n=await ir(t.params,{...o.params});if(!n.success)throw new te(G.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,o)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function gn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function yl(e,t){let r={...e};for(let o in t){let n=o,a=t[n];if(a===void 0)continue;let i=r[n];r[n]=gn(i)&&gn(a)?{...i,...a}:a}return r}function yp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bS(e){let t={},r=[];if(!yp(e))return{accepted:t,droppedKeys:r};for(let[o,n]of Object.entries(e)){if(!yp(n)||"method"in n||"result"in n){r.push(o);continue}t[o]=n}return{accepted:t,droppedKeys:r}}function RS(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var wS=V(e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,o=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=n;function n(l){if(!l)throw new TypeError("argument string is required");var c=typeof l=="object"?a(l):l;if(typeof c!="string")throw new TypeError("argument string is required to be a string");var u=c.indexOf(";"),m=u!==-1?c.slice(0,u).trim():c.trim();if(!o.test(m))throw new TypeError("invalid media type");var f=new i(m.toLowerCase());if(u!==-1){var y,R,S;for(t.lastIndex=u;R=t.exec(c);){if(R.index!==u)throw new TypeError("invalid parameter format");u+=R[0].length,y=R[1].toLowerCase(),S=R[2],S.charCodeAt(0)===34&&(S=S.slice(1,-1),S.indexOf("\\")!==-1&&(S=S.replace(r,"$1"))),f.parameters[y]=S}if(u!==c.length)throw new TypeError("invalid parameter format")}return f}function a(l){var c;if(typeof l.getHeader=="function"?c=l.getHeader("content-type"):typeof l.headers=="object"&&(c=l.headers&&l.headers["content-type"]),typeof c!="string")throw new TypeError("content-type header is missing from object");return c}function i(l){this.parameters=Object.create(null),this.type=l}}),ES=ds(wS(),1);function Sl(e){if(e)try{return ES.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function En(e){return e==="application/json"?!0:Sl(e)==="application/json"}var TS=10*1024*1024;var $S=/^[A-Za-z0-9._-]{1,128}$/;function zS(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"),!$S.test(e)){let r=[...e].filter(o=>!/[A-Za-z0-9._-]/.test(o)).filter((o,n,a)=>a.indexOf(o)===n);return t.push(`Tool name contains invalid characters: ${r.map(o=>`"${o}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function PS(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);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 vl(e){let t=zS(e);return PS(e,t.warnings),t.isValid}function CS(e){return typeof e=="object"&&e!==null&&"_zod"in e}function kS(e){return typeof e=="object"&&e!==null&&!("_zod"in e)&&"_def"in e&&typeof e._def?.typeName=="string"}function IS(e){if(typeof e!="object"||e===null||Br(e))return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.values(e).every(r=>CS(r))}function hi(e){if(e!==void 0){if(IS(e))return s.object(e);if(typeof e=="object"&&e!==null&&!Br(e)&&Object.values(e).some(t=>kS(t)))throw new 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(!Br(e))throw new TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return e}}var gi=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var r=class extends t{constructor(h){if(super(),!e.IDENTIFIER.test(h))throw new Error("CodeGen: name must be a valid identifier");this.str=h}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=r;var o=class extends t{constructor(h){super(),this._items=typeof h=="string"?[h]:h}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let h=this._items[0];return h===""||h==='""'}get str(){var h;return(h=this._str)!==null&&h!==void 0?h:this._str=this._items.reduce(($,v)=>`${$}${v}`,"")}get names(){var h;return(h=this._names)!==null&&h!==void 0?h:this._names=this._items.reduce(($,v)=>(v instanceof r&&($[v.str]=($[v.str]||0)+1),$),{})}};e._Code=o,e.nil=new o("");function n(h,...$){let v=[h[0]],z=0;for(;z<$.length;)l(v,$[z]),v.push(h[++z]);return new o(v)}e._=n;let a=new o("+");function i(h,...$){let v=[R(h[0])],z=0;for(;z<$.length;)v.push(a),l(v,$[z]),v.push(a,R(h[++z]));return c(v),new o(v)}e.str=i;function l(h,$){$ instanceof o?h.push(...$._items):$ instanceof r?h.push($):h.push(f($))}e.addCodeArg=l;function c(h){let $=1;for(;$<h.length-1;){if(h[$]===a){let v=u(h[$-1],h[$+1]);if(v!==void 0){h.splice($-1,3,v);continue}h[$++]="+"}$++}}function u(h,$){if($==='""')return h;if(h==='""')return $;if(typeof h=="string")return $ instanceof r||h[h.length-1]!=='"'?void 0:typeof $!="string"?`${h.slice(0,-1)}${$}"`:$[0]==='"'?h.slice(0,-1)+$.slice(1):void 0;if(typeof $=="string"&&$[0]==='"'&&!(h instanceof r))return`"${h}${$.slice(1)}`}function m(h,$){return $.emptyStr()?h:h.emptyStr()?$:i`${h}${$}`}e.strConcat=m;function f(h){return typeof h=="number"||typeof h=="boolean"||h===null?h:R(Array.isArray(h)?h.join(","):h)}function y(h){return new o(R(h))}e.stringify=y;function R(h){return JSON.stringify(h).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=R;function S(h){return typeof h=="string"&&e.IDENTIFIER.test(h)?new o(`.${h}`):n`[${h}]`}e.getProperty=S;function P(h){if(typeof h=="string"&&e.IDENTIFIER.test(h))return new o(`${h}`);throw new Error(`CodeGen: invalid export name: ${h}, use explicit $id name mapping`)}e.getEsmExportName=P;function b(h){return new o(h.toString())}e.regexpCode=b}),om=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=gi();var r=class extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}},o;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(o||(e.UsedValueState=o={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};var n=class{constructor({prefixes:c,parent:u}={}){this._names={},this._prefixes=c,this._parent=u}toName(c){return c instanceof t.Name?c:this.name(c)}name(c){return new t.Name(this._newName(c))}_newName(c){let u=this._names[c]||this._nameGroup(c);return`${c}${u.index++}`}_nameGroup(c){var u,m;if(!((m=(u=this._parent)===null||u===void 0?void 0:u._prefixes)===null||m===void 0)&&m.has(c)||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}};e.Scope=n;var a=class extends t.Name{constructor(c,u){super(u),this.prefix=c}setValue(c,{property:u,itemIndex:m}){this.value=c,this.scopePath=(0,t._)`.${new t.Name(u)}[${m}]`}};e.ValueScopeName=a;let i=(0,t._)`\n`;var l=class extends n{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?i:t.nil}}get(){return this._scope}name(c){return new a(c,this._newName(c))}value(c,u){var m;if(u.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let f=this.toName(c),{prefix:y}=f,R=(m=u.key)!==null&&m!==void 0?m:u.ref,S=this._values[y];if(S){let h=S.get(R);if(h)return h}else S=this._values[y]=new Map;S.set(R,f);let P=this._scope[y]||(this._scope[y]=[]),b=P.length;return P[b]=u.ref,f.setValue(u,{property:y,itemIndex:b}),f}getValue(c,u){let m=this._values[c];if(m)return m.get(u)}scopeRefs(c,u=this._values){return this._reduceValues(u,m=>{if(m.scopePath===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return(0,t._)`${c}${m.scopePath}`})}scopeCode(c=this._values,u,m){return this._reduceValues(c,f=>{if(f.value===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return f.value.code},u,m)}_reduceValues(c,u,m={},f){let y=t.nil;for(let R in c){let S=c[R];if(!S)continue;let P=m[R]=m[R]||new Map;S.forEach(b=>{if(P.has(b))return;P.set(b,o.Started);let h=u(b);if(h){let $=this.opts.es5?e.varKinds.var:e.varKinds.const;y=(0,t._)`${y}${$} ${b} = ${h};${this.opts._n}`}else if(h=f?.(b))y=(0,t._)`${y}${h}${this.opts._n}`;else throw new r(b);P.set(b,o.Completed)})}return y}};e.ValueScope=l}),de=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=gi(),r=om();var o=gi();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return o.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return o.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return o.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return o.Name}});var n=om();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return n.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return n.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return n.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return n.varKinds}}),e.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(p,g){return this}},i=class extends a{constructor(p,g,w){super(),this.varKind=p,this.name=g,this.rhs=w}render({es5:p,_n:g}){let w=p?r.varKinds.var:this.varKind,A=this.rhs===void 0?"":` = ${this.rhs}`;return`${w} ${this.name}${A};`+g}optimizeNames(p,g){if(p[this.name.str])return this.rhs&&(this.rhs=F(this.rhs,p,g)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},l=class extends a{constructor(p,g,w){super(),this.lhs=p,this.rhs=g,this.sideEffects=w}render({_n:p}){return`${this.lhs} = ${this.rhs};`+p}optimizeNames(p,g){if(!(this.lhs instanceof t.Name&&!p[this.lhs.str]&&!this.sideEffects))return this.rhs=F(this.rhs,p,g),this}get names(){return W(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends l{constructor(p,g,w,A){super(p,w,A),this.op=g}render({_n:p}){return`${this.lhs} ${this.op}= ${this.rhs};`+p}},u=class extends a{constructor(p){super(),this.label=p,this.names={}}render({_n:p}){return`${this.label}:`+p}},m=class extends a{constructor(p){super(),this.label=p,this.names={}}render({_n:p}){return`break${this.label?` ${this.label}`:""};`+p}},f=class extends a{constructor(p){super(),this.error=p}render({_n:p}){return`throw ${this.error};`+p}get names(){return this.error.names}},y=class extends a{constructor(p){super(),this.code=p}render({_n:p}){return`${this.code};`+p}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(p,g){return this.code=F(this.code,p,g),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},R=class extends a{constructor(p=[]){super(),this.nodes=p}render(p){return this.nodes.reduce((g,w)=>g+w.render(p),"")}optimizeNodes(){let{nodes:p}=this,g=p.length;for(;g--;){let w=p[g].optimizeNodes();Array.isArray(w)?p.splice(g,1,...w):w?p[g]=w:p.splice(g,1)}return p.length>0?this:void 0}optimizeNames(p,g){let{nodes:w}=this,A=w.length;for(;A--;){let x=w[A];x.optimizeNames(p,g)||(ie(p,x.names),w.splice(A,1))}return w.length>0?this:void 0}get names(){return this.nodes.reduce((p,g)=>D(p,g.names),{})}},S=class extends R{render(p){return"{"+p._n+super.render(p)+"}"+p._n}},P=class extends R{},b=class extends S{};b.kind="else";var h=class fi extends S{constructor(g,w){super(w),this.condition=g}render(g){let w=`if(${this.condition})`+super.render(g);return this.else&&(w+="else "+this.else.render(g)),w}optimizeNodes(){super.optimizeNodes();let g=this.condition;if(g===!0)return this.nodes;let w=this.else;if(w){let A=w.optimizeNodes();w=this.else=Array.isArray(A)?new b(A):A}if(w)return g===!1?w instanceof fi?w:w.nodes:this.nodes.length?this:new fi(he(g),w instanceof fi?[w]:w.nodes);if(!(g===!1||!this.nodes.length))return this}optimizeNames(g,w){var A;if(this.else=(A=this.else)===null||A===void 0?void 0:A.optimizeNames(g,w),!!(super.optimizeNames(g,w)||this.else))return this.condition=F(this.condition,g,w),this}get names(){let g=super.names;return W(g,this.condition),this.else&&D(g,this.else.names),g}};h.kind="if";var $=class extends S{};$.kind="for";var v=class extends ${constructor(p){super(),this.iteration=p}render(p){return`for(${this.iteration})`+super.render(p)}optimizeNames(p,g){if(super.optimizeNames(p,g))return this.iteration=F(this.iteration,p,g),this}get names(){return D(super.names,this.iteration.names)}},z=class extends ${constructor(p,g,w,A){super(),this.varKind=p,this.name=g,this.from=w,this.to=A}render(p){let g=p.es5?r.varKinds.var:this.varKind,{name:w,from:A,to:x}=this;return`for(${g} ${w}=${A}; ${w}<${x}; ${w}++)`+super.render(p)}get names(){return W(W(super.names,this.from),this.to)}},I=class extends ${constructor(p,g,w,A){super(),this.loop=p,this.varKind=g,this.name=w,this.iterable=A}render(p){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(p)}optimizeNames(p,g){if(super.optimizeNames(p,g))return this.iterable=F(this.iterable,p,g),this}get names(){return D(super.names,this.iterable.names)}},T=class extends S{constructor(p,g,w){super(),this.name=p,this.args=g,this.async=w}render(p){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(p)}};T.kind="func";var _=class extends R{render(p){return"return "+super.render(p)}};_.kind="return";var C=class extends S{render(p){let g="try"+super.render(p);return this.catch&&(g+=this.catch.render(p)),this.finally&&(g+=this.finally.render(p)),g}optimizeNodes(){var p,g;return super.optimizeNodes(),(p=this.catch)===null||p===void 0||p.optimizeNodes(),(g=this.finally)===null||g===void 0||g.optimizeNodes(),this}optimizeNames(p,g){var w,A;return super.optimizeNames(p,g),(w=this.catch)===null||w===void 0||w.optimizeNames(p,g),(A=this.finally)===null||A===void 0||A.optimizeNames(p,g),this}get names(){let p=super.names;return this.catch&&D(p,this.catch.names),this.finally&&D(p,this.finally.names),p}},M=class extends S{constructor(p){super(),this.error=p}render(p){return`catch(${this.error})`+super.render(p)}};M.kind="catch";var U=class extends S{render(p){return"finally"+super.render(p)}};U.kind="finally";var q=class{constructor(p,g={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...g,_n:g.lines?`
|
|
18
|
+
`:""},this._extScope=p,this._scope=new r.Scope({parent:p}),this._nodes=[new P]}toString(){return this._root.render(this.opts)}name(p){return this._scope.name(p)}scopeName(p){return this._extScope.name(p)}scopeValue(p,g){let w=this._extScope.value(p,g);return(this._values[w.prefix]||(this._values[w.prefix]=new Set)).add(w),w}getScopeValue(p,g){return this._extScope.getValue(p,g)}scopeRefs(p){return this._extScope.scopeRefs(p,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(p,g,w,A){let x=this._scope.toName(g);return w!==void 0&&A&&(this._constants[x.str]=w),this._leafNode(new i(p,x,w)),x}const(p,g,w){return this._def(r.varKinds.const,p,g,w)}let(p,g,w){return this._def(r.varKinds.let,p,g,w)}var(p,g,w){return this._def(r.varKinds.var,p,g,w)}assign(p,g,w){return this._leafNode(new l(p,g,w))}add(p,g){return this._leafNode(new c(p,e.operators.ADD,g))}code(p){return typeof p=="function"?p():p!==t.nil&&this._leafNode(new y(p)),this}object(...p){let g=["{"];for(let[w,A]of p)g.length>1&&g.push(","),g.push(w),(w!==A||this.opts.es5)&&(g.push(":"),(0,t.addCodeArg)(g,A));return g.push("}"),new t._Code(g)}if(p,g,w){if(this._blockNode(new h(p)),g&&w)this.code(g).else().code(w).endIf();else if(g)this.code(g).endIf();else if(w)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(p){return this._elseNode(new h(p))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(h,b)}_for(p,g){return this._blockNode(p),g&&this.code(g).endFor(),this}for(p,g){return this._for(new v(p),g)}forRange(p,g,w,A,x=this.opts.es5?r.varKinds.var:r.varKinds.let){let J=this._scope.toName(p);return this._for(new z(x,J,g,w),()=>A(J))}forOf(p,g,w,A=r.varKinds.const){let x=this._scope.toName(p);if(this.opts.es5){let J=g instanceof t.Name?g:this.var("_arr",g);return this.forRange("_i",0,(0,t._)`${J}.length`,K=>{this.var(x,(0,t._)`${J}[${K}]`),w(x)})}return this._for(new I("of",A,x,g),()=>w(x))}forIn(p,g,w,A=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(p,(0,t._)`Object.keys(${g})`,w);let x=this._scope.toName(p);return this._for(new I("in",A,x,g),()=>w(x))}endFor(){return this._endBlockNode($)}label(p){return this._leafNode(new u(p))}break(p){return this._leafNode(new m(p))}return(p){let g=new _;if(this._blockNode(g),this.code(p),g.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(_)}try(p,g,w){if(!g&&!w)throw new Error('CodeGen: "try" without "catch" and "finally"');let A=new C;if(this._blockNode(A),this.code(p),g){let x=this.name("e");this._currNode=A.catch=new M(x),g(x)}return w&&(this._currNode=A.finally=new U,this.code(w)),this._endBlockNode(M,U)}throw(p){return this._leafNode(new f(p))}block(p,g){return this._blockStarts.push(this._nodes.length),p&&this.code(p).endBlock(g),this}endBlock(p){let g=this._blockStarts.pop();if(g===void 0)throw new Error("CodeGen: not in self-balancing block");let w=this._nodes.length-g;if(w<0||p!==void 0&&w!==p)throw new Error(`CodeGen: wrong number of nodes: ${w} vs ${p} expected`);return this._nodes.length=g,this}func(p,g=t.nil,w,A){return this._blockNode(new T(p,g,w)),A&&this.code(A).endFunc(),this}endFunc(){return this._endBlockNode(T)}optimize(p=1){for(;p-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(p){return this._currNode.nodes.push(p),this}_blockNode(p){this._currNode.nodes.push(p),this._nodes.push(p)}_endBlockNode(p,g){let w=this._currNode;if(w instanceof p||g&&w instanceof g)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${g?`${p.kind}/${g.kind}`:p.kind}"`)}_elseNode(p){let g=this._currNode;if(!(g instanceof h))throw new Error('CodeGen: "else" without "if"');return this._currNode=g.else=p,this}get _root(){return this._nodes[0]}get _currNode(){let p=this._nodes;return p[p.length-1]}set _currNode(p){let g=this._nodes;g[g.length-1]=p}};e.CodeGen=q;function D(p,g){for(let w in g)p[w]=(p[w]||0)+(g[w]||0);return p}function W(p,g){return g instanceof t._CodeOrName?D(p,g.names):p}function F(p,g,w){if(p instanceof t.Name)return A(p);if(!x(p))return p;return new t._Code(p._items.reduce((J,K)=>(K instanceof t.Name&&(K=A(K)),K instanceof t._Code?J.push(...K._items):J.push(K),J),[]));function A(J){let K=w[J.str];return K===void 0||g[J.str]!==1?J:(delete g[J.str],K)}function x(J){return J instanceof t._Code&&J._items.some(K=>K instanceof t.Name&&g[K.str]===1&&w[K.str]!==void 0)}}function ie(p,g){for(let w in g)p[w]=(p[w]||0)-(g[w]||0)}function he(p){return typeof p=="boolean"||typeof p=="number"||p===null?!p:(0,t._)`!${E(p)}`}e.not=he;let ge=j(e.operators.AND);function _e(...p){return p.reduce(ge)}e.and=_e;let ue=j(e.operators.OR);function O(...p){return p.reduce(ue)}e.or=O;function j(p){return(g,w)=>g===t.nil?w:w===t.nil?g:(0,t._)`${E(g)} ${p} ${E(w)}`}function E(p){return p instanceof t.Name?p:(0,t._)`(${p})`}}),ye=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=de(),r=gi();function o(T){let _={};for(let C of T)_[C]=!0;return _}e.toHash=o;function n(T,_){return typeof _=="boolean"?_:Object.keys(_).length===0?!0:(a(T,_),!i(_,T.self.RULES.all))}e.alwaysValidSchema=n;function a(T,_=T.schema){let{opts:C,self:M}=T;if(!C.strictSchema||typeof _=="boolean")return;let U=M.RULES.keywords;for(let q in _)U[q]||I(T,`unknown keyword: "${q}"`)}e.checkUnknownRules=a;function i(T,_){if(typeof T=="boolean")return!T;for(let C in T)if(_[C])return!0;return!1}e.schemaHasRules=i;function l(T,_){if(typeof T=="boolean")return!T;for(let C in T)if(C!=="$ref"&&_.all[C])return!0;return!1}e.schemaHasRulesButRef=l;function c({topSchemaRef:T,schemaPath:_},C,M,U){if(!U){if(typeof C=="number"||typeof C=="boolean")return C;if(typeof C=="string")return(0,t._)`${C}`}return(0,t._)`${T}${_}${(0,t.getProperty)(M)}`}e.schemaRefOrVal=c;function u(T){return y(decodeURIComponent(T))}e.unescapeFragment=u;function m(T){return encodeURIComponent(f(T))}e.escapeFragment=m;function f(T){return typeof T=="number"?`${T}`:T.replace(/~/g,"~0").replace(/\//g,"~1")}e.escapeJsonPointer=f;function y(T){return T.replace(/~1/g,"/").replace(/~0/g,"~")}e.unescapeJsonPointer=y;function R(T,_){if(Array.isArray(T))for(let C of T)_(C);else _(T)}e.eachItem=R;function S({mergeNames:T,mergeToName:_,mergeValues:C,resultToName:M}){return(U,q,D,W)=>{let F=D===void 0?q:D instanceof t.Name?(q instanceof t.Name?T(U,q,D):_(U,q,D),D):q instanceof t.Name?(_(U,D,q),q):C(q,D);return W===t.Name&&!(F instanceof t.Name)?M(U,F):F}}e.mergeEvaluated={props:S({mergeNames:(T,_,C)=>T.if((0,t._)`${C} !== true && ${_} !== undefined`,()=>{T.if((0,t._)`${_} === true`,()=>T.assign(C,!0),()=>T.assign(C,(0,t._)`${C} || {}`).code((0,t._)`Object.assign(${C}, ${_})`))}),mergeToName:(T,_,C)=>T.if((0,t._)`${C} !== true`,()=>{_===!0?T.assign(C,!0):(T.assign(C,(0,t._)`${C} || {}`),b(T,C,_))}),mergeValues:(T,_)=>T===!0?!0:{...T,..._},resultToName:P}),items:S({mergeNames:(T,_,C)=>T.if((0,t._)`${C} !== true && ${_} !== undefined`,()=>T.assign(C,(0,t._)`${_} === true ? true : ${C} > ${_} ? ${C} : ${_}`)),mergeToName:(T,_,C)=>T.if((0,t._)`${C} !== true`,()=>T.assign(C,_===!0?!0:(0,t._)`${C} > ${_} ? ${C} : ${_}`)),mergeValues:(T,_)=>T===!0?!0:Math.max(T,_),resultToName:(T,_)=>T.var("items",_)})};function P(T,_){if(_===!0)return T.var("props",!0);let C=T.var("props",(0,t._)`{}`);return _!==void 0&&b(T,C,_),C}e.evaluatedPropsToName=P;function b(T,_,C){Object.keys(C).forEach(M=>T.assign((0,t._)`${_}${(0,t.getProperty)(M)}`,!0))}e.setEvaluated=b;let h={};function $(T,_){return T.scopeValue("func",{ref:_,code:h[_.code]||(h[_.code]=new r._Code(_.code))})}e.useFunc=$;var v;(function(T){T[T.Num=0]="Num",T[T.Str=1]="Str"})(v||(e.Type=v={}));function z(T,_,C){if(T instanceof t.Name){let M=_===v.Num;return C?M?(0,t._)`"[" + ${T} + "]"`:(0,t._)`"['" + ${T} + "']"`:M?(0,t._)`"/" + ${T}`:(0,t._)`"/" + ${T}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return C?(0,t.getProperty)(T).toString():"/"+f(T)}e.getErrorPath=z;function I(T,_,C=T.opts.strictSchema){if(C){if(_=`strict mode: ${_}`,C===!0)throw new Error(_);T.self.logger.warn(_)}}e.checkStrictMode=I}),Qe=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r={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")};e.default=r}),Si=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=de(),r=ye(),o=Qe();e.keywordError={message:({keyword:b})=>(0,t.str)`must pass "${b}" keyword validation`},e.keyword$DataError={message:({keyword:b,schemaType:h})=>h?(0,t.str)`"${b}" keyword must be ${h} ($data)`:(0,t.str)`"${b}" keyword is invalid ($data)`};function n(b,h=e.keywordError,$,v){let{it:z}=b,{gen:I,compositeRule:T,allErrors:_}=z,C=f(b,h,$);v??(T||_)?c(I,C):u(z,(0,t._)`[${C}]`)}e.reportError=n;function a(b,h=e.keywordError,$){let{it:v}=b,{gen:z,compositeRule:I,allErrors:T}=v;c(z,f(b,h,$)),I||T||u(v,o.default.vErrors)}e.reportExtraError=a;function i(b,h){b.assign(o.default.errors,h),b.if((0,t._)`${o.default.vErrors} !== null`,()=>b.if(h,()=>b.assign((0,t._)`${o.default.vErrors}.length`,h),()=>b.assign(o.default.vErrors,null)))}e.resetErrorsCount=i;function l({gen:b,keyword:h,schemaValue:$,data:v,errsCount:z,it:I}){if(z===void 0)throw new Error("ajv implementation error");let T=b.name("err");b.forRange("i",z,o.default.errors,_=>{b.const(T,(0,t._)`${o.default.vErrors}[${_}]`),b.if((0,t._)`${T}.instancePath === undefined`,()=>b.assign((0,t._)`${T}.instancePath`,(0,t.strConcat)(o.default.instancePath,I.errorPath))),b.assign((0,t._)`${T}.schemaPath`,(0,t.str)`${I.errSchemaPath}/${h}`),I.opts.verbose&&(b.assign((0,t._)`${T}.schema`,$),b.assign((0,t._)`${T}.data`,v))})}e.extendErrors=l;function c(b,h){let $=b.const("err",h);b.if((0,t._)`${o.default.vErrors} === null`,()=>b.assign(o.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${o.default.vErrors}.push(${$})`),b.code((0,t._)`${o.default.errors}++`)}function u(b,h){let{gen:$,validateName:v,schemaEnv:z}=b;z.$async?$.throw((0,t._)`new ${b.ValidationError}(${h})`):($.assign((0,t._)`${v}.errors`,h),$.return(!1))}let m={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 f(b,h,$){let{createErrors:v}=b.it;return v===!1?(0,t._)`{}`:y(b,h,$)}function y(b,h,$={}){let{gen:v,it:z}=b,I=[R(z,$),S(b,$)];return P(b,h,I),v.object(...I)}function R({errorPath:b},{instancePath:h}){let $=h?(0,t.str)`${b}${(0,r.getErrorPath)(h,r.Type.Str)}`:b;return[o.default.instancePath,(0,t.strConcat)(o.default.instancePath,$)]}function S({keyword:b,it:{errSchemaPath:h}},{schemaPath:$,parentSchema:v}){let z=v?h:(0,t.str)`${h}/${b}`;return $&&(z=(0,t.str)`${z}${(0,r.getErrorPath)($,r.Type.Str)}`),[m.schemaPath,z]}function P(b,{params:h,message:$},v){let{keyword:z,data:I,schemaValue:T,it:_}=b,{opts:C,propertyName:M,topSchemaRef:U,schemaPath:q}=_;v.push([m.keyword,z],[m.params,typeof h=="function"?h(b):h||(0,t._)`{}`]),C.messages&&v.push([m.message,typeof $=="function"?$(b):$]),C.verbose&&v.push([m.schema,T],[m.parentSchema,(0,t._)`${U}${q}`],[o.default.data,I]),M&&v.push([m.propertyName,M])}}),AS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Si(),r=de(),o=Qe(),n={message:"boolean schema is false"};function a(c){let{gen:u,schema:m,validateName:f}=c;m===!1?l(c,!1):typeof m=="object"&&m.$async===!0?u.return(o.default.data):(u.assign((0,r._)`${f}.errors`,null),u.return(!0))}e.topBoolOrEmptySchema=a;function i(c,u){let{gen:m,schema:f}=c;f===!1?(m.var(u,!1),l(c)):m.var(u,!0)}e.boolOrEmptySchema=i;function l(c,u){let{gen:m,data:f}=c,y={gen:m,keyword:"false schema",data:f,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:c};(0,t.reportError)(y,n,void 0,u)}}),nm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set(["string","number","integer","boolean","null","object","array"]);function r(n){return typeof n=="string"&&t.has(n)}e.isJSONType=r;function o(){let n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...n,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=o}),sm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:n,self:a},i){let l=a.RULES.types[i];return l&&l!==!0&&r(n,l)}e.schemaHasRulesForType=t;function r(n,a){return a.rules.some(i=>o(n,i))}e.shouldUseGroup=r;function o(n,a){var i;return n[a.keyword]!==void 0||((i=a.definition.implements)===null||i===void 0?void 0:i.some(l=>n[l]!==void 0))}e.shouldUseRule=o}),yi=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=nm(),r=sm(),o=Si(),n=de(),a=ye();var i;(function(v){v[v.Correct=0]="Correct",v[v.Wrong=1]="Wrong"})(i||(e.DataType=i={}));function l(v){let z=c(v.type);if(z.includes("null")){if(v.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!z.length&&v.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');v.nullable===!0&&z.push("null")}return z}e.getSchemaTypes=l;function c(v){let z=Array.isArray(v)?v:v?[v]:[];if(z.every(t.isJSONType))return z;throw new Error("type must be JSONType or JSONType[]: "+z.join(","))}e.getJSONTypes=c;function u(v,z){let{gen:I,data:T,opts:_}=v,C=f(z,_.coerceTypes),M=z.length>0&&!(C.length===0&&z.length===1&&(0,r.schemaHasRulesForType)(v,z[0]));if(M){let U=P(z,T,_.strictNumbers,i.Wrong);I.if(U,()=>{C.length?y(v,z,C):h(v)})}return M}e.coerceAndCheckDataType=u;let m=new Set(["string","number","integer","boolean","null"]);function f(v,z){return z?v.filter(I=>m.has(I)||z==="array"&&I==="array"):[]}function y(v,z,I){let{gen:T,data:_,opts:C}=v,M=T.let("dataType",(0,n._)`typeof ${_}`),U=T.let("coerced",(0,n._)`undefined`);C.coerceTypes==="array"&&T.if((0,n._)`${M} == 'object' && Array.isArray(${_}) && ${_}.length == 1`,()=>T.assign(_,(0,n._)`${_}[0]`).assign(M,(0,n._)`typeof ${_}`).if(P(z,_,C.strictNumbers),()=>T.assign(U,_))),T.if((0,n._)`${U} !== undefined`);for(let D of I)(m.has(D)||D==="array"&&C.coerceTypes==="array")&&q(D);T.else(),h(v),T.endIf(),T.if((0,n._)`${U} !== undefined`,()=>{T.assign(_,U),R(v,U)});function q(D){switch(D){case"string":T.elseIf((0,n._)`${M} == "number" || ${M} == "boolean"`).assign(U,(0,n._)`"" + ${_}`).elseIf((0,n._)`${_} === null`).assign(U,(0,n._)`""`);return;case"number":T.elseIf((0,n._)`${M} == "boolean" || ${_} === null
|
|
19
|
+
|| (${M} == "string" && ${_} && ${_} == +${_})`).assign(U,(0,n._)`+${_}`);return;case"integer":T.elseIf((0,n._)`${M} === "boolean" || ${_} === null
|
|
20
|
+
|| (${M} === "string" && ${_} && ${_} == +${_} && !(${_} % 1))`).assign(U,(0,n._)`+${_}`);return;case"boolean":T.elseIf((0,n._)`${_} === "false" || ${_} === 0 || ${_} === null`).assign(U,!1).elseIf((0,n._)`${_} === "true" || ${_} === 1`).assign(U,!0);return;case"null":T.elseIf((0,n._)`${_} === "" || ${_} === 0 || ${_} === false`),T.assign(U,null);return;case"array":T.elseIf((0,n._)`${M} === "string" || ${M} === "number"
|
|
21
|
+
|| ${M} === "boolean" || ${_} === null`).assign(U,(0,n._)`[${_}]`)}}}function R({gen:v,parentData:z,parentDataProperty:I},T){v.if((0,n._)`${z} !== undefined`,()=>v.assign((0,n._)`${z}[${I}]`,T))}function S(v,z,I,T=i.Correct){let _=T===i.Correct?n.operators.EQ:n.operators.NEQ,C;switch(v){case"null":return(0,n._)`${z} ${_} null`;case"array":C=(0,n._)`Array.isArray(${z})`;break;case"object":C=(0,n._)`${z} && typeof ${z} == "object" && !Array.isArray(${z})`;break;case"integer":C=M((0,n._)`!(${z} % 1) && !isNaN(${z})`);break;case"number":C=M();break;default:return(0,n._)`typeof ${z} ${_} ${v}`}return T===i.Correct?C:(0,n.not)(C);function M(U=n.nil){return(0,n.and)((0,n._)`typeof ${z} == "number"`,U,I?(0,n._)`isFinite(${z})`:n.nil)}}e.checkDataType=S;function P(v,z,I,T){if(v.length===1)return S(v[0],z,I,T);let _,C=(0,a.toHash)(v);if(C.array&&C.object){let M=(0,n._)`typeof ${z} != "object"`;_=C.null?M:(0,n._)`!${z} || ${M}`,delete C.null,delete C.array,delete C.object}else _=n.nil;C.number&&delete C.integer;for(let M in C)_=(0,n.and)(_,S(M,z,I,T));return _}e.checkDataTypes=P;let b={message:({schema:v})=>`must be ${v}`,params:({schema:v,schemaValue:z})=>typeof v=="string"?(0,n._)`{type: ${v}}`:(0,n._)`{type: ${z}}`};function h(v){let z=$(v);(0,o.reportError)(z,b)}e.reportTypeError=h;function $(v){let{gen:z,data:I,schema:T}=v,_=(0,a.schemaRefOrVal)(v,T,"type");return{gen:z,keyword:"type",data:I,schema:T.type,schemaCode:_,schemaValue:_,parentSchema:T,params:{},it:v}}}),OS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;let t=de(),r=ye();function o(a,i){let{properties:l,items:c}=a.schema;if(i==="object"&&l)for(let u in l)n(a,u,l[u].default);else i==="array"&&Array.isArray(c)&&c.forEach((u,m)=>n(a,m,u.default))}e.assignDefaults=o;function n(a,i,l){let{gen:c,compositeRule:u,data:m,opts:f}=a;if(l===void 0)return;let y=(0,t._)`${m}${(0,t.getProperty)(i)}`;if(u){(0,r.checkStrictMode)(a,`default is ignored for: ${y}`);return}let R=(0,t._)`${y} === undefined`;f.useDefaults==="empty"&&(R=(0,t._)`${R} || ${y} === null || ${y} === ""`),c.if(R,(0,t._)`${y} = ${(0,t.stringify)(l)}`)}}),et=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=de(),r=ye(),o=Qe(),n=ye();function a(v,z){let{gen:I,data:T,it:_}=v;I.if(f(I,T,z,_.opts.ownProperties),()=>{v.setParams({missingProperty:(0,t._)`${z}`},!0),v.error()})}e.checkReportMissingProp=a;function i({gen:v,data:z,it:{opts:I}},T,_){return(0,t.or)(...T.map(C=>(0,t.and)(f(v,z,C,I.ownProperties),(0,t._)`${_} = ${C}`)))}e.checkMissingProp=i;function l(v,z){v.setParams({missingProperty:z},!0),v.error()}e.reportMissingProp=l;function c(v){return v.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function u(v,z,I){return(0,t._)`${c(v)}.call(${z}, ${I})`}e.isOwnProperty=u;function m(v,z,I,T){let _=(0,t._)`${z}${(0,t.getProperty)(I)} !== undefined`;return T?(0,t._)`${_} && ${u(v,z,I)}`:_}e.propertyInData=m;function f(v,z,I,T){let _=(0,t._)`${z}${(0,t.getProperty)(I)} === undefined`;return T?(0,t.or)(_,(0,t.not)(u(v,z,I))):_}e.noPropertyInData=f;function y(v){return v?Object.keys(v).filter(z=>z!=="__proto__"):[]}e.allSchemaProperties=y;function R(v,z){return y(z).filter(I=>!(0,r.alwaysValidSchema)(v,z[I]))}e.schemaProperties=R;function S({schemaCode:v,data:z,it:{gen:I,topSchemaRef:T,schemaPath:_,errorPath:C},it:M},U,q,D){let W=D?(0,t._)`${v}, ${z}, ${T}${_}`:z,F=[[o.default.instancePath,(0,t.strConcat)(o.default.instancePath,C)],[o.default.parentData,M.parentData],[o.default.parentDataProperty,M.parentDataProperty],[o.default.rootData,o.default.rootData]];M.opts.dynamicRef&&F.push([o.default.dynamicAnchors,o.default.dynamicAnchors]);let ie=(0,t._)`${W}, ${I.object(...F)}`;return q!==t.nil?(0,t._)`${U}.call(${q}, ${ie})`:(0,t._)`${U}(${ie})`}e.callValidateCode=S;let P=(0,t._)`new RegExp`;function b({gen:v,it:{opts:z}},I){let T=z.unicodeRegExp?"u":"",{regExp:_}=z.code,C=_(I,T);return v.scopeValue("pattern",{key:C.toString(),ref:C,code:(0,t._)`${_.code==="new RegExp"?P:(0,n.useFunc)(v,_)}(${I}, ${T})`})}e.usePattern=b;function h(v){let{gen:z,data:I,keyword:T,it:_}=v,C=z.name("valid");if(_.allErrors){let U=z.let("valid",!0);return M(()=>z.assign(U,!1)),U}return z.var(C,!0),M(()=>z.break()),C;function M(U){let q=z.const("len",(0,t._)`${I}.length`);z.forRange("i",0,q,D=>{v.subschema({keyword:T,dataProp:D,dataPropType:r.Type.Num},C),z.if((0,t.not)(C),U)})}}e.validateArray=h;function $(v){let{gen:z,schema:I,keyword:T,it:_}=v;if(!Array.isArray(I))throw new Error("ajv implementation error");if(I.some(U=>(0,r.alwaysValidSchema)(_,U))&&!_.opts.unevaluated)return;let C=z.let("valid",!1),M=z.name("_valid");z.block(()=>I.forEach((U,q)=>{let D=v.subschema({keyword:T,schemaProp:q,compositeRule:!0},M);z.assign(C,(0,t._)`${C} || ${M}`),v.mergeValidEvaluated(D,M)||z.if((0,t.not)(C))})),v.result(C,()=>v.reset(),()=>v.error(!0))}e.validateUnion=$}),MS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=de(),r=Qe(),o=et(),n=Si();function a(R,S){let{gen:P,keyword:b,schema:h,parentSchema:$,it:v}=R,z=S.macro.call(v.self,h,$,v),I=m(P,b,z);v.opts.validateSchema!==!1&&v.self.validateSchema(z,!0);let T=P.name("valid");R.subschema({schema:z,schemaPath:t.nil,errSchemaPath:`${v.errSchemaPath}/${b}`,topSchemaRef:I,compositeRule:!0},T),R.pass(T,()=>R.error(!0))}e.macroKeywordCode=a;function i(R,S){var P;let{gen:b,keyword:h,schema:$,parentSchema:v,$data:z,it:I}=R;u(I,S);let T=m(b,h,!z&&S.compile?S.compile.call(I.self,$,v,I):S.validate),_=b.let("valid");R.block$data(_,C),R.ok((P=S.valid)!==null&&P!==void 0?P:_);function C(){if(S.errors===!1)q(),S.modifying&&l(R),D(()=>R.error());else{let W=S.async?M():U();S.modifying&&l(R),D(()=>c(R,W))}}function M(){let W=b.let("ruleErrs",null);return b.try(()=>q((0,t._)`await `),F=>b.assign(_,!1).if((0,t._)`${F} instanceof ${I.ValidationError}`,()=>b.assign(W,(0,t._)`${F}.errors`),()=>b.throw(F))),W}function U(){let W=(0,t._)`${T}.errors`;return b.assign(W,null),q(t.nil),W}function q(W=S.async?(0,t._)`await `:t.nil){let F=I.opts.passContext?r.default.this:r.default.self,ie=!("compile"in S&&!z||S.schema===!1);b.assign(_,(0,t._)`${W}${(0,o.callValidateCode)(R,T,F,ie)}`,S.modifying)}function D(W){var F;b.if((0,t.not)((F=S.valid)!==null&&F!==void 0?F:_),W)}}e.funcKeywordCode=i;function l(R){let{gen:S,data:P,it:b}=R;S.if(b.parentData,()=>S.assign(P,(0,t._)`${b.parentData}[${b.parentDataProperty}]`))}function c(R,S){let{gen:P}=R;P.if((0,t._)`Array.isArray(${S})`,()=>{P.assign(r.default.vErrors,(0,t._)`${r.default.vErrors} === null ? ${S} : ${r.default.vErrors}.concat(${S})`).assign(r.default.errors,(0,t._)`${r.default.vErrors}.length`),(0,n.extendErrors)(R)},()=>R.error())}function u({schemaEnv:R},S){if(S.async&&!R.$async)throw new Error("async keyword in sync schema")}function m(R,S,P){if(P===void 0)throw new Error(`keyword "${S}" failed to compile`);return R.scopeValue("keyword",typeof P=="function"?{ref:P}:{ref:P,code:(0,t.stringify)(P)})}function f(R,S,P=!1){return!S.length||S.some(b=>b==="array"?Array.isArray(R):b==="object"?R&&typeof R=="object"&&!Array.isArray(R):typeof R==b||P&&typeof R>"u")}e.validSchemaType=f;function y({schema:R,opts:S,self:P,errSchemaPath:b},h,$){if(Array.isArray(h.keyword)?!h.keyword.includes($):h.keyword!==$)throw new Error("ajv implementation error");let v=h.dependencies;if(v?.some(z=>!Object.prototype.hasOwnProperty.call(R,z)))throw new Error(`parent schema must have dependencies of ${$}: ${v.join(",")}`);if(h.validateSchema&&!h.validateSchema(R[$])){let z=`keyword "${$}" value is invalid at path "${b}": `+P.errorsText(h.validateSchema.errors);if(S.validateSchema==="log")P.logger.error(z);else throw new Error(z)}}e.validateKeywordUsage=y}),NS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=de(),r=ye();function o(i,{keyword:l,schemaProp:c,schema:u,schemaPath:m,errSchemaPath:f,topSchemaRef:y}){if(l!==void 0&&u!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(l!==void 0){let R=i.schema[l];return c===void 0?{schema:R,schemaPath:(0,t._)`${i.schemaPath}${(0,t.getProperty)(l)}`,errSchemaPath:`${i.errSchemaPath}/${l}`}:{schema:R[c],schemaPath:(0,t._)`${i.schemaPath}${(0,t.getProperty)(l)}${(0,t.getProperty)(c)}`,errSchemaPath:`${i.errSchemaPath}/${l}/${(0,r.escapeFragment)(c)}`}}if(u!==void 0){if(m===void 0||f===void 0||y===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:u,schemaPath:m,topSchemaRef:y,errSchemaPath:f}}throw new Error('either "keyword" or "schema" must be passed')}e.getSubschema=o;function n(i,l,{dataProp:c,dataPropType:u,data:m,dataTypes:f,propertyName:y}){if(m!==void 0&&c!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:R}=l;if(c!==void 0){let{errorPath:P,dataPathArr:b,opts:h}=l;S(R.let("data",(0,t._)`${l.data}${(0,t.getProperty)(c)}`,!0)),i.errorPath=(0,t.str)`${P}${(0,r.getErrorPath)(c,u,h.jsPropertySyntax)}`,i.parentDataProperty=(0,t._)`${c}`,i.dataPathArr=[...b,i.parentDataProperty]}m!==void 0&&(S(m instanceof t.Name?m:R.let("data",m,!0)),y!==void 0&&(i.propertyName=y)),f&&(i.dataTypes=f);function S(P){i.data=P,i.dataLevel=l.dataLevel+1,i.dataTypes=[],l.definedProperties=new Set,i.parentData=l.data,i.dataNames=[...l.dataNames,P]}}e.extendSubschemaData=n;function a(i,{jtdDiscriminator:l,jtdMetadata:c,compositeRule:u,createErrors:m,allErrors:f}){u!==void 0&&(i.compositeRule=u),m!==void 0&&(i.createErrors=m),f!==void 0&&(i.allErrors=f),i.jtdDiscriminator=l,i.jtdMetadata=c}e.extendSubschemaMode=a}),am=V((e,t)=>{t.exports=function r(o,n){if(o===n)return!0;if(o&&n&&typeof o=="object"&&typeof n=="object"){if(o.constructor!==n.constructor)return!1;var a,i,l;if(Array.isArray(o)){if(a=o.length,a!=n.length)return!1;for(i=a;i--!==0;)if(!r(o[i],n[i]))return!1;return!0}if(o.constructor===RegExp)return o.source===n.source&&o.flags===n.flags;if(o.valueOf!==Object.prototype.valueOf)return o.valueOf()===n.valueOf();if(o.toString!==Object.prototype.toString)return o.toString()===n.toString();if(l=Object.keys(o),a=l.length,a!==Object.keys(n).length)return!1;for(i=a;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,l[i]))return!1;for(i=a;i--!==0;){var c=l[i];if(!r(o[c],n[c]))return!1}return!0}return o!==o&&n!==n}}),qS=V((e,t)=>{var r=t.exports=function(a,i,l){typeof i=="function"&&(l=i,i={}),l=i.cb||l;var c=typeof l=="function"?l:l.pre||function(){},u=l.post||function(){};o(i,c,u,a,"",a)};r.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},r.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},r.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},r.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 o(a,i,l,c,u,m,f,y,R,S){if(c&&typeof c=="object"&&!Array.isArray(c)){i(c,u,m,f,y,R,S);for(var P in c){var b=c[P];if(Array.isArray(b)){if(P in r.arrayKeywords)for(var h=0;h<b.length;h++)o(a,i,l,b[h],u+"/"+P+"/"+h,m,u,P,c,h)}else if(P in r.propsKeywords){if(b&&typeof b=="object")for(var $ in b)o(a,i,l,b[$],u+"/"+P+"/"+n($),m,u,P,c,$)}else(P in r.keywords||a.allKeys&&!(P in r.skipKeywords))&&o(a,i,l,b,u+"/"+P,m,u,P,c)}l(c,u,m,f,y,R,S)}}function n(a){return a.replace(/~/g,"~0").replace(/\//g,"~1")}}),vi=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=ye(),r=am(),o=qS(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function a(b,h=!0){return typeof b=="boolean"?!0:h===!0?!l(b):h?c(b)<=h:!1}e.inlineRef=a;let i=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function l(b){for(let h in b){if(i.has(h))return!0;let $=b[h];if(Array.isArray($)&&$.some(l)||typeof $=="object"&&l($))return!0}return!1}function c(b){let h=0;for(let $ in b){if($==="$ref")return 1/0;if(h++,!n.has($)&&(typeof b[$]=="object"&&(0,t.eachItem)(b[$],v=>h+=c(v)),h===1/0))return 1/0}return h}function u(b,h="",$){return $!==!1&&(h=y(h)),m(b,b.parse(h))}e.getFullPath=u;function m(b,h){return b.serialize(h).split("#")[0]+"#"}e._getFullPath=m;let f=/#\/?$/;function y(b){return b?b.replace(f,""):""}e.normalizeId=y;function R(b,h,$){return $=y($),b.resolve(h,$)}e.resolveUrl=R;let S=/^[a-z_][-a-z0-9._]*$/i;function P(b,h){if(typeof b=="boolean")return{};let{schemaId:$,uriResolver:v}=this.opts,z=y(b[$]||h),I={"":z},T=u(v,z,!1),_={},C=new Set;return o(b,{allKeys:!0},(q,D,W,F)=>{if(F===void 0)return;let ie=T+D,he=I[F];typeof q[$]=="string"&&(he=ge.call(this,q[$])),_e.call(this,q.$anchor),_e.call(this,q.$dynamicAnchor),I[D]=he;function ge(ue){let O=this.opts.uriResolver.resolve;if(ue=y(he?O(he,ue):ue),C.has(ue))throw U(ue);C.add(ue);let j=this.refs[ue];return typeof j=="string"&&(j=this.refs[j]),typeof j=="object"?M(q,j.schema,ue):ue!==y(ie)&&(ue[0]==="#"?(M(q,_[ue],ue),_[ue]=q):this.refs[ue]=ie),ue}function _e(ue){if(typeof ue=="string"){if(!S.test(ue))throw new Error(`invalid anchor "${ue}"`);ge.call(this,`#${ue}`)}}}),_;function M(q,D,W){if(D!==void 0&&!r(q,D))throw U(W)}function U(q){return new Error(`reference "${q}" resolves to more than one schema`)}}e.getSchemaRefs=P}),Fr=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=AS(),r=yi(),o=sm(),n=yi(),a=OS(),i=MS(),l=NS(),c=de(),u=Qe(),m=vi(),f=ye(),y=Si();function R(k){if(T(k)&&(C(k),I(k))){h(k);return}S(k,()=>(0,t.topBoolOrEmptySchema)(k))}e.validateFunctionCode=R;function S({gen:k,validateName:L,schema:H,schemaEnv:Q,opts:re},oe){re.code.es5?k.func(L,(0,c._)`${u.default.data}, ${u.default.valCxt}`,Q.$async,()=>{k.code((0,c._)`"use strict"; ${v(H,re)}`),b(k,re),k.code(oe)}):k.func(L,(0,c._)`${u.default.data}, ${P(re)}`,Q.$async,()=>k.code(v(H,re)).code(oe))}function P(k){return(0,c._)`{${u.default.instancePath}="", ${u.default.parentData}, ${u.default.parentDataProperty}, ${u.default.rootData}=${u.default.data}${k.dynamicRef?(0,c._)`, ${u.default.dynamicAnchors}={}`:c.nil}}={}`}function b(k,L){k.if(u.default.valCxt,()=>{k.var(u.default.instancePath,(0,c._)`${u.default.valCxt}.${u.default.instancePath}`),k.var(u.default.parentData,(0,c._)`${u.default.valCxt}.${u.default.parentData}`),k.var(u.default.parentDataProperty,(0,c._)`${u.default.valCxt}.${u.default.parentDataProperty}`),k.var(u.default.rootData,(0,c._)`${u.default.valCxt}.${u.default.rootData}`),L.dynamicRef&&k.var(u.default.dynamicAnchors,(0,c._)`${u.default.valCxt}.${u.default.dynamicAnchors}`)},()=>{k.var(u.default.instancePath,(0,c._)`""`),k.var(u.default.parentData,(0,c._)`undefined`),k.var(u.default.parentDataProperty,(0,c._)`undefined`),k.var(u.default.rootData,u.default.data),L.dynamicRef&&k.var(u.default.dynamicAnchors,(0,c._)`{}`)})}function h(k){let{schema:L,opts:H,gen:Q}=k;S(k,()=>{H.$comment&&L.$comment&&F(k),q(k),Q.let(u.default.vErrors,null),Q.let(u.default.errors,0),H.unevaluated&&$(k),M(k),ie(k)})}function $(k){let{gen:L,validateName:H}=k;k.evaluated=L.const("evaluated",(0,c._)`${H}.evaluated`),L.if((0,c._)`${k.evaluated}.dynamicProps`,()=>L.assign((0,c._)`${k.evaluated}.props`,(0,c._)`undefined`)),L.if((0,c._)`${k.evaluated}.dynamicItems`,()=>L.assign((0,c._)`${k.evaluated}.items`,(0,c._)`undefined`))}function v(k,L){let H=typeof k=="object"&&k[L.schemaId];return H&&(L.code.source||L.code.process)?(0,c._)`/*# sourceURL=${H} */`:c.nil}function z(k,L){if(T(k)&&(C(k),I(k))){_(k,L);return}(0,t.boolOrEmptySchema)(k,L)}function I({schema:k,self:L}){if(typeof k=="boolean")return!k;for(let H in k)if(L.RULES.all[H])return!0;return!1}function T(k){return typeof k.schema!="boolean"}function _(k,L){let{schema:H,gen:Q,opts:re}=k;re.$comment&&H.$comment&&F(k),D(k),W(k);let oe=Q.const("_errs",u.default.errors);M(k,oe),Q.var(L,(0,c._)`${oe} === ${u.default.errors}`)}function C(k){(0,f.checkUnknownRules)(k),U(k)}function M(k,L){if(k.opts.jtd)return ge(k,[],!1,L);let H=(0,r.getSchemaTypes)(k.schema);ge(k,H,!(0,r.coerceAndCheckDataType)(k,H),L)}function U(k){let{schema:L,errSchemaPath:H,opts:Q,self:re}=k;L.$ref&&Q.ignoreKeywordsWithRef&&(0,f.schemaHasRulesButRef)(L,re.RULES)&&re.logger.warn(`$ref: keywords ignored in schema at path "${H}"`)}function q(k){let{schema:L,opts:H}=k;L.default!==void 0&&H.useDefaults&&H.strictSchema&&(0,f.checkStrictMode)(k,"default is ignored in the schema root")}function D(k){let L=k.schema[k.opts.schemaId];L&&(k.baseId=(0,m.resolveUrl)(k.opts.uriResolver,k.baseId,L))}function W(k){if(k.schema.$async&&!k.schemaEnv.$async)throw new Error("async schema in sync schema")}function F({gen:k,schemaEnv:L,schema:H,errSchemaPath:Q,opts:re}){let oe=H.$comment;if(re.$comment===!0)k.code((0,c._)`${u.default.self}.logger.log(${oe})`);else if(typeof re.$comment=="function"){let me=(0,c.str)`${Q}/$comment`,Re=k.scopeValue("root",{ref:L.root});k.code((0,c._)`${u.default.self}.opts.$comment(${oe}, ${me}, ${Re}.schema)`)}}function ie(k){let{gen:L,schemaEnv:H,validateName:Q,ValidationError:re,opts:oe}=k;H.$async?L.if((0,c._)`${u.default.errors} === 0`,()=>L.return(u.default.data),()=>L.throw((0,c._)`new ${re}(${u.default.vErrors})`)):(L.assign((0,c._)`${Q}.errors`,u.default.vErrors),oe.unevaluated&&he(k),L.return((0,c._)`${u.default.errors} === 0`))}function he({gen:k,evaluated:L,props:H,items:Q}){H instanceof c.Name&&k.assign((0,c._)`${L}.props`,H),Q instanceof c.Name&&k.assign((0,c._)`${L}.items`,Q)}function ge(k,L,H,Q){let{gen:re,schema:oe,data:me,allErrors:Re,opts:B,self:be}=k,{RULES:X}=be;if(oe.$ref&&(B.ignoreKeywordsWithRef||!(0,f.schemaHasRulesButRef)(oe,X))){re.block(()=>J(k,"$ref",X.all.$ref.definition));return}B.jtd||ue(k,L),re.block(()=>{for(let ne of X.rules)ee(ne);ee(X.post)});function ee(ne){(0,o.shouldUseGroup)(oe,ne)&&(ne.type?(re.if((0,n.checkDataType)(ne.type,me,B.strictNumbers)),_e(k,ne),L.length===1&&L[0]===ne.type&&H&&(re.else(),(0,n.reportTypeError)(k)),re.endIf()):_e(k,ne),Re||re.if((0,c._)`${u.default.errors} === ${Q||0}`))}}function _e(k,L){let{gen:H,schema:Q,opts:{useDefaults:re}}=k;re&&(0,a.assignDefaults)(k,L.type),H.block(()=>{for(let oe of L.rules)(0,o.shouldUseRule)(Q,oe)&&J(k,oe.keyword,oe.definition,L.type)})}function ue(k,L){k.schemaEnv.meta||!k.opts.strictTypes||(O(k,L),k.opts.allowUnionTypes||j(k,L),E(k,k.dataTypes))}function O(k,L){if(L.length){if(!k.dataTypes.length){k.dataTypes=L;return}L.forEach(H=>{g(k.dataTypes,H)||A(k,`type "${H}" not allowed by context "${k.dataTypes.join(",")}"`)}),w(k,L)}}function j(k,L){L.length>1&&!(L.length===2&&L.includes("null"))&&A(k,"use allowUnionTypes to allow union type keyword")}function E(k,L){let H=k.self.RULES.all;for(let Q in H){let re=H[Q];if(typeof re=="object"&&(0,o.shouldUseRule)(k.schema,re)){let{type:oe}=re.definition;oe.length&&!oe.some(me=>p(L,me))&&A(k,`missing type "${oe.join(",")}" for keyword "${Q}"`)}}}function p(k,L){return k.includes(L)||L==="number"&&k.includes("integer")}function g(k,L){return k.includes(L)||L==="integer"&&k.includes("number")}function w(k,L){let H=[];for(let Q of k.dataTypes)g(L,Q)?H.push(Q):L.includes("integer")&&Q==="number"&&H.push("integer");k.dataTypes=H}function A(k,L){let H=k.schemaEnv.baseId+k.errSchemaPath;L+=` at "${H}" (strictTypes)`,(0,f.checkStrictMode)(k,L,k.opts.strictTypes)}var x=class{constructor(k,L,H){if((0,i.validateKeywordUsage)(k,L,H),this.gen=k.gen,this.allErrors=k.allErrors,this.keyword=H,this.data=k.data,this.schema=k.schema[H],this.$data=L.$data&&k.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,f.schemaRefOrVal)(k,this.schema,H,this.$data),this.schemaType=L.schemaType,this.parentSchema=k.schema,this.params={},this.it=k,this.def=L,this.$data)this.schemaCode=k.gen.const("vSchema",fe(this.$data,k));else if(this.schemaCode=this.schemaValue,!(0,i.validSchemaType)(this.schema,L.schemaType,L.allowUndefined))throw new Error(`${H} value must be ${JSON.stringify(L.schemaType)}`);("code"in L?L.trackErrors:L.errors!==!1)&&(this.errsCount=k.gen.const("_errs",u.default.errors))}result(k,L,H){this.failResult((0,c.not)(k),L,H)}failResult(k,L,H){this.gen.if(k),H?H():this.error(),L?(this.gen.else(),L(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(k,L){this.failResult((0,c.not)(k),void 0,L)}fail(k){if(k===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(k),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(k){if(!this.$data)return this.fail(k);let{schemaCode:L}=this;this.fail((0,c._)`${L} !== undefined && (${(0,c.or)(this.invalid$data(),k)})`)}error(k,L,H){if(L){this.setParams(L),this._error(k,H),this.setParams({});return}this._error(k,H)}_error(k,L){(k?y.reportExtraError:y.reportError)(this,this.def.error,L)}$dataError(){(0,y.reportError)(this,this.def.$dataError||y.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,y.resetErrorsCount)(this.gen,this.errsCount)}ok(k){this.allErrors||this.gen.if(k)}setParams(k,L){L?Object.assign(this.params,k):this.params=k}block$data(k,L,H=c.nil){this.gen.block(()=>{this.check$data(k,H),L()})}check$data(k=c.nil,L=c.nil){if(!this.$data)return;let{gen:H,schemaCode:Q,schemaType:re,def:oe}=this;H.if((0,c.or)((0,c._)`${Q} === undefined`,L)),k!==c.nil&&H.assign(k,!0),(re.length||oe.validateSchema)&&(H.elseIf(this.invalid$data()),this.$dataError(),k!==c.nil&&H.assign(k,!1)),H.else()}invalid$data(){let{gen:k,schemaCode:L,schemaType:H,def:Q,it:re}=this;return(0,c.or)(oe(),me());function oe(){if(H.length){if(!(L instanceof c.Name))throw new Error("ajv implementation error");let Re=Array.isArray(H)?H:[H];return(0,c._)`${(0,n.checkDataTypes)(Re,L,re.opts.strictNumbers,n.DataType.Wrong)}`}return c.nil}function me(){if(Q.validateSchema){let Re=k.scopeValue("validate$data",{ref:Q.validateSchema});return(0,c._)`!${Re}(${L})`}return c.nil}}subschema(k,L){let H=(0,l.getSubschema)(this.it,k);(0,l.extendSubschemaData)(H,this.it,k),(0,l.extendSubschemaMode)(H,k);let Q={...this.it,...H,items:void 0,props:void 0};return z(Q,L),Q}mergeEvaluated(k,L){let{it:H,gen:Q}=this;H.opts.unevaluated&&(H.props!==!0&&k.props!==void 0&&(H.props=f.mergeEvaluated.props(Q,k.props,H.props,L)),H.items!==!0&&k.items!==void 0&&(H.items=f.mergeEvaluated.items(Q,k.items,H.items,L)))}mergeValidEvaluated(k,L){let{it:H,gen:Q}=this;if(H.opts.unevaluated&&(H.props!==!0||H.items!==!0))return Q.if(L,()=>this.mergeEvaluated(k,c.Name)),!0}};e.KeywordCxt=x;function J(k,L,H,Q){let re=new x(k,H,L);"code"in H?H.code(re,Q):re.$data&&H.validate?(0,i.funcKeywordCode)(re,H):"macro"in H?(0,i.macroKeywordCode)(re,H):(H.compile||H.validate)&&(0,i.funcKeywordCode)(re,H)}let K=/^\/(?:[^~]|~0|~1)*$/,ce=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function fe(k,{dataLevel:L,dataNames:H,dataPathArr:Q}){let re,oe;if(k==="")return u.default.rootData;if(k[0]==="/"){if(!K.test(k))throw new Error(`Invalid JSON-pointer: ${k}`);re=k,oe=u.default.rootData}else{let be=ce.exec(k);if(!be)throw new Error(`Invalid JSON-pointer: ${k}`);let X=+be[1];if(re=be[2],re==="#"){if(X>=L)throw new Error(B("property/index",X));return Q[L-X]}if(X>L)throw new Error(B("data",X));if(oe=H[L-X],!re)return oe}let me=oe,Re=re.split("/");for(let be of Re)be&&(oe=(0,c._)`${oe}${(0,c.getProperty)((0,f.unescapeJsonPointer)(be))}`,me=(0,c._)`${me} && ${oe}`);return me;function B(be,X){return`Cannot access ${be} ${X} levels up, current level is ${L}`}}e.getData=fe}),Tn=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}};e.default=t}),Gr=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vi();var r=class extends Error{constructor(o,n,a,i){super(i||`can't resolve reference ${a} from id ${n}`),this.missingRef=(0,t.resolveUrl)(o,n,a),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(o,this.missingRef))}};e.default=r}),_i=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=de(),r=Tn(),o=Qe(),n=vi(),a=ye(),i=Fr();var l=class{constructor(h){var $;this.refs={},this.dynamicAnchors={};let v;typeof h.schema=="object"&&(v=h.schema),this.schema=h.schema,this.schemaId=h.schemaId,this.root=h.root||this,this.baseId=($=h.baseId)!==null&&$!==void 0?$:(0,n.normalizeId)(v?.[h.schemaId||"$id"]),this.schemaPath=h.schemaPath,this.localRefs=h.localRefs,this.meta=h.meta,this.$async=v?.$async,this.refs={}}};e.SchemaEnv=l;function c(h){let $=f.call(this,h);if($)return $;let v=(0,n.getFullPath)(this.opts.uriResolver,h.root.baseId),{es5:z,lines:I}=this.opts.code,{ownProperties:T}=this.opts,_=new t.CodeGen(this.scope,{es5:z,lines:I,ownProperties:T}),C;h.$async&&(C=_.scopeValue("Error",{ref:r.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let M=_.scopeName("validate");h.validateName=M;let U={gen:_,allErrors:this.opts.allErrors,data:o.default.data,parentData:o.default.parentData,parentDataProperty:o.default.parentDataProperty,dataNames:[o.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:_.scopeValue("schema",this.opts.code.source===!0?{ref:h.schema,code:(0,t.stringify)(h.schema)}:{ref:h.schema}),validateName:M,ValidationError:C,schema:h.schema,schemaEnv:h,rootId:v,baseId:h.baseId||v,schemaPath:t.nil,errSchemaPath:h.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this},q;try{this._compilations.add(h),(0,i.validateFunctionCode)(U),_.optimize(this.opts.code.optimize);let D=_.toString();q=`${_.scopeRefs(o.default.scope)}return ${D}`,this.opts.code.process&&(q=this.opts.code.process(q,h));let W=new Function(`${o.default.self}`,`${o.default.scope}`,q)(this,this.scope.get());if(this.scope.value(M,{ref:W}),W.errors=null,W.schema=h.schema,W.schemaEnv=h,h.$async&&(W.$async=!0),this.opts.code.source===!0&&(W.source={validateName:M,validateCode:D,scopeValues:_._values}),this.opts.unevaluated){let{props:F,items:ie}=U;W.evaluated={props:F instanceof t.Name?void 0:F,items:ie instanceof t.Name?void 0:ie,dynamicProps:F instanceof t.Name,dynamicItems:ie instanceof t.Name},W.source&&(W.source.evaluated=(0,t.stringify)(W.evaluated))}return h.validate=W,h}catch(D){throw delete h.validate,delete h.validateName,q&&this.logger.error("Error compiling schema, function code:",q),D}finally{this._compilations.delete(h)}}e.compileSchema=c;function u(h,$,v){var z;v=(0,n.resolveUrl)(this.opts.uriResolver,$,v);let I=h.refs[v];if(I)return I;let T=R.call(this,h,v);if(T===void 0){let _=(z=h.localRefs)===null||z===void 0?void 0:z[v],{schemaId:C}=this.opts;_&&(T=new l({schema:_,schemaId:C,root:h,baseId:$}))}if(T!==void 0)return h.refs[v]=m.call(this,T)}e.resolveRef=u;function m(h){return(0,n.inlineRef)(h.schema,this.opts.inlineRefs)?h.schema:h.validate?h:c.call(this,h)}function f(h){for(let $ of this._compilations)if(y($,h))return $}e.getCompilingSchema=f;function y(h,$){return h.schema===$.schema&&h.root===$.root&&h.baseId===$.baseId}function R(h,$){let v;for(;typeof(v=this.refs[$])=="string";)$=v;return v||this.schemas[$]||S.call(this,h,$)}function S(h,$){let v=this.opts.uriResolver.parse($),z=(0,n._getFullPath)(this.opts.uriResolver,v),I=(0,n.getFullPath)(this.opts.uriResolver,h.baseId,void 0);if(Object.keys(h.schema).length>0&&z===I)return b.call(this,v,h);let T=(0,n.normalizeId)(z),_=this.refs[T]||this.schemas[T];if(typeof _=="string"){let C=S.call(this,h,_);return typeof C?.schema!="object"?void 0:b.call(this,v,C)}if(typeof _?.schema=="object"){if(_.validate||c.call(this,_),T===(0,n.normalizeId)($)){let{schema:C}=_,{schemaId:M}=this.opts,U=C[M];return U&&(I=(0,n.resolveUrl)(this.opts.uriResolver,I,U)),new l({schema:C,schemaId:M,root:h,baseId:I})}return b.call(this,v,_)}}e.resolveSchema=S;let P=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function b(h,{baseId:$,schema:v,root:z}){var I;if(((I=h.fragment)===null||I===void 0?void 0:I[0])!=="/")return;for(let C of h.fragment.slice(1).split("/")){if(typeof v=="boolean")return;let M=v[(0,a.unescapeFragment)(C)];if(M===void 0)return;v=M;let U=typeof v=="object"&&v[this.opts.schemaId];!P.has(C)&&U&&($=(0,n.resolveUrl)(this.opts.uriResolver,$,U))}let T;if(typeof v!="boolean"&&v.$ref&&!(0,a.schemaHasRulesButRef)(v,this.RULES)){let C=(0,n.resolveUrl)(this.opts.uriResolver,$,v.$ref);T=S.call(this,z,C)}let{schemaId:_}=this.opts;if(T=T||new l({schema:v,schemaId:_,root:z,baseId:$}),T.schema!==T.root.schema)return T}}),jS=V((e,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}}),im=V((e,t)=>{let r=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),o=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),n=RegExp.prototype.test.bind(/^\d*$/u),a=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),i=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),l=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),u=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),m=new Array(256);{let E="0123456789ABCDEF";for(let p=0;p<256;p++)m[p]="%"+E[p>>4]+E[p&15]}function f(E){return E<2048?m[192|E>>6]+m[128|E&63]:E<65536?m[224|E>>12]+m[128|E>>6&63]+m[128|E&63]:m[240|E>>18]+m[128|E>>12&63]+m[128|E>>6&63]+m[128|E&63]}function y(E){let p="",g=0,w=0;for(w=0;w<E.length;w++)if(g=E[w].charCodeAt(0),g!==48){if(!(g>=48&&g<=57||g>=65&&g<=70||g>=97&&g<=102))return"";p+=E[w];break}for(w+=1;w<E.length;w++){if(g=E[w].charCodeAt(0),!(g>=48&&g<=57||g>=65&&g<=70||g>=97&&g<=102))return"";p+=E[w]}return p}let R=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),S=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),P=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),b=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function h(E){if(E.length===0)return!1;for(let p=0;p<E.length;p++)if(!P(E[p])){if(E[p]==="%"&&p+2<E.length&&a(E.slice(p+1,p+3))){p+=2;continue}return!1}return!0}function $(E){let p=-1,g=0,w=-1,A=0;for(let K=0;K<E.length;K++)E[K]==="0"?(w===-1&&(w=K),A++,A>g&&(g=A,p=w)):(w=-1,A=0);if(g<2)return E.join(":");let x=E.slice(0,p).join(":"),J=E.slice(p+g).join(":");return x+"::"+J}function v(E){let p=E.indexOf("::");if(p!==-1&&E.indexOf("::",p+1)!==-1)return;let g=p===-1?E.split(":"):E.slice(0,p).split(":"),w=p===-1?[]:E.slice(p+2).split(":");p!==-1&&(g.length===1&&g[0]===""&&(g.length=0),w.length===1&&w[0]===""&&(w.length=0));let A=g.concat(w),x=0;for(let K=0;K<A.length;K++){let ce=A[K];if(ce==="")return;if(ce.indexOf(".")!==-1){if(K!==A.length-1||p!==-1&&w.length===0||!o(ce))return;x+=2;continue}if(!R(ce))return;A[K]=parseInt(ce,16).toString(16),x++}if(p===-1)return x!==8?void 0:$(A);if(x>=8)return;let J=A.slice(0,g.length);for(let K=x;K<8;K++)J.push("0");for(let K=g.length;K<A.length;K++)J.push(A[K]);return $(J)}function z(E){let p=E[0]==="["&&E[E.length-1]==="]";if((E[0]==="["||E[E.length-1]==="]")&&!p)return{host:E,isIPV6:!1,error:!0};let g=p?E.slice(1,-1):E;if(p&&S(g))return g=g.toLowerCase(),{host:`[${g}]`,escapedHost:g,isIPV6:!1,isIPVFuture:!0};if(I(g,":")<2)return{host:E,isIPV6:!1,error:p};let w="",A=g.indexOf("%");if(A!==-1){let J=g.slice(A,A+3).toLowerCase()==="%25"?3:1;if(w=g.slice(A+J),!h(w))return{host:E,isIPV6:!1,error:!0};g=g.slice(0,A)}let x=v(g);return x===void 0?{host:E,isIPV6:!1,error:!0}:{host:x+(w?"%"+w:""),escapedHost:x+(w?"%25"+w:""),isIPV6:!0}}function I(E,p){let g=0;for(let w=0;w<E.length;w++)E[w]===p&&g++;return g}function T(E){let p=E,g=[],w=-1,A=0;for(;A=p.length;){if(A===1){if(p===".")break;if(p==="/"){g.push("/");break}else{g.push(p);break}}else if(A===2){if(p[0]==="."){if(p[1]===".")break;if(p[1]==="/"){p=p.slice(2);continue}}else if(p[0]==="/"&&(p[1]==="."||p[1]==="/")){g.push("/");break}}else if(A===3&&p==="/.."){g.length!==0&&g.pop(),g.push("/");break}if(p[0]==="."){if(p[1]==="."){if(p[2]==="/"){p=p.slice(3);continue}}else if(p[1]==="/"){p=p.slice(2);continue}}else if(p[0]==="/"&&p[1]==="."){if(p[2]==="/"){p=p.slice(2);continue}else if(p[2]==="."&&p[3]==="/"){p=p.slice(3),g.length!==0&&g.pop();continue}}if((w=p.indexOf("/",1))===-1){g.push(p);break}else g.push(p.slice(0,w)),p=p.slice(w)}return g.join("")}let _={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},C=/[@/?#:]/g,M=/[@/?#]/g;function U(E,p){let g=p?M:C;return g.lastIndex=0,E.replace(g,w=>_[w])}function q(E,p=!1){if(E.indexOf("%")===-1)return E;let g="";for(let w=0;w<E.length;w++){if(E[w]==="%"&&w+2<E.length){let A=E.slice(w+1,w+3);if(a(A)){let x=A.toUpperCase(),J=String.fromCharCode(parseInt(x,16));p&&i(J)?g+=J:g+="%"+x,w+=2;continue}}g+=E[w]}return g}function D(E){let p="";for(let g=0;g<E.length;g++){let w=E[g];if(w==="%"&&g+2<E.length){let A=E.slice(g+1,g+3);if(a(A)){let x=A.toUpperCase(),J=String.fromCharCode(parseInt(x,16));J!=="."&&i(J)?p+=J:p+="%"+x,g+=2;continue}}if(l(w))p+=w;else{let A=E.charCodeAt(g);if(A<128)p+=_e(A)?w:m[A];else if(A<55296||A>57343)p+=f(A);else if(A<=56319&&g+1<E.length){let x=E.charCodeAt(g+1);x>=56320&&x<=57343?(p+=f(65536+(A-55296<<10)+(x-56320)),g++):p+=f(65533)}else p+=f(65533)}}return p}function W(E,p=!1){let g="",w=p&&E[0]!=="/";for(let A=0;A<E.length;A++){let x=E[A];if(x==="%"&&A+2<E.length){let J=E.slice(A+1,A+3);if(a(J)){g+="%"+J.toUpperCase(),A+=2;continue}}if(x==="/"&&(w=!1),l(x)&&(x!==":"||!w))g+=x;else{let J=E.charCodeAt(A);if(J<128)g+=m[J];else if(J<55296||J>57343)g+=f(J);else if(J<=56319&&A+1<E.length){let K=E.charCodeAt(A+1);K>=56320&&K<=57343?(g+=f(65536+(J-55296<<10)+(K-56320)),A++):g+=f(65533)}else g+=f(65533)}}return g}function F(E,p){let g="";for(let w=0;w<E.length;w++){let A=E[w];if(A==="%"&&w+2<E.length){let x=E.slice(w+1,w+3);if(a(x)){g+="%"+x.toUpperCase(),w+=2;continue}}if(p(A))g+=A;else{let x=E.charCodeAt(w);if(x<128)g+=m[x];else if(x<55296||x>57343)g+=f(x);else if(x<=56319&&w+1<E.length){let J=E.charCodeAt(w+1);J>=56320&&J<=57343?(g+=f(65536+(x-55296<<10)+(J-56320)),w++):g+=f(65533)}else g+=f(65533)}}return g}function ie(E){return F(E,u)}function he(E){return F(E,c)}function ge(E){return F(E,c)}function _e(E){return E>=48&&E<=57||E>=65&&E<=90||E>=97&&E<=122||E===42||E===43||E===45||E===46||E===47||E===64||E===95}function ue(E){let p="";for(let g=0;g<E.length;g++){let w=E[g];if(w==="%"&&g+2<E.length){let A=E.slice(g+1,g+3);if(a(A)){let x=A.toUpperCase(),J=String.fromCharCode(parseInt(x,16));i(J)?p+=J:p+="%"+x,g+=2;continue}}if(c(w))p+=w;else{let A=E.charCodeAt(g);if(A<128)p+=_e(A)?w:m[A];else if(A<55296||A>57343)p+=f(A);else if(A<=56319&&g+1<E.length){let x=E.charCodeAt(g+1);x>=56320&&x<=57343?(p+=f(65536+(A-55296<<10)+(x-56320)),g++):p+=f(65533)}else p+=f(65533)}}return p}function O(E){let p="";for(let g=0;g<E.length;g++){if(E[g]==="%"&&g+2<E.length){let w=E.slice(g+1,g+3);if(a(w)){p+="%"+w.toUpperCase(),g+=2;continue}}p+=escape(E[g])}return p}function j(E){let p=[];if(E.userinfo!==void 0&&(p.push(ie(E.userinfo)),p.push("@")),E.host!==void 0){let g=E.host;if(!o(g)){let w=z(g);w.isIPV6!==!0&&w.isIPVFuture!==!0&&(g=q(g,!0),w=z(g)),w.isIPV6===!0||w.isIPVFuture===!0?g=`[${w.escapedHost}]`:g=U(g,!1)}p.push(g)}if(typeof E.port=="number"||typeof E.port=="string"){let g=String(E.port);if(!n(g))throw new TypeError("URI port is malformed.");p.push(":"),p.push(g)}return p.length?p.join(""):void 0}t.exports={nonSimpleDomain:b,recomposeAuthority:j,reescapeHostDelimiters:U,normalizePercentEncoding:q,normalizePathEncoding:D,serializePathEncoding:W,normalizeQueryFragmentEncoding:ue,encodeUserinfo:ie,encodeQuery:he,encodeFragment:ge,escapePreservingEscapes:O,removeDotSegments:T,isIPv4:o,isUUID:r,normalizeIPv6:z,stringArrayToHexStripped:y}}),LS=V((e,t)=>{let{isUUID:r}=im(),o=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,n=["http","https","ws","wss","urn","urn:uuid"];function a(_){return n.indexOf(_)!==-1}function i(_){return _.secure===!0?!0:_.secure===!1?!1:_.scheme?_.scheme.length===3&&(_.scheme[0]==="w"||_.scheme[0]==="W")&&(_.scheme[1]==="s"||_.scheme[1]==="S")&&(_.scheme[2]==="s"||_.scheme[2]==="S"):!1}function l(_){return _.host||(_.error=_.error||"HTTP URIs must have a host."),_}function c(_){let C=String(_.scheme).toLowerCase()==="https";return(_.port===(C?443:80)||_.port==="")&&(_.port=void 0),_.path||(_.path="/"),_}function u(_){return _.secure=i(_),_.resourceName=(_.path||"/")+(_.query?"?"+_.query:""),_.path=void 0,_.query=void 0,_}function m(_){if((_.port===(i(_)?443:80)||_.port==="")&&(_.port=void 0),typeof _.secure=="boolean"&&(_.scheme=_.secure?"wss":"ws",_.secure=void 0),_.resourceName){let C=_.resourceName.indexOf("?"),M=C===-1?_.resourceName:_.resourceName.slice(0,C);_.path=M&&M!=="/"?M:void 0,_.query=C===-1?void 0:_.resourceName.slice(C+1),_.resourceName=void 0}return _.fragment=void 0,_}function f(_,C){if(!_.path)return _.error="URN can not be parsed",_;let M=_.path.match(o);if(M&&M[0]===_.path){let U=C.scheme||_.scheme||"urn";_.nid=M[1].toLowerCase(),_.nss=M[2];let q=T(`${U}:${C.nid||_.nid}`);_.path=void 0,q&&(_=q.parse(_,C))}else _.error=_.error||"URN can not be parsed.";return _}function y(_,C){if(_.nid===void 0)throw new Error("URN without nid cannot be serialized");let M=C.scheme||_.scheme||"urn",U=_.nid.toLowerCase(),q=T(`${M}:${C.nid||U}`);q&&(_=q.serialize(_,C));let D=_,W=_.nss;return D.path=`${U||C.nid}:${W}`,C.skipEscape=!0,D}function R(_,C){let M=_;return M.uuid=M.nss,M.nss=void 0,!C.tolerant&&(!M.uuid||!r(M.uuid))&&(M.error=M.error||"UUID is not valid."),M}function S(_){let C=_;return C.nss=(_.uuid||"").toLowerCase(),C}let P={scheme:"http",domainHost:!0,parse:l,serialize:c},b={scheme:"https",domainHost:P.domainHost,parse:l,serialize:c},h={scheme:"ws",domainHost:!0,parse:u,serialize:m},$={scheme:"wss",domainHost:h.domainHost,parse:h.parse,serialize:h.serialize},I={http:P,https:b,ws:h,wss:$,urn:{scheme:"urn",parse:f,serialize:y,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:R,serialize:S,skipNormalize:!0}};Object.setPrototypeOf(I,null);function T(_){return _&&(I[_]||I[_.toLowerCase()])||void 0}t.exports={wsIsSecure:i,SCHEMES:I,isValidSchemeName:a,getSchemeHandler:T}}),DS=V((e,t)=>{let{normalizeIPv6:r,removeDotSegments:o,recomposeAuthority:n,normalizePercentEncoding:a,normalizePathEncoding:i,serializePathEncoding:l,normalizeQueryFragmentEncoding:c,encodeQuery:u,encodeFragment:m,reescapeHostDelimiters:f,isIPv4:y,nonSimpleDomain:R}=im(),{SCHEMES:S,getSchemeHandler:P}=LS(),b=/^[A-Za-z][A-Za-z0-9+.-]*$/u,h="URI scheme is malformed.";function $(E){let p=unescape(String(E));if(!b.test(p))throw new TypeError(h);return p}function v(E,p){return typeof E=="string"?E=_e(E,p):typeof E=="object"&&(E=ge(_(E,p),p)),E}function z(E,p,g){let w=g?Object.assign({scheme:"null"},g):{scheme:"null"},{parsed:A,malformedAuthorityOrPort:x,malformedPercentEncoding:J,malformedSchemeSpecific:K,malformedHost:ce,malformedScheme:fe}=he(E,w),{parsed:k,malformedAuthorityOrPort:L,malformedPercentEncoding:H,malformedSchemeSpecific:Q,malformedHost:re,malformedScheme:oe}=he(p,w);if(x||L||J||H||K||Q||ce||re||fe||oe)throw new Error(A.error||k.error||"URI is malformed.");let me=I(A,k,w,!0),Re=P(g&&g.scheme||me.scheme),B=me.host,be=B!==void 0&&B!==""&&(y(B)||r(B).isIPV6);ie(me,g||{},Re,be);let X=B&&B.indexOf("%")!==-1&&!/\P{ASCII}/u.test(B);if(me.error&&!X)throw new Error(me.error);return w.skipEscape=!0,_(me,w)}function I(E,p,g,w){let A={};return w||(E=ge(_(E,g),g),p=ge(_(p,g),g)),g=g||{},!g.tolerant&&p.scheme?(A.scheme=p.scheme,A.userinfo=p.userinfo,A.host=p.host,A.port=p.port,A.path=o(p.path||""),A.query=p.query):(p.userinfo!==void 0||p.host!==void 0||p.port!==void 0?(A.userinfo=p.userinfo,A.host=p.host,A.port=p.port,A.path=o(p.path||""),A.query=p.query):(p.path?(p.path[0]==="/"?A.path=o(p.path):((E.userinfo!==void 0||E.host!==void 0||E.port!==void 0)&&!E.path?A.path="/"+p.path:E.path?A.path=E.path.slice(0,E.path.lastIndexOf("/")+1)+p.path:A.path=p.path,A.path=o(A.path)),A.query=p.query):(A.path=E.path,p.query!==void 0?A.query=p.query:A.query=E.query),A.userinfo=E.userinfo,A.host=E.host,A.port=E.port),A.scheme=E.scheme),A.fragment=p.fragment,A}function T(E,p,g){let w=O(E,g),A=O(p,g);return w!==void 0&&A!==void 0&&w===A}function _(E,p){let g={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:""},w=Object.assign({},p),A=[];g.scheme&&(g.scheme=$(g.scheme));let x=P(w.scheme||g.scheme);x&&x.serialize&&x.serialize(g,w);let J=g.userinfo!==void 0||g.host!==void 0||g.port!==void 0,K=!w.skipEscape&&g.scheme===void 0&&!J;g.path!==void 0&&(w.skipEscape?g.path=a(g.path):g.path=l(g.path,K)),w.reference!=="suffix"&&g.scheme&&(g.scheme=$(g.scheme),A.push(g.scheme,":"));let ce=n(g);if(ce!==void 0&&(w.reference!=="suffix"&&A.push("//"),A.push(ce),g.path&&g.path[0]!=="/"&&A.push("/")),g.path!==void 0){let fe=g.path;!w.absolutePath&&(!x||!x.absolutePath)&&(fe=o(fe)),K&&(fe=l(fe,!0)),ce===void 0&&fe[0]==="/"&&fe[1]==="/"&&(fe="/%2F"+fe.slice(2)),A.push(fe)}return g.query!==void 0&&A.push("?",u(g.query)),g.fragment!==void 0&&A.push("#",m(g.fragment)),A.join("")}let C=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,M=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,U=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function q(E,p){if(p[2]!==void 0&&E.path&&E.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof E.port=="number"&&(E.port<0||E.port>65535))return"URI port is malformed."}function D(E){if(E===void 0)return!1;let p=E.indexOf("%");for(;p!==-1;){if(p+2>=E.length||!/^[\da-f]{2}$/iu.test(E.slice(p+1,p+3)))return!0;p=E.indexOf("%",p+3)}return!1}function W(E){return E[0]==="["&&E[E.length-1]==="]"}function F(E){let p=E[4];return D(E[3])||p!==void 0&&!W(p)&&D(p)||D(E[6])||D(E[7])||D(E[8])}function ie(E,p,g,w){if(!p.unicodeSupport&&(!g||!g.unicodeSupport)&&E.host&&!W(E.host)&&(p.domainHost||g&&g.domainHost)&&w===!1&&R(E.host))try{E.host=new URL("http://"+E.host).hostname}catch(A){return E.error=E.error||"Host's domain name can not be converted to ASCII: "+A,!0}return!1}function he(E,p){let g=Object.assign({},p),w={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},A=!1,x=!1,J=!1,K=!1,ce=!1,fe=!1,k=!1;g.reference==="suffix"&&(g.scheme?E=g.scheme+":"+E:E="//"+E);let L=E.match(M);L!==null&&L[1].indexOf("\\")!==-1&&(w.error="URI authority must not contain a literal backslash.",A=!0);let H=E.match(U);if(H!==null){let re=H[1],oe=re.replace(/[\t\n\r]/g,"");oe.length>=2&&(oe.slice(0,2)!=="//"?(w.error=w.error||"URI authority must not contain a literal backslash.",A=!0):re.length!==oe.length&&(w.error=w.error||"URI authority introducer must not contain whitespace.",A=!0))}let Q=E.match(C);if(Q){if(w.scheme=Q[1],w.userinfo=Q[3],w.host=Q[4],w.port=parseInt(Q[5],10),w.path=Q[6]||"",w.query=Q[7],w.fragment=Q[8],w.scheme!==void 0){let me=unescape(w.scheme);b.test(me)?w.scheme=me.toLowerCase():(w.error=w.error||h,fe=!0)}x=F(Q),x&&(w.error=w.error||"URI contains malformed percent-encoding."),isNaN(w.port)&&(w.port=Q[5]);let re=q(w,Q);if(re!==void 0&&(w.error=w.error||re,A=!0),w.host)if(y(w.host)===!1){let me=W(w.host),Re=w.host.indexOf("[")!==-1||w.host.indexOf("]")!==-1,B=r(w.host);k=B.isIPV6||B.isIPVFuture===!0,ce=Re&&(!me||B.error===!0),w.host=k?B.host:B.host.toLowerCase(),ce&&(w.error=w.error||"URI host is malformed.",A=!0)}else k=!0;w.scheme===void 0&&w.userinfo===void 0&&w.host===void 0&&w.port===void 0&&w.query===void 0&&!w.path?w.reference="same-document":w.scheme===void 0?w.reference="relative":w.fragment===void 0?w.reference="absolute":w.reference="uri",g.reference&&g.reference!=="suffix"&&g.reference!==w.reference&&(w.error=w.error||"URI is not a "+g.reference+" reference.");let oe=P(g.scheme||w.scheme);if(ce||(K=ie(w,g,oe,k)),E.indexOf("%")!==-1&&w.host!==void 0&&!ce){let me=k?w.host:a(w.host,!0);k||(me=a(me.toLowerCase())),w.host=f(me,k)}(!oe||oe&&!oe.skipNormalize)&&(w.path&&(w.path=i(w.path)),w.query&&(w.query=c(w.query)),w.fragment&&(w.fragment=c(w.fragment))),oe&&oe.parse&&(oe.parse(w,g),oe===S.urn&&w.nid===void 0&&(J=!0))}else w.error=w.error||"URI can not be parsed.";return{parsed:w,malformedAuthorityOrPort:A,malformedPercentEncoding:x,malformedSchemeSpecific:J,malformedHost:K,malformedScheme:fe}}function ge(E,p){return he(E,p).parsed}function _e(E,p){return ue(E,p).normalized}function ue(E,p){let{parsed:g,malformedAuthorityOrPort:w,malformedPercentEncoding:A,malformedSchemeSpecific:x,malformedHost:J,malformedScheme:K}=he(E,p);return{normalized:w||A||x||J||K?E:_(g,p),malformedAuthorityOrPort:w,malformedPercentEncoding:A,malformedSchemeSpecific:x,malformedHost:J,malformedScheme:K}}function O(E,p){if(typeof E!="string"&&typeof E!="object")return;let g;try{g=typeof E=="string"?E:_(E,p)}catch{return}let{normalized:w,malformedAuthorityOrPort:A,malformedPercentEncoding:x,malformedSchemeSpecific:J,malformedHost:K,malformedScheme:ce}=ue(g,p);return A||x||J||K||ce?void 0:w}let j={SCHEMES:S,normalize:v,resolve:z,resolveComponent:I,equal:T,serialize:_,parse:ge};t.exports=j,t.exports.default=j,t.exports.fastUri=j}),xS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=DS();t.code='require("ajv/dist/runtime/uri").default',e.default=t}),bl=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Fr();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=de();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});let o=Tn(),n=Gr(),a=nm(),i=_i(),l=de(),c=vi(),u=yi(),m=ye(),f=jS(),y=xS(),R=(O,j)=>new RegExp(O,j);R.code="new RegExp";let S=["removeAdditional","useDefaults","coerceTypes"],P=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),b={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."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function v(O){var j,E,p,g,w,A,x,J,K,ce,fe,k,L,H,Q,re,oe,me,Re,B,be,X,ee,ne,Z;let Y=O.strict,se=(j=O.code)===null||j===void 0?void 0:j.optimize,ae=se===!0||se===void 0?1:se||0,Ee=(p=(E=O.code)===null||E===void 0?void 0:E.regExp)!==null&&p!==void 0?p:R,pt=(g=O.uriResolver)!==null&&g!==void 0?g:y.default;return{strictSchema:(A=(w=O.strictSchema)!==null&&w!==void 0?w:Y)!==null&&A!==void 0?A:!0,strictNumbers:(J=(x=O.strictNumbers)!==null&&x!==void 0?x:Y)!==null&&J!==void 0?J:!0,strictTypes:(ce=(K=O.strictTypes)!==null&&K!==void 0?K:Y)!==null&&ce!==void 0?ce:"log",strictTuples:(k=(fe=O.strictTuples)!==null&&fe!==void 0?fe:Y)!==null&&k!==void 0?k:"log",strictRequired:(H=(L=O.strictRequired)!==null&&L!==void 0?L:Y)!==null&&H!==void 0?H:!1,code:O.code?{...O.code,optimize:ae,regExp:Ee}:{optimize:ae,regExp:Ee},loopRequired:(Q=O.loopRequired)!==null&&Q!==void 0?Q:$,loopEnum:(re=O.loopEnum)!==null&&re!==void 0?re:$,meta:(oe=O.meta)!==null&&oe!==void 0?oe:!0,messages:(me=O.messages)!==null&&me!==void 0?me:!0,inlineRefs:(Re=O.inlineRefs)!==null&&Re!==void 0?Re:!0,schemaId:(B=O.schemaId)!==null&&B!==void 0?B:"$id",addUsedSchema:(be=O.addUsedSchema)!==null&&be!==void 0?be:!0,validateSchema:(X=O.validateSchema)!==null&&X!==void 0?X:!0,validateFormats:(ee=O.validateFormats)!==null&&ee!==void 0?ee:!0,unicodeRegExp:(ne=O.unicodeRegExp)!==null&&ne!==void 0?ne:!0,int32range:(Z=O.int32range)!==null&&Z!==void 0?Z:!0,uriResolver:pt}}var z=class{constructor(O={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,O=this.opts={...O,...v(O)};let{es5:j,lines:E}=this.opts.code;this.scope=new l.ValueScope({scope:{},prefixes:P,es5:j,lines:E}),this.logger=D(O.logger);let p=O.validateFormats;O.validateFormats=!1,this.RULES=(0,a.getRules)(),I.call(this,b,O,"NOT SUPPORTED"),I.call(this,h,O,"DEPRECATED","warn"),this._metaOpts=U.call(this),O.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),O.keywords&&M.call(this,O.keywords),typeof O.meta=="object"&&this.addMetaSchema(O.meta),_.call(this),O.validateFormats=p}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:O,meta:j,schemaId:E}=this.opts,p=f;E==="id"&&(p={...f},p.id=p.$id,delete p.$id),j&&O&&this.addMetaSchema(p,p[E],!1)}defaultMeta(){let{meta:O,schemaId:j}=this.opts;return this.opts.defaultMeta=typeof O=="object"?O[j]||O:void 0}validate(O,j){let E;if(typeof O=="string"){if(E=this.getSchema(O),!E)throw new Error(`no schema with key or ref "${O}"`)}else E=this.compile(O);let p=E(j);return"$async"in E||(this.errors=E.errors),p}compile(O,j){let E=this._addSchema(O,j);return E.validate||this._compileSchemaEnv(E)}compileAsync(O,j){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:E}=this.opts;return p.call(this,O,j);async function p(K,ce){await g.call(this,K.$schema);let fe=this._addSchema(K,ce);return fe.validate||w.call(this,fe)}async function g(K){K&&!this.getSchema(K)&&await p.call(this,{$ref:K},!0)}async function w(K){try{return this._compileSchemaEnv(K)}catch(ce){if(!(ce instanceof n.default))throw ce;return A.call(this,ce),await x.call(this,ce.missingSchema),w.call(this,K)}}function A({missingSchema:K,missingRef:ce}){if(this.refs[K])throw new Error(`AnySchema ${K} is loaded but ${ce} cannot be resolved`)}async function x(K){let ce=await J.call(this,K);this.refs[K]||await g.call(this,ce.$schema),this.refs[K]||this.addSchema(ce,K,j)}async function J(K){let ce=this._loading[K];if(ce)return ce;try{return await(this._loading[K]=E(K))}finally{delete this._loading[K]}}}addSchema(O,j,E,p=this.opts.validateSchema){if(Array.isArray(O)){for(let w of O)this.addSchema(w,void 0,E,p);return this}let g;if(typeof O=="object"){let{schemaId:w}=this.opts;if(g=O[w],g!==void 0&&typeof g!="string")throw new Error(`schema ${w} must be string`)}return j=(0,c.normalizeId)(j||g),this._checkUnique(j),this.schemas[j]=this._addSchema(O,E,j,p,!0),this}addMetaSchema(O,j,E=this.opts.validateSchema){return this.addSchema(O,j,!0,E),this}validateSchema(O,j){if(typeof O=="boolean")return!0;let E;if(E=O.$schema,E!==void 0&&typeof E!="string")throw new Error("$schema must be a string");if(E=E||this.opts.defaultMeta||this.defaultMeta(),!E)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let p=this.validate(E,O);if(!p&&j){let g="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(g);else throw new Error(g)}return p}getSchema(O){let j;for(;typeof(j=T.call(this,O))=="string";)O=j;if(j===void 0){let{schemaId:E}=this.opts,p=new i.SchemaEnv({schema:{},schemaId:E});if(j=i.resolveSchema.call(this,p,O),!j)return;this.refs[O]=j}return j.validate||this._compileSchemaEnv(j)}removeSchema(O){if(O instanceof RegExp)return this._removeAllSchemas(this.schemas,O),this._removeAllSchemas(this.refs,O),this;switch(typeof O){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let j=T.call(this,O);return typeof j=="object"&&this._cache.delete(j.schema),delete this.schemas[O],delete this.refs[O],this}case"object":{let j=O;this._cache.delete(j);let E=O[this.opts.schemaId];return E&&(E=(0,c.normalizeId)(E),delete this.schemas[E],delete this.refs[E]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(O){for(let j of O)this.addKeyword(j);return this}addKeyword(O,j){let E;if(typeof O=="string")E=O,typeof j=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),j.keyword=E);else if(typeof O=="object"&&j===void 0){if(j=O,E=j.keyword,Array.isArray(E)&&!E.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(F.call(this,E,j),!j)return(0,m.eachItem)(E,g=>ie.call(this,g)),this;ge.call(this,j);let p={...j,type:(0,u.getJSONTypes)(j.type),schemaType:(0,u.getJSONTypes)(j.schemaType)};return(0,m.eachItem)(E,p.type.length===0?g=>ie.call(this,g,p):g=>p.type.forEach(w=>ie.call(this,g,p,w))),this}getKeyword(O){let j=this.RULES.all[O];return typeof j=="object"?j.definition:!!j}removeKeyword(O){let{RULES:j}=this;delete j.keywords[O],delete j.all[O];for(let E of j.rules){let p=E.rules.findIndex(g=>g.keyword===O);p>=0&&E.rules.splice(p,1)}return this}addFormat(O,j){return typeof j=="string"&&(j=new RegExp(j)),this.formats[O]=j,this}errorsText(O=this.errors,{separator:j=", ",dataVar:E="data"}={}){return!O||O.length===0?"No errors":O.map(p=>`${E}${p.instancePath} ${p.message}`).reduce((p,g)=>p+j+g)}$dataMetaSchema(O,j){let E=this.RULES.all;O=JSON.parse(JSON.stringify(O));for(let p of j){let g=p.split("/").slice(1),w=O;for(let A of g)w=w[A];for(let A in E){let x=E[A];if(typeof x!="object")continue;let{$data:J}=x.definition,K=w[A];J&&K&&(w[A]=ue(K))}}return O}_removeAllSchemas(O,j){for(let E in O){let p=O[E];(!j||j.test(E))&&(typeof p=="string"?delete O[E]:p&&!p.meta&&(this._cache.delete(p.schema),delete O[E]))}}_addSchema(O,j,E,p=this.opts.validateSchema,g=this.opts.addUsedSchema){let w,{schemaId:A}=this.opts;if(typeof O=="object")w=O[A];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof O!="boolean")throw new Error("schema must be object or boolean")}let x=this._cache.get(O);if(x!==void 0)return x;E=(0,c.normalizeId)(w||E);let J=c.getSchemaRefs.call(this,O,E);return x=new i.SchemaEnv({schema:O,schemaId:A,meta:j,baseId:E,localRefs:J}),this._cache.set(x.schema,x),g&&!E.startsWith("#")&&(E&&this._checkUnique(E),this.refs[E]=x),p&&this.validateSchema(O,!0),x}_checkUnique(O){if(this.schemas[O]||this.refs[O])throw new Error(`schema with key or id "${O}" already exists`)}_compileSchemaEnv(O){if(O.meta?this._compileMetaSchema(O):i.compileSchema.call(this,O),!O.validate)throw new Error("ajv implementation error");return O.validate}_compileMetaSchema(O){let j=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,O)}finally{this.opts=j}}};z.ValidationError=o.default,z.MissingRefError=n.default,e.default=z;function I(O,j,E,p="error"){for(let g in O){let w=g;w in j&&this.logger[p](`${E}: option ${g}. ${O[w]}`)}}function T(O){return O=(0,c.normalizeId)(O),this.schemas[O]||this.refs[O]}function _(){let O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(let j in O)this.addSchema(O[j],j)}function C(){for(let O in this.opts.formats){let j=this.opts.formats[O];j&&this.addFormat(O,j)}}function M(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let j in O){let E=O[j];E.keyword||(E.keyword=j),this.addKeyword(E)}}function U(){let O={...this.opts};for(let j of S)delete O[j];return O}let q={log(){},warn(){},error(){}};function D(O){if(O===!1)return q;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}let W=/^[a-z_$][a-z0-9_$:-]*$/i;function F(O,j){let{RULES:E}=this;if((0,m.eachItem)(O,p=>{if(E.keywords[p])throw new Error(`Keyword ${p} is already defined`);if(!W.test(p))throw new Error(`Keyword ${p} has invalid name`)}),!!j&&j.$data&&!("code"in j||"validate"in j))throw new Error('$data keyword must have "code" or "validate" function')}function ie(O,j,E){var p;let g=j?.post;if(E&&g)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:w}=this,A=g?w.post:w.rules.find(({type:J})=>J===E);if(A||(A={type:E,rules:[]},w.rules.push(A)),w.keywords[O]=!0,!j)return;let x={keyword:O,definition:{...j,type:(0,u.getJSONTypes)(j.type),schemaType:(0,u.getJSONTypes)(j.schemaType)}};j.before?he.call(this,A,x,j.before):A.rules.push(x),w.all[O]=x,(p=j.implements)===null||p===void 0||p.forEach(J=>this.addKeyword(J))}function he(O,j,E){let p=O.rules.findIndex(g=>g.keyword===E);p>=0?O.rules.splice(p,0,j):(O.rules.push(j),this.logger.warn(`rule ${E} is not defined`))}function ge(O){let{metaSchema:j}=O;j!==void 0&&(O.$data&&this.opts.$data&&(j=ue(j)),O.validateSchema=this.compile(j,!0))}let _e={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ue(O){return{anyOf:[O,_e]}}}),HS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};e.default=t}),Rl=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;let t=Gr(),r=et(),o=de(),n=Qe(),a=_i(),i=ye(),l={keyword:"$ref",schemaType:"string",code(m){let{gen:f,schema:y,it:R}=m,{baseId:S,schemaEnv:P,validateName:b,opts:h,self:$}=R,{root:v}=P;if((y==="#"||y==="#/")&&S===v.baseId)return I();let z=a.resolveRef.call($,v,S,y);if(z===void 0)throw new t.default(R.opts.uriResolver,S,y);if(z instanceof a.SchemaEnv)return T(z);return _(z);function I(){if(P===v)return u(m,b,P,P.$async);let C=f.scopeValue("root",{ref:v});return u(m,(0,o._)`${C}.validate`,v,v.$async)}function T(C){u(m,c(m,C),C,C.$async)}function _(C){let M=f.scopeValue("schema",h.code.source===!0?{ref:C,code:(0,o.stringify)(C)}:{ref:C}),U=f.name("valid"),q=m.subschema({schema:C,dataTypes:[],schemaPath:o.nil,topSchemaRef:M,errSchemaPath:y},U);m.mergeEvaluated(q),m.ok(U)}}};function c(m,f){let{gen:y}=m;return f.validate?y.scopeValue("validate",{ref:f.validate}):(0,o._)`${y.scopeValue("wrapper",{ref:f})}.validate`}e.getValidate=c;function u(m,f,y,R){let{gen:S,it:P}=m,{allErrors:b,schemaEnv:h,opts:$}=P,v=$.passContext?n.default.this:o.nil;R?z():I();function z(){if(!h.$async)throw new Error("async schema referenced by sync schema");let C=S.let("valid");S.try(()=>{S.code((0,o._)`await ${(0,r.callValidateCode)(m,f,v)}`),_(f),b||S.assign(C,!0)},M=>{S.if((0,o._)`!(${M} instanceof ${P.ValidationError})`,()=>S.throw(M)),T(M),b||S.assign(C,!1)}),m.ok(C)}function I(){m.result((0,r.callValidateCode)(m,f,v),()=>_(f),()=>T(f))}function T(C){let M=(0,o._)`${C}.errors`;S.assign(n.default.vErrors,(0,o._)`${n.default.vErrors} === null ? ${M} : ${n.default.vErrors}.concat(${M})`),S.assign(n.default.errors,(0,o._)`${n.default.vErrors}.length`)}function _(C){var M;if(!P.opts.unevaluated)return;let U=(M=y?.validate)===null||M===void 0?void 0:M.evaluated;if(P.props!==!0)if(U&&!U.dynamicProps)U.props!==void 0&&(P.props=i.mergeEvaluated.props(S,U.props,P.props));else{let q=S.var("props",(0,o._)`${C}.evaluated.props`);P.props=i.mergeEvaluated.props(S,q,P.props,o.Name)}if(P.items!==!0)if(U&&!U.dynamicItems)U.items!==void 0&&(P.items=i.mergeEvaluated.items(S,U.items,P.items));else{let q=S.var("items",(0,o._)`${C}.evaluated.items`);P.items=i.mergeEvaluated.items(S,q,P.items,o.Name)}}}e.callRef=u,e.default=l}),cm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=HS(),r=Rl(),o=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,r.default];e.default=o}),US=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=t.operators,o={maximum:{okStr:"<=",ok:r.LTE,fail:r.GT},minimum:{okStr:">=",ok:r.GTE,fail:r.LT},exclusiveMaximum:{okStr:"<",ok:r.LT,fail:r.GTE},exclusiveMinimum:{okStr:">",ok:r.GT,fail:r.LTE}},n={keyword:Object.keys(o),type:"number",schemaType:"number",$data:!0,error:{message:({keyword:a,schemaCode:i})=>(0,t.str)`must be ${o[a].okStr} ${i}`,params:({keyword:a,schemaCode:i})=>(0,t._)`{comparison: ${o[a].okStr}, limit: ${i}}`},code(a){let{keyword:i,data:l,schemaCode:c}=a;a.fail$data((0,t._)`${l} ${o[i].fail} ${c} || isNaN(${l})`)}};e.default=n}),VS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:o})=>(0,t.str)`must be multiple of ${o}`,params:({schemaCode:o})=>(0,t._)`{multipleOf: ${o}}`},code(o){let{gen:n,data:a,schemaCode:i,it:l}=o,c=l.opts.multipleOfPrecision,u=n.let("res"),m=c?(0,t._)`Math.abs(Math.round(${u}) - ${u}) > 1e-${c}`:(0,t._)`${u} !== parseInt(${u})`;o.fail$data((0,t._)`(${i} === 0 || (${u} = ${a}/${i}, ${m}))`)}};e.default=r}),BS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(r){let o=r.length,n=0,a=0,i;for(;a<o;)n++,i=r.charCodeAt(a++),i>=55296&&i<=56319&&a<o&&(i=r.charCodeAt(a),(i&64512)===56320&&a++);return n}e.default=t,t.code='require("ajv/dist/runtime/ucs2length").default'}),FS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o=BS(),n={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:a,schemaCode:i}){let l=a==="maxLength"?"more":"fewer";return(0,t.str)`must NOT have ${l} than ${i} characters`},params:({schemaCode:a})=>(0,t._)`{limit: ${a}}`},code(a){let{keyword:i,data:l,schemaCode:c,it:u}=a,m=i==="maxLength"?t.operators.GT:t.operators.LT,f=u.opts.unicode===!1?(0,t._)`${l}.length`:(0,t._)`${(0,r.useFunc)(a.gen,o.default)}(${l})`;a.fail$data((0,t._)`${f} ${m} ${c}`)}};e.default=n}),GS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=et(),r=ye(),o=de(),n={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:a})=>(0,o.str)`must match pattern "${a}"`,params:({schemaCode:a})=>(0,o._)`{pattern: ${a}}`},code(a){let{gen:i,data:l,$data:c,schema:u,schemaCode:m,it:f}=a,y=f.opts.unicodeRegExp?"u":"";if(c){let{regExp:R}=f.opts.code,S=R.code==="new RegExp"?(0,o._)`new RegExp`:(0,r.useFunc)(i,R),P=i.let("valid");i.try(()=>i.assign(P,(0,o._)`${S}(${m}, ${y}).test(${l})`),()=>i.assign(P,!1)),a.fail$data((0,o._)`!${P}`)}else{let R=(0,t.usePattern)(a,u);a.fail$data((0,o._)`!${R}.test(${l})`)}}};e.default=n}),JS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:o,schemaCode:n}){let a=o==="maxProperties"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${n} properties`},params:({schemaCode:o})=>(0,t._)`{limit: ${o}}`},code(o){let{keyword:n,data:a,schemaCode:i}=o,l=n==="maxProperties"?t.operators.GT:t.operators.LT;o.fail$data((0,t._)`Object.keys(${a}).length ${l} ${i}`)}};e.default=r}),KS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=et(),r=de(),o=ye(),n={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:a}})=>(0,r.str)`must have required property '${a}'`,params:({params:{missingProperty:a}})=>(0,r._)`{missingProperty: ${a}}`},code(a){let{gen:i,schema:l,schemaCode:c,data:u,$data:m,it:f}=a,{opts:y}=f;if(!m&&l.length===0)return;let R=l.length>=y.loopRequired;if(f.allErrors?S():P(),y.strictRequired){let $=a.parentSchema.properties,{definedProperties:v}=a.it;for(let z of l)if($?.[z]===void 0&&!v.has(z)){let I=`required property "${z}" is not defined at "${f.schemaEnv.baseId+f.errSchemaPath}" (strictRequired)`;(0,o.checkStrictMode)(f,I,f.opts.strictRequired)}}function S(){if(R||m)a.block$data(r.nil,b);else for(let $ of l)(0,t.checkReportMissingProp)(a,$)}function P(){let $=i.let("missing");if(R||m){let v=i.let("valid",!0);a.block$data(v,()=>h($,v)),a.ok(v)}else i.if((0,t.checkMissingProp)(a,l,$)),(0,t.reportMissingProp)(a,$),i.else()}function b(){i.forOf("prop",c,$=>{a.setParams({missingProperty:$}),i.if((0,t.noPropertyInData)(i,u,$,y.ownProperties),()=>a.error())})}function h($,v){a.setParams({missingProperty:$}),i.forOf($,c,()=>{i.assign(v,(0,t.propertyInData)(i,u,$,y.ownProperties)),i.if((0,r.not)(v),()=>{a.error(),i.break()})},r.nil)}}};e.default=n}),WS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:o,schemaCode:n}){let a=o==="maxItems"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${n} items`},params:({schemaCode:o})=>(0,t._)`{limit: ${o}}`},code(o){let{keyword:n,data:a,schemaCode:i}=o,l=n==="maxItems"?t.operators.GT:t.operators.LT;o.fail$data((0,t._)`${a}.length ${l} ${i}`)}};e.default=r}),wl=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=am();t.code='require("ajv/dist/runtime/equal").default',e.default=t}),YS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=yi(),r=de(),o=ye(),n=wl(),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i,j:l}})=>(0,r.str)`must NOT have duplicate items (items ## ${l} and ${i} are identical)`,params:({params:{i,j:l}})=>(0,r._)`{i: ${i}, j: ${l}}`},code(i){let{gen:l,data:c,$data:u,schema:m,parentSchema:f,schemaCode:y,it:R}=i;if(!u&&!m)return;let S=l.let("valid"),P=f.items?(0,t.getSchemaTypes)(f.items):[];i.block$data(S,b,(0,r._)`${y} === false`),i.ok(S);function b(){let z=l.let("i",(0,r._)`${c}.length`),I=l.let("j");i.setParams({i:z,j:I}),l.assign(S,!0),l.if((0,r._)`${z} > 1`,()=>(h()?$:v)(z,I))}function h(){return P.length>0&&!P.some(z=>z==="object"||z==="array")}function $(z,I){let T=l.name("item"),_=(0,t.checkDataTypes)(P,T,R.opts.strictNumbers,t.DataType.Wrong),C=l.const("indices",(0,r._)`{}`);l.for((0,r._)`;${z}--;`,()=>{l.let(T,(0,r._)`${c}[${z}]`),l.if(_,(0,r._)`continue`),P.length>1&&l.if((0,r._)`typeof ${T} == "string"`,(0,r._)`${T} += "_"`),l.if((0,r._)`typeof ${C}[${T}] == "number"`,()=>{l.assign(I,(0,r._)`${C}[${T}]`),i.error(),l.assign(S,!1).break()}).code((0,r._)`${C}[${T}] = ${z}`)})}function v(z,I){let T=(0,o.useFunc)(l,n.default),_=l.name("outer");l.label(_).for((0,r._)`;${z}--;`,()=>l.for((0,r._)`${I} = ${z}; ${I}--;`,()=>l.if((0,r._)`${T}(${c}[${z}], ${c}[${I}])`,()=>{i.error(),l.assign(S,!1).break(_)})))}}};e.default=a}),XS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o=wl(),n={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:a})=>(0,t._)`{allowedValue: ${a}}`},code(a){let{gen:i,data:l,$data:c,schemaCode:u,schema:m}=a;c||m&&typeof m=="object"?a.fail$data((0,t._)`!${(0,r.useFunc)(i,o.default)}(${l}, ${u})`):a.fail((0,t._)`${m} !== ${l}`)}};e.default=n}),ZS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o=wl(),n={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:a})=>(0,t._)`{allowedValues: ${a}}`},code(a){let{gen:i,data:l,$data:c,schema:u,schemaCode:m,it:f}=a;if(!c&&u.length===0)throw new Error("enum must have non-empty array");let y=u.length>=f.opts.loopEnum,R,S=()=>R??(R=(0,r.useFunc)(i,o.default)),P;if(y||c)P=i.let("valid"),a.block$data(P,b);else{if(!Array.isArray(u))throw new Error("ajv implementation error");let $=i.const("vSchema",m);P=(0,t.or)(...u.map((v,z)=>h($,z)))}a.pass(P);function b(){i.assign(P,!1),i.forOf("v",m,$=>i.if((0,t._)`${S()}(${l}, ${$})`,()=>i.assign(P,!0).break()))}function h($,v){let z=u[v];return typeof z=="object"&&z!==null?(0,t._)`${S()}(${l}, ${$}[${v}])`:(0,t._)`${l} === ${z}`}}};e.default=n}),lm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=US(),r=VS(),o=FS(),n=GS(),a=JS(),i=KS(),l=WS(),c=YS(),u=XS(),m=ZS(),f=[t.default,r.default,o.default,n.default,a.default,i.default,l.default,c.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},u.default,m.default];e.default=f}),um=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;let t=de(),r=ye(),o={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:a}})=>(0,t.str)`must NOT have more than ${a} items`,params:({params:{len:a}})=>(0,t._)`{limit: ${a}}`},code(a){let{parentSchema:i,it:l}=a,{items:c}=i;if(!Array.isArray(c)){(0,r.checkStrictMode)(l,'"additionalItems" is ignored when "items" is not an array of schemas');return}n(a,c)}};function n(a,i){let{gen:l,schema:c,data:u,keyword:m,it:f}=a;f.items=!0;let y=l.const("len",(0,t._)`${u}.length`);if(c===!1)a.setParams({len:i.length}),a.pass((0,t._)`${y} <= ${i.length}`);else if(typeof c=="object"&&!(0,r.alwaysValidSchema)(f,c)){let S=l.var("valid",(0,t._)`${y} <= ${i.length}`);l.if((0,t.not)(S),()=>R(S)),a.ok(S)}function R(S){l.forRange("i",i.length,y,P=>{a.subschema({keyword:m,dataProp:P,dataPropType:r.Type.Num},S),f.allErrors||l.if((0,t.not)(S),()=>l.break())})}}e.validateAdditionalItems=n,e.default=o}),dm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;let t=de(),r=ye(),o=et(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(i){let{schema:l,it:c}=i;if(Array.isArray(l))return a(i,"additionalItems",l);c.items=!0,!(0,r.alwaysValidSchema)(c,l)&&i.ok((0,o.validateArray)(i))}};function a(i,l,c=i.schema){let{gen:u,parentSchema:m,data:f,keyword:y,it:R}=i;b(m),R.opts.unevaluated&&c.length&&R.items!==!0&&(R.items=r.mergeEvaluated.items(u,c.length,R.items));let S=u.name("valid"),P=u.const("len",(0,t._)`${f}.length`);c.forEach((h,$)=>{(0,r.alwaysValidSchema)(R,h)||(u.if((0,t._)`${P} > ${$}`,()=>i.subschema({keyword:y,schemaProp:$,dataProp:$},S)),i.ok(S))});function b(h){let{opts:$,errSchemaPath:v}=R,z=c.length,I=z===h.minItems&&(z===h.maxItems||h[l]===!1);if($.strictTuples&&!I){let T=`"${y}" is ${z}-tuple, but minItems or maxItems/${l} are not specified or different at path "${v}"`;(0,r.checkStrictMode)(R,T,$.strictTuples)}}}e.validateTuple=a,e.default=n}),QS=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=dm(),r={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:o=>(0,t.validateTuple)(o,"items")};e.default=r}),ev=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o=et(),n=um(),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:i}})=>(0,t.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,t._)`{limit: ${i}}`},code(i){let{schema:l,parentSchema:c,it:u}=i,{prefixItems:m}=c;u.items=!0,!(0,r.alwaysValidSchema)(u,l)&&(m?(0,n.validateAdditionalItems)(i,m):i.ok((0,o.validateArray)(i)))}};e.default=a}),tv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:n,max:a}})=>a===void 0?(0,t.str)`must contain at least ${n} valid item(s)`:(0,t.str)`must contain at least ${n} and no more than ${a} valid item(s)`,params:({params:{min:n,max:a}})=>a===void 0?(0,t._)`{minContains: ${n}}`:(0,t._)`{minContains: ${n}, maxContains: ${a}}`},code(n){let{gen:a,schema:i,parentSchema:l,data:c,it:u}=n,m,f,{minContains:y,maxContains:R}=l;u.opts.next?(m=y===void 0?1:y,f=R):m=1;let S=a.const("len",(0,t._)`${c}.length`);if(n.setParams({min:m,max:f}),f===void 0&&m===0){(0,r.checkStrictMode)(u,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(f!==void 0&&m>f){(0,r.checkStrictMode)(u,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0,r.alwaysValidSchema)(u,i)){let v=(0,t._)`${S} >= ${m}`;f!==void 0&&(v=(0,t._)`${v} && ${S} <= ${f}`),n.pass(v);return}u.items=!0;let P=a.name("valid");f===void 0&&m===1?h(P,()=>a.if(P,()=>a.break())):m===0?(a.let(P,!0),f!==void 0&&a.if((0,t._)`${c}.length > 0`,b)):(a.let(P,!1),b()),n.result(P,()=>n.reset());function b(){let v=a.name("_valid"),z=a.let("count",0);h(v,()=>a.if(v,()=>$(z)))}function h(v,z){a.forRange("i",0,S,I=>{n.subschema({keyword:"contains",dataProp:I,dataPropType:r.Type.Num,compositeRule:!0},v),z()})}function $(v){a.code((0,t._)`${v}++`),f===void 0?a.if((0,t._)`${v} >= ${m}`,()=>a.assign(P,!0).break()):(a.if((0,t._)`${v} > ${f}`,()=>a.assign(P,!1).break()),m===1?a.assign(P,!0):a.if((0,t._)`${v} >= ${m}`,()=>a.assign(P,!0)))}}};e.default=o}),El=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=de(),r=ye(),o=et();e.error={message:({params:{property:c,depsCount:u,deps:m}})=>{let f=u===1?"property":"properties";return(0,t.str)`must have ${f} ${m} when property ${c} is present`},params:({params:{property:c,depsCount:u,deps:m,missingProperty:f}})=>(0,t._)`{property: ${c},
|
|
22
|
+
missingProperty: ${f},
|
|
23
|
+
depsCount: ${u},
|
|
24
|
+
deps: ${m}}`};let n={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){let[u,m]=a(c);i(c,u),l(c,m)}};function a({schema:c}){let u={},m={};for(let f in c){if(f==="__proto__")continue;let y=Array.isArray(c[f])?u:m;y[f]=c[f]}return[u,m]}function i(c,u=c.schema){let{gen:m,data:f,it:y}=c;if(Object.keys(u).length===0)return;let R=m.let("missing");for(let S in u){let P=u[S];if(P.length===0)continue;let b=(0,o.propertyInData)(m,f,S,y.opts.ownProperties);c.setParams({property:S,depsCount:P.length,deps:P.join(", ")}),y.allErrors?m.if(b,()=>{for(let h of P)(0,o.checkReportMissingProp)(c,h)}):(m.if((0,t._)`${b} && (${(0,o.checkMissingProp)(c,P,R)})`),(0,o.reportMissingProp)(c,R),m.else())}}e.validatePropertyDeps=i;function l(c,u=c.schema){let{gen:m,data:f,keyword:y,it:R}=c,S=m.name("valid");for(let P in u)(0,r.alwaysValidSchema)(R,u[P])||(m.if((0,o.propertyInData)(m,f,P,R.opts.ownProperties),()=>{let b=c.subschema({keyword:y,schemaProp:P},S);c.mergeValidEvaluated(b,S)},()=>m.var(S,!0)),c.ok(S))}e.validateSchemaDeps=l,e.default=n}),rv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:n})=>(0,t._)`{propertyName: ${n.propertyName}}`},code(n){let{gen:a,schema:i,data:l,it:c}=n;if((0,r.alwaysValidSchema)(c,i))return;let u=a.name("valid");a.forIn("key",l,m=>{n.setParams({propertyName:m}),n.subschema({keyword:"propertyNames",data:m,dataTypes:["string"],propertyName:m,compositeRule:!0},u),a.if((0,t.not)(u),()=>{n.error(!0),c.allErrors||a.break()})}),n.ok(u)}};e.default=o}),pm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=et(),r=de(),o=Qe(),n=ye(),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:i})=>(0,r._)`{additionalProperty: ${i.additionalProperty}}`},code(i){let{gen:l,schema:c,parentSchema:u,data:m,errsCount:f,it:y}=i;if(!f)throw new Error("ajv implementation error");let{allErrors:R,opts:S}=y;if(y.props=!0,S.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(y,c))return;let P=(0,t.allSchemaProperties)(u.properties),b=(0,t.allSchemaProperties)(u.patternProperties);h(),i.ok((0,r._)`${f} === ${o.default.errors}`);function h(){l.forIn("key",m,T=>{!P.length&&!b.length?z(T):l.if($(T),()=>z(T))})}function $(T){let _;if(P.length>8){let C=(0,n.schemaRefOrVal)(y,u.properties,"properties");_=(0,t.isOwnProperty)(l,C,T)}else P.length?_=(0,r.or)(...P.map(C=>(0,r._)`${T} === ${C}`)):_=r.nil;return b.length&&(_=(0,r.or)(_,...b.map(C=>(0,r._)`${(0,t.usePattern)(i,C)}.test(${T})`))),(0,r.not)(_)}function v(T){l.code((0,r._)`delete ${m}[${T}]`)}function z(T){if(S.removeAdditional==="all"||S.removeAdditional&&c===!1){v(T);return}if(c===!1){i.setParams({additionalProperty:T}),i.error(),R||l.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(y,c)){let _=l.name("valid");S.removeAdditional==="failing"?(I(T,_,!1),l.if((0,r.not)(_),()=>{i.reset(),v(T)})):(I(T,_),R||l.if((0,r.not)(_),()=>l.break()))}}function I(T,_,C){let M={keyword:"additionalProperties",dataProp:T,dataPropType:n.Type.Str};C===!1&&Object.assign(M,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(M,_)}}};e.default=a}),ov=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Fr(),r=et(),o=ye(),n=pm(),a={keyword:"properties",type:"object",schemaType:"object",code(i){let{gen:l,schema:c,parentSchema:u,data:m,it:f}=i;f.opts.removeAdditional==="all"&&u.additionalProperties===void 0&&n.default.code(new t.KeywordCxt(f,n.default,"additionalProperties"));let y=(0,r.allSchemaProperties)(c);for(let h of y)f.definedProperties.add(h);f.opts.unevaluated&&y.length&&f.props!==!0&&(f.props=o.mergeEvaluated.props(l,(0,o.toHash)(y),f.props));let R=y.filter(h=>!(0,o.alwaysValidSchema)(f,c[h]));if(R.length===0)return;let S=l.name("valid");for(let h of R)P(h)?b(h):(l.if((0,r.propertyInData)(l,m,h,f.opts.ownProperties)),b(h),f.allErrors||l.else().var(S,!0),l.endIf()),i.it.definedProperties.add(h),i.ok(S);function P(h){return f.opts.useDefaults&&!f.compositeRule&&c[h].default!==void 0}function b(h){i.subschema({keyword:"properties",schemaProp:h,dataProp:h},S)}}};e.default=a}),nv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=et(),r=de(),o=ye(),n=ye(),a={keyword:"patternProperties",type:"object",schemaType:"object",code(i){let{gen:l,schema:c,data:u,parentSchema:m,it:f}=i,{opts:y}=f,R=(0,t.allSchemaProperties)(c),S=R.filter(I=>(0,o.alwaysValidSchema)(f,c[I]));if(R.length===0||S.length===R.length&&(!f.opts.unevaluated||f.props===!0))return;let P=y.strictSchema&&!y.allowMatchingProperties&&m.properties,b=l.name("valid");f.props!==!0&&!(f.props instanceof r.Name)&&(f.props=(0,n.evaluatedPropsToName)(l,f.props));let{props:h}=f;$();function $(){for(let I of R)P&&v(I),f.allErrors?z(I):(l.var(b,!0),z(I),l.if(b))}function v(I){for(let T in P)new RegExp(I).test(T)&&(0,o.checkStrictMode)(f,`property ${T} matches pattern ${I} (use allowMatchingProperties)`)}function z(I){l.forIn("key",u,T=>{l.if((0,r._)`${(0,t.usePattern)(i,I)}.test(${T})`,()=>{let _=S.includes(I);_||i.subschema({keyword:"patternProperties",schemaProp:I,dataProp:T,dataPropType:n.Type.Str},b),f.opts.unevaluated&&h!==!0?l.assign((0,r._)`${h}[${T}]`,!0):!_&&!f.allErrors&&l.if((0,r.not)(b),()=>l.break())})})}}};e.default=a}),sv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ye(),r={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(o){let{gen:n,schema:a,it:i}=o;if((0,t.alwaysValidSchema)(i,a)){o.fail();return}let l=n.name("valid");o.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},l),o.failResult(l,()=>o.reset(),()=>o.error())},error:{message:"must NOT be valid"}};e.default=r}),av=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:et().validateUnion,error:{message:"must match a schema in anyOf"}};e.default=t}),iv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:n})=>(0,t._)`{passingSchemas: ${n.passing}}`},code(n){let{gen:a,schema:i,parentSchema:l,it:c}=n;if(!Array.isArray(i))throw new Error("ajv implementation error");if(c.opts.discriminator&&l.discriminator)return;let u=i,m=a.let("valid",!1),f=a.let("passing",null),y=a.name("_valid");n.setParams({passing:f}),a.block(R),n.result(m,()=>n.reset(),()=>n.error(!0));function R(){u.forEach((S,P)=>{let b;(0,r.alwaysValidSchema)(c,S)?a.var(y,!0):b=n.subschema({keyword:"oneOf",schemaProp:P,compositeRule:!0},y),P>0&&a.if((0,t._)`${y} && ${m}`).assign(m,!1).assign(f,(0,t._)`[${f}, ${P}]`).else(),a.if(y,()=>{a.assign(m,!0),a.assign(f,P),b&&n.mergeEvaluated(b,t.Name)})})}}};e.default=o}),cv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ye(),r={keyword:"allOf",schemaType:"array",code(o){let{gen:n,schema:a,it:i}=o;if(!Array.isArray(a))throw new Error("ajv implementation error");let l=n.name("valid");a.forEach((c,u)=>{if((0,t.alwaysValidSchema)(i,c))return;let m=o.subschema({keyword:"allOf",schemaProp:u},l);o.ok(l),o.mergeEvaluated(m)})}};e.default=r}),lv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:a})=>(0,t.str)`must match "${a.ifClause}" schema`,params:({params:a})=>(0,t._)`{failingKeyword: ${a.ifClause}}`},code(a){let{gen:i,parentSchema:l,it:c}=a;l.then===void 0&&l.else===void 0&&(0,r.checkStrictMode)(c,'"if" without "then" and "else" is ignored');let u=n(c,"then"),m=n(c,"else");if(!u&&!m)return;let f=i.let("valid",!0),y=i.name("_valid");if(R(),a.reset(),u&&m){let P=i.let("ifClause");a.setParams({ifClause:P}),i.if(y,S("then",P),S("else",P))}else u?i.if(y,S("then")):i.if((0,t.not)(y),S("else"));a.pass(f,()=>a.error(!0));function R(){let P=a.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},y);a.mergeEvaluated(P)}function S(P,b){return()=>{let h=a.subschema({keyword:P},y);i.assign(f,y),a.mergeValidEvaluated(h,f),b?i.assign(b,(0,t._)`${P}`):a.setParams({ifClause:P})}}}};function n(a,i){let l=a.schema[i];return l!==void 0&&!(0,r.alwaysValidSchema)(a,l)}e.default=o}),uv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ye(),r={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:o,parentSchema:n,it:a}){n.if===void 0&&(0,t.checkStrictMode)(a,`"${o}" without "if" is ignored`)}};e.default=r}),mm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=um(),r=QS(),o=dm(),n=ev(),a=tv(),i=El(),l=rv(),c=pm(),u=ov(),m=nv(),f=sv(),y=av(),R=iv(),S=cv(),P=lv(),b=uv();function h($=!1){let v=[f.default,y.default,R.default,S.default,P.default,b.default,l.default,c.default,i.default,u.default,m.default];return $?v.push(r.default,n.default):v.push(t.default,o.default),v.push(a.default),v}e.default=h}),dv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:o})=>(0,t.str)`must match format "${o}"`,params:({schemaCode:o})=>(0,t._)`{format: ${o}}`},code(o,n){let{gen:a,data:i,$data:l,schema:c,schemaCode:u,it:m}=o,{opts:f,errSchemaPath:y,schemaEnv:R,self:S}=m;if(!f.validateFormats)return;l?P():b();function P(){let h=a.scopeValue("formats",{ref:S.formats,code:f.code.formats}),$=a.const("fDef",(0,t._)`${h}[${u}]`),v=a.let("fType"),z=a.let("format");a.if((0,t._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>a.assign(v,(0,t._)`${$}.type || "string"`).assign(z,(0,t._)`${$}.validate`),()=>a.assign(v,(0,t._)`"string"`).assign(z,$)),o.fail$data((0,t.or)(I(),T()));function I(){return f.strictSchema===!1?t.nil:(0,t._)`${u} && !${z}`}function T(){let _=R.$async?(0,t._)`(${$}.async ? await ${z}(${i}) : ${z}(${i}))`:(0,t._)`${z}(${i})`,C=(0,t._)`(typeof ${z} == "function" ? ${_} : ${z}.test(${i}))`;return(0,t._)`${z} && ${z} !== true && ${v} === ${n} && !${C}`}}function b(){let h=S.formats[c];if(!h){I();return}if(h===!0)return;let[$,v,z]=T(h);$===n&&o.pass(_());function I(){if(f.strictSchema===!1){S.logger.warn(C());return}throw new Error(C());function C(){return`unknown format "${c}" ignored in schema at path "${y}"`}}function T(C){let M=C instanceof RegExp?(0,t.regexpCode)(C):f.code.formats?(0,t._)`${f.code.formats}${(0,t.getProperty)(c)}`:void 0,U=a.scopeValue("formats",{key:c,ref:C,code:M});return typeof C=="object"&&!(C instanceof RegExp)?[C.type||"string",C.validate,(0,t._)`${U}.validate`]:["string",C,U]}function _(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!R.$async)throw new Error("async format in sync schema");return(0,t._)`await ${z}(${i})`}return typeof v=="function"?(0,t._)`${z}(${i})`:(0,t._)`${z}.test(${i})`}}}};e.default=r}),hm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=[dv().default];e.default=t}),fm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],e.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]}),gm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=cm(),r=lm(),o=mm(),n=hm(),a=fm(),i=[t.default,r.default,(0,o.default)(),n.default,a.metadataVocabulary,a.contentVocabulary];e.default=i}),pv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(r){r.Tag="tag",r.Mapping="mapping"})(t||(e.DiscrError=t={}))}),Tl=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=pv(),o=_i(),n=Gr(),a=ye(),i={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:l,tagName:c}})=>l===r.DiscrError.Tag?`tag "${c}" must be string`:`value of tag "${c}" must be in oneOf`,params:({params:{discrError:l,tag:c,tagName:u}})=>(0,t._)`{error: ${l}, tag: ${u}, tagValue: ${c}}`},code(l){let{gen:c,data:u,schema:m,parentSchema:f,it:y}=l,{oneOf:R}=f;if(!y.opts.discriminator)throw new Error("discriminator: requires discriminator option");let S=m.propertyName;if(typeof S!="string")throw new Error("discriminator: requires propertyName");if(m.mapping)throw new Error("discriminator: mapping is not supported");if(!R)throw new Error("discriminator: requires oneOf keyword");let P=c.let("valid",!1),b=c.const("tag",(0,t._)`${u}${(0,t.getProperty)(S)}`);c.if((0,t._)`typeof ${b} == "string"`,()=>h(),()=>l.error(!1,{discrError:r.DiscrError.Tag,tag:b,tagName:S})),l.ok(P);function h(){let z=v();c.if(!1);for(let I in z)c.elseIf((0,t._)`${b} === ${I}`),c.assign(P,$(z[I]));c.else(),l.error(!1,{discrError:r.DiscrError.Mapping,tag:b,tagName:S}),c.endIf()}function $(z){let I=c.name("valid"),T=l.subschema({keyword:"oneOf",schemaProp:z},I);return l.mergeEvaluated(T,t.Name),I}function v(){var z;let I={},T=C(f),_=!0;for(let q=0;q<R.length;q++){let D=R[q];if(D?.$ref&&!(0,a.schemaHasRulesButRef)(D,y.self.RULES)){let F=D.$ref;if(D=o.resolveRef.call(y.self,y.schemaEnv.root,y.baseId,F),D instanceof o.SchemaEnv&&(D=D.schema),D===void 0)throw new n.default(y.opts.uriResolver,y.baseId,F)}let W=(z=D?.properties)===null||z===void 0?void 0:z[S];if(typeof W!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${S}"`);_=_&&(T||C(D)),M(W,q)}if(!_)throw new Error(`discriminator: "${S}" must be required`);return I;function C({required:q}){return Array.isArray(q)&&q.includes(S)}function M(q,D){if(q.const)U(q.const,D);else if(q.enum)for(let W of q.enum)U(W,D);else throw new Error(`discriminator: "properties/${S}" must have "const" or "enum"`)}function U(q,D){if(typeof q!="string"||q in I)throw new Error(`discriminator: "${S}" values must be unique strings`);I[q]=D}}}};e.default=i}),mv=V((e,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}}),ym=V((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let r=bl(),o=gm(),n=Tl(),a=mv(),i=["/properties"],l="http://json-schema.org/draft-07/schema";var c=class extends r.default{_addVocabularies(){super._addVocabularies(),o.default.forEach(R=>this.addVocabulary(R)),this.opts.discriminator&&this.addKeyword(n.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let R=this.opts.$data?this.$dataMetaSchema(a,i):a;this.addMetaSchema(R,l,!1),this.refs["http://json-schema.org/schema"]=l}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var u=Fr();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var m=de();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return m._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return m.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return m.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return m.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return m.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return m.CodeGen}});var f=Tn();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var y=Gr();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return y.default}})}),Sm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;let t=de(),r=Qe(),o=_i(),n=Rl(),a={keyword:"$dynamicAnchor",schemaType:"string",code:c=>i(c,c.schema)};function i(c,u){let{gen:m,it:f}=c;f.schemaEnv.root.dynamicAnchors[u]=!0;let y=(0,t._)`${r.default.dynamicAnchors}${(0,t.getProperty)(u)}`,R=f.errSchemaPath==="#"?f.validateName:l(c);m.if((0,t._)`!${y}`,()=>m.assign(y,R))}e.dynamicAnchor=i;function l(c){let{schemaEnv:u,schema:m,self:f}=c.it,{root:y,baseId:R,localRefs:S,meta:P}=u.root,{schemaId:b}=f.opts,h=new o.SchemaEnv({schema:m,schemaId:b,root:y,baseId:R,localRefs:S,meta:P});return o.compileSchema.call(f,h),(0,n.getValidate)(c,h)}e.default=a}),vm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;let t=de(),r=Qe(),o=Rl(),n={keyword:"$dynamicRef",schemaType:"string",code:i=>a(i,i.schema)};function a(i,l){let{gen:c,keyword:u,it:m}=i;if(l[0]!=="#")throw new Error(`"${u}" only supports hash fragment reference`);let f=l.slice(1);if(m.allErrors)y();else{let S=c.let("valid",!1);y(S),i.ok(S)}function y(S){if(m.schemaEnv.root.dynamicAnchors[f]){let P=c.let("_v",(0,t._)`${r.default.dynamicAnchors}${(0,t.getProperty)(f)}`);c.if(P,R(P,S),R(m.validateName,S))}else R(m.validateName,S)()}function R(S,P){return P?()=>c.block(()=>{(0,o.callRef)(i,S),c.let(P,!0)}):()=>(0,o.callRef)(i,S)}}e.dynamicRef=a,e.default=n}),hv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Sm(),r=ye(),o={keyword:"$recursiveAnchor",schemaType:"boolean",code(n){n.schema?(0,t.dynamicAnchor)(n,""):(0,r.checkStrictMode)(n.it,"$recursiveAnchor: false is ignored")}};e.default=o}),fv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vm(),r={keyword:"$recursiveRef",schemaType:"string",code:o=>(0,t.dynamicRef)(o,o.schema)};e.default=r}),_m=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Sm(),r=vm(),o=hv(),n=fv(),a=[t.default,r.default,o.default,n.default];e.default=a}),gv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=El(),r={keyword:"dependentRequired",type:"object",schemaType:"object",error:t.error,code:o=>(0,t.validatePropertyDeps)(o)};e.default=r}),yv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=El(),r={keyword:"dependentSchemas",type:"object",schemaType:"object",code:o=>(0,t.validateSchemaDeps)(o)};e.default=r}),Sv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ye(),r={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:o,parentSchema:n,it:a}){n.contains===void 0&&(0,t.checkStrictMode)(a,`"${o}" without "contains" is ignored`)}};e.default=r}),bm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=gv(),r=yv(),o=Sv(),n=[t.default,r.default,o.default];e.default=n}),vv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o=Qe(),n={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:a})=>(0,t._)`{unevaluatedProperty: ${a.unevaluatedProperty}}`},code(a){let{gen:i,schema:l,data:c,errsCount:u,it:m}=a;if(!u)throw new Error("ajv implementation error");let{allErrors:f,props:y}=m;y instanceof t.Name?i.if((0,t._)`${y} !== true`,()=>i.forIn("key",c,b=>i.if(S(y,b),()=>R(b)))):y!==!0&&i.forIn("key",c,b=>y===void 0?R(b):i.if(P(y,b),()=>R(b))),m.props=!0,a.ok((0,t._)`${u} === ${o.default.errors}`);function R(b){if(l===!1){a.setParams({unevaluatedProperty:b}),a.error(),f||i.break();return}if(!(0,r.alwaysValidSchema)(m,l)){let h=i.name("valid");a.subschema({keyword:"unevaluatedProperties",dataProp:b,dataPropType:r.Type.Str},h),f||i.if((0,t.not)(h),()=>i.break())}}function S(b,h){return(0,t._)`!${b} || !${b}[${h}]`}function P(b,h){let $=[];for(let v in b)b[v]===!0&&$.push((0,t._)`${h} !== ${v}`);return(0,t.and)(...$)}}};e.default=n}),_v=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=de(),r=ye(),o={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:n}})=>(0,t.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,t._)`{limit: ${n}}`},code(n){let{gen:a,schema:i,data:l,it:c}=n,u=c.items||0;if(u===!0)return;let m=a.const("len",(0,t._)`${l}.length`);if(i===!1)n.setParams({len:u}),n.fail((0,t._)`${m} > ${u}`);else if(typeof i=="object"&&!(0,r.alwaysValidSchema)(c,i)){let y=a.var("valid",(0,t._)`${m} <= ${u}`);a.if((0,t.not)(y),()=>f(y,u)),n.ok(y)}c.items=!0;function f(y,R){a.forRange("i",R,m,S=>{n.subschema({keyword:"unevaluatedItems",dataProp:S,dataPropType:r.Type.Num},y),c.allErrors||a.if((0,t.not)(y),()=>a.break())})}}};e.default=o}),Rm=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vv(),r=_v(),o=[t.default,r.default];e.default=o}),bv=V((e,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"}]}}}}}),Rv=V((e,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:"#"}}}}}),wv=V((e,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:"#"}}}}),Ev=V((e,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:{}}}}}),Tv=V((e,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"}}}}),$v=V((e,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}}}}),zv=V((e,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:[]}}}}),Pv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=bv(),r=Rv(),o=wv(),n=Ev(),a=Tv(),i=$v(),l=zv(),c=["/properties"];function u(m){return[t,r,o,n,f(this,a),i,f(this,l)].forEach(y=>this.addMetaSchema(y,void 0,!1)),this;function f(y,R){return m?y.$dataMetaSchema(R,c):R}}e.default=u}),Cv=V((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2019=void 0;let r=bl(),o=gm(),n=_m(),a=bm(),i=Rm(),l=Tl(),c=Pv(),u="https://json-schema.org/draft/2019-09/schema";var m=class extends r.default{constructor(P={}){super({...P,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(n.default),o.default.forEach(P=>this.addVocabulary(P)),this.addVocabulary(a.default),this.addVocabulary(i.default),this.opts.discriminator&&this.addKeyword(l.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:P,meta:b}=this.opts;b&&(c.default.call(this,P),this.refs["http://json-schema.org/schema"]=u)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(u)?u:void 0)}};e.Ajv2019=m,t.exports=e=m,t.exports.Ajv2019=m,Object.defineProperty(e,"__esModule",{value:!0}),e.default=m;var f=Fr();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return f.KeywordCxt}});var y=de();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return y._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return y.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return y.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return y.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return y.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return y.CodeGen}});var R=Tn();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return R.default}});var S=Gr();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return S.default}})}),kv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=cm(),r=lm(),o=mm(),n=_m(),a=bm(),i=Rm(),l=hm(),c=fm(),u=[n.default,t.default,r.default,(0,o.default)(!0),l.default,c.metadataVocabulary,c.contentVocabulary,a.default,i.default];e.default=u}),Iv=V((e,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}}}}),Av=V((e,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"}}}}}),Ov=V((e,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"}}}}),Mv=V((e,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"}}}}),Nv=V((e,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"}}}}),qv=V((e,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"}}}}),jv=V((e,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}}}}),Lv=V((e,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:[]}}}}),Dv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Iv(),r=Av(),o=Ov(),n=Mv(),a=Nv(),i=qv(),l=jv(),c=Lv(),u=["/properties"];function m(f){return[t,r,o,n,a,y(this,i),l,y(this,c)].forEach(R=>this.addMetaSchema(R,void 0,!1)),this;function y(R,S){return f?R.$dataMetaSchema(S,u):S}}e.default=m}),xv=V((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2020=void 0;let r=bl(),o=kv(),n=Tl(),a=Dv(),i="https://json-schema.org/draft/2020-12/schema";var l=class extends r.default{constructor(y={}){super({...y,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach(y=>this.addVocabulary(y)),this.opts.discriminator&&this.addKeyword(n.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:y,meta:R}=this.opts;R&&(a.default.call(this,y),this.refs["http://json-schema.org/schema"]=i)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}};e.Ajv2020=l,t.exports=e=l,t.exports.Ajv2020=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var c=Fr();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var u=de();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var m=Tn();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return m.default}});var f=Gr();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return f.default}})}),Hv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(q,D){return{validate:q,compare:D}}e.fullFormats={date:t(a,i),time:t(c(!0),u),"date-time":t(y(!0),R),"iso-time":t(c(),m),"iso-date-time":t(y(),S),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"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:U,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:v,int32:{type:"number",validate:T},int64:{type:"number",validate:_},float:{type:"number",validate:C},double:{type:"number",validate:C},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,i),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,u),"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,R),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),"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,S),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},e.formatNames=Object.keys(e.fullFormats);function r(q){return q%4===0&&(q%100!==0||q%400===0)}let o=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(q){let D=o.exec(q);if(!D)return!1;let W=+D[1],F=+D[2],ie=+D[3];return F>=1&&F<=12&&ie>=1&&ie<=(F===2&&r(W)?29:n[F])}function i(q,D){if(q&&D)return q>D?1:q<D?-1:0}let l=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(q){return function(W){let F=l.exec(W);if(!F)return!1;let ie=+F[1],he=+F[2],ge=+F[3],_e=F[4],ue=F[5]==="-"?-1:1,O=+(F[6]||0),j=+(F[7]||0);if(O>23||j>59||q&&!_e)return!1;if(ie<=23&&he<=59&&ge<60)return!0;let E=he-j*ue,p=ie-O*ue-(E<0?1:0);return(p===23||p===-1)&&(E===59||E===-1)&&ge<61}}function u(q,D){if(!(q&&D))return;let W=new Date("2020-01-01T"+q).valueOf(),F=new Date("2020-01-01T"+D).valueOf();if(W&&F)return W-F}function m(q,D){if(!(q&&D))return;let W=l.exec(q),F=l.exec(D);if(W&&F)return q=W[1]+W[2]+W[3],D=F[1]+F[2]+F[3],q>D?1:q<D?-1:0}let f=/t|\s/i;function y(q){let D=c(q);return function(F){let ie=F.split(f);return ie.length===2&&a(ie[0])&&D(ie[1])}}function R(q,D){if(!(q&&D))return;let W=new Date(q).valueOf(),F=new Date(D).valueOf();if(W&&F)return W-F}function S(q,D){if(!(q&&D))return;let[W,F]=q.split(f),[ie,he]=D.split(f),ge=i(W,ie);if(ge!==void 0)return ge||u(F,he)}let P=/\/|:/,b=/^(?:[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 h(q){return P.test(q)&&b.test(q)}let $=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function v(q){return $.lastIndex=0,$.test(q)}let z=-(2**31),I=2**31-1;function T(q){return Number.isInteger(q)&&q<=I&&q>=z}function _(q){return Number.isInteger(q)}function C(){return!0}let M=/[^\\]\\Z/;function U(q){if(M.test(q))return!1;try{return new RegExp(q),!0}catch{return!1}}}),Uv=V(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;let t=ym(),r=de(),o=r.operators,n={formatMaximum:{okStr:"<=",ok:o.LTE,fail:o.GT},formatMinimum:{okStr:">=",ok:o.GTE,fail:o.LT},formatExclusiveMaximum:{okStr:"<",ok:o.LT,fail:o.GTE},formatExclusiveMinimum:{okStr:">",ok:o.GT,fail:o.LTE}},a={message:({keyword:l,schemaCode:c})=>(0,r.str)`should be ${n[l].okStr} ${c}`,params:({keyword:l,schemaCode:c})=>(0,r._)`{comparison: ${n[l].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(n),type:"string",schemaType:"string",$data:!0,error:a,code(l){let{gen:c,data:u,schemaCode:m,keyword:f,it:y}=l,{opts:R,self:S}=y;if(!R.validateFormats)return;let P=new t.KeywordCxt(y,S.RULES.all.format.definition,"format");P.$data?b():h();function b(){let v=c.scopeValue("formats",{ref:S.formats,code:R.code.formats}),z=c.const("fmt",(0,r._)`${v}[${P.schemaCode}]`);l.fail$data((0,r.or)((0,r._)`typeof ${z} != "object"`,(0,r._)`${z} instanceof RegExp`,(0,r._)`typeof ${z}.compare != "function"`,$(z)))}function h(){let v=P.schema,z=S.formats[v];if(!z||z===!0)return;if(typeof z!="object"||z instanceof RegExp||typeof z.compare!="function")throw new Error(`"${f}": format "${v}" does not define "compare" function`);let I=c.scopeValue("formats",{key:v,ref:z,code:R.code.formats?(0,r._)`${R.code.formats}${(0,r.getProperty)(v)}`:void 0});l.fail$data($(I))}function $(v){return(0,r._)`${v}.compare(${u}, ${m}) ${n[f].fail} 0`}},dependencies:["format"]};let i=l=>(l.addKeyword(e.formatLimitDefinition),l);e.default=i}),Vv=V((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});let r=Hv(),o=Uv(),n=de(),a=new n.Name("fullFormats"),i=new n.Name("fastFormats"),l=(u,m={keywords:!0})=>{if(Array.isArray(m))return c(u,m,r.fullFormats,a),u;let[f,y]=m.mode==="fast"?[r.fastFormats,i]:[r.fullFormats,a];return c(u,m.formats||r.formatNames,f,y),m.keywords&&(0,o.default)(u),u};l.get=(u,m="full")=>{let f=(m==="fast"?r.fastFormats:r.fullFormats)[u];if(!f)throw new Error(`Unknown format "${u}"`);return f};function c(u,m,f,y){var R,S;(R=(S=u.opts.code).formats)!==null&&R!==void 0||(S.formats=(0,n._)`require("ajv-formats/dist/formats").${y}`);for(let P of m)u.addFormat(P,f[P])}t.exports=e=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l}),wm=ym(),Bv=Cv(),Fv=xv(),Gv=ds(Vv(),1),Jv=Gv.default;function _l(e){let t=new e({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Jv(t),t}var bi=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor(e){this._userAjv=e!==void 0,this._ajv=e}get ajv(){return this._ajv??=_l(Fv.Ajv2020)}_engineFor(e){if(this._userAjv)return this.ajv;let t=cs(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??=_l(Bv.Ajv2019):this._ajvDraft7??=_l(wm.Ajv)}getValidator(e){let t=this._engineFor(e),r="$id"in e&&typeof e.$id=="string"?t.getSchema(e.$id)??t.compile(e):t.compile(e);return o=>r(o)?{valid:!0,data:o,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:t.errorsText(r.errors)}}},jw=wm.Ajv;var Am=Symbol.for("mcp.completable");function zl(e){return!!e&&typeof e=="object"&&Am in e}function Wv(e){return e[Am]?.complete}var Jr=15e3,Yv=2**31-1;function zn(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,Yv));return r.unref?.(),r}var Om,Pl=class{static{Om=e=>e._classification}onclose;onerror;onmessage;_classification;_responseMode;_started=!1;_used=!1;_closed=!1;_terminalDelivered=!1;_dispatchWindowOpen=!1;_requestId;_deferredResponse;_sse;_abortCleanup;_keepAliveMs;constructor(e){this._classification=e.classification,this._responseMode=e.responseMode??"auto",this._keepAliveMs=e.keepAliveMs??Jr}async start(){if(this._started)throw new Error("PerRequestHTTPServerTransport is already started");this._started=!0}async handleMessage(e,t){if(this._used)throw new Error("PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request");if(!this._started||this.onmessage===void 0)throw new Error("PerRequestHTTPServerTransport is not connected: connect a server to this transport before handling a message");if(this._closed)throw new Error("PerRequestHTTPServerTransport is closed");this._used=!0;let r=t?.request?.signal;if(r?.aborted)throw await this.close(),new le(pe.ConnectionClosed,"The request was aborted before it could be handled");let o={classification:this._classification,...t?.request!==void 0&&{request:t.request},...t?.authInfo!==void 0&&{authInfo:t.authInfo}};if(Ze(e)){this._requestId=e.id;let n,a,i=new Promise((l,c)=>{n=l,a=c});if(this._deferredResponse={promise:i,resolve:n,reject:a,settled:!1},r!==void 0){let l=()=>void this.close();r.addEventListener("abort",l,{once:!0}),this._abortCleanup=()=>r.removeEventListener("abort",l)}this._dispatchWindowOpen=!0;try{this.onmessage(e,o)}finally{this._dispatchWindowOpen=!1}return this._responseMode==="sse"&&!this._closed&&!this._deferredResponse.settled&&this.upgradeToSse(),i}return this.onmessage(e,o),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let r=ct(e)||lt(e),o=r?e.id:t?.relatedRequestId;if(this._requestId===void 0||o===void 0||o!==this._requestId){r&&this.onerror?.(new Error(`Received a response for an unknown request id: ${String(e.id)}`));return}if(r){if(this._terminalDelivered)return;this._terminalDelivered=!0;let n=lt(e)?e.error.code:void 0,a=n!==void 0&&(this._dispatchWindowOpen||n===G.MissingRequiredClientCapability)?ml[n]:void 0;if(a!==void 0&&this._sse===void 0){this.settleResponse(Response.json(e,{status:a,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}if(this._sse!==void 0||this._responseMode==="sse"){this._sse===void 0&&this.upgradeToSse(),this.writeMessageFrame(e),this.finalizeStream();return}this.settleResponse(Response.json(e,{status:200,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}this._responseMode!=="json"&&(this._sse===void 0&&this.upgradeToSse(),this.writeMessageFrame(e))}writeCommentFrame(e){if(this._closed||this._sse===void 0||this._sse.closed)return;let t=e.split(`
|
|
25
|
+
`).map(r=>`: ${r}`).join(`
|
|
26
|
+
`);this.writeFrame(`${t}
|
|
27
|
+
|
|
28
|
+
`)}async close(){if(!this._closed){if(this._closed=!0,this._abortCleanup?.(),this._abortCleanup=void 0,this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),this._sse!==void 0&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}this._deferredResponse!==void 0&&!this._deferredResponse.settled&&(this._deferredResponse.settled=!0,this._deferredResponse.reject(new le(pe.ConnectionClosed,"Connection closed before a response was produced"))),this.onclose?.()}}settleResponse(e){this._deferredResponse===void 0||this._deferredResponse.settled||(this._deferredResponse.settled=!0,this._deferredResponse.resolve(e))}upgradeToSse(){let e,t=new ReadableStream({start:r=>{e=r},cancel:()=>{this.close()}});this._sse={controller:e,encoder:new TextEncoder,closed:!1},this._sse.keepAliveTimer=zn(this._keepAliveMs,()=>this.writeCommentFrame("keepalive")),this.settleResponse(new Response(t,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}))}finalizeStream(){if(this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),this._sse!==void 0&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}queueMicrotask(()=>void this.close())}writeMessageFrame(e){this.writeFrame(`event: message
|
|
29
|
+
data: ${JSON.stringify(e)}
|
|
30
|
+
|
|
31
|
+
`)}writeFrame(e){if(!(this._sse===void 0||this._sse.closed))try{this._sse.controller.enqueue(this._sse.encoder.encode(e))}catch(t){this.onerror?.(new Error(`Failed to write to the response stream: ${t}`))}}};function Xv(e){return e instanceof Pl?Om(e):void 0}function Ri(e){return e.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function Em(e,t,r,o){let n=`Bearer error="${Ri(e)}", error_description="${Ri(t)}"`;return r.length>0&&(n+=`, scope="${Ri(r.join(" "))}"`),o&&(n+=`, resource_metadata="${Ri(o)}"`),n}function Mm(e,t){let{requiredScopes:r=[],resourceMetadataUrl:o}=t??{};if(!(e instanceof vn)){let n=new vn(cr.ServerError,"Internal Server Error");return Response.json(n.toResponseObject(),{status:500})}switch(e.code){case cr.InvalidToken:{let n=Em(e.code,e.message,r,o);return Response.json(e.toResponseObject(),{status:401,headers:{"WWW-Authenticate":n}})}case cr.InsufficientScope:{let n=Em(e.code,e.message,r,o);return Response.json(e.toResponseObject(),{status:403,headers:{"WWW-Authenticate":n}})}case cr.ServerError:return Response.json(e.toResponseObject(),{status:500});default:return Response.json(e.toResponseObject(),{status:400})}}function Nm(e){let t=new URL(e);return t.pathname=Zv(e),t.hash="",t.href}function Zv(e){let t=Qv(e.pathname);return`/.well-known/oauth-protected-resource${t==="/"?"":t}`}function Qv(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function e_(e){return typeof e=="object"&&e!==null&&"setScopeChallengeResolver"in e&&typeof e.setScopeChallengeResolver=="function"}function t_(e,t){if(typeof e!="string"||!/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(e))throw new TypeError(`${t} must satisfy the OAuth scope-token grammar`)}function r_(e){if(e===null||typeof e!="object"||!Array.isArray(e.scopes)||e.scopes.length===0)throw new TypeError("scope challenge must contain at least one scope");for(let[t,r]of e.scopes.entries())t_(r,`scope challenge scopes[${t}]`);if(e.errorDescription!==void 0&&typeof e.errorDescription!="string")throw new TypeError("scope challenge errorDescription must be a string");if(e.errorDescription!==void 0&&!/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(e.errorDescription))throw new TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");return e}async function Cl(e,t,r){for(let o of e){let n=await r({request:o,...t!==void 0&&{authInfo:t}});if(n!==void 0)return r_(n)}}function kl(e){if(e?.resourceMetadataUrl!==void 0)return e.resourceMetadataUrl;if(e?.resource?.protocol==="https:"||e?.resource?.protocol==="http:")return Nm(e.resource)}function Il(e,t){return Mm(new vn(cr.InsufficientScope,e.errorDescription??"Insufficient scope"),{requiredScopes:[...e.scopes],resourceMetadataUrl:t})}var o_=8,n_=6e5;function s_(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw new RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw new RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??o_,roundTimeoutMs:e?.roundTimeoutMs??n_,legacyShim:e?.legacyShim??!0}}function qm(e,t,r){if(r===null||typeof r!="object"||typeof r.method!="string")throw new te(G.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 o=r,n=_p(o);if(n===void 0)throw new te(G.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${o.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:o,required:n}}function a_(){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 r=[...t].map(o=>o.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function $l(e,t){if(e==="tools/call")return{content:[{type:"text",text:t}],isError:!0};throw new te(G.InternalError,t)}var i_=class{constructor(e){this._host=e}async fulfill(e,t,r,o,n){let{maxRounds:a,roundTimeoutMs:i}=this._host,l=o.mcpReq.signal,c=n,u=0;for(;;){if(u+=1,u>a)return $l(e,Kp(e,a));let m=c.inputRequests,f=m!=null&&Object.keys(m).length>0,y=typeof c.requestState=="string"?c.requestState:void 0;if(!f&&y===void 0)throw new te(G.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 R;if(f){let b=this._host.resolvedClientCapabilities(o),h=[];for(let[v,z]of Object.entries(m)){let{embedded:I,required:T}=qm(e,v,z);if(I.method!=="roots/list"&&I.params===void 0)throw new te(G.InternalError,`Handler for ${e} returned an input request '${v}' of kind '${I.method}' without params`);if(_n(T,b)!==void 0)return $l(e,`Cannot request input '${v}' (${I.method}): the client on this 2025-era connection did not declare the required capability${b===void 0?" (no client capabilities are available on this connection \u2014 per-request legacy serving cannot receive server-to-client requests)":""}`);h.push([v,I])}let $=Yp(l);try{let v={relatedRequestId:o.mcpReq.id,timeout:i,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:$.signal},z=await Promise.all(h.map(async([I,T])=>{try{return[I,await this._dispatchLeg(T,v)]}catch(_){throw $.abort(_),_}}));R=Object.fromEntries(z)}catch(v){if(l.aborted)throw v;return $l(e,`Fulfilling input required by '${e}' failed: ${v instanceof Error?v.message:String(v)}`)}finally{$.dispose()}}else await Wp(Jp,l);let S={...o,mcpReq:{...o.mcpReq,inputResponses:R,droppedInputResponseKeys:void 0,requestState:wn(y)}};if(y!==void 0){let b=await this._host.verifyRequestState(y,S,e);b!==void 0&&(S=fl(S,b))}let P=await t(r,S);if(!yt(P))return P;c=P}}async _dispatchLeg(e,t){switch(e.method){case"elicitation/create":{let r=e.params;return r.mode==="url"&&r.elicitationId===void 0&&(r={...r,elicitationId:a_()}),await this._host.sendElicitation(r,t)}case"sampling/createMessage":return await this._host.sendSampling(e.params,t);case"roots/list":return await this._host.listRoots(e.params,t)}}},c_=new Set(["tools/call","prompts/get","resources/read"]),jm,Lm,Dm;function xm(e,t){jm(e,t)}function Hm(e,t){Lm(e,t)}function Um(e){return Dm(e)}var wi=class extends gl{_clientCapabilities;_clientVersion;static{jm=(e,t)=>{t.clientCapabilities!==void 0&&(e._clientCapabilities=t.clientCapabilities),t.clientInfo!==void 0&&(e._clientVersion=t.clientInfo)},Lm=(e,t)=>{let r=t.filter(o=>!e._supportedProtocolVersions.includes(o));r.length>0&&(e._supportedProtocolVersions=[...e._supportedProtocolVersions,...r]),e.setRequestHandler("server/discover",()=>e._ondiscover())},Dm=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_boundFromTransport=!1;_legacyInputRequiredShim(){return this._legacyShim??=new i_({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,r)=>this._verifyRequestState(e,t,r),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){if(super(t),this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new bi,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=s_(t?.inputRequired),t?.cacheHints!==void 0){for(let[r,o]of Object.entries(t.cacheHints))o!==void 0&&al(o,`cacheHints['${r}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",r=>this._oninitialize(r)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),si(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}async connect(e){if(this.transport!==void 0)throw new le(pe.AlreadyConnected,"Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");this._boundFromTransport&&(this._boundFromTransport=!1,this._negotiatedProtocolVersion=void 0);let t=Xv(e)?.revision;t!==void 0&&!this._servedModernEra()&&lr.includes(t)&&si(this._supportedProtocolVersions).includes(t)&&(this._negotiatedProtocolVersion=t,this._boundFromTransport=!0),await super.connect(e)}_registerLoggingHandler(){this.setRequestHandler("logging/setLevel",async(e,t)=>{let r=t.sessionId||t.http?.req?.headers.get("mcp-session-id")||void 0,{level:o}=e.params,n=mi(Nt,o);return n.success&&this._loggingLevels.set(r,n.data),{}})}buildContext(e,t){let r=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(o,n,a)=>{if(!this._capabilities.logging)return Promise.resolve();let i;if(this._servedModernEra()){if(i=e.mcpReq.envelope?.[Ct],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(o)<this.LOG_LEVEL_SEVERITY.get(i)?Promise.resolve():e.mcpReq.notify({method:"notifications/message",params:{level:o,data:n,logger:a}})},elicitInput:(o,n)=>this.elicitInput(o,n),requestSampling:(o,n)=>this.createMessage(o,n)},http:r?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(Nt.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let r=this._loggingLevels.get(t);return r?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(r):!1};registerCapabilities(e){if(this.transport)throw new le(pe.AlreadyConnected,"Cannot register capabilities after connecting to transport");let t=!!this._capabilities.logging;this._capabilities=yl(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if(e!=="tools/call"){let r=this._cacheHints?.[e],o=c_.has(e);return r===void 0&&!o?async(n,a)=>{let i=await t(n,a);if(yt(i))throw new te(G.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(n,a)=>{let i=o?await this._invokeInputRequiredCapableHandler(e,t,n,a):await t(n,a);if(yt(i)){if(!o)throw new te(G.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}return r===void 0?i:ai(i,r)}}return async(r,o)=>{let n=ft(this._negotiatedProtocolVersion),a=n.validateRequest("tools/call",r);if(!a.ok)throw new te(a.reason==="not-in-era"?G.InternalError:G.InvalidParams,a.reason==="not-in-era"?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${a.message}`);let i=await this._invokeInputRequiredCapableHandler("tools/call",t,r,o);if(yt(i))return i;let l=tl(i),c=n.validateResult("tools/call",l);if(!c.ok)throw new te(c.reason==="not-in-era"?G.InternalError:G.InvalidParams,c.reason==="not-in-era"?"No wire schema for tools/call in the resolved era":`Invalid tools/call result: ${c.message}`);return c.value}}_servedModernEra(){return this._negotiatedProtocolVersion!==void 0&>(this._negotiatedProtocolVersion)}async _invokeInputRequiredCapableHandler(e,t,r,o){let n=this._servedModernEra(),a=o.mcpReq.requestState();if(a!==void 0&&typeof a!="string")throw new te(G.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let i=o;if(typeof a=="string"){let f=await this._verifyRequestState(a,o,e);f!==void 0&&(i=fl(o,f))}let l;try{l=await t(r,i)}catch(f){throw f instanceof te&&f.code===G.UrlElicitationRequired&&n?new te(G.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { \u2026: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`):f}if(!yt(l))return l;if(!n){if(!this._inputRequiredServing.legacyShim)throw new te(G.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??rr}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,r,i,l)}let c=l.inputRequests,u=c!=null&&Object.keys(c).length>0,m=typeof l.requestState=="string";if(!u&&!m)throw new te(G.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(u){let f=this._inputRequestCapabilityView(o);for(let[y,R]of Object.entries(c)){let{embedded:S,required:P}=qm(e,y,R),b=_n(P,f);if(b!==void 0)throw new bn({requiredCapabilities:b},`Cannot request input '${y}' (${S.method}): the request's client capabilities do not declare the required capability`)}}return l}async _verifyRequestState(e,t,r){if(this._requestStateVerify!==void 0)try{return await this._requestStateVerify(e,t)}catch(o){throw this.onerror?.(new Error(`requestState verification rejected ${r}: ${o instanceof Error?o.message:String(o)}`)),new te(G.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[it]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new le(pe.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 \u2014 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 le(pe.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new le(pe.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new le(pe.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 le(pe.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 le(pe.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new le(pe.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 le(pe.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 le(pe.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 le(pe.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new le(pe.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new le(pe.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 le(pe.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new le(pe.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 r=Rp(this._supportedProtocolVersions),o=r.includes(t)?t:r[0]??rr;return this._negotiatedProtocolVersion=o,this.transport?.setProtocolVersion?.(o),{protocolVersion:o,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:si(this._supportedProtocolVersions),capabilities:l_(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 le(pe.CapabilityNotSupported,"Client does not support sampling tools capability.");if(e.messages.length>0){let a=e.messages.at(-1),i=Array.isArray(a.content)?a.content:[a.content],l=i.some(f=>f.type==="tool_result"),c=e.messages.length>1?e.messages.at(-2):void 0,u=c?Array.isArray(c.content)?c.content:[c.content]:[],m=u.some(f=>f.type==="tool_use");if(l){if(i.some(f=>f.type!=="tool_result"))throw new te(G.InvalidParams,"The last message must contain only tool_result content if any is present");if(!m)throw new te(G.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(m){let f=new Set(u.filter(R=>R.type==="tool_use").map(R=>R.id)),y=new Set(i.filter(R=>R.type==="tool_result").map(R=>R.toolUseId));if(f.size!==y.size||![...f].every(R=>y.has(R)))throw new te(G.InvalidParams,"ids of tool_result blocks and tool_use blocks from previous message do not match")}}let r=!!(e.tools||e.toolChoice),o=await this.request({method:"sampling/createMessage",params:e},t),n=this._wireCodec().samplingResultVariant(r,o);if(!n.ok)throw new le(pe.InvalidResult,`Invalid sampling/createMessage result: ${n.reason==="invalid"?n.message:n.reason}`);return n.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra("elicitation/create"),e.mode??"form"){case"url":if(!this._clientCapabilities?.elicitation?.url)throw new le(pe.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new le(pe.CapabilityNotSupported,"Client does not support form elicitation.");break}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,r){let o=e.mode??"form",n=r?.validateAcceptedContent??!0;switch(o){case"url":{let a=e;return this.request({method:"elicitation/create",params:a},t)}case"form":{let a=e.mode==="form"?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:a},t);if(n&&i.action==="accept"&&i.content&&a.requestedSchema)try{let l=this._jsonSchemaValidator.getValidator(a.requestedSchema)(i.content);if(!l.valid)throw new te(G.InvalidParams,`Elicitation response content does not match requested schema: ${l.errorMessage}`)}catch(l){throw l instanceof te?l:new te(G.InternalError,`Error validating elicitation response: ${l instanceof Error?l.message:String(l)}`)}return i}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new le(pe.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 l_(e){return{...e}}function u_(e,t){let r=0,o=[e];for(;o.length>0;){let n=o.pop();if(!(n===null||typeof n!="object"))if(Array.isArray(n))for(let a of n){if(++r>t)return r;a!==null&&typeof a=="object"&&o.push(a)}else for(let a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;if(++r>t)return r;let i=n[a];i!==null&&typeof i=="object"&&o.push(i)}}return r}function d_(e){if(!(e===void 0||e===1/0)){if(typeof e!="number"||Number.isNaN(e)||e<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}var Ei=class{server;_maxToolInputElements;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(!(t===void 0||!t.enabled)){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(t.inputSchema===void 0)return $m;try{let r=ur(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new wi(e,t),this._maxToolInputElements=d_(t?.maxToolInputElements),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return e_(e)&&e.setScopeChallengeResolver(t=>this.resolveScopeChallenge(t)),await this.server.connect(e)}async close(){await this.server.close()}resolveScopeChallenge=e=>{switch(e.request.method){case"tools/call":{let t=e.request.params?.name;if(typeof t!="string")return;let r=this._registeredTools[t];return r===void 0||!r.enabled?void 0:r.scopeChallenge?.(e)}case"resources/read":{let t=e.request.params?.uri;if(typeof t!="string")return;let r;try{r=new URL(t)}catch{return}let o=this._registeredResources[r.toString()];if(o!==void 0)return o.enabled?o.scopeChallenge?.(e):void 0;for(let n of Object.values(this._registeredResourceTemplates))if(n.resourceTemplate.uriTemplate.match(r.toString()))return n.enabled?n.scopeChallenge?.(e):void 0;return}case"prompts/get":{let t=e.request.params?.name;if(typeof t!="string")return;let r=this._registeredPrompts[t];return r===void 0||!r.enabled?void 0:r.scopeChallenge?.(e)}default:return}};_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler("tools/list"),this.server.assertCanSetRequestHandler("tools/call"),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler("tools/list",()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let r={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?p_(e,t.inputSchema):$m,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(r.outputSchema=ur(t.outputSchema,"output")),r})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new te(G.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new te(G.InvalidParams,`Tool ${e.params.name} disabled`);try{let o=await this.validateToolInput(r,e.params.arguments,e.params.name),n=await this.executeToolHandler(r,o,t);return await this.validateToolOutput(r,n,e.params.name),yt(n)?n:this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(o){if(o instanceof te&&o.code===G.UrlElicitationRequired)throw o;return this.createToolError(o instanceof Error?o.message:String(o))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,r){if(this._maxToolInputElements!==void 0&&u_(t,this._maxToolInputElements)>this._maxToolInputElements)throw new te(G.InvalidParams,`Invalid arguments for tool ${r}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let o=await ir(e.inputSchema,t??{});if(!o.success)throw new te(G.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${o.error}`);return o.data}async validateToolOutput(e,t,r){if(!e.outputSchema||yt(t)||t.isError)return;if(t.structuredContent===void 0)throw new te(G.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let o=await ir(e.outputSchema,t.structuredContent);if(!o.success)throw new te(G.InvalidParams,`Output validation error: Invalid structured content for tool ${r}: ${o.error}`)}async executeToolHandler(e,t,r){return e.executor(t,r)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler("completion/complete"),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler("completion/complete",async e=>{switch(e.params.ref.type){case"ref/prompt":return dl(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return pl(e),this.handleResourceCompletion(e,e.params.ref);default:throw new te(G.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let r=this._registeredPrompts[t.name];if(!r)throw new te(G.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new te(G.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return $n;let o=Im(km(r.argsSchema)?.[e.params.argument.name]);if(!zl(o))return $n;let n=Wv(o);return n?Cm(await n(e.params.argument.value,e.params.context)):$n}async handleResourceCompletion(e,t){let r=Object.values(this._registeredResourceTemplates).find(n=>n.resourceTemplate.uriTemplate.toString()===t.uri);if(!r){if(this._registeredResources[t.uri])return $n;throw new te(G.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=r.resourceTemplate.completeCallback(e.params.argument.name);return o?Cm(await o(e.params.argument.value,e.params.context)):$n}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler("resources/list"),this.server.assertCanSetRequestHandler("resources/templates/list"),this.server.assertCanSetRequestHandler("resources/read"),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler("resources/list",async(e,t)=>{let r=Object.entries(this._registeredResources).filter(([n,a])=>a.enabled).map(([n,a])=>({uri:n,name:a.name,...a.metadata})),o=[];for(let n of Object.values(this._registeredResourceTemplates)){if(!n.resourceTemplate.listCallback)continue;let a=await n.resourceTemplate.listCallback(t);for(let i of a.resources)o.push({...n.metadata,...i})}return{resources:[...r,...o]}}),this.server.setRequestHandler("resources/templates/list",async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler("resources/read",async(e,t)=>{let r;try{r=new URL(e.params.uri)}catch{throw new te(G.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:"invalid_uri"})}let o=this._registeredResources[r.toString()];if(o){if(!o.enabled)throw new te(G.InvalidParams,`Resource ${r} disabled`);return ai(await o.readCallback(r,t),o.cacheHint)}for(let n of Object.values(this._registeredResourceTemplates)){let a=n.resourceTemplate.uriTemplate.match(r.toString());if(a){if(!n.enabled)throw new te(G.InvalidParams,`Resource template ${n.resourceTemplate.uriTemplate} disabled`);return ai(await n.readCallback(r,a,t),n.cacheHint)}}throw new ii(e.params.uri)}),this._resourceHandlersInitialized=!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler("prompts/list"),this.server.assertCanSetRequestHandler("prompts/get"),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler("prompts/list",()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?Gp(t.argsSchema):void 0,icons:t.icons,_meta:t._meta}))})),this.server.setRequestHandler("prompts/get",async(e,t)=>{let r=this._registeredPrompts[e.params.name];if(!r)throw new te(G.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new te(G.InvalidParams,`Prompt ${e.params.name} disabled`);return r.handler(e.params.arguments,t)}),this._promptHandlersInitialized=!0)}registerResource(e,t,r,o){let{cacheHint:n,scopeChallenge:a,...i}=r,l=i;if(n!==void 0&&al(n,`resource ${e}`),typeof t=="string"){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);let c=this._createRegisteredResource(e,r.title,t,l,a,o);return n!==void 0&&(c.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),c}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let c=this._createRegisteredResourceTemplate(e,r.title,t,l,a,o);return n!==void 0&&(c.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),c}}_createRegisteredResource(e,t,r,o,n,a){let i={name:e,title:t,metadata:o,readCallback:a,scopeChallenge:n,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:l=>{l.uri!==void 0&&l.uri!==r&&(delete this._registeredResources[r],l.uri&&(this._registeredResources[l.uri]=i)),l.name!==void 0&&(i.name=l.name),l.metadata!==void 0&&(i.metadata=l.metadata),l.title!==void 0&&(i.title=l.title,i.metadata={...i.metadata,title:l.title}),l.callback!==void 0&&(i.readCallback=l.callback),l.scopeChallenge!==void 0&&(i.scopeChallenge=l.scopeChallenge===null?void 0:l.scopeChallenge),l.enabled!==void 0&&(i.enabled=l.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=i,i}_createRegisteredResourceTemplate(e,t,r,o,n,a){let i={resourceTemplate:r,title:t,metadata:o,readCallback:a,scopeChallenge:n,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:c=>{c.name!==void 0&&c.name!==e&&(delete this._registeredResourceTemplates[e],c.name&&(this._registeredResourceTemplates[c.name]=i)),c.template!==void 0&&(i.resourceTemplate=c.template),c.metadata!==void 0&&(i.metadata=c.metadata),c.title!==void 0&&(i.title=c.title,i.metadata={...i.metadata,title:c.title}),c.callback!==void 0&&(i.readCallback=c.callback),c.scopeChallenge!==void 0&&(i.scopeChallenge=c.scopeChallenge===null?void 0:c.scopeChallenge),c.enabled!==void 0&&(i.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let l=r.uriTemplate.variableNames;return Array.isArray(l)&&l.some(c=>!!r.completeCallback(c))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,t,r,o,n,a,i,l){let c=o,u=n,m={title:t,description:r,argsSchema:o,icons:a,scopeChallenge:i,_meta:l,handler:Pm(e,o,n),enabled:!0,disable:()=>m.update({enabled:!1}),enable:()=>m.update({enabled:!0}),remove:()=>m.update({name:null}),update:f=>{f.name!==void 0&&f.name!==e&&(delete this._registeredPrompts[e],f.name&&(this._registeredPrompts[f.name]=m)),f.title!==void 0&&(m.title=f.title),f.description!==void 0&&(m.description=f.description),f.icons!==void 0&&(m.icons=f.icons),f.scopeChallenge!==void 0&&(m.scopeChallenge=f.scopeChallenge===null?void 0:f.scopeChallenge),f._meta!==void 0&&(m._meta=f._meta);let y=!1;f.argsSchema!==void 0&&(m.argsSchema=f.argsSchema,c=f.argsSchema,y=!0),f.callback!==void 0&&(u=f.callback,y=!0),y&&(m.handler=Pm(e,c,u)),f.enabled!==void 0&&(m.enabled=f.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=m,o){let f=km(o);f&&Object.values(f).some(y=>zl(Im(y)))&&this.setCompletionRequestHandler()}return m}_createRegisteredTool(e,t,r,o,n,a,i,l,c,u,m){vl(e);let f=m,y,R={title:t,description:r,inputSchema:o,outputSchema:n,get outputSchemaJson(){return y??=zm(R.outputSchema)},set outputSchemaJson(S){y=S},annotations:a,icons:i,execution:l,scopeChallenge:c,_meta:u,handler:m,executor:Tm(o,m),enabled:!0,disable:()=>R.update({enabled:!1}),enable:()=>R.update({enabled:!0}),remove:()=>R.update({name:null}),update:S=>{S.name!==void 0&&S.name!==e&&(typeof S.name=="string"&&vl(S.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],S.name&&(delete this._toolInputSchemaJson[S.name],this._registeredTools[S.name]=R,e=S.name)),S.title!==void 0&&(R.title=S.title),S.description!==void 0&&(R.description=S.description);let P=!1;S.paramsSchema!==void 0&&(R.inputSchema=S.paramsSchema,delete this._toolInputSchemaJson[e],P=!0),S.callback!==void 0&&(R.handler=S.callback,f=S.callback,P=!0),P&&(R.executor=Tm(R.inputSchema,f)),S.outputSchema!==void 0&&(R.outputSchema=S.outputSchema,R.outputSchemaJson=zm(S.outputSchema)),S.annotations!==void 0&&(R.annotations=S.annotations),S.icons!==void 0&&(R.icons=S.icons),S.scopeChallenge!==void 0&&(R.scopeChallenge=S.scopeChallenge===null?void 0:S.scopeChallenge),S._meta!==void 0&&(R._meta=S._meta),S.enabled!==void 0&&(R.enabled=S.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=R,this.setToolRequestHandlers(),this.sendToolListChanged(),R}registerTool(e,t,r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:n,inputSchema:a,outputSchema:i,annotations:l,icons:c,scopeChallenge:u,_meta:m}=t;return this._createRegisteredTool(e,o,n,hi(a),hi(i),l,c,void 0,u,m,r)}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:n,argsSchema:a,icons:i,scopeChallenge:l,_meta:c}=t,u=this._createRegisteredPrompt(e,o,n,hi(a),r,i,l,c);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),u}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 Tm(e,t){if(e){let o=t;return async(n,a)=>o(n,a)}let r=t;return async(o,n)=>r(n)}var $m={type:"object",properties:{}};function p_(e,t){let r=ur(t,"input"),o=di(r);return o.valid||console.warn(`[mcp-sdk] tool '${e}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${o.reason}`),r}function zm(e){if(e!==void 0)try{return ur(e,"output")}catch{return}}function Pm(e,t,r){if(t){let o=r;return async(n,a)=>{let i=await ir(t,n??{});if(!i.success)throw new te(G.InvalidParams,`Invalid arguments for prompt ${e}: ${i.error}`);return o(i.data,a)}}else{let o=r;return async(n,a)=>o(a)}}function Cm(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}var $n={completion:{values:[],hasMore:!1}};function km(e){let t=e;if(t.shape&&typeof t.shape=="object")return t.shape}function m_(e){return e?.type==="optional"}function Im(e){return m_(e)?e.def?.innerType??e:e}var Fm=class{_listeners=new Set;constructor(e){this.onerror=e}publish(e){for(let t of this._listeners)try{t(e)}catch(r){this.onerror?.(r instanceof Error?r:new Error(String(r)))}}subscribe(e){this._listeners.add(e);let t=!0;return()=>{t&&(t=!1,this._listeners.delete(e))}}get listenerCount(){return this._listeners.size}};function Gm(e){return{toolsChanged:()=>e.publish({kind:"tools_list_changed"}),promptsChanged:()=>e.publish({kind:"prompts_list_changed"}),resourcesChanged:()=>e.publish({kind:"resources_list_changed"}),resourceUpdated:t=>e.publish({kind:"resource_updated",uri:t})}}function h_(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 f_(e,t){let r={},o=n=>t===void 0||n===!0;return e.toolsListChanged===!0&&o(t?.tools?.listChanged)&&(r.toolsListChanged=!0),e.promptsListChanged===!0&&o(t?.prompts?.listChanged)&&(r.promptsListChanged=!0),e.resourcesListChanged===!0&&o(t?.resources?.listChanged)&&(r.resourcesListChanged=!0),e.resourceSubscriptions!==void 0&&e.resourceSubscriptions.length>0&&o(t?.resources?.subscribe)&&(r.resourceSubscriptions=[...e.resourceSubscriptions]),r}function g_(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed",...e.params!==void 0&&{params:e.params}};case"prompts_list_changed":return{method:"notifications/prompts/list_changed",...e.params!==void 0&&{params:e.params}};case"resources_list_changed":return{method:"notifications/resources/list_changed",...e.params!==void 0&&{params:e.params}};case"resource_updated":return{method:"notifications/resources/updated",params:{...e.params,uri:e.uri}}}}var Al=1024;function Vm(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function Bm(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[nr]:t}}}}function y_(e){let t=ft(Rn).validateRequest("subscriptions/listen",e);return t.ok?t.value.params?.notifications:void 0}function Jm(e){let{bus:t,onerror:r}=e,o=e.maxSubscriptions??Al,n=e.keepAliveMs??Jr,a=new Set;function i(l,c,u,m){if(a.size>=o)return r?.(new Error(`subscriptions/listen refused: subscription limit reached (${o})`)),Vm(l.id,-32603,"Subscription limit reached");let f=y_(l);if(f===void 0)return Vm(l.id,-32602,"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");let y=f_(f,u),R=l.id,S=new TextEncoder,P,b=!1,h,$,v,z=C=>{if(!b)try{P.enqueue(S.encode(C))}catch(M){r?.(M instanceof Error?M:new Error(String(M)))}},I=(C,M)=>{z(`event: message
|
|
32
|
+
data: ${JSON.stringify({jsonrpc:"2.0",method:C,params:M})}
|
|
33
|
+
|
|
34
|
+
`)},T=C=>{if(!b){C&&z(`event: message
|
|
35
|
+
data: ${JSON.stringify({jsonrpc:"2.0",id:R,result:{resultType:"complete",_meta:{[nr]:R,[at]:m}}})}
|
|
36
|
+
|
|
37
|
+
`),b=!0;try{h?.()}catch(M){r?.(M instanceof Error?M:new Error(String(M)))}$!==void 0&&clearInterval($),v?.(),a.delete(T);try{P.close()}catch{}}},_=new ReadableStream({start(C){P=C;let M=Bm({method:"notifications/subscriptions/acknowledged",params:{notifications:y}},R);if(I(M.method,M.params),Object.keys(y).length===0){T(!0);return}h=t.subscribe(U=>{if(b||!h_(y,U))return;let q=Bm(g_(U),R);I(q.method,q.params)}),$=zn(n,()=>z(`: keepalive
|
|
38
|
+
|
|
39
|
+
`)),a.add(T)},cancel(){T(!1)}});if(c!==void 0)if(c.aborted)T(!1);else{let C=()=>T(!1);c.addEventListener("abort",C,{once:!0}),v=()=>c.removeEventListener("abort",C)}return new Response(_,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})}return{serve:i,closeAll(){for(let l of a)l(!0)},get openCount(){return a.size}}}async function S_(e,t,r){let o=new Pl({classification:r.classification,...r.responseMode!==void 0&&{responseMode:r.responseMode},...r.keepAliveMs!==void 0&&{keepAliveMs:r.keepAliveMs}});return await e.connect(o),o.handleMessage(t,{...r.request!==void 0&&{request:r.request},...r.authInfo!==void 0&&{authInfo:r.authInfo}})}var Ml=4*1024*1024,Ol=100;function Wm(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function Nl(e){if(e===void 0)return Ml;if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(e)}`);return e}async function $i(e,t=Ml){if(Number(e.headers.get("content-length"))>t)return{tooLarge:!0};if(e.body===null)return{tooLarge:!1,text:""};let r=e.body.getReader(),o=new TextDecoder,n=0,a="";try{for(;;){let{done:i,value:l}=await r.read();if(i)break;if(n+=l.byteLength,n>t)return{tooLarge:!0};a+=o.decode(l,{stream:!0})}}finally{r.releaseLock()}return{tooLarge:!1,text:a+o.decode()}}var ql=class{sessionIdGenerator;_started=!1;_hasHandledRequest=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId="_GET_stream";_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;_maxRequestBodySize;_scopeChallengeResolver;sessionId;onclose;onerror;onmessage;constructor(e={}){this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval,this._supportedProtocolVersions=e.supportedProtocolVersions??Do,this._keepAliveMs=e.keepAliveMs??Jr,this._maxRequestBodySize=Nl(e.maxRequestBodySize)}startKeepAlive(e,t){if(this._closed)return;let r=zn(this._keepAliveMs,()=>{try{e.enqueue(t.encode(`: keepalive
|
|
40
|
+
|
|
41
|
+
`))}catch{r!==void 0&&clearInterval(r)}});return r}setScopeChallengeResolver(e){this._scopeChallengeResolver=e}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}setSupportedProtocolVersions(e){this._supportedProtocolVersions=e}createJsonErrorResponse(e,t,r,o){let n={code:t,message:r};return o?.data!==void 0&&(n.data=o.data),Response.json({jsonrpc:"2.0",error:n,id:null},{status:e,headers:{"Content-Type":"application/json",...o?.headers}})}async _checkScopeChallenge(e,t){if(!this._scopeChallengeResolver)return;let r=await Cl(e.filter(o=>Ze(o)),t,this._scopeChallengeResolver);return r===void 0?void 0:Il(r,kl(t))}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let t=e.headers.get("host");if(!t||!this._allowedHosts.includes(t)){let r=`Invalid Host header: ${t}`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(403,-32e3,r)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let t=e.headers.get("origin");if(t&&!this._allowedOrigins.includes(t)){let r=`Invalid Origin header: ${t}`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(403,-32e3,r)}}}}async handleRequest(e,t){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let r=this.validateRequestHeaders(e);if(r)return r;switch(e.method){case"POST":return this.handlePostRequest(e,t);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(e){return this._supportedProtocolVersions.includes(e)&&e>="2025-11-25"}async writePrimingEvent(e,t,r,o){if(!this._eventStore||!this.supportsEmptySSEData(o))return;let n=await this._eventStore.storeEvent(r,{}),a=`id: ${n}
|
|
42
|
+
data:
|
|
43
|
+
|
|
44
|
+
`;this._retryInterval!==void 0&&(a=`id: ${n}
|
|
45
|
+
retry: ${this._retryInterval}
|
|
46
|
+
data:
|
|
47
|
+
|
|
48
|
+
`),e.enqueue(t.encode(a))}async handleGetRequest(e){if(!e.headers.get("accept")?.includes("text/event-stream"))return this.onerror?.(new 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 r=this.validateProtocolVersion(e);if(r)return r;if(this._eventStore){let c=e.headers.get("last-event-id");if(c)return this.replayEvents(c)}if(this._streamMapping.get(this._standaloneSseStreamId)!==void 0)return this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session")),this.createJsonErrorResponse(409,-32e3,"Conflict: Only one SSE stream is allowed per session");let o=new TextEncoder,n,a,i=new ReadableStream({start:c=>{n=c},cancel:()=>{a!==void 0&&clearInterval(a),this._streamMapping.get(this._standaloneSseStreamId)?.controller===n&&this._streamMapping.delete(this._standaloneSseStreamId)}}),l={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};return this.sessionId!==void 0&&(l["mcp-session-id"]=this.sessionId),this._streamMapping.set(this._standaloneSseStreamId,{controller:n,encoder:o,cleanup:()=>{a!==void 0&&clearInterval(a),this._streamMapping.delete(this._standaloneSseStreamId);try{n.close()}catch{}}}),a=this.startKeepAlive(n,o),new Response(i,{headers:l})}async replayEvents(e){if(!this._eventStore)return this.onerror?.(new 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?.(new Error("Invalid event ID format")),this.createJsonErrorResponse(400,-32e3,"Invalid event ID format");if(this._streamMapping.get(t)!==void 0)return this.onerror?.(new Error("Conflict: Stream already has an active connection")),this.createJsonErrorResponse(409,-32e3,"Conflict: Stream already has an active connection")}let r={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};this.sessionId!==void 0&&(r["mcp-session-id"]=this.sessionId);let o=new TextEncoder,n,a,i=!1,l,c=new ReadableStream({start:m=>{n=m},cancel:()=>{i=!0,a!==void 0&&clearInterval(a),l!==void 0&&this._streamMapping.get(l)?.controller===n&&this._streamMapping.delete(l)}}),u=new Set;if(l=await this._eventStore.replayEventsAfter(e,{send:async(m,f)=>{if(u.add(m),!this.writeSSEEvent(n,o,f,m))try{n.close()}catch{}}}),this._closed||i){try{n.close()}catch{}return this.createJsonErrorResponse(404,-32001,"Session not found")}if(this._streamMapping.get(l)?.cleanup(),this._streamMapping.set(l,{controller:n,encoder:o,replayedEventIds:u,cleanup:()=>{a!==void 0&&clearInterval(a),this._streamMapping.delete(l);try{n.close()}catch{}}}),l!==this._standaloneSseStreamId&&![...this._requestToStreamMapping.values()].includes(l)){this._streamMapping.delete(l);try{n.close()}catch{}}return this._streamMapping.get(l)?.controller===n&&(a=this.startKeepAlive(n,o)),new Response(c,{headers:r})}catch(t){return this.onerror?.(t),this.createJsonErrorResponse(500,-32e3,"Error replaying events")}}writeSSEEvent(e,t,r,o){try{let n=`event: message
|
|
49
|
+
`;return o&&(n+=`id: ${o}
|
|
50
|
+
`),n+=`data: ${JSON.stringify(r)}
|
|
51
|
+
|
|
52
|
+
`,e.enqueue(t.encode(n)),!0}catch(n){return this.onerror?.(n),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),Response.json({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null},{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,t){try{let r=e.headers.get("accept");if(!r?.includes("application/json")||!r.includes("text/event-stream"))return this.onerror?.(new 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(!En(e.headers.get("content-type")))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let o=e,n;if(t?.parsedBody===void 0)try{let b=await $i(e,this._maxRequestBodySize);if(b.tooLarge){let h=Wm(this._maxRequestBodySize);return this.onerror?.(new Error(h)),this.createJsonErrorResponse(413,-32e3,h)}n=JSON.parse(b.text)}catch(b){return this.onerror?.(b),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else n=t.parsedBody;if(Array.isArray(n)&&n.length>Ol)return this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${Ol} messages`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Batch must not exceed ${Ol} messages`);let a;try{a=Array.isArray(n)?n.map(b=>kr.parse(b)):[kr.parse(n)]}catch(b){return this.onerror?.(b),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let i=a.some(b=>ul(b));if(i){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(a.length>1)return this.onerror?.(new 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(!i){let b=this.validateSession(e);if(b)return b;let h=this.validateProtocolVersion(e);if(h)return h}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let l;try{l=await this._checkScopeChallenge(a,t?.authInfo)}catch(b){return this.onerror?.(b),this.createJsonErrorResponse(500,-32603,"Internal server error")}if(l)return l;if(!a.some(b=>Ze(b))){for(let b of a)this.onmessage?.(b,{authInfo:t?.authInfo,request:o});return new Response(null,{status:202})}let c=crypto.randomUUID(),u=a.find(b=>ul(b)),m=u?u.params.protocolVersion:e.headers.get("mcp-protocol-version")??ps;if(this._enableJsonResponse)return new Promise(b=>{this._streamMapping.set(c,{resolveJson:b,cleanup:()=>{this._streamMapping.delete(c)}});for(let h of a)Ze(h)&&this._requestToStreamMapping.set(h.id,c);for(let h of a)this.onmessage?.(h,{authInfo:t?.authInfo,request:o})});let f=new TextEncoder,y,R,S=new ReadableStream({start:b=>{y=b},cancel:()=>{R!==void 0&&clearInterval(R),this._streamMapping.get(c)?.controller===y&&this._streamMapping.delete(c)}}),P={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};this.sessionId!==void 0&&(P["mcp-session-id"]=this.sessionId);for(let b of a)Ze(b)&&(this._streamMapping.set(c,{controller:y,encoder:f,cleanup:()=>{R!==void 0&&clearInterval(R),this._streamMapping.delete(c);try{y.close()}catch{}}}),this._requestToStreamMapping.set(b.id,c));await this.writePrimingEvent(y,f,c,m);for(let b of a){let h,$;Ze(b)&&this._eventStore&&this.supportsEmptySSEData(m)&&(h=()=>{this.closeSSEStream(b.id)},$=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(b,{authInfo:t?.authInfo,request:o,closeSSEStream:h,closeStandaloneSSEStream:$})}return this._streamMapping.get(c)?.controller===y&&(R=this.startKeepAlive(y,f)),new Response(S,{status:200,headers:P})}catch(r){return this.onerror?.(r),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(r)})}}async handleDeleteRequest(e){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new 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?.(new 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?.(new 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 r=`Bad Request: Unsupported protocol version: ${t} (supported versions: ${this._supportedProtocolVersions.join(", ")})`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(400,-32e3,r)}}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 r=this._streamMapping.get(t);r&&r.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,t){let r=t?.relatedRequestId;if((ct(e)||lt(e))&&(r=e.id),r===void 0){if(ct(e)||lt(e))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let a;this._eventStore&&(a=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let i=this._streamMapping.get(this._standaloneSseStreamId);if(i===void 0)return;i.controller&&i.encoder&&(a===void 0||!i.replayedEventIds?.has(a))&&this.writeSSEEvent(i.controller,i.encoder,e,a);return}let o=this._requestToStreamMapping.get(r);if(!o)throw new Error(`No connection established for request ID: ${String(r)}`);let n=this._streamMapping.get(o);if(!this._enableJsonResponse){let a;this._eventStore&&(a=await this._eventStore.storeEvent(o,e),n=this._streamMapping.get(o)),n?.controller&&n?.encoder&&(a===void 0||!n.replayedEventIds?.has(a))&&this.writeSSEEvent(n.controller,n.encoder,e,a)}if(ct(e)||lt(e)){this._requestResponseMap.set(r,e);let a=[...this._requestToStreamMapping.entries()].filter(([i,l])=>l===o).map(([i])=>i);if(a.every(i=>this._requestResponseMap.has(i))){if(!n){if(this._enableJsonResponse)throw new Error(`No connection established for request ID: ${String(r)}`);if(!this._eventStore){this.onerror?.(new Error(`Response for request ID ${String(r)} is undeliverable: per-request stream is disconnected and no eventStore is configured`));for(let i of a)this._requestResponseMap.delete(i),this._requestToStreamMapping.delete(i);return}for(let i of a)this._requestResponseMap.delete(i),this._requestToStreamMapping.delete(i);return}if(this._enableJsonResponse&&n.resolveJson){let i={"Content-Type":"application/json"};this.sessionId!==void 0&&(i["mcp-session-id"]=this.sessionId);let l=a.map(c=>this._requestResponseMap.get(c));l.length===1?n.resolveJson(Response.json(l[0],{status:200,headers:i})):n.resolveJson(Response.json(l,{status:200,headers:i})),n.cleanup()}else n.cleanup();for(let i of a)this._requestResponseMap.delete(i),this._requestToStreamMapping.delete(i)}}}};function Dt(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let{method:t,id:r}=e;return typeof t!="string"?null:typeof r=="string"||typeof r=="number"?r:null}function St(e,t,r,o,n=null){return Response.json({jsonrpc:"2.0",error:{code:t,message:r,...o!==void 0&&{data:o}},id:n},{status:e,...e===405&&{headers:{Allow:"POST"}}})}function Ti(e,t=null){return St(e.httpStatus,e.code,e.message,e.data,t)}function Pn(e){return e instanceof Error?e:new Error(String(e))}function Cn(e=null){return St(500,-32603,"Internal server error",void 0,e)}function Km(e){if(e.transport!==void 0)throw new Error("The factory returned an instance that is still serving another request. Return a new instance for each request.")}function v_(e,t,r,o){return async(n,a)=>{if(n.method.toUpperCase()!=="POST")return St(405,-32e3,"Method not allowed.");try{let i=await e({era:"legacy",...a?.authInfo!==void 0&&{authInfo:a.authInfo},requestInfo:n}),l=new ql({sessionIdGenerator:void 0,...r!==void 0&&{keepAliveMs:r},...o!==void 0&&{maxRequestBodySize:o}});await i.connect(l);let c=()=>{l.close().catch(()=>{}),i.close().catch(()=>{})};n.signal?.addEventListener("abort",c,{once:!0});let u=await l.handleRequest(n,{...a?.authInfo!==void 0&&{authInfo:a.authInfo},...a?.parsedBody!==void 0&&{parsedBody:a.parsedBody}});if(u.body===null||Sl(u.headers.get("content-type"))!=="text/event-stream")return c(),u;let m=u.body.getReader(),f=!1,y=()=>{f||(f=!0,c())},R=new ReadableStream({pull:async S=>{try{let{done:P,value:b}=await m.read();if(P){y(),S.close();return}b!==void 0&&S.enqueue(b)}catch(P){y(),S.error(P)}},cancel:S=>(y(),m.cancel(S).catch(()=>{}))});return new Response(R,{status:u.status,statusText:u.statusText,headers:u.headers})}catch(i){try{t?.(Pn(i))}catch{}return Cn(Dt(a?.parsedBody))}}}function Ym(e){return{protocolVersionHeader:e.headers.get("mcp-protocol-version")??void 0,mcpMethodHeader:e.headers.get("mcp-method")??void 0,mcpNameHeader:e.headers.get("mcp-name")??void 0}}async function Xm(e,t,r=!0,o=Ml){let n=e.method.toUpperCase(),a,i=t,l=e,c=!1;if(n==="POST"){if(i===void 0){r&&(l=e.clone());let u;try{let m=await $i(e,o);if(m.tooLarge)return{step:"body-too-large"};u=m.text}catch{return{step:"unreadable-body"}}try{a=u.length===0?void 0:JSON.parse(u)}catch{c=!0}!c&&a!==void 0&&(i=a)}else a=i;if(c||a===void 0)return{step:"no-json-body",forwardRequest:l}}return{step:"classified",outcome:pi({httpMethod:n,...Ym(e),...a!==void 0&&{body:a}}),body:a,parsedBody:i,forwardRequest:l}}async function Zm(e,t,r){let o=Nl(r?.maxRequestBodySize),n=await Xm(t===void 0&&e.method.toUpperCase()==="POST"?e.clone():e,t,!1,o);return n.step==="no-json-body"||n.step==="classified"&&n.outcome.kind==="legacy"}function Qm(e,t={}){let{legacy:r,onerror:o,responseMode:n}=t,a=Nl(t.maxRequestBodySize);if(typeof r=="function")throw new TypeError("The 'legacy' option only accepts 'stateless' or 'reject', not a handler function. To serve 2025-era traffic with your own handler, route in user land with the exported isLegacyRequest(request) predicate in front of a strict (legacy: 'reject') handler.");let i=new Set,l=!1,c=h=>{try{o?.(h)}catch{}},u=t.bus??new Fm(c),m=Gm(u),f=Jm({bus:u,maxSubscriptions:t.maxSubscriptions??Al,keepAliveMs:t.keepAliveMs??Jr,onerror:c});n==="json"&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let y=r==="reject"?void 0:v_(e,c,t.keepAliveMs,a);async function R(h,$,v){let z=h.classification.revision;if(z===void 0||!lr.includes(z)){let D=new ci({supported:[...lr],requested:z??"unknown"});return c(D),St(400,D.code,D.message,D.data,Dt(h.message))}let I=Up({httpMethod:$.method,...Ym($)},h);if(I!==void 0)return c(new Error(`Rejected inbound request (${I.cell}): ${I.message}`)),Ti(I,Dt(h.message));let T=h.messageKind==="request"?Lt(h.message.params):void 0,_=T?.[it];if(h.messageKind==="request"){let D=vp(h.message.method);if(D!==void 0){let W=_n(D,_);if(W!==void 0){let F=new bn({requiredCapabilities:W});return c(F),St(Hp(F.code,"ladder"),F.code,F.message,F.data,h.message.id)}}}let C=await e({era:"modern",...v!==void 0&&{authInfo:v},requestInfo:$}),M=C instanceof Ei?C.server:C;if(Km(M),h.messageKind==="request"&&h.message.method==="subscriptions/listen"){let D=M.getCapabilities(),W=Um(M);return C.close().catch(c),f.serve(h.message,$.signal,D,W)}if(h.messageKind==="request"&&h.message.method==="tools/call"&&C instanceof Ei){let D=h.message.params,W=typeof D?.name=="string"?D.name:void 0,F=W===void 0?void 0:C.toolInputSchemaJson(W);if(F!==void 0){let ie=di(F);if(ie.declarations!==void 0&&ie.declarations.length>0){let he=xp(ie.declarations,D?.arguments,$.headers);if(he!==void 0)return C.close().catch(c),c(new Error(`Rejected inbound request (${he.cell}): ${he.message}`)),Ti(he,h.message.id)}}}if(h.messageKind==="request"&&C instanceof Ei)try{let D=await Cl([h.message],v,W=>C.resolveScopeChallenge(W));if(D!==void 0)return C.close().catch(c),Il(D,kl(v))}catch(D){return C.close().catch(c),c(Pn(D)),Cn(h.message.id)}Km(M),rm(M,z),Hm(M,lr),T!==void 0&&xm(M,{clientInfo:T[or],clientCapabilities:_});let U=M.onclose;i.add(M);let q=()=>{i.delete(M),M.onclose===q&&(M.onclose=U),U?.()};M.onclose=q;try{let D=await S_(C,h.message,{classification:h.classification,request:$,...v!==void 0&&{authInfo:v},...n!==void 0&&{responseMode:n},...t.keepAliveMs!==void 0&&{keepAliveMs:t.keepAliveMs}});return h.messageKind==="notification"&&queueMicrotask(()=>void M.close().catch(()=>{})),D}catch(D){return D instanceof le&&D.code===pe.ConnectionClosed?new Response(null,{status:499}):(await M.close().catch(()=>{}),i.delete(M),c(Pn(D)),Cn(Dt(h.message)))}}async function S(h,$,v,z){if(y!==void 0)return y($,{...v!==void 0&&{authInfo:v},...z!==void 0&&{parsedBody:z}});let I=Bp(h,lr);return I===void 0?new Response(null,{status:202}):(c(new Error(`Rejected 2025-era request on a modern-only endpoint (${I.cell}): ${I.message}`)),Ti(I,Dt(z)))}async function P(h,$){let v=$?.authInfo;if(h.method.toUpperCase()==="POST"&&!En(h.headers.get("content-type")))return c(new Error("Unsupported Media Type: Content-Type must be application/json")),St(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let z=await Xm(h,$?.parsedBody,!0,a);if(z.step==="unreadable-body")return St(400,-32700,"Parse error: the request body could not be read");if(z.step==="body-too-large")return St(413,-32e3,Wm(a));if(z.step==="no-json-body")return y!==void 0?y(z.forwardRequest,{...v!==void 0&&{authInfo:v}}):St(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:I,body:T,parsedBody:_,forwardRequest:C}=z;try{switch(I.kind){case"reject":return c(new Error(`Rejected inbound request (${I.cell}): ${I.message}`)),Ti(I,Dt(T));case"modern":return await R(I,h,v);case"legacy":return await S(I,C,v,_)}}catch(M){return c(Pn(M)),Cn(Dt(T))}}return{fetch:async(h,$)=>{if(l)throw new Error("This MCP handler has been closed");try{return await P(h,$)}catch(v){return c(Pn(v)),Cn(Dt($?.parsedBody))}},notify:m,bus:u,close:async()=>{l=!0,f.closeAll();let h=[...i].map($=>$.close().catch(()=>{}));i.clear(),await Promise.all(h)}}}var jl={member:0,admin:1,owner:2};function __(e){return e!==void 0&&e in jl?jl[e]:-1}function b_(e,t){return __(e)>=jl[t]}function Je(e,t,r){let o=e.risk??"write";return r?.blocked?{action:"hide",reason:"org_blocked"}:e.minRole&&!b_(t.orgRole,e.minRole)?{action:"hide",reason:"role_required"}:e.minRole&&t.appScope==="selected"?{action:"hide",reason:"app_scoped_credential"}:o==="destructive"?{action:"hide",reason:"destructive_requires_approval"}:o==="write"&&t.access==="read"?{action:"hide",reason:"read_only_connection"}:{action:"allow"}}var eh=[{risk:"read",minRole:"member",name:"provider_list",title:"List the API providers",description:'List the API providers this Gateway brokers: the built-in catalog and the ones registered on this Gateway, each with its id (what an app lists under `capabilities`), name, kind (api_key, ai, oauth_client), where the key goes, hosts, docs link, hint, and the Gateway settings it reads; an OAuth provider also with its flow, the redirect URI to register at its console, its scope sets, where its client comes from and how many accounts are connected. Also `presets`: the OAuth presets `everyapp_provider_add` takes by id (`{ preset: "github-oauth" }`). For owners and admins, whether each setting is set. Never a value. Any member.',inputSchema:{type:"object",properties:{},additionalProperties:!1}},{risk:"write",minRole:"admin",needs:"providers",name:"provider_add",title:"Register an API provider",description:"Register a provider on this Gateway: an API provider from its spec `{ id, name, docs, hosts, auth: { kind: bearer | header | query | basic, secret: SETTING_NAME, \u2026 }, hint?, secrets?, access?, writeMethods?, accountWidePaths?, data?, smoke?, cost?, rate? }`, an OAuth provider from a spec with `auth: { kind: oauth2-user, authorizeUrl, tokenUrl, clientId: SETTING_NAME, clientSecret?: SETTING_NAME, \u2026 }` and `scopeSets`, or an OAuth preset by id (`{ preset: \"github-oauth\" }`; `everyapp_provider_list` names them; a built-in client such as `google-workspace` writes no row). A spec names its settings and never carries a value: a client id or secret is set from the terminal (`everyapp secret set NAME`) or pasted under Admin \u2192 Providers, never through a tool. The id must not be a built-in provider's, its settings must start with its own id (`STRIPE_` for `stripe`) and be nobody else's, and its hosts must be the provider's own public https hosts. An id that is registered already is refused: this tool never replaces a row (`everyapp provider add --replace` from the terminal does). For an OAuth provider the answer carries the redirect URI to register at the provider's console and where people connect. Owners and admins, on a self-hosted Gateway.",inputSchema:{type:"object",properties:{spec:{type:"object",description:"The provider spec object (never a URL). Its fields are checked by the same parser as `everyapp provider add`; a problem names the field. One of spec or preset."},preset:{type:"string",description:"An OAuth preset id from `everyapp_provider_list`'s `presets` (github-oauth, notion-oauth, \u2026), or a built-in client's id (google-workspace, slack, microsoft-365, discord). One of spec or preset.",minLength:2,maxLength:40}},additionalProperties:!1}},{risk:"write",minRole:"admin",needs:"providers",name:"provider_remove",title:"Remove a registered API provider",description:"Remove an API provider registered on this Gateway, by its id. Refused for a built-in provider, for a row whose key is set (remove it from the terminal: `everyapp provider remove <id>`, then `everyapp secret unset`), and for a row an app's deployed manifest lists under `capabilities` (naming the apps). The Gateway settings the row named stay until `everyapp secret unset`. Owners and admins, on a self-hosted Gateway.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The provider's id, as everyapp_provider_list lists it (a registered one, never a built-in).",minLength:2,maxLength:40}},required:["id"],additionalProperties:!1}},{risk:"read",minRole:"member",name:"provider_connections",title:"List connected accounts",description:"List the accounts connected to OAuth providers on this Gateway: the caller's own (any member), or with `all: true` every connection in the organization, people's and the organization's own (owners and admins). Each with the provider, whose it is, the account's label at the provider, the scope sets granted, its status (active, or expired: the provider refused a refresh and the person connects again) and when it was last used. Never a token. People connect in the browser at `<gateway>/connect/<provider>`; there is no tool for that.",inputSchema:{type:"object",properties:{all:{type:"boolean",description:"Every connection in the organization, not only the caller's (owners and admins)."},provider:{type:"string",description:"One provider's connections only, by id.",minLength:2,maxLength:40}},additionalProperties:!1}},{risk:"write",minRole:"member",name:"provider_disconnect",title:"Disconnect an account",description:"Remove a connection to an OAuth provider: the caller's own (any member), or for owners and admins another person's (`user`: their email or user id) or the organization's own (`account: organization`). The Gateway drops the tokens it held and revokes the grant at the provider where the preset knows how (`revoked` says whether it did); apps get `integration_not_connected` until the person connects again in the browser.",inputSchema:{type:"object",properties:{provider:{type:"string",description:"The OAuth provider's id, as everyapp_provider_list lists it.",minLength:2,maxLength:40},account:{type:"string",enum:["user","organization"],description:"A person's connection (default) or the organization's own (owners and admins)."},user:{type:"string",description:"Whose connection, by email or user id (owners and admins; default: the caller's own).",minLength:1,maxLength:320}},required:["provider"],additionalProperties:!1}}];var th=[{risk:"read",minRole:"admin",name:"signin_list",title:"List the sign-in providers",description:"List the ways people can sign in to this Gateway beside their password (Manage workspace \u2192 Sign-in): every sign-in provider (google, microsoft, github, apple, cloudflare, oidc) with its status (on; off; incomplete, which means needs setup: some settings are set and the provider stays off until the rest are), the settings it reads with whether each is set (never a value), the redirect URL to register at the provider, and the command that sets it up from a terminal (`pnpm everyapp signin add <id>`); also whether password sign-in is on and whether Cloudflare Access sign-in is on. Nothing here changes a setting: they are Worker secrets, set from the terminal. Owners and admins.",inputSchema:{type:"object",properties:{},additionalProperties:!1}},{risk:"read",minRole:"admin",name:"signin_show",title:"Show one sign-in provider",description:"Show one sign-in provider as `everyapp signin show <id>` does: its status, each setting's name, what to paste there and whether it is set (never a value), the redirect URL to register, where the OAuth app is made and what it is called there, the scopes asked for, which claim becomes the email, the caveats, the setup guide in the everyapp skill, the command that sets it up from a terminal, and for one that needs setup what is wrong. Owners and admins.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The provider's id, as everyapp_signin_list lists it.",enum:[...Ru]}},required:["id"],additionalProperties:!1}}];var R_=64,w_=2048,E_=32,T_=255,$_=1e3,z_=64,P_=100,C_=32,k_=256,_t=(e,t,r=1)=>({type:"string",description:e,minLength:r,maxLength:t});function vt(e,t=[]){return{type:"object",properties:e,...t.length?{required:t}:{},additionalProperties:!1}}var Kr=_t("The MCP app: its id, the prefix of its tools (`treg` for `treg_<tool>`, as everyapp_mcp_list lists it), or its row id.",R_),rh={risk:"read",minRole:"admin"},Wr={risk:"write",minRole:"admin"},oh=[{...rh,name:"mcp_list",title:"List MCP apps",description:"List the organization's MCP apps: the built-in ones (DataForSEO) that were added and every remote MCP server added by URL. Each with its id, name, kind (builtin or remote), status (on; off; or needs setup: on, but its credential isn't set or is pinned to another server), how many tools the Gateway serves, a remote server's URL and auth kind, and the credential's setting name with whether it is set and bound. Never a credential's value. Owners and admins.",inputSchema:vt({})},{...rh,name:"mcp_show",title:"Show an MCP app",description:"Show one MCP app: its URL and auth kind, the credential's setting name and whether it is set and bound (never its value), its status, when its tools were last listed and the error if that failed, and every tool: the name AI clients call, the server's own name, its risk and where that comes from (override, app, hint or default), whether it is on, and why it isn't listed. Owners and admins.",inputSchema:vt({app:Kr},["app"])},{...Wr,name:"mcp_add",title:"Add an MCP server",description:"Add a remote MCP server by its URL as an MCP app: the Gateway serves its tools on /mcp as `<id>_<tool>` to whoever has access (you, the owners and the admins to start). For a server with no credential the Gateway lists its tools at once and the answer says how many. For one with a credential the answer names the Gateway setting that holds it and the command the operator runs in a terminal to set it; the credential itself is never passed here and never returned. Refused for a URL on this Gateway's own domains or a private address, an id in use, or a credential name another server uses. Owners and admins.",inputSchema:vt({url:_t("The server's MCP endpoint, https (`https://treg.to/mcp`).",w_),id:_t("The app id and tool prefix: lowercase letters, digits and hyphens, a letter first. Default: from the URL's host (`treg.to` \u2192 `treg`).",E_),name:_t("The name people read. Default: the id.",T_),description:_t("What the server is for. Default: a sentence naming it and its host.",$_),auth:{description:"How the Gateway authenticates to the server; for a credential, the name of the setting that holds it.",...vt({kind:{type:"string",description:"How the Gateway authenticates to the server: none; bearer (`Authorization: Bearer <credential>`); header (a header of your naming); basic (the credential is `user:password`); oauth (recorded, not served yet).",enum:[...wu]},secret:_t("The NAME of the Gateway setting that holds the credential, ending in _MCP_TOKEN. Default: `<ID>_MCP_TOKEN`. Never the credential itself.",z_),header:_t("For kind header: the header's name (`X-Api-Key`).",P_),prefix:_t("For kind header: text sent before the credential (`Token `). Optional.",C_,0)},["kind"])},risk:{type:"string",description:"How each tool's risk is decided: annotations (the server's hints; a tool without one counts as write; the default), or read or write for every tool.",enum:[...Eu]}},["url","auth"])},{...Wr,name:"mcp_remove",title:"Remove an MCP app",description:"Remove an MCP app, built-in or remote: it stops being served, and everyone's access, its tokens, its tools snapshot and its place in AI connections go. The credential stays set on the Gateway. To stop serving it and keep all that, use everyapp_mcp_off. Cannot be undone: needs confirm: true. Owners and admins.",inputSchema:vt({app:Kr,confirm:{type:"boolean",description:"Must be true. The action cannot be undone; ask the person before calling.",const:!0}},["app","confirm"]),irreversible:!0},{...Wr,name:"mcp_on",title:"Turn an MCP app on",description:"Serve an MCP app's tools again, to the same people as before. A built-in that was never added is added by the operator (`pnpm everyapp mcp on <id>`). Owners and admins.",inputSchema:vt({app:Kr},["app"])},{...Wr,name:"mcp_off",title:"Turn an MCP app off",description:"Stop serving an MCP app's tools. Who has access, their tokens and the tools snapshot are kept, so everyapp_mcp_on brings it back at once. Owners and admins.",inputSchema:vt({app:Kr},["app"])},{...Wr,name:"mcp_refresh",title:"List an MCP app's tools again",description:"List an MCP app's tools again now: the Gateway drops its last listing, asks the server, and answers how many tools it serves and which names are new or gone. Owners and admins.",inputSchema:vt({app:Kr},["app"])},{...Wr,name:"mcp_tool",title:"Change one tool of an MCP server",description:"Change one tool of a remote MCP app: its risk (read, write or destructive; annotations goes back to the server's hint and the app's default) and whether it is on. A destructive tool is never served to AI clients until approvals exist; a write tool is hidden from read-only connections. Give `risk`, `enabled`, or both. Owners and admins.",inputSchema:vt({app:Kr,tool:_t("The tool: the name AI clients call (`treg_get_user`) or the server's own (`getUser`), as everyapp_mcp_show lists them.",k_),risk:{type:"string",description:"The tool's risk, or annotations to clear your override.",enum:[...fu,"annotations"]},enabled:{type:"boolean",description:"false leaves the tool out of the catalog; true serves it again."}},["app","tool"])}];var nh=200,zi=50,sh=864e13,ah=200,I_=80,ih=100,ch=20,A_=50,O_=80,M_=80,Pi=254,N_=500,q_=64,lh=60,uh=500,j_=255,L_=1e3,dh=1e9,D_=.01,x_=1e6,ph=e=>({type:["number","null"],description:e,minimum:D_,maximum:x_}),dr={type:"object",properties:{},additionalProperties:!1},tt=e=>({type:"string",description:e,minLength:1,maxLength:Pi}),Yr=tt("The member: their email address, or their user id (from everyapp_workspace_users)."),kn=tt("The app: its manifest id (as everyapp_list_apps lists it, e.g. `crm`), or its row id (from everyapp_workspace_apps)."),Xr=tt("The group: its name, or its id (`grp_\u2026`, from everyapp_workspace_groups)."),Ll=tt("The event subscription: its id (`sub_\u2026`, from everyapp_workspace_events), or its name. A name several subscriptions share is refused; use the id."),H_=zu.map(e=>e.type).filter(e=>e!=="ping").join(", "),mh=e=>({type:"array",description:e,items:{type:"string",minLength:1,maxLength:O_},maxItems:A_}),Dl={type:"boolean",description:"Must be true. The action cannot be undone; ask the person before calling.",const:!0},Zr=e=>({type:"array",description:e,items:{type:"string",minLength:1,maxLength:Pi},maxItems:N_});function ve(e,t=[]){return{type:"object",properties:e,...t.length?{required:t}:{},additionalProperties:!1}}function hh(e,t){let[r]=Object.keys(e);return ve({...e,users:Zr(`The full list of ${t}, by email or user id. Replaces the current list; give this or add/remove, not both.`),add:Zr("Members to add (email or user id), keeping the rest."),remove:Zr("Members to take out (email or user id), keeping the rest.")},r?[r]:[])}var Ke={risk:"read",minRole:"admin"},we={risk:"write",minRole:"admin"},fh=[{...Ke,name:"workspace_show",title:"Show the workspace",description:"Show this organization: its id, name and slug, your role, whether the Gateway can send email, and how many members, pending invitations, groups and apps it has. Owners and admins.",inputSchema:dr},{...Ke,name:"workspace_users",title:"List members",description:"List the organization's members (id, name, email, role, whether deactivated, when the account was created and when they joined) and its pending invitations (id, email, role, when they expire; an expired one stays listed until canceled). Owners and admins.",inputSchema:dr},{...we,name:"workspace_invite",title:"Invite someone",description:"Invite an email address to the organization as a member or an admin. Creates the invitation and mails it when the Gateway can send email; the answer says whether it was mailed and never carries the invitation link (an admin copies it from Admin \u2192 Users). Refused for an address that is a member or already invited, and once the organization holds 100 pending invitations. Owners and admins.",inputSchema:ve({email:{type:"string",description:"The email address to invite.",minLength:3,maxLength:Pi},role:{type:"string",description:"The role they join with. Default member.",enum:["member","admin"],default:"member"}},["email"])},{...we,name:"workspace_uninvite",title:"Cancel an invitation",description:"Cancel a pending invitation (an expired one too), by its id or the invited email address. Owners and admins.",inputSchema:ve({invitation:tt("The invitation: its id (from everyapp_workspace_users), or the invited email address.")},["invitation"])},{...we,name:"workspace_role",title:"Change a member's role",description:"Make a member an admin, an admin a member, or make or demote an owner. Only an owner changes an admin or an owner, or makes one; nobody changes their own role; the last owner is never demoted. Owners and admins.",inputSchema:ve({user:Yr,role:{type:"string",description:"The role to give.",enum:["member","admin","owner"]}},["user","role"])},{...we,name:"workspace_deactivate",title:"Deactivate a member",description:"Lock a member out everywhere: no sign-in, every session ended, their personal access tokens and AI connections revoked. They stay listed and can be reactivated. Only an owner deactivates an admin; never yourself or an owner. Owners and admins.",inputSchema:ve({user:Yr},["user"])},{...we,name:"workspace_reactivate",title:"Reactivate a member",description:"Let a deactivated member sign in again. Tokens and connections revoked at deactivation stay revoked. Owners and admins.",inputSchema:ve({user:Yr},["user"])},{...we,name:"workspace_remove",title:"Remove a member",description:"Remove a member from the organization: their membership, app access, group places, tokens and AI connections go, and their account when it belongs to no other organization. Where Cloudflare Access would let them straight back in they are deactivated instead, and the answer says so. Cannot be undone: needs confirm: true. Owners and admins; an owner is removed only by another owner, never the last one.",inputSchema:ve({user:Yr,confirm:Dl},["user","confirm"]),irreversible:!0},{...we,name:"workspace_reset_email",title:"Send a password-reset email",description:"Mail a member a password-reset link. The link goes to their inbox, never to you. Refused where the Gateway sends no email (an admin copies a reset link from Admin \u2192 Users instead) or password sign-in is off; only for active members of this organization alone, never yourself or an owner. Owners and admins.",inputSchema:ve({user:Yr},["user"])},{...Ke,name:"workspace_groups",title:"List groups",description:"List the organization's groups with their id (`grp_\u2026`), name, description, and how many members and apps each has. Owners and admins.",inputSchema:dr},{...we,name:"workspace_group_create",title:"Create a group",description:"Create a group. Names are unique in the organization, letter case aside. Owners and admins.",inputSchema:ve({name:{type:"string",description:"The group's name, 1 to 60 characters.",minLength:1,maxLength:lh},description:{type:"string",description:"What the group is for. Optional.",maxLength:uh}},["name"])},{...we,name:"workspace_group_set",title:"Rename or describe a group",description:"Change a group's name or description. A field left out keeps its value. Owners and admins.",inputSchema:ve({group:Xr,name:{type:"string",description:"The new name, 1 to 60 characters.",minLength:1,maxLength:lh},description:{type:"string",description:"The new description; an empty string clears it.",maxLength:uh}},["group"])},{...we,name:"workspace_group_delete",title:"Delete a group",description:"Delete a group. The app access it granted its members ends with it. Owners and admins.",inputSchema:ve({group:Xr},["group"])},{...Ke,name:"workspace_group_members",title:"List a group's members",description:"List every member of the organization with whether they are in the group. Owners and admins.",inputSchema:ve({group:Xr},["group"])},{...we,name:"workspace_group_members_set",title:"Set a group's members",description:"Set who is in a group: give `users` (the full list) or `add` and/or `remove` (changes to the current list). Only members of the organization. Owners and admins.",inputSchema:hh({group:Xr},"the group's members")},{...Ke,name:"workspace_group_apps",title:"List a group's apps",description:"List the organization's own apps with whether the group opens each. Owners and admins.",inputSchema:ve({group:Xr},["group"])},{...we,name:"workspace_group_apps_set",title:"Set a group's apps",description:"Set which apps a group opens: give `apps` (the full list) or `add` and/or `remove` (changes to the current list), each app by manifest id or row id. Only the organization's own apps; a shared app is everyone's already. Owners and admins.",inputSchema:ve({group:Xr,apps:Zr("The full list of apps the group opens, by manifest id or row id. Replaces the current list; give this or add/remove, not both."),add:Zr("Apps to grant (manifest id or row id), keeping the rest."),remove:Zr("Apps to revoke (manifest id or row id), keeping the rest.")},["group"])},{...Ke,name:"workspace_apps",title:"List apps",description:"List every app of the organization (and the shared apps on a hosted Gateway): row id, manifest id, name, description, status, whether everyone can open it, how many members have direct access, and what it still needs before it opens (setup). Owners and admins.",inputSchema:dr},{...we,name:"workspace_app_set",title:"Edit an app",description:"Change an app's name, description, or whether it is available to everyone (every current and future member gets access; turning it off keeps existing access). A field left out keeps its value. Owners and admins.",inputSchema:ve({app:kn,name:{type:"string",description:"The new name.",minLength:1,maxLength:j_},description:{type:"string",description:"The new description.",minLength:1,maxLength:L_},everyone:{type:"boolean",description:"Whether the app is available to every member."}},["app"])},{...Ke,name:"workspace_app_access",title:"Who can open an app",description:"List every member of the organization with whether they hold direct access to the app, and the groups that grant it to them. Owners and admins.",inputSchema:ve({app:kn},["app"])},{...we,name:"workspace_app_access_set",title:"Set who can open an app",description:"Set which members hold direct access to an app: give `users` (the full list) or `add` and/or `remove` (changes to the current list). Access a group grants is not touched here; your own access is never revoked. Owners and admins.",inputSchema:hh({app:kn},"members with direct access")},{...we,name:"workspace_app_cap",title:"Cap an app's monthly calls or dollars",description:"Set the organization's monthly caps on an app's provider calls (Manage workspace \u2192 Usage): `cap` in calls and `costUsd` in dollars of provider-reported cost (counted only where the provider reports a price: OpenRouter, DataForSEO), each a number, null for none of its own (the workspace default for that kind applies), or left out to keep it; or say the app has no cap of either kind whatever the workspace defaults (`unlimited: true` alone). A cap of either kind ends `unlimited`. The app is paused once either cap is reached. Answers the app's own caps (`monthlyCallCap`, `monthlyCostCapMicros`), `capUnlimited`, and the caps that bind it now with their sources (`effectiveMonthlyCallCap`/`capSource`, `effectiveMonthlyCostCapMicros`/`costCapSource`: `app`, `default`, or null). Owners and admins.",inputSchema:ve({app:kn,cap:{type:["integer","null"],description:"Calls per month, 1 to 1,000,000,000; null for no call cap of its own (the workspace default applies unless `unlimited`); leave it out to keep the app's call cap.",minimum:1,maximum:dh},costUsd:ph("US dollars of provider-reported cost per month, 0.01 to 1,000,000 in whole cents; null for no dollar cap of its own (the workspace default applies unless `unlimited`); leave it out to keep the app's dollar cap."),unlimited:{type:"boolean",description:"No cap at all, of either kind, even with workspace defaults. Alone: a cap and unlimited together are refused."}},["app"])},{...we,name:"workspace_cap_default",title:"The workspace default caps",description:"Set or clear the organization's default monthly caps on provider calls (Manage workspace \u2192 Usage \u2192 Default monthly cap): what binds every app without a cap of that kind or `unlimited` of its own. `cap` in calls and `costUsd` in dollars of provider-reported cost (counted only where the provider reports a price: OpenRouter, DataForSEO), each a number, null for no default, or left out to keep it; give at least one. Owners and admins.",inputSchema:ve({cap:{type:["integer","null"],description:"Calls per month for every app without its own call cap, 1 to 1,000,000,000; null for no default; leave it out to keep it.",minimum:1,maximum:dh},costUsd:ph("US dollars of provider-reported cost per month for every app without its own dollar cap, 0.01 to 1,000,000 in whole cents; null for no default; leave it out to keep it.")})},{risk:"read",minRole:"member",name:"ai_show",title:"The default model provider",description:"What the Gateway's default model provider resolves to now and why: the provider, its model, the source (the stored choice, the shipped order, or nothing configured yet), whether it is configured (its Gateway settings set; shown to owners and admins), whether calls go through Cloudflare AI Gateway, and every provider the default could be, in order, each with its state. What an app gets for `ai: { chat: true }`. Any member.",inputSchema:ve({})},{...we,name:"ai_default",title:"Choose the default model provider",description:"Set the organization's default model provider (Admin \u2192 Usage \u2192 AI default; `everyapp ai default`): the provider id, and optionally the model to fill in when an app names none; or clear it (`clear: true`) so the shipped order decides (OpenRouter, Workers AI, OpenAI, Anthropic, Groq, Mistral, Gemini: the first whose key is set). Refused for an API provider, an entry without an OpenAI-shaped chat route (Cohere) or AI Gateway. A provider whose key isn't set is accepted: apps get ai_default_not_configured until the operator sets it from the terminal. Queues ai.default_changed when the choice changed. Owners and admins.",inputSchema:ve({provider:{type:"string",description:"The provider's id, as ai_show lists the candidates (openrouter, workers-ai, openai, \u2026).",minLength:2,maxLength:Pi},model:{type:"string",description:"The model to fill in when an app names none (anthropic/claude-sonnet-5.5); omitted, the provider's own default model.",minLength:1,maxLength:200},clear:{type:"boolean",description:"True to clear the choice: the shipped order decides again. Give this or provider, not both."}})},{...we,name:"workspace_app_delete",title:"Delete an app",description:"Delete an app from the catalog: it stops being served and leaves every list. Its Worker stays until `everyapp delete`. Cannot be undone: needs confirm: true. Owners and admins.",inputSchema:ve({app:kn,confirm:Dl},["app","confirm"]),irreversible:!0},{...Ke,name:"workspace_usage",title:"Usage for a month",description:"What the organization's apps spent in a UTC month: per app, per member and per provider or capability, with the workspace default caps (`defaultMonthlyCallCap`, `defaultMonthlyCostCapMicros` in millionths of a dollar) and for each app its own caps (`monthlyCallCap`, `monthlyCostCapMicros`), `capUnlimited`, the caps that bind it (`effectiveMonthlyCallCap` with `capSource`, `effectiveMonthlyCostCapMicros` with `costCapSource`: app or default), whether it is `paused` this month and by which cap (`pausedBy`: calls or cost). Owners and admins.",inputSchema:ve({month:{type:"string",description:"The month as YYYY-MM (UTC). Default: the current month.",minLength:7,maxLength:7}})},{...Ke,name:"workspace_activity",title:"Agent activity",description:"One page of the organization's MCP tool calls (the audit trail), newest first: who, through which credential and client, which tool, the decision and outcome. Never the arguments or results. Filter by app, member, decision, risk or time; page with `before` from the previous answer's `nextBefore`. Owners and admins.",inputSchema:ve({app:tt("Only calls to this app: its manifest id (a removed app's too, or `everyapp` for the Gateway's own tools) or its row id."),user:Yr,decision:{type:"string",description:"Only calls that were allowed, or only blocked ones.",enum:["allowed","blocked"]},risk:{type:"string",description:"Only calls to tools of this risk.",enum:["read","write","destructive"]},since:{type:"string",description:"Only calls at or after this time, as an ISO 8601 date-time.",minLength:4,maxLength:40},limit:{type:"integer",description:`Rows per page, 1 to ${nh}. Default ${zi}.`,minimum:1,maximum:nh,default:zi},before:{type:"object",description:"The previous page's `nextBefore`: the page continues before this row.",properties:{createdAt:{type:"integer",description:"The row's time in milliseconds since the epoch.",minimum:0,maximum:sh},id:{type:"string",description:"The row's id.",minLength:1,maxLength:128}},required:["createdAt","id"],additionalProperties:!1}})},{...Ke,name:"workspace_audit",title:"Audit log",description:"One page of the organization's audit log, newest first: every event the Gateway recorded (members, apps, caps, connections, tokens, Access, MCP apps, providers, apps' own events), with who did it, the type in plain words, a one-line summary and what it was about; never an event's data, a secret or a tool's arguments. Test pings and tool calls stay out unless `type` names them (`tool.*`, `*`): everyapp_workspace_activity lists the calls. Filter by actor, type or time; page with `before` from the previous answer's `nextBefore`. Kept 90 days. Owners and admins.",inputSchema:ve({actor:tt("Only events this actor caused: a member's email or user id, an AI connection's or token's id, an app's id, or the operator's id from everyapp_workspace_audit's own `actor.id`."),type:{type:"string",description:"Only this event type (member.joined), every type under a prefix (member.*, app.crm.*), or * for everything, pings and tool calls included.",minLength:1,maxLength:I_},since:{type:"string",description:"Only events at or after this time, as an ISO 8601 date-time.",minLength:4,maxLength:40},limit:{type:"integer",description:`Rows per page, 1 to ${ah}. Default ${zi}.`,minimum:1,maximum:ah,default:zi},before:{type:"object",description:"The previous page's `nextBefore`: the page continues before this row.",properties:{time:{type:"integer",description:"The row's time in milliseconds since the epoch.",minimum:0,maximum:sh},id:{type:"string",description:"The row's id.",minLength:1,maxLength:128}},required:["time","id"],additionalProperties:!1}})},{...we,name:"workspace_rename",title:"Rename the workspace",description:"Rename the organization. The slug (its address) stays as it is. Owners and admins.",inputSchema:ve({name:{type:"string",description:"The new name, 1 to 64 characters.",minLength:1,maxLength:q_}},["name"])},{...Ke,name:"workspace_events",title:"List event subscriptions",description:"List the organization's event subscriptions: id (`sub_\u2026`), name, where it delivers (a webhook URL's host and path, never its query; or email to the owners, or to the owners and admins), the event types and patterns it takes, whether it is on, whether it is built in (Cap alerts), and its last delivery (when, and delivered, failed or dead) with the failures in a row. Never a signing secret. Owners and admins.",inputSchema:dr},{...we,name:"workspace_events_add",title:"Add an event subscription",description:`Subscribe a webhook URL (Slack's workflow webhook, Zapier, n8n, your own endpoint), or the organization's owners or owners and admins by email, to the Gateway's events. Give \`url\` or \`email\`, not both. A webhook URL is https on a public hostname, never the Gateway's own host or an app's. \`events\` takes types or patterns; none means every event. The types: ${H_}; patterns: a group (\`member.*\`, \`cap.*\`), an app's own events (\`app.crm.*\`, or \`app.crm.invoice.paid\`), or \`*\`. Every webhook delivery is signed with the subscription's secret (HMAC-SHA256 over the timestamp and the body, in the X-EveryApp-Signature header). Give \`secret\` when the receiver already has one; leave it out and the Gateway generates one and returns it once, in this answer, and never again. That secret only signs deliveries to this URL and opens nothing on the Gateway; the person must store it in their receiver now. At most ${Pu} subscriptions per organization. Owners and admins.`,inputSchema:ve({url:{type:"string",description:"The webhook URL every matching event is POSTed to, signed. Give this or email, not both.",minLength:1,maxLength:Cu},email:{type:"string",description:"Mail each event to the organization's owners (`owners`) or its owners and admins (`admins`) instead of a webhook. Give this or url, not both.",enum:[...ku]},events:mh("Event types (`member.joined`) or patterns (`member.*`, `app.crm.*`, `*`) to deliver. Leave it out for every event."),name:{type:"string",description:`What to call it, like "Slack #ops", up to ${ko} characters. Default: the URL's host, or "Email owners and admins".`,minLength:1,maxLength:ko},secret:{type:"string",description:`A webhook's signing secret the receiver already has, ${qi} to ${ji} characters with no spaces. Leave it out to have one generated and returned once.`,minLength:qi,maxLength:ji}})},{...we,name:"workspace_events_set",title:"Change an event subscription",description:"Change an event subscription: turn it off or on (`enabled`; a paused one is sent no events, though everyapp_workspace_events_test still reaches it), replace the event types and patterns it takes (`events`; an empty list means every event), or rename it. A field left out keeps its value. Owners and admins.",inputSchema:ve({subscription:Ll,enabled:{type:"boolean",description:"false pauses it; true turns it back on."},events:mh("The event types and patterns it takes from now on, replacing the current list."),name:{type:"string",description:`The new name, 1 to ${ko} characters.`,minLength:1,maxLength:ko}},["subscription"])},{...we,name:"workspace_events_remove",title:"Remove an event subscription",description:"Remove an event subscription: events stop going to it at once, and its signing secret goes with it. A built-in one (Cap alerts) is turned off instead, so the Gateway never recreates it behind the person's back, and the answer says so. Cannot be undone: needs confirm: true. Owners and admins.",inputSchema:ve({subscription:Ll,confirm:Dl},["subscription","confirm"]),irreversible:!0},{...we,name:"workspace_events_test",title:"Send a test event",description:"Send a test event (type `ping`) to one subscription, a paused one too, and wait for the first attempt. The answer says where the delivery stands: delivered, with the receiver's HTTP status (for an email subscription, how many owners and admins were mailed); or failed, with the status or the error and when the Gateway retries; or dead. Nothing goes to any other subscription. Owners and admins.",inputSchema:ve({subscription:Ll},["subscription"])},{...Ke,name:"workspace_event_deliveries",title:"List event deliveries",description:"One page of the organization's event deliveries from the last 30 days, newest first: the event (id, type, its one-line summary, when), the subscription, the attempts, where it stands (pending, delivered, failed and retrying, or dead), the last HTTP status or error, and the next attempt. Never the request body. Only one subscription's with `subscription`, only dead ones with `dead: true`; page with `before` from the previous answer's `nextBefore`. Owners and admins.",inputSchema:ve({subscription:tt("Only this subscription's deliveries: its id (`sub_\u2026`) or its name."),dead:{type:"boolean",description:"true for dead deliveries only: out of attempts, or refused for good (everyapp_workspace_event_redeliver sends one again)."},limit:{type:"integer",description:`Deliveries per page, 1 to ${ih}. Default ${ch}.`,minimum:1,maximum:ih,default:ch},before:{type:"string",description:"The previous page's `nextBefore`: the page continues with the deliveries older than that one.",minLength:1,maxLength:M_}})},{...we,name:"workspace_event_redeliver",title:"Redeliver an event",description:"Send one failed or dead delivery again now, its retry schedule starting over, and answer where it stands after that attempt. A delivered one is left alone and the answer says so. Owners and admins.",inputSchema:ve({delivery:tt("The delivery's id (`dlv_\u2026`, from everyapp_workspace_event_deliveries).")},["delivery"])},{risk:"read",minRole:"member",name:"my_tokens",title:"My personal access tokens",description:"List your own personal access tokens in this organization: id, name, prefix, scopes, the app it is bound to, when it was made, expires, was last used, and whether it is revoked. Never the token value. Any member.",inputSchema:dr},{risk:"write",minRole:"member",name:"revoke_token",title:"Revoke one of my tokens",description:"Revoke one of your own personal access tokens, by its id or its name. Any member.",inputSchema:ve({token:tt("The token: its id or its name (from everyapp_my_tokens). A name several tokens share is refused; use the id.")},["token"])},{risk:"read",minRole:"member",name:"my_connections",title:"My AI connections",description:"List the AI apps you connected to this Gateway over OAuth, in every organization: id, organization, client, which apps, read only or read & write, when made and last used. Any member.",inputSchema:dr},{risk:"write",minRole:"member",name:"revoke_connection",title:"Revoke one of my AI connections",description:"Revoke one of your own AI connections by its id (from everyapp_my_connections). Revoking the connection this call came through ends it on the next request. Any member.",inputSchema:ve({connection:tt("The connection's id.")},["connection"])},...oh];var ut="everyapp";function bh(e,t){return t.workspace===!0&&(e.needs!=="providers"||t.providers===!0)}var gh=256*1024,Hl=200,Ul=64,Rh=10,Vl=25,U_=128,V_="anthropic/alwaysLoad",yh={type:"object",properties:{},additionalProperties:!1},Sh={type:"object",properties:{name:{type:"string",description:"The tool's name as everyapp_search_tools lists it: `<app>_<tool>`.",minLength:1,maxLength:U_},arguments:{type:"object",description:"The tool's arguments, as its input schema describes them."}},required:["name"],additionalProperties:!1},wh={type:"object",properties:{query:{type:"string",description:"Words to look for in tool names, titles and descriptions. Give a query, an app id, or both.",minLength:1,maxLength:Hl},app:{type:"string",description:"An app id (from everyapp_list_apps): only its tools.",minLength:1,maxLength:Ul},limit:{type:"integer",description:"How many tools to return at most.",minimum:1,maximum:Vl,default:Rh}},additionalProperties:!1};function B_(e,t){let r=[];for(let o of Fl)o.kind==="host"&&bh(o,t)&&Je(o,e.principal).action==="allow"&&r.push({appId:ut,tool:o});for(let o of e.apps)for(let n of o.tools)Je(n,e.principal).action==="allow"&&r.push({appId:o.appId,tool:n});return r}function F_(e,t){return t.tools.filter(r=>Je(r,e.principal).action==="allow").length}var vh=(e,t)=>e.appId<t.appId?-1:e.appId>t.appId?1:e.tool.name<t.tool.name?-1:e.tool.name>t.tool.name?1:0;function G_(e,t,r,o){let n=r===e||r===t.name?10:0,a=t.title?.toLowerCase(),i=t.description.toLowerCase();for(let l of o)e.includes(l)&&(n+=5),a?.includes(l)&&(n+=3),i.includes(l)&&(n+=1);return n}var J_=new Set(Object.keys(wh.properties)),_h=(e,t)=>typeof e=="string"&&e.length>=1&&e.length<=t;function K_(e){let t=Object.keys(e).find(a=>!J_.has(a));if(t!==void 0)return{problem:`\`${t}\` is not one of query, app, limit.`};let r=e.query,o=e.app,n=e.limit===void 0?Rh:e.limit;return r!==void 0&&!_h(r,Hl)?{problem:`query must be a string of 1 to ${Hl} characters.`}:o!==void 0&&!_h(o,Ul)?{problem:`app must be a string of 1 to ${Ul} characters.`}:typeof n!="number"||!Number.isInteger(n)||n<1||n>Vl?{problem:`limit must be an integer from 1 to ${Vl}.`}:{...r!==void 0?{query:r.trim().toLowerCase()}:{},...o!==void 0?{app:o}:{},limit:n}}function W_(e,t,r){let o=K_(t);if("problem"in o)return o;let{query:n,app:a,limit:i}=o;if(n===void 0&&a===void 0)return{problem:"give a query, an app id, or both."};let c=B_(e,r).filter(y=>a===void 0||y.appId===a).map(y=>({...y,name:nt(y.appId,y.tool.name)})).sort(vh);if(n!==void 0){let y=[...new Set(n.split(/[^\p{L}\p{N}]+/u).filter(Boolean))];c=c.map(R=>({entry:R,score:G_(R.name,R.tool,n,y)})).filter(R=>R.score>0).sort((R,S)=>S.score-R.score||vh(R.entry,S.entry)).map(R=>R.entry)}let u=c.slice(0,i).map(({name:y,appId:R,tool:S})=>({name:y,app:R,...S.title?{title:S.title}:{},description:S.description,risk:S.risk,inputSchema:S.inputSchema})),m=y=>({tools:u.slice(0,y),total:c.length,...y<u.length?{truncated:!0}:{}}),f=u.length;if(In(Bl(m(f)))>gh){let y=0,R=u.length-1;for(;y<R;){let S=Math.ceil((y+R)/2);In(Bl(m(S)))>gh?R=S-1:y=S}f=y}return{data:m(f)}}var xl={risk:"read",listedIn:["full","compact"],kind:"answer"},Fl=[{...xl,name:"list_apps",title:"List apps",description:"List the EveryApp apps this connection can use: what each is for, its URL, and how many tools it offers. Tool names are `<app>_<tool>`. An app that isn't available yet (it needs setup, or an admin hasn't turned it on) says so, with what an admin runs.",inputSchema:yh,run:e=>({data:{apps:[...e.apps.map(t=>({id:t.appId,name:t.name,...t.description?{description:t.description}:{},url:t.baseUrl,tools:F_(e,t)})),...(e.unavailable??[]).map(t=>({id:t.appId,name:t.name,available:!1,reason:t.reason})),...(e.offered??[]).map(t=>({id:t.appId,name:t.name,available:!1,offered:!0,reason:`off and its key is set: an admin runs ${t.command}`}))]}})},{...xl,name:"whoami",title:"Who am I",description:"Show who this connection acts as: the user, their organization and role, the access it was granted, and the apps it can use.",inputSchema:yh,run:({principal:e,apps:t})=>({data:{user:{email:e.email,role:e.orgRole},organization:{id:e.organizationId,...e.organizationName?{name:e.organizationName}:{}},connection:{kind:e.credential.kind,access:e.access==="write"?"read & write":"read only",...e.credential.clientName?{client:e.credential.clientName}:{}},apps:t.map(r=>r.appId)}})},{...xl,name:"search_tools",title:"Search tools",description:"Find tools this connection can call, by words, by app id, or both: each result has the tool's name (`<app>_<tool>`), what it does, whether it reads or changes data, and its input schema. Best matches first, 10 by default and 25 at most. Call a tool by that name when it is listed, else through everyapp_call_read, or everyapp_call_write for one that changes data.",inputSchema:wh,run:W_},{name:"call_read",title:"Call a read tool",description:"Run one tool that only reads data, by its name (`<app>_<tool>`, from everyapp_search_tools) with its arguments. A tool that changes data is refused here; call it through everyapp_call_write.",risk:"read",inputSchema:Sh,listedIn:["compact"],kind:"wrapper",ceiling:"read"},{name:"call_write",title:"Call a write tool",description:"Run one tool by its name (`<app>_<tool>`, from everyapp_search_tools) with its arguments, including a tool that changes data.",risk:"write",inputSchema:Sh,listedIn:["compact"],kind:"wrapper",ceiling:"write"},...[...fh,...eh,...th].map(e=>({name:e.name,title:e.title,description:e.description,risk:e.risk,inputSchema:e.inputSchema,listedIn:["full"],kind:"host",minRole:e.minRole,...e.irreversible?{irreversible:!0}:{},...e.needs?{needs:e.needs}:{}}))],Gl=nt(ut,"call_write");function Y_(e){return{name:nt(ut,e.name),title:e.title,description:e.description,inputSchema:e.inputSchema,annotations:e.risk==="read"?{readOnlyHint:!0,idempotentHint:!0,openWorldHint:!1}:{readOnlyHint:!1,destructiveHint:e.kind==="host"&&e.irreversible===!0,idempotentHint:!1,openWorldHint:!1},...e.kind==="host"?{}:{_meta:{[V_]:!0}}}}function Eh(e,t={}){let r=e?.listing??"full";return Fl.filter(o=>!e||o.listedIn.includes(r)&&(o.kind!=="host"||bh(o,t))&&Je(o,e.principal).action==="allow").map(Y_)}function Jl(e){return Fl.find(t=>t.name===e)??null}function Bl(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}],structuredContent:e}}function In(e){return new TextEncoder().encode(JSON.stringify(e)).length}function Th(e,t,r,o={}){let n=e.run(t,r,o);return"problem"in n?n:{result:Bl(n.data)}}var X_=3e4,$h=1024*1024,zh=64;function Kl(e){return e==="write"?[Co,Yn]:[Co]}function Z_(e){switch(e.credential.kind){case"pat":return`pat:${e.credential.id}`;case"oauth":return`oauth:${e.credential.id}`;case"access":return`access:${e.credential.id}`;default:return e.userId}}function xe(e){return{content:[{type:"text",text:e}],isError:!0}}function Wl(e){let{view:t,deps:r,call:o}=e,{principal:n}=t;return(a,i)=>r.audit?.({surface:t.surface,tool:jo(a),callId:e.callId,userId:n.userId,organizationId:n.organizationId,credentialKind:n.credential.kind,credentialId:n.credential.id,...n.credential.clientName?{clientName:n.credential.clientName}:{},...o.protocolVersion?{protocolVersion:o.protocolVersion}:{},...o.clientInfo?{clientInfo:o.clientInfo}:{},...t.requestId?{requestId:t.requestId}:{},...e.via?{via:e.via.name}:{},...i,durationMs:Date.now()-e.startedAt})}async function Ch(e,t,r){let o={view:e,deps:r,call:t,callId:crypto.randomUUID(),startedAt:Date.now()},n=e.surface==="gateway"&&t.name.length<=128?is(t.name):null,a=n?.appId===ut?Jl(n.localName):null;return a?Q_(o,a):Ih(o,t.name,t.arguments)}async function Yl(e,t,r,o,n={}){let a=t??{};if(!Se(a))return{ok:!1,problem:"arguments must be a JSON object."};let i=Bd(a,zh);if(i.tooDeep)return{ok:!1,problem:`arguments are nested more than ${zh} levels deep.`,reason:"too_deep"};let l,c;try{l=e.digestArguments?await e.digestArguments(a):void 0,c=n.ownSchema||i.values<=Hd?eb(r,o,a):null}catch{return{ok:!1,problem:"they could not be checked.",reason:"check_failed",...l?{argsDigest:l}:{}}}return c?{ok:!1,problem:c,...l?{argsDigest:l}:{}}:{ok:!0,args:a,...l?{argsDigest:l}:{}}}function Xl(e){return{outcome:"invalid_arguments",...e.reason?{reason:e.reason}:{},...e.argsDigest?{argsDigest:e.argsDigest}:{}}}async function Q_(e,t){let{view:r,deps:o,call:n}=e;if(t.kind==="host")return kh(e,t,n.arguments);let a=Wl(e),i=nt(ut,t.name),l={appId:ut,risk:t.risk},c=Je(t,r.principal);if(c.action!=="allow")return a(i,{...l,decision:"blocked",reason:c.reason,outcome:"not_run"}),{kind:"unknown_tool"};let u=(S,P)=>(a(i,{...l,decision:"allowed",outcome:"invalid_arguments",...P}),{kind:"result",result:xe(`Invalid arguments for ${i}: ${S}`),tool:t}),m=await Yl(o,n.arguments,`builtin\0${t.name}`,t.inputSchema,{ownSchema:!0});if(!m.ok)return u(m.problem,Xl(m));let f=m.argsDigest?{argsDigest:m.argsDigest}:{};if(t.kind==="answer"){let S=Th(t,r,m.args,{workspace:o.workspace!==void 0,providers:o.workspace?.providers===!0});return"problem"in S?u(S.problem,f):(a(i,{...l,decision:"allowed",outcome:"ok",...f,resultBytes:In(S.result)}),{kind:"result",result:S.result,tool:t})}let y=m.args.name,R=m.args.arguments;return typeof y!="string"?u("name must be the tool's name, `<app>_<tool>`.",f):R!==void 0&&!Se(R)?u("arguments must be a JSON object.",f):Ih({...e,via:{name:i,tool:t,ceiling:t.ceiling}},y,R??{})}async function kh(e,t,r){let{view:o,deps:n}=e,a=Wl(e),i=nt(ut,t.name),l={appId:ut,risk:t.risk},c=e.via?.tool??t,u=P=>(a(i,{...l,decision:"blocked",reason:P,outcome:"not_run"}),e.via?{kind:"result",result:xe(`Unknown tool: ${i}`),tool:e.via.tool}:{kind:"unknown_tool"}),m=n.workspace;if(!m||t.needs==="providers"&&m.providers!==!0)return u("unknown_tool");let f=Je(t,o.principal);if(f.action!=="allow")return u(f.reason);if(e.via?.ceiling==="read"&&t.risk!=="read")return a(i,{...l,decision:"blocked",reason:"write_via_read_wrapper",outcome:"not_run"}),{kind:"result",result:xe(`\`${i}\` changes data; call it through ${Gl}.`),tool:e.via.tool};let y=await Yl(n,r,`builtin\0${t.name}`,t.inputSchema,{ownSchema:!0});if(!y.ok)return a(i,{...l,decision:"allowed",...Xl(y)}),{kind:"result",result:xe(`Invalid arguments for ${i}: ${y.problem}`),tool:c};let R={...l,decision:"allowed",...y.argsDigest?{argsDigest:y.argsDigest}:{}},S;try{S=await m.run(t.name,y.args,o.principal)}catch{return a(i,{...R,outcome:"app_error",reason:"host_error"}),{kind:"result",result:xe(`${i} failed.`),tool:c}}return a(i,{...R,outcome:S.isError?"tool_error":"ok",resultBytes:In(S)}),{kind:"result",result:S,tool:c}}async function Ih(e,t,r){let{view:o,deps:n}=e,{principal:a}=o,i=Wl(e),l=I=>(i(t,{decision:"blocked",outcome:"not_run",...I}),e.via?{kind:"result",result:xe(`Unknown tool: ${jo(t)}`),tool:e.via.tool}:{kind:"unknown_tool"});if(t.length>128)return l({reason:"unknown_tool"});if(e.via){let I=is(t);if(I?.appId===ut){let T=Jl(I.localName);return T?.kind==="host"?kh(e,T,r):l({reason:"unknown_tool"})}}let c=Od(o,t);if(!c)return l({reason:"unknown_tool"});let{app:u,tool:m}=c,f={appId:u.appId,appRowId:u.rowId,risk:m.risk},y=Je(m,a);if(y.action!=="allow")return l({...f,reason:y.reason});if(e.via?.ceiling==="read"&&m.risk!=="read")return i(t,{...f,decision:"blocked",reason:"write_via_read_wrapper",outcome:"not_run"}),{kind:"result",result:xe(`\`${t}\` changes data; call it through ${Gl}.`),tool:e.via.tool};let R=e.via?.tool??m,S=await Yl(n,r,`${u.rowId}\0${u.catalogHash}\0${m.name}`,m.inputSchema);if(!S.ok)return i(t,{...f,decision:"allowed",...Xl(S)}),{kind:"result",result:xe(`Invalid arguments for ${t}: ${S.problem}`),tool:R};let{args:P}=S,b={...f,decision:"allowed",...S.argsDigest?{argsDigest:S.argsDigest}:{}},h=e.via?.ceiling==="read"?"read":a.access,$=await Er(n.signing.privateKeyPem,{subject:{sub:a.userId,email:a.email,orgId:a.organizationId,orgRole:a.orgRole},audience:u.audience,issuer:n.signing.issuer,keyId:n.signing.keyId,channel:"mcp",actor:{sub:Z_(a)},scopes:Kl(h),toolCall:{id:e.callId,name:m.name}}),v=n.callTimeoutMs??X_,z;try{z=await ss(v,async I=>{let T=await n.invokeApp(u,new Request(new URL(hu,u.baseUrl),{method:"POST",headers:{"content-type":"application/json",[Tt]:$},body:JSON.stringify({v:1,name:m.name,arguments:P,callId:e.callId}),signal:I}));return tb(u,m,T,I)})}catch(I){let T=I instanceof qo;return i(t,{...b,outcome:T?"timeout":"unreachable"}),{kind:"result",result:xe(T?`${u.name} did not answer within ${Math.round(v/1e3)} seconds.`:`${u.name} could not be reached.`),tool:R}}return z.drifted&&n.onCatalogDrift?.(u),i(t,{...b,outcome:z.outcome,resultBytes:z.bytes,...z.reason?{reason:z.reason}:{}}),{kind:"result",result:z.result,tool:R}}function eb(e,t,r){let n=Ud(e,t)?.(r);return!n||n.valid?null:n.errorMessage??"invalid arguments."}async function tb(e,t,r,o){let n;try{n=await as(r,$h,o)}catch{return{result:xe(`${e.name} failed to run ${t.name}.`),outcome:"app_error",bytes:0,drifted:!1,reason:"unreadable_answer"}}if(!n.ok)return{result:xe(`The result from ${e.name} is larger than ${$h/1024/1024} MB.`),outcome:"app_error",bytes:n.bytes,drifted:!1,reason:"result_too_large"};let a;try{a=JSON.parse(n.text)}catch{a=void 0}let i=u=>({result:xe(`${e.name} failed to run ${t.name}.`),outcome:"app_error",bytes:n.bytes,drifted:!1,reason:u});if(!Se(a)||a.v!==1)return i(`http_${r.status}`);if(r.ok){let u=rb(a.result);return u?{result:u,outcome:u.isError?"tool_error":"ok",bytes:n.bytes,drifted:a.catalogHash!==e.catalogHash}:i("malformed_result")}let l=Se(a.error)?a.error:{},c=typeof l.code=="string"?l.code:"unknown";return c==="invalid_arguments"?{result:xe(typeof l.message=="string"?l.message:`Invalid arguments for ${t.name}.`),outcome:"invalid_arguments",bytes:n.bytes,drifted:!1}:c==="unknown_tool"?{result:xe(`${t.name} is no longer available in ${e.name}. Its tool list is being refreshed; list tools again.`),outcome:"app_error",bytes:n.bytes,drifted:!0,reason:"unknown_tool"}:i(c)}function rb(e){if(!Se(e)||!Array.isArray(e.content))return null;let t=e.content;if(!t.every(o=>Se(o)&&typeof o.type=="string"&&(o.type!=="text"||typeof o.text=="string")))return null;let r=e.structuredContent;return r!==void 0&&!Se(r)?null:{content:t,...r?{structuredContent:r}:{},...e.isError===!0?{isError:!0}:{}}}var Zl="0.1.0",ob=6e4,nb=100,sb=50,Oh=200;function Ci(e,t){if(typeof e!="string")return"";let r=e.replace(/[\p{Cc}\p{Cf}]/gu," ").replace(/\s+/g," ").trim();return Array.from(r).slice(0,t).join("").trim()}function Ql(e){if(!Se(e))return;let t=Ci(e.name,nb);if(!t)return;let r=Ci(e.version,sb);return r?`${t} ${r}`:t}function Ah(e){return(t,r)=>e(t)<e(r)?-1:e(t)>e(r)?1:0}function ab(e,t,r){return{name:Ad(e,t,r),...r.title?{title:r.title}:{},description:r.description,inputSchema:r.inputSchema,...r.outputSchema?{outputSchema:r.outputSchema}:{},annotations:{...r.annotations,readOnlyHint:r.risk==="read",...r.risk==="read"?{}:{destructiveHint:r.risk==="destructive"},openWorldHint:r.annotations?.openWorldHint??!1}}}function eu(e,t={}){let r=e.surface==="gateway"?Eh(e,t):[];if(e.surface==="gateway"&&e.listing==="compact")return r;for(let o of[...e.apps].sort(Ah(n=>n.appId)))for(let n of[...o.tools].sort(Ah(a=>a.name)))Je(n,e.principal).action==="allow"&&r.push(ab(e,o,n));return r}async function ki(e,t={}){let r=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(Su(eu(e,t)))),o="";for(let n of new Uint8Array(r).subarray(0,8))o+=n.toString(16).padStart(2,"0");return o}function tu(e,t,r,o={}){let n=new wi({name:e.serverInfo.name,...e.serverInfo.title?{title:e.serverInfo.title}:{},version:Zl},{capabilities:{tools:{listChanged:o.listChanged??!1}},...e.instructions?{instructions:e.instructions}:{},jsonSchemaValidator:ls,cacheHints:{"tools/list":{ttlMs:ob,cacheScope:"private"}}});return n.setRequestHandler("tools/list",async()=>({tools:eu(e,{workspace:t.workspace!==void 0,providers:t.workspace?.providers===!0})})),n.setRequestHandler("tools/call",async a=>{let i=Ql(n.getClientVersion())??o.clientInfo,l=await Ch(e,{name:a.params.name,arguments:a.params.arguments,...r?{protocolVersion:r}:{},...i?{clientInfo:i}:{}},t);if(l.kind==="unknown_tool")throw new te(G.InvalidParams,`Unknown tool: ${jo(a.params.name)}`);return n.projectCallToolResult(l.result,l.tool.outputSchema)}),n}var Ii=class extends Error{name="ViewRefusedError"};var ru=256*1024,ib=3e4,cb=30*6e4,lb=10*6e4,ub=3,db=8,qh=128,pb=qh/4*3,Mh="2026-07-28",jh="everyapp.toolbus.view",mb="io.modelcontextprotocol/subscriptionId",hb="io.modelcontextprotocol/serverInfo",Lh={jsonrpc:"2.0",method:"notifications/tools/list_changed"},Dh={"content-type":"text/event-stream","cache-control":"no-cache, no-transform","x-accel-buffering":"no"},fb=["accept","authorization","content-type","last-event-id","mcp-method","mcp-name","mcp-protocol-version","mcp-session-id","x-everyapp-tools"].join(", ");function xh(e){let t=new Map,r,o=()=>r??=Qm(n=>{let a=yb(n);return tu(a,e,n.requestInfo?.headers.get("mcp-protocol-version")??void 0,{listChanged:a.refresh!==void 0})},{legacy:"reject",responseMode:"json",maxSubscriptions:0,maxRequestBodySize:ru});return async(n,a)=>{let i=Ib(n,e,a);if(i)return i;let l=Ob(n);if(n.method==="OPTIONS")return new Response(null,{status:204,headers:{...l,"access-control-allow-methods":"POST, OPTIONS","access-control-allow-headers":fb,"access-control-max-age":"600"}});if(n.method!=="POST")return Ai(bt(405,-32e3,"Method not allowed.",{allow:"POST, OPTIONS"}),l);let c;try{c=await $i(n.clone(),ru)}catch{return Ai(bt(400,-32700,"Parse error: the request body could not be read."),l)}if(c.tooLarge)return Ai(bt(413,-32600,"Request body too large."),l);let u;try{u=JSON.parse(c.text)}catch{u=void 0}let m={token:"toolbus",clientId:a.principal.credential.id,scopes:Kl(a.principal.access),extra:{[jh]:a}},f=u!==void 0?{parsedBody:u}:{},y=await Zm(n,u,{maxRequestBodySize:ru}),R,S=a.refresh?gb(n,u):null;return y?R=await Sb(n,a,e,m,u):S?R=await zb(n,a,e,S,t):R=await o().fetch(n,{authInfo:m,...f}),Ai(R,l)}}function gb(e,t){if(e.headers.get("mcp-method")!=="subscriptions/listen"||e.headers.get("mcp-protocol-version")!==Mh||!En(e.headers.get("content-type")))return null;let r=pi({httpMethod:e.method,protocolVersionHeader:e.headers.get("mcp-protocol-version"),mcpMethodHeader:"subscriptions/listen",mcpNameHeader:e.headers.get("mcp-name")??void 0,body:t});return r.kind==="modern"&&r.messageKind==="request"&&r.message.method==="subscriptions/listen"&&r.classification.revision===Mh?r.message:null}function yb(e){let t=e.authInfo?.extra?.[jh];if(!t)throw new Error("ToolBus request has no view");return t}function ou(e){return{workspace:e.workspace!==void 0,providers:e.workspace?.providers===!0}}async function Sb(e,t,r,o,n){if(Array.isArray(n))return bt(400,-32600,"Bad Request: JSON-RPC batches are not supported by this endpoint.");let a=kb(e.headers,n);if(a)return bt(400,-32020,`Bad Request: ${a}`,{},n);let i=Se(n)?n.method:void 0,l=Se(n)&&Se(n.params)?n.params:{},c=await ki(t,ou(r)),u=e.headers.get("mcp-session-id"),m=bb(u),f=m!==void 0&&m!==c,y=i==="initialize"?Ql(l.clientInfo):_b(u);if(f&&i==="tools/list")return bt(404,-32001,"Session not found");let R=tu(t,r,e.headers.get("mcp-protocol-version")??void 0,{listChanged:!0,...y?{clientInfo:y}:{}}),S=new ql({sessionIdGenerator:i==="initialize"?()=>Hh(c,y):void 0,enableJsonResponse:!0});try{await R.connect(S);let P=await S.handleRequest(e,{authInfo:o,...n!==void 0?{parsedBody:n}:{}});return f&&Rb(n)&&i!=="initialize"&&Uh(e)?await wb(P,c,y):P}finally{await Promise.all([S.close().catch(()=>{}),R.close().catch(()=>{})])}}function Hh(e,t){let r=t?vb(t):"";return r?`${crypto.randomUUID()}.${r}.${e}`:`${crypto.randomUUID()}.${e}`}function vb(e){let t=new TextEncoder,r=e,o=t.encode(r);for(;o.length>pb;)r=Array.from(r).slice(0,-1).join(""),o=t.encode(r);let n="";for(let a of o)n+=String.fromCharCode(a);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function _b(e){let t=e?.split(".")??[],r=t.length===3?t[1]:void 0;if(!(!r||r.length>qh||!/^[A-Za-z0-9_-]+$/.test(r)))try{let o=r.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-r.length%4)%4),n=new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(atob(o),a=>a.charCodeAt(0)));return Ci(n,Oh)||void 0}catch{return}}function bb(e){let t=e?.slice(e.lastIndexOf(".")+1);return t&&/^[0-9a-f]{16}$/.test(t)?t:void 0}function Rb(e){return Se(e)&&typeof e.method=="string"&&"id"in e}function Uh(e){return(e.headers.get("accept")??"").includes("text/event-stream")}function Oi(e){return`event: message
|
|
53
|
+
data: ${JSON.stringify(e)}
|
|
54
|
+
|
|
55
|
+
`}async function wb(e,t,r){if(e.status!==200||!e.headers.get("content-type")?.includes("application/json"))return e;let o=new Headers(e.headers);for(let[n,a]of Object.entries(Dh))o.set(n,a);return o.set("mcp-session-id",Hh(t,r)),new Response(`${Oi(Lh)}event: message
|
|
56
|
+
data: ${await e.text()}
|
|
57
|
+
|
|
58
|
+
`,{status:200,headers:o})}function Eb(e){for(let r of["toolsListChanged","promptsListChanged","resourcesListChanged"])if(r in e&&typeof e[r]!="boolean")return!1;let t=e.resourceSubscriptions;return t===void 0||Array.isArray(t)&&t.every(r=>typeof r=="string")}function Tb(e){let{credential:t}=e.principal;return t.id==="session"||t.id==="pat"?`${t.kind}:${e.principal.userId}`:t.id}function $b(e,t){return t.listenMaxMs??(e.surface==="gateway"?cb:lb)}async function zb(e,t,r,o,n){let a=o.id;if(!Uh(e))return bt(406,-32e3,"Not Acceptable: Client must accept text/event-stream");let l=(Se(o.params)?o.params:{}).notifications;if(!Se(l)||!Eb(l))return Response.json({jsonrpc:"2.0",id:a,error:{code:-32602,message:Se(l)?"notifications: invalid subscription filter":"notifications is required"}});let c=l.toolsListChanged===!0,u=t.refresh;if(!u)throw new Error("subscriptions/listen needs view.refresh");let m=Tb(t);if((n.get(m)??0)>=db)return Response.json({jsonrpc:"2.0",id:a,error:{code:-32603,message:"Subscription limit reached"}});n.set(m,(n.get(m)??0)+1);let f=()=>{let z=(n.get(m)??1)-1;z>0?n.set(m,z):n.delete(m)},y=r.listenPollMs??ib,R=$b(t,r),S={[mb]:a},P=new TextEncoder,b;try{b=await ki(t,ou(r))}catch(z){throw f(),z}let h,$=!1,v=new ReadableStream({start(z){let I=q=>z.enqueue(P.encode(q)),T=()=>{$||($=!0,f(),I(Oi({jsonrpc:"2.0",id:a,result:{resultType:"complete",_meta:{...S,[hb]:Pb(t)}}})),z.close())};if(I(Oi({jsonrpc:"2.0",method:"notifications/subscriptions/acknowledged",params:{notifications:c?{toolsListChanged:!0}:{},_meta:S}})),!c){T();return}let _=Date.now(),C=Math.min(_+R,t.listenUntil??1/0),M=0,U=async()=>{if($)return;if(Date.now()>=C){T();return}let q;try{q=await ki(await Cb(u(),y),ou(r)),M=0}catch(D){if(M+=1,D instanceof Ii||M>=ub){T();return}}$||(q===void 0||q===b?I(`: keepalive
|
|
59
|
+
|
|
60
|
+
`):(b=q,I(Oi({...Lh,params:{_meta:S}}))),h=setTimeout(U,y))};h=setTimeout(U,y)},cancel(){$||f(),$=!0,clearTimeout(h)}});return e.signal?.addEventListener("abort",()=>{$||f(),$=!0,clearTimeout(h)}),new Response(v,{status:200,headers:Dh})}function Pb(e){return{name:e.serverInfo.name,...e.serverInfo.title?{title:e.serverInfo.title}:{},version:Zl}}function Cb(e,t){let r,o=new Promise((n,a)=>{r=setTimeout(()=>a(new Error("refresh timed out")),t)});return Promise.race([e,o]).finally(()=>clearTimeout(r))}function Nh(e){let t=/^=\?base64\?(.*)\?=$/i.exec(e)?.[1];if(t===void 0)return e;try{return new TextDecoder().decode(Uint8Array.from(atob(t),r=>r.charCodeAt(0)))}catch{return e}}function kb(e,t){if(!Se(t))return null;let r=e.get("mcp-method");if(r!==null&&Nh(r)!==t.method)return`the Mcp-Method header names "${r}" but the body is "${String(t.method)}"`;let o=e.get("mcp-name");if(o!==null){let n=Se(t.params)?t.params:{},a=n.name??n.uri;if(Nh(o)!==a)return`the Mcp-Name header names "${o}" but the body names "${String(a)}"`}return null}function Vh(e){let t=e.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t==="127.0.0.1"||t==="[::1]"}function Ib(e,t,r){if(t.localhostOnly){let n=null;try{n=new URL(`http://${e.headers.get("host")??""}`).hostname}catch{n=null}if(!n||!Vh(n))return bt(403,-32e3,"Forbidden: invalid Host header.")}let o=e.headers.get("origin");return o===null||Ab(o,e,t,r)?null:bt(403,-32e3,"Forbidden: origin not allowed.")}function Ab(e,t,r,o){if(e===new URL(t.url).origin||o.allowedOrigins?.includes(e.toLowerCase()))return!0;if(!r.localhostOnly)return!1;try{let n=new URL(e);return(n.protocol==="http:"||n.protocol==="https:")&&Vh(n.hostname)}catch{return!1}}function Ob(e){let t=e.headers.get("origin");return t===null||t===new URL(e.url).origin?{}:{"access-control-allow-origin":t,"access-control-expose-headers":"mcp-protocol-version, mcp-session-id",vary:"Origin"}}function Ai(e,t){if(Object.keys(t).length===0)return e;let r=new Headers(e.headers);for(let[o,n]of Object.entries(t))r.set(o,n);return new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}function bt(e,t,r,o={},n){let a=Se(n)&&(typeof n.id=="string"||typeof n.id=="number")?n.id:null;return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:a},{status:e,headers:o})}function Bh(e,t){let r={userId:e.sub,email:e.email,organizationId:e.orgId,orgRole:e.orgRole},o=e.credential;if(!o)return{ok:!0,principal:{...r,credential:{kind:t.sessionKind,id:"session"},access:"write"}};if(o.kind!=="pat")return{ok:!1,reason:"unsupported_credential"};let n=o.scopes??[],a=n.some(l=>l==="*"||l===Yn)?"write":n.includes(Co)?"read":null;if(!a)return{ok:!1,reason:"token_scope"};let i=o.actor?.startsWith("pat:")?o.actor.slice(4):"pat";return{ok:!0,principal:{...r,credential:{kind:"pat",id:i},access:a}}}var e$=8*1024;var t$=1024*1024;function Fh(e,t,r){return{surface:"app",principal:t,apps:[e],serverInfo:{name:`every-app-${e.appId}`,title:e.name},...e.instructions?{instructions:e.instructions}:{},...r?{requestId:r}:{}}}var Mb=2e3;function Gh(e){let t=new Map(e.apps.map(u=>[u.appId,u])),r={privateKeyPem:e.privateKeyPem,issuer:e.issuer,keyId:e.keyId??Kt},o=e.catalogTtlMs??Mb,n=new Map,a=new Set,i=(u,m)=>{let f=`${u}\0${m}`;a.has(f)||(a.add(f),e.onCatalogProblem?.(u,m))},l=u=>{let m=n.get(u.appId);if(m&&m.expiresAt>Date.now())return m.snapshot;let f=Jd({...u,audience:u.appId},{signing:r,invoke:y=>u.fetcher.fetch(y)}).catch(y=>({status:"error",error:`could not reach the app (${y instanceof Error?y.message:String(y)})`}));return n.set(u.appId,{expiresAt:Date.now()+o,snapshot:f}),f},c=xh({signing:r,invokeApp:(u,m)=>{let f=t.get(u.appId);if(!f)throw new Error(`no dev app "${u.appId}"`);return f.fetcher.fetch(m)},onCatalogDrift:u=>n.delete(u.appId),audit:e.onToolCall,localhostOnly:!0});return{async serveAppHost(u,m,f){let y=t.get(m);if(!y)return null;let R=await l(y);if("error"in R)return i(m,R.error),null;if(R.status==="empty")return null;for(let b of R.warnings)i(m,b);let S=Bh(f,{sessionKind:"dev"});if(!S.ok)return Response.json({error:"forbidden",reason:S.reason},{status:403});let P={rowId:m,appId:m,audience:m,name:y.name??m,baseUrl:y.baseUrl,catalogHash:R.hash,...R.instructions?{instructions:R.instructions}:{},tools:R.tools};return c(u,Fh(P,S.principal))}}}var Jh=e=>e.replaceAll("_"," ");function Kh(e){let{out:t}=e,r=Gh({apps:[{appId:e.app.appId,name:e.appName,baseUrl:e.appUrl,fetcher:e.appFetcher}],privateKeyPem:Yt,issuer:Wt,onToolCall:o=>t.emit({type:"progress",step:"dev.mcp",message:["MCP",o.tool,o.decision==="blocked"?`blocked${o.reason?`: ${Jh(o.reason)}`:""}`:`${Jh(o.outcome)} ${o.durationMs}ms`].join(" "),data:{tool:o.tool,decision:o.decision,reason:o.reason,outcome:o.outcome,durationMs:o.durationMs}}),onCatalogProblem:(o,n)=>t.emit({type:"warning",code:"TOOLS_CATALOG",step:"dev.mcp",message:`Agent tools: ${n}`,data:{appId:o}})});return kd({apps:[e.app],env:{[`APP__${e.app.workerName}`]:e.appFetcher},authenticator:e.authenticator,interceptMcp:({request:o,app:n,session:a})=>r.serveAppHost(o,n.appId,a)})}function Wh(e,t,r){return["<!doctype html><html><head><meta charset=utf-8>","<title>every app \u2014 dev launcher</title>","<style>body{font-family:system-ui;max-width:32rem;margin:4rem auto;padding:0 1rem;color:#222}a{color:#0a7;font-size:1.25rem}p{color:#666}</style>","</head><body>","<h1>every app <small style='color:#999;font-weight:400'>dev launcher</small></h1>","<p>Signed in as <code>dev@everyapp.localhost</code> (seeded dev user \u2014 stub mode).</p>",`<p><a href="http://${e}.${r}/">${t??e} \u2192</a></p>`,"</body></html>"].join("")}function Yh(e){return{appId:e.id,hostname:`${e.id}.localhost`,workerName:Nu(e.id),tier:"service_binding",scope:"org",organizationId:zt.orgId,status:"active",manifest:e}}var nu="/__everyapp/cron";async function Zh(e,t){let r=await ef(e,t);if(r)throw await tf(r,e,t)}async function Qh(e,t,r){try{await new Promise((o,n)=>{e.once("error",n),e.listen(t,r,o)})}catch(o){throw await tf(o,t,r)}return e.address()}function ef(e,t){return new Promise(r=>{let o=Xh.createServer();o.once("error",r),o.listen(e,t,()=>o.close(()=>r(null)))})}async function tf(e,t,r){if(e.code!=="EADDRINUSE")return new De("DEV_PORT_UNAVAILABLE",`Can't listen on ${r}:${t}
|
|
61
|
+
${e.message}`,{data:{port:t,host:r,fix:"pass another --port or --host"}});let o=t+1;for(;await ef(o,r);)o++;return new De("DEV_PORT_IN_USE",`Port ${t} is already in use`,{rerun:ns("--port",String(o)),data:{port:t,host:r,free:o,error:e.message}})}function rf(e,{manifest:t,mode:r,mirrorBaseHost:o,gatewayUrl:n,authenticator:a,appPort:i,appUrl:l,out:c}){let u=Yh(t),m=jb(c),f=sc(i),y=Kh({app:u,appName:t.name,appUrl:l,appFetcher:{fetch:b=>f.fetch(b).catch(h=>{throw m.failed(b.method,new URL(b.url).pathname,h),h})},authenticator:a,out:c}),R=Number(n?.port||80),S=n?sc(R,n.hostname):null;e.on("request",(b,h)=>{(async()=>{try{let $=b.headers.host??"";if(!dc($,S?o:void 0)){P(h,$,`${t.id}.localhost`);return}if(b.method==="POST"&&b.url===nu){if($d(b.headers)){h.writeHead(403,{"content-type":"text/plain; charset=utf-8"}),h.end(`The cron trigger takes a terminal's POST (curl -X POST ... -d '<schedule>'), not a web page's.
|
|
62
|
+
`);return}await os(h,await Nb(await qb(b),i,u.workerName));return}if(S){let I=uc($,o);if(I.kind==="launcher"){let T=await S.fetch(nc(b));await os(h,T);return}if(I.kind==="invalid"||I.appLabel!==t.id){P(h,$,`${t.id}.${o}`);return}}let v=Xt($||null);if(r==="stub"&&v){if(v.appLabel===""){h.writeHead(200,{"content-type":"text/html; charset=utf-8"}),h.end(Wh(t.id,t.name,v.host));return}if(v.appLabel!==t.id&&!Xh.isIP(v.host.replace(/:\d+$/,""))){P(h,$,`${t.id}.${v.baseHost.replace(/:\d+$/,"")}`);return}}let z=await y(nc(b));await os(h,z)}catch($){m.failed(b.method??"GET",b.url??"/",$),h.headersSent||h.writeHead(502,{"content-type":"application/json"}),h.end(JSON.stringify({error:"dev_gateway_error",message:String($)}))}})()});function P(b,h,$){m.misdirected(h,$),b.writeHead(421,{"content-type":"text/plain; charset=utf-8"}),b.end(`This dev server serves ${$}, not ${h}.
|
|
63
|
+
`)}e.on("upgrade",(b,h,$)=>{if(!dc(b.headers.host??"",n?o:void 0)){h.write(`HTTP/1.1 421 Misdirected Request\r
|
|
64
|
+
Connection: close\r
|
|
65
|
+
\r
|
|
66
|
+
`),h.destroy();return}if(n&&uc(b.headers.host??"",o).kind==="launcher"){ac(b,h,$,R,{targetHost:n.hostname});return}bd(b,h,$,{appId:t.id,appPort:i,publicRoutes:u.manifest.public,parseAppLabel:v=>Xt(v)?.appLabel??"",mintIdentity:async v=>{if(a){let z=await a.authenticate(v);return z?pc(t.id,z):null}return pc(t.id)},mintPublicMarker:()=>Id(t.id)})})}async function Nb(e,t,r){let o=e.trim();return o?fetch(`http://127.0.0.1:${t}/cdn-cgi/local/explorer/api/local/scheduled?worker=${encodeURIComponent(r)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({cron:o})}):new Response(`Send the cron schedule as the body: -d '*/5 * * * *'
|
|
67
|
+
`,{status:400,headers:{"content-type":"text/plain; charset=utf-8"}})}async function qb(e){let t=[];for await(let r of e)t.push(r);return Buffer.concat(t).toString("utf8")}function jb(e){let t=new Set,r=(o,n)=>{t.has(o)||(t.add(o),n())};return{failed(o,n,a){let i=Tr(a);r(`failed
|
|
68
|
+
${i}`,()=>e.emit({type:"warning",code:"DEV_REQUEST_FAILED",message:`${o} ${n} failed in the local Gateway: ${i}`,data:{method:o,path:n,status:502}}))},misdirected(o,n){r(`misdirected
|
|
69
|
+
${o}`,()=>e.emit({type:"warning",code:"DEV_WRONG_HOST",message:`Request for ${o} refused: this dev server serves ${n}`,data:{host:o,served:n,status:421}}))}}}import su from"node:fs";import au from"node:path";import{parseEnv as Lb}from"node:util";import dt from"chalk";function of({manifest:e,mode:t,appUrl:r,appPort:o,gatewayUrl:n,loginUrl:a,crons:i,cwd:l}){let c=[{label:"App",value:dt.cyan(r)},{label:"MCP",value:`${dt.cyan(`${r}/mcp`)} ${dt.dim(t==="mirror"?"bearer: a personal access token from the local Gateway":"any bearer token acts as the dev user")}`},...t==="mirror"?[{label:"Log in",value:`${dt.cyan(a)} ${dt.dim("the session carries to the app")}`},{label:"Gateway",value:`${n} ${dt.dim("(real login and launcher)")}`}]:[{label:"Dev user",value:`${zt.email} ${dt.dim(`(${zt.orgRole} of ${zt.orgId})`)}`}],...e.resources?.workflows?.length?[{label:"Workflows",value:dt.cyan(`http://127.0.0.1:${o}/cdn-cgi/local/explorer`)}]:[],...Db(e,o),...xb(e),...i?[{label:"Cron",value:`curl -X POST ${r}${nu} -d '<schedule>'`}]:[],...Hb(e,l)];return["",...Uu(c).map(u=>` ${u}`),""].join(`
|
|
70
|
+
`)}function Db(e,t){return e.email?.inbound!==!0?[]:[{label:"Email",value:`curl -X POST "http://127.0.0.1:${t}/cdn-cgi/local/email?from=someone@example.net&to=hello@example.com" --data-binary @message.eml`}]}function xb(e){let t=(e.resources?.secretsStore??[]).map(r=>r.name);return t.length===0?[]:[{label:"Secrets Store",value:`${t.join(", ")} ${dt.dim(`${t.length===1?"is":"are"} empty locally: get() throws until seeded (https://everyapp.com/docs/agent/dev#secrets-store-in-development)`)}`}]}var iu=".dev.vars";function Hb(e,t){let r=Ub(e,cu(t));if(r.length===0)return[];let o=Vb(t),n=$u(r,(c,u)=>!!o?.[u]);if(n.ready)return[];let a=[];for(let c of n.unmet)if(c.need.kind==="required")for(let u of c.names)!o?.[u]&&!a.includes(u)&&a.push(u);let i=n.groups.filter(c=>!c.met).map(c=>`one of ${c.members.map(u=>u.names.join(" with ")).join(", ")}`),l=[...a.length>0?[a.join(", ")]:[],...i].join(" and ");return[{label:"Dev vars",value:`${o?`${iu} is missing ${l}`:`no ${iu} yet: add ${l}`} ${dt.dim(`(the app's keys for local runs; see ${Po} dev --help)`)}`}]}function Ub(e,t){return Tu(e,t).flatMap(r=>{switch(r.kind){case"provider":{let o=_u(r.id);return[o?{...r,names:bu(o)}:r]}case"capability":return Xn(r.id)&&vu[r.id].mode==="service"?[]:[r];case"ai-routes":return[];case"ai-default":return[r];case"remote-mcp":return[];case"secret":return[r]}})}function cu(e){let t=au.join(e,Au),r;try{r=su.readdirSync(t).filter(n=>n.endsWith(".json")).sort()}catch{return Ni}let o=r.flatMap(n=>{try{let a=JSON.parse(su.readFileSync(au.join(t,n),"utf8"));return[{id:a&&typeof a=="object"&&typeof a.id=="string"?a.id:n.replace(/\.json$/,""),spec:a}]}catch{return[]}});return o.length>0?Iu(o):Ni}function Vb(e){try{return Lb(su.readFileSync(au.join(e,iu),"utf8"))}catch{return null}}var Fb="http://localhost:3000",Gb="127.0.0.1",Jb=8787,Kb=5e3;async function Wb(e){let t=Vu(!1);await Bu(t,()=>Yb(e,t))}async function Yb(e,t,{cwd:r=process.cwd(),cf:o=Hu(),env:n=process.env}={}){let a=Ed(e.mode,n[lc]),i=e.gateway??Fb,l=e.baseHost??Zt;a==="mirror"&&Td(l);let c=await Xb(r);Zb(c,r,t);let u=await Qu(r);if(!c.dev&&!u)throw new De("MISSING_CLOUDFLARE_CONFIG",["No cloudflare.config.ts in this directory","EveryApp apps build their Worker in cloudflare.config.ts with everyAppWorker() from @every-app/sdk/cloudflare."].join(`
|
|
71
|
+
`),{data:{fix:"copy cloudflare.config.ts from starter/"}});let m=e.host??Gb,f=e.port??(n.PORT?Number(n.PORT):Jb);await Zh(f,m);let y=await xu(r);y.source==="project"&&y.version!==Zn&&t.emit({type:"warning",code:"CF_VERSION_DIFFERS",message:`Using the app's cf ${y.version}; everyapp is tested with ${Zn}`,data:{version:y.version,tested:Zn}});let R,S=!1,P=Lu({sync:()=>R?.stop(),async:async()=>{await R?.exited,t.emit({type:"step",step:"dev.stop",status:"ok",data:{appId:c.id,started:S}})}}),b=Hi(c.id),h=v=>{b(),b=Hi(v)},$=()=>R?.stop();process.on("exit",$);try{a==="mirror"&&await Qb(i,t),u&&!await Yu(r)&&(t.emit({type:"step",step:"dev.types",status:"start",message:"Generating Worker types..."}),await Wu(o,r),t.emit({type:"step",step:"dev.types",status:"ok",message:"Generated the Worker's types (.cloudflare/types)."})),h("the local migrations"),await Pd({cwd:r,manifest:c,cf:o,out:t,skip:e["skip-migrations"]??!1}),h(c.id);let v=await Rd();t.emit({type:"step",step:"dev.app",status:"start",message:c.dev?`Starting ${c.id} with its dev command...`:`Starting ${c.id}...`,data:{appPort:v}}),R=await Cd({cwd:r,manifest:c,cf:o,port:v});let z=Bb.createServer();try{await t0(R,v,c).catch(async C=>{throw xi()||(t.emit({type:"step",step:"dev.app",status:"fail"}),R.stop(),await R.exited,R.releaseOutput(!0)),C});let I=await Qh(z,f,m),T=a==="mirror"?`http://${c.id}.${l}:${I.port}`:`http://${c.id}.localhost:${I.port}`,_=`http://${l}:${I.port}`;rf(z,{manifest:c,mode:a,mirrorBaseHost:l,gatewayUrl:a==="mirror"?new URL(i):null,authenticator:e0(a,i,_,t),appPort:v,appUrl:T,out:t}),S=!0,h(""),t.emit({type:"step",step:"dev.app",status:"ok",message:of({manifest:c,mode:a,appUrl:T,appPort:v,gatewayUrl:i,loginUrl:_,crons:u?.hasCrons??!1,cwd:r}),data:{appId:c.id}}),R.releaseOutput(!1),t.emit({type:"step",step:"dev.ready",status:"ok",data:{mode:a,appUrl:T,mcpUrl:`${T}/mcp`,host:I.address,port:I.port,appPort:v}}),a==="stub"&&!r0(I.address)&&t.emit({type:"warning",code:"DEV_EXPOSED",message:`Listening on ${I.address}: anyone who can reach port ${I.port} gets in as the dev user`}),t.emit({type:"progress",step:"dev.session",message:"Every request goes through the real perimeter. Ctrl+C to stop."}),await R.exited}finally{z.close()}}catch(v){if(xi())return;throw R?.stop(),v}finally{process.off("exit",$),b(),P()}}async function Xb(e){try{return await Fu(e)}catch(t){throw t instanceof Mu?new De("INVALID_MANIFEST",`everyapp.config.ts isn't valid
|
|
72
|
+
${t.message}`):t}}function Zb(e,t,r){let o=cu(t);for(let n of Object.keys(e.capabilities??{})){if(Xn(n))continue;let a=Ou(n),i=o.get(n)!==void 0;r.emit({type:"warning",code:"CAPABILITY_NOT_IN_CATALOG",message:i?`${n} isn't in the built-in provider catalog
|
|
73
|
+
This run reaches it from ${a} with your key from .dev.vars; the deploy checks it against the Gateway's registered providers.`:`${n} isn't in the built-in provider catalog
|
|
74
|
+
If it's registered on your Gateway, ${Po} provider show ${n} --save writes ${a}, which this run reaches it from (start dev again after). The deploy checks it against the Gateway's registered providers.`,data:{id:n,file:a,found:i,...i?{}:{fix:`${Po} provider show ${n} --save`}}})}}async function Qb(e,t){t.emit({type:"step",step:"dev.gateway",status:"start",message:`Looking for the local Gateway at ${e}...`});try{await ic(e,Kb)}catch{throw t.emit({type:"step",step:"dev.gateway",status:"fail"}),new De("MIRROR_GATEWAY_UNREACHABLE",`No local Gateway at ${e}
|
|
75
|
+
See "mirror mode" in docs/TESTING.md.`,{data:{gatewayUrl:e,fix:"run pnpm dev in apps/every-app-gateway, or pass --gateway <url>"}})}t.emit({type:"step",step:"dev.gateway",status:"ok",data:{gatewayUrl:e}})}function e0(e,t,r,o){if(e==="mirror")return zd({gatewayUrl:t,loginUrl:r,onHint:n=>o.emit({type:"warning",code:"MIRROR_SESSION",message:n})})}async function t0(e,t,r){let o=await Promise.race([wd(t).then(()=>"up",()=>"timeout"),e.exited.then(()=>"exited")]);if(o!=="up")throw o==="exited"?new De("DEV_SERVER_FAILED",`${r.id}'s dev server exited before it was ready
|
|
76
|
+
Its output is above.`):new De("DEV_SERVER_TIMEOUT",`${r.id}'s dev server didn't start listening in time
|
|
77
|
+
It must listen on the port everyapp passes in PORT.`,{data:{appPort:t,fix:r.dev?`make its dev command (${r.dev}) listen on the port in PORT`:"in vite.config.ts, set server.port: Number(process.env.PORT)"}})}function r0(e){return e==="::1"||e.startsWith("127.")}export{Wb as default,Yb as runDev};
|
|
78
|
+
/*! Bundled license information:
|
|
79
|
+
|
|
80
|
+
@modelcontextprotocol/server/dist/src-DdvbAHrR.mjs:
|
|
81
|
+
(*!
|
|
82
|
+
* content-type
|
|
83
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
84
|
+
* MIT Licensed
|
|
85
|
+
*)
|
|
86
|
+
*/
|