@smithery/cli 0.0.25 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ Calls to async() callback can have unexpected results.`),d=!0,function(y,b){y?c(
58
58
  `+Gi.red(">> ")+e),this.firstRender=!1,this.screen.render(t,n)}onSubmit(e){let t=e||this.rl.line;if(this.opt.suggestOnly&&!t&&(t=this.opt.default===null?"":this.opt.default),typeof this.opt.validate=="function"){let n=a=>{a!==!0?this.render(a||"Enter something, tab to autocomplete!"):this.onSubmitAfterValidation(t)},i;if(this.opt.suggestOnly)i=this.opt.validate(t,this.answers);else{let a=this.currentChoices.getChoice(this.selected);i=this.opt.validate(a,this.answers)}yoe(i)?i.then(n):n(i)}else this.onSubmitAfterValidation(t)}onSubmitAfterValidation(e){let t={};if(this.nbChoices<=this.selected&&!this.opt.suggestOnly){this.rl.write(e),this.search(e);return}if(this.opt.suggestOnly)t.value=e||this.rl.line,this.answer=e||this.rl.line,this.answerName=e||this.rl.line,this.shortAnswer=e||this.rl.line,this.rl.line="";else if(this.nbChoices)t=this.currentChoices.getChoice(this.selected),this.answer=t.value,this.answerName=t.name,this.shortAnswer=t.short;else{this.rl.write(e),this.search(e);return}voe(this.opt.filter,(n,i)=>{t.value=i,this.answer=i,this.opt.suggestOnly&&(this.shortAnswer=i),this.status="answered",this.render(),this.screen.done(),this.done(t.value)})(t.value)}search(e){this.selected=0,this.searchedOnce?(this.searching=!0,this.currentChoices=new Iv([]),this.render()):this.searchedOnce=!0,this.lastSearchTerm=e;let t;try{let n=this.opt.source(this.answers,e);t=Promise.resolve(n)}catch(n){t=Promise.reject(n)}return this.lastPromise=t,t.then(n=>{if(t!==this.lastPromise)return;this.currentChoices=new Iv(n);let i=n.filter(o=>boe(o));this.nbChoices=i.length;let a=i.findIndex(o=>o===this.initialValue||o.value===this.initialValue);a>=0&&(this.selected=a),this.searching=!1,this.render()})}ensureSelectedInRange(){let e=Math.min(this.selected,this.nbChoices);this.selected=Math.max(e,0)}onKeypress(e){let t,n=e.key&&e.key.name||void 0;if(n==="tab"&&this.opt.suggestOnly){if(this.currentChoices.getChoice(this.selected)){this.rl.write($C.cursorLeft);let i=this.currentChoices.getChoice(this.selected).value;this.rl.write($C.cursorForward(i.length)),this.rl.line=i,this.render()}}else n==="down"||n==="n"&&e.key.ctrl?(t=this.nbChoices,this.selected=this.selected<t-1?this.selected+1:0,this.ensureSelectedInRange(),this.render(),poe.up(this.rl,2)):n==="up"||n==="p"&&e.key.ctrl?(t=this.nbChoices,this.selected=this.selected>0?this.selected-1:t-1,this.ensureSelectedInRange(),this.render()):(this.render(),this.lastSearchTerm!==this.rl.line&&this.search(this.rl.line))}};function moe(r,e){let t="",n=0;return r.forEach((i,a)=>{if(i.type==="separator"){n++,t+=" "+i+`
59
59
  `;return}if(i.disabled){n++,t+=" - "+i.name,t+=" ("+(typeof i.disabled=="string"?i.disabled:"Disabled")+")",t+=`
60
60
  `;return}let o=a-n===e,s=(o?foe.pointer+" ":" ")+i.name;o&&(s=Gi.cyan(s)),t+=s+`
61
- `}),t.replace(/\n$/,"")}function yoe(r){return typeof r=="object"&&typeof r.then=="function"}KC.exports=kv});var El=Z(H());var yn=Z(require("node:fs")),qo=Z(require("node:os")),xr=Z(require("node:path")),ee=class ee{static getConfigPath(e){let t=xr.default.dirname(ee.configPath);return!e||e.toLowerCase()==="claude"?ee.configPath:xr.default.join(t,"..",e,`${e.toLowerCase()}_config.json`)}static readConfig(e){try{let t=ee.getConfigPath(e);return yn.default.existsSync(t)?{mcpServers:JSON.parse(yn.default.readFileSync(t,"utf8")).mcpServers||{}}:{mcpServers:{}}}catch{return{mcpServers:{}}}}static writeConfig(e,t){try{let n=ee.getConfigPath(t),i=xr.default.dirname(n);if(yn.default.existsSync(i)||yn.default.mkdirSync(i,{recursive:!0}),!e.mcpServers||typeof e.mcpServers!="object")throw new Error("Invalid config structure");yn.default.writeFileSync(n,JSON.stringify(e,null,2))}catch(n){throw n}}static isServerInstalled(e,t){let n=ee.readConfig(t);return ee.normalizeServerId(e)in n.mcpServers}static async installServer(e,t,n){try{let i=ee.normalizeServerId(e),a=ee.readConfig(n);a.mcpServers[i]=t,ee.writeConfig(a,n)}catch(i){throw i}}static async uninstallServer(e,t){let n=ee.normalizeServerId(e),i=ee.readConfig(t);if(!i.mcpServers[n]){console.log(`Server ${n} not found in configuration`);return}delete i.mcpServers[n],ee.writeConfig(i,t)}static getServerConfig(e,t){return ee.readConfig(t).mcpServers[e]||null}static envVarsToArgs(e){return Object.entries(e).flatMap(([t,n])=>[`--${t.toLowerCase().replace(/_/g,"-")}`,n])}static normalizeServerId(e){if(e.startsWith("@")){let t=e.indexOf("/");if(t!==-1)return e.substring(0,t)+"-"+e.substring(t+1)}return e}static denormalizeServerId(e){if(e.startsWith("@")){let t=e.indexOf("-");if(t!==-1)return e.substring(0,t)+"/"+e.substring(t+1)}return e}static getInstalledServerIds(e){let t=ee.readConfig(e);return Object.keys(t.mcpServers||{})}};(()=>{if(process.platform==="win32"){let e=process.env.APPDATA||xr.default.join(qo.default.homedir(),"AppData","Roaming");ee.configPath=xr.default.join(e,"Claude","claude_desktop_config.json")}else if(process.platform==="darwin"){let e=qo.default.homedir();ee.configPath=xr.default.join(e,"Library","Application Support","Claude","claude_desktop_config.json")}else{let e=qo.default.homedir(),t=process.env.XDG_CONFIG_HOME||xr.default.join(e,".config");ee.configPath=xr.default.join(t,"Claude","claude_desktop_config.json")}})();var _e=ee;var Ib=Z(Tb());Ib.default.config();var kb=process.env.REGISTRY_ENDPOINT||"https://registry.smithery.ai";async function Rb(r,e=[]){try{if(e.length===0)return[];let t=e.map(i=>sa(i,r));return(await Promise.all(t)).filter(i=>i!==null)}catch(t){throw new Error(`Failed to resolve servers: ${t instanceof Error?t.message:String(t)}`)}}async function sa(r,e){try{let t=_e.isServerInstalled(r),n=await fetch(`${kb}/servers/${r}`);if(!n.ok)return t?{id:r,name:r,connections:[],isInstalled:!0,client:e}:null;let i=await n.json();return{id:i.id,name:i.name,connections:i.connections,isInstalled:t,client:e}}catch{return null}}async function Bb(r,e,t="stdio"){try{let n={connectionType:t,config:e},a=await(await fetch(`${kb}/servers/${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).text();if(!a)throw new Error("Empty response received from registry");try{return JSON.parse(a).result}catch(o){let s=o instanceof Error?o.message:"Unknown parsing error";throw new Error(`Invalid JSON response from registry: ${s}`)}}catch(n){return console.error("Error getting server configuration:",n),null}}var jC=require("node:child_process"),TC=require("node:util"),IC=Z(xt()),qr=(0,TC.promisify)(jC.exec);async function ioe(r){if(!r)return!1;try{let e=process.platform,t={claude:"Claude"}[r]||r;if(e==="win32"){let{stdout:n}=await qr(`tasklist /FI "IMAGENAME eq ${t}.exe" /NH`);return n.includes(`${t}.exe`)}else if(e==="darwin"){let{stdout:n}=await qr(`pgrep -x "${t}"`);return!!n.trim()}else if(e==="linux"){let{stdout:n}=await qr(`pgrep -f "${t.toLowerCase()}"`);return!!n.trim()}return!1}catch{return!1}}async function aoe(r){let e={claude:"Claude",jan:"Jan"}[r]||r;try{let t=process.platform;t==="win32"?await qr(`taskkill /F /IM "${e}.exe" && start "" "${e}.exe"`):t==="darwin"?await qr(`killall "${e}" && open -a "${e}"`):t==="linux"&&await qr(`pkill -f "${e.toLowerCase()}" && ${e.toLowerCase()}`),await new Promise(n=>setTimeout(n,2e3)),t==="win32"?await qr(`start "" "${e}.exe"`):t==="darwin"?await qr(`open -a "${e}"`):t==="linux"&&await qr(e.toLowerCase()),console.log(`${e} has been restarted.`)}catch(t){console.error(`Failed to restart ${e}:`,t)}}async function qv(r){if(!r||!await ioe(r))return!1;let{shouldRestart:t}=await IC.default.prompt([{type:"confirm",name:"shouldRestart",message:`Would you like to restart the ${r} app to apply changes?`,default:!0}]);return t&&(console.log(`Restarting ${r} app...`),await aoe(r)),t}var kC=require("node:child_process"),RC=require("node:util"),Av=Z(xt()),Pv=Z(H()),rbe=(0,RC.promisify)(kC.exec);async function BC(r){var i;let e=new Map;if((i=r.configSchema)!=null&&i.properties){let a=new Set(r.configSchema.required||[]);Object.entries(r.configSchema.properties).forEach(([o,s])=>{let u=s;e.set(o,{key:o,description:u.description||`Enter value for ${o}`,required:a.has(o),default:u.default,type:u.type})})}let t={};function n(a,o){if(!o)return a;if(a==="")switch(o){case"array":return[];case"number":case"integer":return null;default:return a}if(!a)return a;switch(o){case"boolean":return String(a).toLowerCase()==="true";case"number":return Number(a);case"integer":return parseInt(String(a),10);case"array":return String(a).split(",").map(s=>s.trim()).filter(s=>s!=="");default:return a}}for(let a of e.values()){if(process.env[a.key]&&!a.required){let{reuseExisting:c}=await Av.default.prompt([{type:"confirm",name:"reuseExisting",message:`Found ${a.key} in environment. Use it?`,default:!0}]);if(c){t[a.key]=n(process.env[a.key],a.type);continue}}let o=a.required?Pv.default.red(" (required)"):Pv.default.gray(" (optional)"),s=a.key.toLowerCase().includes("key")?"password":a.type==="boolean"?"confirm":a.type==="array"?"input":a.type==="number"||a.type==="integer"?"number":"input",{value:u}=await Av.default.prompt([{type:s,name:"value",message:`${a.description}${o}${a.type==="array"?" (comma-separated)":""}`,default:a.default,mask:s==="password"?"*":void 0,validate:c=>a.required&&!c?!1:a.type==="number"||a.type==="integer"?!isNaN(Number(c))||"Please enter a valid number":!0}]);(u!==void 0||a.default!==void 0)&&(t[a.key]=n(u??a.default,a.type))}return t}var vt=class{constructor(e=_e){this.configManager=e}validateConnection(e){var n;let t=(n=e.connections)==null?void 0:n[0];if(!t)throw new Error("No connection configuration found");return t}async installServer(e){try{let t=this.validateConnection(e),n=await BC(t),i=await Bb(e.id,n,t.type);if(!i)throw new Error(`Unable to fetch server configuration for server ${e.id}`);await this.configManager.installServer(e.id,i,e.client),await qv(e.client)}catch(t){throw t}}async uninstallServer(e,t){try{await this.configManager.uninstallServer(e,t),console.log(`
61
+ `}),t.replace(/\n$/,"")}function yoe(r){return typeof r=="object"&&typeof r.then=="function"}KC.exports=kv});var El=Z(H());var yn=Z(require("node:fs")),qo=Z(require("node:os")),xr=Z(require("node:path")),ee=class ee{static getConfigPath(e){let t=xr.default.dirname(ee.configPath);return!e||e.toLowerCase()==="claude"?ee.configPath:xr.default.join(t,"..",e,`${e.toLowerCase()}_config.json`)}static readConfig(e){try{let t=ee.getConfigPath(e);return yn.default.existsSync(t)?{mcpServers:JSON.parse(yn.default.readFileSync(t,"utf8")).mcpServers||{}}:{mcpServers:{}}}catch{return{mcpServers:{}}}}static writeConfig(e,t){let n=ee.getConfigPath(t),i=xr.default.dirname(n);if(yn.default.existsSync(i)||yn.default.mkdirSync(i,{recursive:!0}),!e.mcpServers||typeof e.mcpServers!="object")throw new Error("Invalid config structure");yn.default.writeFileSync(n,JSON.stringify(e,null,2))}static isServerInstalled(e,t){let n=ee.readConfig(t);return ee.normalizeServerId(e)in n.mcpServers}static async installServer(e,t,n){let i=ee.normalizeServerId(e),a=ee.readConfig(n);a.mcpServers[i]=t,ee.writeConfig(a,n)}static async uninstallServer(e,t){let n=ee.normalizeServerId(e),i=ee.readConfig(t);if(!i.mcpServers[n]){console.log(`Server ${n} not found in configuration`);return}delete i.mcpServers[n],ee.writeConfig(i,t)}static getServerConfig(e,t){return ee.readConfig(t).mcpServers[e]||null}static envVarsToArgs(e){return Object.entries(e).flatMap(([t,n])=>[`--${t.toLowerCase().replace(/_/g,"-")}`,n])}static normalizeServerId(e){if(e.startsWith("@")){let t=e.indexOf("/");if(t!==-1)return`${e.substring(0,t)}-${e.substring(t+1)}`}return e}static denormalizeServerId(e){if(e.startsWith("@")){let t=e.indexOf("-");if(t!==-1)return`${e.substring(0,t)}/${e.substring(t+1)}`}return e}static getInstalledServerIds(e){let t=ee.readConfig(e);return Object.keys(t.mcpServers||{})}};(()=>{if(process.platform==="win32"){let e=process.env.APPDATA||xr.default.join(qo.default.homedir(),"AppData","Roaming");ee.configPath=xr.default.join(e,"Claude","claude_desktop_config.json")}else if(process.platform==="darwin"){let e=qo.default.homedir();ee.configPath=xr.default.join(e,"Library","Application Support","Claude","claude_desktop_config.json")}else{let e=qo.default.homedir(),t=process.env.XDG_CONFIG_HOME||xr.default.join(e,".config");ee.configPath=xr.default.join(t,"Claude","claude_desktop_config.json")}})();var _e=ee;var Ib=Z(Tb());Ib.default.config();var kb=process.env.REGISTRY_ENDPOINT||"https://registry.smithery.ai";async function Rb(r,e=[]){try{if(e.length===0)return[];let t=e.map(i=>sa(i,r));return(await Promise.all(t)).filter(i=>i!==null)}catch(t){throw new Error(`Failed to resolve servers: ${t instanceof Error?t.message:String(t)}`)}}async function sa(r,e){try{let t=_e.isServerInstalled(r),n=await fetch(`${kb}/servers/${r}`);if(!n.ok)return t?{id:r,name:r,connections:[],isInstalled:!0,client:e}:null;let i=await n.json();return{id:i.id,name:i.name,connections:i.connections,isInstalled:t,client:e}}catch{return null}}async function Bb(r,e,t="stdio"){try{let n={connectionType:t,config:e},a=await(await fetch(`${kb}/servers/${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).text();if(!a)throw new Error("Empty response received from registry");try{return JSON.parse(a).result}catch(o){let s=o instanceof Error?o.message:"Unknown parsing error";throw new Error(`Invalid JSON response from registry: ${s}`)}}catch(n){return console.error("Error getting server configuration:",n),null}}var jC=require("node:child_process"),TC=require("node:util"),IC=Z(xt()),qr=(0,TC.promisify)(jC.exec);async function ioe(r){if(!r)return!1;try{let e=process.platform,t={claude:"Claude"}[r]||r;if(e==="win32"){let{stdout:n}=await qr(`tasklist /FI "IMAGENAME eq ${t}.exe" /NH`);return n.includes(`${t}.exe`)}else if(e==="darwin"){let{stdout:n}=await qr(`pgrep -x "${t}"`);return!!n.trim()}else if(e==="linux"){let{stdout:n}=await qr(`pgrep -f "${t.toLowerCase()}"`);return!!n.trim()}return!1}catch{return!1}}async function aoe(r){let e={claude:"Claude",jan:"Jan"}[r]||r;try{let t=process.platform;t==="win32"?await qr(`taskkill /F /IM "${e}.exe" && start "" "${e}.exe"`):t==="darwin"?await qr(`killall "${e}" && open -a "${e}"`):t==="linux"&&await qr(`pkill -f "${e.toLowerCase()}" && ${e.toLowerCase()}`),await new Promise(n=>setTimeout(n,2e3)),t==="win32"?await qr(`start "" "${e}.exe"`):t==="darwin"?await qr(`open -a "${e}"`):t==="linux"&&await qr(e.toLowerCase()),console.log(`${e} has been restarted.`)}catch(t){console.error(`Failed to restart ${e}:`,t)}}async function qv(r){if(!r||!await ioe(r))return!1;let{shouldRestart:t}=await IC.default.prompt([{type:"confirm",name:"shouldRestart",message:`Would you like to restart the ${r} app to apply changes?`,default:!0}]);return t&&(console.log(`Restarting ${r} app...`),await aoe(r)),t}var kC=require("node:child_process"),RC=require("node:util"),Av=Z(xt()),Pv=Z(H()),rbe=(0,RC.promisify)(kC.exec);async function BC(r){var i;let e=new Map;if((i=r.configSchema)!=null&&i.properties){let a=new Set(r.configSchema.required||[]);Object.entries(r.configSchema.properties).forEach(([o,s])=>{let u=s;e.set(o,{key:o,description:u.description||`Enter value for ${o}`,required:a.has(o),default:u.default,type:u.type})})}let t={};function n(a,o){if(!o)return a;if(a==="")switch(o){case"array":return[];case"number":case"integer":return null;default:return a}if(!a)return a;switch(o){case"boolean":return String(a).toLowerCase()==="true";case"number":return Number(a);case"integer":return Number.parseInt(String(a),10);case"array":return String(a).split(",").map(s=>s.trim()).filter(s=>s!=="");default:return a}}for(let a of e.values()){if(process.env[a.key]&&!a.required){let{reuseExisting:c}=await Av.default.prompt([{type:"confirm",name:"reuseExisting",message:`Found ${a.key} in environment. Use it?`,default:!0}]);if(c){t[a.key]=n(process.env[a.key],a.type);continue}}let o=a.required?Pv.default.red(" (required)"):Pv.default.gray(" (optional)"),s=a.key.toLowerCase().includes("key")?"password":a.type==="boolean"?"confirm":a.type==="array"?"input":a.type==="number"||a.type==="integer"?"number":"input",{value:u}=await Av.default.prompt([{type:s,name:"value",message:`${a.description}${o}${a.type==="array"?" (comma-separated)":""}`,default:a.default,mask:s==="password"?"*":void 0,validate:c=>a.required&&!c?!1:a.type==="number"||a.type==="integer"?!Number.isNaN(Number(c))||"Please enter a valid number":!0}]);(u!==void 0||a.default!==void 0)&&(t[a.key]=n(u??a.default,a.type))}return t}var vt=class{constructor(e=_e){this.configManager=e}validateConnection(e){var n;let t=(n=e.connections)==null?void 0:n[0];if(!t)throw new Error("No connection configuration found");return t}async installServer(e){let t=this.validateConnection(e),n=await BC(t),i=await Bb(e.id,n,t.type);if(!i)throw new Error(`Unable to fetch server configuration for server ${e.id}`);await this.configManager.installServer(e.id,i,e.client),await qv(e.client)}async uninstallServer(e,t){try{await this.configManager.uninstallServer(e,t),console.log(`
62
62
  Uninstalled ${e}`),await qv(t)}catch(n){throw console.error("Failed to uninstall server:",n),n}}};var jv=["claude"];var ooe=new vt;async function MC(r,e){e&&!jv.includes(e)&&(console.error(El.default.red(`Invalid client: ${e}
63
63
  Valid clients are: ${jv.join(", ")}`)),process.exit(1));let t=await sa(r,e);t||(console.error(El.default.red(`Server '${r}' not found in registry`)),process.exit(1)),await ooe.installServer(t),console.log(El.default.green(`\u2713 Successfully installed package '${r}'`))}var Ki=Z(H()),NC=Z(xt());var soe=new vt;async function LC(r){try{r||(console.error(Ki.default.red("Error: Server ID is required")),console.log("Usage: @smithery/cli uninstall <server-id>"),process.exit(1));let{confirmUninstall:e}=await NC.default.prompt([{type:"confirm",name:"confirmUninstall",message:`Are you sure you want to uninstall ${r}?`,default:!1}]);if(!e){console.log("Uninstallation cancelled.");return}await soe.uninstallServer(r),console.log(Ki.default.green(`
64
64
  Successfully uninstalled ${r}`)),console.log(Ki.default.yellow(`
@@ -68,9 +68,9 @@ Note: Please restart Claude for the changes to take effect.`))}catch(e){console.
68
68
  ${De.default.bold.cyan("Server Details:")}`),console.log(De.default.bold("ID: ")+r.id),console.log(De.default.bold("Name: ")+r.name);let t=[{name:r.isInstalled?De.default.yellow("\u{1F504} Reinstall this server"):De.default.yellow("\u{1F4E6} Install this server"),value:"install"},...r.isInstalled?[{name:De.default.yellow("\u{1F5D1}\uFE0F Uninstall this server"),value:"uninstall"}]:[],...e?[{name:De.default.yellow("\u21A9 Back to list"),value:"back"}]:[],{name:De.default.red("\u2716 Exit"),value:"exit"}],{action:n}=await Cl.default.prompt([{type:"list",name:"action",message:"What would you like to do?",choices:t}]);return n}async function ZC(r){let{confirm:e}=await Cl.default.prompt([{type:"confirm",name:"confirm",message:`Are you sure you want to uninstall ${r}?`,default:!1}]);return e}var YC=new vt;async function fo(r,e,t,n=!0){switch(e){case"install":console.log(Fl.default.cyan(`
69
69
  Preparing to install ${r.name}...`)),await YC.installServer(r),r.isInstalled=!0,t.onInstall&&await t.onInstall(r),console.log(Fl.default.green(`
70
70
  Successfully installed ${r.name}`));return;case"uninstall":if(await ZC(r.name)){await YC.uninstallServer(r.id),console.log(Fl.default.green(`Successfully uninstalled ${r.name}`)),r.isInstalled=!1,t.onUninstall&&await t.onUninstall(r);return}else console.log("Uninstallation cancelled.");break;case"back":t.onBack&&await t.onBack();return;case"exit":process.exit(0)}if(n){let i=await Hi(r);await fo(r,i,t)}}Rv.default.registerPrompt("autocomplete",QC.default);var Zi=null;async function Ol(){let r=_e.getInstalledServerIds();if(r.length===0){console.log(JC.default.yellow(`
71
- No MCP servers are currently installed.`));return}let e=r.map(a=>_e.denormalizeServerId(a));(!Zi||!_oe(e,Zi.map(a=>a.id)))&&(Zi=await Rb(void 0,e),Zi.forEach(a=>a.isInstalled=!0)),HC(Zi.length,"installed");let t={type:"list",name:"selectedServer",message:"Search and select a server:",choices:Sl(Zi,!1,!0)},n=await Rv.default.prompt([t]);if(!n.selectedServer||n.selectedServer==="exit")return;let i=await Hi(n.selectedServer);await fo(n.selectedServer,i,{onUninstall:()=>Ol(),onBack:Ol})}function _oe(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}var ho=Z(H());async function XC(r){try{let e=await sa(r);if(!e){console.log(ho.default.yellow(`No server found with ID: ${r}`));return}let t=await Hi(e,!1);await fo(e,t,{})}catch(e){console.error(ho.default.red("Error loading server:")),e instanceof Error&&e.message.includes("fetch")?console.error(ho.default.red("Failed to connect to the registry. Please check your internet connection.")):console.error(ho.default.red(e instanceof Error?e.message:String(e))),process.exit(1)}}var _o=Z(H());var B;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{let a={};for(let o of i)a[o]=o;return a},r.getValidEnumValues=i=>{let a=r.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(let s of a)o[s]=i[s];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(a){return i[a]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},r.find=(i,a)=>{for(let o of i)if(a(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(B||(B={}));var Mv;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Mv||(Mv={}));var C=B.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pr=r=>{switch(typeof r){case"undefined":return C.undefined;case"string":return C.string;case"number":return isNaN(r)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(r)?C.array:r===null?C.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?C.promise:typeof Map<"u"&&r instanceof Map?C.map:typeof Set<"u"&&r instanceof Set?C.set:typeof Date<"u"&&r instanceof Date?C.date:C.object;default:return C.unknown}},_=B.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Eoe=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),we=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},n={_errors:[]},i=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let s=n,u=0;for(;u<o.path.length;){let c=o.path[u];u===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(o))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return i(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,B.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};we.create=r=>new we(r);var Qi=(r,e)=>{let t;switch(r.code){case _.invalid_type:r.received===C.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,B.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${B.joinValues(r.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${B.joinValues(r.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${B.joinValues(r.options)}, received '${r.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:B.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case _.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case _.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,B.assertNever(r)}return{message:t}},tS=Qi;function Doe(r){tS=r}function ql(){return tS}var Al=r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,a=[...t,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)s=c(o,{data:e,defaultError:s}).message;return{...i,path:a,message:s}},woe=[];function D(r,e){let t=ql(),n=Al({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Qi?void 0:Qi].filter(i=>!!i)});r.common.issues.push(n)}var he=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){if(i.status==="aborted")return A;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let i of t){let a=await i.key,o=await i.value;n.push({key:a,value:o})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return A;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}},A=Object.freeze({status:"aborted"}),Ji=r=>({status:"dirty",value:r}),pe=r=>({status:"valid",value:r}),Nv=r=>r.status==="aborted",Lv=r=>r.status==="dirty",Yt=r=>r.status==="valid",vo=r=>typeof Promise<"u"&&r instanceof Promise;function Pl(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function nS(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t}var O;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(O||(O={}));var po,xo,Be=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},eS=(r,e)=>{if(Yt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new we(r.common.issues);return this._error=t,this._error}}};function j(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,s)=>{var u,c;let{message:d}=r;return o.code==="invalid_enum_value"?{message:d??s.defaultError}:typeof s.data>"u"?{message:(u=d??n)!==null&&u!==void 0?u:s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:(c=d??t)!==null&&c!==void 0?c:s.defaultError}},description:i}}var T=class{get description(){return this._def.description}_getType(e){return Pr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new he,ctx:{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(vo(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},a=this._parseSync({data:e,path:i.path,parent:i});return eS(i,a)}"~validate"(e){var t,n;let i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)};if(!this["~standard"].async)try{let a=this._parseSync({data:e,path:[],parent:i});return Yt(a)?{value:a.value}:{issues:i.common.issues}}catch(a){!((n=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(a=>Yt(a)?{value:a.value}:{issues:i.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(vo(i)?i:Promise.resolve(i));return eS(n,a)}refine(e,t){let n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,a)=>{let o=e(i),s=()=>a.addIssue({code:_.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Ce({schema:this,typeName:q.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Re.create(this,this._def)}nullable(){return dr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tr.create(this)}promise(){return yt.create(this,this._def)}or(e){return nn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new Ce({...j(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ln({...j(this._def),innerType:this,defaultValue:t,typeName:q.ZodDefault})}brand(){return new bo({typeName:q.ZodBranded,type:this,...j(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new fn({...j(this._def),innerType:this,catchValue:t,typeName:q.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return mo.create(this,e)}readonly(){return dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Coe=/^c[^\s-]{8,}$/i,Soe=/^[0-9a-z]+$/,Foe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ooe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qoe=/^[a-z0-9_-]{21}$/i,Aoe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Poe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,joe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Toe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Bv,Ioe=/^(?:(?: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])$/,koe=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Roe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Boe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Moe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Noe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,iS="((\\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])))",Loe=new RegExp(`^${iS}$`);function aS(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Uoe(r){return new RegExp(`^${aS(r)}$`)}function oS(r){let e=`${iS}T${aS(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Woe(r,e){return!!((e==="v4"||!e)&&Ioe.test(r)||(e==="v6"||!e)&&Roe.test(r))}function Voe(r,e){if(!Aoe.test(r))return!1;try{let[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function $oe(r,e){return!!((e==="v4"||!e)&&koe.test(r)||(e==="v6"||!e)&&Boe.test(r))}var bt=class r extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_type,expected:C.string,received:a.parsedType}),A}let n=new he,i;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,s=e.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(e,i),o?D(i,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&D(i,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")joe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"email",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Bv||(Bv=new RegExp(Toe,"u")),Bv.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"emoji",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ooe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"uuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")qoe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"nanoid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Coe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"cuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Soe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"cuid2",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Foe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"ulid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),D(i,{validation:"url",code:_.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"regex",code:_.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?oS(a).test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Loe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Uoe(a).test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Poe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"duration",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Woe(e.data,a.version)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"ip",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Voe(e.data,a.alg)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"jwt",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?$oe(e.data,a.version)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"cidr",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Moe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"base64",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Noe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"base64url",code:_.invalid_string,message:a.message}),n.dirty()):B.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:_.invalid_string,...O.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...O.errToObj(e)})}url(e){return this._addCheck({kind:"url",...O.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...O.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...O.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...O.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...O.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...O.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...O.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...O.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...O.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...O.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...O.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...O.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...O.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...O.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...O.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...O.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...O.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...O.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...O.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...O.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...O.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...O.errToObj(t)})}nonempty(e){return this.min(1,O.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};bt.create=r=>{var e;return new bt({checks:[],typeName:q.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...j(r)})};function zoe(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,a=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return a%o/Math.pow(10,i)}var Jt=class r extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==C.number){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_type,expected:C.number,received:a.parsedType}),A}let n,i=new he;for(let a of this._def.checks)a.kind==="int"?B.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),D(n,{code:_.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?zoe(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),D(n,{code:_.not_finite,message:a.message}),i.dirty()):B.assertNever(a);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,O.toString(t))}gt(e,t){return this.setLimit("min",e,!1,O.toString(t))}lte(e,t){return this.setLimit("max",e,!0,O.toString(t))}lt(e,t){return this.setLimit("max",e,!1,O.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:O.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:O.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:O.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&B.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Jt.create=r=>new Jt({checks:[],typeName:q.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...j(r)});var Qt=class r extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==C.bigint)return this._getInvalidInput(e);let n,i=new he;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):B.assertNever(a);return{status:i.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return D(t,{code:_.invalid_type,expected:C.bigint,received:t.parsedType}),A}gte(e,t){return this.setLimit("min",e,!0,O.toString(t))}gt(e,t){return this.setLimit("min",e,!1,O.toString(t))}lte(e,t){return this.setLimit("max",e,!0,O.toString(t))}lt(e,t){return this.setLimit("max",e,!1,O.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:O.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Qt.create=r=>{var e;return new Qt({checks:[],typeName:q.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...j(r)})};var Xt=class extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==C.boolean){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.boolean,received:n.parsedType}),A}return pe(e.data)}};Xt.create=r=>new Xt({typeName:q.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...j(r)});var en=class r extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_type,expected:C.date,received:a.parsedType}),A}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_date}),A}let n=new he,i;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):B.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:O.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:O.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};en.create=r=>new en({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:q.ZodDate,...j(r)});var Xi=class extends T{_parse(e){if(this._getType(e)!==C.symbol){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.symbol,received:n.parsedType}),A}return pe(e.data)}};Xi.create=r=>new Xi({typeName:q.ZodSymbol,...j(r)});var rn=class extends T{_parse(e){if(this._getType(e)!==C.undefined){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.undefined,received:n.parsedType}),A}return pe(e.data)}};rn.create=r=>new rn({typeName:q.ZodUndefined,...j(r)});var tn=class extends T{_parse(e){if(this._getType(e)!==C.null){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.null,received:n.parsedType}),A}return pe(e.data)}};tn.create=r=>new tn({typeName:q.ZodNull,...j(r)});var mt=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return pe(e.data)}};mt.create=r=>new mt({typeName:q.ZodAny,...j(r)});var jr=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pe(e.data)}};jr.create=r=>new jr({typeName:q.ZodUnknown,...j(r)});var ze=class extends T{_parse(e){let t=this._getOrReturnCtx(e);return D(t,{code:_.invalid_type,expected:C.never,received:t.parsedType}),A}};ze.create=r=>new ze({typeName:q.ZodNever,...j(r)});var ea=class extends T{_parse(e){if(this._getType(e)!==C.undefined){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.void,received:n.parsedType}),A}return pe(e.data)}};ea.create=r=>new ea({typeName:q.ZodVoid,...j(r)});var Tr=class r extends T{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==C.array)return D(t,{code:_.invalid_type,expected:C.array,received:t.parsedType}),A;if(i.exactLength!==null){let o=t.data.length>i.exactLength.value,s=t.data.length<i.exactLength.value;(o||s)&&(D(t,{code:o?_.too_big:_.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(D(t,{code:_.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(D(t,{code:_.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,s)=>i.type._parseAsync(new Be(t,o,t.path,s)))).then(o=>he.mergeArray(n,o));let a=[...t.data].map((o,s)=>i.type._parseSync(new Be(t,o,t.path,s)));return he.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:O.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:O.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:O.toString(t)}})}nonempty(e){return this.min(1,e)}};Tr.create=(r,e)=>new Tr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...j(e)});function Yi(r){if(r instanceof ge){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Re.create(Yi(n))}return new ge({...r._def,shape:()=>e})}else return r instanceof Tr?new Tr({...r._def,type:Yi(r.element)}):r instanceof Re?Re.create(Yi(r.unwrap())):r instanceof dr?dr.create(Yi(r.unwrap())):r instanceof fr?fr.create(r.items.map(e=>Yi(e))):r}var ge=class r extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=B.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==C.object){let c=this._getOrReturnCtx(e);return D(c,{code:_.invalid_type,expected:C.object,received:c.parsedType}),A}let{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof ze&&this._def.unknownKeys==="strip"))for(let c in i.data)o.includes(c)||s.push(c);let u=[];for(let c of o){let d=a[c],x=i.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new Be(i,x,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ze){let c=this._def.unknownKeys;if(c==="passthrough")for(let d of s)u.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")s.length>0&&(D(i,{code:_.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let d of s){let x=i.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new Be(i,x,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let d of u){let x=await d.key,v=await d.value;c.push({key:x,value:v,alwaysSet:d.alwaysSet})}return c}).then(c=>he.mergeObjectSync(n,c)):he.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return O.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,a,o,s;let u=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(s=O.errToObj(e).message)!==null&&s!==void 0?s:u}:{message:u}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:q.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return B.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return B.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return Yi(this)}partial(e){let t={};return B.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return B.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Re;)a=a._def.innerType;t[n]=a}}),new r({...this._def,shape:()=>t})}keyof(){return sS(B.objectKeys(this.shape))}};ge.create=(r,e)=>new ge({shape:()=>r,unknownKeys:"strip",catchall:ze.create(),typeName:q.ZodObject,...j(e)});ge.strictCreate=(r,e)=>new ge({shape:()=>r,unknownKeys:"strict",catchall:ze.create(),typeName:q.ZodObject,...j(e)});ge.lazycreate=(r,e)=>new ge({shape:r,unknownKeys:"strip",catchall:ze.create(),typeName:q.ZodObject,...j(e)});var nn=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new we(s.ctx.common.issues));return D(t,{code:_.invalid_union,unionErrors:o}),A}if(t.common.async)return Promise.all(n.map(async a=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let a,o=[];for(let u of n){let c={...t,common:{...t.common,issues:[]},parent:null},d=u._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(u=>new we(u));return D(t,{code:_.invalid_union,unionErrors:s}),A}}get options(){return this._def.options}};nn.create=(r,e)=>new nn({options:r,typeName:q.ZodUnion,...j(e)});var Ar=r=>r instanceof on?Ar(r.schema):r instanceof Ce?Ar(r.innerType()):r instanceof sn?[r.value]:r instanceof un?r.options:r instanceof cn?B.objectValues(r.enum):r instanceof ln?Ar(r._def.innerType):r instanceof rn?[void 0]:r instanceof tn?[null]:r instanceof Re?[void 0,...Ar(r.unwrap())]:r instanceof dr?[null,...Ar(r.unwrap())]:r instanceof bo||r instanceof dn?Ar(r.unwrap()):r instanceof fn?Ar(r._def.innerType):[],jl=class r extends T{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==C.object)return D(t,{code:_.invalid_type,expected:C.object,received:t.parsedType}),A;let n=this.discriminator,i=t.data[n],a=this.optionsMap.get(i);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(D(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),A)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let i=new Map;for(let a of t){let o=Ar(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,a)}}return new r({typeName:q.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...j(n)})}};function Uv(r,e){let t=Pr(r),n=Pr(e);if(r===e)return{valid:!0,data:r};if(t===C.object&&n===C.object){let i=B.objectKeys(e),a=B.objectKeys(r).filter(s=>i.indexOf(s)!==-1),o={...r,...e};for(let s of a){let u=Uv(r[s],e[s]);if(!u.valid)return{valid:!1};o[s]=u.data}return{valid:!0,data:o}}else if(t===C.array&&n===C.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let a=0;a<r.length;a++){let o=r[a],s=e[a],u=Uv(o,s);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===C.date&&n===C.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var an=class extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=(a,o)=>{if(Nv(a)||Nv(o))return A;let s=Uv(a.value,o.value);return s.valid?((Lv(a)||Lv(o))&&t.dirty(),{status:t.value,value:s.data}):(D(n,{code:_.invalid_intersection_types}),A)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};an.create=(r,e,t)=>new an({left:r,right:e,typeName:q.ZodIntersection,...j(t)});var fr=class r extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.array)return D(n,{code:_.invalid_type,expected:C.array,received:n.parsedType}),A;if(n.data.length<this._def.items.length)return D(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),A;!this._def.rest&&n.data.length>this._def.items.length&&(D(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((o,s)=>{let u=this._def.items[s]||this._def.rest;return u?u._parse(new Be(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>he.mergeArray(t,o)):he.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};fr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fr({items:r,typeName:q.ZodTuple,rest:null,...j(e)})};var Tl=class r extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.object)return D(n,{code:_.invalid_type,expected:C.object,received:n.parsedType}),A;let i=[],a=this._def.keyType,o=this._def.valueType;for(let s in n.data)i.push({key:a._parse(new Be(n,s,n.path,s)),value:o._parse(new Be(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?he.mergeObjectAsync(t,i):he.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof T?new r({keyType:e,valueType:t,typeName:q.ZodRecord,...j(n)}):new r({keyType:bt.create(),valueType:e,typeName:q.ZodRecord,...j(t)})}},ra=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.map)return D(n,{code:_.invalid_type,expected:C.map,received:n.parsedType}),A;let i=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([s,u],c)=>({key:i._parse(new Be(n,s,n.path,[c,"key"])),value:a._parse(new Be(n,u,n.path,[c,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let u of o){let c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return A;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let u of o){let c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return A;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}}}};ra.create=(r,e,t)=>new ra({valueType:e,keyType:r,typeName:q.ZodMap,...j(t)});var ta=class r extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.set)return D(n,{code:_.invalid_type,expected:C.set,received:n.parsedType}),A;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(D(n,{code:_.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(D(n,{code:_.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let a=this._def.valueType;function o(u){let c=new Set;for(let d of u){if(d.status==="aborted")return A;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}let s=[...n.data.values()].map((u,c)=>a._parse(new Be(n,u,n.path,c)));return n.common.async?Promise.all(s).then(u=>o(u)):o(s)}min(e,t){return new r({...this._def,minSize:{value:e,message:O.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:O.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ta.create=(r,e)=>new ta({valueType:r,minSize:null,maxSize:null,typeName:q.ZodSet,...j(e)});var Il=class r extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==C.function)return D(t,{code:_.invalid_type,expected:C.function,received:t.parsedType}),A;function n(s,u){return Al({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ql(),Qi].filter(c=>!!c),issueData:{code:_.invalid_arguments,argumentsError:u}})}function i(s,u){return Al({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ql(),Qi].filter(c=>!!c),issueData:{code:_.invalid_return_type,returnTypeError:u}})}let a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof yt){let s=this;return pe(async function(...u){let c=new we([]),d=await s._def.args.parseAsync(u,a).catch(m=>{throw c.addIssue(n(u,m)),c}),x=await Reflect.apply(o,this,d);return await s._def.returns._def.type.parseAsync(x,a).catch(m=>{throw c.addIssue(i(x,m)),c})})}else{let s=this;return pe(function(...u){let c=s._def.args.safeParse(u,a);if(!c.success)throw new we([n(u,c.error)]);let d=Reflect.apply(o,this,c.data),x=s._def.returns.safeParse(d,a);if(!x.success)throw new we([i(d,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:fr.create(e).rest(jr.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||fr.create([]).rest(jr.create()),returns:t||jr.create(),typeName:q.ZodFunction,...j(n)})}},on=class extends T{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};on.create=(r,e)=>new on({getter:r,typeName:q.ZodLazy,...j(e)});var sn=class extends T{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return D(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),A}return{status:"valid",value:e.data}}get value(){return this._def.value}};sn.create=(r,e)=>new sn({value:r,typeName:q.ZodLiteral,...j(e)});function sS(r,e){return new un({values:r,typeName:q.ZodEnum,...j(e)})}var un=class r extends T{constructor(){super(...arguments),po.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return D(t,{expected:B.joinValues(n),received:t.parsedType,code:_.invalid_type}),A}if(Pl(this,po,"f")||nS(this,po,new Set(this._def.values),"f"),!Pl(this,po,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return D(t,{received:t.data,code:_.invalid_enum_value,options:n}),A}return pe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};po=new WeakMap;un.create=sS;var cn=class extends T{constructor(){super(...arguments),xo.set(this,void 0)}_parse(e){let t=B.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==C.string&&n.parsedType!==C.number){let i=B.objectValues(t);return D(n,{expected:B.joinValues(i),received:n.parsedType,code:_.invalid_type}),A}if(Pl(this,xo,"f")||nS(this,xo,new Set(B.getValidEnumValues(this._def.values)),"f"),!Pl(this,xo,"f").has(e.data)){let i=B.objectValues(t);return D(n,{received:n.data,code:_.invalid_enum_value,options:i}),A}return pe(e.data)}get enum(){return this._def.values}};xo=new WeakMap;cn.create=(r,e)=>new cn({values:r,typeName:q.ZodNativeEnum,...j(e)});var yt=class extends T{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==C.promise&&t.common.async===!1)return D(t,{code:_.invalid_type,expected:C.promise,received:t.parsedType}),A;let n=t.parsedType===C.promise?t.data:Promise.resolve(t.data);return pe(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};yt.create=(r,e)=>new yt({type:r,typeName:q.ZodPromise,...j(e)});var Ce=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:o=>{D(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let o=i.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async s=>{if(t.value==="aborted")return A;let u=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return u.status==="aborted"?A:u.status==="dirty"||t.value==="dirty"?Ji(u.value):u});{if(t.value==="aborted")return A;let s=this._def.schema._parseSync({data:o,path:n.path,parent:n});return s.status==="aborted"?A:s.status==="dirty"||t.value==="dirty"?Ji(s.value):s}}if(i.type==="refinement"){let o=s=>{let u=i.refinement(s,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?A:(s.status==="dirty"&&t.dirty(),o(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?A:(s.status==="dirty"&&t.dirty(),o(s.value).then(()=>({status:t.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Yt(o))return o;let s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Yt(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:t.value,value:s})):o);B.assertNever(i)}};Ce.create=(r,e,t)=>new Ce({schema:r,typeName:q.ZodEffects,effect:e,...j(t)});Ce.createWithPreprocess=(r,e,t)=>new Ce({schema:e,effect:{type:"preprocess",transform:r},typeName:q.ZodEffects,...j(t)});var Re=class extends T{_parse(e){return this._getType(e)===C.undefined?pe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Re.create=(r,e)=>new Re({innerType:r,typeName:q.ZodOptional,...j(e)});var dr=class extends T{_parse(e){return this._getType(e)===C.null?pe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};dr.create=(r,e)=>new dr({innerType:r,typeName:q.ZodNullable,...j(e)});var ln=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===C.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ln.create=(r,e)=>new ln({innerType:r,typeName:q.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...j(e)});var fn=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return vo(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new we(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new we(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};fn.create=(r,e)=>new fn({innerType:r,typeName:q.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...j(e)});var na=class extends T{_parse(e){if(this._getType(e)!==C.nan){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.nan,received:n.parsedType}),A}return{status:"valid",value:e.data}}};na.create=r=>new na({typeName:q.ZodNaN,...j(r)});var Koe=Symbol("zod_brand"),bo=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},mo=class r extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?A:a.status==="dirty"?(t.dirty(),Ji(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?A:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:q.ZodPipeline})}},dn=class extends T{_parse(e){let t=this._def.innerType._parse(e),n=i=>(Yt(i)&&(i.value=Object.freeze(i.value)),i);return vo(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};dn.create=(r,e)=>new dn({innerType:r,typeName:q.ZodReadonly,...j(e)});function uS(r,e={},t){return r?mt.create().superRefine((n,i)=>{var a,o;if(!r(n)){let s=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(a=s.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,c=typeof s=="string"?{message:s}:s;i.addIssue({code:"custom",...c,fatal:u})}}):mt.create()}var Goe={object:ge.lazycreate},q;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(q||(q={}));var Hoe=(r,e={message:`Input not instance of ${r.name}`})=>uS(t=>t instanceof r,e),cS=bt.create,lS=Jt.create,Zoe=na.create,Yoe=Qt.create,fS=Xt.create,Joe=en.create,Qoe=Xi.create,Xoe=rn.create,ese=tn.create,rse=mt.create,tse=jr.create,nse=ze.create,ise=ea.create,ase=Tr.create,ose=ge.create,sse=ge.strictCreate,use=nn.create,cse=jl.create,lse=an.create,fse=fr.create,dse=Tl.create,hse=ra.create,pse=ta.create,xse=Il.create,vse=on.create,bse=sn.create,mse=un.create,yse=cn.create,gse=yt.create,rS=Ce.create,_se=Re.create,Ese=dr.create,Dse=Ce.createWithPreprocess,wse=mo.create,Cse=()=>cS().optional(),Sse=()=>lS().optional(),Fse=()=>fS().optional(),Ose={string:r=>bt.create({...r,coerce:!0}),number:r=>Jt.create({...r,coerce:!0}),boolean:r=>Xt.create({...r,coerce:!0}),bigint:r=>Qt.create({...r,coerce:!0}),date:r=>en.create({...r,coerce:!0})},qse=A,h=Object.freeze({__proto__:null,defaultErrorMap:Qi,setErrorMap:Doe,getErrorMap:ql,makeIssue:Al,EMPTY_PATH:woe,addIssueToContext:D,ParseStatus:he,INVALID:A,DIRTY:Ji,OK:pe,isAborted:Nv,isDirty:Lv,isValid:Yt,isAsync:vo,get util(){return B},get objectUtil(){return Mv},ZodParsedType:C,getParsedType:Pr,ZodType:T,datetimeRegex:oS,ZodString:bt,ZodNumber:Jt,ZodBigInt:Qt,ZodBoolean:Xt,ZodDate:en,ZodSymbol:Xi,ZodUndefined:rn,ZodNull:tn,ZodAny:mt,ZodUnknown:jr,ZodNever:ze,ZodVoid:ea,ZodArray:Tr,ZodObject:ge,ZodUnion:nn,ZodDiscriminatedUnion:jl,ZodIntersection:an,ZodTuple:fr,ZodRecord:Tl,ZodMap:ra,ZodSet:ta,ZodFunction:Il,ZodLazy:on,ZodLiteral:sn,ZodEnum:un,ZodNativeEnum:cn,ZodPromise:yt,ZodEffects:Ce,ZodTransformer:Ce,ZodOptional:Re,ZodNullable:dr,ZodDefault:ln,ZodCatch:fn,ZodNaN:na,BRAND:Koe,ZodBranded:bo,ZodPipeline:mo,ZodReadonly:dn,custom:uS,Schema:T,ZodSchema:T,late:Goe,get ZodFirstPartyTypeKind(){return q},coerce:Ose,any:rse,array:ase,bigint:Yoe,boolean:fS,date:Joe,discriminatedUnion:cse,effect:rS,enum:mse,function:xse,instanceof:Hoe,intersection:lse,lazy:vse,literal:bse,map:hse,nan:Zoe,nativeEnum:yse,never:nse,null:ese,nullable:Ese,number:lS,object:ose,oboolean:Fse,onumber:Sse,optional:_se,ostring:Cse,pipeline:wse,preprocess:Dse,promise:gse,record:dse,set:pse,strictObject:sse,string:cS,symbol:Qoe,transformer:rS,tuple:fse,undefined:Xoe,union:use,unknown:tse,void:ise,NEVER:qse,ZodIssueCode:_,quotelessJson:Eoe,ZodError:we});var Wv="2024-11-05",dS=[Wv,"2024-10-07"],kl="2.0",hS=h.union([h.string(),h.number().int()]),pS=h.string(),Ke=h.object({_meta:h.optional(h.object({progressToken:h.optional(hS)}).passthrough())}).passthrough(),Se=h.object({method:h.string(),params:h.optional(Ke)}),yo=h.object({_meta:h.optional(h.object({}).passthrough())}).passthrough(),hr=h.object({method:h.string(),params:h.optional(yo)}),Ge=h.object({_meta:h.optional(h.object({}).passthrough())}).passthrough(),Rl=h.union([h.string(),h.number().int()]),Ase=h.object({jsonrpc:h.literal(kl),id:Rl}).merge(Se).strict(),Pse=h.object({jsonrpc:h.literal(kl)}).merge(hr).strict(),jse=h.object({jsonrpc:h.literal(kl),id:Rl,result:Ge}).strict(),hn;(function(r){r[r.ConnectionClosed=-1]="ConnectionClosed",r[r.RequestTimeout=-2]="RequestTimeout",r[r.ParseError=-32700]="ParseError",r[r.InvalidRequest=-32600]="InvalidRequest",r[r.MethodNotFound=-32601]="MethodNotFound",r[r.InvalidParams=-32602]="InvalidParams",r[r.InternalError=-32603]="InternalError"})(hn||(hn={}));var Tse=h.object({jsonrpc:h.literal(kl),id:Rl,error:h.object({code:h.number().int(),message:h.string(),data:h.optional(h.unknown())})}).strict(),xS=h.union([Ase,Pse,jse,Tse]),pn=Ge.strict(),Bl=hr.extend({method:h.literal("notifications/cancelled"),params:yo.extend({requestId:Rl,reason:h.string().optional()})}),vS=h.object({name:h.string(),version:h.string()}).passthrough(),Ise=h.object({experimental:h.optional(h.object({}).passthrough()),sampling:h.optional(h.object({}).passthrough()),roots:h.optional(h.object({listChanged:h.optional(h.boolean())}).passthrough())}).passthrough(),kse=Se.extend({method:h.literal("initialize"),params:Ke.extend({protocolVersion:h.string(),capabilities:Ise,clientInfo:vS})}),Rse=h.object({experimental:h.optional(h.object({}).passthrough()),logging:h.optional(h.object({}).passthrough()),prompts:h.optional(h.object({listChanged:h.optional(h.boolean())}).passthrough()),resources:h.optional(h.object({subscribe:h.optional(h.boolean()),listChanged:h.optional(h.boolean())}).passthrough()),tools:h.optional(h.object({listChanged:h.optional(h.boolean())}).passthrough())}).passthrough(),Vv=Ge.extend({protocolVersion:h.string(),capabilities:Rse,serverInfo:vS}),Bse=hr.extend({method:h.literal("notifications/initialized")}),Ml=Se.extend({method:h.literal("ping")}),Mse=h.object({progress:h.number(),total:h.optional(h.number())}).passthrough(),Nl=hr.extend({method:h.literal("notifications/progress"),params:yo.merge(Mse).extend({progressToken:hS})}),Ll=Se.extend({params:Ke.extend({cursor:h.optional(pS)}).optional()}),Ul=Ge.extend({nextCursor:h.optional(pS)}),bS=h.object({uri:h.string(),mimeType:h.optional(h.string())}).passthrough(),mS=bS.extend({text:h.string()}),yS=bS.extend({blob:h.string().base64()}),Nse=h.object({uri:h.string(),name:h.string(),description:h.optional(h.string()),mimeType:h.optional(h.string())}).passthrough(),Lse=h.object({uriTemplate:h.string(),name:h.string(),description:h.optional(h.string()),mimeType:h.optional(h.string())}).passthrough(),Use=Ll.extend({method:h.literal("resources/list")}),$v=Ul.extend({resources:h.array(Nse)}),Wse=Ll.extend({method:h.literal("resources/templates/list")}),zv=Ul.extend({resourceTemplates:h.array(Lse)}),Vse=Se.extend({method:h.literal("resources/read"),params:Ke.extend({uri:h.string()})}),Kv=Ge.extend({contents:h.array(h.union([mS,yS]))}),$se=hr.extend({method:h.literal("notifications/resources/list_changed")}),zse=Se.extend({method:h.literal("resources/subscribe"),params:Ke.extend({uri:h.string()})}),Kse=Se.extend({method:h.literal("resources/unsubscribe"),params:Ke.extend({uri:h.string()})}),Gse=hr.extend({method:h.literal("notifications/resources/updated"),params:yo.extend({uri:h.string()})}),Hse=h.object({name:h.string(),description:h.optional(h.string()),required:h.optional(h.boolean())}).passthrough(),Zse=h.object({name:h.string(),description:h.optional(h.string()),arguments:h.optional(h.array(Hse))}).passthrough(),Yse=Ll.extend({method:h.literal("prompts/list")}),Gv=Ul.extend({prompts:h.array(Zse)}),Jse=Se.extend({method:h.literal("prompts/get"),params:Ke.extend({name:h.string(),arguments:h.optional(h.record(h.string()))})}),Wl=h.object({type:h.literal("text"),text:h.string()}).passthrough(),Vl=h.object({type:h.literal("image"),data:h.string().base64(),mimeType:h.string()}).passthrough(),gS=h.object({type:h.literal("resource"),resource:h.union([mS,yS])}).passthrough(),Qse=h.object({role:h.enum(["user","assistant"]),content:h.union([Wl,Vl,gS])}).passthrough(),Hv=Ge.extend({description:h.optional(h.string()),messages:h.array(Qse)}),Xse=hr.extend({method:h.literal("notifications/prompts/list_changed")}),eue=h.object({name:h.string(),description:h.optional(h.string()),inputSchema:h.object({type:h.literal("object"),properties:h.optional(h.object({}).passthrough())}).passthrough()}).passthrough(),rue=Ll.extend({method:h.literal("tools/list")}),Zv=Ul.extend({tools:h.array(eue)}),$l=Ge.extend({content:h.array(h.union([Wl,Vl,gS])),isError:h.boolean().default(!1).optional()}),jbe=$l.or(Ge.extend({toolResult:h.unknown()})),tue=Se.extend({method:h.literal("tools/call"),params:Ke.extend({name:h.string(),arguments:h.optional(h.record(h.unknown()))})}),nue=hr.extend({method:h.literal("notifications/tools/list_changed")}),_S=h.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),iue=Se.extend({method:h.literal("logging/setLevel"),params:Ke.extend({level:_S})}),aue=hr.extend({method:h.literal("notifications/message"),params:yo.extend({level:_S,logger:h.optional(h.string()),data:h.unknown()})}),oue=h.object({name:h.string().optional()}).passthrough(),sue=h.object({hints:h.optional(h.array(oue)),costPriority:h.optional(h.number().min(0).max(1)),speedPriority:h.optional(h.number().min(0).max(1)),intelligencePriority:h.optional(h.number().min(0).max(1))}).passthrough(),uue=h.object({role:h.enum(["user","assistant"]),content:h.union([Wl,Vl])}).passthrough(),cue=Se.extend({method:h.literal("sampling/createMessage"),params:Ke.extend({messages:h.array(uue),systemPrompt:h.optional(h.string()),includeContext:h.optional(h.enum(["none","thisServer","allServers"])),temperature:h.optional(h.number()),maxTokens:h.number().int(),stopSequences:h.optional(h.array(h.string())),metadata:h.optional(h.object({}).passthrough()),modelPreferences:h.optional(sue)})}),lue=Ge.extend({model:h.string(),stopReason:h.optional(h.enum(["endTurn","stopSequence","maxTokens"]).or(h.string())),role:h.enum(["user","assistant"]),content:h.discriminatedUnion("type",[Wl,Vl])}),fue=h.object({type:h.literal("ref/resource"),uri:h.string()}).passthrough(),due=h.object({type:h.literal("ref/prompt"),name:h.string()}).passthrough(),hue=Se.extend({method:h.literal("completion/complete"),params:Ke.extend({ref:h.union([due,fue]),argument:h.object({name:h.string(),value:h.string()}).passthrough()})}),Yv=Ge.extend({completion:h.object({values:h.array(h.string()).max(100),total:h.optional(h.number().int()),hasMore:h.optional(h.boolean())}).passthrough()}),pue=h.object({uri:h.string().startsWith("file://"),name:h.optional(h.string())}).passthrough(),xue=Se.extend({method:h.literal("roots/list")}),vue=Ge.extend({roots:h.array(pue)}),bue=hr.extend({method:h.literal("notifications/roots/list_changed")}),Tbe=h.union([Ml,kse,hue,iue,Jse,Yse,Use,Wse,Vse,zse,Kse,tue,rue]),Ibe=h.union([Bl,Nl,Bse,bue]),kbe=h.union([pn,lue,vue]),Rbe=h.union([Ml,cue,xue]),Bbe=h.union([Bl,Nl,aue,Gse,$se,nue,Xse]),Mbe=h.union([pn,Vv,Yv,Hv,Gv,$v,zv,Kv,$l,Zv]),ia=class extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n}};var mue=6e4,zl=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this.setNotificationHandler(Bl,t=>{let n=this._requestHandlerAbortControllers.get(t.params.requestId);n==null||n.abort(t.params.reason)}),this.setNotificationHandler(Nl,t=>{this._onprogress(t)}),this.setRequestHandler(Ml,t=>({}))}async connect(e){this._transport=e,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=t=>{this._onerror(t)},this._transport.onmessage=t=>{"method"in t?"id"in t?this._onrequest(t):this._onnotification(t):this._onresponse(t)},await this._transport.start()}_onclose(){var e;let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let n=new ia(hn.ConnectionClosed,"Connection closed");for(let i of t.values())i(n)}_onerror(e){var t;(t=this.onerror)===null||t===void 0||t.call(this,e)}_onnotification(e){var t;let n=(t=this._notificationHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e){var t,n;let i=(t=this._requestHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackRequestHandler;if(i===void 0){(n=this._transport)===null||n===void 0||n.send({jsonrpc:"2.0",id:e.id,error:{code:hn.MethodNotFound,message:"Method not found"}}).catch(o=>this._onerror(new Error(`Failed to send an error response: ${o}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a),Promise.resolve().then(()=>i(e,{signal:a.signal})).then(o=>{var s;if(!a.signal.aborted)return(s=this._transport)===null||s===void 0?void 0:s.send({result:o,jsonrpc:"2.0",id:e.id})},o=>{var s,u;if(!a.signal.aborted)return(s=this._transport)===null||s===void 0?void 0:s.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(o.code)?o.code:hn.InternalError,message:(u=o.message)!==null&&u!==void 0?u:"Internal error"}})}).catch(o=>this._onerror(new Error(`Failed to send response: ${o}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progress:t,total:n,progressToken:i}=e.params,a=this._progressHandlers.get(Number(i));if(a===void 0){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}a({progress:t,total:n})}_onresponse(e){let t=e.id,n=this._responseHandlers.get(Number(t));if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(Number(t)),this._progressHandlers.delete(Number(t)),"result"in e)n(e);else{let i=new ia(e.error.code,e.error.message,e.error.data);n(i)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,t,n){return new Promise((i,a)=>{var o,s,u,c;if(!this._transport){a(new Error("Not connected"));return}((o=this._options)===null||o===void 0?void 0:o.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(s=n==null?void 0:n.signal)===null||s===void 0||s.throwIfAborted();let d=this._requestMessageId++,x={...e,jsonrpc:"2.0",id:d};n!=null&&n.onprogress&&(this._progressHandlers.set(d,n.onprogress),x.params={...e.params,_meta:{progressToken:d}});let v;this._responseHandlers.set(d,b=>{var g;if(v!==void 0&&clearTimeout(v),!(!((g=n==null?void 0:n.signal)===null||g===void 0)&&g.aborted)){if(b instanceof Error)return a(b);try{let E=t.parse(b.result);i(E)}catch(E){a(E)}}});let m=b=>{var g;this._responseHandlers.delete(d),this._progressHandlers.delete(d),(g=this._transport)===null||g===void 0||g.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(b)}}).catch(E=>this._onerror(new Error(`Failed to send cancellation: ${E}`))),a(b)};(u=n==null?void 0:n.signal)===null||u===void 0||u.addEventListener("abort",()=>{var b;v!==void 0&&clearTimeout(v),m((b=n==null?void 0:n.signal)===null||b===void 0?void 0:b.reason)});let y=(c=n==null?void 0:n.timeout)!==null&&c!==void 0?c:mue;v=setTimeout(()=>m(new ia(hn.RequestTimeout,"Request timed out",{timeout:y})),y),this._transport.send(x).catch(b=>{v!==void 0&&clearTimeout(v),a(b)})})}async notification(e){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let t={...e,jsonrpc:"2.0"};await this._transport.send(t)}setRequestHandler(e,t){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,a)=>Promise.resolve(t(e.parse(i),a)))}removeRequestHandler(e){this._requestHandlers.delete(e)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(t(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};var Kl=class extends zl{constructor(e,t){super(t),this._clientInfo=e,this._capabilities=t.capabilities}assertCapability(e,t){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e){await super.connect(e);try{let t=await this.request({method:"initialize",params:{protocolVersion:Wv,capabilities:this._capabilities,clientInfo:this._clientInfo}},Vv);if(t===void 0)throw new Error(`Server sent invalid initialize result: ${t}`);if(!dS.includes(t.protocolVersion))throw new Error(`Server's protocol version is not supported: ${t.protocolVersion}`);this._serverCapabilities=t.capabilities,this._serverVersion=t.serverInfo,await this.notification({method:"notifications/initialized"})}catch(t){throw this.close(),t}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}assertCapabilityForMethod(e){var t,n,i,a,o;switch(e){case"logging/setLevel":if(!(!((t=this._serverCapabilities)===null||t===void 0)&&t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((i=this._serverCapabilities)===null||i===void 0)&&i.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((a=this._serverCapabilities)===null||a===void 0)&&a.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((o=this._serverCapabilities)===null||o===void 0)&&o.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var t;switch(e){case"notifications/roots/list_changed":if(!(!((t=this._capabilities.roots)===null||t===void 0)&&t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},pn,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Yv,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},pn,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Hv,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Gv,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},$v,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},zv,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Kv,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},pn,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},pn,t)}async callTool(e,t=$l,n){return this.request({method:"tools/call",params:e},t,n)}async listTools(e,t){return this.request({method:"tools/list",params:e},Zv,t)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var DS=require("node:child_process"),go=Z(require("node:process"),1);var Gl=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
71
+ No MCP servers are currently installed.`));return}let e=r.map(a=>_e.denormalizeServerId(a));(!Zi||!_oe(e,Zi.map(a=>a.id)))&&(Zi=await Rb(void 0,e),Zi.forEach(a=>{a.isInstalled=!0})),HC(Zi.length,"installed");let t={type:"list",name:"selectedServer",message:"Search and select a server:",choices:Sl(Zi,!1,!0)},n=await Rv.default.prompt([t]);if(!n.selectedServer||n.selectedServer==="exit")return;let i=await Hi(n.selectedServer);await fo(n.selectedServer,i,{onUninstall:()=>Ol(),onBack:Ol})}function _oe(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}var ho=Z(H());async function XC(r){try{let e=await sa(r);if(!e){console.log(ho.default.yellow(`No server found with ID: ${r}`));return}let t=await Hi(e,!1);await fo(e,t,{})}catch(e){console.error(ho.default.red("Error loading server:")),e instanceof Error&&e.message.includes("fetch")?console.error(ho.default.red("Failed to connect to the registry. Please check your internet connection.")):console.error(ho.default.red(e instanceof Error?e.message:String(e))),process.exit(1)}}var _o=Z(H());var B;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{let a={};for(let o of i)a[o]=o;return a},r.getValidEnumValues=i=>{let a=r.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(let s of a)o[s]=i[s];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(a){return i[a]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},r.find=(i,a)=>{for(let o of i)if(a(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(B||(B={}));var Mv;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Mv||(Mv={}));var C=B.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pr=r=>{switch(typeof r){case"undefined":return C.undefined;case"string":return C.string;case"number":return isNaN(r)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(r)?C.array:r===null?C.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?C.promise:typeof Map<"u"&&r instanceof Map?C.map:typeof Set<"u"&&r instanceof Set?C.set:typeof Date<"u"&&r instanceof Date?C.date:C.object;default:return C.unknown}},_=B.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Eoe=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),we=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},n={_errors:[]},i=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let s=n,u=0;for(;u<o.path.length;){let c=o.path[u];u===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(o))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return i(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,B.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};we.create=r=>new we(r);var Qi=(r,e)=>{let t;switch(r.code){case _.invalid_type:r.received===C.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,B.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${B.joinValues(r.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${B.joinValues(r.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${B.joinValues(r.options)}, received '${r.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:B.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case _.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case _.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,B.assertNever(r)}return{message:t}},tS=Qi;function Doe(r){tS=r}function ql(){return tS}var Al=r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,a=[...t,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)s=c(o,{data:e,defaultError:s}).message;return{...i,path:a,message:s}},woe=[];function D(r,e){let t=ql(),n=Al({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Qi?void 0:Qi].filter(i=>!!i)});r.common.issues.push(n)}var he=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){if(i.status==="aborted")return A;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let i of t){let a=await i.key,o=await i.value;n.push({key:a,value:o})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return A;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}},A=Object.freeze({status:"aborted"}),Ji=r=>({status:"dirty",value:r}),pe=r=>({status:"valid",value:r}),Nv=r=>r.status==="aborted",Lv=r=>r.status==="dirty",Yt=r=>r.status==="valid",vo=r=>typeof Promise<"u"&&r instanceof Promise;function Pl(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function nS(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t}var O;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(O||(O={}));var po,xo,Be=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},eS=(r,e)=>{if(Yt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new we(r.common.issues);return this._error=t,this._error}}};function j(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,s)=>{var u,c;let{message:d}=r;return o.code==="invalid_enum_value"?{message:d??s.defaultError}:typeof s.data>"u"?{message:(u=d??n)!==null&&u!==void 0?u:s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:(c=d??t)!==null&&c!==void 0?c:s.defaultError}},description:i}}var T=class{get description(){return this._def.description}_getType(e){return Pr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new he,ctx:{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(vo(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},a=this._parseSync({data:e,path:i.path,parent:i});return eS(i,a)}"~validate"(e){var t,n;let i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)};if(!this["~standard"].async)try{let a=this._parseSync({data:e,path:[],parent:i});return Yt(a)?{value:a.value}:{issues:i.common.issues}}catch(a){!((n=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:i}).then(a=>Yt(a)?{value:a.value}:{issues:i.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(vo(i)?i:Promise.resolve(i));return eS(n,a)}refine(e,t){let n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,a)=>{let o=e(i),s=()=>a.addIssue({code:_.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Ce({schema:this,typeName:q.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Re.create(this,this._def)}nullable(){return dr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tr.create(this)}promise(){return yt.create(this,this._def)}or(e){return nn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new Ce({...j(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ln({...j(this._def),innerType:this,defaultValue:t,typeName:q.ZodDefault})}brand(){return new bo({typeName:q.ZodBranded,type:this,...j(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new fn({...j(this._def),innerType:this,catchValue:t,typeName:q.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return mo.create(this,e)}readonly(){return dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Coe=/^c[^\s-]{8,}$/i,Soe=/^[0-9a-z]+$/,Foe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ooe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qoe=/^[a-z0-9_-]{21}$/i,Aoe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Poe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,joe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Toe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Bv,Ioe=/^(?:(?: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])$/,koe=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Roe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Boe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Moe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Noe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,iS="((\\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])))",Loe=new RegExp(`^${iS}$`);function aS(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Uoe(r){return new RegExp(`^${aS(r)}$`)}function oS(r){let e=`${iS}T${aS(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Woe(r,e){return!!((e==="v4"||!e)&&Ioe.test(r)||(e==="v6"||!e)&&Roe.test(r))}function Voe(r,e){if(!Aoe.test(r))return!1;try{let[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function $oe(r,e){return!!((e==="v4"||!e)&&koe.test(r)||(e==="v6"||!e)&&Boe.test(r))}var bt=class r extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_type,expected:C.string,received:a.parsedType}),A}let n=new he,i;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,s=e.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(e,i),o?D(i,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&D(i,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")joe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"email",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Bv||(Bv=new RegExp(Toe,"u")),Bv.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"emoji",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ooe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"uuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")qoe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"nanoid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Coe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"cuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Soe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"cuid2",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Foe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"ulid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),D(i,{validation:"url",code:_.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"regex",code:_.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?oS(a).test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Loe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Uoe(a).test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{code:_.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Poe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"duration",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Woe(e.data,a.version)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"ip",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Voe(e.data,a.alg)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"jwt",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?$oe(e.data,a.version)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"cidr",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Moe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"base64",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Noe.test(e.data)||(i=this._getOrReturnCtx(e,i),D(i,{validation:"base64url",code:_.invalid_string,message:a.message}),n.dirty()):B.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:_.invalid_string,...O.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...O.errToObj(e)})}url(e){return this._addCheck({kind:"url",...O.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...O.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...O.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...O.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...O.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...O.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...O.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...O.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...O.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...O.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...O.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...O.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...O.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...O.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...O.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...O.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...O.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...O.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...O.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...O.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...O.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...O.errToObj(t)})}nonempty(e){return this.min(1,O.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};bt.create=r=>{var e;return new bt({checks:[],typeName:q.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...j(r)})};function zoe(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,a=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return a%o/Math.pow(10,i)}var Jt=class r extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==C.number){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_type,expected:C.number,received:a.parsedType}),A}let n,i=new he;for(let a of this._def.checks)a.kind==="int"?B.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),D(n,{code:_.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?zoe(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),D(n,{code:_.not_finite,message:a.message}),i.dirty()):B.assertNever(a);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,O.toString(t))}gt(e,t){return this.setLimit("min",e,!1,O.toString(t))}lte(e,t){return this.setLimit("max",e,!0,O.toString(t))}lt(e,t){return this.setLimit("max",e,!1,O.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:O.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:O.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:O.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&B.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Jt.create=r=>new Jt({checks:[],typeName:q.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...j(r)});var Qt=class r extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==C.bigint)return this._getInvalidInput(e);let n,i=new he;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),D(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):B.assertNever(a);return{status:i.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return D(t,{code:_.invalid_type,expected:C.bigint,received:t.parsedType}),A}gte(e,t){return this.setLimit("min",e,!0,O.toString(t))}gt(e,t){return this.setLimit("min",e,!1,O.toString(t))}lte(e,t){return this.setLimit("max",e,!0,O.toString(t))}lt(e,t){return this.setLimit("max",e,!1,O.toString(t))}setLimit(e,t,n,i){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:O.toString(i)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Qt.create=r=>{var e;return new Qt({checks:[],typeName:q.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...j(r)})};var Xt=class extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==C.boolean){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.boolean,received:n.parsedType}),A}return pe(e.data)}};Xt.create=r=>new Xt({typeName:q.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...j(r)});var en=class r extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_type,expected:C.date,received:a.parsedType}),A}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return D(a,{code:_.invalid_date}),A}let n=new he,i;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),D(i,{code:_.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):B.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:O.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:O.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};en.create=r=>new en({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:q.ZodDate,...j(r)});var Xi=class extends T{_parse(e){if(this._getType(e)!==C.symbol){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.symbol,received:n.parsedType}),A}return pe(e.data)}};Xi.create=r=>new Xi({typeName:q.ZodSymbol,...j(r)});var rn=class extends T{_parse(e){if(this._getType(e)!==C.undefined){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.undefined,received:n.parsedType}),A}return pe(e.data)}};rn.create=r=>new rn({typeName:q.ZodUndefined,...j(r)});var tn=class extends T{_parse(e){if(this._getType(e)!==C.null){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.null,received:n.parsedType}),A}return pe(e.data)}};tn.create=r=>new tn({typeName:q.ZodNull,...j(r)});var mt=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return pe(e.data)}};mt.create=r=>new mt({typeName:q.ZodAny,...j(r)});var jr=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pe(e.data)}};jr.create=r=>new jr({typeName:q.ZodUnknown,...j(r)});var ze=class extends T{_parse(e){let t=this._getOrReturnCtx(e);return D(t,{code:_.invalid_type,expected:C.never,received:t.parsedType}),A}};ze.create=r=>new ze({typeName:q.ZodNever,...j(r)});var ea=class extends T{_parse(e){if(this._getType(e)!==C.undefined){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.void,received:n.parsedType}),A}return pe(e.data)}};ea.create=r=>new ea({typeName:q.ZodVoid,...j(r)});var Tr=class r extends T{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==C.array)return D(t,{code:_.invalid_type,expected:C.array,received:t.parsedType}),A;if(i.exactLength!==null){let o=t.data.length>i.exactLength.value,s=t.data.length<i.exactLength.value;(o||s)&&(D(t,{code:o?_.too_big:_.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(D(t,{code:_.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(D(t,{code:_.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,s)=>i.type._parseAsync(new Be(t,o,t.path,s)))).then(o=>he.mergeArray(n,o));let a=[...t.data].map((o,s)=>i.type._parseSync(new Be(t,o,t.path,s)));return he.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:O.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:O.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:O.toString(t)}})}nonempty(e){return this.min(1,e)}};Tr.create=(r,e)=>new Tr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...j(e)});function Yi(r){if(r instanceof ge){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Re.create(Yi(n))}return new ge({...r._def,shape:()=>e})}else return r instanceof Tr?new Tr({...r._def,type:Yi(r.element)}):r instanceof Re?Re.create(Yi(r.unwrap())):r instanceof dr?dr.create(Yi(r.unwrap())):r instanceof fr?fr.create(r.items.map(e=>Yi(e))):r}var ge=class r extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=B.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==C.object){let c=this._getOrReturnCtx(e);return D(c,{code:_.invalid_type,expected:C.object,received:c.parsedType}),A}let{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof ze&&this._def.unknownKeys==="strip"))for(let c in i.data)o.includes(c)||s.push(c);let u=[];for(let c of o){let d=a[c],x=i.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new Be(i,x,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ze){let c=this._def.unknownKeys;if(c==="passthrough")for(let d of s)u.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")s.length>0&&(D(i,{code:_.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let d of s){let x=i.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new Be(i,x,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let d of u){let x=await d.key,v=await d.value;c.push({key:x,value:v,alwaysSet:d.alwaysSet})}return c}).then(c=>he.mergeObjectSync(n,c)):he.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return O.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,a,o,s;let u=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(s=O.errToObj(e).message)!==null&&s!==void 0?s:u}:{message:u}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:q.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return B.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return B.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return Yi(this)}partial(e){let t={};return B.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return B.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Re;)a=a._def.innerType;t[n]=a}}),new r({...this._def,shape:()=>t})}keyof(){return sS(B.objectKeys(this.shape))}};ge.create=(r,e)=>new ge({shape:()=>r,unknownKeys:"strip",catchall:ze.create(),typeName:q.ZodObject,...j(e)});ge.strictCreate=(r,e)=>new ge({shape:()=>r,unknownKeys:"strict",catchall:ze.create(),typeName:q.ZodObject,...j(e)});ge.lazycreate=(r,e)=>new ge({shape:r,unknownKeys:"strip",catchall:ze.create(),typeName:q.ZodObject,...j(e)});var nn=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new we(s.ctx.common.issues));return D(t,{code:_.invalid_union,unionErrors:o}),A}if(t.common.async)return Promise.all(n.map(async a=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let a,o=[];for(let u of n){let c={...t,common:{...t.common,issues:[]},parent:null},d=u._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(u=>new we(u));return D(t,{code:_.invalid_union,unionErrors:s}),A}}get options(){return this._def.options}};nn.create=(r,e)=>new nn({options:r,typeName:q.ZodUnion,...j(e)});var Ar=r=>r instanceof on?Ar(r.schema):r instanceof Ce?Ar(r.innerType()):r instanceof sn?[r.value]:r instanceof un?r.options:r instanceof cn?B.objectValues(r.enum):r instanceof ln?Ar(r._def.innerType):r instanceof rn?[void 0]:r instanceof tn?[null]:r instanceof Re?[void 0,...Ar(r.unwrap())]:r instanceof dr?[null,...Ar(r.unwrap())]:r instanceof bo||r instanceof dn?Ar(r.unwrap()):r instanceof fn?Ar(r._def.innerType):[],jl=class r extends T{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==C.object)return D(t,{code:_.invalid_type,expected:C.object,received:t.parsedType}),A;let n=this.discriminator,i=t.data[n],a=this.optionsMap.get(i);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(D(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),A)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let i=new Map;for(let a of t){let o=Ar(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,a)}}return new r({typeName:q.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...j(n)})}};function Uv(r,e){let t=Pr(r),n=Pr(e);if(r===e)return{valid:!0,data:r};if(t===C.object&&n===C.object){let i=B.objectKeys(e),a=B.objectKeys(r).filter(s=>i.indexOf(s)!==-1),o={...r,...e};for(let s of a){let u=Uv(r[s],e[s]);if(!u.valid)return{valid:!1};o[s]=u.data}return{valid:!0,data:o}}else if(t===C.array&&n===C.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let a=0;a<r.length;a++){let o=r[a],s=e[a],u=Uv(o,s);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===C.date&&n===C.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var an=class extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=(a,o)=>{if(Nv(a)||Nv(o))return A;let s=Uv(a.value,o.value);return s.valid?((Lv(a)||Lv(o))&&t.dirty(),{status:t.value,value:s.data}):(D(n,{code:_.invalid_intersection_types}),A)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};an.create=(r,e,t)=>new an({left:r,right:e,typeName:q.ZodIntersection,...j(t)});var fr=class r extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.array)return D(n,{code:_.invalid_type,expected:C.array,received:n.parsedType}),A;if(n.data.length<this._def.items.length)return D(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),A;!this._def.rest&&n.data.length>this._def.items.length&&(D(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((o,s)=>{let u=this._def.items[s]||this._def.rest;return u?u._parse(new Be(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>he.mergeArray(t,o)):he.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};fr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fr({items:r,typeName:q.ZodTuple,rest:null,...j(e)})};var Tl=class r extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.object)return D(n,{code:_.invalid_type,expected:C.object,received:n.parsedType}),A;let i=[],a=this._def.keyType,o=this._def.valueType;for(let s in n.data)i.push({key:a._parse(new Be(n,s,n.path,s)),value:o._parse(new Be(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?he.mergeObjectAsync(t,i):he.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof T?new r({keyType:e,valueType:t,typeName:q.ZodRecord,...j(n)}):new r({keyType:bt.create(),valueType:e,typeName:q.ZodRecord,...j(t)})}},ra=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.map)return D(n,{code:_.invalid_type,expected:C.map,received:n.parsedType}),A;let i=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([s,u],c)=>({key:i._parse(new Be(n,s,n.path,[c,"key"])),value:a._parse(new Be(n,u,n.path,[c,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let u of o){let c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return A;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let u of o){let c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return A;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),s.set(c.value,d.value)}return{status:t.value,value:s}}}};ra.create=(r,e,t)=>new ra({valueType:e,keyType:r,typeName:q.ZodMap,...j(t)});var ta=class r extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.set)return D(n,{code:_.invalid_type,expected:C.set,received:n.parsedType}),A;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(D(n,{code:_.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(D(n,{code:_.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let a=this._def.valueType;function o(u){let c=new Set;for(let d of u){if(d.status==="aborted")return A;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}let s=[...n.data.values()].map((u,c)=>a._parse(new Be(n,u,n.path,c)));return n.common.async?Promise.all(s).then(u=>o(u)):o(s)}min(e,t){return new r({...this._def,minSize:{value:e,message:O.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:O.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ta.create=(r,e)=>new ta({valueType:r,minSize:null,maxSize:null,typeName:q.ZodSet,...j(e)});var Il=class r extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==C.function)return D(t,{code:_.invalid_type,expected:C.function,received:t.parsedType}),A;function n(s,u){return Al({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ql(),Qi].filter(c=>!!c),issueData:{code:_.invalid_arguments,argumentsError:u}})}function i(s,u){return Al({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ql(),Qi].filter(c=>!!c),issueData:{code:_.invalid_return_type,returnTypeError:u}})}let a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof yt){let s=this;return pe(async function(...u){let c=new we([]),d=await s._def.args.parseAsync(u,a).catch(m=>{throw c.addIssue(n(u,m)),c}),x=await Reflect.apply(o,this,d);return await s._def.returns._def.type.parseAsync(x,a).catch(m=>{throw c.addIssue(i(x,m)),c})})}else{let s=this;return pe(function(...u){let c=s._def.args.safeParse(u,a);if(!c.success)throw new we([n(u,c.error)]);let d=Reflect.apply(o,this,c.data),x=s._def.returns.safeParse(d,a);if(!x.success)throw new we([i(d,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:fr.create(e).rest(jr.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||fr.create([]).rest(jr.create()),returns:t||jr.create(),typeName:q.ZodFunction,...j(n)})}},on=class extends T{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};on.create=(r,e)=>new on({getter:r,typeName:q.ZodLazy,...j(e)});var sn=class extends T{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return D(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),A}return{status:"valid",value:e.data}}get value(){return this._def.value}};sn.create=(r,e)=>new sn({value:r,typeName:q.ZodLiteral,...j(e)});function sS(r,e){return new un({values:r,typeName:q.ZodEnum,...j(e)})}var un=class r extends T{constructor(){super(...arguments),po.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return D(t,{expected:B.joinValues(n),received:t.parsedType,code:_.invalid_type}),A}if(Pl(this,po,"f")||nS(this,po,new Set(this._def.values),"f"),!Pl(this,po,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return D(t,{received:t.data,code:_.invalid_enum_value,options:n}),A}return pe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};po=new WeakMap;un.create=sS;var cn=class extends T{constructor(){super(...arguments),xo.set(this,void 0)}_parse(e){let t=B.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==C.string&&n.parsedType!==C.number){let i=B.objectValues(t);return D(n,{expected:B.joinValues(i),received:n.parsedType,code:_.invalid_type}),A}if(Pl(this,xo,"f")||nS(this,xo,new Set(B.getValidEnumValues(this._def.values)),"f"),!Pl(this,xo,"f").has(e.data)){let i=B.objectValues(t);return D(n,{received:n.data,code:_.invalid_enum_value,options:i}),A}return pe(e.data)}get enum(){return this._def.values}};xo=new WeakMap;cn.create=(r,e)=>new cn({values:r,typeName:q.ZodNativeEnum,...j(e)});var yt=class extends T{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==C.promise&&t.common.async===!1)return D(t,{code:_.invalid_type,expected:C.promise,received:t.parsedType}),A;let n=t.parsedType===C.promise?t.data:Promise.resolve(t.data);return pe(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};yt.create=(r,e)=>new yt({type:r,typeName:q.ZodPromise,...j(e)});var Ce=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:o=>{D(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let o=i.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async s=>{if(t.value==="aborted")return A;let u=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return u.status==="aborted"?A:u.status==="dirty"||t.value==="dirty"?Ji(u.value):u});{if(t.value==="aborted")return A;let s=this._def.schema._parseSync({data:o,path:n.path,parent:n});return s.status==="aborted"?A:s.status==="dirty"||t.value==="dirty"?Ji(s.value):s}}if(i.type==="refinement"){let o=s=>{let u=i.refinement(s,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?A:(s.status==="dirty"&&t.dirty(),o(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?A:(s.status==="dirty"&&t.dirty(),o(s.value).then(()=>({status:t.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Yt(o))return o;let s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Yt(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:t.value,value:s})):o);B.assertNever(i)}};Ce.create=(r,e,t)=>new Ce({schema:r,typeName:q.ZodEffects,effect:e,...j(t)});Ce.createWithPreprocess=(r,e,t)=>new Ce({schema:e,effect:{type:"preprocess",transform:r},typeName:q.ZodEffects,...j(t)});var Re=class extends T{_parse(e){return this._getType(e)===C.undefined?pe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Re.create=(r,e)=>new Re({innerType:r,typeName:q.ZodOptional,...j(e)});var dr=class extends T{_parse(e){return this._getType(e)===C.null?pe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};dr.create=(r,e)=>new dr({innerType:r,typeName:q.ZodNullable,...j(e)});var ln=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===C.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ln.create=(r,e)=>new ln({innerType:r,typeName:q.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...j(e)});var fn=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return vo(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new we(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new we(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};fn.create=(r,e)=>new fn({innerType:r,typeName:q.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...j(e)});var na=class extends T{_parse(e){if(this._getType(e)!==C.nan){let n=this._getOrReturnCtx(e);return D(n,{code:_.invalid_type,expected:C.nan,received:n.parsedType}),A}return{status:"valid",value:e.data}}};na.create=r=>new na({typeName:q.ZodNaN,...j(r)});var Koe=Symbol("zod_brand"),bo=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},mo=class r extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?A:a.status==="dirty"?(t.dirty(),Ji(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?A:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:q.ZodPipeline})}},dn=class extends T{_parse(e){let t=this._def.innerType._parse(e),n=i=>(Yt(i)&&(i.value=Object.freeze(i.value)),i);return vo(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};dn.create=(r,e)=>new dn({innerType:r,typeName:q.ZodReadonly,...j(e)});function uS(r,e={},t){return r?mt.create().superRefine((n,i)=>{var a,o;if(!r(n)){let s=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(a=s.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,c=typeof s=="string"?{message:s}:s;i.addIssue({code:"custom",...c,fatal:u})}}):mt.create()}var Goe={object:ge.lazycreate},q;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(q||(q={}));var Hoe=(r,e={message:`Input not instance of ${r.name}`})=>uS(t=>t instanceof r,e),cS=bt.create,lS=Jt.create,Zoe=na.create,Yoe=Qt.create,fS=Xt.create,Joe=en.create,Qoe=Xi.create,Xoe=rn.create,ese=tn.create,rse=mt.create,tse=jr.create,nse=ze.create,ise=ea.create,ase=Tr.create,ose=ge.create,sse=ge.strictCreate,use=nn.create,cse=jl.create,lse=an.create,fse=fr.create,dse=Tl.create,hse=ra.create,pse=ta.create,xse=Il.create,vse=on.create,bse=sn.create,mse=un.create,yse=cn.create,gse=yt.create,rS=Ce.create,_se=Re.create,Ese=dr.create,Dse=Ce.createWithPreprocess,wse=mo.create,Cse=()=>cS().optional(),Sse=()=>lS().optional(),Fse=()=>fS().optional(),Ose={string:r=>bt.create({...r,coerce:!0}),number:r=>Jt.create({...r,coerce:!0}),boolean:r=>Xt.create({...r,coerce:!0}),bigint:r=>Qt.create({...r,coerce:!0}),date:r=>en.create({...r,coerce:!0})},qse=A,h=Object.freeze({__proto__:null,defaultErrorMap:Qi,setErrorMap:Doe,getErrorMap:ql,makeIssue:Al,EMPTY_PATH:woe,addIssueToContext:D,ParseStatus:he,INVALID:A,DIRTY:Ji,OK:pe,isAborted:Nv,isDirty:Lv,isValid:Yt,isAsync:vo,get util(){return B},get objectUtil(){return Mv},ZodParsedType:C,getParsedType:Pr,ZodType:T,datetimeRegex:oS,ZodString:bt,ZodNumber:Jt,ZodBigInt:Qt,ZodBoolean:Xt,ZodDate:en,ZodSymbol:Xi,ZodUndefined:rn,ZodNull:tn,ZodAny:mt,ZodUnknown:jr,ZodNever:ze,ZodVoid:ea,ZodArray:Tr,ZodObject:ge,ZodUnion:nn,ZodDiscriminatedUnion:jl,ZodIntersection:an,ZodTuple:fr,ZodRecord:Tl,ZodMap:ra,ZodSet:ta,ZodFunction:Il,ZodLazy:on,ZodLiteral:sn,ZodEnum:un,ZodNativeEnum:cn,ZodPromise:yt,ZodEffects:Ce,ZodTransformer:Ce,ZodOptional:Re,ZodNullable:dr,ZodDefault:ln,ZodCatch:fn,ZodNaN:na,BRAND:Koe,ZodBranded:bo,ZodPipeline:mo,ZodReadonly:dn,custom:uS,Schema:T,ZodSchema:T,late:Goe,get ZodFirstPartyTypeKind(){return q},coerce:Ose,any:rse,array:ase,bigint:Yoe,boolean:fS,date:Joe,discriminatedUnion:cse,effect:rS,enum:mse,function:xse,instanceof:Hoe,intersection:lse,lazy:vse,literal:bse,map:hse,nan:Zoe,nativeEnum:yse,never:nse,null:ese,nullable:Ese,number:lS,object:ose,oboolean:Fse,onumber:Sse,optional:_se,ostring:Cse,pipeline:wse,preprocess:Dse,promise:gse,record:dse,set:pse,strictObject:sse,string:cS,symbol:Qoe,transformer:rS,tuple:fse,undefined:Xoe,union:use,unknown:tse,void:ise,NEVER:qse,ZodIssueCode:_,quotelessJson:Eoe,ZodError:we});var Wv="2024-11-05",dS=[Wv,"2024-10-07"],kl="2.0",hS=h.union([h.string(),h.number().int()]),pS=h.string(),Ke=h.object({_meta:h.optional(h.object({progressToken:h.optional(hS)}).passthrough())}).passthrough(),Se=h.object({method:h.string(),params:h.optional(Ke)}),yo=h.object({_meta:h.optional(h.object({}).passthrough())}).passthrough(),hr=h.object({method:h.string(),params:h.optional(yo)}),Ge=h.object({_meta:h.optional(h.object({}).passthrough())}).passthrough(),Rl=h.union([h.string(),h.number().int()]),Ase=h.object({jsonrpc:h.literal(kl),id:Rl}).merge(Se).strict(),Pse=h.object({jsonrpc:h.literal(kl)}).merge(hr).strict(),jse=h.object({jsonrpc:h.literal(kl),id:Rl,result:Ge}).strict(),hn;(function(r){r[r.ConnectionClosed=-1]="ConnectionClosed",r[r.RequestTimeout=-2]="RequestTimeout",r[r.ParseError=-32700]="ParseError",r[r.InvalidRequest=-32600]="InvalidRequest",r[r.MethodNotFound=-32601]="MethodNotFound",r[r.InvalidParams=-32602]="InvalidParams",r[r.InternalError=-32603]="InternalError"})(hn||(hn={}));var Tse=h.object({jsonrpc:h.literal(kl),id:Rl,error:h.object({code:h.number().int(),message:h.string(),data:h.optional(h.unknown())})}).strict(),xS=h.union([Ase,Pse,jse,Tse]),pn=Ge.strict(),Bl=hr.extend({method:h.literal("notifications/cancelled"),params:yo.extend({requestId:Rl,reason:h.string().optional()})}),vS=h.object({name:h.string(),version:h.string()}).passthrough(),Ise=h.object({experimental:h.optional(h.object({}).passthrough()),sampling:h.optional(h.object({}).passthrough()),roots:h.optional(h.object({listChanged:h.optional(h.boolean())}).passthrough())}).passthrough(),kse=Se.extend({method:h.literal("initialize"),params:Ke.extend({protocolVersion:h.string(),capabilities:Ise,clientInfo:vS})}),Rse=h.object({experimental:h.optional(h.object({}).passthrough()),logging:h.optional(h.object({}).passthrough()),prompts:h.optional(h.object({listChanged:h.optional(h.boolean())}).passthrough()),resources:h.optional(h.object({subscribe:h.optional(h.boolean()),listChanged:h.optional(h.boolean())}).passthrough()),tools:h.optional(h.object({listChanged:h.optional(h.boolean())}).passthrough())}).passthrough(),Vv=Ge.extend({protocolVersion:h.string(),capabilities:Rse,serverInfo:vS}),Bse=hr.extend({method:h.literal("notifications/initialized")}),Ml=Se.extend({method:h.literal("ping")}),Mse=h.object({progress:h.number(),total:h.optional(h.number())}).passthrough(),Nl=hr.extend({method:h.literal("notifications/progress"),params:yo.merge(Mse).extend({progressToken:hS})}),Ll=Se.extend({params:Ke.extend({cursor:h.optional(pS)}).optional()}),Ul=Ge.extend({nextCursor:h.optional(pS)}),bS=h.object({uri:h.string(),mimeType:h.optional(h.string())}).passthrough(),mS=bS.extend({text:h.string()}),yS=bS.extend({blob:h.string().base64()}),Nse=h.object({uri:h.string(),name:h.string(),description:h.optional(h.string()),mimeType:h.optional(h.string())}).passthrough(),Lse=h.object({uriTemplate:h.string(),name:h.string(),description:h.optional(h.string()),mimeType:h.optional(h.string())}).passthrough(),Use=Ll.extend({method:h.literal("resources/list")}),$v=Ul.extend({resources:h.array(Nse)}),Wse=Ll.extend({method:h.literal("resources/templates/list")}),zv=Ul.extend({resourceTemplates:h.array(Lse)}),Vse=Se.extend({method:h.literal("resources/read"),params:Ke.extend({uri:h.string()})}),Kv=Ge.extend({contents:h.array(h.union([mS,yS]))}),$se=hr.extend({method:h.literal("notifications/resources/list_changed")}),zse=Se.extend({method:h.literal("resources/subscribe"),params:Ke.extend({uri:h.string()})}),Kse=Se.extend({method:h.literal("resources/unsubscribe"),params:Ke.extend({uri:h.string()})}),Gse=hr.extend({method:h.literal("notifications/resources/updated"),params:yo.extend({uri:h.string()})}),Hse=h.object({name:h.string(),description:h.optional(h.string()),required:h.optional(h.boolean())}).passthrough(),Zse=h.object({name:h.string(),description:h.optional(h.string()),arguments:h.optional(h.array(Hse))}).passthrough(),Yse=Ll.extend({method:h.literal("prompts/list")}),Gv=Ul.extend({prompts:h.array(Zse)}),Jse=Se.extend({method:h.literal("prompts/get"),params:Ke.extend({name:h.string(),arguments:h.optional(h.record(h.string()))})}),Wl=h.object({type:h.literal("text"),text:h.string()}).passthrough(),Vl=h.object({type:h.literal("image"),data:h.string().base64(),mimeType:h.string()}).passthrough(),gS=h.object({type:h.literal("resource"),resource:h.union([mS,yS])}).passthrough(),Qse=h.object({role:h.enum(["user","assistant"]),content:h.union([Wl,Vl,gS])}).passthrough(),Hv=Ge.extend({description:h.optional(h.string()),messages:h.array(Qse)}),Xse=hr.extend({method:h.literal("notifications/prompts/list_changed")}),eue=h.object({name:h.string(),description:h.optional(h.string()),inputSchema:h.object({type:h.literal("object"),properties:h.optional(h.object({}).passthrough())}).passthrough()}).passthrough(),rue=Ll.extend({method:h.literal("tools/list")}),Zv=Ul.extend({tools:h.array(eue)}),$l=Ge.extend({content:h.array(h.union([Wl,Vl,gS])),isError:h.boolean().default(!1).optional()}),jbe=$l.or(Ge.extend({toolResult:h.unknown()})),tue=Se.extend({method:h.literal("tools/call"),params:Ke.extend({name:h.string(),arguments:h.optional(h.record(h.unknown()))})}),nue=hr.extend({method:h.literal("notifications/tools/list_changed")}),_S=h.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),iue=Se.extend({method:h.literal("logging/setLevel"),params:Ke.extend({level:_S})}),aue=hr.extend({method:h.literal("notifications/message"),params:yo.extend({level:_S,logger:h.optional(h.string()),data:h.unknown()})}),oue=h.object({name:h.string().optional()}).passthrough(),sue=h.object({hints:h.optional(h.array(oue)),costPriority:h.optional(h.number().min(0).max(1)),speedPriority:h.optional(h.number().min(0).max(1)),intelligencePriority:h.optional(h.number().min(0).max(1))}).passthrough(),uue=h.object({role:h.enum(["user","assistant"]),content:h.union([Wl,Vl])}).passthrough(),cue=Se.extend({method:h.literal("sampling/createMessage"),params:Ke.extend({messages:h.array(uue),systemPrompt:h.optional(h.string()),includeContext:h.optional(h.enum(["none","thisServer","allServers"])),temperature:h.optional(h.number()),maxTokens:h.number().int(),stopSequences:h.optional(h.array(h.string())),metadata:h.optional(h.object({}).passthrough()),modelPreferences:h.optional(sue)})}),lue=Ge.extend({model:h.string(),stopReason:h.optional(h.enum(["endTurn","stopSequence","maxTokens"]).or(h.string())),role:h.enum(["user","assistant"]),content:h.discriminatedUnion("type",[Wl,Vl])}),fue=h.object({type:h.literal("ref/resource"),uri:h.string()}).passthrough(),due=h.object({type:h.literal("ref/prompt"),name:h.string()}).passthrough(),hue=Se.extend({method:h.literal("completion/complete"),params:Ke.extend({ref:h.union([due,fue]),argument:h.object({name:h.string(),value:h.string()}).passthrough()})}),Yv=Ge.extend({completion:h.object({values:h.array(h.string()).max(100),total:h.optional(h.number().int()),hasMore:h.optional(h.boolean())}).passthrough()}),pue=h.object({uri:h.string().startsWith("file://"),name:h.optional(h.string())}).passthrough(),xue=Se.extend({method:h.literal("roots/list")}),vue=Ge.extend({roots:h.array(pue)}),bue=hr.extend({method:h.literal("notifications/roots/list_changed")}),Tbe=h.union([Ml,kse,hue,iue,Jse,Yse,Use,Wse,Vse,zse,Kse,tue,rue]),Ibe=h.union([Bl,Nl,Bse,bue]),kbe=h.union([pn,lue,vue]),Rbe=h.union([Ml,cue,xue]),Bbe=h.union([Bl,Nl,aue,Gse,$se,nue,Xse]),Mbe=h.union([pn,Vv,Yv,Hv,Gv,$v,zv,Kv,$l,Zv]),ia=class extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n}};var mue=6e4,zl=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this.setNotificationHandler(Bl,t=>{let n=this._requestHandlerAbortControllers.get(t.params.requestId);n==null||n.abort(t.params.reason)}),this.setNotificationHandler(Nl,t=>{this._onprogress(t)}),this.setRequestHandler(Ml,t=>({}))}async connect(e){this._transport=e,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=t=>{this._onerror(t)},this._transport.onmessage=t=>{"method"in t?"id"in t?this._onrequest(t):this._onnotification(t):this._onresponse(t)},await this._transport.start()}_onclose(){var e;let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let n=new ia(hn.ConnectionClosed,"Connection closed");for(let i of t.values())i(n)}_onerror(e){var t;(t=this.onerror)===null||t===void 0||t.call(this,e)}_onnotification(e){var t;let n=(t=this._notificationHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e){var t,n;let i=(t=this._requestHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackRequestHandler;if(i===void 0){(n=this._transport)===null||n===void 0||n.send({jsonrpc:"2.0",id:e.id,error:{code:hn.MethodNotFound,message:"Method not found"}}).catch(o=>this._onerror(new Error(`Failed to send an error response: ${o}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a),Promise.resolve().then(()=>i(e,{signal:a.signal})).then(o=>{var s;if(!a.signal.aborted)return(s=this._transport)===null||s===void 0?void 0:s.send({result:o,jsonrpc:"2.0",id:e.id})},o=>{var s,u;if(!a.signal.aborted)return(s=this._transport)===null||s===void 0?void 0:s.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(o.code)?o.code:hn.InternalError,message:(u=o.message)!==null&&u!==void 0?u:"Internal error"}})}).catch(o=>this._onerror(new Error(`Failed to send response: ${o}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progress:t,total:n,progressToken:i}=e.params,a=this._progressHandlers.get(Number(i));if(a===void 0){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}a({progress:t,total:n})}_onresponse(e){let t=e.id,n=this._responseHandlers.get(Number(t));if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(Number(t)),this._progressHandlers.delete(Number(t)),"result"in e)n(e);else{let i=new ia(e.error.code,e.error.message,e.error.data);n(i)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,t,n){return new Promise((i,a)=>{var o,s,u,c;if(!this._transport){a(new Error("Not connected"));return}((o=this._options)===null||o===void 0?void 0:o.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(s=n==null?void 0:n.signal)===null||s===void 0||s.throwIfAborted();let d=this._requestMessageId++,x={...e,jsonrpc:"2.0",id:d};n!=null&&n.onprogress&&(this._progressHandlers.set(d,n.onprogress),x.params={...e.params,_meta:{progressToken:d}});let v;this._responseHandlers.set(d,b=>{var g;if(v!==void 0&&clearTimeout(v),!(!((g=n==null?void 0:n.signal)===null||g===void 0)&&g.aborted)){if(b instanceof Error)return a(b);try{let E=t.parse(b.result);i(E)}catch(E){a(E)}}});let m=b=>{var g;this._responseHandlers.delete(d),this._progressHandlers.delete(d),(g=this._transport)===null||g===void 0||g.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(b)}}).catch(E=>this._onerror(new Error(`Failed to send cancellation: ${E}`))),a(b)};(u=n==null?void 0:n.signal)===null||u===void 0||u.addEventListener("abort",()=>{var b;v!==void 0&&clearTimeout(v),m((b=n==null?void 0:n.signal)===null||b===void 0?void 0:b.reason)});let y=(c=n==null?void 0:n.timeout)!==null&&c!==void 0?c:mue;v=setTimeout(()=>m(new ia(hn.RequestTimeout,"Request timed out",{timeout:y})),y),this._transport.send(x).catch(b=>{v!==void 0&&clearTimeout(v),a(b)})})}async notification(e){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let t={...e,jsonrpc:"2.0"};await this._transport.send(t)}setRequestHandler(e,t){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,a)=>Promise.resolve(t(e.parse(i),a)))}removeRequestHandler(e){this._requestHandlers.delete(e)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(t(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};var Kl=class extends zl{constructor(e,t){super(t),this._clientInfo=e,this._capabilities=t.capabilities}assertCapability(e,t){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e){await super.connect(e);try{let t=await this.request({method:"initialize",params:{protocolVersion:Wv,capabilities:this._capabilities,clientInfo:this._clientInfo}},Vv);if(t===void 0)throw new Error(`Server sent invalid initialize result: ${t}`);if(!dS.includes(t.protocolVersion))throw new Error(`Server's protocol version is not supported: ${t.protocolVersion}`);this._serverCapabilities=t.capabilities,this._serverVersion=t.serverInfo,await this.notification({method:"notifications/initialized"})}catch(t){throw this.close(),t}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}assertCapabilityForMethod(e){var t,n,i,a,o;switch(e){case"logging/setLevel":if(!(!((t=this._serverCapabilities)===null||t===void 0)&&t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((i=this._serverCapabilities)===null||i===void 0)&&i.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((a=this._serverCapabilities)===null||a===void 0)&&a.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((o=this._serverCapabilities)===null||o===void 0)&&o.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var t;switch(e){case"notifications/roots/list_changed":if(!(!((t=this._capabilities.roots)===null||t===void 0)&&t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},pn,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Yv,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},pn,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Hv,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Gv,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},$v,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},zv,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Kv,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},pn,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},pn,t)}async callTool(e,t=$l,n){return this.request({method:"tools/call",params:e},t,n)}async listTools(e,t){return this.request({method:"tools/list",params:e},Zv,t)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var DS=require("node:child_process"),go=Z(require("node:process"),1);var Gl=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
72
72
  `);if(e===-1)return null;let t=this._buffer.toString("utf8",0,e);return this._buffer=this._buffer.subarray(e+1),yue(t)}clear(){this._buffer=void 0}};function yue(r){return xS.parse(JSON.parse(r))}function ES(r){return JSON.stringify(r)+`
73
- `}var gue=go.default.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function _ue(){let r={};for(let e of gue){let t=go.default.env[e];t!==void 0&&(t.startsWith("()")||(r[e]=t))}return r}var Hl=class{constructor(e){this._abortController=new AbortController,this._readBuffer=new Gl,this._serverParams=e}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,t)=>{var n,i,a,o,s,u;this._process=(0,DS.spawn)(this._serverParams.command,(n=this._serverParams.args)!==null&&n!==void 0?n:[],{env:(i=this._serverParams.env)!==null&&i!==void 0?i:_ue(),stdio:["pipe","pipe",(a=this._serverParams.stderr)!==null&&a!==void 0?a:"inherit"],shell:!1,signal:this._abortController.signal,windowsHide:go.default.platform==="win32"&&Eue()}),this._process.on("error",c=>{var d,x;if(c.name==="AbortError"){(d=this.onclose)===null||d===void 0||d.call(this);return}t(c),(x=this.onerror)===null||x===void 0||x.call(this,c)}),this._process.on("spawn",()=>{e()}),this._process.on("close",c=>{var d;this._process=void 0,(d=this.onclose)===null||d===void 0||d.call(this)}),(o=this._process.stdin)===null||o===void 0||o.on("error",c=>{var d;(d=this.onerror)===null||d===void 0||d.call(this,c)}),(s=this._process.stdout)===null||s===void 0||s.on("data",c=>{this._readBuffer.append(c),this.processReadBuffer()}),(u=this._process.stdout)===null||u===void 0||u.on("error",c=>{var d;(d=this.onerror)===null||d===void 0||d.call(this,c)})})}get stderr(){var e,t;return(t=(e=this._process)===null||e===void 0?void 0:e.stderr)!==null&&t!==void 0?t:null}processReadBuffer(){for(var e,t;;)try{let n=this._readBuffer.readMessage();if(n===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,n)}catch(n){(t=this.onerror)===null||t===void 0||t.call(this,n)}}async close(){this._abortController.abort(),this._process=void 0,this._readBuffer.clear()}send(e){return new Promise(t=>{var n;if(!(!((n=this._process)===null||n===void 0)&&n.stdin))throw new Error("Not connected");let i=ES(e);this._process.stdin.write(i)?t():this._process.stdin.once("drain",t)})}};function Eue(){return"type"in go.default}var Zl=Z(xt()),pr=Z(H());async function wS(r,e){if(!e)throw new Error(`No connection configuration found for server ${r}`);let t=new Hl({command:process.platform==="win32"?"npx.cmd":"/usr/local/bin/npx",args:e.args||[],env:{...process.env,...e.env||{}}}),n=new Kl({name:"mcp-cli",version:"1.0.0"},{capabilities:{}});return await n.connect(t),n}async function Due(r){let e=r.getServerCapabilities()||{},t=[],n=[];return e.resources&&n.push(r.listResources().then(({resources:i})=>{i.forEach(a=>t.push({type:"resource",value:a}))})),e.tools&&n.push(r.listTools().then(({tools:i})=>{i.forEach(a=>t.push({type:"tool",value:a}))})),e.prompts&&n.push(r.listPrompts().then(({prompts:i})=>{i.forEach(a=>t.push({type:"prompt",value:a}))})),await Promise.all(n),t}async function wue(r){let e=(i,a=100)=>i?i.length>a?i.slice(0,a)+"...":i:"No description",t=[...r.map(i=>({name:`${pr.default.green(`${i.type}(${i.value.name})`)} - ${pr.default.gray(e(i.value.description||""))}`,value:i,description:i.value.description})),new Zl.default.Separator,{name:pr.default.yellow("\u21A9 Back"),value:"back"},{name:pr.default.red("\u2716 Exit"),value:"exit"}],{selected:n}=await Zl.default.prompt([{type:"list",name:"selected",message:"Pick a primitive",choices:t,pageSize:10}]);return n}async function CS(r){var t,n,i;let e=await Due(r);for(;;){let a=await wue(e);if(a==="back")return null;if(a==="exit")return"exit";let o={type:a.type,value:{name:a.value.name,description:a.value.description,...a.type==="tool"&&{inputSchema:(i=(n=(t=await r.listTools({name:a.value.name}))==null?void 0:t.tools)==null?void 0:n[0])==null?void 0:i.inputSchema},...a.value.uri&&{uri:a.value.uri}}};console.log(`
73
+ `}var gue=go.default.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function _ue(){let r={};for(let e of gue){let t=go.default.env[e];t!==void 0&&(t.startsWith("()")||(r[e]=t))}return r}var Hl=class{constructor(e){this._abortController=new AbortController,this._readBuffer=new Gl,this._serverParams=e}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,t)=>{var n,i,a,o,s,u;this._process=(0,DS.spawn)(this._serverParams.command,(n=this._serverParams.args)!==null&&n!==void 0?n:[],{env:(i=this._serverParams.env)!==null&&i!==void 0?i:_ue(),stdio:["pipe","pipe",(a=this._serverParams.stderr)!==null&&a!==void 0?a:"inherit"],shell:!1,signal:this._abortController.signal,windowsHide:go.default.platform==="win32"&&Eue()}),this._process.on("error",c=>{var d,x;if(c.name==="AbortError"){(d=this.onclose)===null||d===void 0||d.call(this);return}t(c),(x=this.onerror)===null||x===void 0||x.call(this,c)}),this._process.on("spawn",()=>{e()}),this._process.on("close",c=>{var d;this._process=void 0,(d=this.onclose)===null||d===void 0||d.call(this)}),(o=this._process.stdin)===null||o===void 0||o.on("error",c=>{var d;(d=this.onerror)===null||d===void 0||d.call(this,c)}),(s=this._process.stdout)===null||s===void 0||s.on("data",c=>{this._readBuffer.append(c),this.processReadBuffer()}),(u=this._process.stdout)===null||u===void 0||u.on("error",c=>{var d;(d=this.onerror)===null||d===void 0||d.call(this,c)})})}get stderr(){var e,t;return(t=(e=this._process)===null||e===void 0?void 0:e.stderr)!==null&&t!==void 0?t:null}processReadBuffer(){for(var e,t;;)try{let n=this._readBuffer.readMessage();if(n===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,n)}catch(n){(t=this.onerror)===null||t===void 0||t.call(this,n)}}async close(){this._abortController.abort(),this._process=void 0,this._readBuffer.clear()}send(e){return new Promise(t=>{var n;if(!(!((n=this._process)===null||n===void 0)&&n.stdin))throw new Error("Not connected");let i=ES(e);this._process.stdin.write(i)?t():this._process.stdin.once("drain",t)})}};function Eue(){return"type"in go.default}var Zl=Z(xt()),pr=Z(H());async function wS(r,e){if(!e)throw new Error(`No connection configuration found for server ${r}`);let t=new Hl({command:process.platform==="win32"?"npx.cmd":"/usr/local/bin/npx",args:e.args||[],env:{...process.env,...e.env||{}}}),n=new Kl({name:"mcp-cli",version:"1.0.0"},{capabilities:{}});return await n.connect(t),n}async function Due(r){let e=r.getServerCapabilities()||{},t=[],n=[];return e.resources&&n.push(r.listResources().then(({resources:i})=>{i.forEach(a=>t.push({type:"resource",value:a}))})),e.tools&&n.push(r.listTools().then(({tools:i})=>{i.forEach(a=>t.push({type:"tool",value:a}))})),e.prompts&&n.push(r.listPrompts().then(({prompts:i})=>{i.forEach(a=>t.push({type:"prompt",value:a}))})),await Promise.all(n),t}async function wue(r){let e=(i,a=100)=>i?i.length>a?`${i.slice(0,a)}...`:i:"No description",t=[...r.map(i=>({name:`${pr.default.green(`${i.type}(${i.value.name})`)} - ${pr.default.gray(e(i.value.description||""))}`,value:i,description:i.value.description})),new Zl.default.Separator,{name:pr.default.yellow("\u21A9 Back"),value:"back"},{name:pr.default.red("\u2716 Exit"),value:"exit"}],{selected:n}=await Zl.default.prompt([{type:"list",name:"selected",message:"Pick a primitive",choices:t,pageSize:10}]);return n}async function CS(r){var t,n,i;let e=await Due(r);for(;;){let a=await wue(e);if(a==="back")return null;if(a==="exit")return"exit";let o={type:a.type,value:{name:a.value.name,description:a.value.description,...a.type==="tool"&&{inputSchema:(i=(n=(t=await r.listTools({name:a.value.name}))==null?void 0:t.tools)==null?void 0:n[0])==null?void 0:i.inputSchema},...a.value.uri&&{uri:a.value.uri}}};console.log(`
74
74
  `,pr.default.cyan(JSON.stringify(o,null,2).replace(/"(\w+)":/g,u=>pr.default.green(u)).replace(/"([^"]+)"(?=,|\n|\})/g,u=>pr.default.yellow(u))));let{action:s}=await Zl.default.prompt([{type:"list",name:"action",message:"What would you like to do?",choices:[{name:pr.default.yellow("\u21A9 Back to primitives"),value:"back"},{name:pr.default.red("\u2716 Exit"),value:"exit"}]}]);if(s==="exit")return"exit"}}var SS=Z(xt());async function FS(){try{let r=_e.getInstalledServerIds();if(r.length===0){console.log(_o.default.yellow(`
75
75
  No MCP servers are currently installed.`));return}let e=_e.readConfig();for(;;){let t=Sl(r.map(a=>({id:a,name:_e.denormalizeServerId(a),isInstalled:!0,connections:[]})),!1,!0),{selectedId:n}=await SS.default.prompt([{type:"list",name:"selectedId",message:"Select a server to inspect:",choices:t}]);if(n==="exit"&&process.exit(0),!n)return;console.log(_o.default.blue(`
76
76
  Connecting to server...`));let i=e.mcpServers[n.id];if("command"in i){let a=await wS(n.id,i);await CS(a)==="exit"&&process.exit(0)}else throw new Error("Only stdio connections are supported")}}catch(r){console.error(_o.default.red("Error during inspection:")),console.error(_o.default.red(r instanceof Error?r.message:String(r))),process.exit(1)}}var Cue=process.argv[2],Eo=process.argv[3],OS=process.argv.indexOf("--client"),Sue=OS!==-1?process.argv[OS+1]:void 0;async function Fue(){switch(Cue){case"inspect":await FS();break;case"install":Eo||(console.error("Please provide a package name to install"),process.exit(1)),await MC(Eo,Sue);break;case"uninstall":await LC(Eo);break;case"installed":await Ol();break;case"view":Eo||(console.error("Please provide a package ID to get details"),process.exit(1)),await XC(Eo);break;default:console.log("Available commands:"),console.log(" install <package> Install a package"),console.log(" --client <name> Specify the AI client"),console.log(" uninstall [package] Uninstall a package"),console.log(" installed List installed packages"),console.log(" view <package> Get details for a specific package"),console.log(" inspect Inspect installed servers"),process.exit(1)}}Fue();
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Types for entries in the Smithery registry
3
+ */
4
+ import { z } from "zod";
5
+ export const JSONSchemaSchema = z.lazy(() => z.object({
6
+ type: z.string().optional(),
7
+ properties: z.record(JSONSchemaSchema).optional(),
8
+ items: JSONSchemaSchema.optional(),
9
+ required: z.array(z.string()).optional(),
10
+ description: z.string().optional(),
11
+ default: z.unknown().optional(),
12
+ }));
13
+ export const ConnectionDetailsSchema = z.object({
14
+ type: z.enum(["stdio"]),
15
+ configSchema: JSONSchemaSchema.optional(),
16
+ exampleConfig: z.record(z.any()).optional(),
17
+ });
18
+ // stdio connection
19
+ export const StdioConnectionSchema = z.object({
20
+ command: z.string().describe("The executable to run to start the server."),
21
+ args: z
22
+ .array(z.string())
23
+ .optional()
24
+ .describe("Command line arguments to pass to the executable."),
25
+ env: z
26
+ .record(z.string(), z.string())
27
+ .optional()
28
+ .describe("The environment to use when spawning the process."),
29
+ });