@redocly/cli 2.60.0 → 2.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES +2 -2
- package/lib/chunks/{AP2GA7RS.js → 22EANOP2.js} +87 -87
- package/lib/chunks/{G4ZIYGF5.js → 2KG4GEMM.js} +1 -1
- package/lib/chunks/2OVI7BIW.js +105 -0
- package/lib/chunks/{7C244K4X.js → 2WJSVZYJ.js} +1 -1
- package/lib/chunks/{B5GZ7KU2.js → 3QZ3M2JX.js} +1 -1
- package/lib/chunks/{W7VT3BOM.js → 3TBVUHVH.js} +1 -1
- package/lib/chunks/{IAN3UOJT.js → 3VI3PRNZ.js} +1 -1
- package/lib/chunks/45DZYRBQ.js +7 -0
- package/lib/chunks/{SDNESV5E.js → 47H7SS4U.js} +1 -1
- package/lib/chunks/{SXOXAG7R.js → 5PG3ST2N.js} +2 -2
- package/lib/chunks/{V46KUEYR.js → 6DO6IN4A.js} +1 -1
- package/lib/chunks/6ETCN64B.js +20 -0
- package/lib/chunks/{XZKUPNLZ.js → 6GH5BRNP.js} +1 -1
- package/lib/chunks/{O5WCU6SC.js → 6L6AYZQS.js} +10 -10
- package/lib/chunks/{72ZX5WSN.js → 6NGWHZCB.js} +1 -1
- package/lib/chunks/{HSHAARAO.js → 6ZVVKLZR.js} +1 -1
- package/lib/chunks/{DAAOXDSB.js → 7FLYZDPU.js} +1 -1
- package/lib/chunks/{SL6UQOKE.js → 7RZON3J3.js} +1 -1
- package/lib/chunks/{GYKYFMW3.js → B6HOY6AV.js} +1 -1
- package/lib/chunks/DDAZZC3I.js +20 -0
- package/lib/chunks/{PKYNMOKV.js → DNQSGL2N.js} +1 -1
- package/lib/chunks/{UXSV2J6V.js → E5BMYA7V.js} +1 -1
- package/lib/chunks/ERFYZ47T.js +11 -0
- package/lib/chunks/{MJYI42E6.js → F6IXS3RL.js} +1 -1
- package/lib/chunks/{BHUCIWQF.js → FAIK7Y6U.js} +1 -1
- package/lib/chunks/{SNR3DAVL.js → FAZWASU6.js} +1 -1
- package/lib/chunks/{HFGKPU2P.js → FDMXHRDK.js} +1 -1
- package/lib/chunks/{HZZP3BZQ.js → FUH5ZFZ2.js} +1 -1
- package/lib/chunks/{RDMFHSDB.js → GGRILIN6.js} +1 -1
- package/lib/chunks/{HNKSHJLU.js → GJDVFWVH.js} +1 -1
- package/lib/chunks/{GHPOEF7A.js → GLOLLUKD.js} +1 -1
- package/lib/chunks/{N4AA4DRD.js → GZ7EDJXV.js} +1 -1
- package/lib/chunks/{WFIIXHF3.js → HBPMIV7U.js} +1 -1
- package/lib/chunks/{HVO5F4MP.js → HHJX3B7U.js} +1 -1
- package/lib/chunks/{HQUG6XPO.js → IKDYY4XW.js} +2 -2
- package/lib/chunks/{Q526MFO3.js → IMYWYFYT.js} +1 -1
- package/lib/chunks/{MCJLOALK.js → IRHTRVFK.js} +1 -1
- package/lib/chunks/{CEPC3LL4.js → JP2RKFML.js} +1 -1
- package/lib/chunks/{52MW7SRF.js → KRCCY64H.js} +1 -1
- package/lib/chunks/{QGUZ4KFX.js → KVXNE2UB.js} +1 -1
- package/lib/chunks/{S5G22GL5.js → LR2FZ43E.js} +1 -1
- package/lib/chunks/{4XDEFJCF.js → LRLGVYCG.js} +1 -1
- package/lib/chunks/{DJWI7SF7.js → LXU55G2P.js} +1 -1
- package/lib/chunks/{NADFEIIN.js → MAHMSXK6.js} +1 -1
- package/lib/chunks/{3MPID4OC.js → MK6X55UC.js} +1 -1
- package/lib/chunks/{XHDOW23C.js → MNH2K4WM.js} +1 -1
- package/lib/chunks/{ZJAFKITR.js → MUKYSFRK.js} +1 -1
- package/lib/chunks/MXOINKB2.js +7 -0
- package/lib/chunks/{YNPWONFN.js → OP7NIAI7.js} +1 -1
- package/lib/chunks/{LF35KJ5M.js → OXA7GLZA.js} +1 -1
- package/lib/chunks/{CKZ35ARL.js → PSEWUH36.js} +1 -1
- package/lib/chunks/{ACVFQG4D.js → PTNNX4IU.js} +1 -1
- package/lib/chunks/{J4NCFMOR.js → QFJ6QZPG.js} +1 -1
- package/lib/chunks/{W3K4YAMS.js → RPHIT72T.js} +1 -1
- package/lib/chunks/{DTMC35L3.js → RPQMBRTA.js} +1 -1
- package/lib/chunks/{CAJM6OL3.js → SFNDGMJM.js} +1 -1
- package/lib/chunks/{VCV3FKMW.js → SLQPKXO2.js} +1 -1
- package/lib/chunks/{7ED6ZTTH.js → SYWAPWW7.js} +1 -1
- package/lib/chunks/{UPHYYNN3.js → SZVRKEMY.js} +5 -5
- package/lib/chunks/{O4RAFGZA.js → TBZEEKTV.js} +1 -1
- package/lib/chunks/{EXCIOEBN.js → US7X4XPD.js} +1 -1
- package/lib/chunks/{4WAQNM63.js → V5CIDI6D.js} +58 -12
- package/lib/chunks/WCWEP2X5.js +20 -0
- package/lib/chunks/{4HEJ6GQB.js → WEOCCL26.js} +2 -2
- package/lib/chunks/{2F2YM4RD.js → WSOBFTCE.js} +1 -1
- package/lib/chunks/{2U6O26CV.js → XJE2OFDN.js} +116 -16
- package/lib/chunks/{GD6WKI2C.js → YEOWW3LR.js} +1 -1
- package/lib/chunks/{S46ENZHC.js → ZH5HJBCG.js} +1 -1
- package/lib/chunks/{S27TE7KZ.js → ZOE6CZ74.js} +1 -1
- package/lib/eject-assets/AGENTS.md +24 -23
- package/lib/eject-assets/generators/cli/docs.ts +1 -1
- package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
- package/lib/eject-assets/generators/cli/index.ts +2 -2
- package/lib/eject-assets/generators/cli/render.ts +1 -1
- package/lib/eject-assets/generators/go/client.ts +1 -1
- package/lib/eject-assets/generators/go/descriptor.ts +1 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +35 -3
- package/lib/eject-assets/generators/go/pagination.ts +1 -1
- package/lib/eject-assets/generators/go/types.ts +1 -1
- package/lib/eject-assets/generators/mock/faker.ts +1 -1
- package/lib/eject-assets/generators/mock/index.ts +2 -2
- package/lib/eject-assets/generators/mock/render.ts +1 -1
- package/lib/eject-assets/generators/mock/sample.ts +1 -1
- package/lib/eject-assets/generators/mock/values.ts +1 -1
- package/lib/eject-assets/generators/php/client.ts +1 -1
- package/lib/eject-assets/generators/php/descriptor.ts +1 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +21 -3
- package/lib/eject-assets/generators/php/pagination.ts +1 -1
- package/lib/eject-assets/generators/php/types.ts +1 -1
- package/lib/eject-assets/generators/python/client.ts +1 -1
- package/lib/eject-assets/generators/python/descriptor.ts +1 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +19 -6
- package/lib/eject-assets/generators/python/pagination.ts +1 -1
- package/lib/eject-assets/generators/python/types.ts +1 -1
- package/lib/eject-assets/generators/swr/index.ts +2 -2
- package/lib/eject-assets/generators/swr/render.ts +1 -1
- package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +2 -2
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +3 -4
- package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
- package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
- package/lib/eject-assets/generators/typescript/types.ts +1 -1
- package/lib/eject-assets/generators/zod/index.ts +2 -2
- package/lib/eject-assets/generators/zod/schemas.ts +1 -1
- package/lib/eject-assets/skills/client-generators/SKILL.md +24 -23
- package/lib/eject-assets/skills/go-generator/SKILL.md +11 -0
- package/lib/eject-assets/skills/php-generator/SKILL.md +16 -0
- package/lib/eject-assets/skills/python-generator/SKILL.md +13 -0
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +16 -0
- package/lib/index.js +54 -54
- package/package.json +1 -1
- package/lib/chunks/BZBFESBB.js +0 -11
- package/lib/chunks/DJXBNZCO.js +0 -7
- package/lib/chunks/GC26XZYZ.js +0 -20
- package/lib/chunks/IJ43XWPG.js +0 -20
- package/lib/chunks/OKTLNLO3.js +0 -7
- package/lib/chunks/PGZIUA7J.js +0 -105
- package/lib/chunks/XQA4EEZA.js +0 -20
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a}from"./
|
|
7
|
+
import{a}from"./FAIK7Y6U.js";import"./MAHMSXK6.js";import"./6L6AYZQS.js";import"./ERFYZ47T.js";import"./V5CIDI6D.js";import"./WZXA5XPB.js";import"./22EANOP2.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{a as tanstackQueryGenerator};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{O as ks,P as $s,X as Np,Y as jp,ba as ho,c as Se,ca as go,ga as hr,ia as _e,oa as ye,pa as Ps}from"./22EANOP2.js";import"./NEWT5A6S.js";import{a as Oe,c as ae,d as mo,e as mr}from"./RFWIIJFG.js";var ql=ae((kb,Ul)=>{Ul.exports=Ll;Ll.sync=Mh;var Ml=Oe("fs");function jh(e,t){var r=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var o=0;o<r.length;o++){var n=r[o].toLowerCase();if(n&&e.substr(-n.length).toLowerCase()===n)return!0}return!1}function Dl(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:jh(t,r)}function Ll(e,t,r){Ml.stat(e,function(o,n){r(o,o?!1:Dl(n,e,t))})}function Mh(e,t){return Dl(Ml.statSync(e),e,t)}});var Wl=ae(($b,Jl)=>{Jl.exports=Vl;Vl.sync=Dh;var Fl=Oe("fs");function Vl(e,t,r){Fl.stat(e,function(o,n){r(o,o?!1:Hl(n,t))})}function Dh(e,t){return Hl(Fl.statSync(e),t)}function Hl(e,t){return e.isFile()&&Lh(e,t)}function Lh(e,t){var r=e.mode,o=e.uid,n=e.gid,s=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),i=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),p=a|c,d=r&u||r&c&&n===i||r&a&&o===s||r&p&&s===0;return d}});var Gl=ae((Tb,Bl)=>{var Pb=Oe("fs"),co;process.platform==="win32"||global.TESTING_WINDOWS?co=ql():co=Wl();Bl.exports=ls;ls.sync=Uh;function ls(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(o,n){ls(e,t||{},function(s,i){s?n(s):o(i)})})}co(e,t||{},function(o,n){o&&(o.code==="EACCES"||t&&t.ignoreErrors)&&(o=null,n=!1),r(o,n)})}function Uh(e,t){try{return co.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var rp=ae((Rb,tp)=>{var St=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Kl=Oe("path"),qh=St?";":":",Xl=Gl(),Yl=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Ql=(e,t)=>{let r=t.colon||qh,o=e.match(/\//)||St&&e.match(/\\/)?[""]:[...St?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],n=St?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=St?n.split(r):[""];return St&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:o,pathExt:s,pathExtExe:n}},ep=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:o,pathExt:n,pathExtExe:s}=Ql(e,t),i=[],a=u=>new Promise((p,d)=>{if(u===o.length)return t.all&&i.length?p(i):d(Yl(e));let m=o[u],h=/^".*"$/.test(m)?m.slice(1,-1):m,_=Kl.join(h,e),w=!h&&/^\.[\\\/]/.test(e)?e.slice(0,2)+_:_;p(c(w,u,0))}),c=(u,p,d)=>new Promise((m,h)=>{if(d===n.length)return m(a(p+1));let _=n[d];Xl(u+_,{pathExt:s},(w,v)=>{if(!w&&v)if(t.all)i.push(u+_);else return m(u+_);return m(c(u,p,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},Fh=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:o,pathExtExe:n}=Ql(e,t),s=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Kl.join(c,e),p=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+u:u;for(let d=0;d<o.length;d++){let m=p+o[d];try{if(Xl.sync(m,{pathExt:n}))if(t.all)s.push(m);else return m}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw Yl(e)};tp.exports=ep;ep.sync=Fh});var np=ae((Eb,ps)=>{"use strict";var op=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(o=>o.toUpperCase()==="PATH")||"Path"};ps.exports=op;ps.exports.default=op});var cp=ae((Cb,ap)=>{"use strict";var sp=Oe("path"),Vh=rp(),Hh=np();function ip(e,t){let r=e.options.env||process.env,o=process.cwd(),n=e.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let i;try{i=Vh.sync(e.command,{path:r[Hh({env:r})],pathExt:t?sp.delimiter:void 0})}catch{}finally{s&&process.chdir(o)}return i&&(i=sp.resolve(n?e.options.cwd:"",i)),i}function Jh(e){return ip(e)||ip(e,!0)}ap.exports=Jh});var up=ae((Ib,fs)=>{"use strict";var ds=/([()\][%!^"`<>&|;, *?])/g;function Wh(e){return e=e.replace(ds,"^$1"),e}function Bh(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(ds,"^$1"),t&&(e=e.replace(ds,"^$1")),e}fs.exports.command=Wh;fs.exports.argument=Bh});var pp=ae((Ob,lp)=>{"use strict";lp.exports=/^#!(.*)/});var fp=ae((Zb,dp)=>{"use strict";var Gh=pp();dp.exports=(e="")=>{let t=e.match(Gh);if(!t)return null;let[r,o]=t[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?o:o?`${n} ${o}`:n}});var hp=ae((Ab,mp)=>{"use strict";var ms=Oe("fs"),Kh=fp();function Xh(e){let r=Buffer.alloc(150),o;try{o=ms.openSync(e,"r"),ms.readSync(o,r,0,150,0),ms.closeSync(o)}catch{}return Kh(r.toString())}mp.exports=Xh});var xp=ae((Nb,yp)=>{"use strict";var Yh=Oe("path"),gp=cp(),_p=up(),Qh=hp(),eg=process.platform==="win32",tg=/\.(?:com|exe)$/i,rg=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function og(e){e.file=gp(e);let t=e.file&&Qh(e.file);return t?(e.args.unshift(e.file),e.command=t,gp(e)):e.file}function ng(e){if(!eg)return e;let t=og(e),r=!tg.test(t);if(e.options.forceShell||r){let o=rg.test(t);e.command=Yh.normalize(e.command),e.command=_p.command(e.command),e.args=e.args.map(s=>_p.argument(s,o));let n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function sg(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);let o={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?o:ng(o)}yp.exports=sg});var vp=ae((jb,wp)=>{"use strict";var hs=process.platform==="win32";function gs(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function ig(e,t){if(!hs)return;let r=e.emit;e.emit=function(o,n){if(o==="exit"){let s=zp(n,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function zp(e,t){return hs&&e===1&&!t.file?gs(t.original,"spawn"):null}function ag(e,t){return hs&&e===1&&!t.file?gs(t.original,"spawnSync"):null}wp.exports={hookChildProcess:ig,verifyENOENT:zp,verifyENOENTSync:ag,notFoundError:gs}});var kp=ae((Mb,kt)=>{"use strict";var bp=Oe("child_process"),_s=xp(),ys=vp();function Sp(e,t,r){let o=_s(e,t,r),n=bp.spawn(o.command,o.args,o.options);return ys.hookChildProcess(n,o),n}function cg(e,t,r){let o=_s(e,t,r),n=bp.spawnSync(o.command,o.args,o.options);return n.error=n.error||ys.verifyENOENTSync(n.status,o),n}kt.exports=Sp;kt.exports.spawn=Sp;kt.exports.sync=cg;kt.exports._parse=_s;kt.exports._enoent=ys});var Cp=ae(zs=>{"use strict";var Tp=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,mg=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Rp=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,hg=/\\([\u000b\u0020-\u00ff])/g,gg=/([\\"])/g,Ep=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;zs.format=_g;zs.parse=yg;function _g(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!Ep.test(r))throw new TypeError("invalid type");var o=r;if(t&&typeof t=="object")for(var n,s=Object.keys(t).sort(),i=0;i<s.length;i++){if(n=s[i],!Rp.test(n))throw new TypeError("invalid parameter name");o+="; "+n+"="+zg(t[n])}return o}function yg(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?xg(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),o=r!==-1?t.slice(0,r).trim():t.trim();if(!Ep.test(o))throw new TypeError("invalid media type");var n=new wg(o.toLowerCase());if(r!==-1){var s,i,a;for(Tp.lastIndex=r;i=Tp.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,s=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(hg,"$1"))),n.parameters[s]=a}if(r!==t.length)throw new TypeError("invalid parameter format")}return n}function xg(e){var t;if(typeof e.getHeader=="function"?t=e.getHeader("content-type"):typeof e.headers=="object"&&(t=e.headers&&e.headers["content-type"]),typeof t!="string")throw new TypeError("content-type header is missing from object");return t}function zg(e){var t=String(e);if(Rp.test(t))return t;if(t.length>0&&!mg.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(gg,"\\$1")+'"'}function wg(e){this.parameters=Object.create(null),this.type=e}});import{existsSync as Pg,mkdirSync as Tg,readFileSync as Rg,writeFileSync as Eg}from"node:fs";import{dirname as Cg}from"node:path";import{isDeepStrictEqual as Pt}from"node:util";function $t(e){let t=new Map;for(let r of Array.isArray(e)?e:[])Se(r)&&t.set(r.name,r);return t}function gr(e,t,r){let o=$t(t);return e.map(n=>{let s=o.get(n.name),i={};for(let a of r)s&&s[a]!==void 0&&(i[a]=s[a]);return{...n,...i}})}function Mp(e,t){let r=$t(t);return gr(e,t,["tags","security"]).map(o=>{if(!o.arguments)return o;let n=r.get(o.name)?.arguments;return{...o,arguments:gr(o.arguments,n,["example"])}})}function _o(e,t,r){let o=e??{openapi:"3.1.0",info:{title:t.serverInfo?.title||t.serverInfo?.name||"MCP API",...t.instructions?{description:t.instructions}:{},version:t.serverInfo?.version||"1.0.0"},paths:{}},n=Se(o["x-mcp"])?o["x-mcp"]:{},s={...n};if(t.protocolVersion&&(s.protocolVersion=t.protocolVersion),r){let i=Array.isArray(s.servers)?s.servers:[];i.some(a=>Se(a)&&a.url===r)||i.push({url:r}),s.servers=i}return t.capabilities&&(s.capabilities=t.capabilities),t.capabilities?.tools?s.tools=gr(t.tools,n.tools,["tags","security"]):delete s.tools,t.capabilities?.prompts?s.prompts=Mp(t.prompts,n.prompts):delete s.prompts,t.capabilities?.resources?s.resources=gr(t.resources,n.resources,["tags","security"]):delete s.resources,o["x-mcp"]=s,o}function Dp(e,t){let r=$t(e),o=$t(t),n=[...o.keys()].filter(c=>!r.has(c)),s=[...r.keys()].filter(c=>!o.has(c)),i=[...o.keys()].filter(c=>r.has(c)&&!Pt(r.get(c),o.get(c))),a=[];return n.length>0&&a.push(`added: ${n.join(", ")}`),s.length>0&&a.push(`removed: ${s.join(", ")}`),i.length>0&&a.push(`changed: ${i.join(", ")}`),a.length>0?a.join("; "):void 0}function Ts(e,t){if(Pt(e,t))return[];let r=Se(e["x-mcp"])?e["x-mcp"]:{},o=Se(t["x-mcp"])?t["x-mcp"]:{},n=[];for(let s of["tools","prompts","resources"]){let i=Dp(r[s],o[s]);i&&n.push(`${s} - ${i}`)}return Pt(r.protocolVersion,o.protocolVersion)||n.push(`protocolVersion - ${r.protocolVersion??"not set"} -> ${o.protocolVersion}`),Pt(r.capabilities,o.capabilities)||n.push("capabilities changed"),Pt(r.servers,o.servers)||n.push("servers - the MCP server URL is not listed"),n.length===0&&n.push("x-mcp changed"),n}var Rs,yo=Object.freeze({status:"aborted"});function f(e,t,r){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=i.prototype,p=Object.keys(u);for(let d=0;d<p.length;d++){let m=p[d];m in a||(a[m]=u[m].bind(a))}}let n=r?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function i(a){var c;let u=r?.Parent?new s:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let p of u._zod.deferred)p();return u}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var ve=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},rt=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Rs=globalThis).__zod_globalConfig??(Rs.__zod_globalConfig={});var ot=globalThis.__zod_globalConfig;function ce(e){return e&&Object.assign(ot,e),ot}var E={};mo(E,{BIGINT_FORMAT_RANGES:()=>Os,Class:()=>zo,NUMBER_FORMAT_RANGES:()=>$o,aborted:()=>Ne,allowsEval:()=>bo,assert:()=>Vp,assertEqual:()=>Lp,assertIs:()=>qp,assertNever:()=>Fp,assertNotEqual:()=>Up,assignProp:()=>Ze,base64ToUint8Array:()=>As,base64urlToUint8Array:()=>ad,cached:()=>st,captureStackTrace:()=>xr,cleanEnum:()=>id,cleanRegex:()=>Ct,clone:()=>fe,cloneDef:()=>Jp,createTransparentProxy:()=>Yp,defineLazy:()=>Z,esc:()=>yr,escapeRegex:()=>$e,explicitlyAborted:()=>Po,extend:()=>td,finalizeIssue:()=>me,floatSafeRemainder:()=>wo,getElementAtPath:()=>Wp,getEnumValues:()=>Rt,getLengthableOrigin:()=>It,getParsedType:()=>Xp,getSizableOrigin:()=>Zs,hexToUint8Array:()=>ud,isObject:()=>Ve,isPlainObject:()=>Ae,issue:()=>it,joinValues:()=>_r,jsonStringifyReplacer:()=>nt,merge:()=>od,mergeDefs:()=>ke,normalizeParams:()=>S,nullish:()=>Et,numKeys:()=>Kp,objectClone:()=>Hp,omit:()=>ed,optionalKeys:()=>ko,parsedType:()=>To,partial:()=>nd,pick:()=>Qp,prefixIssues:()=>Pe,primitiveTypes:()=>Is,promiseAllObject:()=>Bp,propertyKeyTypes:()=>So,randomString:()=>Gp,required:()=>sd,safeExtend:()=>rd,shallowClone:()=>Cs,slugify:()=>vo,stringifyPrimitive:()=>zr,uint8ArrayToBase64:()=>Ns,uint8ArrayToBase64url:()=>cd,uint8ArrayToHex:()=>ld,unwrapMessage:()=>Tt});function Lp(e){return e}function Up(e){return e}function qp(e){}function Fp(e){throw new Error("Unexpected value in exhaustive check")}function Vp(e){}function Rt(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function _r(e,t="|"){return e.map(r=>zr(r)).join(t)}function nt(e,t){return typeof t=="bigint"?t.toString():t}function st(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Et(e){return e==null}function Ct(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function wo(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var Es=Symbol("evaluating");function Z(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==Es)return o===void 0&&(o=Es,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Hp(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ze(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ke(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function Jp(e){return ke(e._zod.def)}function Wp(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function Bp(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let s=0;s<t.length;s++)n[t[s]]=o[s];return n})}function Gp(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function yr(e){return JSON.stringify(e)}function vo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var bo=st(()=>{if(ot.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ae(e){if(Ve(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Ve(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Cs(e){return Ae(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Kp(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Xp=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},So=new Set(["string","number","symbol"]),Is=new Set(["string","number","bigint","boolean","symbol","undefined"]);function $e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function S(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Yp(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,s){return t??(t=e()),Reflect.set(t,o,n,s)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function zr(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ko(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var $o={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Os={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Qp(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=ke(e._zod.def,{get shape(){let i={};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=r.shape[a])}return Ze(this,"shape",i),i},checks:[]});return fe(e,s)}function ed(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=ke(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return Ze(this,"shape",i),i},checks:[]});return fe(e,s)}function td(e,t){if(!Ae(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=ke(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return Ze(this,"shape",s),s}});return fe(e,n)}function rd(e,t){if(!Ae(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=ke(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Ze(this,"shape",o),o}});return fe(e,r)}function od(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=ke(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return Ze(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return fe(e,r)}function nd(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=ke(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Ze(this,"shape",c),c},checks:[]});return fe(t,i)}function sd(e,t,r){let o=ke(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(let i in n)s[i]=new e({type:"nonoptional",innerType:n[i]});return Ze(this,"shape",s),s}});return fe(t,o)}function Ne(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Po(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Pe(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Tt(e){return typeof e=="string"?e:e?.message}function me(e,t,r){let o=e.message?e.message:Tt(e.inst?._zod.def?.error?.(e))??Tt(t?.error?.(e))??Tt(r.customError?.(e))??Tt(r.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:i,...a}=e;return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=i),a}function Zs(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function It(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function To(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function it(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function id(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function As(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function Ns(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function ad(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return As(t+r)}function cd(e){return Ns(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ud(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function ld(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var zo=class{constructor(...t){}};var js=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,nt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wr=f("$ZodError",js),Ro=f("$ZodError",js,{Parent:Error});function Eo(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):o.push(t(n));return{formErrors:o,fieldErrors:r}}function Co(e,t=r=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")o({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")o({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let p=a[u];u===a.length-1?(c[p]=c[p]||{_errors:[]},c[p]._errors.push(t(i))):c[p]=c[p]||{_errors:[]},c=c[p],u++}}}};return o(e),r}var vr=e=>(t,r,o,n)=>{let s=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ve;if(i.issues.length){let a=new(n?.Err??e)(i.issues.map(c=>me(c,s,ce())));throw xr(a,n?.callee),a}return i.value};var br=e=>async(t,r,o,n)=>{let s=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(n?.Err??e)(i.issues.map(c=>me(c,s,ce())));throw xr(a,n?.callee),a}return i.value};var Ot=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new ve;return s.issues.length?{success:!1,error:new(e??wr)(s.issues.map(i=>me(i,n,ce())))}:{success:!0,data:s.value}},Zt=Ot(Ro),At=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>me(i,n,ce())))}:{success:!0,data:s.value}},Sr=At(Ro),Ms=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return vr(e)(t,r,n)};var Ds=e=>(t,r,o)=>vr(e)(t,r,o);var Ls=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return br(e)(t,r,n)};var Us=e=>async(t,r,o)=>br(e)(t,r,o);var qs=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ot(e)(t,r,n)};var Fs=e=>(t,r,o)=>Ot(e)(t,r,o);var Vs=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return At(e)(t,r,n)};var Hs=e=>async(t,r,o)=>At(e)(t,r,o);var Js=/^[cC][0-9a-z]{6,}$/,Ws=/^[0-9a-z]+$/,Bs=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Gs=/^[0-9a-vA-V]{20}$/,Ks=/^[A-Za-z0-9]{27}$/,Xs=/^[a-zA-Z0-9_-]{21}$/,Ys=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Qs=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Io=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var ei=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var dd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ti(){return new RegExp(dd,"u")}var ri=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,oi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var ni=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,si=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ii=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Oo=/^[A-Za-z0-9_-]*$/;var ai=/^https?$/,ci=/^\+[1-9]\d{6,14}$/,ui="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",li=new RegExp(`^${ui}$`);function pi(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function di(e){return new RegExp(`^${pi(e)}$`)}function fi(e){let t=pi({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${ui}T(?:${o})$`)}var mi=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},hi=/^-?\d+n?$/,gi=/^-?\d+$/,Zo=/^-?\d+(?:\.\d+)?$/,_i=/^(?:true|false)$/i,yi=/^null$/i;var xi=/^[^A-Z]*$/,zi=/^[^a-z]*$/;var Q=f("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),wi={number:"number",bigint:"bigint",object:"date"},Ao=f("$ZodCheckLessThan",(e,t)=>{Q.init(e,t);let r=wi[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),No=f("$ZodCheckGreaterThan",(e,t)=>{Q.init(e,t);let r=wi[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vi=f("$ZodCheckMultipleOf",(e,t)=>{Q.init(e,t),e._zod.onattach.push(r=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):wo(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),bi=f("$ZodCheckNumberFormat",(e,t)=>{Q.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=$o[t.format];e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,a.minimum=n,a.maximum=s,r&&(a.pattern=gi)}),e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}a<n&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Si=f("$ZodCheckMaxLength",(e,t)=>{var r;Q.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!Et(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let n=o.value;if(n.length<=t.maximum)return;let i=It(n);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ki=f("$ZodCheckMinLength",(e,t)=>{var r;Q.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!Et(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let n=o.value;if(n.length>=t.minimum)return;let i=It(n);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),$i=f("$ZodCheckLengthEquals",(e,t)=>{var r;Q.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!Et(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=o=>{let n=o.value,s=n.length;if(s===t.length)return;let i=It(n),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),jt=f("$ZodCheckStringFormat",(e,t)=>{var r,o;Q.init(e,t),e._zod.onattach.push(n=>{let s=n._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Pi=f("$ZodCheckRegex",(e,t)=>{jt.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ti=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=xi),jt.init(e,t)}),Ri=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zi),jt.init(e,t)}),Ei=f("$ZodCheckIncludes",(e,t)=>{Q.init(e,t);let r=$e(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ci=f("$ZodCheckStartsWith",(e,t)=>{Q.init(e,t);let r=new RegExp(`^${$e(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ii=f("$ZodCheckEndsWith",(e,t)=>{Q.init(e,t);let r=new RegExp(`.*${$e(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var Oi=f("$ZodCheckOverwrite",(e,t)=>{Q.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var kr=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
|
|
8
|
+
`).filter(i=>i),n=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(n)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.args,n=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,n.join(`
|
|
9
|
+
`))}};var Ai={major:4,minor:4,patch:3};var N=f("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ai;let o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(let n of o)for(let s of n._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(i,a,c)=>{let u=Ne(i),p;for(let d of a){if(d._zod.def.when){if(Po(i)||!d._zod.def.when(i))continue}else if(u)continue;let m=i.issues.length,h=d._zod.check(i);if(h instanceof Promise&&c?.async===!1)throw new ve;if(p||h instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await h,i.issues.length!==m&&(u||(u=Ne(i,m)))});else{if(i.issues.length===m)continue;u||(u=Ne(i,m))}}return p?p.then(()=>i):i},s=(i,a,c)=>{if(Ne(i))return i.aborted=!0,i;let u=n(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new ve;return u.then(p=>e._zod.parse(p,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){let u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(p=>s(p,i,a)):s(u,i,a)}let c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new ve;return c.then(u=>n(u,o,a))}return n(c,o,a)}}Z(e,"~standard",()=>({validate:n=>{try{let s=Zt(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Sr(e,n).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Tr=f("$ZodString",(e,t)=>{N.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??mi(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),U=f("$ZodStringFormat",(e,t)=>{jt.init(e,t),Tr.init(e,t)}),Vi=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qs),U.init(e,t)}),Hi=f("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Io(o))}else t.pattern??(t.pattern=Io());U.init(e,t)}),Ji=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ei),U.init(e,t)}),Wi=f("$ZodURL",(e,t)=>{U.init(e,t),e._zod.check=r=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===ai.source&&!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let n=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Bi=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ti()),U.init(e,t)}),Gi=f("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Xs),U.init(e,t)}),Ki=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Js),U.init(e,t)}),Xi=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ws),U.init(e,t)}),Yi=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Bs),U.init(e,t)}),Qi=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Gs),U.init(e,t)}),ea=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ks),U.init(e,t)}),ta=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=fi(t)),U.init(e,t)}),ra=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=li),U.init(e,t)}),oa=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=di(t)),U.init(e,t)}),na=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ys),U.init(e,t)}),sa=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ri),U.init(e,t),e._zod.bag.format="ipv4"}),ia=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=oi),U.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var aa=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ni),U.init(e,t)}),ca=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=si),U.init(e,t),e._zod.check=r=>{let o=r.value.split("/");try{if(o.length!==2)throw new Error;let[n,s]=o;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function ua(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var la=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ii),U.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{ua(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function hd(e){if(!Oo.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return ua(r)}var pa=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Oo),U.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{hd(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),da=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ci),U.init(e,t)});function gd(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var fa=f("$ZodJWT",(e,t)=>{U.init(e,t),e._zod.check=r=>{gd(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Mo=f("$ZodNumber",(e,t)=>{N.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zo,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),ma=f("$ZodNumberFormat",(e,t)=>{bi.init(e,t),Mo.init(e,t)}),ha=f("$ZodBoolean",(e,t)=>{N.init(e,t),e._zod.pattern=_i,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),ga=f("$ZodBigInt",(e,t)=>{N.init(e,t),e._zod.pattern=hi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var _a=f("$ZodNull",(e,t)=>{N.init(e,t),e._zod.pattern=yi,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),ya=f("$ZodAny",(e,t)=>{N.init(e,t),e._zod.parse=r=>r}),xa=f("$ZodUnknown",(e,t)=>{N.init(e,t),e._zod.parse=r=>r}),za=f("$ZodNever",(e,t)=>{N.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var wa=f("$ZodDate",(e,t)=>{N.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,s=n instanceof Date;return s&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Ni(e,t,r){e.issues.length&&t.issues.push(...Pe(r,e.issues)),t.value[r]=e.value}var va=f("$ZodArray",(e,t)=>{N.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let s=[];for(let i=0;i<n.length;i++){let a=n[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(u=>Ni(u,r,i))):Ni(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Pr(e,t,r,o,n,s){let i=r in o;if(e.issues.length){if(n&&s&&!i)return;t.issues.push(...Pe(r,e.issues))}if(!i&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function ba(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);let r=ko(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Sa(e,t,r,o,n,s){let i=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,p=c.optin==="optional",d=c.optout==="optional";for(let m in t){if(m==="__proto__"||a.has(m))continue;if(u==="never"){i.push(m);continue}let h=c.run({value:t[m],issues:[]},o);h instanceof Promise?e.push(h.then(_=>Pr(_,r,m,t,p,d))):Pr(h,r,m,t,p,d)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var _d=f("$ZodObject",(e,t)=>{if(N.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=st(()=>ba(t));Z(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let p=a[u]._zod;if(p.values){c[u]??(c[u]=new Set);for(let d of p.values)c[u].add(d)}}return c});let n=Ve,s=t.catchall,i;e._zod.parse=(a,c)=>{i??(i=o.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let p=[],d=i.shape;for(let m of i.keys){let h=d[m],_=h._zod.optin==="optional",w=h._zod.optout==="optional",v=h._zod.run({value:u[m],issues:[]},c);v instanceof Promise?p.push(v.then(L=>Pr(L,a,m,u,_,w))):Pr(v,a,m,u,_,w)}return s?Sa(p,u,a,c,o.value,e):p.length?Promise.all(p).then(()=>a):a}}),ka=f("$ZodObjectJIT",(e,t)=>{_d.init(e,t);let r=e._zod.parse,o=st(()=>ba(t)),n=m=>{let h=new kr(["shape","payload","ctx"]),_=o.value,w=A=>{let I=yr(A);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};h.write("const input = payload.value;");let v=Object.create(null),L=0;for(let A of _.keys)v[A]=`key_${L++}`;h.write("const newResult = {};");for(let A of _.keys){let I=v[A],g=yr(A),z=m[A],T=z?._zod?.optin==="optional",W=z?._zod?.optout==="optional";h.write(`const ${I} = ${w(A)};`),T&&W?h.write(`
|
|
10
|
+
if (${I}.issues.length) {
|
|
11
|
+
if (${g} in input) {
|
|
12
|
+
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
13
|
+
...iss,
|
|
14
|
+
path: iss.path ? [${g}, ...iss.path] : [${g}]
|
|
15
|
+
})));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (${I}.value === undefined) {
|
|
20
|
+
if (${g} in input) {
|
|
21
|
+
newResult[${g}] = undefined;
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
newResult[${g}] = ${I}.value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
`):T?h.write(`
|
|
28
|
+
if (${I}.issues.length) {
|
|
29
|
+
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
30
|
+
...iss,
|
|
31
|
+
path: iss.path ? [${g}, ...iss.path] : [${g}]
|
|
32
|
+
})));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (${I}.value === undefined) {
|
|
36
|
+
if (${g} in input) {
|
|
37
|
+
newResult[${g}] = undefined;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
newResult[${g}] = ${I}.value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
`):h.write(`
|
|
44
|
+
const ${I}_present = ${g} in input;
|
|
45
|
+
if (${I}.issues.length) {
|
|
46
|
+
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
47
|
+
...iss,
|
|
48
|
+
path: iss.path ? [${g}, ...iss.path] : [${g}]
|
|
49
|
+
})));
|
|
50
|
+
}
|
|
51
|
+
if (!${I}_present && !${I}.issues.length) {
|
|
52
|
+
payload.issues.push({
|
|
53
|
+
code: "invalid_type",
|
|
54
|
+
expected: "nonoptional",
|
|
55
|
+
input: undefined,
|
|
56
|
+
path: [${g}]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (${I}_present) {
|
|
61
|
+
if (${I}.value === undefined) {
|
|
62
|
+
newResult[${g}] = undefined;
|
|
63
|
+
} else {
|
|
64
|
+
newResult[${g}] = ${I}.value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
`)}h.write("payload.value = newResult;"),h.write("return payload;");let P=h.compile();return(A,I)=>P(m,A,I)},s,i=Ve,a=!ot.jitless,u=a&&bo.value,p=t.catchall,d;e._zod.parse=(m,h)=>{d??(d=o.value);let _=m.value;return i(_)?a&&u&&h?.async===!1&&h.jitless!==!0?(s||(s=n(t.shape)),m=s(m,h),p?Sa([],_,m,h,d,e):m):r(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),m)}});function ji(e,t,r,o){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let n=e.filter(s=>!Ne(s));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>me(i,o,ce())))}),t)}var Do=f("$ZodUnion",(e,t)=>{N.init(e,t),Z(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Z(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Z(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Z(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){let o=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${o.map(n=>Ct(n.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>ji(a,o,e,n)):ji(i,o,e,n)}});var $a=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Do.init(e,t);let r=e._zod.parse;Z(e._zod,"propValues",()=>{let n={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){n[a]||(n[a]=new Set);for(let u of c)n[a].add(u)}}return n});let o=st(()=>{let n=t.options,s=new Map;for(let i of n){let a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(n,s)=>{let i=n.value;if(!Ve(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let a=o.value.get(i?.[t.discriminator]);return a?a._zod.run(n,s):t.unionFallback||s.direction==="backward"?r(n,s):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:i,path:[t.discriminator],inst:e}),n)}}),Pa=f("$ZodIntersection",(e,t)=>{N.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,s=t.left._zod.run({value:n,issues:[]},o),i=t.right._zod.run({value:n,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Mi(r,c,u)):Mi(r,s,i)}});function jo(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ae(e)&&Ae(t)){let r=Object.keys(t),o=Object.keys(e).filter(s=>r.indexOf(s)!==-1),n={...e,...t};for(let s of o){let i=jo(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n[s]=i.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],s=t[o],i=jo(n,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Mi(e,t,r){let o=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);let s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&n&&e.issues.push({...n,keys:s}),Ne(e))return e;let i=jo(t.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Ta=f("$ZodRecord",(e,t)=>{N.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Ae(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let s=[],i=t.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let p=t.keyType._zod.run({value:u,issues:[]},o);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(h=>me(h,o,ce())),input:u,path:[u],inst:e});continue}let d=p.value,m=t.valueType._zod.run({value:n[u],issues:[]},o);m instanceof Promise?s.push(m.then(h=>{h.issues.length&&r.issues.push(...Pe(u,h.issues)),r.value[d]=h.value})):(m.issues.length&&r.issues.push(...Pe(u,m.issues)),r.value[d]=m.value)}let c;for(let u in n)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Zo.test(a)&&c.issues.length){let d=t.keyType._zod.run({value:Number(a),issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[a]=n[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>me(d,o,ce())),input:a,path:[a],inst:e});continue}let p=t.valueType._zod.run({value:n[a],issues:[]},o);p instanceof Promise?s.push(p.then(d=>{d.issues.length&&r.issues.push(...Pe(a,d.issues)),r.value[c.value]=d.value})):(p.issues.length&&r.issues.push(...Pe(a,p.issues)),r.value[c.value]=p.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Ra=f("$ZodEnum",(e,t)=>{N.init(e,t);let r=Rt(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter(n=>So.has(typeof n)).map(n=>typeof n=="string"?$e(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{let i=n.value;return o.has(i)||n.issues.push({code:"invalid_value",values:r,input:i,inst:e}),n}}),Ea=f("$ZodLiteral",(e,t)=>{if(N.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?$e(o):o?$e(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}});var Ca=f("$ZodTransform",(e,t)=>{N.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new rt(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(i=>(r.value=i,r.fallback=!0,r));if(n instanceof Promise)throw new ve;return r.value=n,r.fallback=!0,r}});function Di(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Lo=f("$ZodOptional",(e,t)=>{N.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Z(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ct(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,s=t.innerType._zod.run(r,o);return s instanceof Promise?s.then(i=>Di(i,n)):Di(s,n)}return r.value===void 0?r:t.innerType._zod.run(r,o)}}),Ia=f("$ZodExactOptional",(e,t)=>{Lo.init(e,t),Z(e._zod,"values",()=>t.innerType._zod.values),Z(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Oa=f("$ZodNullable",(e,t)=>{N.init(e,t),Z(e._zod,"optin",()=>t.innerType._zod.optin),Z(e._zod,"optout",()=>t.innerType._zod.optout),Z(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ct(r.source)}|null)$`):void 0}),Z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>r.value===null?r:t.innerType._zod.run(r,o)}),Za=f("$ZodDefault",(e,t)=>{N.init(e,t),e._zod.optin="optional",Z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(s=>Li(s,t)):Li(n,t)}});function Li(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Aa=f("$ZodPrefault",(e,t)=>{N.init(e,t),e._zod.optin="optional",Z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>(o.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,o))}),Na=f("$ZodNonOptional",(e,t)=>{N.init(e,t),Z(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(s=>Ui(s,e)):Ui(n,e)}});function Ui(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var ja=f("$ZodCatch",(e,t)=>{N.init(e,t),e._zod.optin="optional",Z(e._zod,"optout",()=>t.innerType._zod.optout),Z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>me(i,o,ce()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(s=>me(s,o,ce()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var Uo=f("$ZodPipe",(e,t)=>{N.init(e,t),Z(e._zod,"values",()=>t.in._zod.values),Z(e._zod,"optin",()=>t.in._zod.optin),Z(e._zod,"optout",()=>t.out._zod.optout),Z(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let s=t.out._zod.run(r,o);return s instanceof Promise?s.then(i=>$r(i,t.in,o)):$r(s,t.in,o)}let n=t.in._zod.run(r,o);return n instanceof Promise?n.then(s=>$r(s,t.out,o)):$r(n,t.out,o)}});function $r(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var Ma=f("$ZodPreprocess",(e,t)=>{Uo.init(e,t)}),Da=f("$ZodReadonly",(e,t)=>{N.init(e,t),Z(e._zod,"propValues",()=>t.innerType._zod.propValues),Z(e._zod,"values",()=>t.innerType._zod.values),Z(e._zod,"optin",()=>t.innerType?._zod?.optin),Z(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(qi):qi(n)}});function qi(e){return e.value=Object.freeze(e.value),e}var La=f("$ZodCustom",(e,t)=>{Q.init(e,t),N.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=r=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then(s=>Fi(s,r,o,e));Fi(n,r,o,e)}});function Fi(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(n.params=o._zod.def.params),t.issues.push(it(n))}}var yd=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let s=o[n.expected]??n.expected,i=To(n.input),a=o[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${zr(n.values[0])}`:`Invalid option: expected one of ${_r(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",i=t(n.origin);return i?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",i=t(n.origin);return i?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${i.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${_r(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`Invalid discriminator value. Expected ${n.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Ua(){return{localeError:yd()}}var qa;var qo=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let o=r[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let o={...this.get(r)??{}};delete o.id;let n={...o,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Fa(){return new qo}(qa=globalThis).__zod_globalRegistry??(qa.__zod_globalRegistry=Fa());var je=globalThis.__zod_globalRegistry;function Va(e,t){return new e({type:"string",...S(t)})}function Ha(e,t){return new e({type:"string",coerce:!0,...S(t)})}function Ja(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function Fo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function Wa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function Ba(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function Ga(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function Ka(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function Vo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function Xa(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function Ya(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function Qa(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function ec(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function tc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function rc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function oc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function nc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function sc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function ic(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function ac(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function cc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function uc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function lc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function pc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function dc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function fc(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function mc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function hc(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function gc(e,t){return new e({type:"number",checks:[],...S(t)})}function _c(e,t){return new e({type:"number",coerce:!0,checks:[],...S(t)})}function yc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}function xc(e,t){return new e({type:"boolean",...S(t)})}function zc(e,t){return new e({type:"boolean",coerce:!0,...S(t)})}function wc(e,t){return new e({type:"bigint",coerce:!0,...S(t)})}function vc(e,t){return new e({type:"null",...S(t)})}function bc(e){return new e({type:"any"})}function Sc(e){return new e({type:"unknown"})}function kc(e,t){return new e({type:"never",...S(t)})}function $c(e,t){return new e({type:"date",coerce:!0,...S(t)})}function at(e,t){return new Ao({check:"less_than",...S(t),value:e,inclusive:!1})}function Te(e,t){return new Ao({check:"less_than",...S(t),value:e,inclusive:!0})}function ct(e,t){return new No({check:"greater_than",...S(t),value:e,inclusive:!1})}function xe(e,t){return new No({check:"greater_than",...S(t),value:e,inclusive:!0})}function Mt(e,t){return new vi({check:"multiple_of",...S(t),value:e})}function Rr(e,t){return new Si({check:"max_length",...S(t),maximum:e})}function ut(e,t){return new ki({check:"min_length",...S(t),minimum:e})}function Er(e,t){return new $i({check:"length_equals",...S(t),length:e})}function Ho(e,t){return new Pi({check:"string_format",format:"regex",...S(t),pattern:e})}function Jo(e){return new Ti({check:"string_format",format:"lowercase",...S(e)})}function Wo(e){return new Ri({check:"string_format",format:"uppercase",...S(e)})}function Bo(e,t){return new Ei({check:"string_format",format:"includes",...S(t),includes:e})}function Go(e,t){return new Ci({check:"string_format",format:"starts_with",...S(t),prefix:e})}function Ko(e,t){return new Ii({check:"string_format",format:"ends_with",...S(t),suffix:e})}function Me(e){return new Oi({check:"overwrite",tx:e})}function Xo(e){return Me(t=>t.normalize(e))}function Yo(){return Me(e=>e.trim())}function Qo(){return Me(e=>e.toLowerCase())}function en(){return Me(e=>e.toUpperCase())}function tn(){return Me(e=>vo(e))}function Pc(e,t,r){return new e({type:"array",element:t,...S(r)})}function Tc(e,t,r){let o=S(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Rc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...S(r)})}function Ec(e,t){let r=xd(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(it(n,o.value,r._zod.def));else{let s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=o.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),o.issues.push(it(s))}},e(o.value,o)),t);return r}function xd(e,t){let r=new Q({check:"custom",...S(t)});return r._zod.check=e,r}function rn(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??je,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function B(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,p);else{let m=i.schema,h=t.processors[n.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);h(e,t,m,p)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),B(d,t,p),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&ne(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function on(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=o.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,i[0])}}let n=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,m=e.external.uri??(_=>_);if(d)return{ref:m(d)};let h=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=h,{defId:h,ref:`${m("__shared")}#/${a}/${h}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,p=i[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+p}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=n(i);a.def={...a.schema},u&&(a.defId=u);let p=a.schema;for(let d in p)delete p[d];p.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
69
|
+
|
|
70
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function nn(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,p={...u},d=c.ref;if(c.ref=null,d){o(d);let h=e.seen.get(d),_=h.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(_)):Object.assign(u,_),Object.assign(u,p),a._zod.parent===d)for(let v in u)v==="$ref"||v==="allOf"||v in p||delete u[v];if(_.$ref&&h.def)for(let v in u)v==="$ref"||v==="allOf"||v in h.def&&JSON.stringify(u[v])===JSON.stringify(h.def[v])&&delete u[v]}let m=a._zod.parent;if(m&&m!==d){o(m);let h=e.seen.get(m);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(let _ in u)_==="$ref"||_==="allOf"||_ in h.def&&JSON.stringify(u[_])===JSON.stringify(h.def[_])&&delete u[_]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&n.id===s&&delete n.id;let i=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Dt(t,"input",e.processors),output:Dt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ne(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return ne(o.element,r);if(o.type==="set")return ne(o.valueType,r);if(o.type==="lazy")return ne(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return ne(o.innerType,r);if(o.type==="intersection")return ne(o.left,r)||ne(o.right,r);if(o.type==="record"||o.type==="map")return ne(o.keyType,r)||ne(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ne(o.in,r)||ne(o.out,r);if(o.type==="object"){for(let n in o.shape)if(ne(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(ne(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(ne(n,r))return!0;return!!(o.rest&&ne(o.rest,r))}return!1}var Cc=(e,t={})=>r=>{let o=rn({...r,processors:t});return B(e,o),on(o,e),nn(o,e)},Dt=(e,t,r={})=>o=>{let{libraryOptions:n,target:s}=o??{},i=rn({...n??{},target:s,io:t,processors:r});return B(e,i),on(i,e),nn(i,e)};var zd={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ic=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(n.minLength=s),typeof i=="number"&&(n.maxLength=i),a&&(n.format=zd[a]??a,n.format===""&&delete n.format,a==="time"&&delete n.format),u&&(n.contentEncoding=u),c&&c.size>0){let p=[...c];p.length===1?n.pattern=p[0].source:p.length>1&&(n.allOf=[...p.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Oc=(e,t,r,o)=>{let n=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:p}=e._zod.bag;typeof a=="string"&&a.includes("int")?n.type="integer":n.type="number";let d=typeof p=="number"&&p>=(s??Number.NEGATIVE_INFINITY),m=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";d?h?(n.minimum=p,n.exclusiveMinimum=!0):n.exclusiveMinimum=p:typeof s=="number"&&(n.minimum=s),m?h?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof i=="number"&&(n.maximum=i),typeof c=="number"&&(n.multipleOf=c)},Zc=(e,t,r,o)=>{r.type="boolean"},Ac=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")};var Nc=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var jc=(e,t,r,o)=>{r.not={}},Mc=(e,t,r,o)=>{},Dc=(e,t,r,o)=>{},Lc=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Uc=(e,t,r,o)=>{let n=e._zod.def,s=Rt(n.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},qc=(e,t,r,o)=>{let n=e._zod.def,s=[];for(let i of n.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Fc=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Vc=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var Hc=(e,t,r,o)=>{let n=r,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(n.minItems=i),typeof a=="number"&&(n.maxItems=a),n.type="array",n.items=B(s.element,t,{...o,path:[...o.path,"items"]})},Jc=(e,t,r,o)=>{let n=r,s=e._zod.def;n.type="object",n.properties={};let i=s.shape;for(let u in i)n.properties[u]=B(i[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let p=s.shape[u]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(n.required=Array.from(c)),s.catchall?._zod.def.type==="never"?n.additionalProperties=!1:s.catchall?s.catchall&&(n.additionalProperties=B(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Wc=(e,t,r,o)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((a,c)=>B(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Bc=(e,t,r,o)=>{let n=e._zod.def,s=B(n.left,t,{...o,path:[...o.path,"allOf",0]}),i=B(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c};var Gc=(e,t,r,o)=>{let n=r,s=e._zod.def;n.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let p=B(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let d of c)n.patternProperties[d.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=B(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),n.additionalProperties=B(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]});let u=i._zod.values;if(u){let p=[...u].filter(d=>typeof d=="string"||typeof d=="number");p.length>0&&(n.required=p)}},Kc=(e,t,r,o)=>{let n=e._zod.def,s=B(n.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=n.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},Xc=(e,t,r,o)=>{let n=e._zod.def;B(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType},Yc=(e,t,r,o)=>{let n=e._zod.def;B(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},Qc=(e,t,r,o)=>{let n=e._zod.def;B(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},eu=(e,t,r,o)=>{let n=e._zod.def;B(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},tu=(e,t,r,o)=>{let n=e._zod.def,s=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?n.out:n.in:n.out;B(i,t,o);let a=t.seen.get(e);a.ref=i},ru=(e,t,r,o)=>{let n=e._zod.def;B(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.readOnly=!0};var sn=(e,t,r,o)=>{let n=e._zod.def;B(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType};function Cr(e){return!!e._zod}function ze(e,t){return Cr(e)?Zt(e,t):e.safeParse(t)}function Ir(e){if(!e)return;let t;if(Cr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Or(e){if(Cr(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let o=e.value;if(o!==void 0)return o}var Lt={};mo(Lt,{ZodISODate:()=>nu,ZodISODateTime:()=>ou,ZodISODuration:()=>iu,ZodISOTime:()=>su,date:()=>cn,datetime:()=>an,duration:()=>ln,time:()=>un});var ou=f("ZodISODateTime",(e,t)=>{ta.init(e,t),F.init(e,t)});function an(e){return dc(ou,e)}var nu=f("ZodISODate",(e,t)=>{ra.init(e,t),F.init(e,t)});function cn(e){return fc(nu,e)}var su=f("ZodISOTime",(e,t)=>{oa.init(e,t),F.init(e,t)});function un(e){return mc(su,e)}var iu=f("ZodISODuration",(e,t)=>{na.init(e,t),F.init(e,t)});function ln(e){return hc(iu,e)}var Td=(e,t)=>{wr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Co(e,r)},flatten:{value:r=>Eo(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,nt,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,nt,2)}},isEmpty:{get(){return e.issues.length===0}}})};var pe=f("ZodError",Td,{Parent:Error});var cu=vr(pe),uu=br(pe),lu=Ot(pe),pu=At(pe),du=Ms(pe),fu=Ds(pe),mu=Ls(pe),hu=Us(pe),gu=qs(pe),_u=Fs(pe),yu=Vs(pe),xu=Hs(pe);var zu=new WeakMap;function Ut(e,t,r){let o=Object.getPrototypeOf(e),n=zu.get(o);if(n||(n=new Set,zu.set(o,n)),!n.has(t)){n.add(t);for(let s in r){let i=r[s];Object.defineProperty(o,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var j=f("ZodType",(e,t)=>(N.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Dt(e,"input"),output:Dt(e,"output")}}),e.toJSONSchema=Cc(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>cu(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>lu(e,r,o),e.parseAsync=async(r,o)=>uu(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>pu(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>du(e,r,o),e.decode=(r,o)=>fu(e,r,o),e.encodeAsync=async(r,o)=>mu(e,r,o),e.decodeAsync=async(r,o)=>hu(e,r,o),e.safeEncode=(r,o)=>gu(e,r,o),e.safeDecode=(r,o)=>_u(e,r,o),e.safeEncodeAsync=async(r,o)=>yu(e,r,o),e.safeDecodeAsync=async(r,o)=>xu(e,r,o),Ut(e,"ZodType",{check(...r){let o=this.def;return this.clone(E.mergeDefs(o,{checks:[...o.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return fe(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(_f(r,o))},superRefine(r,o){return this.check(yf(r,o))},overwrite(r){return this.check(Me(r))},optional(){return H(this)},exactOptional(){return nf(this)},nullable(){return Su(this)},nullish(){return H(Su(this))},nonoptional(r){return pf(this,r)},array(){return y(this)},or(r){return q([this,r])},and(r){return Nr(this,r)},transform(r){return ku(this,Au(r))},default(r){return cf(this,r)},prefault(r){return lf(this,r)},catch(r){return ff(this,r)},pipe(r){return ku(this,r)},readonly(){return gf(this)},describe(r){let o=this.clone();return je.add(o,{description:r}),o},meta(...r){if(r.length===0)return je.get(this);let o=this.clone();return je.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return je.get(e)?.description},configurable:!0}),e)),$u=f("_ZodString",(e,t)=>{Tr.init(e,t),j.init(e,t),e._zod.processJSONSchema=(o,n,s)=>Ic(e,o,n,s);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Ut(e,"_ZodString",{regex(...o){return this.check(Ho(...o))},includes(...o){return this.check(Bo(...o))},startsWith(...o){return this.check(Go(...o))},endsWith(...o){return this.check(Ko(...o))},min(...o){return this.check(ut(...o))},max(...o){return this.check(Rr(...o))},length(...o){return this.check(Er(...o))},nonempty(...o){return this.check(ut(1,...o))},lowercase(o){return this.check(Jo(o))},uppercase(o){return this.check(Wo(o))},trim(){return this.check(Yo())},normalize(...o){return this.check(Xo(...o))},toLowerCase(){return this.check(Qo())},toUpperCase(){return this.check(en())},slugify(){return this.check(tn())}})}),dn=f("ZodString",(e,t)=>{Tr.init(e,t),$u.init(e,t),e.email=r=>e.check(Ja(Ed,r)),e.url=r=>e.check(Vo(Pu,r)),e.jwt=r=>e.check(pc(Hd,r)),e.emoji=r=>e.check(Xa(Cd,r)),e.guid=r=>e.check(Fo(wu,r)),e.uuid=r=>e.check(Wa(Zr,r)),e.uuidv4=r=>e.check(Ba(Zr,r)),e.uuidv6=r=>e.check(Ga(Zr,r)),e.uuidv7=r=>e.check(Ka(Zr,r)),e.nanoid=r=>e.check(Ya(Id,r)),e.guid=r=>e.check(Fo(wu,r)),e.cuid=r=>e.check(Qa(Od,r)),e.cuid2=r=>e.check(ec(Zd,r)),e.ulid=r=>e.check(tc(Ad,r)),e.base64=r=>e.check(cc(qd,r)),e.base64url=r=>e.check(uc(Fd,r)),e.xid=r=>e.check(rc(Nd,r)),e.ksuid=r=>e.check(oc(jd,r)),e.ipv4=r=>e.check(nc(Md,r)),e.ipv6=r=>e.check(sc(Dd,r)),e.cidrv4=r=>e.check(ic(Ld,r)),e.cidrv6=r=>e.check(ac(Ud,r)),e.e164=r=>e.check(lc(Vd,r)),e.datetime=r=>e.check(an(r)),e.date=r=>e.check(cn(r)),e.time=r=>e.check(un(r)),e.duration=r=>e.check(ln(r))});function l(e){return Va(dn,e)}var F=f("ZodStringFormat",(e,t)=>{U.init(e,t),$u.init(e,t)}),Ed=f("ZodEmail",(e,t)=>{Ji.init(e,t),F.init(e,t)});var wu=f("ZodGUID",(e,t)=>{Vi.init(e,t),F.init(e,t)});var Zr=f("ZodUUID",(e,t)=>{Hi.init(e,t),F.init(e,t)});var Pu=f("ZodURL",(e,t)=>{Wi.init(e,t),F.init(e,t)});function Tu(e){return Vo(Pu,e)}var Cd=f("ZodEmoji",(e,t)=>{Bi.init(e,t),F.init(e,t)});var Id=f("ZodNanoID",(e,t)=>{Gi.init(e,t),F.init(e,t)});var Od=f("ZodCUID",(e,t)=>{Ki.init(e,t),F.init(e,t)});var Zd=f("ZodCUID2",(e,t)=>{Xi.init(e,t),F.init(e,t)});var Ad=f("ZodULID",(e,t)=>{Yi.init(e,t),F.init(e,t)});var Nd=f("ZodXID",(e,t)=>{Qi.init(e,t),F.init(e,t)});var jd=f("ZodKSUID",(e,t)=>{ea.init(e,t),F.init(e,t)});var Md=f("ZodIPv4",(e,t)=>{sa.init(e,t),F.init(e,t)});var Dd=f("ZodIPv6",(e,t)=>{ia.init(e,t),F.init(e,t)});var Ld=f("ZodCIDRv4",(e,t)=>{aa.init(e,t),F.init(e,t)});var Ud=f("ZodCIDRv6",(e,t)=>{ca.init(e,t),F.init(e,t)});var qd=f("ZodBase64",(e,t)=>{la.init(e,t),F.init(e,t)});var Fd=f("ZodBase64URL",(e,t)=>{pa.init(e,t),F.init(e,t)});var Vd=f("ZodE164",(e,t)=>{da.init(e,t),F.init(e,t)});var Hd=f("ZodJWT",(e,t)=>{fa.init(e,t),F.init(e,t)});var Ar=f("ZodNumber",(e,t)=>{Mo.init(e,t),j.init(e,t),e._zod.processJSONSchema=(o,n,s)=>Oc(e,o,n,s),Ut(e,"ZodNumber",{gt(o,n){return this.check(ct(o,n))},gte(o,n){return this.check(xe(o,n))},min(o,n){return this.check(xe(o,n))},lt(o,n){return this.check(at(o,n))},lte(o,n){return this.check(Te(o,n))},max(o,n){return this.check(Te(o,n))},int(o){return this.check(vu(o))},safe(o){return this.check(vu(o))},positive(o){return this.check(ct(0,o))},nonnegative(o){return this.check(xe(0,o))},negative(o){return this.check(at(0,o))},nonpositive(o){return this.check(Te(0,o))},multipleOf(o,n){return this.check(Mt(o,n))},step(o,n){return this.check(Mt(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function C(e){return gc(Ar,e)}var Jd=f("ZodNumberFormat",(e,t)=>{ma.init(e,t),Ar.init(e,t)});function vu(e){return yc(Jd,e)}var fn=f("ZodBoolean",(e,t)=>{ha.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zc(e,r,o,n)});function M(e){return xc(fn,e)}var Ru=f("ZodBigInt",(e,t)=>{ga.init(e,t),j.init(e,t),e._zod.processJSONSchema=(o,n,s)=>Ac(e,o,n,s),e.gte=(o,n)=>e.check(xe(o,n)),e.min=(o,n)=>e.check(xe(o,n)),e.gt=(o,n)=>e.check(ct(o,n)),e.gte=(o,n)=>e.check(xe(o,n)),e.min=(o,n)=>e.check(xe(o,n)),e.lt=(o,n)=>e.check(at(o,n)),e.lte=(o,n)=>e.check(Te(o,n)),e.max=(o,n)=>e.check(Te(o,n)),e.positive=o=>e.check(ct(BigInt(0),o)),e.negative=o=>e.check(at(BigInt(0),o)),e.nonpositive=o=>e.check(Te(BigInt(0),o)),e.nonnegative=o=>e.check(xe(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(Mt(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});var Wd=f("ZodNull",(e,t)=>{_a.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Nc(e,r,o,n)});function Eu(e){return vc(Wd,e)}var Bd=f("ZodAny",(e,t)=>{ya.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Mc(e,r,o,n)});function Cu(){return bc(Bd)}var Gd=f("ZodUnknown",(e,t)=>{xa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dc(e,r,o,n)});function V(){return Sc(Gd)}var Kd=f("ZodNever",(e,t)=>{za.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jc(e,r,o,n)});function Xd(e){return kc(Kd,e)}var Iu=f("ZodDate",(e,t)=>{wa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(o,n,s)=>Lc(e,o,n,s),e.min=(o,n)=>e.check(xe(o,n)),e.max=(o,n)=>e.check(Te(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});var Yd=f("ZodArray",(e,t)=>{va.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hc(e,r,o,n),e.element=t.element,Ut(e,"ZodArray",{min(r,o){return this.check(ut(r,o))},nonempty(r){return this.check(ut(1,r))},max(r,o){return this.check(Rr(r,o))},length(r,o){return this.check(Er(r,o))},unwrap(){return this.element}})});function y(e,t){return Pc(Yd,e,t)}var Ou=f("ZodObject",(e,t)=>{ka.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jc(e,r,o,n),E.defineLazy(e,"shape",()=>t.shape),Ut(e,"ZodObject",{keyof(){return ue(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:V()})},loose(){return this.clone({...this._zod.def,catchall:V()})},strict(){return this.clone({...this._zod.def,catchall:Xd()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return E.extend(this,r)},safeExtend(r){return E.safeExtend(this,r)},merge(r){return E.merge(this,r)},pick(r){return E.pick(this,r)},omit(r){return E.omit(this,r)},partial(...r){return E.partial(Nu,this,r[0])},required(...r){return E.required(ju,this,r[0])}})});function x(e,t){let r={type:"object",shape:e??{},...E.normalizeParams(t)};return new Ou(r)}function K(e,t){return new Ou({type:"object",shape:e,catchall:V(),...E.normalizeParams(t)})}var Zu=f("ZodUnion",(e,t)=>{Do.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wc(e,r,o,n),e.options=t.options});function q(e,t){return new Zu({type:"union",options:e,...E.normalizeParams(t)})}var Qd=f("ZodDiscriminatedUnion",(e,t)=>{Zu.init(e,t),$a.init(e,t)});function mn(e,t,r){return new Qd({type:"union",options:t,discriminator:e,...E.normalizeParams(r)})}var ef=f("ZodIntersection",(e,t)=>{Pa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bc(e,r,o,n)});function Nr(e,t){return new ef({type:"intersection",left:e,right:t})}var bu=f("ZodRecord",(e,t)=>{Ta.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gc(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function D(e,t,r){return!t||!t._zod?new bu({type:"record",keyType:l(),valueType:e,...E.normalizeParams(t)}):new bu({type:"record",keyType:e,valueType:t,...E.normalizeParams(r)})}var pn=f("ZodEnum",(e,t)=>{Ra.init(e,t),j.init(e,t),e._zod.processJSONSchema=(o,n,s)=>Uc(e,o,n,s),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let s={};for(let i of o)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new pn({...t,checks:[],...E.normalizeParams(n),entries:s})},e.exclude=(o,n)=>{let s={...t.entries};for(let i of o)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new pn({...t,checks:[],...E.normalizeParams(n),entries:s})}});function ue(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new pn({type:"enum",entries:r,...E.normalizeParams(t)})}var tf=f("ZodLiteral",(e,t)=>{Ea.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qc(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function b(e,t){return new tf({type:"literal",values:Array.isArray(e)?e:[e],...E.normalizeParams(t)})}var rf=f("ZodTransform",(e,t)=>{Ca.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vc(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new rt(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(E.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(E.issue(i))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function Au(e){return new rf({type:"transform",transform:e})}var Nu=f("ZodOptional",(e,t)=>{Lo.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sn(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function H(e){return new Nu({type:"optional",innerType:e})}var of=f("ZodExactOptional",(e,t)=>{Ia.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sn(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function nf(e){return new of({type:"optional",innerType:e})}var sf=f("ZodNullable",(e,t)=>{Oa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Su(e){return new sf({type:"nullable",innerType:e})}var af=f("ZodDefault",(e,t)=>{Za.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function cf(e,t){return new af({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var uf=f("ZodPrefault",(e,t)=>{Aa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Qc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function lf(e,t){return new uf({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var ju=f("ZodNonOptional",(e,t)=>{Na.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function pf(e,t){return new ju({type:"nonoptional",innerType:e,...E.normalizeParams(t)})}var df=f("ZodCatch",(e,t)=>{ja.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>eu(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ff(e,t){return new df({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Mu=f("ZodPipe",(e,t)=>{Uo.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>tu(e,r,o,n),e.in=t.in,e.out=t.out});function ku(e,t){return new Mu({type:"pipe",in:e,out:t})}var mf=f("ZodPreprocess",(e,t)=>{Mu.init(e,t),Ma.init(e,t)}),hf=f("ZodReadonly",(e,t)=>{Da.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ru(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function gf(e){return new hf({type:"readonly",innerType:e})}var Du=f("ZodCustom",(e,t)=>{La.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fc(e,r,o,n)});function Lu(e,t){return Tc(Du,e??(()=>!0),t)}function _f(e,t={}){return Rc(Du,e,t)}function yf(e,t){return Ec(e,t)}function hn(e,t){return new mf({type:"pipe",in:Au(e),out:t})}var qu={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var Uu;Uu||(Uu={});var jr={};mo(jr,{bigint:()=>vf,boolean:()=>wf,date:()=>bf,number:()=>zf,string:()=>xf});function xf(e){return Ha(dn,e)}function zf(e){return _c(Ar,e)}function wf(e){return zc(fn,e)}function vf(e){return wc(Ru,e)}function bf(e){return $c(Iu,e)}ce(Ua());var dt="2025-11-25";var Fu=[dt,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],De="io.modelcontextprotocol/related-task",Dr="2.0",X=Lu(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Vu=q([l(),C().int()]),Hu=l(),nx=K({ttl:C().optional(),pollInterval:C().optional()}),kf=x({ttl:C().optional()}),$f=x({taskId:l()}),_n=K({progressToken:Vu.optional(),[De]:$f.optional()}),de=x({_meta:_n.optional()}),qt=de.extend({task:kf.optional()}),Ju=e=>qt.safeParse(e).success,ee=x({method:l(),params:de.loose().optional()}),he=x({_meta:_n.optional()}),ge=x({method:l(),params:he.loose().optional()}),te=K({_meta:_n.optional()}),Lr=q([l(),C().int()]),Wu=x({jsonrpc:b(Dr),id:Lr,...ee.shape}).strict(),Ft=e=>Wu.safeParse(e).success,Bu=x({jsonrpc:b(Dr),...ge.shape}).strict(),Gu=e=>Bu.safeParse(e).success,yn=x({jsonrpc:b(Dr),id:Lr,result:te}).strict(),He=e=>yn.safeParse(e).success;var $;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",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.UrlElicitationRequired=-32042]="UrlElicitationRequired"})($||($={}));var xn=x({jsonrpc:b(Dr),id:Lr.optional(),error:x({code:C().int(),message:l(),data:V().optional()})}).strict();var Ku=e=>xn.safeParse(e).success;var Le=q([Wu,Bu,yn,xn]),sx=q([yn,xn]),Je=te.strict(),Pf=he.extend({requestId:Lr.optional(),reason:l().optional()}),Ur=ge.extend({method:b("notifications/cancelled"),params:Pf}),Tf=x({src:l(),mimeType:l().optional(),sizes:y(l()).optional(),theme:ue(["light","dark"]).optional()}),Vt=x({icons:y(Tf).optional()}),pt=x({name:l(),title:l().optional()}),Xu=pt.extend({...pt.shape,...Vt.shape,version:l(),websiteUrl:l().optional(),description:l().optional()}),Rf=Nr(x({applyDefaults:M().optional()}),D(l(),V())),Ef=hn(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Nr(x({form:Rf.optional(),url:X.optional()}),D(l(),V()).optional())),Cf=K({list:X.optional(),cancel:X.optional(),requests:K({sampling:K({createMessage:X.optional()}).optional(),elicitation:K({create:X.optional()}).optional()}).optional()}),If=K({list:X.optional(),cancel:X.optional(),requests:K({tools:K({call:X.optional()}).optional()}).optional()}),Of=x({experimental:D(l(),X).optional(),sampling:x({context:X.optional(),tools:X.optional()}).optional(),elicitation:Ef.optional(),roots:x({listChanged:M().optional()}).optional(),tasks:Cf.optional(),extensions:D(l(),X).optional()}),Zf=de.extend({protocolVersion:l(),capabilities:Of,clientInfo:Xu}),Af=ee.extend({method:b("initialize"),params:Zf});var Nf=x({experimental:D(l(),X).optional(),logging:X.optional(),completions:X.optional(),prompts:x({listChanged:M().optional()}).optional(),resources:x({subscribe:M().optional(),listChanged:M().optional()}).optional(),tools:x({listChanged:M().optional()}).optional(),tasks:If.optional(),extensions:D(l(),X).optional()}),zn=te.extend({protocolVersion:l(),capabilities:Nf,serverInfo:Xu,instructions:l().optional()}),Yu=ge.extend({method:b("notifications/initialized"),params:he.optional()}),Qu=e=>Yu.safeParse(e).success,qr=ee.extend({method:b("ping"),params:de.optional()}),jf=x({progress:C(),total:H(C()),message:H(l())}),Mf=x({...he.shape,...jf.shape,progressToken:Vu}),Fr=ge.extend({method:b("notifications/progress"),params:Mf}),Df=de.extend({cursor:Hu.optional()}),Ht=ee.extend({params:Df.optional()}),Jt=te.extend({nextCursor:Hu.optional()}),Lf=ue(["working","input_required","completed","failed","cancelled"]),Wt=x({taskId:l(),status:Lf,ttl:q([C(),Eu()]),createdAt:l(),lastUpdatedAt:l(),pollInterval:H(C()),statusMessage:H(l())}),We=te.extend({task:Wt}),Uf=he.merge(Wt),Bt=ge.extend({method:b("notifications/tasks/status"),params:Uf}),Vr=ee.extend({method:b("tasks/get"),params:de.extend({taskId:l()})}),Hr=te.merge(Wt),Jr=ee.extend({method:b("tasks/result"),params:de.extend({taskId:l()})}),ix=te.loose(),Wr=Ht.extend({method:b("tasks/list")}),Br=Jt.extend({tasks:y(Wt)}),Gr=ee.extend({method:b("tasks/cancel"),params:de.extend({taskId:l()})}),el=te.merge(Wt),tl=x({uri:l(),mimeType:H(l()),_meta:D(l(),V()).optional()}),rl=tl.extend({text:l()}),wn=l().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ol=tl.extend({blob:wn}),Gt=ue(["user","assistant"]),ft=x({audience:y(Gt).optional(),priority:C().min(0).max(1).optional(),lastModified:Lt.datetime({offset:!0}).optional()}),nl=x({...pt.shape,...Vt.shape,uri:l(),description:H(l()),mimeType:H(l()),size:H(C()),annotations:ft.optional(),_meta:H(K({}))}),qf=x({...pt.shape,...Vt.shape,uriTemplate:l(),description:H(l()),mimeType:H(l()),annotations:ft.optional(),_meta:H(K({}))}),Ff=Ht.extend({method:b("resources/list")}),vn=Jt.extend({resources:y(nl)}),Vf=Ht.extend({method:b("resources/templates/list")}),bn=Jt.extend({resourceTemplates:y(qf)}),Sn=de.extend({uri:l()}),Hf=Sn,Jf=ee.extend({method:b("resources/read"),params:Hf}),kn=te.extend({contents:y(q([rl,ol]))}),$n=ge.extend({method:b("notifications/resources/list_changed"),params:he.optional()}),Wf=Sn,Bf=ee.extend({method:b("resources/subscribe"),params:Wf}),Gf=Sn,Kf=ee.extend({method:b("resources/unsubscribe"),params:Gf}),Xf=he.extend({uri:l()}),Yf=ge.extend({method:b("notifications/resources/updated"),params:Xf}),Qf=x({name:l(),description:H(l()),required:H(M())}),em=x({...pt.shape,...Vt.shape,description:H(l()),arguments:H(y(Qf)),_meta:H(K({}))}),tm=Ht.extend({method:b("prompts/list")}),Pn=Jt.extend({prompts:y(em)}),rm=de.extend({name:l(),arguments:D(l(),l()).optional()}),om=ee.extend({method:b("prompts/get"),params:rm}),Tn=x({type:b("text"),text:l(),annotations:ft.optional(),_meta:D(l(),V()).optional()}),Rn=x({type:b("image"),data:wn,mimeType:l(),annotations:ft.optional(),_meta:D(l(),V()).optional()}),En=x({type:b("audio"),data:wn,mimeType:l(),annotations:ft.optional(),_meta:D(l(),V()).optional()}),nm=x({type:b("tool_use"),name:l(),id:l(),input:D(l(),V()),_meta:D(l(),V()).optional()}),sm=x({type:b("resource"),resource:q([rl,ol]),annotations:ft.optional(),_meta:D(l(),V()).optional()}),im=nl.extend({type:b("resource_link")}),Cn=q([Tn,Rn,En,im,sm]),am=x({role:Gt,content:Cn}),In=te.extend({description:l().optional(),messages:y(am)}),On=ge.extend({method:b("notifications/prompts/list_changed"),params:he.optional()}),cm=x({title:l().optional(),readOnlyHint:M().optional(),destructiveHint:M().optional(),idempotentHint:M().optional(),openWorldHint:M().optional()}),um=x({taskSupport:ue(["required","optional","forbidden"]).optional()}),sl=x({...pt.shape,...Vt.shape,description:l().optional(),inputSchema:x({type:b("object"),properties:D(l(),X).optional(),required:y(l()).optional()}).catchall(V()),outputSchema:x({type:b("object"),properties:D(l(),X).optional(),required:y(l()).optional()}).catchall(V()).optional(),annotations:cm.optional(),execution:um.optional(),_meta:D(l(),V()).optional()}),lm=Ht.extend({method:b("tools/list")}),Zn=Jt.extend({tools:y(sl)}),mt=te.extend({content:y(Cn).default([]),structuredContent:D(l(),V()).optional(),isError:M().optional()}),ax=mt.or(te.extend({toolResult:V()})),pm=qt.extend({name:l(),arguments:D(l(),V()).optional()}),dm=ee.extend({method:b("tools/call"),params:pm}),An=ge.extend({method:b("notifications/tools/list_changed"),params:he.optional()}),il=x({autoRefresh:M().default(!0),debounceMs:C().int().nonnegative().default(300)}),al=ue(["debug","info","notice","warning","error","critical","alert","emergency"]),fm=de.extend({level:al}),mm=ee.extend({method:b("logging/setLevel"),params:fm}),hm=he.extend({level:al,logger:l().optional(),data:V()}),gm=ge.extend({method:b("notifications/message"),params:hm}),_m=x({name:l().optional()}),ym=x({hints:y(_m).optional(),costPriority:C().min(0).max(1).optional(),speedPriority:C().min(0).max(1).optional(),intelligencePriority:C().min(0).max(1).optional()}),xm=x({mode:ue(["auto","required","none"]).optional()}),zm=x({type:b("tool_result"),toolUseId:l().describe("The unique identifier for the corresponding tool call."),content:y(Cn).default([]),structuredContent:x({}).loose().optional(),isError:M().optional(),_meta:D(l(),V()).optional()}),wm=mn("type",[Tn,Rn,En]),Mr=mn("type",[Tn,Rn,En,nm,zm]),vm=x({role:Gt,content:q([Mr,y(Mr)]),_meta:D(l(),V()).optional()}),bm=qt.extend({messages:y(vm),modelPreferences:ym.optional(),systemPrompt:l().optional(),includeContext:ue(["none","thisServer","allServers"]).optional(),temperature:C().optional(),maxTokens:C().int(),stopSequences:y(l()).optional(),metadata:X.optional(),tools:y(sl).optional(),toolChoice:xm.optional()}),Nn=ee.extend({method:b("sampling/createMessage"),params:bm}),jn=te.extend({model:l(),stopReason:H(ue(["endTurn","stopSequence","maxTokens"]).or(l())),role:Gt,content:wm}),Mn=te.extend({model:l(),stopReason:H(ue(["endTurn","stopSequence","maxTokens","toolUse"]).or(l())),role:Gt,content:q([Mr,y(Mr)])}),Sm=x({type:b("boolean"),title:l().optional(),description:l().optional(),default:M().optional()}),km=x({type:b("string"),title:l().optional(),description:l().optional(),minLength:C().optional(),maxLength:C().optional(),format:ue(["email","uri","date","date-time"]).optional(),default:l().optional()}),$m=x({type:ue(["number","integer"]),title:l().optional(),description:l().optional(),minimum:C().optional(),maximum:C().optional(),default:C().optional()}),Pm=x({type:b("string"),title:l().optional(),description:l().optional(),enum:y(l()),default:l().optional()}),Tm=x({type:b("string"),title:l().optional(),description:l().optional(),oneOf:y(x({const:l(),title:l()})),default:l().optional()}),Rm=x({type:b("string"),title:l().optional(),description:l().optional(),enum:y(l()),enumNames:y(l()).optional(),default:l().optional()}),Em=q([Pm,Tm]),Cm=x({type:b("array"),title:l().optional(),description:l().optional(),minItems:C().optional(),maxItems:C().optional(),items:x({type:b("string"),enum:y(l())}),default:y(l()).optional()}),Im=x({type:b("array"),title:l().optional(),description:l().optional(),minItems:C().optional(),maxItems:C().optional(),items:x({anyOf:y(x({const:l(),title:l()}))}),default:y(l()).optional()}),Om=q([Cm,Im]),Zm=q([Rm,Em,Om]),Am=q([Zm,Sm,km,$m]),Nm=qt.extend({mode:b("form").optional(),message:l(),requestedSchema:x({type:b("object"),properties:D(l(),Am),required:y(l()).optional()})}),jm=qt.extend({mode:b("url"),message:l(),elicitationId:l(),url:l().url()}),Mm=q([Nm,jm]),Dn=ee.extend({method:b("elicitation/create"),params:Mm}),Dm=he.extend({elicitationId:l()}),Lm=ge.extend({method:b("notifications/elicitation/complete"),params:Dm}),Ln=te.extend({action:ue(["accept","decline","cancel"]),content:hn(e=>e===null?void 0:e,D(l(),q([l(),C(),M(),y(l())])).optional())}),Um=x({type:b("ref/resource"),uri:l()});var qm=x({type:b("ref/prompt"),name:l()}),Fm=de.extend({ref:q([qm,Um]),argument:x({name:l(),value:l()}),context:x({arguments:D(l(),l()).optional()}).optional()}),Vm=ee.extend({method:b("completion/complete"),params:Fm});var Un=te.extend({completion:K({values:y(l()).max(100),total:H(C().int()),hasMore:H(M())})}),Hm=x({uri:l().startsWith("file://"),name:l().optional(),_meta:D(l(),V()).optional()}),Jm=ee.extend({method:b("roots/list"),params:de.optional()}),Wm=te.extend({roots:y(Hm)}),Bm=ge.extend({method:b("notifications/roots/list_changed"),params:he.optional()}),cx=q([qr,Af,Vm,mm,om,tm,Ff,Vf,Jf,Bf,Kf,dm,lm,Vr,Jr,Wr,Gr]),ux=q([Ur,Fr,Yu,Bm,Bt]),lx=q([Je,jn,Mn,Ln,Wm,Hr,Br,We]),px=q([qr,Nn,Dn,Jm,Vr,Jr,Wr,Gr]),dx=q([Ur,Fr,gm,Yf,$n,An,On,Bt,Lm]),fx=q([Je,zn,Un,In,Pn,vn,bn,kn,mt,Zn,Hr,Br,We]),k=class e extends Error{constructor(t,r,o){super(`MCP error ${t}: ${r}`),this.code=t,this.data=o,this.name="McpError"}static fromError(t,r,o){if(t===$.UrlElicitationRequired&&o){let n=o;if(n.elicitations)return new gn(n.elicitations,r)}return new e(t,r,o)}},gn=class extends k{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super($.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Ue(e){return e==="completed"||e==="failed"||e==="cancelled"}var Jx=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function qn(e){let r=Ir(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let o=Or(r);if(typeof o!="string")throw new Error("Schema method literal must be a string");return o}function Fn(e,t){let r=ze(e,t);if(!r.success)throw r.error;return r.data}var eh=6e4,Kr=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ur,r=>{this._oncancel(r)}),this.setNotificationHandler(Fr,r=>{this._onprogress(r)}),this.setRequestHandler(qr,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Vr,async(r,o)=>{let n=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!n)throw new k($.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(Jr,async(r,o)=>{let n=async()=>{let s=r.params.taskId;if(!await this._taskStore.getTask(s,o.sessionId))throw new k($.InvalidParams,`Task not found: ${s}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,o.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,p=this._requestResolvers.get(u);if(p)if(this._requestResolvers.delete(u),a.type==="response")p(c);else{let d=c,m=new k(d.error.code,d.error.message,d.error.data);p(m)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:o.requestId})}}let i=await this._taskStore.getTask(s,o.sessionId);if(!i)throw new k($.InvalidParams,`Task not found: ${s}`);if(!Ue(i.status))return await this._waitForTaskUpdate(s,o.signal,o.sessionId),await n();if(Ue(i.status)){let a=await this._taskStore.getTaskResult(s,o.sessionId);return this._clearTaskQueue(s,o.sessionId),{...a,_meta:{...a._meta,[De]:{taskId:s}}}}return await n()};return await n()}),this.setRequestHandler(Wr,async(r,o)=>{try{let{tasks:n,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,o.sessionId);return{tasks:n,nextCursor:s,_meta:{}}}catch(n){throw new k($.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(Gr,async(r,o)=>{try{let n=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!n)throw new k($.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ue(n.status))throw new k($.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId),this._clearTaskQueue(r.params.taskId,o.sessionId);let s=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!s)throw new k($.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(n){throw n instanceof k?n:new k($.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,o,n,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:o,resetTimeoutOnProgress:s,onTimeout:n})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let o=Date.now()-r.startTime;if(r.maxTotalTimeout&&o>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),k.fromError($.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:o});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let o=this.transport?.onerror;this._transport.onerror=s=>{o?.(s),this._onerror(s)};let n=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{n?.(s,i),He(s)||Ku(s)?this._onresponse(s):Ft(s)?this._onrequest(s,i):Gu(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();for(let o of this._requestHandlerAbortControllers.values())o.abort();this._requestHandlerAbortControllers.clear();let r=k.fromError($.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let o of t.values())o(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(t,r){let o=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,n=this._transport,s=t.params?._meta?.[De]?.taskId,i=n?.sessionId,a=this._taskStore,c=!0,u;if(s&&a&&this._taskMessageQueue&&i!==void 0&&(c=!1,u=(async()=>{if(!await a.getTask(s,i))throw new k($.InvalidParams,`Task not found: ${s}`);c=!0})()),o===void 0){let _={jsonrpc:"2.0",id:t.id,error:{code:$.MethodNotFound,message:"Method not found"}};if(s&&u){let w={type:"error",message:_,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(s,w,i),()=>n?.send(_)).catch(v=>this._onerror(new Error(`Failed to send an error response: ${v}`)))}else s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:_,timestamp:Date.now()},n?.sessionId).catch(w=>this._onerror(new Error(`Failed to enqueue error response: ${w}`))):n?.send(_).catch(w=>this._onerror(new Error(`Failed to send an error response: ${w}`)));return}let p=new AbortController;this._requestHandlerAbortControllers.set(t.id,p);let d=Ju(t.params)?t.params.task:void 0,m=this._taskStore?this.requestTaskStore(t,n?.sessionId):void 0,h={signal:p.signal,sessionId:n?.sessionId,_meta:t.params?._meta,sendNotification:async _=>{if(p.signal.aborted)return;let w={relatedRequestId:t.id};s&&(w.relatedTask={taskId:s}),await this.notification(_,w)},sendRequest:async(_,w,v)=>{if(p.signal.aborted)throw new k($.ConnectionClosed,"Request was cancelled");let L={...v,relatedRequestId:t.id};s&&!L.relatedTask&&(L.relatedTask={taskId:s});let P=L.relatedTask?.taskId??s;return P&&m&&await m.updateTaskStatus(P,"input_required"),await this.request(_,w,L)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:m,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&p.signal.aborted)throw new k($.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>o(t,h)).then(async _=>{if(p.signal.aborted)return;let w={result:_,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:w,timestamp:Date.now()},n?.sessionId):await n?.send(w)},async _=>{if(p.signal.aborted)return;let w={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(_.code)?_.code:$.InternalError,message:_.message??"Internal error",..._.data!==void 0&&{data:_.data}}};s&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(s,{type:"error",message:w,timestamp:Date.now()},n?.sessionId):await n?.send(w)}).catch(_=>this._onerror(new Error(`Failed to send response: ${_}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===p&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...o}=t.params,n=Number(r),s=this._progressHandlers.get(n);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(c){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),i(c);return}s(o)}_onresponse(t){let r=Number(t.id),o=this._requestResolvers.get(r);if(o){if(this._requestResolvers.delete(r),He(t))o(t);else{let i=new k(t.error.code,t.error.message,t.error.data);o(i)}return}let n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(He(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),He(t))n(t);else{let i=k.fromError(t.error.code,t.error.message,t.error.data);n(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,o){let{task:n}=o??{};if(!n){try{yield{type:"result",result:await this.request(t,r,o)}}catch(i){yield{type:"error",error:i instanceof k?i:new k($.InternalError,String(i))}}return}let s;try{let i=await this.request(t,We,o);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new k($.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},o);if(yield{type:"taskStatus",task:a},Ue(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,o)}:a.status==="failed"?yield{type:"error",error:new k($.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new k($.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,o)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),o?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof k?i:new k($.InternalError,String(i))}}}request(t,r,o){let{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=o??{};return new Promise((u,p)=>{let d=P=>{p(P)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(P){d(P);return}o?.signal?.throwIfAborted();let m=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:m};o?.onprogress&&(this._progressHandlers.set(m,o.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),a&&(h.params={...h.params,task:a}),c&&(h.params={...h.params,_meta:{...h.params?._meta||{},[De]:c}});let _=P=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(P)}},{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i}).catch(I=>this._onerror(new Error(`Failed to send cancellation: ${I}`)));let A=P instanceof k?P:new k($.RequestTimeout,String(P));p(A)};this._responseHandlers.set(m,P=>{if(!o?.signal?.aborted){if(P instanceof Error)return p(P);try{let A=ze(r,P.result);A.success?u(A.data):p(A.error)}catch(A){p(A)}}}),o?.signal?.addEventListener("abort",()=>{_(o?.signal?.reason)});let w=o?.timeout??eh,v=()=>_(k.fromError($.RequestTimeout,"Request timed out",{timeout:w}));this._setupTimeout(m,w,o?.maxTotalTimeout,v,o?.resetTimeoutOnProgress??!1);let L=c?.taskId;if(L){let P=A=>{let I=this._responseHandlers.get(m);I?I(A):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,P),this._enqueueTaskMessage(L,{type:"request",message:h,timestamp:Date.now()}).catch(A=>{this._cleanupTimeout(m),p(A)})}else this._transport.send(h,{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i}).catch(P=>{this._cleanupTimeout(m),p(P)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Hr,r)}async getTaskResult(t,r,o){return this.request({method:"tasks/result",params:t},r,o)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Br,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},el,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let o=r?.relatedTask?.taskId;if(o){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[De]:r.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[De]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[De]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let o=qn(t);this.assertRequestHandlerCapability(o),this._requestHandlers.set(o,(n,s)=>{let i=Fn(t,n);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let o=qn(t);this._notificationHandlers.set(o,n=>{let s=Fn(t,n);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,o){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,o??this._transport?.sessionId,n)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let o=await this._taskMessageQueue.dequeueAll(t,r);for(let n of o)if(n.type==="request"&&Ft(n.message)){let s=n.message.id,i=this._requestResolvers.get(s);i?(i(new k($.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r,o){let n=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(t,o);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new k($.InvalidRequest,"Request cancelled"));return}let a=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(a),i(new k($.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let o=this._taskStore;if(!o)throw new Error("No task store configured");return{createTask:async n=>{if(!t)throw new Error("No request provided");return await o.createTask(n,t.id,{method:t.method,params:t.params},r)},getTask:async n=>{let s=await o.getTask(n,r);if(!s)throw new k($.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(n,s,i)=>{await o.storeTaskResult(n,s,i,r);let a=await o.getTask(n,r);if(a){let c=Bt.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ue(a.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>o.getTaskResult(n,r),updateTaskStatus:async(n,s,i)=>{let a=await o.getTask(n,r);if(!a)throw new k($.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(Ue(a.status))throw new k($.InvalidParams,`Cannot update task "${n}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await o.updateTaskStatus(n,s,i,r);let c=await o.getTask(n,r);if(c){let u=Bt.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ue(c.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>o.listTasks(n,r)}}};function cl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ul(e,t){let r={...e};for(let o in t){let n=o,s=t[n];if(s===void 0)continue;let i=r[n];cl(i)&&cl(s)?r[n]={...i,...s}:r[n]=s}return r}var ll=mr(Np(),1),pl=mr(jp(),1);function th(){let e=new ll.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,pl.default)(e),e}var Xr=class{constructor(t){this._ajv=t??th()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return o=>r(o)?{valid:!0,data:o,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Yr=class{constructor(t){this._client=t}async*callToolStream(t,r=mt,o){let n=this._client,s={...o,task:o?.task??(n.isToolTask(t.name)?{}:void 0)},i=n.requestStream({method:"tools/call",params:t},r,s),a=n.getToolOutputValidator(t.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new k($.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let p=a(u.structuredContent);if(!p.valid){yield{type:"error",error:new k($.InvalidParams,`Structured content does not match the tool's output schema: ${p.errorMessage}`)};return}}catch(p){if(p instanceof k){yield{type:"error",error:p};return}yield{type:"error",error:new k($.InvalidParams,`Failed to validate structured content: ${p instanceof Error?p.message:String(p)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,o){return this._client.getTaskResult({taskId:t},r,o)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,o){return this._client.requestStream(t,r,o)}};function dl(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function fl(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function Qr(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,o=e.properties;for(let n of Object.keys(o)){let s=o[n];r[n]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[n]=s.default),r[n]!==void 0&&Qr(s,r[n])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&Qr(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&Qr(r,t)}}function rh(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}var eo=class extends Kr{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new Xr,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",An,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",On,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",$n,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Yr(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ul(this._capabilities,t)}setRequestHandler(t,r){let n=Ir(t)?.method;if(!n)throw new Error("Schema is missing a method literal");let s=Or(n);if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let p=ze(Dn,c);if(!p.success){let P=p.error instanceof Error?p.error.message:String(p.error);throw new k($.InvalidParams,`Invalid elicitation request: ${P}`)}let{params:d}=p.data;d.mode=d.mode??"form";let{supportsFormMode:m,supportsUrlMode:h}=rh(this._capabilities.elicitation);if(d.mode==="form"&&!m)throw new k($.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!h)throw new k($.InvalidParams,"Client does not support URL-mode elicitation requests");let _=await Promise.resolve(r(c,u));if(d.task){let P=ze(We,_);if(!P.success){let A=P.error instanceof Error?P.error.message:String(P.error);throw new k($.InvalidParams,`Invalid task creation result: ${A}`)}return P.data}let w=ze(Ln,_);if(!w.success){let P=w.error instanceof Error?w.error.message:String(w.error);throw new k($.InvalidParams,`Invalid elicitation result: ${P}`)}let v=w.data,L=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&v.action==="accept"&&v.content&&L&&this._capabilities.elicitation?.form?.applyDefaults)try{Qr(L,v.content)}catch{}return v};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let p=ze(Nn,c);if(!p.success){let v=p.error instanceof Error?p.error.message:String(p.error);throw new k($.InvalidParams,`Invalid sampling request: ${v}`)}let{params:d}=p.data,m=await Promise.resolve(r(c,u));if(d.task){let v=ze(We,m);if(!v.success){let L=v.error instanceof Error?v.error.message:String(v.error);throw new k($.InvalidParams,`Invalid task creation result: ${L}`)}return v.data}let _=d.tools||d.toolChoice?Mn:jn,w=ze(_,m);if(!w.success){let v=w.error instanceof Error?w.error.message:String(w.error);throw new k($.InvalidParams,`Invalid sampling result: ${v}`)}return w.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{let o=await this.request({method:"initialize",params:{protocolVersion:dt,capabilities:this._capabilities,clientInfo:this._clientInfo}},zn,r);if(o===void 0)throw new Error(`Server sent invalid initialize result: ${o}`);if(!Fu.includes(o.protocolVersion))throw new Error(`Server's protocol version is not supported: ${o.protocolVersion}`);this._serverCapabilities=o.capabilities,this._serverVersion=o.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(o.protocolVersion),this._instructions=o.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(o){throw this.close(),o}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${t})`);break;case"ping":break}}assertTaskCapability(t){dl(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&fl(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Je,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},Un,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Je,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},In,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Pn,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},vn,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},bn,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},kn,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Je,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Je,r)}async callTool(t,r=mt,o){if(this.isToolTaskRequired(t.name))throw new k($.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let n=await this.request({method:"tools/call",params:t},r,o),s=this.getToolOutputValidator(t.name);if(s){if(!n.structuredContent&&!n.isError)throw new k($.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(n.structuredContent)try{let i=s(n.structuredContent);if(!i.valid)throw new k($.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof k?i:new k($.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return n}isToolTask(t){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of t){if(r.outputSchema){let n=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,n)}let o=r.execution?.taskSupport;(o==="required"||o==="optional")&&this._cachedKnownTaskTools.add(r.name),o==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let o=await this.request({method:"tools/list",params:t},Zn,r);return this.cacheToolMetadata(o.tools),o}_setupListChangedHandler(t,r,o,n){let s=il.safeParse(o);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof o.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=o,u=async()=>{if(!i){c(null,null);return}try{let d=await n();c(null,d)}catch(d){let m=d instanceof Error?d:new Error(String(d));c(m,null)}},p=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let m=setTimeout(u,a);this._listChangedDebounceTimers.set(t,m)}else u()};this.setNotificationHandler(r,p)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var Xt=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},ml=10,oh=13,Be=32;function Vn(e){}function to(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Vn,onError:r=Vn,onRetry:o=Vn,onComment:n,maxBufferSize:s}=e,i=[],a=0,c=!0,u,p="",d=0,m,h=!1;function _(g){if(h)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,g.charCodeAt(0)===239&&g.charCodeAt(1)===187&&g.charCodeAt(2)===191&&(g=g.slice(3))),i.length===0){let W=v(g);W!==""&&(i.push(W),a=W.length),w();return}if(g.indexOf(`
|
|
71
|
+
`)===-1&&g.indexOf("\r")===-1){i.push(g),a+=g.length,w();return}i.push(g);let z=i.join("");i.length=0,a=0;let T=v(z);T!==""&&(i.push(T),a=T.length),w()}function w(){s!==void 0&&(a+p.length<=s||(h=!0,i.length=0,a=0,u=void 0,p="",d=0,m=void 0,r(new Xt(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function v(g){let z=0;if(g.indexOf("\r")===-1){let T=g.indexOf(`
|
|
72
|
+
`,z);for(;T!==-1;){if(z===T){d>0&&t({id:u,event:m,data:p}),u=void 0,p="",d=0,m=void 0,z=T+1,T=g.indexOf(`
|
|
73
|
+
`,z);continue}let W=g.charCodeAt(z);if(hl(g,z,W)){let O=g.charCodeAt(z+5)===Be?z+6:z+5,ie=g.slice(O,T);if(d===0&&g.charCodeAt(T+1)===ml){t({id:u,event:m,data:ie}),u=void 0,p="",m=void 0,z=T+2,T=g.indexOf(`
|
|
74
|
+
`,z);continue}p=d===0?ie:`${p}
|
|
75
|
+
${ie}`,d++}else gl(g,z,W)?m=g.slice(g.charCodeAt(z+6)===Be?z+7:z+6,T)||void 0:L(g,z,T);z=T+1,T=g.indexOf(`
|
|
76
|
+
`,z)}return g.slice(z)}for(;z<g.length;){let T=g.indexOf("\r",z),W=g.indexOf(`
|
|
77
|
+
`,z),O=-1;if(T!==-1&&W!==-1?O=T<W?T:W:T!==-1?T===g.length-1?O=-1:O=T:W!==-1&&(O=W),O===-1)break;L(g,z,O),z=O+1,g.charCodeAt(z-1)===oh&&g.charCodeAt(z)===ml&&z++}return g.slice(z)}function L(g,z,T){if(z===T){A();return}let W=g.charCodeAt(z);if(hl(g,z,W)){let tt=g.charCodeAt(z+5)===Be?z+6:z+5,Ss=g.slice(tt,T);p=d===0?Ss:`${p}
|
|
78
|
+
${Ss}`,d++;return}if(gl(g,z,W)){m=g.slice(g.charCodeAt(z+6)===Be?z+7:z+6,T)||void 0;return}if(W===105&&g.charCodeAt(z+1)===100&&g.charCodeAt(z+2)===58){let tt=g.slice(g.charCodeAt(z+3)===Be?z+4:z+3,T);tt.includes("\0")||(u=tt);return}if(W===58){if(n){let tt=g.slice(z,T);n(tt.slice(g.charCodeAt(z+1)===Be?2:1))}return}let O=g.slice(z,T),ie=O.indexOf(":");if(ie===-1){P(O,"",O);return}let vs=O.slice(0,ie),bs=O.charCodeAt(ie+1)===Be?2:1,Ap=O.slice(ie+bs);P(vs,Ap,O)}function P(g,z,T){switch(g){case"event":m=z||void 0;break;case"data":p=d===0?z:`${p}
|
|
79
|
+
${z}`,d++;break;case"id":z.includes("\0")||(u=z);break;case"retry":/^\d+$/.test(z)?o(parseInt(z,10)):r(new Xt(`Invalid \`retry\` value: "${z}"`,{type:"invalid-retry",value:z,line:T}));break;default:r(new Xt(`Unknown field "${g.length>20?`${g.slice(0,20)}\u2026`:g}"`,{type:"unknown-field",field:g,value:z,line:T}));break}}function A(){d>0&&t({id:u,event:m,data:p}),u=void 0,p="",d=0,m=void 0}function I(g={}){if(g.consume&&i.length>0){let z=i.join("");L(z,0,z.length)}c=!0,u=void 0,p="",d=0,m=void 0,i.length=0,a=0,h=!1}return{feed:_,reset:I}}function hl(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function gl(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var oo=class extends Event{constructor(t,r){var o,n;super(t),this.code=(o=r?.code)!=null?o:void 0,this.message=(n=r?.message)!=null?n:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,r,o){return o(_l(this),r)}[Symbol.for("Deno.customInspect")](t,r){return t(_l(this),r)}};function nh(e){let t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function Hn(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(Hn).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${Hn(e.cause)}`:e.message:`${e}`}function _l(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var xl=e=>{throw TypeError(e)},Qn=(e,t,r)=>t.has(e)||xl("Cannot "+r),R=(e,t,r)=>(Qn(e,t,"read from private field"),r?r.call(e):t.get(e)),Y=(e,t,r)=>t.has(e)?xl("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),J=(e,t,r,o)=>(Qn(e,t,"write to private field"),t.set(e,r),r),Ee=(e,t,r)=>(Qn(e,t,"access private method"),r),le,Ge,ht,ro,no,er,yt,tr,qe,gt,xt,_t,Yt,we,Jn,Wn,Bn,yl,Gn,Kn,Qt,Xn,Yn,Ke=class extends EventTarget{constructor(t,r){var o,n;super(),Y(this,we),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Y(this,le),Y(this,Ge),Y(this,ht),Y(this,ro),Y(this,no),Y(this,er),Y(this,yt),Y(this,tr,null),Y(this,qe),Y(this,gt),Y(this,xt,null),Y(this,_t,null),Y(this,Yt,null),Y(this,Wn,async s=>{var i;R(this,gt).reset();let{body:a,redirected:c,status:u,headers:p}=s;if(u===204){Ee(this,we,Qt).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?J(this,ht,new URL(s.url)):J(this,ht,void 0),u!==200){Ee(this,we,Qt).call(this,`Non-200 status code (${u})`,u);return}if(!(p.get("content-type")||"").startsWith("text/event-stream")){Ee(this,we,Qt).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(R(this,le)===this.CLOSED)return;J(this,le,this.OPEN);let d=new Event("open");if((i=R(this,Yt))==null||i.call(this,d),this.dispatchEvent(d),typeof a!="object"||!a||!("getReader"in a)){Ee(this,we,Qt).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}let m=new TextDecoder,h=a.getReader(),_=!0;do{let{done:w,value:v}=await h.read();v&&R(this,gt).feed(m.decode(v,{stream:!w})),w&&(_=!1,R(this,gt).reset(),Ee(this,we,Xn).call(this))}while(_)}),Y(this,Bn,s=>{J(this,qe,void 0),!(s.name==="AbortError"||s.type==="aborted")&&Ee(this,we,Xn).call(this,Hn(s))}),Y(this,Gn,s=>{typeof s.id=="string"&&J(this,tr,s.id);let i=new MessageEvent(s.event||"message",{data:s.data,origin:R(this,ht)?R(this,ht).origin:R(this,Ge).origin,lastEventId:s.id||""});R(this,_t)&&(!s.event||s.event==="message")&&R(this,_t).call(this,i),this.dispatchEvent(i)}),Y(this,Kn,s=>{J(this,er,s)}),Y(this,Yn,()=>{J(this,yt,void 0),R(this,le)===this.CONNECTING&&Ee(this,we,Jn).call(this)});try{if(t instanceof URL)J(this,Ge,t);else if(typeof t=="string")J(this,Ge,new URL(t,sh()));else throw new Error("Invalid URL")}catch{throw nh("An invalid or illegal string was specified")}J(this,gt,to({onEvent:R(this,Gn),onRetry:R(this,Kn)})),J(this,le,this.CONNECTING),J(this,er,3e3),J(this,no,(o=r?.fetch)!=null?o:globalThis.fetch),J(this,ro,(n=r?.withCredentials)!=null?n:!1),Ee(this,we,Jn).call(this)}get readyState(){return R(this,le)}get url(){return R(this,Ge).href}get withCredentials(){return R(this,ro)}get onerror(){return R(this,xt)}set onerror(t){J(this,xt,t)}get onmessage(){return R(this,_t)}set onmessage(t){J(this,_t,t)}get onopen(){return R(this,Yt)}set onopen(t){J(this,Yt,t)}addEventListener(t,r,o){let n=r;super.addEventListener(t,n,o)}removeEventListener(t,r,o){let n=r;super.removeEventListener(t,n,o)}close(){R(this,yt)&&clearTimeout(R(this,yt)),R(this,le)!==this.CLOSED&&(R(this,qe)&&R(this,qe).abort(),J(this,le,this.CLOSED),J(this,qe,void 0))}};le=new WeakMap,Ge=new WeakMap,ht=new WeakMap,ro=new WeakMap,no=new WeakMap,er=new WeakMap,yt=new WeakMap,tr=new WeakMap,qe=new WeakMap,gt=new WeakMap,xt=new WeakMap,_t=new WeakMap,Yt=new WeakMap,we=new WeakSet,Jn=function(){J(this,le,this.CONNECTING),J(this,qe,new AbortController),R(this,no)(R(this,Ge),Ee(this,we,yl).call(this)).then(R(this,Wn)).catch(R(this,Bn))},Wn=new WeakMap,Bn=new WeakMap,yl=function(){var e;let t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...R(this,tr)?{"Last-Event-ID":R(this,tr)}:void 0},cache:"no-store",signal:(e=R(this,qe))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Gn=new WeakMap,Kn=new WeakMap,Qt=function(e,t){var r;R(this,le)!==this.CLOSED&&J(this,le,this.CLOSED);let o=new oo("error",{code:t,message:e});(r=R(this,xt))==null||r.call(this,o),this.dispatchEvent(o)},Xn=function(e,t){var r;if(R(this,le)===this.CLOSED)return;J(this,le,this.CONNECTING);let o=new oo("error",{code:t,message:e});(r=R(this,xt))==null||r.call(this,o),this.dispatchEvent(o),J(this,yt,setTimeout(R(this,Yn),R(this,er)))},Yn=new WeakMap,Ke.CONNECTING=0,Ke.OPEN=1,Ke.CLOSED=2;function sh(){let e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}function zt(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function so(e=fetch,t){return t?async(r,o)=>{let n={...t,...o,headers:o?.headers?{...zt(t.headers),...zt(o.headers)}:t.headers};return e(r,n)}:e}var ih=5,ah=[301,302,303,307,308];function ch(e,t){return e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port?!0:e.hostname===t.hostname&&e.protocol==="http:"&&e.port===""&&t.protocol==="https:"&&t.port===""}function zl(e,t){let r=ah.includes(e.status)?e.headers.get("location"):null;try{return r?new URL(r,t):void 0}catch{return}}function io(e,t,r,o,n=0){let s=zl(o,t),i=o.status===307||o.status===308||(r?.method??"GET").toUpperCase()==="GET";if(!s||n===ih||!i)return;let a=new URL(t);if(!((s.username||s.password)&&(s.username!==a.username||s.password!==a.password)||!ch(a,s)))return Promise.resolve(o.body?.cancel()).then(()=>e(s,{...r,redirect:"manual"})).then(u=>io(e,s,r,u,n+1)??u)}var wl=new WeakSet;function wt(e){let t=(r,o)=>(e??fetch)(r,o);return wl.add(t),t}function be(e=fetch){return wl.has(e)?e:(t,r)=>r?.redirect==="error"||r?.redirect==="manual"?e(t,r):Promise.resolve(e(t,{...r,redirect:"manual"})).then(o=>io(e,t,r,o)??o)}function vt(e,t){if(e.type==="opaqueredirect")return"Redirect not followed: this runtime does not expose the redirect target";let r=e.url||t,o=zl(e,r);if(o)return o.username=o.password=o.search=o.hash="",o.protocol==="http:"&&new URL(r).protocol==="https:"?(o.protocol="https:",`Redirect to plain http not followed; try ${o.href} instead`):`Redirect to ${o.href} not followed`}var es;es=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function uh(e){return(await es).getRandomValues(new Uint8Array(e))}async function lh(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,o="";for(;o.length<e;){let n=await uh(e-o.length);for(let s of n)s<r&&(o+=t[s%t.length])}return o}async function ph(e){return await lh(e)}async function dh(e){let t=await(await es).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function ts(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await ph(e),r=await dh(t);return{code_verifier:t,code_challenge:r}}var oe=Tu().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:qu.custom,message:"URL must be parseable",fatal:!0}),yo}).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"}),bl=K({resource:l().url(),authorization_servers:y(oe).optional(),jwks_uri:l().url().optional(),scopes_supported:y(l()).optional(),bearer_methods_supported:y(l()).optional(),resource_signing_alg_values_supported:y(l()).optional(),resource_name:l().optional(),resource_documentation:l().optional(),resource_policy_uri:l().url().optional(),resource_tos_uri:l().url().optional(),tls_client_certificate_bound_access_tokens:M().optional(),authorization_details_types_supported:y(l()).optional(),dpop_signing_alg_values_supported:y(l()).optional(),dpop_bound_access_tokens_required:M().optional()}),rs=K({issuer:l(),authorization_endpoint:oe,token_endpoint:oe,registration_endpoint:oe.optional(),scopes_supported:y(l()).optional(),response_types_supported:y(l()),response_modes_supported:y(l()).optional(),grant_types_supported:y(l()).optional(),token_endpoint_auth_methods_supported:y(l()).optional(),token_endpoint_auth_signing_alg_values_supported:y(l()).optional(),service_documentation:oe.optional(),revocation_endpoint:oe.optional(),revocation_endpoint_auth_methods_supported:y(l()).optional(),revocation_endpoint_auth_signing_alg_values_supported:y(l()).optional(),introspection_endpoint:l().optional(),introspection_endpoint_auth_methods_supported:y(l()).optional(),introspection_endpoint_auth_signing_alg_values_supported:y(l()).optional(),code_challenge_methods_supported:y(l()).optional(),client_id_metadata_document_supported:M().optional()}),fh=K({issuer:l(),authorization_endpoint:oe,token_endpoint:oe,userinfo_endpoint:oe.optional(),jwks_uri:oe,registration_endpoint:oe.optional(),scopes_supported:y(l()).optional(),response_types_supported:y(l()),response_modes_supported:y(l()).optional(),grant_types_supported:y(l()).optional(),acr_values_supported:y(l()).optional(),subject_types_supported:y(l()),id_token_signing_alg_values_supported:y(l()),id_token_encryption_alg_values_supported:y(l()).optional(),id_token_encryption_enc_values_supported:y(l()).optional(),userinfo_signing_alg_values_supported:y(l()).optional(),userinfo_encryption_alg_values_supported:y(l()).optional(),userinfo_encryption_enc_values_supported:y(l()).optional(),request_object_signing_alg_values_supported:y(l()).optional(),request_object_encryption_alg_values_supported:y(l()).optional(),request_object_encryption_enc_values_supported:y(l()).optional(),token_endpoint_auth_methods_supported:y(l()).optional(),token_endpoint_auth_signing_alg_values_supported:y(l()).optional(),display_values_supported:y(l()).optional(),claim_types_supported:y(l()).optional(),claims_supported:y(l()).optional(),service_documentation:l().optional(),claims_locales_supported:y(l()).optional(),ui_locales_supported:y(l()).optional(),claims_parameter_supported:M().optional(),request_parameter_supported:M().optional(),request_uri_parameter_supported:M().optional(),require_request_uri_registration:M().optional(),op_policy_uri:oe.optional(),op_tos_uri:oe.optional(),client_id_metadata_document_supported:M().optional()}),Sl=x({...fh.shape,...rs.pick({code_challenge_methods_supported:!0}).shape}),kl=x({access_token:l(),id_token:l().optional(),token_type:l(),expires_in:jr.number().optional(),scope:l().optional(),refresh_token:l().optional(),issuer:l().optional().catch(void 0)}).strip(),$l=x({error:l(),error_description:l().optional(),error_uri:l().optional()}),vl=oe.optional().or(b("").transform(()=>{})),mh=x({redirect_uris:y(oe),token_endpoint_auth_method:l().optional(),grant_types:y(l()).optional(),response_types:y(l()).optional(),client_name:l().optional(),client_uri:oe.optional(),logo_uri:vl,scope:l().optional(),contacts:y(l()).optional(),tos_uri:vl,policy_uri:l().optional(),jwks_uri:oe.optional(),jwks:Cu().optional(),software_id:l().optional(),software_version:l().optional(),software_statement:l().optional()}).strip(),hh=x({client_id:l(),client_secret:l().optional(),client_id_issued_at:C().optional(),client_secret_expires_at:C().optional(),issuer:l().optional().catch(void 0)}).strip(),Pl=mh.merge(hh),ab=x({error:l(),error_description:l().optional()}).strip(),cb=x({token:l(),token_type_hint:l().optional()}).strip();function Tl(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Rl({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;let n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(s)}var G=class extends Error{constructor(t,r){super(t),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let t={error:this.errorCode,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}get errorCode(){return this.constructor.errorCode}},rr=class extends G{};rr.errorCode="invalid_request";var Xe=class extends G{};Xe.errorCode="invalid_client";var Ye=class extends G{};Ye.errorCode="invalid_grant";var Qe=class extends G{};Qe.errorCode="unauthorized_client";var or=class extends G{};or.errorCode="unsupported_grant_type";var nr=class extends G{};nr.errorCode="invalid_scope";var sr=class extends G{};sr.errorCode="access_denied";var Ce=class extends G{};Ce.errorCode="server_error";var ir=class extends G{};ir.errorCode="temporarily_unavailable";var ar=class extends G{};ar.errorCode="unsupported_response_type";var cr=class extends G{};cr.errorCode="unsupported_token_type";var ur=class extends G{};ur.errorCode="invalid_token";var lr=class extends G{};lr.errorCode="method_not_allowed";var pr=class extends G{};pr.errorCode="too_many_requests";var et=class extends G{};et.errorCode="invalid_client_metadata";var dr=class extends G{};dr.errorCode="insufficient_scope";var fr=class extends G{};fr.errorCode="invalid_target";var El={[rr.errorCode]:rr,[Xe.errorCode]:Xe,[Ye.errorCode]:Ye,[Qe.errorCode]:Qe,[or.errorCode]:or,[nr.errorCode]:nr,[sr.errorCode]:sr,[Ce.errorCode]:Ce,[ir.errorCode]:ir,[ar.errorCode]:ar,[cr.errorCode]:cr,[ur.errorCode]:ur,[lr.errorCode]:lr,[pr.errorCode]:pr,[et.errorCode]:et,[dr.errorCode]:dr,[fr.errorCode]:fr};var se=class extends Error{constructor(t){super(t??"Unauthorized")}};function gh(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var os="code",ns="S256";function _h(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&gh(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function yh(e,t,r,o){let{client_id:n,client_secret:s}=t;switch(e){case"client_secret_basic":xh(n,s,r);return;case"client_secret_post":zh(n,s,o);return;case"none":wh(n,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function xh(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}function zh(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function wh(e,t){t.set("client_id",e)}async function Il(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let o=$l.parse(JSON.parse(r)),{error:n,error_description:s,error_uri:i}=o,a=El[n]||Ce;return new a(s||"",i)}catch(o){let n=e instanceof Response?vt(e,e.url):void 0,s=`${t?`HTTP ${t}: `:""}${n??`Invalid OAuth error response: ${o}. Raw body: ${r}`}`;return new Ce(s)}}function vh(e,t){let[r,o]=[e,t];try{[r,o]=[new URL(e).href,new URL(t).href]}catch{}return r===o||r.endsWith("/")&&r.slice(0,-1)===o||o.endsWith("/")&&o.slice(0,-1)===r}function as(e,t){if(e)return typeof e.issuer!="string"?e.issuer==null?e:{...e,issuer:void 0}:vh(e.issuer,t)?e:void 0}var bh=kl.omit({issuer:!0}),Sh=Pl.omit({issuer:!0});function Ol(e,t){return new Error(`OAuth client information is bound to authorization server ${e.issuer} and is not presented to ${t}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}async function Ie(e,t){try{return await ss(e,t)}catch(r){if(r instanceof Xe||r instanceof Qe)return await e.invalidateCredentials?.("all"),await ss(e,t);if(r instanceof Ye)return await e.invalidateCredentials?.("tokens"),await ss(e,t);throw r}}async function ss(e,{serverUrl:t,authorizationCode:r,scope:o,resourceMetadataUrl:n,fetchFn:s}){let i=await e.discoveryState?.(),a,c,u,p=n;if(!p&&i?.resourceMetadataUrl&&(p=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await Al(c,{fetchFn:s}),!a)try{a=await Zl(t,{resourceMetadataUrl:p},s)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:p?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let O=await Ch(t,{resourceMetadataUrl:p,fetchFn:s});c=O.authorizationServerUrl,u=O.authorizationServerMetadata,a=O.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:p?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=String(c),m=await $h(t,e,a),h=m&&a&&!e.validateResourceURL?a.resource:m,_=o||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,w=await Promise.resolve(e.clientInformation()),v=as(w,d),L=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(w&&!v&&!L)throw Ol(w,d);let P=v?.issuer==null?v:void 0,A=async()=>{try{P&&await e.saveClientInformation?.({...P,issuer:d})}catch{}};if(!v){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let O=u?.client_id_metadata_document_supported===!0,ie=e.clientMetadataUrl;if(ie&&!kh(ie))throw new et(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${ie}`);if(O&&ie)v={client_id:ie,issuer:d},await e.saveClientInformation?.(v);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");v={...await Nh(c,{metadata:u,clientMetadata:e.clientMetadata,scope:_,fetchFn:s}),issuer:d},await e.saveClientInformation(v)}}let I=!e.redirectUrl;if(r!==void 0||I){let O=await Ah(e,c,{metadata:u,resource:h,authorizationCode:r,fetchFn:s});return await A(),await e.saveTokens({...O,issuer:d}),"AUTHORIZED"}let g=as(await e.tokens(),d);if(g?.refresh_token&&g.issuer==null&&console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged."),g?.refresh_token)try{let O=await Zh(c,{metadata:u,clientInformation:v,refreshToken:g.refresh_token,resource:h,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await A(),await e.saveTokens({...O,issuer:d}),"AUTHORIZED"}catch(O){if(!(!(O instanceof G)||O instanceof Ce))throw O}let z=e.state?await e.state():void 0,{authorizationUrl:T,codeVerifier:W}=await Ih(c,{metadata:u,clientInformation:v,state:z,redirectUrl:e.redirectUrl,scope:_,resource:h});return await e.saveCodeVerifier(W),await e.redirectToAuthorization(T),"REDIRECT"}function kh(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function $h(e,t,r){let o=Tl(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!Rl({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}function bt(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,o]=t.split(" ");if(r.toLowerCase()!=="bearer"||!o)return{};let n=is(e,"resource_metadata")||void 0,s;if(n)try{s=new URL(n)}catch{}let i=is(e,"scope")||void 0,a=is(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function is(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let o=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),n=r.match(o);return n?n[1]||n[2]:null}async function Zl(e,t,r=fetch){let o=await Rh(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw await o?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw await o.body?.cancel(),new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return bl.parse(await o.json())}async function cs(e,t,r=fetch){try{return await be(r)(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?cs(e,void 0,r):void 0;throw o}}function Ph(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Cl(e,t,r=fetch){return await cs(e,{"MCP-Protocol-Version":t},r)}function Th(e,t){return!e||!e.ok&&e.status<500&&t!=="/"}async function Rh(e,t,r,o){let n=new URL(e),s=o?.protocolVersion??dt,i;if(o?.metadataUrl)i=new URL(o.metadataUrl);else{let c=Ph(t,n.pathname);i=new URL(c,o?.metadataServerUrl??n),i.search=n.search}let a=await Cl(i,s,r);if(!o?.metadataUrl&&Th(a,n.pathname)){let c=new URL(`/.well-known/${t}`,n);a=await Cl(c,s,r)}return a}function Eh(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function Al(e,{fetchFn:t=fetch,protocolVersion:r=dt}={}){let o={"MCP-Protocol-Version":r,Accept:"application/json"},n=Eh(e);for(let{url:s,type:i}of n){let a=await cs(s,o,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}return i==="oauth"?rs.parse(await a.json()):Sl.parse(await a.json())}}}async function Ch(e,t){let r,o;try{r=await Zl(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(o=r.authorization_servers[0])}catch{}o||(o=String(new URL("/",e)));let n=await Al(o,{fetchFn:t?.fetchFn});return{authorizationServerUrl:o,authorizationServerMetadata:n,resourceMetadata:r}}function Nl(e){return typeof e=="string"?e:e.href}async function Ih(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:n,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(os))throw new Error(`Incompatible auth server: does not support response type ${os}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ns))throw new Error(`Incompatible auth server: does not support code challenge method ${ns}`)}else a=new URL("/authorize",e);let c=await ts(),u=c.code_verifier,p=c.code_challenge;return a.searchParams.set("response_type",os),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",p),a.searchParams.set("code_challenge_method",ns),a.searchParams.set("redirect_uri",String(o)),s&&a.searchParams.set("state",s),n&&a.searchParams.set("scope",n),n?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",Nl(i)),{authorizationUrl:a,codeVerifier:u}}function Oh(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function jl(e,{metadata:t,tokenRequestParams:r,clientInformation:o,addClientAuthentication:n,resource:s,fetchFn:i}){let a=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",Nl(s)),n)await n(c,r,a,t);else if(o){let p=t?.token_endpoint_auth_methods_supported??[],d=_h(o,p);yh(d,o,c,r)}let u=await be(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await Il(u);return bh.parse(await u.json())}async function Zh(e,{metadata:t,clientInformation:r,refreshToken:o,resource:n,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:o}),c=await jl(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:n,fetchFn:i});return{refresh_token:o,...c}}async function Ah(e,t,{metadata:r,resource:o,authorizationCode:n,fetchFn:s}={}){let i=async()=>{let p=await e.clientInformation(),d=as(p,String(t));if(p&&!d)throw Ol(p,String(t));return d},a=await i(),c=e.clientMetadata.scope,u;if(e.prepareTokenRequest&&(u=await e.prepareTokenRequest(c)),!u){if(!n)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let p=await e.codeVerifier();u=Oh(n,p,e.redirectUrl)}return a??(a=await i()),jl(t,{metadata:r,tokenRequestParams:u,clientInformation:a,addClientAuthentication:e.addClientAuthentication,resource:o,fetchFn:s})}async function Nh(e,{metadata:t,clientMetadata:r,scope:o,fetchFn:n}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i=await be(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...o!==void 0?{scope:o}:{}})});if(!i.ok)throw await Il(i);return Sh.parse(await i.json())}var us=class extends Error{constructor(t,r,o){super(`SSE error: ${r}`),this.code=t,this.event=o}},ao=class{constructor(t,r){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=so(r?.fetch,r?.requestInit),this._followRedirects=r?.redirectPolicy==="follow",this._followRedirects&&(this._fetch=wt(this._fetch),this._fetchWithInit=wt(this._fetchWithInit))}_unfollowedRedirect(t,r){let o=vt(t,r);return o&&!this._followRedirects?`${o} (redirectPolicy: 'same-origin')`:o}async _authThenStart(){if(!this._authProvider)throw new se("No auth provider");let t;try{t=await Ie(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new se;return await this._startOrAuth()}async _commonHeaders(){let t={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(t.Authorization=`Bearer ${o.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=zt(this._requestInit?.headers);return new Headers({...t,...r})}_startOrAuth(){let t=this?._eventSourceInit?.fetch??this._fetch??fetch,r=this._followRedirects?t:be(t),o;return new Promise((n,s)=>{this._eventSource=new Ke(this._url.href,{...this._eventSourceInit,fetch:async(i,a)=>{let c=await this._commonHeaders();c.set("Accept","text/event-stream");let u=await r(i,{...a,headers:c});if(o=this._unfollowedRedirect(u,i),u.status===401&&u.headers.has("www-authenticate")){let{resourceMetadataUrl:p,scope:d}=bt(u);this._resourceMetadataUrl=p,this._scope=d}return u}}),this._abortController=new AbortController,this._eventSource.onerror=i=>{if(i.code===401&&this._authProvider){this._authThenStart().then(n,s);return}let a=new us(i.code,o??i.message,i);s(a),this.onerror?.(a)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",i=>{let a=i;try{if(this._endpoint=new URL(a.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(c){s(c),this.onerror?.(c),this.close();return}n()}),this._eventSource.onmessage=i=>{let a=i,c;try{c=Le.parse(JSON.parse(a.data))}catch(u){this.onerror?.(u);return}this.onmessage?.(c)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new se("No auth provider");if(await Ie(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new se("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(t){if(!this._endpoint)throw new Error("Not connected");try{let r=await this._commonHeaders();r.set("content-type","application/json");let o={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(t),signal:this._abortController?.signal},n=await be(this._fetch??fetch)(this._endpoint,o);if(!n.ok){let s=await n.text().catch(()=>null);if(n.status===401&&this._authProvider){let{resourceMetadataUrl:i,scope:a}=bt(n);if(this._resourceMetadataUrl=i,this._scope=a,await Ie(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new se;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${n.status}): ${this._unfollowedRedirect(n,this._endpoint)??s}`)}await n.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(t){this._protocolVersion=t}};var Pp=mr(kp(),1);import xs from"node:process";import{PassThrough as pg}from"node:stream";var ug=10*1024*1024,uo=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??ug}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
80
|
+
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),lg(r)}clear(){this._buffer=void 0}};function lg(e){return Le.parse(JSON.parse(e))}function $p(e){return JSON.stringify(e)+`
|
|
81
|
+
`}var dg=xs.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function fg(){let e={};for(let t of dg){let r=xs.env[t];r!==void 0&&(r.startsWith("()")||(e[t]=r))}return e}var lo=class{constructor(t){this._stderrStream=null,this._serverParams=t,this._readBuffer=new uo({maxBufferSize:t.maxBufferSize}),(t.stderr==="pipe"||t.stderr==="overlapped")&&(this._stderrStream=new pg)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((t,r)=>{this._process=(0,Pp.default)(this._serverParams.command,this._serverParams.args??[],{env:{...fg(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:xs.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",o=>{r(o),this.onerror?.(o)}),this._process.on("spawn",()=>{t()}),this._process.on("close",o=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",o=>{this.onerror?.(o)}),this._process.stdout?.on("data",o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(n){this.onerror?.(n),this.close().catch(()=>{})}}),this._process.stdout?.on("error",o=>{this.onerror?.(o)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){if(this._process){let t=this._process;this._process=void 0;let r=new Promise(o=>{t.once("close",()=>{o()})});try{t.stdin?.end()}catch{}if(await Promise.race([r,new Promise(o=>setTimeout(o,2e3).unref())]),t.exitCode===null){try{t.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(o=>setTimeout(o,2e3).unref())])}if(t.exitCode===null)try{t.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(t){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let o=$p(t);this._process.stdin.write(o)?r():this._process.stdin.once("drain",r)})}};var Ip=mr(Cp(),1);function Op(e){if(e)try{return Ip.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}var po=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:o,maxBufferSize:n}={}){let s;super({start(i){s=to({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:o,maxBufferSize:n})},transform(i){s.feed(i)}})}};var vg={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Fe=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},fo=class{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=so(r?.fetch,r?.requestInit),this._followRedirects=r?.redirectPolicy==="follow",this._followRedirects&&(this._fetch=wt(this._fetch),this._fetchWithInit=wt(this._fetchWithInit)),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??vg}_unfollowedRedirect(t,r){let o=vt(t,r);return o&&!this._followRedirects?`${o} (redirectPolicy: 'same-origin')`:o}async _authThenStart(){if(!this._authProvider)throw new se("No auth provider");let t;try{t=await Ie(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new se;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(t.Authorization=`Bearer ${o.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=zt(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let o=await this._commonHeaders();o.set("Accept","text/event-stream"),r&&o.set("last-event-id",r);let n=this._fetch??fetch,s={method:"GET",headers:o,signal:this._abortController?.signal},i=await n(this._url,this._followRedirects?s:{...s,redirect:"manual"}),a=this._followRedirects?void 0:io(n,this._url,s,i);if(a&&(i=await a),!i.ok){if(await i.body?.cancel(),i.status===401&&this._authProvider)return await this._authThenStart();if(i.status===405)return;throw new Fe(i.status,`Failed to open SSE stream: ${this._unfollowedRedirect(i,this._url)??i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(o){throw this.onerror?.(o),o}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor,n=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(o,t),n)}_scheduleReconnection(t,r=0){let o=this._reconnectionOptions.maxRetries;if(r>=o){this.onerror?.(new Error(`Maximum reconnection attempts (${o}) exceeded.`));return}let n=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},n)}_handleSseStream(t,r,o){if(!t)return;let{onresumptiontoken:n,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let p=t.pipeThrough(new TextDecoderStream).pipeThrough(new po({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){let{value:h,done:_}=await p.read();if(_)break;if(h.id&&(i=h.id,a=!0,n?.(h.id)),!!h.data&&(!h.event||h.event==="message"))try{let w=Le.parse(JSON.parse(h.data));He(w)&&(c=!0,s!==void 0&&(w.id=s)),this.onmessage?.(w)}catch(w){this.onerror?.(w)}}(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:n,replayMessageId:s},0)}catch(p){if(this.onerror?.(new Error(`SSE stream disconnected: ${p}`)),(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:n,replayMessageId:s},0)}catch(h){this.onerror?.(new Error(`Failed to reconnect: ${h instanceof Error?h.message:String(h)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new se("No auth provider");if(await Ie(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new se("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,r){try{let{resumptionToken:o,onresumptiontoken:n}=r||{};if(o){this._startOrAuthSse({resumptionToken:o,replayMessageId:Ft(t)?t.id:void 0}).catch(h=>this.onerror?.(h));return}let s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:this._abortController?.signal},a=await be(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let h=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Fe(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:_,scope:w}=bt(a);if(this._resourceMetadataUrl=_,this._scope=w,await Ie(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new se;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:_,scope:w,error:v}=bt(a);if(v==="insufficient_scope"){let L=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===L)throw new Fe(403,"Server returned 403 after trying upscoping");if(w&&(this._scope=w),_&&(this._resourceMetadataUrl=_),this._lastUpscopingHeader=L??void 0,await Ie(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new se;return this.send(t)}}throw new Fe(a.status,`Error POSTing to endpoint: ${this._unfollowedRedirect(a,this._url)??h}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),Qu(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(h=>this.onerror?.(h));return}let p=(Array.isArray(t)?t:[t]).filter(h=>"method"in h&&"id"in h&&h.id!==void 0).length>0,d=a.headers.get("content-type"),m=Op(d);if(p)if(m==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:n},!1);else if(m==="application/json"){let h=await a.json(),_=Array.isArray(h)?h.map(w=>Le.parse(w)):[Le.parse(h)];for(let w of _)this.onmessage?.(w)}else throw await a.body?.cancel(),new Fe(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(o){throw this.onerror?.(o),o}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},o=await be(this._fetch??fetch)(this._url,r);if(await o.body?.cancel(),!o.ok&&o.status!==405)throw new Fe(o.status,`Failed to terminate session: ${this._unfollowedRedirect(o,this._url)??o.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};async function ws(e){let t=[],r;do{let o=await e(r);t.push(...o.items),r=o.nextCursor}while(r);return t}function bg(e){let t,r=e.setProtocolVersion?.bind(e);return e.setProtocolVersion=o=>{t=o,r?.(o)},()=>t}function Sg(){let e={};for(let[t,r]of Object.entries(process.env))r!==void 0&&(e[t]=r);return e}function kg(e){return e.kind==="http"?e.url.href:`"${[e.command,...e.args].join(" ")}"`}async function $g(e,t){let r=e.kind==="stdio"?[()=>new lo({command:e.command,args:e.args,env:Sg()})]:[()=>new fo(e.url,{requestInit:{headers:e.headers}}),()=>new ao(e.url,{requestInit:{headers:e.headers}})],o;for(let[n,s]of r.entries()){n>0&&_e.info(hr(` Retrying with the legacy HTTP+SSE transport...
|
|
82
|
+
`));let i=s(),a=bg(i),c=new eo({name:"redocly-cli",version:t});try{return await c.connect(i),{mcpClient:c,getProtocolVersion:a}}catch(u){o??=u,await c.close().catch(()=>{})}}throw new ye(`Failed to connect to the MCP server at ${kg(e)}: ${o instanceof Error?o.message:String(o)}`)}async function Zp(e,t){let{mcpClient:r,getProtocolVersion:o}=await $g(e,t);try{let n=r.getServerCapabilities(),s=n?.tools?await ws(async c=>{let u=await r.listTools({cursor:c});return{items:u.tools,nextCursor:u.nextCursor}}):[],i=n?.prompts?await ws(async c=>{let u=await r.listPrompts({cursor:c});return{items:u.prompts,nextCursor:u.nextCursor}}):[],a=n?.resources?await ws(async c=>{let u=await r.listResources({cursor:c});return{items:u.resources,nextCursor:u.nextCursor}}):[];return{protocolVersion:o(),capabilities:n,serverInfo:r.getServerVersion(),instructions:r.getInstructions(),tools:s,prompts:i,resources:a}}finally{await r.close()}}function Ig(e=[]){let t={};for(let r of e){let o=r.indexOf(":");if(o===-1)throw new ye(`Invalid header "${r}". Use the "Name: value" format.`);let n=r.slice(0,o).trim(),s=r.slice(o+1).trim();if(!n||!s)throw new ye(`Invalid header "${r}". Use the "Name: value" format.`);t[n]=s}return t}function Og(e){let t=[],r="",o,n=!1;for(let s of e)o?s===o?o=void 0:r+=s:s==='"'||s==="'"?(o=s,n=!0):/\s/.test(s)?(n||r)&&(t.push(r),r="",n=!1):r+=s;if(o)throw new ye(`Unclosed ${o} quote in --command.`);return(n||r)&&t.push(r),t}function Zg(e){if(e.command){let[r,...o]=Og(e.command);if(!r)throw new ye("The --command option cannot be empty.");return{kind:"stdio",command:r,args:o}}let t;try{t=new URL(e["server-url"]??"")}catch{throw new ye(`Invalid MCP server URL: ${e["server-url"]}.`)}return{kind:"http",url:t,headers:Ig(e.header)}}async function hS({argv:e,version:t}){let r=Zg(e),o=e.output;_e.info(hr(`
|
|
83
|
+
Connecting to the MCP server at ${r.kind==="http"?r.url.href:e.command}...
|
|
84
|
+
`));let n=await Zp(r,t),s=!Pg(o),i;if(!s){let p;try{p=ks(Rg(o,"utf-8"))}catch(d){throw new ye(`Failed to parse ${o}: ${d instanceof Error?d.message:String(d)}`)}if(!Se(p))throw new ye(`Expected ${o} to contain an OpenAPI description object.`);i=p}let a=r.kind==="http"?e["server-url"]:void 0;if(e.check){if(!i)throw new ye(`Cannot check ${o} - the file does not exist. Run the command without --check to create it.`);let p=_o(structuredClone(i),n,a),d=Ts(i,p);if(d.length===0){_e.info(`
|
|
85
|
+
`+go(`${ho(o)} is up to date with the MCP server.`)+`
|
|
86
|
+
`);return}_e.error(`
|
|
87
|
+
${o} is out of date with the MCP server:
|
|
88
|
+
`);for(let m of d)_e.error(` - ${m}
|
|
89
|
+
`);throw _e.error(`
|
|
90
|
+
Run the command without --check to update it.
|
|
91
|
+
`),new Ps}let c=_o(i,n,a),u=o.endsWith(".json")?JSON.stringify(c,null,2)+`
|
|
92
|
+
`:$s(c);Tg(Cg(o),{recursive:!0}),Eg(o,u),_e.info(`Recorded ${n.tools.length} tool(s), ${n.prompts.length} prompt(s), and ${n.resources.length} resource(s).
|
|
93
|
+
`),_e.info(`
|
|
94
|
+
`+go(`${s?"Created":"Updated"} ${ho(o)} with the MCP server capabilities in the x-mcp extension.`)+`
|
|
95
|
+
`),s&&_e.warn(`The info section of ${o} is scaffolded - review and complete it.
|
|
96
|
+
`)}export{hS as handleIntrospectMcp};
|
|
97
|
+
/*! Bundled license information:
|
|
98
|
+
|
|
99
|
+
content-type/index.js:
|
|
100
|
+
(*!
|
|
101
|
+
* content-type
|
|
102
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
103
|
+
* MIT Licensed
|
|
104
|
+
*)
|
|
105
|
+
*/
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as q}from"./
|
|
7
|
+
import{a as q}from"./6DO6IN4A.js";import{h as H,l as B,r as z,t as K,u as V,v as Z,w as _}from"./3TBVUHVH.js";import{b as J,d as M,e as Y,v as L}from"./F6IXS3RL.js";import"./LRUXN6H5.js";import{$ as O,V as N,Z as v,aa as A,ba as j,ca as b,ea as y,fa as C,ga as R,ia as e,l as h,oa as w,pa as D,ua as S,xa as g}from"./22EANOP2.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{dirname as le}from"node:path";function W(r,t,o,n){n&&e.info(C(v(`
|
|
8
8
|
\u2611\uFE0F Achieved Level: ${y(o)}
|
|
9
9
|
|
|
10
10
|
`))),e.output(`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a}from"./
|
|
7
|
+
import{a}from"./DNQSGL2N.js";import"./ERFYZ47T.js";import"./V5CIDI6D.js";import"./WZXA5XPB.js";import"./22EANOP2.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{a as mockGenerator};
|