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