@redocly/cli 2.70.0 → 2.71.1
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 +3 -3
- package/lib/chunks/25RSTUQA.js +7 -0
- package/lib/chunks/{K4NCFIYY.js → 2IUGP2IH.js} +3 -3
- package/lib/chunks/{7R4MBJSO.js → 2NYYNBAC.js} +1 -1
- package/lib/chunks/{27HOIIUB.js → 3N7LKSDD.js} +1 -1
- package/lib/chunks/4DUOPCYP.js +7 -0
- package/lib/chunks/{636S3S3W.js → 54EKLNNI.js} +1 -1
- package/lib/chunks/5BQNATJZ.js +20 -0
- package/lib/chunks/{PF43QQZA.js → 5DW3QRJB.js} +2 -2
- package/lib/chunks/{57DEU3FG.js → 5SSWNONM.js} +1 -1
- package/lib/chunks/6TCEQRVX.js +10 -0
- package/lib/chunks/{U6PNFV4R.js → 6ZNJ7RDX.js} +2 -2
- package/lib/chunks/{EHJFDQN5.js → 7HFLPQAB.js} +2 -2
- package/lib/chunks/{BXUA6AY4.js → ACAPGKSR.js} +59 -25
- package/lib/chunks/ACECCMWJ.js +14 -0
- package/lib/chunks/AH6ANNYP.js +9 -0
- package/lib/chunks/B5SUTVG4.js +7 -0
- package/lib/chunks/{HAOBCQWB.js → BE4Z5FOC.js} +10 -8
- package/lib/chunks/{PL7WHX67.js → BOWZV5S6.js} +1 -1
- package/lib/chunks/{IULINGO6.js → BPSWCUZE.js} +1 -1
- package/lib/chunks/{7CBQD5PF.js → BXXX3ZCV.js} +1 -1
- package/lib/chunks/{SV2XHB2S.js → CHX7O5AM.js} +7 -7
- package/lib/chunks/{2NVGTELR.js → CJWIDJTB.js} +1 -1
- package/lib/chunks/{ACLT4ABL.js → CX76LEFC.js} +1 -1
- package/lib/chunks/{WBWCX3LS.js → DORXGE7Z.js} +93 -93
- package/lib/chunks/{LD5MEXEL.js → DP3T6VZX.js} +1 -1
- package/lib/chunks/{FKKC7G6X.js → DURXFJ7H.js} +1 -1
- package/lib/chunks/DVLD4FET.js +20 -0
- package/lib/chunks/{YQZIKJQK.js → EAFZ6DNQ.js} +1 -1
- package/lib/chunks/{LS3G7CUH.js → EBHQXW6Z.js} +1 -1
- package/lib/chunks/{6RKDRRBP.js → EO65RJ4Z.js} +1 -1
- package/lib/chunks/{T55LQK2H.js → EQOFXQKD.js} +1 -1
- package/lib/chunks/FBEEMKTB.js +7 -0
- package/lib/chunks/{BU4AMVHN.js → FGJDZKD2.js} +1 -1
- package/lib/chunks/G6SB4ZP5.js +7 -0
- package/lib/chunks/{LRMOPAZ4.js → GAKWND4S.js} +1 -1
- package/lib/chunks/HAGYQ4BK.js +20 -0
- package/lib/chunks/{UW36CSXE.js → HBWCMTP3.js} +1 -1
- package/lib/chunks/{2R2CXBRH.js → HWOL3HHR.js} +1 -1
- package/lib/chunks/{FXHPWQD4.js → ILYXMZRT.js} +1 -1
- package/lib/chunks/{U32PWLWM.js → INGAWMLB.js} +1 -1
- package/lib/chunks/{23VRM4VC.js → IYV7EO2J.js} +1 -1
- package/lib/chunks/IZMDARCL.js +22 -0
- package/lib/chunks/JOWPA3MJ.js +7 -0
- package/lib/chunks/KFQC57GK.js +145 -0
- package/lib/chunks/KJIUDCYZ.js +7 -0
- package/lib/chunks/{EV2R6OHD.js → L2O63VRM.js} +1 -1
- package/lib/chunks/{6P2KU7XN.js → MH5X2EVH.js} +1 -1
- package/lib/chunks/{RLJVKAOL.js → NLAPR7D4.js} +1 -1
- package/lib/chunks/O53IFFP3.js +98 -0
- package/lib/chunks/PBQOGZ5C.js +8 -0
- package/lib/chunks/{AFZIICGE.js → Q3IJURM3.js} +1 -1
- package/lib/chunks/{HHCU6T2V.js → QXBSAWH3.js} +1 -1
- package/lib/chunks/QXHFS5G6.js +7 -0
- package/lib/chunks/{IPDHEEHQ.js → QZJAXPYF.js} +1 -1
- package/lib/chunks/{LT6WLL3O.js → RBJCAITC.js} +1 -1
- package/lib/chunks/{LG6FRFOY.js → RBNQC5ZB.js} +1 -1
- package/lib/chunks/{2CMKIFTE.js → RNA6JDRC.js} +1 -1
- package/lib/chunks/{DHP4BBTH.js → RNL7TC2W.js} +1 -1
- package/lib/chunks/{WKDC6LN3.js → RUPTJCF5.js} +1 -1
- package/lib/chunks/{MKYAX4HH.js → S6W63XAS.js} +1 -1
- package/lib/chunks/{B3GE7EIX.js → TN3JQHMS.js} +1 -1
- package/lib/chunks/TNRIBQHV.js +7 -0
- package/lib/chunks/TZROZMVE.js +20 -0
- package/lib/chunks/{BMAUX474.js → U7KIB7CD.js} +1 -1
- package/lib/chunks/{BD5WLGAJ.js → UMN7TKTH.js} +2 -2
- package/lib/chunks/{Q43RV27Q.js → V34D5CUU.js} +1 -1
- package/lib/chunks/{7PKQV3SS.js → W2CABGMW.js} +1 -1
- package/lib/chunks/{ODGGZDFZ.js → WCJ2HAN3.js} +1 -1
- package/lib/chunks/{YNBDXA7I.js → WJ3YDHQA.js} +1 -1
- package/lib/chunks/{CKDLDSPG.js → WLI2XLEP.js} +1 -1
- package/lib/chunks/X7C43UBI.js +7 -0
- package/lib/chunks/{EH6VW7JO.js → XGPGFZMH.js} +1 -1
- package/lib/chunks/{7GM5RHYD.js → XZIK3H6V.js} +1 -1
- package/lib/chunks/{NOS4FCD7.js → Y3LDWYZD.js} +1 -1
- package/lib/chunks/{YYPD75S5.js → Y5DDX2MU.js} +1 -1
- package/lib/chunks/{MT4W54PL.js → YL3LVBZF.js} +1 -1
- package/lib/chunks/{EIXR5LCC.js → ZBB6PS6I.js} +1 -1
- package/lib/chunks/{NZE22F7Q.js → ZQTHHPK3.js} +2 -2
- 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 +7 -2
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +1 -1
- 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 +17 -9
- package/lib/eject-assets/generators/mock/index.ts +4 -3
- package/lib/eject-assets/generators/mock/render.ts +128 -9
- package/lib/eject-assets/generators/mock/sample.ts +87 -4
- 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 +10 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +8 -3
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +11 -6
- package/lib/eject-assets/generators/php/pagination.ts +3 -2
- package/lib/eject-assets/generators/php/types.ts +12 -2
- 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 +3 -3
- package/lib/eject-assets/generators/python/models.ts +9 -3
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +6 -5
- 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 +6 -5
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +34 -7
- 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 +1 -1
- 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/go-generator/SKILL.md +3 -0
- package/lib/eject-assets/skills/mock-generator/SKILL.md +22 -0
- package/lib/eject-assets/skills/php-generator/SKILL.md +9 -2
- package/lib/eject-assets/skills/python-generator/SKILL.md +6 -0
- package/lib/eject-assets/skills/tanstack-query-generator/SKILL.md +2 -1
- package/lib/eject-assets/skills/transformers-generator/SKILL.md +4 -0
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +5 -0
- package/lib/index.js +37 -37
- package/lib/skills/redocly-cli/SKILL.md +20 -1
- package/package.json +1 -1
- package/lib/chunks/2Y7MGFQS.js +0 -105
- package/lib/chunks/AHEGLURA.js +0 -20
- package/lib/chunks/DQDJVO3X.js +0 -7
- package/lib/chunks/EK7EYCIE.js +0 -7
- package/lib/chunks/ERYWHU32.js +0 -19
- package/lib/chunks/GBN5W6T3.js +0 -9
- package/lib/chunks/GKXY6U4S.js +0 -145
- package/lib/chunks/HJWQEB7Y.js +0 -7
- package/lib/chunks/JKDUUCNL.js +0 -22
- package/lib/chunks/JM7BMZLD.js +0 -13
- package/lib/chunks/JUWXQD7B.js +0 -8
- package/lib/chunks/KGWCBODF.js +0 -7
- package/lib/chunks/LAML5K4D.js +0 -7
- package/lib/chunks/MOK3JA6R.js +0 -7
- package/lib/chunks/QKUESS2C.js +0 -20
- package/lib/chunks/RGVTUA3V.js +0 -7
- package/lib/chunks/RWKEGTOO.js +0 -7
- package/lib/chunks/S56YFLS5.js +0 -7
- package/lib/chunks/S6P42X5N.js +0 -20
- package/lib/chunks/UW4UC7ZI.js +0 -9
|
@@ -0,0 +1,98 @@
|
|
|
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{$ as to,L as wi,M as zi,U as rf,V as nf,_ as eo,c as Te,da as Cr,fa as xe,la as we,ma as bi}from"./DORXGE7Z.js";import"./NEWT5A6S.js";import{a as De,c as ce,d as Qn,e as Or}from"./RFWIIJFG.js";var ud=ce((r$,cd)=>{cd.exports=ad;ad.sync=H_;var sd=De("fs");function B_(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 n=0;n<r.length;n++){var o=r[n].toLowerCase();if(o&&e.substr(-o.length).toLowerCase()===o)return!0}return!1}function id(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:B_(t,r)}function ad(e,t,r){sd.stat(e,function(n,o){r(n,n?!1:id(o,e,t))})}function H_(e,t){return id(sd.statSync(e),e,t)}});var md=ce((n$,fd)=>{fd.exports=pd;pd.sync=J_;var ld=De("fs");function pd(e,t,r){ld.stat(e,function(n,o){r(n,n?!1:dd(o,t))})}function J_(e,t){return dd(ld.statSync(e),t)}function dd(e,t){return e.isFile()&&W_(e,t)}function W_(e,t){var r=e.mode,n=e.uid,o=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),l=a|c,d=r&u||r&c&&o===i||r&a&&n===s||r&l&&s===0;return d}});var gd=ce((s$,hd)=>{var o$=De("fs"),Jn;process.platform==="win32"||global.TESTING_WINDOWS?Jn=ud():Jn=md();hd.exports=ai;ai.sync=K_;function ai(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(n,o){ai(e,t||{},function(s,i){s?o(s):n(i)})})}Jn(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function K_(e,t){try{return Jn.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var vd=ce((i$,bd)=>{var Nt=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",_d=De("path"),G_=Nt?";":":",yd=gd(),xd=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),wd=(e,t)=>{let r=t.colon||G_,n=e.match(/\//)||Nt&&e.match(/\\/)?[""]:[...Nt?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=Nt?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Nt?o.split(r):[""];return Nt&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},zd=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:n,pathExt:o,pathExtExe:s}=wd(e,t),i=[],a=u=>new Promise((l,d)=>{if(u===n.length)return t.all&&i.length?l(i):d(xd(e));let f=n[u],m=/^".*"$/.test(f)?f.slice(1,-1):f,h=_d.join(m,e),_=!m&&/^\.[\\\/]/.test(e)?e.slice(0,2)+h:h;l(c(_,u,0))}),c=(u,l,d)=>new Promise((f,m)=>{if(d===o.length)return f(a(l+1));let h=o[d];yd(u+h,{pathExt:s},(_,x)=>{if(!_&&x)if(t.all)i.push(u+h);else return f(u+h);return f(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},X_=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:n,pathExtExe:o}=wd(e,t),s=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=_d.join(c,e),l=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+u:u;for(let d=0;d<n.length;d++){let f=l+n[d];try{if(yd.sync(f,{pathExt:o}))if(t.all)s.push(f);else return f}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw xd(e)};bd.exports=zd;zd.sync=X_});var kd=ce((a$,ci)=>{"use strict";var Sd=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};ci.exports=Sd;ci.exports.default=Sd});var Rd=ce((c$,Td)=>{"use strict";var $d=De("path"),Y_=vd(),Q_=kd();function Pd(e,t){let r=e.options.env||process.env,n=process.cwd(),o=e.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let i;try{i=Y_.sync(e.command,{path:r[Q_({env:r})],pathExt:t?$d.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return i&&(i=$d.resolve(o?e.options.cwd:"",i)),i}function ey(e){return Pd(e)||Pd(e,!0)}Td.exports=ey});var Ed=ce((u$,li)=>{"use strict";var ui=/([()\][%!^"`<>&|;, *?])/g;function ty(e){return e=e.replace(ui,"^$1"),e}function ry(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(ui,"^$1"),t&&(e=e.replace(ui,"^$1")),e}li.exports.command=ty;li.exports.argument=ry});var Cd=ce((l$,Od)=>{"use strict";Od.exports=/^#!(.*)/});var Ad=ce((p$,Id)=>{"use strict";var ny=Cd();Id.exports=(e="")=>{let t=e.match(ny);if(!t)return null;let[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o}});var Nd=ce((d$,Zd)=>{"use strict";var pi=De("fs"),oy=Ad();function sy(e){let r=Buffer.alloc(150),n;try{n=pi.openSync(e,"r"),pi.readSync(n,r,0,150,0),pi.closeSync(n)}catch{}return oy(r.toString())}Zd.exports=sy});var Ld=ce((f$,Dd)=>{"use strict";var iy=De("path"),Md=Rd(),jd=Ed(),ay=Nd(),cy=process.platform==="win32",uy=/\.(?:com|exe)$/i,ly=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function py(e){e.file=Md(e);let t=e.file&&ay(e.file);return t?(e.args.unshift(e.file),e.command=t,Md(e)):e.file}function dy(e){if(!cy)return e;let t=py(e),r=!uy.test(t);if(e.options.forceShell||r){let n=ly.test(t);e.command=iy.normalize(e.command),e.command=jd.command(e.command),e.args=e.args.map(s=>jd.argument(s,n));let o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function fy(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);let n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:dy(n)}Dd.exports=fy});var Fd=ce((m$,qd)=>{"use strict";var di=process.platform==="win32";function fi(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 my(e,t){if(!di)return;let r=e.emit;e.emit=function(n,o){if(n==="exit"){let s=Ud(o,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function Ud(e,t){return di&&e===1&&!t.file?fi(t.original,"spawn"):null}function hy(e,t){return di&&e===1&&!t.file?fi(t.original,"spawnSync"):null}qd.exports={hookChildProcess:my,verifyENOENT:Ud,verifyENOENTSync:hy,notFoundError:fi}});var Hd=ce((h$,Mt)=>{"use strict";var Vd=De("child_process"),mi=Ld(),hi=Fd();function Bd(e,t,r){let n=mi(e,t,r),o=Vd.spawn(n.command,n.args,n.options);return hi.hookChildProcess(o,n),o}function gy(e,t,r){let n=mi(e,t,r),o=Vd.spawnSync(n.command,n.args,n.options);return o.error=o.error||hi.verifyENOENTSync(o.status,n),o}Mt.exports=Bd;Mt.exports.spawn=Bd;Mt.exports.sync=gy;Mt.exports._parse=mi;Mt.exports._enoent=hi});var Yd=ce(_i=>{"use strict";var Kd=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,by=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Gd=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,vy=/\\([\u000b\u0020-\u00ff])/g,Sy=/([\\"])/g,Xd=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;_i.format=ky;_i.parse=$y;function ky(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!Xd.test(r))throw new TypeError("invalid type");var n=r;if(t&&typeof t=="object")for(var o,s=Object.keys(t).sort(),i=0;i<s.length;i++){if(o=s[i],!Gd.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+Ty(t[o])}return n}function $y(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?Py(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=r!==-1?t.slice(0,r).trim():t.trim();if(!Xd.test(n))throw new TypeError("invalid media type");var o=new Ry(n.toLowerCase());if(r!==-1){var s,i,a;for(Kd.lastIndex=r;i=Kd.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(vy,"$1"))),o.parameters[s]=a}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}function Py(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 Ty(e){var t=String(e);if(Gd.test(t))return t;if(t.length>0&&!by.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(Sy,"\\$1")+'"'}function Ry(e){this.parameters=Object.create(null),this.type=e}});import{existsSync as Zy,mkdirSync as Ny,readFileSync as My,writeFileSync as jy}from"node:fs";import{dirname as Dy}from"node:path";import{isDeepStrictEqual as Lt}from"node:util";function Dt(e){let t=new Map;for(let r of Array.isArray(e)?e:[])Te(r)&&t.set(r.name,r);return t}function Ir(e,t,r){let n=Dt(t);return e.map(o=>{let s=n.get(o.name),i={};for(let a of r)s&&s[a]!==void 0&&(i[a]=s[a]);return{...o,...i}})}function of(e,t){let r=Dt(t);return Ir(e,t,["tags","security"]).map(n=>{if(!n.arguments)return n;let o=r.get(n.name)?.arguments;return{...n,arguments:Ir(n.arguments,o,["example"])}})}function ro(e,t,r){let n=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:{}},o=Te(n["x-mcp"])?n["x-mcp"]:{},s={...o};if(t.protocolVersion&&(s.protocolVersion=t.protocolVersion),r){let i=Array.isArray(s.servers)?s.servers:[];i.some(a=>Te(a)&&a.url===r)||i.push({url:r}),s.servers=i}return t.capabilities&&(s.capabilities=t.capabilities),t.capabilities?.tools?s.tools=Ir(t.tools,o.tools,["tags","security"]):delete s.tools,t.capabilities?.prompts?s.prompts=of(t.prompts,o.prompts):delete s.prompts,t.capabilities?.resources?s.resources=Ir(t.resources,o.resources,["tags","security"]):delete s.resources,n["x-mcp"]=s,n}function sf(e,t){let r=Dt(e),n=Dt(t),o=[...n.keys()].filter(c=>!r.has(c)),s=[...r.keys()].filter(c=>!n.has(c)),i=[...n.keys()].filter(c=>r.has(c)&&!Lt(r.get(c),n.get(c))),a=[];return o.length>0&&a.push(`added: ${o.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 vi(e,t){if(Lt(e,t))return[];let r=Te(e["x-mcp"])?e["x-mcp"]:{},n=Te(t["x-mcp"])?t["x-mcp"]:{},o=[];for(let s of["tools","prompts","resources"]){let i=sf(r[s],n[s]);i&&o.push(`${s} - ${i}`)}return Lt(r.protocolVersion,n.protocolVersion)||o.push(`protocolVersion - ${r.protocolVersion??"not set"} -> ${n.protocolVersion}`),Lt(r.capabilities,n.capabilities)||o.push("capabilities changed"),Lt(r.servers,n.servers)||o.push("servers - the MCP server URL is not listed"),o.length===0&&o.push("x-mcp changed"),o}var P={};Qn(P,{BIGINT_FORMAT_RANGES:()=>Mr,CONSTANT_CATCH:()=>Zi,Class:()=>so,NUMBER_FORMAT_RANGES:()=>qt,aborted:()=>ze,allowsEval:()=>lo,assert:()=>pf,assertEqual:()=>af,assertIs:()=>uf,assertNever:()=>lf,assertNotEqual:()=>cf,assignProp:()=>fe,attachSchema:()=>Ft,base64ToUint8Array:()=>Ii,base64urlToUint8Array:()=>Ef,cached:()=>dt,captureStackTrace:()=>Zr,cleanEnum:()=>Rf,cleanRegex:()=>Ut,clone:()=>ge,cloneDef:()=>mf,codePointLength:()=>Vt,constantCatch:()=>Ni,createTransparentProxy:()=>wf,defineLazy:()=>$i,defineLazyInternal:()=>I,derived:()=>Af,esc:()=>co,escapeRegex:()=>Oe,explicitlyAborted:()=>mo,extend:()=>vf,finalizeIssue:()=>be,floatSafeRemainder:()=>ao,getElementAtPath:()=>hf,getEnumValues:()=>lt,getLengthableOrigin:()=>Bt,getParsedType:()=>xf,getSizableOrigin:()=>Ci,hexToUint8Array:()=>Cf,hide:()=>Lr,installLazyProp:()=>jf,isObject:()=>Xe,isPlainObject:()=>qe,issue:()=>mt,joinValues:()=>Ar,jsonStringifyReplacer:()=>pt,members:()=>go,merge:()=>kf,mergeDefs:()=>Ee,normalizeParams:()=>S,nullish:()=>io,numKeys:()=>yf,objectClone:()=>df,omit:()=>bf,optionalKeys:()=>fo,own:()=>Ue,parsedType:()=>ho,partial:()=>$f,pick:()=>zf,prefixIssues:()=>Ce,primitiveTypes:()=>Ei,promiseAllObject:()=>gf,propertyKeyTypes:()=>po,randomString:()=>_f,rawShape:()=>ft,required:()=>Pf,safeExtend:()=>Sf,shallowClone:()=>Ri,sizeCaps:()=>Dr,slugify:()=>uo,stringifyPrimitive:()=>Nr,toZod:()=>ki,uint8ArrayToBase64:()=>Ai,uint8ArrayToBase64url:()=>Of,uint8ArrayToHex:()=>If,unwrapMessage:()=>ut});function af(e){return e}function cf(e){return e}function ki(){return e=>e}function uf(e){}function lf(e){throw new Error("Unexpected value in exhaustive check")}function pf(e){}function lt(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Ar(e,t="|"){return e.map(r=>Nr(r)).join(t)}function pt(e,t){return typeof t=="bigint"?t.toString():t}var oo=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function dt(e){return new oo(e)}function io(e){return e==null}function Ut(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ao(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Si=Symbol("evaluating");function $i(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Si)return n===void 0&&(n=Si,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function df(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function fe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ft(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Re(e){return ft(e._zod.def)??e._zod.def.shape}function Pi(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return fe(this,t,n),n},enumerable:!0,configurable:!0})}function Ti(e,t,r){t in e?fe(e,t,r):e[t]=r}function Ge(e,t,r,n){let o=Re(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?Pi(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):Ti(e,s,n?n(i.value,s):i.value))}}function ff(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?Pi(e,r,()=>t[r]):Ti(e,r,n.value))}}function Ee(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function mf(e){return Ee(e._zod.def)}function hf(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function gf(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function _f(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function co(e){return JSON.stringify(e)}function uo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Zr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var lo=dt(()=>{if(ue.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function qe(e){if(Xe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Xe(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ri(e){return qe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function yf(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var xf=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}`)}},po=new Set(["string","number","symbol"]),Ei=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}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 wf(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function Nr(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function fo(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var qt={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]},Mr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function zf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return Ge(s,e,jr(e,t)),ge(e,Ee(r,{shape:s,checks:[]}))}function jr(e,t){let r=Re(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function bf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(jr(e,t)),i={};return Ge(i,e,Reflect.ownKeys(Re(e)).filter(a=>!s.has(a))),ge(e,Ee(r,{shape:i,checks:[]}))}function vf(e,t){if(!qe(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Re(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ge(e,Ee(e._zod.def,{shape:Oi(e,t)}))}function Oi(e,t){let r={};return Ge(r,e,Reflect.ownKeys(Re(e))),ff(r,t),r}function Sf(e,t){if(!qe(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ge(e,Ee(e._zod.def,{shape:Oi(e,t)}))}function kf(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Ge(r,e,Reflect.ownKeys(Re(e))),Ge(r,t,Reflect.ownKeys(Re(t)));let n=Ee(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ge(e,n)}function $f(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(jr(t,r)):void 0,c={};return Ge(c,t,Reflect.ownKeys(Re(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),ge(t,Ee(t._zod.def,{shape:c,checks:[]}))}function Pf(e,t,r){let n=r?new Set(jr(t,r)):void 0,o={};return Ge(o,t,Reflect.ownKeys(Re(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),ge(t,Ee(t._zod.def,{shape:o}))}function ze(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 mo(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 Ce(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ut(e){return typeof e=="string"?e:e?.message}function Dr(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function Ft(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function be(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:ut(e.inst?._zod.def?.error?.(e))??ut(s?.(e))??ut(t?.error?.(e))??ut(r.customError?.(e))??ut(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Ci(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var Tf=/[\uD800-\uDBFF]/;function Vt(e){let t=e.length;if(!Tf.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Bt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ho(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 mt(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Rf(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Ii(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Ai(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Ef(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Ii(t+r)}function Of(e){return Ai(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Cf(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 n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function If(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var so=class{constructor(...t){}};function go(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Zf(e,r,n.value)}}function Ue(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Lr(e,t,r){return Ue(e,t,r,!1)}function Af(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ue(this,r,n(this))},set(o){Ue(this,r,o)}})}return t}function Zf(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ue(this,t,r.bind(this))},set(n){Ue(this,t,n)}})}function Nf(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var no,Le=!1,Mf={configurable:!0,get(){Le=!0}};function I(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&no!==e._zod){no=void 0;return}no=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Mf);let o=Le;Le=!1;try{let s=r(this);return Le?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Le=Le||o,s}catch(s){throw delete this[t],Le=Le||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function jf(e,t,r,n){let o=Nf(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Zi="~constantCatch";function Ni(e){let t=()=>e;return t[Zi]=!0,t}var Mi,yo=Object.freeze({status:"aborted"}),_o={value:void 0,enumerable:!1},ji="captureStackTrace"in Error?Error:null;function Df(e){let t=ji;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return ji=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function g(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,m){if(f._zod){if(f._zod.traits.has(e))return}else{_o.value=new s(m);try{Object.defineProperty(f,"_zod",_o)}finally{_o.value=void 0}}if(f._zod.traits.add(e),t(f,m),a){let _=Object.getPrototypeOf(f),x=f._zod.constr.prototype,$=_;for(;$&&$!==x;)$=Object.getPrototypeOf($);let R=$??_;a.has(R)||(a.add(R),go(R,i))}let h=d.prototype;for(let _ in h)Object.prototype.hasOwnProperty.call(h,_)&&(_ in f||(f[_]=h[_].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let m=n?.Parent?Df(l):this;c(m,f);let h=m._zod.deferred;if(h){for(let x of h)x();m._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;return _&&_(m),m}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ve=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ht=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Mi=globalThis).__zod_globalConfig??(Mi.__zod_globalConfig={});var ue=globalThis.__zod_globalConfig;function le(e){return e&&Object.assign(ue,e),ue}function Lf(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,pt,2)),e.message}function Uf(e){this._zod.message=e}var qf={get:Lf,set:Uf,enumerable:!0,configurable:!0},wo={value:void 0,enumerable:!1},Di=new WeakSet([Object.prototype,Error.prototype]),Li=(e,t)=>{e.name="$ZodError",wo.value=t,Object.defineProperty(e,"issues",wo),wo.value=void 0,Object.defineProperty(e,"message",qf);let r=Object.getPrototypeOf(e);Di.has(r)||(Di.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Ui=g("$ZodError",Li),qi=g("$ZodError",Li,void 0,{Parent:Error});function Ff(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function zo(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?Ff(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function bo(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({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 l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function Ur(e,t){return{callee:t?.callee??e,Err:t?.Err}}var qr=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ve;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>be(u,i,le())));throw Zr(c,s?.callee??t),c}return a.value};return t};var Fr=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>be(u,i,le())));throw Zr(c,s?.callee??t),c}return a.value};return t};var Ht=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ve;return s.issues.length?Fi(e,s.issues,o):{success:!0,data:s.value}},vo=Ht(qi);function Fi(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>be(o,r,le()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Vr=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Fi(e,s.issues,o):{success:!0,data:s.value}};var Bf=Symbol.for("zod.compile.invalid"),Hf=Symbol.for("zod.compile.fallback"),Br=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Bf)return!0;if(n.definite===!0&&r===void 0)return!1}return Jf(e,t,r)});function Jf(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[Hf]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ve;return s.issues.length===0}var Hr=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Vi=e=>{let t=qr(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Ur(r,i))};return r};var Bi=e=>{let t=qr(e),r=(n,o,s,i)=>t(n,o,s,Ur(r,i));return r};var Hi=e=>{let t=Fr(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Ur(r,i))};return r};var Ji=e=>{let t=Fr(e),r=async(n,o,s,i)=>await t(n,o,s,Ur(r,i));return r};var Wi=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Ht(e)(t,r,o)};var Ki=e=>(t,r,n)=>Ht(e)(t,r,n);var Gi=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Vr(e)(t,r,o)};var Xi=e=>async(t,r,n)=>Vr(e)(t,r,n);var Yi=/^[cC][0-9a-z]{6,}$/,Qi=/^[0-9a-z]+$/,ea=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ta=/^[0-9a-vA-V]{20}$/,ra=/^[A-Za-z0-9]{27}$/,na=/^[a-zA-Z0-9_-]{21}$/;function oa(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var sa=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ia=/^([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})$/,ko=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 aa=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Wf="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function ca(){return new RegExp(Wf,"u")}var ua=/^(?:(?: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])$/,la=/^(([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 pa=/^((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])$/,da=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ma=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var ha=/^https?$/,ga=/^\+[1-9]\d{6,14}$/;var _a="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Kf(e){return new RegExp(`^${e}$`)}var ya=Kf(_a);function So(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function xa(e){return new RegExp(`^${So(e)}$`)}function wa(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${So({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${So({precision:e.precision})}`:r;return new RegExp(`^${_a}T(?:${n})$`)}var za=/^[\s\S]{0,}$/;var ba=/^-?\d+n?$/,$o=/^-?\d+$/,Jt=/^-?\d+(?:\.\d+)?$/,va=/^(?:true|false)$/i,Sa=/^null$/i;var ka=/^[^A-Z]*$/,$a=/^[^a-z]*$/;var Q=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Po=e=>{let t=e.value;return!io(t)&&t.length!==void 0},Jr={number:"number",bigint:"bigint",object:"date"},To=g("$ZodCheckLessThan",(e,t)=>{Q.init(e,t);let r=Jr[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Jr[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ro=g("$ZodCheckGreaterThan",(e,t)=>{Q.init(e,t);let r=Jr[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Jr[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pa=g("$ZodCheckMultipleOf",(e,t)=>{Q.init(e,t),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"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):ao(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})}}),Ta=g("$ZodCheckNumberFormat",(e,t)=>{Q.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=qt[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,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:n,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:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,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 Ra=g("$ZodCheckMaxLength",(e,t)=>{var r;Q.init(e,t),(r=e._zod.def).when??(r.when=Po),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?Vt(o):s)<=t.maximum)return;let a=Bt(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ea=g("$ZodCheckMinLength",(e,t)=>{var r;Q.init(e,t),(r=e._zod.def).when??(r.when=Po),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?Vt(o):s)>=t.minimum)return;let a=Bt(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Oa=g("$ZodCheckLengthEquals",(e,t)=>{var r;Q.init(e,t),(r=e._zod.def).when??(r.when=Po),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?Vt(o):s;if(i===t.length)return;let a=Bt(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Wt=g("$ZodCheckStringFormat",(e,t)=>{var r,n;Q.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ca=g("$ZodCheckRegex",(e,t)=>{Wt.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})}}),Ia=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ka),Wt.init(e,t)}),Aa=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$a),Wt.init(e,t)}),Za=g("$ZodCheckIncludes",(e,t)=>{Q.init(e,t);let r=Oe(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Na=g("$ZodCheckStartsWith",(e,t)=>{Q.init(e,t);let r=new RegExp(`^${Oe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ma=g("$ZodCheckEndsWith",(e,t)=>{Q.init(e,t);let r=new RegExp(`.*${Oe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var ja=g("$ZodCheckOverwrite",(e,t)=>{Q.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Wr=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
8
|
+
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
9
|
+
${r.join(`
|
|
10
|
+
`)}
|
|
11
|
+
};`)(...Object.values(this.closed))}};var La={major:4,minor:6,patch:7};var Z=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=La;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=ze(a),d;for(let f of c){if(f._zod.def.when){if(mo(a)||!f._zod.def.when(a))continue}else if(l)continue;let m=a.issues.length,h=f._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new ve;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==m&&(Ft(a.issues,m,e),l||(l=ze(a,m)))});else{if(a.issues.length===m)continue;Ft(a.issues,m,e),l||(l=ze(a,m))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(ze(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ve;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ve;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return Lr(this,"~standard",Oo(this))},set"~standard"(e){Ue(this,"~standard",e)}}),Xa=(e,t)=>e.issues.length?{issues:e.issues.map(r=>be(r,t,le()))}:{value:e.value};async function Gf(e,t){let r={async:!0};return Xa(await e._zod.run({value:t,issues:[]},r),r)}function Oo(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Xa(n,r)}catch{}return Gf(e,t)},vendor:"zod",version:1}}var Yr=g("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=t.pattern??za,e._zod.parse=(r,n)=>{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}}),D=g("$ZodStringFormat",(e,t)=>{Wt.init(e,t),Yr.init(e,t)}),Ya=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ia),D.init(e,t)}),Qa=g("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ko(n))}else t.pattern??(t.pattern=ko());D.init(e,t)}),ec=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=aa),D.init(e,t)}),tc=1,Gr=2;function rc(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Xf(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?rc(e)||Gr:Yf(e,t)}function Yf(e,t){if(!t.normalize&&t.protocol?.source===ha.source&&!/^https?:\/\//i.test(e))return tc;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Gr}return new URL(e)}catch{return Gr}}var Qf=/[\t\n\r]/g;function Ua(e){return e.replace(Qf,"")}function em(e,t){return t.lastIndex=0,t.test(e.hostname)}function tm(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var nc=g("$ZodURL",(e,t)=>{D.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=Xf(n,t);if(o===tc){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Gr){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ua(n);return}t.hostname&&!em(o,t.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&&!tm(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Ua(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),oc=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ca()),D.init(e,t)}),sc=g("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?na:oa(t.length)),D.init(e,t)}),ic=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yi),D.init(e,t)}),ac=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Qi),D.init(e,t)}),cc=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ea),D.init(e,t)}),uc=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ta),D.init(e,t)}),lc=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ra),D.init(e,t)}),pc=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=wa(t)),D.init(e,t)}),dc=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ya),D.init(e,t)}),fc=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xa(t)),D.init(e,t)}),mc=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=sa),D.init(e,t)}),hc=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ua),D.init(e,t)}),rm=/^[0-9a-fA-F:.]+$/;function gc(e){return rm.test(e)?rc(`http://[${e}]`):!1}var _c=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=la),D.init(e,t),e._zod.check=r=>{gc(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var yc=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=pa),D.init(e,t)});function nm(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:gc(r)}var xc=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=da),D.init(e,t),e._zod.check=r=>{nm(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function wc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Co=/^[0-9a-zA-Z+/]*={0,2}$/,zc=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Co),D.init(e,t),e._zod.check=r=>{wc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Qr=/^[A-Za-z0-9_-]*$/;function om(e){if(!Qr.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return wc(r)}var bc=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qr),D.init(e,t),e._zod.check=r=>{om(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),vc=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ga),D.init(e,t)});function sm(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Sc=g("$ZodJWT",(e,t)=>{D.init(e,t),e._zod.check=r=>{sm(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Io=g("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=Jt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),kc=g("$ZodNumberFormat",(e,t)=>{Ta.init(e,t),Io.init(e,t)}),$c=g("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=va,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),Pc=g("$ZodBigInt",(e,t)=>{Z.init(e,t),e._zod.pattern=ba,e._zod.parse=(r,n)=>{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 Tc=g("$ZodNull",(e,t)=>{Z.init(e,t),e._zod.pattern=Sa,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),Rc=g("$ZodAny",(e,t)=>{Z.init(e,t),e._zod.parse=r=>r}),Ec=g("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=r=>r}),Oc=g("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var Cc=g("$ZodDate",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,s=o instanceof Date;return s&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...s?{received:"Invalid Date"}:{},inst:e}),r}});function im(e,t){let r=Dr(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(s=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let a=t(s.value);if(a>n&&!i?.skipChecks&&i?.direction!=="backward"){for(let[c,u]of Dr(e._zod.def.checks))if(a>c&&u._zod.def.when(s)){let l=s.issues.length;return u._zod.check(s),s.issues[l].continue=!1,Ft(s.issues,l,e),s}}return o(s,i)}}var am=e=>Array.isArray(e)?e.length:-1;function qa(e,t,r){e.issues.length&&t.issues.push(...Ce(r,e.issues)),t.value[r]=e.value}var Ic=g("$ZodArray",(e,t)=>{Z.init(e,t);let r=ue.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>qa(d,n,c)));else if(qa(l,n,c),a&&l.issues.length!==0&&ze(l))break}return i.length?Promise.all(i).then(()=>n):n},im(e,am)});function Xr(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...Ce(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var cm=[];function Ac(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:cm,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=fo(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Zc(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,m=0;for(let h in t){if(i&&r.issues.length!==m){if(ze(r,m))break;m=r.issues.length}if(c.has(h))continue;if(h==="__proto__"){l==="never"&&a.push(h);continue}if(l==="never"){a.push(h);continue}let _=u.run({value:t[h],issues:[]},n);_ instanceof Promise?e.push(_.then(x=>Xr(x,r,h,t,d,f))):Xr(_,r,h,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var um=g("$ZodObject",(e,t)=>{Z.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=dt(()=>Ac(t));I(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let m=l[f]._zod;if(m.values){Object.prototype.hasOwnProperty.call(d,f)||fe(d,f,new Set);for(let h of m.values)d[f].add(h);m.optin!==void 0&&d[f].add(void 0)}}return d});let s=Xe,i=t.catchall,a,c=ue.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],m=a.shape,h=l?.abortEarly,_=u.issues.length;for(let x of a.allKeys){if(h&&u.issues.length!==_){if(ze(u,_))break;_=u.issues.length}if(x==="__proto__")continue;let $=m[x],R=$._zod.optin,U=$._zod.optout,ae=$._zod.run({value:d[x],issues:[]},l);ae instanceof Promise?f.push(ae.then(w=>Xr(w,u,x,d,R,U))):Xr(ae,u,x,d,R,U)}return i?Zc(f,d,u,l,o.value,e,h===!0):f.length?Promise.all(f).then(()=>u):u}}),Nc=g("$ZodObjectJIT",(e,t)=>{um.init(e,t);let r=e._zod.parse,n=dt(()=>Ac(t)),o=ue.memoizer,s=m=>{let h=n.value,_=h.symbolKeys,x=new Wr(["payload","ctx"],{shape:m,inst:e,memo:o,syms:_}),$=w=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,R=(w,y)=>`
|
|
12
|
+
let ${w}_ab = false;
|
|
13
|
+
for (let i = 0; i < ${w}.issues.length; i++) {
|
|
14
|
+
const iss = ${w}.issues[i];
|
|
15
|
+
iss.path = iss.path ? [${y}, ...iss.path] : [${y}];
|
|
16
|
+
payload.issues.push(iss);
|
|
17
|
+
if (iss.continue !== true) ${w}_ab = true;
|
|
18
|
+
}
|
|
19
|
+
if (${w}_ab && ctx && ctx.abortEarly) {
|
|
20
|
+
payload.value = newResult;
|
|
21
|
+
return payload;
|
|
22
|
+
}`;x.write("const input = payload.value;");let U=Object.create(null),ae=0;for(let w of h.allKeys)U[w]=`key_${ae++}`;x.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of h.allKeys){if(w==="__proto__")continue;let y=U[w],E=typeof w=="symbol"?`syms[${_.indexOf(w)}]`:co(w),B=`${E} in input`,C=m[w],Y=C?._zod?.optin,jt=Y!==void 0,Er=C?._zod?.optout==="optional";if(x.write(`const ${y} = ${$(E)};`),jt&&Er){let Yn=Y==="optional"?`${y}_present`:`${y}.value !== undefined || ${y}_present`;x.write(`
|
|
23
|
+
const ${y}_present = ${B};
|
|
24
|
+
if (!${y}.issues.length || ${y}_present) {
|
|
25
|
+
if (${y}.issues.length) {${R(y,E)}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (${Yn}) {
|
|
29
|
+
newResult[${E}] = ${y}.value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
`)}else jt?(x.write(`
|
|
34
|
+
if (${y}.issues.length) {${R(y,E)}
|
|
35
|
+
}
|
|
36
|
+
`),Y==="defaulted"?x.write(`newResult[${E}] = ${y}.value;`):x.write(`
|
|
37
|
+
if (${y}.value !== undefined || ${B}) {
|
|
38
|
+
newResult[${E}] = ${y}.value;
|
|
39
|
+
}
|
|
40
|
+
`)):x.write(`
|
|
41
|
+
const ${y}_present = ${B};
|
|
42
|
+
if (${y}.issues.length) {${R(y,E)}
|
|
43
|
+
}
|
|
44
|
+
if (!${y}_present && !${y}.issues.length) {
|
|
45
|
+
payload.issues.push({
|
|
46
|
+
code: "invalid_type",
|
|
47
|
+
expected: "nonoptional",
|
|
48
|
+
input: undefined,
|
|
49
|
+
path: [${E}]
|
|
50
|
+
});
|
|
51
|
+
if (ctx && ctx.abortEarly) {
|
|
52
|
+
payload.value = newResult;
|
|
53
|
+
return payload;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (${y}_present) {
|
|
58
|
+
newResult[${E}] = ${y}.value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
`)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()},i,a=Xe,c=!ue.jitless,l=c&&lo.value,d=t.catchall,f;e._zod.parse=(m,h)=>{f??(f=n.value);let _=m.value;return a(_)?c&&l&&h?.async===!1&&h.jitless!==!0?(i||(i=s(t.shape)),m=i(m,h),d?Zc([],_,m,h,f,e,h?.abortEarly===!0):m):r(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),m)}});function Fa(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!ze(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>be(i,n,le())))}),t)}var Ao=g("$ZodUnion",(e,t)=>{Z.init(e,t),I(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),I(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),I(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),I(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Ut(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);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=>Fa(a,n,e,o)):Fa(i,n,e,o)}});function lm(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Mc=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ao.init(e,t);let r=e._zod.parse;I(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||fe(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=ft(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=dt(()=>lm(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Xe(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),jc=g("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Va(r,c,u)):Va(r,s,i)}});function Eo(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(qe(e)&&qe(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Eo(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Eo(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Va(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Eo(t.value,r.value);if(!c.valid){if(ze(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Dc=g("$ZodRecord",(e,t)=>{Z.init(e,t);let r=ue.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!qe(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>be(h,o,le())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let m=t.valueType._zod.run({value:s[l],issues:[]},o);m instanceof Promise?i.push(m.then(h=>{h.issues.length&&n.issues.push(...Ce(l,h.issues)),n.value[f]=h.value})):(m.issues.length&&n.issues.push(...Ce(l,m.issues)),n.value[f]=m.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Jt.test(u)&&l.issues.length){let h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>be(h,o,le())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let m=t.valueType._zod.run({value:s[u],issues:[]},o);m instanceof Promise?i.push(m.then(h=>{h.issues.length&&n.issues.push(...Ce(u,h.issues)),n.value[f]=h.value})):(m.issues.length&&n.issues.push(...Ce(u,m.issues)),n.value[f]=m.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var Lc=g("$ZodEnum",(e,t)=>{Z.init(e,t);let r=lt(t.entries),n=new Set(r);e._zod.values=n,I(e,"pattern",o=>{let s=lt(o.def.entries).filter(i=>po.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>Oe(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Uc=g("$ZodLiteral",(e,t)=>{Z.init(e,t);let r=new Set(t.values);e._zod.values=r,I(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?Oe(s):s?Oe(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var qc=g("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.optin="optional",ue.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ht(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ve;return r.value=o,r}});function Ba(e,t){return e.value=t.issues.length?void 0:t.value,e}var Zo=g("$ZodOptional",(e,t)=>{Z.init(e,t),I(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",I(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),I(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ut(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Ba(r,s)):Ba(r,o)}return t.innerType._zod.run(r,n)}}),Fc=g("$ZodExactOptional",(e,t)=>{Zo.init(e,t),I(e,"values",r=>r.def.innerType._zod.values),I(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Vc=g("$ZodNullable",(e,t)=>{Z.init(e,t),I(e,"optin",r=>r.def.innerType._zod.optin),I(e,"optout",r=>r.def.innerType._zod.optout),I(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ut(n.source)}|null)$`):void 0}),I(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Bc=g("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",I(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ha(s,t)):Ha(o,t)}});function Ha(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Hc=g("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",I(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Jc=g("$ZodNonOptional",(e,t)=>{Z.init(e,t),I(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ja(s,e)):Ja(o,e)}});function Ja(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Wa(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>be(o,n,le()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Wc=g("$ZodCatch",(e,t)=>{Z.init(e,t),I(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),I(e,"optout",r=>r.def.innerType._zod.optout),I(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Wa(r,s,t,n)):Wa(r,o,t,n)}});var No=g("$ZodPipe",(e,t)=>{Z.init(e,t),I(e,"values",r=>r.def.in._zod.values),I(e,"optin",r=>r.def.in._zod.optin),I(e,"optout",r=>r.def.out._zod.optout),I(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Kr(i,t.in,n)):Kr(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Kr(s,t.out,n)):Kr(o,t.out,n)}});function Kr(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Kc=g("$ZodPreprocess",(e,t)=>{No.init(e,t)}),Gc=g("$ZodReadonly",(e,t)=>{Z.init(e,t),I(e,"propValues",r=>r.def.innerType._zod.propValues),I(e,"values",r=>r.def.innerType._zod.values),I(e,"optin",r=>r.def.innerType?._zod?.optin),I(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Ka):Ka(o)}});function Ka(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Xc=g("$ZodCustom",(e,t)=>{Q.init(e,t),Z.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Ga(s,r,n,e));Ga(o,r,n,e)}});function Ga(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(mt(o))}}var jo=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},Do="~memo",Yc=[];function Qc(e){return e!==null&&typeof e=="object"}function Mo(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var eu=new WeakMap,Kt=0,rn=1,Gt=2;function nn(e,t,r){let n=eu.get(e);if(n!==void 0)return n?Gt:Kt;if(t.has(e))return Gt;t.add(e);let o=Kt,s=l=>{if(o!==Gt&&l?._zod){let d=nn(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=Kt;for(let m of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,m);if(d&&!h.enumerable)continue;let _=h.get?rn:h.value?._zod?nn(h.value,t,r):Kt;_>f&&(f=_)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=ft(c);a(l?i(l,!0):rn),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?nn(l,t,!1):rn);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let m of f)s(m)}}}return t.delete(e),pm(e,o)}function pm(e,t){return t!==rn&&eu.set(e,t===Gt),t}function dm(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var en,tn=[],fm={alloc(e,t,r){let n=en;if(!n)return r;en=void 0;let o={value:r,issues:null};return n.set(t.value,o),tn.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&mm(s,o.value))throw new jo;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let $=nn(e,new Set,!1);if($===Kt)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);$===Gt||n?r=!0:n=!0}let l=c.value;if(!Qc(l))return i(c,u);let d=u[Do];d||(d={buckets:new WeakMap,backEdges:void 0},u[Do]=d);let f;o===u?f=s:(f=dm(d,e),o=u,s=f);let m=f.get(l);if(m)return c.value=m.value,m.issues?m.issues.length&&c.issues.push(...Mo(m.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(m.value)),c;en=f;let h=tn.length,_=i(c,u);en=void 0;let x=tn.length>h?tn.pop():void 0;return _ instanceof Promise?_.then($=>(x&&(x.issues=$.issues.length?Mo($.issues):Yc),$)):(x&&(x.issues=_.issues.length?Mo(_.issues):Yc),_)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Lo(){return fm}function mm(e,t){let r=e[Do]?.backEdges;return r!==void 0&&Qc(t)&&r.has(t)}var hm=()=>{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(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=ho(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${Nr(s.values[0])}`:`Invalid option: expected one of ${Ar(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Ar(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function tu(){return{localeError:hm()}}var ru;var Uo=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function nu(){return new Uo}(ru=globalThis).__zod_globalRegistry??(ru.__zod_globalRegistry=nu());var Fe=globalThis.__zod_globalRegistry;function on(e){return e.checks&&(e.checks=[...e.checks]),e}function ou(e,t){return new e(on({type:"string",...S(t)}))}function su(e,t){return new e(on({type:"string",coerce:!0,...S(t)}))}function iu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function au(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function cu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function uu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function lu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function pu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function qo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function du(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function fu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function mu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function hu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function gu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function _u(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function yu(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function xu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function wu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function zu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function bu(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function vu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function Su(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function ku(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function $u(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function sn(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function an(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function cn(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function un(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function Pu(e,t){return new e(on({type:"number",checks:[],...S(t)}))}function Tu(e,t){return new e(on({type:"number",coerce:!0,checks:[],...S(t)}))}function Ru(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}function Eu(e,t){return new e({type:"boolean",...S(t)})}function Ou(e,t){return new e({type:"boolean",coerce:!0,...S(t)})}function Cu(e,t){return new e({type:"bigint",coerce:!0,...S(t)})}function Iu(e,t){return new e({type:"null",...S(t)})}function Au(e){return new e({type:"any"})}function Zu(e){return new e({type:"unknown"})}function Nu(e,t){return new e({type:"never",...S(t)})}function Mu(e,t){return new e({type:"date",coerce:!0,...S(t)})}function _t(e,t){return new To({check:"less_than",...S(t),value:e,inclusive:!1})}function Ie(e,t){return new To({check:"less_than",...S(t),value:e,inclusive:!0})}function yt(e,t){return new Ro({check:"greater_than",...S(t),value:e,inclusive:!1})}function Ae(e,t){return new Ro({check:"greater_than",...S(t),value:e,inclusive:!0})}function Xt(e,t){return new Pa({check:"multiple_of",...S(t),value:e})}function ln(e,t){return new Ra({check:"max_length",...S(t),maximum:e})}function xt(e,t){return new Ea({check:"min_length",...S(t),minimum:e})}function pn(e,t){return new Oa({check:"length_equals",...S(t),length:e})}function Fo(e,t){return new Ca({check:"string_format",format:"regex",...S(t),pattern:e})}function Vo(e){return new Ia({check:"string_format",format:"lowercase",...S(e)})}function Bo(e){return new Aa({check:"string_format",format:"uppercase",...S(e)})}function Ho(e,t){return new Za({check:"string_format",format:"includes",...S(t),includes:e})}function Jo(e,t){return new Na({check:"string_format",format:"starts_with",...S(t),prefix:e})}function Wo(e,t){return new Ma({check:"string_format",format:"ends_with",...S(t),suffix:e})}function Ve(e){return new ja({check:"overwrite",tx:e})}function Ko(e){return Ve(t=>t.normalize(e))}function Go(){return Ve(e=>e.trim())}function Xo(){return Ve(e=>e.toLowerCase())}function Yo(){return Ve(e=>e.toUpperCase())}function Qo(){return Ve(e=>uo(e))}function ju(e,t,r){return new e({type:"array",element:t,...S(r)})}function Du(e,t,r){let n=S(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Lu(e,t,r){return new e({type:"custom",check:"custom",fn:t,...S(r)})}function Uu(e,t){let r=gm(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(mt(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(mt(s))}},e(n.value,n)),t);return r}function gm(e,t){let r=new Q({check:"custom",...S(t)});return r._zod.check=e,r}function Yt(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&fe(e,n,r[n]);return e}function ts(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??Fe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Se(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function J(e,t,r={path:[],schemaPath:[]}){var n;let o=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),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),J(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Yt(i.schema,c),t.io==="input"&&se(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function qu(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function rs(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.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.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(h=>h);if(d)return{ref:f(d)};let m=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=m,{defId:m,ref:`${f("__shared")}#/${a}/${qu(m)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+qu(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$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>
|
|
62
|
+
|
|
63
|
+
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}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Bu(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Bu(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Hu=new Set(["type","properties","required","additionalProperties"]),Fu=["oneOf","anyOf"];function Vu(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function es(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Hu.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Vu(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:es(a)??{allOf:a};fe(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Vu(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function _m(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Hu)if(o in e)return;let r=t.filter(o=>Fu.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=es(t);else{let o=r[0],s=Fu.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>es([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,Yt(e,n))}function ns(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Yt(u,h),Yt(u,l),a._zod.parent===d)for(let x in u)x==="$ref"||x==="allOf"||x in l||delete u[x];if(h.$ref&&m.def)for(let x in u)x==="$ref"||x==="allOf"||x in m.def&&JSON.stringify(u[x])===JSON.stringify(m.def[x])&&delete u[x]}let f=a._zod.parent;if(f&&f!==d){n(f);let m=e.seen.get(f);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let h in u)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Bu(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])_m(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$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");o.$id=e.external.uri(a)}Yt(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,fe(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Qt(t,"input",e.processors),output:Qt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function se(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return se(n.element,r);if(n.type==="set")return se(n.valueType,r);if(n.type==="lazy")return se(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return se(n.innerType,r);if(n.type==="intersection")return se(n.left,r)||se(n.right,r);if(n.type==="record"||n.type==="map")return se(n.keyType,r)||se(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:se(n.in,r)||se(n.out,r);if(n.type==="object"){for(let o in n.shape)if(se(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(se(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(se(o,r))return!0;return!!(n.rest&&se(n.rest,r))}return!1}var Ju=(e,t={})=>r=>{let n=ts({...r,processors:t});return J(e,n),rs(n,e),ns(n,e)},Qt=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=ts({...o??{},target:s,io:t,processors:r});return J(e,i),rs(i,e),ns(i,e)};var wt=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},zt=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Wu=(e,t)=>{wt(e,"minimum",t),zt(e,"maximum",t)},Yu=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Qu=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},el=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},tl=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Ku=(e,t)=>wt(e,"minimum",t.minimum),Gu=(e,t)=>zt(e,"maximum",t.maximum),Xu=e=>(t,r)=>{tl(t,r.format);let[n,o]=e[r.format];wt(t,"minimum",n),zt(t,"maximum",o)},ym={greater_than:(e,t)=>wt(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>zt(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Yu(e,t.value),number_format:Xu(qt),bigint_format:Xu(Mr),min_length:Ku,max_length:Gu,length_equals:(e,t)=>Wu(e,t.length),min_size:Ku,max_size:Gu,size_equals:(e,t)=>Wu(e,t.size),string_format:(e,t)=>{tl(e,t.format),t.pattern&&Qu(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>el(e,t.mime)};function ee(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)ym[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&wt(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&wt(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&zt(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&zt(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Yu(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&el(t,o.mime);for(let s of o.patterns??[])Qu(t,s);return t}var xm={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},wm=new Map([[Co,fa],[Qr,ma]]),rl=e=>wm.get(e)??e,nl=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ee(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=xm[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(rl);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},ol=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ee(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d?m?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?m?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let h=new Set;for(let $ of a)Number.isFinite($)&&$!==0?h.add(Math.abs($)):Se(e,t,o,n,`A multipleOf divisor of ${$} cannot be represented in JSON Schema`);let[_,...x]=h;_!==void 0&&(o.multipleOf=_),x.length&&(o.allOf=[...o.allOf??[],...x.map($=>({multipleOf:$}))])}},sl=(e,t,r,n)=>{r.type="boolean"},il=(e,t,r,n)=>{Se(e,t,r,n,"BigInt cannot be represented in JSON Schema")};var al=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var cl=(e,t,r,n)=>{r.not={}},ul=(e,t,r,n)=>{},ll=(e,t,r,n)=>{},pl=(e,t,r,n)=>{Se(e,t,r,n,"Date cannot be represented in JSON Schema")},dl=(e,t,r,n)=>{let o=e._zod.def,s=lt(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},fl=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Se(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Se(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;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 ml=(e,t,r,n)=>{Se(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var hl=(e,t,r,n)=>{Se(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var gl=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ee(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=J(s.element,t,{...n,path:[...n.path,"items"]})};function dn(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?dn(t.out):t.type==="catch"?dn(t.innerType):e._zod.optin}var _l=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Se(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)fe(o.properties,u,J(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?dn(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=J(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},yl=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>J(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},xl=(e,t,r,n)=>{let o=e._zod.def,s=J(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=J(o.right,t,{...n,path:[...n.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,t.intersections.push(c)};function os(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let _=os(e,h,r);return _===h?t:_}for(let h of["anyOf","oneOf"]){let _=t[h];if(!Array.isArray(_))continue;let x=_.map($=>os(e,$,r));x.some(($,R)=>$!==_[R])&&(t={...t,[h]:x})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(h=>h==="number"||h==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(h=>typeof h=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...m}=t;return m.enum?m.enum=m.enum.map(h=>typeof h=="number"?String(h):h):typeof m.const=="number"&&(m.const=String(m.const)),o&&(m.type="string",s||(m.pattern=(n.includes("number")?Jt:$o).source)),m}var ss=new WeakMap;function zm(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of ss.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=os(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var wl=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ee(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=J(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)fe(o.patternProperties,rl(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=J(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=ss.get(t);l||(l=[],ss.set(t,l),t.deferred.push(()=>zm(t))),l.push(e)}o.additionalProperties=J(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&dn(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},zl=(e,t,r,n)=>{let o=e._zod.def,s=J(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},bl=(e,t,r,n)=>{let o=e._zod.def;J(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},is=Symbol();function vl(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Se(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),is):JSON.parse(i)}var Sl=(e,t,r,n)=>{let o=e._zod.def;J(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=vl(o.defaultValue,e,t,r,n);i!==is&&(r.default=i)},kl=(e,t,r,n)=>{let o=e._zod.def;J(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=vl(o.defaultValue,e,t,r,n);i!==is&&(r._prefault=i)},$l=(e,t,r,n)=>{let o=e._zod.def;J(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Se(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Pl=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;J(i,t,n);let a=t.seen.get(e);a.ref=i},Tl=(e,t,r,n)=>{let o=e._zod.def;J(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var as=(e,t,r,n)=>{let o=e._zod.def;J(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function fn(e){return!!e._zod}function ke(e,t){return fn(e)?vo(e,t):e.safeParse(t)}function mn(e){if(!e)return;let t;if(fn(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function hn(e){if(fn(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 n=e.value;if(n!==void 0)return n}var Rl=new WeakSet([Object.prototype,Error.prototype]);function gn(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Om=(e,t)=>{Ui.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Rl.has(r)||(Rl.add(r),gn(r,"format",n=>o=>bo(n,o)),gn(r,"flatten",n=>o=>zo(n,o)),gn(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,pt,2)}),gn(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,pt,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var me=g("ZodError",Om,void 0,{Parent:Error});var El=qr(me),Ol=Fr(me),Cl=Ht(me),Il=Vr(me),Al=Vi(me),Zl=Bi(me),Nl=Hi(me),Ml=Ji(me),jl=Wi(me),Dl=Ki(me),Ll=Gi(me),Ul=Xi(me);function Im(){ue.localeError||le(tu())}function yn(){ue.memoizer||le({memoizer:Lo()})}var N=g("ZodType",(e,t)=>(Im(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(P.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ge(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(wh(e,t))},superRefine(e,t){return this.check(zh(e,t))},overwrite(e){return this.check(Ve(e))},optional(){return F(this)},exactOptional(){return ch(this)},nullable(){return Vl(this)},nullish(){return F(Vl(this))},nonoptional(e){return mh(this,e)},array(){return z(this)},or(e){return L([this,e])},and(e){return wn(this,e)},transform(e){return Bl(this,tp(e))},default(e){return ph(this,e)},prefault(e){return fh(this,e)},catch(e){return gh(this,e)},pipe(e){return Bl(this,e)},readonly(){return xh(this)},describe(e){let t=this.clone();return Fe.add(t,{description:e}),t},meta(...e){if(e.length===0)return Fe.get(this);let t=this.clone();return Fe.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return P.hide(this,"~standard",{...Oo(this),jsonSchema:{input:Qt(this,"input"),output:Qt(this,"output")}})},set"~standard"(e){P.own(this,"~standard",e)},parse:function e(t,r){return El(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Ol(this,t,r,{callee:e})},safeParse(e,t){return Cl(this,e,t)},async safeParseAsync(e,t){return Il(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){P.own(this,"spa",e)},validate(e,t){return Br(this,e,t)},validateAsync(e,t){return Hr(this,e,t)},encode:function e(t,r){return Al(this,t,r,{callee:e})},decode:function e(t,r){return Zl(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Nl(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Ml(this,t,r,{callee:e})},safeEncode(e,t){return jl(this,e,t)},safeDecode(e,t){return Dl(this,e,t)},async safeEncodeAsync(e,t){return Ll(this,e,t)},async safeDecodeAsync(e,t){return Ul(this,e,t)},toJSONSchema(e){return Ju(this,{})(e)},get description(){return Fe.get(this)?.description},get _def(){return this._zod.def}}),Hl=g("_ZodString",(e,t)=>{Yr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nl(e,r,n,o)},P.derived({format:e=>ee(e).format??null,minLength:e=>ee(e).minimum??null,maxLength:e=>ee(e).maximum??null},{regex(...e){return this.check(Fo(...e))},includes(...e){return this.check(Ho(...e))},startsWith(...e){return this.check(Jo(...e))},endsWith(...e){return this.check(Wo(...e))},min(...e){return this.check(xt(...e))},max(...e){return this.check(ln(...e))},length(...e){return this.check(pn(...e))},nonempty(...e){return this.check(xt(1,...e))},lowercase(e){return this.check(Vo(e))},uppercase(e){return this.check(Bo(e))},trim(){return this.check(Go())},normalize(...e){return this.check(Ko(...e))},toLowerCase(){return this.check(Xo())},toUpperCase(){return this.check(Yo())},slugify(){return this.check(Qo())}})),us=g("ZodString",(e,t)=>{Yr.init(e,t),Hl.init(e,t)},{email(e){return this.check(iu(Am,e))},url(e){return this.check(qo(Jl,e))},jwt(e){return this.check($u(Gm,e))},emoji(e){return this.check(du(Nm,e))},guid(e){return this.check(au(Zm,e))},uuid(e){return this.check(cu(_n,e))},uuidv4(e){return this.check(uu(_n,e))},uuidv6(e){return this.check(lu(_n,e))},uuidv7(e){return this.check(pu(_n,e))},nanoid(e){return this.check(fu(Mm,e))},cuid(e){return this.check(mu(jm,e))},cuid2(e){return this.check(hu(Dm,e))},ulid(e){return this.check(gu(Lm,e))},base64(e){return this.check(vu(Jm,e))},base64url(e){return this.check(Su(Wm,e))},xid(e){return this.check(_u(Um,e))},ksuid(e){return this.check(yu(qm,e))},ipv4(e){return this.check(xu(Fm,e))},ipv6(e){return this.check(wu(Vm,e))},cidrv4(e){return this.check(zu(Bm,e))},cidrv6(e){return this.check(bu(Hm,e))},e164(e){return this.check(ku(Km,e))},datetime(e){return this.check(sn(er,e))},date(e){return this.check(an(tr,e))},time(e){return this.check(cn(rr,e))},duration(e){return this.check(un(nr,e))}});function p(e){return ou(us,e)}var H=g("ZodStringFormat",(e,t)=>{D.init(e,t),Hl.init(e,t)}),er=g("ZodISODateTime",(e,t)=>{pc.init(e,t),H.init(e,t)}),tr=g("ZodISODate",(e,t)=>{dc.init(e,t),H.init(e,t)}),rr=g("ZodISOTime",(e,t)=>{fc.init(e,t),H.init(e,t)}),nr=g("ZodISODuration",(e,t)=>{mc.init(e,t),H.init(e,t)}),Am=g("ZodEmail",(e,t)=>{ec.init(e,t),H.init(e,t)});var Zm=g("ZodGUID",(e,t)=>{Ya.init(e,t),H.init(e,t)});var _n=g("ZodUUID",(e,t)=>{Qa.init(e,t),H.init(e,t)});var Jl=g("ZodURL",(e,t)=>{nc.init(e,t),H.init(e,t)});function Wl(e){return qo(Jl,e)}var Nm=g("ZodEmoji",(e,t)=>{oc.init(e,t),H.init(e,t)});var Mm=g("ZodNanoID",(e,t)=>{sc.init(e,t),H.init(e,t)});var jm=g("ZodCUID",(e,t)=>{ic.init(e,t),H.init(e,t)});var Dm=g("ZodCUID2",(e,t)=>{ac.init(e,t),H.init(e,t)});var Lm=g("ZodULID",(e,t)=>{cc.init(e,t),H.init(e,t)});var Um=g("ZodXID",(e,t)=>{uc.init(e,t),H.init(e,t)});var qm=g("ZodKSUID",(e,t)=>{lc.init(e,t),H.init(e,t)});var Fm=g("ZodIPv4",(e,t)=>{hc.init(e,t),H.init(e,t)});var Vm=g("ZodIPv6",(e,t)=>{_c.init(e,t),H.init(e,t)});var Bm=g("ZodCIDRv4",(e,t)=>{yc.init(e,t),H.init(e,t)});var Hm=g("ZodCIDRv6",(e,t)=>{xc.init(e,t),H.init(e,t)});var Jm=g("ZodBase64",(e,t)=>{zc.init(e,t),H.init(e,t)});var Wm=g("ZodBase64URL",(e,t)=>{bc.init(e,t),H.init(e,t)});var Km=g("ZodE164",(e,t)=>{vc.init(e,t),H.init(e,t)});var Gm=g("ZodJWT",(e,t)=>{Sc.init(e,t),H.init(e,t)});var xn=g("ZodNumber",(e,t)=>{Io.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ol(e,r,n,o),e.isFinite=!0},P.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ee(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ee(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=ee(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ee(e).format??null},{gt(e,t){return this.check(yt(e,t))},gte(e,t){return this.check(Ae(e,t))},min(e,t){return this.check(Ae(e,t))},lt(e,t){return this.check(_t(e,t))},lte(e,t){return this.check(Ie(e,t))},max(e,t){return this.check(Ie(e,t))},int(e){return this.check(ql(e))},safe(e){return this.check(ql(e))},positive(e){return this.check(yt(0,e))},nonnegative(e){return this.check(Ae(0,e))},negative(e){return this.check(_t(0,e))},nonpositive(e){return this.check(Ie(0,e))},multipleOf(e,t){return this.check(Xt(e,t))},step(e,t){return this.check(Xt(e,t))},finite(){return this}}));function A(e){return Pu(xn,e)}var Xm=g("ZodNumberFormat",(e,t)=>{kc.init(e,t),xn.init(e,t)});function ql(e){return Ru(Xm,e)}var ls=g("ZodBoolean",(e,t)=>{$c.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sl(e,r,n,o)});function M(e){return Eu(ls,e)}var Kl=g("ZodBigInt",(e,t)=>{Pc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>il(e,r,n,o)},P.derived({minValue:e=>ee(e).minimum??null,maxValue:e=>ee(e).maximum??null,format:e=>ee(e).format??null},{gte(e,t){return this.check(Ae(e,t))},min(e,t){return this.check(Ae(e,t))},gt(e,t){return this.check(yt(e,t))},lt(e,t){return this.check(_t(e,t))},lte(e,t){return this.check(Ie(e,t))},max(e,t){return this.check(Ie(e,t))},positive(e){return this.check(yt(BigInt(0),e))},negative(e){return this.check(_t(BigInt(0),e))},nonpositive(e){return this.check(Ie(BigInt(0),e))},nonnegative(e){return this.check(Ae(BigInt(0),e))},multipleOf(e,t){return this.check(Xt(e,t))}}));var Ym=g("ZodNull",(e,t)=>{Tc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>al(e,r,n,o)});function Gl(e){return Iu(Ym,e)}var Qm=g("ZodAny",(e,t)=>{Rc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ul(e,r,n,o)});function Xl(){return Au(Qm)}var eh=g("ZodUnknown",(e,t)=>{Ec.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ll(e,r,n,o)});function q(){return Zu(eh)}var th=g("ZodNever",(e,t)=>{Oc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cl(e,r,n,o)});function rh(e){return Nu(th,e)}var Yl=g("ZodDate",(e,t)=>{Cc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pl(e,r,n,o),e.min=(r,n)=>e.check(Ae(r,n)),e.max=(r,n)=>e.check(Ie(r,n))},P.derived({minDate:e=>{let{minimum:t}=ee(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=ee(e);return t?new Date(t):null}},{}));var nh=g("ZodArray",(e,t)=>{yn(),Ic.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gl(e,r,n,o),e.element=t.element},{min(e,t){return this.check(xt(e,t))},nonempty(e){return this.check(xt(1,e))},max(e,t){return this.check(ln(e,t))},length(e,t){return this.check(pn(e,t))},unwrap(){return this.element}});function z(e,t){return ju(nh,e,t)}var Ql=g("ZodObject",(e,t)=>{yn(),Nc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_l(e,r,n,o),P.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return pe(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(P.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(P.mergeDefs(this._zod.def,{catchall:q()}))},loose(){return this.clone(P.mergeDefs(this._zod.def,{catchall:q()}))},strict(){return this.clone(P.mergeDefs(this._zod.def,{catchall:rh()}))},strip(){return this.clone(P.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return P.extend(this,e)},safeExtend(e){return P.safeExtend(this,e)},merge(e){return P.merge(this,e)},pick(e){return P.pick(this,e)},omit(e){return P.omit(this,e)},partial(...e){return P.partial(rp,this,e[0])},exactPartial(...e){return P.partial(np,this,e[0],"exactPartial")},required(...e){return P.required(op,this,e[0])}});function b(e,t){let r={type:"object",shape:e??{},...P.normalizeParams(t)};return new Ql(r)}function K(e,t){return new Ql({type:"object",shape:e,catchall:q(),...P.normalizeParams(t)})}var ep=g("ZodUnion",(e,t)=>{Ao.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yl(e,r,n,o),e.options=t.options});function L(e,t){return new ep({type:"union",options:e,...P.normalizeParams(t)})}var oh=g("ZodDiscriminatedUnion",(e,t)=>{ep.init(e,t),Mc.init(e,t)});function ps(e,t,r){return new oh({type:"union",options:t,discriminator:e,...P.normalizeParams(r)})}var sh=g("ZodIntersection",(e,t)=>{jc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xl(e,r,n,o)});function wn(e,t){return new sh({type:"intersection",left:e,right:t})}var Fl=g("ZodRecord",(e,t)=>{yn(),Dc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wl(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function j(e,t,r){return!t||!t._zod?new Fl({type:"record",keyType:p(),valueType:e,...P.normalizeParams(t)}):new Fl({type:"record",keyType:e,valueType:t,...P.normalizeParams(r)})}var cs=g("ZodEnum",(e,t)=>{Lc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,s)=>dl(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new cs({...t,checks:[],...P.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new cs({...t,checks:[],...P.normalizeParams(o),entries:s})}});function pe(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new cs({type:"enum",entries:r,...P.normalizeParams(t)})}var ih=g("ZodLiteral",(e,t)=>{Uc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fl(e,r,n,o),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 v(e,t){return new ih({type:"literal",values:Array.isArray(e)?e:[e],...P.normalizeParams(t)})}var ah=g("ZodTransform",(e,t)=>{yn(),qc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hl(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ht(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(P.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(P.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function tp(e){return new ah({type:"transform",transform:e})}var rp=g("ZodOptional",(e,t)=>{Zo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>as(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function F(e){return new rp({type:"optional",innerType:e})}var np=g("ZodExactOptional",(e,t)=>{Fc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>as(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ch(e){return new np({type:"optional",innerType:e})}var uh=g("ZodNullable",(e,t)=>{Vc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Vl(e){return new uh({type:"nullable",innerType:e})}var lh=g("ZodDefault",(e,t)=>{Bc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ph(e,t){return new lh({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():P.shallowClone(t)}})}var dh=g("ZodPrefault",(e,t)=>{Hc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function fh(e,t){return new dh({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():P.shallowClone(t)}})}var op=g("ZodNonOptional",(e,t)=>{Jc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function mh(e,t){return new op({type:"nonoptional",innerType:e,...P.normalizeParams(t)})}var hh=g("ZodCatch",(e,t)=>{Wc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$l(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gh(e,t){return new hh({type:"catch",innerType:e,catchValue:typeof t=="function"?t:P.constantCatch(t)})}var sp=g("ZodPipe",(e,t)=>{No.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pl(e,r,n,o),e.in=t.in,e.out=t.out});function Bl(e,t){return new sp({type:"pipe",in:e,out:t})}var _h=g("ZodPreprocess",(e,t)=>{sp.init(e,t),Kc.init(e,t)}),yh=g("ZodReadonly",(e,t)=>{Gc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function xh(e){return new yh({type:"readonly",innerType:e})}var ip=g("ZodCustom",(e,t)=>{Xc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ml(e,r,n,o)});function ap(e,t){return Du(ip,e??(()=>!0),t)}function wh(e,t={}){return Lu(ip,e,t)}function zh(e,t){return Uu(e,t)}function ds(e,t){return new _h({type:"pipe",in:tp(e),out:t})}var up={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 cp;cp||(cp={});var zn={};Qn(zn,{ZodISODate:()=>tr,ZodISODateTime:()=>er,ZodISODuration:()=>nr,ZodISOTime:()=>rr,date:()=>Sh,datetime:()=>vh,duration:()=>$h,time:()=>kh});function vh(e){return sn(er,e)}function Sh(e){return an(tr,e)}function kh(e){return cn(rr,e)}function $h(e){return un(nr,e)}var bn={};Qn(bn,{bigint:()=>Eh,boolean:()=>Rh,date:()=>Oh,number:()=>Th,string:()=>Ph});function Ph(e){return su(us,e)}function Th(e){return Tu(xn,e)}function Rh(e){return Ou(ls,e)}function Eh(e){return Cu(Kl,e)}function Oh(e){return Mu(Yl,e)}var St="2025-11-25";var lp=[St,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Be="io.modelcontextprotocol/related-task",Sn="2.0",G=ap(e=>e!==null&&(typeof e=="object"||typeof e=="function")),pp=L([p(),A().int()]),dp=p(),Zz=K({ttl:A().optional(),pollInterval:A().optional()}),Ih=b({ttl:A().optional()}),Ah=b({taskId:p()}),ms=K({progressToken:pp.optional(),[Be]:Ah.optional()}),he=b({_meta:ms.optional()}),or=he.extend({task:Ih.optional()}),fp=e=>or.safeParse(e).success,te=b({method:p(),params:he.loose().optional()}),_e=b({_meta:ms.optional()}),ye=b({method:p(),params:_e.loose().optional()}),re=K({_meta:ms.optional()}),kn=L([p(),A().int()]),mp=b({jsonrpc:v(Sn),id:kn,...te.shape}).strict(),sr=e=>mp.safeParse(e).success,hp=b({jsonrpc:v(Sn),...ye.shape}).strict(),gp=e=>hp.safeParse(e).success,hs=b({jsonrpc:v(Sn),id:kn,result:re}).strict(),Ye=e=>hs.safeParse(e).success;var T;(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"})(T||(T={}));var gs=b({jsonrpc:v(Sn),id:kn.optional(),error:b({code:A().int(),message:p(),data:q().optional()})}).strict();var _p=e=>gs.safeParse(e).success;var He=L([mp,hp,hs,gs]),Nz=L([hs,gs]),Qe=re.strict(),Zh=_e.extend({requestId:kn.optional(),reason:p().optional()}),$n=ye.extend({method:v("notifications/cancelled"),params:Zh}),Nh=b({src:p(),mimeType:p().optional(),sizes:z(p()).optional(),theme:pe(["light","dark"]).optional()}),ir=b({icons:z(Nh).optional()}),vt=b({name:p(),title:p().optional()}),yp=vt.extend({...vt.shape,...ir.shape,version:p(),websiteUrl:p().optional(),description:p().optional()}),Mh=wn(b({applyDefaults:M().optional()}),j(p(),q())),jh=ds(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,wn(b({form:Mh.optional(),url:G.optional()}),j(p(),q()).optional())),Dh=K({list:G.optional(),cancel:G.optional(),requests:K({sampling:K({createMessage:G.optional()}).optional(),elicitation:K({create:G.optional()}).optional()}).optional()}),Lh=K({list:G.optional(),cancel:G.optional(),requests:K({tools:K({call:G.optional()}).optional()}).optional()}),Uh=b({experimental:j(p(),G).optional(),sampling:b({context:G.optional(),tools:G.optional()}).optional(),elicitation:jh.optional(),roots:b({listChanged:M().optional()}).optional(),tasks:Dh.optional(),extensions:j(p(),G).optional()}),qh=he.extend({protocolVersion:p(),capabilities:Uh,clientInfo:yp}),Fh=te.extend({method:v("initialize"),params:qh});var Vh=b({experimental:j(p(),G).optional(),logging:G.optional(),completions:G.optional(),prompts:b({listChanged:M().optional()}).optional(),resources:b({subscribe:M().optional(),listChanged:M().optional()}).optional(),tools:b({listChanged:M().optional()}).optional(),tasks:Lh.optional(),extensions:j(p(),G).optional()}),_s=re.extend({protocolVersion:p(),capabilities:Vh,serverInfo:yp,instructions:p().optional()}),xp=ye.extend({method:v("notifications/initialized"),params:_e.optional()}),wp=e=>xp.safeParse(e).success,Pn=te.extend({method:v("ping"),params:he.optional()}),Bh=b({progress:A(),total:F(A()),message:F(p())}),Hh=b({..._e.shape,...Bh.shape,progressToken:pp}),Tn=ye.extend({method:v("notifications/progress"),params:Hh}),Jh=he.extend({cursor:dp.optional()}),ar=te.extend({params:Jh.optional()}),cr=re.extend({nextCursor:dp.optional()}),Wh=pe(["working","input_required","completed","failed","cancelled"]),ur=b({taskId:p(),status:Wh,ttl:L([A(),Gl()]),createdAt:p(),lastUpdatedAt:p(),pollInterval:F(A()),statusMessage:F(p())}),et=re.extend({task:ur}),Kh=_e.merge(ur),lr=ye.extend({method:v("notifications/tasks/status"),params:Kh}),Rn=te.extend({method:v("tasks/get"),params:he.extend({taskId:p()})}),En=re.merge(ur),On=te.extend({method:v("tasks/result"),params:he.extend({taskId:p()})}),Mz=re.loose(),Cn=ar.extend({method:v("tasks/list")}),In=cr.extend({tasks:z(ur)}),An=te.extend({method:v("tasks/cancel"),params:he.extend({taskId:p()})}),zp=re.merge(ur),bp=b({uri:p(),mimeType:F(p()),_meta:j(p(),q()).optional()}),vp=bp.extend({text:p()}),ys=p().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Sp=bp.extend({blob:ys}),pr=pe(["user","assistant"]),kt=b({audience:z(pr).optional(),priority:A().min(0).max(1).optional(),lastModified:zn.datetime({offset:!0}).optional()}),kp=b({...vt.shape,...ir.shape,uri:p(),description:F(p()),mimeType:F(p()),size:F(A()),annotations:kt.optional(),_meta:F(K({}))}),Gh=b({...vt.shape,...ir.shape,uriTemplate:p(),description:F(p()),mimeType:F(p()),annotations:kt.optional(),_meta:F(K({}))}),Xh=ar.extend({method:v("resources/list")}),xs=cr.extend({resources:z(kp)}),Yh=ar.extend({method:v("resources/templates/list")}),ws=cr.extend({resourceTemplates:z(Gh)}),zs=he.extend({uri:p()}),Qh=zs,eg=te.extend({method:v("resources/read"),params:Qh}),bs=re.extend({contents:z(L([vp,Sp]))}),vs=ye.extend({method:v("notifications/resources/list_changed"),params:_e.optional()}),tg=zs,rg=te.extend({method:v("resources/subscribe"),params:tg}),ng=zs,og=te.extend({method:v("resources/unsubscribe"),params:ng}),sg=_e.extend({uri:p()}),ig=ye.extend({method:v("notifications/resources/updated"),params:sg}),ag=b({name:p(),description:F(p()),required:F(M())}),cg=b({...vt.shape,...ir.shape,description:F(p()),arguments:F(z(ag)),_meta:F(K({}))}),ug=ar.extend({method:v("prompts/list")}),Ss=cr.extend({prompts:z(cg)}),lg=he.extend({name:p(),arguments:j(p(),p()).optional()}),pg=te.extend({method:v("prompts/get"),params:lg}),ks=b({type:v("text"),text:p(),annotations:kt.optional(),_meta:j(p(),q()).optional()}),$s=b({type:v("image"),data:ys,mimeType:p(),annotations:kt.optional(),_meta:j(p(),q()).optional()}),Ps=b({type:v("audio"),data:ys,mimeType:p(),annotations:kt.optional(),_meta:j(p(),q()).optional()}),dg=b({type:v("tool_use"),name:p(),id:p(),input:j(p(),q()),_meta:j(p(),q()).optional()}),fg=b({type:v("resource"),resource:L([vp,Sp]),annotations:kt.optional(),_meta:j(p(),q()).optional()}),mg=kp.extend({type:v("resource_link")}),Ts=L([ks,$s,Ps,mg,fg]),hg=b({role:pr,content:Ts}),Rs=re.extend({description:p().optional(),messages:z(hg)}),Es=ye.extend({method:v("notifications/prompts/list_changed"),params:_e.optional()}),gg=b({title:p().optional(),readOnlyHint:M().optional(),destructiveHint:M().optional(),idempotentHint:M().optional(),openWorldHint:M().optional()}),_g=b({taskSupport:pe(["required","optional","forbidden"]).optional()}),$p=b({...vt.shape,...ir.shape,description:p().optional(),inputSchema:b({type:v("object"),properties:j(p(),G).optional(),required:z(p()).optional()}).catchall(q()),outputSchema:b({type:v("object"),properties:j(p(),G).optional(),required:z(p()).optional()}).catchall(q()).optional(),annotations:gg.optional(),execution:_g.optional(),_meta:j(p(),q()).optional()}),yg=ar.extend({method:v("tools/list")}),Os=cr.extend({tools:z($p)}),$t=re.extend({content:z(Ts).default([]),structuredContent:j(p(),q()).optional(),isError:M().optional()}),jz=$t.or(re.extend({toolResult:q()})),xg=or.extend({name:p(),arguments:j(p(),q()).optional()}),wg=te.extend({method:v("tools/call"),params:xg}),Cs=ye.extend({method:v("notifications/tools/list_changed"),params:_e.optional()}),Pp=b({autoRefresh:M().default(!0),debounceMs:A().int().nonnegative().default(300)}),Tp=pe(["debug","info","notice","warning","error","critical","alert","emergency"]),zg=he.extend({level:Tp}),bg=te.extend({method:v("logging/setLevel"),params:zg}),vg=_e.extend({level:Tp,logger:p().optional(),data:q()}),Sg=ye.extend({method:v("notifications/message"),params:vg}),kg=b({name:p().optional()}),$g=b({hints:z(kg).optional(),costPriority:A().min(0).max(1).optional(),speedPriority:A().min(0).max(1).optional(),intelligencePriority:A().min(0).max(1).optional()}),Pg=b({mode:pe(["auto","required","none"]).optional()}),Tg=b({type:v("tool_result"),toolUseId:p().describe("The unique identifier for the corresponding tool call."),content:z(Ts).default([]),structuredContent:b({}).loose().optional(),isError:M().optional(),_meta:j(p(),q()).optional()}),Rg=ps("type",[ks,$s,Ps]),vn=ps("type",[ks,$s,Ps,dg,Tg]),Eg=b({role:pr,content:L([vn,z(vn)]),_meta:j(p(),q()).optional()}),Og=or.extend({messages:z(Eg),modelPreferences:$g.optional(),systemPrompt:p().optional(),includeContext:pe(["none","thisServer","allServers"]).optional(),temperature:A().optional(),maxTokens:A().int(),stopSequences:z(p()).optional(),metadata:G.optional(),tools:z($p).optional(),toolChoice:Pg.optional()}),Is=te.extend({method:v("sampling/createMessage"),params:Og}),As=re.extend({model:p(),stopReason:F(pe(["endTurn","stopSequence","maxTokens"]).or(p())),role:pr,content:Rg}),Zs=re.extend({model:p(),stopReason:F(pe(["endTurn","stopSequence","maxTokens","toolUse"]).or(p())),role:pr,content:L([vn,z(vn)])}),Cg=b({type:v("boolean"),title:p().optional(),description:p().optional(),default:M().optional()}),Ig=b({type:v("string"),title:p().optional(),description:p().optional(),minLength:A().optional(),maxLength:A().optional(),format:pe(["email","uri","date","date-time"]).optional(),default:p().optional()}),Ag=b({type:pe(["number","integer"]),title:p().optional(),description:p().optional(),minimum:A().optional(),maximum:A().optional(),default:A().optional()}),Zg=b({type:v("string"),title:p().optional(),description:p().optional(),enum:z(p()),default:p().optional()}),Ng=b({type:v("string"),title:p().optional(),description:p().optional(),oneOf:z(b({const:p(),title:p()})),default:p().optional()}),Mg=b({type:v("string"),title:p().optional(),description:p().optional(),enum:z(p()),enumNames:z(p()).optional(),default:p().optional()}),jg=L([Zg,Ng]),Dg=b({type:v("array"),title:p().optional(),description:p().optional(),minItems:A().optional(),maxItems:A().optional(),items:b({type:v("string"),enum:z(p())}),default:z(p()).optional()}),Lg=b({type:v("array"),title:p().optional(),description:p().optional(),minItems:A().optional(),maxItems:A().optional(),items:b({anyOf:z(b({const:p(),title:p()}))}),default:z(p()).optional()}),Ug=L([Dg,Lg]),qg=L([Mg,jg,Ug]),Fg=L([qg,Cg,Ig,Ag]),Vg=or.extend({mode:v("form").optional(),message:p(),requestedSchema:b({type:v("object"),properties:j(p(),Fg),required:z(p()).optional()})}),Bg=or.extend({mode:v("url"),message:p(),elicitationId:p(),url:p().url()}),Hg=L([Vg,Bg]),Ns=te.extend({method:v("elicitation/create"),params:Hg}),Jg=_e.extend({elicitationId:p()}),Wg=ye.extend({method:v("notifications/elicitation/complete"),params:Jg}),Ms=re.extend({action:pe(["accept","decline","cancel"]),content:ds(e=>e===null?void 0:e,j(p(),L([p(),A(),M(),z(p())])).optional())}),Kg=b({type:v("ref/resource"),uri:p()});var Gg=b({type:v("ref/prompt"),name:p()}),Xg=he.extend({ref:L([Gg,Kg]),argument:b({name:p(),value:p()}),context:b({arguments:j(p(),p()).optional()}).optional()}),Yg=te.extend({method:v("completion/complete"),params:Xg});var js=re.extend({completion:K({values:z(p()).max(100),total:F(A().int()),hasMore:F(M())})}),Qg=b({uri:p().startsWith("file://"),name:p().optional(),_meta:j(p(),q()).optional()}),e_=te.extend({method:v("roots/list"),params:he.optional()}),t_=re.extend({roots:z(Qg)}),r_=ye.extend({method:v("notifications/roots/list_changed"),params:_e.optional()}),Dz=L([Pn,Fh,Yg,bg,pg,ug,Xh,Yh,eg,rg,og,wg,yg,Rn,On,Cn,An]),Lz=L([$n,Tn,xp,r_,lr]),Uz=L([Qe,As,Zs,Ms,t_,En,In,et]),qz=L([Pn,Is,Ns,e_,Rn,On,Cn,An]),Fz=L([$n,Tn,Sg,ig,vs,Cs,Es,lr,Wg]),Vz=L([Qe,_s,js,Rs,Ss,xs,ws,bs,$t,Os,En,In,et]),k=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===T.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new fs(o.elicitations,r)}return new e(t,r,n)}},fs=class extends k{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(T.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Je(e){return e==="completed"||e==="failed"||e==="cancelled"}var vb=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ds(e){let r=mn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=hn(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Ls(e,t){let r=ke(e,t);if(!r.success)throw r.error;return r.data}var c_=6e4,Zn=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($n,r=>{this._oncancel(r)}),this.setNotificationHandler(Tn,r=>{this._onprogress(r)}),this.setRequestHandler(Pn,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Rn,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new k(T.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(On,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(!await this._taskStore.getTask(s,n.sessionId))throw new k(T.InvalidParams,`Task not found: ${s}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new k(d.error.code,d.error.message,d.error.data);l(f)}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:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new k(T.InvalidParams,`Task not found: ${s}`);if(!Je(i.status))return await this._waitForTaskUpdate(s,n.signal,n.sessionId),await o();if(Je(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s,n.sessionId),{...a,_meta:{...a._meta,[Be]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Cn,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new k(T.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(An,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new k(T.InvalidParams,`Task not found: ${r.params.taskId}`);if(Je(o.status))throw new k(T.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId,n.sessionId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new k(T.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof k?o:new k(T.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),k.fromError(T.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});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 n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Ye(s)||_p(s)?this._onresponse(s):sr(s)?this._onrequest(s,i):gp(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 n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=k.fromError(T.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(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(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Be]?.taskId,i=o?.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(T.InvalidParams,`Task not found: ${s}`);c=!0})()),n===void 0){let h={jsonrpc:"2.0",id:t.id,error:{code:T.MethodNotFound,message:"Method not found"}};if(s&&u){let _={type:"error",message:h,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(s,_,i),()=>o?.send(h)).catch(x=>this._onerror(new Error(`Failed to send an error response: ${x}`)))}else s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:h,timestamp:Date.now()},o?.sessionId).catch(_=>this._onerror(new Error(`Failed to enqueue error response: ${_}`))):o?.send(h).catch(_=>this._onerror(new Error(`Failed to send an error response: ${_}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);let d=fp(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,m={signal:l.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async h=>{if(l.signal.aborted)return;let _={relatedRequestId:t.id};s&&(_.relatedTask={taskId:s}),await this.notification(h,_)},sendRequest:async(h,_,x)=>{if(l.signal.aborted)throw new k(T.ConnectionClosed,"Request was cancelled");let $={...x,relatedRequestId:t.id};s&&!$.relatedTask&&($.relatedTask={taskId:s});let R=$.relatedTask?.taskId??s;return R&&f&&await f.updateTaskStatus(R,"input_required"),await this.request(h,_,$)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&l.signal.aborted)throw new k(T.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,m)).then(async h=>{if(l.signal.aborted)return;let _={result:h,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:_,timestamp:Date.now()},o?.sessionId):await o?.send(_)},async h=>{if(l.signal.aborted)return;let _={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(h.code)?h.code:T.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};s&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(s,{type:"error",message:_,timestamp:Date.now()},o?.sessionId):await o?.send(_)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Ye(t))n(t);else{let i=new k(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===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(Ye(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),Ye(t))o(t);else{let i=k.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof k?i:new k(T.InternalError,String(i))}}return}let s;try{let i=await this.request(t,et,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new k(T.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Je(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new k(T.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new k(T.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof k?i:new k(T.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=R=>{l(R)};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(R){d(R);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,m={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),m.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Be]:c}});let h=R=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(R)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(ae=>this._onerror(new Error(`Failed to send cancellation: ${ae}`)));let U=R instanceof k?R:new k(T.RequestTimeout,String(R));l(U)};this._responseHandlers.set(f,R=>{if(!n?.signal?.aborted){if(R instanceof Error)return l(R);try{let U=ke(r,R.result);U.success?u(U.data):l(U.error)}catch(U){l(U)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let _=n?.timeout??c_,x=()=>h(k.fromError(T.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(f,_,n?.maxTotalTimeout,x,n?.resetTimeoutOnProgress??!1);let $=c?.taskId;if($){let R=U=>{let ae=this._responseHandlers.get(f);ae?ae(U):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,R),this._enqueueTaskMessage($,{type:"request",message:m,timestamp:Date.now()}).catch(U=>{this._cleanupTimeout(f),l(U)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(R=>{this._cleanupTimeout(f),l(R)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},En,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},In,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},zp,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Be]:r.relatedTask}}};await this._enqueueTaskMessage(n,{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||{},[Be]: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||{},[Be]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Ds(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Ls(t,o);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 n=Ds(t);this._notificationHandlers.set(n,o=>{let s=Ls(t,o);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,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n??this._transport?.sessionId,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&sr(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new k(T.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,n){let o=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(t,n);s?.pollInterval&&(o=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new k(T.InvalidRequest,"Request cancelled"));return}let a=setTimeout(s,o);r.addEventListener("abort",()=>{clearTimeout(a),i(new k(T.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new k(T.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=lr.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Je(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new k(T.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Je(a.status))throw new k(T.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=lr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Je(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Rp(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ep(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];Rp(i)&&Rp(s)?r[o]={...i,...s}:r[o]=s}return r}var Op=Or(rf(),1),Cp=Or(nf(),1);function u_(){let e=new Op.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Cp.default)(e),e}var Nn=class{constructor(t){this._ajv=t??u_()}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 n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Mn=class{constructor(t){this._client=t}async*callToolStream(t,r=$t,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(t.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:t},r,s),a=o.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(T.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new k(T.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof k){yield{type:"error",error:l};return}yield{type:"error",error:new k(T.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}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,n){return this._client.requestStream(t,r,n)}};function Ip(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 Ap(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 jn(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,n=e.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&jn(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&jn(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&jn(r,t)}}function l_(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 Dn=class extends Zn{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 Nn,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Cs,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Es,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",vs,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Mn(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Ep(this._capabilities,t)}setRequestHandler(t,r){let o=mn(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=hn(o);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 l=ke(Ns,c);if(!l.success){let R=l.error instanceof Error?l.error.message:String(l.error);throw new k(T.InvalidParams,`Invalid elicitation request: ${R}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:f,supportsUrlMode:m}=l_(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new k(T.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new k(T.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let R=ke(et,h);if(!R.success){let U=R.error instanceof Error?R.error.message:String(R.error);throw new k(T.InvalidParams,`Invalid task creation result: ${U}`)}return R.data}let _=ke(Ms,h);if(!_.success){let R=_.error instanceof Error?_.error.message:String(_.error);throw new k(T.InvalidParams,`Invalid elicitation result: ${R}`)}let x=_.data,$=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&x.action==="accept"&&x.content&&$&&this._capabilities.elicitation?.form?.applyDefaults)try{jn($,x.content)}catch{}return x};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=ke(Is,c);if(!l.success){let x=l.error instanceof Error?l.error.message:String(l.error);throw new k(T.InvalidParams,`Invalid sampling request: ${x}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let x=ke(et,f);if(!x.success){let $=x.error instanceof Error?x.error.message:String(x.error);throw new k(T.InvalidParams,`Invalid task creation result: ${$}`)}return x.data}let h=d.tools||d.toolChoice?Zs:As,_=ke(h,f);if(!_.success){let x=_.error instanceof Error?_.error.message:String(_.error);throw new k(T.InvalidParams,`Invalid sampling result: ${x}`)}return _.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 n=await this.request({method:"initialize",params:{protocolVersion:St,capabilities:this._capabilities,clientInfo:this._clientInfo}},_s,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!lp.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}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){Ip(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&Ap(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Qe,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},js,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Qe,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Rs,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Ss,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},xs,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},ws,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},bs,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Qe,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Qe,r)}async callTool(t,r=$t,n){if(this.isToolTaskRequired(t.name))throw new k(T.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:t},r,n),s=this.getToolOutputValidator(t.name);if(s){if(!o.structuredContent&&!o.isError)throw new k(T.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new k(T.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof k?i:new k(T.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}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 o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let n=await this.request({method:"tools/list",params:t},Os,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=Pp.safeParse(n);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let f=d instanceof Error?d:new Error(String(d));c(f,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let f=setTimeout(u,a);this._listChangedDebounceTimers.set(t,f)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var fr=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}},Zp=10,p_=13,tt=32;function Us(e){}function Ln(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=Us,onError:r=Us,onRetry:n=Us,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,u,l="",d=0,f,m=!1;function h(w){if(m)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,w.charCodeAt(0)===239&&w.charCodeAt(1)===187&&w.charCodeAt(2)===191&&(w=w.slice(3))),i.length===0){let B=x(w);B!==""&&(i.push(B),a=B.length),_();return}if(w.indexOf(`
|
|
64
|
+
`)===-1&&w.indexOf("\r")===-1){i.push(w),a+=w.length,_();return}i.push(w);let y=i.join("");i.length=0,a=0;let E=x(y);E!==""&&(i.push(E),a=E.length),_()}function _(){s!==void 0&&(a+l.length<=s||(m=!0,i.length=0,a=0,u=void 0,l="",d=0,f=void 0,r(new fr(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function x(w){let y=0;if(w.indexOf("\r")===-1){let E=w.indexOf(`
|
|
65
|
+
`,y);for(;E!==-1;){if(y===E){d>0&&t({id:u,event:f,data:l}),u=void 0,l="",d=0,f=void 0,y=E+1,E=w.indexOf(`
|
|
66
|
+
`,y);continue}let B=w.charCodeAt(y);if(Np(w,y,B)){let C=w.charCodeAt(y+5)===tt?y+6:y+5,Y=w.slice(C,E);if(d===0&&w.charCodeAt(E+1)===Zp){t({id:u,event:f,data:Y}),u=void 0,l="",f=void 0,y=E+2,E=w.indexOf(`
|
|
67
|
+
`,y);continue}l=d===0?Y:`${l}
|
|
68
|
+
${Y}`,d++}else Mp(w,y,B)?f=w.slice(w.charCodeAt(y+6)===tt?y+7:y+6,E)||void 0:$(w,y,E);y=E+1,E=w.indexOf(`
|
|
69
|
+
`,y)}return w.slice(y)}for(;y<w.length;){let E=w.indexOf("\r",y),B=w.indexOf(`
|
|
70
|
+
`,y),C=-1;if(E!==-1&&B!==-1?C=E<B?E:B:E!==-1?E===w.length-1?C=-1:C=E:B!==-1&&(C=B),C===-1)break;$(w,y,C),y=C+1,w.charCodeAt(y-1)===p_&&w.charCodeAt(y)===Zp&&y++}return w.slice(y)}function $(w,y,E){if(y===E){U();return}let B=w.charCodeAt(y);if(Np(w,y,B)){let ct=w.charCodeAt(y+5)===tt?y+6:y+5,xi=w.slice(ct,E);l=d===0?xi:`${l}
|
|
71
|
+
${xi}`,d++;return}if(Mp(w,y,B)){f=w.slice(w.charCodeAt(y+6)===tt?y+7:y+6,E)||void 0;return}if(B===105&&w.charCodeAt(y+1)===100&&w.charCodeAt(y+2)===58){let ct=w.slice(w.charCodeAt(y+3)===tt?y+4:y+3,E);ct.includes("\0")||(u=ct);return}if(B===58){if(o){let ct=w.slice(y,E);o(ct.slice(w.charCodeAt(y+1)===tt?2:1))}return}let C=w.slice(y,E),Y=C.indexOf(":");if(Y===-1){R(C,"",C);return}let jt=C.slice(0,Y),Er=C.charCodeAt(Y+1)===tt?2:1,Yn=C.slice(Y+Er);R(jt,Yn,C)}function R(w,y,E){switch(w){case"event":f=y||void 0;break;case"data":l=d===0?y:`${l}
|
|
72
|
+
${y}`,d++;break;case"id":y.includes("\0")||(u=y);break;case"retry":/^\d+$/.test(y)?n(parseInt(y,10)):r(new fr(`Invalid \`retry\` value: "${y}"`,{type:"invalid-retry",value:y,line:E}));break;default:r(new fr(`Unknown field "${w.length>20?`${w.slice(0,20)}\u2026`:w}"`,{type:"unknown-field",field:w,value:y,line:E}));break}}function U(){d>0&&t({id:u,event:f,data:l}),u=void 0,l="",d=0,f=void 0}function ae(w={}){if(w.consume&&i.length>0){let y=i.join("");$(y,0,y.length)}c=!0,u=void 0,l="",d=0,f=void 0,i.length=0,a=0,m=!1}return{feed:h,reset:ae}}function Np(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 Mp(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 qn=class extends Event{constructor(t,r){var n,o;super(t),this.code=(n=r?.code)!=null?n:void 0,this.message=(o=r?.message)!=null?o:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,r,n){return n(jp(this),r)}[Symbol.for("Deno.customInspect")](t,r){return t(jp(this),r)}};function d_(e){let t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function qs(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(qs).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${qs(e.cause)}`:e.message:`${e}`}function jp(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var Lp=e=>{throw TypeError(e)},Gs=(e,t,r)=>t.has(e)||Lp("Cannot "+r),O=(e,t,r)=>(Gs(e,t,"read from private field"),r?r.call(e):t.get(e)),X=(e,t,r)=>t.has(e)?Lp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),V=(e,t,r,n)=>(Gs(e,t,"write to private field"),t.set(e,r),r),Ne=(e,t,r)=>(Gs(e,t,"access private method"),r),de,rt,Pt,Un,Fn,gr,Et,_r,We,Tt,Ot,Rt,mr,$e,Fs,Vs,Bs,Dp,Hs,Js,hr,Ws,Ks,nt=class extends EventTarget{constructor(t,r){var n,o;super(),X(this,$e),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,X(this,de),X(this,rt),X(this,Pt),X(this,Un),X(this,Fn),X(this,gr),X(this,Et),X(this,_r,null),X(this,We),X(this,Tt),X(this,Ot,null),X(this,Rt,null),X(this,mr,null),X(this,Vs,async s=>{var i;O(this,Tt).reset();let{body:a,redirected:c,status:u,headers:l}=s;if(u===204){Ne(this,$e,hr).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?V(this,Pt,new URL(s.url)):V(this,Pt,void 0),u!==200){Ne(this,$e,hr).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){Ne(this,$e,hr).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(O(this,de)===this.CLOSED)return;V(this,de,this.OPEN);let d=new Event("open");if((i=O(this,mr))==null||i.call(this,d),this.dispatchEvent(d),typeof a!="object"||!a||!("getReader"in a)){Ne(this,$e,hr).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}let f=new TextDecoder,m=a.getReader(),h=!0;do{let{done:_,value:x}=await m.read();x&&O(this,Tt).feed(f.decode(x,{stream:!_})),_&&(h=!1,O(this,Tt).reset(),Ne(this,$e,Ws).call(this))}while(h)}),X(this,Bs,s=>{V(this,We,void 0),!(s.name==="AbortError"||s.type==="aborted")&&Ne(this,$e,Ws).call(this,qs(s))}),X(this,Hs,s=>{typeof s.id=="string"&&V(this,_r,s.id);let i=new MessageEvent(s.event||"message",{data:s.data,origin:O(this,Pt)?O(this,Pt).origin:O(this,rt).origin,lastEventId:s.id||""});O(this,Rt)&&(!s.event||s.event==="message")&&O(this,Rt).call(this,i),this.dispatchEvent(i)}),X(this,Js,s=>{V(this,gr,s)}),X(this,Ks,()=>{V(this,Et,void 0),O(this,de)===this.CONNECTING&&Ne(this,$e,Fs).call(this)});try{if(t instanceof URL)V(this,rt,t);else if(typeof t=="string")V(this,rt,new URL(t,f_()));else throw new Error("Invalid URL")}catch{throw d_("An invalid or illegal string was specified")}V(this,Tt,Ln({onEvent:O(this,Hs),onRetry:O(this,Js)})),V(this,de,this.CONNECTING),V(this,gr,3e3),V(this,Fn,(n=r?.fetch)!=null?n:globalThis.fetch),V(this,Un,(o=r?.withCredentials)!=null?o:!1),Ne(this,$e,Fs).call(this)}get readyState(){return O(this,de)}get url(){return O(this,rt).href}get withCredentials(){return O(this,Un)}get onerror(){return O(this,Ot)}set onerror(t){V(this,Ot,t)}get onmessage(){return O(this,Rt)}set onmessage(t){V(this,Rt,t)}get onopen(){return O(this,mr)}set onopen(t){V(this,mr,t)}addEventListener(t,r,n){let o=r;super.addEventListener(t,o,n)}removeEventListener(t,r,n){let o=r;super.removeEventListener(t,o,n)}close(){O(this,Et)&&clearTimeout(O(this,Et)),O(this,de)!==this.CLOSED&&(O(this,We)&&O(this,We).abort(),V(this,de,this.CLOSED),V(this,We,void 0))}};de=new WeakMap,rt=new WeakMap,Pt=new WeakMap,Un=new WeakMap,Fn=new WeakMap,gr=new WeakMap,Et=new WeakMap,_r=new WeakMap,We=new WeakMap,Tt=new WeakMap,Ot=new WeakMap,Rt=new WeakMap,mr=new WeakMap,$e=new WeakSet,Fs=function(){V(this,de,this.CONNECTING),V(this,We,new AbortController),O(this,Fn)(O(this,rt),Ne(this,$e,Dp).call(this)).then(O(this,Vs)).catch(O(this,Bs))},Vs=new WeakMap,Bs=new WeakMap,Dp=function(){var e;let t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...O(this,_r)?{"Last-Event-ID":O(this,_r)}:void 0},cache:"no-store",signal:(e=O(this,We))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Hs=new WeakMap,Js=new WeakMap,hr=function(e,t){var r;O(this,de)!==this.CLOSED&&V(this,de,this.CLOSED);let n=new qn("error",{code:t,message:e});(r=O(this,Ot))==null||r.call(this,n),this.dispatchEvent(n)},Ws=function(e,t){var r;if(O(this,de)===this.CLOSED)return;V(this,de,this.CONNECTING);let n=new qn("error",{code:t,message:e});(r=O(this,Ot))==null||r.call(this,n),this.dispatchEvent(n),V(this,Et,setTimeout(O(this,Ks),O(this,gr)))},Ks=new WeakMap,nt.CONNECTING=0,nt.OPEN=1,nt.CLOSED=2;function f_(){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 Ct(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Vn(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...Ct(t.headers),...Ct(n.headers)}:t.headers};return e(r,o)}:e}var m_=5,h_=[301,302,303,307,308];function g_(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 Up(e,t){let r=h_.includes(e.status)?e.headers.get("location"):null;try{return r?new URL(r,t):void 0}catch{return}}function Bn(e,t,r,n,o=0){let s=Up(n,t),i=n.status===307||n.status===308||(r?.method??"GET").toUpperCase()==="GET";if(!s||o===m_||!i)return;let a=new URL(t);if(!((s.username||s.password)&&(s.username!==a.username||s.password!==a.password)||!g_(a,s)))return Promise.resolve(n.body?.cancel()).then(()=>e(s,{...r,redirect:"manual"})).then(u=>Bn(e,s,r,u,o+1)??u)}var qp=new WeakSet;function It(e){let t=(r,n)=>(e??fetch)(r,n);return qp.add(t),t}function Pe(e=fetch){return qp.has(e)?e:(t,r)=>r?.redirect==="error"||r?.redirect==="manual"?e(t,r):Promise.resolve(e(t,{...r,redirect:"manual"})).then(n=>Bn(e,t,r,n)??n)}function At(e,t){if(e.type==="opaqueredirect")return"Redirect not followed: this runtime does not expose the redirect target";let r=e.url||t,n=Up(e,r);if(n)return n.username=n.password=n.search=n.hash="",n.protocol==="http:"&&new URL(r).protocol==="https:"?(n.protocol="https:",`Redirect to plain http not followed; try ${n.href} instead`):`Redirect to ${n.href} not followed`}var Xs;Xs=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function __(e){return(await Xs).getRandomValues(new Uint8Array(e))}async function y_(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await __(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function x_(e){return await y_(e)}async function w_(e){let t=await(await Xs).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Ys(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await x_(e),r=await w_(t);return{code_verifier:t,code_challenge:r}}var oe=Wl().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:up.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"}),Vp=K({resource:p().url(),authorization_servers:z(oe).optional(),jwks_uri:p().url().optional(),scopes_supported:z(p()).optional(),bearer_methods_supported:z(p()).optional(),resource_signing_alg_values_supported:z(p()).optional(),resource_name:p().optional(),resource_documentation:p().optional(),resource_policy_uri:p().url().optional(),resource_tos_uri:p().url().optional(),tls_client_certificate_bound_access_tokens:M().optional(),authorization_details_types_supported:z(p()).optional(),dpop_signing_alg_values_supported:z(p()).optional(),dpop_bound_access_tokens_required:M().optional()}),Qs=K({issuer:p(),authorization_endpoint:oe,token_endpoint:oe,registration_endpoint:oe.optional(),scopes_supported:z(p()).optional(),response_types_supported:z(p()),response_modes_supported:z(p()).optional(),grant_types_supported:z(p()).optional(),token_endpoint_auth_methods_supported:z(p()).optional(),token_endpoint_auth_signing_alg_values_supported:z(p()).optional(),service_documentation:oe.optional(),revocation_endpoint:oe.optional(),revocation_endpoint_auth_methods_supported:z(p()).optional(),revocation_endpoint_auth_signing_alg_values_supported:z(p()).optional(),introspection_endpoint:p().optional(),introspection_endpoint_auth_methods_supported:z(p()).optional(),introspection_endpoint_auth_signing_alg_values_supported:z(p()).optional(),code_challenge_methods_supported:z(p()).optional(),client_id_metadata_document_supported:M().optional()}),z_=K({issuer:p(),authorization_endpoint:oe,token_endpoint:oe,userinfo_endpoint:oe.optional(),jwks_uri:oe,registration_endpoint:oe.optional(),scopes_supported:z(p()).optional(),response_types_supported:z(p()),response_modes_supported:z(p()).optional(),grant_types_supported:z(p()).optional(),acr_values_supported:z(p()).optional(),subject_types_supported:z(p()),id_token_signing_alg_values_supported:z(p()),id_token_encryption_alg_values_supported:z(p()).optional(),id_token_encryption_enc_values_supported:z(p()).optional(),userinfo_signing_alg_values_supported:z(p()).optional(),userinfo_encryption_alg_values_supported:z(p()).optional(),userinfo_encryption_enc_values_supported:z(p()).optional(),request_object_signing_alg_values_supported:z(p()).optional(),request_object_encryption_alg_values_supported:z(p()).optional(),request_object_encryption_enc_values_supported:z(p()).optional(),token_endpoint_auth_methods_supported:z(p()).optional(),token_endpoint_auth_signing_alg_values_supported:z(p()).optional(),display_values_supported:z(p()).optional(),claim_types_supported:z(p()).optional(),claims_supported:z(p()).optional(),service_documentation:p().optional(),claims_locales_supported:z(p()).optional(),ui_locales_supported:z(p()).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()}),Bp=b({...z_.shape,...Qs.pick({code_challenge_methods_supported:!0}).shape}),Hp=b({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:bn.number().optional(),scope:p().optional(),refresh_token:p().optional(),issuer:p().optional().catch(void 0)}).strip(),Jp=b({error:p(),error_description:p().optional(),error_uri:p().optional()}),Fp=oe.optional().or(v("").transform(()=>{})),b_=b({redirect_uris:z(oe),token_endpoint_auth_method:p().optional(),grant_types:z(p()).optional(),response_types:z(p()).optional(),client_name:p().optional(),client_uri:oe.optional(),logo_uri:Fp,scope:p().optional(),contacts:z(p()).optional(),tos_uri:Fp,policy_uri:p().optional(),jwks_uri:oe.optional(),jwks:Xl().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),v_=b({client_id:p(),client_secret:p().optional(),client_id_issued_at:A().optional(),client_secret_expires_at:A().optional(),issuer:p().optional().catch(void 0)}).strip(),Wp=b_.merge(v_),jk=b({error:p(),error_description:p().optional()}).strip(),Dk=b({token:p(),token_type_hint:p().optional()}).strip();function Kp(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Gp({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}var W=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}},yr=class extends W{};yr.errorCode="invalid_request";var ot=class extends W{};ot.errorCode="invalid_client";var st=class extends W{};st.errorCode="invalid_grant";var it=class extends W{};it.errorCode="unauthorized_client";var xr=class extends W{};xr.errorCode="unsupported_grant_type";var wr=class extends W{};wr.errorCode="invalid_scope";var zr=class extends W{};zr.errorCode="access_denied";var Me=class extends W{};Me.errorCode="server_error";var br=class extends W{};br.errorCode="temporarily_unavailable";var vr=class extends W{};vr.errorCode="unsupported_response_type";var Sr=class extends W{};Sr.errorCode="unsupported_token_type";var kr=class extends W{};kr.errorCode="invalid_token";var $r=class extends W{};$r.errorCode="method_not_allowed";var Pr=class extends W{};Pr.errorCode="too_many_requests";var at=class extends W{};at.errorCode="invalid_client_metadata";var Tr=class extends W{};Tr.errorCode="insufficient_scope";var Rr=class extends W{};Rr.errorCode="invalid_target";var Xp={[yr.errorCode]:yr,[ot.errorCode]:ot,[st.errorCode]:st,[it.errorCode]:it,[xr.errorCode]:xr,[wr.errorCode]:wr,[zr.errorCode]:zr,[Me.errorCode]:Me,[br.errorCode]:br,[vr.errorCode]:vr,[Sr.errorCode]:Sr,[kr.errorCode]:kr,[$r.errorCode]:$r,[Pr.errorCode]:Pr,[at.errorCode]:at,[Tr.errorCode]:Tr,[Rr.errorCode]:Rr};var ie=class extends Error{constructor(t){super(t??"Unauthorized")}};function S_(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var ei="code",ti="S256";function k_(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&S_(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 $_(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":P_(o,s,r);return;case"client_secret_post":T_(o,s,n);return;case"none":R_(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function P_(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}function T_(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function R_(e,t){t.set("client_id",e)}async function Qp(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let n=Jp.parse(JSON.parse(r)),{error:o,error_description:s,error_uri:i}=n,a=Xp[o]||Me;return new a(s||"",i)}catch(n){let o=e instanceof Response?At(e,e.url):void 0,s=`${t?`HTTP ${t}: `:""}${o??`Invalid OAuth error response: ${n}. Raw body: ${r}`}`;return new Me(s)}}function E_(e,t){let[r,n]=[e,t];try{[r,n]=[new URL(e).href,new URL(t).href]}catch{}return r===n||r.endsWith("/")&&r.slice(0,-1)===n||n.endsWith("/")&&n.slice(0,-1)===r}function oi(e,t){if(e)return typeof e.issuer!="string"?e.issuer==null?e:{...e,issuer:void 0}:E_(e.issuer,t)?e:void 0}var O_=Hp.omit({issuer:!0}),C_=Wp.omit({issuer:!0});function ed(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 je(e,t){try{return await ri(e,t)}catch(r){if(r instanceof ot||r instanceof it)return await e.invalidateCredentials?.("all"),await ri(e,t);if(r instanceof st)return await e.invalidateCredentials?.("tokens"),await ri(e,t);throw r}}async function ri(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let i=await e.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await rd(c,{fetchFn:s}),!a)try{a=await td(t,{resourceMetadataUrl:l},s)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let C=await D_(t,{resourceMetadataUrl:l,fetchFn:s});c=C.authorizationServerUrl,u=C.authorizationServerMetadata,a=C.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=String(c),f=await A_(t,e,a),m=f&&a&&!e.validateResourceURL?a.resource:f,h=n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,_=await Promise.resolve(e.clientInformation()),x=oi(_,d),$=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(_&&!x&&!$)throw ed(_,d);let R=x?.issuer==null?x:void 0,U=async()=>{try{R&&await e.saveClientInformation?.({...R,issuer:d})}catch{}};if(!x){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let C=u?.client_id_metadata_document_supported===!0,Y=e.clientMetadataUrl;if(Y&&!I_(Y))throw new at(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${Y}`);if(C&&Y)x={client_id:Y,issuer:d},await e.saveClientInformation?.(x);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");x={...await V_(c,{metadata:u,clientMetadata:e.clientMetadata,scope:h,fetchFn:s}),issuer:d},await e.saveClientInformation(x)}}let ae=!e.redirectUrl;if(r!==void 0||ae){let C=await F_(e,c,{metadata:u,resource:m,authorizationCode:r,fetchFn:s});return await U(),await e.saveTokens({...C,issuer:d}),"AUTHORIZED"}let w=oi(await e.tokens(),d);if(w?.refresh_token&&w.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."),w?.refresh_token)try{let C=await q_(c,{metadata:u,clientInformation:x,refreshToken:w.refresh_token,resource:m,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await U(),await e.saveTokens({...C,issuer:d}),"AUTHORIZED"}catch(C){if(!(!(C instanceof W)||C instanceof Me))throw C}let y=e.state?await e.state():void 0,{authorizationUrl:E,codeVerifier:B}=await L_(c,{metadata:u,clientInformation:x,state:y,redirectUrl:e.redirectUrl,scope:h,resource:m});return await e.saveCodeVerifier(B),await e.redirectToAuthorization(E),"REDIRECT"}function I_(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function A_(e,t,r){let n=Kp(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!Gp({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function Zt(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=ni(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=ni(e,"scope")||void 0,a=ni(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function ni(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function td(e,t,r=fetch){let n=await M_(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||n.status===404)throw await n?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return Vp.parse(await n.json())}async function si(e,t,r=fetch){try{return await Pe(r)(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?si(e,void 0,r):void 0;throw n}}function Z_(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Yp(e,t,r=fetch){return await si(e,{"MCP-Protocol-Version":t},r)}function N_(e,t){return!e||!e.ok&&e.status<500&&t!=="/"}async function M_(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??St,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=Z_(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await Yp(i,s,r);if(!n?.metadataUrl&&N_(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await Yp(c,s,r)}return a}function j_(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function rd(e,{fetchFn:t=fetch,protocolVersion:r=St}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=j_(e);for(let{url:s,type:i}of o){let a=await si(s,n,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"?Qs.parse(await a.json()):Bp.parse(await a.json())}}}async function D_(e,t){let r,n;try{r=await td(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));let o=await rd(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}function nd(e){return typeof e=="string"?e:e.href}async function L_(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(ei))throw new Error(`Incompatible auth server: does not support response type ${ei}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ti))throw new Error(`Incompatible auth server: does not support code challenge method ${ti}`)}else a=new URL("/authorize",e);let c=await Ys(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",ei),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",ti),a.searchParams.set("redirect_uri",String(n)),s&&a.searchParams.set("state",s),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",nd(i)),{authorizationUrl:a,codeVerifier:u}}function U_(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function od(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,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",nd(s)),o)await o(c,r,a,t);else if(n){let l=t?.token_endpoint_auth_methods_supported??[],d=k_(n,l);$_(d,n,c,r)}let u=await Pe(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await Qp(u);return O_.parse(await u.json())}async function q_(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await od(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:i});return{refresh_token:n,...c}}async function F_(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){let i=async()=>{let l=await e.clientInformation(),d=oi(l,String(t));if(l&&!d)throw ed(l,String(t));return d},a=await i(),c=e.clientMetadata.scope,u;if(e.prepareTokenRequest&&(u=await e.prepareTokenRequest(c)),!u){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let l=await e.codeVerifier();u=U_(o,l,e.redirectUrl)}return a??(a=await i()),od(t,{metadata:r,tokenRequestParams:u,clientInformation:a,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}async function V_(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:o}){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 Pe(o??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!i.ok)throw await Qp(i);return C_.parse(await i.json())}var ii=class extends Error{constructor(t,r,n){super(`SSE error: ${r}`),this.code=t,this.event=n}},Hn=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=Vn(r?.fetch,r?.requestInit),this._followRedirects=r?.redirectPolicy==="follow",this._followRedirects&&(this._fetch=It(this._fetch),this._fetchWithInit=It(this._fetchWithInit))}_unfollowedRedirect(t,r){let n=At(t,r);return n&&!this._followRedirects?`${n} (redirectPolicy: 'same-origin')`:n}async _authThenStart(){if(!this._authProvider)throw new ie("No auth provider");let t;try{t=await je(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 ie;return await this._startOrAuth()}async _commonHeaders(){let t={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(t.Authorization=`Bearer ${n.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=Ct(this._requestInit?.headers);return new Headers({...t,...r})}_startOrAuth(){let t=this?._eventSourceInit?.fetch??this._fetch??fetch,r=this._followRedirects?t:Pe(t),n;return new Promise((o,s)=>{this._eventSource=new nt(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(n=this._unfollowedRedirect(u,i),u.status===401&&u.headers.has("www-authenticate")){let{resourceMetadataUrl:l,scope:d}=Zt(u);this._resourceMetadataUrl=l,this._scope=d}return u}}),this._abortController=new AbortController,this._eventSource.onerror=i=>{if(i.code===401&&this._authProvider){this._authThenStart().then(o,s);return}let a=new ii(i.code,n??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}o()}),this._eventSource.onmessage=i=>{let a=i,c;try{c=He.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 ie("No auth provider");if(await je(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ie("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 n={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(t),signal:this._abortController?.signal},o=await Pe(this._fetch??fetch)(this._endpoint,n);if(!o.ok){let s=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){let{resourceMetadataUrl:i,scope:a}=Zt(o);if(this._resourceMetadataUrl=i,this._scope=a,await je(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ie;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${o.status}): ${this._unfollowedRedirect(o,this._endpoint)??s}`)}await o.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(t){this._protocolVersion=t}};var Wd=Or(Hd(),1);import gi from"node:process";import{PassThrough as xy}from"node:stream";var _y=10*1024*1024,Wn=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??_y}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(`
|
|
73
|
+
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),yy(r)}clear(){this._buffer=void 0}};function yy(e){return He.parse(JSON.parse(e))}function Jd(e){return JSON.stringify(e)+`
|
|
74
|
+
`}var wy=gi.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function zy(){let e={};for(let t of wy){let r=gi.env[t];r!==void 0&&(r.startsWith("()")||(e[t]=r))}return e}var Kn=class{constructor(t){this._stderrStream=null,this._serverParams=t,this._readBuffer=new Wn({maxBufferSize:t.maxBufferSize}),(t.stderr==="pipe"||t.stderr==="overlapped")&&(this._stderrStream=new xy)}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,Wd.default)(this._serverParams.command,this._serverParams.args??[],{env:{...zy(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:gi.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",n=>{r(n),this.onerror?.(n)}),this._process.on("spawn",()=>{t()}),this._process.on("close",n=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",n=>{this.onerror?.(n)}),this._process.stdout?.on("data",n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}}),this._process.stdout?.on("error",n=>{this.onerror?.(n)}),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(n=>{t.once("close",()=>{n()})});try{t.stdin?.end()}catch{}if(await Promise.race([r,new Promise(n=>setTimeout(n,2e3).unref())]),t.exitCode===null){try{t.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(n=>setTimeout(n,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 n=Jd(t);this._process.stdin.write(n)?r():this._process.stdin.once("drain",r)})}};var Qd=Or(Yd(),1);function ef(e){if(e)try{return Qd.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}var Gn=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=Ln({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:n,maxBufferSize:o})},transform(i){s.feed(i)}})}};var Ey={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Ke=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Xn=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=Vn(r?.fetch,r?.requestInit),this._followRedirects=r?.redirectPolicy==="follow",this._followRedirects&&(this._fetch=It(this._fetch),this._fetchWithInit=It(this._fetchWithInit)),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??Ey}_unfollowedRedirect(t,r){let n=At(t,r);return n&&!this._followRedirects?`${n} (redirectPolicy: 'same-origin')`:n}async _authThenStart(){if(!this._authProvider)throw new ie("No auth provider");let t;try{t=await je(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 ie;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(t.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=Ct(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);let o=this._fetch??fetch,s={method:"GET",headers:n,signal:this._abortController?.signal},i=await o(this._url,this._followRedirects?s:{...s,redirect:"manual"}),a=this._followRedirects?void 0:Bn(o,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 Ke(i.status,`Failed to open SSE stream: ${this._unfollowedRedirect(i,this._url)??i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),o)}_scheduleReconnection(t,r=0){let n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let o=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)})},o)}_handleSseStream(t,r,n){if(!t)return;let{onresumptiontoken:o,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let l=t.pipeThrough(new TextDecoderStream).pipeThrough(new Gn({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:h}=await l.read();if(h)break;if(m.id&&(i=m.id,a=!0,o?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let _=He.parse(JSON.parse(m.data));Ye(_)&&(c=!0,s!==void 0&&(_.id=s)),this.onmessage?.(_)}catch(_){this.onerror?.(_)}}(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}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 ie("No auth provider");if(await je(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ie("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:n,onresumptiontoken:o}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:sr(t)?t.id:void 0}).catch(m=>this.onerror?.(m));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 Pe(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Ke(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:h,scope:_}=Zt(a);if(this._resourceMetadataUrl=h,this._scope=_,await je(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ie;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:h,scope:_,error:x}=Zt(a);if(x==="insufficient_scope"){let $=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===$)throw new Ke(403,"Server returned 403 after trying upscoping");if(_&&(this._scope=_),h&&(this._resourceMetadataUrl=h),this._lastUpscopingHeader=$??void 0,await je(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new ie;return this.send(t)}}throw new Ke(a.status,`Error POSTing to endpoint: ${this._unfollowedRedirect(a,this._url)??m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),wp(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(t)?t:[t]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,d=a.headers.get("content-type"),f=ef(d);if(l)if(f==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(f==="application/json"){let m=await a.json(),h=Array.isArray(m)?m.map(_=>He.parse(_)):[He.parse(m)];for(let _ of h)this.onmessage?.(_)}else throw await a.body?.cancel(),new Ke(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}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},n=await Pe(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Ke(n.status,`Failed to terminate session: ${this._unfollowedRedirect(n,this._url)??n.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 yi(e){let t=[],r;do{let n=await e(r);t.push(...n.items),r=n.nextCursor}while(r);return t}function Oy(e){let t,r=e.setProtocolVersion?.bind(e);return e.setProtocolVersion=n=>{t=n,r?.(n)},()=>t}function Cy(){let e={};for(let[t,r]of Object.entries(process.env))r!==void 0&&(e[t]=r);return e}function Iy(e){return e.kind==="http"?e.url.href:`"${[e.command,...e.args].join(" ")}"`}async function Ay(e,t){let r=e.kind==="stdio"?[()=>new Kn({command:e.command,args:e.args,env:Cy()})]:[()=>new Xn(e.url,{requestInit:{headers:e.headers}}),()=>new Hn(e.url,{requestInit:{headers:e.headers}})],n;for(let[o,s]of r.entries()){o>0&&xe.info(Cr(` Retrying with the legacy HTTP+SSE transport...
|
|
75
|
+
`));let i=s(),a=Oy(i),c=new Dn({name:"redocly-cli",version:t});try{return await c.connect(i),{mcpClient:c,getProtocolVersion:a}}catch(u){n??=u,await c.close().catch(()=>{})}}throw new we(`Failed to connect to the MCP server at ${Iy(e)}: ${n instanceof Error?n.message:String(n)}`)}async function tf(e,t){let{mcpClient:r,getProtocolVersion:n}=await Ay(e,t);try{let o=r.getServerCapabilities(),s=o?.tools?await yi(async c=>{let u=await r.listTools({cursor:c});return{items:u.tools,nextCursor:u.nextCursor}}):[],i=o?.prompts?await yi(async c=>{let u=await r.listPrompts({cursor:c});return{items:u.prompts,nextCursor:u.nextCursor}}):[],a=o?.resources?await yi(async c=>{let u=await r.listResources({cursor:c});return{items:u.resources,nextCursor:u.nextCursor}}):[];return{protocolVersion:n(),capabilities:o,serverInfo:r.getServerVersion(),instructions:r.getInstructions(),tools:s,prompts:i,resources:a}}finally{await r.close()}}function Ly(e=[]){let t={};for(let r of e){let n=r.indexOf(":");if(n===-1)throw new we(`Invalid header "${r}". Use the "Name: value" format.`);let o=r.slice(0,n).trim(),s=r.slice(n+1).trim();if(!o||!s)throw new we(`Invalid header "${r}". Use the "Name: value" format.`);t[o]=s}return t}function Uy(e){let t=[],r="",n,o=!1;for(let s of e)n?s===n?n=void 0:r+=s:s==='"'||s==="'"?(n=s,o=!0):/\s/.test(s)?(o||r)&&(t.push(r),r="",o=!1):r+=s;if(n)throw new we(`Unclosed ${n} quote in --command.`);return(o||r)&&t.push(r),t}function qy(e){if(e.command){let[r,...n]=Uy(e.command);if(!r)throw new we("The --command option cannot be empty.");return{kind:"stdio",command:r,args:n}}let t;try{t=new URL(e["server-url"]??"")}catch{throw new we(`Invalid MCP server URL: ${e["server-url"]}.`)}return{kind:"http",url:t,headers:Ly(e.header)}}async function H$({argv:e,version:t}){let r=qy(e),n=e.output;xe.info(Cr(`
|
|
76
|
+
Connecting to the MCP server at ${r.kind==="http"?r.url.href:e.command}...
|
|
77
|
+
`));let o=await tf(r,t),s=!Zy(n),i;if(!s){let l;try{l=wi(My(n,"utf-8"))}catch(d){throw new we(`Failed to parse ${n}: ${d instanceof Error?d.message:String(d)}`)}if(!Te(l))throw new we(`Expected ${n} to contain an OpenAPI description object.`);i=l}let a=r.kind==="http"?e["server-url"]:void 0;if(e.check){if(!i)throw new we(`Cannot check ${n} - the file does not exist. Run the command without --check to create it.`);let l=ro(structuredClone(i),o,a),d=vi(i,l);if(d.length===0){xe.info(`
|
|
78
|
+
`+to(`${eo(n)} is up to date with the MCP server.`)+`
|
|
79
|
+
`);return}xe.error(`
|
|
80
|
+
${n} is out of date with the MCP server:
|
|
81
|
+
`);for(let f of d)xe.error(` - ${f}
|
|
82
|
+
`);throw xe.error(`
|
|
83
|
+
Run the command without --check to update it.
|
|
84
|
+
`),new bi}let c=ro(i,o,a),u=n.endsWith(".json")?JSON.stringify(c,null,2)+`
|
|
85
|
+
`:zi(c);Ny(Dy(n),{recursive:!0}),jy(n,u),xe.info(`Recorded ${o.tools.length} tool(s), ${o.prompts.length} prompt(s), and ${o.resources.length} resource(s).
|
|
86
|
+
`),xe.info(`
|
|
87
|
+
`+to(`${s?"Created":"Updated"} ${eo(n)} with the MCP server capabilities in the x-mcp extension.`)+`
|
|
88
|
+
`),s&&xe.warn(`The info section of ${n} is scaffolded - review and complete it.
|
|
89
|
+
`)}export{H$ as handleIntrospectMcp};
|
|
90
|
+
/*! Bundled license information:
|
|
91
|
+
|
|
92
|
+
content-type/index.js:
|
|
93
|
+
(*!
|
|
94
|
+
* content-type
|
|
95
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
96
|
+
* MIT Licensed
|
|
97
|
+
*)
|
|
98
|
+
*/
|